answer stringlengths 15 1.25M |
|---|
#ifndef __MSM_ISP_UTIL_H__
#define __MSM_ISP_UTIL_H__
#include "msm_isp.h"
#include <soc/qcom/camera2.h>
/* #define CONFIG_MSM_ISP_DBG 1 */
#ifdef CONFIG_MSM_ISP_DBG
#define ISP_DBG(fmt, args...) printk(fmt, ##args)
#else
#define ISP_DBG(fmt, args...) pr_debug(fmt, ##args)
#endif
#define ALT_VECTOR_IDX(x) {x = 3 - x; }
struct <API key> {
uint32_t active;
uint64_t ab;
uint64_t ib;
};
enum msm_isp_hw_client {
ISP_VFE0,
ISP_VFE1,
ISP_CPP,
MAX_ISP_CLIENT,
};
struct <API key> {
uint32_t bus_client;
uint32_t <API key>;
uint32_t use_count;
struct <API key> client_info[MAX_ISP_CLIENT];
};
uint32_t <API key>(
enum <API key> frame_skip_pattern);
int <API key>(enum msm_isp_hw_client client);
int <API key>(enum msm_isp_hw_client client,
uint64_t ab, uint64_t ib);
void <API key>(enum msm_isp_hw_client client);
int <API key>(struct v4l2_subdev *sd, struct v4l2_fh *fh,
struct <API key> *sub);
int <API key>(struct v4l2_subdev *sd, struct v4l2_fh *fh,
struct <API key> *sub);
int msm_isp_proc_cmd(struct vfe_device *vfe_dev, void *arg);
int msm_isp_send_event(struct vfe_device *vfe_dev,
uint32_t type, struct msm_isp_event_data *event_data);
int <API key>(uint32_t output_format,
uint32_t pixel_per_line);
int <API key>(uint32_t output_format);
enum msm_isp_pack_fmt <API key>(uint32_t output_format);
irqreturn_t msm_isp_process_irq(int irq_num, void *data);
int <API key>(struct vfe_device *vfe_dev, void *arg);
void msm_isp_do_tasklet(unsigned long data);
void <API key>(struct vfe_device *vfe_dev);
void <API key>(struct vfe_device *vfe_dev);
int msm_isp_open_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
int msm_isp_close_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
long msm_isp_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg);
int <API key>(struct vfe_device *vfe_dev,
struct platform_device *pdev, struct msm_cam_clk_info *vfe_clk_info);
#endif /* __MSM_ISP_UTIL_H__ */ |
#include "MainWindow.h"
#include "opengl/kis_opengl.h"
#include <QApplication>
#include <QResizeEvent>
#include <QDeclarativeView>
#include <QDeclarativeContext>
#include <QDeclarativeEngine>
#include <QDir>
#include <QFile>
#include <QMessageBox>
#include <QFileInfo>
#include <QGLWidget>
#include <QTimer>
#include <kurl.h>
#include <kstandarddirs.h>
#include <kdialog.h>
#include <kdebug.h>
#include "filter/kis_filter.h"
#include "filter/kis_filter_registry.h"
#include "kis_paintop.h"
#include "<API key>.h"
#include <KoZoomController.h>
#include <KoIcon.h>
#include "KisViewManager.h"
#include <<API key>.h>
#include "kis_config.h"
#include <KisDocument.h>
#include "<API key>.h"
#include "RecentFileManager.h"
#include "DocumentManager.h"
#include "QmlGlobalEngine.h"
#include "Settings.h"
class MainWindow::Private
{
public:
Private(MainWindow* qq)
: q(qq)
, allowClose(true)
, viewManager(0)
{
centerer = new QTimer(q);
centerer->setInterval(10);
centerer->setSingleShot(true);
connect(centerer, SIGNAL(timeout()), q, SLOT(<API key>()));
}
MainWindow* q;
bool allowClose;
KisViewManager* viewManager;
QString currentSketchPage;
QTimer *centerer;
};
MainWindow::MainWindow(QStringList fileNames, QWidget* parent, Qt::WindowFlags flags)
: QMainWindow(parent, flags ), d( new Private(this))
{
qApp->setActiveWindow(this);
setWindowTitle(i18n("Krita Sketch"));
setWindowIcon(koIcon("kritasketch"));
// Load filters and other plugins in the gui thread
Q_UNUSED(KisFilterRegistry::instance());
Q_UNUSED(KisPaintOpRegistry::instance());
KisConfig cfg;
cfg.setNewCursorStyle(<API key>);
cfg.setNewOutlineStyle(OUTLINE_NONE);
cfg.setUseOpenGL(true);
foreach(QString fileName, fileNames) {
DocumentManager::instance()->recentFileManager()->addRecent(fileName);
}
connect(DocumentManager::instance(), SIGNAL(documentChanged()), SLOT(resetWindowTitle()));
connect(DocumentManager::instance(), SIGNAL(documentSaved()), SLOT(resetWindowTitle()));
QDeclarativeView* view = new <API key>();
QmlGlobalEngine::instance()->setEngine(view->engine());
view->engine()->rootContext()->setContextProperty("mainWindow", this);
#ifdef Q_OS_WIN
QDir appdir(qApp->applicationDirPath());
// Corrects for mismatched case errors in path (qtdeclarative fails to load)
wchar_t buffer[1024];
QString absolute = appdir.absolutePath();
DWORD rv = ::GetShortPathName((wchar_t*)absolute.utf16(), buffer, 1024);
rv = ::GetLongPathName(buffer, buffer, 1024);
QString correctedPath((QChar *)buffer);
appdir.setPath(correctedPath);
// for now, the app in bin/ and we still use the env.bat script
appdir.cdUp();
view->engine()->addImportPath(appdir.canonicalPath() + "/lib/calligra/imports");
view->engine()->addImportPath(appdir.canonicalPath() + "/lib64/calligra/imports");
QString mainqml = appdir.canonicalPath() + "/share/apps/kritasketch/kritasketch.qml";
#else
view->engine()->addImportPath(KGlobal::dirs()->findDirs("lib", "calligra/imports").value(0));
QString mainqml = KGlobal::dirs()->findResource("data", "kritasketch/kritasketch.qml");
#endif
Q_ASSERT(QFile::exists(mainqml));
if (!QFile::exists(mainqml)) {
QMessageBox::warning(0, i18nc("@title:window", "No QML found"), mainqml + " doesn't exist.");
}
QFileInfo fi(mainqml);
view->setSource(QUrl::fromLocalFile(fi.canonicalFilePath()));
view->setResizeMode( QDeclarativeView::<API key> );
if (view->errors().count() > 0) {
foreach(const QDeclarativeError &error, view->errors()) {
kDebug() << error.toString();
}
}
setCentralWidget(view);
}
void MainWindow::resetWindowTitle()
{
KUrl url(DocumentManager::instance()->settingsManager()->currentFile());
QString fileName = url.fileName();
if(url.protocol() == "temp")
fileName = i18n("Untitled");
KDialog::CaptionFlags flags = KDialog::HIGCompliantCaption;
KisDocument* document = DocumentManager::instance()->document();
if (document && document->isModified() ) {
flags |= KDialog::ModifiedCaption;
}
setWindowTitle( KDialog::makeStandardCaption(fileName, this, flags) );
}
bool MainWindow::allowClose() const
{
return d->allowClose;
}
void MainWindow::setAllowClose(bool allow)
{
d->allowClose = allow;
}
QString MainWindow::currentSketchPage() const
{
return d->currentSketchPage;
}
void MainWindow::<API key>(QString newPage)
{
d->currentSketchPage = newPage;
emit <API key>();
}
void MainWindow::<API key>()
{
if (d->viewManager) {
qApp->processEvents();
d->viewManager->zoomController()->setZoom(KoZoomMode::ZOOM_PAGE, 1.0);
qApp->processEvents();
QPoint center = d->viewManager->canvas()->rect().center();
static_cast<<API key>*>(d->viewManager->canvasBase()->canvasController())->zoomRelativeToPoint(center, 0.9);
qApp->processEvents();
}
}
QObject* MainWindow::sketchKisView() const
{
return d->viewManager;
}
void MainWindow::setSketchKisView(QObject* newView)
{
if (d->viewManager)
d->viewManager->disconnect(this);
if (d->viewManager != newView)
{
d->viewManager = qobject_cast<KisViewManager*>(newView);
connect(d->viewManager, SIGNAL(sigLoadingFinished()), d->centerer, SLOT(start()));
d->centerer->start();
emit <API key>();
}
}
void MainWindow::minimize()
{
setWindowState(windowState() ^ Qt::WindowMinimized);
}
void MainWindow::closeWindow()
{
//For some reason, close() does not work even if setAllowClose(true) was called just before this method.
//So instead just completely quit the application, since we are using a single window anyway.
QApplication::exit();
}
void MainWindow::resizeEvent(QResizeEvent* event)
{
// TODO this needs setting somewhere...
// d->constants->setGridWidth( event->size().width() / d->constants->gridColumns() );
// d->constants->setGridHeight( event->size().height() / d->constants->gridRows() );
QWidget::resizeEvent(event);
}
void MainWindow::closeEvent(QCloseEvent* event)
{
if (!d->allowClose) {
event->ignore();
emit closeRequested();
} else {
event->accept();
}
}
MainWindow::~MainWindow()
{
delete d;
}
#include "MainWindow.moc" |
// Project owner : Ray Liang (csharp2002@hotmail.com)
using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
namespace DNA.Web.Data.Entity.ModelConfiguration
{
public class <API key> : <API key><ContentDataItem>
{
public <API key>()
{
HasKey(i => i.ID).ToTable("<API key>");
Property(i => i.Owner).HasMaxLength(50);
Property(i => i.Auditor).HasMaxLength(50);
Property(i => i.Locale).HasMaxLength(20);
//Property(i => i.Categories).HasMaxLength(1024);
Property(i => i.Tags).HasMaxLength(1024);
Property(i => i.Path).HasColumnType("ntext");
Property(i => i.RawData).HasColumnType("ntext");
Property(i => i.Annotation).HasColumnType("ntext");
Property(i => i.Modifier).HasMaxLength(50);
Property(i => i.Slug).HasMaxLength(1024);
//Property(i => i.LockBy).HasMaxLength(50);
HasMany(i => i.Attachments)
.WithRequired(i => i.Item)
.HasForeignKey(i => i.ItemID);
HasMany(c => c.Categories)
.WithMany(d => d.ContentDataItems)
.Map(pr =>
{
pr.MapLeftKey("ContentDataItemID")
.MapRightKey("CategoryID")
.ToTable("<API key>");
});
}
}
} |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WaveLibrary.Wave
{
public class SubWave : IWave
{
IWave original;
int index, count;
public SubWave(IWave original, double sec) : this(original, (int)(original.SamplingRate * sec)) { }
public SubWave(IWave original, double start, double sec) : this(original, (int)(original.SamplingRate * start), (int)(original.SamplingRate * sec)) { }
public SubWave(IWave original, int length) : this(original, 0, length) { }
public SubWave(IWave original, int start, int length)
{
if (original.Length < (start + length)) throw new <API key>();
this.original = original;
this.index = start;
this.count = length;
}
public int SamplingRate
{
get { return original.SamplingRate; }
}
public int Length
{
get { return count; }
}
public double Read(int n)
{
if (n < count)
return original.Read(index + n);
throw new <API key>();
}
public IEnumerable<double> Reads()
{
for (int i = 0; i < Length; i++)
{
yield return Read(i);
}
yield break;
}
}
} |
<?php
// No direct access
defined('_JEXEC') or die;
/**
* @param array A named array
* @return array
*/
function EpgBuildRoute(&$query)
{
$segments = array();
if (isset($query['task'])) {
$segments[] = implode('/',explode('.',$query['task']));
unset($query['task']);
}
if (isset($query['id'])) {
$segments[] = $query['id'];
unset($query['id']);
}
return $segments;
}
/**
* @param array A named array
* @param array
*
* Formats:
*
* index.php?/epg/task/id/Itemid
*
* index.php?/epg/id/Itemid
*/
function EpgParseRoute($segments)
{
$vars = array();
// view is always the first element of the array
$count = count($segments);
if ($count)
{
$count
$segment = array_pop($segments) ;
if (is_numeric($segment)) {
$vars['id'] = $segment;
}
else{
$count
$vars['task'] = array_pop($segments) . '.' . $segment;
}
}
if ($count)
{
$vars['task'] = implode('.',$segments);
}
return $vars;
} |
#ifndef __UCL_AV_H
#define __UCL_AV_H
@begin
include "ucl_bitmap.h"
include "script_parser.h"
@end
extern "C" {
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}
extern "C" {
// - mutex lock callback function -
int av_lock_callback(void **mutex,enum AVLockOp op);
// - log callback function -
void av_log_callback(void* ptr,int level,const char *fmt,va_list vl);
}
/*
* definition of structure av_format_s
*/
struct av_format_s
{
AVFormatContext *format_ctx;
AVCodecContext **codec_ctxs;
AVPacket packet;
int proc_size;
inline void init();
inline void clear(<API key> &it);
};
/*
* definition of structure av_stream_s
*/
struct av_stream_s
{
location_s *format_ctx_ptr;
unsigned stream_idx;
inline void init();
inline void clear(<API key> &it);
};
/*
* definition of structure av_frame_s
*/
struct av_frame_s
{
AVFrame *frame;
unsigned stream_idx;
inline void init();
inline void clear(<API key> &it);
};
/*
* definition of structure av_picture_s
*/
struct av_picture_s
{
AVFrame picture;
int width;
int height;
AVPixelFormat format;
inline void init();
inline void clear(<API key> &it);
};
/*
* definition of class av_c
*/
class av_c
{
public:
inline av_c();
inline ~av_c();
};
/*
* inline methods of structure av_format_s
*/
inline void av_format_s::init()
{
format_ctx = nullptr;
codec_ctxs = nullptr;
packet.size = 0;
proc_size = 0;
}
inline void av_format_s::clear(<API key> &it)
{
// - if packet is not empty -
if (packet.size != 0)
{
av_packet_unref(&packet);
}
// - if format context exists -
if (format_ctx != nullptr)
{
// - if codec context array exists -
if (codec_ctxs != nullptr)
{
// - for each codec context -
if (format_ctx->nb_streams > 0)
{
AVCodecContext **cc_ptr = codec_ctxs;
AVCodecContext **cc_ptr_end = cc_ptr + format_ctx->nb_streams;
do {
// - if codec context exists -
if (*cc_ptr != nullptr)
{
avcodec_close(*cc_ptr);
}
} while(++cc_ptr < cc_ptr_end);
}
// - release codec context array -
cfree(codec_ctxs);
}
// - release format context -
if (format_ctx->iformat != nullptr)
{
<API key>(&format_ctx);
}
else
{
<API key>(format_ctx);
}
}
init();
}
/*
* inline methods of structure av_stream_s
*/
inline void av_stream_s::init()
{
format_ctx_ptr = nullptr;
stream_idx = 0;
}
inline void av_stream_s::clear(<API key> &it)
{
if (format_ctx_ptr != nullptr)
{
it.<API key>(format_ctx_ptr);
}
init();
}
/*
* inline methods of structure av_frame_s
*/
inline void av_frame_s::init()
{
frame = nullptr;
stream_idx = 0;
}
inline void av_frame_s::clear(<API key> &it)
{
if (frame != nullptr)
{
av_frame_free(&frame);
}
init();
}
/*
* inline methods of structure av_picture_s
*/
inline void av_picture_s::init()
{
format = AV_PIX_FMT_NONE;
}
inline void av_picture_s::clear(<API key> &it)
{
if (format != AV_PIX_FMT_NONE)
{
av_frame_unref(&picture);
}
init();
}
/*
* inline methods of class av_c
*/
inline av_c::av_c()
{
debug_message_2(fprintf(stderr,"libav_init()\n"););
av_register_all();
av_log_set_callback(&av_log_callback);
av_lockmgr_register(&av_lock_callback);
}
inline av_c::~av_c()
{
debug_message_2(fprintf(stderr,"libav_exit()\n"););
av_lockmgr_register(nullptr);
}
#endif |
@lost gutter 10px;
@lost flexbox flex;
@custom-media --medium-up (min-width: 768px);
/**
* Default
*/
.<API key>,
.<API key> {
margin: 0 auto;
max-width: 1100px;
}
.<API key> {
margin-bottom: 2em;
padding-bottom: 2em;
text-align: center;
}
.<API key> h1 {
margin-bottom: 0;
}
/**
* Featured Sermon
*/
.<API key> {
border: 1px solid #eee;
box-shadow: 0 1px 1px rgba(0,0,0,0.1);
lost-utility: clearfix;
display: flex;
flex-direction: column;
margin-bottom: 4em;
@media (--medium-up) {
flex-direction: row;
}
}
.<API key> {
font-size: 13px;
text-transform: uppercase;
}
.<API key> {
@media (--medium-up) {
width: 66.666667%;
}
}
.<API key> .featured-box-image {
display: block;
height: 200px;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
@media (--medium-up) {
height: 425px;
}
}
.<API key> iframe {
@media (--medium-up) {
height: 425px !important;
}
}
.<API key> {
background: #fff;
padding: 2em 30px;
position: relative;
@media (--medium-up) {
height: 425px;
width: 33.33333%;
}
}
.<API key> h2 {
font-size: 32px;
font-weight: bold;
margin-bottom: 10px;
padding-top: 0;
}
.<API key> {
font-size: 13px;
font-weight: bold;
text-transform: uppercase;
}
.<API key> {
align-items: center;
display: flex;
font-size: 13px;
@media (--medium-up) {
position: absolute;
bottom: 2em;
left: 30px;
right: 30px;
}
}
.<API key> {
font-weight: bold;
margin-left: auto;
text-transform: uppercase;
}
/**
* Series Grid
*/
.<API key> {
lost-utility: clearfix;
margin-bottom: 4em;
@media (--medium-up) {
lost-flex-container: row;
}
}
.<API key> {
background-color: #fff;
border: 1px solid #eee;
box-shadow: 0 1px 1px rgba(0,0,0,0.1);
margin-bottom: 1em;
min-height: 475px;
position: relative;
@media (--medium-up) {
lost-column: 1/3;
margin-bottom: 0;
}
}
.<API key> > a {
background-position: top center;
background-repeat: no-repeat;
background-size: cover;
display: block;
height: 197px;
max-height: 197px;
}
.<API key> > h3 {
font-weight: bold;
margin-bottom: 10px;
margin-top: 20px;
}
.<API key> {
padding: 20px 20px 60px;
}
.<API key> {
bottom: 0;
display: flex;
font-size: 13px;
left: 0;
padding: 20px 20px 15px;
position: absolute;
right: 0;
text-transform: uppercase;
}
.<API key> {
font-weight: bold;
margin-left: auto;
}
/**
* Sermons Grid
*/
.<API key> {
padding-bottom: 2em;
text-align: center;
text-transform: uppercase;
}
.pl-sermons-grid .pl-sermons-wrap {
lost-flex-container: row;
}
.<API key> {
background: #fff;
border: 1px solid #eee;
box-shadow: 0 1px 1px rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
margin-bottom: 1em;
padding: 2em 30px;
position: relative;
@media (--medium-up) {
display: block;
padding: 3em 30px 4em;
}
}
.pl-sermons-grid.gris-is-inline .<API key> {
display: flex;
@media (--medium-up) {
display: block;
padding: 3em 30px 4em;
}
}
.pl-sermons-grid.grid-is-inline .<API key> {
lost-column: 1;
}
.pl-sermons-grid.grid-is-grid .<API key> {
display: flex;
lost-column: 1;
@media (--medium-up) {
lost-column: 1/3;
padding: 2em 30px;
}
}
.<API key> {
margin-bottom: 15px;
}
.<API key> img {
display: block;
max-width: 100%;
}
.<API key> {
padding: 1em 0;
order: 1;
@media (--medium-up) {
order: 0;
padding: 0;
}
}
.pl-sermons-grid.grid-is-grid .<API key> {
padding: 1em 0;
}
.<API key> {
font-size: 28px;
font-weight: bold;
margin-bottom: 10px;
padding-top: 0;
@media(--medium-up) {
font-size: 32px;
}
}
.pl-sermons-grid.grid-is-grid .<API key> {
font-size: 24px;
@media(--medium-up) {
font-size: 28px;
}
}
.<API key> {
font-size: 13px;
font-weight: bold;
margin: 0;
text-transform: uppercase;
}
.<API key> {
font-weight: bold;
text-transform: uppercase;
font-size: 13px;
}
.<API key>:after {
content: '\2192';
margin-left: 5px;
}
.<API key>,
.<API key> {
font-size: 13px;
text-transform: uppercase;
}
.pl-sermons-grid.grid-is-inline .<API key>,
.pl-sermons-grid.grid-is-inline .<API key> {
bottom: 2em;
@media (--medium-up) {
display: flex;
left: 0;
padding: 0 30px;
position: absolute;
right: 0;
}
}
.pl-sermons-grid.grid-is-inline .<API key> {
order: 3;
@media(--medium-up) {
bottom: auto;
order: 0;
top: 2em;
}
}
.pl-sermons-grid.grid-is-inline .<API key> {
order: 2;
@media (--medium-up) {
order: 0;
}
}
.pl-sermons-grid.grid-is-inline .<API key> > span,
.pl-sermons-grid.grid-is-inline .<API key> > span {
display: block;
padding-bottom: 10px;
@media (--medium-up) {
display: inline;
padding-bottom: 0;
}
}
.pl-sermons-grid.grid-is-grid .<API key> > span,
.pl-sermons-grid.grid-is-grid .<API key> > span {
display: block;
padding-bottom: 10px;
}
.pl-sermons-grid.grid-is-inline .<API key> span:first-child,
.pl-sermons-grid.grid-is-inline .<API key> span:last-child {
@media (--medium-up) {
margin-left: auto;
}
}
.pl-sermons-grid.grid-is-inline .<API key> span:first-child {
margin-right: 1%;
}
.pl-sermons-grid.grid-is-grid .<API key> {
order: 2;
}
.pl-sermons-grid.grid-is-grid .<API key> {
order: 3;
}
.pl-sermons .<API key> ul.page-numbers {
list-style-type: none;
margin: 0;
text-align: center;
}
.pl-sermons .<API key> ul.page-numbers li {
border: 1px solid #ccc;
border-radius: 3px;
display: inline-block;
padding: 5px 10px;
}
/**
* Single Sermon
*/
.<API key> {
display: flex;
align-items: center;
padding: 1em 0 0 0;
}
.<API key> {
font-weight: bold;
margin-bottom: 10px;
margin-top: 0;
padding: 0;
}
.<API key> {
font-size: 14px;
font-weight: bold;
text-transform: uppercase;
}
.<API key> {
margin-left: auto;
}
.<API key> ul {
margin: 0;
}
.<API key> li {
display: inline-block;
list-style-type: none;
}
.<API key> {
text-transform: uppercase;
}
.<API key> {
padding: 1em 0 2em;
}
.<API key> p:last-child {
margin-bottom: 0;
}
.<API key> {
align-items: center;
border-bottom: 1px solid #ccc;
border-top: 1px solid #ccc;
cursor: pointer;
display: flex;
font-weight: bold;
padding: 10px;
text-transform: uppercase;
}
.<API key> {
margin-left: auto;
}
.<API key> {
background: #222;
border-radius: 4px;
color: #fff;
font-size: 14px;
font-weight: normal;
padding: 0.5em;
text-decoration: none;
text-transform: uppercase;
transition: all 0.3s ease-in-out;
}
.<API key>:hover {
background: #2e2e2e;
color: #fff;
}
.<API key> {
display: none;
padding: 1em;
}
.pl-sermons-caret {
display: inline-block;
width: 0;
height: 0;
margin-left: 2px;
vertical-align: middle;
border-top: 6px dashed;
border-top: 6px solid\9;
border-right: 6px solid transparent;
border-left: 6px solid transparent;
transition: all 0.3s ease-in-out;
}
.<API key>.active .pl-sermons-caret {
transform: rotate(180deg);
}
/**
* Sermon Attachments
*/
.<API key> {
margin: 4em 0;
}
.<API key> {
border-top: 1px solid #ccc;
align-items: center;
display: flex;
padding: 10px;
transition: all 0.3s ease-in-out;
}
.<API key>:hover {
background: #eee;
}
.<API key>:hover .<API key> button {
opacity: 1;
}
.<API key>:last-child {
border-bottom: 1px solid #ccc;
}
.<API key> svg {
display: block;
margin-right: 1em;
}
.<API key> {
display: none;
margin-left: auto;
}
@media only screen and (min-width: 900px) {
.<API key> {
display: block;
margin-left: auto;
}
}
.<API key> button {
background: #222;
border-radius: 4px;
color: #fff;
font-size: 14px;
font-weight: normal;
opacity: 0;
padding: 0.5em;
text-transform: uppercase;
transition: all 0.3s ease-in-out;
}
.<API key> button:hover {
background: #222;
}
/**
* Grid Nav
*/
.pl-sermons-nav li {
display: inline-block;
}
.pl-sermons-nav li:after {
color: #ccc;
content: '
margin-left: 5px;
margin-right: 2px;
}
.pl-sermons-nav li:last-child:after {
content: '';
display: none;
}
/**
* Taxonomy Series
*/
.<API key> {
background-position: center;
background-repeat: no-repeat;
background-size: cover;
display: block;
height: 475px;
margin-bottom: 2em;
}
/**
* Theme Support for 2017
*/
.has-sidebar.pl-sermons-page:not(.error404) #primary {
width: 100%;
}
.<API key> {
background: #eee;
padding: 30px;
}
.<API key> .mejs-container {
margin-bottom: 0;
} |
#!/bin/bash
LINKS_FILE=$1
DOWNLOADS_PATH=$(dirname "$1")
echo "
echo "Usage: playlister <LINKS FILE>"
echo "
echo "Reading videos from: $LINKS_FILE"
echo "Your downloaded files will be available here: $DOWNLOADS_PATH"
echo ''
youtube-dl -o "$DOWNLOADS_PATH/%(title)s.%(ext)s" --batch-file "$LINKS_FILE"
# while read -r url; do
# echo "youtube-dl -o \"$DOWNLOADS_PATH/%(title)s.%(ext)s\" $url"
# echo 'Download completed'
# done < "$LINKS_FILE" |
<?php
defined('_JEXEC') or die;
?>
<dl class="search-results<?php echo $this->pageclass_sfx; ?>">
<?php foreach ($this->results as $result) : ?>
<dt class="result-title">
<?php echo $this->pagination->limitstart + $result->count.'. ';?>
<?php if(isset($result->joomgallerypicture)) : ?>
<a href="<?php echo JRoute::_($result->href); ?>"><?php echo $this->escape($result->title); ?></a>
<br />
<br />
<?php echo $result->joomgallerypicture; ?>
<?php else : ?>
<?php if ($result->href) :?>
<a href="<?php echo JRoute::_($result->href); ?>"<?php if ($result->browsernav == 1) :?> target="_blank"<?php endif;?>>
<?php echo $this->escape($result->title);?>
</a>
<?php else : ?>
<?php echo $this->escape($result->title);?>
<?php endif; ?>
<?php endif; ?>
</dt>
<?php if ($result->section) : ?>
<dd class="result-category">
<span class="small<?php echo $this->pageclass_sfx; ?>">
(<?php echo $this->escape($result->section); ?>)
</span>
</dd>
<?php endif; ?>
<dd class="result-text">
<?php echo $result->text; ?>
</dd>
<?php if ($this->params->get('show_date')) : ?>
<dd class="result-created<?php echo $this->pageclass_sfx; ?>">
<?php echo JText::sprintf('<API key>', $result->created); ?>
</dd>
<?php endif; ?>
<?php endforeach; ?>
</dl>
<div class="pagination">
<?php echo $this->pagination->getPagesLinks(); ?>
</div> |
#!/usr/bin/env ruby
require 'rubygems'
require 'gollum/app'
gollum_path = File.expand_path(File.dirname(__FILE__)) # CHANGE THIS TO POINT TO YOUR OWN WIKI REPO
Precious::App.set(:gollum_path, gollum_path)
Precious::App.set(:default_markup, :markdown) # set your favorite markup language
Precious::App.set(:wiki_options, {:universal_toc => false})
run Precious::App |
<?php
$logname = "/tmp/stats";
/* PUT data comes in on the stdin stream */
$putdata = fopen("php://input", "r");
$stats = fopen($logname, "w");
/* Read the data 1 packet at a time */
$int_start = microtime(true);
$bytes = 0;
while ($data = fread($putdata, 1420)) {
if (($curr = microtime(true)) > ($int_start + 1)) {
fprintf($stats, "%u\n", $bytes * 8);
$int_start = $curr;
$bytes = 0;
}
$bytes += strlen($data);
}
$end = microtime(true);
fprintf($stats, "%f %f - %u %u\n", $int_start, $end, $bytes, ($bytes * 8)/($end - $int_start) );
fclose($putdata);
fclose($stats);
Header("HTTP/1.1 201 Created");
?> |
// ISSideBarVC.h
// <API key>
#import <UIKit/UIKit.h>
#import "ISSideBarTVC.h"
@interface ISSideBarVC : UIViewController
@property (weak, nonatomic) ISSideBarTVC *tableVC;
@end |
package org.hl7.v3;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
@XmlRootElement(name = "PRPA_IN201302UV02")
public class PRPAIN201302UV02
extends <API key>
{
@XmlAttribute(name = "ITSVersion", required = true)
protected String itsVersion;
/**
* Gets the value of the itsVersion property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getITSVersion() {
if (itsVersion == null) {
return "XML_1.0";
} else {
return itsVersion;
}
}
/**
* Sets the value of the itsVersion property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setITSVersion(String value) {
this.itsVersion = value;
}
} |
#ifndef BCHP_TIMER_H__
#define BCHP_TIMER_H__
#define BCHP_TIMER_TIMER_IS 0x004067c0 /* TIMER INTERRUPT STATUS REGISTER */
#define <API key> 0x004067c4 /* TIMER CPU INTERRUPT ENABLE REGISTER */
#define <API key> 0x004067c8 /* TIMER0 CONTROL REGISTER */
#define <API key> 0x004067cc /* TIMER1 CONTROL REGISTER */
#define <API key> 0x004067d0 /* TIMER2 CONTROL REGISTER */
#define <API key> 0x004067d4 /* TIMER3 CONTROL REGISTER */
#define <API key> 0x004067d8 /* TIMER0 STATUS REGISTER */
#define <API key> 0x004067dc /* TIMER1 STATUS REGISTER */
#define <API key> 0x004067e0 /* TIMER2 STATUS REGISTER */
#define <API key> 0x004067e4 /* TIMER3 STATUS REGISTER */
#define <API key> 0x004067e8 /* WATCHDOG TIMEOUT REGISTER */
#define BCHP_TIMER_WDCMD 0x004067ec /* WATCHDOG COMMAND REGISTER */
#define <API key> 0x004067f0 /* WATCHDOG CHIP RESET COUNT REGISTER */
#define BCHP_TIMER_WDCRS 0x004067f4 /* WATCHDOG CHIP RESET STATUS REGISTER */
#define <API key> 0x004067f8 /* TIMER PCI INTERRUPT ENABLE REGISTER */
#define BCHP_TIMER_WDCTRL 0x004067fc /* WATCHDOG CONTROL REGISTER */
/* TIMER :: TIMER_IS :: reserved0 [31:05] */
#define <API key> 0xffffffe0
#define <API key> 5
/* TIMER :: TIMER_IS :: WDINT [04:04] */
#define <API key> 0x00000010
#define <API key> 4
/* TIMER :: TIMER_IS :: TMR3TO [03:03] */
#define <API key> 0x00000008
#define <API key> 3
/* TIMER :: TIMER_IS :: TMR2TO [02:02] */
#define <API key> 0x00000004
#define <API key> 2
/* TIMER :: TIMER_IS :: TMR1TO [01:01] */
#define <API key> 0x00000002
#define <API key> 1
/* TIMER :: TIMER_IS :: TMR0TO [00:00] */
#define <API key> 0x00000001
#define <API key> 0
/* TIMER :: TIMER_IE0 :: reserved0 [31:05] */
#define <API key> 0xffffffe0
#define <API key> 5
/* TIMER :: TIMER_IE0 :: WDINTMASK [04:04] */
#define <API key> 0x00000010
#define <API key> 4
/* TIMER :: TIMER_IE0 :: TMR3TO [03:03] */
#define <API key> 0x00000008
#define <API key> 3
/* TIMER :: TIMER_IE0 :: TMR2TO [02:02] */
#define <API key> 0x00000004
#define <API key> 2
/* TIMER :: TIMER_IE0 :: TMR1TO [01:01] */
#define <API key> 0x00000002
#define <API key> 1
/* TIMER :: TIMER_IE0 :: TMR0TO [00:00] */
#define <API key> 0x00000001
#define <API key> 0
/* TIMER :: TIMER0_CTRL :: ENA [31:31] */
#define <API key> 0x80000000
#define <API key> 31
/* TIMER :: TIMER0_CTRL :: MODE [30:30] */
#define <API key> 0x40000000
#define <API key> 30
/* TIMER :: TIMER0_CTRL :: TIMEOUT_VAL [29:00] */
#define <API key> 0x3fffffff
#define <API key> 0
/* TIMER :: TIMER1_CTRL :: ENA [31:31] */
#define <API key> 0x80000000
#define <API key> 31
/* TIMER :: TIMER1_CTRL :: MODE [30:30] */
#define <API key> 0x40000000
#define <API key> 30
/* TIMER :: TIMER1_CTRL :: TIMEOUT_VAL [29:00] */
#define <API key> 0x3fffffff
#define <API key> 0
/* TIMER :: TIMER2_CTRL :: ENA [31:31] */
#define <API key> 0x80000000
#define <API key> 31
/* TIMER :: TIMER2_CTRL :: MODE [30:30] */
#define <API key> 0x40000000
#define <API key> 30
/* TIMER :: TIMER2_CTRL :: TIMEOUT_VAL [29:00] */
#define <API key> 0x3fffffff
#define <API key> 0
/* TIMER :: TIMER3_CTRL :: ENA [31:31] */
#define <API key> 0x80000000
#define <API key> 31
/* TIMER :: TIMER3_CTRL :: MODE [30:30] */
#define <API key> 0x40000000
#define <API key> 30
/* TIMER :: TIMER3_CTRL :: TIMEOUT_VAL [29:00] */
#define <API key> 0x3fffffff
#define <API key> 0
/* TIMER :: TIMER0_STAT :: RESERVED [31:30] */
#define <API key> 0xc0000000
#define <API key> 30
/* TIMER :: TIMER0_STAT :: COUNTER_VAL [29:00] */
#define <API key> 0x3fffffff
#define <API key> 0
/* TIMER :: TIMER1_STAT :: RESERVED [31:30] */
#define <API key> 0xc0000000
#define <API key> 30
/* TIMER :: TIMER1_STAT :: COUNTER_VAL [29:00] */
#define <API key> 0x3fffffff
#define <API key> 0
/* TIMER :: TIMER2_STAT :: RESERVED [31:30] */
#define <API key> 0xc0000000
#define <API key> 30
/* TIMER :: TIMER2_STAT :: COUNTER_VAL [29:00] */
#define <API key> 0x3fffffff
#define <API key> 0
/* TIMER :: TIMER3_STAT :: RESERVED [31:30] */
#define <API key> 0xc0000000
#define <API key> 30
/* TIMER :: TIMER3_STAT :: COUNTER_VAL [29:00] */
#define <API key> 0x3fffffff
#define <API key> 0
/* TIMER :: WDTIMEOUT :: WDTIMEOUT_VAL [31:00] */
#define <API key> 0xffffffff
#define <API key> 0
/* TIMER :: WDCMD :: WDCMD [31:00] */
#define <API key> 0xffffffff
#define <API key> 0
/* TIMER :: WDCHIPRST_CNT :: reserved0 [31:26] */
#define <API key> 0xfc000000
#define <API key> 26
/* TIMER :: WDCHIPRST_CNT :: WDCHIPRST_CNT [25:00] */
#define <API key> 0x03ffffff
#define <API key> 0
/* TIMER :: WDCRS :: reserved0 [31:01] */
#define <API key> 0xfffffffe
#define <API key> 1
/* TIMER :: WDCRS :: WDCR [00:00] */
#define <API key> 0x00000001
#define <API key> 0
/* TIMER :: TIMER_IE1 :: reserved0 [31:05] */
#define <API key> 0xffffffe0
#define <API key> 5
/* TIMER :: TIMER_IE1 :: WDINTMASK [04:04] */
#define <API key> 0x00000010
#define <API key> 4
/* TIMER :: TIMER_IE1 :: TMR3TO [03:03] */
#define <API key> 0x00000008
#define <API key> 3
/* TIMER :: TIMER_IE1 :: TMR2TO [02:02] */
#define <API key> 0x00000004
#define <API key> 2
/* TIMER :: TIMER_IE1 :: TMR1TO [01:01] */
#define <API key> 0x00000002
#define <API key> 1
/* TIMER :: TIMER_IE1 :: TMR0TO [00:00] */
#define <API key> 0x00000001
#define <API key> 0
/* TIMER :: WDCTRL :: reserved0 [31:03] */
#define <API key> 0xfffffff8
#define <API key> 3
/* TIMER :: WDCTRL :: WD_COUNT_MODE [02:02] */
#define <API key> 0x00000004
#define <API key> 2
/* TIMER :: WDCTRL :: WD_EVENT_MODE [01:00] */
#define <API key> 0x00000003
#define <API key> 0
#endif /* #ifndef BCHP_TIMER_H__ */
/* End of File */ |
<?php
// clearing the session before starting new API Call
session_unset();
?>
<html>
<head>
<title>PayPal Merchant SDK - DoDirectPayment API</title>
<link rel="stylesheet" href="../Common/sdk.css"/>
<script language="JavaScript">
function generateCC(){
var cc_number = new Array(16);
var cc_len = 16;
var start = 0;
var rand_number = Math.random();
switch(document.DoDirectPaymentForm.creditCardType.value)
{
case "Visa":
cc_number[start++] = 4;
break;
case "Discover":
cc_number[start++] = 6;
cc_number[start++] = 0;
cc_number[start++] = 1;
cc_number[start++] = 1;
break;
case "MasterCard":
cc_number[start++] = 5;
cc_number[start++] = Math.floor(Math.random() * 5) + 1;
break;
case "Amex":
cc_number[start++] = 3;
cc_number[start++] = Math.round(Math.random()) ? 7 : 4 ;
cc_len = 15;
break;
}
for (var i = start; i < (cc_len - 1); i++) {
cc_number[i] = Math.floor(Math.random() * 10);
}
var sum = 0;
for (var j = 0; j < (cc_len - 1); j++) {
var digit = cc_number[j];
if ((j & 1) == (cc_len & 1)) digit *= 2;
if (digit > 9) digit -= 9;
sum += digit;
}
var check_digit = new Array(0, 9, 8, 7, 6, 5, 4, 3, 2, 1);
cc_number[cc_len - 1] = check_digit[sum % 10];
document.DoDirectPaymentForm.creditCardNumber.value = "";
for (var k = 0; k < cc_len; k++) {
document.DoDirectPaymentForm.creditCardNumber.value += cc_number[k];
}
}
</script>
</head>
<body>
<div id="wrapper">
<div id="header">
<h3>DoDirectPayment</h3>
<div id="apidetails">Process a credit card payment.</div>
</div>
<div id="request_form">
<form method="POST" action="DoDirectPayment.php"
name="DoDirectPaymentForm">
<div class="params">
<div class="param_name">Payment type</div>
<div class="param_value">
<select name="paymentType">
<option value="Sale" selected="selected">Sale</option>
<option value="Authorisation">Authorisation</option>
</select>
</div>
</div>
<div class="params">
<div class="param_name">First name</div>
<div class="param_value">
<input type="text" name="firstName" value="John"/>
</div>
</div>
<div class="params">
<div class="param_name">Last name</div>
<div class="param_value">
<input type="text" name="lastName" value="Doe"/>
</div>
</div>
<div class="params">
<div class="param_name">Card type</div>
<div class="param_value">
<select name="creditCardType"
onChange="javascript:generateCC(); return false;">
<option value="Visa" selected="selected">Visa</option>
<option value="MasterCard">MasterCard</option>
<option value="Discover">Discover</option>
<option value="Amex">American Express</option>
</select>
</div>
</div>
<div class="params">
<div class="param_name">Card number</div>
<div class="param_value">
<input type="text" size="19" maxlength="19" name="creditCardNumber">
</div>
</div>
<div class="params">
<div class="param_name">Expiry date</div>
<div class="param_value">
<select name="expDateMonth">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
<select name="expDateYear">
<option value="2013">2013</option>
<option value="2014" selected>2014</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
<option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
</select>
</div>
</div>
<div class="params">
<div class="param_name">CVV</div>
<div class="param_value">
<input type="text" size="3" maxlength="4" name="cvv2Number" value="962">
</div>
</div>
<div class="params">
<div class="param_name">Amount</div>
<div class="param_value">
<input type="text" size="5" maxlength="7" name="amount" value="1.00"> USD
</div>
</div>
<div class="section_header">Billing address</div>
<div class="params">
<div class="param_name">Address 1</div>
<div class="param_value">
<input type="text" size="25" maxlength="100" name="address1" value="1 Main St">
</div>
</div>
<div class="params">
<div class="param_name">Address 2 (optional)</div>
<div class="param_value">
<input type="text" size="25" maxlength="100" name="address2" value="">
</div>
</div>
<div class="params">
<div class="param_name">City</div>
<div class="param_value">
<input type="text" size="25" maxlength="40" name="city" value="San Jose">
</div>
</div>
<div class="params">
<div class="param_name">State</div>
<div class="param_value">
<select id=state name="state">
<option value=""></option>
<option value="AK">AK</option>
<option value="AL">AL</option>
<option value="AR">AR</option>
<option value="AZ">AZ</option>
<option value="CA" selected>CA</option>
<option value="CO">CO</option>
<option value="CT">CT</option>
<option value="DC">DC</option>
<option value="DE">DE</option>
<option value="FL">FL</option>
<option value="GA">GA</option>
<option value="HI">HI</option>
<option value="IA">IA</option>
<option value="ID">ID</option>
<option value="IL">IL</option>
<option value="IN">IN</option>
<option value="KS">KS</option>
<option value="KY">KY</option>
<option value="LA">LA</option>
<option value="MA">MA</option>
<option value="MD">MD</option>
<option value="ME">ME</option>
<option value="MI">MI</option>
<option value="MN">MN</option>
<option value="MO">MO</option>
<option value="MS">MS</option>
<option value="MT">MT</option>
<option value="NC">NC</option>
<option value="ND">ND</option>
<option value="NE">NE</option>
<option value="NH">NH</option>
<option value="NJ">NJ</option>
<option value="NM">NM</option>
<option value="NV">NV</option>
<option value="NY">NY</option>
<option value="OH">OH</option>
<option value="OK">OK</option>
<option value="OR">OR</option>
<option value="PA">PA</option>
<option value="RI">RI</option>
<option value="SC">SC</option>
<option value="SD">SD</option>
<option value="TN">TN</option>
<option value="TX">TX</option>
<option value="UT">UT</option>
<option value="VA">VA</option>
<option value="VT">VT</option>
<option value="WA">WA</option>
<option value="WI">WI</option>
<option value="WV">WV</option>
<option value="WY">WY</option>
<option value="AA">AA</option>
<option value="AE">AE</option>
<option value="AP">AP</option>
<option value="AS">AS</option>
<option value="FM">FM</option>
<option value="GU">GU</option>
<option value="MH">MH</option>
<option value="MP">MP</option>
<option value="PR">PR</option>
<option value="PW">PW</option>
<option value="VI">VI</option>
</select>
</div>
</div>
<div class="params">
<div class="param_name">Zip code</div>
<div class="param_value">
<input type="text" size="10" maxlength="10" name="zip" value="95131"> (5 or 9 digits)
</div>
</div>
<div class="params">
<div class="param_name">Country</div>
<div class="param_value">
<input type="text" size="10" maxlength="10" name="country" value="US">
</div>
</div>
<div class="params">
<div class="param_name">Phone</div>
<div class="param_value">
<input type="text" size="10" maxlength="10" name="phone" value="">
</div>
</div>
<div class="params">
<div class="param_name"></div>
<div class="param_value">
</div>
</div>
<div class="submit">
<input type="submit" name="DoDirectPaymentBtn"
value="DoDirectPayment" />
</div>
</form>
<a href="../index.php">Home</a>
</div>
</div>
<script language="javascript">
generateCC();
</script>
</body>
</html> |
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "hash-set.h"
#include "machmode.h"
#include "vec.h"
#include "double-int.h"
#include "input.h"
#include "alias.h"
#include "symtab.h"
#include "wide-int.h"
#include "inchash.h"
#include "tree.h"
#include "fold-const.h"
#include "stringpool.h"
#include "predict.h"
#include "hard-reg-set.h"
#include "input.h"
#include "function.h"
#include "basic-block.h"
#include "tree-ssa-alias.h"
#include "internal-fn.h"
#include "gimple-expr.h"
#include "is-a.h"
#include "gimple.h"
#include "expr.h"
#include "flags.h"
#include "params.h"
#include "langhooks.h"
#include "bitmap.h"
#include "diagnostic-core.h"
#include "except.h"
#include "timevar.h"
#include "hash-map.h"
#include "plugin-api.h"
#include "ipa-ref.h"
#include "cgraph.h"
#include "lto-streamer.h"
#include "data-streamer.h"
#include "tree-streamer.h"
#include "gcov-io.h"
#include "tree-pass.h"
#include "profile.h"
#include "context.h"
#include "pass_manager.h"
#include "ipa-utils.h"
#include "omp-low.h"
/* True when asm nodes has been output. */
bool asm_nodes_output = false;
static void <API key> (void);
static void <API key> (vec<symtab_node *> nodes);
/* Number of LDPR values known to GCC. */
#define LDPR_NUM_KNOWN (<API key> + 1)
/* All node orders are ofsetted by ORDER_BASE. */
static int order_base;
/* Cgraph streaming is organized as set of record whose type
is indicated by a tag. */
enum LTO_symtab_tags
{
/* Must leave 0 for the stopper. */
/* Cgraph node without body available. */
<API key> = 1,
/* Cgraph node with function body. */
<API key>,
/* Cgraph edges. */
LTO_symtab_edge,
<API key>,
LTO_symtab_variable,
LTO_symtab_last_tag
};
/* Create a new symtab encoder.
if FOR_INPUT, the encoder allocate only datastructures needed
to read the symtab. */
<API key>
<API key> (bool for_input)
{
<API key> encoder = XCNEW (struct <API key>);
if (!for_input)
encoder->map = new hash_map<symtab_node *, size_t>;
encoder->nodes.create (0);
return encoder;
}
/* Delete ENCODER and its components. */
void
<API key> (<API key> encoder)
{
encoder->nodes.release ();
if (encoder->map)
delete encoder->map;
free (encoder);
}
/* Return the existing reference number of NODE in the symtab encoder in
output block OB. Assign a new reference if this is the first time
NODE is encoded. */
int
<API key> (<API key> encoder,
symtab_node *node)
{
int ref;
if (!encoder->map)
{
lto_encoder_entry entry = {node, false, false, false};
ref = encoder->nodes.length ();
encoder->nodes.safe_push (entry);
return ref;
}
size_t *slot = encoder->map->get (node);
if (!slot || !*slot)
{
lto_encoder_entry entry = {node, false, false, false};
ref = encoder->nodes.length ();
if (!slot)
encoder->map->put (node, ref + 1);
encoder->nodes.safe_push (entry);
}
else
ref = *slot - 1;
return ref;
}
/* Remove NODE from encoder. */
bool
<API key> (<API key> encoder,
symtab_node *node)
{
int index;
lto_encoder_entry last_node;
size_t *slot = encoder->map->get (node);
if (slot == NULL || !*slot)
return false;
index = *slot - 1;
gcc_checking_assert (encoder->nodes[index].node == node);
/* Remove from vector. We do this by swapping node with the last element
of the vector. */
last_node = encoder->nodes.pop ();
if (last_node.node != node)
{
gcc_assert (encoder->map->put (last_node.node, index + 1));
/* Move the last element to the original spot of NODE. */
encoder->nodes[index] = last_node;
}
/* Remove element from hash table. */
encoder->map->remove (node);
return true;
}
/* Return TRUE if we should encode initializer of NODE (if any). */
bool
<API key> (<API key> encoder,
struct cgraph_node *node)
{
int index = <API key> (encoder, node);
return encoder->nodes[index].body;
}
/* Return TRUE if we should encode body of NODE (if any). */
static void
<API key> (<API key> encoder,
struct cgraph_node *node)
{
int index = <API key> (encoder, node);
gcc_checking_assert (encoder->nodes[index].node == node);
encoder->nodes[index].body = true;
}
/* Return TRUE if we should encode initializer of NODE (if any). */
bool
<API key> (<API key> encoder,
varpool_node *node)
{
int index = <API key> (encoder, node);
if (index == LCC_NOT_FOUND)
return false;
return encoder->nodes[index].initializer;
}
/* Return TRUE if we should encode initializer of NODE (if any). */
static void
<API key> (<API key> encoder,
varpool_node *node)
{
int index = <API key> (encoder, node);
encoder->nodes[index].initializer = true;
}
/* Return TRUE if we should encode initializer of NODE (if any). */
bool
<API key> (<API key> encoder,
symtab_node *node)
{
int index = <API key> (encoder, node);
if (index == LCC_NOT_FOUND)
return false;
return encoder->nodes[index].in_partition;
}
/* Return TRUE if we should encode body of NODE (if any). */
void
<API key> (<API key> encoder,
symtab_node *node)
{
int index = <API key> (encoder, node);
encoder->nodes[index].in_partition = true;
}
/* Output the cgraph EDGE to OB using ENCODER. */
static void
lto_output_edge (struct <API key> *ob, struct cgraph_edge *edge,
<API key> encoder)
{
unsigned int uid;
intptr_t ref;
struct bitpack_d bp;
if (edge-><API key>)
streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag,
<API key>);
else
streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag,
LTO_symtab_edge);
ref = <API key> (encoder, edge->caller);
gcc_assert (ref != LCC_NOT_FOUND);
<API key> (ob->main_stream, ref);
if (!edge-><API key>)
{
ref = <API key> (encoder, edge->callee);
gcc_assert (ref != LCC_NOT_FOUND);
<API key> (ob->main_stream, ref);
}
<API key> (ob->main_stream, edge->count);
bp = bitpack_create (ob->main_stream);
uid = (!gimple_has_body_p (edge->caller->decl)
? edge->lto_stmt_uid : gimple_uid (edge->call_stmt) + 1);
bp_pack_enum (&bp, <API key>,
CIF_N_REASONS, edge->inline_failed);
<API key> (&bp, uid);
<API key> (&bp, edge->frequency);
bp_pack_value (&bp, edge-><API key>, 1);
bp_pack_value (&bp, edge->speculative, 1);
bp_pack_value (&bp, edge-><API key>, 1);
bp_pack_value (&bp, edge->can_throw_external, 1);
bp_pack_value (&bp, edge-><API key>, 1);
if (edge-><API key>)
{
int flags = edge->indirect_info->ecf_flags;
bp_pack_value (&bp, (flags & ECF_CONST) != 0, 1);
bp_pack_value (&bp, (flags & ECF_PURE) != 0, 1);
bp_pack_value (&bp, (flags & ECF_NORETURN) != 0, 1);
bp_pack_value (&bp, (flags & ECF_MALLOC) != 0, 1);
bp_pack_value (&bp, (flags & ECF_NOTHROW) != 0, 1);
bp_pack_value (&bp, (flags & ECF_RETURNS_TWICE) != 0, 1);
/* Flags that should not appear on indirect calls. */
gcc_assert (!(flags & (<API key>
| ECF_MAY_BE_ALLOCA
| ECF_SIBCALL
| ECF_LEAF
| ECF_NOVOPS)));
}
<API key> (&bp);
if (edge-><API key>)
{
<API key> (ob->main_stream,
edge->indirect_info->common_target_id);
if (edge->indirect_info->common_target_id)
<API key>
(ob->main_stream, edge->indirect_info-><API key>);
}
}
/* Return if NODE contain references from other partitions. */
bool
<API key> (symtab_node *node, <API key> encoder)
{
int i;
struct ipa_ref *ref = NULL;
for (i = 0; node->iterate_referring (i, ref); i++)
{
/* Ignore references from non-offloadable nodes while streaming NODE into
offload LTO section. */
if (!ref->referring->need_lto_streaming)
continue;
if (ref->referring->in_other_partition
|| !<API key> (encoder, ref->referring))
return true;
}
return false;
}
/* Return true when node is reachable from other partition. */
bool
<API key> (struct cgraph_node *node, <API key> encoder)
{
struct cgraph_edge *e;
if (!node->definition)
return false;
if (node->global.inlined_to)
return false;
for (e = node->callers; e; e = e->next_caller)
{
/* Ignore references from non-offloadable nodes while streaming NODE into
offload LTO section. */
if (!e->caller->need_lto_streaming)
continue;
if (e->caller->in_other_partition
|| !<API key> (encoder, e->caller))
return true;
}
return false;
}
/* Return if NODE contain references from other partitions. */
bool
<API key> (symtab_node *node,
<API key> encoder)
{
int i;
struct ipa_ref *ref = NULL;
for (i = 0; node->iterate_referring (i, ref); i++)
if (<API key> (encoder, ref->referring))
return true;
return false;
}
/* Return true when node is reachable from other partition. */
bool
<API key> (struct cgraph_node *node, <API key> encoder)
{
struct cgraph_edge *e;
for (e = node->callers; e; e = e->next_caller)
if (<API key> (encoder, e->caller))
return true;
return false;
}
/* Output the cgraph NODE to OB. ENCODER is used to find the
reference number of NODE->inlined_to. SET is the set of nodes we
are writing to the current file. If NODE is not in SET, then NODE
is a boundary of a cgraph_node_set and we pretend NODE just has a
decl and no callees. WRITTEN_DECLS is the set of FUNCTION_DECLs
that have had their callgraph node written so far. This is used to
determine if NODE is a clone of a previously written node. */
static void
lto_output_node (struct <API key> *ob, struct cgraph_node *node,
<API key> encoder)
{
unsigned int tag;
struct bitpack_d bp;
bool boundary_p;
intptr_t ref;
bool in_other_partition = false;
struct cgraph_node *clone_of, *ultimate_clone_of;
ipa_opt_pass_d *pass;
int i;
bool alias_p;
const char *comdat;
const char *section;
tree group;
boundary_p = !<API key> (encoder, node);
if (node->analyzed && !boundary_p)
tag = <API key>;
else
tag = <API key>;
streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag,
tag);
<API key> (ob->main_stream, node->order);
/* In WPA mode, we only output part of the call-graph. Also, we
fake cgraph node attributes. There are two cases that we care.
Boundary nodes: There are nodes that are not part of SET but are
called from within SET. We artificially make them look like
externally visible nodes with no function body.
Cherry-picked nodes: These are nodes we pulled from other
translation units into SET during IPA-inlining. We make them as
local static nodes to prevent clashes with other local statics. */
if (boundary_p && node->analyzed
&& node-><API key> () == SYMBOL_PARTITION)
{
/* Inline clones can not be part of boundary.
gcc_assert (!node->global.inlined_to);
FIXME: At the moment they can be, when partition contains an inline
clone that is clone of inline clone from outside partition. We can
reshape the clone tree and make other tree to be the root, but it
needs a bit extra work and will be promplty done by cgraph_remove_node
after reading back. */
in_other_partition = 1;
}
clone_of = node->clone_of;
while (clone_of
&& (ref = <API key> (encoder, clone_of)) == LCC_NOT_FOUND)
if (clone_of->prev_sibling_clone)
clone_of = clone_of->prev_sibling_clone;
else
clone_of = clone_of->clone_of;
/* See if body of the master function is output. If not, we are seeing only
an declaration and we do not need to pass down clone tree. */
ultimate_clone_of = clone_of;
while (ultimate_clone_of && ultimate_clone_of->clone_of)
ultimate_clone_of = ultimate_clone_of->clone_of;
if (clone_of && !<API key> (encoder, ultimate_clone_of))
clone_of = NULL;
if (tag == <API key>)
gcc_assert (clone_of || !node->clone_of);
if (!clone_of)
<API key> (ob->main_stream, LCC_NOT_FOUND);
else
<API key> (ob->main_stream, ref);
<API key> (ob->decl_state, ob->main_stream, node->decl);
<API key> (ob->main_stream, node->count);
<API key> (ob->main_stream, node-><API key>);
<API key> (ob->main_stream,
node-><API key>.length ());
FOR_EACH_VEC_ELT (node-><API key>, i, pass)
<API key> (ob->main_stream, pass->static_pass_number);
if (tag == <API key>)
{
if (node->global.inlined_to)
{
ref = <API key> (encoder, node->global.inlined_to);
gcc_assert (ref != LCC_NOT_FOUND);
}
else
ref = LCC_NOT_FOUND;
<API key> (ob->main_stream, ref);
}
group = node->get_comdat_group ();
if (group)
comdat = IDENTIFIER_POINTER (group);
else
comdat = "";
<API key> (ob->main_stream, comdat, strlen (comdat) + 1);
if (group)
{
if (node->same_comdat_group && !boundary_p)
{
ref = <API key> (encoder,
node->same_comdat_group);
gcc_assert (ref != LCC_NOT_FOUND);
}
else
ref = LCC_NOT_FOUND;
<API key> (ob->main_stream, ref);
}
section = node->get_section ();
if (!section)
section = "";
<API key> (ob->main_stream, node->tp_first_run);
bp = bitpack_create (ob->main_stream);
bp_pack_value (&bp, node->local.local, 1);
bp_pack_value (&bp, node->externally_visible, 1);
bp_pack_value (&bp, node->no_reorder, 1);
bp_pack_value (&bp, node->definition, 1);
bp_pack_value (&bp, node->local.versionable, 1);
bp_pack_value (&bp, node->local.<API key>, 1);
bp_pack_value (&bp, node->local.<API key>, 1);
bp_pack_value (&bp, node->force_output, 1);
bp_pack_value (&bp, node->forced_by_abi, 1);
bp_pack_value (&bp, node->unique_name, 1);
bp_pack_value (&bp, node->body_removed, 1);
bp_pack_value (&bp, node->implicit_section, 1);
bp_pack_value (&bp, node->address_taken, 1);
bp_pack_value (&bp, tag == <API key>
&& node-><API key> () == SYMBOL_PARTITION
&& (<API key> (node, encoder)
|| <API key> (node, encoder)), 1);
bp_pack_value (&bp, node->lowered, 1);
bp_pack_value (&bp, in_other_partition, 1);
/* Real aliases in a boundary become non-aliases. However we still stream
alias info on weakrefs.
TODO: We lose a bit of information here - when we know that variable is
defined in other unit, we may use the info on aliases to resolve
symbol1 != symbol2 type tests that we can do only for locally defined objects
otherwise. */
alias_p = node->alias && (!boundary_p || node->weakref);
bp_pack_value (&bp, alias_p, 1);
bp_pack_value (&bp, node->weakref, 1);
bp_pack_value (&bp, node->frequency, 2);
bp_pack_value (&bp, node-><API key>, 1);
bp_pack_value (&bp, node->only_called_at_exit, 1);
bp_pack_value (&bp, node->tm_clone, 1);
bp_pack_value (&bp, node->calls_comdat_local, 1);
bp_pack_value (&bp, node->icf_merged, 1);
bp_pack_value (&bp, node->nonfreeing_fn, 1);
bp_pack_value (&bp, node->thunk.thunk_p && !boundary_p, 1);
bp_pack_enum (&bp, <API key>,
LDPR_NUM_KNOWN, node->resolution);
bp_pack_value (&bp, node-><API key>, 1);
<API key> (&bp);
<API key> (ob->main_stream, section, strlen (section) + 1);
if (node->thunk.thunk_p && !boundary_p)
{
<API key>
(ob->main_stream,
1 + (node->thunk.this_adjusting != 0) * 2
+ (node->thunk.virtual_offset_p != 0) * 4
+ (node->thunk.<API key> != 0) * 8);
<API key> (ob->main_stream, node->thunk.fixed_offset);
<API key> (ob->main_stream, node->thunk.virtual_value);
}
<API key> (ob->main_stream, node->profile_id);
if (<API key> (node->decl))
<API key> (ob->main_stream, node->get_init_priority ());
if (<API key> (node->decl))
<API key> (ob->main_stream, node->get_fini_priority ());
if (node-><API key>)
<API key> (ob->decl_state, ob->main_stream, node->orig_decl);
}
/* Output the varpool NODE to OB.
If NODE is not in SET, then NODE is a boundary. */
static void
<API key> (struct <API key> *ob, varpool_node *node,
<API key> encoder)
{
bool boundary_p = !<API key> (encoder, node);
struct bitpack_d bp;
int ref;
bool alias_p;
const char *comdat;
const char *section;
tree group;
streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag,
LTO_symtab_variable);
<API key> (ob->main_stream, node->order);
<API key> (ob->decl_state, ob->main_stream, node->decl);
bp = bitpack_create (ob->main_stream);
bp_pack_value (&bp, node->externally_visible, 1);
bp_pack_value (&bp, node->no_reorder, 1);
bp_pack_value (&bp, node->force_output, 1);
bp_pack_value (&bp, node->forced_by_abi, 1);
bp_pack_value (&bp, node->unique_name, 1);
bp_pack_value (&bp, node->body_removed
|| !<API key> (encoder, node), 1);
bp_pack_value (&bp, node->implicit_section, 1);
bp_pack_value (&bp, node->writeonly, 1);
bp_pack_value (&bp, node->definition, 1);
alias_p = node->alias && (!boundary_p || node->weakref);
bp_pack_value (&bp, alias_p, 1);
bp_pack_value (&bp, node->weakref, 1);
bp_pack_value (&bp, node->analyzed && !boundary_p, 1);
gcc_assert (node->definition || !node->analyzed);
/* Constant pool initializers can be de-unified into individual ltrans units.
FIXME: Alternatively at -Os we may want to avoid generating for them the local
labels and share them across LTRANS partitions. */
if (node-><API key> () != SYMBOL_PARTITION)
{
bp_pack_value (&bp, 0, 1); /* <API key>. */
bp_pack_value (&bp, 0, 1); /* in_other_partition. */
}
else
{
bp_pack_value (&bp, node->definition
&& <API key> (node, encoder), 1);
bp_pack_value (&bp, node->analyzed
&& boundary_p && !DECL_EXTERNAL (node->decl), 1);
/* in_other_partition. */
}
bp_pack_value (&bp, node->tls_model, 3);
bp_pack_value (&bp, node-><API key>, 1);
bp_pack_value (&bp, node->need_bounds_init, 1);
<API key> (&bp);
group = node->get_comdat_group ();
if (group)
comdat = IDENTIFIER_POINTER (group);
else
comdat = "";
<API key> (ob->main_stream, comdat, strlen (comdat) + 1);
if (group)
{
if (node->same_comdat_group && !boundary_p)
{
ref = <API key> (encoder,
node->same_comdat_group);
gcc_assert (ref != LCC_NOT_FOUND);
}
else
ref = LCC_NOT_FOUND;
<API key> (ob->main_stream, ref);
}
section = node->get_section ();
if (!section)
section = "";
<API key> (ob->main_stream, section, strlen (section) + 1);
streamer_write_enum (ob->main_stream, <API key>,
LDPR_NUM_KNOWN, node->resolution);
}
/* Output the varpool NODE to OB.
If NODE is not in SET, then NODE is a boundary. */
static void
lto_output_ref (struct <API key> *ob, struct ipa_ref *ref,
<API key> encoder)
{
struct bitpack_d bp;
int nref;
int uid = ref->lto_stmt_uid;
struct cgraph_node *node;
bp = bitpack_create (ob->main_stream);
bp_pack_value (&bp, ref->use, 3);
bp_pack_value (&bp, ref->speculative, 1);
<API key> (&bp);
nref = <API key> (encoder, ref->referred);
gcc_assert (nref != LCC_NOT_FOUND);
<API key> (ob->main_stream, nref);
node = dyn_cast <cgraph_node *> (ref->referring);
if (node)
{
if (ref->stmt)
uid = gimple_uid (ref->stmt) + 1;
<API key> (ob->main_stream, uid);
}
}
/* Stream out profile_summary to OB. */
static void
<API key> (struct <API key> *ob)
{
unsigned h_ix;
struct bitpack_d bp;
if (profile_info)
{
/* We do not output num and run_max, they are not used by
GCC profile feedback and they are difficult to merge from multiple
units. */
gcc_assert (profile_info->runs);
<API key> (ob->main_stream, profile_info->runs);
<API key> (ob->main_stream, profile_info->sum_max);
/* sum_all is needed for computing the working set with the
histogram. */
<API key> (ob->main_stream, profile_info->sum_all);
/* Create and output a bitpack of non-zero histogram entries indices. */
bp = bitpack_create (ob->main_stream);
for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
bp_pack_value (&bp, profile_info->histogram[h_ix].num_counters > 0, 1);
<API key> (&bp);
/* Now stream out only those non-zero entries. */
for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
{
if (!profile_info->histogram[h_ix].num_counters)
continue;
<API key> (ob->main_stream,
profile_info->histogram[h_ix].num_counters);
<API key> (ob->main_stream,
profile_info->histogram[h_ix].min_value);
<API key> (ob->main_stream,
profile_info->histogram[h_ix].cum_value);
}
/* IPA-profile computes hot bb threshold based on cumulated
whole program profile. We need to stream it down to ltrans. */
if (flag_wpa)
<API key> (ob->main_stream,
<API key> ());
}
else
<API key> (ob->main_stream, 0);
}
/* Output all callees or indirect outgoing edges. EDGE must be the first such
edge. */
static void
<API key> (struct cgraph_edge *edge,
struct <API key> *ob,
<API key> encoder)
{
if (!edge)
return;
/* Output edges in backward direction, so the reconstructed callgraph match
and it is easy to associate call sites in the IPA pass summaries. */
while (edge->next_callee)
edge = edge->next_callee;
for (; edge; edge = edge->prev_callee)
lto_output_edge (ob, edge, encoder);
}
/* Output the part of the cgraph in SET. */
static void
output_refs (<API key> encoder)
{
<API key> lsei;
struct <API key> *ob;
int count;
struct ipa_ref *ref;
int i;
ob = <API key> (LTO_section_refs);
for (lsei = <API key> (encoder); !lsei_end_p (lsei);
<API key> (&lsei))
{
symtab_node *node = lsei_node (lsei);
count = node->ref_list.nreferences ();
if (count)
{
<API key> (ob->main_stream, count);
<API key> (ob->main_stream,
<API key> (encoder, node));
for (i = 0; node->iterate_reference (i, ref); i++)
lto_output_ref (ob, ref, encoder);
}
}
<API key> (ob->main_stream, 0);
<API key> (ob);
}
/* Add NODE into encoder as well as nodes it is cloned from.
Do it in a way so clones appear first. */
static void
add_node_to (<API key> encoder, struct cgraph_node *node,
bool include_body)
{
if (node->clone_of)
add_node_to (encoder, node->clone_of, include_body);
else if (include_body)
<API key> (encoder, node);
<API key> (encoder, node);
}
/* Add all references in NODE to encoders. */
static void
create_references (<API key> encoder, symtab_node *node)
{
int i;
struct ipa_ref *ref = NULL;
for (i = 0; node->iterate_reference (i, ref); i++)
if (is_a <cgraph_node *> (ref->referred))
add_node_to (encoder, dyn_cast <cgraph_node *> (ref->referred), false);
else
<API key> (encoder, ref->referred);
}
/* Select what needs to be streamed out. In regular lto mode stream everything.
In offload lto mode stream only nodes marked as offloadable. */
void
<API key> (void)
{
struct symtab_node *snode;
FOR_EACH_SYMBOL (snode)
snode->need_lto_streaming = !<API key> || snode->offloadable;
}
/* Find all symbols we want to stream into given partition and insert them
to encoders.
The function actually replaces IN_ENCODER by new one. The reason is that
streaming code needs clone's origin to be streamed before clone. This
means that we need to insert the nodes in specific order. This order is
ignored by the partitioning logic earlier. */
<API key>
<API key> (<API key> in_encoder)
{
struct cgraph_edge *edge;
int i;
<API key> encoder;
<API key> lsei;
hash_set<void *> <API key>;
encoder = <API key> (false);
/* Go over all entries in the IN_ENCODER and duplicate them to
ENCODER. At the same time insert masters of clones so
every master appears before clone. */
for (lsei = <API key> (in_encoder);
!lsei_end_p (lsei); <API key> (&lsei))
{
struct cgraph_node *node = lsei_cgraph_node (lsei);
if (!node->need_lto_streaming)
continue;
add_node_to (encoder, node, true);
<API key> (encoder, node);
create_references (encoder, node);
/* For proper debug info, we need to ship the origins, too. */
if (<API key> (node->decl))
{
struct cgraph_node *origin_node
= cgraph_node::get_create (<API key> (node->decl));
origin_node-><API key> = true;
add_node_to (encoder, origin_node, true);
}
}
for (lsei = <API key> (in_encoder);
!lsei_end_p (lsei); <API key> (&lsei))
{
varpool_node *vnode = lsei_varpool_node (lsei);
if (!vnode->need_lto_streaming)
continue;
<API key> (encoder, vnode);
<API key> (encoder, vnode);
create_references (encoder, vnode);
/* For proper debug info, we need to ship the origins, too. */
if (<API key> (vnode->decl))
{
varpool_node *origin_node
= varpool_node::get (<API key> (vnode->decl));
<API key> (encoder, origin_node);
}
}
/* Pickle in also the initializer of all referenced readonly variables
to help folding. Constant pool variables are not shared, so we must
pickle those too. */
for (i = 0; i < <API key> (encoder); i++)
{
symtab_node *node = <API key> (encoder, i);
if (varpool_node *vnode = dyn_cast <varpool_node *> (node))
{
if (!<API key> (encoder,
vnode)
&& (((vnode-><API key> ()
&& (!DECL_VIRTUAL_P (vnode->decl)
|| !flag_wpa
|| <API key>))
|| POINTER_BOUNDS_P (vnode->decl))))
{
<API key> (encoder, vnode);
create_references (encoder, vnode);
}
}
}
/* Go over all the nodes again to include callees that are not in
SET. */
for (lsei = <API key> (encoder);
!lsei_end_p (lsei); <API key> (&lsei))
{
struct cgraph_node *node = lsei_cgraph_node (lsei);
for (edge = node->callees; edge; edge = edge->next_callee)
{
struct cgraph_node *callee = edge->callee;
if (!<API key> (encoder, callee))
{
/* We should have moved all the inlines. */
gcc_assert (!callee->global.inlined_to);
add_node_to (encoder, callee, false);
}
}
/* Add all possible targets for late devirtualization. */
if (<API key> || !flag_wpa)
for (edge = node->indirect_calls; edge; edge = edge->next_callee)
if (edge->indirect_info->polymorphic)
{
unsigned int i;
void *cache_token;
bool final;
vec <cgraph_node *>targets
= <API key>
(edge, &final, &cache_token);
if (!<API key>.add (cache_token))
{
for (i = 0; i < targets.length (); i++)
{
struct cgraph_node *callee = targets[i];
/* Adding an external declarations into the unit serves
no purpose and just increases its boundary. */
if (callee->definition
&& !<API key>
(encoder, callee))
{
gcc_assert (!callee->global.inlined_to);
add_node_to (encoder, callee, false);
}
}
}
}
}
<API key> (in_encoder);
return encoder;
}
/* Output the part of the symtab in SET and VSET. */
void
output_symtab (void)
{
struct cgraph_node *node;
struct <API key> *ob;
<API key> lsei;
int i, n_nodes;
<API key> encoder;
if (flag_wpa)
<API key> ();
ob = <API key> (<API key>);
<API key> (ob);
gcc_assert (ob->decl_state->symtab_node_encoder);
encoder = ob->decl_state->symtab_node_encoder;
/* Write out the nodes. We must first output a node and then its clones,
otherwise at a time reading back the node there would be nothing to clone
from. */
n_nodes = <API key> (encoder);
for (i = 0; i < n_nodes; i++)
{
symtab_node *node = <API key> (encoder, i);
if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node))
lto_output_node (ob, cnode, encoder);
else
<API key> (ob, dyn_cast<varpool_node *> (node), encoder);
}
/* Go over the nodes in SET again to write edges. */
for (lsei = <API key> (encoder); !lsei_end_p (lsei);
<API key> (&lsei))
{
node = lsei_cgraph_node (lsei);
<API key> (node->callees, ob, encoder);
<API key> (node->indirect_calls, ob, encoder);
}
<API key> (ob->main_stream, 0);
<API key> (ob);
/* Emit toplevel asms.
When doing WPA we must output every asm just once. Since we do not partition asm
nodes at all, output them to first output. This is kind of hack, but should work
well. */
if (!asm_nodes_output)
{
asm_nodes_output = true;
<API key> ();
}
output_refs (encoder);
}
/* Return identifier encoded in IB as a plain string. */
static tree
read_identifier (struct lto_input_block *ib)
{
unsigned int len = strnlen (ib->data + ib->p, ib->len - ib->p - 1);
tree id;
if (ib->data[ib->p + len])
lto_section_overrun (ib);
if (!len)
{
ib->p++;
return NULL;
}
id = get_identifier (ib->data + ib->p);
ib->p += len + 1;
return id;
}
/* Return string encoded in IB, NULL if string is empty. */
static const char *
read_string (struct lto_input_block *ib)
{
unsigned int len = strnlen (ib->data + ib->p, ib->len - ib->p - 1);
const char *str;
if (ib->data[ib->p + len])
lto_section_overrun (ib);
if (!len)
{
ib->p++;
return NULL;
}
str = ib->data + ib->p;
ib->p += len + 1;
return str;
}
/* Output function/variable tables that will allow libgomp to look up offload
target code.
OFFLOAD_FUNCS is filled in expand_omp_target, OFFLOAD_VARS is filled in
varpool_node::get_create. In WHOPR (partitioned) mode during the WPA stage
both OFFLOAD_FUNCS and OFFLOAD_VARS are filled by <API key>. */
void
<API key> (void)
{
if (vec_safe_is_empty (offload_funcs) && vec_safe_is_empty (offload_vars))
return;
struct <API key> *ob
= <API key> (<API key>);
for (unsigned i = 0; i < vec_safe_length (offload_funcs); i++)
{
streamer_write_enum (ob->main_stream, LTO_symtab_tags,
LTO_symtab_last_tag, <API key>);
<API key> (ob->decl_state, ob->main_stream,
(*offload_funcs)[i]);
}
for (unsigned i = 0; i < vec_safe_length (offload_vars); i++)
{
streamer_write_enum (ob->main_stream, LTO_symtab_tags,
LTO_symtab_last_tag, LTO_symtab_variable);
<API key> (ob->decl_state, ob->main_stream,
(*offload_vars)[i]);
}
<API key> (ob->main_stream, 0);
<API key> (ob);
/* In WHOPR mode during the WPA stage the joint offload tables need to be
streamed to one partition only. That's why we free offload_funcs and
offload_vars after the first call of <API key>. */
if (flag_wpa)
{
vec_free (offload_funcs);
vec_free (offload_vars);
}
}
/* Overwrite the information in NODE based on FILE_DATA, TAG, FLAGS,
STACK_SIZE, SELF_TIME and SELF_SIZE. This is called either to initialize
NODE or to replace the values in it, for instance because the first
time we saw it, the function body was not available but now it
is. BP is a bitpack with all the bitflags for NODE read from the
stream. */
static void
<API key> (struct lto_file_decl_data *file_data,
struct cgraph_node *node,
enum LTO_symtab_tags tag,
struct bitpack_d *bp)
{
node->aux = (void *) tag;
node->lto_file_data = file_data;
node->local.local = bp_unpack_value (bp, 1);
node->externally_visible = bp_unpack_value (bp, 1);
node->no_reorder = bp_unpack_value (bp, 1);
node->definition = bp_unpack_value (bp, 1);
node->local.versionable = bp_unpack_value (bp, 1);
node->local.<API key> = bp_unpack_value (bp, 1);
node->local.<API key> = bp_unpack_value (bp, 1);
node->force_output = bp_unpack_value (bp, 1);
node->forced_by_abi = bp_unpack_value (bp, 1);
node->unique_name = bp_unpack_value (bp, 1);
node->body_removed = bp_unpack_value (bp, 1);
node->implicit_section = bp_unpack_value (bp, 1);
node->address_taken = bp_unpack_value (bp, 1);
node-><API key> = bp_unpack_value (bp, 1);
node->lowered = bp_unpack_value (bp, 1);
node->analyzed = tag == <API key>;
node->in_other_partition = bp_unpack_value (bp, 1);
if (node->in_other_partition
/* Avoid updating decl when we are seeing just inline clone.
When inlining function that has functions already inlined into it,
we produce clones of inline clones.
WPA partitioning might put each clone into different unit and
we might end up streaming inline clone from other partition
to support clone we are interested in. */
&& (!node->clone_of
|| node->clone_of->decl != node->decl))
{
DECL_EXTERNAL (node->decl) = 1;
TREE_STATIC (node->decl) = 0;
}
node->alias = bp_unpack_value (bp, 1);
node->weakref = bp_unpack_value (bp, 1);
node->frequency = (enum node_frequency)bp_unpack_value (bp, 2);
node-><API key> = bp_unpack_value (bp, 1);
node->only_called_at_exit = bp_unpack_value (bp, 1);
node->tm_clone = bp_unpack_value (bp, 1);
node->calls_comdat_local = bp_unpack_value (bp, 1);
node->icf_merged = bp_unpack_value (bp, 1);
node->nonfreeing_fn = bp_unpack_value (bp, 1);
node->thunk.thunk_p = bp_unpack_value (bp, 1);
node->resolution = bp_unpack_enum (bp, <API key>,
LDPR_NUM_KNOWN);
node-><API key> = bp_unpack_value (bp, 1);
gcc_assert (flag_ltrans
|| (!node->in_other_partition
&& !node-><API key>));
}
/* Return string alias is alias of. */
static tree
get_alias_symbol (tree decl)
{
tree alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
return get_identifier (TREE_STRING_POINTER
(TREE_VALUE (TREE_VALUE (alias))));
}
/* Read a node from input_block IB. TAG is the node's tag just read.
Return the node read or overwriten. */
static struct cgraph_node *
input_node (struct lto_file_decl_data *file_data,
struct lto_input_block *ib,
enum LTO_symtab_tags tag,
vec<symtab_node *> nodes)
{
gcc::pass_manager *passes = g->get_passes ();
tree fn_decl;
struct cgraph_node *node;
struct bitpack_d bp;
unsigned decl_index;
int ref = LCC_NOT_FOUND, ref2 = LCC_NOT_FOUND;
int clone_ref;
int order;
int i, count;
tree group;
const char *section;
order = streamer_read_hwi (ib) + order_base;
clone_ref = streamer_read_hwi (ib);
decl_index = streamer_read_uhwi (ib);
fn_decl = <API key> (file_data, decl_index);
if (clone_ref != LCC_NOT_FOUND)
{
node = dyn_cast<cgraph_node *> (nodes[clone_ref])->create_clone (fn_decl,
0, CGRAPH_FREQ_BASE, false,
vNULL, false, NULL, NULL);
}
else
{
/* Declaration of functions can be already merged with a declaration
from other input file. We keep cgraph unmerged until after streaming
of ipa passes is done. Alays forcingly create a fresh node. */
node = symtab->create_empty ();
node->decl = fn_decl;
node->register_symbol ();
}
node->order = order;
if (order >= symtab->order)
symtab->order = order + 1;
node->count = <API key> (ib);
node-><API key> = streamer_read_hwi (ib);
count = streamer_read_hwi (ib);
node-><API key> = vNULL;
for (i = 0; i < count; i++)
{
opt_pass *pass;
int pid = streamer_read_hwi (ib);
gcc_assert (pid < passes->passes_by_id_size);
pass = passes->passes_by_id[pid];
node-><API key>.safe_push ((ipa_opt_pass_d *) pass);
}
if (tag == <API key>)
ref = streamer_read_hwi (ib);
group = read_identifier (ib);
if (group)
ref2 = streamer_read_hwi (ib);
/* Make sure that we have not read this node before. Nodes that
have already been read will have their tag stored in the 'aux'
field. Since built-in functions can be referenced in multiple
functions, they are expected to be read more than once. */
if (node->aux && !DECL_BUILT_IN (node->decl))
internal_error ("bytecode stream: found multiple instances of cgraph "
"node with uid %d", node->uid);
node->tp_first_run = streamer_read_uhwi (ib);
bp = <API key> (ib);
<API key> (file_data, node, tag, &bp);
/* Store a reference for now, and fix up later to be a pointer. */
node->global.inlined_to = (cgraph_node *) (intptr_t) ref;
if (group)
{
node->set_comdat_group (group);
/* Store a reference for now, and fix up later to be a pointer. */
node->same_comdat_group = (symtab_node *) (intptr_t) ref2;
}
else
node->same_comdat_group = (symtab_node *) (intptr_t) LCC_NOT_FOUND;
section = read_string (ib);
if (section)
node-><API key> (section);
if (node->thunk.thunk_p)
{
int type = streamer_read_uhwi (ib);
HOST_WIDE_INT fixed_offset = streamer_read_uhwi (ib);
HOST_WIDE_INT virtual_value = streamer_read_uhwi (ib);
node->thunk.fixed_offset = fixed_offset;
node->thunk.this_adjusting = (type & 2);
node->thunk.virtual_value = virtual_value;
node->thunk.virtual_offset_p = (type & 4);
node->thunk.<API key> = (type & 8);
}
if (node->alias && !node->analyzed && node->weakref)
node->alias_target = get_alias_symbol (node->decl);
node->profile_id = streamer_read_hwi (ib);
if (<API key> (node->decl))
node->set_init_priority (streamer_read_hwi (ib));
if (<API key> (node->decl))
node->set_fini_priority (streamer_read_hwi (ib));
if (node-><API key>)
{
decl_index = streamer_read_uhwi (ib);
fn_decl = <API key> (file_data, decl_index);
node->orig_decl = fn_decl;
}
return node;
}
/* Read a node from input_block IB. TAG is the node's tag just read.
Return the node read or overwriten. */
static varpool_node *
input_varpool_node (struct lto_file_decl_data *file_data,
struct lto_input_block *ib)
{
int decl_index;
tree var_decl;
varpool_node *node;
struct bitpack_d bp;
int ref = LCC_NOT_FOUND;
int order;
tree group;
const char *section;
order = streamer_read_hwi (ib) + order_base;
decl_index = streamer_read_uhwi (ib);
var_decl = <API key> (file_data, decl_index);
/* Declaration of functions can be already merged with a declaration
from other input file. We keep cgraph unmerged until after streaming
of ipa passes is done. Alays forcingly create a fresh node. */
node = varpool_node::create_empty ();
node->decl = var_decl;
node->register_symbol ();
node->order = order;
if (order >= symtab->order)
symtab->order = order + 1;
node->lto_file_data = file_data;
bp = <API key> (ib);
node->externally_visible = bp_unpack_value (&bp, 1);
node->no_reorder = bp_unpack_value (&bp, 1);
node->force_output = bp_unpack_value (&bp, 1);
node->forced_by_abi = bp_unpack_value (&bp, 1);
node->unique_name = bp_unpack_value (&bp, 1);
node->body_removed = bp_unpack_value (&bp, 1);
node->implicit_section = bp_unpack_value (&bp, 1);
node->writeonly = bp_unpack_value (&bp, 1);
node->definition = bp_unpack_value (&bp, 1);
node->alias = bp_unpack_value (&bp, 1);
node->weakref = bp_unpack_value (&bp, 1);
node->analyzed = bp_unpack_value (&bp, 1);
node-><API key> = bp_unpack_value (&bp, 1);
node->in_other_partition = bp_unpack_value (&bp, 1);
if (node->in_other_partition)
{
DECL_EXTERNAL (node->decl) = 1;
TREE_STATIC (node->decl) = 0;
}
if (node->alias && !node->analyzed && node->weakref)
node->alias_target = get_alias_symbol (node->decl);
node->tls_model = (enum tls_model)bp_unpack_value (&bp, 3);
node-><API key> = (enum tls_model)bp_unpack_value (&bp, 1);
node->need_bounds_init = bp_unpack_value (&bp, 1);
group = read_identifier (ib);
if (group)
{
node->set_comdat_group (group);
ref = streamer_read_hwi (ib);
/* Store a reference for now, and fix up later to be a pointer. */
node->same_comdat_group = (symtab_node *) (intptr_t) ref;
}
else
node->same_comdat_group = (symtab_node *) (intptr_t) LCC_NOT_FOUND;
section = read_string (ib);
if (section)
node-><API key> (section);
node->resolution = streamer_read_enum (ib, <API key>,
LDPR_NUM_KNOWN);
gcc_assert (flag_ltrans
|| (!node->in_other_partition
&& !node-><API key>));
return node;
}
/* Read a node from input_block IB. TAG is the node's tag just read.
Return the node read or overwriten. */
static void
input_ref (struct lto_input_block *ib,
symtab_node *referring_node,
vec<symtab_node *> nodes)
{
symtab_node *node = NULL;
struct bitpack_d bp;
enum ipa_ref_use use;
bool speculative;
struct ipa_ref *ref;
bp = <API key> (ib);
use = (enum ipa_ref_use) bp_unpack_value (&bp, 3);
speculative = (enum ipa_ref_use) bp_unpack_value (&bp, 1);
node = nodes[streamer_read_hwi (ib)];
ref = referring_node->create_reference (node, use);
ref->speculative = speculative;
if (is_a <cgraph_node *> (referring_node))
ref->lto_stmt_uid = streamer_read_hwi (ib);
}
/* Read an edge from IB. NODES points to a vector of previously read nodes for
decoding caller and callee of the edge to be read. If INDIRECT is true, the
edge being read is indirect (in the sense that it has
<API key> set). */
static void
input_edge (struct lto_input_block *ib, vec<symtab_node *> nodes,
bool indirect)
{
struct cgraph_node *caller, *callee;
struct cgraph_edge *edge;
unsigned int stmt_id;
gcov_type count;
int freq;
<API key> inline_failed;
struct bitpack_d bp;
int ecf_flags = 0;
caller = dyn_cast<cgraph_node *> (nodes[streamer_read_hwi (ib)]);
if (caller == NULL || caller->decl == NULL_TREE)
internal_error ("bytecode stream: no caller found while reading edge");
if (!indirect)
{
callee = dyn_cast<cgraph_node *> (nodes[streamer_read_hwi (ib)]);
if (callee == NULL || callee->decl == NULL_TREE)
internal_error ("bytecode stream: no callee found while reading edge");
}
else
callee = NULL;
count = <API key> (ib);
bp = <API key> (ib);
inline_failed = bp_unpack_enum (&bp, <API key>, CIF_N_REASONS);
stmt_id = <API key> (&bp);
freq = (int) <API key> (&bp);
if (indirect)
edge = caller-><API key> (NULL, 0, count, freq);
else
edge = caller->create_edge (callee, NULL, count, freq);
edge-><API key> = bp_unpack_value (&bp, 1);
edge->speculative = bp_unpack_value (&bp, 1);
edge->lto_stmt_uid = stmt_id;
edge->inline_failed = inline_failed;
edge-><API key> = bp_unpack_value (&bp, 1);
edge->can_throw_external = bp_unpack_value (&bp, 1);
edge-><API key> = bp_unpack_value (&bp, 1);
if (indirect)
{
if (bp_unpack_value (&bp, 1))
ecf_flags |= ECF_CONST;
if (bp_unpack_value (&bp, 1))
ecf_flags |= ECF_PURE;
if (bp_unpack_value (&bp, 1))
ecf_flags |= ECF_NORETURN;
if (bp_unpack_value (&bp, 1))
ecf_flags |= ECF_MALLOC;
if (bp_unpack_value (&bp, 1))
ecf_flags |= ECF_NOTHROW;
if (bp_unpack_value (&bp, 1))
ecf_flags |= ECF_RETURNS_TWICE;
edge->indirect_info->ecf_flags = ecf_flags;
edge->indirect_info->common_target_id = streamer_read_hwi (ib);
if (edge->indirect_info->common_target_id)
edge->indirect_info-><API key> = streamer_read_hwi (ib);
}
}
/* Read a cgraph from IB using the info in FILE_DATA. */
static vec<symtab_node *>
input_cgraph_1 (struct lto_file_decl_data *file_data,
struct lto_input_block *ib)
{
enum LTO_symtab_tags tag;
vec<symtab_node *> nodes = vNULL;
symtab_node *node;
unsigned i;
tag = streamer_read_enum (ib, LTO_symtab_tags, LTO_symtab_last_tag);
order_base = symtab->order;
while (tag)
{
if (tag == LTO_symtab_edge)
input_edge (ib, nodes, false);
else if (tag == <API key>)
input_edge (ib, nodes, true);
else if (tag == LTO_symtab_variable)
{
node = input_varpool_node (file_data, ib);
nodes.safe_push (node);
<API key> (file_data->symtab_node_encoder, node);
}
else
{
node = input_node (file_data, ib, tag, nodes);
if (node == NULL || node->decl == NULL_TREE)
internal_error ("bytecode stream: found empty cgraph node");
nodes.safe_push (node);
<API key> (file_data->symtab_node_encoder, node);
}
tag = streamer_read_enum (ib, LTO_symtab_tags, LTO_symtab_last_tag);
}
<API key> (file_data, order_base);
/* AUX pointers should be all non-zero for function nodes read from the stream. */
#ifdef ENABLE_CHECKING
FOR_EACH_VEC_ELT (nodes, i, node)
gcc_assert (node->aux || !is_a <cgraph_node *> (node));
#endif
FOR_EACH_VEC_ELT (nodes, i, node)
{
int ref;
if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node))
{
ref = (int) (intptr_t) cnode->global.inlined_to;
/* We share declaration of builtins, so we may read same node twice. */
if (!node->aux)
continue;
node->aux = NULL;
/* Fixup inlined_to from reference to pointer. */
if (ref != LCC_NOT_FOUND)
dyn_cast<cgraph_node *> (node)->global.inlined_to
= dyn_cast<cgraph_node *> (nodes[ref]);
else
cnode->global.inlined_to = NULL;
/* Compute <API key>. */
if (cnode-><API key>)
{
gcc_assert (cnode->orig_decl);
cnode-><API key> = cgraph_node::get (cnode->orig_decl);
if (cnode-><API key>)
{
/* We may have multiple nodes for a single function which
will be merged later. To have a proper merge we need
to keep <API key> reference between nodes
consistent: each <API key> reference should
have proper reverse reference. Thus don't break existing
<API key> reference if it already exists. */
if (cnode-><API key>-><API key>)
cnode-><API key> = NULL;
else
cnode-><API key>-><API key> = cnode;
}
/* Restore decl names reference. */
if (<API key> (DECL_ASSEMBLER_NAME (cnode->decl))
&& !TREE_CHAIN (DECL_ASSEMBLER_NAME (cnode->decl)))
TREE_CHAIN (DECL_ASSEMBLER_NAME (cnode->decl))
= DECL_ASSEMBLER_NAME (cnode->orig_decl);
}
}
ref = (int) (intptr_t) node->same_comdat_group;
/* Fixup same_comdat_group from reference to pointer. */
if (ref != LCC_NOT_FOUND)
node->same_comdat_group = nodes[ref];
else
node->same_comdat_group = NULL;
}
FOR_EACH_VEC_ELT (nodes, i, node)
node->aux = is_a <cgraph_node *> (node) ? (void *)1 : NULL;
return nodes;
}
/* Input ipa_refs. */
static void
input_refs (struct lto_input_block *ib,
vec<symtab_node *> nodes)
{
int count;
int idx;
while (true)
{
symtab_node *node;
count = streamer_read_uhwi (ib);
if (!count)
break;
idx = streamer_read_uhwi (ib);
node = nodes[idx];
while (count)
{
input_ref (ib, node, nodes);
count
}
}
}
static struct gcov_ctr_summary lto_gcov_summary;
/* Input profile_info from IB. */
static void
<API key> (struct lto_input_block *ib,
struct lto_file_decl_data *file_data)
{
unsigned h_ix;
struct bitpack_d bp;
unsigned int runs = streamer_read_uhwi (ib);
if (runs)
{
file_data->profile_info.runs = runs;
file_data->profile_info.sum_max = <API key> (ib);
file_data->profile_info.sum_all = <API key> (ib);
memset (file_data->profile_info.histogram, 0,
sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE);
/* Input the bitpack of non-zero histogram indices. */
bp = <API key> (ib);
/* Read in and unpack the full bitpack, flagging non-zero
histogram entries by setting the num_counters non-zero. */
for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
{
file_data->profile_info.histogram[h_ix].num_counters
= bp_unpack_value (&bp, 1);
}
for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
{
if (!file_data->profile_info.histogram[h_ix].num_counters)
continue;
file_data->profile_info.histogram[h_ix].num_counters
= <API key> (ib);
file_data->profile_info.histogram[h_ix].min_value
= <API key> (ib);
file_data->profile_info.histogram[h_ix].cum_value
= <API key> (ib);
}
/* IPA-profile computes hot bb threshold based on cumulated
whole program profile. We need to stream it down to ltrans. */
if (flag_ltrans)
<API key> (<API key> (ib));
}
}
/* Rescale profile summaries to the same number of runs in the whole unit. */
static void
<API key> (struct lto_file_decl_data **file_data_vec)
{
struct lto_file_decl_data *file_data;
unsigned int j, h_ix;
gcov_unsigned_t max_runs = 0;
struct cgraph_node *node;
struct cgraph_edge *edge;
gcov_type saved_sum_all = 0;
gcov_ctr_summary *saved_profile_info = 0;
int saved_scale = 0;
/* Find unit with maximal number of runs. If we ever get serious about
roundoff errors, we might also consider computing smallest common
multiply. */
for (j = 0; (file_data = file_data_vec[j]) != NULL; j++)
if (max_runs < file_data->profile_info.runs)
max_runs = file_data->profile_info.runs;
if (!max_runs)
return;
/* Simple overflow check. We probably don't need to support that many train
runs. Such a large value probably imply data corruption anyway. */
if (max_runs > INT_MAX / REG_BR_PROB_BASE)
{
sorry ("At most %i profile runs is supported. Perhaps corrupted profile?",
INT_MAX / REG_BR_PROB_BASE);
return;
}
profile_info = <o_gcov_summary;
lto_gcov_summary.runs = max_runs;
lto_gcov_summary.sum_max = 0;
memset (lto_gcov_summary.histogram, 0,
sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE);
/* Rescale all units to the maximal number of runs.
sum_max can not be easily merged, as we have no idea what files come from
the same run. We do not use the info anyway, so leave it 0. */
for (j = 0; (file_data = file_data_vec[j]) != NULL; j++)
if (file_data->profile_info.runs)
{
int scale = GCOV_COMPUTE_SCALE (max_runs,
file_data->profile_info.runs);
lto_gcov_summary.sum_max
= MAX (lto_gcov_summary.sum_max,
apply_scale (file_data->profile_info.sum_max, scale));
lto_gcov_summary.sum_all
= MAX (lto_gcov_summary.sum_all,
apply_scale (file_data->profile_info.sum_all, scale));
/* Save a pointer to the profile_info with the largest
scaled sum_all and the scale for use in merging the
histogram. */
if (!saved_profile_info
|| lto_gcov_summary.sum_all > saved_sum_all)
{
saved_profile_info = &file_data->profile_info;
saved_sum_all = lto_gcov_summary.sum_all;
saved_scale = scale;
}
}
gcc_assert (saved_profile_info);
/* Scale up the histogram from the profile that had the largest
scaled sum_all above. */
for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
{
/* Scale up the min value as we did the corresponding sum_all
above. Use that to find the new histogram index. */
gcov_type scaled_min
= apply_scale (saved_profile_info->histogram[h_ix].min_value,
saved_scale);
/* The new index may be shared with another scaled histogram entry,
so we need to account for a non-zero histogram entry at new_ix. */
unsigned new_ix = gcov_histo_index (scaled_min);
lto_gcov_summary.histogram[new_ix].min_value
= (lto_gcov_summary.histogram[new_ix].num_counters
? MIN (lto_gcov_summary.histogram[new_ix].min_value, scaled_min)
: scaled_min);
/* Some of the scaled counter values would ostensibly need to be placed
into different (larger) histogram buckets, but we keep things simple
here and place the scaled cumulative counter value in the bucket
corresponding to the scaled minimum counter value. */
lto_gcov_summary.histogram[new_ix].cum_value
+= apply_scale (saved_profile_info->histogram[h_ix].cum_value,
saved_scale);
lto_gcov_summary.histogram[new_ix].num_counters
+= saved_profile_info->histogram[h_ix].num_counters;
}
/* Watch roundoff errors. */
if (lto_gcov_summary.sum_max < max_runs)
lto_gcov_summary.sum_max = max_runs;
/* If merging already happent at WPA time, we are done. */
if (flag_ltrans)
return;
/* Now compute <API key> of each node.
During LTRANS we already have values of <API key>
computed, so just update them. */
FOR_EACH_FUNCTION (node)
if (node->lto_file_data
&& node->lto_file_data->profile_info.runs)
{
int scale;
scale = RDIV (node-><API key> * max_runs,
node->lto_file_data->profile_info.runs);
node-><API key> = scale;
if (scale < 0)
fatal_error ("Profile information in %s corrupted",
file_data->file_name);
if (scale == REG_BR_PROB_BASE)
continue;
for (edge = node->callees; edge; edge = edge->next_callee)
edge->count = apply_scale (edge->count, scale);
node->count = apply_scale (node->count, scale);
}
}
/* Input and merge the symtab from each of the .o files passed to
lto1. */
void
input_symtab (void)
{
struct lto_file_decl_data **file_data_vec = <API key> ();
struct lto_file_decl_data *file_data;
unsigned int j = 0;
struct cgraph_node *node;
while ((file_data = file_data_vec[j++]))
{
const char *data;
size_t len;
struct lto_input_block *ib;
vec<symtab_node *> nodes;
ib = <API key> (file_data, <API key>,
&data, &len);
if (!ib)
fatal_error ("cannot find LTO cgraph in %s", file_data->file_name);
<API key> (ib, file_data);
file_data->symtab_node_encoder = <API key> (true);
nodes = input_cgraph_1 (file_data, ib);
<API key> (file_data, <API key>,
ib, data, len);
ib = <API key> (file_data, LTO_section_refs,
&data, &len);
if (!ib)
fatal_error ("cannot find LTO section refs in %s",
file_data->file_name);
input_refs (ib, nodes);
<API key> (file_data, LTO_section_refs,
ib, data, len);
if (flag_ltrans)
<API key> (nodes);
nodes.release ();
}
<API key> (file_data_vec);
get_working_sets ();
/* Clear out the aux field that was used to store enough state to
tell which nodes should be overwritten. */
FOR_EACH_FUNCTION (node)
{
if (node->lto_file_data)
node->aux = NULL;
}
}
/* Input function/variable tables that will allow libgomp to look up offload
target code, and store them into OFFLOAD_FUNCS and OFFLOAD_VARS. */
void
<API key> (void)
{
struct lto_file_decl_data **file_data_vec = <API key> ();
struct lto_file_decl_data *file_data;
unsigned int j = 0;
while ((file_data = file_data_vec[j++]))
{
const char *data;
size_t len;
struct lto_input_block *ib
= <API key> (file_data, <API key>,
&data, &len);
if (!ib)
continue;
enum LTO_symtab_tags tag
= streamer_read_enum (ib, LTO_symtab_tags, LTO_symtab_last_tag);
while (tag)
{
if (tag == <API key>)
{
int decl_index = streamer_read_uhwi (ib);
tree fn_decl
= <API key> (file_data, decl_index);
vec_safe_push (offload_funcs, fn_decl);
}
else if (tag == LTO_symtab_variable)
{
int decl_index = streamer_read_uhwi (ib);
tree var_decl
= <API key> (file_data, decl_index);
vec_safe_push (offload_vars, var_decl);
}
else
fatal_error ("invalid offload table in %s", file_data->file_name);
tag = streamer_read_enum (ib, LTO_symtab_tags, LTO_symtab_last_tag);
}
<API key> (file_data, <API key>,
ib, data, len);
}
}
/* True when we need optimization summary for NODE. */
static int
<API key> (struct cgraph_node *node)
{
return (node->clone_of
&& (node->clone.tree_map
|| node->clone.args_to_skip
|| node->clone.<API key>));
}
/* Output optimization summary for EDGE to OB. */
static void
<API key> (struct output_block *ob ATTRIBUTE_UNUSED,
struct cgraph_edge *edge ATTRIBUTE_UNUSED)
{
}
/* Output optimization summary for NODE to OB. */
static void
<API key> (struct output_block *ob,
struct cgraph_node *node,
<API key> encoder)
{
unsigned int index;
bitmap_iterator bi;
struct ipa_replace_map *map;
struct bitpack_d bp;
int i;
struct cgraph_edge *e;
if (node->clone.args_to_skip)
{
streamer_write_uhwi (ob, bitmap_count_bits (node->clone.args_to_skip));
<API key> (node->clone.args_to_skip, 0, index, bi)
streamer_write_uhwi (ob, index);
}
else
streamer_write_uhwi (ob, 0);
if (node->clone.<API key>)
{
streamer_write_uhwi (ob, bitmap_count_bits (node->clone.<API key>));
<API key> (node->clone.<API key>, 0, index, bi)
streamer_write_uhwi (ob, index);
}
else
streamer_write_uhwi (ob, 0);
streamer_write_uhwi (ob, vec_safe_length (node->clone.tree_map));
<API key> (node->clone.tree_map, i, map)
{
/* At the moment we assume all old trees to be PARM_DECLs, because we have no
mechanism to store function local declarations into summaries. */
gcc_assert (!map->old_tree);
streamer_write_uhwi (ob, map->parm_num);
gcc_assert (EXPR_LOCATION (map->new_tree) == UNKNOWN_LOCATION);
stream_write_tree (ob, map->new_tree, true);
bp = bitpack_create (ob->main_stream);
bp_pack_value (&bp, map->replace_p, 1);
bp_pack_value (&bp, map->ref_p, 1);
<API key> (&bp);
}
if (<API key> (encoder, node))
{
for (e = node->callees; e; e = e->next_callee)
<API key> (ob, e);
for (e = node->indirect_calls; e; e = e->next_callee)
<API key> (ob, e);
}
}
/* Output optimization summaries stored in callgraph.
At the moment it is the clone info structure. */
static void
<API key> (void)
{
int i, n_nodes;
<API key> encoder;
struct output_block *ob = create_output_block (<API key>);
unsigned count = 0;
ob->symbol = NULL;
encoder = ob->decl_state->symtab_node_encoder;
n_nodes = <API key> (encoder);
for (i = 0; i < n_nodes; i++)
{
symtab_node *node = <API key> (encoder, i);
cgraph_node *cnode = dyn_cast <cgraph_node *> (node);
if (cnode && <API key> (cnode))
count++;
}
streamer_write_uhwi (ob, count);
for (i = 0; i < n_nodes; i++)
{
symtab_node *node = <API key> (encoder, i);
cgraph_node *cnode = dyn_cast <cgraph_node *> (node);
if (cnode && <API key> (cnode))
{
streamer_write_uhwi (ob, i);
<API key> (ob, cnode, encoder);
}
}
produce_asm (ob, NULL);
<API key> (ob);
}
/* Input optimisation summary of EDGE. */
static void
<API key> (struct cgraph_edge *edge ATTRIBUTE_UNUSED,
struct lto_input_block *ib_main ATTRIBUTE_UNUSED)
{
}
/* Input optimisation summary of NODE. */
static void
<API key> (struct cgraph_node *node,
struct lto_input_block *ib_main,
struct data_in *data_in)
{
int i;
int count;
int bit;
struct bitpack_d bp;
struct cgraph_edge *e;
count = streamer_read_uhwi (ib_main);
if (count)
node->clone.args_to_skip = BITMAP_GGC_ALLOC ();
for (i = 0; i < count; i++)
{
bit = streamer_read_uhwi (ib_main);
bitmap_set_bit (node->clone.args_to_skip, bit);
}
count = streamer_read_uhwi (ib_main);
if (count)
node->clone.<API key> = BITMAP_GGC_ALLOC ();
for (i = 0; i < count; i++)
{
bit = streamer_read_uhwi (ib_main);
bitmap_set_bit (node->clone.<API key>, bit);
}
count = streamer_read_uhwi (ib_main);
for (i = 0; i < count; i++)
{
struct ipa_replace_map *map = ggc_alloc<ipa_replace_map> ();
vec_safe_push (node->clone.tree_map, map);
map->parm_num = streamer_read_uhwi (ib_main);
map->old_tree = NULL;
map->new_tree = stream_read_tree (ib_main, data_in);
bp = <API key> (ib_main);
map->replace_p = bp_unpack_value (&bp, 1);
map->ref_p = bp_unpack_value (&bp, 1);
}
for (e = node->callees; e; e = e->next_callee)
<API key> (e, ib_main);
for (e = node->indirect_calls; e; e = e->next_callee)
<API key> (e, ib_main);
}
/* Read section in file FILE_DATA of length LEN with data DATA. */
static void
<API key> (struct lto_file_decl_data *file_data,
const char *data, size_t len,
vec<symtab_node *> nodes)
{
const struct lto_function_header *header =
(const struct lto_function_header *) data;
const int cfg_offset = sizeof (struct lto_function_header);
const int main_offset = cfg_offset + header->cfg_size;
const int string_offset = main_offset + header->main_size;
struct data_in *data_in;
unsigned int i;
unsigned int count;
lto_input_block ib_main ((const char *) data + main_offset,
header->main_size);
data_in =
lto_data_in_create (file_data, (const char *) data + string_offset,
header->string_size, vNULL);
count = streamer_read_uhwi (&ib_main);
for (i = 0; i < count; i++)
{
int ref = streamer_read_uhwi (&ib_main);
<API key> (dyn_cast<cgraph_node *> (nodes[ref]),
&ib_main, data_in);
}
<API key> (file_data, <API key>, NULL, data,
len);
lto_data_in_delete (data_in);
}
/* Input optimization summary of cgraph. */
static void
<API key> (vec<symtab_node *> nodes)
{
struct lto_file_decl_data **file_data_vec = <API key> ();
struct lto_file_decl_data *file_data;
unsigned int j = 0;
while ((file_data = file_data_vec[j++]))
{
size_t len;
const char *data =
<API key> (file_data, <API key>, NULL,
&len);
if (data)
<API key> (file_data, data, len, nodes);
}
} |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Class <API key> | Mi proyecto</title>
<link rel="stylesheet" href="resources/style.css?<SHA1-like>">
</head>
<body>
<div id="left">
<div id="menu">
<a href="index.html" title="Overview"><span>Overview</span></a>
<div id="groups">
</div>
<div id="elements">
<h3>Classes</h3>
<ul>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">bitacoraTableClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">ciudadTableClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">controlTableClass</a></li>
<li><a href="<API key>.html" class="invalid">createActionClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html" class="invalid"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html" class="invalid">deleteActionClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html" class="invalid"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html" class="invalid"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">deptoBaseTableClass</a></li>
<li><a href="<API key>.html">deptoTableClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html" class="invalid">editActionClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">editProvActionClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">empleadoTableClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">entradaTableClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">estadoTableClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">hojaVidaTableClass</a></li>
<li><a href="<API key>.html" class="invalid">indexActionClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html" class="invalid">insertActionClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">insumoTableClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">loginActionClass</a></li>
<li><a href="<API key>.html">logoutActionClass</a></li>
<li><a href="<API key>.html">loteBaseTableClass</a></li>
<li><a href="<API key>.html">loteTableClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">partoBaseTableClass</a></li>
<li><a href="<API key>.html">partoTableClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">proveedorTableClass</a></li>
<li><a href="<API key>.html">razaBaseTableClass</a></li>
<li><a href="<API key>.html">razaTableClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html" class="invalid">reportActionClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li class="active"><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">tipodocTableClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">tipoIdTableClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">tipovBaseTableClass</a></li>
<li><a href="<API key>.html">tipovTableClass</a></li>
<li><a href="<API key>.html" class="invalid"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html" class="invalid">updateActionClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">usuarioTableClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html" class="invalid">verActionClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">verDeptoActionClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">verProvActionClass</a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html"><API key></a></li>
<li><a href="<API key>.html">verTipovActionClass</a></li>
</ul>
</div>
</div>
</div>
<div id="splitter"></div>
<div id="right">
<div id="rightInner">
<form id="search">
<input type="hidden" name="cx" value="">
<input type="hidden" name="ie" value="UTF-8">
<input type="text" name="q" class="text" placeholder="Search">
</form>
<div id="navigation">
<ul>
<li>
<a href="index.html" title="Overview"><span>Overview</span></a>
</li>
<li class="active">
<span>Class</span> </li>
</ul>
<ul>
</ul>
<ul>
</ul>
</div>
<div id="content" class="class">
<h1>Class <API key></h1>
<dl class="tree">
<dd style="padding-left:0px">
mvc\controller\controllerClass
</dd>
<dd style="padding-left:30px">
<img src="resources/inherit.png" alt="Extended by">
<b><span><API key></span></b>
implements
<span>mvc\interfaces\<API key></span>
</dd>
</dl>
<div class="info">
<b>Located at</b> <a href="<API key>.html#16-37" title="Go to source code">depto/<API key>.php</a>
<br>
</div>
<table class="summary methods" id="methods">
<caption>Methods summary</caption>
<tr data-order="execute" id="_execute">
<td class="attributes"><code>
public
</code>
</td>
<td class="name"><div>
<a class="anchor" href="#_execute">#</a>
<code><a href="<API key>.html#18-35" title="Go to source code">execute</a>( )</code>
<div class="description short">
</div>
<div class="description detailed hidden">
</div>
</div></td>
</tr>
</table>
</div>
<div id="footer">
Mi proyecto API documentation generated by <a href="http://apigen.org">ApiGen</a>
</div>
</div>
</div>
<script src="resources/combined.js"></script>
<script src="elementlist.js"></script>
</body>
</html> |
#include "Common.h"
#include "PlayerDump.h"
#include "DatabaseEnv.h"
#include "UpdateFields.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "AccountMgr.h"
#include "CharacterCache.h"
#include "World.h"
#define DUMP_TABLE_COUNT 32
struct DumpTable
{
char const* name;
DumpTableType type;
};
DumpTable const dumpTables[DUMP_TABLE_COUNT] =
{
{ "characters", DTT_CHARACTER },
{ "<API key>", DTT_CHAR_TABLE },
{ "<API key>", DTT_CHAR_TABLE },
{ "<API key>", DTT_CHAR_TABLE },
{ "character_action", DTT_CHAR_TABLE },
{ "character_aura", DTT_CHAR_TABLE },
{ "<API key>", DTT_CHAR_TABLE },
{ "<API key>", DTT_EQSET_TABLE},
{ "<API key>", DTT_CHAR_TABLE },
{ "character_glyphs", DTT_CHAR_TABLE },
{ "character_homebind", DTT_CHAR_TABLE },
{ "character_inventory", DTT_INVENTORY },
{ "character_pet", DTT_PET },
{ "<API key>", DTT_PET },
{ "<API key>", DTT_CHAR_TABLE },
{ "<API key>", DTT_CHAR_TABLE },
{ "<API key>", DTT_CHAR_TABLE },
{ "<API key>", DTT_CHAR_TABLE },
{ "<API key>", DTT_CHAR_TABLE },
{ "<API key>", DTT_CHAR_TABLE },
{ "<API key>", DTT_CHAR_TABLE },
{ "character_skills", DTT_CHAR_TABLE },
{ "character_spell", DTT_CHAR_TABLE },
{ "<API key>", DTT_CHAR_TABLE },
{ "character_talent", DTT_CHAR_TABLE },
{ "mail", DTT_MAIL },
{ "mail_items", DTT_MAIL_ITEM }, // must be after mail
{ "pet_aura", DTT_PET_TABLE }, // must be after character_pet
{ "pet_spell", DTT_PET_TABLE }, // must be after character_pet
{ "pet_spell_cooldown", DTT_PET_TABLE }, // must be after character_pet
{ "item_instance", DTT_ITEM }, // must be after character_inventory and mail_items
{ "character_gifts", DTT_ITEM_GIFT }, // must be after item_instance
};
// Low level functions
static bool FindTokNth(std::string const& str, uint32 n, std::string::size_type& s, std::string::size_type& e)
{
s = e = 0;
uint32 i = 1;
for (; s < str.size() && i < n; ++s)
if (str[s] == ' ')
++i;
if (i < n)
return false;
e = str.find(' ', s);
return e != std::string::npos;
}
std::string GetTokNth(std::string const& str, uint32 n)
{
std::string::size_type s = 0, e = 0;
if (!FindTokNth(str, n, s, e))
return "";
return str.substr(s, e - s);
}
bool FindNth(std::string const& str, uint32 n, std::string::size_type& s, std::string::size_type& e)
{
s = str.find("VALUES ('") + 9;
if (s == std::string::npos)
return false;
do
{
e = str.find('\'', s);
if (e == std::string::npos)
return false;
} while (str[e - 1] == '\\');
for (uint32 i = 1; i < n; ++i)
{
do
{
s = e + 4;
e = str.find('\'', s);
if (e == std::string::npos)
return false;
} while (str[e - 1] == '\\');
}
return true;
}
std::string GetTableName(std::string const& str)
{
static std::string::size_type const s = 13;
std::string::size_type e = str.find(_TABLE_SIM_, s);
if (e == std::string::npos)
return "";
return str.substr(s, e - s);
}
bool ChangeNth(std::string& str, uint32 n, char const* with, bool insert = false, bool allowZero = false)
{
std::string::size_type s, e;
if (!FindNth(str, n, s, e))
return false;
if (allowZero && str.substr(s, e - s) == "0")
return true; // not an error
if (!insert)
str.replace(s, e - s, with);
else
str.insert(s, with);
return true;
}
std::string GetNth(std::string& str, uint32 n)
{
std::string::size_type s, e;
if (!FindNth(str, n, s, e))
return "";
return str.substr(s, e-s);
}
bool ChangeTokNth(std::string& str, uint32 n, char const* with, bool insert = false, bool allowZero = false)
{
std::string::size_type s = 0, e = 0;
if (!FindTokNth(str, n, s, e))
return false;
if (allowZero && str.substr(s, e - s) == "0")
return true; // not an error
if (!insert)
str.replace(s, e-s, with);
else
str.insert(s, with);
return true;
}
ObjectGuid::LowType RegisterNewGuid(ObjectGuid::LowType oldGuid, PlayerDump::DumpGuidMap& guidMap, ObjectGuid::LowType guidOffset)
{
PlayerDumpWriter::DumpGuidMap::const_iterator itr = guidMap.find(oldGuid);
if (itr != guidMap.end())
return itr->second;
ObjectGuid::LowType newguid = guidOffset + guidMap.size();
guidMap[oldGuid] = newguid;
return newguid;
}
bool ChangeGuid(std::string& str, uint32 n, PlayerDump::DumpGuidMap& guidMap, ObjectGuid::LowType guidOffset, bool allowZero = false)
{
ObjectGuid::LowType oldGuid = strtoull(GetNth(str, n).c_str(), nullptr, 10);
if (allowZero && !oldGuid)
return true; // not an error
char chritem[20];
ObjectGuid::LowType newGuid = RegisterNewGuid(oldGuid, guidMap, guidOffset);
snprintf(chritem, 20, "%u", newGuid);
return ChangeNth(str, n, chritem, false, allowZero);
}
std::string CreateDumpString(char const* tableName, QueryResult result)
{
if (!tableName || !result) return "";
std::ostringstream ss;
ss << "INSERT INTO " << _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES (";
Field* fields = result->Fetch();
for (uint32 i = 0; i < result->GetFieldCount(); ++i)
{
if (i == 0) ss << '\'';
else ss << ", '";
std::string s = fields[i].GetString();
CharacterDatabase.EscapeString(s);
ss << s;
ss << '\'';
}
ss << ");";
return ss.str();
}
std::string PlayerDumpWriter::GenerateWhereStr(char const* field, ObjectGuid::LowType guid)
{
std::ostringstream wherestr;
wherestr << field << " = '" << guid << '\'';
return wherestr.str();
}
std::string PlayerDumpWriter::GenerateWhereStr(char const* field, DumpGuidSet const& guids, DumpGuidSet::const_iterator& itr)
{
std::ostringstream wherestr;
wherestr << field << " IN ('";
for (; itr != guids.end();)
{
wherestr << *itr;
++itr;
if (wherestr.str().size() > MAX_QUERY_LEN - 50) // near to max query
break;
if (itr != guids.end())
wherestr << "', '";
}
wherestr << "')";
return wherestr.str();
}
void StoreGUID(QueryResult result, uint32 field, PlayerDump::DumpGuidSet &guids)
{
Field* fields = result->Fetch();
ObjectGuid::LowType guid = fields[field].GetUInt32();
if (guid)
guids.insert(guid);
}
void StoreGUID(QueryResult result, uint32 data, uint32 field, PlayerDump::DumpGuidSet& guids)
{
Field* fields = result->Fetch();
std::string dataStr = fields[data].GetString();
ObjectGuid::LowType guid = strtoull(GetTokNth(dataStr, field).c_str(), nullptr, 10);
if (guid)
guids.insert(guid);
}
// Writing - High-level functions
bool PlayerDumpWriter::DumpTable(std::string& dump, ObjectGuid::LowType guid, char const* tableFrom, char const* tableTo, DumpTableType type)
{
DumpGuidSet const* guids = nullptr;
char const* fieldname = nullptr;
switch (type)
{
case DTT_ITEM: fieldname = "guid"; guids = &items; break;
case DTT_ITEM_GIFT: fieldname = "item_guid"; guids = &items; break;
case DTT_PET: fieldname = "owner"; break;
case DTT_PET_TABLE: fieldname = "guid"; guids = &pets; break;
case DTT_MAIL: fieldname = "receiver"; break;
case DTT_MAIL_ITEM: fieldname = "mail_id"; guids = &mails; break;
default: fieldname = "guid"; break;
}
// for guid set stop if set is empty
if (guids && guids->empty())
return true; // nothing to do
// setup for guids case start position
DumpGuidSet::const_iterator guidsItr;
if (guids)
guidsItr = guids->begin();
do
{
std::string wherestr;
if (guids) // set case, get next guids string
wherestr = GenerateWhereStr(fieldname, *guids, guidsItr);
else // not set case, get single guid string
wherestr = GenerateWhereStr(fieldname, guid);
QueryResult result = CharacterDatabase.PQuery("SELECT * FROM %s WHERE %s", tableFrom, wherestr.c_str());
if (!result)
return true;
do
{
// collect guids
switch (type)
{
case DTT_INVENTORY:
StoreGUID(result, 3, items); // item guid collection (character_inventory.item)
break;
case DTT_PET:
StoreGUID(result, 0, pets); // pet petnumber collection (character_pet.id)
break;
case DTT_MAIL:
StoreGUID(result, 0, mails); // mail id collection (mail.id)
break;
case DTT_MAIL_ITEM:
StoreGUID(result, 1, items); // item guid collection (mail_items.item_guid)
break;
case DTT_CHARACTER:
{
if (result->GetFieldCount() <= 73) // avoid crashes on next check
TC_LOG_FATAL("misc", "PlayerDumpWriter::DumpTable - Trying to access non-existing or wrong positioned field (`deleteInfos_Account`) in `characters` table.");
if (result->Fetch()[73].GetUInt32()) // characters.deleteInfos_Account - if filled error
return false;
break;
}
default:
break;
}
dump += CreateDumpString(tableTo, result);
dump += "\n";
}
while (result->NextRow());
}
while (guids && guidsItr != guids->end()); // not set case iterate single time, set case iterate for all guids
return true;
}
bool PlayerDumpWriter::GetDump(ObjectGuid::LowType guid, std::string &dump)
{
dump = "IMPORTANT NOTE: THIS DUMPFILE IS MADE FOR USE WITH THE 'PDUMP' COMMAND ONLY - EITHER THROUGH INGAME CHAT OR ON CONSOLE!\n";
dump += "IMPORTANT NOTE: DO NOT apply it directly - it will irreversibly DAMAGE and CORRUPT your database! You have been warned!\n\n";
for (uint8 i = 0; i < DUMP_TABLE_COUNT; ++i)
if (!DumpTable(dump, guid, dumpTables[i].name, dumpTables[i].name, dumpTables[i].type))
return false;
@todo Add instance/group..
@todo Add a dump level option to skip some non-important tables
return true;
}
DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, ObjectGuid::LowType guid)
{
if (sWorld->getBoolConfig(<API key>))
if (strstr(file.c_str(), "\\") || strstr(file.c_str(), "/"))
return <API key>;
if (sWorld->getBoolConfig(<API key>))
if (FILE* f = fopen(file.c_str(), "r"))
{
fclose(f);
return <API key>;
}
FILE* fout = fopen(file.c_str(), "w");
if (!fout)
return <API key>;
DumpReturn ret = DUMP_SUCCESS;
std::string dump;
if (!GetDump(guid, dump))
ret = <API key>;
fprintf(fout, "%s\n", dump.c_str());
fclose(fout);
return ret;
}
// Reading - High-level functions
#define ROLLBACK(DR) {fclose(fin); return (DR);}
void fixNULLfields(std::string& line)
{
static std::string const nullString("'NULL'");
size_t pos = line.find(nullString);
while (pos != std::string::npos)
{
line.replace(pos, nullString.length(), "NULL");
pos = line.find(nullString);
}
}
DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, std::string name, ObjectGuid::LowType guid)
{
uint32 charcount = AccountMgr::GetCharactersCount(account);
if (charcount >= 10)
return DUMP_TOO_MANY_CHARS;
FILE* fin = fopen(file.c_str(), "r");
if (!fin)
return <API key>;
char newguid[20], chraccount[20];
// make sure the same guid doesn't already exist and is safe to use
bool incHighest = true;
if (guid && guid < sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed())
{
PreparedStatement* stmt = CharacterDatabase.<API key>(CHAR_SEL_CHECK_GUID);
stmt->setUInt32(0, guid);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
guid = sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed(); // use first free if exists
else
incHighest = false;
}
else
guid = sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed();
// normalize the name if specified and check if it exists
if (!normalizePlayerName(name))
name.clear();
if (ObjectMgr::CheckPlayerName(name, sWorld->GetDefaultDbcLocale(), true) == CHAR_NAME_SUCCESS)
{
PreparedStatement* stmt = CharacterDatabase.<API key>(CHAR_SEL_CHECK_NAME);
stmt->setString(0, name);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
name.clear(); // use the one from the dump
}
else
name.clear();
// name encoded or empty
snprintf(newguid, 20, "%u", guid);
snprintf(chraccount, 20, "%u", account);
DumpGuidMap items;
DumpGuidMap mails;
char buf[32000];
memset(buf, 0, sizeof(buf));
typedef std::map<uint32 /*old*/, uint32 /*new*/> PetIds;
PetIds petIds;
uint8 gender = GENDER_NONE;
uint8 race = RACE_NONE;
uint8 playerClass = 0;
uint8 level = 1;
ObjectGuid::LowType itemLowGuidOffset = sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed();
SQLTransaction trans = CharacterDatabase.BeginTransaction();
while (!feof(fin))
{
if (!fgets(buf, 32000, fin))
{
if (feof(fin))
break;
ROLLBACK(DUMP_FILE_BROKEN);
}
std::string line; line.assign(buf);
// skip empty strings
size_t nw_pos = line.find_first_not_of(" \t\n\r\7");
if (nw_pos == std::string::npos)
continue;
// skip logfile-side dump start notice, the important notes and dump end notices
if ((line.substr(nw_pos, 16) == "== START DUMP ==") ||
(line.substr(nw_pos, 15) == "IMPORTANT NOTE:") ||
(line.substr(nw_pos, 14) == "== END DUMP =="))
continue;
// add required_ check
/*
if (line.substr(nw_pos, 41) == "UPDATE <API key> SET required_")
{
if (!CharacterDatabase.Execute(line.c_str()))
ROLLBACK(DUMP_FILE_BROKEN);
continue;
}
*/
// determine table name and load type
std::string tn = GetTableName(line);
if (tn.empty())
{
TC_LOG_ERROR("misc", "LoadPlayerDump: Can't extract table name from line: '%s'!", line.c_str());
ROLLBACK(DUMP_FILE_BROKEN);
}
DumpTableType type = DumpTableType(0);
uint8 i;
for (i = 0; i < DUMP_TABLE_COUNT; ++i)
{
if (tn == dumpTables[i].name)
{
type = dumpTables[i].type;
break;
}
}
if (i == DUMP_TABLE_COUNT)
{
TC_LOG_ERROR("misc", "LoadPlayerDump: Unknown table: '%s'!", tn.c_str());
ROLLBACK(DUMP_FILE_BROKEN);
}
// change the data to server values
switch (type)
{
case DTT_CHARACTER:
{
if (!ChangeNth(line, 1, newguid)) // characters.guid update
ROLLBACK(DUMP_FILE_BROKEN);
if (!ChangeNth(line, 2, chraccount)) // characters.account update
ROLLBACK(DUMP_FILE_BROKEN);
race = uint8(atoul(GetNth(line, 4).c_str()));
playerClass = uint8(atoul(GetNth(line, 5).c_str()));
gender = uint8(atoul(GetNth(line, 6).c_str()));
level = uint8(atoul(GetNth(line, 7).c_str()));
if (name.empty())
{
// check if the original name already exists
name = GetNth(line, 3);
PreparedStatement* stmt = CharacterDatabase.<API key>(CHAR_SEL_CHECK_NAME);
stmt->setString(0, name);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
if (!ChangeNth(line, 37, "1")) // characters.at_login set to "rename on login"
ROLLBACK(DUMP_FILE_BROKEN);
}
else if (!ChangeNth(line, 3, name.c_str())) // characters.name
ROLLBACK(DUMP_FILE_BROKEN);
const char null[5] = "NULL";
if (!ChangeNth(line, 74, null)) // characters.deleteInfos_Account
ROLLBACK(DUMP_FILE_BROKEN);
if (!ChangeNth(line, 75, null)) // characters.deleteInfos_Name
ROLLBACK(DUMP_FILE_BROKEN);
if (!ChangeNth(line, 76, null)) // characters.deleteDate
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_CHAR_TABLE:
{
if (!ChangeNth(line, 1, newguid)) // character_*.guid update
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_EQSET_TABLE:
{
if (!ChangeNth(line, 1, newguid))
ROLLBACK(DUMP_FILE_BROKEN); // <API key>.guid
char newSetGuid[24];
snprintf(newSetGuid, 24, UI64FMTD, sObjectMgr-><API key>());
if (!ChangeNth(line, 2, newSetGuid))
ROLLBACK(DUMP_FILE_BROKEN); // <API key>.setguid
for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; ++slot)
if (!ChangeGuid(line, 7 + slot, items, itemLowGuidOffset, true))
ROLLBACK(DUMP_FILE_BROKEN); // <API key>.item
break;
}
case DTT_INVENTORY:
{
if (!ChangeNth(line, 1, newguid)) // character_inventory.guid update
ROLLBACK(DUMP_FILE_BROKEN);
if (!ChangeGuid(line, 2, items, itemLowGuidOffset, true))
ROLLBACK(DUMP_FILE_BROKEN); // character_inventory.bag update
if (!ChangeGuid(line, 4, items, itemLowGuidOffset))
ROLLBACK(DUMP_FILE_BROKEN); // character_inventory.item update
break;
}
case DTT_MAIL: // mail
{
if (!ChangeGuid(line, 1, mails, sObjectMgr->_mailId))
ROLLBACK(DUMP_FILE_BROKEN); // mail.id update
if (!ChangeNth(line, 6, newguid)) // mail.receiver update
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_MAIL_ITEM: // mail_items
{
if (!ChangeGuid(line, 1, mails, sObjectMgr->_mailId))
ROLLBACK(DUMP_FILE_BROKEN); // mail_items.id
if (!ChangeGuid(line, 2, items, itemLowGuidOffset))
ROLLBACK(DUMP_FILE_BROKEN); // mail_items.item_guid
if (!ChangeNth(line, 3, newguid)) // mail_items.receiver
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_ITEM:
{
// item, owner, data field:item, owner guid
if (!ChangeGuid(line, 1, items, itemLowGuidOffset))
ROLLBACK(DUMP_FILE_BROKEN); // item_instance.guid update
if (!ChangeNth(line, 3, newguid)) // item_instance.owner_guid update
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_ITEM_GIFT:
{
if (!ChangeNth(line, 1, newguid)) // character_gifts.guid update
ROLLBACK(DUMP_FILE_BROKEN);
if (!ChangeGuid(line, 2, items, itemLowGuidOffset))
ROLLBACK(DUMP_FILE_BROKEN); // character_gifts.item_guid update
break;
}
case DTT_PET:
{
// store a map of old pet id to new inserted pet id for use by DTT_PET_TABLE tables
std::string petIdStr = GetNth(line, 1);
uint32 currentPetId = atoul(petIdStr.c_str());
PetIds::const_iterator petIdsItr = petIds.find(currentPetId);
if (petIdsItr != petIds.end()) // duplicate pets
ROLLBACK(DUMP_FILE_BROKEN);
uint32 newPetId = sObjectMgr->GeneratePetNumber();
petIds[currentPetId] = newPetId;
if (!ChangeNth(line, 1, std::to_string(newPetId).c_str())) // character_pet.id update
ROLLBACK(DUMP_FILE_BROKEN);
if (!ChangeNth(line, 3, newguid)) // character_pet.owner update
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_PET_TABLE: // pet_aura, pet_spell, pet_spell_cooldown
{
std::string petIdStr = GetNth(line, 1);
// lookup currpetid and match to new inserted pet id
PetIds::const_iterator petIdsItr = petIds.find(atoul(petIdStr.c_str()));
if (petIdsItr == petIds.end()) // couldn't find new inserted id
ROLLBACK(DUMP_FILE_BROKEN);
if (!ChangeNth(line, 1, std::to_string(petIdsItr->second).c_str()))
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
default:
TC_LOG_ERROR("misc", "Unknown dump table type: %u", type);
break;
}
fixNULLfields(line);
trans->Append(line.c_str());
}
CharacterDatabase.CommitTransaction(trans);
// in case of name conflict player has to rename at login anyway
sCharacterCache-><API key>(ObjectGuid(HighGuid::Player, guid), account, name, gender, race, playerClass, level);
sObjectMgr->GetGenerator<HighGuid::Item>().Set(sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed() + items.size());
sObjectMgr->_mailId += mails.size();
if (incHighest)
sObjectMgr->GetGenerator<HighGuid::Player>().Generate();
fclose(fin);
return DUMP_SUCCESS;
} |
<?php
function <API key>(){
include_once(ABSPATH . WPINC . '/feed.php');
$rss = fetch_feed('http://themes.tielabs.com/xml/themes.xml');
if ( !is_wp_error( $rss ) ){
return $rss->get_items();
}
return false;
}
# Custom Admin Bar Menus
function tie_admin_bar() {
global $wp_admin_bar;
if ( current_user_can( 'switch_themes' ) ){
$wp_admin_bar->add_menu( array(
'parent' => 0,
'id' => 'mpanel_page',
'title' => theme_name ,
'href' => admin_url( 'admin.php?page=panel')
) );
}
}
add_action( '<API key>', 'tie_admin_bar' );
# Register main Scripts and Styles
function tie_admin_register() {
wp_register_script( 'tie-admin-slider', <API key>() . '/panel/js/jquery.ui.slider.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-mouse', 'jquery-ui-sortable' ) , false , false );
wp_register_script( 'tie-admin-checkbox', <API key>() . '/panel/js/checkbox.min.js', array( 'jquery' ) , false , false );
wp_register_script( 'tie-admin-main', <API key>() . '/panel/js/tie.js', array( 'jquery' ) , false , false );
wp_register_script( '<API key>', <API key>() . '/panel/js/colorpicker.js', array( 'jquery' ) , false , false );
wp_register_script( 'tie-admin-eye', <API key>() . '/panel/js/eye.js', array( 'jquery' ) , false , false );
wp_register_script( 'tie-admin-utils', <API key>() . '/panel/js/utils.js', array( 'jquery' ) , false , false );
wp_register_script( 'tie-admin-layout', <API key>() . '/panel/js/layout.js', array( 'jquery' ) , false , false );
wp_register_style( 'tie-style', <API key>().'/panel/style.css', array(), '20120208', 'all' );
if ( isset( $_GET['page'] ) && $_GET['page'] == 'panel' ) {
wp_enqueue_script( '<API key>');
wp_enqueue_script( 'tie-admin-eye' );
wp_enqueue_script( 'tie-admin-utils' );
wp_enqueue_script( 'tie-admin-layout' );
wp_enqueue_script( 'tie-admin-slider' );
wp_enqueue_script( 'tie-admin-checkbox' );
}
wp_enqueue_script( 'tie-admin-main' );
wp_enqueue_style( 'tie-style' );
}
add_action( '<API key>', 'tie_admin_register' );
# To change Insert into Post Text
function tie_options_setup() {
global $pagenow;
if ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow )
add_filter( 'gettext', '<API key>' , 1, 3 );
}
add_action( 'admin_init', 'tie_options_setup' );
function <API key>($translated_text, $text, $domain) {
if ('Insert into Post' == $text) {
$referer = strpos( wp_get_referer(), 'tie-settings' );
if ( $referer != '' )
return __('Use this image', 'tie' );
}
return $translated_text;
}
# get Google Fonts
require ('google-fonts.php');
$google_font_array = json_decode ($google_api_output,true) ;
$items = $google_font_array['items'];
$options_fonts=array();
array_push($options_fonts, "Default Font");
$fontID = 0;
foreach ($items as $item) {
$fontID++;
$variants='';
$variantCount=0;
foreach ($item['variants'] as $variant) {
$variantCount++;
if ($variantCount>1) { $variants .= '|'; }
$variants .= $variant;
}
$variantText = ' (' . $variantCount . ' Varaints' . ')';
if ($variantCount <= 1) $variantText = '';
$options_fonts[ $item['family'] . ':' . $variants ] = $item['family']. $variantText;
}
# Clean options before store it in DB
function tie_clean_options(&$value) {
$value = htmlspecialchars(stripslashes($value));
}
# Options Array
$array_options =
array(
"tie_home_cats",
"tie_options"
);
# Save Theme Settings
function tie_save_settings ( $data , $refresh = 0 ) {
global $array_options ;
foreach( $array_options as $option ){
if( isset( $data[$option] )){
<API key>( $data[$option] , 'tie_clean_options');
update_option( $option , $data[$option] );
}
elseif( !isset( $data[$option] ) && $option != 'tie_options' ){
delete_option($option);
}
}
if( $refresh == 2 ) die('2');
elseif( $refresh == 1 ) die('1');
}
# Save Options
add_action('<API key>', 'tie_save_ajax');
function tie_save_ajax() {
check_ajax_referer('test-theme-data', 'security');
$data = $_POST;
$refresh = 1;
if( $data['tie_import'] ){
$refresh = 2;
$data = unserialize(base64_decode( $data['tie_import'] ));
}
tie_save_settings ($data , $refresh );
}
# Add Panel Page
function tie_add_admin() {
$current_page = isset( $_REQUEST['page'] ) ? $_REQUEST['page'] : '';
$icon = <API key>().'/panel/images/general.png';
add_menu_page(theme_name.' Settings', theme_name ,'install_themes', 'panel' , 'panel_options', $icon );
$theme_page = add_submenu_page('panel',theme_name.' Settings', theme_name.' Settings','install_themes', 'panel' , 'panel_options');
add_submenu_page('panel',theme_name.' Documentation', 'Documentation','install_themes', 'docs' , 'redirect_docs');
//add_submenu_page('panel','Support', 'Support','install_themes', 'support' , 'tie_get_support');
function tie_get_support(){
echo "<script type='text/javascript'>window.location='http://support.tielabs.com/';</script>";
}
function redirect_docs(){
global $docs_url;
echo "<script type='text/javascript'>window.location='".$docs_url."';</script>";
}
add_action( 'admin_head-'. $theme_page, 'tie_admin_head' );
function tie_admin_head(){
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
jQuery('.on-of').checkbox({empty:'<?php echo <API key>(); ?>/panel/images/empty.png'});
jQuery('form#tie_form').submit(function() {
var data = jQuery(this).serialize();
jQuery.post(ajaxurl, data, function(response) {
if(response == 1) {
jQuery('#save-alert').addClass('save-done');
t = setTimeout('fade_message()', 1000);
}
else if( response == 2 ){
location.reload();
}
else {
jQuery('#save-alert').addClass('save-error');
t = setTimeout('fade_message()', 1000);
}
});
return false;
});
});
function fade_message() {
jQuery('#save-alert').fadeOut(function() {
jQuery('#save-alert').removeClass('save-done');
});
clearTimeout(t);
}
jQuery(function() {
jQuery( "#cat_sortable" ).sortable({placeholder: "ui-state-highlight"});
jQuery( "#customList" ).sortable({placeholder: "ui-state-highlight"});
jQuery( "#tabs_cats" ).sortable({placeholder: "ui-state-highlight"});
});
</script>
<?php
wp_print_scripts('media-upload');
wp_enqueue_script('thickbox');
wp_enqueue_style('thickbox');
do_action('admin_print_styles');
}
if( isset( $_REQUEST['action'] ) ){
if( 'reset' == $_REQUEST['action'] && $current_page == 'panel' && check_admin_referer('reset-action-code' , 'resetnonce') ) {
global $default_data;
tie_save_settings( $default_data );
header("Location: admin.php?page=panel&reset=true");
die;
}
}
}
# Add Options
function tie_options($value){
global $options_fonts;
?>
<div class="option-item" id="<?php echo $value['id'] ?>-item">
<span class="label"><?php echo $value['name']; ?></span>
<?php
switch ( $value['type'] ) {
case 'text': ?>
<input name="tie_options[<?php echo $value['id']; ?>]" id="<?php echo $value['id']; ?>" type="text" value="<?php echo tie_get_option( $value['id'] ); ?>" />
<?php if( isset( $value['extra_text'] ) ) : ?><span class="extra-text"><?php echo $value['extra_text'] ?></span><?php endif; ?>
<?php
if( $value['id']=="slider_tag" || $value['id']=="breaking_tag"){
$tags = get_tags('orderby=count&order=desc&number=50'); ?>
<a style="cursor:pointer" title="Choose from the most used tags" onclick="toggleVisibility('<?php echo $value['id']; ?>_tags');"><img src="<?php echo <API key>(); ?>/panel/images/expand.png" alt="" /></a>
<span class="tags-list" id="<?php echo $value['id']; ?>_tags">
<?php foreach ($tags as $tag){?>
<a style="cursor:pointer" onclick="if(<?php echo $value['id'] ?>.value != ''){ var sep = ' , '}else{var sep = ''} <?php echo $value['id'] ?>.value=<?php echo $value['id'] ?>.value+sep+(this.rel);" rel="<?php echo $tag->name ?>"><?php echo $tag->name ?></a>
<?php } ?>
</span>
<?php } ?>
<?php
break;
case 'arrayText': $currentValue = tie_get_option( $value['id'] );?>
<input name="tie_options[<?php echo $value['id']; ?>][<?php echo $value['key']; ?>]" id="<?php echo $value['id']; ?>[<?php echo $value['key']; ?>]" type="text" value="<?php echo $currentValue[$value['key']] ?>" />
<?php
break;
case 'short-text': ?>
<input style="width:50px" name="tie_options[<?php echo $value['id']; ?>]" id="<?php echo $value['id']; ?>" type="text" value="<?php echo tie_get_option( $value['id'] ); ?>" />
<?php
break;
case 'checkbox':
if(tie_get_option($value['id'])){$checked = "checked=\"checked\""; } else{$checked = "";} ?>
<input class="on-of" type="checkbox" name="tie_options[<?php echo $value['id'] ?>]" id="<?php echo $value['id'] ?>" value="true" <?php echo $checked; ?> />
<?php
break;
case 'radio':
?>
<div style="float:left; width: 295px;">
<?php foreach ($value['options'] as $key => $option) { ?>
<label style="display:block; margin-bottom:8px;"><input name="tie_options[<?php echo $value['id']; ?>]" id="<?php echo $value['id']; ?>" type="radio" value="<?php echo $key ?>" <?php if ( tie_get_option( $value['id'] ) == $key) { echo ' checked="checked"' ; } ?>> <?php echo $option; ?></label>
<?php } ?>
</div>
<?php
break;
case 'select':
?>
<select name="tie_options[<?php echo $value['id']; ?>]" id="<?php echo $value['id']; ?>">
<?php foreach ($value['options'] as $key => $option) { ?>
<option value="<?php echo $key ?>" <?php if ( tie_get_option( $value['id'] ) == $key) { echo ' selected="selected"' ; } ?>><?php echo $option; ?></option>
<?php } ?>
</select>
<?php
break;
case 'textarea':
?>
<textarea style="direction:ltr; text-align:left" name="tie_options[<?php echo $value['id']; ?>]" id="<?php echo $value['id']; ?>" type="textarea" cols="100%" rows="3" tabindex="4"><?php echo tie_get_option( $value['id'] ); ?></textarea>
<?php
break;
case 'upload':
?>
<input id="<?php echo $value['id']; ?>" class="img-path" type="text" size="56" style="direction:ltr; text-laign:left" name="tie_options[<?php echo $value['id']; ?>]" value="<?php echo tie_get_option($value['id']); ?>" />
<input id="upload_<?php echo $value['id']; ?>_button" type="button" class="small_button" value="Upload" />
<div id="<?php echo $value['id']; ?>-preview" class="img-preview" <?php if(!tie_get_option( $value['id'] )) echo 'style="display:none;"' ?>>
<img src="<?php if(tie_get_option( $value['id'] )) echo tie_get_option( $value['id'] ); else echo <API key>().'/panel/images/spacer.png'; ?>" alt="" />
<a class="del-img" title="Delete"></a>
</div>
<?php
break;
case 'slider':
?>
<div id="<?php echo $value['id']; ?>-slider"></div>
<input type="text" id="<?php echo $value['id']; ?>" value="<?php echo tie_get_option($value['id']); ?>" name="tie_options[<?php echo $value['id']; ?>]" style="width:50px;" /> <?php echo $value['unit']; ?>
<script>
jQuery(document).ready(function() {
jQuery("#<?php echo $value['id']; ?>-slider").slider({
range: "min",
min: <?php echo $value['min']; ?>,
max: <?php echo $value['max']; ?>,
value: <?php if( tie_get_option($value['id']) ) echo tie_get_option($value['id']); else echo 0; ?>,
slide: function(event, ui) {
jQuery('#<?php echo $value['id']; ?>').attr('value', ui.value );
}
});
});
</script>
<?php
break;
case 'background':
$current_value = tie_get_option($value['id']);
?>
<input id="<?php echo $value['id']; ?>-img" class="img-path" type="text" size="56" style="direction:ltr; text-align:left" name="tie_options[<?php echo $value['id']; ?>][img]" value="<?php echo $current_value['img']; ?>" />
<input id="upload_<?php echo $value['id']; ?>_button" type="button" class="small_button" value="Upload" />
<div style="margin-top:15px; clear:both">
<div id="<?php echo $value['id']; ?>colorSelector" class="color-pic"><div style="background-color:<?php echo $current_value['color'] ; ?>"></div></div>
<input style="width:80px; margin-right:5px;" name="tie_options[<?php echo $value['id']; ?>][color]" id="<?php echo $value['id']; ?>color" type="text" value="<?php echo $current_value['color'] ; ?>" />
<select name="tie_options[<?php echo $value['id']; ?>][repeat]" id="<?php echo $value['id']; ?>[repeat]" style="width:96px;">
<option value="" <?php if ( !$current_value['repeat'] ) { echo ' selected="selected"' ; } ?>></option>
<option value="repeat" <?php if ( $current_value['repeat'] == 'repeat' ) { echo ' selected="selected"' ; } ?>>repeat</option>
<option value="no-repeat" <?php if ( $current_value['repeat'] == 'no-repeat') { echo ' selected="selected"' ; } ?>>no-repeat</option>
<option value="repeat-x" <?php if ( $current_value['repeat'] == 'repeat-x') { echo ' selected="selected"' ; } ?>>repeat-x</option>
<option value="repeat-y" <?php if ( $current_value['repeat'] == 'repeat-y') { echo ' selected="selected"' ; } ?>>repeat-y</option>
</select>
<select name="tie_options[<?php echo $value['id']; ?>][attachment]" id="<?php echo $value['id']; ?>[attachment]" style="width:96px;">
<option value="" <?php if ( !$current_value['attachment'] ) { echo ' selected="selected"' ; } ?>></option>
<option value="fixed" <?php if ( $current_value['attachment'] == 'fixed' ) { echo ' selected="selected"' ; } ?>>Fixed</option>
<option value="scroll" <?php if ( $current_value['attachment'] == 'scroll') { echo ' selected="selected"' ; } ?>>scroll</option>
</select>
<select name="tie_options[<?php echo $value['id']; ?>][hor]" id="<?php echo $value['id']; ?>[hor]" style="width:96px;">
<option value="" <?php if ( !$current_value['hor'] ) { echo ' selected="selected"' ; } ?>></option>
<option value="left" <?php if ( $current_value['hor'] == 'left' ) { echo ' selected="selected"' ; } ?>>Left</option>
<option value="right" <?php if ( $current_value['hor'] == 'right') { echo ' selected="selected"' ; } ?>>Right</option>
<option value="center" <?php if ( $current_value['hor'] == 'center') { echo ' selected="selected"' ; } ?>>Center</option>
</select>
<select name="tie_options[<?php echo $value['id']; ?>][ver]" id="<?php echo $value['id']; ?>[ver]" style="width:100px;">
<option value="" <?php if ( !$current_value['ver'] ) { echo ' selected="selected"' ; } ?>></option>
<option value="top" <?php if ( $current_value['ver'] == 'top' ) { echo ' selected="selected"' ; } ?>>Top</option>
<option value="center" <?php if ( $current_value['ver'] == 'center') { echo ' selected="selected"' ; } ?>>Center</option>
<option value="bottom" <?php if ( $current_value['ver'] == 'bottom') { echo ' selected="selected"' ; } ?>>Bottom</option>
</select>
</div>
<div id="<?php echo $value['id']; ?>-preview" class="img-preview" <?php if( !$current_value['img'] ) echo 'style="display:none;"' ?>>
<img src="<?php if( $current_value['img'] ) echo $current_value['img'] ; else echo <API key>().'/panel/images/spacer.png'; ?>" alt="" />
<a class="del-img" title="Delete"></a>
</div>
<script>
jQuery('#<?php echo $value['id']; ?>colorSelector').ColorPicker({
color: '<?php echo $current_value['color'] ; ?>',
onShow: function (colpkr) {
jQuery(colpkr).fadeIn(500);
return false;
},
onHide: function (colpkr) {
jQuery(colpkr).fadeOut(500);
return false;
},
onChange: function (hsb, hex, rgb) {
jQuery('#<?php echo $value['id']; ?>colorSelector div').css('backgroundColor', '#' + hex);
jQuery('#<?php echo $value['id']; ?>color').val('#'+hex);
}
});
</script>
<?php
break;
case 'color':
?>
<div id="<?php echo $value['id']; ?>colorSelector" class="color-pic"><div style="background-color:<?php echo tie_get_option($value['id']) ; ?>"></div></div>
<input style="width:80px; margin-right:5px;" name="tie_options[<?php echo $value['id']; ?>]" id="<?php echo $value['id']; ?>" type="text" value="<?php echo tie_get_option($value['id']) ; ?>" />
<script>
jQuery('#<?php echo $value['id']; ?>colorSelector').ColorPicker({
color: '<?php echo tie_get_option($value['id']) ; ?>',
onShow: function (colpkr) {
jQuery(colpkr).fadeIn(500);
return false;
},
onHide: function (colpkr) {
jQuery(colpkr).fadeOut(500);
return false;
},
onChange: function (hsb, hex, rgb) {
jQuery('#<?php echo $value['id']; ?>colorSelector div').css('backgroundColor', '#' + hex);
jQuery('#<?php echo $value['id']; ?>').val('#'+hex);
}
});
</script>
<?php
break;
case 'typography':
$current_value = tie_get_option($value['id']);
?>
<div style="clear:both;"></div>
<div style="clear:both; padding:10px 14px; margin:0 -15px;">
<div id="<?php echo $value['id']; ?>colorSelector" class="color-pic"><div style="background-color:<?php echo $current_value['color'] ; ?>"></div></div>
<input style="width:80px; margin-right:5px;" name="tie_options[<?php echo $value['id']; ?>][color]" id="<?php echo $value['id']; ?>color" type="text" value="<?php echo $current_value['color'] ; ?>" />
<select name="tie_options[<?php echo $value['id']; ?>][size]" id="<?php echo $value['id']; ?>[size]" style="width:55px;">
<option value="" <?php if (!$current_value['size'] ) { echo ' selected="selected"' ; } ?>></option>
<?php for( $i=1 ; $i<101 ; $i++){ ?>
<option value="<?php echo $i ?>" <?php if (( $current_value['size'] == $i ) ) { echo ' selected="selected"' ; } ?>><?php echo $i ?></option>
<?php } ?>
</select>
<select name="tie_options[<?php echo $value['id']; ?>][font]" id="<?php echo $value['id']; ?>[font]" style="width:150px;">
<?php foreach( $options_fonts as $font => $font_name ){ ?>
<option value="<?php echo $font ?>" <?php if ( $current_value['font'] == $font ) { echo ' selected="selected"' ; } ?>><?php echo $font_name ?></option>
<?php } ?>
</select>
<select name="tie_options[<?php echo $value['id']; ?>][weight]" id="<?php echo $value['id']; ?>[weight]" style="width:96px;">
<option value="" <?php if ( !$current_value['weight'] ) { echo ' selected="selected"' ; } ?>></option>
<option value="normal" <?php if ( $current_value['weight'] == 'normal' ) { echo ' selected="selected"' ; } ?>>Normal</option>
<option value="bold" <?php if ( $current_value['weight'] == 'bold') { echo ' selected="selected"' ; } ?>>Bold</option>
<option value="lighter" <?php if ( $current_value['weight'] == 'lighter') { echo ' selected="selected"' ; } ?>>Lighter</option>
<option value="bolder" <?php if ( $current_value['weight'] == 'bolder') { echo ' selected="selected"' ; } ?>>Bolder</option>
<option value="100" <?php if ( $current_value['weight'] == '100') { echo ' selected="selected"' ; } ?>>100</option>
<option value="200" <?php if ( $current_value['weight'] == '200') { echo ' selected="selected"' ; } ?>>200</option>
<option value="300" <?php if ( $current_value['weight'] == '300') { echo ' selected="selected"' ; } ?>>300</option>
<option value="400" <?php if ( $current_value['weight'] == '400') { echo ' selected="selected"' ; } ?>>400</option>
<option value="500" <?php if ( $current_value['weight'] == '500') { echo ' selected="selected"' ; } ?>>500</option>
<option value="600" <?php if ( $current_value['weight'] == '600') { echo ' selected="selected"' ; } ?>>600</option>
<option value="700" <?php if ( $current_value['weight'] == '700') { echo ' selected="selected"' ; } ?>>700</option>
<option value="800" <?php if ( $current_value['weight'] == '800') { echo ' selected="selected"' ; } ?>>800</option>
<option value="900" <?php if ( $current_value['weight'] == '900') { echo ' selected="selected"' ; } ?>>900</option>
</select>
<select name="tie_options[<?php echo $value['id']; ?>][style]" id="<?php echo $value['id']; ?>[style]" style="width:100px;">
<option value="" <?php if ( !$current_value['style'] ) { echo ' selected="selected"' ; } ?>></option>
<option value="normal" <?php if ( $current_value['style'] == 'normal' ) { echo ' selected="selected"' ; } ?>>Normal</option>
<option value="italic" <?php if ( $current_value['style'] == 'italic') { echo ' selected="selected"' ; } ?>>Italic</option>
<option value="oblique" <?php if ( $current_value['style'] == 'oblique') { echo ' selected="selected"' ; } ?>>oblique</option>
</select>
</div>
<script>
jQuery('#<?php echo $value['id']; ?>colorSelector').ColorPicker({
color: '#<?php echo $current_value['color'] ; ?>',
onShow: function (colpkr) {
jQuery(colpkr).fadeIn(500);
return false;
},
onHide: function (colpkr) {
jQuery(colpkr).fadeOut(500);
return false;
},
onChange: function (hsb, hex, rgb) {
jQuery('#<?php echo $value['id']; ?>colorSelector div').css('backgroundColor', '#' + hex);
jQuery('#<?php echo $value['id']; ?>color').val('#'+hex);
}
});
</script>
<?php
break;
}
?>
<?php if( isset( $value['help'] ) ) : ?>
<a class="mo-help tooltip" title="<?php echo $value['help'] ?>"></a>
<?php endif; ?>
</div>
<?php
}
add_action('admin_menu', 'tie_add_admin');
?> |
<?php
/**
* Latest message
*
* Links to DBC Media and podcast
*
* @package Hybrid
* @subpackage Template
*/
?>
<div id="latest-message">
<div class="<API key>">This Week's Message</div>
<div class="latest-message-left">
<div class="<API key>"><a href="http://dbcmedia.org/" rel="external">Visit DBC Media for the latest sermon</a></div>
<div class="<API key>">Sunday Sermons and More</div>
</div>
<div class="<API key>">
<div class="<API key>"><a href="http://itunes.apple.com/podcast/<API key>/id335635432" rel="external">DBC Podcast</a></div>
<div class="<API key>"><a href="http://dbcmedia.org/" rel="external">Listen</a></div>
</div>
</div> |
#include <drm/drmP.h>
#include <drm/drm_crtc_helper.h>
#include <drm/radeon_drm.h>
#include <drm/drm_fixed.h>
#include "radeon.h"
#include "atom.h"
#include "atom-bits.h"
static void <API key>(struct drm_crtc *crtc,
struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
{
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
<API key> args;
int index = <API key>(COMMAND, SetCRTC_OverScan);
int a1, a2;
memset(&args, 0, sizeof(args));
args.ucCRTC = radeon_crtc->crtc_id;
switch (radeon_crtc->rmx_type) {
case RMX_CENTER:
args.usOverscanTop = cpu_to_le16((adjusted_mode->crtc_vdisplay - mode->crtc_vdisplay) / 2);
args.usOverscanBottom = cpu_to_le16((adjusted_mode->crtc_vdisplay - mode->crtc_vdisplay) / 2);
args.usOverscanLeft = cpu_to_le16((adjusted_mode->crtc_hdisplay - mode->crtc_hdisplay) / 2);
args.usOverscanRight = cpu_to_le16((adjusted_mode->crtc_hdisplay - mode->crtc_hdisplay) / 2);
break;
case RMX_ASPECT:
a1 = mode->crtc_vdisplay * adjusted_mode->crtc_hdisplay;
a2 = adjusted_mode->crtc_vdisplay * mode->crtc_hdisplay;
if (a1 > a2) {
args.usOverscanLeft = cpu_to_le16((adjusted_mode->crtc_hdisplay - (a2 / mode->crtc_vdisplay)) / 2);
args.usOverscanRight = cpu_to_le16((adjusted_mode->crtc_hdisplay - (a2 / mode->crtc_vdisplay)) / 2);
} else if (a2 > a1) {
args.usOverscanTop = cpu_to_le16((adjusted_mode->crtc_vdisplay - (a1 / mode->crtc_hdisplay)) / 2);
args.usOverscanBottom = cpu_to_le16((adjusted_mode->crtc_vdisplay - (a1 / mode->crtc_hdisplay)) / 2);
}
break;
case RMX_FULL:
default:
args.usOverscanRight = cpu_to_le16(radeon_crtc->h_border);
args.usOverscanLeft = cpu_to_le16(radeon_crtc->h_border);
args.usOverscanBottom = cpu_to_le16(radeon_crtc->v_border);
args.usOverscanTop = cpu_to_le16(radeon_crtc->v_border);
break;
}
atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
}
static void <API key>(struct drm_crtc *crtc)
{
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
<API key> args;
int index = <API key>(COMMAND, EnableScaler);
/* fixme - fill in enc_priv for atom dac */
enum radeon_tv_std tv_std = TV_STD_NTSC;
bool is_tv = false, is_cv = false;
struct drm_encoder *encoder;
if (!ASIC_IS_AVIVO(rdev) && radeon_crtc->crtc_id)
return;
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
/* find tv std */
if (encoder->crtc == crtc) {
struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
if (radeon_encoder->active_device & <API key>) {
struct <API key> *tv_dac = radeon_encoder->enc_priv;
tv_std = tv_dac->tv_std;
is_tv = true;
}
}
}
memset(&args, 0, sizeof(args));
args.ucScaler = radeon_crtc->crtc_id;
if (is_tv) {
switch (tv_std) {
case TV_STD_NTSC:
default:
args.ucTVStandard = ATOM_TV_NTSC;
break;
case TV_STD_PAL:
args.ucTVStandard = ATOM_TV_PAL;
break;
case TV_STD_PAL_M:
args.ucTVStandard = ATOM_TV_PALM;
break;
case TV_STD_PAL_60:
args.ucTVStandard = ATOM_TV_PAL60;
break;
case TV_STD_NTSC_J:
args.ucTVStandard = ATOM_TV_NTSCJ;
break;
case TV_STD_SCART_PAL:
args.ucTVStandard = ATOM_TV_PAL;
break;
case TV_STD_SECAM:
args.ucTVStandard = ATOM_TV_SECAM;
break;
case TV_STD_PAL_CN:
args.ucTVStandard = ATOM_TV_PALCN;
break;
}
args.ucEnable = <API key>;
} else if (is_cv) {
args.ucTVStandard = ATOM_TV_CV;
args.ucEnable = <API key>;
} else {
switch (radeon_crtc->rmx_type) {
case RMX_FULL:
args.ucEnable = <API key>;
break;
case RMX_CENTER:
args.ucEnable = ATOM_SCALER_CENTER;
break;
case RMX_ASPECT:
args.ucEnable = <API key>;
break;
default:
if (ASIC_IS_AVIVO(rdev))
args.ucEnable = ATOM_SCALER_DISABLE;
else
args.ucEnable = ATOM_SCALER_CENTER;
break;
}
}
atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
if ((is_tv || is_cv)
&& rdev->family >= CHIP_RV515 && rdev->family <= CHIP_R580) {
<API key>(rdev, radeon_crtc);
}
}
static void atombios_lock_crtc(struct drm_crtc *crtc, int lock)
{
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
int index =
<API key>(COMMAND, <API key>);
<API key> args;
memset(&args, 0, sizeof(args));
args.ucCRTC = radeon_crtc->crtc_id;
args.ucEnable = lock;
atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
}
static void <API key>(struct drm_crtc *crtc, int state)
{
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
int index = <API key>(COMMAND, EnableCRTC);
<API key> args;
memset(&args, 0, sizeof(args));
args.ucCRTC = radeon_crtc->crtc_id;
args.ucEnable = state;
atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
}
static void <API key>(struct drm_crtc *crtc, int state)
{
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
int index = <API key>(COMMAND, EnableCRTCMemReq);
<API key> args;
memset(&args, 0, sizeof(args));
args.ucCRTC = radeon_crtc->crtc_id;
args.ucEnable = state;
atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
}
static void atombios_blank_crtc(struct drm_crtc *crtc, int state)
{
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
int index = <API key>(COMMAND, BlankCRTC);
<API key> args;
memset(&args, 0, sizeof(args));
args.ucCRTC = radeon_crtc->crtc_id;
args.ucBlanking = state;
atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
}
static void <API key>(struct drm_crtc *crtc, int state)
{
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
int index = <API key>(COMMAND, <API key>);
<API key> args;
memset(&args, 0, sizeof(args));
args.ucDispPipeId = radeon_crtc->crtc_id;
args.ucEnable = state;
atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
}
void atombios_crtc_dpms(struct drm_crtc *crtc, int mode)
{
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
switch (mode) {
case DRM_MODE_DPMS_ON:
radeon_crtc->enabled = true;
/* adjust pm to dpms changes BEFORE enabling crtcs */
<API key>(rdev);
/* disable crtc pair power gating before programming */
if (ASIC_IS_DCE6(rdev))
<API key>(crtc, ATOM_DISABLE);
<API key>(crtc, ATOM_ENABLE);
if (ASIC_IS_DCE3(rdev) && !ASIC_IS_DCE6(rdev))
<API key>(crtc, ATOM_ENABLE);
atombios_blank_crtc(crtc, ATOM_DISABLE);
<API key>(dev, radeon_crtc->crtc_id);
<API key>(crtc);
break;
case <API key>:
case <API key>:
case DRM_MODE_DPMS_OFF:
<API key>(dev, radeon_crtc->crtc_id);
if (radeon_crtc->enabled)
atombios_blank_crtc(crtc, ATOM_ENABLE);
if (ASIC_IS_DCE3(rdev) && !ASIC_IS_DCE6(rdev))
<API key>(crtc, ATOM_DISABLE);
<API key>(crtc, ATOM_DISABLE);
radeon_crtc->enabled = false;
/* power gating is per-pair */
if (ASIC_IS_DCE6(rdev)) {
struct drm_crtc *other_crtc;
struct radeon_crtc *other_radeon_crtc;
list_for_each_entry(other_crtc, &rdev->ddev->mode_config.crtc_list, head) {
other_radeon_crtc = to_radeon_crtc(other_crtc);
if (((radeon_crtc->crtc_id == 0) && (other_radeon_crtc->crtc_id == 1)) ||
((radeon_crtc->crtc_id == 1) && (other_radeon_crtc->crtc_id == 0)) ||
((radeon_crtc->crtc_id == 2) && (other_radeon_crtc->crtc_id == 3)) ||
((radeon_crtc->crtc_id == 3) && (other_radeon_crtc->crtc_id == 2)) ||
((radeon_crtc->crtc_id == 4) && (other_radeon_crtc->crtc_id == 5)) ||
((radeon_crtc->crtc_id == 5) && (other_radeon_crtc->crtc_id == 4))) {
/* if both crtcs in the pair are off, enable power gating */
if (other_radeon_crtc->enabled == false)
<API key>(crtc, ATOM_ENABLE);
break;
}
}
}
/* adjust pm to dpms changes AFTER disabling crtcs */
<API key>(rdev);
break;
}
}
static void
<API key>(struct drm_crtc *crtc,
struct drm_display_mode *mode)
{
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
<API key> args;
int index = <API key>(COMMAND, <API key>);
u16 misc = 0;
memset(&args, 0, sizeof(args));
args.usH_Size = cpu_to_le16(mode->crtc_hdisplay - (radeon_crtc->h_border * 2));
args.usH_Blanking_Time =
cpu_to_le16(mode->crtc_hblank_end - mode->crtc_hdisplay + (radeon_crtc->h_border * 2));
args.usV_Size = cpu_to_le16(mode->crtc_vdisplay - (radeon_crtc->v_border * 2));
args.usV_Blanking_Time =
cpu_to_le16(mode->crtc_vblank_end - mode->crtc_vdisplay + (radeon_crtc->v_border * 2));
args.usH_SyncOffset =
cpu_to_le16(mode->crtc_hsync_start - mode->crtc_hdisplay + radeon_crtc->h_border);
args.usH_SyncWidth =
cpu_to_le16(mode->crtc_hsync_end - mode->crtc_hsync_start);
args.usV_SyncOffset =
cpu_to_le16(mode->crtc_vsync_start - mode->crtc_vdisplay + radeon_crtc->v_border);
args.usV_SyncWidth =
cpu_to_le16(mode->crtc_vsync_end - mode->crtc_vsync_start);
args.ucH_Border = radeon_crtc->h_border;
args.ucV_Border = radeon_crtc->v_border;
if (mode->flags & <API key>)
misc |= ATOM_VSYNC_POLARITY;
if (mode->flags & <API key>)
misc |= ATOM_HSYNC_POLARITY;
if (mode->flags & DRM_MODE_FLAG_CSYNC)
misc |= ATOM_COMPOSITESYNC;
if (mode->flags & <API key>)
misc |= ATOM_INTERLACE;
if (mode->flags & <API key>)
misc |= <API key>;
args.susModeMiscInfo.usAccess = cpu_to_le16(misc);
args.ucCRTC = radeon_crtc->crtc_id;
atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
}
static void <API key>(struct drm_crtc *crtc,
struct drm_display_mode *mode)
{
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
<API key> args;
int index = <API key>(COMMAND, SetCRTC_Timing);
u16 misc = 0;
memset(&args, 0, sizeof(args));
args.usH_Total = cpu_to_le16(mode->crtc_htotal);
args.usH_Disp = cpu_to_le16(mode->crtc_hdisplay);
args.usH_SyncStart = cpu_to_le16(mode->crtc_hsync_start);
args.usH_SyncWidth =
cpu_to_le16(mode->crtc_hsync_end - mode->crtc_hsync_start);
args.usV_Total = cpu_to_le16(mode->crtc_vtotal);
args.usV_Disp = cpu_to_le16(mode->crtc_vdisplay);
args.usV_SyncStart = cpu_to_le16(mode->crtc_vsync_start);
args.usV_SyncWidth =
cpu_to_le16(mode->crtc_vsync_end - mode->crtc_vsync_start);
args.ucOverscanRight = radeon_crtc->h_border;
args.ucOverscanLeft = radeon_crtc->h_border;
args.ucOverscanBottom = radeon_crtc->v_border;
args.ucOverscanTop = radeon_crtc->v_border;
if (mode->flags & <API key>)
misc |= ATOM_VSYNC_POLARITY;
if (mode->flags & <API key>)
misc |= ATOM_HSYNC_POLARITY;
if (mode->flags & DRM_MODE_FLAG_CSYNC)
misc |= ATOM_COMPOSITESYNC;
if (mode->flags & <API key>)
misc |= ATOM_INTERLACE;
if (mode->flags & <API key>)
misc |= <API key>;
args.susModeMiscInfo.usAccess = cpu_to_le16(misc);
args.ucCRTC = radeon_crtc->crtc_id;
atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
}
static void atombios_disable_ss(struct radeon_device *rdev, int pll_id)
{
u32 ss_cntl;
if (ASIC_IS_DCE4(rdev)) {
switch (pll_id) {
case ATOM_PPLL1:
ss_cntl = RREG32(<API key>);
ss_cntl &= ~<API key>;
WREG32(<API key>, ss_cntl);
break;
case ATOM_PPLL2:
ss_cntl = RREG32(<API key>);
ss_cntl &= ~<API key>;
WREG32(<API key>, ss_cntl);
break;
case ATOM_DCPLL:
case ATOM_PPLL_INVALID:
return;
}
} else if (ASIC_IS_AVIVO(rdev)) {
switch (pll_id) {
case ATOM_PPLL1:
ss_cntl = RREG32(<API key>);
ss_cntl &= ~1;
WREG32(<API key>, ss_cntl);
break;
case ATOM_PPLL2:
ss_cntl = RREG32(<API key>);
ss_cntl &= ~1;
WREG32(<API key>, ss_cntl);
break;
case ATOM_DCPLL:
case ATOM_PPLL_INVALID:
return;
}
}
}
union atom_enable_ss {
<API key> lvds_ss;
<API key> lvds_ss_2;
<API key> v1;
<API key> v2;
<API key> v3;
};
static void <API key>(struct radeon_device *rdev,
int enable,
int pll_id,
struct radeon_atom_ss *ss)
{
int index = <API key>(COMMAND, <API key>);
union atom_enable_ss args;
memset(&args, 0, sizeof(args));
if (ASIC_IS_DCE5(rdev)) {
args.v3.<API key> = cpu_to_le16(0);
args.v3.<API key> = ss->type & <API key>;
switch (pll_id) {
case ATOM_PPLL1:
args.v3.<API key> |= <API key>;
args.v3.<API key> = cpu_to_le16(ss->amount);
args.v3.<API key> = cpu_to_le16(ss->step);
break;
case ATOM_PPLL2:
args.v3.<API key> |= <API key>;
args.v3.<API key> = cpu_to_le16(ss->amount);
args.v3.<API key> = cpu_to_le16(ss->step);
break;
case ATOM_DCPLL:
args.v3.<API key> |= <API key>;
args.v3.<API key> = cpu_to_le16(0);
args.v3.<API key> = cpu_to_le16(0);
break;
case ATOM_PPLL_INVALID:
return;
}
args.v3.ucEnable = enable;
if ((ss->percentage == 0) || (ss->type & <API key>) || ASIC_IS_DCE61(rdev))
args.v3.ucEnable = ATOM_DISABLE;
} else if (ASIC_IS_DCE4(rdev)) {
args.v2.<API key> = cpu_to_le16(ss->percentage);
args.v2.<API key> = ss->type & <API key>;
switch (pll_id) {
case ATOM_PPLL1:
args.v2.<API key> |= <API key>;
args.v2.<API key> = cpu_to_le16(ss->amount);
args.v2.<API key> = cpu_to_le16(ss->step);
break;
case ATOM_PPLL2:
args.v2.<API key> |= <API key>;
args.v2.<API key> = cpu_to_le16(ss->amount);
args.v2.<API key> = cpu_to_le16(ss->step);
break;
case ATOM_DCPLL:
args.v2.<API key> |= <API key>;
args.v2.<API key> = cpu_to_le16(0);
args.v2.<API key> = cpu_to_le16(0);
break;
case ATOM_PPLL_INVALID:
return;
}
args.v2.ucEnable = enable;
if ((ss->percentage == 0) || (ss->type & <API key>) || ASIC_IS_DCE41(rdev))
args.v2.ucEnable = ATOM_DISABLE;
} else if (ASIC_IS_DCE3(rdev)) {
args.v1.<API key> = cpu_to_le16(ss->percentage);
args.v1.<API key> = ss->type & <API key>;
args.v1.<API key> = ss->step;
args.v1.<API key> = ss->delay;
args.v1.<API key> = ss->range;
args.v1.ucPpll = pll_id;
args.v1.ucEnable = enable;
} else if (ASIC_IS_AVIVO(rdev)) {
if ((enable == ATOM_DISABLE) || (ss->percentage == 0) ||
(ss->type & <API key>)) {
atombios_disable_ss(rdev, pll_id);
return;
}
args.lvds_ss_2.<API key> = cpu_to_le16(ss->percentage);
args.lvds_ss_2.<API key> = ss->type & <API key>;
args.lvds_ss_2.<API key> = ss->step;
args.lvds_ss_2.<API key> = ss->delay;
args.lvds_ss_2.<API key> = ss->range;
args.lvds_ss_2.ucEnable = enable;
} else {
if ((enable == ATOM_DISABLE) || (ss->percentage == 0) ||
(ss->type & <API key>)) {
atombios_disable_ss(rdev, pll_id);
return;
}
args.lvds_ss.<API key> = cpu_to_le16(ss->percentage);
args.lvds_ss.<API key> = ss->type & <API key>;
args.lvds_ss.<API key> = (ss->step & 3) << 2;
args.lvds_ss.<API key> |= (ss->delay & 7) << 4;
args.lvds_ss.ucEnable = enable;
}
atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
}
union adjust_pixel_clock {
<API key> v1;
<API key> v3;
};
static u32 atombios_adjust_pll(struct drm_crtc *crtc,
struct drm_display_mode *mode,
struct radeon_pll *pll,
bool ss_enabled,
struct radeon_atom_ss *ss)
{
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
struct drm_encoder *encoder = NULL;
struct radeon_encoder *radeon_encoder = NULL;
struct drm_connector *connector = NULL;
u32 adjusted_clock = mode->clock;
int encoder_mode = 0;
u32 dp_clock = mode->clock;
int bpc = 8;
bool is_duallink = false;
/* reset the pll flags */
pll->flags = 0;
if (ASIC_IS_AVIVO(rdev)) {
if ((rdev->family == CHIP_RS600) ||
(rdev->family == CHIP_RS690) ||
(rdev->family == CHIP_RS740))
pll->flags |= (/*<API key> |*/
<API key>);
if (ASIC_IS_DCE32(rdev) && mode->clock > 200000) /* range limits??? */
pll->flags |= <API key>;
else
pll->flags |= <API key>;
if (rdev->family < CHIP_RV770)
pll->flags |= <API key>;
/* use frac fb div on APUs */
if (ASIC_IS_DCE41(rdev) || ASIC_IS_DCE61(rdev))
radeon_crtc->pll_flags |= <API key>;
/* use frac fb div on RS780/RS880 */
if ((rdev->family == CHIP_RS780) || (rdev->family == CHIP_RS880))
radeon_crtc->pll_flags |= <API key>;
if (ASIC_IS_DCE32(rdev) && mode->clock > 165000)
radeon_crtc->pll_flags |= <API key>;
} else {
pll->flags |= RADEON_PLL_LEGACY;
if (mode->clock > 200000) /* range limits??? */
pll->flags |= <API key>;
else
pll->flags |= <API key>;
}
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
if (encoder->crtc == crtc) {
radeon_encoder = to_radeon_encoder(encoder);
connector = <API key>(encoder);
/* if (connector && connector->display_info.bpc)
bpc = connector->display_info.bpc; */
encoder_mode = <API key>(encoder);
is_duallink = <API key>(encoder, mode->clock);
if ((radeon_encoder->devices & (<API key> | <API key>)) ||
(<API key>(encoder) != <API key>)) {
if (connector) {
struct radeon_connector *radeon_connector = to_radeon_connector(connector);
struct <API key> *dig_connector =
radeon_connector->con_priv;
dp_clock = dig_connector->dp_clock;
}
}
/* use recommended ref_div for ss */
if (radeon_encoder->devices & (<API key>)) {
if (ss_enabled) {
if (ss->refdiv) {
pll->flags |= <API key>;
pll->reference_div = ss->refdiv;
if (ASIC_IS_AVIVO(rdev))
pll->flags |= <API key>;
}
}
}
if (ASIC_IS_AVIVO(rdev)) {
/* DVO wants 2x pixel clock if the DVO chip is in 12 bit mode */
if (radeon_encoder->encoder_id == <API key>)
adjusted_clock = mode->clock * 2;
if (radeon_encoder->active_device & (<API key>))
pll->flags |= <API key>;
if (radeon_encoder->devices & (<API key>))
pll->flags |= RADEON_PLL_IS_LCD;
} else {
if (encoder->encoder_type != <API key>)
pll->flags |= <API key>;
if (encoder->encoder_type == <API key>)
pll->flags |= <API key>;
}
break;
}
}
/* DCE3+ has an AdjustDisplayPll that will adjust the pixel clock
* accordingly based on the encoder/transmitter to work around
* special hw requirements.
*/
if (ASIC_IS_DCE3(rdev)) {
union adjust_pixel_clock args;
u8 frev, crev;
int index;
index = <API key>(COMMAND, AdjustDisplayPll);
if (!<API key>(rdev->mode_info.atom_context, index, &frev,
&crev))
return adjusted_clock;
memset(&args, 0, sizeof(args));
switch (frev) {
case 1:
switch (crev) {
case 1:
case 2:
args.v1.usPixelClock = cpu_to_le16(mode->clock / 10);
args.v1.ucTransmitterID = radeon_encoder->encoder_id;
args.v1.ucEncodeMode = encoder_mode;
if (ss_enabled && ss->percentage)
args.v1.ucConfig |=
<API key>;
atom_execute_table(rdev->mode_info.atom_context,
index, (uint32_t *)&args);
adjusted_clock = le16_to_cpu(args.v1.usPixelClock) * 10;
break;
case 3:
args.v3.sInput.usPixelClock = cpu_to_le16(mode->clock / 10);
args.v3.sInput.ucTransmitterID = radeon_encoder->encoder_id;
args.v3.sInput.ucEncodeMode = encoder_mode;
args.v3.sInput.ucDispPllConfig = 0;
if (ss_enabled && ss->percentage)
args.v3.sInput.ucDispPllConfig |=
<API key>;
if (ENCODER_MODE_IS_DP(encoder_mode)) {
args.v3.sInput.ucDispPllConfig |=
<API key>;
/* 16200 or 27000 */
args.v3.sInput.usPixelClock = cpu_to_le16(dp_clock / 10);
} else if (radeon_encoder->devices & (<API key>)) {
struct <API key> *dig = radeon_encoder->enc_priv;
if (encoder_mode == <API key>)
/* deep color support */
args.v3.sInput.usPixelClock =
cpu_to_le16((mode->clock * bpc / 8) / 10);
if (dig->coherent_mode)
args.v3.sInput.ucDispPllConfig |=
<API key>;
if (is_duallink)
args.v3.sInput.ucDispPllConfig |=
<API key>;
}
if (<API key>(encoder) !=
<API key>)
args.v3.sInput.ucExtTransmitterID =
<API key>(encoder);
else
args.v3.sInput.ucExtTransmitterID = 0;
atom_execute_table(rdev->mode_info.atom_context,
index, (uint32_t *)&args);
adjusted_clock = le32_to_cpu(args.v3.sOutput.ulDispPllFreq) * 10;
if (args.v3.sOutput.ucRefDiv) {
pll->flags |= <API key>;
pll->flags |= <API key>;
pll->reference_div = args.v3.sOutput.ucRefDiv;
}
if (args.v3.sOutput.ucPostDiv) {
pll->flags |= <API key>;
pll->flags |= <API key>;
pll->post_div = args.v3.sOutput.ucPostDiv;
}
break;
default:
DRM_ERROR("Unknown table version %d %d\n", frev, crev);
return adjusted_clock;
}
break;
default:
DRM_ERROR("Unknown table version %d %d\n", frev, crev);
return adjusted_clock;
}
}
return adjusted_clock;
}
union set_pixel_clock {
<API key> base;
<API key> v1;
<API key> v2;
<API key> v3;
<API key> v5;
<API key> v6;
};
/* on DCE5, make sure the voltage is high enough to support the
* required disp clk.
*/
static void <API key>(struct radeon_device *rdev,
u32 dispclk)
{
u8 frev, crev;
int index;
union set_pixel_clock args;
memset(&args, 0, sizeof(args));
index = <API key>(COMMAND, SetPixelClock);
if (!<API key>(rdev->mode_info.atom_context, index, &frev,
&crev))
return;
switch (frev) {
case 1:
switch (crev) {
case 5:
/* if the default dcpll clock is specified,
* SetPixelClock provides the dividers
*/
args.v5.ucCRTC = ATOM_CRTC_INVALID;
args.v5.usPixelClock = cpu_to_le16(dispclk);
args.v5.ucPpll = ATOM_DCPLL;
break;
case 6:
/* if the default dcpll clock is specified,
* SetPixelClock provides the dividers
*/
args.v6.ulDispEngClkFreq = cpu_to_le32(dispclk);
if (ASIC_IS_DCE61(rdev))
args.v6.ucPpll = ATOM_EXT_PLL1;
else if (ASIC_IS_DCE6(rdev))
args.v6.ucPpll = ATOM_PPLL0;
else
args.v6.ucPpll = ATOM_DCPLL;
break;
default:
DRM_ERROR("Unknown table version %d %d\n", frev, crev);
return;
}
break;
default:
DRM_ERROR("Unknown table version %d %d\n", frev, crev);
return;
}
atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
}
static void <API key>(struct drm_crtc *crtc,
u32 crtc_id,
int pll_id,
u32 encoder_mode,
u32 encoder_id,
u32 clock,
u32 ref_div,
u32 fb_div,
u32 frac_fb_div,
u32 post_div,
int bpc,
bool ss_enabled,
struct radeon_atom_ss *ss)
{
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
u8 frev, crev;
int index = <API key>(COMMAND, SetPixelClock);
union set_pixel_clock args;
memset(&args, 0, sizeof(args));
if (!<API key>(rdev->mode_info.atom_context, index, &frev,
&crev))
return;
switch (frev) {
case 1:
switch (crev) {
case 1:
if (clock == ATOM_DISABLE)
return;
args.v1.usPixelClock = cpu_to_le16(clock / 10);
args.v1.usRefDiv = cpu_to_le16(ref_div);
args.v1.usFbDiv = cpu_to_le16(fb_div);
args.v1.ucFracFbDiv = frac_fb_div;
args.v1.ucPostDiv = post_div;
args.v1.ucPpll = pll_id;
args.v1.ucCRTC = crtc_id;
args.v1.ucRefDivSrc = 1;
break;
case 2:
args.v2.usPixelClock = cpu_to_le16(clock / 10);
args.v2.usRefDiv = cpu_to_le16(ref_div);
args.v2.usFbDiv = cpu_to_le16(fb_div);
args.v2.ucFracFbDiv = frac_fb_div;
args.v2.ucPostDiv = post_div;
args.v2.ucPpll = pll_id;
args.v2.ucCRTC = crtc_id;
args.v2.ucRefDivSrc = 1;
break;
case 3:
args.v3.usPixelClock = cpu_to_le16(clock / 10);
args.v3.usRefDiv = cpu_to_le16(ref_div);
args.v3.usFbDiv = cpu_to_le16(fb_div);
args.v3.ucFracFbDiv = frac_fb_div;
args.v3.ucPostDiv = post_div;
args.v3.ucPpll = pll_id;
args.v3.ucMiscInfo = (pll_id << 2);
if (ss_enabled && (ss->type & <API key>))
args.v3.ucMiscInfo |= <API key>;
args.v3.ucTransmitterId = encoder_id;
args.v3.ucEncoderMode = encoder_mode;
break;
case 5:
args.v5.ucCRTC = crtc_id;
args.v5.usPixelClock = cpu_to_le16(clock / 10);
args.v5.ucRefDiv = ref_div;
args.v5.usFbDiv = cpu_to_le16(fb_div);
args.v5.ulFbDivDecFrac = cpu_to_le32(frac_fb_div * 100000);
args.v5.ucPostDiv = post_div;
args.v5.ucMiscInfo = 0; /* HDMI depth, etc. */
if (ss_enabled && (ss->type & <API key>))
args.v5.ucMiscInfo |= <API key>;
if (encoder_mode == <API key>) {
switch (bpc) {
case 8:
default:
args.v5.ucMiscInfo |= <API key>;
break;
case 10:
args.v5.ucMiscInfo |= <API key>;
break;
}
}
args.v5.ucTransmitterID = encoder_id;
args.v5.ucEncoderMode = encoder_mode;
args.v5.ucPpll = pll_id;
break;
case 6:
args.v6.ulDispEngClkFreq = cpu_to_le32(crtc_id << 24 | clock / 10);
args.v6.ucRefDiv = ref_div;
args.v6.usFbDiv = cpu_to_le16(fb_div);
args.v6.ulFbDivDecFrac = cpu_to_le32(frac_fb_div * 100000);
args.v6.ucPostDiv = post_div;
args.v6.ucMiscInfo = 0; /* HDMI depth, etc. */
if (ss_enabled && (ss->type & <API key>))
args.v6.ucMiscInfo |= <API key>;
if (encoder_mode == <API key>) {
switch (bpc) {
case 8:
default:
args.v6.ucMiscInfo |= <API key>;
break;
case 10:
args.v6.ucMiscInfo |= <API key>;
break;
case 12:
args.v6.ucMiscInfo |= <API key>;
break;
case 16:
args.v6.ucMiscInfo |= <API key>;
break;
}
}
args.v6.ucTransmitterID = encoder_id;
args.v6.ucEncoderMode = encoder_mode;
args.v6.ucPpll = pll_id;
break;
default:
DRM_ERROR("Unknown table version %d %d\n", frev, crev);
return;
}
break;
default:
DRM_ERROR("Unknown table version %d %d\n", frev, crev);
return;
}
atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
}
static void <API key>(struct drm_crtc *crtc, struct drm_display_mode *mode)
{
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
struct drm_encoder *encoder = NULL;
struct radeon_encoder *radeon_encoder = NULL;
u32 pll_clock = mode->clock;
u32 ref_div = 0, fb_div = 0, frac_fb_div = 0, post_div = 0;
struct radeon_pll *pll;
u32 adjusted_clock;
int encoder_mode = 0;
struct radeon_atom_ss ss;
bool ss_enabled = false;
int bpc = 8;
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
if (encoder->crtc == crtc) {
radeon_encoder = to_radeon_encoder(encoder);
encoder_mode = <API key>(encoder);
break;
}
}
if (!radeon_encoder)
return;
switch (radeon_crtc->pll_id) {
case ATOM_PPLL1:
pll = &rdev->clock.p1pll;
break;
case ATOM_PPLL2:
pll = &rdev->clock.p2pll;
break;
case ATOM_DCPLL:
case ATOM_PPLL_INVALID:
default:
pll = &rdev->clock.dcpll;
break;
}
if ((radeon_encoder->active_device & (<API key> | <API key>)) ||
(<API key>(encoder) != <API key>)) {
struct <API key> *dig = radeon_encoder->enc_priv;
struct drm_connector *connector =
<API key>(encoder);
struct radeon_connector *radeon_connector =
to_radeon_connector(connector);
struct <API key> *dig_connector =
radeon_connector->con_priv;
int dp_clock;
/* if (connector->display_info.bpc)
bpc = connector->display_info.bpc; */
switch (encoder_mode) {
case <API key>:
case <API key>:
/* DP/eDP */
dp_clock = dig_connector->dp_clock / 10;
if (ASIC_IS_DCE4(rdev))
ss_enabled =
<API key>(rdev, &ss,
<API key>,
dp_clock);
else {
if (dp_clock == 16200) {
ss_enabled =
<API key>(rdev, &ss,
ATOM_DP_SS_ID2);
if (!ss_enabled)
ss_enabled =
<API key>(rdev, &ss,
ATOM_DP_SS_ID1);
} else
ss_enabled =
<API key>(rdev, &ss,
ATOM_DP_SS_ID1);
}
break;
case <API key>:
if (ASIC_IS_DCE4(rdev))
ss_enabled = <API key>(rdev, &ss,
dig->lcd_ss_id,
mode->clock / 10);
else
ss_enabled = <API key>(rdev, &ss,
dig->lcd_ss_id);
break;
case <API key>:
if (ASIC_IS_DCE4(rdev))
ss_enabled =
<API key>(rdev, &ss,
<API key>,
mode->clock / 10);
break;
case <API key>:
if (ASIC_IS_DCE4(rdev))
ss_enabled =
<API key>(rdev, &ss,
<API key>,
mode->clock / 10);
break;
default:
break;
}
}
/* adjust pixel clock as needed */
adjusted_clock = atombios_adjust_pll(crtc, mode, pll, ss_enabled, &ss);
if (radeon_encoder->active_device & (<API key>))
/* TV seems to prefer the legacy algo on some boards */
<API key>(pll, adjusted_clock, &pll_clock, &fb_div, &frac_fb_div,
&ref_div, &post_div);
else if (ASIC_IS_AVIVO(rdev))
<API key>(pll, adjusted_clock, &pll_clock, &fb_div, &frac_fb_div,
&ref_div, &post_div);
else
<API key>(pll, adjusted_clock, &pll_clock, &fb_div, &frac_fb_div,
&ref_div, &post_div);
<API key>(rdev, ATOM_DISABLE, radeon_crtc->pll_id, &ss);
<API key>(crtc, radeon_crtc->crtc_id, radeon_crtc->pll_id,
encoder_mode, radeon_encoder->encoder_id, mode->clock,
ref_div, fb_div, frac_fb_div, post_div, bpc, ss_enabled, &ss);
if (ss_enabled) {
/* calculate ss amount and step size */
if (ASIC_IS_DCE4(rdev)) {
u32 step_size;
u32 amount = (((fb_div * 10) + frac_fb_div) * ss.percentage) / 10000;
ss.amount = (amount / 10) & <API key>;
ss.amount |= ((amount - (amount / 10)) << <API key>) &
<API key>;
if (ss.type & <API key>)
step_size = (4 * amount * ref_div * (ss.rate * 2048)) /
(125 * 25 * pll->reference_freq / 100);
else
step_size = (2 * amount * ref_div * (ss.rate * 2048)) /
(125 * 25 * pll->reference_freq / 100);
ss.step = step_size;
}
<API key>(rdev, ATOM_ENABLE, radeon_crtc->pll_id, &ss);
}
}
static int <API key>(struct drm_crtc *crtc,
struct drm_framebuffer *fb,
int x, int y, int atomic)
{
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
struct radeon_framebuffer *radeon_fb;
struct drm_framebuffer *target_fb;
struct drm_gem_object *obj;
struct radeon_bo *rbo;
uint64_t fb_location;
uint32_t fb_format, fb_pitch_pixels, tiling_flags;
unsigned bankw, bankh, mtaspect, tile_split;
u32 fb_swap = <API key>(<API key>);
u32 tmp, viewport_w, viewport_h;
int r;
/* no fb bound */
if (!atomic && !crtc->fb) {
DRM_DEBUG_KMS("No FB bound\n");
return 0;
}
if (atomic) {
radeon_fb = <API key>(fb);
target_fb = fb;
}
else {
radeon_fb = <API key>(crtc->fb);
target_fb = crtc->fb;
}
/* If atomic, assume fb object is pinned & idle & fenced and
* just update base pointers
*/
obj = radeon_fb->obj;
rbo = gem_to_radeon_bo(obj);
r = radeon_bo_reserve(rbo, false);
if (unlikely(r != 0))
return r;
if (atomic)
fb_location = <API key>(rbo);
else {
r = radeon_bo_pin(rbo, <API key>, &fb_location);
if (unlikely(r != 0)) {
radeon_bo_unreserve(rbo);
return -EINVAL;
}
}
<API key>(rbo, &tiling_flags, NULL);
radeon_bo_unreserve(rbo);
switch (target_fb->bits_per_pixel) {
case 8:
fb_format = (<API key>(<API key>) |
<API key>(<API key>));
break;
case 15:
fb_format = (<API key>(<API key>) |
<API key>(<API key>));
break;
case 16:
fb_format = (<API key>(<API key>) |
<API key>(<API key>));
#ifdef __BIG_ENDIAN
fb_swap = <API key>(<API key>);
#endif
break;
case 24:
case 32:
fb_format = (<API key>(<API key>) |
<API key>(<API key>));
#ifdef __BIG_ENDIAN
fb_swap = <API key>(<API key>);
#endif
break;
default:
DRM_ERROR("Unsupported screen depth %d\n",
target_fb->bits_per_pixel);
return -EINVAL;
}
if (tiling_flags & RADEON_TILING_MACRO) {
if (rdev->family >= CHIP_CAYMAN)
tmp = rdev->config.cayman.tile_config;
else
tmp = rdev->config.evergreen.tile_config;
switch ((tmp & 0xf0) >> 4) {
case 0: /* 4 banks */
fb_format |= <API key>(<API key>);
break;
case 1: /* 8 banks */
default:
fb_format |= <API key>(<API key>);
break;
case 2: /* 16 banks */
fb_format |= <API key>(<API key>);
break;
}
fb_format |= <API key>(<API key>);
<API key>(tiling_flags, &bankw, &bankh, &mtaspect, &tile_split);
fb_format |= <API key>(tile_split);
fb_format |= <API key>(bankw);
fb_format |= <API key>(bankh);
fb_format |= <API key>(mtaspect);
} else if (tiling_flags & RADEON_TILING_MICRO)
fb_format |= <API key>(<API key>);
switch (radeon_crtc->crtc_id) {
case 0:
WREG32(AVIVO_D1VGA_CONTROL, 0);
break;
case 1:
WREG32(AVIVO_D2VGA_CONTROL, 0);
break;
case 2:
WREG32(<API key>, 0);
break;
case 3:
WREG32(<API key>, 0);
break;
case 4:
WREG32(<API key>, 0);
break;
case 5:
WREG32(<API key>, 0);
break;
default:
break;
}
WREG32(<API key> + radeon_crtc->crtc_offset,
upper_32_bits(fb_location));
WREG32(<API key> + radeon_crtc->crtc_offset,
upper_32_bits(fb_location));
WREG32(<API key> + radeon_crtc->crtc_offset,
(u32)fb_location & <API key>);
WREG32(<API key> + radeon_crtc->crtc_offset,
(u32) fb_location & <API key>);
WREG32(<API key> + radeon_crtc->crtc_offset, fb_format);
WREG32(<API key> + radeon_crtc->crtc_offset, fb_swap);
WREG32(<API key> + radeon_crtc->crtc_offset, 0);
WREG32(<API key> + radeon_crtc->crtc_offset, 0);
WREG32(<API key> + radeon_crtc->crtc_offset, 0);
WREG32(<API key> + radeon_crtc->crtc_offset, 0);
WREG32(<API key> + radeon_crtc->crtc_offset, target_fb->width);
WREG32(<API key> + radeon_crtc->crtc_offset, target_fb->height);
fb_pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
WREG32(<API key> + radeon_crtc->crtc_offset, fb_pitch_pixels);
WREG32(<API key> + radeon_crtc->crtc_offset, 1);
WREG32(<API key> + radeon_crtc->crtc_offset,
target_fb->height);
x &= ~3;
y &= ~1;
WREG32(<API key> + radeon_crtc->crtc_offset,
(x << 16) | y);
viewport_w = crtc->mode.hdisplay;
viewport_h = (crtc->mode.vdisplay + 1) & ~1;
WREG32(<API key> + radeon_crtc->crtc_offset,
(viewport_w << 16) | viewport_h);
/* pageflip setup */
/* make sure flip is at vb rather than hb */
tmp = RREG32(<API key> + radeon_crtc->crtc_offset);
tmp &= ~<API key>;
WREG32(<API key> + radeon_crtc->crtc_offset, tmp);
/* set pageflip to happen anywhere in vblank interval */
WREG32(<API key> + radeon_crtc->crtc_offset, 0);
if (!atomic && fb && fb != crtc->fb) {
radeon_fb = <API key>(fb);
rbo = gem_to_radeon_bo(radeon_fb->obj);
r = radeon_bo_reserve(rbo, false);
if (unlikely(r != 0))
return r;
radeon_bo_unpin(rbo);
radeon_bo_unreserve(rbo);
}
/* Bytes per pixel may have changed */
<API key>(rdev);
return 0;
}
static int <API key>(struct drm_crtc *crtc,
struct drm_framebuffer *fb,
int x, int y, int atomic)
{
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
struct radeon_framebuffer *radeon_fb;
struct drm_gem_object *obj;
struct radeon_bo *rbo;
struct drm_framebuffer *target_fb;
uint64_t fb_location;
uint32_t fb_format, fb_pitch_pixels, tiling_flags;
u32 fb_swap = <API key>;
u32 tmp, viewport_w, viewport_h;
int r;
/* no fb bound */
if (!atomic && !crtc->fb) {
DRM_DEBUG_KMS("No FB bound\n");
return 0;
}
if (atomic) {
radeon_fb = <API key>(fb);
target_fb = fb;
}
else {
radeon_fb = <API key>(crtc->fb);
target_fb = crtc->fb;
}
obj = radeon_fb->obj;
rbo = gem_to_radeon_bo(obj);
r = radeon_bo_reserve(rbo, false);
if (unlikely(r != 0))
return r;
/* If atomic, assume fb object is pinned & idle & fenced and
* just update base pointers
*/
if (atomic)
fb_location = <API key>(rbo);
else {
r = radeon_bo_pin(rbo, <API key>, &fb_location);
if (unlikely(r != 0)) {
radeon_bo_unreserve(rbo);
return -EINVAL;
}
}
<API key>(rbo, &tiling_flags, NULL);
radeon_bo_unreserve(rbo);
switch (target_fb->bits_per_pixel) {
case 8:
fb_format =
<API key> |
<API key>;
break;
case 15:
fb_format =
<API key> |
<API key>;
break;
case 16:
fb_format =
<API key> |
<API key>;
#ifdef __BIG_ENDIAN
fb_swap = <API key>;
#endif
break;
case 24:
case 32:
fb_format =
<API key> |
<API key>;
#ifdef __BIG_ENDIAN
fb_swap = <API key>;
#endif
break;
default:
DRM_ERROR("Unsupported screen depth %d\n",
target_fb->bits_per_pixel);
return -EINVAL;
}
if (rdev->family >= CHIP_R600) {
if (tiling_flags & RADEON_TILING_MACRO)
fb_format |= <API key>;
else if (tiling_flags & RADEON_TILING_MICRO)
fb_format |= <API key>;
} else {
if (tiling_flags & RADEON_TILING_MACRO)
fb_format |= <API key>;
if (tiling_flags & RADEON_TILING_MICRO)
fb_format |= AVIVO_D1GRPH_TILED;
}
if (radeon_crtc->crtc_id == 0)
WREG32(AVIVO_D1VGA_CONTROL, 0);
else
WREG32(AVIVO_D2VGA_CONTROL, 0);
if (rdev->family >= CHIP_RV770) {
if (radeon_crtc->crtc_id) {
WREG32(<API key>, upper_32_bits(fb_location));
WREG32(<API key>, upper_32_bits(fb_location));
} else {
WREG32(<API key>, upper_32_bits(fb_location));
WREG32(<API key>, upper_32_bits(fb_location));
}
}
WREG32(<API key> + radeon_crtc->crtc_offset,
(u32) fb_location);
WREG32(<API key> +
radeon_crtc->crtc_offset, (u32) fb_location);
WREG32(<API key> + radeon_crtc->crtc_offset, fb_format);
if (rdev->family >= CHIP_R600)
WREG32(<API key> + radeon_crtc->crtc_offset, fb_swap);
WREG32(<API key> + radeon_crtc->crtc_offset, 0);
WREG32(<API key> + radeon_crtc->crtc_offset, 0);
WREG32(<API key> + radeon_crtc->crtc_offset, 0);
WREG32(<API key> + radeon_crtc->crtc_offset, 0);
WREG32(AVIVO_D1GRPH_X_END + radeon_crtc->crtc_offset, target_fb->width);
WREG32(AVIVO_D1GRPH_Y_END + radeon_crtc->crtc_offset, target_fb->height);
fb_pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
WREG32(AVIVO_D1GRPH_PITCH + radeon_crtc->crtc_offset, fb_pitch_pixels);
WREG32(AVIVO_D1GRPH_ENABLE + radeon_crtc->crtc_offset, 1);
WREG32(<API key> + radeon_crtc->crtc_offset,
target_fb->height);
x &= ~3;
y &= ~1;
WREG32(<API key> + radeon_crtc->crtc_offset,
(x << 16) | y);
viewport_w = crtc->mode.hdisplay;
viewport_h = (crtc->mode.vdisplay + 1) & ~1;
WREG32(<API key> + radeon_crtc->crtc_offset,
(viewport_w << 16) | viewport_h);
/* pageflip setup */
/* make sure flip is at vb rather than hb */
tmp = RREG32(<API key> + radeon_crtc->crtc_offset);
tmp &= ~<API key>;
WREG32(<API key> + radeon_crtc->crtc_offset, tmp);
/* set pageflip to happen anywhere in vblank interval */
WREG32(<API key> + radeon_crtc->crtc_offset, 0);
if (!atomic && fb && fb != crtc->fb) {
radeon_fb = <API key>(fb);
rbo = gem_to_radeon_bo(radeon_fb->obj);
r = radeon_bo_reserve(rbo, false);
if (unlikely(r != 0))
return r;
radeon_bo_unpin(rbo);
radeon_bo_unreserve(rbo);
}
/* Bytes per pixel may have changed */
<API key>(rdev);
return 0;
}
int <API key>(struct drm_crtc *crtc, int x, int y,
struct drm_framebuffer *old_fb)
{
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
if (ASIC_IS_DCE4(rdev))
return <API key>(crtc, old_fb, x, y, 0);
else if (ASIC_IS_AVIVO(rdev))
return <API key>(crtc, old_fb, x, y, 0);
else
return <API key>(crtc, old_fb, x, y, 0);
}
int <API key>(struct drm_crtc *crtc,
struct drm_framebuffer *fb,
int x, int y, enum mode_set_atomic state)
{
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
if (ASIC_IS_DCE4(rdev))
return <API key>(crtc, fb, x, y, 1);
else if (ASIC_IS_AVIVO(rdev))
return <API key>(crtc, fb, x, y, 1);
else
return <API key>(crtc, fb, x, y, 1);
}
/* properly set additional regs when using atombios */
static void <API key>(struct drm_crtc *crtc)
{
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
u32 disp_merge_cntl;
switch (radeon_crtc->crtc_id) {
case 0:
disp_merge_cntl = RREG32(<API key>);
disp_merge_cntl &= ~<API key>;
WREG32(<API key>, disp_merge_cntl);
break;
case 1:
disp_merge_cntl = RREG32(<API key>);
disp_merge_cntl &= ~<API key>;
WREG32(<API key>, disp_merge_cntl);
WREG32(<API key>, RREG32(<API key>));
WREG32(<API key>, RREG32(<API key>));
break;
}
}
static int <API key>(struct drm_crtc *crtc)
{
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
struct drm_encoder *test_encoder;
struct drm_crtc *test_crtc;
uint32_t pll_in_use = 0;
if (ASIC_IS_DCE61(rdev)) {
list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) {
if (test_encoder->crtc && (test_encoder->crtc == crtc)) {
struct radeon_encoder *test_radeon_encoder =
to_radeon_encoder(test_encoder);
struct <API key> *dig =
test_radeon_encoder->enc_priv;
if ((test_radeon_encoder->encoder_id ==
<API key>) &&
(dig->linkb == false)) /* UNIPHY A uses PPLL2 */
return ATOM_PPLL2;
}
}
/* UNIPHY B/C/D/E/F */
list_for_each_entry(test_crtc, &dev->mode_config.crtc_list, head) {
struct radeon_crtc *radeon_test_crtc;
if (crtc == test_crtc)
continue;
radeon_test_crtc = to_radeon_crtc(test_crtc);
if ((radeon_test_crtc->pll_id == ATOM_PPLL0) ||
(radeon_test_crtc->pll_id == ATOM_PPLL1))
pll_in_use |= (1 << radeon_test_crtc->pll_id);
}
if (!(pll_in_use & 4))
return ATOM_PPLL0;
return ATOM_PPLL1;
} else if (ASIC_IS_DCE4(rdev)) {
list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) {
if (test_encoder->crtc && (test_encoder->crtc == crtc)) {
/* in DP mode, the DP ref clock can come from PPLL, DCPLL, or ext clock,
* depending on the asic:
* DCE4: PPLL or ext clock
* DCE5: DCPLL or ext clock
*
* Setting ATOM_PPLL_INVALID will cause SetPixelClock to skip
* PPLL/DCPLL programming and only program the DP DTO for the
* crtc virtual pixel clock.
*/
if (ENCODER_MODE_IS_DP(<API key>(test_encoder))) {
if (ASIC_IS_DCE5(rdev) || rdev->clock.dp_extclk)
return ATOM_PPLL_INVALID;
}
}
}
/* otherwise, pick one of the plls */
list_for_each_entry(test_crtc, &dev->mode_config.crtc_list, head) {
struct radeon_crtc *radeon_test_crtc;
if (crtc == test_crtc)
continue;
radeon_test_crtc = to_radeon_crtc(test_crtc);
if ((radeon_test_crtc->pll_id >= ATOM_PPLL1) &&
(radeon_test_crtc->pll_id <= ATOM_PPLL2))
pll_in_use |= (1 << radeon_test_crtc->pll_id);
}
if (!(pll_in_use & 1))
return ATOM_PPLL1;
return ATOM_PPLL2;
} else
return radeon_crtc->crtc_id;
}
void <API key>(struct radeon_device *rdev)
{
/* always set DCPLL */
if (ASIC_IS_DCE6(rdev))
<API key>(rdev, rdev->clock.default_dispclk);
else if (ASIC_IS_DCE4(rdev)) {
struct radeon_atom_ss ss;
bool ss_enabled = <API key>(rdev, &ss,
<API key>,
rdev->clock.default_dispclk);
if (ss_enabled)
<API key>(rdev, ATOM_DISABLE, ATOM_DCPLL, &ss);
/* XXX: DCE5, make sure voltage, dispclk is high enough */
<API key>(rdev, rdev->clock.default_dispclk);
if (ss_enabled)
<API key>(rdev, ATOM_ENABLE, ATOM_DCPLL, &ss);
}
}
int <API key>(struct drm_crtc *crtc,
struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode,
int x, int y, struct drm_framebuffer *old_fb)
{
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
struct drm_encoder *encoder;
bool is_tvcv = false;
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
/* find tv std */
if (encoder->crtc == crtc) {
struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
if (radeon_encoder->active_device &
(<API key> | <API key>))
is_tvcv = true;
}
}
<API key>(crtc, adjusted_mode);
if (ASIC_IS_DCE4(rdev))
<API key>(crtc, adjusted_mode);
else if (ASIC_IS_AVIVO(rdev)) {
if (is_tvcv)
<API key>(crtc, adjusted_mode);
else
<API key>(crtc, adjusted_mode);
} else {
<API key>(crtc, adjusted_mode);
if (radeon_crtc->crtc_id == 0)
<API key>(crtc, adjusted_mode);
<API key>(crtc);
}
<API key>(crtc, x, y, old_fb);
<API key>(crtc, mode, adjusted_mode);
<API key>(crtc);
return 0;
}
static bool <API key>(struct drm_crtc *crtc,
struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
{
if (!<API key>(crtc, mode, adjusted_mode))
return false;
return true;
}
static void <API key>(struct drm_crtc *crtc)
{
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
/* pick pll */
radeon_crtc->pll_id = <API key>(crtc);
atombios_lock_crtc(crtc, ATOM_ENABLE);
atombios_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
}
static void <API key>(struct drm_crtc *crtc)
{
atombios_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
atombios_lock_crtc(crtc, ATOM_DISABLE);
}
static void <API key>(struct drm_crtc *crtc)
{
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
struct radeon_atom_ss ss;
atombios_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
switch (radeon_crtc->pll_id) {
case ATOM_PPLL1:
case ATOM_PPLL2:
/* disable the ppll */
<API key>(crtc, radeon_crtc->crtc_id, radeon_crtc->pll_id,
0, 0, ATOM_DISABLE, 0, 0, 0, 0, 0, false, &ss);
break;
case ATOM_PPLL0:
/* disable the ppll */
if (ASIC_IS_DCE61(rdev))
<API key>(crtc, radeon_crtc->crtc_id, radeon_crtc->pll_id,
0, 0, ATOM_DISABLE, 0, 0, 0, 0, 0, false, &ss);
break;
default:
break;
}
radeon_crtc->pll_id = -1;
}
static const struct <API key> <API key> = {
.dpms = atombios_crtc_dpms,
.mode_fixup = <API key>,
.mode_set = <API key>,
.mode_set_base = <API key>,
.<API key> = <API key>,
.prepare = <API key>,
.commit = <API key>,
.load_lut = <API key>,
.disable = <API key>,
};
void <API key>(struct drm_device *dev,
struct radeon_crtc *radeon_crtc)
{
struct radeon_device *rdev = dev->dev_private;
if (ASIC_IS_DCE4(rdev)) {
switch (radeon_crtc->crtc_id) {
case 0:
default:
radeon_crtc->crtc_offset = <API key>;
break;
case 1:
radeon_crtc->crtc_offset = <API key>;
break;
case 2:
radeon_crtc->crtc_offset = <API key>;
break;
case 3:
radeon_crtc->crtc_offset = <API key>;
break;
case 4:
radeon_crtc->crtc_offset = <API key>;
break;
case 5:
radeon_crtc->crtc_offset = <API key>;
break;
}
} else {
if (radeon_crtc->crtc_id == 1)
radeon_crtc->crtc_offset =
<API key> - <API key>;
else
radeon_crtc->crtc_offset = 0;
}
radeon_crtc->pll_id = -1;
drm_crtc_helper_add(&radeon_crtc->base, &<API key>);
} |
require './lib/downloader'
require './lib/csv_exporter.rb'
ENV['mysql_host'] ||= 'localhost'
ENV['mysql_port'] ||= '3306'
ENV['mysql_username'] ||= 'chill_user'
ENV['mysql_password'] ||= 'chill_pass'
ENV['mysql_database'] ||= 'chill_prod'
ENV['url_base'] ||= 'http:
ENV['destination_dir'] ||= 'downloads/'
exporter = CsvExporter.connect
exporter.write_csv(<<EOSQL, 'tNotice.csv')
SELECT tNotice.*,
group_concat(originals.Location) AS OriginalFilePath,
group_concat(supporting.Location) AS SupportingFilePath,
tCat.CatName as CategoryName
FROM tNotice
LEFT JOIN tNotImage originals
ON originals.NoticeID = tNotice.NoticeID
AND originals.ReadLevel != 0
LEFT JOIN tNotImage supporting
ON supporting.NoticeID = tNotice.NoticeID
AND supporting.ReadLevel = 0
LEFT JOIN tCat
ON tCat.CatId = tNotice.CatId
WHERE tNotice.Subject IS NOT NULL
GROUP BY tNotice.NoticeID
ORDER BY tNotice.NoticeID DESC
LIMIT 100
EOSQL
exporter.write_csv(<<EOSQL, 'tNews.csv')
SELECT tNews.NewsID, concat_ws(', ', tNews.Byline, tNews.Source) as author,
tNews.Headline as title,
URL as url,
CAST(tNews.Abstract as char CHARACTER SET UTF8) as abstract,
CAST(tNews.Body as char CHARACTER SET UTF8) as content,
tNews.add_date as published_at, tNews.add_date as created_at,
tNews.alter_date as updated_at, tCat.CatName as CategoryName
FROM tNews
LEFT JOIN tCat
ON tCat.CatId = tNews.CatId
where tNews.Readlevel = 0
EOSQL
exporter.write_csv(<<EOSQL, 'tQuestion.csv')
SELECT rQueNot.NoticeID as OriginalNoticeID,
tQuestion.Question
FROM rQueNot
JOIN tQuestion
ON tQuestion.QuestionID = rQueNot.QuestionID
EOSQL |
/*
USAGE:
Create a new prompt for the user like this;
var askuser = new $.Prompt();
Then add header, message, responses etc like this;
askuser.setTitle('This is the title');
askuser.setMessage('This is the body text');
askuser.addResponseBtn('Hello', function() {
alert('action');
askuser.hide();
});
Change the look and feel with CSS, like a bawhs.
I use CSS3 transition, and don't really care for browsers who
don't support this.
*/
$(function()
{
// Create AJAX Area
$('body').append('<div class="ajaxarea"></div>');
var ajaxarea = $('.ajaxarea');
// jQuery selector for elements to hide when prompt
// this could be java applets like Jmol
var hideElements = $('.canvas');
/*
* Center object in vertical alignment
* because that is still not possible with
* CSS only.
*/
jQuery.fn.center = function ()
{
var top_margin = Math.max(($(window).height() - $(this).outerHeight() )/ 2);
this.css('margin-top',top_margin+'px');
return this;
}
/**
* Prompt gives the user a prompt message to respond too.
*/
jQuery.Prompt = function Prompt()
{
// Define the parent block
var stamp = new Date().getTime();
this.stamp = stamp;
this.parentblock = $('<div></div>');
this.parentblock.attr('id', stamp);
this.parentblock.hide();
ajaxarea.append(this.parentblock);
// Define some HTML Blocks
var background = $('<div class="prompt-container"></div>');
var box = $('<div class="prompt-box"></div>');
var boxHeader = $('<div class="prompt-header"></div>');
var boxMessage = $('<div class="prompt-message"></div>');
var boxFooter = $('<div class="prompt-respond"></div>');
// Hide Elements by default
boxHeader.hide();
boxFooter.hide();
// Define the class variables
this.title = " ";
this.message = " ";
this.response = " ";
this.responselist = $('<ul></ul>');
this.addClass = function addClass() {}
this.removeClass = function removeClass() {}
this.setMessage = function addMessage(message)
{
this.message = message;
}
this.setTitle = function addTitle(title)
{
this.title = title;
boxHeader.show();
}
this.setType = function setType(type)
{
// Set the type of message, ask-prompt or tell-prompt.
// Default should be ask.
}
this.addResponseBtn = function addResponseBtn(msg, action)
{
boxFooter.show();
var btn = $('<a class="button">'+msg+'</a>');
btn.click(action);
this.responselist.append($('<li></li>').append(btn));
return btn;
}
this.addCancelBtn = function addCancelBtn(msg)
{
msg = typeof msg !== 'undefined' ? msg : "Cancel";
this.addResponseBtn(msg, function()
{
hide();
});
}
this.getStamp = function getStamp()
{
return this.stamp;
}
this.show = function show()
{
//if(this.responselist.find('li').size() > 0)
this.response = this.responselist;
// Insert Variable
boxMessage.append(this.message);
boxFooter.html('<div></div>');
boxFooter.append(this.response);
boxFooter.append('<div class="clean"></div>');
// Filling
var html = box;
html.append(boxHeader.html($('<strong></strong>').html(this.title)));
html.append(boxMessage.html(this.message));
html.append(boxFooter);
html = background.append(html);
hideElements.hide();
this.parentblock.html(html);
this.parentblock.show();
box.center();
$(window).resize(function() {
box.center();
});
}
function hide()
{
$('#'+stamp).fadeOut(100, function()
{
hideElements.show();
});
// Unbind window resize
$(window).unbind('resize');
}
this.cancel = function cancel()
{
hide();
}
} // Prompt
}); |
#ifndef SPYKEE_HEADER
#define SPYKEE_HEADER
#include "PracticalSocket.h"
#include <vector>
#include <string>
#include <stdint.h>
#define SPYKEE_MAX_IMAGE 10000
class SpykeeException: public exception
{
virtual const char* what() const throw()
{
return "Error while communicating with the robot!";
}
};
class SpykeeManager
{
private:
TCPSocket* tcp;
char <API key>();
int <API key>();
void readDataFromSpykee();
void sendMsg(uint8_t pkType, int length, const int8_t* payload);
void authenticate(string username, string password);
unsigned char buffer[SPYKEE_MAX_IMAGE];
int bufferContentLength;
bool hasNewImage;
int lastBatteryLevel;
bool batteryIsUnread;
public:
SpykeeManager(std::string username, std::string password) throw(SpykeeException);
void setCameraStatus(bool setEnabled);
void setLed(char ledid, bool status);
inline bool hasBattery()
{
return batteryIsUnread;
}
inline int getBatteryLevel()
{
batteryIsUnread = false;
return lastBatteryLevel;
}
std::vector<unsigned char>* readImage();
void move(char leftSpeed, char rightSpeed);
void unplug();
inline bool hasImage()
{
return hasNewImage;
}
void readPacket();
};
#endif |
#include <linux/module.h>
const unsigned int p_lg_qc_lcdc_lut[256] = {
#if defined(<API key>) || defined(<API key>)
0x00000000, 0x00010101, 0x00020202, 0x00030303,
0x00040404, 0x00050505, 0x00060606, 0x00070707,
0x00080808, 0x00090909, 0x000a0a0a, 0x000b0b0b,
0x000c0c0c, 0x000d0d0d, 0x000e0e0e, 0x000f0f0f,
0x00101010, 0x00111111, 0x00121212, 0x00131313,
0x00141414, 0x00151515, 0x00161616, 0x00171717,
0x00181818, 0x00191919, 0x001a1a1a, 0x001b1b1b,
0x001c1c1c, 0x001d1d1d, 0x001e1e1e, 0x001f1f1f,
0x00202020, 0x00212121, 0x00222222, 0x00232323,
0x00242424, 0x00252525, 0x00262626, 0x00272727,
0x00282828, 0x00292929, 0x002a2a2a, 0x002b2b2b,
0x002c2c2c, 0x002d2d2d, 0x002e2e2e, 0x002f2f2f,
0x00303030, 0x00313131, 0x00323232, 0x00333333,
0x00343434, 0x00353535, 0x00363636, 0x00373737,
0x00383838, 0x00393939, 0x003a3a3a, 0x003b3b3b,
0x003c3c3c, 0x003d3d3d, 0x003e3e3e, 0x003f3f3f,
0x00404040, 0x00414141, 0x00424242, 0x00434343,
0x00444444, 0x00454545, 0x00464646, 0x00474747,
0x00484848, 0x00494949, 0x004a4a4a, 0x004b4b4b,
0x004c4c4c, 0x004d4d4d, 0x004e4e4e, 0x004f4f4f,
0x00505050, 0x00515151, 0x00525252, 0x00535353,
0x00545454, 0x00555555, 0x00565656, 0x00575757,
0x00585858, 0x00595959, 0x005a5a5a, 0x005b5b5b,
0x005c5c5c, 0x005d5d5d, 0x005e5e5e, 0x005f5f5f,
0x00606060, 0x00616161, 0x00626262, 0x00636363,
0x00646464, 0x00656565, 0x00666666, 0x00676767,
0x00686868, 0x00696969, 0x006a6a6a, 0x006b6b6b,
0x006c6c6c, 0x006d6d6d, 0x006e6e6e, 0x006f6f6f,
0x00707070, 0x00717171, 0x00727272, 0x00737373,
0x00747474, 0x00757575, 0x00767676, 0x00777777,
0x00787878, 0x00797979, 0x007a7a7a, 0x007b7b7b,
0x007c7c7c, 0x007d7d7d, 0x007e7e7e, 0x007f7f7f,
0x00808080, 0x00818181, 0x00828282, 0x00838383,
0x00848484, 0x00858585, 0x00868686, 0x00878787,
0x00888888, 0x00898989, 0x008a8a8a, 0x008b8b8b,
0x008c8c8c, 0x008d8d8d, 0x008e8e8e, 0x008f8f8f,
0x00909090, 0x00919191, 0x00929292, 0x00939393,
0x00949494, 0x00959595, 0x00969696, 0x00979797,
0x00989898, 0x00999999, 0x009a9a9a, 0x009b9b9b,
0x009c9c9c, 0x009d9d9d, 0x009e9e9e, 0x009f9f9f,
0x00a0a0a0, 0x00a1a1a1, 0x00a2a2a2, 0x00a3a3a3,
0x00a4a4a4, 0x00a5a5a5, 0x00a6a6a6, 0x00a7a7a7,
0x00a8a8a8, 0x00a9a9a9, 0x00aaaaaa, 0x00ababab,
0x00acacac, 0x00adadad, 0x00aeaeae, 0x00afafaf,
0x00b0b0b0, 0x00b1b1b1, 0x00b2b2b2, 0x00b3b3b3,
0x00b4b4b4, 0x00b5b5b5, 0x00b6b6b6, 0x00b7b7b7,
0x00b8b8b8, 0x00b9b9b9, 0x00bababa, 0x00bbbbbb,
0x00bcbcbc, 0x00bdbdbd, 0x00bebebe, 0x00bfbfbf,
0x00c0c0c0, 0x00c1c1c1, 0x00c2c2c2, 0x00c3c3c3,
0x00c4c4c4, 0x00c5c5c5, 0x00c6c6c6, 0x00c7c7c7,
0x00c8c8c8, 0x00c9c9c9, 0x00cacaca, 0x00cbcbcb,
0x00cccccc, 0x00cdcdcd, 0x00cecece, 0x00cfcfcf,
0x00d0d0d0, 0x00d1d1d1, 0x00d2d2d2, 0x00d3d3d3,
0x00d4d4d4, 0x00d5d5d5, 0x00d6d6d6, 0x00d7d7d7,
0x00d8d8d8, 0x00d9d9d9, 0x00dadada, 0x00dbdbdb,
0x00dcdcdc, 0x00dddddd, 0x00dedede, 0x00dfdfdf,
0x00e0e0e0, 0x00e1e1e1, 0x00e2e2e2, 0x00e3e3e3,
0x00e4e4e4, 0x00e5e5e5, 0x00e6e6e6, 0x00e7e7e7,
0x00e8e8e8, 0x00e9e9e9, 0x00eaeaea, 0x00ebebeb,
0x00ececec, 0x00ededed, 0x00eeeeee, 0x00efefef,
0x00f0f0f0, 0x00f1f1f1, 0x00f2f2f2, 0x00f3f3f3,
0x00f4f4f4, 0x00f5f5f5, 0x00f6f6f6, 0x00f7f7f7,
0x00f8f8f8, 0x00f9f9f9, 0x00fafafa, 0x00fbfbfb,
0x00fcfcfc, 0x00fdfdfd, 0x00fefefe, 0x00ffffff
#elif defined(<API key>)
0x00000000, 0x00010101, 0x00010201, 0x00020302,
0x00030303, 0x00040404, 0x00040504, 0x00050605,
0x00060706, 0x00070807, 0x00070807, 0x00080908,
0x00090a09, 0x000a0b0a, 0x000a0c0a, 0x000b0d0b,
0x000c0d0c, 0x000d0e0d, 0x000d0f0d, 0x000e100e,
0x000f110f, 0x00101210, 0x00101310, 0x00111311,
0x00121412, 0x00131513, 0x00131613, 0x00141714,
0x00151815, 0x00161916, 0x00171a17, 0x00171a17,
0x00181b18, 0x00191c19, 0x001a1d1a, 0x001a1e1a,
0x001b1f1b, 0x001c201c, 0x001d211d, 0x001e221e,
0x001e221e, 0x001f231f, 0x00202420, 0x00212521,
0x00222622, 0x00222722, 0x00232823, 0x00242924,
0x00252a25, 0x00262b26, 0x00272c27, 0x00272d27,
0x00282e28, 0x00292e29, 0x002a2f2a, 0x002b302b,
0x002c312c, 0x002c322c, 0x002d332d, 0x002e342e,
0x002f352f, 0x00303630, 0x00313731, 0x00323832,
0x00323932, 0x00333a33, 0x00343b34, 0x00353c35,
0x00363d36, 0x00373e37, 0x00383f38, 0x00394039,
0x003a413a, 0x003a423a, 0x003b433b, 0x003c443c,
0x003d453d, 0x003e463e, 0x003f473f, 0x00404840,
0x00414941, 0x00424a42, 0x00434b43, 0x00444d44,
0x00454e45, 0x00454f45, 0x00465046, 0x00475147,
0x00485248, 0x00495349, 0x004a544a, 0x004b554b,
0x004c564c, 0x004d574d, 0x004e584e, 0x004f594f,
0x00505b50, 0x00515c51, 0x00525d52, 0x00535e53,
0x00545f54, 0x00556055, 0x00566156, 0x00576257,
0x00586358, 0x00596559, 0x005a665a, 0x005b675b,
0x005c685c, 0x005d695d, 0x005e6a5e, 0x005f6b5f,
0x00606c60, 0x00616e61, 0x00626f62, 0x00637063,
0x00647164, 0x00657265, 0x00667366, 0x00677467,
0x00687668, 0x00697769, 0x006a786a, 0x006b796b,
0x006c7a6c, 0x006d7b6d, 0x006e7d6e, 0x006f7e6f,
0x00707f70, 0x00718071, 0x00728172, 0x00738373,
0x00758475, 0x00768576, 0x00778777, 0x00788878,
0x00798979, 0x007a8a7a, 0x007b8c7b, 0x007d8d7d,
0x007e8e7e, 0x007f907f, 0x00809180, 0x00819281,
0x00829482, 0x00839583, 0x00859685, 0x00869786,
0x00879987, 0x00889a88, 0x00899b89, 0x008a9c8a,
0x008b9e8b, 0x008c9f8c, 0x008da08d, 0x008ea18e,
0x0090a290, 0x0091a491, 0x0092a592, 0x0093a693,
0x0094a794, 0x0095a895, 0x0096aa96, 0x0097ab97,
0x0098ac98, 0x0099ad99, 0x009aae9a, 0x009baf9b,
0x009cb09c, 0x009db29d, 0x009eb39e, 0x009fb49f,
0x00a0b5a0, 0x00a1b6a1, 0x00a2b7a2, 0x00a3b8a3,
0x00a4b9a4, 0x00a4baa4, 0x00a5bba5, 0x00a6bca6,
0x00a7bda7, 0x00a8bea8, 0x00a9bfa9, 0x00aac0aa,
0x00abc1ab, 0x00acc2ac, 0x00adc3ad, 0x00adc4ad,
0x00aec5ae, 0x00afc6af, 0x00b0c7b0, 0x00b1c8b1,
0x00b2c9b2, 0x00b3cab3, 0x00b4cbb4, 0x00b5cdb5,
0x00b6ceb6, 0x00b7cfb7, 0x00b8d0b8, 0x00b8d1b8,
0x00b9d2b9, 0x00bad3ba, 0x00bbd4bb, 0x00bcd5bc,
0x00bdd6bd, 0x00bed7be, 0x00bfd8bf, 0x00c0d9c0,
0x00c1dac1, 0x00c2dbc2, 0x00c2dcc2, 0x00c3ddc3,
0x00c4dec4, 0x00c5dfc5, 0x00c6e0c6, 0x00c7e1c7,
0x00c8e2c8, 0x00c9e3c9, 0x00c9e4c9, 0x00cae5ca,
0x00cbe6cb, 0x00cce7cc, 0x00cde8cd, 0x00cee9ce,
0x00cfeacf, 0x00cfebcf, 0x00d0ecd0, 0x00d1edd1,
0x00d2eed2, 0x00d3efd3, 0x00d4f0d4, 0x00d4f0d4,
0x00d5f1d5, 0x00d6f2d6, 0x00d7f3d7, 0x00d8f4d8,
0x00d9f5d9, 0x00d9f6d9, 0x00daf7da, 0x00dbf8db,
0x00dcf9dc, 0x00ddfadd, 0x00defbde, 0x00defcde,
0x00dffddf, 0x00e0fde0, 0x00e1fee1, 0x00e2ffe2,
0x00e2ffe2, 0x00e3ffe3, 0x00e4ffe4, 0x00e5ffe5,
0x00e6ffe6, 0x00e6ffe6, 0x00e7ffe7, 0x00e8ffe8
#elif defined (<API key>)
0x00000000, 0x00010101, 0x00020202, 0x00020202,
0x00030303, 0x00040404, 0x00050505, 0x00050505,
0x00060606, 0x00070707, 0x00080808, 0x00080808,
0x00090909, 0x000a0a0a, 0x000b0b0b, 0x000b0b0b,
0x000c0c0c, 0x000d0d0d, 0x000e0e0e, 0x000e0e0e,
0x000f0f0f, 0x00101010, 0x00111111, 0x00121212,
0x00121212, 0x00131313, 0x00141414, 0x00151515,
0x00161616, 0x00161616, 0x00171717, 0x00181818,
0x00191919, 0x001a1a1a, 0x001b1b1b, 0x001b1b1b,
0x001c1c1c, 0x001d1d1d, 0x001e1e1e, 0x001f1f1f,
0x00202020, 0x00212121, 0x00212121, 0x00222222,
0x00232323, 0x00242424, 0x00252525, 0x00262626,
0x00272727, 0x00282828, 0x00292929, 0x00292929,
0x002a2a2a, 0x002b2b2b, 0x002c2c2c, 0x002d2d2d,
0x002e2e2e, 0x002f2f2f, 0x00303030, 0x00313131,
0x00323232, 0x00333333, 0x00343434, 0x00353535,
0x00363636, 0x00373737, 0x00383838, 0x00393939,
0x003a3a3a, 0x003b3b3b, 0x003c3c3c, 0x003d3d3d,
0x003e3e3e, 0x003f3f3f, 0x00404040, 0x00414141,
0x00424242, 0x00444444, 0x00454545, 0x00464646,
0x00474747, 0x00484848, 0x00494949, 0x004a4a4a,
0x004b4b4b, 0x004c4c4c, 0x004e4e4e, 0x004f4f4f,
0x00505050, 0x00515151, 0x00525252, 0x00535353,
0x00545454, 0x00565656, 0x00575757, 0x00585858,
0x00595959, 0x005a5a5a, 0x005b5b5b, 0x005d5d5d,
0x005e5e5e, 0x005f5f5f, 0x00606060, 0x00616161,
0x00636363, 0x00646464, 0x00656565, 0x00666666,
0x00676767, 0x00696969, 0x006a6a6a, 0x006b6b6b,
0x006c6c6c, 0x006e6e6e, 0x006f6f6f, 0x00707070,
0x00717171, 0x00737373, 0x00747474, 0x00757575,
0x00767676, 0x00787878, 0x00797979, 0x007a7a7a,
0x007b7b7b, 0x007d7d7d, 0x007e7e7e, 0x007f7f7f,
0x00808080, 0x00818181, 0x00828282, 0x00848484,
0x00858585, 0x00868686, 0x00878787, 0x00898989,
0x008a8a8a, 0x008b8b8b, 0x008c8c8c, 0x008e8e8e,
0x008f8f8f, 0x00909090, 0x00919191, 0x00939393,
0x00949494, 0x00959595, 0x00969696, 0x00989898,
0x00999999, 0x009a9a9a, 0x009b9b9b, 0x009c9c9c,
0x009e9e9e, 0x009f9f9f, 0x00a0a0a0, 0x00a1a1a1,
0x00a2a2a2, 0x00a4a4a4, 0x00a5a5a5, 0x00a6a6a6,
0x00a7a7a7, 0x00a8a8a8, 0x00a9a9a9, 0x00ababab,
0x00acacac, 0x00adadad, 0x00aeaeae, 0x00afafaf,
0x00b0b0b0, 0x00b1b1b1, 0x00b3b3b3, 0x00b4b4b4,
0x00b5b5b5, 0x00b6b6b6, 0x00b7b7b7, 0x00b8b8b8,
0x00b9b9b9, 0x00bababa, 0x00bbbbbb, 0x00bdbdbd,
0x00bebebe, 0x00bfbfbf, 0x00c0c0c0, 0x00c1c1c1,
0x00c2c2c2, 0x00c3c3c3, 0x00c4c4c4, 0x00c5c5c5,
0x00c6c6c6, 0x00c7c7c7, 0x00c8c8c8, 0x00c9c9c9,
0x00cacaca, 0x00cbcbcb, 0x00cccccc, 0x00cdcdcd,
0x00cecece, 0x00cfcfcf, 0x00d0d0d0, 0x00d1d1d1,
0x00d2d2d2, 0x00d3d3d3, 0x00d4d4d4, 0x00d5d5d5,
0x00d6d6d6, 0x00d6d6d6, 0x00d7d7d7, 0x00d8d8d8,
0x00d9d9d9, 0x00dadada, 0x00dbdbdb, 0x00dcdcdc,
0x00dddddd, 0x00dedede, 0x00dedede, 0x00dfdfdf,
0x00e0e0e0, 0x00e1e1e1, 0x00e2e2e2, 0x00e3e3e3,
0x00e4e4e4, 0x00e4e4e4, 0x00e5e5e5, 0x00e6e6e6,
0x00e7e7e7, 0x00e8e8e8, 0x00e9e9e9, 0x00e9e9e9,
0x00eaeaea, 0x00ebebeb, 0x00ececec, 0x00ededed,
0x00ededed, 0x00eeeeee, 0x00efefef, 0x00f0f0f0,
0x00f1f1f1, 0x00f1f1f1, 0x00f2f2f2, 0x00f3f3f3,
0x00f4f4f4, 0x00f4f4f4, 0x00f5f5f5, 0x00f6f6f6,
0x00f7f7f7, 0x00f7f7f7, 0x00f8f8f8, 0x00f9f9f9,
0x00fafafa, 0x00fafafa, 0x00fbfbfb, 0x00fcfcfc,
0x00fdfdfd, 0x00fdfdfd, 0x00fefefe, 0x00ffffff
#elif defined (<API key>)
0x00000000, 0x00010101, 0x00020202, 0x00030303,
0x00040404, 0x00050505, 0x00060606, 0x00070707,
0x00080808, 0x00090909, 0x000a0a0a, 0x000b0b0b,
0x000c0c0c, 0x000d0d0d, 0x000e0e0e, 0x000f0f0f,
0x00101010, 0x00111111, 0x00121212, 0x00131313,
0x00141414, 0x00151515, 0x00161616, 0x00171717,
0x00181818, 0x00191919, 0x001a1a1a, 0x001b1b1b,
0x001c1c1c, 0x001d1d1d, 0x001e1e1e, 0x001f1f1f,
0x00202020, 0x00212121, 0x00222222, 0x00232323,
0x00242424, 0x00252525, 0x00262626, 0x00272727,
0x00282828, 0x00292929, 0x002a2a2a, 0x002b2b2b,
0x002c2c2c, 0x002d2d2d, 0x002e2e2e, 0x002f2f2f,
0x00303030, 0x00313131, 0x00323232, 0x00333333,
0x00343434, 0x00353535, 0x00363636, 0x00373737,
0x00383838, 0x00393939, 0x003a3a3a, 0x003b3b3b,
0x003c3c3c, 0x003d3d3d, 0x003e3e3e, 0x003f3f3f,
0x00404040, 0x00414141, 0x00424242, 0x00434343,
0x00444444, 0x00454545, 0x00464646, 0x00474747,
0x00484848, 0x00494949, 0x004a4a4a, 0x004b4b4b,
0x004c4c4c, 0x004d4d4d, 0x004e4e4e, 0x004f4f4f,
0x00505050, 0x00515151, 0x00525252, 0x00535353,
0x00545454, 0x00555555, 0x00565656, 0x00575757,
0x00585858, 0x00595959, 0x005a5a5a, 0x005b5b5b,
0x005c5c5c, 0x005d5d5d, 0x005e5e5e, 0x005f5f5f,
0x00606060, 0x00616161, 0x00626262, 0x00636363,
0x00646464, 0x00656565, 0x00666666, 0x00676767,
0x00686868, 0x00696969, 0x006a6a6a, 0x006b6b6b,
0x006c6c6c, 0x006d6d6d, 0x006e6e6e, 0x006f6f6f,
0x00707070, 0x00717171, 0x00727272, 0x00737373,
0x00747474, 0x00757575, 0x00767676, 0x00777777,
0x00787878, 0x00797979, 0x007a7a7a, 0x007b7b7b,
0x007c7c7c, 0x007d7d7d, 0x007e7e7e, 0x007f7f7f,
0x00808080, 0x00818181, 0x00828282, 0x00838383,
0x00848484, 0x00858585, 0x00868686, 0x00878787,
0x00888888, 0x00898989, 0x008a8a8a, 0x008b8b8b,
0x008c8c8c, 0x008d8d8d, 0x008e8e8e, 0x008f8f8f,
0x00909090, 0x00919191, 0x00929292, 0x00939393,
0x00949494, 0x00959595, 0x00969696, 0x00979797,
0x00989898, 0x00999999, 0x009a9a9a, 0x009b9b9b,
0x009c9c9c, 0x009d9d9d, 0x009e9e9e, 0x009f9f9f,
0x00a0a0a0, 0x00a1a1a1, 0x00a2a2a2, 0x00a3a3a3,
0x00a4a4a4, 0x00a5a5a5, 0x00a6a6a6, 0x00a7a7a7,
0x00a8a8a8, 0x00a9a9a9, 0x00aaaaaa, 0x00ababab,
0x00acacac, 0x00adadad, 0x00aeaeae, 0x00afafaf,
0x00b0b0b0, 0x00b1b1b1, 0x00b2b2b2, 0x00b3b3b3,
0x00b4b4b4, 0x00b5b5b5, 0x00b6b6b6, 0x00b7b7b7,
0x00b8b8b8, 0x00b9b9b9, 0x00bababa, 0x00bbbbbb,
0x00bcbcbc, 0x00bdbdbd, 0x00bebebe, 0x00bfbfbf,
0x00c0c0c0, 0x00c1c1c1, 0x00c2c2c2, 0x00c3c3c3,
0x00c4c4c4, 0x00c5c5c5, 0x00c6c6c6, 0x00c7c7c7,
0x00c8c8c8, 0x00c9c9c9, 0x00cacaca, 0x00cbcbcb,
0x00cccccc, 0x00cdcdcd, 0x00cecece, 0x00cfcfcf,
0x00d0d0d0, 0x00d1d1d1, 0x00d2d2d2, 0x00d3d3d3,
0x00d4d4d4, 0x00d5d5d5, 0x00d6d6d6, 0x00d7d7d7,
0x00d8d8d8, 0x00d9d9d9, 0x00dadada, 0x00dbdbdb,
0x00dcdcdc, 0x00dddddd, 0x00dedede, 0x00dfdfdf,
0x00e0e0e0, 0x00e1e1e1, 0x00e2e2e2, 0x00e3e3e3,
0x00e4e4e4, 0x00e5e5e5, 0x00e6e6e6, 0x00e7e7e7,
0x00e8e8e8, 0x00e9e9e9, 0x00eaeaea, 0x00ebebeb,
0x00ececec, 0x00ededed, 0x00eeeeee, 0x00efefef,
0x00f0f0f0, 0x00f1f1f1, 0x00f2f2f2, 0x00f3f3f3,
0x00f4f4f4, 0x00f5f5f5, 0x00f6f6f6, 0x00f7f7f7,
0x00f8f8f8, 0x00f9f9f9, 0x00fafafa, 0x00fbfbfb,
0x00fcfcfc, 0x00fdfdfd, 0x00fefefe, 0x00ffffff
#else
0x00000000, 0x00010101, 0x00020202, 0x00030303,
0x00040404, 0x00050505, 0x00060606, 0x00070707,
0x00080808, 0x00090909, 0x000a0a0a, 0x000b0b0b,
0x000c0c0c, 0x000d0d0d, 0x000e0e0e, 0x000f0f0f,
0x00101010, 0x00111111, 0x00121212, 0x00131313,
0x00141414, 0x00151515, 0x00161616, 0x00171717,
0x00181818, 0x00191919, 0x001a1a1a, 0x001b1b1b,
0x001c1c1c, 0x001d1d1d, 0x001e1e1e, 0x001f1f1f,
0x00202020, 0x00212121, 0x00222222, 0x00232323,
0x00242424, 0x00252525, 0x00262626, 0x00272727,
0x00282828, 0x00292929, 0x002a2a2a, 0x002b2b2b,
0x002c2c2c, 0x002d2d2d, 0x002e2e2e, 0x002f2f2f,
0x00303030, 0x00313131, 0x00323232, 0x00333333,
0x00343434, 0x00353535, 0x00363636, 0x00373737,
0x00383838, 0x00393939, 0x003a3a3a, 0x003b3b3b,
0x003c3c3c, 0x003d3d3d, 0x003e3e3e, 0x003f3f3f,
0x00404040, 0x00414141, 0x00424242, 0x00434343,
0x00444444, 0x00454545, 0x00464646, 0x00474747,
0x00484848, 0x00494949, 0x004a4a4a, 0x004b4b4b,
0x004c4c4c, 0x004d4d4d, 0x004e4e4e, 0x004f4f4f,
0x00505050, 0x00515151, 0x00525252, 0x00535353,
0x00545454, 0x00555555, 0x00565656, 0x00575757,
0x00585858, 0x00595959, 0x005a5a5a, 0x005b5b5b,
0x005c5c5c, 0x005d5d5d, 0x005e5e5e, 0x005f5f5f,
0x00606060, 0x00616161, 0x00626262, 0x00636363,
0x00646464, 0x00656565, 0x00666666, 0x00676767,
0x00686868, 0x00696969, 0x006a6a6a, 0x006b6b6b,
0x006c6c6c, 0x006d6d6d, 0x006e6e6e, 0x006f6f6f,
0x00707070, 0x00717171, 0x00727272, 0x00737373,
0x00747474, 0x00757575, 0x00767676, 0x00777777,
0x00787878, 0x00797979, 0x007a7a7a, 0x007b7b7b,
0x007c7c7c, 0x007d7d7d, 0x007e7e7e, 0x007f7f7f,
0x00808080, 0x00818181, 0x00828282, 0x00838383,
0x00848484, 0x00858585, 0x00868686, 0x00878787,
0x00888888, 0x00898989, 0x008a8a8a, 0x008b8b8b,
0x008c8c8c, 0x008d8d8d, 0x008e8e8e, 0x008f8f8f,
0x00909090, 0x00919191, 0x00929292, 0x00939393,
0x00949494, 0x00959595, 0x00969696, 0x00979797,
0x00989898, 0x00999999, 0x009a9a9a, 0x009b9b9b,
0x009c9c9c, 0x009d9d9d, 0x009e9e9e, 0x009f9f9f,
0x00a0a0a0, 0x00a1a1a1, 0x00a2a2a2, 0x00a3a3a3,
0x00a4a4a4, 0x00a5a5a5, 0x00a6a6a6, 0x00a7a7a7,
0x00a8a8a8, 0x00a9a9a9, 0x00aaaaaa, 0x00ababab,
0x00acacac, 0x00adadad, 0x00aeaeae, 0x00afafaf,
0x00b0b0b0, 0x00b1b1b1, 0x00b2b2b2, 0x00b3b3b3,
0x00b4b4b4, 0x00b5b5b5, 0x00b6b6b6, 0x00b7b7b7,
0x00b8b8b8, 0x00b9b9b9, 0x00bababa, 0x00bbbbbb,
0x00bcbcbc, 0x00bdbdbd, 0x00bebebe, 0x00bfbfbf,
0x00c0c0c0, 0x00c1c1c1, 0x00c2c2c2, 0x00c3c3c3,
0x00c4c4c4, 0x00c5c5c5, 0x00c6c6c6, 0x00c7c7c7,
0x00c8c8c8, 0x00c9c9c9, 0x00cacaca, 0x00cbcbcb,
0x00cccccc, 0x00cdcdcd, 0x00cecece, 0x00cfcfcf,
0x00d0d0d0, 0x00d1d1d1, 0x00d2d2d2, 0x00d3d3d3,
0x00d4d4d4, 0x00d5d5d5, 0x00d6d6d6, 0x00d7d7d7,
0x00d8d8d8, 0x00d9d9d9, 0x00dadada, 0x00dbdbdb,
0x00dcdcdc, 0x00dddddd, 0x00dedede, 0x00dfdfdf,
0x00e0e0e0, 0x00e1e1e1, 0x00e2e2e2, 0x00e3e3e3,
0x00e4e4e4, 0x00e5e5e5, 0x00e6e6e6, 0x00e7e7e7,
0x00e8e8e8, 0x00e9e9e9, 0x00eaeaea, 0x00ebebeb,
0x00ececec, 0x00ededed, 0x00eeeeee, 0x00efefef,
0x00f0f0f0, 0x00f1f1f1, 0x00f2f2f2, 0x00f3f3f3,
0x00f4f4f4, 0x00f5f5f5, 0x00f6f6f6, 0x00f7f7f7,
0x00f8f8f8, 0x00f9f9f9, 0x00fafafa, 0x00fbfbfb,
0x00fcfcfc, 0x00fdfdfd, 0x00fefefe, 0x00ffffff
#endif
};
EXPORT_SYMBOL(p_lg_qc_lcdc_lut); |
// flickRoomCell.h
// veraflick
// This program is free software; you can redistribute it and/or modify
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#import <UIKit/UIKit.h>
@protocol <API key> <NSObject>
- (IBAction)roomSwitchToggled:(id)sender value:(BOOL)value;
@end
@interface flickRoomCell : UITableViewCell
@property (atomic, strong) IBOutlet UILabel *roomLabel;
@property (atomic, strong) IBOutlet UIImageView *roomImageView;
@property (atomic, strong) IBOutlet UILabel *statusLabel;
@property (atomic, strong) IBOutlet UISwitch *roomSwitch;
@property (atomic) NSInteger roomID;
@property (atomic, strong) IBOutlet id<<API key>> delegate;
-(IBAction)toggleSwitch:(id)sender;
@end |
# jack_m3u: generate a m3u playlist - a module for
# jack - tag audio from a CD and encode it using 3rd party software
# This program is free software; you can redistribute it and/or modify
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from jack_globals import *
m3u = None
wavm3u = None
def init():
global m3u, wavm3u
m3u = []
wavm3u = []
def add(file):
m3u.append(file)
def add_wav(file):
wavm3u.append(file)
# fixeme - not written to a file yet
def write(file="jack.m3u"):
if m3u and cf['_write_m3u']:
f = open(file, "w")
for i in m3u:
f.write(i)
f.write("\n")
f.close() |
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/blkdev.h>
#include <linux/delay.h>
#include <linux/kthread.h>
#include <linux/spinlock.h>
#include <linux/async.h>
#include <linux/slab.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_driver.h>
#include <scsi/scsi_devinfo.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_transport.h>
#include <scsi/scsi_eh.h>
#include "scsi_priv.h"
#include "scsi_logging.h"
#define ALLOC_FAILURE_MSG KERN_ERR "%s: Allocation failure during" \
" SCSI scanning, some SCSI devices might not be configured\n"
/*
* Default timeout
*/
#define SCSI_TIMEOUT (2*HZ)
/*
* Prefix values for the SCSI id's (stored in sysfs name field)
*/
#define SCSI_UID_SER_NUM 'S'
#define SCSI_UID_UNKNOWN 'Z'
/*
* Return values of some of the scanning functions.
*
* <API key>: no valid response received from the target, this
* includes allocation or general failures preventing IO from being sent.
*
* <API key>: target responded, but no device is available
* on the given LUN.
*
* <API key>: target responded, and a device is available on a
* given LUN.
*/
#define <API key> 0
#define <API key> 1
#define <API key> 2
static const char *<API key> = "nullnullnullnull";
#define MAX_SCSI_LUNS 512
#ifdef <API key>
static unsigned int max_scsi_luns = MAX_SCSI_LUNS;
#else
static unsigned int max_scsi_luns = 1;
#endif
module_param_named(max_luns, max_scsi_luns, uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(max_luns,
"last scsi LUN (should be between 1 and 2^32-1)");
#ifdef <API key>
#define <API key> "async"
#else
#define <API key> "sync"
#endif
static char scsi_scan_type[6] = <API key>;
module_param_string(scan, scsi_scan_type, sizeof(scsi_scan_type), S_IRUGO);
MODULE_PARM_DESC(scan, "sync, async or none");
/*
* <API key>: the maximum number of LUNS that will be
* returned from the REPORT LUNS command. 8 times this value must
* be allocated. In theory this could be up to an 8 byte value, but
* in practice, the maximum number of LUNs suppored by any device
* is about 16k.
*/
static unsigned int <API key> = 511;
module_param_named(max_report_luns, <API key>, uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(max_report_luns,
"REPORT LUNS maximum number of LUNS received (should be"
" between 1 and 16384)");
static unsigned int scsi_inq_timeout = SCSI_TIMEOUT/HZ + 18;
module_param_named(inq_timeout, scsi_inq_timeout, uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(inq_timeout,
"Timeout (in seconds) waiting for devices to answer INQUIRY."
" Default is 20. Some devices may need more; most need less.");
/* This lock protects only this list */
static DEFINE_SPINLOCK(async_scan_lock);
static LIST_HEAD(scanning_hosts);
struct async_scan_data {
struct list_head list;
struct Scsi_Host *shost;
struct completion prev_finished;
};
/**
* <API key> - Wait for asynchronous scans to complete
*
* When this function returns, any host which started scanning before
* this function was called will have finished its scan. Hosts which
* started scanning after this function was called may or may not have
* finished.
*/
int <API key>(void)
{
struct async_scan_data *data;
do {
if (list_empty(&scanning_hosts))
return 0;
/* If we can't get memory immediately, that's OK. Just
* sleep a little. Even if we never get memory, the async
* scans will finish eventually.
*/
data = kmalloc(sizeof(*data), GFP_KERNEL);
if (!data)
msleep(1);
} while (!data);
data->shost = NULL;
init_completion(&data->prev_finished);
spin_lock(&async_scan_lock);
/* Check that there's still somebody else on the list */
if (list_empty(&scanning_hosts))
goto done;
list_add_tail(&data->list, &scanning_hosts);
spin_unlock(&async_scan_lock);
printk(KERN_INFO "scsi: waiting for bus probes to complete ...\n");
wait_for_completion(&data->prev_finished);
spin_lock(&async_scan_lock);
list_del(&data->list);
if (!list_empty(&scanning_hosts)) {
struct async_scan_data *next = list_entry(scanning_hosts.next,
struct async_scan_data, list);
complete(&next->prev_finished);
}
done:
spin_unlock(&async_scan_lock);
kfree(data);
return 0;
}
/**
* <API key> - unlock device via a special MODE SENSE command
* @sdev: scsi device to send command to
* @result: area to store the result of the MODE SENSE
*
* Description:
* Send a vendor specific MODE SENSE (not a MODE SELECT) command.
* Called for BLIST_KEY devices.
**/
static void <API key>(struct scsi_device *sdev,
unsigned char *result)
{
unsigned char scsi_cmd[MAX_COMMAND_SIZE];
printk(KERN_NOTICE "scsi: unlocking floptical drive\n");
scsi_cmd[0] = MODE_SENSE;
scsi_cmd[1] = 0;
scsi_cmd[2] = 0x2e;
scsi_cmd[3] = 0;
scsi_cmd[4] = 0x2a; /* size */
scsi_cmd[5] = 0;
scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, result, 0x2a, NULL,
SCSI_TIMEOUT, 3, NULL);
}
/**
* scsi_alloc_sdev - allocate and setup a scsi_Device
* @starget: which target to allocate a &scsi_device for
* @lun: which lun
* @hostdata: usually NULL and set by ->slave_alloc instead
*
* Description:
* Allocate, initialize for io, and return a pointer to a scsi_Device.
* Stores the @shost, @channel, @id, and @lun in the scsi_Device, and
* adds scsi_Device to the appropriate list.
*
* Return value:
* scsi_Device pointer, or NULL on failure.
**/
static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
unsigned int lun, void *hostdata)
{
struct scsi_device *sdev;
int display_failure_msg = 1, ret;
struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
extern void scsi_evt_thread(struct work_struct *work);
extern void <API key>(struct work_struct *work);
sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size,
GFP_ATOMIC);
if (!sdev)
goto out;
sdev->vendor = <API key>;
sdev->model = <API key>;
sdev->rev = <API key>;
sdev->host = shost;
sdev-><API key> = <API key>;
sdev->id = starget->id;
sdev->lun = lun;
sdev->channel = starget->channel;
sdev->sdev_state = SDEV_CREATED;
INIT_LIST_HEAD(&sdev->siblings);
INIT_LIST_HEAD(&sdev-><API key>);
INIT_LIST_HEAD(&sdev->cmd_list);
INIT_LIST_HEAD(&sdev->starved_entry);
INIT_LIST_HEAD(&sdev->event_list);
spin_lock_init(&sdev->list_lock);
INIT_WORK(&sdev->event_work, scsi_evt_thread);
INIT_WORK(&sdev->requeue_work, <API key>);
sdev->sdev_gendev.parent = get_device(&starget->dev);
sdev->sdev_target = starget;
/* usually NULL and set by ->slave_alloc instead */
sdev->hostdata = hostdata;
/* if the device needs this changing, it may do so in the
* slave_configure function */
sdev->max_device_blocked = <API key>;
/*
* Some low level driver could use device->type
*/
sdev->type = -1;
/*
* Assume that the device will have handshaking problems,
* and then fix this field later if it turns out it
* doesn't
*/
sdev->borken = 1;
sdev->request_queue = scsi_alloc_queue(sdev);
if (!sdev->request_queue) {
/* release fn is set up in <API key>, so
* have to free and put manually here */
put_device(&starget->dev);
kfree(sdev);
goto out;
}
WARN_ON_ONCE(!blk_get_queue(sdev->request_queue));
sdev->request_queue->queuedata = sdev;
<API key>(sdev, 0, sdev->host->cmd_per_lun);
<API key>(sdev);
if (shost->hostt->slave_alloc) {
ret = shost->hostt->slave_alloc(sdev);
if (ret) {
/*
* if LLDD reports slave not present, don't clutter
* console with alloc failure messages
*/
if (ret == -ENXIO)
display_failure_msg = 0;
goto out_device_destroy;
}
}
return sdev;
out_device_destroy:
<API key>(sdev);
out:
if (display_failure_msg)
printk(ALLOC_FAILURE_MSG, __func__);
return NULL;
}
static void scsi_target_destroy(struct scsi_target *starget)
{
struct device *dev = &starget->dev;
struct Scsi_Host *shost = dev_to_shost(dev->parent);
unsigned long flags;
<API key>(dev);
spin_lock_irqsave(shost->host_lock, flags);
if (shost->hostt->target_destroy)
shost->hostt->target_destroy(starget);
list_del_init(&starget->siblings);
<API key>(shost->host_lock, flags);
put_device(dev);
}
static void <API key>(struct device *dev)
{
struct device *parent = dev->parent;
struct scsi_target *starget = to_scsi_target(dev);
kfree(starget);
put_device(parent);
}
static struct device_type scsi_target_type = {
.name = "scsi_target",
.release = <API key>,
};
int <API key>(const struct device *dev)
{
return dev->type == &scsi_target_type;
}
EXPORT_SYMBOL(<API key>);
static struct scsi_target *__scsi_find_target(struct device *parent,
int channel, uint id)
{
struct scsi_target *starget, *found_starget = NULL;
struct Scsi_Host *shost = dev_to_shost(parent);
/*
* Search for an existing target for this sdev.
*/
list_for_each_entry(starget, &shost->__targets, siblings) {
if (starget->id == id &&
starget->channel == channel) {
found_starget = starget;
break;
}
}
if (found_starget)
get_device(&found_starget->dev);
return found_starget;
}
/**
* scsi_alloc_target - allocate a new or find an existing target
* @parent: parent of the target (need not be a scsi host)
* @channel: target channel number (zero if no channels)
* @id: target id number
*
* Return an existing target if one exists, provided it hasn't already
* gone into STARGET_DEL state, otherwise allocate a new target.
*
* The target is returned with an incremented reference, so the caller
* is responsible for both reaping and doing a last put
*/
static struct scsi_target *scsi_alloc_target(struct device *parent,
int channel, uint id)
{
struct Scsi_Host *shost = dev_to_shost(parent);
struct device *dev = NULL;
unsigned long flags;
const int size = sizeof(struct scsi_target)
+ shost->transportt->target_size;
struct scsi_target *starget;
struct scsi_target *found_target;
int error;
starget = kzalloc(size, GFP_KERNEL);
if (!starget) {
printk(KERN_ERR "%s: allocation failure\n", __func__);
return NULL;
}
dev = &starget->dev;
device_initialize(dev);
starget->reap_ref = 1;
dev->parent = get_device(parent);
dev_set_name(dev, "target%d:%d:%d", shost->host_no, channel, id);
dev->bus = &scsi_bus_type;
dev->type = &scsi_target_type;
starget->id = id;
starget->channel = channel;
starget->can_queue = 0;
INIT_LIST_HEAD(&starget->siblings);
INIT_LIST_HEAD(&starget->devices);
starget->state = STARGET_CREATED;
starget->scsi_level = SCSI_2;
starget->max_target_blocked = <API key>;
retry:
spin_lock_irqsave(shost->host_lock, flags);
found_target = __scsi_find_target(parent, channel, id);
if (found_target)
goto found;
list_add_tail(&starget->siblings, &shost->__targets);
<API key>(shost->host_lock, flags);
/* allocate and add */
<API key>(dev);
if (shost->hostt->target_alloc) {
error = shost->hostt->target_alloc(starget);
if(error) {
dev_printk(KERN_ERR, dev, "target allocation failed, error %d\n", error);
/* don't want scsi_target_reap to do the final
* put because it will be under the host lock */
scsi_target_destroy(starget);
return NULL;
}
}
get_device(dev);
return starget;
found:
found_target->reap_ref++;
<API key>(shost->host_lock, flags);
if (found_target->state != STARGET_DEL) {
put_device(dev);
return found_target;
}
/* Unfortunately, we found a dying target; need to
* wait until it's dead before we can get a new one */
put_device(&found_target->dev);
<API key>();
goto retry;
}
static void <API key>(struct work_struct *work)
{
struct scsi_target *starget =
container_of(work, struct scsi_target, ew.work);
<API key>(&starget->dev);
device_del(&starget->dev);
scsi_target_destroy(starget);
}
/**
* scsi_target_reap - check to see if target is in use and destroy if not
* @starget: target to be checked
*
* This is used after removing a LUN or doing a last put of the target
* it checks atomically that nothing is using the target and removes
* it if so.
*/
void scsi_target_reap(struct scsi_target *starget)
{
struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
unsigned long flags;
enum scsi_target_state state;
int empty = 0;
spin_lock_irqsave(shost->host_lock, flags);
state = starget->state;
if (--starget->reap_ref == 0 && list_empty(&starget->devices)) {
empty = 1;
starget->state = STARGET_DEL;
}
<API key>(shost->host_lock, flags);
if (!empty)
return;
BUG_ON(state == STARGET_DEL);
if (state == STARGET_CREATED)
scsi_target_destroy(starget);
else
<API key>(<API key>,
&starget->ew);
}
/**
* <API key> - remove non-graphical chars from an INQUIRY result string
* @s: INQUIRY result string to sanitize
* @len: length of the string
*
* Description:
* The SCSI spec says that INQUIRY vendor, product, and revision
* strings must consist entirely of graphic ASCII characters,
* padded on the right with spaces. Since not all devices obey
* this rule, we will replace non-graphic or non-ASCII characters
* with spaces. Exception: a NUL character is interpreted as a
* string terminator, so all the following characters are set to
* spaces.
**/
static void <API key>(unsigned char *s, int len)
{
int terminated = 0;
for (; len > 0; (--len, ++s)) {
if (*s == 0)
terminated = 1;
if (terminated || *s < 0x20 || *s > 0x7e)
*s = ' ';
}
}
/**
* scsi_probe_lun - probe a single LUN using a SCSI INQUIRY
* @sdev: scsi_device to probe
* @inq_result: area to store the INQUIRY result
* @result_len: len of inq_result
* @bflags: store any bflags found here
*
* Description:
* Probe the lun associated with @req using a standard SCSI INQUIRY;
*
* If the INQUIRY is successful, zero is returned and the
* INQUIRY data is in @inq_result; the scsi_level and INQUIRY length
* are copied to the scsi_device any flags value is stored in *@bflags.
**/
static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
int result_len, int *bflags)
{
unsigned char scsi_cmd[MAX_COMMAND_SIZE];
int first_inquiry_len, try_inquiry_len, next_inquiry_len;
int response_len = 0;
int pass, count, result;
struct scsi_sense_hdr sshdr;
*bflags = 0;
/* Perform up to 3 passes. The first pass uses a conservative
* transfer length of 36 unless sdev->inquiry_len specifies a
* different value. */
first_inquiry_len = sdev->inquiry_len ? sdev->inquiry_len : 36;
try_inquiry_len = first_inquiry_len;
pass = 1;
next_pass:
SCSI_LOG_SCAN_BUS(3, sdev_printk(KERN_INFO, sdev,
"scsi scan: INQUIRY pass %d length %d\n",
pass, try_inquiry_len));
/* Each pass gets up to three chances to ignore Unit Attention */
for (count = 0; count < 3; ++count) {
int resid;
memset(scsi_cmd, 0, 6);
scsi_cmd[0] = INQUIRY;
scsi_cmd[4] = (unsigned char) try_inquiry_len;
memset(inq_result, 0, try_inquiry_len);
result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
inq_result, try_inquiry_len, &sshdr,
HZ / 2 + HZ * scsi_inq_timeout, 3,
&resid);
SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: INQUIRY %s "
"with code 0x%x\n",
result ? "failed" : "successful", result));
if (result) {
/*
* not-ready to ready transition [asc/ascq=0x28/0x0]
* or power-on, reset [asc/ascq=0x29/0x0], continue.
* INQUIRY should not yield UNIT_ATTENTION
* but many buggy devices do so anyway.
*/
if ((driver_byte(result) & DRIVER_SENSE) &&
scsi_sense_valid(&sshdr)) {
if ((sshdr.sense_key == UNIT_ATTENTION) &&
((sshdr.asc == 0x28) ||
(sshdr.asc == 0x29)) &&
(sshdr.ascq == 0))
continue;
}
} else {
/*
* if nothing was transferred, we try
* again. It's a workaround for some USB
* devices.
*/
if (resid == try_inquiry_len)
continue;
}
break;
}
if (result == 0) {
<API key>(&inq_result[8], 8);
<API key>(&inq_result[16], 16);
<API key>(&inq_result[32], 4);
response_len = inq_result[4] + 5;
if (response_len > 255)
response_len = first_inquiry_len; /* sanity */
/*
* Get any flags for this device.
*
* XXX add a bflags to scsi_device, and replace the
* corresponding bit fields in scsi_device, so bflags
* need not be passed as an argument.
*/
*bflags = <API key>(sdev, &inq_result[8],
&inq_result[16]);
/* When the first pass succeeds we gain information about
* what larger transfer lengths might work. */
if (pass == 1) {
if (BLIST_INQUIRY_36 & *bflags)
next_inquiry_len = 36;
else if (BLIST_INQUIRY_58 & *bflags)
next_inquiry_len = 58;
else if (sdev->inquiry_len)
next_inquiry_len = sdev->inquiry_len;
else
next_inquiry_len = response_len;
/* If more data is available perform the second pass */
if (next_inquiry_len > try_inquiry_len) {
try_inquiry_len = next_inquiry_len;
pass = 2;
goto next_pass;
}
}
} else if (pass == 2) {
printk(KERN_INFO "scsi scan: %d byte inquiry failed. "
"Consider BLIST_INQUIRY_36 for this device\n",
try_inquiry_len);
/* If this pass failed, the third pass goes back and transfers
* the same amount as we successfully got in the first pass. */
try_inquiry_len = first_inquiry_len;
pass = 3;
goto next_pass;
}
/* If the last transfer attempt got an error, assume the
* peripheral doesn't exist or is dead. */
if (result)
return -EIO;
/* Don't report any more data than the device says is valid */
sdev->inquiry_len = min(try_inquiry_len, response_len);
/*
* XXX Abort if the response length is less than 36? If less than
* 32, the lookup of the device flags (above) could be invalid,
* and it would be possible to take an incorrect action - we do
* not want to hang because of a short INQUIRY. On the flip side,
* if the device is spun down or becoming ready (and so it gives a
* short INQUIRY), an abort here prevents any further use of the
* device, including spin up.
*
* On the whole, the best approach seems to be to assume the first
* 36 bytes are valid no matter what the device says. That's
* better than copying < 36 bytes to the inquiry-result buffer
* and displaying garbage for the Vendor, Product, or Revision
* strings.
*/
if (sdev->inquiry_len < 36) {
printk(KERN_INFO "scsi scan: INQUIRY result too short (%d),"
" using 36\n", sdev->inquiry_len);
printk(KERN_INFO "scsi scan: ADERIAN INQUIRY result too short (%d),"
" using 36\n", sdev->inquiry_len);
sdev->inquiry_len = 36;
}
/*
* Related to the above issue:
*
* XXX Devices (disk or all?) should be sent a TEST UNIT READY,
* and if not ready, sent a START_STOP to start (maybe spin up) and
* then send the INQUIRY again, since the INQUIRY can change after
* a device is initialized.
*
* Ideally, start a device if explicitly asked to do so. This
* assumes that a device is spun up on power on, spun down on
* request, and then spun up on request.
*/
/*
* The scanning code needs to know the scsi_level, even if no
* device is attached at LUN 0 (<API key>) so
* non-zero LUNs can be scanned.
*/
sdev->scsi_level = inq_result[2] & 0x07;
if (sdev->scsi_level >= 2 ||
(sdev->scsi_level == 1 && (inq_result[3] & 0x0f) == 1))
sdev->scsi_level++;
sdev->sdev_target->scsi_level = sdev->scsi_level;
return 0;
}
/**
* scsi_add_lun - allocate and fully initialze a scsi_device
* @sdev: holds information to be stored in the new scsi_device
* @inq_result: holds the result of a previous INQUIRY to the LUN
* @bflags: black/white list flag
* @async: 1 if this device is being scanned asynchronously
*
* Description:
* Initialize the scsi_device @sdev. Optionally set fields based
* on values in *@bflags.
*
* Return:
* <API key>: could not allocate or setup a scsi_device
* <API key>: a new scsi_device was allocated and initialized
**/
static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
int *bflags, int async)
{
int ret;
/*
* XXX do not save the inquiry, since it can change underneath us,
* save just vendor/model/rev.
*
* Rather than save it and have an ioctl that retrieves the saved
* value, have an ioctl that executes the same INQUIRY code used
* in scsi_probe_lun, let user level programs doing INQUIRY
* scanning run at their own risk, or supply a user level program
* that can correctly scan.
*/
/*
* Copy at least 36 bytes of INQUIRY data, so that we don't
* dereference unallocated memory when accessing the Vendor,
* Product, and Revision strings. Badly behaved devices may set
* the INQUIRY Additional Length byte to a small value, indicating
* these strings are invalid, but often they contain plausible data
* nonetheless. It doesn't matter if the device sent < 36 bytes
* total, since scsi_probe_lun() initializes inq_result with 0s.
*/
sdev->inquiry = kmemdup(inq_result,
max_t(size_t, sdev->inquiry_len, 36),
GFP_ATOMIC);
if (sdev->inquiry == NULL)
return <API key>;
sdev->vendor = (char *) (sdev->inquiry + 8);
sdev->model = (char *) (sdev->inquiry + 16);
sdev->rev = (char *) (sdev->inquiry + 32);
if (strncmp(sdev->vendor, "ATA ", 8) == 0) {
/*
* sata emulation layer device. This is a hack to work around
* the SATL power management specifications which state that
* when the SATL detects the device has gone into standby
* mode, it shall respond with NOT READY.
*/
sdev->allow_restart = 1;
}
if (*bflags & BLIST_ISROM) {
sdev->type = TYPE_ROM;
sdev->removable = 1;
} else {
sdev->type = (inq_result[0] & 0x1f);
sdev->removable = (inq_result[1] & 0x80) >> 7;
}
switch (sdev->type) {
case TYPE_RBC:
case TYPE_TAPE:
case TYPE_DISK:
case TYPE_PRINTER:
case TYPE_MOD:
case TYPE_PROCESSOR:
case TYPE_SCANNER:
case TYPE_MEDIUM_CHANGER:
case TYPE_ENCLOSURE:
case TYPE_COMM:
case TYPE_RAID:
case TYPE_OSD:
sdev->writeable = 1;
break;
case TYPE_ROM:
case TYPE_WORM:
sdev->writeable = 0;
break;
default:
printk(KERN_INFO "scsi: unknown device type %d\n", sdev->type);
}
if (sdev->type == TYPE_RBC || sdev->type == TYPE_ROM) {
/* RBC and MMC devices can return SCSI-3 compliance and yet
* still not support REPORT LUNS, so make them act as
* BLIST_NOREPORTLUN unless BLIST_REPORTLUN2 is
* specifically set */
if ((*bflags & BLIST_REPORTLUN2) == 0)
*bflags |= BLIST_NOREPORTLUN;
}
/*
* For a peripheral qualifier (PQ) value of 1 (001b), the SCSI
* spec says: The device server is capable of supporting the
* specified peripheral device type on this logical unit. However,
* the physical device is not currently connected to this logical
* unit.
*
* The above is vague, as it implies that we could treat 001 and
* 011 the same. Stay compatible with previous code, and create a
* scsi_device for a PQ of 1
*
* Don't set the device offline here; rather let the upper
* level drivers eval the PQ to decide whether they should
* attach. So remove ((inq_result[0] >> 5) & 7) == 1 check.
*/
sdev->inq_periph_qual = (inq_result[0] >> 5) & 7;
sdev->lockable = sdev->removable;
sdev->soft_reset = (inq_result[7] & 1) && ((inq_result[3] & 7) == 2);
if (sdev->scsi_level >= SCSI_3 ||
(sdev->inquiry_len > 56 && inq_result[56] & 0x04))
sdev->ppr = 1;
if (inq_result[7] & 0x60)
sdev->wdtr = 1;
if (inq_result[7] & 0x10)
sdev->sdtr = 1;
sdev_printk(KERN_NOTICE, sdev, "%s %.8s %.16s %.4s PQ: %d "
"ANSI: %d%s\n", scsi_device_type(sdev->type),
sdev->vendor, sdev->model, sdev->rev,
sdev->inq_periph_qual, inq_result[2] & 0x07,
(inq_result[3] & 0x0f) == 1 ? " CCS" : "");
if ((sdev->scsi_level >= SCSI_2) && (inq_result[7] & 2) &&
!(*bflags & BLIST_NOTQ))
sdev->tagged_supported = 1;
/*
* Some devices (Texel CD ROM drives) have handshaking problems
* when used with the Seagate controllers. borken is initialized
* to 1, and then set it to 0 here.
*/
if ((*bflags & BLIST_BORKEN) == 0)
sdev->borken = 0;
if (*bflags & BLIST_NO_ULD_ATTACH)
sdev->no_uld_attach = 1;
/*
* Apparently some really broken devices (contrary to the SCSI
* standards) need to be selected without asserting ATN
*/
if (*bflags & BLIST_SELECT_NO_ATN)
sdev->select_no_atn = 1;
/*
* Maximum 512 sector transfer length
* broken RA4x00 Compaq Disk Array
*/
if (*bflags & BLIST_MAX_512)
<API key>(sdev->request_queue, 512);
/*
* Some devices may not want to have a start command automatically
* issued when a device is added.
*/
if (*bflags & BLIST_NOSTARTONADD)
sdev->no_start_on_add = 1;
if (*bflags & BLIST_SINGLELUN)
scsi_target(sdev)->single_lun = 1;
sdev->use_10_for_rw = 1;
if (*bflags & <API key>)
sdev->skip_ms_page_8 = 1;
if (*bflags & <API key>)
sdev->skip_ms_page_3f = 1;
if (*bflags & <API key>)
sdev->use_10_for_ms = 1;
/* set the device running here so that slave configure
* may do I/O */
ret = <API key>(sdev, SDEV_RUNNING);
if (ret) {
ret = <API key>(sdev, SDEV_BLOCK);
if (ret) {
sdev_printk(KERN_ERR, sdev,
"in wrong state %s to complete scan\n",
<API key>(sdev->sdev_state));
return <API key>;
}
}
if (*bflags & <API key>)
sdev-><API key> = 1;
if (*bflags & BLIST_NOT_LOCKABLE)
sdev->lockable = 0;
if (*bflags & BLIST_RETRY_HWERROR)
sdev->retry_hwerror = 1;
if (*bflags & BLIST_NO_DIF)
sdev->no_dif = 1;
sdev->eh_timeout = <API key>;
if (*bflags & <API key>)
sdev->skip_vpd_pages = 1;
<API key>(&sdev->sdev_gendev);
if (sdev->host->hostt->slave_configure) {
ret = sdev->host->hostt->slave_configure(sdev);
if (ret) {
/*
* if LLDD reports slave not present, don't clutter
* console with alloc failure messages
*/
if (ret != -ENXIO) {
sdev_printk(KERN_ERR, sdev,
"failed to configure device\n");
}
return <API key>;
}
}
sdev->max_queue_depth = sdev->queue_depth;
/*
* Ok, the device is now all set up, we can
* register it and tell the rest of the kernel
* about it.
*/
if (!async && scsi_sysfs_add_sdev(sdev) != 0)
return <API key>;
return <API key>;
}
#ifdef CONFIG_SCSI_LOGGING
/**
* scsi_inq_str - print INQUIRY data from min to max index, strip trailing whitespace
* @buf: Output buffer with at least end-first+1 bytes of space
* @inq: Inquiry buffer (input)
* @first: Offset of string into inq
* @end: Index after last character in inq
*/
static unsigned char *scsi_inq_str(unsigned char *buf, unsigned char *inq,
unsigned first, unsigned end)
{
unsigned term = 0, idx;
for (idx = 0; idx + first < end && idx + first < inq[4] + 5; idx++) {
if (inq[idx+first] > ' ') {
buf[idx] = inq[idx+first];
term = idx+1;
} else {
buf[idx] = ' ';
}
}
buf[term] = 0;
return buf;
}
#endif
/**
* <API key> - probe a LUN, if a LUN is found add it
* @starget: pointer to target device structure
* @lun: LUN of target device
* @bflagsp: store bflags here if not NULL
* @sdevp: probe the LUN corresponding to this scsi_device
* @rescan: if nonzero skip some code only needed on first scan
* @hostdata: passed to scsi_alloc_sdev()
*
* Description:
* Call scsi_probe_lun, if a LUN with an attached device is found,
* allocate and set it up by calling scsi_add_lun.
*
* Return:
* <API key>: could not allocate or setup a scsi_device
* <API key>: target responded, but no device is
* attached at the LUN
* <API key>: a new scsi_device was allocated and initialized
**/
static int <API key>(struct scsi_target *starget,
uint lun, int *bflagsp,
struct scsi_device **sdevp, int rescan,
void *hostdata)
{
struct scsi_device *sdev;
unsigned char *result;
int bflags, res = <API key>, result_len = 256;
struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
/*
* The rescan flag is used as an optimization, the first scan of a
* host adapter calls into here with rescan == 0.
*/
sdev = <API key>(starget, lun);
if (sdev) {
if (rescan || !scsi_device_created(sdev)) {
SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO
"scsi scan: device exists on %s\n",
dev_name(&sdev->sdev_gendev)));
if (sdevp)
*sdevp = sdev;
else
scsi_device_put(sdev);
if (bflagsp)
*bflagsp = <API key>(sdev,
sdev->vendor,
sdev->model);
return <API key>;
}
scsi_device_put(sdev);
} else
sdev = scsi_alloc_sdev(starget, lun, hostdata);
if (!sdev)
goto out;
result = kmalloc(result_len, GFP_ATOMIC |
((shost->unchecked_isa_dma) ? __GFP_DMA : 0));
if (!result)
goto out_free_sdev;
if (scsi_probe_lun(sdev, result, result_len, &bflags))
goto out_free_result;
if (bflagsp)
*bflagsp = bflags;
/*
* result contains valid SCSI INQUIRY data.
*/
if (((result[0] >> 5) == 3) && !(bflags & BLIST_ATTACH_PQ3)) {
/*
* For a Peripheral qualifier 3 (011b), the SCSI
* spec says: The device server is not capable of
* supporting a physical device on this logical
* unit.
*
* For disks, this implies that there is no
* logical disk configured at sdev->lun, but there
* is a target id responding.
*/
SCSI_LOG_SCAN_BUS(2, sdev_printk(KERN_INFO, sdev, "scsi scan:"
" peripheral qualifier of 3, device not"
" added\n"))
if (lun == 0) {
SCSI_LOG_SCAN_BUS(1, {
unsigned char vend[9];
unsigned char mod[17];
sdev_printk(KERN_INFO, sdev,
"scsi scan: consider passing scsi_mod."
"dev_flags=%s:%s:0x240 or 0x1000240\n",
scsi_inq_str(vend, result, 8, 16),
scsi_inq_str(mod, result, 16, 32));
});
}
res = <API key>;
goto out_free_result;
}
/*
* Some targets may set slight variations of PQ and PDT to signal
* that no LUN is present, so don't add sdev in these cases.
* Two specific examples are:
* 1) NetApp targets: return PQ=1, PDT=0x1f
* 2) USB UFI: returns PDT=0x1f, with the PQ bits being "reserved"
* in the UFI 1.0 spec (we cannot rely on reserved bits).
*
* References:
* 1) SCSI SPC-3, pp. 145-146
* PQ=1: "A peripheral device having the specified peripheral
* device type is not connected to this logical unit. However, the
* device server is capable of supporting the specified peripheral
* device type on this logical unit."
* PDT=0x1f: "Unknown or no device type"
* 2) USB UFI 1.0, p. 20
* PDT=00h Direct-access device (floppy)
* PDT=1Fh none (no FDD connected to the requested logical unit)
*/
if (((result[0] >> 5) == 1 || starget->pdt_1f_for_no_lun) &&
(result[0] & 0x1f) == 0x1f &&
!scsi_is_wlun(lun)) {
SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO
"scsi scan: peripheral device type"
" of 31, no device added\n"));
res = <API key>;
goto out_free_result;
}
res = scsi_add_lun(sdev, result, &bflags, shost->async_scan);
if (res == <API key>) {
if (bflags & BLIST_KEY) {
sdev->lockable = 0;
<API key>(sdev, result);
}
}
out_free_result:
kfree(result);
out_free_sdev:
if (res == <API key>) {
if (sdevp) {
if (scsi_device_get(sdev) == 0) {
*sdevp = sdev;
} else {
<API key>(sdev);
res = <API key>;
}
}
} else
<API key>(sdev);
out:
return res;
}
/**
* <API key> - sequentially scan a SCSI target
* @starget: pointer to target structure to scan
* @bflags: black/white list flag for LUN 0
* @scsi_level: Which version of the standard does this device adhere to
* @rescan: passed to scsi_probe_add_lun()
*
* Description:
* Generally, scan from LUN 1 (LUN 0 is assumed to already have been
* scanned) to some maximum lun until a LUN is found with no device
* attached. Use the bflags to figure out any oddities.
*
* Modifies sdevscan->lun.
**/
static void <API key>(struct scsi_target *starget,
int bflags, int scsi_level, int rescan)
{
unsigned int sparse_lun, lun, max_dev_lun;
struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: Sequential scan of"
"%s\n", dev_name(&starget->dev)));
max_dev_lun = min(max_scsi_luns, shost->max_lun);
/*
* If this device is known to support sparse multiple units,
* override the other settings, and scan all of them. Normally,
* SCSI-3 devices should be scanned via the REPORT LUNS.
*/
if (bflags & BLIST_SPARSELUN) {
max_dev_lun = shost->max_lun;
sparse_lun = 1;
} else
sparse_lun = 0;
/*
* If less than SCSI_1_CSS, and no special lun scaning, stop
* scanning; this matches 2.4 behaviour, but could just be a bug
* (to continue scanning a SCSI_1_CSS device).
*
* This test is broken. We might not have any device on lun0 for
* a sparselun device, and if that's the case then how would we
* know the real scsi_level, eh? It might make sense to just not
* scan any SCSI_1 device for non-0 luns, but that check would best
* go into scsi_alloc_sdev() and just have it return null when asked
* to alloc an sdev for lun > 0 on an already found SCSI_1 device.
*
if ((sdevscan->scsi_level < SCSI_1_CCS) &&
((bflags & (BLIST_FORCELUN | BLIST_SPARSELUN | BLIST_MAX5LUN))
== 0))
return;
*/
/*
* If this device is known to support multiple units, override
* the other settings, and scan all of them.
*/
if (bflags & BLIST_FORCELUN)
max_dev_lun = shost->max_lun;
/*
* REGAL CDC-4X: avoid hang after LUN 4
*/
if (bflags & BLIST_MAX5LUN)
max_dev_lun = min(5U, max_dev_lun);
/*
* Do not scan SCSI-2 or lower device past LUN 7, unless
* BLIST_LARGELUN.
*/
if (scsi_level < SCSI_3 && !(bflags & BLIST_LARGELUN))
max_dev_lun = min(8U, max_dev_lun);
/*
* We have already scanned LUN 0, so start at LUN 1. Keep scanning
* until we reach the max, or no LUN is found and we are not
* sparse_lun.
*/
for (lun = 1; lun < max_dev_lun; ++lun)
if ((<API key>(starget, lun, NULL, NULL, rescan,
NULL) != <API key>) &&
!sparse_lun)
return;
}
/**
* scsilun_to_int - convert a scsi_lun to an int
* @scsilun: struct scsi_lun to be converted.
*
* Description:
* Convert @scsilun from a struct scsi_lun to a four byte host byte-ordered
* integer, and return the result. The caller must check for
* truncation before using this function.
*
* Notes:
* The struct scsi_lun is assumed to be four levels, with each level
* effectively containing a SCSI byte-ordered (big endian) short; the
* addressing bits of each level are ignored (the highest two bits).
* For a description of the LUN format, post SCSI-3 see the SCSI
* Architecture Model, for SCSI-3 see the SCSI Controller Commands.
*
* Given a struct scsi_lun of: 0a 04 0b 03 00 00 00 00, this function returns
* the integer: 0x0b030a04
**/
int scsilun_to_int(struct scsi_lun *scsilun)
{
int i;
unsigned int lun;
lun = 0;
for (i = 0; i < sizeof(lun); i += 2)
lun = lun | (((scsilun->scsi_lun[i] << 8) |
scsilun->scsi_lun[i + 1]) << (i * 8));
return lun;
}
EXPORT_SYMBOL(scsilun_to_int);
/**
* int_to_scsilun - reverts an int into a scsi_lun
* @lun: integer to be reverted
* @scsilun: struct scsi_lun to be set.
*
* Description:
* Reverts the functionality of the scsilun_to_int, which packed
* an 8-byte lun value into an int. This routine unpacks the int
* back into the lun value.
* Note: the scsilun_to_int() routine does not truly handle all
* 8bytes of the lun value. This functions restores only as much
* as was set by the routine.
*
* Notes:
* Given an integer : 0x0b030a04, this function returns a
* scsi_lun of : struct scsi_lun of: 0a 04 0b 03 00 00 00 00
*
**/
void int_to_scsilun(unsigned int lun, struct scsi_lun *scsilun)
{
int i;
memset(scsilun->scsi_lun, 0, sizeof(scsilun->scsi_lun));
for (i = 0; i < sizeof(lun); i += 2) {
scsilun->scsi_lun[i] = (lun >> 8) & 0xFF;
scsilun->scsi_lun[i+1] = lun & 0xFF;
lun = lun >> 16;
}
}
EXPORT_SYMBOL(int_to_scsilun);
/**
* <API key> - Scan using SCSI REPORT LUN results
* @starget: which target
* @bflags: Zero or a mix of BLIST_NOLUN, BLIST_REPORTLUN2, or BLIST_NOREPORTLUN
* @rescan: nonzero if we can skip code only needed on first scan
*
* Description:
* Fast scanning for modern (SCSI-3) devices by sending a REPORT LUN command.
* Scan the resulting list of LUNs by calling <API key>.
*
* If BLINK_REPORTLUN2 is set, scan a target that supports more than 8
* LUNs even if it's older than SCSI-3.
* If BLIST_NOREPORTLUN is set, return 1 always.
* If BLIST_NOLUN is set, return 0 always.
* If starget->no_report_luns is set, return 1 always.
*
* Return:
* 0: scan completed (or no memory, so further scanning is futile)
* 1: could not scan with REPORT LUN
**/
static int <API key>(struct scsi_target *starget, int bflags,
int rescan)
{
char devname[64];
unsigned char scsi_cmd[MAX_COMMAND_SIZE];
unsigned int length;
unsigned int lun;
unsigned int num_luns;
unsigned int retries;
int w_lun = <API key>;
int result;
struct scsi_lun *lunp, *lun_data;
u8 *data;
struct scsi_sense_hdr sshdr;
struct scsi_device *sdev;
struct Scsi_Host *shost = dev_to_shost(&starget->dev);
int ret = 0;
/*
* Only support SCSI-3 and up devices if BLIST_NOREPORTLUN is not set.
* Also allow SCSI-2 if BLIST_REPORTLUN2 is set and host adapter does
* support more than 8 LUNs.
* Don't attempt if the target doesn't support REPORT LUNS.
*/
if (bflags & BLIST_NOREPORTLUN)
return 1;
if (starget->scsi_level < SCSI_2 &&
starget->scsi_level != SCSI_UNKNOWN)
return 1;
if (starget->scsi_level < SCSI_3 &&
(!(bflags & BLIST_REPORTLUN2) || shost->max_lun <= 8))
return 1;
if (bflags & BLIST_NOLUN)
return 0;
if (starget->no_report_luns)
return 1;
if (bflags & BLIST_NO_WLUN)
w_lun = 0;
<API key>:
if (!(sdev = <API key>(starget, 0))) {
sdev = scsi_alloc_sdev(starget, w_lun, NULL);
printk(KERN_INFO "scsi scan: for w_lun %d \n", w_lun);
if (!sdev) {
if (w_lun != 0) {
w_lun = 0;
printk(KERN_INFO "scsi scan: failed for w_lun %d \n", w_lun);
sdev = scsi_alloc_sdev(starget, w_lun, NULL);
}
if (!sdev)
return 0;
}
if (scsi_device_get(sdev)) {
<API key>(sdev);
return 0;
}
}
sprintf(devname, "host %d channel %d id %d",
shost->host_no, sdev->channel, sdev->id);
/*
* Allocate enough to hold the header (the same size as one scsi_lun)
* plus the max number of luns we are requesting.
*
* Reallocating and trying again (with the exact amount we need)
* would be nice, but then we need to somehow limit the size
* allocated based on the available memory and the limits of
* kmalloc - we don't want a kmalloc() failure of a huge value to
* prevent us from finding any LUNs on this target.
*/
length = (<API key> + 1) * sizeof(struct scsi_lun);
lun_data = kmalloc(length, GFP_ATOMIC |
(sdev->host->unchecked_isa_dma ? __GFP_DMA : 0));
if (!lun_data) {
printk(ALLOC_FAILURE_MSG, __func__);
goto out;
}
scsi_cmd[0] = REPORT_LUNS;
/*
* bytes 1 - 5: reserved, set to zero.
*/
memset(&scsi_cmd[1], 0, 5);
/*
* bytes 6 - 9: length of the command.
*/
scsi_cmd[6] = (unsigned char) (length >> 24) & 0xff;
scsi_cmd[7] = (unsigned char) (length >> 16) & 0xff;
scsi_cmd[8] = (unsigned char) (length >> 8) & 0xff;
scsi_cmd[9] = (unsigned char) length & 0xff;
scsi_cmd[10] = 0; /* reserved */
scsi_cmd[11] = 0; /* control */
for (retries = 0; retries < 3; retries++) {
SCSI_LOG_SCAN_BUS(3, printk (KERN_INFO "scsi scan: Sending"
" REPORT LUNS to %s (try %d)\n", devname,
retries));
result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
lun_data, length, &sshdr,
SCSI_TIMEOUT + 4 * HZ, 3, NULL);
SCSI_LOG_SCAN_BUS(3, printk (KERN_INFO "scsi scan: REPORT LUNS"
" %s (try %d) result 0x%x\n", result
? "failed" : "successful", retries, result));
if (result == 0)
break;
else if (scsi_sense_valid(&sshdr)) {
if (sshdr.sense_key != UNIT_ATTENTION)
break;
}
}
if (result) {
if (w_lun != 0 && scsi_device_created(sdev)) {
/*
* W_LUN probably not supported, try with LUN 0
*/
SCSI_LOG_SCAN_BUS(3, printk (KERN_INFO "scsi scan:"
"W_LUN not supported, try LUN 0\n"));
kfree(lun_data);
scsi_device_put(sdev);
<API key>(sdev);
w_lun = 0;
goto <API key>;
}
/*
* The device probably does not support a REPORT LUN command
*/
ret = 1;
goto out_err;
}
/*
* Get the length from the first four bytes of lun_data.
*/
data = (u8 *) lun_data->scsi_lun;
length = ((data[0] << 24) | (data[1] << 16) |
(data[2] << 8) | (data[3] << 0));
num_luns = (length / sizeof(struct scsi_lun));
if (num_luns > <API key>) {
printk(KERN_WARNING "scsi: On %s only %d (<API key>)"
" of %d luns reported, try increasing"
" <API key>.\n", devname,
<API key>, num_luns);
num_luns = <API key>;
}
SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev,
"scsi scan: REPORT LUN scan\n"));
/*
* Scan the luns in lun_data. The entry at offset 0 is really
* the header, so start at 1 and go up to and including num_luns.
*/
for (lunp = &lun_data[1]; lunp <= &lun_data[num_luns]; lunp++) {
lun = scsilun_to_int(lunp);
/*
* Check if the unused part of lunp is non-zero, and so
* does not fit in lun.
*/
if (memcmp(&lunp->scsi_lun[sizeof(lun)], "\0\0\0\0", 4)) {
int i;
/*
* Output an error displaying the LUN in byte order,
* this differs from what linux would print for the
* integer LUN value.
*/
printk(KERN_WARNING "scsi: %s lun 0x", devname);
data = (char *)lunp->scsi_lun;
for (i = 0; i < sizeof(struct scsi_lun); i++)
printk("%02x", data[i]);
printk(" has a LUN larger than currently supported.\n");
} else if (lun > sdev->host->max_lun) {
printk(KERN_WARNING "scsi: %s lun%d has a LUN larger"
" than allowed by the host adapter\n",
devname, lun);
} else {
int res;
res = <API key>(starget,
lun, NULL, NULL, rescan, NULL);
if (res == <API key>) {
/*
* Got some results, but now none, abort.
*/
sdev_printk(KERN_ERR, sdev,
"Unexpected response"
" from lun %d while scanning, scan"
" aborted\n", lun);
break;
}
}
}
out_err:
kfree(lun_data);
out:
scsi_device_put(sdev);
if (scsi_device_created(sdev))
/*
* the sdev we used didn't appear in the report luns scan
*/
<API key>(sdev);
return ret;
}
struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel,
uint id, uint lun, void *hostdata)
{
struct scsi_device *sdev = ERR_PTR(-ENODEV);
struct device *parent = &shost->shost_gendev;
struct scsi_target *starget;
if (strncmp(scsi_scan_type, "none", 4) == 0)
return ERR_PTR(-ENODEV);
starget = scsi_alloc_target(parent, channel, id);
if (!starget)
return ERR_PTR(-ENOMEM);
<API key>(starget);
mutex_lock(&shost->scan_mutex);
if (!shost->async_scan)
<API key>();
if (<API key>(shost) && <API key>(shost) == 0) {
<API key>(starget, lun, NULL, &sdev, 1, hostdata);
<API key>(shost);
}
mutex_unlock(&shost->scan_mutex);
<API key>(starget);
scsi_target_reap(starget);
put_device(&starget->dev);
return sdev;
}
EXPORT_SYMBOL(__scsi_add_device);
int scsi_add_device(struct Scsi_Host *host, uint channel,
uint target, uint lun)
{
struct scsi_device *sdev =
__scsi_add_device(host, channel, target, lun, NULL);
if (IS_ERR(sdev))
return PTR_ERR(sdev);
scsi_device_put(sdev);
return 0;
}
EXPORT_SYMBOL(scsi_add_device);
void scsi_rescan_device(struct device *dev)
{
struct scsi_driver *drv;
if (!dev->driver)
return;
drv = to_scsi_driver(dev->driver);
if (try_module_get(drv->owner)) {
if (drv->rescan)
drv->rescan(dev);
module_put(drv->owner);
}
}
EXPORT_SYMBOL(scsi_rescan_device);
static void __scsi_scan_target(struct device *parent, unsigned int channel,
unsigned int id, unsigned int lun, int rescan)
{
struct Scsi_Host *shost = dev_to_shost(parent);
int bflags = 0;
int res;
struct scsi_target *starget;
if (shost->this_id == id)
/*
* Don't scan the host adapter
*/
return;
starget = scsi_alloc_target(parent, channel, id);
if (!starget)
return;
<API key>(starget);
if (lun != SCAN_WILD_CARD) {
/*
* Scan for a specific host/chan/id/lun.
*/
<API key>(starget, lun, NULL, NULL, rescan, NULL);
goto out_reap;
}
/*
* Scan LUN 0, if there is some response, scan further. Ideally, we
* would not configure LUN 0 until all LUNs are scanned.
*/
res = <API key>(starget, 0, &bflags, NULL, rescan, NULL);
if (true || res == <API key> || res == <API key>) {
if (<API key>(starget, bflags, rescan) != 0 || true)
/*
* The REPORT LUN did not scan the target,
* do a sequential scan.
*/
<API key>(starget, bflags,
starget->scsi_level, rescan);
}
out_reap:
<API key>(starget);
/* now determine if the target has any children at all
* and if not, nuke it */
scsi_target_reap(starget);
put_device(&starget->dev);
}
/**
* scsi_scan_target - scan a target id, possibly including all LUNs on the target.
* @parent: host to scan
* @channel: channel to scan
* @id: target id to scan
* @lun: Specific LUN to scan or SCAN_WILD_CARD
* @rescan: passed to LUN scanning routines
*
* Description:
* Scan the target id on @parent, @channel, and @id. Scan at least LUN 0,
* and possibly all LUNs on the target id.
*
* First try a REPORT LUN scan, if that does not scan the target, do a
* sequential scan of LUNs on the target id.
**/
void scsi_scan_target(struct device *parent, unsigned int channel,
unsigned int id, unsigned int lun, int rescan)
{
struct Scsi_Host *shost = dev_to_shost(parent);
if (strncmp(scsi_scan_type, "none", 4) == 0)
return;
mutex_lock(&shost->scan_mutex);
if (!shost->async_scan)
<API key>();
if (<API key>(shost) && <API key>(shost) == 0) {
__scsi_scan_target(parent, channel, id, lun, rescan);
<API key>(shost);
}
mutex_unlock(&shost->scan_mutex);
}
EXPORT_SYMBOL(scsi_scan_target);
static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel,
unsigned int id, unsigned int lun, int rescan)
{
uint order_id;
if (id == SCAN_WILD_CARD)
for (id = 0; id < shost->max_id; ++id) {
/*
* XXX adapter drivers when possible (FCP, iSCSI)
* could modify max_id to match the current max,
* not the absolute max.
*
* XXX add a shost id iterator, so for example,
* the FC ID can be the same as a target id
* without a huge overhead of sparse id's.
*/
if (shost->reverse_ordering)
/*
* Scan from high to low id.
*/
order_id = shost->max_id - id - 1;
else
order_id = id;
__scsi_scan_target(&shost->shost_gendev, channel,
order_id, lun, rescan);
}
else
__scsi_scan_target(&shost->shost_gendev, channel,
id, lun, rescan);
}
int <API key>(struct Scsi_Host *shost, unsigned int channel,
unsigned int id, unsigned int lun, int rescan)
{
SCSI_LOG_SCAN_BUS(3, shost_printk (KERN_INFO, shost,
"%s: <%u:%u:%u>\n",
__func__, channel, id, lun));
if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) ||
((id != SCAN_WILD_CARD) && (id >= shost->max_id)) ||
((lun != SCAN_WILD_CARD) && (lun > shost->max_lun)))
return -EINVAL;
mutex_lock(&shost->scan_mutex);
if (!shost->async_scan)
<API key>();
if (<API key>(shost) && <API key>(shost) == 0) {
if (channel == SCAN_WILD_CARD)
for (channel = 0; channel <= shost->max_channel;
channel++)
scsi_scan_channel(shost, channel, id, lun,
rescan);
else
scsi_scan_channel(shost, channel, id, lun, rescan);
<API key>(shost);
}
mutex_unlock(&shost->scan_mutex);
return 0;
}
static void <API key>(struct Scsi_Host *shost)
{
struct scsi_device *sdev;
<API key>(sdev, shost) {
/* target removed before the device could be added */
if (sdev->sdev_state == SDEV_DEL)
continue;
if (!<API key>(shost) ||
scsi_sysfs_add_sdev(sdev) != 0)
<API key>(sdev);
}
}
/**
* <API key> - prepare for an async scan
* @shost: the host which will be scanned
* Returns: a cookie to be passed to <API key>()
*
* Tells the midlayer this host is going to do an asynchronous scan.
* It reserves the host's position in the scanning list and ensures
* that other asynchronous scans started after this one won't affect the
* ordering of the discovered devices.
*/
static struct async_scan_data *<API key>(struct Scsi_Host *shost)
{
struct async_scan_data *data;
unsigned long flags;
if (strncmp(scsi_scan_type, "sync", 4) == 0)
return NULL;
if (shost->async_scan) {
printk("%s called twice for host %d", __func__,
shost->host_no);
dump_stack();
return NULL;
}
data = kmalloc(sizeof(*data), GFP_KERNEL);
if (!data)
goto err;
data->shost = scsi_host_get(shost);
if (!data->shost)
goto err;
init_completion(&data->prev_finished);
mutex_lock(&shost->scan_mutex);
spin_lock_irqsave(shost->host_lock, flags);
shost->async_scan = 1;
<API key>(shost->host_lock, flags);
mutex_unlock(&shost->scan_mutex);
spin_lock(&async_scan_lock);
if (list_empty(&scanning_hosts))
complete(&data->prev_finished);
list_add_tail(&data->list, &scanning_hosts);
spin_unlock(&async_scan_lock);
return data;
err:
kfree(data);
return NULL;
}
/**
* <API key> - asynchronous scan has finished
* @data: cookie returned from earlier call to <API key>()
*
* All the devices currently attached to this host have been found.
* This function announces all the devices it has found to the rest
* of the system.
*/
static void <API key>(struct async_scan_data *data)
{
struct Scsi_Host *shost;
unsigned long flags;
if (!data)
return;
shost = data->shost;
mutex_lock(&shost->scan_mutex);
if (!shost->async_scan) {
printk("%s called twice for host %d", __func__,
shost->host_no);
dump_stack();
mutex_unlock(&shost->scan_mutex);
return;
}
wait_for_completion(&data->prev_finished);
<API key>(shost);
spin_lock_irqsave(shost->host_lock, flags);
shost->async_scan = 0;
<API key>(shost->host_lock, flags);
mutex_unlock(&shost->scan_mutex);
spin_lock(&async_scan_lock);
list_del(&data->list);
if (!list_empty(&scanning_hosts)) {
struct async_scan_data *next = list_entry(scanning_hosts.next,
struct async_scan_data, list);
complete(&next->prev_finished);
}
spin_unlock(&async_scan_lock);
<API key>(shost);
scsi_host_put(shost);
kfree(data);
}
static void do_scsi_scan_host(struct Scsi_Host *shost)
{
if (shost->hostt->scan_finished) {
unsigned long start = jiffies;
if (shost->hostt->scan_start)
shost->hostt->scan_start(shost);
while (!shost->hostt->scan_finished(shost, jiffies - start))
msleep(10);
} else {
<API key>(shost, SCAN_WILD_CARD, SCAN_WILD_CARD,
SCAN_WILD_CARD, 0);
}
}
static void do_scan_async(void *_data, async_cookie_t c)
{
struct async_scan_data *data = _data;
struct Scsi_Host *shost = data->shost;
do_scsi_scan_host(shost);
<API key>(data);
}
/**
* scsi_scan_host - scan the given adapter
* @shost: adapter to scan
**/
void scsi_scan_host(struct Scsi_Host *shost)
{
struct async_scan_data *data;
if (strncmp(scsi_scan_type, "none", 4) == 0)
return;
if (<API key>(shost) < 0)
return;
data = <API key>(shost);
if (!data) {
do_scsi_scan_host(shost);
<API key>(shost);
return;
}
/* register with the async subsystem so <API key>()
* will flush this work
*/
async_schedule(do_scan_async, data);
/* <API key>(shost) is called in <API key>() */
}
EXPORT_SYMBOL(scsi_scan_host);
void scsi_forget_host(struct Scsi_Host *shost)
{
struct scsi_device *sdev;
unsigned long flags;
restart:
spin_lock_irqsave(shost->host_lock, flags);
list_for_each_entry(sdev, &shost->__devices, siblings) {
if (sdev->sdev_state == SDEV_DEL)
continue;
<API key>(shost->host_lock, flags);
<API key>(sdev);
goto restart;
}
<API key>(shost->host_lock, flags);
}
/**
* scsi_get_host_dev - Create a scsi_device that points to the host adapter itself
* @shost: Host that needs a scsi_device
*
* Lock status: None assumed.
*
* Returns: The scsi_device or NULL
*
* Notes:
* Attach a single scsi_device to the Scsi_Host - this should
* be made to look like a "pseudo-device" that points to the
* HA itself.
*
* Note - this device is not accessible from any high-level
* drivers (including generics), which is probably not
* optimal. We can add hooks later to attach.
*/
struct scsi_device *scsi_get_host_dev(struct Scsi_Host *shost)
{
struct scsi_device *sdev = NULL;
struct scsi_target *starget;
mutex_lock(&shost->scan_mutex);
if (!<API key>(shost))
goto out;
starget = scsi_alloc_target(&shost->shost_gendev, 0, shost->this_id);
if (!starget)
goto out;
sdev = scsi_alloc_sdev(starget, 0, NULL);
if (sdev)
sdev->borken = 0;
else
scsi_target_reap(starget);
put_device(&starget->dev);
out:
mutex_unlock(&shost->scan_mutex);
return sdev;
}
EXPORT_SYMBOL(scsi_get_host_dev);
/**
* scsi_free_host_dev - Free a scsi_device that points to the host adapter itself
* @sdev: Host device to be freed
*
* Lock status: None assumed.
*
* Returns: Nothing
*/
void scsi_free_host_dev(struct scsi_device *sdev)
{
BUG_ON(sdev->id != sdev->host->this_id);
<API key>(sdev);
}
EXPORT_SYMBOL(scsi_free_host_dev); |
/* ScriptData
SDName: Loch_Modan
SD%Complete: 100
SDComment: Quest support: 3181 (only to argue with pebblebitty to get to searing gorge, before quest rewarded)
SDCategory: Loch Modan
EndScriptData */
/* ContentData
<API key>
EndContentData */
#include "precompiled.h"
bool <API key>(Player* pPlayer, Creature* pCreature)
{
if (pCreature->isQuestGiver())
pPlayer->PrepareQuestMenu(pCreature->GetGUID());
if (!pPlayer-><API key>(3181) == 1)
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Open the gate please, i need to get to Searing Gorge", GOSSIP_SENDER_MAIN, <API key>+1);
pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetGUID());
return true;
}
bool <API key>(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
{
switch(uiAction)
{
case <API key>+1:
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "But i need to get there, now open the gate!", GOSSIP_SENDER_MAIN, <API key> + 2);
pPlayer->SEND_GOSSIP_MENU(1833, pCreature->GetGUID());
break;
case <API key>+2:
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Ok, so what is this other way?", GOSSIP_SENDER_MAIN, <API key> + 3);
pPlayer->SEND_GOSSIP_MENU(1834, pCreature->GetGUID());
break;
case <API key>+3:
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Doesn't matter, i'm invulnerable.", GOSSIP_SENDER_MAIN, <API key> + 4);
pPlayer->SEND_GOSSIP_MENU(1835, pCreature->GetGUID());
break;
case <API key>+4:
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Yes...", GOSSIP_SENDER_MAIN, <API key> + 5);
pPlayer->SEND_GOSSIP_MENU(1836, pCreature->GetGUID());
break;
case <API key>+5:
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Ok, i'll try to remember that.", GOSSIP_SENDER_MAIN, <API key> + 6);
pPlayer->SEND_GOSSIP_MENU(1837, pCreature->GetGUID());
break;
case <API key>+6:
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "A key? Ok!", GOSSIP_SENDER_MAIN, <API key> + 7);
pPlayer->SEND_GOSSIP_MENU(1838, pCreature->GetGUID());
break;
case <API key>+7:
pPlayer->CLOSE_GOSSIP_MENU();
break;
}
return true;
}
void AddSC_loch_modan()
{
Script *newscript;
newscript = new Script;
newscript->Name = "<API key>";
newscript->pGossipHello = &<API key>;
newscript->pGossipSelect = &<API key>;
newscript->RegisterSelf();
} |
!! ======================================================================
!! Atomistica - Interatomic potential library and molecular dynamics code
!! https://github.com/Atomistica/atomistica
!!
!! Copyright (2005-2020) Lars Pastewka <lars.pastewka@imtek.uni-freiburg.de>
!! and others. See the AUTHORS file in the top-level Atomistica directory.
!!
!! 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 <http:
!! ======================================================================
! H0 <API key>
! H0 X
! H0 X libAtoms+QUIP: atomistic simulation library
! H0 X
! H0 X Portions of this code were written by
! H0 X Albert Bartok-Partay, Silvia Cereda, Gabor Csanyi, James Kermode,
! H0 X Ivan Solt, Wojciech Szlachta, Csilla Varnai, Steven Winfield.
! H0 X
! H0 X Copyright 2006-2010.
! H0 X
! H0 X These portions of the source code are released under the GNU General
! H0 X Public License, version 2, http:
! H0 X
! H0 X If you would like to license the source code under different terms,
! H0 X please contact Gabor Csanyi, gabor@csanyi.net
! H0 X
! H0 X Portions of this code were written by Noam Bernstein as part of
! H0 X his employment for the U.S. Government, and are not subject
! H0 X to copyright in the USA.
! H0 X
! H0 X
! H0 X When using this software, please cite the following reference:
! H0 X
! H0 X http:
! H0 X
! H0 X Additional contributions by
! H0 X Alessio Comisso, Chiara Gattinoni, and Gianpietro Moras
! H0 X
! H0 <API key>
!<API key>
!X
!X Exception handling
!X
!% This modules keeps track an error stack. When an error occurs a list
!% of files/lines that allow to trace back the position in the code where
!% the error occured first is constructed.
!%
!X
!<API key>
module error_module
use, intrinsic :: iso_c_binding
use c_f
implicit none
private
!
integer, parameter :: ERROR_STACK_SIZE = 100
integer, parameter :: ERROR_DOC_LENGTH = 1000
integer, parameter :: ERROR_FN_LENGTH = 100
!
!% Error kinds
integer, parameter :: ERROR_NONE = 0
integer, parameter :: ERROR_UNSPECIFIED = -1
integer, parameter :: ERROR_IO = -2
integer, parameter :: ERROR_IO_EOF = -3
integer, parameter :: ERROR_MPI = -4
integer, parameter :: <API key> = -5
!% Strings
integer, parameter :: ERROR_STR_LENGTH = 20
character(ERROR_STR_LENGTH), parameter :: <API key> = &
"unspecified"
character(ERROR_STR_LENGTH), parameter :: ERROR_STR_IO = "IO"
character(ERROR_STR_LENGTH), parameter :: ERROR_STR_IO_EOF = "IO EOF"
character(ERROR_STR_LENGTH), parameter :: ERROR_STR_MPI = "MPI"
character(ERROR_STR_LENGTH), parameter :: <API key> = &
"MINIM_NOT_CONVERGED"
character(ERROR_STR_LENGTH), parameter :: ERROR_STRINGS(5) = &
(/ <API key>, ERROR_STR_IO, ERROR_STR_IO_EOF, &
ERROR_STR_MPI, <API key> /)
public :: ERROR_NONE, ERROR_UNSPECIFIED, ERROR_IO, ERROR_IO_EOF, ERROR_MPI
public :: <API key>
!
type ErrorDescriptor
integer :: kind !% kind of error
logical :: has_doc !% does the documentation string exist?
character(ERROR_DOC_LENGTH) :: doc !% documentation string
character(ERROR_FN_LENGTH) :: fn !% file name where the error occured
integer :: line !% code line where the error occured
endtype ErrorDescriptor
!
save
integer :: <API key> = 0 !% If this is zero, no error has occured
type(ErrorDescriptor) :: error_stack(ERROR_STACK_SIZE) !% Error stack
!
public :: system_abort
interface system_abort
module procedure <API key>
endinterface
public :: error_abort
interface error_abort
module procedure <API key>
endinterface
public :: error_clear_stack
public :: push_error, <API key>
public :: <API key>, clear_error
contains
!% Push a new error callback to the stack
subroutine push_error(fn, line, kind)
implicit none
character(*), intent(in) :: fn
integer, intent(in) :: line
integer, intent(in), optional :: kind
!
!$omp critical
<API key> = <API key> + 1
if (<API key> > ERROR_STACK_SIZE) then
<API key> = <API key> - 1
write(*,*) <API key>()
call system_abort("Fatal error: Error stack size too small.")
endif
if (present(kind)) then
error_stack(<API key>)%kind = kind
else
error_stack(<API key>)%kind = ERROR_UNSPECIFIED
endif
error_stack(<API key>)%fn = fn
error_stack(<API key>)%line = line
!$omp end critical
endsubroutine push_error
subroutine error_clear_stack() bind(C)
<API key> = 0
end subroutine error_clear_stack
!% Push a new information string onto the error stack
subroutine <API key>(doc, fn, line, kind)
implicit none
character(*), intent(in) :: doc
character(*), intent(in) :: fn
integer, intent(in) :: line
integer, intent(in), optional :: kind
!
!$omp critical
<API key> = <API key> + 1
if (<API key> > ERROR_STACK_SIZE) then
<API key> = <API key> - 1
write(*,*) <API key>()
call system_abort("Fatal error: Error stack size too small.")
endif
if (present(kind)) then
error_stack(<API key>)%kind = kind
else
error_stack(<API key>)%kind = ERROR_UNSPECIFIED
endif
error_stack(<API key>)%fn = fn
error_stack(<API key>)%line = line
error_stack(<API key>)%has_doc = .true.
error_stack(<API key>)%doc = doc
!$omp end critical
endsubroutine <API key>
!% This error has been handled, clear it.
subroutine clear_error(error)
implicit none
integer, intent(inout) :: error
!
error = ERROR_NONE
<API key> = 0
endsubroutine clear_error
!% Construct a string describing the error.
function <API key>(error) result(str)
use iso_c_binding
implicit none
integer, intent(inout), optional :: error
character(ERROR_DOC_LENGTH) :: str
!
integer :: i
character(10) :: linestr
!
if (present(error)) then
if (-error < lbound(ERROR_STRINGS, 1) .or. &
-error > ubound(ERROR_STRINGS, 1)) then
!call system_abort("Fatal: error descriptor out of bounds. Did you initialise the error variable?")
str = "Traceback (most recent call last - error descriptor out of bounds)"
else
str = "Traceback (most recent call last - error kind " &
// trim(ERROR_STRINGS(-error)) // "):"
endif
else
str = "Traceback (most recent call last)"
endif
do i = <API key>, 1, -1
write (linestr, '(I10)') error_stack(i)%line
if (error_stack(i)%has_doc) then
str = trim(str) // C_NEW_LINE // &
' File "'
trim(error_stack(i)%fn)
'", line '
trim(adjustl(linestr))
C_NEW_LINE
" "
trim(error_stack(i)%doc)
else
str = trim(str) // C_NEW_LINE // &
' File "'
trim(error_stack(i)%fn)
'", line '
trim(adjustl(linestr))
endif
enddo
<API key> = 0
if (present(error)) then
error = ERROR_NONE
endif
endfunction <API key>
!% Quit with an error message. Calls 'MPI_Abort' for MPI programs.
subroutine <API key>(message)
character(*), intent(in) :: message
#ifdef <API key>
integer :: j
#endif /* <API key> */
#ifdef SIGNAL_ON_ABORT
integer :: status
integer, parameter :: SIGUSR1 = 30
#endif
#ifdef _MPI
integer::PRINT_ALWAYS
include "mpif.h"
#endif
#ifdef _MPI
write(*, fmt='(a,i0," ",a)') 'SYSTEM ABORT: proc=',-1,<API key>(trim(message),100)
#else
write(*, fmt='(a," ",a)') 'SYSTEM ABORT:', <API key>(trim(message),100)
#endif
#ifdef _MPI
call MPI_Abort(MPI_COMM_WORLD, 1, PRINT_ALWAYS)
#endif
#ifdef <API key>
! Cause an integer divide by zero error to persuade
! ifort to issue a traceback
j = 1/0
#endif
#ifdef DUMP_CORE_ON_ABORT
call fabort()
#else
#ifdef SIGNAL_ON_ABORT
! send ourselves a USR1 signal rather than aborting
call kill(getpid(), SIGUSR1, status)
#else
stop 999
#endif
#endif
end subroutine <API key>
!% Stop program execution since this error is not handled properly
subroutine <API key>(error)
implicit none
integer, intent(inout), optional :: error
!
! This is for compatibility with quippy, change to error_abort
call system_abort(<API key>(error))
endsubroutine <API key>
pure function <API key>(str, line_len) result(length)
character(len=*), intent(in) :: str
integer, intent(in) :: line_len
integer :: length
length = len_trim(str)+2*len_trim(str)/line_len+3
end function <API key>
function <API key>(str, line_len) result(lb_str)
character(len=*), intent(in) :: str
integer, intent(in) :: line_len
character(len=<API key>(str, line_len)) :: lb_str
logical :: word_break
integer :: copy_len, last_space, next_cr
character(len=len(lb_str)) :: tmp_str
character :: quip_new_line
#ifdef NO_F2003_NEW_LINE
quip_new_line = char(13)
#else
quip_new_line = new_line(' ')
#endif
lb_str=""
tmp_str=trim(str)
do while (len_trim(tmp_str) > 0)
next_cr = scan(trim(tmp_str),quip_new_line)
if (next_cr > 0) then
copy_len = min(len_trim(tmp_str),line_len,next_cr)
else
copy_len = min(len_trim(tmp_str),line_len)
endif
if (copy_len < len_trim(tmp_str) .and. tmp_str(copy_len+1:copy_len+1) /= " ") then
last_space=scan(tmp_str(1:copy_len), " ", .true.)
if ( last_space > 0 .and. (len_trim(tmp_str(1:copy_len)) - last_space) < 4) then
copy_len=last_space
endif
endif
if (len_trim(lb_str) > 0) then ! we already have some text, add newline before concatenating next line
if (lb_str(len_trim(lb_str):len_trim(lb_str)) == quip_new_line) then
lb_str = trim(lb_str)//trim(tmp_str(1:copy_len))
else
lb_str = trim(lb_str)//quip_new_line//trim(tmp_str(1:copy_len))
endif
else ! just concatenate next line
lb_str = trim(tmp_str(1:copy_len))
endif
! if we broke in mid word, add "-"
word_break = .true.
if (tmp_str(copy_len:copy_len) == " ") then ! we broke right after a space, so no wordbreak
word_break = .false.
else ! we broke after a character
if (copy_len < len_trim(tmp_str)) then ! there's another character after this one, check if it's a space
if (tmp_str(copy_len+1:copy_len+1) == " ") then
word_break = .false.
endif
else ! we broke after the last character
word_break = .false.
endif
endif
if (word_break) lb_str = trim(lb_str)
tmp_str(1:copy_len) = ""
tmp_str=adjustl(tmp_str)
end do
end function <API key>
!>
!! Invoke errors from C/C++
!<
subroutine <API key>(doc, fn, line, kind) bind(C)
use, intrinsic :: iso_c_binding
implicit none
type(C_PTR), value :: doc, fn
integer(C_INT), value :: line, kind
call <API key>(a2s(c_f_string(doc)), a2s(c_f_string(fn)), line,&
kind)
endsubroutine <API key>
!>
!! Invoke errors from C/C++
!<
subroutine c_push_error(fn, line, kind) bind(C)
use, intrinsic :: iso_c_binding
implicit none
type(C_PTR), value :: fn
integer(C_INT), value :: line, kind
call push_error(a2s(c_f_string(fn)), line, kind)
endsubroutine c_push_error
!>
!! Invoke errors from C/C++
!<
subroutine c_error_abort(error) bind(C)
implicit none
integer(C_INT), value :: error
!
! This is for compatibility with quippy, change to error_abort
call system_abort(<API key>(error))
endsubroutine c_error_abort
endmodule error_module |
Date.format = 'yyyy-mm-dd';
$(function()
{
$('.date-pick').datePicker({startDate:'06/07/1980'});
}); |
/* A Bison parser, made by GNU Bison 3.0.2. */
/* C LALR(1) parser skeleton written by Richard Stallman, by
simplifying the original so-called "semantic" parser. */
/* All symbols defined below should begin with yy or YY, to avoid
infringing on user name space. This should be done even for local
variables, as they might otherwise be expanded by user macros.
There are some unavoidable exceptions within include files to
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "3.0.2"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
/* Pure parsers. */
#define YYPURE 0
/* Push parsers. */
#define YYPUSH 0
/* Pull parsers. */
#define YYPULL 1
/* Copy the first part of user declarations. */
#line 11 "parse_y.y" /* yacc.c:339 */
/* grammar to parse ASCII input of PCB description
*/
#include "config.h"
#include "global.h"
#include "create.h"
#include "data.h"
#include "error.h"
#include "file.h"
#include "mymem.h"
#include "misc.h"
#include "parse_l.h"
#include "polygon.h"
#include "remove.h"
#include "rtree.h"
#include "strflags.h"
#include "thermal.h"
#ifdef HAVE_LIBDMALLOC
# include <dmalloc.h>
#endif
RCSID("$Id$");
static LayerTypePtr Layer;
static PolygonTypePtr Polygon;
static SymbolTypePtr Symbol;
static int pin_num;
static LibraryMenuTypePtr Menu;
static bool LayerFlag[MAX_LAYER + 2];
extern char *yytext; /* defined by LEX */
extern PCBTypePtr yyPCB;
extern DataTypePtr yyData;
extern ElementTypePtr yyElement;
extern FontTypePtr yyFont;
extern int yylineno; /* linenumber */
extern char *yyfilename; /* in this file */
static char *layer_group_string;
static <API key> attr_list;
int yyerror(const char *s);
int yylex();
static int check_file_version (int);
static void do_measure (PLMeasure *m, Coord i, double d, int u);
#define M(r,f,d) do_measure (&(r), f, d, 1)
/* Macros for interpreting what "measure" means - integer value only,
old units (mil), or new units (cmil). */
#define IV(m) integer_value (m)
#define OU(m) old_units (m)
#define NU(m) new_units (m)
static int integer_value (PLMeasure m);
static Coord old_units (PLMeasure m);
static Coord new_units (PLMeasure m);
#define YYDEBUG 1
#define YYERROR_VERBOSE 1
#include "parse_y.h"
#line 161 "parse_y.tab.c" /* yacc.c:339 */
# ifndef YY_NULLPTR
# if defined __cplusplus && 201103L <= __cplusplus
# define YY_NULLPTR nullptr
# else
# define YY_NULLPTR 0
# endif
# endif
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 0
#endif
/* In a future release of Bison, this section will be replaced
by #include "parse_y.tab.h". */
#ifndef <API key>
# define <API key>
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
FLOATING = 258,
INTEGER = 259,
CHAR_CONST = 260,
STRING = 261,
T_FILEVERSION = 262,
T_PCB = 263,
T_LAYER = 264,
T_VIA = 265,
T_RAT = 266,
T_LINE = 267,
T_ARC = 268,
T_RECTANGLE = 269,
T_TEXT = 270,
T_ELEMENTLINE = 271,
T_ELEMENT = 272,
T_PIN = 273,
T_PAD = 274,
T_GRID = 275,
T_FLAGS = 276,
T_SYMBOL = 277,
T_SYMBOLLINE = 278,
T_CURSOR = 279,
T_ELEMENTARC = 280,
T_MARK = 281,
T_GROUPS = 282,
T_STYLES = 283,
T_POLYGON = 284,
T_POLYGON_HOLE = 285,
T_NETLIST = 286,
T_NET = 287,
T_CONN = 288,
T_AREA = 289,
T_THERMAL = 290,
T_DRC = 291,
T_ATTRIBUTE = 292,
T_UMIL = 293,
T_CMIL = 294,
T_MIL = 295,
T_IN = 296,
T_NM = 297,
T_UM = 298,
T_MM = 299,
T_M = 300,
T_KM = 301
};
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE YYSTYPE;
union YYSTYPE
{
#line 109 "parse_y.y" /* yacc.c:355 */
int integer;
double number;
char *string;
FlagType flagtype;
PLMeasure measure;
#line 256 "parse_y.tab.c" /* yacc.c:355 */
};
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE yylval;
int yyparse (void);
#endif /* !<API key> */
/* Copy the second part of user declarations. */
#line 271 "parse_y.tab.c" /* yacc.c:358 */
#ifdef short
# undef short
#endif
#ifdef YYTYPE_UINT8
typedef YYTYPE_UINT8 yytype_uint8;
#else
typedef unsigned char yytype_uint8;
#endif
#ifdef YYTYPE_INT8
typedef YYTYPE_INT8 yytype_int8;
#else
typedef signed char yytype_int8;
#endif
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
typedef unsigned short int yytype_uint16;
#endif
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
typedef short int yytype_int16;
#endif
#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
# define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
# define YYSIZE_T size_t
# elif ! defined YYSIZE_T
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
# define YYSIZE_T unsigned int
# endif
#endif
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(Msgid) Msgid
# endif
#endif
#ifndef YY_ATTRIBUTE
# if (defined __GNUC__ \
&& (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
|| defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
# else
# define YY_ATTRIBUTE(Spec) /* empty */
# endif
#endif
#ifndef YY_ATTRIBUTE_PURE
# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
#endif
#ifndef YY_ATTRIBUTE_UNUSED
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
#endif
#if !defined _Noreturn \
&& (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
# if defined _MSC_VER && 1200 <= _MSC_VER
# define _Noreturn __declspec (noreturn)
# else
# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(E) /* empty */
#endif
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define <API key> \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
_Pragma ("GCC diagnostic ignored \"-<API key>\"")
# define <API key> \
_Pragma ("GCC diagnostic pop")
#else
# define YY_INITIAL_VALUE(Value) Value
#endif
#ifndef <API key>
# define <API key>
# define <API key>
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
#if ! defined yyoverflow || YYERROR_VERBOSE
/* The parser invokes alloca or malloc; define the necessary symbols. */
# ifdef YYSTACK_USE_ALLOCA
# if YYSTACK_USE_ALLOCA
# ifdef __GNUC__
# define YYSTACK_ALLOC __builtin_alloca
# elif defined <API key>
# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
# elif defined _AIX
# define YYSTACK_ALLOC __alloca
# elif defined _MSC_VER
# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
# define alloca _alloca
# else
# define YYSTACK_ALLOC alloca
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
/* Use EXIT_SUCCESS as a witness for stdlib.h. */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# endif
# endif
# endif
# ifdef YYSTACK_ALLOC
/* Pacify GCC's 'empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# ifndef <API key>
/* The OS might guarantee only one guard page at the bottom of the stack,
and a page size can be as small as 4096 bytes. So we cannot safely
invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
to allow for a few compiler-allocated temporary stack slots. */
# define <API key> 4032 /* reasonable circa 2006 */
# endif
# else
# define YYSTACK_ALLOC YYMALLOC
# define YYSTACK_FREE YYFREE
# ifndef <API key>
# define <API key> YYSIZE_MAXIMUM
# endif
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
&& ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free)))
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
# if ! defined malloc && ! defined EXIT_SUCCESS
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
# if ! defined free && ! defined EXIT_SUCCESS
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# endif
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
#if (! defined yyoverflow \
&& (! defined __cplusplus \
|| (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
{
yytype_int16 yyss_alloc;
YYSTYPE yyvs_alloc;
};
/* The size of the maximum gap between one aligned stack and the next. */
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
/* The size of an array large to enough to hold all stacks, each with
N elements. */
# define YYSTACK_BYTES(N) \
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ YYSTACK_GAP_MAXIMUM)
# define YYCOPY_NEEDED 1
/* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (0)
#endif
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from SRC to DST. The source and destination do
not overlap. */
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(Dst, Src, Count) \
__builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
# else
# define YYCOPY(Dst, Src, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(Dst)[yyi] = (Src)[yyi]; \
} \
while (0)
# endif
# endif
#endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 10
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 584
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 51
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 107
/* YYNRULES -- Number of rules. */
#define YYNRULES 204
/* YYNSTATES -- Number of states. */
#define YYNSTATES 616
/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2
#define YYMAXUTOK 301
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
as returned by yylex, without out-of-bounds checking. */
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
49, 50, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 47, 2, 48, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46
};
#if YYDEBUG
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
0, 135, 135, 136, 137, 138, 162, 162, 217, 217,
228, 228, 247, 248, 253, 253, 293, 295, 325, 331,
337, 366, 367, 368, 371, 379, 392, 424, 430, 436,
452, 454, 479, 481, 512, 514, 515, 516, 520, 530,
541, 568, 572, 576, 604, 608, 652, 660, 668, 672,
673, 677, 678, 682, 683, 683, 684, 685, 687, 687,
694, 698, 699, 700, 701, 702, 738, 748, 759, 769,
779, 815, 820, 852, 851, 875, 876, 880, 881, 885,
886, 887, 888, 889, 890, 892, 897, 898, 899, 900,
900, 901, 931, 940, 949, 997, 1006, 1015, 1052, 1062,
1080, 1130, 1129, 1168, 1170, 1175, 1174, 1181, 1183, 1188,
1192, 1252, 1253, 1254, 1255, 1256, 1264, 1263, 1282, 1281,
1300, 1299, 1320, 1318, 1342, 1340, 1421, 1422, 1426, 1427,
1428, 1429, 1430, 1432, 1437, 1442, 1447, 1452, 1457, 1462,
1462, 1466, 1467, 1471, 1472, 1473, 1474, 1476, 1482, 1489,
1494, 1499, 1499, 1540, 1552, 1564, 1575, 1591, 1645, 1659,
1672, 1683, 1694, 1695, 1699, 1700, 1722, 1724, 1740, 1759,
1760, 1763, 1765, 1766, 1787, 1794, 1810, 1811, 1815, 1820,
1821, 1825, 1826, 1849, 1848, 1858, 1859, 1863, 1864, 1883,
1913, 1921, 1922, 1926, 1927, 1932, 1933, 1934, 1935, 1936,
1937, 1938, 1939, 1940, 1941
};
#endif
#if YYDEBUG || YYERROR_VERBOSE || 0
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
"$end", "error", "$undefined", "FLOATING", "INTEGER", "CHAR_CONST",
"STRING", "T_FILEVERSION", "T_PCB", "T_LAYER", "T_VIA", "T_RAT",
"T_LINE", "T_ARC", "T_RECTANGLE", "T_TEXT", "T_ELEMENTLINE", "T_ELEMENT",
"T_PIN", "T_PAD", "T_GRID", "T_FLAGS", "T_SYMBOL", "T_SYMBOLLINE",
"T_CURSOR", "T_ELEMENTARC", "T_MARK", "T_GROUPS", "T_STYLES",
"T_POLYGON", "T_POLYGON_HOLE", "T_NETLIST", "T_NET", "T_CONN", "T_AREA",
"T_THERMAL", "T_DRC", "T_ATTRIBUTE", "T_UMIL", "T_CMIL", "T_MIL", "T_IN",
"T_NM", "T_UM", "T_MM", "T_M", "T_KM", "'['", "']'", "'('", "')'",
"$accept", "parse", "parsepcb", "$@1", "$@2", "parsedata", "$@3",
"pcbfont", "parsefont", "$@4", "pcbfileversion", "pcbname", "pcbgrid",
"pcbgridold", "pcbgridnew", "pcbhigrid", "pcbcursor", "polyarea",
"pcbthermal", "pcbdrc", "pcbdrc1", "pcbdrc2", "pcbdrc3", "pcbflags",
"pcbgroups", "pcbstyles", "pcbdata", "pcbdefinitions", "pcbdefinition",
"$@5", "$@6", "via", "via_hi_format", "via_2.0_format", "via_1.7_format",
"via_newformat", "via_oldformat", "rats", "layer", "$@7", "layerdata",
"layerdefinitions", "layerdefinition", "$@8", "line_hi_format",
"line_1.7_format", "line_oldformat", "arc_hi_format", "arc_1.7_format",
"arc_oldformat", "text_oldformat", "text_newformat", "text_hi_format",
"polygon_format", "$@9", "polygonholes", "polygonhole", "$@10",
"polygonpoints", "polygonpoint", "element", "element_oldformat", "$@11",
"element_1.3.4_format", "$@12", "element_newformat", "$@13",
"element_1.7_format", "$@14", "element_hi_format", "$@15",
"elementdefinitions", "elementdefinition", "$@16", "relementdefs",
"relementdef", "$@17", "pin_hi_format", "pin_1.7_format",
"pin_1.6.3_format", "pin_newformat", "pin_oldformat", "pad_hi_format",
"pad_1.7_format", "pad_newformat", "pad", "flags", "symbols", "symbol",
"symbolhead", "symbolid", "symboldata", "symboldefinition",
"hiressymbol", "pcbnetlist", "pcbnetdef", "nets", "netdefs", "net",
"$@18", "connections", "conndefs", "conn", "attribute", "opt_string",
"number", "measure", YY_NULLPTR
};
#endif
# ifdef YYPRINT
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
(internal) symbol number NUM (which must be that of a token). */
static const yytype_uint16 yytoknum[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
295, 296, 297, 298, 299, 300, 301, 91, 93, 40,
41
};
# endif
#define YYPACT_NINF -445
#define <API key>(Yystate) \
(!!((Yystate) == (-445)))
#define YYTABLE_NINF -90
#define <API key>(Yytable_value) \
0
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
static const yytype_int16 yypact[] =
{
15, -445, 27, -445, 32, 61, -445, 189, -445, 67,
-445, 46, 86, 30, -445, -445, -445, -445, -445, -445,
-445, 52, 120, 136, -445, 147, -445, 75, 61, -445,
-445, -445, -445, -445, -445, -445, -445, 144, 67, -445,
-445, 109, 184, 114, 47, 84, 124, 44, 44, 44,
44, -445, 80, -445, -445, 29, 29, -445, -4, 92,
139, 143, 228, 135, -445, -445, -445, -445, -445, 157,
164, 169, 173, -445, -445, 211, 44, 44, 44, 44,
180, -445, -445, 44, 44, 241, -445, -445, -445, -445,
44, 4, 44, 44, 255, 153, 186, 195, 44, 196,
-445, -445, -445, -445, -445, -445, -445, -445, -445, 44,
44, 191, 204, 206, 168, 174, 44, 44, 44, -445,
44, 44, 44, 44, 44, 192, 210, 236, 102, 44,
-445, 208, 44, 115, 44, 44, 209, 224, 225, 44,
44, 230, 229, 44, 44, 44, 44, 44, 242, 260,
44, 44, 44, 334, 281, 44, 349, 133, 44, 44,
-445, -445, -445, 44, 44, -445, -445, 357, -1, 44,
44, 291, 44, 315, 356, -445, -445, -445, 44, 44,
44, 328, -445, 44, 331, 383, 140, 384, 393, 44,
44, 351, 350, -445, 354, 353, -445, 358, 44, 355,
378, 44, 44, 44, 359, 294, 401, -445, 360, 405,
406, 47, 407, 44, 44, -445, -445, -445, -445, -445,
44, 299, 364, 386, 44, 44, 411, -445, 279, 280,
367, 297, 368, 369, 294, -445, 75, -445, -445, -445,
-445, -445, -445, -445, -445, -445, -445, 47, -445, 372,
414, 375, 374, 379, 380, 44, 381, 382, 422, 298,
412, 44, 60, 385, 41, 44, 44, 44, 44, 44,
44, 44, 47, -445, -445, -445, 396, -445, 395, -445,
-445, -445, -445, 8, -445, -445, 397, 423, 427, 151,
-445, 44, 398, 44, 400, 301, 402, 403, 302, 305,
155, -445, 75, -445, -445, -445, -445, -445, 44, 44,
44, 44, 44, 44, 44, 408, -445, -445, -445, 10,
-445, 409, 410, 415, 47, 404, 446, -445, 44, 44,
44, 44, 44, 44, 44, 44, -445, -445, -445, 44,
44, 44, 44, 44, 44, 44, 413, -445, 44, -445,
-445, 424, -445, -445, 416, -445, 425, 41, 44, 44,
44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
44, 44, 207, -445, 426, 428, 430, 41, 431, 178,
44, 44, 44, 44, 44, 44, 429, 432, 44, 44,
44, 44, 452, 453, 457, 470, 320, -445, 434, -445,
222, -445, -445, 44, 44, 226, 44, 44, 44, -445,
-445, 44, 44, 44, 44, 442, 47, 443, 459, 44,
44, -445, 320, 449, 108, -445, 108, 44, 44, 490,
489, 44, 44, 44, 47, 5, 44, 44, -445, 448,
-445, 447, 44, 44, -12, -445, 450, 460, 449, -445,
321, 326, 327, 335, 218, -445, 75, -445, -445, -445,
-445, 251, 461, 468, 471, 387, 492, 44, 44, 463,
472, -445, 44, 79, -445, -445, 479, 480, 451, -445,
-445, 525, -445, -445, 44, 44, 44, 44, 44, 44,
44, 44, -445, -445, -445, -445, -445, -445, -445, 482,
529, 392, 44, 44, -445, -445, 47, 484, 531, -445,
-445, -445, 530, 44, 44, 44, 44, 44, 44, 44,
44, -445, 491, 493, 538, 496, 495, 498, -445, 497,
320, 499, 44, 44, 44, 44, 44, 44, 44, 44,
-445, -445, 500, -445, -445, -445, -445, 501, 503, 44,
44, 44, 44, 44, 44, 44, 44, -445, -445, -445,
44, 44, 44, 44, 44, 44, 44, 44, 515, 505,
504, 44, 44, 44, 44, 44, 44, 506, 507, 515,
-445, -445, -445, 550, 552, 44, 44, 44, 44, 553,
-445, -445, 554, 555, 556, 557, 516, 517, 518, 47,
561, 560, 563, -445, -445, -445, 522, 521, 47, 568,
-445, -445, 526, 523, -445, -445
};
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
Performed when YYTABLE does not specify something else to do. Zero
means the default is an error. */
static const yytype_uint8 yydefact[] =
{
0, 5, 0, 2, 16, 0, 3, 0, 4, 0,
1, 0, 0, 0, 9, 111, 112, 113, 114, 115,
60, 0, 0, 0, 11, 0, 51, 0, 0, 53,
61, 62, 63, 64, 65, 56, 57, 0, 15, 164,
171, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 52, 0, 55, 59, 0, 0, 165, 0, 0,
0, 0, 0, 29, 21, 22, 23, 162, 163, 0,
0, 0, 0, 193, 194, 195, 0, 0, 0, 0,
0, 169, 170, 0, 0, 0, 166, 172, 173, 17,
0, 0, 0, 0, 0, 30, 0, 0, 0, 192,
196, 197, 198, 199, 200, 201, 202, 203, 204, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 18,
0, 0, 0, 0, 0, 0, 32, 0, 0, 0,
191, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 34,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
190, 167, 168, 0, 0, 20, 19, 0, 0, 0,
0, 0, 0, 0, 43, 35, 36, 37, 0, 0,
0, 0, 73, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 24, 0, 0, 31, 0, 0, 0,
45, 0, 0, 0, 0, 76, 0, 70, 0, 0,
0, 0, 0, 0, 0, 26, 25, 28, 27, 33,
0, 0, 0, 48, 0, 0, 0, 116, 0, 0,
0, 0, 0, 0, 75, 77, 0, 79, 80, 81,
82, 83, 84, 88, 87, 86, 91, 0, 69, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
13, 0, 0, 0, 139, 0, 0, 0, 0, 0,
0, 0, 0, 74, 78, 90, 0, 68, 0, 71,
72, 175, 174, 0, 41, 42, 0, 0, 0, 0,
12, 0, 194, 0, 0, 0, 0, 0, 0, 0,
139, 126, 0, 128, 129, 130, 131, 132, 0, 0,
0, 0, 0, 0, 0, 0, 66, 67, 38, 0,
44, 0, 0, 177, 0, 0, 0, 118, 0, 0,
0, 0, 0, 0, 0, 0, 117, 127, 140, 0,
0, 0, 0, 0, 0, 0, 0, 39, 0, 47,
46, 0, 7, 176, 0, 120, 0, 139, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 101, 0, 0, 0, 139, 0, 139,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 107, 40, 0, 124,
139, 122, 119, 0, 0, 0, 0, 0, 0, 137,
138, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 103, 107, 180, 151, 121, 151, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 85, 0,
98, 0, 0, 0, 0, 108, 0, 0, 179, 181,
0, 0, 0, 0, 151, 141, 0, 144, 143, 146,
145, 151, 0, 0, 0, 0, 0, 0, 0, 0,
0, 94, 0, 0, 100, 99, 0, 0, 0, 102,
104, 0, 178, 182, 0, 0, 0, 0, 0, 0,
0, 0, 125, 142, 152, 123, 133, 134, 157, 0,
0, 0, 0, 0, 92, 93, 0, 194, 0, 110,
109, 105, 0, 0, 0, 0, 0, 0, 0, 0,
0, 156, 0, 0, 0, 0, 0, 0, 97, 0,
107, 0, 0, 0, 0, 0, 0, 0, 0, 0,
155, 161, 0, 135, 136, 95, 96, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 160, 106, 183,
0, 0, 0, 0, 0, 0, 0, 0, 186, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 185,
187, 147, 148, 0, 0, 0, 0, 0, 0, 0,
184, 188, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 149, 150, 189, 0, 0, 0, 0,
153, 154, 0, 0, 158, 159
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int16 yypgoto[] =
{
-445, -445, -445, -445, -445, -445, -445, -445, 316, -445,
-445, -445, -445, -445, -445, -445, -445, -445, -445, -445,
-445, -445, -445, -445, -445, -445, 286, -445, 558, -445,
-445, -445, -445, -445, -445, -445, -445, -445, -445, -445,
-445, -445, 343, -445, -445, -445, -445, -445, -445, -445,
-445, -445, -445, -445, -445, -445, -445, -445, -416, -445,
551, -445, -445, -445, -445, -445, -445, -445, -445, -445,
-445, -336, -280, -445, 152, -444, -445, -445, -445, -445,
-445, -445, -445, -445, -445, -445, -207, -445, 542, -445,
528, -445, -445, -445, -445, -445, -445, -445, 134, -445,
-445, -445, 2, -231, -445, -47, -48
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int16 yydefgoto[] =
{
-1, 2, 3, 4, 5, 6, 7, 289, 8, 9,
12, 43, 63, 64, 65, 66, 95, 126, 149, 174,
175, 176, 177, 200, 223, 260, 24, 25, 26, 27,
28, 29, 30, 31, 32, 33, 34, 35, 36, 205,
233, 234, 235, 236, 237, 238, 239, 240, 241, 242,
243, 244, 245, 246, 396, 444, 480, 530, 421, 422,
14, 15, 264, 16, 357, 17, 377, 18, 426, 19,
424, 300, 301, 302, 454, 455, 456, 457, 458, 303,
304, 305, 459, 460, 306, 307, 69, 38, 39, 40,
83, 58, 87, 88, 352, 353, 447, 448, 449, 568,
578, 579, 580, 53, 131, 75, 76
};
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule whose
number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_int16 yytable[] =
{
77, 78, 79, 192, 251, 275, 445, 73, 74, 470,
493, 73, 74, 73, 74, -10, 1, 493, 478, 85,
337, 379, -6, -6, -10, -10, -10, 10, 109, 110,
111, 112, -8, 81, 82, 114, 115, -14, 479, 11,
276, 400, 118, 120, 121, 122, 86, 73, 74, 193,
129, 67, -10, 68, 119, 471, 318, 295, 347, 296,
297, 132, 133, 73, 292, 315, 298, 299, 139, 140,
141, 338, 142, 143, 144, 145, 146, 44, 13, 45,
152, 153, 73, 507, 155, 157, 158, 159, 70, 37,
71, 163, 164, 41, 42, 167, 168, 169, 170, 337,
171, 46, 178, 179, 180, 73, 74, 183, 151, 186,
187, 188, 52, 59, 547, 189, 190, 354, 73, 74,
337, 156, 194, 195, 450, 197, 451, 452, 72, 80,
201, 202, 203, 453, 62, 206, 73, 74, 210, 185,
89, 213, 214, 73, 74, 90, 209, -49, 20, 91,
220, -50, 20, 224, 225, 226, 21, 22, 23, 94,
21, 22, 23, 96, -58, 253, 254, 47, -58, 48,
97, 295, 255, 296, 297, 98, 261, 262, -49, 99,
298, 299, -50, 49, -54, 50, 113, 125, -54, -50,
20, 55, 127, 56, 295, 134, 296, 297, 21, 22,
23, 128, 130, 298, 299, 336, -58, 283, 135, 439,
73, 74, 136, 394, 291, 293, 137, 308, 309, 310,
311, 312, 313, 314, 138, 494, -54, 469, 402, 73,
74, 60, 429, 61, 450, 319, 451, 452, 295, 147,
296, 297, 150, 453, 324, 148, 326, 298, 299, 100,
101, 102, 103, 104, 105, 106, 107, 108, 154, 160,
339, 340, 341, 342, 343, 344, 345, 450, 492, 451,
452, 348, 425, 161, 162, 92, 453, 93, 165, 166,
358, 359, 360, 361, 362, 363, 364, 365, 116, 172,
117, 366, 367, 368, 369, 370, 173, 371, 372, 527,
374, 495, 123, 256, 124, 257, 228, 229, 230, 231,
380, 381, 382, 383, 384, 385, 386, 387, 388, 389,
390, 391, 392, 232, 393, 395, 265, 267, 266, 268,
182, -89, 403, 404, 405, 406, 407, 408, 181, 196,
411, 412, 413, 414, 270, 287, 271, 288, 328, 332,
329, 333, 334, 184, 335, 427, 428, 430, 431, 432,
433, 191, 198, 434, 435, 436, 437, 419, 484, 420,
485, 442, 443, 486, 488, 487, 489, 199, 204, 462,
463, 207, 490, 466, 491, 467, 468, 208, 211, 472,
473, 499, 606, 500, 476, 477, 523, 212, 524, 215,
216, 612, 217, 218, 221, 222, 219, 247, 227, 249,
248, 252, 250, 258, 259, 263, 269, 272, 278, 273,
502, 503, 277, 279, 280, 506, 508, 281, 286, 321,
282, 284, 285, 322, -14, 294, 513, 514, 515, 516,
517, 518, 519, 520, 316, 317, 351, 320, 325, 327,
356, 330, 331, 355, 525, 526, 415, 349, 346, 416,
350, 417, 373, 441, 376, 532, 533, 534, 535, 536,
537, 538, 539, 375, 397, 378, 418, 409, 398, 399,
401, 446, 410, 423, 549, 550, 551, 552, 553, 554,
555, 556, 438, 440, 464, 465, 474, 475, 501, 481,
511, 560, 561, 562, 563, 564, 565, 566, 567, 496,
482, 504, 569, 570, 571, 572, 573, 574, 497, 575,
576, 498, 505, 583, 584, 585, 586, 509, 587, 588,
510, 512, 521, 522, 528, 529, 531, 594, 595, 596,
597, 540, 542, 541, 543, 544, 545, 546, 577, 548,
557, 558, 559, 581, 582, 589, 592, 590, 593, 598,
599, 600, 601, 602, 603, 607, 608, 604, 605, 609,
610, 611, 613, 615, 614, 323, 290, 274, 461, 54,
57, 591, 483, 51, 84
};
static const yytype_uint16 yycheck[] =
{
48, 49, 50, 4, 211, 236, 422, 3, 4, 4,
454, 3, 4, 3, 4, 0, 1, 461, 30, 23,
300, 357, 7, 8, 9, 10, 11, 0, 76, 77,
78, 79, 17, 4, 5, 83, 84, 22, 50, 7,
247, 377, 90, 91, 92, 93, 50, 3, 4, 50,
98, 4, 37, 6, 50, 50, 48, 16, 48, 18,
19, 109, 110, 3, 4, 272, 25, 26, 116, 117,
118, 302, 120, 121, 122, 123, 124, 47, 17, 49,
128, 129, 3, 4, 132, 133, 134, 135, 4, 22,
6, 139, 140, 47, 8, 143, 144, 145, 146, 379,
147, 49, 150, 151, 152, 3, 4, 155, 6, 157,
158, 159, 37, 4, 530, 163, 164, 324, 3, 4,
400, 6, 169, 170, 16, 172, 18, 19, 4, 49,
178, 179, 180, 25, 20, 183, 3, 4, 186, 6,
48, 189, 190, 3, 4, 6, 6, 0, 1, 6,
198, 0, 1, 201, 202, 203, 9, 10, 11, 24,
9, 10, 11, 6, 17, 213, 214, 47, 17, 49,
6, 16, 220, 18, 19, 6, 224, 225, 31, 6,
25, 26, 31, 47, 37, 49, 6, 34, 37, 0,
1, 47, 6, 49, 16, 4, 18, 19, 9, 10,
11, 6, 6, 25, 26, 50, 17, 255, 4, 416,
3, 4, 6, 6, 261, 262, 48, 265, 266, 267,
268, 269, 270, 271, 50, 456, 37, 434, 50, 3,
4, 47, 6, 49, 16, 283, 18, 19, 16, 47,
18, 19, 6, 25, 291, 35, 293, 25, 26, 38,
39, 40, 41, 42, 43, 44, 45, 46, 50, 50,
308, 309, 310, 311, 312, 313, 314, 16, 50, 18,
19, 319, 50, 49, 49, 47, 25, 49, 48, 50,
328, 329, 330, 331, 332, 333, 334, 335, 47, 47,
49, 339, 340, 341, 342, 343, 36, 344, 345, 506,
348, 50, 47, 4, 49, 6, 12, 13, 14, 15,
358, 359, 360, 361, 362, 363, 364, 365, 366, 367,
368, 369, 370, 29, 371, 372, 47, 47, 49, 49,
49, 37, 380, 381, 382, 383, 384, 385, 4, 48,
388, 389, 390, 391, 47, 47, 49, 49, 47, 47,
49, 49, 47, 4, 49, 403, 404, 405, 406, 407,
408, 4, 47, 411, 412, 413, 414, 47, 47, 49,
49, 419, 420, 47, 47, 49, 49, 21, 50, 427,
428, 50, 47, 431, 49, 432, 433, 4, 4, 436,
437, 4, 599, 6, 442, 443, 4, 4, 6, 48,
50, 608, 48, 50, 49, 27, 48, 6, 49, 4,
50, 4, 6, 49, 28, 4, 49, 49, 4, 50,
467, 468, 50, 48, 50, 472, 473, 48, 6, 6,
50, 50, 50, 6, 22, 50, 484, 485, 486, 487,
488, 489, 490, 491, 48, 50, 31, 50, 50, 49,
4, 49, 49, 49, 502, 503, 4, 48, 50, 6,
50, 4, 49, 4, 48, 513, 514, 515, 516, 517,
518, 519, 520, 49, 48, 50, 6, 48, 50, 49,
49, 32, 50, 49, 532, 533, 534, 535, 536, 537,
538, 539, 50, 50, 4, 6, 48, 50, 6, 49,
49, 549, 550, 551, 552, 553, 554, 555, 556, 48,
50, 48, 560, 561, 562, 563, 564, 565, 50, 566,
567, 50, 50, 571, 572, 573, 574, 48, 575, 576,
50, 6, 50, 4, 50, 4, 6, 585, 586, 587,
588, 50, 4, 50, 48, 50, 48, 50, 33, 50,
50, 50, 49, 48, 50, 49, 6, 50, 6, 6,
6, 6, 6, 6, 48, 4, 6, 50, 50, 6,
48, 50, 4, 50, 48, 289, 260, 234, 426, 28,
38, 579, 448, 25, 56
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] =
{
0, 1, 52, 53, 54, 55, 56, 57, 59, 60,
0, 7, 61, 17, 111, 112, 114, 116, 118, 120,
1, 9, 10, 11, 77, 78, 79, 80, 81, 82,
83, 84, 85, 86, 87, 88, 89, 22, 138, 139,
140, 47, 8, 62, 47, 49, 49, 47, 49, 47,
49, 79, 37, 154, 111, 47, 49, 139, 142, 4,
47, 49, 20, 63, 64, 65, 66, 4, 6, 137,
4, 6, 4, 3, 4, 156, 157, 157, 157, 157,
49, 4, 5, 141, 141, 23, 50, 143, 144, 48,
6, 6, 47, 49, 24, 67, 6, 6, 6, 6,
38, 39, 40, 41, 42, 43, 44, 45, 46, 157,
157, 157, 157, 6, 157, 157, 47, 49, 157, 50,
157, 157, 157, 47, 49, 34, 68, 6, 6, 157,
6, 155, 157, 157, 4, 4, 6, 48, 50, 157,
157, 157, 157, 157, 157, 157, 157, 47, 35, 69,
6, 6, 157, 157, 50, 157, 6, 157, 157, 157,
50, 49, 49, 157, 157, 48, 50, 157, 157, 157,
157, 156, 47, 36, 70, 71, 72, 73, 157, 157,
157, 4, 49, 157, 4, 6, 157, 157, 157, 157,
157, 4, 4, 50, 156, 156, 48, 156, 47, 21,
74, 157, 157, 157, 50, 90, 157, 50, 4, 6,
157, 4, 4, 157, 157, 48, 50, 48, 50, 48,
157, 49, 27, 75, 157, 157, 157, 49, 12, 13,
14, 15, 29, 91, 92, 93, 94, 95, 96, 97,
98, 99, 100, 101, 102, 103, 104, 6, 50, 4,
6, 137, 4, 157, 157, 157, 4, 6, 49, 28,
76, 157, 157, 4, 113, 47, 49, 47, 49, 49,
47, 49, 49, 50, 93, 154, 137, 50, 4, 48,
50, 48, 50, 157, 50, 50, 6, 47, 49, 58,
59, 156, 4, 156, 50, 16, 18, 19, 25, 26,
122, 123, 124, 130, 131, 132, 135, 136, 157, 157,
157, 157, 157, 157, 157, 137, 48, 50, 48, 157,
50, 6, 6, 77, 156, 50, 156, 49, 47, 49,
49, 49, 47, 49, 47, 49, 50, 123, 154, 157,
157, 157, 157, 157, 157, 157, 50, 48, 157, 48,
50, 31, 145, 146, 137, 49, 4, 115, 157, 157,
157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
157, 156, 156, 49, 157, 49, 48, 117, 50, 122,
157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
157, 157, 157, 156, 6, 156, 105, 48, 50, 49,
122, 49, 50, 157, 157, 157, 157, 157, 157, 48,
50, 157, 157, 157, 157, 4, 6, 4, 6, 47,
49, 109, 110, 49, 121, 50, 119, 157, 157, 6,
157, 157, 157, 157, 157, 157, 157, 157, 50, 137,
50, 4, 157, 157, 106, 109, 32, 147, 148, 149,
16, 18, 19, 25, 125, 126, 127, 128, 129, 133,
134, 125, 157, 157, 4, 6, 157, 156, 156, 137,
4, 50, 156, 156, 48, 50, 157, 157, 30, 50,
107, 49, 50, 149, 47, 49, 47, 49, 47, 49,
47, 49, 50, 126, 154, 50, 48, 50, 50, 4,
6, 6, 156, 156, 48, 50, 156, 4, 156, 48,
50, 49, 6, 157, 157, 157, 157, 157, 157, 157,
157, 50, 4, 4, 6, 157, 157, 137, 50, 4,
108, 6, 157, 157, 157, 157, 157, 157, 157, 157,
50, 50, 4, 48, 50, 48, 50, 109, 50, 157,
157, 157, 157, 157, 157, 157, 157, 50, 50, 49,
157, 157, 157, 157, 157, 157, 157, 157, 150, 157,
157, 157, 157, 157, 157, 156, 156, 33, 151, 152,
153, 48, 50, 157, 157, 157, 157, 156, 156, 49,
50, 153, 6, 6, 157, 157, 157, 157, 6, 6,
6, 6, 6, 48, 50, 50, 137, 4, 6, 6,
48, 50, 137, 4, 48, 50
};
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] =
{
0, 51, 52, 52, 52, 52, 54, 53, 55, 53,
57, 56, 58, 58, 60, 59, 61, 61, 62, 62,
62, 63, 63, 63, 64, 65, 66, 67, 67, 67,
68, 68, 69, 69, 70, 70, 70, 70, 71, 72,
73, 74, 74, 74, 75, 75, 76, 76, 76, 77,
77, 78, 78, 79, 80, 79, 79, 79, 81, 79,
79, 82, 82, 82, 82, 82, 83, 84, 85, 86,
87, 88, 88, 90, 89, 91, 91, 92, 92, 93,
93, 93, 93, 93, 93, 93, 93, 93, 93, 94,
93, 93, 95, 96, 97, 98, 99, 100, 101, 102,
103, 105, 104, 106, 106, 108, 107, 109, 109, 110,
110, 111, 111, 111, 111, 111, 113, 112, 115, 114,
117, 116, 119, 118, 121, 120, 122, 122, 123, 123,
123, 123, 123, 123, 123, 123, 123, 123, 123, 124,
123, 125, 125, 126, 126, 126, 126, 126, 126, 126,
126, 127, 126, 128, 129, 130, 131, 132, 133, 134,
135, 136, 137, 137, 138, 138, 139, 140, 140, 141,
141, 142, 142, 142, 143, 144, 145, 145, 146, 147,
147, 148, 148, 150, 149, 151, 151, 152, 152, 153,
154, 155, 155, 156, 156, 157, 157, 157, 157, 157,
157, 157, 157, 157, 157
};
/* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
static const yytype_uint8 yyr2[] =
{
0, 2, 1, 1, 1, 1, 0, 14, 0, 2,
0, 2, 1, 0, 0, 2, 0, 4, 4, 6,
6, 1, 1, 1, 6, 7, 7, 6, 6, 0,
0, 4, 0, 4, 0, 1, 1, 1, 6, 7,
9, 4, 4, 0, 4, 0, 4, 4, 0, 1,
0, 1, 2, 1, 0, 2, 1, 1, 0, 2,
1, 1, 1, 1, 1, 1, 11, 11, 10, 9,
8, 10, 10, 0, 10, 1, 0, 1, 2, 1,
1, 1, 1, 1, 1, 8, 1, 1, 1, 0,
2, 1, 10, 10, 9, 12, 12, 11, 8, 9,
9, 0, 9, 0, 2, 0, 5, 0, 2, 4,
4, 1, 1, 1, 1, 1, 0, 12, 0, 15,
0, 16, 0, 18, 0, 18, 1, 2, 1, 1,
1, 1, 1, 8, 8, 10, 10, 5, 5, 0,
2, 1, 2, 1, 1, 1, 1, 8, 8, 10,
10, 0, 2, 12, 12, 10, 9, 8, 13, 13,
11, 10, 1, 1, 1, 2, 3, 6, 6, 1,
1, 0, 2, 2, 8, 8, 1, 0, 6, 1,
0, 1, 2, 0, 9, 1, 0, 1, 2, 4,
5, 1, 0, 1, 1, 1, 2, 2, 2, 2,
2, 2, 2, 2, 2
};
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY (-2)
#define YYEOF 0
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY) \
{ \
yychar = (Token); \
yylval = (Value); \
YYPOPSTACK (yylen); \
yystate = *yyssp; \
goto yybackup; \
} \
else \
{ \
yyerror (YY_("syntax error: cannot back up")); \
YYERROR; \
} \
while (0)
/* Error token number */
#define YYTERROR 1
#define YYERRCODE 256
/* Enable debugging if requested. */
#if YYDEBUG
# ifndef YYFPRINTF
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
# define YYFPRINTF fprintf
# endif
# define YYDPRINTF(Args) \
do { \
if (yydebug) \
YYFPRINTF Args; \
} while (0)
/* This macro is provided for backward compatibility. */
#ifndef YY_LOCATION_PRINT
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
#endif
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
yy_symbol_print (stderr, \
Type, Value); \
YYFPRINTF (stderr, "\n"); \
} \
} while (0)
static void
<API key> (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
{
FILE *yyo = yyoutput;
YYUSE (yyo);
if (!yyvaluep)
return;
# ifdef YYPRINT
if (yytype < YYNTOKENS)
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
# endif
YYUSE (yytype);
}
static void
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
{
YYFPRINTF (yyoutput, "%s %s (",
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
<API key> (yyoutput, yytype, yyvaluep);
YYFPRINTF (yyoutput, ")");
}
static void
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
{
YYFPRINTF (stderr, "Stack now");
for (; yybottom <= yytop; yybottom++)
{
int yybot = *yybottom;
YYFPRINTF (stderr, " %d", yybot);
}
YYFPRINTF (stderr, "\n");
}
# define YY_STACK_PRINT(Bottom, Top) \
do { \
if (yydebug) \
yy_stack_print ((Bottom), (Top)); \
} while (0)
static void
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
{
unsigned long int yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
int yyi;
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
yyrule - 1, yylno);
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr,
yystos[yyssp[yyi + 1 - yynrhs]],
&(yyvsp[(yyi + 1) - (yynrhs)])
);
YYFPRINTF (stderr, "\n");
}
}
# define YY_REDUCE_PRINT(Rule) \
do { \
if (yydebug) \
yy_reduce_print (yyssp, yyvsp, Rule); \
} while (0)
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */
/* YYINITDEPTH -- initial size of the parser's stacks. */
#ifndef YYINITDEPTH
# define YYINITDEPTH 200
#endif
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
if the built-in stack extension method is used).
Do not make this value too large; the results are undefined if
<API key> < YYSTACK_BYTES (YYMAXDEPTH)
evaluated with infinite-precision integer arithmetic. */
#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif
#if YYERROR_VERBOSE
# ifndef yystrlen
# if defined __GLIBC__ && defined _STRING_H
# define yystrlen strlen
# else
/* Return the length of YYSTR. */
static YYSIZE_T
yystrlen (const char *yystr)
{
YYSIZE_T yylen;
for (yylen = 0; yystr[yylen]; yylen++)
continue;
return yylen;
}
# endif
# endif
# ifndef yystpcpy
# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
# define yystpcpy stpcpy
# else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
YYDEST. */
static char *
yystpcpy (char *yydest, const char *yysrc)
{
char *yyd = yydest;
const char *yys = yysrc;
while ((*yyd++ = *yys++) != '\0')
continue;
return yyd - 1;
}
# endif
# endif
# ifndef yytnamerr
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
quotes and backslashes, so that it's suitable for yyerror. The
heuristic is that double-quoting is unnecessary unless the string
contains an apostrophe, a comma, or backslash (other than
backslash-backslash). YYSTR is taken from yytname. If YYRES is
null, do not copy; instead, return the length of what the result
would have been. */
static YYSIZE_T
yytnamerr (char *yyres, const char *yystr)
{
if (*yystr == '"')
{
YYSIZE_T yyn = 0;
char const *yyp = yystr;
for (;;)
switch (*++yyp)
{
case '\'':
case ',':
goto do_not_strip_quotes;
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
/* Fall through. */
default:
if (yyres)
yyres[yyn] = *yyp;
yyn++;
break;
case '"':
if (yyres)
yyres[yyn] = '\0';
return yyn;
}
do_not_strip_quotes: ;
}
if (! yyres)
return yystrlen (yystr);
return yystpcpy (yyres, yystr) - yyres;
}
# endif
/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
about the unexpected token YYTOKEN for the state stack whose top is
YYSSP.
Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
not large enough to hold the message. In that case, also set
*YYMSG_ALLOC to the required number of bytes. Return 2 if the
required number of bytes is too large to store. */
static int
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yytype_int16 *yyssp, int yytoken)
{
YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
YYSIZE_T yysize = yysize0;
enum { <API key> = 5 };
/* Internationalized format string. */
const char *yyformat = YY_NULLPTR;
/* Arguments of yyformat. */
char const *yyarg[<API key>];
/* Number of reported tokens (one for the "unexpected", one per
"expected"). */
int yycount = 0;
/* There are many possibilities here to consider:
- If this state is a consistent state with a default action, then
the only way this function was invoked is if the default action
is an error action. In that case, don't check for expected
tokens because there are none.
- The only way there can be no lookahead present (in yychar) is if
this state is a consistent state with a default action. Thus,
detecting the absence of a lookahead is sufficient to determine
that there is no unexpected or expected token to report. In that
case, just report a simple "syntax error".
- Don't assume there isn't a lookahead just because this state is a
consistent state with a default action. There might have been a
previous inconsistent state, consistent state with a non-default
action, or user semantic action that manipulated yychar.
- Of course, the expected token list depends on states to have
correct lookahead information, and it depends on the parser not
to perform extra reductions after fetching a lookahead from the
scanner and before detecting a syntax error. Thus, state merging
(from LALR or IELR) and default reductions corrupt the expected
token list. However, the list is correct for canonical LR with
one exception: it will still contain any token that will not be
accepted due to an error action in a later state.
*/
if (yytoken != YYEMPTY)
{
int yyn = yypact[*yyssp];
yyarg[yycount++] = yytname[yytoken];
if (!<API key> (yyn))
{
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. In other words, skip the first -YYN actions for
this state because they are default actions. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yyx;
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
&& !<API key> (yytable[yyx + yyn]))
{
if (yycount == <API key>)
{
yycount = 1;
yysize = yysize0;
break;
}
yyarg[yycount++] = yytname[yyx];
{
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
if (! (yysize <= yysize1
&& yysize1 <= <API key>))
return 2;
yysize = yysize1;
}
}
}
}
switch (yycount)
{
# define YYCASE_(N, S) \
case N: \
yyformat = S; \
break
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
# undef YYCASE_
}
{
YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
if (! (yysize <= yysize1 && yysize1 <= <API key>))
return 2;
yysize = yysize1;
}
if (*yymsg_alloc < yysize)
{
*yymsg_alloc = 2 * yysize;
if (! (yysize <= *yymsg_alloc
&& *yymsg_alloc <= <API key>))
*yymsg_alloc = <API key>;
return 1;
}
/* Avoid sprintf, as that infringes on the user's name space.
Don't have undefined behavior even if the translation
produced a string with the wrong number of "%s"s. */
{
char *yyp = *yymsg;
int yyi = 0;
while ((*yyp = *yyformat) != '\0')
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
{
yyp += yytnamerr (yyp, yyarg[yyi++]);
yyformat += 2;
}
else
{
yyp++;
yyformat++;
}
}
return 0;
}
#endif /* YYERROR_VERBOSE */
static void
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
{
YYUSE (yyvaluep);
if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
<API key>
YYUSE (yytype);
<API key>
}
/* The lookahead symbol. */
int yychar;
/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
/* Number of syntax errors so far. */
int yynerrs;
int
yyparse (void)
{
int yystate;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
/* The stacks and their tools:
'yyss': related to states.
'yyvs': related to semantic values.
Refer to the stacks through separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The state stack. */
yytype_int16 yyssa[YYINITDEPTH];
yytype_int16 *yyss;
yytype_int16 *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs;
YYSTYPE *yyvsp;
YYSIZE_T yystacksize;
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken = 0;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
#if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
char *yymsg = yymsgbuf;
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
yyssp = yyss = yyssa;
yyvsp = yyvs = yyvsa;
yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
goto yysetstate;
yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
yysetstate:
*yyssp = yystate;
if (yyss + yystacksize - 1 <= yyssp)
{
/* Get the current used size of the three stacks, in elements. */
YYSIZE_T yysize = yyssp - yyss + 1;
#ifdef yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss;
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yystacksize);
yyss = yyss1;
yyvs = yyvs1;
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
goto yyexhaustedlab;
# else
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
{
yytype_int16 *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
if (yystate == YYFINAL)
YYACCEPT;
goto yybackup;
yybackup:
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (<API key> (yyn))
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
yychar = yylex ();
}
if (yychar <= YYEOF)
{
yychar = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
yytoken = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
detect an error, take that action. */
yyn += yytoken;
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
goto yydefault;
yyn = yytable[yyn];
if (yyn <= 0)
{
if (<API key> (yyn))
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus
/* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
/* Discard the shifted token. */
yychar = YYEMPTY;
yystate = yyn;
<API key>
*++yyvsp = yylval;
<API key>
goto yynewstate;
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
goto yyreduce;
yyreduce:
/* yyn is the number of a rule to reduce with. */
yylen = yyr2[yyn];
/* If YYLEN is nonzero, implement the default value of the action:
'$$ = $1'.
Otherwise, the following line sets YYVAL to garbage.
This behavior is undocumented and Bison
users should not rely upon it. Assigning to YYVAL
unconditionally makes the parser a bit smaller, and it avoids a
GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1-yylen];
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
case 5:
#line 138 "parse_y.y" /* yacc.c:1646 */
{ YYABORT; }
#line 1753 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 6:
#line 162 "parse_y.y" /* yacc.c:1646 */
{
/* reset flags for 'used layers';
* init font and data pointers
*/
int i;
if (!yyPCB)
{
Message("illegal fileformat\n");
YYABORT;
}
for (i = 0; i < MAX_LAYER + 2; i++)
LayerFlag[i] = false;
yyFont = &yyPCB->Font;
yyData = yyPCB->Data;
yyData->pcb = yyPCB;
yyData->LayerN = 0;
layer_group_string = NULL;
}
#line 1777 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 7:
#line 194 "parse_y.y" /* yacc.c:1646 */
{
PCBTypePtr pcb_save = PCB;
if (layer_group_string == NULL)
layer_group_string = Settings.Groups;
CreateNewPCBPost (yyPCB, 0);
if (ParseGroupString(layer_group_string, &yyPCB->LayerGroups, yyData->LayerN))
{
Message("illegal layer-group string\n");
YYABORT;
}
/* initialize the polygon clipping now since
* we didn't know the layer grouping before.
*/
PCB = yyPCB;
ALLPOLYGON_LOOP (yyData);
{
InitClip (yyData, layer, polygon);
}
ENDALL_LOOP;
PCB = pcb_save;
}
#line 1804 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 8:
#line 217 "parse_y.y" /* yacc.c:1646 */
{ PreLoadElementPCB ();
layer_group_string = NULL; }
#line 1811 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 9:
#line 220 "parse_y.y" /* yacc.c:1646 */
{ LayerFlag[0] = true;
LayerFlag[1] = true;
yyData->LayerN = 2;
PostLoadElementPCB ();
}
#line 1821 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 10:
#line 228 "parse_y.y" /* yacc.c:1646 */
{
/* reset flags for 'used layers';
* init font and data pointers
*/
int i;
if (!yyData || !yyFont)
{
Message("illegal fileformat\n");
YYABORT;
}
for (i = 0; i < MAX_LAYER + 2; i++)
LayerFlag[i] = false;
yyData->LayerN = 0;
}
#line 1841 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 14:
#line 253 "parse_y.y" /* yacc.c:1646 */
{
/* mark all symbols invalid */
int i;
if (!yyFont)
{
Message("illegal fileformat\n");
YYABORT;
}
yyFont->Valid = false;
for (i = 0; i <= MAX_FONTPOSITION; i++)
free (yyFont->Symbol[i].Line);
bzero(yyFont->Symbol, sizeof(yyFont->Symbol));
}
#line 1860 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 15:
#line 268 "parse_y.y" /* yacc.c:1646 */
{
yyFont->Valid = true;
SetFontInfo(yyFont);
}
#line 1869 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 17:
#line 296 "parse_y.y" /* yacc.c:1646 */
{
if (check_file_version ((yyvsp[-1].integer)) != 0)
{
YYABORT;
}
}
#line 1880 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 18:
#line 326 "parse_y.y" /* yacc.c:1646 */
{
yyPCB->Name = (yyvsp[-1].string);
yyPCB->MaxWidth = MAX_COORD;
yyPCB->MaxHeight = MAX_COORD;
}
#line 1890 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 19:
#line 332 "parse_y.y" /* yacc.c:1646 */
{
yyPCB->Name = (yyvsp[-3].string);
yyPCB->MaxWidth = OU ((yyvsp[-2].measure));
yyPCB->MaxHeight = OU ((yyvsp[-1].measure));
}
#line 1900 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 20:
#line 338 "parse_y.y" /* yacc.c:1646 */
{
yyPCB->Name = (yyvsp[-3].string);
yyPCB->MaxWidth = NU ((yyvsp[-2].measure));
yyPCB->MaxHeight = NU ((yyvsp[-1].measure));
}
#line 1910 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 24:
#line 372 "parse_y.y" /* yacc.c:1646 */
{
yyPCB->Grid = OU ((yyvsp[-3].measure));
yyPCB->GridOffsetX = OU ((yyvsp[-2].measure));
yyPCB->GridOffsetY = OU ((yyvsp[-1].measure));
}
#line 1920 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 25:
#line 380 "parse_y.y" /* yacc.c:1646 */
{
yyPCB->Grid = OU ((yyvsp[-4].measure));
yyPCB->GridOffsetX = OU ((yyvsp[-3].measure));
yyPCB->GridOffsetY = OU ((yyvsp[-2].measure));
if ((yyvsp[-1].integer))
Settings.DrawGrid = true;
else
Settings.DrawGrid = false;
}
#line 1934 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 26:
#line 393 "parse_y.y" /* yacc.c:1646 */
{
yyPCB->Grid = NU ((yyvsp[-4].measure));
yyPCB->GridOffsetX = NU ((yyvsp[-3].measure));
yyPCB->GridOffsetY = NU ((yyvsp[-2].measure));
if ((yyvsp[-1].integer))
Settings.DrawGrid = true;
else
Settings.DrawGrid = false;
}
#line 1948 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 27:
#line 425 "parse_y.y" /* yacc.c:1646 */
{
yyPCB->CursorX = OU ((yyvsp[-3].measure));
yyPCB->CursorY = OU ((yyvsp[-2].measure));
yyPCB->Zoom = (yyvsp[-1].number)*2;
}
#line 1958 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 28:
#line 431 "parse_y.y" /* yacc.c:1646 */
{
yyPCB->CursorX = NU ((yyvsp[-3].measure));
yyPCB->CursorY = NU ((yyvsp[-2].measure));
yyPCB->Zoom = (yyvsp[-1].number);
}
#line 1968 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 31:
#line 455 "parse_y.y" /* yacc.c:1646 */
{
/* Read in cmil^2 for now; in future this should be a noop. */
yyPCB->IsleArea = MIL_TO_COORD (MIL_TO_COORD ((yyvsp[-1].number)) / 100.0) / 100.0;
}
#line 1977 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 33:
#line 482 "parse_y.y" /* yacc.c:1646 */
{
yyPCB->ThermScale = (yyvsp[-1].number);
}
#line 1985 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 38:
#line 521 "parse_y.y" /* yacc.c:1646 */
{
yyPCB->Bloat = NU ((yyvsp[-3].measure));
yyPCB->Shrink = NU ((yyvsp[-2].measure));
yyPCB->minWid = NU ((yyvsp[-1].measure));
yyPCB->minRing = NU ((yyvsp[-1].measure));
}
#line 1996 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 39:
#line 531 "parse_y.y" /* yacc.c:1646 */
{
yyPCB->Bloat = NU ((yyvsp[-4].measure));
yyPCB->Shrink = NU ((yyvsp[-3].measure));
yyPCB->minWid = NU ((yyvsp[-2].measure));
yyPCB->minSlk = NU ((yyvsp[-1].measure));
yyPCB->minRing = NU ((yyvsp[-2].measure));
}
#line 2008 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 40:
#line 542 "parse_y.y" /* yacc.c:1646 */
{
yyPCB->Bloat = NU ((yyvsp[-6].measure));
yyPCB->Shrink = NU ((yyvsp[-5].measure));
yyPCB->minWid = NU ((yyvsp[-4].measure));
yyPCB->minSlk = NU ((yyvsp[-3].measure));
yyPCB->minDrill = NU ((yyvsp[-2].measure));
yyPCB->minRing = NU ((yyvsp[-1].measure));
}
#line 2021 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 41:
#line 569 "parse_y.y" /* yacc.c:1646 */
{
yyPCB->Flags = MakeFlags ((yyvsp[-1].integer) & PCB_FLAGS);
}
#line 2029 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 42:
#line 573 "parse_y.y" /* yacc.c:1646 */
{
yyPCB->Flags = string_to_pcbflags ((yyvsp[-1].string), yyerror);
}
#line 2037 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 44:
#line 605 "parse_y.y" /* yacc.c:1646 */
{
layer_group_string = (yyvsp[-1].string);
}
#line 2045 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 46:
#line 653 "parse_y.y" /* yacc.c:1646 */
{
if (ParseRouteString((yyvsp[-1].string), &yyPCB->RouteStyle[0], "mil"))
{
Message("illegal route-style string\n");
YYABORT;
}
}
#line 2057 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 47:
#line 661 "parse_y.y" /* yacc.c:1646 */
{
if (ParseRouteString((yyvsp[-1].string), &yyPCB->RouteStyle[0], "cmil"))
{
Message("illegal route-style string\n");
YYABORT;
}
}
#line 2069 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 54:
#line 683 "parse_y.y" /* yacc.c:1646 */
{ attr_list = & yyPCB->Attributes; }
#line 2075 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 58:
#line 687 "parse_y.y" /* yacc.c:1646 */
{
/* clear pointer to force memory allocation by
* the appropriate subroutine
*/
yyElement = NULL;
}
#line 2086 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 60:
#line 694 "parse_y.y" /* yacc.c:1646 */
{ YYABORT; }
#line 2092 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 66:
#line 739 "parse_y.y" /* yacc.c:1646 */
{
CreateNewVia(yyData, NU ((yyvsp[-8].measure)), NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)),
NU ((yyvsp[-3].measure)), (yyvsp[-2].string), (yyvsp[-1].flagtype));
free ((yyvsp[-2].string));
}
#line 2102 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 67:
#line 749 "parse_y.y" /* yacc.c:1646 */
{
CreateNewVia(yyData, OU ((yyvsp[-8].measure)), OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), (yyvsp[-2].string),
OldFlags((yyvsp[-1].integer)));
free ((yyvsp[-2].string));
}
#line 2112 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 68:
#line 760 "parse_y.y" /* yacc.c:1646 */
{
CreateNewVia(yyData, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)),
OU ((yyvsp[-5].measure)) + OU((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), (yyvsp[-2].string), OldFlags((yyvsp[-1].integer)));
free ((yyvsp[-2].string));
}
#line 2122 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 69:
#line 770 "parse_y.y" /* yacc.c:1646 */
{
CreateNewVia(yyData, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), 2*GROUNDPLANEFRAME,
OU((yyvsp[-4].measure)) + 2*MASKFRAME, OU ((yyvsp[-3].measure)), (yyvsp[-2].string), OldFlags((yyvsp[-1].integer)));
free ((yyvsp[-2].string));
}
#line 2132 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 70:
#line 780 "parse_y.y" /* yacc.c:1646 */
{
Coord hole = (OU((yyvsp[-3].measure)) * <API key>);
/* make sure that there's enough copper left */
if (OU((yyvsp[-3].measure)) - hole < MIN_PINORVIACOPPER &&
OU((yyvsp[-3].measure)) > MIN_PINORVIACOPPER)
hole = OU((yyvsp[-3].measure)) - MIN_PINORVIACOPPER;
CreateNewVia(yyData, OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), 2*GROUNDPLANEFRAME,
OU((yyvsp[-3].measure)) + 2*MASKFRAME, hole, (yyvsp[-2].string), OldFlags((yyvsp[-1].integer)));
free ((yyvsp[-2].string));
}
#line 2149 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 71:
#line 816 "parse_y.y" /* yacc.c:1646 */
{
CreateNewRat(yyData, NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), NU ((yyvsp[-4].measure)), NU ((yyvsp[-3].measure)), (yyvsp[-5].integer), (yyvsp[-2].integer),
Settings.RatThickness, (yyvsp[-1].flagtype));
}
#line 2158 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 72:
#line 821 "parse_y.y" /* yacc.c:1646 */
{
CreateNewRat(yyData, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), (yyvsp[-5].integer), (yyvsp[-2].integer),
Settings.RatThickness, OldFlags((yyvsp[-1].integer)));
}
#line 2167 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 73:
#line 852 "parse_y.y" /* yacc.c:1646 */
{
if ((yyvsp[-4].integer) <= 0 || (yyvsp[-4].integer) > MAX_LAYER + 2)
{
yyerror("Layernumber out of range");
YYABORT;
}
if (LayerFlag[(yyvsp[-4].integer)-1])
{
yyerror("Layernumber used twice");
YYABORT;
}
Layer = &yyData->Layer[(yyvsp[-4].integer)-1];
/* memory for name is already allocated */
Layer->Name = (yyvsp[-3].string);
LayerFlag[(yyvsp[-4].integer)-1] = true;
if (yyData->LayerN + 2 < (yyvsp[-4].integer))
yyData->LayerN = (yyvsp[-4].integer) - 2;
}
#line 2191 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 85:
#line 893 "parse_y.y" /* yacc.c:1646 */
{
<API key>(Layer,
OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-5].measure)) + OU ((yyvsp[-3].measure)), OU ((yyvsp[-4].measure)) + OU ((yyvsp[-2].measure)), OldFlags((yyvsp[-1].integer)));
}
#line 2200 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 89:
#line 900 "parse_y.y" /* yacc.c:1646 */
{ attr_list = & Layer->Attributes; }
#line 2206 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 92:
#line 932 "parse_y.y" /* yacc.c:1646 */
{
<API key>(Layer, NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)),
NU ((yyvsp[-3].measure)), NU ((yyvsp[-2].measure)), (yyvsp[-1].flagtype));
}
#line 2215 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 93:
#line 941 "parse_y.y" /* yacc.c:1646 */
{
<API key>(Layer, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)),
OU ((yyvsp[-3].measure)), OU ((yyvsp[-2].measure)), OldFlags((yyvsp[-1].integer)));
}
#line 2224 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 94:
#line 950 "parse_y.y" /* yacc.c:1646 */
{
/* eliminate old-style rat-lines */
if ((IV ((yyvsp[-1].measure)) & RATFLAG) == 0)
<API key>(Layer, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), OU ((yyvsp[-2].measure)),
200*GROUNDPLANEFRAME, OldFlags(IV ((yyvsp[-1].measure))));
}
#line 2235 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 95:
#line 998 "parse_y.y" /* yacc.c:1646 */
{
CreateNewArcOnLayer(Layer, NU ((yyvsp[-9].measure)), NU ((yyvsp[-8].measure)), NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), (yyvsp[-3].number), (yyvsp[-2].number),
NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), (yyvsp[-1].flagtype));
}
#line 2244 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 96:
#line 1007 "parse_y.y" /* yacc.c:1646 */
{
CreateNewArcOnLayer(Layer, OU ((yyvsp[-9].measure)), OU ((yyvsp[-8].measure)), OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), (yyvsp[-3].number), (yyvsp[-2].number),
OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OldFlags((yyvsp[-1].integer)));
}
#line 2253 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 97:
#line 1016 "parse_y.y" /* yacc.c:1646 */
{
CreateNewArcOnLayer(Layer, OU ((yyvsp[-8].measure)), OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-6].measure)), IV ((yyvsp[-3].measure)), (yyvsp[-2].number),
OU ((yyvsp[-4].measure)), 200*GROUNDPLANEFRAME, OldFlags((yyvsp[-1].integer)));
}
#line 2262 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 98:
#line 1053 "parse_y.y" /* yacc.c:1646 */
{
/* use a default scale of 100% */
CreateNewText(Layer,yyFont,OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), (yyvsp[-3].number), 100, (yyvsp[-2].string), OldFlags((yyvsp[-1].integer)));
free ((yyvsp[-2].string));
}
#line 2272 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 99:
#line 1063 "parse_y.y" /* yacc.c:1646 */
{
if ((yyvsp[-1].integer) & ONSILKFLAG)
{
LayerTypePtr lay = &yyData->Layer[yyData->LayerN +
(((yyvsp[-1].integer) & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)];
CreateNewText(lay ,yyFont, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), (yyvsp[-4].number), (yyvsp[-3].number), (yyvsp[-2].string),
OldFlags((yyvsp[-1].integer)));
}
else
CreateNewText(Layer, yyFont, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), (yyvsp[-4].number), (yyvsp[-3].number), (yyvsp[-2].string),
OldFlags((yyvsp[-1].integer)));
free ((yyvsp[-2].string));
}
#line 2291 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 100:
#line 1081 "parse_y.y" /* yacc.c:1646 */
{
/* FIXME: shouldn't know about .f */
/* I don't think this matters because anything with hi_format
* will have the silk on its own layer in the file rather
* than using the ONSILKFLAG and having it in a copper layer.
* Thus there is no need for anything besides the 'else'
* part of this code.
*/
if ((yyvsp[-1].flagtype).f & ONSILKFLAG)
{
LayerTypePtr lay = &yyData->Layer[yyData->LayerN +
(((yyvsp[-1].flagtype).f & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)];
CreateNewText(lay, yyFont, NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), (yyvsp[-4].number), (yyvsp[-3].number), (yyvsp[-2].string), (yyvsp[-1].flagtype));
}
else
CreateNewText(Layer, yyFont, NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), (yyvsp[-4].number), (yyvsp[-3].number), (yyvsp[-2].string), (yyvsp[-1].flagtype));
free ((yyvsp[-2].string));
}
#line 2315 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 101:
#line 1130 "parse_y.y" /* yacc.c:1646 */
{
Polygon = CreateNewPolygon(Layer, (yyvsp[-2].flagtype));
}
#line 2323 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 102:
#line 1135 "parse_y.y" /* yacc.c:1646 */
{
Cardinal contour, contour_start, contour_end;
bool bad_contour_found = false;
/* ignore junk */
for (contour = 0; contour <= Polygon->HoleIndexN; contour++)
{
contour_start = (contour == 0) ?
0 : Polygon->HoleIndex[contour - 1];
contour_end = (contour == Polygon->HoleIndexN) ?
Polygon->PointN :
Polygon->HoleIndex[contour];
if (contour_end - contour_start < 3)
bad_contour_found = true;
}
if (bad_contour_found)
{
Message("WARNING parsing file '%s'\n"
" line: %i\n"
" description: 'ignored polygon (< 3 points in a contour)'\n",
yyfilename, yylineno);
DestroyObject(yyData, POLYGON_TYPE, Layer, Polygon, Polygon);
}
else
{
<API key> (Polygon);
if (!Layer->polygon_tree)
Layer->polygon_tree = r_create_tree (NULL, 0, 0);
r_insert_entry (Layer->polygon_tree, (BoxType *) Polygon, 0);
}
}
#line 2359 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 105:
#line 1175 "parse_y.y" /* yacc.c:1646 */
{
<API key> (Polygon);
}
#line 2367 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 109:
#line 1189 "parse_y.y" /* yacc.c:1646 */
{
<API key>(Polygon, OU ((yyvsp[-2].measure)), OU ((yyvsp[-1].measure)));
}
#line 2375 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 110:
#line 1193 "parse_y.y" /* yacc.c:1646 */
{
<API key>(Polygon, NU ((yyvsp[-2].measure)), NU ((yyvsp[-1].measure)));
}
#line 2383 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 116:
#line 1264 "parse_y.y" /* yacc.c:1646 */
{
yyElement = CreateNewElement(yyData, yyElement, yyFont, NoFlags(),
(yyvsp[-6].string), (yyvsp[-5].string), NULL, OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), (yyvsp[-2].integer), 100, NoFlags(), false);
free ((yyvsp[-6].string));
free ((yyvsp[-5].string));
pin_num = 1;
}
#line 2395 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 117:
#line 1272 "parse_y.y" /* yacc.c:1646 */
{
<API key>(yyData, yyElement, yyFont);
}
#line 2403 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 118:
#line 1282 "parse_y.y" /* yacc.c:1646 */
{
yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags((yyvsp[-9].integer)),
(yyvsp[-8].string), (yyvsp[-7].string), NULL, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), IV ((yyvsp[-4].measure)), IV ((yyvsp[-3].measure)), OldFlags((yyvsp[-2].integer)), false);
free ((yyvsp[-8].string));
free ((yyvsp[-7].string));
pin_num = 1;
}
#line 2415 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 119:
#line 1290 "parse_y.y" /* yacc.c:1646 */
{
<API key>(yyData, yyElement, yyFont);
}
#line 2423 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 120:
#line 1300 "parse_y.y" /* yacc.c:1646 */
{
yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags((yyvsp[-10].integer)),
(yyvsp[-9].string), (yyvsp[-8].string), (yyvsp[-7].string), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), IV ((yyvsp[-4].measure)), IV ((yyvsp[-3].measure)), OldFlags((yyvsp[-2].integer)), false);
free ((yyvsp[-9].string));
free ((yyvsp[-8].string));
free ((yyvsp[-7].string));
pin_num = 1;
}
#line 2436 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 121:
#line 1309 "parse_y.y" /* yacc.c:1646 */
{
<API key>(yyData, yyElement, yyFont);
}
#line 2444 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 122:
#line 1320 "parse_y.y" /* yacc.c:1646 */
{
yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags((yyvsp[-12].integer)),
(yyvsp[-11].string), (yyvsp[-10].string), (yyvsp[-9].string), OU ((yyvsp[-8].measure)) + OU ((yyvsp[-6].measure)), OU ((yyvsp[-7].measure)) + OU ((yyvsp[-5].measure)),
(yyvsp[-4].number), (yyvsp[-3].number), OldFlags((yyvsp[-2].integer)), false);
yyElement->MarkX = OU ((yyvsp[-8].measure));
yyElement->MarkY = OU ((yyvsp[-7].measure));
free ((yyvsp[-11].string));
free ((yyvsp[-10].string));
free ((yyvsp[-9].string));
}
#line 2459 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 123:
#line 1331 "parse_y.y" /* yacc.c:1646 */
{
<API key>(yyData, yyElement, yyFont);
}
#line 2467 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 124:
#line 1342 "parse_y.y" /* yacc.c:1646 */
{
yyElement = CreateNewElement(yyData, yyElement, yyFont, (yyvsp[-12].flagtype),
(yyvsp[-11].string), (yyvsp[-10].string), (yyvsp[-9].string), NU ((yyvsp[-8].measure)) + NU ((yyvsp[-6].measure)), NU ((yyvsp[-7].measure)) + NU ((yyvsp[-5].measure)),
(yyvsp[-4].number), (yyvsp[-3].number), (yyvsp[-2].flagtype), false);
yyElement->MarkX = NU ((yyvsp[-8].measure));
yyElement->MarkY = NU ((yyvsp[-7].measure));
free ((yyvsp[-11].string));
free ((yyvsp[-10].string));
free ((yyvsp[-9].string));
}
#line 2482 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 125:
#line 1353 "parse_y.y" /* yacc.c:1646 */
{
<API key>(yyData, yyElement, yyFont);
}
#line 2490 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 133:
#line 1433 "parse_y.y" /* yacc.c:1646 */
{
<API key>(yyElement, NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), NU ((yyvsp[-3].measure)), NU ((yyvsp[-2].measure)), NU ((yyvsp[-1].measure)));
}
#line 2498 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 134:
#line 1438 "parse_y.y" /* yacc.c:1646 */
{
<API key>(yyElement, OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), OU ((yyvsp[-2].measure)), OU ((yyvsp[-1].measure)));
}
#line 2506 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 135:
#line 1443 "parse_y.y" /* yacc.c:1646 */
{
<API key>(yyElement, NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), (yyvsp[-3].number), (yyvsp[-2].number), NU ((yyvsp[-1].measure)));
}
#line 2514 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 136:
#line 1448 "parse_y.y" /* yacc.c:1646 */
{
<API key>(yyElement, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), (yyvsp[-3].number), (yyvsp[-2].number), OU ((yyvsp[-1].measure)));
}
#line 2522 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 137:
#line 1453 "parse_y.y" /* yacc.c:1646 */
{
yyElement->MarkX = NU ((yyvsp[-2].measure));
yyElement->MarkY = NU ((yyvsp[-1].measure));
}
#line 2531 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 138:
#line 1458 "parse_y.y" /* yacc.c:1646 */
{
yyElement->MarkX = OU ((yyvsp[-2].measure));
yyElement->MarkY = OU ((yyvsp[-1].measure));
}
#line 2540 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 139:
#line 1462 "parse_y.y" /* yacc.c:1646 */
{ attr_list = & yyElement->Attributes; }
#line 2546 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 147:
#line 1477 "parse_y.y" /* yacc.c:1646 */
{
<API key>(yyElement, NU ((yyvsp[-5].measure)) + yyElement->MarkX,
NU ((yyvsp[-4].measure)) + yyElement->MarkY, NU ((yyvsp[-3].measure)) + yyElement->MarkX,
NU ((yyvsp[-2].measure)) + yyElement->MarkY, NU ((yyvsp[-1].measure)));
}
#line 2556 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 148:
#line 1483 "parse_y.y" /* yacc.c:1646 */
{
<API key>(yyElement, OU ((yyvsp[-5].measure)) + yyElement->MarkX,
OU ((yyvsp[-4].measure)) + yyElement->MarkY, OU ((yyvsp[-3].measure)) + yyElement->MarkX,
OU ((yyvsp[-2].measure)) + yyElement->MarkY, OU ((yyvsp[-1].measure)));
}
#line 2566 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 149:
#line 1490 "parse_y.y" /* yacc.c:1646 */
{
<API key>(yyElement, NU ((yyvsp[-7].measure)) + yyElement->MarkX,
NU ((yyvsp[-6].measure)) + yyElement->MarkY, NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), (yyvsp[-3].number), (yyvsp[-2].number), NU ((yyvsp[-1].measure)));
}
#line 2575 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 150:
#line 1495 "parse_y.y" /* yacc.c:1646 */
{
<API key>(yyElement, OU ((yyvsp[-7].measure)) + yyElement->MarkX,
OU ((yyvsp[-6].measure)) + yyElement->MarkY, OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), (yyvsp[-3].number), (yyvsp[-2].number), OU ((yyvsp[-1].measure)));
}
#line 2584 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 151:
#line 1499 "parse_y.y" /* yacc.c:1646 */
{ attr_list = & yyElement->Attributes; }
#line 2590 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 153:
#line 1541 "parse_y.y" /* yacc.c:1646 */
{
CreateNewPin(yyElement, NU ((yyvsp[-9].measure)) + yyElement->MarkX,
NU ((yyvsp[-8].measure)) + yyElement->MarkY, NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), (yyvsp[-3].string),
(yyvsp[-2].string), (yyvsp[-1].flagtype));
free ((yyvsp[-3].string));
free ((yyvsp[-2].string));
}
#line 2602 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 154:
#line 1553 "parse_y.y" /* yacc.c:1646 */
{
CreateNewPin(yyElement, OU ((yyvsp[-9].measure)) + yyElement->MarkX,
OU ((yyvsp[-8].measure)) + yyElement->MarkY, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), (yyvsp[-3].string),
(yyvsp[-2].string), OldFlags((yyvsp[-1].integer)));
free ((yyvsp[-3].string));
free ((yyvsp[-2].string));
}
#line 2614 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 155:
#line 1565 "parse_y.y" /* yacc.c:1646 */
{
CreateNewPin(yyElement, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), 2*GROUNDPLANEFRAME,
OU ((yyvsp[-5].measure)) + 2*MASKFRAME, OU ((yyvsp[-4].measure)), (yyvsp[-3].string), (yyvsp[-2].string), OldFlags((yyvsp[-1].integer)));
free ((yyvsp[-3].string));
free ((yyvsp[-2].string));
}
#line 2625 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 156:
#line 1576 "parse_y.y" /* yacc.c:1646 */
{
char p_number[8];
sprintf(p_number, "%d", pin_num++);
CreateNewPin(yyElement, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), 2*GROUNDPLANEFRAME,
OU ((yyvsp[-4].measure)) + 2*MASKFRAME, OU ((yyvsp[-3].measure)), (yyvsp[-2].string), p_number, OldFlags((yyvsp[-1].integer)));
free ((yyvsp[-2].string));
}
#line 2639 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 157:
#line 1592 "parse_y.y" /* yacc.c:1646 */
{
Coord hole = OU ((yyvsp[-3].measure)) * <API key>;
char p_number[8];
/* make sure that there's enough copper left */
if (OU ((yyvsp[-3].measure)) - hole < MIN_PINORVIACOPPER &&
OU ((yyvsp[-3].measure)) > MIN_PINORVIACOPPER)
hole = OU ((yyvsp[-3].measure)) - MIN_PINORVIACOPPER;
sprintf(p_number, "%d", pin_num++);
CreateNewPin(yyElement, OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), 2*GROUNDPLANEFRAME,
OU ((yyvsp[-3].measure)) + 2*MASKFRAME, hole, (yyvsp[-2].string), p_number, OldFlags((yyvsp[-1].integer)));
free ((yyvsp[-2].string));
}
#line 2658 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 158:
#line 1646 "parse_y.y" /* yacc.c:1646 */
{
CreateNewPad(yyElement, NU ((yyvsp[-10].measure)) + yyElement->MarkX,
NU ((yyvsp[-9].measure)) + yyElement->MarkY,
NU ((yyvsp[-8].measure)) + yyElement->MarkX,
NU ((yyvsp[-7].measure)) + yyElement->MarkY, NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)),
(yyvsp[-3].string), (yyvsp[-2].string), (yyvsp[-1].flagtype));
free ((yyvsp[-3].string));
free ((yyvsp[-2].string));
}
#line 2672 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 159:
#line 1660 "parse_y.y" /* yacc.c:1646 */
{
CreateNewPad(yyElement,OU ((yyvsp[-10].measure)) + yyElement->MarkX,
OU ((yyvsp[-9].measure)) + yyElement->MarkY, OU ((yyvsp[-8].measure)) + yyElement->MarkX,
OU ((yyvsp[-7].measure)) + yyElement->MarkY, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)),
(yyvsp[-3].string), (yyvsp[-2].string), OldFlags((yyvsp[-1].integer)));
free ((yyvsp[-3].string));
free ((yyvsp[-2].string));
}
#line 2685 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 160:
#line 1673 "parse_y.y" /* yacc.c:1646 */
{
CreateNewPad(yyElement,OU ((yyvsp[-8].measure)),OU ((yyvsp[-7].measure)),OU ((yyvsp[-6].measure)),OU ((yyvsp[-5].measure)),OU ((yyvsp[-4].measure)), 2*GROUNDPLANEFRAME,
OU ((yyvsp[-4].measure)) + 2*MASKFRAME, (yyvsp[-3].string), (yyvsp[-2].string), OldFlags((yyvsp[-1].integer)));
free ((yyvsp[-3].string));
free ((yyvsp[-2].string));
}
#line 2696 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 161:
#line 1684 "parse_y.y" /* yacc.c:1646 */
{
char p_number[8];
sprintf(p_number, "%d", pin_num++);
CreateNewPad(yyElement,OU ((yyvsp[-7].measure)),OU ((yyvsp[-6].measure)),OU ((yyvsp[-5].measure)),OU ((yyvsp[-4].measure)),OU ((yyvsp[-3].measure)), 2*GROUNDPLANEFRAME,
OU ((yyvsp[-3].measure)) + 2*MASKFRAME, (yyvsp[-2].string),p_number, OldFlags((yyvsp[-1].integer)));
free ((yyvsp[-2].string));
}
#line 2709 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 162:
#line 1694 "parse_y.y" /* yacc.c:1646 */
{ (yyval.flagtype) = OldFlags((yyvsp[0].integer)); }
#line 2715 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 163:
#line 1695 "parse_y.y" /* yacc.c:1646 */
{ (yyval.flagtype) = string_to_flags ((yyvsp[0].string), yyerror); }
#line 2721 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 167:
#line 1725 "parse_y.y" /* yacc.c:1646 */
{
if ((yyvsp[-3].integer) <= 0 || (yyvsp[-3].integer) > MAX_FONTPOSITION)
{
yyerror("fontposition out of range");
YYABORT;
}
Symbol = &yyFont->Symbol[(yyvsp[-3].integer)];
if (Symbol->Valid)
{
yyerror("symbol ID used twice");
YYABORT;
}
Symbol->Valid = true;
Symbol->Delta = NU ((yyvsp[-2].measure));
}
#line 2741 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 168:
#line 1741 "parse_y.y" /* yacc.c:1646 */
{
if ((yyvsp[-3].integer) <= 0 || (yyvsp[-3].integer) > MAX_FONTPOSITION)
{
yyerror("fontposition out of range");
YYABORT;
}
Symbol = &yyFont->Symbol[(yyvsp[-3].integer)];
if (Symbol->Valid)
{
yyerror("symbol ID used twice");
YYABORT;
}
Symbol->Valid = true;
Symbol->Delta = OU ((yyvsp[-2].measure));
}
#line 2761 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 174:
#line 1788 "parse_y.y" /* yacc.c:1646 */
{
<API key>(Symbol, OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), OU ((yyvsp[-2].measure)), OU ((yyvsp[-1].measure)));
}
#line 2769 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 175:
#line 1795 "parse_y.y" /* yacc.c:1646 */
{
<API key>(Symbol, NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), NU ((yyvsp[-3].measure)), NU ((yyvsp[-2].measure)), NU ((yyvsp[-1].measure)));
}
#line 2777 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 183:
#line 1849 "parse_y.y" /* yacc.c:1646 */
{
Menu = CreateNewNet(&yyPCB->NetlistLib, (yyvsp[-3].string), (yyvsp[-2].string));
free ((yyvsp[-3].string));
free ((yyvsp[-2].string));
}
#line 2787 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 189:
#line 1884 "parse_y.y" /* yacc.c:1646 */
{
CreateNewConnection(Menu, (yyvsp[-1].string));
free ((yyvsp[-1].string));
}
#line 2796 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 190:
#line 1914 "parse_y.y" /* yacc.c:1646 */
{
CreateNewAttribute (attr_list, (yyvsp[-2].string), (yyvsp[-1].string) ? (yyvsp[-1].string) : (char *)"");
free ((yyvsp[-2].string));
free ((yyvsp[-1].string));
}
#line 2806 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 191:
#line 1921 "parse_y.y" /* yacc.c:1646 */
{ (yyval.string) = (yyvsp[0].string); }
#line 2812 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 192:
#line 1922 "parse_y.y" /* yacc.c:1646 */
{ (yyval.string) = 0; }
#line 2818 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 193:
#line 1926 "parse_y.y" /* yacc.c:1646 */
{ (yyval.number) = (yyvsp[0].number); }
#line 2824 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 194:
#line 1927 "parse_y.y" /* yacc.c:1646 */
{ (yyval.number) = (yyvsp[0].integer); }
#line 2830 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 195:
#line 1932 "parse_y.y" /* yacc.c:1646 */
{ do_measure(&(yyval.measure), (yyvsp[0].number), MIL_TO_COORD ((yyvsp[0].number)) / 100.0, 0); }
#line 2836 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 196:
#line 1933 "parse_y.y" /* yacc.c:1646 */
{ M ((yyval.measure), (yyvsp[-1].number), MIL_TO_COORD ((yyvsp[-1].number)) / 100000.0); }
#line 2842 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 197:
#line 1934 "parse_y.y" /* yacc.c:1646 */
{ M ((yyval.measure), (yyvsp[-1].number), MIL_TO_COORD ((yyvsp[-1].number)) / 100.0); }
#line 2848 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 198:
#line 1935 "parse_y.y" /* yacc.c:1646 */
{ M ((yyval.measure), (yyvsp[-1].number), MIL_TO_COORD ((yyvsp[-1].number))); }
#line 2854 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 199:
#line 1936 "parse_y.y" /* yacc.c:1646 */
{ M ((yyval.measure), (yyvsp[-1].number), INCH_TO_COORD ((yyvsp[-1].number))); }
#line 2860 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 200:
#line 1937 "parse_y.y" /* yacc.c:1646 */
{ M ((yyval.measure), (yyvsp[-1].number), MM_TO_COORD ((yyvsp[-1].number)) / 1000000.0); }
#line 2866 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 201:
#line 1938 "parse_y.y" /* yacc.c:1646 */
{ M ((yyval.measure), (yyvsp[-1].number), MM_TO_COORD ((yyvsp[-1].number)) / 1000.0); }
#line 2872 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 202:
#line 1939 "parse_y.y" /* yacc.c:1646 */
{ M ((yyval.measure), (yyvsp[-1].number), MM_TO_COORD ((yyvsp[-1].number))); }
#line 2878 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 203:
#line 1940 "parse_y.y" /* yacc.c:1646 */
{ M ((yyval.measure), (yyvsp[-1].number), MM_TO_COORD ((yyvsp[-1].number)) * 1000.0); }
#line 2884 "parse_y.tab.c" /* yacc.c:1646 */
break;
case 204:
#line 1941 "parse_y.y" /* yacc.c:1646 */
{ M ((yyval.measure), (yyvsp[-1].number), MM_TO_COORD ((yyvsp[-1].number)) * 1000000.0); }
#line 2890 "parse_y.tab.c" /* yacc.c:1646 */
break;
#line 2894 "parse_y.tab.c" /* yacc.c:1646 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
that yytoken be updated with the new translation. We take the
approach of translating immediately before every use of yytoken.
One alternative is translating here after every semantic action,
but that translation would be missed if the semantic action invokes
YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
incorrect destructor might then be invoked immediately. In the
case of YYERROR or YYBACKUP, subsequent parser actions might lead
to an incorrect destructor call or verbose syntax error message
before the lookahead is translated. */
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
*++yyvsp = yyval;
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTOKENS];
goto yynewstate;
yyerrlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
++yynerrs;
#if ! YYERROR_VERBOSE
yyerror (YY_("syntax error"));
#else
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
yyssp, yytoken)
{
char const *yymsgp = YY_("syntax error");
int <API key>;
<API key> = YYSYNTAX_ERROR;
if (<API key> == 0)
yymsgp = yymsg;
else if (<API key> == 1)
{
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
if (!yymsg)
{
yymsg = yymsgbuf;
yymsg_alloc = sizeof yymsgbuf;
<API key> = 2;
}
else
{
<API key> = YYSYNTAX_ERROR;
yymsgp = yymsg;
}
}
yyerror (yymsgp);
if (<API key> == 2)
goto yyexhaustedlab;
}
# undef YYSYNTAX_ERROR
#endif
}
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
else
{
yydestruct ("Error: discarding",
yytoken, &yylval);
yychar = YYEMPTY;
}
}
/* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
yyerrorlab:
/* Pacify compilers like GCC when the user code never invokes
YYERROR and the label yyerrorlab therefore never appears in user
code. */
if (/*CONSTCOND*/ 0)
goto yyerrorlab;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
yystate = *yyssp;
goto yyerrlab1;
yyerrlab1:
yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;)
{
yyn = yypact[yystate];
if (!<API key> (yyn))
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
{
yyn = yytable[yyn];
if (0 < yyn)
break;
}
}
/* Pop the current state because it cannot handle the error token. */
if (yyssp == yyss)
YYABORT;
yydestruct ("Error: popping",
yystos[yystate], yyvsp);
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
}
<API key>
*++yyvsp = yylval;
<API key>
/* Shift the error token. */
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
yystate = yyn;
goto yynewstate;
yyacceptlab:
yyresult = 0;
goto yyreturn;
yyabortlab:
yyresult = 1;
goto yyreturn;
#if !defined yyoverflow || YYERROR_VERBOSE
yyexhaustedlab:
yyerror (YY_("memory exhausted"));
yyresult = 2;
/* Fall through. */
#endif
yyreturn:
if (yychar != YYEMPTY)
{
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = YYTRANSLATE (yychar);
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval);
}
/* Do not reclaim the symbols of the rule whose action triggered
this YYABORT or YYACCEPT. */
YYPOPSTACK (yylen);
YY_STACK_PRINT (yyss, yyssp);
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
yystos[*yyssp], yyvsp);
YYPOPSTACK (1);
}
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);
#endif
#if YYERROR_VERBOSE
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
#endif
return yyresult;
}
#line 1944 "parse_y.y" /* yacc.c:1906 */
int yyerror(const char * s)
{
Message("ERROR parsing file '%s'\n"
" line: %i\n"
" description: '%s'\n",
yyfilename, yylineno, s);
return(0);
}
int yywrap()
{
return 1;
}
static int
check_file_version (int ver)
{
if ( ver > PCB_FILE_VERSION ) {
Message ("ERROR: The file you are attempting to load is in a format\n"
"which is too new for this version of pcb. To load this file\n"
"you need a version of pcb which is >= %d. If you are\n"
"using a version built from git source, the source date\n"
"must be >= %d. This copy of pcb can only read files\n"
"up to file version %d.\n", ver, ver, PCB_FILE_VERSION);
return 1;
}
return 0;
}
static void
do_measure (PLMeasure *m, Coord i, double d, int u)
{
m->ival = i;
m->bval = round (d);
m->dval = d;
m->has_units = u;
}
static int
integer_value (PLMeasure m)
{
if (m.has_units)
yyerror("units ignored here");
return m.ival;
}
static Coord
old_units (PLMeasure m)
{
if (m.has_units)
return m.bval;
return round (MIL_TO_COORD (m.ival));
}
static Coord
new_units (PLMeasure m)
{
if (m.has_units)
return m.bval;
return round (MIL_TO_COORD (m.ival) / 100.0);
} |
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94";
#endif /* LIBC_SCCS and not lint */
/*
* the outer shell of regexec()
*
* This file includes engine.c *twice*, after muchos fiddling with the
* macros that code uses. This lets the same code operate on two different
* representations for state sets.
*/
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <ctype.h>
/* #include <regex.h>*/
#include "regex.h"
#include "utils.h"
#include "regex2.h"
static int nope = 0; /* for use in asserts; shuts lint up */
/* macros for manipulating states, small version */
#define states long
#define states1 states /* for later use in regexec() decision */
#define CLEAR(v) ((v) = 0)
#define SET0(v, n) ((v) &= ~(1 << (n)))
#define SET1(v, n) ((v) |= 1 << (n))
#define ISSET(v, n) ((v) & (1 << (n)))
#define ASSIGN(d, s) ((d) = (s))
#define EQ(a, b) ((a) == (b))
#define STATEVARS int dummy /* dummy version */
#define STATESETUP(m, n) /* nothing */
#define STATETEARDOWN(m) /* nothing */
#define SETUP(v) ((v) = 0)
#define onestate int
#define INIT(o, n) ((o) = (unsigned)1 << (n))
#define INC(o) ((o) <<= 1)
#define ISSTATEIN(v, o) ((v) & (o))
/* some abbreviations; note that some of these know variable names! */
/* do "if I'm here, I can also be there" etc without branches */
#define FWD(dst, src, n) ((dst) |= ((unsigned)(src)&(here)) << (n))
#define BACK(dst, src, n) ((dst) |= ((unsigned)(src)&(here)) >> (n))
#define ISSETBACK(v, n) ((v) & ((unsigned)here >> (n)))
/* function names */
#define SNAMES /* engine.c looks after details */
#include "engine.c"
/* now undo things */
#undef states
#undef CLEAR
#undef SET0
#undef SET1
#undef ISSET
#undef ASSIGN
#undef EQ
#undef STATEVARS
#undef STATESETUP
#undef STATETEARDOWN
#undef SETUP
#undef onestate
#undef INIT
#undef INC
#undef ISSTATEIN
#undef FWD
#undef BACK
#undef ISSETBACK
#undef SNAMES
/* macros for manipulating states, large version */
#define states char *
#define CLEAR(v) memset(v, 0, m->g->nstates)
#define SET0(v, n) ((v)[n] = 0)
#define SET1(v, n) ((v)[n] = 1)
#define ISSET(v, n) ((v)[n])
#define ASSIGN(d, s) memcpy(d, s, m->g->nstates)
#define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0)
#define STATEVARS int vn; char *space
#define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \
if ((m)->space == NULL) return(REG_ESPACE); \
(m)->vn = 0; }
#define STATETEARDOWN(m) { free((m)->space); }
#define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates])
#define onestate int
#define INIT(o, n) ((o) = (n))
#define INC(o) ((o)++)
#define ISSTATEIN(v, o) ((v)[o])
/* some abbreviations; note that some of these know variable names! */
/* do "if I'm here, I can also be there" etc without branches */
#define FWD(dst, src, n) ((dst)[here+(n)] |= (src)[here])
#define BACK(dst, src, n) ((dst)[here-(n)] |= (src)[here])
#define ISSETBACK(v, n) ((v)[here - (n)])
/* function names */
#define LNAMES /* flag */
#include "engine.c"
/*
- regexec - interface for matching
= extern int regexec(const regex_t *, const char *, size_t, \
= regmatch_t [], int);
= #define REG_NOTBOL 00001
= #define REG_NOTEOL 00002
= #define REG_STARTEND 00004
= #define REG_TRACE 00400 // tracing of execution
= #define REG_LARGE 01000 // force large representation
= #define REG_BACKR 02000 // force use of backref code
*
* We put this here so we can exploit knowledge of the state representation
* when choosing which matcher to call. Also, by this point the matchers
* have been prototyped.
*/
int /* 0 success, REG_NOMATCH failure */
regexec(preg, string, nmatch, pmatch, eflags)
const regex_t *preg;
const char *string;
size_t nmatch;
regmatch_t pmatch[];
int eflags;
{
register struct re_guts *g = preg->re_g;
#ifdef REDEBUG
# define GOODFLAGS(f) (f)
#else
# define GOODFLAGS(f) ((f)&(REG_NOTBOL|REG_NOTEOL|REG_STARTEND))
#endif
if (preg->re_magic != MAGIC1 || g->magic != MAGIC2)
return(REG_BADPAT);
assert(!(g->iflags&BAD));
if (g->iflags&BAD) /* backstop for no-debug case */
return(REG_BADPAT);
eflags = GOODFLAGS(eflags);
if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags®_LARGE))
return(smatcher(g, (char *)string, nmatch, pmatch, eflags));
else
return(lmatcher(g, (char *)string, nmatch, pmatch, eflags));
} |
//>>built
define("dojox/editor/plugins/nls/pt/InsertEntity",{insertEntity:"Inserir S\u00edmbolo"});
//@ sourceMappingURL=InsertEntity.js.map |
package com.bob.demo02.client;
import com.bob.demo02.domain.Constants;
import com.bob.demo02.domain.msg.AskMsg;
import com.bob.demo02.domain.msg.AskParams;
import com.bob.demo02.domain.msg.LoginMsg;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.serialization.ClassResolvers;
import io.netty.handler.codec.serialization.ObjectDecoder;
import io.netty.handler.codec.serialization.ObjectEncoder;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.util.concurrent.<API key>;
import io.netty.util.concurrent.EventExecutorGroup;
import java.util.concurrent.TimeUnit;
public class <API key> {
private int port;
private String host;
private SocketChannel socketChannel;
private static final EventExecutorGroup group = new <API key>(20);
public <API key>(int port, String host) throws <API key> {
this.port = port;
this.host = host;
start();
}
private void start() throws <API key> {
EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
Bootstrap bootstrap = new Bootstrap();
bootstrap.channel(NioSocketChannel.class);
bootstrap.option(ChannelOption.SO_KEEPALIVE, true);
bootstrap.group(eventLoopGroup);
bootstrap.remoteAddress(host, port);
bootstrap.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
socketChannel.pipeline().addLast(new IdleStateHandler(20, 10, 0));
socketChannel.pipeline().addLast(new ObjectEncoder());
socketChannel.pipeline().addLast(new ObjectDecoder(ClassResolvers.cacheDisabled(null)));
socketChannel.pipeline().addLast(new NettyClientHandler());
}
});
ChannelFuture future = bootstrap.connect(host, port).sync();
if (future.isSuccess()) {
socketChannel = (SocketChannel) future.channel();
System.out.println("connect server
}
}
public static void main(String[] args) throws <API key> {
Constants.setClientId("001");
<API key> bootstrap = new <API key>(9999, "localhost");
LoginMsg loginMsg = new LoginMsg();
loginMsg.setPassword("yao");
loginMsg.setUserName("robin");
bootstrap.socketChannel.writeAndFlush(loginMsg);
// while (true) {
// TimeUnit.SECONDS.sleep(20);
// AskMsg askMsg = new AskMsg();
// AskParams askParams = new AskParams();
// askParams.setAuth("authToken");
// askMsg.setParams(askParams);
// bootstrap.socketChannel.writeAndFlush(askMsg);
}
} |
// System.Security.Cryptography.X509Certificate2 class
// Sebastien Pouliot <sebastien@ximian.com>
// 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,
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// included in all copies or substantial portions of the Software.
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// 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.
#if SECURITY_DEP
#if MONOTOUCH || MONODROID
using Mono.Security;
using Mono.Security.Cryptography;
using MX = Mono.Security.X509;
#else
extern alias MonoSecurity;
using MonoSecurity::Mono.Security;
using MonoSecurity::Mono.Security.Cryptography;
using MX = MonoSecurity::Mono.Security.X509;
#endif
#endif
using System.IO;
using System.Text;
namespace System.Security.Cryptography.X509Certificates {
#if NET_4_0
[Serializable]
#endif
public class X509Certificate2 : X509Certificate {
#if !SECURITY_DEP
// Used in Mono.Security HttpsClientStream
public X509Certificate2 (byte[] rawData)
{
}
#endif
#if SECURITY_DEP
private bool _archived;
private <API key> _extensions;
private string _name = String.Empty;
private string _serial;
private PublicKey _publicKey;
private <API key> issuer_name;
private <API key> subject_name;
private Oid signature_algorithm;
private MX.X509Certificate _cert;
private static string empty_error = Locale.GetText ("Certificate instance is empty.");
// constructors
public X509Certificate2 ()
{
_cert = null;
}
public X509Certificate2 (byte[] rawData)
{
Import (rawData, (string)null, X509KeyStorageFlags.DefaultKeySet);
}
public X509Certificate2 (byte[] rawData, string password)
{
Import (rawData, password, X509KeyStorageFlags.DefaultKeySet);
}
public X509Certificate2 (byte[] rawData, SecureString password)
{
Import (rawData, password, X509KeyStorageFlags.DefaultKeySet);
}
public X509Certificate2 (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
{
Import (rawData, password, keyStorageFlags);
}
public X509Certificate2 (byte[] rawData, SecureString password, X509KeyStorageFlags keyStorageFlags)
{
Import (rawData, password, keyStorageFlags);
}
public X509Certificate2 (string fileName)
{
Import (fileName, String.Empty, X509KeyStorageFlags.DefaultKeySet);
}
public X509Certificate2 (string fileName, string password)
{
Import (fileName, password, X509KeyStorageFlags.DefaultKeySet);
}
public X509Certificate2 (string fileName, SecureString password)
{
Import (fileName, password, X509KeyStorageFlags.DefaultKeySet);
}
public X509Certificate2 (string fileName, string password, X509KeyStorageFlags keyStorageFlags)
{
Import (fileName, password, keyStorageFlags);
}
public X509Certificate2 (string fileName, SecureString password, X509KeyStorageFlags keyStorageFlags)
{
Import (fileName, password, keyStorageFlags);
}
public X509Certificate2 (IntPtr handle) : base (handle)
{
_cert = new MX.X509Certificate (base.GetRawCertData ());
}
public X509Certificate2 (X509Certificate certificate)
: base (certificate)
{
_cert = new MX.X509Certificate (base.GetRawCertData ());
}
// properties
public bool Archived {
get {
if (_cert == null)
throw new <API key> (empty_error);
return _archived;
}
set {
if (_cert == null)
throw new <API key> (empty_error);
_archived = value;
}
}
public <API key> Extensions {
get {
if (_cert == null)
throw new <API key> (empty_error);
if (_extensions == null)
_extensions = new <API key> (_cert);
return _extensions;
}
}
public string FriendlyName {
get {
if (_cert == null)
throw new <API key> (empty_error);
return _name;
}
set {
if (_cert == null)
throw new <API key> (empty_error);
_name = value;
}
}
// FIXME - Could be more efficient
public bool HasPrivateKey {
get { return PrivateKey != null; }
}
public <API key> IssuerName {
get {
if (_cert == null)
throw new <API key> (empty_error);
if (issuer_name == null)
issuer_name = new <API key> (_cert.GetIssuerName ().GetBytes ());
return issuer_name;
}
}
public DateTime NotAfter {
get {
if (_cert == null)
throw new <API key> (empty_error);
return _cert.ValidUntil.ToLocalTime ();
}
}
public DateTime NotBefore {
get {
if (_cert == null)
throw new <API key> (empty_error);
return _cert.ValidFrom.ToLocalTime ();
}
}
public AsymmetricAlgorithm PrivateKey {
get {
if (_cert == null)
throw new <API key> (empty_error);
try {
if (_cert.RSA != null) {
<API key> rcsp = _cert.RSA as <API key>;
if (rcsp != null)
return rcsp.PublicOnly ? null : rcsp;
RSAManaged rsam = _cert.RSA as RSAManaged;
if (rsam != null)
return rsam.PublicOnly ? null : rsam;
_cert.RSA.ExportParameters (true);
return _cert.RSA;
} else if (_cert.DSA != null) {
<API key> dcsp = _cert.DSA as <API key>;
if (dcsp != null)
return dcsp.PublicOnly ? null : dcsp;
_cert.DSA.ExportParameters (true);
return _cert.DSA;
}
}
catch {
}
return null;
}
set {
if (_cert == null)
throw new <API key> (empty_error);
// allow NULL so we can "forget" the key associated to the certificate
// e.g. in case we want to export it in another format (see bug #396620)
if (value == null) {
_cert.RSA = null;
_cert.DSA = null;
} else if (value is RSA)
_cert.RSA = (RSA) value;
else if (value is DSA)
_cert.DSA = (DSA) value;
else
throw new <API key> ();
}
}
public PublicKey PublicKey {
get {
if (_cert == null)
throw new <API key> (empty_error);
if (_publicKey == null) {
try {
_publicKey = new PublicKey (_cert);
}
catch (Exception e) {
string msg = Locale.GetText ("Unable to decode public key.");
throw new <API key> (msg, e);
}
}
return _publicKey;
}
}
public byte[] RawData {
get {
if (_cert == null)
throw new <API key> (empty_error);
return base.GetRawCertData ();
}
}
public string SerialNumber {
get {
if (_cert == null)
throw new <API key> (empty_error);
if (_serial == null) {
StringBuilder sb = new StringBuilder ();
byte[] serial = _cert.SerialNumber;
for (int i=serial.Length - 1; i >= 0; i
sb.Append (serial [i].ToString ("X2"));
_serial = sb.ToString ();
}
return _serial;
}
}
public Oid SignatureAlgorithm {
get {
if (_cert == null)
throw new <API key> (empty_error);
if (signature_algorithm == null)
signature_algorithm = new Oid (_cert.SignatureAlgorithm);
return signature_algorithm;
}
}
public <API key> SubjectName {
get {
if (_cert == null)
throw new <API key> (empty_error);
if (subject_name == null)
subject_name = new <API key> (_cert.GetSubjectName ().GetBytes ());
return subject_name;
}
}
public string Thumbprint {
get { return base.GetCertHashString (); }
}
public int Version {
get {
if (_cert == null)
throw new <API key> (empty_error);
return _cert.Version;
}
}
// methods
[MonoTODO ("always return String.Empty for UpnName, <API key> and UrlName")]
public string GetNameInfo (X509NameType nameType, bool forIssuer)
{
switch (nameType) {
case X509NameType.SimpleName:
if (_cert == null)
throw new <API key> (empty_error);
// return CN= or, if missing, the first part of the DN
ASN1 sn = forIssuer ? _cert.GetIssuerName () : _cert.GetSubjectName ();
ASN1 dn = Find (commonName, sn);
if (dn != null)
return GetValueAsString (dn);
if (sn.Count == 0)
return String.Empty;
ASN1 last_entry = sn [sn.Count - 1];
if (last_entry.Count == 0)
return String.Empty;
return GetValueAsString (last_entry [0]);
case X509NameType.EmailName:
// return the E= part of the DN (if present)
ASN1 e = Find (email, forIssuer ? _cert.GetIssuerName () : _cert.GetSubjectName ());
if (e != null)
return GetValueAsString (e);
return String.Empty;
case X509NameType.UpnName:
// FIXME - must find/create test case
return String.Empty;
case X509NameType.DnsName:
// return the CN= part of the DN (if present)
ASN1 cn = Find (commonName, forIssuer ? _cert.GetIssuerName () : _cert.GetSubjectName ());
if (cn != null)
return GetValueAsString (cn);
return String.Empty;
case X509NameType.<API key>:
// FIXME - must find/create test case
return String.Empty;
case X509NameType.UrlName:
// FIXME - must find/create test case
return String.Empty;
default:
throw new ArgumentException ("nameType");
}
}
static byte[] commonName = { 0x55, 0x04, 0x03 };
static byte[] email = { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01 };
private ASN1 Find (byte[] oid, ASN1 dn)
{
if (dn.Count == 0)
return null;
// process SET
for (int i = 0; i < dn.Count; i++) {
ASN1 set = dn [i];
for (int j = 0; j < set.Count; j++) {
ASN1 pair = set [j];
if (pair.Count != 2)
continue;
ASN1 poid = pair [0];
if (poid == null)
continue;
if (poid.CompareValue (oid))
return pair;
}
}
return null;
}
private string GetValueAsString (ASN1 pair)
{
if (pair.Count != 2)
return String.Empty;
ASN1 value = pair [1];
if ((value.Value == null) || (value.Length == 0))
return String.Empty;
if (value.Tag == 0x1E) {
// BMPSTRING
StringBuilder sb = new StringBuilder ();
for (int j = 1; j < value.Value.Length; j += 2)
sb.Append ((char)value.Value [j]);
return sb.ToString ();
} else {
return Encoding.UTF8.GetString (value.Value);
}
}
private MX.X509Certificate ImportPkcs12 (byte[] rawData, string password)
{
MX.PKCS12 pfx = null;
if (string.IsNullOrEmpty (password)) {
try {
// Support both unencrypted PKCS
pfx = new MX.PKCS12 (rawData, (string)null);
} catch {
// ..and PKCS#12 encrypted with an empty password
pfx = new MX.PKCS12 (rawData, string.Empty);
}
} else {
pfx = new MX.PKCS12 (rawData, password);
}
if (pfx.Certificates.Count == 0) {
// no certificate was found
return null;
} else if (pfx.Keys.Count == 0) {
// no key were found - pick the first certificate
return pfx.Certificates [0];
} else {
// find the certificate that match the first key
MX.X509Certificate cert = null;
var keypair = (pfx.Keys [0] as AsymmetricAlgorithm);
string pubkey = keypair.ToXmlString (false);
foreach (var c in pfx.Certificates) {
if (((c.RSA != null) && (pubkey == c.RSA.ToXmlString (false))) ||
((c.DSA != null) && (pubkey == c.DSA.ToXmlString (false)))) {
cert = c;
break;
}
}
if (cert == null) {
cert = pfx.Certificates [0]; // no match, pick first certificate without keys
} else {
cert.RSA = (keypair as RSA);
cert.DSA = (keypair as DSA);
}
return cert;
}
}
public override void Import (byte[] rawData)
{
Import (rawData, (string)null, X509KeyStorageFlags.DefaultKeySet);
}
[MonoTODO ("missing KeyStorageFlags support")]
public override void Import (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
{
MX.X509Certificate cert = null;
if (password == null) {
try {
cert = new MX.X509Certificate (rawData);
}
catch (Exception e) {
try {
cert = ImportPkcs12 (rawData, null);
}
catch {
string msg = Locale.GetText ("Unable to decode certificate.");
// inner exception is the original (not second) exception
throw new <API key> (msg, e);
}
}
} else {
// try PKCS
try {
cert = ImportPkcs12 (rawData, password);
}
catch {
// it's possible to supply a (unrequired/unusued) password
// fix bug #79028
cert = new MX.X509Certificate (rawData);
}
}
// we do not have to fully re-decode the certificate since X509Certificate does not deal with keys
if (cert != null) {
base.Import (cert.RawData, (string) null, keyStorageFlags);
_cert = cert; // becuase base call will call Reset!
}
}
[MonoTODO ("SecureString is incomplete")]
public override void Import (byte[] rawData, SecureString password, X509KeyStorageFlags keyStorageFlags)
{
Import (rawData, (string) null, keyStorageFlags);
}
public override void Import (string fileName)
{
byte[] rawData = File.ReadAllBytes (fileName);
Import (rawData, (string)null, X509KeyStorageFlags.DefaultKeySet);
}
[MonoTODO ("missing KeyStorageFlags support")]
public override void Import (string fileName, string password, X509KeyStorageFlags keyStorageFlags)
{
byte[] rawData = File.ReadAllBytes (fileName);
Import (rawData, password, keyStorageFlags);
}
[MonoTODO ("SecureString is incomplete")]
public override void Import (string fileName, SecureString password, X509KeyStorageFlags keyStorageFlags)
{
byte[] rawData = File.ReadAllBytes (fileName);
Import (rawData, (string)null, keyStorageFlags);
}
public override void Reset ()
{
_cert = null;
_archived = false;
_extensions = null;
_name = String.Empty;
_serial = null;
_publicKey = null;
issuer_name = null;
subject_name = null;
signature_algorithm = null;
base.Reset ();
}
public override string ToString ()
{
if (_cert == null)
return "System.Security.Cryptography.X509Certificates.X509Certificate2";
return base.ToString (true);
}
public override string ToString (bool verbose)
{
if (_cert == null)
return "System.Security.Cryptography.X509Certificates.X509Certificate2";
// the non-verbose X509Certificate2 == verbose X509Certificate
if (!verbose)
return base.ToString (true);
string nl = Environment.NewLine;
StringBuilder sb = new StringBuilder ();
sb.AppendFormat ("[Version]{0} V{1}{0}{0}", nl, Version);
sb.AppendFormat ("[Subject]{0} {1}{0}{0}", nl, Subject);
sb.AppendFormat ("[Issuer]{0} {1}{0}{0}", nl, Issuer);
sb.AppendFormat ("[Serial Number]{0} {1}{0}{0}", nl, SerialNumber);
sb.AppendFormat ("[Not Before]{0} {1}{0}{0}", nl, NotBefore);
sb.AppendFormat ("[Not After]{0} {1}{0}{0}", nl, NotAfter);
sb.AppendFormat ("[Thumbprint]{0} {1}{0}{0}", nl, Thumbprint);
sb.AppendFormat ("[Signature Algorithm]{0} {1}({2}){0}{0}", nl, SignatureAlgorithm.FriendlyName,
SignatureAlgorithm.Value);
AsymmetricAlgorithm key = PublicKey.Key;
sb.AppendFormat ("[Public Key]{0} Algorithm: ", nl);
if (key is RSA)
sb.Append ("RSA");
else if (key is DSA)
sb.Append ("DSA");
else
sb.Append (key.ToString ());
sb.AppendFormat ("{0} Length: {1}{0} Key Blob: ", nl, key.KeySize);
AppendBuffer (sb, PublicKey.EncodedKeyValue.RawData);
sb.AppendFormat ("{0} Parameters: ", nl);
AppendBuffer (sb, PublicKey.EncodedParameters.RawData);
sb.Append (nl);
return sb.ToString ();
}
private static void AppendBuffer (StringBuilder sb, byte[] buffer)
{
if (buffer == null)
return;
for (int i=0; i < buffer.Length; i++) {
sb.Append (buffer [i].ToString ("x2"));
if (i < buffer.Length - 1)
sb.Append (" ");
}
}
[MonoTODO ("by default this depends on the incomplete X509Chain")]
public bool Verify ()
{
if (_cert == null)
throw new <API key> (empty_error);
X509Chain chain = X509Chain.Create ();
if (!chain.Build (this))
return false;
// TODO - check chain and other stuff ???
return true;
}
// static methods
private static byte[] signedData = new byte[] { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02 };
[MonoTODO ("Detection limited to Cert, Pfx, Pkcs12, Pkcs7 and Unknown")]
public static X509ContentType GetCertContentType (byte[] rawData)
{
if ((rawData == null) || (rawData.Length == 0))
throw new ArgumentException ("rawData");
X509ContentType type = X509ContentType.Unknown;
try {
ASN1 data = new ASN1 (rawData);
if (data.Tag != 0x30) {
string msg = Locale.GetText ("Unable to decode certificate.");
throw new <API key> (msg);
}
if (data.Count == 0)
return type;
if (data.Count == 3) {
switch (data [0].Tag) {
case 0x30:
// SEQUENCE / SEQUENCE / BITSTRING
if ((data [1].Tag == 0x30) && (data [2].Tag == 0x03))
type = X509ContentType.Cert;
break;
case 0x02:
// INTEGER / SEQUENCE / SEQUENCE
if ((data [1].Tag == 0x30) && (data [2].Tag == 0x30))
type = X509ContentType.Pkcs12;
// note: Pfx == Pkcs12
break;
}
}
// check for PKCS#7 (count unknown but greater than 0)
// SEQUENCE / OID (signedData)
if ((data [0].Tag == 0x06) && data [0].CompareValue (signedData))
type = X509ContentType.Pkcs7;
}
catch (Exception e) {
string msg = Locale.GetText ("Unable to decode certificate.");
throw new <API key> (msg, e);
}
return type;
}
[MonoTODO ("Detection limited to Cert, Pfx, Pkcs12 and Unknown")]
public static X509ContentType GetCertContentType (string fileName)
{
if (fileName == null)
throw new <API key> ("fileName");
if (fileName.Length == 0)
throw new ArgumentException ("fileName");
byte[] data = File.ReadAllBytes (fileName);
return GetCertContentType (data);
}
// internal stuff because X509Certificate2 isn't complete enough
// (maybe X509Certificate3 will be better?)
internal MX.X509Certificate MonoCertificate {
get { return _cert; }
}
#else
// HACK - this ensure the type X509Certificate2 and PrivateKey property exists in the build before
// Mono.Security.dll is built. This is required to get working client certificate in SSL/TLS
public AsymmetricAlgorithm PrivateKey {
get { return null; }
}
#endif
}
} |
# -*- coding: utf-8 -*-
# This tool helps you rebase your package to the latest version
# This program is free software; you can redistribute it and/or modify
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import logging
import os
import random
import string
import sys
import time
from typing import List, cast
from rebasehelper.exceptions import RebaseHelperError
from rebasehelper.helpers.console_helper import ConsoleHelper
from rebasehelper.helpers.rpm_helper import RpmHelper
from rebasehelper.helpers.download_helper import DownloadHelper
from rebasehelper.logger import CustomLogger
<API key>: bool
try:
import koji # type: ignore
from koji_cli.lib import TaskWatcher # type: ignore
except ImportError:
<API key> = False
else:
<API key> = True
logger: CustomLogger = cast(CustomLogger, logging.getLogger(__name__))
class KojiHelper:
functional: bool = <API key>
@classmethod
def create_session(cls, login=False, profile='koji'):
"""Creates new Koji session and immediately logs in to a Koji hub.
Args:
login (bool): Whether to perform a login.
profile (str): Koji profile to use.
Returns:
koji.ClientSession: Newly created session instance.
Raises:
RebaseHelperError: If login failed.
"""
config = koji.read_config(profile)
session = koji.ClientSession(config['server'], opts=config)
if not login:
return session
try:
session.gssapi_login()
except Exception: # pylint: disable=broad-except
pass
else:
return session
# fall back to kerberos login (doesn't work with python3)
exc = (koji.AuthError, koji.krbV.Krb5Error) if koji.krbV else koji.AuthError
try:
session.krb_login()
except exc as e:
raise RebaseHelperError('Login failed: {}'.format(str(e))) from e
else:
return session
@classmethod
def upload_srpm(cls, session, srpm):
"""Uploads SRPM to a Koji hub.
Args:
session (koji.ClientSession): Active Koji session instance.
srpm (str): Valid path to SRPM.
Returns:
str: Remote path to the uploaded SRPM.
Raises:
RebaseHelperError: If upload failed.
"""
def progress(uploaded, total, chunksize, t1, t2): # pylint: disable=unused-argument
DownloadHelper.progress(total, uploaded, upload_start)
suffix = ''.join(random.choice(string.ascii_letters) for _ in range(8))
path = os.path.join('cli-build', str(time.time()), suffix)
logger.info('Uploading SRPM')
try:
try:
upload_start = time.time()
session.uploadWrapper(srpm, path, callback=progress)
except koji.GenericError as e:
raise RebaseHelperError('Upload failed: {}'.format(str(e))) from e
finally:
sys.stdout.write('\n')
sys.stdout.flush()
return os.path.join(path, os.path.basename(srpm))
@classmethod
def get_task_url(cls, session, task_id):
return '/'.join([session.opts['weburl'], 'taskinfo?taskID={}'.format(task_id)])
@classmethod
def <API key>(cls, tasks):
"""Prints states of Koji tasks.
Args:
tasks (list): List of koji.TaskWatcher instances.
"""
for task in [t for t in tasks if t.level == 0]:
state = task.info['state']
task_label = task.str()
logger.info('State %s (%s)', state, task_label)
if state == koji.TASK_STATES['CLOSED']:
logger.info('%s completed successfully', task_label)
elif state == koji.TASK_STATES['FAILED']:
logger.info('%s failed', task_label)
elif state == koji.TASK_STATES['CANCELED']:
logger.info('%s was canceled', task_label)
else:
# shouldn't happen
logger.info('%s has not completed', task_label)
@classmethod
def watch_koji_tasks(cls, session, tasklist):
"""Waits for Koji tasks to finish and prints their states.
Args:
session (koji.ClientSession): Active Koji session instance.
tasklist (list): List of task IDs.
Returns:
dict: Dictionary mapping task IDs to their states or None if interrupted.
"""
if not tasklist:
return None
sys.stdout.flush()
rh_tasks = {}
try:
tasks = {}
for task_id in tasklist:
task_id = int(task_id)
tasks[task_id] = TaskWatcher(task_id, session, quiet=False)
while True:
all_done = True
for task_id, task in list(tasks.items()):
with ConsoleHelper.Capturer(stdout=True) as capturer:
changed = task.update()
for line in capturer.stdout.split('\n'):
if line:
logger.info(line)
info = session.getTaskInfo(task_id)
state = task.info['state']
if state == koji.TASK_STATES['FAILED']:
return {info['id']: state}
else:
# FIXME: multiple arches
if info['arch'] == 'x86_64' or info['arch'] == 'noarch':
rh_tasks[info['id']] = state
if not task.is_done():
all_done = False
else:
if changed:
# task is done and state just changed
cls.<API key>(list(tasks.values()))
if not task.is_success():
rh_tasks = None
for child in session.getTaskChildren(task_id):
child_id = child['id']
if child_id not in list(tasks.keys()):
tasks[child_id] = TaskWatcher(child_id, session, task.level + 1, quiet=False)
with ConsoleHelper.Capturer(stdout=True) as capturer:
tasks[child_id].update()
for line in capturer.stdout.split('\n'):
if line:
logger.info(line)
info = session.getTaskInfo(child_id)
state = task.info['state']
if state == koji.TASK_STATES['FAILED']:
return {info['id']: state}
else:
# FIXME: multiple arches
if info['arch'] == 'x86_64' or info['arch'] == 'noarch':
rh_tasks[info['id']] = state
# If we found new children, go through the list again,
# in case they have children also
all_done = False
if all_done:
cls.<API key>(list(tasks.values()))
break
sys.stdout.flush()
time.sleep(1)
except KeyboardInterrupt:
rh_tasks = None
return rh_tasks
@classmethod
def <API key>(cls, session, tasklist, destination):
"""Downloads packages and logs of finished Koji tasks.
Args:
session (koji.ClientSession): Active Koji session instance.
tasklist (list): List of task IDs.
destination (str): Path where to download files to.
Returns:
tuple: List of downloaded RPMs and list of downloaded logs.
Raises:
DownloadError: If download failed.
"""
rpms: List[str] = []
logs: List[str] = []
for task_id in tasklist:
logger.info('Downloading packages and logs for task %s', task_id)
task = session.getTaskInfo(task_id, request=True)
if task['state'] in [koji.TASK_STATES['FREE'], koji.TASK_STATES['OPEN']]:
logger.info('Task %s is still running!', task_id)
continue
elif task['state'] != koji.TASK_STATES['CLOSED']:
logger.info('Task %s did not complete successfully!', task_id)
if task['method'] == 'buildArch':
tasks = [task]
elif task['method'] == 'build':
opts = dict(parent=task_id, method='buildArch', decode=True,
state=[koji.TASK_STATES['CLOSED'], koji.TASK_STATES['FAILED']])
tasks = session.listTasks(opts=opts)
else:
logger.info('Task %s is not a build or buildArch task!', task_id)
continue
for task in tasks:
base_path = koji.pathinfo.taskrelpath(task['id'])
output = session.listTaskOutput(task['id'])
for filename in output:
local_path = os.path.join(destination, filename)
download = False
fn, ext = os.path.splitext(filename)
if ext == '.rpm':
if task['state'] != koji.TASK_STATES['CLOSED']:
continue
if local_path not in rpms:
nevra = RpmHelper.split_nevra(fn)
# FIXME: multiple arches
download = nevra['arch'] in ['noarch', 'x86_64']
if download:
rpms.append(local_path)
else:
if local_path not in logs:
download = True
logs.append(local_path)
if download:
logger.info('Downloading file %s', filename)
url = '/'.join([session.opts['topurl'], 'work', base_path, filename])
DownloadHelper.download_file(url, local_path)
return rpms, logs
@classmethod
def get_latest_build(cls, session, package):
"""Looks up latest Koji build of a package.
Args:
session (koji.ClientSession): Active Koji session instance.
package (str): Package name.
Returns:
tuple: Found latest package version and Koji build ID.
"""
builds = session.getLatestBuilds('rawhide', package=package)
if builds:
build = builds.pop()
return build['version'], build['id']
return None, None
@classmethod
def get_build(cls, session, package, version):
"""Looks up Koji build of a specific version of a package.
Args:
session (koji.ClientSession): Active Koji session instance.
package (str): Package name.
version (str): Package version.
Returns:
tuple: Found latest package version and Koji build ID.
"""
builds = session.listTagged('rawhide', inherit=True, package=package)
if builds:
for build in builds:
if build['version'] == version:
return build['version'], build['id']
return None, None
@classmethod
def download_build(cls, session, build_id, destination, arches):
"""Downloads RPMs and logs of a Koji build.
Args:
session (koji.ClientSession): Active Koji session instance.
build_id (str): Koji build ID.
destination (str): Path where to download files to.
arches (list): List of architectures to be downloaded.
Returns:
tuple: List of downloaded RPMs and list of downloaded logs.
Raises:
DownloadError: If download failed.
"""
build = session.getBuild(build_id)
pathinfo = koji.PathInfo(topdir=session.opts['topurl'])
rpms: List[str] = []
logs: List[str] = []
os.makedirs(destination, exist_ok=True)
for pkg in session.listBuildRPMs(build_id):
if pkg['arch'] not in arches:
continue
rpmpath = pathinfo.rpm(pkg)
local_path = os.path.join(destination, os.path.basename(rpmpath))
if local_path not in rpms:
url = pathinfo.build(build) + '/' + rpmpath
DownloadHelper.download_file(url, local_path)
rpms.append(local_path)
for logfile in session.getBuildLogs(build_id):
if logfile['dir'] not in arches:
continue
local_path = os.path.join(destination, logfile['name'])
if local_path not in logs:
url = pathinfo.topdir + '/' + logfile['path']
DownloadHelper.download_file(url, local_path)
logs.append(local_path)
return rpms, logs
@classmethod
def get_old_build_info(cls, package_name, package_version):
"""Gets old build info from Koji.
Args:
package_name (str): Package name from specfile.
package_version (str): Package version from specfile.
Returns:
tuple: Koji build id, package version.
"""
if cls.functional:
session = KojiHelper.create_session()
koji_version, koji_build_id = KojiHelper.get_build(session, package_name, package_version)
if koji_version:
return koji_build_id, koji_version
else:
logger.warning('Unable to find old version Koji build!')
return None, None
else:
logger.warning('Unable to get old version Koji build!')
return None, None |
<?php
namespace Core\Bundle\BlogBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class <API key> extends WebTestCase
{
public function testIndex()
{
$client = static::createClient();
$crawler = $client->request('GET', '/hello/Fabien');
$this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0);
}
} |
package de.geotech.systems.utilities;
import java.util.ArrayList;
import android.graphics.Color;
public class ClassesColorModel {
public ClassesColorModel() {
}
public class VCColor {
private String name;
private int color;
public VCColor(int i, String n) {
color = i;
name = n;
}
public String getText() {
return name;
}
public int getColor() {
return color;
}
@Override
public String toString() {
return getText();
}
}
public class ColorTable {
ArrayList<VCColor> table;
public ColorTable(){
table = new ArrayList<VCColor>();
table.add( new VCColor(Color.BLACK, "Black") );
table.add( new VCColor(Color.BLUE, "Blue") );
// table.add( new VCColor(Color.CYAN, "Cyan") );
table.add( new VCColor(Color.DKGRAY, "Dark gray") );
table.add( new VCColor(Color.GRAY, "Gray") );
table.add( new VCColor(Color.GREEN, "Green") );
table.add( new VCColor(Color.LTGRAY, "Light gray") );
table.add( new VCColor(Color.MAGENTA, "Magenta") );
table.add( new VCColor(Color.RED, "Red") );
table.add( new VCColor(Color.WHITE, "White") );
table.add( new VCColor(Color.YELLOW, "Yellow") );
}
public VCColor[] getColorsAsArray() {
VCColor[] array = new VCColor[table.size()];
table.toArray(array);
return array;
}
}
public VCColor[] getColorsAsArray() {
ColorTable table = new ColorTable();
return table.getColorsAsArray();
}
} |
#include "Database/SqlDelayThread.h"
#include "Database/SqlOperations.h"
#include "DatabaseEnv.h"
SqlDelayThread::SqlDelayThread(Database* db) : m_dbEngine(db), m_running(true)
{
}
void SqlDelayThread::run()
{
mysql_thread_init();
SqlAsyncTask * s = NULL;
ACE_Time_Value _time(2);
while (m_running)
{
// if the running state gets turned off while sleeping
// empty the queue before exiting
s = dynamic_cast<SqlAsyncTask*> (m_sqlQueue.dequeue());
if (s)
{
s->call();
delete s;
}
}
mysql_thread_end();
}
void SqlDelayThread::Stop()
{
m_running = false;
m_sqlQueue.queue()->deactivate();
}
bool SqlDelayThread::Delay(SqlOperation* sql)
{
int res = m_sqlQueue.enqueue(new SqlAsyncTask(m_dbEngine, sql));
return (res != -1);
} |
<html>
<head>
<title>RunUO Documentation - Class Overview - WhiteMisoSoup</title>
</head>
<body bgcolor="white" style="font-family: Courier New" text="#000000" link="#000000" vlink="#000000" alink="#808080">
<h4><a href="../namespaces/Server.Items.html">Back to Server.Items</a></h4>
<h2>WhiteMisoSoup : <!-- DBG-1 --><a href="Food.html">Food</a>, <!-- DBG-2.2 --><a href="IHued.html">IHued</a>, <!-- DBG-2.1 --><font color="blue">IComparable</font><<a href="Item.html">Item</a>>, <!-- DBG-2.2 --><a href="ISerializable.html">ISerializable</a>, <!-- DBG-2.2 --><a href="ISpawnable.html">ISpawnable</a>, <!-- DBG-2.2 --><a href="IEntity.html">IEntity</a>, <!-- DBG-2.2 --><a href="IPoint3D.html">IPoint3D</a>, <!-- DBG-2.2 --><a href="IPoint2D.html">IPoint2D</a>, <!-- DBG-2.1 --><font color="blue">IComparable</font>, <!-- DBG-2.1 --><font color="blue">IComparable</font><<a href="IEntity.html">IEntity</a>></h2>
(<font color="blue">ctor</font>) WhiteMisoSoup()<br>
(<font color="blue">ctor</font>) WhiteMisoSoup( <!-- DBG-0 --><a href="Serial.html">Serial</a> serial )<br>
<font color="blue">virtual</font> <font color="blue">void</font> Deserialize( <!-- DBG-0 --><a href="GenericReader.html">GenericReader</a> reader )<br>
<font color="blue">virtual</font> <font color="blue">void</font> Serialize( <!-- DBG-0 --><a href="GenericWriter.html">GenericWriter</a> writer )<br>
</body>
</html> |
#include "<API key>.h"
#include <map>
#include "qgsgeometry.h"
#include "qgslogger.h"
#include "qgsvectorfilewriter.h"
double leftOfTresh = 0.00000001;
<API key>::~<API key>()
{
//remove all the points
if ( mPointVector.count() > 0 )
{
for ( int i = 0; i < mPointVector.count(); i++ )
{
delete mPointVector[i];
}
}
//remove all the HalfEdge
if ( mHalfEdge.count() > 0 )
{
for ( int i = 0; i < mHalfEdge.count(); i++ )
{
delete mHalfEdge[i];
}
}
}
void <API key>::<API key>()
{
QgsDebugMsg( "performing consistency test" );
for ( int i = 0; i < mHalfEdge.count(); i++ )
{
int a = mHalfEdge[mHalfEdge[i]->getDual()]->getDual();
int b = mHalfEdge[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()]->getNext();
if ( i != a )
{
QgsDebugMsg( "warning, first test failed" );
}
if ( i != b )
{
QgsDebugMsg( "warning, second test failed" );
}
}
QgsDebugMsg( "consistency test finished" );
}
void <API key>::addLine( Line3D* line, bool breakline )
{
int actpoint = -10;//number of the last point, which has been inserted from the line
int currentpoint = -10;//number of the point, which is currently inserted from the line
if ( line )
{
//first, find the first point
unsigned int i;
line->goToBegin();
for ( i = 0; i < line->getSize(); i++ )
{
line->goToNext();
actpoint = mDecorator->addPoint( line->getPoint() );
if ( actpoint != -100 )
{
i++;
break;
}
}
if ( actpoint == -100 )//no point of the line could be inserted
{
delete line;
return;
}
for ( ; i < line->getSize(); i++ )
{
line->goToNext();
currentpoint = mDecorator->addPoint( line->getPoint() );
if ( currentpoint != -100 && actpoint != -100 && currentpoint != actpoint )//-100 is the return value if the point could not be not inserted
{
insertForcedSegment( actpoint, currentpoint, breakline );
}
actpoint = currentpoint;
}
}
delete line;
}
int <API key>::addPoint( Point3D* p )
{
if ( p )
{
// QgsDebugMsg( QString("inserting point %1,%2//%3//%4").arg(mPointVector.count()).arg(p->getX()).arg(p->getY()).arg(p->getZ()));
//first update the bounding box
if ( mPointVector.count() == 0 )//update bounding box when the first point is inserted
{
xMin = ( *p ).getX();
yMin = ( *p ).getY();
xMax = ( *p ).getX();
yMax = ( *p ).getY();
}
else//update bounding box else
{
if (( *p ).getX() < xMin )
{
xMin = ( *p ).getX();
}
else if (( *p ).getX() > xMax )
{
xMax = ( *p ).getX();
}
if (( *p ).getY() < yMin )
{
yMin = ( *p ).getY();
}
else if (( *p ).getY() > yMax )
{
yMax = ( *p ).getY();
}
}
//then update mPointVector
mPointVector.append( p );
//then update the HalfEdgeStructure
if ( mPointVector.count() == 1 )//insert the first point into the triangulation
{
unsigned int zedge = insertEdge( -10, -10, -1, false, false );//edge pointing from p to the virtual point
unsigned int fedge = insertEdge(( int )zedge, ( int )zedge, 0, false, false );//edge pointing from the virtual point to p
( mHalfEdge.at( zedge ) )->setDual(( int )fedge );
( mHalfEdge.at( zedge ) )->setNext(( int )fedge );
}
else if ( mPointVector.count() == 2 )//insert the second point into the triangulation
{
//test, if it is the same point as the first point
if ( p->getX() == mPointVector[0]->getX() && p->getY() == mPointVector[0]->getY() )
{
QgsDebugMsg( "second point is the same as the first point, it thus has not been inserted" );
Point3D* p = mPointVector[1];
mPointVector.remove( 1 );
delete p;
return -100;
}
unsigned int sedge = insertEdge( -10, -10, 1, false, false );//edge pointing from point 0 to point 1
unsigned int tedge = insertEdge(( int )sedge, 0, 0, false, false );//edge pointing from point 1 to point 0
unsigned int foedge = insertEdge( -10, 4, 1, false, false );//edge pointing from the virtual point to point 1
unsigned int fiedge = insertEdge(( int )foedge, 1, -1, false, false );//edge pointing from point 2 to the virtual point
mHalfEdge.at( sedge )->setDual(( int )tedge );
mHalfEdge.at( sedge )->setNext(( int )fiedge );
mHalfEdge.at( foedge )->setDual(( int )fiedge );
mHalfEdge.at( foedge )->setNext(( int )tedge );
mHalfEdge.at( 0 )->setNext(( int )foedge );
mHalfEdge.at( 1 )->setNext(( int )sedge );
mEdgeInside = 3;
}
else if ( mPointVector.count() == 3 )//insert the third point into the triangulation
{
//we first have to decide, if the third point is to the left or to the right of the line through p0 and p1
double number = MathUtils::leftOf( p, mPointVector[0], mPointVector[1] );
if ( number < -leftOfTresh )//p is on the left side
{
//insert six new edges
unsigned int edgea = insertEdge( -10, -10, 2, false, false );//edge pointing from point1 to point2
unsigned int edgeb = insertEdge(( int )edgea, 5, 1, false, false );//edge pointing from point2 to point1
unsigned int edgec = insertEdge( -10, ( int )edgeb, 2, false, false );//edge pointing from the virtual point to p2
unsigned int edged = insertEdge( -10, 2, 0, false, false );//edge pointing from point2 to point0
unsigned int edgee = insertEdge(( int )edged, -10, 2, false, false );//edge pointing from point0 to point2
unsigned int edgef = insertEdge(( int )edgec, 1, -1, false, false );//edge pointing from point2 to the virtual point
mHalfEdge.at( edgea )->setDual(( int )edgeb );
mHalfEdge.at( edgea )->setNext(( int )edged );
mHalfEdge.at( edgec )->setDual(( int )edgef );
mHalfEdge.at( edged )->setDual(( int )edgee );
mHalfEdge.at( edgee )->setNext(( int )edgef );
mHalfEdge.at( 5 )->setNext(( int )edgec );
mHalfEdge.at( 1 )->setNext(( int )edgee );
mHalfEdge.at( 2 )->setNext(( int )edgea );
}
else if ( number > leftOfTresh )//p is on the right side
{
//insert six new edges
unsigned int edgea = insertEdge( -10, -10, 2, false, false );//edge pointing from p0 to p2
unsigned int edgeb = insertEdge(( int )edgea, 0, 0, false, false );//edge pointing from p2 to p0
unsigned int edgec = insertEdge( -10, ( int )edgeb, 2, false, false );//edge pointing from the virtual point to p2
unsigned int edged = insertEdge( -10, 3, 1, false, false );//edge pointing from p2 to p1
unsigned int edgee = insertEdge(( int )edged, -10, 2, false, false );//edge pointing from p1 to p2
unsigned int edgef = insertEdge(( int )edgec, 4, -1, false, false );//edge pointing from p2 to the virtual point
mHalfEdge.at( edgea )->setDual(( int )edgeb );
mHalfEdge.at( edgea )->setNext(( int )edged );
mHalfEdge.at( edgec )->setDual(( int )edgef );
mHalfEdge.at( edged )->setDual(( int )edgee );
mHalfEdge.at( edgee )->setNext(( int )edgef );
mHalfEdge.at( 0 )->setNext(( int )edgec );
mHalfEdge.at( 4 )->setNext(( int )edgee );
mHalfEdge.at( 3 )->setNext(( int )edgea );
}
else//p is in a line with p0 and p1
{
mPointVector.remove( mPointVector.count() - 1 );
QgsDebugMsg( "error: third point is on the same line as the first and the second point. It thus has not been inserted into the triangulation" );
return -100;
}
}
else if ( mPointVector.count() >= 4 )//insert an arbitrary point into the triangulation
{
int number = baseEdgeOfTriangle( p );
if ( number == -10 )
{
unsigned int cwedge = mEdgeOutside;//the last visible edge clockwise from mEdgeOutside
unsigned int ccwedge = mEdgeOutside;//the last visible edge counterclockwise from mEdgeOutside
//mEdgeOutside is in each case visible
mHalfEdge[mHalfEdge[mEdgeOutside]->getNext()]->setPoint( mPointVector.count() - 1 );
//find cwedge and replace the virtual point with the new point when necessary
while ( MathUtils::leftOf( mPointVector[( unsigned int ) mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[cwedge]->getNext()]->getDual()]->getNext()]->getPoint()], p, mPointVector[( unsigned int ) mHalfEdge[cwedge]->getPoint()] ) < ( -leftOfTresh ) )
{
//set the point number of the necessary edge to the actual point instead of the virtual point
mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[cwedge]->getNext()]->getDual()]->getNext()]->getNext()]->setPoint( mPointVector.count() - 1 );
//advance cwedge one edge further clockwise
cwedge = ( unsigned int )mHalfEdge[mHalfEdge[mHalfEdge[cwedge]->getNext()]->getDual()]->getNext();
}
//build the necessary connections with the virtual point
unsigned int edge1 = insertEdge( mHalfEdge[cwedge]->getNext(), -10, mHalfEdge[cwedge]->getPoint(), false, false );//edge pointing from the new point to the last visible point clockwise
unsigned int edge2 = insertEdge( mHalfEdge[mHalfEdge[cwedge]->getNext()]->getDual(), -10, -1, false, false );//edge pointing from the last visible point to the virtual point
unsigned int edge3 = insertEdge( -10, edge1, mPointVector.count() - 1, false, false );//edge pointing from the virtual point to new point
//adjust the other pointers
mHalfEdge[mHalfEdge[mHalfEdge[cwedge]->getNext()]->getDual()]->setDual( edge2 );
mHalfEdge[mHalfEdge[cwedge]->getNext()]->setDual( edge1 );
mHalfEdge[edge1]->setNext( edge2 );
mHalfEdge[edge2]->setNext( edge3 );
//find ccwedge and replace the virtual point with the new point when necessary
while ( MathUtils::leftOf( mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[ccwedge]->getNext()]->getNext()]->getPoint()], mPointVector[mPointVector.count()-1], mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[ccwedge]->getNext()]->getNext()]->getDual()]->getNext()]->getPoint()] ) < ( -leftOfTresh ) )
{
//set the point number of the necessary edge to the actual point instead of the virtual point
mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[ccwedge]->getNext()]->getNext()]->getDual()]->setPoint( mPointVector.count() - 1 );
//advance ccwedge one edge further counterclockwise
ccwedge = mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[ccwedge]->getNext()]->getNext()]->getDual()]->getNext()]->getNext();
}
//build the necessary connections with the virtual point
unsigned int edge4 = insertEdge( mHalfEdge[mHalfEdge[ccwedge]->getNext()]->getNext(), -10, mPointVector.count() - 1, false, false );//points from the last visible point counterclockwise to the new point
unsigned int edge5 = insertEdge( edge3, -10, -1, false, false );//points from the new point to the virtual point
unsigned int edge6 = insertEdge( mHalfEdge[mHalfEdge[mHalfEdge[ccwedge]->getNext()]->getNext()]->getDual(), edge4, mHalfEdge[mHalfEdge[ccwedge]->getDual()]->getPoint(), false, false );//points from the virtual point to the last visible point counterclockwise
//adjust the other pointers
mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[ccwedge]->getNext()]->getNext()]->getDual()]->setDual( edge6 );
mHalfEdge[mHalfEdge[mHalfEdge[ccwedge]->getNext()]->getNext()]->setDual( edge4 );
mHalfEdge[edge4]->setNext( edge5 );
mHalfEdge[edge5]->setNext( edge6 );
mHalfEdge[edge3]->setDual( edge5 );
//now test the HalfEdge at the former convex hull for swappint
unsigned int index = ccwedge;
unsigned int toswap;
while ( true )
{
toswap = index;
index = mHalfEdge[mHalfEdge[mHalfEdge[index]->getNext()]->getDual()]->getNext();
checkSwap( toswap );
if ( toswap == cwedge )
{
break;
}
}
}
else if ( number >= 0 )
{
int nextnumber = mHalfEdge[number]->getNext();
int nextnextnumber = mHalfEdge[mHalfEdge[number]->getNext()]->getNext();
//insert 6 new HalfEdges for the connections to the vertices of the triangle
unsigned int edge1 = insertEdge( -10, nextnumber, mHalfEdge[number]->getPoint(), false, false );
unsigned int edge2 = insertEdge(( int )edge1, -10, mPointVector.count() - 1, false, false );
unsigned int edge3 = insertEdge( -10, nextnextnumber, mHalfEdge[nextnumber]->getPoint(), false, false );
unsigned int edge4 = insertEdge(( int )edge3, ( int )edge1, mPointVector.count() - 1, false, false );
unsigned int edge5 = insertEdge( -10, number, mHalfEdge[nextnextnumber]->getPoint(), false, false );
unsigned int edge6 = insertEdge(( int )edge5, ( int )edge3, mPointVector.count() - 1, false, false );
mHalfEdge.at( edge1 )->setDual(( int )edge2 );
mHalfEdge.at( edge2 )->setNext(( int )edge5 );
mHalfEdge.at( edge3 )->setDual(( int )edge4 );
mHalfEdge.at( edge5 )->setDual(( int )edge6 );
mHalfEdge.at( number )->setNext(( int )edge2 );
mHalfEdge.at( nextnumber )->setNext(( int )edge4 );
mHalfEdge.at( nextnextnumber )->setNext(( int )edge6 );
//check, if there are swaps necessary
checkSwap( number );
checkSwap( nextnumber );
checkSwap( nextnextnumber );
}
else if ( number == -20 )
{
int edgea = mEdgeWithPoint;
int edgeb = mHalfEdge[mEdgeWithPoint]->getDual();
int edgec = mHalfEdge[edgea]->getNext();
int edged = mHalfEdge[edgec]->getNext();
int edgee = mHalfEdge[edgeb]->getNext();
int edgef = mHalfEdge[edgee]->getNext();
//insert the six new edges
int nedge1 = insertEdge( -10, mHalfEdge[edgea]->getNext(), mHalfEdge[edgea]->getPoint(), false, false );
int nedge2 = insertEdge( nedge1, -10, mPointVector.count() - 1, false, false );
int nedge3 = insertEdge( -10, edged, mHalfEdge[edgec]->getPoint(), false, false );
int nedge4 = insertEdge( nedge3, nedge1, mPointVector.count() - 1, false, false );
int nedge5 = insertEdge( -10, edgef, mHalfEdge[edgee]->getPoint(), false, false );
int nedge6 = insertEdge( nedge5, edgeb, mPointVector.count() - 1, false, false );
//adjust the triangular structure
mHalfEdge[nedge1]->setDual( nedge2 );
mHalfEdge[nedge2]->setNext( nedge5 );
mHalfEdge[nedge3]->setDual( nedge4 );
mHalfEdge[nedge5]->setDual( nedge6 );
mHalfEdge[edgea]->setPoint( mPointVector.count() - 1 );
mHalfEdge[edgea]->setNext( nedge3 );
mHalfEdge[edgec]->setNext( nedge4 );
mHalfEdge[edgee]->setNext( nedge6 );
mHalfEdge[edgef]->setNext( nedge2 );
//swap edges if necessary
checkSwap( edgec );
checkSwap( edged );
checkSwap( edgee );
checkSwap( edgef );
}
else if ( number == -100 || number == -5 )//this means unknown problems or a numerical error occured in 'baseEdgeOfTriangle'
{
// QgsDebugMsg("point has not been inserted because of unknown problems");
Point3D* p = mPointVector[mPointVector.count()-1];
mPointVector.remove( mPointVector.count() - 1 );
delete p;
return -100;
}
else if ( number == -25 )//this means that the point has already been inserted in the triangulation
{
//Take the higher z-Value in case of two equal points
Point3D* newPoint = mPointVector[mPointVector.count()-1];
Point3D* existingPoint = mPointVector[mTwiceInsPoint];
existingPoint->setZ( qMax( newPoint->getZ(), existingPoint->getZ() ) );
mPointVector.remove( mPointVector.count() - 1 );
delete newPoint;
return mTwiceInsPoint;
}
}
return ( mPointVector.count() - 1 );
}
else
{
QgsDebugMsg( "warning: null pointer" );
return -100;
}
}
int <API key>::baseEdgeOfPoint( int point )
{
unsigned int actedge = mEdgeInside;//starting edge
if ( mPointVector.count() < 4 || point == -1 )//at the beginning, mEdgeInside is not defined yet
{
//first find pointingedge(an edge pointing to p1)
for ( int i = 0; i < mHalfEdge.count(); i++ )
{
if ( mHalfEdge[i]->getPoint() == point )//we found it
{
return i;
}
}
}
int control = 0;
while ( true )//otherwise, start the search
{
control += 1;
if ( control > 1000000 )
{
// QgsDebugMsg( "warning, endless loop" );
//use the secure and slow method
for ( int i = 0; i < mHalfEdge.count(); i++ )
{
if ( mHalfEdge[i]->getPoint() == point && mHalfEdge[mHalfEdge[i]->getNext()]->getPoint() != -1 )//we found it
{
return i;
}
}
}
int frompoint = mHalfEdge[mHalfEdge[actedge]->getDual()]->getPoint();
int topoint = mHalfEdge[actedge]->getPoint();
if ( frompoint == -1 || topoint == -1 )//this would cause a crash. Therefore we use the slow method in this case
{
for ( int i = 0; i < mHalfEdge.count(); i++ )
{
if ( mHalfEdge[i]->getPoint() == point && mHalfEdge[mHalfEdge[i]->getNext()]->getPoint() != -1 )//we found it
{
mEdgeInside = i;
return i;
}
}
}
double leftofnumber = MathUtils::leftOf( mPointVector[point], mPointVector[mHalfEdge[mHalfEdge[actedge]->getDual()]->getPoint()], mPointVector[mHalfEdge[actedge]->getPoint()] );
if ( mHalfEdge[actedge]->getPoint() == point && mHalfEdge[mHalfEdge[actedge]->getNext()]->getPoint() != -1 )//we found the edge
{
mEdgeInside = actedge;
return actedge;
}
else if ( leftofnumber <= 0 )
{
actedge = mHalfEdge[actedge]->getNext();
}
else if ( leftofnumber > 0 )
{
actedge = mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[actedge]->getDual()]->getNext()]->getNext()]->getDual();
}
}
}
int <API key>::baseEdgeOfTriangle( Point3D* point )
{
unsigned int actedge = mEdgeInside;//start with an edge which does not point to the virtual point (usualy number 3)
int counter = 0;//number of consecutive successful left-of-tests
int nulls = 0;//number of left-of-tests, which returned 0. 1 means, that the point is on a line, 2 means that it is on an existing point
int numinstabs = 0;//number of suspect left-of-tests due to 'leftOfTresh'
int runs = 0;//counter for the number of iterations in the loop to prevent an endless loop
int firstendp = 0, secendp = 0, thendp = 0, fouendp = 0; //four numbers of endpoints in cases when two left-of-test are 0
while ( true )
{
if ( runs > nBaseOfRuns )//prevents endless loops
{
// QgsDebugMsg("warning, probable endless loop detected");
return -100;
}
double leftofvalue = MathUtils::leftOf( point, mPointVector[mHalfEdge[mHalfEdge[actedge]->getDual()]->getPoint()], mPointVector[mHalfEdge[actedge]->getPoint()] );
if ( leftofvalue < ( -leftOfTresh ) )//point is on the left side
{
counter += 1;
if ( counter == 3 )//three successful passes means that we have found the triangle
{
break;
}
}
else if ( leftofvalue == 0 )//point is exactly in the line of the edge
{
if ( nulls == 0 )
{
//store the numbers of the two endpoints of the line
firstendp = mHalfEdge[mHalfEdge[actedge]->getDual()]->getPoint();
secendp = mHalfEdge[actedge]->getPoint();
}
else if ( nulls == 1 )
{
//store the numbers of the two endpoints of the line
thendp = mHalfEdge[mHalfEdge[actedge]->getDual()]->getPoint();
fouendp = mHalfEdge[actedge]->getPoint();
}
counter += 1;
mEdgeWithPoint = actedge;
nulls += 1;
if ( counter == 3 )//three successful passes means that we have found the triangle
{
break;
}
}
else if ( leftofvalue < leftOfTresh )//numerical problems
{
counter += 1;
numinstabs += 1;
if ( counter == 3 )//three successful passes means that we have found the triangle
{
break;
}
}
else//point is on the right side
{
actedge = mHalfEdge[actedge]->getDual();
counter = 1;
nulls = 0;
numinstabs = 0;
}
actedge = mHalfEdge[actedge]->getNext();
if ( mHalfEdge[actedge]->getPoint() == -1 )//the half edge points to the virtual point
{
if ( nulls == 1 )//point is exactly on the convex hull
{
return -20;
}
mEdgeOutside = ( unsigned int )mHalfEdge[mHalfEdge[actedge]->getNext()]->getNext();
mEdgeInside = mHalfEdge[mHalfEdge[mEdgeOutside]->getDual()]->getNext();
return -10;//the point is outside the convex hull
}
runs++;
}
if ( numinstabs > 0 )//we hit an existing point or a numerical instability occured
{
// QgsDebugMsg("numerical instability occured");
mUnstableEdge = actedge;
return -5;
}
if ( nulls == 2 )
{
//find out the number of the point, which has already been inserted
if ( firstendp == thendp || firstendp == fouendp )
{
//firstendp is the number of the point which has been inserted twice
mTwiceInsPoint = firstendp;
// QgsDebugMsg(QString("point nr %1 already inserted").arg(firstendp));
}
else if ( secendp == thendp || secendp == fouendp )
{
//secendp is the number of the point which has been inserted twice
mTwiceInsPoint = secendp;
// QgsDebugMsg(QString("point nr %1 already inserted").arg(secendp));
}
return -25;//return the code for a point that is already contained in the triangulation
}
if ( nulls == 1 )//point is on an existing edge
{
return -20;
}
mEdgeInside = actedge;
int nr1, nr2, nr3;
nr1 = mHalfEdge[actedge]->getPoint();
nr2 = mHalfEdge[mHalfEdge[actedge]->getNext()]->getPoint();
nr3 = mHalfEdge[mHalfEdge[mHalfEdge[actedge]->getNext()]->getNext()]->getPoint();
double x1 = mPointVector[nr1]->getX();
double y1 = mPointVector[nr1]->getY();
double x2 = mPointVector[nr2]->getX();
double y2 = mPointVector[nr2]->getY();
double x3 = mPointVector[nr3]->getX();
double y3 = mPointVector[nr3]->getY();
//now make sure that always the same edge is returned
if ( x1 < x2 && x1 < x3 )//return the edge which points to the point with the lowest x-coordinate
{
return actedge;
}
else if ( x2 < x1 && x2 < x3 )
{
return mHalfEdge[actedge]->getNext();
}
else if ( x3 < x1 && x3 < x2 )
{
return mHalfEdge[mHalfEdge[actedge]->getNext()]->getNext();
}
//in case two x-coordinates are the same, the edge pointing to the point with the lower y-coordinate is returned
else if ( x1 == x2 )
{
if ( y1 < y2 )
{
return actedge;
}
else if ( y2 < y1 )
{
return mHalfEdge[actedge]->getNext();
}
}
else if ( x2 == x3 )
{
if ( y2 < y3 )
{
return mHalfEdge[actedge]->getNext();
}
else if ( y3 < y2 )
{
return mHalfEdge[mHalfEdge[actedge]->getNext()]->getNext();
}
}
else if ( x1 == x3 )
{
if ( y1 < y3 )
{
return actedge;
}
else if ( y3 < y1 )
{
return mHalfEdge[mHalfEdge[actedge]->getNext()]->getNext();
}
}
return -100;//this means a bug happened
}
bool <API key>::calcNormal( double x, double y, Vector3D* result )
{
if ( result && <API key> )
{
if ( !<API key>->calcNormVec( x, y, result ) )
{return false;}
return true;
}
else
{
QgsDebugMsg( "warning, null pointer" );
return false;
}
}
bool <API key>::calcPoint( double x, double y, Point3D* result )
{
if ( result && <API key> )
{
if ( !<API key>->calcPoint( x, y, result ) )
{return false;}
return true;
}
else
{
QgsDebugMsg( "warning, null pointer" );
return false;
}
}
bool <API key>::checkSwap( unsigned int edge )
{
if ( swapPossible( edge ) )
{
Point3D* pta = mPointVector[mHalfEdge[edge]->getPoint()];
Point3D* ptb = mPointVector[mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint()];
Point3D* ptc = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[edge]->getNext()]->getNext()]->getPoint()];
Point3D* ptd = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getPoint()];
if ( MathUtils::inCircle( ptd, pta, ptb, ptc ) )//empty circle criterion violated
{
doSwap( edge );//swap the edge (recursiv)
return true;
}
}
return false;
}
void <API key>::doOnlySwap( unsigned int edge )
{
unsigned int edge1 = edge;
unsigned int edge2 = mHalfEdge[edge]->getDual();
unsigned int edge3 = mHalfEdge[edge]->getNext();
unsigned int edge4 = mHalfEdge[mHalfEdge[edge]->getNext()]->getNext();
unsigned int edge5 = mHalfEdge[mHalfEdge[edge]->getDual()]->getNext();
unsigned int edge6 = mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getNext();
mHalfEdge[edge1]->setNext( edge4 );//set the necessary nexts
mHalfEdge[edge2]->setNext( edge6 );
mHalfEdge[edge3]->setNext( edge2 );
mHalfEdge[edge4]->setNext( edge5 );
mHalfEdge[edge5]->setNext( edge1 );
mHalfEdge[edge6]->setNext( edge3 );
mHalfEdge[edge1]->setPoint( mHalfEdge[edge3]->getPoint() );//change the points to which edge1 and edge2 point
mHalfEdge[edge2]->setPoint( mHalfEdge[edge5]->getPoint() );
}
void <API key>::doSwap( unsigned int edge )
{
unsigned int edge1 = edge;
unsigned int edge2 = mHalfEdge[edge]->getDual();
unsigned int edge3 = mHalfEdge[edge]->getNext();
unsigned int edge4 = mHalfEdge[mHalfEdge[edge]->getNext()]->getNext();
unsigned int edge5 = mHalfEdge[mHalfEdge[edge]->getDual()]->getNext();
unsigned int edge6 = mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getNext();
mHalfEdge[edge1]->setNext( edge4 );//set the necessary nexts
mHalfEdge[edge2]->setNext( edge6 );
mHalfEdge[edge3]->setNext( edge2 );
mHalfEdge[edge4]->setNext( edge5 );
mHalfEdge[edge5]->setNext( edge1 );
mHalfEdge[edge6]->setNext( edge3 );
mHalfEdge[edge1]->setPoint( mHalfEdge[edge3]->getPoint() );//change the points to which edge1 and edge2 point
mHalfEdge[edge2]->setPoint( mHalfEdge[edge5]->getPoint() );
checkSwap( edge3 );
checkSwap( edge6 );
checkSwap( edge4 );
checkSwap( edge5 );
}
#if 0
void <API key>::draw( QPainter* p, double xlowleft, double ylowleft, double xupright, double yupright, double width, double height ) const
{
//if mPointVector is empty, there is nothing to do
if ( mPointVector.count() == 0 )
{
return;
}
p->setPen( mEdgeColor );
bool* control = new bool[mHalfEdge.count()];//controllarray that no edge is painted twice
bool* control2 = new bool[mHalfEdge.count()];//controllarray for the flat triangles
for ( unsigned int i = 0; i <= mHalfEdge.count() - 1; i++ )
{
control[i] = false;
control2[i] = false;
}
if ((( xupright - xlowleft ) / width ) > (( yupright - ylowleft ) / height ) )
{
double lowerborder = -( height * ( xupright - xlowleft ) / width - yupright );//real world coordinates of the lower widget border. This is useful to know because of the HalfEdge bounding box test
for ( unsigned int i = 0; i < mHalfEdge.count() - 1; i++ )
{
if ( mHalfEdge[i]->getPoint() == -1 || mHalfEdge[mHalfEdge[i]->getDual()]->getPoint() == -1 )
{continue;}
//check, if the edge belongs to a flat triangle, remove this later
if ( !control2[i] )
{
double p1, p2, p3;
if ( mHalfEdge[i]->getPoint() != -1 && mHalfEdge[mHalfEdge[i]->getNext()]->getPoint() != -1 && mHalfEdge[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()]->getPoint() != -1 )
{
p1 = mPointVector[mHalfEdge[i]->getPoint()]->getZ();
p2 = mPointVector[mHalfEdge[mHalfEdge[i]->getNext()]->getPoint()]->getZ();
p3 = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()]->getPoint()]->getZ();
if ( p1 == p2 && p2 == p3 && halfEdgeBBoxTest( i, xlowleft, lowerborder, xupright, yupright ) && halfEdgeBBoxTest( mHalfEdge[i]->getNext(), xlowleft, lowerborder, xupright, yupright ) && halfEdgeBBoxTest( mHalfEdge[mHalfEdge[i]->getNext()]->getNext(), xlowleft, lowerborder, xupright, yupright ) )//draw the triangle
{
QPointArray pa( 3 );
pa.setPoint( 0, ( mPointVector[mHalfEdge[i]->getPoint()]->getX() - xlowleft ) / ( xupright - xlowleft )*width, ( yupright - mPointVector[mHalfEdge[i]->getPoint()]->getY() ) / ( xupright - xlowleft )*width );
pa.setPoint( 1, ( mPointVector[mHalfEdge[mHalfEdge[i]->getNext()]->getPoint()]->getX() - xlowleft ) / ( xupright - xlowleft )*width, ( yupright - mPointVector[mHalfEdge[mHalfEdge[i]->getNext()]->getPoint()]->getY() ) / ( xupright - xlowleft )*width );
pa.setPoint( 2, ( mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()]->getPoint()]->getX() - xlowleft ) / ( xupright - xlowleft )*width, ( yupright - mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()]->getPoint()]->getY() ) / ( xupright - xlowleft )*width );
QColor c( 255, 0, 0 );
p->setBrush( c );
p->drawPolygon( pa );
}
}
control2[i] = true;
control2[mHalfEdge[i]->getNext()] = true;
control2[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()] = true;
}//end of the section, which has to be removed later
if ( control[i] )//check, if edge has already been drawn
{continue;}
//draw the edge;
if ( halfEdgeBBoxTest( i, xlowleft, lowerborder, xupright, yupright ) )//only draw the halfedge if its bounding box intersects the painted area
{
if ( mHalfEdge[i]->getBreak() )//change the color it the edge is a breakline
{
p->setPen( mBreakEdgeColor );
}
else if ( mHalfEdge[i]->getForced() )//change the color if the edge is forced
{
p->setPen( mForcedEdgeColor );
}
p->drawLine(( mPointVector[mHalfEdge[i]->getPoint()]->getX() - xlowleft ) / ( xupright - xlowleft )*width, ( yupright - mPointVector[mHalfEdge[i]->getPoint()]->getY() ) / ( xupright - xlowleft )*width, ( mPointVector[mHalfEdge[mHalfEdge[i]->getDual()]->getPoint()]->getX() - xlowleft ) / ( xupright - xlowleft )*width, ( yupright - mPointVector[mHalfEdge[mHalfEdge[i]->getDual()]->getPoint()]->getY() ) / ( xupright - xlowleft )*width );
if ( mHalfEdge[i]->getForced() )
{
p->setPen( mEdgeColor );
}
}
control[i] = true;
control[mHalfEdge[i]->getDual()] = true;
}
}
else
{
double rightborder = width * ( yupright - ylowleft ) / height + xlowleft;//real world coordinates of the right widget border. This is useful to know because of the HalfEdge bounding box test
for ( unsigned int i = 0; i < mHalfEdge.count() - 1; i++ )
{
if ( mHalfEdge[i]->getPoint() == -1 || mHalfEdge[mHalfEdge[i]->getDual()]->getPoint() == -1 )
{continue;}
//check, if the edge belongs to a flat triangle, remove this section later
if ( !control2[i] )
{
double p1, p2, p3;
if ( mHalfEdge[i]->getPoint() != -1 && mHalfEdge[mHalfEdge[i]->getNext()]->getPoint() != -1 && mHalfEdge[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()]->getPoint() != -1 )
{
p1 = mPointVector[mHalfEdge[i]->getPoint()]->getZ();
p2 = mPointVector[mHalfEdge[mHalfEdge[i]->getNext()]->getPoint()]->getZ();
p3 = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()]->getPoint()]->getZ();
if ( p1 == p2 && p2 == p3 && halfEdgeBBoxTest( i, xlowleft, ylowleft, rightborder, yupright ) && halfEdgeBBoxTest( mHalfEdge[i]->getNext(), xlowleft, ylowleft, rightborder, yupright ) && halfEdgeBBoxTest( mHalfEdge[mHalfEdge[i]->getNext()]->getNext(), xlowleft, ylowleft, rightborder, yupright ) )//draw the triangle
{
QPointArray pa( 3 );
pa.setPoint( 0, ( mPointVector[mHalfEdge[i]->getPoint()]->getX() - xlowleft ) / ( yupright - ylowleft )*height, ( yupright - mPointVector[mHalfEdge[i]->getPoint()]->getY() ) / ( yupright - ylowleft )*height );
pa.setPoint( 1, ( mPointVector[mHalfEdge[mHalfEdge[i]->getNext()]->getPoint()]->getX() - xlowleft ) / ( yupright - ylowleft )*height, ( yupright - mPointVector[mHalfEdge[mHalfEdge[i]->getNext()]->getPoint()]->getY() ) / ( yupright - ylowleft )*height );
pa.setPoint( 2, ( mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()]->getPoint()]->getX() - xlowleft ) / ( yupright - ylowleft )*height, ( yupright - mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()]->getPoint()]->getY() ) / ( yupright - ylowleft )*height );
QColor c( 255, 0, 0 );
p->setBrush( c );
p->drawPolygon( pa );
}
}
control2[i] = true;
control2[mHalfEdge[i]->getNext()] = true;
control2[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()] = true;
}//end of the section, which has to be removed later
if ( control[i] )//check, if edge has already been drawn
{continue;}
//draw the edge
if ( halfEdgeBBoxTest( i, xlowleft, ylowleft, rightborder, yupright ) )//only draw the edge if its bounding box intersects with the painted area
{
if ( mHalfEdge[i]->getBreak() )//change the color if the edge is a breakline
{
p->setPen( mBreakEdgeColor );
}
else if ( mHalfEdge[i]->getForced() )//change the color if the edge is forced
{
p->setPen( mForcedEdgeColor );
}
p->drawLine(( mPointVector[mHalfEdge[i]->getPoint()]->getX() - xlowleft ) / ( yupright - ylowleft )*height, ( yupright - mPointVector[mHalfEdge[i]->getPoint()]->getY() ) / ( yupright - ylowleft )*height, ( mPointVector[mHalfEdge[mHalfEdge[i]->getDual()]->getPoint()]->getX() - xlowleft ) / ( yupright - ylowleft )*height, ( yupright - mPointVector[mHalfEdge[mHalfEdge[i]->getDual()]->getPoint()]->getY() ) / ( yupright - ylowleft )*height );
if ( mHalfEdge[i]->getForced() )
{
p->setPen( mEdgeColor );
}
}
control[i] = true;
control[mHalfEdge[i]->getDual()] = true;
}
}
delete[] control;
delete[] control2;
}
#endif
int <API key>::getOppositePoint( int p1, int p2 )
{
//first find a half edge which points to p2
int firstedge = baseEdgeOfPoint( p2 );
//then find the edge which comes from p1 or print an error message if there isn't any
int theedge = -10;
int nextnextedge = firstedge;
int edge, nextedge;
do
{
edge = mHalfEdge[nextnextedge]->getDual();
if ( mHalfEdge[edge]->getPoint() == p1 )
{
theedge = nextnextedge;
break;
}//we found the edge
nextedge = mHalfEdge[edge]->getNext();
nextnextedge = mHalfEdge[nextedge]->getNext();
}
while ( nextnextedge != firstedge );
if ( theedge == -10 )//there is no edge between p1 and p2
{
QgsDebugMsg( QString( "warning, error: the points are: %1 and %2" ).arg( p1 ).arg( p2 ) );
return -10;
}
//finally find the opposite point
return mHalfEdge[mHalfEdge[mHalfEdge[theedge]->getDual()]->getNext()]->getPoint();
}
QList<int>* <API key>::<API key>( int pointno )
{
int firstedge = baseEdgeOfPoint( pointno );
if ( firstedge == -1 )//an error occured
{
return 0;
}
QList<int>* vlist = new QList<int>();//create the value list on the heap
int actedge = firstedge;
int edge, nextedge, nextnextedge;
do
{
edge = mHalfEdge[actedge]->getDual();
vlist->append( mHalfEdge[edge]->getPoint() );//add the number of the endpoint of the first edge to the value list
nextedge = mHalfEdge[edge]->getNext();
vlist->append( mHalfEdge[nextedge]->getPoint() );//add the number of the endpoint of the second edge to the value list
nextnextedge = mHalfEdge[nextedge]->getNext();
vlist->append( mHalfEdge[nextnextedge]->getPoint() );//add the number of endpoint of the third edge to the value list
if ( mHalfEdge[nextnextedge]->getBreak() )//add, whether the third edge is a breakline or not
{
vlist->append( -10 );
}
else
{
vlist->append( -20 );
}
actedge = nextnextedge;
}
while ( nextnextedge != firstedge );
return vlist;
}
bool <API key>::getTriangle( double x, double y, Point3D* p1, int* n1, Point3D* p2, int* n2, Point3D* p3, int* n3 )
{
if ( mPointVector.size() < 3 )
{
return false;
}
if ( p1 && p2 && p3 )
{
Point3D point( x, y, 0 );
int edge = baseEdgeOfTriangle( &point );
if ( edge == -10 )//the point is outside the convex hull
{
QgsDebugMsg( "edge outside the convex hull" );
return false;
}
else if ( edge >= 0 )//the point is inside the convex hull
{
int ptnr1 = mHalfEdge[edge]->getPoint();
int ptnr2 = mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint();
int ptnr3 = mHalfEdge[mHalfEdge[mHalfEdge[edge]->getNext()]->getNext()]->getPoint();
p1->setX( mPointVector[ptnr1]->getX() );
p1->setY( mPointVector[ptnr1]->getY() );
p1->setZ( mPointVector[ptnr1]->getZ() );
p2->setX( mPointVector[ptnr2]->getX() );
p2->setY( mPointVector[ptnr2]->getY() );
p2->setZ( mPointVector[ptnr2]->getZ() );
p3->setX( mPointVector[ptnr3]->getX() );
p3->setY( mPointVector[ptnr3]->getY() );
p3->setZ( mPointVector[ptnr3]->getZ() );
( *n1 ) = ptnr1;
( *n2 ) = ptnr2;
( *n3 ) = ptnr3;
return true;
}
else if ( edge == -20 )//the point is exactly on an edge
{
int ptnr1 = mHalfEdge[mEdgeWithPoint]->getPoint();
int ptnr2 = mHalfEdge[mHalfEdge[mEdgeWithPoint]->getNext()]->getPoint();
int ptnr3 = mHalfEdge[mHalfEdge[mHalfEdge[mEdgeWithPoint]->getNext()]->getNext()]->getPoint();
if ( ptnr1 == -1 || ptnr2 == -1 || ptnr3 == -1 )
{
return false;
}
p1->setX( mPointVector[ptnr1]->getX() );
p1->setY( mPointVector[ptnr1]->getY() );
p1->setZ( mPointVector[ptnr1]->getZ() );
p2->setX( mPointVector[ptnr2]->getX() );
p2->setY( mPointVector[ptnr2]->getY() );
p2->setZ( mPointVector[ptnr2]->getZ() );
p3->setX( mPointVector[ptnr3]->getX() );
p3->setY( mPointVector[ptnr3]->getY() );
p3->setZ( mPointVector[ptnr3]->getZ() );
( *n1 ) = ptnr1;
( *n2 ) = ptnr2;
( *n3 ) = ptnr3;
return true;
}
else if ( edge == -25 )//x and y are the coordinates of an existing point
{
int edge1 = baseEdgeOfPoint( mTwiceInsPoint );
int edge2 = mHalfEdge[edge1]->getNext();
int edge3 = mHalfEdge[edge2]->getNext();
int ptnr1 = mHalfEdge[edge1]->getPoint();
int ptnr2 = mHalfEdge[edge2]->getPoint();
int ptnr3 = mHalfEdge[edge3]->getPoint();
p1->setX( mPointVector[ptnr1]->getX() );
p1->setY( mPointVector[ptnr1]->getY() );
p1->setZ( mPointVector[ptnr1]->getZ() );
p2->setX( mPointVector[ptnr2]->getX() );
p2->setY( mPointVector[ptnr2]->getY() );
p2->setZ( mPointVector[ptnr2]->getZ() );
p3->setX( mPointVector[ptnr3]->getX() );
p3->setY( mPointVector[ptnr3]->getY() );
p3->setZ( mPointVector[ptnr3]->getZ() );
( *n1 ) = ptnr1;
( *n2 ) = ptnr2;
( *n3 ) = ptnr3;
return true;
}
else if ( edge == -5 )//numerical problems in 'baseEdgeOfTriangle'
{
int ptnr1 = mHalfEdge[mUnstableEdge]->getPoint();
int ptnr2 = mHalfEdge[mHalfEdge[mUnstableEdge]->getNext()]->getPoint();
int ptnr3 = mHalfEdge[mHalfEdge[mHalfEdge[mUnstableEdge]->getNext()]->getNext()]->getPoint();
if ( ptnr1 == -1 || ptnr2 == -1 || ptnr3 == -1 )
{
return false;
}
p1->setX( mPointVector[ptnr1]->getX() );
p1->setY( mPointVector[ptnr1]->getY() );
p1->setZ( mPointVector[ptnr1]->getZ() );
p2->setX( mPointVector[ptnr2]->getX() );
p2->setY( mPointVector[ptnr2]->getY() );
p2->setZ( mPointVector[ptnr2]->getZ() );
p3->setX( mPointVector[ptnr3]->getX() );
p3->setY( mPointVector[ptnr3]->getY() );
p3->setZ( mPointVector[ptnr3]->getZ() );
( *n1 ) = ptnr1;
( *n2 ) = ptnr2;
( *n3 ) = ptnr3;
return true;
}
else//problems
{
QgsDebugMsg( QString( "problem: the edge is: %1" ).arg( edge ) );
return false;
}
}
else
{
QgsDebugMsg( "warning, null pointer" );
return false;
}
}
bool <API key>::getTriangle( double x, double y, Point3D* p1, Point3D* p2, Point3D* p3 )
{
if ( mPointVector.size() < 3 )
{
return false;
}
if ( p1 && p2 && p3 )
{
Point3D point( x, y, 0 );
int edge = baseEdgeOfTriangle( &point );
if ( edge == -10 )//the point is outside the convex hull
{
QgsDebugMsg( "edge outside the convex hull" );
return false;
}
else if ( edge >= 0 )//the point is inside the convex hull
{
int ptnr1 = mHalfEdge[edge]->getPoint();
int ptnr2 = mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint();
int ptnr3 = mHalfEdge[mHalfEdge[mHalfEdge[edge]->getNext()]->getNext()]->getPoint();
p1->setX( mPointVector[ptnr1]->getX() );
p1->setY( mPointVector[ptnr1]->getY() );
p1->setZ( mPointVector[ptnr1]->getZ() );
p2->setX( mPointVector[ptnr2]->getX() );
p2->setY( mPointVector[ptnr2]->getY() );
p2->setZ( mPointVector[ptnr2]->getZ() );
p3->setX( mPointVector[ptnr3]->getX() );
p3->setY( mPointVector[ptnr3]->getY() );
p3->setZ( mPointVector[ptnr3]->getZ() );
return true;
}
else if ( edge == -20 )//the point is exactly on an edge
{
int ptnr1 = mHalfEdge[mEdgeWithPoint]->getPoint();
int ptnr2 = mHalfEdge[mHalfEdge[mEdgeWithPoint]->getNext()]->getPoint();
int ptnr3 = mHalfEdge[mHalfEdge[mHalfEdge[mEdgeWithPoint]->getNext()]->getNext()]->getPoint();
if ( ptnr1 == -1 || ptnr2 == -1 || ptnr3 == -1 )
{
return false;
}
p1->setX( mPointVector[ptnr1]->getX() );
p1->setY( mPointVector[ptnr1]->getY() );
p1->setZ( mPointVector[ptnr1]->getZ() );
p2->setX( mPointVector[ptnr2]->getX() );
p2->setY( mPointVector[ptnr2]->getY() );
p2->setZ( mPointVector[ptnr2]->getZ() );
p3->setX( mPointVector[ptnr3]->getX() );
p3->setY( mPointVector[ptnr3]->getY() );
p3->setZ( mPointVector[ptnr3]->getZ() );
return true;
}
else if ( edge == -25 )//x and y are the coordinates of an existing point
{
int edge1 = baseEdgeOfPoint( mTwiceInsPoint );
int edge2 = mHalfEdge[edge1]->getNext();
int edge3 = mHalfEdge[edge2]->getNext();
int ptnr1 = mHalfEdge[edge1]->getPoint();
int ptnr2 = mHalfEdge[edge2]->getPoint();
int ptnr3 = mHalfEdge[edge3]->getPoint();
if ( ptnr1 == -1 || ptnr2 == -1 || ptnr3 == -1 )
{
return false;
}
p1->setX( mPointVector[ptnr1]->getX() );
p1->setY( mPointVector[ptnr1]->getY() );
p1->setZ( mPointVector[ptnr1]->getZ() );
p2->setX( mPointVector[ptnr2]->getX() );
p2->setY( mPointVector[ptnr2]->getY() );
p2->setZ( mPointVector[ptnr2]->getZ() );
p3->setX( mPointVector[ptnr3]->getX() );
p3->setY( mPointVector[ptnr3]->getY() );
p3->setZ( mPointVector[ptnr3]->getZ() );
return true;
}
else if ( edge == -5 )//numerical problems in 'baseEdgeOfTriangle'
{
int ptnr1 = mHalfEdge[mUnstableEdge]->getPoint();
int ptnr2 = mHalfEdge[mHalfEdge[mUnstableEdge]->getNext()]->getPoint();
int ptnr3 = mHalfEdge[mHalfEdge[mHalfEdge[mUnstableEdge]->getNext()]->getNext()]->getPoint();
if ( ptnr1 == -1 || ptnr2 == -1 || ptnr3 == -1 )
{
return false;
}
p1->setX( mPointVector[ptnr1]->getX() );
p1->setY( mPointVector[ptnr1]->getY() );
p1->setZ( mPointVector[ptnr1]->getZ() );
p2->setX( mPointVector[ptnr2]->getX() );
p2->setY( mPointVector[ptnr2]->getY() );
p2->setZ( mPointVector[ptnr2]->getZ() );
p3->setX( mPointVector[ptnr3]->getX() );
p3->setY( mPointVector[ptnr3]->getY() );
p3->setZ( mPointVector[ptnr3]->getZ() );
return true;
}
else//problems
{
QgsDebugMsg( QString( "problems: the edge is: %1" ).arg( edge ) );
return false;
}
}
else
{
QgsDebugMsg( "warning, null pointer" );
return false;
}
}
unsigned int <API key>::insertEdge( int dual, int next, int point, bool mbreak, bool forced )
{
HalfEdge* edge = new HalfEdge( dual, next, point, mbreak, forced );
mHalfEdge.append( edge );
return mHalfEdge.count() - 1;
}
int <API key>::insertForcedSegment( int p1, int p2, bool breakline )
{
if ( p1 == p2 )
{
return 0;
}
//list with (half of) the crossed edges
QList<int> crossedEdges;
//an edge pointing to p1
int pointingedge = 0;
pointingedge = baseEdgeOfPoint( p1 );
if ( pointingedge == -1 )
{
return -100;//return an error code
}
//go around p1 and find out, if the segment already exists and if not, which is the first cutted edge
int actedge = mHalfEdge[pointingedge]->getDual();
//number to prevent endless loops
int control = 0;
while ( true )//if it's an endless loop, something went wrong
{
control += 1;
if ( control > 17000 )
{
QgsDebugMsg( "warning, endless loop" );
return -100;//return an error code
}
if ( mHalfEdge[actedge]->getPoint() == -1 )//actedge points to the virtual point
{
actedge = mHalfEdge[mHalfEdge[mHalfEdge[actedge]->getNext()]->getNext()]->getDual();
continue;
}
//test, if actedge is already the forced edge
if ( mHalfEdge[actedge]->getPoint() == p2 )
{
mHalfEdge[actedge]->setForced( true );
mHalfEdge[actedge]->setBreak( breakline );
mHalfEdge[mHalfEdge[actedge]->getDual()]->setForced( true );
mHalfEdge[mHalfEdge[actedge]->getDual()]->setBreak( breakline );
return actedge;
}
//test, if the forced segment is a multiple of actedge and if the direction is the same
else if ( /*lines are parallel*/( mPointVector[p2]->getY() - mPointVector[p1]->getY() ) / ( mPointVector[mHalfEdge[actedge]->getPoint()]->getY() - mPointVector[p1]->getY() ) == ( mPointVector[p2]->getX() - mPointVector[p1]->getX() ) / ( mPointVector[mHalfEdge[actedge]->getPoint()]->getX() - mPointVector[p1]->getX() ) && (( mPointVector[p2]->getY() - mPointVector[p1]->getY() ) >= 0 ) == (( mPointVector[mHalfEdge[actedge]->getPoint()]->getY() - mPointVector[p1]->getY() ) > 0 ) && (( mPointVector[p2]->getX() - mPointVector[p1]->getX() ) >= 0 ) == (( mPointVector[mHalfEdge[actedge]->getPoint()]->getX() - mPointVector[p1]->getX() ) > 0 ) )
{
//mark actedge and Dual(actedge) as forced, reset p1 and start the method from the beginning
mHalfEdge[actedge]->setForced( true );
mHalfEdge[actedge]->setBreak( breakline );
mHalfEdge[mHalfEdge[actedge]->getDual()]->setForced( true );
mHalfEdge[mHalfEdge[actedge]->getDual()]->setBreak( breakline );
int a = insertForcedSegment( mHalfEdge[actedge]->getPoint(), p2, breakline );
return a;
}
//test, if the forced segment intersects Next(actedge)
if ( mHalfEdge[mHalfEdge[actedge]->getNext()]->getPoint() == -1 )//intersection with line to the virtual point makes no sense
{
actedge = mHalfEdge[mHalfEdge[mHalfEdge[actedge]->getNext()]->getNext()]->getDual();
continue;
}
else if ( MathUtils::lineIntersection( mPointVector[p1], mPointVector[p2], mPointVector[mHalfEdge[mHalfEdge[actedge]->getNext()]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[actedge]->getNext()]->getDual()]->getPoint()] ) )
{
if ( mHalfEdge[mHalfEdge[actedge]->getNext()]->getForced() && <API key> == Triangulation::<API key> )//if the crossed edge is a forced edge, we have to snap the forced line to the next node
{
Point3D crosspoint;
int p3, p4;
p3 = mHalfEdge[mHalfEdge[actedge]->getNext()]->getPoint();
p4 = mHalfEdge[mHalfEdge[mHalfEdge[actedge]->getNext()]->getDual()]->getPoint();
MathUtils::lineIntersection( mPointVector[p1], mPointVector[p2], mPointVector[p3], mPointVector[p4], &crosspoint );
double dista = sqrt(( crosspoint.getX() - mPointVector[p3]->getX() ) * ( crosspoint.getX() - mPointVector[p3]->getX() ) + ( crosspoint.getY() - mPointVector[p3]->getY() ) * ( crosspoint.getY() - mPointVector[p3]->getY() ) );
double distb = sqrt(( crosspoint.getX() - mPointVector[p4]->getX() ) * ( crosspoint.getX() - mPointVector[p4]->getX() ) + ( crosspoint.getY() - mPointVector[p4]->getY() ) * ( crosspoint.getY() - mPointVector[p4]->getY() ) );
if ( dista <= distb )
{
insertForcedSegment( p1, p3, breakline );
int e = insertForcedSegment( p3, p2, breakline );
return e;
}
else if ( distb <= dista )
{
insertForcedSegment( p1, p4, breakline );
int e = insertForcedSegment( p4, p2, breakline );
return e;
}
}
else if ( mHalfEdge[mHalfEdge[actedge]->getNext()]->getForced() && <API key> == Triangulation::INSERT_VERTICE )//if the crossed edge is a forced edge, we have to insert a new vertice on this edge
{
Point3D crosspoint;
int p3, p4;
p3 = mHalfEdge[mHalfEdge[actedge]->getNext()]->getPoint();
p4 = mHalfEdge[mHalfEdge[mHalfEdge[actedge]->getNext()]->getDual()]->getPoint();
MathUtils::lineIntersection( mPointVector[p1], mPointVector[p2], mPointVector[p3], mPointVector[p4], &crosspoint );
double distpart = sqrt(( crosspoint.getX() - mPointVector[p4]->getX() ) * ( crosspoint.getX() - mPointVector[p4]->getX() ) + ( crosspoint.getY() - mPointVector[p4]->getY() ) * ( crosspoint.getY() - mPointVector[p4]->getY() ) );
double disttot = sqrt(( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) * ( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) + ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) * ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) );
float frac = distpart / disttot;
if ( frac == 0 || frac == 1 )//just in case MathUtils::lineIntersection does not work as expected
{
if ( frac == 0 )
{
//mark actedge and Dual(actedge) as forced, reset p1 and start the method from the beginning
mHalfEdge[actedge]->setForced( true );
mHalfEdge[actedge]->setBreak( breakline );
mHalfEdge[mHalfEdge[actedge]->getDual()]->setForced( true );
mHalfEdge[mHalfEdge[actedge]->getDual()]->setBreak( breakline );
int a = insertForcedSegment( p4, p2, breakline );
return a;
}
else if ( frac == 1 )
{
//mark actedge and Dual(actedge) as forced, reset p1 and start the method from the beginning
mHalfEdge[actedge]->setForced( true );
mHalfEdge[actedge]->setBreak( breakline );
mHalfEdge[mHalfEdge[actedge]->getDual()]->setForced( true );
mHalfEdge[mHalfEdge[actedge]->getDual()]->setBreak( breakline );
if ( p3 != p2 )
{
int a = insertForcedSegment( p3, p2, breakline );
return a;
}
else
{
return actedge;
}
}
}
else
{
int newpoint = splitHalfEdge( mHalfEdge[actedge]->getNext(), frac );
insertForcedSegment( p1, newpoint, breakline );
int e = insertForcedSegment( newpoint, p2, breakline );
return e;
}
}
//add the first HalfEdge to the list of crossed edges
crossedEdges.append( mHalfEdge[actedge]->getNext() );
break;
}
actedge = mHalfEdge[mHalfEdge[mHalfEdge[actedge]->getNext()]->getNext()]->getDual();
}
//we found the first edge, terminated the method or called the method with other points. Lets search for all the other crossed edges
while ( true )//if its an endless loop, something went wrong.
{
if ( MathUtils::lineIntersection( mPointVector[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getPoint()], mPointVector[p1], mPointVector[p2] ) )
{
if ( mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getForced() && <API key> == Triangulation::<API key> )//if the crossed edge is a forced edge and <API key> is <API key>, we have to snap the forced line to the next node
{
Point3D crosspoint;
int p3, p4;
p3 = mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getPoint();
p4 = mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getPoint();
MathUtils::lineIntersection( mPointVector[p1], mPointVector[p2], mPointVector[p3], mPointVector[p4], &crosspoint );
double dista = sqrt(( crosspoint.getX() - mPointVector[p3]->getX() ) * ( crosspoint.getX() - mPointVector[p3]->getX() ) + ( crosspoint.getY() - mPointVector[p3]->getY() ) * ( crosspoint.getY() - mPointVector[p3]->getY() ) );
double distb = sqrt(( crosspoint.getX() - mPointVector[p4]->getX() ) * ( crosspoint.getX() - mPointVector[p4]->getX() ) + ( crosspoint.getY() - mPointVector[p4]->getY() ) * ( crosspoint.getY() - mPointVector[p4]->getY() ) );
if ( dista <= distb )
{
insertForcedSegment( p1, p3, breakline );
int e = insertForcedSegment( p3, p2, breakline );
return e;
}
else if ( distb <= dista )
{
insertForcedSegment( p1, p4, breakline );
int e = insertForcedSegment( p4, p2, breakline );
return e;
}
}
else if ( mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getForced() && <API key> == Triangulation::INSERT_VERTICE )//if the crossed edge is a forced edge, we have to insert a new vertice on this edge
{
Point3D crosspoint;
int p3, p4;
p3 = mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getPoint();
p4 = mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getPoint();
MathUtils::lineIntersection( mPointVector[p1], mPointVector[p2], mPointVector[p3], mPointVector[p4], &crosspoint );
double distpart = sqrt(( crosspoint.getX() - mPointVector[p3]->getX() ) * ( crosspoint.getX() - mPointVector[p3]->getX() ) + ( crosspoint.getY() - mPointVector[p3]->getY() ) * ( crosspoint.getY() - mPointVector[p3]->getY() ) );
double disttot = sqrt(( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) * ( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) + ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) * ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) );
float frac = distpart / disttot;
if ( frac == 0 || frac == 1 )
{
break;//seems that a roundoff error occured. We found the endpoint
}
int newpoint = splitHalfEdge( mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext(), frac );
insertForcedSegment( p1, newpoint, breakline );
int e = insertForcedSegment( newpoint, p2, breakline );
return e;
}
crossedEdges.append( mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext() );
continue;
}
else if ( MathUtils::lineIntersection( mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getNext()]->getPoint()], mPointVector[p1], mPointVector[p2] ) )
{
if ( mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getNext()]->getForced() && <API key> == Triangulation::<API key> )//if the crossed edge is a forced edge and <API key> is <API key>, we have to snap the forced line to the next node
{
Point3D crosspoint;
int p3, p4;
p3 = mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getPoint();
p4 = mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getNext()]->getPoint();
MathUtils::lineIntersection( mPointVector[p1], mPointVector[p2], mPointVector[p3], mPointVector[p4], &crosspoint );
double dista = sqrt(( crosspoint.getX() - mPointVector[p3]->getX() ) * ( crosspoint.getX() - mPointVector[p3]->getX() ) + ( crosspoint.getY() - mPointVector[p3]->getY() ) * ( crosspoint.getY() - mPointVector[p3]->getY() ) );
double distb = sqrt(( crosspoint.getX() - mPointVector[p4]->getX() ) * ( crosspoint.getX() - mPointVector[p4]->getX() ) + ( crosspoint.getY() - mPointVector[p4]->getY() ) * ( crosspoint.getY() - mPointVector[p4]->getY() ) );
if ( dista <= distb )
{
insertForcedSegment( p1, p3, breakline );
int e = insertForcedSegment( p3, p2, breakline );
return e;
}
else if ( distb <= dista )
{
insertForcedSegment( p1, p4, breakline );
int e = insertForcedSegment( p4, p2, breakline );
return e;
}
}
else if ( mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getNext()]->getForced() && <API key> == Triangulation::INSERT_VERTICE )//if the crossed edge is a forced edge, we have to insert a new vertice on this edge
{
Point3D crosspoint;
int p3, p4;
p3 = mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getPoint();
p4 = mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getNext()]->getPoint();
MathUtils::lineIntersection( mPointVector[p1], mPointVector[p2], mPointVector[p3], mPointVector[p4], &crosspoint );
double distpart = sqrt(( crosspoint.getX() - mPointVector[p3]->getX() ) * ( crosspoint.getX() - mPointVector[p3]->getX() ) + ( crosspoint.getY() - mPointVector[p3]->getY() ) * ( crosspoint.getY() - mPointVector[p3]->getY() ) );
double disttot = sqrt(( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) * ( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) + ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) * ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) );
float frac = distpart / disttot;
if ( frac == 0 || frac == 1 )
{
break;//seems that a roundoff error occured. We found the endpoint
}
int newpoint = splitHalfEdge( mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getNext(), frac );
insertForcedSegment( p1, newpoint, breakline );
int e = insertForcedSegment( newpoint, p2, breakline );
return e;
}
crossedEdges.append( mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getNext() );
continue;
}
else//forced edge terminates
{
break;
}
}
//set the flags 'forced' and 'break' to false for every edge and dualedge of 'crossEdges'
QList<int>::const_iterator iter;
for ( iter = crossedEdges.constBegin(); iter != crossedEdges.constEnd(); ++iter )
{
mHalfEdge[( *( iter ) )]->setForced( false );
mHalfEdge[( *( iter ) )]->setBreak( false );
mHalfEdge[mHalfEdge[( *( iter ) )]->getDual()]->setForced( false );
mHalfEdge[mHalfEdge[( *( iter ) )]->getDual()]->setBreak( false );
}
//crossed edges is filled, now the two polygons to be retriangulated can be build
QList<int> freelist = crossedEdges;//copy the list with the crossed edges to remove the edges already reused
//create the left polygon as a list of the numbers of the halfedges
QList<int> leftPolygon;
QList<int> rightPolygon;
//insert the forced edge and enter the corresponding halfedges as the first edges in the left and right polygons. The nexts and points are set later because of the algorithm to build two polygons from 'crossedEdges'
int firstedge = freelist.first();//edge pointing from p1 to p2
mHalfEdge[firstedge]->setForced( true );
mHalfEdge[firstedge]->setBreak( breakline );
leftPolygon.append( firstedge );
int dualfirstedge = mHalfEdge[freelist.first()]->getDual();//edge pointing from p2 to p1
mHalfEdge[dualfirstedge]->setForced( true );
mHalfEdge[dualfirstedge]->setBreak( breakline );
rightPolygon.append( dualfirstedge );
freelist.pop_front();//delete the first entry from the freelist
//finish the polygon on the left side
int actpointl = p2;
QList<int>::const_iterator leftiter; //todo: is there a better way to set an iterator to the last list element?
leftiter = crossedEdges.constEnd();
--leftiter;
while ( true )
{
int newpoint = mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[( *leftiter )]->getDual()]->getNext()]->getNext()]->getPoint();
if ( newpoint != actpointl )
{
//insert the edge into the leftPolygon
actpointl = newpoint;
int theedge = mHalfEdge[mHalfEdge[mHalfEdge[( *leftiter )]->getDual()]->getNext()]->getNext();
leftPolygon.append( theedge );
}
if ( leftiter == crossedEdges.constBegin() )
{break;}
--leftiter;
}
//insert the last element into leftPolygon
leftPolygon.append( mHalfEdge[crossedEdges.first()]->getNext() );
//finish the polygon on the right side
QList<int>::const_iterator rightiter;
int actpointr = p1;
for ( rightiter = crossedEdges.constBegin(); rightiter != crossedEdges.constEnd(); ++rightiter )
{
int newpoint = mHalfEdge[mHalfEdge[mHalfEdge[( *rightiter )]->getNext()]->getNext()]->getPoint();
if ( newpoint != actpointr )
{
//insert the edge into the right polygon
actpointr = newpoint;
int theedge = mHalfEdge[mHalfEdge[( *rightiter )]->getNext()]->getNext();
rightPolygon.append( theedge );
}
}
//insert the last element into rightPolygon
rightPolygon.append( mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext() );
mHalfEdge[rightPolygon.last()]->setNext( dualfirstedge );//set 'Next' of the last edge to dualfirstedge
//set the necessary nexts of leftPolygon(exept the first)
int actedgel = leftPolygon[1];
leftiter = leftPolygon.constBegin(); leftiter += 2;
for ( ; leftiter != leftPolygon.constEnd(); ++leftiter )
{
mHalfEdge[actedgel]->setNext(( *leftiter ) );
actedgel = ( *leftiter );
}
//set all the necessary nexts of rightPolygon
int actedger = rightPolygon[1];
rightiter = rightPolygon.constBegin(); rightiter += 2;
for ( ; rightiter != rightPolygon.constEnd(); ++rightiter )
{
mHalfEdge[actedger]->setNext(( *rightiter ) );
actedger = ( *( rightiter ) );
}
//setNext and setPoint for the forced edge because this would disturb the building of 'leftpoly' and 'rightpoly' otherwise
mHalfEdge[leftPolygon.first()]->setNext(( *( ++( leftiter = leftPolygon.begin() ) ) ) );
mHalfEdge[leftPolygon.first()]->setPoint( p2 );
mHalfEdge[leftPolygon.last()]->setNext( firstedge );
mHalfEdge[rightPolygon.first()]->setNext(( *( ++( rightiter = rightPolygon.begin() ) ) ) );
mHalfEdge[rightPolygon.first()]->setPoint( p1 );
mHalfEdge[rightPolygon.last()]->setNext( dualfirstedge );
triangulatePolygon( &leftPolygon, &freelist, firstedge );
triangulatePolygon( &rightPolygon, &freelist, dualfirstedge );
//optimisation of the new edges
for ( iter = crossedEdges.begin(); iter != crossedEdges.end(); ++iter )
{
checkSwap(( *( iter ) ) );
}
return leftPolygon.first();
}
void <API key>::<API key>( Triangulation::<API key> b )
{
<API key> = b;
}
void <API key>::setEdgeColor( int r, int g, int b )
{
mEdgeColor.setRgb( r, g, b );
}
void <API key>::setForcedEdgeColor( int r, int g, int b )
{
mForcedEdgeColor.setRgb( r, g, b );
}
void <API key>::setBreakEdgeColor( int r, int g, int b )
{
mBreakEdgeColor.setRgb( r, g, b );
}
void <API key>::<API key>( <API key>* interpolator )
{
<API key> = interpolator;
}
void <API key>::<API key>()
{
QgsDebugMsg( "am in <API key>" );
double minangle = 0;//minimum angle for swapped triangles. If triangles generated by a swap would have a minimum angle (in degrees) below that value, the swap will not be done.
while ( true )
{
bool swapped = false;//flag which allows to exit the loop
bool* control = new bool[mHalfEdge.count()];//controlarray
for ( int i = 0; i <= mHalfEdge.count() - 1; i++ )
{
control[i] = false;
}
for ( int i = 0; i <= mHalfEdge.count() - 1; i++ )
{
if ( control[i] )//edge has already been examined
{
continue;
}
int e1, e2, e3;//numbers of the three edges
e1 = i;
e2 = mHalfEdge[e1]->getNext();
e3 = mHalfEdge[e2]->getNext();
int p1, p2, p3;//numbers of the three points
p1 = mHalfEdge[e1]->getPoint();
p2 = mHalfEdge[e2]->getPoint();
p3 = mHalfEdge[e3]->getPoint();
//skip the iteration, if one point is the virtual point
if ( p1 == -1 || p2 == -1 || p3 == -1 )
{
control[e1] = true;
control[e2] = true;
control[e3] = true;
continue;
}
double el1, el2, el3;//elevations of the points
el1 = mPointVector[p1]->getZ();
el2 = mPointVector[p2]->getZ();
el3 = mPointVector[p3]->getZ();
if ( el1 == el2 && el2 == el3 )//we found a horizonal triangle
{
//swap edges if it is possible, if it would remove the horizontal triangle and if the minimum angle generated by the swap is high enough
if ( swapPossible(( uint )e1 ) && mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[e1]->getDual()]->getNext()]->getPoint()]->getZ() != el1 && swapMinAngle( e1 ) > minangle )
{
doOnlySwap(( uint )e1 );
swapped = true;
}
else if ( swapPossible(( uint )e2 ) && mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[e2]->getDual()]->getNext()]->getPoint()]->getZ() != el2 && swapMinAngle( e2 ) > minangle )
{
doOnlySwap(( uint )e2 );
swapped = true;
}
else if ( swapPossible(( uint )e3 ) && mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[e3]->getDual()]->getNext()]->getPoint()]->getZ() != el3 && swapMinAngle( e3 ) > minangle )
{
doOnlySwap(( uint )e3 );
swapped = true;
}
control[e1] = true;
control[e2] = true;
control[e3] = true;
continue;
}
else//no horizontal triangle, go to the next one
{
control[e1] = true;
control[e2] = true;
control[e3] = true;
continue;
}
}
if ( !swapped )
{
delete[] control;
break;
}
delete[] control;
}
QgsDebugMsg( "end of method" );
}
void <API key>::ruppertRefinement()
{
//minimum angle
double mintol = 17;//refinement stops after the minimum angle reached this tolerance
//data structures
std::map<int, double> edge_angle;//search tree with the edge number as key
std::multimap<double, int> angle_edge;//multimap (map with not unique keys) with angle as key
QSet<int> dontexamine;//search tree containing the edges which do not have to be examined (because of numerical problems)
//first, go through all the forced edges and subdivide if they are encroached by a point
bool stop = false;//flag to ensure that the for-loop is repeated until no half edge is split any more
while ( !stop )
{
stop = true;
int nhalfedges = mHalfEdge.count();
for ( int i = 0; i < nhalfedges - 1; i++ )
{
int next = mHalfEdge[i]->getNext();
int nextnext = mHalfEdge[next]->getNext();
if ( mHalfEdge[next]->getPoint() != -1 && ( mHalfEdge[i]->getForced() || mHalfEdge[mHalfEdge[mHalfEdge[i]->getDual()]->getNext()]->getPoint() == -1 ) )//check for encroached points on forced segments and segments on the inner side of the convex hull, but don't consider edges on the outer side of the convex hull
{
if ( !(( mHalfEdge[next]->getForced() || edgeOnConvexHull( next ) ) || ( mHalfEdge[nextnext]->getForced() || edgeOnConvexHull( nextnext ) ) ) )//don't consider triangles where all three edges are forced edges or hull edges
{
//test for encroachment
while ( MathUtils::inDiametral( mPointVector[mHalfEdge[mHalfEdge[i]->getDual()]->getPoint()], mPointVector[mHalfEdge[i]->getPoint()], mPointVector[mHalfEdge[next]->getPoint()] ) )
{
//split segment
int pointno = splitHalfEdge( i, 0.5 );
Q_UNUSED( pointno );
stop = false;
}
}
}
}
}
//examine the triangulation for angles below the minimum and insert the edges into angle_edge and edge_angle, except the small angle is between forced segments or convex hull edges
double angle;//angle between edge i and the consecutive edge
int p1, p2, p3;//numbers of the triangle points
for ( int i = 0; i < mHalfEdge.count() - 1; i++ )
{
p1 = mHalfEdge[mHalfEdge[i]->getDual()]->getPoint();
p2 = mHalfEdge[i]->getPoint();
p3 = mHalfEdge[mHalfEdge[i]->getNext()]->getPoint();
if ( p1 == -1 || p2 == -1 || p3 == -1 )//don't consider triangles with the virtual point
{
continue;
}
angle = MathUtils::angle( mPointVector[p1], mPointVector[p2], mPointVector[p3], mPointVector[p2] );
bool twoforcededges;//flag to decide, if edges should be added to the maps. Do not add them if true
if (( mHalfEdge[i]->getForced() || edgeOnConvexHull( i ) ) && ( mHalfEdge[mHalfEdge[i]->getNext()]->getForced() || edgeOnConvexHull( mHalfEdge[i]->getNext() ) ) )
{
twoforcededges = true;
}
else
{
twoforcededges = false;
}
if ( angle < mintol && !twoforcededges )
{
edge_angle.insert( std::make_pair( i, angle ) );
angle_edge.insert( std::make_pair( angle, i ) );
}
}
//debugging: print out all the angles below the minimum for a test
for ( std::multimap<double, int>::const_iterator it = angle_edge.begin(); it != angle_edge.end(); ++it )
{
QgsDebugMsg( QString( "angle: %1" ).arg( it->first ) );
}
double minangle = 0;//actual minimum angle
int minedge;//first edge adjacent to the minimum angle
int minedgenext;
int minedgenextnext;
Point3D circumcenter;
while ( !edge_angle.empty() )
{
minangle = angle_edge.begin()->first;
QgsDebugMsg( QString( "minangle: %1" ).arg( minangle ) );
minedge = angle_edge.begin()->second;
minedgenext = mHalfEdge[minedge]->getNext();
minedgenextnext = mHalfEdge[minedgenext]->getNext();
//calculate the circumcenter
if ( !MathUtils::circumcenter( mPointVector[mHalfEdge[minedge]->getPoint()], mPointVector[mHalfEdge[minedgenext]->getPoint()], mPointVector[mHalfEdge[minedgenextnext]->getPoint()], &circumcenter ) )
{
QgsDebugMsg( "warning, calculation of circumcenter failed" );
//put all three edges to dontexamine and remove them from the other maps
dontexamine.insert( minedge );
edge_angle.erase( minedge );
std::multimap<double, int>::iterator minedgeiter = angle_edge.find( minangle );
while ( minedgeiter->second != minedge )
{
++minedgeiter;
}
angle_edge.erase( minedgeiter );
continue;
}
if ( !pointInside( circumcenter.getX(), circumcenter.getY() ) )
{
//put all three edges to dontexamine and remove them from the other maps
QgsDebugMsg( QString( "put circumcenter %1//%2 on dontexamine list because it is outside the convex hull" )
.arg( circumcenter.getX() ).arg( circumcenter.getY() ) );
dontexamine.insert( minedge );
edge_angle.erase( minedge );
std::multimap<double, int>::iterator minedgeiter = angle_edge.find( minangle );
while ( minedgeiter->second != minedge )
{
++minedgeiter;
}
angle_edge.erase( minedgeiter );
continue;
}
bool encroached = false;
#if 0 //slow version
int numhalfedges = mHalfEdge.count();//begin slow version
for ( int i = 0; i < numhalfedges; i++ )
{
if ( mHalfEdge[i]->getForced() || edgeOnConvexHull( i ) )
{
if ( MathUtils::inDiametral( mPointVector[mHalfEdge[i]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[i]->getDual()]->getPoint()], &circumcenter ) )
{
encroached = true;
//split segment
QgsDebugMsg( "segment split" );
int pointno = splitHalfEdge( i, 0.5 );
//update dontexmine, angle_edge, edge_angle
int pointingedge = baseEdgeOfPoint( pointno );
int actedge = pointingedge;
int ed1, ed2, ed3;//numbers of the three edges
int pt1, pt2, pt3;//numbers of the three points
double angle1, angle2, angle3;
do
{
ed1 = mHalfEdge[actedge]->getDual();
pt1 = mHalfEdge[ed1]->getPoint();
ed2 = mHalfEdge[ed1]->getNext();
pt2 = mHalfEdge[ed2]->getPoint();
ed3 = mHalfEdge[ed2]->getNext();
pt3 = mHalfEdge[ed3]->getPoint();
actedge = ed3;
if ( pt1 == -1 || pt2 == -1 || pt3 == -1 )//don't consider triangles with the virtual point
{
continue;
}
angle1 = MathUtils::angle( mPointVector[pt3], mPointVector[pt1], mPointVector[pt2], mPointVector[pt1] );
angle2 = MathUtils::angle( mPointVector[pt1], mPointVector[pt2], mPointVector[pt3], mPointVector[pt2] );
angle3 = MathUtils::angle( mPointVector[pt2], mPointVector[pt3], mPointVector[pt1], mPointVector[pt3] );
//don't put the edges on the maps if two segments are forced or on a hull
bool twoforcededges1, twoforcededges2, twoforcededges3;//flag to indicate, if angle1, angle2 and angle3 are between forced edges or hull edges
if (( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) )
{
twoforcededges1 = true;
}
else
{
twoforcededges1 = false;
}
if (( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) )
{
twoforcededges2 = true;
}
else
{
twoforcededges2 = false;
}
if (( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) )
{
twoforcededges3 = true;
}
else
{
twoforcededges3 = false;
}
//update the settings related to ed1
QSet<int>::iterator ed1iter = dontexamine.find( ed1 );
if ( ed1iter != dontexamine.end() )
{
//edge number is on dontexamine list
dontexamine.erase( ed1iter );
}
else
{
//test, if it is on edge_angle and angle_edge and erase them if yes
std::map<int, double>::iterator tempit1;
tempit1 = edge_angle.find( ed1 );
if ( tempit1 != edge_angle.end() )
{
//erase the entries
double angle = tempit1->second;
edge_angle.erase( ed1 );
std::multimap<double, int>::iterator tempit2 = angle_edge.lower_bound( angle );
while ( tempit2->second != ed1 )
{
++tempit2;
}
angle_edge.erase( tempit2 );
}
}
if ( angle1 < mintol && !twoforcededges1 )
{
edge_angle.insert( std::make_pair( ed1, angle1 ) );
angle_edge.insert( std::make_pair( angle1, ed1 ) );
}
//update the settings related to ed2
QSet<int>::iterator ed2iter = dontexamine.find( ed2 );
if ( ed2iter != dontexamine.end() )
{
//edge number is on dontexamine list
dontexamine.erase( ed2iter );
}
else
{
//test, if it is on edge_angle and angle_edge and erase them if yes
std::map<int, double>::iterator tempit1;
tempit1 = edge_angle.find( ed2 );
if ( tempit1 != edge_angle.end() )
{
//erase the entries
double angle = tempit1->second;
edge_angle.erase( ed2 );
std::multimap<double, int>::iterator tempit2 = angle_edge.lower_bound( angle );
while ( tempit2->second != ed2 )
{
++tempit2;
}
angle_edge.erase( tempit2 );
}
}
if ( angle2 < mintol && !twoforcededges2 )
{
edge_angle.insert( std::make_pair( ed2, angle2 ) );
angle_edge.insert( std::make_pair( angle2, ed2 ) );
}
//update the settings related to ed3
QSet<int>::iterator ed3iter = dontexamine.find( ed3 );
if ( ed3iter != dontexamine.end() )
{
//edge number is on dontexamine list
dontexamine.erase( ed3iter );
}
else
{
//test, if it is on edge_angle and angle_edge and erase them if yes
std::map<int, double>::iterator tempit1;
tempit1 = edge_angle.find( ed3 );
if ( tempit1 != edge_angle.end() )
{
//erase the entries
double angle = tempit1->second;
edge_angle.erase( ed3 );
std::multimap<double, int>::iterator tempit2 = angle_edge.lower_bound( angle );
while ( tempit2->second != ed3 )
{
++tempit2;
}
angle_edge.erase( tempit2 );
}
}
if ( angle3 < mintol && !twoforcededges3 )
{
edge_angle.insert( std::make_pair( ed3, angle3 ) );
angle_edge.insert( std::make_pair( angle3, ed3 ) );
}
}
while ( actedge != pointingedge );
}
}
}
#endif //end slow version
//fast version. Maybe this does not work
QSet<int> influenceedges;//begin fast method
int baseedge = baseEdgeOfTriangle( &circumcenter );
if ( baseedge == -5 )//a numerical instability occured or the circumcenter already exists in the triangulation
{
//delete minedge from edge_angle and minangle from angle_edge
edge_angle.erase( minedge );
std::multimap<double, int>::iterator minedgeiter = angle_edge.find( minangle );
while ( minedgeiter->second != minedge )
{
++minedgeiter;
}
angle_edge.erase( minedgeiter );
continue;
}
else if ( baseedge == -25 )//circumcenter already exists in the triangulation
{
//delete minedge from edge_angle and minangle from angle_edge
edge_angle.erase( minedge );
std::multimap<double, int>::iterator minedgeiter = angle_edge.find( minangle );
while ( minedgeiter->second != minedge )
{
++minedgeiter;
}
angle_edge.erase( minedgeiter );
continue;
}
else if ( baseedge == -20 )
{
baseedge = mEdgeWithPoint;
}
<API key>( &circumcenter, baseedge, influenceedges );
<API key>( &circumcenter, mHalfEdge[baseedge]->getNext(), influenceedges );
<API key>( &circumcenter, mHalfEdge[mHalfEdge[baseedge]->getNext()]->getNext(), influenceedges );
for ( QSet<int>::iterator it = influenceedges.begin(); it != influenceedges.end(); ++it )
{
if (( mHalfEdge[*it]->getForced() || edgeOnConvexHull( *it ) ) && MathUtils::inDiametral( mPointVector[mHalfEdge[*it]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[*it]->getDual()]->getPoint()], &circumcenter ) )
{
//split segment
QgsDebugMsg( "segment split" );
int pointno = splitHalfEdge( *it, 0.5 );
encroached = true;
//update dontexmine, angle_edge, edge_angle
int pointingedge = baseEdgeOfPoint( pointno );
int actedge = pointingedge;
int ed1, ed2, ed3;//numbers of the three edges
int pt1, pt2, pt3;//numbers of the three points
double angle1, angle2, angle3;
do
{
ed1 = mHalfEdge[actedge]->getDual();
pt1 = mHalfEdge[ed1]->getPoint();
ed2 = mHalfEdge[ed1]->getNext();
pt2 = mHalfEdge[ed2]->getPoint();
ed3 = mHalfEdge[ed2]->getNext();
pt3 = mHalfEdge[ed3]->getPoint();
actedge = ed3;
if ( pt1 == -1 || pt2 == -1 || pt3 == -1 )//don't consider triangles with the virtual point
{
continue;
}
angle1 = MathUtils::angle( mPointVector[pt3], mPointVector[pt1], mPointVector[pt2], mPointVector[pt1] );
angle2 = MathUtils::angle( mPointVector[pt1], mPointVector[pt2], mPointVector[pt3], mPointVector[pt2] );
angle3 = MathUtils::angle( mPointVector[pt2], mPointVector[pt3], mPointVector[pt1], mPointVector[pt3] );
//don't put the edges on the maps if two segments are forced or on a hull
bool twoforcededges1, twoforcededges2, twoforcededges3;//flag to decide, if edges should be added to the maps. Do not add them if true
if (( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) )
{
twoforcededges1 = true;
}
else
{
twoforcededges1 = false;
}
if (( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) )
{
twoforcededges2 = true;
}
else
{
twoforcededges2 = false;
}
if (( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) )
{
twoforcededges3 = true;
}
else
{
twoforcededges3 = false;
}
//update the settings related to ed1
QSet<int>::iterator ed1iter = dontexamine.find( ed1 );
if ( ed1iter != dontexamine.end() )
{
//edge number is on dontexamine list
dontexamine.erase( ed1iter );
}
else
{
//test, if it is on edge_angle and angle_edge and erase them if yes
std::map<int, double>::iterator tempit1;
tempit1 = edge_angle.find( ed1 );
if ( tempit1 != edge_angle.end() )
{
//erase the entries
double angle = tempit1->second;
edge_angle.erase( ed1 );
std::multimap<double, int>::iterator tempit2 = angle_edge.lower_bound( angle );
while ( tempit2->second != ed1 )
{
++tempit2;
}
angle_edge.erase( tempit2 );
}
}
if ( angle1 < mintol && !twoforcededges1 )
{
edge_angle.insert( std::make_pair( ed1, angle1 ) );
angle_edge.insert( std::make_pair( angle1, ed1 ) );
}
//update the settings related to ed2
QSet<int>::iterator ed2iter = dontexamine.find( ed2 );
if ( ed2iter != dontexamine.end() )
{
//edge number is on dontexamine list
dontexamine.erase( ed2iter );
}
else
{
//test, if it is on edge_angle and angle_edge and erase them if yes
std::map<int, double>::iterator tempit1;
tempit1 = edge_angle.find( ed2 );
if ( tempit1 != edge_angle.end() )
{
//erase the entries
double angle = tempit1->second;
edge_angle.erase( ed2 );
std::multimap<double, int>::iterator tempit2 = angle_edge.lower_bound( angle );
while ( tempit2->second != ed2 )
{
++tempit2;
}
angle_edge.erase( tempit2 );
}
}
if ( angle2 < mintol && !twoforcededges2 )
{
edge_angle.insert( std::make_pair( ed2, angle2 ) );
angle_edge.insert( std::make_pair( angle2, ed2 ) );
}
//update the settings related to ed3
QSet<int>::iterator ed3iter = dontexamine.find( ed3 );
if ( ed3iter != dontexamine.end() )
{
//edge number is on dontexamine list
dontexamine.erase( ed3iter );
}
else
{
//test, if it is on edge_angle and angle_edge and erase them if yes
std::map<int, double>::iterator tempit1;
tempit1 = edge_angle.find( ed3 );
if ( tempit1 != edge_angle.end() )
{
//erase the entries
double angle = tempit1->second;
edge_angle.erase( ed3 );
std::multimap<double, int>::iterator tempit2 = angle_edge.lower_bound( angle );
while ( tempit2->second != ed3 )
{
++tempit2;
}
angle_edge.erase( tempit2 );
}
}
if ( angle3 < mintol && !twoforcededges3 )
{
edge_angle.insert( std::make_pair( ed3, angle3 ) );
angle_edge.insert( std::make_pair( angle3, ed3 ) );
}
}
while ( actedge != pointingedge );
}
} //end fast method
if ( encroached )
{
continue;
}
Point3D* p = new Point3D();
mDecorator->calcPoint( circumcenter.getX(), circumcenter.getY(), p );
int pointno = mDecorator->addPoint( p );
if ( pointno == -100 || pointno == mTwiceInsPoint )
{
if ( pointno == -100 )
{
QgsDebugMsg( QString( "put circumcenter %1//%2 on dontexamine list because of numerical instabilities" )
.arg( circumcenter.getX() ).arg( circumcenter.getY() ) );
}
else if ( pointno == mTwiceInsPoint )
{
QgsDebugMsg( QString( "put circumcenter %1//%2 on dontexamine list because it is already inserted" )
.arg( circumcenter.getX() ).arg( circumcenter.getY() ) );
//test, if the point is present in the triangulation
bool flag = false;
for ( int i = 0; i < mPointVector.count(); i++ )
{
if ( mPointVector[i]->getX() == circumcenter.getX() && mPointVector[i]->getY() == circumcenter.getY() )
{
flag = true;
}
}
if ( !flag )
{
QgsDebugMsg( "point is not present in the triangulation" );
}
}
//put all three edges to dontexamine and remove them from the other maps
dontexamine.insert( minedge );
edge_angle.erase( minedge );
std::multimap<double, int>::iterator minedgeiter = angle_edge.lower_bound( minangle );
while ( minedgeiter->second != minedge )
{
++minedgeiter;
}
angle_edge.erase( minedgeiter );
continue;
}
else//insertion successful
{
QgsDebugMsg( "circumcenter added" );
//update the maps
//go around the inserted point and make changes for every half edge
int pointingedge = baseEdgeOfPoint( pointno );
int actedge = pointingedge;
int ed1, ed2, ed3;//numbers of the three edges
int pt1, pt2, pt3;//numbers of the three points
double angle1, angle2, angle3;
do
{
ed1 = mHalfEdge[actedge]->getDual();
pt1 = mHalfEdge[ed1]->getPoint();
ed2 = mHalfEdge[ed1]->getNext();
pt2 = mHalfEdge[ed2]->getPoint();
ed3 = mHalfEdge[ed2]->getNext();
pt3 = mHalfEdge[ed3]->getPoint();
actedge = ed3;
if ( pt1 == -1 || pt2 == -1 || pt3 == -1 )//don't consider triangles with the virtual point
{
continue;
}
angle1 = MathUtils::angle( mPointVector[pt3], mPointVector[pt1], mPointVector[pt2], mPointVector[pt1] );
angle2 = MathUtils::angle( mPointVector[pt1], mPointVector[pt2], mPointVector[pt3], mPointVector[pt2] );
angle3 = MathUtils::angle( mPointVector[pt2], mPointVector[pt3], mPointVector[pt1], mPointVector[pt3] );
//todo: put all three edges on the dontexamine list if two edges are forced or convex hull edges
bool twoforcededges1, twoforcededges2, twoforcededges3;
if (( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) )
{
twoforcededges1 = true;
}
else
{
twoforcededges1 = false;
}
if (( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) )
{
twoforcededges2 = true;
}
else
{
twoforcededges2 = false;
}
if (( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) )
{
twoforcededges3 = true;
}
else
{
twoforcededges3 = false;
}
//update the settings related to ed1
QSet<int>::iterator ed1iter = dontexamine.find( ed1 );
if ( ed1iter != dontexamine.end() )
{
//edge number is on dontexamine list
dontexamine.erase( ed1iter );
}
else
{
//test, if it is on edge_angle and angle_edge and erase them if yes
std::map<int, double>::iterator tempit1;
tempit1 = edge_angle.find( ed1 );
if ( tempit1 != edge_angle.end() )
{
//erase the entries
double angle = tempit1->second;
edge_angle.erase( ed1 );
std::multimap<double, int>::iterator tempit2 = angle_edge.lower_bound( angle );
while ( tempit2->second != ed1 )
{
++tempit2;
}
angle_edge.erase( tempit2 );
}
}
if ( angle1 < mintol && !twoforcededges1 )
{
edge_angle.insert( std::make_pair( ed1, angle1 ) );
angle_edge.insert( std::make_pair( angle1, ed1 ) );
}
//update the settings related to ed2
QSet<int>::iterator ed2iter = dontexamine.find( ed2 );
if ( ed2iter != dontexamine.end() )
{
//edge number is on dontexamine list
dontexamine.erase( ed2iter );
}
else
{
//test, if it is on edge_angle and angle_edge and erase them if yes
std::map<int, double>::iterator tempit1;
tempit1 = edge_angle.find( ed2 );
if ( tempit1 != edge_angle.end() )
{
//erase the entries
double angle = tempit1->second;
edge_angle.erase( ed2 );
std::multimap<double, int>::iterator tempit2 = angle_edge.lower_bound( angle );
while ( tempit2->second != ed2 )
{
++tempit2;
}
angle_edge.erase( tempit2 );
}
}
if ( angle2 < mintol && !twoforcededges2 )
{
edge_angle.insert( std::make_pair( ed2, angle2 ) );
angle_edge.insert( std::make_pair( angle2, ed2 ) );
}
//update the settings related to ed3
QSet<int>::iterator ed3iter = dontexamine.find( ed3 );
if ( ed3iter != dontexamine.end() )
{
//edge number is on dontexamine list
dontexamine.erase( ed3iter );
}
else
{
//test, if it is on edge_angle and angle_edge and erase them if yes
std::map<int, double>::iterator tempit1;
tempit1 = edge_angle.find( ed3 );
if ( tempit1 != edge_angle.end() )
{
//erase the entries
double angle = tempit1->second;
edge_angle.erase( ed3 );
std::multimap<double, int>::iterator tempit2 = angle_edge.lower_bound( angle );
while ( tempit2->second != ed3 )
{
++tempit2;
}
angle_edge.erase( tempit2 );
}
}
if ( angle3 < mintol && !twoforcededges3 )
{
edge_angle.insert( std::make_pair( ed3, angle3 ) );
angle_edge.insert( std::make_pair( angle3, ed3 ) );
}
}
while ( actedge != pointingedge );
}
}
#if 0
//debugging: print out all edge of dontexamine
for ( QSet<int>::iterator it = dontexamine.begin(); it != dontexamine.end(); ++it )
{
QgsDebugMsg( QString( "edge nr. %1 is in dontexamine" ).arg( *it ) );
}
#endif
}
bool <API key>::swapPossible( unsigned int edge )
{
//test, if edge belongs to a forced edge
if ( mHalfEdge[edge]->getForced() )
{
return false;
}
//test, if the edge is on the convex hull or is connected to the virtual point
if ( mHalfEdge[edge]->getPoint() == -1 || mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint() == -1 || mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getPoint() == -1 || mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint() == -1 )
{
return false;
}
//then, test, if the edge is in the middle of a not convex quad
Point3D* pta = mPointVector[mHalfEdge[edge]->getPoint()];
Point3D* ptb = mPointVector[mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint()];
Point3D* ptc = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[edge]->getNext()]->getNext()]->getPoint()];
Point3D* ptd = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getPoint()];
if ( MathUtils::leftOf( ptc, pta, ptb ) > leftOfTresh )
{
return false;
}
else if ( MathUtils::leftOf( ptd, ptb, ptc ) > leftOfTresh )
{
return false;
}
else if ( MathUtils::leftOf( pta, ptc, ptd ) > leftOfTresh )
{
return false;
}
else if ( MathUtils::leftOf( ptb, ptd, pta ) > leftOfTresh )
{
return false;
}
return true;
}
void <API key>::triangulatePolygon( QList<int>* poly, QList<int>* free, int mainedge )
{
if ( poly && free )
{
if ( poly->count() == 3 )//polygon is already a triangle
{
return;
}
//search for the edge pointing on the closest point(distedge) and for the next(nextdistedge)
QList<int>::const_iterator iterator = ++( poly->constBegin() );//go to the second edge
double distance = MathUtils::distPointFromLine( mPointVector[mHalfEdge[( *iterator )]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[mainedge]->getDual()]->getPoint()], mPointVector[mHalfEdge[mainedge]->getPoint()] );
int distedge = ( *iterator );
int nextdistedge = mHalfEdge[( *iterator )]->getNext();
++iterator;
while ( iterator != --( poly->constEnd() ) )
{
if ( MathUtils::distPointFromLine( mPointVector[mHalfEdge[( *iterator )]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[mainedge]->getDual()]->getPoint()], mPointVector[mHalfEdge[mainedge]->getPoint()] ) < distance )
{
distedge = ( *iterator );
nextdistedge = mHalfEdge[( *iterator )]->getNext();
distance = MathUtils::distPointFromLine( mPointVector[mHalfEdge[( *iterator )]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[mainedge]->getDual()]->getPoint()], mPointVector[mHalfEdge[mainedge]->getPoint()] );
}
++iterator;
}
if ( nextdistedge == ( *( --poly->end() ) ) )//the nearest point is connected to the endpoint of mainedge
{
int inserta = free->first();//take an edge from the freelist
int insertb = mHalfEdge[inserta]->getDual();
free->pop_front();
mHalfEdge[inserta]->setNext(( poly->at( 1 ) ) );
mHalfEdge[inserta]->setPoint( mHalfEdge[mainedge]->getPoint() );
mHalfEdge[insertb]->setNext( nextdistedge );
mHalfEdge[insertb]->setPoint( mHalfEdge[distedge]->getPoint() );
mHalfEdge[distedge]->setNext( inserta );
mHalfEdge[mainedge]->setNext( insertb );
QList<int> polya;
for ( iterator = ( ++( poly->constBegin() ) ); ( *iterator ) != nextdistedge; ++iterator )
{
polya.append(( *iterator ) );
}
polya.prepend( inserta );
#if 0
//print out all the elements of polya for a test
for ( iterator = polya.begin(); iterator != polya.end(); ++iterator )
{
QgsDebugMsg( *iterator );
}
#endif
triangulatePolygon( &polya, free, inserta );
}
else if ( distedge == ( *( ++poly->begin() ) ) )//the nearest point is connected to the beginpoint of mainedge
{
int inserta = free->first();//take an edge from the freelist
int insertb = mHalfEdge[inserta]->getDual();
free->pop_front();
mHalfEdge[inserta]->setNext(( poly->at( 2 ) ) );
mHalfEdge[inserta]->setPoint( mHalfEdge[distedge]->getPoint() );
mHalfEdge[insertb]->setNext( mainedge );
mHalfEdge[insertb]->setPoint( mHalfEdge[mHalfEdge[mainedge]->getDual()]->getPoint() );
mHalfEdge[distedge]->setNext( insertb );
mHalfEdge[( *( --poly->end() ) )]->setNext( inserta );
QList<int> polya;
iterator = poly->constBegin(); iterator += 2;
while ( iterator != poly->constEnd() )
{
polya.append(( *iterator ) );
++iterator;
}
polya.prepend( inserta );
triangulatePolygon( &polya, free, inserta );
}
else//the nearest point is not connected to an endpoint of mainedge
{
int inserta = free->first();//take an edge from the freelist
int insertb = mHalfEdge[inserta]->getDual();
free->pop_front();
int insertc = free->first();
int insertd = mHalfEdge[insertc]->getDual();
free->pop_front();
mHalfEdge[inserta]->setNext(( poly->at( 1 ) ) );
mHalfEdge[inserta]->setPoint( mHalfEdge[mainedge]->getPoint() );
mHalfEdge[insertb]->setNext( insertd );
mHalfEdge[insertb]->setPoint( mHalfEdge[distedge]->getPoint() );
mHalfEdge[insertc]->setNext( nextdistedge );
mHalfEdge[insertc]->setPoint( mHalfEdge[distedge]->getPoint() );
mHalfEdge[insertd]->setNext( mainedge );
mHalfEdge[insertd]->setPoint( mHalfEdge[mHalfEdge[mainedge]->getDual()]->getPoint() );
mHalfEdge[distedge]->setNext( inserta );
mHalfEdge[mainedge]->setNext( insertb );
mHalfEdge[( *( --poly->end() ) )]->setNext( insertc );
//build two new polygons for recursive triangulation
QList<int> polya;
QList<int> polyb;
for ( iterator = ++( poly->constBegin() ); ( *iterator ) != nextdistedge; ++iterator )
{
polya.append(( *iterator ) );
}
polya.prepend( inserta );
while ( iterator != poly->constEnd() )
{
polyb.append(( *iterator ) );
++iterator;
}
polyb.prepend( insertc );
triangulatePolygon( &polya, free, inserta );
triangulatePolygon( &polyb, free, insertc );
}
}
else
{
QgsDebugMsg( "warning, null pointer" );
}
}
bool <API key>::pointInside( double x, double y )
{
Point3D point( x, y, 0 );
unsigned int actedge = mEdgeInside;//start with an edge which does not point to the virtual point
int counter = 0;//number of consecutive successful left-of-tests
int nulls = 0;//number of left-of-tests, which returned 0. 1 means, that the point is on a line, 2 means that it is on an existing point
int numinstabs = 0;//number of suspect left-of-tests due to 'leftOfTresh'
int runs = 0;//counter for the number of iterations in the loop to prevent an endless loop
while ( true )
{
if ( runs > nBaseOfRuns )//prevents endless loops
{
QgsDebugMsg( QString( "warning, instability detected: Point coordinates: %1//%2" ).arg( x ).arg( y ) );
return false;
}
if ( MathUtils::leftOf( &point, mPointVector[mHalfEdge[mHalfEdge[actedge]->getDual()]->getPoint()], mPointVector[mHalfEdge[actedge]->getPoint()] ) < ( -leftOfTresh ) )//point is on the left side
{
counter += 1;
if ( counter == 3 )//three successful passes means that we have found the triangle
{
break;
}
}
else if ( MathUtils::leftOf( &point, mPointVector[mHalfEdge[mHalfEdge[actedge]->getDual()]->getPoint()], mPointVector[mHalfEdge[actedge]->getPoint()] ) == 0 )//point is exactly in the line of the edge
{
counter += 1;
mEdgeWithPoint = actedge;
nulls += 1;
if ( counter == 3 )//three successful passes means that we have found the triangle
{
break;
}
}
else if ( MathUtils::leftOf( &point, mPointVector[mHalfEdge[mHalfEdge[actedge]->getDual()]->getPoint()], mPointVector[mHalfEdge[actedge]->getPoint()] ) < leftOfTresh )//numerical problems
{
counter += 1;
numinstabs += 1;
if ( counter == 3 )//three successful passes means that we have found the triangle
{
break;
}
}
else//point is on the right side
{
actedge = mHalfEdge[actedge]->getDual();
counter = 1;
nulls = 0;
numinstabs = 0;
}
actedge = mHalfEdge[actedge]->getNext();
if ( mHalfEdge[actedge]->getPoint() == -1 )//the half edge points to the virtual point
{
if ( nulls == 1 )//point is exactly on the convex hull
{
return true;
}
mEdgeOutside = ( unsigned int )mHalfEdge[mHalfEdge[actedge]->getNext()]->getNext();
return false;//the point is outside the convex hull
}
runs++;
}
if ( nulls == 2 )//we hit an existing point
{
return true;
}
if ( numinstabs > 0 )//a numerical instability occured
{
QgsDebugMsg( "numerical instabilities" );
return true;
}
if ( nulls == 1 )//point is on an existing edge
{
return true;
}
mEdgeInside = actedge;
return true;
}
#if 0
bool <API key>::readFromTAFF( QString filename )
{
QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );//change the cursor
QFile file( filename );//the file to be read
file.open( IO_Raw | IO_ReadOnly );
QBuffer buffer( file.readAll() );//the buffer to copy the file to
file.close();
QTextStream textstream( &buffer );
buffer.open( IO_ReadOnly );
QString buff;
int numberofhalfedges;
int numberofpoints;
//edge section
while ( buff.mid( 0, 4 ) != "TRIA" )//search for the TRIA-section
{
buff = textstream.readLine();
}
while ( buff.mid( 0, 4 ) != "NEDG" )
{
buff = textstream.readLine();
}
numberofhalfedges = buff.section( ' ', 1, 1 ).toInt();
mHalfEdge.resize( numberofhalfedges );
while ( buff.mid( 0, 4 ) != "DATA" )//search for the data section
{
textstream >> buff;
}
int nr1, nr2, dual1, dual2, point1, point2, next1, next2, fo1, fo2, b1, b2;
bool forced1, forced2, break1, break2;
//import all the DualEdges
QProgressBar* edgebar = new QProgressBar();//use a progress dialog so that it is not boring for the user
edgebar->setCaption( "Reading edges..." );
edgebar->setTotalSteps( numberofhalfedges / 2 );
edgebar->setMinimumWidth( 400 );
edgebar->move( 500, 500 );
edgebar->show();
for ( int i = 0; i < numberofhalfedges / 2; i++ )
{
if ( i % 1000 == 0 )
{
edgebar->setProgress( i );
}
textstream >> nr1;
textstream >> point1;
textstream >> next1;
textstream >> fo1;
if ( fo1 == 0 )
{
forced1 = false;
}
else
{
forced1 = true;
}
textstream >> b1;
if ( b1 == 0 )
{
break1 = false;
}
else
{
break1 = true;
}
textstream >> nr2;
textstream >> point2;
textstream >> next2;
textstream >> fo2;
if ( fo2 == 0 )
{
forced2 = false;
}
else
{
forced2 = true;
}
textstream >> b2;
if ( b2 == 0 )
{
break2 = false;
}
else
{
break2 = true;
}
HalfEdge* hf1 = new HalfEdge();
hf1->setDual( nr2 );
hf1->setNext( next1 );
hf1->setPoint( point1 );
hf1->setBreak( break1 );
hf1->setForced( forced1 );
HalfEdge* hf2 = new HalfEdge();
hf2->setDual( nr1 );
hf2->setNext( next2 );
hf2->setPoint( point2 );
hf2->setBreak( break2 );
hf2->setForced( forced2 );
// QgsDebugMsg( QString( "inserting half edge pair %1" ).arg( i ) );
mHalfEdge.insert( nr1, hf1 );
mHalfEdge.insert( nr2, hf2 );
}
edgebar->setProgress( numberofhalfedges / 2 );
delete edgebar;
//set mEdgeInside to a reasonable value
for ( int i = 0; i < numberofhalfedges; i++ )
{
int a, b, c, d;
a = mHalfEdge[i]->getPoint();
b = mHalfEdge[mHalfEdge[i]->getDual()]->getPoint();
c = mHalfEdge[mHalfEdge[i]->getNext()]->getPoint();
d = mHalfEdge[mHalfEdge[mHalfEdge[i]->getDual()]->getNext()]->getPoint();
if ( a != -1 && b != -1 && c != -1 && d != -1 )
{
mEdgeInside = i;
break;
}
}
//point section
while ( buff.mid( 0, 4 ) != "POIN" )
{
buff = textstream.readLine();
QgsDebugMsg( buff );
}
while ( buff.mid( 0, 4 ) != "NPTS" )
{
buff = textstream.readLine();
QgsDebugMsg( buff );
}
numberofpoints = buff.section( ' ', 1, 1 ).toInt();
mPointVector.resize( numberofpoints );
while ( buff.mid( 0, 4 ) != "DATA" )
{
textstream >> buff;
}
QProgressBar* pointbar = new QProgressBar();
pointbar->setCaption( "Reading points..." );
pointbar->setTotalSteps( numberofpoints );
pointbar->setMinimumWidth( 400 );
pointbar->move( 500, 500 );
pointbar->show();
double x, y, z;
for ( int i = 0; i < numberofpoints; i++ )
{
if ( i % 1000 == 0 )
{
pointbar->setProgress( i );
}
textstream >> x;
textstream >> y;
textstream >> z;
Point3D* p = new Point3D( x, y, z );
// QgsDebugMsg( QString( "inserting point %1" ).arg( i ) );
mPointVector.insert( i, p );
if ( i == 0 )
{
xMin = x;
xMax = x;
yMin = y;
yMax = y;
}
else
{
//update the bounding box
if ( x < xMin )
{
xMin = x;
}
else if ( x > xMax )
{
xMax = x;
}
if ( y < yMin )
{
yMin = y;
}
else if ( y > yMax )
{
yMax = y;
}
}
}
pointbar->setProgress( numberofpoints );
delete pointbar;
QApplication::<API key>();
}
bool <API key>::saveToTAFF( QString filename ) const
{
QFile outputfile( filename );
if ( !outputfile.open( IO_WriteOnly ) )
{
QMessageBox::warning( 0, "warning", "File could not be written", QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton );
return false;
}
QTextStream outstream( &outputfile );
outstream.precision( 9 );
//export the edges. Attention, dual edges must be adjacent in the TAFF-file
outstream << "TRIA" << std::endl << std::flush;
outstream << "NEDG " << mHalfEdge.count() << std::endl << std::flush;
outstream << "PANO 1" << std::endl << std::flush;
outstream << "DATA ";
bool* cont = new bool[mHalfEdge.count()];
for ( unsigned int i = 0; i <= mHalfEdge.count() - 1; i++ )
{
cont[i] = false;
}
for ( unsigned int i = 0; i < mHalfEdge.count(); i++ )
{
if ( cont[i] )
{
continue;
}
int dual = mHalfEdge[i]->getDual();
outstream << i << " " << mHalfEdge[i]->getPoint() << " " << mHalfEdge[i]->getNext() << " " << mHalfEdge[i]->getForced() << " " << mHalfEdge[i]->getBreak() << " ";
outstream << dual << " " << mHalfEdge[dual]->getPoint() << " " << mHalfEdge[dual]->getNext() << " " << mHalfEdge[dual]->getForced() << " " << mHalfEdge[dual]->getBreak() << " ";
cont[i] = true;
cont[dual] = true;
}
outstream << std::endl << std::flush;
outstream << std::endl << std::flush;
delete[] cont;
//export the points to the file
outstream << "POIN" << std::endl << std::flush;
outstream << "NPTS " << getNumberOfPoints() << std::endl << std::flush;
outstream << "PATT 3" << std::endl << std::flush;
outstream << "DATA ";
for ( int i = 0; i < getNumberOfPoints(); i++ )
{
Point3D* p = mPointVector[i];
outstream << p->getX() << " " << p->getY() << " " << p->getZ() << " ";
}
outstream << std::endl << std::flush;
outstream << std::endl << std::flush;
return true;
}
#endif
bool <API key>::swapEdge( double x, double y )
{
Point3D p( x, y, 0 );
int edge1 = baseEdgeOfTriangle( &p );
if ( edge1 >= 0 )
{
int edge2, edge3;
Point3D* point1;
Point3D* point2;
Point3D* point3;
edge2 = mHalfEdge[edge1]->getNext();
edge3 = mHalfEdge[edge2]->getNext();
point1 = getPoint( mHalfEdge[edge1]->getPoint() );
point2 = getPoint( mHalfEdge[edge2]->getPoint() );
point3 = getPoint( mHalfEdge[edge3]->getPoint() );
if ( point1 && point2 && point3 )
{
//find out the closest edge to the point and swap this edge
double dist1, dist2, dist3;
dist1 = MathUtils::distPointFromLine( &p, point3, point1 );
dist2 = MathUtils::distPointFromLine( &p, point1, point2 );
dist3 = MathUtils::distPointFromLine( &p, point2, point3 );
if ( dist1 <= dist2 && dist1 <= dist3 )
{
//qWarning("edge "+QString::number(edge1)+" is closest");
if ( swapPossible( edge1 ) )
{
doOnlySwap( edge1 );
}
}
else if ( dist2 <= dist1 && dist2 <= dist3 )
{
//qWarning("edge "+QString::number(edge2)+" is closest");
if ( swapPossible( edge2 ) )
{
doOnlySwap( edge2 );
}
}
else if ( dist3 <= dist1 && dist3 <= dist2 )
{
//qWarning("edge "+QString::number(edge3)+" is closest");
if ( swapPossible( edge3 ) )
{
doOnlySwap( edge3 );
}
}
return true;
}
else
{
// QgsDebugMsg("warning: null pointer");
return false;
}
}
else
{
// QgsDebugMsg("Edge number negative");
return false;
}
}
QList<int>* <API key>::getPointsAroundEdge( double x, double y )
{
Point3D p( x, y, 0 );
int p1, p2, p3, p4;
int edge1 = baseEdgeOfTriangle( &p );
if ( edge1 >= 0 )
{
int edge2, edge3;
Point3D* point1;
Point3D* point2;
Point3D* point3;
edge2 = mHalfEdge[edge1]->getNext();
edge3 = mHalfEdge[edge2]->getNext();
point1 = getPoint( mHalfEdge[edge1]->getPoint() );
point2 = getPoint( mHalfEdge[edge2]->getPoint() );
point3 = getPoint( mHalfEdge[edge3]->getPoint() );
if ( point1 && point2 && point3 )
{
double dist1, dist2, dist3;
dist1 = MathUtils::distPointFromLine( &p, point3, point1 );
dist2 = MathUtils::distPointFromLine( &p, point1, point2 );
dist3 = MathUtils::distPointFromLine( &p, point2, point3 );
if ( dist1 <= dist2 && dist1 <= dist3 )
{
p1 = mHalfEdge[edge1]->getPoint();
p2 = mHalfEdge[mHalfEdge[edge1]->getNext()]->getPoint();
p3 = mHalfEdge[mHalfEdge[edge1]->getDual()]->getPoint();
p4 = mHalfEdge[mHalfEdge[mHalfEdge[edge1]->getDual()]->getNext()]->getPoint();
}
else if ( dist2 <= dist1 && dist2 <= dist3 )
{
p1 = mHalfEdge[edge2]->getPoint();
p2 = mHalfEdge[mHalfEdge[edge2]->getNext()]->getPoint();
p3 = mHalfEdge[mHalfEdge[edge2]->getDual()]->getPoint();
p4 = mHalfEdge[mHalfEdge[mHalfEdge[edge2]->getDual()]->getNext()]->getPoint();
}
else if ( dist3 <= dist1 && dist3 <= dist2 )
{
p1 = mHalfEdge[edge3]->getPoint();
p2 = mHalfEdge[mHalfEdge[edge3]->getNext()]->getPoint();
p3 = mHalfEdge[mHalfEdge[edge3]->getDual()]->getPoint();
p4 = mHalfEdge[mHalfEdge[mHalfEdge[edge3]->getDual()]->getNext()]->getPoint();
}
QList<int>* list = new QList<int>();
list->append( p1 );
list->append( p2 );
list->append( p3 );
list->append( p4 );
return list;
}
else
{
QgsDebugMsg( "warning: null pointer" );
return 0;
}
}
else
{
QgsDebugMsg( "Edge number negative" );
return 0;
}
}
bool <API key>::saveAsShapefile( const QString& fileName ) const
{
QString shapeFileName = fileName;
QgsFields fields;
fields.append( QgsField( "type", QVariant::String, "String" ) );
// add the extension if not present
if ( shapeFileName.indexOf( ".shp" ) == -1 )
{
shapeFileName += ".shp";
}
//delete already existing files
if ( QFile::exists( shapeFileName ) )
{
if ( !QgsVectorFileWriter::deleteShapeFile( shapeFileName ) )
{
return false;
}
}
QgsVectorFileWriter writer( shapeFileName, "Utf-8", fields, QGis::WKBLineString, 0 );
if ( writer.hasError() != QgsVectorFileWriter::NoError )
{
return false;
}
bool *alreadyVisitedEdges = new bool[mHalfEdge.size()];
if ( !alreadyVisitedEdges )
{
QgsDebugMsg( "out of memory" );
return false;
}
for ( int i = 0; i < mHalfEdge.size(); ++i )
{
alreadyVisitedEdges[i] = false;
}
for ( int i = 0; i < mHalfEdge.size(); ++i )
{
HalfEdge* currentEdge = mHalfEdge[i];
if ( currentEdge->getPoint() != -1 && mHalfEdge[currentEdge->getDual()]->getPoint() != -1 && !alreadyVisitedEdges[currentEdge->getDual()] )
{
QgsFeature edgeLineFeature;
//geometry
Point3D* p1 = mPointVector[currentEdge->getPoint()];
Point3D* p2 = mPointVector[mHalfEdge[currentEdge->getDual()]->getPoint()];
QgsPolyline lineGeom;
lineGeom.push_back( QgsPoint( p1->getX(), p1->getY() ) );
lineGeom.push_back( QgsPoint( p2->getX(), p2->getY() ) );
QgsGeometry* geom = QgsGeometry::fromPolyline( lineGeom );
edgeLineFeature.setGeometry( geom );
edgeLineFeature.initAttributes( 1 );
//attributes
QString attributeString;
if ( currentEdge->getForced() )
{
if ( currentEdge->getBreak() )
{
attributeString = "break line";
}
else
{
attributeString = "structure line";
}
}
edgeLineFeature.setAttribute( 0, attributeString );
writer.addFeature( edgeLineFeature );
}
alreadyVisitedEdges[i] = true;
}
delete [] alreadyVisitedEdges;
return true;
}
double <API key>::swapMinAngle( int edge ) const
{
Point3D* p1 = getPoint( mHalfEdge[edge]->getPoint() );
Point3D* p2 = getPoint( mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint() );
Point3D* p3 = getPoint( mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint() );
Point3D* p4 = getPoint( mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getPoint() );
//search for the minimum angle (it is important, which directions the lines have!)
double minangle;
double angle1 = MathUtils::angle( p1, p2, p4, p2 );
minangle = angle1;
double angle2 = MathUtils::angle( p3, p2, p4, p2 );
if ( angle2 < minangle )
{
minangle = angle2;
}
double angle3 = MathUtils::angle( p2, p3, p4, p3 );
if ( angle3 < minangle )
{
minangle = angle3;
}
double angle4 = MathUtils::angle( p3, p4, p2, p4 );
if ( angle4 < minangle )
{
minangle = angle4;
}
double angle5 = MathUtils::angle( p2, p4, p1, p4 );
if ( angle5 < minangle )
{
minangle = angle5;
}
double angle6 = MathUtils::angle( p4, p1, p2, p1 );
if ( angle6 < minangle )
{
minangle = angle6;
}
return minangle;
}
int <API key>::splitHalfEdge( int edge, float position )
{
//just a short test if position is between 0 and 1
if ( position < 0 || position > 1 )
{
QgsDebugMsg( "warning, position is not between 0 and 1" );
}
//create the new point on the heap
Point3D* p = new Point3D( mPointVector[mHalfEdge[edge]->getPoint()]->getX()*position + mPointVector[mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint()]->getX()*( 1 - position ), mPointVector[mHalfEdge[edge]->getPoint()]->getY()*position + mPointVector[mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint()]->getY()*( 1 - position ), 0 );
//calculate the z-value of the point to insert
Point3D zvaluepoint;
mDecorator->calcPoint( p->getX(), p->getY(), &zvaluepoint );
p->setZ( zvaluepoint.getZ() );
//insert p into mPointVector
if ( mPointVector.count() >= mPointVector.size() )
{
mPointVector.resize( mPointVector.count() + 1 );
}
QgsDebugMsg( QString( "inserting point nr. %1, %2//%3//%4" ).arg( mPointVector.count() ).arg( p->getX() ).arg( p->getY() ).arg( p->getZ() ) );
mPointVector.insert( mPointVector.count(), p );
//insert the six new halfedges
int dualedge = mHalfEdge[edge]->getDual();
int edge1 = insertEdge( -10, -10, mPointVector.count() - 1, false, false );
int edge2 = insertEdge( edge1, mHalfEdge[mHalfEdge[edge]->getNext()]->getNext(), mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint(), false, false );
int edge3 = insertEdge( -10, mHalfEdge[mHalfEdge[dualedge]->getNext()]->getNext(), mHalfEdge[mHalfEdge[dualedge]->getNext()]->getPoint(), false, false );
int edge4 = insertEdge( edge3, dualedge, mPointVector.count() - 1, false, false );
int edge5 = insertEdge( -10, mHalfEdge[edge]->getNext(), mHalfEdge[edge]->getPoint(), mHalfEdge[edge]->getBreak(), mHalfEdge[edge]->getForced() );
int edge6 = insertEdge( edge5, edge3, mPointVector.count() - 1, mHalfEdge[dualedge]->getBreak(), mHalfEdge[dualedge]->getForced() );
mHalfEdge[edge1]->setDual( edge2 );
mHalfEdge[edge1]->setNext( edge5 );
mHalfEdge[edge3]->setDual( edge4 );
mHalfEdge[edge5]->setDual( edge6 );
//adjust the already existing halfedges
mHalfEdge[mHalfEdge[edge]->getNext()]->setNext( edge1 );
mHalfEdge[mHalfEdge[dualedge]->getNext()]->setNext( edge4 );
mHalfEdge[edge]->setNext( edge2 );
mHalfEdge[edge]->setPoint( mPointVector.count() - 1 );
mHalfEdge[mHalfEdge[edge3]->getNext()]->setNext( edge6 );
//test four times recursively for swaping
checkSwap( mHalfEdge[edge5]->getNext() );
checkSwap( mHalfEdge[edge2]->getNext() );
checkSwap( mHalfEdge[dualedge]->getNext() );
checkSwap( mHalfEdge[edge3]->getNext() );
mDecorator->addPoint( new Point3D( p->getX(), p->getY(), 0 ) );//dirty hack to enforce update of decorators
return mPointVector.count() - 1;
}
bool <API key>::edgeOnConvexHull( int edge )
{
return ( mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint() == -1 || mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getPoint() == -1 );
}
void <API key>::<API key>( Point3D* point, int edge, QSet<int> &set )
{
if ( set.find( edge ) == set.end() )
{
set.insert( edge );
}
else//prevent endless loops
{
return;
}
if ( !mHalfEdge[edge]->getForced() && !edgeOnConvexHull( edge ) )
{
//test, if point is in the circle through both endpoints of edge and the endpoint of edge->dual->next->point
if ( MathUtils::inCircle( point, mPointVector[mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint()], mPointVector[mHalfEdge[edge]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint()] ) )
{
<API key>( point, mHalfEdge[mHalfEdge[edge]->getDual()]->getNext(), set );
<API key>( point, mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getNext(), set );
}
}
} |
<?php
$wp_config = [
'db_name' => getenv('DB_NAME'),
'db_user' => getenv('DB_USER'),
'db_password' => getenv('DB_PASSWORD'),
'db_host' => getenv('DB_HOST'),
'db_ssl' => getenv('DB_SSL') === 'false' ? false : true,
'auth_key' => getenv('AUTH_KEY'),
'secure_auth_key' => getenv('SECURE_AUTH_KEY'),
'logged_in_key' => getenv('LOGGED_IN_KEY'),
'nonce_key' => getenv('NONCE_KEY'),
'auth_salt' => getenv('AUTH_SALT'),
'secure_auth_salt' => getenv('SECURE_AUTH_SALT'),
'logged_in_salt' => getenv('LOGGED_IN_SALT'),
'nonce_salt' => getenv('NONCE_SALT'),
'wp_debug' => false,
'wp_cache' => getenv('WP_CACHE') === 'false' ? false : true,
'disallow_file_mods' => true,
'force_ssl_admin' => true,
'<API key>' => true,
'wp_env' => getenv('WP_ENV') ?: 'production',
'wp_config_env' => __DIR__ . '/config/env.php',
'wp_config_local' => __DIR__ . '/config/local.php',
];
/* Settings for each environment */
if ( file_exists($wp_config['wp_config_local']) ) {
require($wp_config['wp_config_local']);
} else {
require($wp_config['wp_config_env']);
}
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', $wp_config['db_name']);
/** MySQL database username */
define('DB_USER', $wp_config['db_user']);
/** MySQL database password */
define('DB_PASSWORD', $wp_config['db_password']);
/** MySQL hostname */
define('DB_HOST', $wp_config['db_host']);
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
/** MySQL options */
if ( $wp_config['db_ssl'] ) {
define('MYSQL_CLIENT_FLAGS', <API key> | MYSQLI_CLIENT_SSL);
} else {
define('MYSQL_CLIENT_FLAGS', <API key>);
}
define('AUTH_KEY', $wp_config['auth_key']);
define('SECURE_AUTH_KEY', $wp_config['secure_auth_key']);
define('LOGGED_IN_KEY', $wp_config['logged_in_key']);
define('NONCE_KEY', $wp_config['nonce_key']);
define('AUTH_SALT', $wp_config['auth_salt']);
define('SECURE_AUTH_SALT', $wp_config['secure_auth_salt']);
define('LOGGED_IN_SALT', $wp_config['logged_in_salt']);
define('NONCE_SALT', $wp_config['nonce_salt']);
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each a unique
* prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
define('WP_DEBUG', $wp_config['wp_debug']);
/** Enable cache (include 'wp-content/advanced-cache.php') */
define('WP_CACHE', $wp_config['wp_cache']);
/** Disable plugin and theme update and installation */
define('DISALLOW_FILE_MODS', $wp_config['disallow_file_mods']);
/** Require SSL for admin and logins */
define('FORCE_SSL_ADMIN', $wp_config['force_ssl_admin']);
/** Disable WordPress auto updates */
define('<API key>', $wp_config['<API key>']);
if ( isset($_SERVER['<API key>']) && $_SERVER['<API key>'] === 'https' )
$_SERVER['HTTPS'] = 'on';
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/public/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php'); |
# GENERATED FROM XML -- DO NOT EDIT
URI: suexec.html.en
Content-Language: en
Content-type: text/html; charset=ISO-8859-1
URI: suexec.html.ko.euc-kr
Content-Language: ko
Content-type: text/html; charset=EUC-KR |
<?php print $doctype; ?>
<html lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>"<?php print $rdf->version . $rdf->namespaces; ?>>
<head<?php print $rdf->profile; ?>>
<?php print $head; ?>
<title><?php print $head_title; ?></title>
<?php print $styles; ?>
<?php print $scripts; ?>
</head>
<body<?php print $attributes;?>>
<div id="skip-link">
<a href="#main-content" class="element-invisible element-focusable"><?php print t('Skip to main content'); ?></a>
</div>
<?php print $page_top; ?>
<div class="typography">
<?php print $page; ?>
</div>
<?php print $page_bottom; ?>
</body>
</html> |
#include "config.h"
#include "mount_util.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <errno.h>
#include <limits.h>
#include <mntent.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/mount.h>
#include <sys/param.h>
static int mtab_needs_update(const char *mnt)
{
int res;
struct stat stbuf;
/* If mtab is within new mount, don't touch it */
if (strncmp(mnt, _PATH_MOUNTED, strlen(mnt)) == 0 &&
_PATH_MOUNTED[strlen(mnt)] == '/')
return 0;
/*
* Skip mtab update if /etc/mtab:
*
* - doesn't exist,
* - is a symlink,
* - is on a read-only filesystem.
*/
res = lstat(_PATH_MOUNTED, &stbuf);
if (res == -1) {
if (errno == ENOENT)
return 0;
} else {
if (S_ISLNK(stbuf.st_mode))
return 0;
res = access(_PATH_MOUNTED, W_OK);
if (res == -1 && errno == EROFS)
return 0;
}
return 1;
}
int fuse_mnt_add_mount(const char *progname, const char *fsname,
const char *mnt, const char *type, const char *opts)
{
int res;
int status;
if (!mtab_needs_update(mnt))
return 0;
res = fork();
if (res == -1) {
fprintf(stderr, "%s: fork: %s\n", progname, strerror(errno));
return -1;
}
if (res == 0) {
char templ[] = "/tmp/fusermountXXXXXX";
char *tmp;
setuid(geteuid());
/*
* hide in a directory, where mount isn't able to resolve
* fsname as a valid path
*/
tmp = mkdtemp(templ);
if (!tmp) {
fprintf(stderr, "%s: failed to create temporary directory\n",
progname);
exit(1);
}
if (chdir(tmp)) {
fprintf(stderr, "%s: failed to chdir to %s: %s\n",
progname, tmp, strerror(errno));
exit(1);
}
rmdir(tmp);
execl("/bin/mount", "/bin/mount", "-i", "-f", "-t", type, "-o", opts,
fsname, mnt, NULL);
fprintf(stderr, "%s: failed to execute /bin/mount: %s\n", progname,
strerror(errno));
exit(1);
}
res = waitpid(res, &status, 0);
if (res == -1) {
fprintf(stderr, "%s: waitpid: %s\n", progname, strerror(errno));
return -1;
}
if (status != 0)
return -1;
return 0;
}
int fuse_mnt_umount(const char *progname, const char *mnt, int lazy)
{
int res;
int status;
if (!mtab_needs_update(mnt)) {
res = umount2(mnt, lazy ? 2 : 0);
if (res == -1)
fprintf(stderr, "%s: failed to unmount %s: %s\n", progname,
mnt, strerror(errno));
return res;
}
res = fork();
if (res == -1) {
fprintf(stderr, "%s: fork: %s\n", progname, strerror(errno));
return -1;
}
if (res == 0) {
setuid(geteuid());
execl("/bin/umount", "/bin/umount", "-i", mnt, lazy ? "-l" : NULL,
NULL);
fprintf(stderr, "%s: failed to execute /bin/umount: %s\n", progname,
strerror(errno));
exit(1);
}
res = waitpid(res, &status, 0);
if (res == -1) {
fprintf(stderr, "%s: waitpid: %s\n", progname, strerror(errno));
return -1;
}
if (status != 0)
return -1;
return 0;
}
char *<API key>(const char *progname, const char *orig)
{
char buf[PATH_MAX];
char *copy;
char *dst;
char *end;
char *lastcomp;
const char *toresolv;
if (!orig[0]) {
fprintf(stderr, "%s: invalid mountpoint '%s'\n", progname, orig);
return NULL;
}
copy = strdup(orig);
if (copy == NULL) {
fprintf(stderr, "%s: failed to allocate memory\n", progname);
return NULL;
}
toresolv = copy;
lastcomp = NULL;
for (end = copy + strlen(copy) - 1; end > copy && *end == '/'; end
if (end[0] != '/') {
char *tmp;
end[1] = '\0';
tmp = strrchr(copy, '/');
if (tmp == NULL) {
lastcomp = copy;
toresolv = ".";
} else {
lastcomp = tmp + 1;
if (tmp == copy)
toresolv = "/";
}
if (strcmp(lastcomp, ".") == 0 || strcmp(lastcomp, "..") == 0) {
lastcomp = NULL;
toresolv = copy;
}
else if (tmp)
tmp[0] = '\0';
}
if (realpath(toresolv, buf) == NULL) {
fprintf(stderr, "%s: bad mount point %s: %s\n", progname, orig,
strerror(errno));
free(copy);
return NULL;
}
if (lastcomp == NULL)
dst = strdup(buf);
else {
dst = (char *) malloc(strlen(buf) + 1 + strlen(lastcomp) + 1);
if (dst) {
unsigned buflen = strlen(buf);
if (buflen && buf[buflen-1] == '/')
sprintf(dst, "%s%s", buf, lastcomp);
else
sprintf(dst, "%s/%s", buf, lastcomp);
}
}
free(copy);
if (dst == NULL)
fprintf(stderr, "%s: failed to allocate memory\n", progname);
return dst;
}
int <API key>(void)
{
char buf[256];
FILE *f = fopen("/proc/filesystems", "r");
if (!f)
return 1;
while (fgets(buf, sizeof(buf), f))
if (strstr(buf, "fuseblk\n")) {
fclose(f);
return 1;
}
fclose(f);
return 0;
} |
#include "Spectrum.h"
#include "Spectrogram.h"
autoSpectrum <API key> (Spectrogram me, double time);
/*
Function:
Create a time slice from the Spectrogram at the time nearest to 'time'.
Postconditions:
result -> xmin == my ymin; // Lowest frequency; often 0.
result -> xmax == my ymax; // Highest frequency.
result -> nx == my ny; // Number of frequency bands.
result -> dx == my dy; // Frequency step.
result -> x1 == my y1; // Centre of first frequency band.
for (iy = 1; iy <= my ny; iy ++) {
result -> z [1] [i] == sqrt (my z [i] ['time']);
result -> z [2] [i] == 0.0;
}
*/
autoSpectrogram <API key> (Spectrum me);
/*
Function:
Create a Spectrogram with one time slice from the Spectrum.
Postconditions:
thy xmin = 0.0; thy ymin == my xmin;
thy xmax = 1.0; thy ymax == my xmax;
thy nx == 1; thy ny == my nx;
thy dx == 1.0; thy dy == my dx;
thy x1 == 0.5; thy y1 == my x1;
for (i = 1; i <= my nx; i ++)
thy z [i] [1] == (my z [1] [i]) ^ 2 + (my z [2] [i]) ^ 2;
*/
/* End of file <API key>.h */ |
#include "callback.h"
#include "access.h"
#include <cdio/version.h>
#if LIBCDIO_VERSION_NUM >= 72
static char *psz_paranoia_list[] = { "none", "overlap", "full" };
static char *<API key>[] = { N_("none"), N_("overlap"),
N_("full") };
#endif
#define DEBUG_LONGTEXT N_( \
"This integer when viewed in binary is a debugging mask\n" \
"meta info 1\n" \
"events 2\n" \
"MRL 4\n" \
"external call 8\n" \
"all calls (0x10) 16\n" \
"LSN (0x20) 32\n" \
"seek (0x40) 64\n" \
"libcdio (0x80) 128\n" \
"libcddb (0x100) 256\n" )
#define CACHING_LONGTEXT N_( \
"Caching value for CDDA streams. This " \
"value should be set in millisecond units." )
#define <API key> N_( \
"How many CD blocks to get on a single CD read. " \
"Generally on newer/faster CDs, this increases throughput at the " \
"expense of a little more memory usage and initial delay. SCSI-MMC " \
"limitations generally don't allow for more than 25 blocks per access.")
#define <API key> N_( \
"Format used in the GUI Playlist Title. Similar to the Unix date \n" \
"Format specifiers that start with a percent sign. Specifiers are: \n" \
" %a : The artist (for the album)\n" \
" %A : The album information\n" \
" %C : Category\n" \
" %e : The extended data (for a track)\n" \
" %I : CDDB disk ID\n" \
" %G : Genre\n" \
" %M : The current MRL\n" \
" %m : The CD-DA Media Catalog Number (MCN)\n" \
" %n : The number of tracks on the CD\n" \
" %p : The artist/performer/composer in the track\n" \
" %T : The track number\n" \
" %s : Number of seconds in this track\n" \
" %S : Number of seconds in the CD\n" \
" %t : The track title or MRL if no title\n" \
" %Y : The year 19xx or 20xx\n" \
" %% : a % \n")
#define TITLE_FMT_LONGTEXT N_( \
"Format used in the GUI Playlist Title. Similar to the Unix date \n" \
"Format specifiers that start with a percent sign. Specifiers are: \n" \
" %M : The current MRL\n" \
" %m : The CD-DA Media Catalog Number (MCN)\n" \
" %n : The number of tracks on the CD\n" \
" %T : The track number\n" \
" %s : Number of seconds in this track\n" \
" %S : Number of seconds in the CD\n" \
" %t : The track title or MRL if no title\n" \
" %% : a % \n")
#define PARANOIA_TEXT N_("Enable CD paranoia?")
#define PARANOIA_LONGTEXT N_( \
"Select whether to use CD Paranoia for jitter/error correction.\n" \
"none: no paranoia - fastest.\n" \
"overlap: do only overlap detection - not generally recommended.\n" \
"full: complete jitter and error correction detection - slowest.\n" )
vlc_module_begin();
add_usage_hint( N_("cddax://[device-or-file][@[T]track]") );
set_description( _("Compact Disc Digital Audio (CD-DA) input") );
set_capability( "access2", 10 /* compare with priority of cdda */ );
set_shortname( _("Audio Compact Disc"));
set_callbacks( CDDAOpen, CDDAClose );
add_shortcut( "cddax" );
add_shortcut( "cd" );
set_category( CAT_INPUT );
set_subcategory( SUBCAT_INPUT_ACCESS );
/* Configuration options */
add_integer ( MODULE_STRING "-debug", 0, CDDADebugCB,
N_("Additional debug"),
DEBUG_LONGTEXT, VLC_TRUE );
add_integer( MODULE_STRING "-caching",
DEFAULT_PTS_DELAY / <API key>, NULL,
N_("Caching value in microseconds"),
CACHING_LONGTEXT, VLC_TRUE );
add_integer( MODULE_STRING "-blocks-per-read",
<API key>, CDDABlocksPerReadCB,
N_("Number of blocks per CD read"),
<API key>, VLC_TRUE );
add_string( MODULE_STRING "-title-format",
"Track %T. %t", NULL,
N_("Format to use in playlist \"title\" field when no CDDB"),
TITLE_FMT_LONGTEXT, VLC_TRUE );
#if LIBCDIO_VERSION_NUM >= 73
add_bool( MODULE_STRING "-analog-output", VLC_FALSE, NULL,
N_("Use CD audio controls and output?"),
N_("If set, audio controls and audio jack output are used"),
VLC_FALSE );
#endif
add_bool( MODULE_STRING "-cdtext-enabled", VLC_TRUE, CDTextEnabledCB,
N_("Do CD-Text lookups?"),
N_("If set, get CD-Text information"),
VLC_FALSE );
add_bool( MODULE_STRING "-navigation-mode", VLC_TRUE,
#if FIXED
CDDANavModeCB,
#else
NULL,
#endif
N_("Use Navigation-style playback?"),
N_("Tracks are navigated via Navagation rather than "
"a playlist entries"),
VLC_FALSE );
#if LIBCDIO_VERSION_NUM >= 72
add_string( MODULE_STRING "-paranoia", NULL, NULL,
PARANOIA_TEXT,
PARANOIA_LONGTEXT,
VLC_FALSE );
change_string_list( psz_paranoia_list, <API key>, 0 );
#endif /* LIBCDIO_VERSION_NUM >= 72 */
#ifdef HAVE_LIBCDDB
set_section( N_("CDDB" ), 0 );
add_string( MODULE_STRING "-cddb-title-format",
"Track %T. %t - %p %A", NULL,
N_("Format to use in playlist \"title\" field when using CDDB"),
<API key>, VLC_TRUE );
add_bool( MODULE_STRING "-cddb-enabled", VLC_TRUE, CDDBEnabledCB,
N_("CDDB lookups"),
N_("If set, lookup CD-DA track information using the CDDB "
"protocol"),
VLC_FALSE );
add_string( MODULE_STRING "-cddb-server", "freedb.freedb.org", NULL,
N_("CDDB server"),
N_( "Contact this CDDB server look up CD-DA information"),
VLC_TRUE );
add_integer( MODULE_STRING "-cddb-port", 8880, NULL,
N_("CDDB server port"),
N_("CDDB server uses this port number to communicate on"),
VLC_TRUE );
add_string( MODULE_STRING "-cddb-email", "me@home", NULL,
N_("email address reported to CDDB server"),
N_("email address reported to CDDB server"),
VLC_TRUE );
add_bool( MODULE_STRING "-cddb-enable-cache", VLC_TRUE, NULL,
N_("Cache CDDB lookups?"),
N_("If set cache CDDB information about this CD"),
VLC_FALSE );
add_bool( MODULE_STRING "-cddb-httpd", VLC_FALSE, NULL,
N_("Contact CDDB via the HTTP protocol?"),
N_("If set, the CDDB server gets information via the CDDB HTTP "
"protocol"),
VLC_TRUE );
add_integer( MODULE_STRING "-cddb-timeout", 10, NULL,
N_("CDDB server timeout"),
N_("Time (in seconds) to wait for a response from the "
"CDDB server"),
VLC_FALSE );
add_string( MODULE_STRING "-cddb-cachedir", "~/.cddbslave", NULL,
N_("Directory to cache CDDB requests"),
N_("Directory to cache CDDB requests"),
VLC_TRUE );
add_bool( MODULE_STRING "-cdtext-prefer", VLC_TRUE, CDTextPreferCB,
N_("Prefer CD-Text info to CDDB info?"),
N_("If set, CD-Text information will be preferred "
"to CDDB information when both are available"),
VLC_FALSE );
#endif /*HAVE_LIBCDDB*/
vlc_module_end(); |
<!DOCTYPE html PUBLIC "-
<html xmlns="http:
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Tamil Romanised Bible</title>
<link rel="stylesheet" type="text/css" href="../../../style.css" />
</head>
<body>
<div><h3 id="3jo">3 yoavaan</h3>
<h4 class="center hide-this">Navigation</h4>
<p class="title-nav hide-this"><span class="left-book"><a href="2-john-intro.html"><< 2 John</a></span><br /><span class="right-book"><a href="jude-intro.html">Jude >></a></span></p><p class="title-nav"><span class="left-pos"><a href="2-john.html#2jo-ch1"><<</a> </span><span class="tn-heading"><a href="toc.html">Table of Contents</a></span><span class="right-pos"> <a href="3-john.html#3jo-ch1">>></a></span></p>
<h4 class="center">Chapters</h4>
<p class="ch-nav"><span> <a href="3-john.html#3jo-ch1">1</a> </span> </p></div></body></html> |
<header id="header">
</header>
<form name="form" ng-submit="doLogin()" role="form">
<h3 class="<API key>">Please sign in</h3>
<div ng-show="error" class="alert alert-danger">{{error}}</div>
<div class="form-group">
<label for="username">Username</label>
<i class="fa fa-key"></i>
<input type="text" name="username" id="username" class="form-control" ng-model="username" required />
<span ng-show="form.username.$dirty && form.username.$error.required" class="help-block">Username is required</span>
</div>
<div class="form-group">
<label for="password">Password</label>
<i class="fa fa-lock"></i>
<input type="password" name="password" id="password" class="form-control" ng-model="password" required />
<span ng-show="form.password.$dirty && form.password.$error.required" class="help-block">Password is required</span>
</div>
<div class="form-actions">
<button type="submit" ng-disabled="form.$invalid || dataLoading" class="btn btn-danger">Login</button>
<p class="text-center" ng-show="loading">
<span class="fa fa-spinner fa-spin fa-3x"></span>
</p>
</div>
</form> |
<?php
require_once plugin_dir_path( __FILE__ ) . '../public/<API key>.php';
require_once plugin_dir_path( __FILE__ ) . '<API key>.php';
class <API key> extends <API key> {
const <API key> = '<API key>';
const <API key> = '<API key>';
const SETTINGS_FORM = 'fbrfg_settings_form';
protected static $instance = null;
private function __construct() {
add_action( 'init', array( $this, '<API key>' ) );
add_action( 'admin_head', array( $this, 'add_favicon_markups' ) );
// Deactivate Genesis default favicon
add_filter( '<API key>', array( $this, '<API key>' ) );
// See
// The idea: is_super_admin must not be called too soon.
add_action( 'init', array( $this, '<API key>' ) );
}
/**
* Return an instance of this class.
*
* @since 1.0
*
* @return object A single instance of this class.
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
public function <API key>() {
// Except for the headers, everything is accessible only to the admin
if ( ! is_super_admin() ) {
return;
}
add_action( 'admin_menu',
array( $this, '<API key>' ) );
add_action('wp_ajax_' . <API key>::PLUGIN_PREFIX . '<API key>',
array( $this, 'install_new_favicon' ) );
add_action('wp_ajax_nopriv_' . <API key>::PLUGIN_PREFIX . '<API key>',
array( $this, 'install_new_favicon' ) );
// Update notice
add_action('admin_notices', array( $this, '<API key>' ) );
add_action('admin_init', array( $this, '<API key>' ) );
// Schedule update check
if ( ! wp_next_scheduled( <API key>::<API key> ) ) {
wp_schedule_event( time(), 'daily', <API key>::<API key> );
}
}
public function <API key>() {
add_theme_page( __( 'Favicon', <API key>::PLUGIN_SLUG ),
__( 'Favicon', <API key>::PLUGIN_SLUG ), 'manage_options', __FILE__ . '<API key>',
array( $this, '<API key>' ) );
add_options_page( __( 'Favicon Settings', <API key>::PLUGIN_SLUG ),
__( 'Favicon', <API key>::PLUGIN_SLUG ), 'manage_options', __FILE__ . '<API key>',
array( $this, '<API key>' ) );
}
public function <API key>() {
global $current_user;
$user_id = $current_user->ID;
// Prepare variables
$<API key> = admin_url( 'themes.php?page=' . __FILE__ . '<API key>' );
$favicon_admin_url = admin_url( 'options-general.php?page=' . __FILE__ . '<API key>' );
$<API key> = ! $this-><API key>(
<API key>::<API key> );
// Template time!
include_once( plugin_dir_path(__FILE__) . 'views/settings.php' );
}
public function <API key>() {
$result = NULL;
// Prepare settings page
// Option to allow user to not use the Rewrite API: display it only when the Rewrite API is available
$can_rewrite = $this-><API key>();
$pic_path = $this-><API key>();
$favicon_configured = $this-><API key>();
$favicon_in_root = $this->is_favicon_in_root();
$preview_url = $this-><API key>() ? $this->get_preview_url() : NULL;
if ( isset( $_REQUEST['json_result_url'] ) ) {
// New favicon to install:
// Parameters will be processed with an Ajax call
$<API key> = 'http://<API key>.net' . $_REQUEST['json_result_url'];
$ajax_url = admin_url( 'admin-ajax.php', isset( $_SERVER['HTTPS'] ) ? 'https:
}
else {
// No new favicon, simply display the settings page
$<API key> = NULL;
}
// External files
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui' );
wp_enqueue_script( '<API key>' );
wp_enqueue_media();
wp_enqueue_style( 'fbrfg_admin_style', plugins_url( 'assets/css/admin.css', __FILE__ ) );
// Template time!
include_once( plugin_dir_path(__FILE__) . 'views/appearance.php' );
}
private function <API key>( $url ) {
$resp = wp_remote_get( $url );
if ( is_wp_error( $resp )) {
throw new <API key>( "Cannot download JSON file at " . $url . ": " . $resp->get_error_message() );
}
$json = <API key>( $resp );
if ( empty( $json ) ) {
throw new <API key>( "Empty JSON document at " . $url );
}
return $json;
}
public function install_new_favicon() {
header("Content-type: application/json");
try {
// URL is explicitely decoded to compensate the extra encoding performed while generating the settings page
$url = $_REQUEST['json_result_url'];
$result = $this-><API key>( $url );
$response = new <API key>( $result );
$zip_path = <API key>::get_tmp_dir();
if ( ! file_exists( $zip_path ) ) {
mkdir( $zip_path, 0755, true );
}
$response->downloadAndUnpack( $zip_path );
$this->store_pictures( $response );
$this->store_preview( $response->getPreviewPath() );
<API key>::remove_directory( $zip_path );
update_option( <API key>::OPTION_HTML_CODE, $response->getHtmlCode() );
$this-><API key>( true, $response->isFilesInRoot(), $response->getVersion() );
?>
{
"status": "success",
"preview_url": <?php echo json_encode( $this->get_preview_url() ) ?>,
"favicon_in_root": <?php echo json_encode( $this->is_favicon_in_root() ) ?>
}
<?php
}
catch(Exception $e) {
?>
{
"status": "error",
"message": <?php echo json_encode( $e->getMessage() ) ?>
}
<?php
}
die();
}
public function get_picture_dir() {
return <API key>::get_files_dir();
}
/**
* Returns http//somesite.com/blog/wp-content/upload/fbrfg/
*/
public function get_picture_url() {
return <API key>::get_files_url();
}
/**
* Returns /blog/wp-content/upload/fbrfg/
*/
public function <API key>() {
return parse_url( $this->get_picture_url(), PHP_URL_PATH );
}
/**
* Returns wp-content/upload/fbrfg/
*/
public function get_picture_path() {
return substr( $this->get_picture_url(), strlen( home_url() ) );
}
public function get_preview_path( $preview_file_name = NULL ) {
if ( ! $preview_file_name ) {
$preview_file_name = $this-><API key>();
}
return $this->get_picture_dir() . 'preview/' . $preview_file_name;
}
public function get_preview_url( $preview_file_name = NULL ) {
if ( ! $preview_file_name ) {
$preview_file_name = $this-><API key>();
}
return $this->get_picture_url() . '/preview/' . $preview_file_name;
}
public function store_preview( $preview_path ) {
// Remove previous preview, if any
$previous_preview = $this-><API key>();
if ( $previous_preview != NULL && ( file_exists( $this->get_preview_path( $previous_preview ) ) ) ) {
unlink( $this->get_preview_path( $previous_preview ) );
}
if ( $preview_path == NULL ) {
// "Unregister" previous preview, if any
$this-><API key>( NULL );
return NULL;
}
else {
$preview_file_name = 'preview_' . md5( 'RFB stuff here ' . rand() . microtime() ) . '.png';
}
if ( ! file_exists( dirname( $this->get_preview_path( $preview_file_name ) ) ) ) {
mkdir( dirname( $this->get_preview_path( $preview_file_name ) ), 0755 );
}
rename( $preview_path, $this->get_preview_path( $preview_file_name ) );
$this-><API key>( $preview_file_name );
}
public function store_pictures( $rfg_response ) {
$working_dir = $this->get_picture_dir();
// Move pictures to production directory
$files = glob( $working_dir . '*' );
foreach( $files as $file ) {
if ( is_file( $file ) ) {
unlink( $file );
}
}
/**
* Indicate if it is possible to create URLs such as /favicon.ico
*/
public function <API key>() {
global $wp_rewrite;
// Due to too many problems with the rewrite API (for example, http://wordpress.org/support/topic/do-not-work-8?replies=3#post-),
// it was deciced to turn the feature off once for all
return false;
// we can produce URLs such as /favicon.ico
// $rewrite = ( $this->wp_in_root() && $wp_rewrite->using_permalinks() );
// if ( ! $rewrite ) {
// return false;
// $htaccess = get_home_path() . '/.htaccess';
// Two cases:
// - There is no .htaccess. Either we are not using Apache (so the Rewrite API is supposed to handle
// the rewriting differently) or there is a problem with Apache/WordPress config, but this is not our job.
// - .htaccess is present. If so, it should be writable.
// return ( ( ! file_exists( $htaccess ) ) || is_writable( $htaccess ) );
}
public function wp_in_root() {
$path = parse_url( home_url(), PHP_URL_PATH );
return ( ($path == NULL) || (strlen( $path ) == 0) );
}
public function <API key>( $option_name, $option_value ) {
global $current_user;
$user_id = $current_user->ID;
update_user_option( $user_id, $option_name, $option_value );
}
public function <API key>( $option_name ) {
global $current_user;
$user_id = $current_user->ID;
return get_user_option( $option_name );
}
public function <API key>() {
// No update? No notice
if ( ! $this->is_update_available() ) {
return false;
}
// Did the user prevent all notices?
if ( $this-><API key>( <API key>::<API key> . $this-><API key>() ) ) {
return false;
}
// Did the user prevent the notice for this particular version?
if ( $this-><API key>( <API key>::<API key> ) ) {
return false;
}
return true;
}
public function <API key>() {
if ( $this-><API key>() ) {
echo '<div class="update-nag">';
printf( __( '<a href="%s" target="_blank">An update is available</a> on <API key>. You might want to <a href="%s">generate your favicon again</a>.', FBRFG_PLUGIN_SLUG ),
'http://<API key>.net/change_log?since='. $this->get_favicon_version(),
admin_url( 'themes.php?page=' . __FILE__ . '<API key>') );
printf( __( ' | <a href="%s">Hide this notice</a>', FBRFG_PLUGIN_SLUG),
$this-><API key>( <API key>::<API key> . '=0' ) );
printf( __( ' | <a href="%s">Do not warn me again in case of update</a>', FBRFG_PLUGIN_SLUG),
$this-><API key>( <API key>::<API key> . '=0' ) );
echo '</div>';
}
}
public function <API key>() {
global $current_user;
$user_id = $current_user->ID;
if ( isset( $_REQUEST[<API key>::<API key>] ) &&
'0' == $_REQUEST[<API key>::<API key>] ) {
$this-><API key>( <API key>::<API key> . $this-><API key>(), true );
}
$no_notices = NULL;
if ( ( isset( $_REQUEST[<API key>::<API key>] ) &&
'0' == $_REQUEST[<API key>::<API key>] ) ) {
// The "no more notifications" link was clicked in the notification itself
$no_notices = true;
}
if ( isset( $_REQUEST[<API key>::SETTINGS_FORM] ) &&
'1' == $_REQUEST[<API key>::SETTINGS_FORM] ) {
// The settings form was validated
$no_notices = ( ! isset( $_REQUEST[<API key>::<API key>] ) ||
( '0' == $_REQUEST[<API key>::<API key>] ) );
}
if ( $no_notices !== NULL ) {
$this-><API key>( <API key>::<API key>, $no_notices );
}
}
}
?> |
<?php
defined('_JEXEC') or die('Restricted access');
?><?php
class acyslidersHelper {
var $ctrl = 'sliders';
var $tabs = null;
var $openPanel = false;
var $mode = null;
var $count = 0;
var $name = '';
var $options = null;
function __construct() {
if(!ACYMAILING_J16) {
$this->mode = 'pane';
} elseif(!ACYMAILING_J30) {
$this->mode = 'sliders';
} else {
$this->mode = 'bootstrap';
}
}
function startPane($name) { return $this->start($name); }
function startPanel($text, $id) { return $this->panel($text, $id); }
function endPanel() { return ''; }
function endPane() { return $this->end(); }
function setOptions($options = array()) {
if($this->options == null)
$this->options = $options;
else
$this->options = array_merge($this->options, $options);
}
function start($name, $options = array()) {
$ret = '';
if($this->mode == 'pane') {
jimport('joomla.html.pane');
if(!empty($this->options))
$options = array_merge($options, $this->options);
$this->tabs = JPane::getInstance('sliders', $options);
$ret .= $this->tabs->startPane($name);
} elseif($this->mode == 'sliders') {
if(!empty($this->options))
$options = array_merge($options, $this->options);
$ret .= JHtml::_('sliders.start', $name, $options);
} else {
if($this->options == null)
$this->options = $options;
else
$this->options = array_merge($this->options, $options);
$this->name = $name;
$this->count = 0;
$ret .= '<div class="accordion" id="'.$name.'">';
}
return $ret;
}
function panel($text, $id) {
$ret = '';
if($this->mode == 'pane') {
if($this->openPanel)
$ret .= $this->tabs->endPanel();
$ret .= $this->tabs->startPanel($text, $id);
$this->openPanel = true;
} elseif($this->mode == 'sliders') {
$ret .= JHtml::_('sliders.panel', JText::_($text), $id);
} else {
if($this->openPanel)
$ret .= $this->_closePanel();
$open = '';
if((isset($this->options['startOffset']) && $this->options['startOffset'] == $this->count) || $this->count == 0)
$open = ' in';
$this->count++;
$ret .= '
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#'.$this->name.'" href="#'.$id.'">
'.$text.'
</a>
</div>
<div id="'.$id.'" class="accordion-body collapse'.$open.'">
<div class="accordion-inner">
';
$this->openPanel = true;
}
return $ret;
}
function _closePanel() {
if(!$this->openPanel)
return '';
$this->openPanel = false;
return '</div></div></div>';
}
function end() {
$ret = '';
if($this->mode == 'pane') {
if($this->openPanel)
$ret .= $this->tabs->endPanel();
$ret .= $this->tabs->endPane();
} elseif($this->mode == 'sliders') {
$ret .= JHtml::_('sliders.end');
} else {
if($this->openPanel)
$ret .= $this->_closePanel();
$ret .= '</div>';
}
return $ret;
}
} |
<?php
/**
* Include parent class
*/
require_once("class.Bootstrap.php");
class <API key> extends <API key> {
function show() {
$dms = $this->params['dms'];
$user = $this->params['user'];
$logfileenable = $this->params['logfileenable'];
$enablefullsearch = $this->params['enablefullsearch'];
$this->htmlStartPage(getMLText("admin_tools"));
$this->globalNavigation();
$this->contentStart();
$this->pageNavigation(getMLText("admin_tools"), "admin_tools");
// $this->contentHeading(getMLText("admin_tools"));
$this-><API key>();
?>
<div id="admin-tools">
<div class="row-fluid">
<a href="../out/out.UsrMgr.php" class="span3 btn btn-medium"><i class="icon-user"></i><br /><?php echo getMLText("user_management")?></a>
<a href="../out/out.GroupMgr.php" class="span3 btn btn-medium"><i class="icon-group"></i><br /><?php echo getMLText("group_management")?></a>
</div>
<p></p>
<div class="row-fluid">
<a href="../out/out.BackupTools.php" class="span3 btn btn-medium"><i class="icon-hdd"></i><br /><?php echo getMLText("backup_tools")?></a>
<?php
if ($logfileenable)
echo "<a href=\"../out/out.LogManagement.php\" class=\"span3 btn btn-medium\"><i class=\"icon-list\"></i><br />".getMLText("log_management")."</a>";
?>
</div>
<p></p>
<div class="row-fluid">
<a href="../out/out.DefaultKeywords.php" class="span3 btn btn-medium"><i class="icon-reorder"></i><br /><?php echo getMLText("<API key>")?></a>
<a href="../out/out.Categories.php" class="span3 btn btn-medium"><i class="icon-columns"></i><br /><?php echo getMLText("<API key>")?></a>
<a href="../out/out.AttributeMgr.php" class="span3 btn btn-medium"><i class="icon-tags"></i><br /><?php echo getMLText("<API key>")?></a>
</div>
<?php
if($this->params['workflowmode'] != 'traditional') {
?>
<p></p>
<div class="row-fluid">
<a href="../out/out.WorkflowMgr.php" class="span3 btn btn-medium"><i class="icon-sitemap"></i><br /><?php echo getMLText("global_workflows"); ?></a>
<a href="../out/out.WorkflowStatesMgr.php" class="span3 btn btn-medium"><i class="icon-star"></i><br /><?php echo getMLText("<API key>"); ?></a>
<a href="../out/out.WorkflowActionsMgr.php" class="span3 btn btn-medium"><i class="icon-bolt"></i><br /><?php echo getMLText("<API key>"); ?></a>
</div>
<?php
}
if($enablefullsearch) {
?>
<p></p>
<div class="row-fluid">
<a href="../out/out.Indexer.php" class="span3 btn btn-medium"><i class="icon-refresh"></i><br /><?php echo getMLText("<API key>")?></a>
<a href="../out/out.CreateIndex.php" class="span3 btn btn-medium"><i class="icon-search"></i><br /><?php echo getMLText("<API key>")?></a>
<a href="../out/out.IndexInfo.php" class="span3 btn btn-medium"><i class="icon-info-sign"></i><br /><?php echo getMLText("fulltext_info")?></a>
</div>
<?php
}
?>
<p></p>
<div class="row-fluid">
<a href="../out/out.Statistic.php" class="span3 btn btn-medium"><i class="icon-tasks"></i><br /><?php echo getMLText("<API key>")?></a>
<a href="../out/out.ObjectCheck.php" class="span3 btn btn-medium"><i class="icon-check"></i><br /><?php echo getMLText("objectcheck")?></a>
<a href="../out/out.Info.php" class="span3 btn btn-medium"><i class="icon-info-sign"></i><br /><?php echo getMLText("version_info")?></a>
</div>
<p></p>
<div class="row-fluid">
<a href="../out/out.Settings.php" class="span3 btn btn-medium"><i class="icon-cogs"></i><br /><?php echo getMLText("settings")?></a>
</div>
</div>
<?php
$this->contentContainerEnd();
$this->htmlEndPage();
}
}
?> |
/**
* @file maxinfo_parse.c - Parse the limited set of SQL that the MaxScale
* information schema can use
*
* @verbatim
* Revision History
*
* Date Who Description
* 16/02/15 Mark Riddoch Initial implementation
*
* @endverbatim
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <service.h>
#include <session.h>
#include <router.h>
#include <modules.h>
#include <modinfo.h>
#include <modutil.h>
#include <atomic.h>
#include <spinlock.h>
#include <dcb.h>
#include <poll.h>
#include <maxinfo.h>
#include <skygw_utils.h>
#include <log_manager.h>
static MAXINFO_TREE *make_tree_node(MAXINFO_OPERATOR, char *, MAXINFO_TREE *, MAXINFO_TREE *);
static void free_tree(MAXINFO_TREE *);
static char *fetch_token(char *, int *, char **);
static MAXINFO_TREE *parse_column_list(char **sql);
static MAXINFO_TREE *parse_table_name(char **sql);
MAXINFO_TREE* <API key>(MAXINFO_TREE *tree, int min_args, char *ptr,
PARSE_ERROR *parse_error);
/**
* Parse a SQL subset for the maxinfo plugin and return a parse tree
*
* @param sql The SQL query
* @return Parse tree or NULL on error
*/
MAXINFO_TREE *
maxinfo_parse(char *sql, PARSE_ERROR *parse_error)
{
int token;
char *ptr, *text;
MAXINFO_TREE *tree = NULL;
MAXINFO_TREE *col, *table;
*parse_error = PARSE_NOERROR;
while ((ptr = fetch_token(sql, &token, &text)) != NULL)
{
switch (token)
{
case LT_SHOW:
free(text); // not needed
ptr = fetch_token(ptr, &token, &text);
if (ptr == NULL || token != LT_STRING)
{
// Expected show "name"
*parse_error = <API key>;
return NULL;
}
tree = make_tree_node(MAXOP_SHOW, text, NULL, NULL);
if ((ptr = fetch_token(ptr, &token, &text)) == NULL)
return tree;
else if (token == LT_LIKE)
{
if ((ptr = fetch_token(ptr, &token, &text)) != NULL)
{
tree->right = make_tree_node(MAXOP_LIKE,
text, NULL, NULL);
return tree;
}
else
{
// Expected expression
*parse_error = PARSE_EXPECTED_LIKE;
free_tree(tree);
return NULL;
}
}
// Malformed show
free(text);
free_tree(tree);
*parse_error = <API key>;
return NULL;
#if 0
case LT_SELECT:
free(text); // not needed
col = parse_column_list(&ptr);
table = parse_table_name(&ptr);
return make_tree_node(MAXOP_SELECT, NULL, col, table);
#endif
case LT_FLUSH:
free(text); // not needed
ptr = fetch_token(ptr, &token, &text);
return make_tree_node(MAXOP_FLUSH, text, NULL, NULL);
case LT_SHUTDOWN:
free(text);
ptr = fetch_token(ptr, &token, &text);
tree = make_tree_node(MAXOP_SHUTDOWN, text, NULL, NULL);
if ((ptr = fetch_token(ptr, &token, &text)) == NULL)
{
/** Possibly SHUTDOWN MAXSCALE */
return tree;
}
tree->right = make_tree_node(MAXOP_LITERAL, text, NULL, NULL);
if ((ptr = fetch_token(ptr, &token, &text)) != NULL)
{
/** Unknown token after SHUTDOWN MONITOR|SERVICE */
*parse_error = PARSE_SYNTAX_ERROR;
free_tree(tree);
return NULL;
}
return tree;
case LT_RESTART:
free(text);
ptr = fetch_token(ptr, &token, &text);
tree = make_tree_node(MAXOP_RESTART, text, NULL, NULL);
if ((ptr = fetch_token(ptr, &token, &text)) == NULL)
{
/** Missing token for RESTART MONITOR|SERVICE */
*parse_error = PARSE_SYNTAX_ERROR;
free_tree(tree);
return NULL;
}
tree->right = make_tree_node(MAXOP_LITERAL, text, NULL, NULL);
if ((ptr = fetch_token(ptr, &token, &text)) != NULL)
{
/** Unknown token after RESTART MONITOR|SERVICE */
*parse_error = PARSE_SYNTAX_ERROR;
free_tree(tree);
return NULL;
}
return tree;
case LT_SET:
free(text); // not needed
ptr = fetch_token(ptr, &token, &text);
tree = make_tree_node(MAXOP_SET, text, NULL, NULL);
return <API key>(tree, 2, ptr, parse_error);
case LT_CLEAR:
free(text); // not needed
ptr = fetch_token(ptr, &token, &text);
tree = make_tree_node(MAXOP_CLEAR, text, NULL, NULL);
return <API key>(tree, 2, ptr, parse_error);
break;
default:
*parse_error = PARSE_SYNTAX_ERROR;
return NULL;
}
}
*parse_error = PARSE_SYNTAX_ERROR;
return NULL;
}
/**
* Parse a column list, may be a * or a valid list of string name
* separated by a comma
*
* @param sql Pointer to pointer to column list updated to point to the table name
* @return A tree of column names
*/
static MAXINFO_TREE *
parse_column_list(char **ptr)
{
int token, lookahead;
char *text, *text2;
MAXINFO_TREE *tree = NULL;
MAXINFO_TREE * rval = NULL;
*ptr = fetch_token(*ptr, &token, &text);
*ptr = fetch_token(*ptr, &lookahead, &text2);
switch (token)
{
case LT_STRING:
switch (lookahead)
{
case LT_COMMA:
rval = make_tree_node(MAXOP_COLUMNS, text, NULL,
parse_column_list(ptr));
break;
case LT_FROM:
rval = make_tree_node(MAXOP_COLUMNS, text, NULL,
NULL);
break;
default:
break;
}
break;
case LT_STAR:
if (lookahead != LT_FROM)
rval = make_tree_node(MAXOP_ALL_COLUMNS, NULL, NULL,
NULL);
break;
default:
break;
}
free(text);
free(text2);
return rval;
}
/**
* Parse a table name
*
* @param sql Pointer to pointer to column list updated to point to the table name
* @return A tree of table names
*/
static MAXINFO_TREE *
parse_table_name(char **ptr)
{
int token;
char *text;
MAXINFO_TREE *tree = NULL;
*ptr = fetch_token(*ptr, &token, &text);
if (token == LT_STRING)
return make_tree_node(MAXOP_TABLE, text, NULL, NULL);
free(text);
return NULL;
}
/**
* Allocate and populate a parse tree node
*
* @param op The node operator
* @param value The node value
* @param left The left branch of the parse tree
* @param right The right branch of the parse tree
* @return The new parse tree node
*/
static MAXINFO_TREE *
make_tree_node(MAXINFO_OPERATOR op, char *value, MAXINFO_TREE *left, MAXINFO_TREE *right)
{
MAXINFO_TREE *node;
if ((node = (MAXINFO_TREE *)malloc(sizeof(MAXINFO_TREE))) == NULL)
return NULL;
node->op = op;
node->value = value;
node->left = left;
node->right = right;
return node;
}
/**
* Recusrsively free the storage associated with a parse tree
*
* @param tree The parse tree to free
*/
static void
free_tree(MAXINFO_TREE *tree)
{
if (tree->left)
free_tree(tree->left);
if (tree->right)
free_tree(tree->right);
if (tree->value)
free(tree->value);
free(tree);
}
/**
* The set of keywords known to the tokeniser
*/
static struct
{
char *text;
int token;
} keywords[] = {
{ "show", LT_SHOW},
{ "select", LT_SELECT},
{ "from", LT_FROM},
{ "like", LT_LIKE},
{ "=", LT_EQUAL},
{ ",", LT_COMMA},
{ "*", LT_STAR},
{ "flush", LT_FLUSH},
{ "set", LT_SET},
{ "clear", LT_CLEAR},
{ "shutdown", LT_SHUTDOWN},
{ "restart", LT_RESTART},
{ NULL, 0}
};
/**
* Limited SQL tokeniser. Understands a limited set of key words and
* quoted strings.
*
* @param sql The SQL to tokenise
* @param token The returned token
* @param text The matching text
* @return The next position to tokenise from
*/
static char *
fetch_token(char *sql, int *token, char **text)
{
char *s1, *s2, quote = '\0';
int i;
s1 = sql;
while (*s1 && isspace(*s1))
{
s1++;
}
if (quote == '\0' && (*s1 == '\'' || *s1 == '\"'))
{
quote = *s1++;
}
if (*s1 == '/' && *(s1 + 1) == '*')
{
s1 += 2;
// Skip the comment
do {
while (*s1 && *s1 != '*')
s1++;
} while (*(s1 + 1) && *(s1 + 1) != '/');
s1 += 2;
while (*s1 && isspace(*s1))
{
s1++;
}
if (quote == '\0' && (*s1 == '\'' || *s1 == '\"'))
{
quote = *s1++;
}
}
s2 = s1;
while (*s2)
{
if (quote == '\0' && (isspace(*s2)
|| *s2 == ',' || *s2 == '='))
break;
else if (quote == *s2)
{
break;
}
s2++;
}
if (*s1 == '@' && *(s1 + 1) == '@')
{
*text = strndup(s1 + 2, (s2 - s1) - 2);
*token = LT_VARIABLE;
return s2;
}
if (s1 == s2)
return NULL;
*text = strndup(s1, s2 - s1);
for (i = 0; keywords[i].text; i++)
{
if (strcasecmp(keywords[i].text, *text) == 0)
{
*token = keywords[i].token;
return s2;
}
}
*token = LT_STRING;
return s2;
}
/**
* Parse the remaining arguments as literals.
* @param tree Previous head of the parse tree
* @param min_args Minimum required number of arguments
* @param ptr Pointer to client command
* @param parse_error Pointer to parsing error to fill
* @return Parsed tree or NULL if parsing failed
*/
MAXINFO_TREE* <API key>(MAXINFO_TREE *tree, int min_args, char *ptr,
PARSE_ERROR *parse_error)
{
int token;
MAXINFO_TREE* node = tree;
char *text;
for(int i = 0; i < min_args; i++)
{
if((ptr = fetch_token(ptr, &token, &text)) == NULL ||
(node->right = make_tree_node(MAXOP_LITERAL, text, NULL, NULL)) == NULL)
{
*parse_error = PARSE_SYNTAX_ERROR;
free_tree(tree);
if(ptr)
{
free(text);
}
return NULL;
}
node = node->right;
}
return tree;
} |
// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
#ifndef <API key>$GetField__
#define <API key>$GetField__
#pragma interface
#include <java/lang/Object.h>
class java::io::ObjectInputStream$GetField : public ::java::lang::Object
{
public:
virtual ::java::io::ObjectStreamClass *<API key> () = 0;
virtual jboolean defaulted (::java::lang::String *) = 0;
virtual jboolean get (::java::lang::String *, jboolean) = 0;
virtual jchar get (::java::lang::String *, jchar) = 0;
virtual jbyte get (::java::lang::String *, jbyte) = 0;
virtual jshort get (::java::lang::String *, jshort) = 0;
virtual jint get (::java::lang::String *, jint) = 0;
virtual jlong get (::java::lang::String *, jlong) = 0;
virtual jfloat get (::java::lang::String *, jfloat) = 0;
virtual jdouble get (::java::lang::String *, jdouble) = 0;
virtual ::java::lang::Object *get (::java::lang::String *, ::java::lang::Object *) = 0;
ObjectInputStream$GetField ();
friend class <API key>$GetField;
static ::java::lang::Class class$;
};
#endif /* <API key>$GetField__ */ |
package com.prueba.model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
@Entity
@Table(name="NOVEDAD", schema = "michiros")
public class Novedad implements Serializable{
@Id
@Column(name="ID_NOVEDAD")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="NOVEDAD_SEQ")
@SequenceGenerator(name="NOVEDAD_SEQ" , sequenceName="SIB_SEQ_NOVEDAD" , allocationSize=1)
private int idNovedad;
@ManyToOne
@JoinColumn(name = "ID_EMPLEADO" , nullable = false)
private Empleado empleado;
@ManyToOne
@JoinColumn(name = "ID_VENTA" , nullable = false)
private Venta venta;
@ManyToOne
@JoinColumn(name = "ID_PRODUCTO" , nullable = false)
private Producto producto;
@ManyToOne
@JoinColumn(name = "ID_TIPO_NOVEDAD" , nullable = false)
private TipoNovedad tipoNovedad;
public int getIdNovedad() {
return idNovedad;
}
public void setIdNovedad(int idNovedad) {
this.idNovedad = idNovedad;
}
public Empleado getEmpleado() {
return empleado;
}
public void setEmpleado(Empleado empleado) {
this.empleado = empleado;
}
public Venta getVenta() {
return venta;
}
public void setVenta(Venta venta) {
this.venta = venta;
}
public Producto getProducto() {
return producto;
}
public void setProducto(Producto producto) {
this.producto = producto;
}
public TipoNovedad getTipoNovedad() {
return tipoNovedad;
}
public void setTipoNovedad(TipoNovedad tipoNovedad) {
this.tipoNovedad = tipoNovedad;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + idNovedad;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Novedad other = (Novedad) obj;
if (idNovedad != other.idNovedad)
return false;
return true;
}
@Override
public String toString() {
return "Novedad [idNovedad=" + idNovedad + "]";
}
} |
#ifndef CFICCALLBACK_H_
#define CFICCALLBACK_H_
#include <anyrpc/anyrpc.h>
#include <anyrpc/method.h>
#include "fic_decoder.h"
class CFICCallback: public anyrpc::Method
{
public:
CFICCallback(std::string const& name, std::string const& help, bool deleteOnRemove, FICDecoder* DABFICDecoder_);
virtual ~CFICCallback();
void Execute(anyrpc::Value& params, anyrpc::Value& result);
private:
FICDecoder* DABFICDecoder;
};
#endif /* CFICCALLBACK_H_ */ |
<?php
defined('_JEXEC') or die;
class PlgCaptchaNocaptcha extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.4
*/
protected $autoloadLanguage = true;
/**
* Initialise the captcha
*
* @param string $id The id of the field.
*
* @return boolean True on success, false otherwise
*
* @since 3.4
*/
public function onInit($id = 'dynamic_recaptcha_1')
{
$document = JFactory::getDocument();
$app = JFactory::getApplication();
JHtml::_('jquery.framework');
$public_key = $this->params->get('public_key', '');
$theme = $this->params->get('theme', 'light');
if ($public_key == null || $public_key == '')
{
throw new Exception(JText::_('<API key>'));
}
$file = $app->isSSLConnection() ? 'https' : 'http';
$file .= ':
->getTag() . '&onload=onloadCallback&render=explicit';
JHtml::_('script', $file, true, true);
$document-><API key>('var onloadCallback = function() {'
. 'grecaptcha.render("' . $id . '", {sitekey: "' . $public_key . '", theme: "' . $theme . '"});'
. '}'
);
return true;
}
/**
* Gets the challenge HTML
*
* @param string $name The name of the field.
* @param string $id The id of the field.
* @param string $class The class of the field. This should be passed as
* e.g. 'class="required"'.
*
* @return string The HTML to be embedded in the form.
*
* @since 3.4
*/
public function onDisplay($name, $id = 'dynamic_recaptcha_1', $class = '')
{
return '<div id="' . $id . '" ' . $class . '></div>';
}
/**
* Calls an HTTP POST function to verify if the user's guess was correct
*
* @param string $code Answer provided by user.
*
* @return True if the answer is correct, false otherwise
*
* @since 3.4
*/
public function onCheckAnswer($code)
{
$input = JFactory::getApplication()->input;
$privatekey = $this->params->get('private_key');
$remoteip = $input->server->get('REMOTE_ADDR', '', 'string');
$response = $input->get('<API key>', '', 'string');
// Check for Private Key
if (empty($privatekey))
{
$this->_subject->setError(JText::_('<API key>'));
return false;
}
// Check for IP
if (empty($remoteip))
{
$this->_subject->setError(JText::_('<API key>'));
return false;
}
// Discard spam submissions
if ($response == null || strlen($response) == 0)
{
$this->_subject->setError(JText::_('<API key>'));
return false;
}
require_once 'recaptchalib.php';
$reCaptcha = new JReCaptcha($privatekey);
$response = $reCaptcha->verifyResponse($remoteip, $response);
if ( !isset($response->success) || !$response->success)
{
// @todo use exceptions here
foreach ($response->errorCodes as $error)
{
$this->_subject->setError($error);
}
return false;
}
return true;
}
} |
<?php
namespace AppBundle\Service;
/**
* Defines an interface to get date from the remote url
*/
interface UrlHttpInterface{
/**
* Get the body of the remote url
* @param [type] $url the remote url
* @return [type] the body of the remote document
*/
public function getBody($url);
/**
* Get the headers of the remote url
* the expected format is as follows:
* $result = array();
* $result['Url'] = $url;
* $result['Type'] = "";
* $result['SubType'] = "";
* $result['Size'] = 0;
* @param [type] $url the remote url
* @return [type] an array containing the headers
*/
public function getHeaders($url);
/**
* Find the absolute url from an url and it's base url
* Basically should clean up $url and compose it with the baseUrl if it's a relative url
* @param [type] $url the target url, can be relative or absolute
* @param [type] $baseUrl the base url for the url
* @return [type] the calculated absolute url
*/
public function urlToAbsolute($url,$baseUrl);
} |
Short, high-level description of algorithm. Brief summary of chaffing stuff.
\subsection*{Chaffing Strategies}
We chaff.\\
List strategies here:\\
\begin{enumerate}
\item \textbf{Strategy 1.} We do this and that.
\item \textbf{Strategy 2.} We do that and this.
\end{enumerate}
\subsection*{Strategy Analysis}
Some seem good. Some seem less good.
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "mics_paper"
%%% End: |
EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS)
EXTRA_CFLAGS += -O1
#EXTRA_CFLAGS += -O3
#EXTRA_CFLAGS += -Wall
#EXTRA_CFLAGS += -Wextra
#EXTRA_CFLAGS += -Werror
#EXTRA_CFLAGS += -pedantic
#EXTRA_CFLAGS += -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes
EXTRA_CFLAGS += -Wno-unused-variable
EXTRA_CFLAGS += -Wno-unused-value
EXTRA_CFLAGS += -Wno-unused-label
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -Wno-unused-function
EXTRA_CFLAGS += -Wno-unused
#EXTRA_CFLAGS += -Wno-uninitialized
EXTRA_CFLAGS += -I$(src)/include
# for tegra wifi gpio
EXTRA_CFLAGS += -I$(srctree)/arch/arm/mach-tegra
EXTRA_LDFLAGS += --strip-debug
CONFIG_AUTOCFG_CP = n
CONFIG_MULTIDRV = n
CONFIG_RTL8192C = n
CONFIG_RTL8192D = n
CONFIG_RTL8723A = n
CONFIG_RTL8188E = n
CONFIG_RTL8812A = n
CONFIG_RTL8821A = n
CONFIG_RTL8192E = n
CONFIG_RTL8723B = y
CONFIG_USB_HCI = n
CONFIG_PCI_HCI = n
CONFIG_SDIO_HCI = y
CONFIG_GSPI_HCI = n
CONFIG_MP_INCLUDED = y
CONFIG_POWER_SAVING = y
<API key> = n
<API key> = n
CONFIG_WIFI_TEST = n
CONFIG_BT_COEXIST = y
<API key> = n
CONFIG_INTEL_WIDI = n
CONFIG_WAPI_SUPPORT = n
<API key> = n
CONFIG_EXT_CLK = n
<API key> = y
<API key> = y
<API key> = n
<API key> = n
<API key> = n
<API key> = n
CONFIG_WOWLAN = y
CONFIG_GPIO_WAKEUP = y
CONFIG_PNO_SUPPORT = n
<API key> = n
CONFIG_AP_WOWLAN = n
<API key> = y
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = y
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
<API key> = n
export TopDIR ?= $(shell pwd)
ifeq ($(CONFIG_GSPI_HCI), y)
HCI_NAME = gspi
endif
ifeq ($(CONFIG_SDIO_HCI), y)
HCI_NAME = sdio
endif
ifeq ($(CONFIG_USB_HCI), y)
HCI_NAME = usb
endif
ifeq ($(CONFIG_PCI_HCI), y)
HCI_NAME = pci
endif
_OS_INTFS_FILES := os_dep/osdep_service.o \
os_dep/linux/os_intfs.o \
os_dep/linux/$(HCI_NAME)_intf.o \
os_dep/linux/$(HCI_NAME)_ops_linux.o \
os_dep/linux/ioctl_linux.o \
os_dep/linux/xmit_linux.o \
os_dep/linux/mlme_linux.o \
os_dep/linux/recv_linux.o \
os_dep/linux/ioctl_cfg80211.o \
os_dep/linux/wifi_regd.o \
os_dep/linux/rtw_android.o \
os_dep/linux/rtw_proc.o
ifeq ($(CONFIG_SDIO_HCI), y)
_OS_INTFS_FILES += os_dep/linux/custom_gpio_linux.o
_OS_INTFS_FILES += os_dep/linux/$(HCI_NAME)_ops_linux.o
endif
ifeq ($(CONFIG_GSPI_HCI), y)
_OS_INTFS_FILES += os_dep/linux/custom_gpio_linux.o
_OS_INTFS_FILES += os_dep/linux/$(HCI_NAME)_ops_linux.o
endif
_HAL_INTFS_FILES := hal/hal_intf.o \
hal/hal_com.o \
hal/hal_com_phycfg.o \
hal/hal_phy.o \
hal/hal_btcoex.o \
hal/hal_hci/hal_$(HCI_NAME).o \
hal/led/hal_$(HCI_NAME)_led.o
_OUTSRC_FILES := hal/OUTSRC/odm_debug.o \
hal/OUTSRC/odm_AntDiv.o\
hal/OUTSRC/odm_interface.o\
hal/OUTSRC/odm_HWConfig.o\
hal/OUTSRC/odm.o\
hal/OUTSRC/HalPhyRf.o\
hal/OUTSRC/odm_EdcaTurboCheck.o\
hal/OUTSRC/odm_DIG.o\
hal/OUTSRC/odm_PathDiv.o\
hal/OUTSRC/<API key>.o\
hal/OUTSRC/odm_DynamicTxPower.o\
hal/OUTSRC/odm_CfoTracking.o\
hal/OUTSRC/odm_NoiseMonitor.o
EXTRA_CFLAGS += -I$(src)/platform
_PLATFORM_FILES := platform/platform_ops.o
ifeq ($(CONFIG_BT_COEXIST), y)
EXTRA_CFLAGS += -I$(src)/hal/OUTSRC-BTCoexist
_OUTSRC_FILES += hal/OUTSRC-BTCoexist/HalBtc8188c2Ant.o \
hal/OUTSRC-BTCoexist/HalBtc8192d2Ant.o \
hal/OUTSRC-BTCoexist/HalBtc8192e1Ant.o \
hal/OUTSRC-BTCoexist/HalBtc8192e2Ant.o \
hal/OUTSRC-BTCoexist/HalBtc8723a1Ant.o \
hal/OUTSRC-BTCoexist/HalBtc8723a2Ant.o \
hal/OUTSRC-BTCoexist/HalBtc8723b1Ant.o \
hal/OUTSRC-BTCoexist/HalBtc8723b2Ant.o \
hal/OUTSRC-BTCoexist/HalBtc8812a1Ant.o \
hal/OUTSRC-BTCoexist/HalBtc8812a2Ant.o \
hal/OUTSRC-BTCoexist/HalBtc8821a1Ant.o \
hal/OUTSRC-BTCoexist/HalBtc8821a2Ant.o
endif
ifeq ($(CONFIG_RTL8192C), y)
RTL871X = rtl8192c
ifeq ($(CONFIG_USB_HCI), y)
MODULE_NAME = 8192cu
endif
ifeq ($(CONFIG_PCI_HCI), y)
MODULE_NAME = 8192ce
endif
EXTRA_CFLAGS += -DCONFIG_RTL8192C
_HAL_INTFS_FILES += \
hal/$(RTL871X)/$(RTL871X)_sreset.o \
hal/$(RTL871X)/$(RTL871X)_xmit.o
_HAL_INTFS_FILES += hal/$(RTL871X)/$(RTL871X)_hal_init.o \
hal/$(RTL871X)/$(RTL871X)_phycfg.o \
hal/$(RTL871X)/$(RTL871X)_rf6052.o \
hal/$(RTL871X)/$(RTL871X)_dm.o \
hal/$(RTL871X)/$(RTL871X)_rxdesc.o \
hal/$(RTL871X)/$(RTL871X)_cmd.o \
hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_halinit.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_led.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_xmit.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_recv.o
_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops_linux.o
ifeq ($(CONFIG_MP_INCLUDED), y)
_HAL_INTFS_FILES += hal/$(RTL871X)/$(RTL871X)_mp.o
endif
_OUTSRC_FILES += hal/OUTSRC/$(RTL871X)/odm_RTL8192C.o\
hal/OUTSRC/$(RTL871X)/HalDMOutSrc8192C_CE.o
ifeq ($(CONFIG_USB_HCI), y)
_OUTSRC_FILES += hal/OUTSRC/$(RTL871X)/Hal8192CUFWImg_CE.o \
hal/OUTSRC/$(RTL871X)/Hal8192CUPHYImg_CE.o \
hal/OUTSRC/$(RTL871X)/Hal8192CUMACImg_CE.o
endif
ifeq ($(CONFIG_PCI_HCI), y)
_OUTSRC_FILES += hal/OUTSRC/$(RTL871X)/Hal8192CEFWImg_CE.o \
hal/OUTSRC/$(RTL871X)/Hal8192CEPHYImg_CE.o \
hal/OUTSRC/$(RTL871X)/Hal8192CEMACImg_CE.o
endif
endif
ifeq ($(CONFIG_RTL8192D), y)
RTL871X = rtl8192d
ifeq ($(CONFIG_USB_HCI), y)
MODULE_NAME = 8192du
endif
ifeq ($(CONFIG_PCI_HCI), y)
MODULE_NAME = 8192de
endif
EXTRA_CFLAGS += -DCONFIG_RTL8192D
_HAL_INTFS_FILES += \
hal/$(RTL871X)/$(RTL871X)_xmit.o
_HAL_INTFS_FILES += hal/$(RTL871X)/$(RTL871X)_hal_init.o \
hal/$(RTL871X)/$(RTL871X)_phycfg.o \
hal/$(RTL871X)/$(RTL871X)_rf6052.o \
hal/$(RTL871X)/$(RTL871X)_dm.o \
hal/$(RTL871X)/$(RTL871X)_rxdesc.o \
hal/$(RTL871X)/$(RTL871X)_cmd.o \
hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_halinit.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_led.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_xmit.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_recv.o
_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops_linux.o
ifeq ($(CONFIG_MP_INCLUDED), y)
_HAL_INTFS_FILES += hal/$(RTL871X)/$(RTL871X)_mp.o
endif
_OUTSRC_FILES += hal/OUTSRC/$(RTL871X)/odm_RTL8192D.o\
hal/OUTSRC/$(RTL871X)/HalDMOutSrc8192D_CE.o
ifeq ($(CONFIG_USB_HCI), y)
_OUTSRC_FILES += hal/OUTSRC/$(RTL871X)/Hal8192DUFWImg_CE.o \
hal/OUTSRC/$(RTL871X)/Hal8192DUPHYImg_CE.o \
hal/OUTSRC/$(RTL871X)/Hal8192DUMACImg_CE.o
endif
ifeq ($(CONFIG_PCI_HCI), y)
_OUTSRC_FILES += hal/OUTSRC/$(RTL871X)/Hal8192DEFWImg_CE.o \
hal/OUTSRC/$(RTL871X)/Hal8192DEPHYImg_CE.o \
hal/OUTSRC/$(RTL871X)/Hal8192DEMACImg_CE.o
endif
endif
ifeq ($(CONFIG_RTL8723A), y)
RTL871X = rtl8723a
ifeq ($(CONFIG_GSPI_HCI), y)
MODULE_NAME = 8723as
endif
ifeq ($(CONFIG_SDIO_HCI), y)
MODULE_NAME = 8723as
endif
ifeq ($(CONFIG_USB_HCI), y)
MODULE_NAME = 8723au
endif
ifeq ($(CONFIG_PCI_HCI), y)
MODULE_NAME = 8723ae
endif
EXTRA_CFLAGS += -DCONFIG_RTL8723A
_HAL_INTFS_FILES += hal/HalPwrSeqCmd.o \
hal/$(RTL871X)/Hal8723PwrSeq.o\
hal/$(RTL871X)/$(RTL871X)_xmit.o \
hal/$(RTL871X)/$(RTL871X)_sreset.o
_HAL_INTFS_FILES += hal/$(RTL871X)/$(RTL871X)_hal_init.o \
hal/$(RTL871X)/$(RTL871X)_phycfg.o \
hal/$(RTL871X)/$(RTL871X)_rf6052.o \
hal/$(RTL871X)/$(RTL871X)_dm.o \
hal/$(RTL871X)/$(RTL871X)_rxdesc.o \
hal/$(RTL871X)/$(RTL871X)_cmd.o \
hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_halinit.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_led.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_xmit.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_recv.o
ifeq ($(CONFIG_SDIO_HCI), y)
_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops.o
else
ifeq ($(CONFIG_GSPI_HCI), y)
_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops.o
else
_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops_linux.o
endif
endif
ifeq ($(CONFIG_MP_INCLUDED), y)
_HAL_INTFS_FILES += hal/$(RTL871X)/$(RTL871X)_mp.o
endif
ifeq ($(CONFIG_GSPI_HCI), y)
_OUTSRC_FILES += hal/OUTSRC/$(RTL871X)/Hal8723SHWImg_CE.o
endif
ifeq ($(CONFIG_SDIO_HCI), y)
_OUTSRC_FILES += hal/OUTSRC/$(RTL871X)/Hal8723SHWImg_CE.o
endif
ifeq ($(CONFIG_USB_HCI), y)
_OUTSRC_FILES += hal/OUTSRC/$(RTL871X)/Hal8723UHWImg_CE.o
endif
ifeq ($(CONFIG_PCI_HCI), y)
_OUTSRC_FILES += hal/OUTSRC/$(RTL871X)/Hal8723EHWImg_CE.o
endif
#hal/OUTSRC/$(RTL871X)/HalHWImg8723A_FW.o
_OUTSRC_FILES += hal/OUTSRC/$(RTL871X)/HalHWImg8723A_BB.o\
hal/OUTSRC/$(RTL871X)/HalHWImg8723A_MAC.o\
hal/OUTSRC/$(RTL871X)/HalHWImg8723A_RF.o\
hal/OUTSRC/$(RTL871X)/odm_RegConfig8723A.o
_OUTSRC_FILES += hal/OUTSRC/rtl8192c/HalDMOutSrc8192C_CE.o
endif
ifeq ($(CONFIG_RTL8188E), y)
RTL871X = rtl8188e
ifeq ($(CONFIG_SDIO_HCI), y)
MODULE_NAME = 8189es
endif
ifeq ($(CONFIG_USB_HCI), y)
MODULE_NAME = 8188eu
endif
ifeq ($(CONFIG_PCI_HCI), y)
MODULE_NAME = 8188ee
endif
EXTRA_CFLAGS += -DCONFIG_RTL8188E
_HAL_INTFS_FILES += hal/HalPwrSeqCmd.o \
hal/$(RTL871X)/Hal8188EPwrSeq.o\
hal/$(RTL871X)/$(RTL871X)_xmit.o\
hal/$(RTL871X)/$(RTL871X)_sreset.o
_HAL_INTFS_FILES += hal/$(RTL871X)/$(RTL871X)_hal_init.o \
hal/$(RTL871X)/$(RTL871X)_phycfg.o \
hal/$(RTL871X)/$(RTL871X)_rf6052.o \
hal/$(RTL871X)/$(RTL871X)_dm.o \
hal/$(RTL871X)/$(RTL871X)_rxdesc.o \
hal/$(RTL871X)/$(RTL871X)_cmd.o \
hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_halinit.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_led.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_xmit.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_recv.o
ifeq ($(CONFIG_SDIO_HCI), y)
_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops.o
else
ifeq ($(CONFIG_GSPI_HCI), y)
_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops.o
else
_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops_linux.o
endif
endif
ifeq ($(CONFIG_MP_INCLUDED), y)
_HAL_INTFS_FILES += hal/$(RTL871X)/$(RTL871X)_mp.o
endif
#hal/OUTSRC/$(RTL871X)/Hal8188EFWImg_CE.o
_OUTSRC_FILES += hal/OUTSRC/$(RTL871X)/HalHWImg8188E_MAC.o\
hal/OUTSRC/$(RTL871X)/HalHWImg8188E_BB.o\
hal/OUTSRC/$(RTL871X)/HalHWImg8188E_RF.o\
hal/OUTSRC/$(RTL871X)/HalHWImg8188E_FW.o\
hal/OUTSRC/$(RTL871X)/HalPhyRf_8188e.o\
hal/OUTSRC/$(RTL871X)/odm_RegConfig8188E.o\
hal/OUTSRC/$(RTL871X)/<API key>.o\
hal/OUTSRC/$(RTL871X)/odm_RTL8188E.o
endif
ifeq ($(CONFIG_RTL8192E), y)
RTL871X = rtl8192e
ifeq ($(CONFIG_SDIO_HCI), y)
MODULE_NAME = 8192es
endif
ifeq ($(CONFIG_USB_HCI), y)
MODULE_NAME = 8192eu
endif
ifeq ($(CONFIG_PCI_HCI), y)
MODULE_NAME = 8192ee
endif
EXTRA_CFLAGS += -DCONFIG_RTL8192E
_HAL_INTFS_FILES += hal/HalPwrSeqCmd.o \
hal/$(RTL871X)/Hal8192EPwrSeq.o\
hal/$(RTL871X)/$(RTL871X)_xmit.o\
hal/$(RTL871X)/$(RTL871X)_sreset.o
_HAL_INTFS_FILES += hal/$(RTL871X)/$(RTL871X)_hal_init.o \
hal/$(RTL871X)/$(RTL871X)_phycfg.o \
hal/$(RTL871X)/$(RTL871X)_rf6052.o \
hal/$(RTL871X)/$(RTL871X)_dm.o \
hal/$(RTL871X)/$(RTL871X)_rxdesc.o \
hal/$(RTL871X)/$(RTL871X)_cmd.o \
hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_halinit.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_led.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_xmit.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_recv.o
ifeq ($(CONFIG_SDIO_HCI), y)
_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops.o
else
ifeq ($(CONFIG_GSPI_HCI), y)
_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops.o
else
_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops_linux.o
endif
endif
ifeq ($(CONFIG_MP_INCLUDED), y)
_HAL_INTFS_FILES += hal/$(RTL871X)/$(RTL871X)_mp.o
endif
#hal/OUTSRC/$(RTL871X)/HalHWImg8188E_FW.o
_OUTSRC_FILES += hal/OUTSRC/$(RTL871X)/HalHWImg8192E_MAC.o\
hal/OUTSRC/$(RTL871X)/HalHWImg8192E_BB.o\
hal/OUTSRC/$(RTL871X)/HalHWImg8192E_RF.o\
hal/OUTSRC/$(RTL871X)/HalHWImg8192E_FW.o\
hal/OUTSRC/$(RTL871X)/HalPhyRf_8192e.o\
hal/OUTSRC/$(RTL871X)/odm_RegConfig8192E.o\
hal/OUTSRC/$(RTL871X)/odm_RTL8192E.o
endif
ifneq ($(CONFIG_RTL8812A)_$(CONFIG_RTL8821A), n_n)
RTL871X = rtl8812a
ifeq ($(CONFIG_USB_HCI), y)
MODULE_NAME = 8812au
endif
ifeq ($(CONFIG_PCI_HCI), y)
MODULE_NAME = 8812ae
endif
ifeq ($(CONFIG_SDIO_HCI), y)
MODULE_NAME = 8812as
endif
_HAL_INTFS_FILES += hal/HalPwrSeqCmd.o \
hal/$(RTL871X)/Hal8812PwrSeq.o \
hal/$(RTL871X)/Hal8821APwrSeq.o\
hal/$(RTL871X)/$(RTL871X)_xmit.o\
hal/$(RTL871X)/$(RTL871X)_sreset.o
_HAL_INTFS_FILES += hal/$(RTL871X)/$(RTL871X)_hal_init.o \
hal/$(RTL871X)/$(RTL871X)_phycfg.o \
hal/$(RTL871X)/$(RTL871X)_rf6052.o \
hal/$(RTL871X)/$(RTL871X)_dm.o \
hal/$(RTL871X)/$(RTL871X)_rxdesc.o \
hal/$(RTL871X)/$(RTL871X)_cmd.o \
hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_halinit.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_led.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_xmit.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_recv.o
ifeq ($(CONFIG_SDIO_HCI), y)
_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops.o
else
ifeq ($(CONFIG_GSPI_HCI), y)
_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops.o
else
_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops_linux.o
endif
endif
ifeq ($(CONFIG_MP_INCLUDED), y)
_HAL_INTFS_FILES += hal/$(RTL871X)/$(RTL871X)_mp.o
endif
ifeq ($(CONFIG_RTL8812A), y)
EXTRA_CFLAGS += -DCONFIG_RTL8812A
_OUTSRC_FILES += hal/OUTSRC/$(RTL871X)/HalHWImg8812A_FW.o\
hal/OUTSRC/$(RTL871X)/HalHWImg8812A_MAC.o\
hal/OUTSRC/$(RTL871X)/HalHWImg8812A_BB.o\
hal/OUTSRC/$(RTL871X)/HalHWImg8812A_RF.o\
hal/OUTSRC/$(RTL871X)/HalPhyRf_8812A.o\
hal/OUTSRC/$(RTL871X)/odm_RegConfig8812A.o\
hal/OUTSRC/$(RTL871X)/odm_RTL8812A.o
endif
ifeq ($(CONFIG_RTL8821A), y)
ifeq ($(CONFIG_RTL8812A), n)
RTL871X = rtl8821a
ifeq ($(CONFIG_USB_HCI), y)
MODULE_NAME := 8821au
endif
ifeq ($(CONFIG_PCI_HCI), y)
MODULE_NAME := 8821ae
endif
ifeq ($(CONFIG_SDIO_HCI), y)
MODULE_NAME := 8821as
endif
endif
EXTRA_CFLAGS += -DCONFIG_RTL8821A
_OUTSRC_FILES += hal/OUTSRC/rtl8821a/HalHWImg8821A_FW.o\
hal/OUTSRC/rtl8821a/HalHWImg8821A_MAC.o\
hal/OUTSRC/rtl8821a/HalHWImg8821A_BB.o\
hal/OUTSRC/rtl8821a/HalHWImg8821A_RF.o\
hal/OUTSRC/rtl8812a/HalPhyRf_8812A.o\
hal/OUTSRC/rtl8821a/HalPhyRf_8821A.o\
hal/OUTSRC/rtl8821a/odm_RegConfig8821A.o\
hal/OUTSRC/rtl8821a/odm_RTL8821A.o
endif
endif
ifeq ($(CONFIG_RTL8723B), y)
RTL871X = rtl8723b
ifeq ($(CONFIG_USB_HCI), y)
MODULE_NAME = 8723bu
endif
ifeq ($(CONFIG_PCI_HCI), y)
MODULE_NAME = 8723be
endif
ifeq ($(CONFIG_SDIO_HCI), y)
MODULE_NAME = 8723bs
endif
EXTRA_CFLAGS += -DCONFIG_RTL8723B
_HAL_INTFS_FILES += hal/HalPwrSeqCmd.o \
hal/$(RTL871X)/Hal8723BPwrSeq.o\
hal/$(RTL871X)/$(RTL871X)_sreset.o
_HAL_INTFS_FILES += hal/$(RTL871X)/$(RTL871X)_hal_init.o \
hal/$(RTL871X)/$(RTL871X)_phycfg.o \
hal/$(RTL871X)/$(RTL871X)_rf6052.o \
hal/$(RTL871X)/$(RTL871X)_dm.o \
hal/$(RTL871X)/$(RTL871X)_rxdesc.o \
hal/$(RTL871X)/$(RTL871X)_cmd.o \
_HAL_INTFS_FILES += \
hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_halinit.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_led.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_xmit.o \
hal/$(RTL871X)/$(HCI_NAME)/rtl$(MODULE_NAME)_recv.o
ifeq ($(CONFIG_PCI_HCI), y)
_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops_linux.o
else
_HAL_INTFS_FILES += hal/$(RTL871X)/$(HCI_NAME)/$(HCI_NAME)_ops.o
endif
ifeq ($(CONFIG_MP_INCLUDED), y)
_HAL_INTFS_FILES += hal/$(RTL871X)/$(RTL871X)_mp.o
endif
_OUTSRC_FILES += hal/OUTSRC/$(RTL871X)/HalHWImg8723B_BB.o\
hal/OUTSRC/$(RTL871X)/HalHWImg8723B_MAC.o\
hal/OUTSRC/$(RTL871X)/HalHWImg8723B_RF.o\
hal/OUTSRC/$(RTL871X)/HalHWImg8723B_FW.o\
hal/OUTSRC/$(RTL871X)/HalHWImg8723B_MP.o\
hal/OUTSRC/$(RTL871X)/odm_RegConfig8723B.o\
hal/OUTSRC/$(RTL871X)/HalPhyRf_8723B.o\
hal/OUTSRC/$(RTL871X)/odm_RTL8723B.o
endif
ifeq ($(CONFIG_AUTOCFG_CP), y)
ifeq ($(CONFIG_MULTIDRV), y)
$(shell cp $(TopDIR)/autoconf_multidrv_$(HCI_NAME)_linux.h $(TopDIR)/include/autoconf.h)
else
ifeq ($(CONFIG_RTL8188E)$(CONFIG_SDIO_HCI),yy)
$(shell cp $(TopDIR)/autoconf_rtl8189e_$(HCI_NAME)_linux.h $(TopDIR)/include/autoconf.h)
else
$(shell cp $(TopDIR)/autoconf_$(RTL871X)_$(HCI_NAME)_linux.h $(TopDIR)/include/autoconf.h)
endif
endif
endif
ifeq ($(CONFIG_USB_HCI), y)
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
endif
endif
ifeq ($(CONFIG_MP_INCLUDED), y)
#MODULE_NAME := $(MODULE_NAME)_mp
EXTRA_CFLAGS += -DCONFIG_MP_INCLUDED
endif
ifeq ($(CONFIG_POWER_SAVING), y)
EXTRA_CFLAGS += -<API key>
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
endif
ifeq ($(CONFIG_WIFI_TEST), y)
EXTRA_CFLAGS += -DCONFIG_WIFI_TEST
endif
ifeq ($(CONFIG_BT_COEXIST), y)
EXTRA_CFLAGS += -DCONFIG_BT_COEXIST
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
endif
ifeq ($(CONFIG_INTEL_WIDI), y)
EXTRA_CFLAGS += -DCONFIG_INTEL_WIDI
endif
ifeq ($(CONFIG_WAPI_SUPPORT), y)
EXTRA_CFLAGS += -<API key>
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
ifeq ($(MODULE_NAME), 8189es)
EXTRA_CFLAGS += -DEFUSE_MAP_PATH=\"/system/etc/wifi/wifi_efuse_8189e.map\"
else
EXTRA_CFLAGS += -DEFUSE_MAP_PATH=\"/system/etc/wifi/wifi_efuse_$(MODULE_NAME).map\"
endif
EXTRA_CFLAGS += -DWIFIMAC_PATH=\"/data/wifimac.txt\"
endif
ifeq ($(CONFIG_EXT_CLK), y)
EXTRA_CFLAGS += -DCONFIG_EXT_CLK
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
endif
ifeq ($(CONFIG_WOWLAN), y)
EXTRA_CFLAGS += -DCONFIG_WOWLAN
ifeq ($(CONFIG_SDIO_HCI), y)
EXTRA_CFLAGS += -<API key>
endif
endif
ifeq ($(CONFIG_AP_WOWLAN), y)
EXTRA_CFLAGS += -DCONFIG_AP_WOWLAN
ifeq ($(CONFIG_SDIO_HCI), y)
EXTRA_CFLAGS += -<API key>
endif
endif
ifeq ($(CONFIG_PNO_SUPPORT), y)
EXTRA_CFLAGS += -DCONFIG_PNO_SUPPORT
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
endif
endif
ifeq ($(CONFIG_GPIO_WAKEUP), y)
EXTRA_CFLAGS += -DCONFIG_GPIO_WAKEUP
endif
ifeq ($(<API key>), y)
ifeq ($(CONFIG_SDIO_HCI), y)
EXTRA_CFLAGS += -<API key>
endif
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
SUBARCH := $(shell uname -m | sed -e s/i.86/i386/)
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?=
KVER := $(shell uname -r)
KSRC := /lib/modules/$(KVER)/build
MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless/
INSTALL_PREFIX :=
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -<API key> -<API key>
#ARCH := arm
ARCH := $(R_ARCH)
#CROSS_COMPILE := <API key>-
CROSS_COMPILE := $(R_CROSS_COMPILE)
KVER:= 3.4.0
#KSRC := ../../../../build/out/kernel
KSRC := $(KERNEL_BUILD_PATH)
MODULE_NAME :=wlan
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -<API key> -<API key>
CROSS_COMPILE := arm-eabi-
KSRC := $(shell pwd)/../../../Android/kernel
ARCH := arm
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -<API key> -<API key>
ARCH:=mips
CROSS_COMPILE:= /usr/src/Mstar_kernel/mips-4.3/bin/mips-linux-gnu-
KVER:= 2.6.28.9
KSRC:= /usr/src/Mstar_kernel/2.6.28.9/
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -<API key> #-<API key>
ARCH:=arm
CROSS_COMPILE:= /usr/src/bin/<API key>-
KVER:= 3.1.10
KSRC:= /usr/src/Mstar_kernel/3.1.10/
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
SUBARCH := $(shell uname -m | sed -e s/i.86/i386/)
ARCH := $(SUBARCH)
CROSS_COMPILE := /media/DATA-2/android-x86/ics-x86_20120130/prebuilt/linux-x86/toolchain/<API key>.2.1/bin/<API key>-
KSRC := /media/DATA-2/android-x86/ics-x86_20120130/out/target/product/generic_x86/obj/kernel
MODULE_NAME :=wlan
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key> -<API key>
EXTRA_CFLAGS += -DCONFIG_P2P_IPS
SUBARCH := $(shell uname -m | sed -e s/i.86/i386/)
ARCH := $(SUBARCH)
CROSS_COMPILE := /home/android_sdk/android-x86_JB/prebuilts/gcc/linux-x86/x86/<API key>.7/bin/i686-linux-android-
KSRC := /home/android_sdk/android-x86_JB/out/target/product/x86/obj/kernel/
MODULE_NAME :=wlan
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
ARCH := arm
CROSS_COMPILE := <API key>-
KVER := 2.6.34.1
KSRC ?= /usr/src/linux-2.6.34.1
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
ARCH := arm
CROSS_COMPILE := arm-linux-
KVER := 2.6.24.7_$(ARCH)
KSRC := /usr/src/kernels/linux-$(KVER)
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
ARCH := arm
CROSS_COMPILE := <API key>-
KVER := 2.6.34.1
KSRC ?= /usr/src/linux-2.6.34.1
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -DCONFIG_BIG_ENDIAN -<API key>
ARCH:=
CROSS_COMPILE:=
KVER:=
KSRC:=
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
ARCH:=mips
CROSS_COMPILE:=mipsisa32r2-uclibc-
KVER:=
KSRC:= /root/work/kernel_realtek
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -DCONFIG_BIG_ENDIAN
ARCH:=mips
CROSS_COMPILE:=mipsisa32r2-uclibc-
KVER:=
KSRC:= /root/work/kernel_realtek
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -<API key>
ARCH:=mips
CROSS_COMPILE:= mips-linux-gnu-
KVER:= 2.6.28.10
KSRC:= /home/mstar/mstar_linux/2.6.28.9/
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -DCONFIG_BIG_ENDIAN
ARCH := mips
CROSS_COMPILE := mips-openwrt-linux-
KSRC := /home/alex/test_openwrt/tmp/linux-2.6.30.9
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -DRTK_DMP_PLATFORM
ARCH := mips
#CROSS_COMPILE:=/usr/local/msdk-4.3.6-mips-EL-2.6.12.6-0.9.30.3/bin/mipsel-linux-
CROSS_COMPILE:=/usr/local/toolchain_mipsel/bin/mipsel-linux-
KSRC ?=/usr/local/Jupiter/linux-2.6.12
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -DRTK_DMP_PLATFORM -<API key>
EXTRA_CFLAGS += -<API key>
ifeq ($(CONFIG_USB_HCI), y)
_PLATFORM_FILES += platform/<API key>.o
endif
ARCH:=mips
CROSS_COMPILE:=mipsel-linux-
KVER:=
KSRC ?= /usr/src/DMP_Kernel/jupiter/linux-2.6.12
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -<API key>
ARCH:= arm
CROSS_COMPILE:= arm11_mtk_le-
KVER:= 2.6.27
KSRC?= /proj/mtk00802/BD_Compare/BDP/Dev/BDP_V301/BDP_Linux/linux-2.6.27
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -<API key>
ARCH := arm
CROSS_COMPILE := /opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/<API key>/bin/<API key>-
KVER := 2.6.31
KSRC ?= /lib/modules/2.6.31-770-g0e46b52/source
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
ARCH := arm
CROSS_COMPILE := /home/share/CusEnv/FreeScale/arm-eabi-4.4.3/bin/arm-eabi-
KSRC ?= /home/share/CusEnv/FreeScale/FS_kernel_env
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -<API key>
ARCH := mips
CROSS_COMPILE := /home/cnsd4/project/actions/tools-2.6.27/bin/mipsel-linux-gnu-
KVER := 2.6.27
KSRC := /home/cnsd4/project/actions/linux-2.6.27.28
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -<API key>
EXTRA_CFLAGS += -<API key>
ARCH := arm
CROSS_COMPILE := /home/cnsd4/Appro/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/bin/arm_v5t_le-
KVER := 2.6.18
KSRC := /home/cnsd4/Appro/mv_pro_5.0/montavista/pro/devkit/lsp/ti-davinci/linux-dm365
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
# default setting for Android 4.1, 4.2
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key> -<API key>
EXTRA_CFLAGS += -DCONFIG_P2P_IPS
ARCH := arm
CROSS_COMPILE := /home/android_sdk/nvidia/<API key>.1_20120723/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
KSRC := /home/android_sdk/nvidia/<API key>.1_20120723/out/target/product/cardhu/obj/KERNEL
MODULE_NAME := wlan
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
# default setting for Android 4.1, 4.2
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key> -<API key>
EXTRA_CFLAGS += -DCONFIG_P2P_IPS
ARCH := arm
CROSS_COMPILE := /home/android_sdk/nvidia/<API key>.2-dalmore_20130131/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
KSRC := /home/android_sdk/nvidia/<API key>.2-dalmore_20130131/out/target/product/dalmore/obj/KERNEL
MODULE_NAME := wlan
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
# default setting for Android 4.1, 4.2
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key> -<API key>
EXTRA_CFLAGS += -DCONFIG_P2P_IPS
#EXTRA_CFLAGS += -<API key> -DCONFIG_WEXT_PRIV
ARCH := arm
CROSS_COMPILE := /home/android_sdk/src/nvidia/bowser/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
KSRC := /home/android_sdk/nvidia/bowser/out/target/product/dalmore/obj/KERNEL
MODULE_NAME := rtl8723bs
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
# default setting for Android 4.1, 4.2
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key> -<API key>
EXTRA_CFLAGS += -DCONFIG_P2P_IPS
EXTRA_LDFLAGS += --strip-debug
#EXTRA_CFLAGS += -<API key> -DCONFIG_WEXT_PRIV
ARCH := arm
CROSS_COMPILE := /home/android_sdk/src/nvidia/bowser/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
KSRC := /home/android_sdk/nvidia/bowser/out/target/product/dalmore/obj/KERNEL
MODULE_NAME := rtl8723bs
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
ARCH := arm
CROSS_COMPILE := /home/android_sdk/Telechips/SDK_2304_20110613/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
KSRC := /home/android_sdk/Telechips/SDK_2304_20110613/kernel
MODULE_NAME := wlan
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
ARCH := arm
CROSS_COMPILE := /home/android_sdk/Telechips/v12.06_r1-tcc-android-4.0.4/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
KSRC := /home/android_sdk/Telechips/v12.06_r1-tcc-android-4.0.4/kernel
MODULE_NAME := wlan
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
# default setting for Android 4.1, 4.2
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key> -<API key>
EXTRA_CFLAGS += -DCONFIG_P2P_IPS
ARCH := arm
CROSS_COMPILE := /home/android_sdk/Telechips/v13.03_r1-tcc-android-4.2.2_ds_patched/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
KSRC := /home/android_sdk/Telechips/v13.03_r1-tcc-android-4.2.2_ds_patched/kernel
MODULE_NAME := wlan
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -<API key> -<API key>
ARCH := arm
CROSS_COMPILE := /usr/src/release_fae_version/toolchain/arm-eabi-4.4.0/bin/arm-eabi-
KSRC := /usr/src/release_fae_version/kernel25_A7_281x
MODULE_NAME := wlan
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -<API key> -<API key>
# default setting for Android 4.1, 4.2, 4.3, 4.4
EXTRA_CFLAGS += -<API key> -<API key>
EXTRA_CFLAGS += -<API key>
# default setting for Power control
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
# default setting for Special function
EXTRA_CFLAGS += -DCONFIG_P2P_IPS
ARCH := arm
CROSS_COMPILE := /home/android_sdk/Rockchip/Rk3188/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
KSRC := /home/android_sdk/Rockchip/Rk3188/kernel
MODULE_NAME := wlan
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -DCONFIG_P2P_IPS
ifeq ($(CONFIG_SDIO_HCI), y)
EXTRA_CFLAGS += -<API key>
endif
EXTRA_CFLAGS += -fno-pic
ARCH := arm
CROSS_COMPILE := /home/android_sdk/Rockchip/rk3066_20130607/prebuilts/gcc/linux-x86/arm/<API key>.6/bin/<API key>-
#CROSS_COMPILE := /home/android_sdk/Rockchip/Rk3066sdk/prebuilts/gcc/linux-x86/arm/<API key>.6/bin/<API key>-
KSRC := /home/android_sdk/Rockchip/Rk3066sdk/kernel
MODULE_NAME :=wlan
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> #-<API key>
ARCH := arm
CROSS_COMPILE := /media/DATA-1/urbetter/arm-2009q3/bin/<API key>-
KSRC := /media/DATA-1/urbetter/ics-urbetter/kernel
MODULE_NAME := wlan
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> #-<API key>
ARCH := arm
#CROSS_COMPILE := /media/DATA-1/aosp/ics-aosp_20111227/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
#KSRC := /media/DATA-1/aosp/<API key>.0_20120104
CROSS_COMPILE := /media/DATA-1/android-4.0/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
KSRC := /media/DATA-1/android-4.0/panda_kernel/omap
MODULE_NAME := wlan
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -<API key>
ARCH ?= mips
CROSS_COMPILE ?= /mnt/sdb5/Ingenic/Umido/mips-4.3/bin/mips-linux-gnu-
KSRC ?= /mnt/sdb5/Ingenic/Umido/kernel
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -DCONFIG_BIG_ENDIAN
ARCH:=arm
CROSS_COMPILE:=/opt/crosstool2/bin/<API key>-
KVER:= 2.6.31.6
KSRC:= ../code/linux-2.6.31.6-2020/
endif
#Add setting for MN10300
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -<API key>
ARCH := mn10300
CROSS_COMPILE := mn10300-linux-
KVER := 2.6.32.2
KSRC := /home/winuser/work/Plat_sLD2T_V3010/usr/src/linux-2.6.32.2
INSTALL_PREFIX :=
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
# default setting for Android 4.1, 4.2
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key> -<API key>
EXTRA_CFLAGS += -DDCONFIG_P2P_IPS
EXTRA_CFLAGS += -<API key>
ifeq ($(CONFIG_USB_HCI), y)
EXTRA_CFLAGS += -<API key>
_PLATFORM_FILES += platform/<API key>.o
endif
ifeq ($(CONFIG_SDIO_HCI), y)
# default setting for A10-EVB mmc0
#EXTRA_CFLAGS += -<API key>
_PLATFORM_FILES += platform/<API key>.o
endif
ARCH := arm
#CROSS_COMPILE := <API key>-
CROSS_COMPILE=/home/android_sdk/Allwinner/a10/android-jb42/lichee-jb42/buildroot/output/external-toolchain/bin/<API key>-
KVER := 3.0.8
#KSRC:= ../lichee/linux-3.0/
KSRC=/home/android_sdk/Allwinner/a10/android-jb42/lichee-jb42/linux-3.0
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
# default setting for Android 4.1, 4.2, 4.3, 4.4
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key> -<API key>
EXTRA_CFLAGS += -DCONFIG_P2P_IPS -<API key>
EXTRA_CFLAGS += -<API key>
ifeq ($(CONFIG_USB_HCI), y)
EXTRA_CFLAGS += -<API key>
_PLATFORM_FILES += platform/<API key>.o
endif
ifeq ($(CONFIG_SDIO_HCI), y)
# default setting for A31-EVB mmc0
EXTRA_CFLAGS += -DCONFIG_A31_EVB
_PLATFORM_FILES += platform/<API key>.o
endif
ARCH := arm
#Android-JB42
#CROSS_COMPILE := /home/android_sdk/Allwinner/a31/android-jb42/lichee/buildroot/output/external-toolchain/bin/arm-linux-gnueabi-
#KSRC :=/home/android_sdk/Allwinner/a31/android-jb42/lichee/linux-3.3
#ifeq ($(CONFIG_USB_HCI), y)
#MODULE_NAME := 8188eu_sw
#endif
CROSS_COMPILE := /home/android_sdk/Allwinner/a31/kitkat-a3x_v4.5/lichee/buildroot/output/external-toolchain/bin/arm-linux-gnueabi-
KSRC :=/home/android_sdk/Allwinner/a31/kitkat-a3x_v4.5/lichee/linux-3.3
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
# default setting for Android 4.1, 4.2, 4.3, 4.4
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key> -<API key>
EXTRA_CFLAGS += -DCONFIG_P2P_IPS -<API key>
EXTRA_CFLAGS += -<API key>
ifeq ($(CONFIG_USB_HCI), y)
EXTRA_CFLAGS += -<API key>
_PLATFORM_FILES += platform/<API key>.o
endif
ifeq ($(CONFIG_SDIO_HCI), y)
_PLATFORM_FILES += platform/<API key>.o
endif
ARCH := arm
#CROSS_COMPILE := /home/android_sdk/Allwinner/a20_evb/lichee/out/android/common/buildroot/external-toolchain/bin/arm-linux-gnueabi-
#KSRC := /home/android_sdk/Allwinner/a20_evb/lichee/linux-3.3
#CROSS_COMPILE := /home/android_sdk/Allwinner/a20/android-jb43/lichee/out/android/common/buildroot/external-toolchain/bin/arm-linux-gnueabi-
#KSRC := /home/android_sdk/Allwinner/a20/android-jb43/lichee/linux-3.4
CROSS_COMPILE := /home/android_sdk/Allwinner/a20/kitkat-a20_v4.4/lichee/out/android/common/buildroot/external-toolchain/bin/arm-linux-gnueabi-
KSRC := /home/android_sdk/Allwinner/a20/kitkat-a20_v4.4/lichee/linux-3.4
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
# default setting for Android 4.1, 4.2
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key> -<API key>
EXTRA_CFLAGS += -DCONFIG_P2P_IPS
EXTRA_CFLAGS += -<API key>
ifeq ($(CONFIG_USB_HCI), y)
EXTRA_CFLAGS += -<API key>
_PLATFORM_FILES += platform/<API key>.o
endif
ifeq ($(CONFIG_SDIO_HCI), y)
_PLATFORM_FILES += platform/<API key>.o
endif
ARCH := arm
#CROSS_COMPILE := /home/android_sdk/Allwinner/a23/android-jb42/lichee/out/android/common/buildroot/external-toolchain/bin/arm-linux-gnueabi-
#KSRC :=/home/android_sdk/Allwinner/a23/android-jb42/lichee/linux-3.4
CROSS_COMPILE := /home/android_sdk/Allwinner/a23/android-kk44/lichee/out/android/common/buildroot/external-toolchain/bin/arm-linux-gnueabi-
KSRC :=/home/android_sdk/Allwinner/a23/android-kk44/lichee/linux-3.4
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -<API key>
ARCH := mips
CROSS_COMPILE := mipsel-linux-gnu-
KVER := $(KERNEL_VER)
KSRC:= $(CFGDIR)/../../kernel/linux-$(KERNEL_VER)
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key> -<API key>=1024 -<API key>=0
#ARCH, CROSS_COMPILE, KSRC,and MODDESTDIR are provided by external makefile
INSTALL_PREFIX :=
endif
# Platfrom setting
ifeq ($(<API key>), y)
ifeq ($(CONFIG_ANDROID_2X), y)
EXTRA_CFLAGS += -DANDROID_2X
endif
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
ifeq ($(RTL871X), rtl8188e)
EXTRA_CFLAGS += -DSOFTAP_PS_DURATION=50
endif
ifeq ($(CONFIG_SDIO_HCI), y)
EXTRA_CFLAGS += -<API key>
_PLATFORM_FILES += platform/platform_sprd_sdio.o
endif
endif
ifeq ($(<API key>), y)
ifeq ($(CONFIG_ANDROID_2X), y)
EXTRA_CFLAGS += -DANDROID_2X
endif
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
ifeq ($(RTL871X), rtl8188e)
EXTRA_CFLAGS += -DSOFTAP_PS_DURATION=50
endif
ifeq ($(CONFIG_SDIO_HCI), y)
EXTRA_CFLAGS += -<API key>
_PLATFORM_FILES += platform/platform_sprd_sdio.o
endif
endif
ifeq ($(<API key>), y)
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key>
EXTRA_CFLAGS += -<API key> -<API key>
EXTRA_CFLAGS += -<API key>
ifeq ($(CONFIG_SDIO_HCI), y)
_PLATFORM_FILES += platform/<API key>.o
endif
ARCH := arm
CROSS_COMPILE := /home/android_sdk/WonderMedia/wm8880-android4.4/toolchain/arm_201103_gcc4.5.2/mybin/arm_1103_le-
KSRC := /home/android_sdk/WonderMedia/wm8880-android4.4/kernel4.4/
MODULE_NAME :=8189es_kk
endif
ifeq ($(CONFIG_MULTIDRV), y)
ifeq ($(CONFIG_SDIO_HCI), y)
MODULE_NAME := rtw_sdio
endif
ifeq ($(CONFIG_USB_HCI), y)
MODULE_NAME := rtw_usb
endif
ifeq ($(CONFIG_PCI_HCI), y)
MODULE_NAME := rtw_pci
endif
endif
ifneq ($(USER_MODULE_NAME),)
MODULE_NAME := $(USER_MODULE_NAME)
endif
ifneq ($(KERNELRELEASE),)
rtk_core := core/rtw_cmd.o \
core/rtw_security.o \
core/rtw_debug.o \
core/rtw_io.o \
core/rtw_ioctl_query.o \
core/rtw_ioctl_set.o \
core/rtw_ieee80211.o \
core/rtw_mlme.o \
core/rtw_mlme_ext.o \
core/rtw_wlan_util.o \
core/rtw_vht.o \
core/rtw_pwrctrl.o \
core/rtw_rf.o \
core/rtw_recv.o \
core/rtw_sta_mgt.o \
core/rtw_ap.o \
core/rtw_xmit.o \
core/rtw_p2p.o \
core/rtw_tdls.o \
core/rtw_br_ext.o \
core/rtw_iol.o \
core/rtw_sreset.o \
core/rtw_btcoex.o \
core/rtw_beamforming.o \
core/rtw_odm.o \
core/efuse/rtw_efuse.o
$(MODULE_NAME)-y += $(rtk_core)
$(MODULE_NAME)-$(CONFIG_INTEL_WIDI) += core/rtw_intel_widi.o
$(MODULE_NAME)-$(CONFIG_WAPI_SUPPORT) += core/rtw_wapi.o \
core/rtw_wapi_sms4.o
$(MODULE_NAME)-y += $(_OS_INTFS_FILES)
$(MODULE_NAME)-y += $(_HAL_INTFS_FILES)
$(MODULE_NAME)-y += $(_OUTSRC_FILES)
$(MODULE_NAME)-y += $(_PLATFORM_FILES)
$(MODULE_NAME)-$(CONFIG_MP_INCLUDED) += core/rtw_mp.o \
core/rtw_mp_ioctl.o
ifeq ($(CONFIG_RTL8723A), y)
$(MODULE_NAME)-$(CONFIG_MP_INCLUDED)+= core/rtw_bt_mp.o
endif
ifeq ($(CONFIG_RTL8723B), y)
$(MODULE_NAME)-$(CONFIG_MP_INCLUDED)+= core/rtw_bt_mp.o
endif
ifeq ($(CONFIG_RTL8821A), y)
$(MODULE_NAME)-$(CONFIG_MP_INCLUDED)+= core/rtw_bt_mp.o
endif
obj-$(CONFIG_RTL8723BS) := $(MODULE_NAME).o
else
export CONFIG_RTL8723BS = m
all: modules
modules:
$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KSRC) M=$(shell pwd) modules
strip:
$(CROSS_COMPILE)strip $(MODULE_NAME).ko --strip-unneeded
install:
install -p -m 644 $(MODULE_NAME).ko $(MODDESTDIR)
/sbin/depmod -a ${KVER}
uninstall:
rm -f $(MODDESTDIR)/$(MODULE_NAME).ko
/sbin/depmod -a ${KVER}
config_r:
@echo "make config"
/bin/bash script/Configure script/config.in
.PHONY: modules clean
clean:
cd hal/OUTSRC/ ; rm -fr */*.mod.c */*.mod */*.o */.*.cmd */*.ko
cd hal/OUTSRC/ ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
cd hal/led ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
cd hal ; rm -fr */*/*.mod.c */*/*.mod */*/*.o */*/.*.cmd */*/*.ko
cd hal ; rm -fr */*.mod.c */*.mod */*.o */.*.cmd */*.ko
cd hal ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
cd core/efuse ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
cd core ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
cd os_dep/linux ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
cd os_dep ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
cd platform ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
rm -fr Module.symvers ; rm -fr Module.markers ; rm -fr modules.order
rm -fr *.mod.c *.mod *.o .*.cmd *.ko *~
rm -fr .tmp_versions
endif |
using System;
using Server.Mobiles;
namespace Server.Items
{
public abstract class BaseThrown : BaseRanged
{
private Mobile m_Thrower;
private Mobile m_Target;
private Point3D m_KillSave;
public BaseThrown(int itemID)
: base(itemID)
{
}
public BaseThrown(Serial serial)
: base(serial)
{
}
public abstract int MinThrowRange { get; }
public virtual int MaxThrowRange
{
get
{
return MinThrowRange + 3;
}
}
public override int DefMaxRange
{
get
{
int baseRange = MaxThrowRange;
var attacker = Parent as Mobile;
if (attacker != null)
{
return (baseRange - 3) + ((attacker.Str - AosStrengthReq) / ((140 - AosStrengthReq) / 3));
}
else
{
return baseRange;
}
}
}
public override int EffectID
{
get
{
return ItemID;
}
}
public override Type AmmoType
{
get
{
return null;
}
}
public override Item Ammo
{
get
{
return null;
}
}
public override int DefHitSound
{
get
{
return 0x5D3;
}
}
public override int DefMissSound
{
get
{
return 0x5D4;
}
}
public override SkillName DefSkill
{
get
{
return SkillName.Throwing;
}
}
public override WeaponAnimation DefAnimation
{
get
{
return WeaponAnimation.Throwing;
}
}
public override SkillName AccuracySkill
{
get
{
return SkillName.Throwing;
}
}
public override TimeSpan OnSwing(Mobile attacker, IDamageable damageable)
{
TimeSpan ts = base.OnSwing(attacker, damageable);
// time it takes to throw it around including mystic arc
if (ts < TimeSpan.FromMilliseconds(1000))
ts = TimeSpan.FromMilliseconds(1000);
return ts;
}
public override bool OnFired(Mobile attacker, IDamageable damageable)
{
m_Thrower = attacker;
if (!attacker.InRange(damageable, 1))
{
attacker.MovingEffect(damageable, EffectID, 18, 1, false, false, Hue, 0);
}
return true;
}
public override void OnHit(Mobile attacker, IDamageable damageable, double damageBonus)
{
m_KillSave = damageable.Location;
if (!(WeaponAbility.GetCurrentAbility(attacker) is MysticArc))
Timer.DelayCall(TimeSpan.FromMilliseconds(333.0), new TimerCallback(ThrowBack));
base.OnHit(attacker, damageable, damageBonus);
}
public override void OnMiss(Mobile attacker, IDamageable damageable)
{
m_Target = damageable as Mobile;
if (!(WeaponAbility.GetCurrentAbility(attacker) is MysticArc))
Timer.DelayCall(TimeSpan.FromMilliseconds(333.0), new TimerCallback(ThrowBack));
base.OnMiss(attacker, damageable);
}
public virtual void ThrowBack()
{
if (m_Target != null)
m_Target.MovingEffect(m_Thrower, EffectID, 18, 1, false, false, Hue, 0);
else if (m_Thrower != null)
Effects.SendMovingParticles(new Entity(Serial.Zero, m_KillSave, m_Thrower.Map), m_Thrower, ItemID, 18, 0, false, false, Hue, 0, 9502, 1, 0, (EffectLayer)255, 0x100);
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)1); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
if (version == 0)
InheritsItem = true;
}
#region Old Item Serialization Vars
/* DO NOT USE! Only used in serialization of abyss reaver that originally derived from Item */
public bool InheritsItem { get; protected set; }
#endregion
}
} |
#!/bin/sh
test_description='git apply should not get confused with rename/copy.
'
. ./test-lib.sh
# setup
mkdir -p klibc/arch/x86_64/include/klibc
cat >klibc/arch/x86_64/include/klibc/archsetjmp.h <<\EOF
/*
* arch/x86_64/include/klibc/archsetjmp.h
*/
#ifndef _KLIBC_ARCHSETJMP_H
#define _KLIBC_ARCHSETJMP_H
struct __jmp_buf {
unsigned long __rbx;
unsigned long __rsp;
unsigned long __rbp;
unsigned long __r12;
unsigned long __r13;
unsigned long __r14;
unsigned long __r15;
unsigned long __rip;
};
typedef struct __jmp_buf jmp_buf[1];
#endif /* _SETJMP_H */
EOF
cat >klibc/README <<\EOF
This is a simple readme file.
EOF
cat >patch <<\EOF
diff --git a/klibc/arch/x86_64/include/klibc/archsetjmp.h b/include/arch/cris/klibc/archsetjmp.h
similarity index 76%
copy from klibc/arch/x86_64/include/klibc/archsetjmp.h
copy to include/arch/cris/klibc/archsetjmp.h
a/klibc/arch/x86_64/include/klibc/archsetjmp.h
+++ b/include/arch/cris/klibc/archsetjmp.h
@@ -1,21 +1,24 @@
/*
- * arch/x86_64/include/klibc/archsetjmp.h
+ * arch/cris/include/klibc/archsetjmp.h
*/
#ifndef _KLIBC_ARCHSETJMP_H
#define _KLIBC_ARCHSETJMP_H
struct __jmp_buf {
- unsigned long __rbx;
- unsigned long __rsp;
- unsigned long __rbp;
- unsigned long __r12;
- unsigned long __r13;
- unsigned long __r14;
- unsigned long __r15;
- unsigned long __rip;
+ unsigned long __r0;
+ unsigned long __r1;
+ unsigned long __r2;
+ unsigned long __r3;
+ unsigned long __r4;
+ unsigned long __r5;
+ unsigned long __r6;
+ unsigned long __r7;
+ unsigned long __r8;
+ unsigned long __sp;
+ unsigned long __srp;
};
typedef struct __jmp_buf jmp_buf[1];
-#endif /* _SETJMP_H */
+#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/klibc/arch/x86_64/include/klibc/archsetjmp.h b/include/arch/m32r/klibc/archsetjmp.h
similarity index 66%
rename from klibc/arch/x86_64/include/klibc/archsetjmp.h
rename to include/arch/m32r/klibc/archsetjmp.h
a/klibc/arch/x86_64/include/klibc/archsetjmp.h
+++ b/include/arch/m32r/klibc/archsetjmp.h
@@ -1,21 +1,21 @@
/*
- * arch/x86_64/include/klibc/archsetjmp.h
+ * arch/m32r/include/klibc/archsetjmp.h
*/
#ifndef _KLIBC_ARCHSETJMP_H
#define _KLIBC_ARCHSETJMP_H
struct __jmp_buf {
- unsigned long __rbx;
- unsigned long __rsp;
- unsigned long __rbp;
+ unsigned long __r8;
+ unsigned long __r9;
+ unsigned long __r10;
+ unsigned long __r11;
unsigned long __r12;
unsigned long __r13;
unsigned long __r14;
unsigned long __r15;
- unsigned long __rip;
};
typedef struct __jmp_buf jmp_buf[1];
-#endif /* _SETJMP_H */
+#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/klibc/README b/klibc/README
a/klibc/README
+++ b/klibc/README
@@ -1,1 +1,4 @@
This is a simple readme file.
+And we add a few
+lines at the
+end of it.
diff --git a/klibc/README b/klibc/arch/README
copy from klibc/README
copy to klibc/arch/README
a/klibc/README
+++ b/klibc/arch/README
@@ -1,1 +1,3 @@
This is a simple readme file.
+And we copy it to one level down, and
+add a few lines at the end of it.
EOF
find klibc -type f -print | xargs git update-index --add
test_expect_success 'check rename/copy patch' 'git apply --check patch'
test_expect_success 'apply rename/copy patch' 'git apply --index patch'
test_done |
#include <string.h>
#include <time.h>
#include <gammu-config.h>
#include "../../gsmcomon.h"
#include "../../gsmphones.h"
#include "../../misc/coding/coding.h"
#include "../../service/gsmmisc.h"
#include "../../service/gsmcal.h"
#include "../nokia/nfunc.h"
#include "../pfunc.h"
#ifdef GSM_ENABLE_GNAPGEN
unsigned char <API key>[] = {
MEM_SM, 0x01,
MEM_ON, 0x03,
MEM_DC, 0x05,
MEM_RC, 0x06,
MEM_MC, 0x07,
0x00, 0x00
};
GSM_Error GNAPGEN_Install(GSM_StateMachine *s, const char *ExtraPath, gboolean Minimal)
{
GSM_StateMachine *gsm;
GSM_Debug_Info *debug_info;
GSM_Config *cfg;
GSM_Error error;
GSM_File INIFile, AppletFile;
AppletFile.Buffer = NULL;
AppletFile.Used = 0;
INIFile.Buffer = NULL;
INIFile.Used = 0;
error = PHONE_FindDataFile(s, &AppletFile, ExtraPath, "gnapplet.sis");
if (error != ERR_NONE) {
smprintf(s, "Failed to load applet data!\n");
return <API key>;
}
error = PHONE_FindDataFile(s, &INIFile, ExtraPath, "gnapplet.ini");
if (error != ERR_NONE) {
smprintf(s, "Failed to load applet configuration!\n");
return <API key>;
}
gsm = <API key>();
if (gsm == NULL) {
return ERR_MOREMEMORY;
}
/* Copy debug configuration */
debug_info = GSM_GetDebug(gsm);
*debug_info = *GSM_GetDebug(s);
debug_info->closable = FALSE;
<API key>(GSM_GetDebug(s)->df, FALSE, debug_info);
GSM_SetDebugLevel(s->CurrentConfig->DebugLevel, debug_info);
/* Generate configuration */
cfg = GSM_GetConfig(gsm, 0);
cfg->Device = strdup(s->CurrentConfig->Device);
cfg->Connection = strdup("blueobex");
strcpy(cfg->Model, "obexnone");
strcpy(cfg->DebugLevel, s->CurrentConfig->DebugLevel);
cfg->UseGlobalDebugFile = s->CurrentConfig->UseGlobalDebugFile;
/* We have one configuration */
GSM_SetConfigNum(gsm, 1);
error = GSM_InitConnection(gsm, 1);
if (error != ERR_NONE) {
return error;
}
error = PHONE_UploadFile(gsm, &AppletFile);
free(AppletFile.Buffer);
if (error != ERR_NONE) {
return error;
}
error = PHONE_UploadFile(gsm, &INIFile);
free(AppletFile.Buffer);
if (error != ERR_NONE) {
return error;
}
error = <API key>(gsm);
if (error != ERR_NONE) {
return error;
}
/* Free up used memory */
<API key>(gsm);
return ERR_NONE;
}
GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s) {
<API key> *Priv = &s->Phone.Data.Priv.GNAPGEN;
int i;
int pos = 10;
if( msg->Buffer[3] == 17){
smprintf(s, "Invalid memory type");
return ERR_UNKNOWN;
}
Priv->SMSCount = msg->Buffer[8] * 256 + msg->Buffer[9];
smprintf(s, "SMS count: %d\n", Priv->SMSCount );
for( i=0; i<Priv->SMSCount; i++ ) {
smprintf(s, "Entry id %d: %d\n", i, msg->Buffer[pos+1] * 256 * 256 + msg->Buffer[pos+2]*256+msg->Buffer[pos+3]);
Priv->SMSIDs[i].byte1 = msg->Buffer[pos];
Priv->SMSIDs[i].byte2 = msg->Buffer[pos+1];
Priv->SMSIDs[i].byte3 = msg->Buffer[pos+2];
Priv->SMSIDs[i].byte4 = msg->Buffer[pos+3];
pos += 4;
}
return ERR_NONE;
}
static GSM_Error <API key>(GSM_StateMachine *s, int folderid)
{
unsigned char req[] = {0, 3,
0,0x0c}; /* folderID c,d,e,f...*/
req[3] = folderid;
return GSM_WaitFor(s, req, 4, 6, 4, <API key>);
}
static GSM_Error <API key>(GSM_StateMachine *s, GSM_DateTime *DT, unsigned char *req)
{
DT->Year = <API key>(req[0]);
if (DT->Year<90) DT->Year=DT->Year+2000; else DT->Year=DT->Year+1990;
DT->Month = <API key>(req[1]);
DT->Day = <API key>(req[2]);
DT->Hour = <API key>(req[3]);
DT->Minute = <API key>(req[4]);
DT->Second = <API key>(req[5]);
/* Base for timezone is GMT. It's in quarters */
DT->Timezone=(10*(req[6]&0x07)+(req[6]>>4))*3600/4;
if (req[6]&0x08) DT->Timezone = -DT->Timezone;
smprintf(s, "Decoding date & time: ");
smprintf(s, "%s %4d/%02d/%02d ", DayOfWeek(DT->Year, DT->Month, DT->Day),
DT->Year, DT->Month, DT->Day);
smprintf(s, "%02d:%02d:%02d%+03i%02i\n", DT->Hour, DT->Minute, DT->Second,
DT->Timezone / 3600, abs((DT->Timezone % 3600) / 60));
return ERR_NONE;
}
GSM_Error <API key>(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *buffer, <API key> *Layout ) {
int position = 0;
/* setting sms layout */
*Layout = PHONE_SMSDeliver;
Layout->SMSCNumber = 0;
/* the pdu type is always behind the smsc number */
if( (buffer[0] % 2) == 0 )
position = (buffer[0] / 2) + 1;
else
position = ((buffer[0] +1 ) / 2) + 1;
position++;
Layout->firstbyte = position;
/* determine whether the sms was received or sent */
switch( buffer[position] & 1 ) {
/* SMS-DELIVER (incoming message, received) */
case 0:
smprintf(s, "Message type: SMS-DELIVER\n");
sms->PDU = SMS_Deliver;
position++;
Layout->Number = position;
if( (buffer[position] % 2) == 0 )
position += (buffer[position] / 2) + 1;
else
position += ((buffer[position] + 1 ) / 2) + 1;
position++;
Layout->TPPID = position;
position++;
Layout->TPDCS = position;
position++;
Layout->DateTime = position;
Layout->SMSCTime = position;
position += 7;
Layout->TPUDL = position;
position++;
Layout->Text = position;
Layout->TPStatus = 255;
Layout->TPVP = 255;
Layout->TPMR = 255;
break;
/* SMS-SUBMIT (outgoing message, to be sent) */
case 1:
smprintf(s, "Message type: SMS-SUBMIT\n");
sms->PDU = SMS_Submit;
position++;
Layout->TPMR = position;
position++;
Layout->Number = position;
if( (buffer[position] % 2) == 0 )
position += (buffer[position] / 2) + 1;
else
position += ((buffer[position] + 1 ) / 2) + 1;
position++;
Layout->TPPID = position;
position++;
Layout->TPDCS = position;
position++;
/* the validity period field length depends on the VP flag set in the pdu-type */
if( buffer[position] & 0x16 ) {
/* VP is integer represented */
Layout->TPVP = position;
} else if ( buffer[position] & 0x08 ) {
position += 6;
Layout->TPVP = position;
/* VP is semi-octet represented */
}
position++;
Layout->TPUDL = position;
position++;
Layout->Text = position;
Layout->TPStatus = 255;
Layout->DateTime = 255;
Layout->SMSCTime = 255;
break;
default:
smprintf(s, "Unknown message type: (PDU) %d\n", buffer[Layout->firstbyte] );
return ERR_UNKNOWN;
}
return ERR_NONE;
}
GSM_Error <API key>(GSM_StateMachine *s, GSM_SMSMessage *SMS, unsigned char *buffer, size_t length, <API key> *Layout)
{
GSM_DateTime zerodt = {0,0,0,0,0,0,0};
size_t pos;
GSM_Error error;
#ifdef DEBUG
if (Layout->firstbyte == 255) {
smprintf(s, "ERROR: firstbyte in SMS layout not set\n");
return ERR_UNKNOWN;
}
if (Layout->TPDCS != 255) smprintf(s, "TPDCS : %02x %i\n",buffer[Layout->TPDCS] ,buffer[Layout->TPDCS]);
if (Layout->TPMR != 255) smprintf(s, "TPMR : %02x %i\n",buffer[Layout->TPMR] ,buffer[Layout->TPMR]);
if (Layout->TPPID != 255) smprintf(s, "TPPID : %02x %i\n",buffer[Layout->TPPID] ,buffer[Layout->TPPID]);
if (Layout->TPUDL != 255) smprintf(s, "TPUDL : %02x %i\n",buffer[Layout->TPUDL] ,buffer[Layout->TPUDL]);
if (Layout->firstbyte != 255) smprintf(s, "FirstByte : %02x %i\n",buffer[Layout->firstbyte],buffer[Layout->firstbyte]);
if (Layout->Text != 255) smprintf(s, "Text : %02x %i\n",buffer[Layout->Text] ,buffer[Layout->Text]);
#endif
SMS->UDH.Type = UDH_NoUDH;
SMS->Coding = SMS_Coding_8bit;
SMS->Length = 0;
SMS->SMSC.Location = 0;
SMS->SMSC.DefaultNumber[0] = 0;
SMS->SMSC.DefaultNumber[1] = 0;
SMS->SMSC.Number[0] = 0;
SMS->SMSC.Number[1] = 0;
SMS->SMSC.Name[0] = 0;
SMS->SMSC.Name[1] = 0;
SMS->SMSC.Validity.Format = <API key>;
SMS->SMSC.Format = SMS_FORMAT_Text;
SMS->Number[0] = 0;
SMS->Number[1] = 0;
SMS->OtherNumbersNum = 0;
SMS->Name[0] = 0;
SMS->Name[1] = 0;
SMS->ReplyViaSameSMSC = FALSE;
if (Layout->SMSCNumber!=255) {
pos = Layout->SMSCNumber;
error = <API key>(&(s->di), SMS->SMSC.Number, buffer, &pos, length, TRUE);
if (error != ERR_NONE) {
return error;
}
smprintf(s, "SMS center number : \"%s\"\n",DecodeUnicodeString(SMS->SMSC.Number));
}
if ((buffer[Layout->firstbyte] & 0x80)!=0) SMS->ReplyViaSameSMSC=TRUE;
#ifdef DEBUG
if (SMS->ReplyViaSameSMSC) smprintf(s, "SMS centre set for reply\n");
#endif
if (Layout->Number!=255) {
pos = Layout->Number;
error = <API key>(&(s->di), SMS->Number,buffer, &pos, length, TRUE);
if (error != ERR_NONE) {
return error;
}
smprintf(s, "Remote number : \"%s\"\n",DecodeUnicodeString(SMS->Number));
}
if (Layout->Text != 255 && Layout->TPDCS!=255 && Layout->TPUDL!=255) {
SMS->Coding = <API key>(&(s->di), buffer[Layout->TPDCS]);
<API key>(&(s->di), SMS, buffer, *Layout);
}
if (Layout->DateTime != 255) {
<API key>(s, &SMS->DateTime,buffer+(Layout->DateTime));
} else {
SMS->DateTime = zerodt;
}
if (Layout->SMSCTime != 255 && Layout->TPStatus != 255) {
/* GSM 03.40 section 9.2.3.11 (<API key>) */
smprintf(s, "SMSC response date: ");
<API key>(s, &SMS->SMSCTime, buffer+(Layout->SMSCTime));
<API key>(&(s->di), SMS,buffer,*Layout);
<API key>(s, &SMS->DateTime, buffer+(Layout->SMSCTime));
} else {
SMS->SMSCTime = zerodt;
}
SMS->Class = -1;
if (Layout->TPDCS != 255) {
/* GSM 03.40 section 9.2.3.10 (<API key>) and GSM 03.38 section 4 */
if ((buffer[Layout->TPDCS] & 0xD0) == 0x10) {
/* bits 7..4 set to 00x1 */
if ((buffer[Layout->TPDCS] & 0xC) == 0xC) {
smprintf(s, "WARNING: reserved alphabet value in TPDCS\n");
} else {
SMS->Class = (buffer[Layout->TPDCS] & 3);
}
} else if ((buffer[Layout->TPDCS] & 0xF0) == 0xF0) {
/* bits 7..4 set to 1111 */
if ((buffer[Layout->TPDCS] & 8) == 8) {
smprintf(s, "WARNING: set reserved bit 3 in TPDCS\n");
} else {
SMS->Class = (buffer[Layout->TPDCS] & 3);
}
}
smprintf(s, "SMS class: %i\n",SMS->Class);
}
SMS->MessageReference = 0;
if (Layout->TPMR != 255) SMS->MessageReference = buffer[Layout->TPMR];
SMS->ReplaceMessage = 0;
if (Layout->TPPID != 255) {
if (buffer[Layout->TPPID] > 0x40 && buffer[Layout->TPPID] < 0x48) {
SMS->ReplaceMessage = buffer[Layout->TPPID] - 0x40;
}
}
SMS->RejectDuplicates = FALSE;
if ((buffer[Layout->firstbyte] & 0x04)==0x04) SMS->RejectDuplicates = TRUE;
return ERR_NONE;
}
static GSM_Error GNAPGEN_ReplyGetSMS(<API key> *msg, GSM_StateMachine *s) {
GSM_SMSMessage *sms = 0;
unsigned char buffer[800];
int numberOfMessages = 0;
int messageLen = 0;
int state = 0;
int i;
int current=6;
<API key> layout;
numberOfMessages = msg->Buffer[4] * 256 + msg->Buffer[5];
s->Phone.Data.GetSMSMessage->Number = numberOfMessages;
switch( msg->Buffer[msg->Length-1] ) {
case 0x01:
state = SMS_Read;
break;
case 0x03:
state = SMS_UnRead;
break;
case 0x05:
state = SMS_Sent;
break;
case 0x07:
state = SMS_UnSent;
break;
}
for( i=0; i<numberOfMessages; i++ ) {
messageLen = msg->Buffer[current] * 256 + msg->Buffer[current+1];
memset( buffer, 0, 800 );
memcpy( buffer, msg->Buffer + current + 2, messageLen );
current += messageLen + 2;
sms = &s->Phone.Data.GetSMSMessage->SMS[i];
sms->State = state;
s->Phone.Data.GetSMSMessage->SMS[i].Name[0] = 0;
s->Phone.Data.GetSMSMessage->SMS[i].Name[1] = 0;
<API key>(s, sms, buffer, &layout );
<API key>(s, sms,buffer,messageLen,&layout);
}
return ERR_NONE;
}
static GSM_Error GNAPGEN_GetNextSMS(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, gboolean start)
{
<API key> *Priv = &s->Phone.Data.Priv.GNAPGEN;
GSM_Phone_Data *Data = &s->Phone.Data;
/* @todo remove the folder attribute from the request header since it's not used on the phone */
unsigned char req [8] = {0,11,
0x00,0x0c, /* folder */
0x00,0x10,0x00,0x3F}; /* location */
int i;
gboolean skipfolder;
GSM_Error error;
if( start ) {
Priv->CurrentFolderNumber = 0;
Priv->CurrentSMSNumber = 0;
}
/* retrieve the sms IDs for the given folder */
if( Priv->CurrentSMSNumber == 0 )
<API key>(s,Priv->SMSFolderID[Priv->CurrentFolderNumber]);
for( i=0; i<5; i++ )
<API key>(&sms->SMS[i]);
/* if there are no SMS in current folder, just skip it */
do {
if( Priv->SMSCount == 0 ) {
if( (Data->SMSFolders->Number - 1) == Priv->CurrentFolderNumber )
return ERR_EMPTY;
else {
Priv->CurrentSMSNumber = 0;
Priv->CurrentFolderNumber++;
}
<API key>(s,Priv->SMSFolderID[Priv->CurrentFolderNumber]);
skipfolder = TRUE;
} else
skipfolder = FALSE;
} while( skipfolder );
/* set location */
req[4] = Priv->SMSIDs[Priv->CurrentSMSNumber].byte1;
req[5] = Priv->SMSIDs[Priv->CurrentSMSNumber].byte2;
req[6] = Priv->SMSIDs[Priv->CurrentSMSNumber].byte3;
req[7] = Priv->SMSIDs[Priv->CurrentSMSNumber].byte4;
sms->SMS[0].Folder = Priv->SMSFolderID[Priv->CurrentFolderNumber];
if( Priv->CurrentFolderNumber == 0 )
sms->SMS[0].InboxFolder = TRUE;
sms->SMS[0].Location = ( req[4] * (256*256*256) ) + req[5] * 256 * 256 + req[6] * 256 + req[7];
sms->SMS[0].Memory = MEM_ME;
s->Phone.Data.GetSMSMessage=sms;
error = GSM_WaitFor(s, req, 8, 0x6, 500, ID_GetSMSMessage);
if( error != ERR_NONE )
return error;
if( Priv->CurrentSMSNumber == ( Priv->SMSCount - 1 ) ) {
/* last sms in current folder reached, check if there are folders left to checkout */
if( Priv->CurrentFolderNumber == (Data->SMSFolders->Number - 1) )
return ERR_UNKNOWN;
else {
Priv->CurrentSMSNumber = 0;
Priv->CurrentFolderNumber++;
}
} else
Priv->CurrentSMSNumber++;
return error;
}
static GSM_Error <API key>(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *req, <API key> *Layout, int *length)
{
int count = 0;
GSM_Error error;
memset(Layout,255,sizeof(<API key>));
sms->Class = -1;
*Layout = PHONE_SMSSubmit;
/* smsc number is semi-octet */
Layout->SMSCNumber = count;
smprintf(s, "SMSCNumber: %d\n", count );
if( UnicodeLength(sms->SMSC.Number) == 0 )
count += (UnicodeLength(sms->SMSC.Number) / 2) + 1;
else
count += ((UnicodeLength(sms->SMSC.Number) + 1 ) / 2) + 1;
/* firstbyte set in SMS Layout */
Layout->firstbyte = count;
smprintf(s, "firstbyte: %d\n", count);
count++;
if (sms->PDU != SMS_Deliver) {
Layout->TPMR = count;
smprintf(s, "TPMR: %d\n", Layout->TPMR);
count++;
}
/* Phone number */
Layout->Number = count;
smprintf(s, "Number: %d\n", count);
if( UnicodeLength(sms->Number) == 0 )
count += (UnicodeLength(sms->Number) / 2) + 1;
else
count += ((UnicodeLength(sms->Number) + 1 ) / 2) + 1;
Layout->TPPID = count;
smprintf(s, "TPPID: %d\n", count);
count++;
Layout->TPDCS = count;
smprintf(s, "TPDCS: %d\n", count);
count++;
if (sms->PDU == SMS_Deliver) {
Layout->DateTime = count;
smprintf(s, "DateTime: %d\n", count);
count += 7;
} else {
Layout->TPVP = count;
smprintf(s, "TPVP: %d\n", count);
count++;
}
Layout->TPUDL = count;
smprintf(s, "TPUDL: %d\n", count);
count++;
Layout->Text = count;
smprintf(s, "Text: %d\n", count);
error = <API key>(s,sms,req,*Layout,length,FALSE);
if (error != ERR_NONE) return error;
req[0] = 0x0b;
req[10] = 0x07;
return ERR_NONE;
}
static GSM_Error <API key>(GSM_StateMachine *s, GSM_SMSMessage *sms)
{
int length = 11;
GSM_Error error;
<API key> Layout;
unsigned char req [300] = {0,15};
if (sms->PDU == SMS_Deliver) sms->PDU = SMS_Submit;
memset(req+2,0x00,sizeof(req) - 2);
error=<API key>(s, sms, req + 2, &Layout, &length);
if (error != ERR_NONE) return error;
DumpMessage(&s->di, req, length+1);
/* return ERR_NONE; */
smprintf(s, "Sending sms\n");
return s->Protocol.Functions->WriteMessage(s, req, length + 2, 0x06);
}
GSM_Error GNAPGEN_ReplySetSMS (<API key> *msg UNUSED, GSM_StateMachine *s) {
/* @todo do something useful here ;) */
smprintf(s, "SetSMS: got reply\n");
return ERR_NONE;
}
static GSM_Error <API key>(GSM_StateMachine *s, GSM_SMSMessage *sms)
{
int length = 0;
<API key> Layout;
GSM_Error error;
unsigned char req [300] = {0,13,
0x00,0x0c, /* folder */
0x00,0x10,0x00,0x3F}; /* location */
req[3] = sms->Folder;
/* @todo allow existing messages to be edited (not implemented in gnapplet) */
if (sms->PDU == SMS_Deliver)
sms->PDU = SMS_Submit;
memset(req+8,0x00,300-8);
error = <API key>( s, sms, req + 10, &Layout, &length );
if (error != ERR_NONE) return error;
req[9] = length;
s->Phone.Data.SaveSMSMessage=sms;
return GSM_WaitFor(s, req, length+10, 0x6, 4, ID_SaveSMSMessage);
}
static GSM_Error GNAPGEN_AddSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
{
/* <API key>(s, sms, &folderid, &location); */
/* location = 0; */
/* <API key>(s, sms, folderid, location); */
return <API key>(s, sms);
}
static GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s)
{
GSM_Phone_Data *Data = &s->Phone.Data;
smprintf(s, "Network level received: %i\n",msg->Buffer[4]);
Data->SignalQuality->SignalStrength = -1;
Data->SignalQuality->SignalPercent = ((int)msg->Buffer[4]);
Data->SignalQuality->BitErrorRate = -1;
return ERR_NONE;
}
static GSM_Error <API key>(GSM_StateMachine *s, GSM_SignalQuality *sig)
{
unsigned char req[] = {0x00,0x03};
s->Phone.Data.SignalQuality = sig;
smprintf(s, "Getting network level\n");
return GSM_WaitFor(s, req, 2, 0x03, 4, ID_GetSignalQuality);
}
static GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s)
{
GSM_Phone_Data *Data = &s->Phone.Data;
smprintf(s, "Battery level received: %i\n",msg->Buffer[4]);
Data->BatteryCharge->BatteryPercent = ((int)(msg->Buffer[4]));
Data->BatteryCharge->ChargeState = 0;
return ERR_NONE;
}
static GSM_Error <API key>(GSM_StateMachine *s, GSM_BatteryCharge *bat)
{
unsigned char req[] = {0x00, 0x01};
<API key>(bat);
s->Phone.Data.BatteryCharge = bat;
smprintf(s, "Getting battery level\n");
return GSM_WaitFor(s, req, 2, 0x04, 4, ID_GetBatteryCharge);
}
static GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s)
{
GSM_Phone_Data *Data = &s->Phone.Data;
char buf[100];
#ifdef DEBUG
GSM_NetworkInfo NetInfo;
smprintf(s, "Network status : ");
switch (msg->Buffer[9]) {
case 0x00 : smprintf(s, "home network ?\n"); break;
default : smprintf(s, "unknown %i!\n",msg->Buffer[9]); break;
}
if (msg->Buffer[9]==0x00) {
sprintf(NetInfo.CID, "%02X%02X", msg->Buffer[4], msg->Buffer[5]);
smprintf(s, "CID : %s\n", NetInfo.CID);
sprintf(NetInfo.LAC, "%02X%02X", msg->Buffer[6], msg->Buffer[7]);
smprintf(s, "LAC : %s\n", NetInfo.LAC);
memset(buf,0,sizeof(buf));
memcpy(buf,msg->Buffer+11,msg->Buffer[10]*2);
sprintf(NetInfo.NetworkCode,"%s",DecodeUnicodeString(buf));
smprintf(s, "Network code : %s\n", NetInfo.NetworkCode);
smprintf(s, "Network name for Gammu : %s ",
DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode)));
smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode)));
}
#endif
Data->NetworkInfo->NetworkName[0] = 0x00;
Data->NetworkInfo->NetworkName[1] = 0x00;
Data->NetworkInfo->State = 0;
switch (msg->Buffer[8]) {
case 0x00: Data->NetworkInfo->State = GSM_HomeNetwork; break;
}
if (Data->NetworkInfo->State == GSM_HomeNetwork) {
sprintf(Data->NetworkInfo->CID, "%02X%02X", msg->Buffer[4], msg->Buffer[5]);
sprintf(Data->NetworkInfo->LAC, "%02X%02X", msg->Buffer[6], msg->Buffer[7]);
memset(buf,0,sizeof(buf));
memcpy(buf,msg->Buffer+11,msg->Buffer[10]*2);
sprintf(Data->NetworkInfo->NetworkCode,"%s",DecodeUnicodeString(buf));
}
return ERR_NONE;
}
static GSM_Error <API key>(GSM_StateMachine *s, GSM_NetworkInfo *netinfo)
{
unsigned char req[] = {0x00, 0x01};
netinfo->GPRS = 0;
s->Phone.Data.NetworkInfo=netinfo;
smprintf(s, "Getting network info\n");
return GSM_WaitFor(s, req, 2, 0x03, 4, ID_GetNetworkInfo);
}
static GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s)
{
GSM_Phone_Data *Data = &s->Phone.Data;
smprintf(s, "Memory status received\n");
if (msg->Length == 4) return ERR_EMPTY;
Data->MemoryStatus->MemoryUsed = msg->Buffer[8]*256 + msg->Buffer[9];
Data->MemoryStatus->MemoryFree = msg->Buffer[12]*256 + msg->Buffer[13];
smprintf(s, "Free : %i\n",Data->MemoryStatus->MemoryFree);
smprintf(s, "Used : %i\n",Data->MemoryStatus->MemoryUsed);
return ERR_NONE;
}
static GSM_Error <API key>(GSM_StateMachine *s, GSM_MemoryStatus *Status)
{
unsigned char req[] = {0x00,0x07,0x00,
0x00}; /* memory type */
if (Status->MemoryType != MEM_ME) {
req[3] = NOKIA_GetMemoryType(s, Status->MemoryType,<API key>);
if (req[3]==0xff) return ERR_NOTSUPPORTED;
}
s->Phone.Data.MemoryStatus=Status;
smprintf(s, "Getting memory status\n");
return GSM_WaitFor(s, req, 4, 0x02, 4, ID_GetMemoryStatus);
}
GSM_Error <API key>( <API key> *msg, GSM_StateMachine *s ) {
int i,pos=8,type,subtype,len;
GSM_MemoryEntry *entry = s->Phone.Data.Memory;
<API key> *Priv = &s->Phone.Data.Priv.GNAPGEN;
/* 17 == <API key> */
if( msg->Buffer[3] == 17 ) {
smprintf(s, "unknown memory type\n");
return ERR_UNKNOWN;
}
entry->Location=msg->Buffer[5];
entry->EntriesNum=0;
for (i=0;i<msg->Buffer[7];i++) {
type = msg->Buffer[pos]*256+msg->Buffer[pos+1];
subtype = msg->Buffer[pos+2]*256+msg->Buffer[pos+3];
pos+=4;
switch (type) {
/* name */
case 0x07:
len = msg->Buffer[pos]*256+msg->Buffer[pos+1];
if (len!=0) {
entry->Entries[entry->EntriesNum].EntryType=PBK_Text_Name;
entry->Entries[entry->EntriesNum].Location = <API key>;
memcpy(entry->Entries[entry->EntriesNum].Text,msg->Buffer+pos+2,len*2);
entry->Entries[entry->EntriesNum].Text[len*2]=0;
entry->Entries[entry->EntriesNum].Text[len*2+1]=0;
entry->EntriesNum++;
}
pos+=2+len*2;
break;
/* email */
case 0x08:
len = msg->Buffer[pos]*256+msg->Buffer[pos+1];
entry->Entries[entry->EntriesNum].EntryType=PBK_Text_Email;
entry->Entries[entry->EntriesNum].Location = <API key>;
memcpy(entry->Entries[entry->EntriesNum].Text,msg->Buffer+pos+2,len*2);
entry->Entries[entry->EntriesNum].Text[len*2]=0;
entry->Entries[entry->EntriesNum].Text[len*2+1]=0;
entry->EntriesNum++;
pos+=2+len*2;
break;
/* 0x0b is a general identifier for a number */
case 0x0B:
switch(subtype) {
/* fax */
case 0x04:
entry->Entries[entry->EntriesNum].EntryType=PBK_Number_Fax;
entry->Entries[entry->EntriesNum].Location = <API key>;
break;
/* work */
case 0x06:
entry->Entries[entry->EntriesNum].EntryType=PBK_Number_General;
entry->Entries[entry->EntriesNum].Location = PBK_Location_Work;
break;
/* mobile */
case 0x03:
entry->Entries[entry->EntriesNum].EntryType=PBK_Number_Mobile;
entry->Entries[entry->EntriesNum].Location = <API key>;
break;
/* home */
case 0x02:
entry->Entries[entry->EntriesNum].EntryType=PBK_Number_General;
entry->Entries[entry->EntriesNum].Location = PBK_Location_Home;
break;
/* general */
case 0x0a: default:
entry->Entries[entry->EntriesNum].EntryType=PBK_Number_General;
entry->Entries[entry->EntriesNum].Location = <API key>;
break;
}
len = msg->Buffer[pos]*256+msg->Buffer[pos+1];
memcpy(entry->Entries[entry->EntriesNum].Text,msg->Buffer+pos+2,len*2);
entry->Entries[entry->EntriesNum].Text[len*2]=0;
entry->Entries[entry->EntriesNum].Text[len*2+1]=0;
entry->EntriesNum++;
pos+=2+len*2;
break;
/* date */
case 0x13:
entry->Entries[entry->EntriesNum].EntryType=PBK_Date;
entry->Entries[entry->EntriesNum].Location = <API key>;
<API key>(s, msg->Buffer+pos, &entry->Entries[entry->EntriesNum].Date, TRUE, FALSE);
entry->EntriesNum++;
pos+=2+7;
break;
/* note */
case 0x0a:
len = msg->Buffer[pos]*256+msg->Buffer[pos+1];
entry->Entries[entry->EntriesNum].EntryType=PBK_Text_Note;
entry->Entries[entry->EntriesNum].Location = <API key>;
memcpy(entry->Entries[entry->EntriesNum].Text,msg->Buffer+pos+2,len*2);
entry->Entries[entry->EntriesNum].Text[len*2]=0;
entry->Entries[entry->EntriesNum].Text[len*2+1]=0;
entry->EntriesNum++;
pos+=2+len*2;
break;
/* url */
case 0x2c:
len = msg->Buffer[pos]*256+msg->Buffer[pos+1];
entry->Entries[entry->EntriesNum].EntryType=PBK_Text_URL;
entry->Entries[entry->EntriesNum].Location = <API key>;
memcpy(entry->Entries[entry->EntriesNum].Text,msg->Buffer+pos+2,len*2);
entry->Entries[entry->EntriesNum].Text[len*2]=0;
entry->Entries[entry->EntriesNum].Text[len*2+1]=0;
entry->EntriesNum++;
pos+=2+len*2;
break;
default:
Priv->LastContactArrived = TRUE;
return ERR_UNKNOWN;
}
}
return ERR_NONE;
}
static GSM_Error <API key>( GSM_StateMachine *s, GSM_MemoryEntry *entry, gboolean start ) {
<API key> *Priv = &s->Phone.Data.Priv.GNAPGEN;
unsigned char req[] = {0x00, 11,
0x00, 0x00, /* memory type */
0x00, 0x00}; /* start (gboolean) */
if( start ) {
Priv->LastContactArrived = FALSE;
req[5] = 0x01;
} else
req[5] = 0x00;
if( Priv->LastContactArrived )
return ERR_EMPTY;
if (entry->MemoryType != MEM_ME) {
req[3] = NOKIA_GetMemoryType(s, entry->MemoryType,<API key>);
if (req[3]==0xff) return ERR_NOTSUPPORTED;
}
s->Phone.Data.Memory=entry;
return GSM_WaitFor(s, req, 6, 0x02, 6, ID_GetMemory);
}
static GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s)
{
int i,pos=6,type,subtype,len;
GSM_MemoryEntry *entry = s->Phone.Data.Memory;
entry->EntriesNum=0;
smprintf(s, "Phonebook entry received\n");
for (i=0;i<msg->Buffer[5];i++) {
type = msg->Buffer[pos]*256+msg->Buffer[pos+1];
subtype = msg->Buffer[pos+2]*256+msg->Buffer[pos+3];
pos+=4;
switch (type) {
/* name */
case 0x07:
len = msg->Buffer[pos]*256+msg->Buffer[pos+1];
if (len!=0) {
entry->Entries[entry->EntriesNum].EntryType=PBK_Text_Name;
entry->Entries[entry->EntriesNum].Location = <API key>;
memcpy(entry->Entries[entry->EntriesNum].Text,msg->Buffer+pos+2,len*2);
entry->Entries[entry->EntriesNum].Text[len*2]=0;
entry->Entries[entry->EntriesNum].Text[len*2+1]=0;
entry->EntriesNum++;
}
pos+=2+len*2;
break;
/* email */
case 0x08:
len = msg->Buffer[pos]*256+msg->Buffer[pos+1];
entry->Entries[entry->EntriesNum].EntryType=PBK_Text_Email;
entry->Entries[entry->EntriesNum].Location = <API key>;
memcpy(entry->Entries[entry->EntriesNum].Text,msg->Buffer+pos+2,len*2);
entry->Entries[entry->EntriesNum].Text[len*2]=0;
entry->Entries[entry->EntriesNum].Text[len*2+1]=0;
entry->EntriesNum++;
pos+=2+len*2;
break;
/* 0x0b is a general identifier for a number */
case 0x0B:
switch(subtype) {
/* fax */
case 0x04:
entry->Entries[entry->EntriesNum].EntryType=PBK_Number_Fax;
entry->Entries[entry->EntriesNum].Location = <API key>;
break;
/* work */
case 0x06:
entry->Entries[entry->EntriesNum].EntryType=PBK_Number_General;
entry->Entries[entry->EntriesNum].Location = PBK_Location_Work;
break;
/* mobile */
case 0x03:
entry->Entries[entry->EntriesNum].EntryType=PBK_Number_Mobile;
entry->Entries[entry->EntriesNum].Location = <API key>;
break;
/* home */
case 0x02:
entry->Entries[entry->EntriesNum].EntryType=PBK_Number_General;
entry->Entries[entry->EntriesNum].Location = PBK_Location_Home;
break;
/* general */
case 0x0a: default:
entry->Entries[entry->EntriesNum].EntryType=PBK_Number_General;
entry->Entries[entry->EntriesNum].Location = <API key>;
break;
}
len = msg->Buffer[pos]*256+msg->Buffer[pos+1];
memcpy(entry->Entries[entry->EntriesNum].Text,msg->Buffer+pos+2,len*2);
entry->Entries[entry->EntriesNum].Text[len*2]=0;
entry->Entries[entry->EntriesNum].Text[len*2+1]=0;
entry->EntriesNum++;
pos+=2+len*2;
break;
/* date */
case 0x13:
entry->Entries[entry->EntriesNum].EntryType=PBK_Date;
entry->Entries[entry->EntriesNum].Location = <API key>;
<API key>(s, msg->Buffer+pos, &entry->Entries[entry->EntriesNum].Date, TRUE, FALSE);
entry->EntriesNum++;
pos+=2+7;
break;
/* note */
case 0x0a:
len = msg->Buffer[pos]*256+msg->Buffer[pos+1];
entry->Entries[entry->EntriesNum].EntryType=PBK_Text_Note;
entry->Entries[entry->EntriesNum].Location = <API key>;
memcpy(entry->Entries[entry->EntriesNum].Text,msg->Buffer+pos+2,len*2);
entry->Entries[entry->EntriesNum].Text[len*2]=0;
entry->Entries[entry->EntriesNum].Text[len*2+1]=0;
entry->EntriesNum++;
pos+=2+len*2;
break;
/* url */
case 0x2c:
len = msg->Buffer[pos]*256+msg->Buffer[pos+1];
entry->Entries[entry->EntriesNum].EntryType=PBK_Text_URL;
entry->Entries[entry->EntriesNum].Location = <API key>;
memcpy(entry->Entries[entry->EntriesNum].Text,msg->Buffer+pos+2,len*2);
entry->Entries[entry->EntriesNum].Text[len*2]=0;
entry->Entries[entry->EntriesNum].Text[len*2+1]=0;
entry->EntriesNum++;
pos+=2+len*2;
break;
default:
smprintf(s, "unknown %i\n",type);
return ERR_UNKNOWN;
}
}
return ERR_NONE;
}
static GSM_Error GNAPGEN_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
{
unsigned char req[] = {0x00, 0x01,
0x00, 0x00, /* memory type */
0x00, 0x00, 0x00, 0x00}; /* location */
if (entry->MemoryType != MEM_ME) {
req[3] = NOKIA_GetMemoryType(s, entry->MemoryType,<API key>);
if (req[3]==0xff) return ERR_NOTSUPPORTED;
}
if (entry->Location==0x00) return ERR_INVALIDLOCATION;
req[6] = entry->Location / 256;
req[7] = entry->Location % 256;
s->Phone.Data.Memory=entry;
smprintf(s, "Getting phonebook entry\n");
return GSM_WaitFor(s, req, 8, 0x02, 6, ID_GetMemory);
}
static GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s) {
smprintf(s, "Got reply: SetMemory()\n");
if( msg->Buffer[4] == 0 )
return ERR_NONE;
else
return ERR_UNKNOWN;
}
static GSM_Error GNAPGEN_SetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
{
unsigned char req[1000] = {0x00, 0x03,
0x00, 0x00, /* memory type */
0x00, 0x00, 0x00, 0x00, /* location */
0x00, 0x00 }; /* number of entries to read */
/* for each entry, 2 bytes are reserved for the entry type, */
/* 2 bytes for the entry sub-type if available and 64 byte for the actual entry */
int currentByte = 10;
int i = 0;
int entryCount = 0;
GSM_SubMemoryEntry *subMemoryEntry;
memset( req + 3,0x00,sizeof(req) - 3 );
if (entry->MemoryType != MEM_ME) {
req[3] = NOKIA_GetMemoryType(s, entry->MemoryType,<API key>);
if (req[3]==0xff) return ERR_NOTSUPPORTED;
}
if (entry->Location==0x00) return ERR_INVALIDLOCATION;
req[6] = entry->Location / 256;
req[7] = entry->Location % 256;
for( i=0; i< entry->EntriesNum; i++ ) {
subMemoryEntry = &entry->Entries[i];
switch( subMemoryEntry->EntryType ) {
break;
case PBK_Number_General:
case PBK_Number_Mobile:
if (subMemoryEntry->Location == PBK_Location_Home) {
req[currentByte++] = 0x00;
req[currentByte++] = 0x0b;
req[currentByte++] = 0x00;
req[currentByte++] = 0x02;
} else if (subMemoryEntry->Location == PBK_Location_Home) {
req[currentByte++] = 0x00;
req[currentByte++] = 0x0b;
req[currentByte++] = 0x00;
req[currentByte++] = 0x06;
} else {
req[currentByte++] = 0x00;
req[currentByte++] = 0x0b;
req[currentByte++] = 0x00;
req[currentByte++] = 0x03;
}
break;
case PBK_Number_Fax:
req[currentByte++] = 0x00;
req[currentByte++] = 0x0b;
req[currentByte++] = 0x00;
req[currentByte++] = 0x04;
break;
case PBK_Text_Email:
req[currentByte++] = 0x00;
req[currentByte++] = 0x08;
req[currentByte++] = 0x00;
req[currentByte++] = 0x00;
break;
case PBK_Text_Name:
req[currentByte++] = 0x00;
req[currentByte++] = 0x07;
req[currentByte++] = 0x00;
req[currentByte++] = 0x00;
break;
default:
continue;
}
entryCount++;
req[currentByte++] = 0x00;
req[currentByte++] = UnicodeLength( subMemoryEntry->Text );
memcpy( req + currentByte, subMemoryEntry->Text, UnicodeLength( subMemoryEntry->Text ) * 2 );
currentByte += UnicodeLength( subMemoryEntry->Text ) * 2;
}
req[9] = entryCount;
return GSM_WaitFor(s, req, currentByte, 0x02, 4, ID_SetMemory);
}
GSM_Error <API key> ( <API key> *msg UNUSED, GSM_StateMachine *s ) {
/* @todo implement error handling */
smprintf(s, "Deleted\n");
return ERR_NONE;
}
static GSM_Error <API key> ( GSM_StateMachine *s, GSM_MemoryEntry *entry ) {
unsigned char req[] = {0x00, 0x05,
0x00, 0x00, /* memory type */
0x00, 0x00, 0x00, 0x00 }; /* location */
if (entry->MemoryType != MEM_ME) {
req[3] = NOKIA_GetMemoryType(s, entry->MemoryType,<API key>);
if (req[3]==0xff) return ERR_NOTSUPPORTED;
}
if (entry->Location==0x00) return ERR_INVALIDLOCATION;
req[6] = entry->Location / 256;
req[7] = entry->Location % 256;
return GSM_WaitFor(s, req, 8, 0x02, 6, ID_DeleteMemory);
}
static GSM_Error GNAPGEN_AddMemory ( GSM_StateMachine *s, GSM_MemoryEntry *entry ) {
entry->Location = -1;
return GNAPGEN_SetMemory( s, entry );
}
static GSM_Error <API key> ( <API key> *msg, GSM_StateMachine *s ) {
/* 17 == <API key> */
switch( msg->Buffer[3] ) {
case 16:
smprintf(s, "invalid location\n");
return ERR_UNKNOWN;
case 17:
smprintf(s, "unknown memory type\n");
return ERR_UNKNOWN;
case 0:
smprintf(s, "deleted");
}
return ERR_NONE;
}
static GSM_Error <API key>(GSM_StateMachine *s, GSM_SMSMessage *sms) {
unsigned char req[] = {0x00, 17,
0x00, 0x00, /* folder */
0x00, 0x00, 0x00, 0x00 }; /* location */
req[3] = sms->Folder;
req[4] = (sms->Location / (256*256*256)) % 256;
req[5] = (sms->Location / (256*256)) % 256;
req[6] = (sms->Location / 256) % 256 ;
req[7] = sms->Location % 256;
return GSM_WaitFor(s, req, 8, 0x06, 6, ID_DeleteSMSMessage );
}
GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s)
{
GSM_ToDoEntry *Last = s->Phone.Data.ToDo;
int pos = 8;
smprintf(s, "TODO received\n");
memcpy(Last->Entries[0].Text,msg->Buffer+pos+2,(msg->Buffer[pos]*256+msg->Buffer[pos+1])*2);
Last->Entries[0].Text[(msg->Buffer[pos]*256+msg->Buffer[pos+1])*2] = 0;
Last->Entries[0].Text[(msg->Buffer[pos]*256+msg->Buffer[pos+1])*2+1] = 0;
smprintf(s, "Text: \"%s\"\n",DecodeUnicodeString(Last->Entries[0].Text));
pos+=(msg->Buffer[pos]*256+msg->Buffer[pos+1])*2+2;
/**
* @todo There might be better type.
*/
Last->Type = GSM_CAL_MEMO;
switch (msg->Buffer[pos]) {
case 1 : Last->Priority = GSM_Priority_High; break;
case 2 : Last->Priority = GSM_Priority_Medium; break;
case 3 : Last->Priority = GSM_Priority_Low; break;
default : return ERR_UNKNOWN;
}
smprintf(s, "Priority: %i\n",msg->Buffer[4]);
Last->Entries[0].EntryType = TODO_TEXT;
Last->EntriesNum = 1;
return ERR_NONE;
}
static GSM_Error GNAPGEN_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, gboolean refresh)
{
GSM_Error error;
unsigned char req[] = {0x00, 0x07,
0x00, 0x00, 0x00, 0x00}; /* Location */
if (refresh) {
ToDo->Location = 1;
} else {
ToDo->Location++;
}
req[4] = ToDo->Location / 256;
req[5] = ToDo->Location % 256;
s->Phone.Data.ToDo = ToDo;
smprintf(s, "Getting todo\n");
error = GSM_WaitFor(s, req, 6, 7, 4, ID_GetToDo);
if (error == ERR_INVALIDLOCATION) error = ERR_EMPTY;
return error;
}
GSM_Error <API key>(GSM_StateMachine *s, GSM_CalendarEntry *Note)
{
unsigned char req[] = {0x00, 0x05,
0x00, 0x00, 0x00, 0x00}; /* Location */
req[4] = Note->Location / 256;
req[5] = Note->Location % 256;
smprintf(s, "Deleting calendar note\n");
return GSM_WaitFor(s, req, 6, 7, 4, <API key>);
}
GSM_Error GNAPGEN_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
{
GSM_DateTime DT;
int Text, Time, Alarm, Phone, EndTime, Location, current=7;
unsigned char req[5000] = {
0x00, 0x03,0x00,0x00,
0x00, 0x00, 0x00, 0x00, /* location ? */
0x00}; /* type */
switch(Note->Type) {
case GSM_CAL_MEETING : req[6] = 0x01; break;
case GSM_CAL_REMINDER : req[6] = 0x04; break;
case GSM_CAL_MEMO :
default : req[6] = 0x08; break;
}
<API key>(Note, &Text, &Time, &Alarm, &Phone, &EndTime, &Location);
if (Time == -1) return ERR_UNKNOWN;
memcpy(&DT,&Note->Entries[Time].Date,sizeof(GSM_DateTime));
req[current++] = DT.Year / 256;
req[current++] = DT.Year % 256;
req[current++] = DT.Month;
req[current++] = DT.Day;
req[current++] = DT.Hour;
req[current++] = DT.Minute;
req[current++] = DT.Second;
if (EndTime == -1) {
memset(&DT,0,sizeof(GSM_DateTime));
DT.Month = 1;
DT.Day = 1;
} else {
memcpy(&DT,&Note->Entries[EndTime].Date,sizeof(GSM_DateTime));
}
req[current++] = DT.Year / 256;
req[current++] = DT.Year % 256;
req[current++] = DT.Month;
req[current++] = DT.Day;
req[current++] = DT.Hour;
req[current++] = DT.Minute;
req[current++] = DT.Second;
if (Alarm == -1) {
memset(&DT,0,sizeof(GSM_DateTime));
DT.Month = 1;
DT.Day = 1;
} else {
memcpy(&DT,&Note->Entries[Alarm].Date,sizeof(GSM_DateTime));
}
req[current++] = DT.Year / 256;
req[current++] = DT.Year % 256;
req[current++] = DT.Month;
req[current++] = DT.Day;
req[current++] = DT.Hour;
req[current++] = DT.Minute;
req[current++] = DT.Second;
if (Text == -1) return ERR_UNKNOWN;
req[current++] = UnicodeLength(Note->Entries[Text].Text) / 256;
req[current++] = UnicodeLength(Note->Entries[Text].Text) % 256;
memcpy(req+current,Note->Entries[Text].Text,UnicodeLength(Note->Entries[Text].Text)*2);
current+=UnicodeLength(Note->Entries[Text].Text)*2;
req[current++] = 0;
req[current++] = 0;
if (Location==-1) {
req[current++] = 0;
req[current++] = 0;
} else {
req[current++] = UnicodeLength(Note->Entries[Location].Text) / 256;
req[current++] = UnicodeLength(Note->Entries[Location].Text) % 256;
memcpy(req+current,Note->Entries[Location].Text,UnicodeLength(Note->Entries[Location].Text)*2);
current+=UnicodeLength(Note->Entries[Location].Text)*2;
}
if (Note->Type == GSM_CAL_MEETING) {
<API key>(&(s->di), req+current, NULL, Note);
current+=2;
} else {
req[current++] = 0xff;
req[current++] = 0xff;
}
smprintf(s, "Writing calendar note\n");
return GSM_WaitFor(s, req, current, 7, 4, ID_SetCalendarNote);
}
static GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s)
{
int pos;
GSM_CalendarEntry *Entry = s->Phone.Data.Cal;
switch (msg->Buffer[3]) {
case 0x00:
smprintf(s, "Calendar note received\n");
switch (msg->Buffer[8]) {
case 0x01: Entry->Type = GSM_CAL_MEETING; break;
case 0x04: Entry->Type = GSM_CAL_REMINDER; break;
case 0x08: Entry->Type = GSM_CAL_MEMO; break;
default :
smprintf(s, "Unknown note type %i\n",msg->Buffer[8]);
return ERR_UNKNOWNRESPONSE;
}
pos = 9;
Entry->EntriesNum = 0;
<API key>(s, msg->Buffer+pos, &Entry->Entries[Entry->EntriesNum].Date, TRUE, FALSE);
smprintf(s, "Time : %02i-%02i-%04i %02i:%02i:%02i\n",
Entry->Entries[Entry->EntriesNum].Date.Day,Entry->Entries[Entry->EntriesNum].Date.Month,Entry->Entries[Entry->EntriesNum].Date.Year,
Entry->Entries[Entry->EntriesNum].Date.Hour,Entry->Entries[Entry->EntriesNum].Date.Minute,Entry->Entries[Entry->EntriesNum].Date.Second);
Entry->Entries[Entry->EntriesNum].EntryType = CAL_START_DATETIME;
Entry->EntriesNum++;
pos+=7;
<API key>(s, msg->Buffer+pos, &Entry->Entries[Entry->EntriesNum].Date, TRUE, FALSE);
smprintf(s, "Time : %02i-%02i-%04i %02i:%02i:%02i\n",
Entry->Entries[Entry->EntriesNum].Date.Day,Entry->Entries[Entry->EntriesNum].Date.Month,Entry->Entries[Entry->EntriesNum].Date.Year,
Entry->Entries[Entry->EntriesNum].Date.Hour,Entry->Entries[Entry->EntriesNum].Date.Minute,Entry->Entries[Entry->EntriesNum].Date.Second);
Entry->Entries[Entry->EntriesNum].EntryType = CAL_END_DATETIME;
Entry->EntriesNum++;
pos+=7;
<API key>(s, msg->Buffer+pos, &Entry->Entries[Entry->EntriesNum].Date, TRUE, FALSE);
if (Entry->Entries[Entry->EntriesNum].Date.Year!=0) {
smprintf(s, "Alarm : %02i-%02i-%04i %02i:%02i:%02i\n",
Entry->Entries[Entry->EntriesNum].Date.Day,Entry->Entries[Entry->EntriesNum].Date.Month,Entry->Entries[Entry->EntriesNum].Date.Year,
Entry->Entries[Entry->EntriesNum].Date.Hour,Entry->Entries[Entry->EntriesNum].Date.Minute,Entry->Entries[Entry->EntriesNum].Date.Second);
Entry->Entries[Entry->EntriesNum].EntryType = <API key>;
Entry->EntriesNum++;
} else {
smprintf(s, "No alarm\n");
}
pos+=7;
memcpy(Entry->Entries[Entry->EntriesNum].Text,msg->Buffer+pos+2,msg->Buffer[pos+1]*2);
Entry->Entries[Entry->EntriesNum].Text[msg->Buffer[pos+1]*2 ]=0;
Entry->Entries[Entry->EntriesNum].Text[msg->Buffer[pos+1]*2+1]=0;
smprintf(s, "Text \"%s\"\n",DecodeUnicodeString(Entry->Entries[Entry->EntriesNum].Text));
if (msg->Buffer[pos+1] != 0x00) {
Entry->Entries[Entry->EntriesNum].EntryType = CAL_TEXT;
Entry->EntriesNum++;
}
pos+=msg->Buffer[pos+1]*2+4;
memcpy(Entry->Entries[Entry->EntriesNum].Text,msg->Buffer+pos+2,msg->Buffer[pos+1]*2);
Entry->Entries[Entry->EntriesNum].Text[msg->Buffer[pos+1]*2 ]=0;
Entry->Entries[Entry->EntriesNum].Text[msg->Buffer[pos+1]*2+1]=0;
smprintf(s, "Text \"%s\"\n",DecodeUnicodeString(Entry->Entries[Entry->EntriesNum].Text));
if (msg->Buffer[pos+1] != 0x00) {
Entry->Entries[Entry->EntriesNum].EntryType = CAL_LOCATION;
Entry->EntriesNum++;
}
pos+=msg->Buffer[pos+1]*2+2;
if (Entry->Type == GSM_CAL_MEETING) {
<API key>(&(s->di), msg->Buffer+pos, NULL, Entry);
}
return ERR_NONE;
case 0x10:
smprintf(s, "Can't get calendar note - too high location?\n");
return ERR_INVALIDLOCATION;
}
return ERR_UNKNOWNRESPONSE;
}
static GSM_Error <API key>(GSM_StateMachine *s, GSM_CalendarEntry *Note, gboolean start)
{
GSM_Error error;
<API key> *Priv = &s->Phone.Data.Priv.GNAPGEN;
unsigned char req[] = {0x00, 0x01,
0x00, 0x00, 0x00, 0x00}; /* Location */
if (start) {
Priv->LastCalendarPos = 1;
} else {
Priv->LastCalendarPos++;
}
Note->Location = Priv->LastCalendarPos;
req[4] = Priv->LastCalendarPos / 256;
req[5] = Priv->LastCalendarPos % 256;
s->Phone.Data.Cal=Note;
smprintf(s, "Getting calendar note\n");
error = GSM_WaitFor(s, req, 6, 7, 4, ID_GetCalendarNote);
if (error == ERR_INVALIDLOCATION) error = ERR_EMPTY;
return error;
}
static GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s)
{
GSM_Phone_Data *Data = &s->Phone.Data;
smprintf(s, "Used in phone memory : %i\n",msg->Buffer[6]*256+msg->Buffer[7]);
smprintf(s, "Unread in phone memory : %i\n",msg->Buffer[10]*256+msg->Buffer[11]);
Data->SMSStatus->PhoneSize = 0xff*256+0xff;
Data->SMSStatus->PhoneUsed = msg->Buffer[6]*256+msg->Buffer[7];
Data->SMSStatus->PhoneUnRead = msg->Buffer[10]*256+msg->Buffer[11];
Data->SMSStatus->TemplatesUsed = 0;
return ERR_NONE;
}
static GSM_Error <API key>(GSM_StateMachine *s, GSM_SMSMemoryStatus *status)
{
unsigned char req[] = {0x00, 0x09};
s->Phone.Data.SMSStatus=status;
smprintf(s, "Getting SMS status\n");
return GSM_WaitFor(s, req, 2, 0x6, 2, ID_GetSMSStatus);
}
static GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s)
{
int j, pos;
GSM_Phone_Data *Data = &s->Phone.Data;
<API key> *Priv = &s->Phone.Data.Priv.GNAPGEN;
smprintf(s, "SMS folders names received\n");
Data->SMSFolders->Number = msg->Buffer[5];
pos = 6;
for (j=0;j<msg->Buffer[5];j++) {
if (msg->Buffer[pos+3]><API key>) {
smprintf(s, "Too long text\n");
return ERR_UNKNOWNRESPONSE;
}
Priv->SMSFolderID[j] = msg->Buffer[pos+1];
memcpy(Data->SMSFolders->Folder[j].Name,msg->Buffer + pos+4,msg->Buffer[pos+3]*2);
Data->SMSFolders->Folder[j].Name[msg->Buffer[pos+3]*2]=0;
Data->SMSFolders->Folder[j].Name[msg->Buffer[pos+3]*2+1]=0;
smprintf(s, "id: %d, folder name: \"%s\"\n",msg->Buffer[pos+1], DecodeUnicodeString(Data->SMSFolders->Folder[j].Name));
if( msg->Buffer[pos+1] == 12 )
Data->SMSFolders->Folder[j].InboxFolder = TRUE;
else
Data->SMSFolders->Folder[j].InboxFolder = FALSE;
Data->SMSFolders->Folder[j].OutboxFolder = FALSE;
/**
* @todo Need to detect outbox folder somehow.
*/
Data->SMSFolders->Folder[j].Memory = MEM_ME;
pos+=msg->Buffer[pos+3]*2+4;
}
return ERR_NONE;
}
static GSM_Error <API key>(GSM_StateMachine *s, GSM_SMSFolders *folders)
{
unsigned char req[] = {0x00,0x01};
s->Phone.Data.SMSFolders=folders;
smprintf(s, "Getting SMS folders\n");
return GSM_WaitFor(s, req, 2, 0x06, 4, ID_GetSMSFolders);
}
static GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s)
{
int pos=7;
GSM_Phone_Data *Data = &s->Phone.Data;
if (msg->Buffer[7]*2><API key>) {
smprintf(s, "Too long name\n");
return ERR_UNKNOWNRESPONSE;
}
memcpy(Data->SMSC->Name,msg->Buffer+8,msg->Buffer[7]*2);
Data->SMSC->Name[msg->Buffer[7]*2] = 0;
Data->SMSC->Name[msg->Buffer[7]*2+1] = 0;
smprintf(s, " Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name));
pos+=msg->Buffer[7]*2;
pos+=4;
Data->SMSC->Format = SMS_FORMAT_Text;
Data->SMSC->Validity.Format = <API key>;
Data->SMSC->Validity.Relative = SMS_VALID_Max_Time;
Data->SMSC->DefaultNumber[0] = 0;
Data->SMSC->DefaultNumber[1] = 0;
memcpy(Data->SMSC->Number,msg->Buffer+pos+4,msg->Buffer[pos+3]*2);
Data->SMSC->Number[msg->Buffer[pos+3]*2] = 0;
Data->SMSC->Number[msg->Buffer[pos+3]*2+1] = 0;
smprintf(s, " Number \"%s\"\n", DecodeUnicodeString(Data->SMSC->Number));
return ERR_NONE;
}
static GSM_Error GNAPGEN_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
{
unsigned char req[] = {0x00,21,
0x00,0x01}; /* location */
if (smsc->Location==0x00) return ERR_INVALIDLOCATION;
req[3]=smsc->Location-1;
s->Phone.Data.SMSC=smsc;
smprintf(s, "Getting SMSC\n");
return GSM_WaitFor(s, req, 4, 0x06, 4, ID_GetSMSC);
}
static GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s)
{
GSM_Phone_Data *Data = &s->Phone.Data;
smprintf(s, "Alarm received\n");
if (msg->Buffer[4] == 0x00) return ERR_EMPTY;
Data->Alarm->Repeating = FALSE;
Data->Alarm->Text[0] = 0;
Data->Alarm->Text[1] = 0;
<API key>(s, msg->Buffer+5, &Data->Alarm->DateTime, TRUE, FALSE);
return ERR_NONE;
}
static GSM_Error GNAPGEN_GetAlarm(GSM_StateMachine *s, GSM_Alarm *timedelta)
{
unsigned char req[] = {0x00, 0x05};
if (timedelta->Location != 1) return ERR_NOTSUPPORTED;
s->Phone.Data.Alarm=timedelta;
smprintf(s, "Getting alarm\n");
return GSM_WaitFor(s, req, 2, 0x8, 4, ID_GetAlarm);
}
static GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s)
{
smprintf(s, "Date & time received\n");
<API key>(s, msg->Buffer+4, s->Phone.Data.DateTime, TRUE, FALSE);
return ERR_NONE;
}
static GSM_Error GNAPGEN_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
{
unsigned char req[2] = {0x00,0x01};
s->Phone.Data.DateTime=date_time;
smprintf(s, "Getting date & time\n");
return GSM_WaitFor(s, req, 2, 0x08, 4, ID_GetDateTime);
}
GSM_Error <API key>( <API key> *msg UNUSED, GSM_StateMachine *s ) {
smprintf(s, "Dialed voice number\n");
return ERR_NONE;
}
static GSM_Error GNAPGEN_DialVoice ( GSM_StateMachine *s, char *Number, GSM_CallShowNumber ShowNumber UNUSED) {
/* @todo implement ShowNumber */
unsigned char req[100] = {0x00,0x09};
int currentByte = 2;
unsigned char unicodeNumber[200];
memset( req + 2,0x00,sizeof(req) - 2 );
EncodeUnicode( unicodeNumber, Number, strlen(Number) );
req[currentByte++] = 0x00;
req[currentByte++] = UnicodeLength( unicodeNumber );
memcpy( req + currentByte, unicodeNumber, UnicodeLength( unicodeNumber ) * 2 );
currentByte += UnicodeLength( unicodeNumber ) * 2;
return GSM_WaitFor(s, req, currentByte, 0x02, 8, ID_DialVoice);
}
GSM_Error GNAPGEN_ReplyGetHW(<API key> *msg, GSM_StateMachine *s)
{
unsigned char buff[200];
int pos=8,len,i;
for (i=0;i<5;i++) {
len=msg->Buffer[pos]*256+msg->Buffer[pos+1];
memset(buff,0,sizeof(buff));
memcpy(buff,msg->Buffer+pos+2,len*2);
pos+=2+len*2;
}
strcpy(s->Phone.Data.HardwareCache,DecodeUnicodeString(buff));
smprintf(s, "Received HW %s\n",s->Phone.Data.HardwareCache);
return ERR_NONE;
}
GSM_Error GNAPGEN_GetHW(GSM_StateMachine *s, char *value)
{
GSM_Error error;
unsigned char req[2] = {0x00,0x01};
if (strlen(s->Phone.Data.HardwareCache)!=0) {
strcpy(value,s->Phone.Data.HardwareCache);
return ERR_NONE;
}
smprintf(s, "Getting HW\n");
error = GSM_WaitFor(s, req, 2, 0x01, 2, ID_GetHardware);
if (error == ERR_NONE) strcpy(value,s->Phone.Data.HardwareCache);
return error;
}
GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s)
{
unsigned char buff[200];
int pos=8,len;
<API key> *Priv = &s->Phone.Data.Priv.GNAPGEN;
smprintf(s, "gnapplet %i. %i\n",msg->Buffer[4]*256+msg->Buffer[5],msg->Buffer[6]*256+msg->Buffer[7]);
Priv->GNAPPLETVer = msg->Buffer[4]*256+msg->Buffer[5] * 100 + msg->Buffer[6]*256+msg->Buffer[7];
len=msg->Buffer[pos]*256+msg->Buffer[pos+1];
memset(buff,0,sizeof(buff));
memcpy(buff,msg->Buffer+pos+2,len*2);
strcpy(s->Phone.Data.Manufacturer,DecodeUnicodeString(buff));
return ERR_NONE;
}
GSM_Error <API key>(GSM_StateMachine *s)
{
unsigned char req[2] = {0x00,0x01};
smprintf(s, "Getting manufacturer\n");
return GSM_WaitFor(s, req, 2, 0x01, 2, ID_GetManufacturer);
}
GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s)
{
unsigned char buff[200];
int pos=8,len,i;
for (i=0;i<3;i++) {
len=msg->Buffer[pos]*256+msg->Buffer[pos+1];
memset(buff,0,sizeof(buff));
memcpy(buff,msg->Buffer+pos+2,len*2);
pos+=2+len*2;
}
strcpy(s->Phone.Data.IMEI,DecodeUnicodeString(buff));
smprintf(s, "Received IMEI %s\n",s->Phone.Data.IMEI);
return ERR_NONE;
}
GSM_Error GNAPGEN_GetIMEI(GSM_StateMachine *s)
{
unsigned char req[2] = {0x00,0x01};
smprintf(s, "Getting IMEI\n");
return GSM_WaitFor(s, req, 2, 0x01, 2, ID_GetIMEI);
}
GSM_Error GNAPGEN_ReplyGetID(<API key> *msg UNUSED, GSM_StateMachine *s UNUSED)
{
return ERR_NONE;
}
GSM_Error <API key>(<API key> *msg, GSM_StateMachine *s)
{
GSM_CutLines lines;
GSM_Phone_Data *Data = &s->Phone.Data;
if (Data->RequestID!=ID_GetManufacturer && Data->RequestID!=ID_GetModel) return ERR_NONE;
InitLines(&lines);
SplitLines(DecodeUnicodeString(msg->Buffer+6), msg->Length-6, &lines, "\x0A", 1, "", 0, FALSE);
strcpy(Data->Model,GetLineString(DecodeUnicodeString(msg->Buffer+6), &lines, 4));
smprintf(s, "Received model %s\n",Data->Model);
Data->ModelInfo = GetModelData(s, NULL, Data->Model, NULL);
strcpy(Data->VerDate,GetLineString(DecodeUnicodeString(msg->Buffer+6), &lines, 3));
smprintf(s, "Received firmware date %s\n",Data->VerDate);
strcpy(Data->Version,GetLineString(DecodeUnicodeString(msg->Buffer+6), &lines, 2));
smprintf(s, "Received firmware version %s\n",Data->Version);
<API key>(s);
FreeLines(&lines);
return ERR_NONE;
}
GSM_Error GNAPGEN_GetModel (GSM_StateMachine *s)
{
unsigned char req[2] = {0x00,0x01};
GSM_Error error;
if (strlen(s->Phone.Data.Model)>0) return ERR_NONE;
smprintf(s, "Getting model\n");
error = GSM_WaitFor(s, req, 2, 0x01, 2, ID_GetModel);
if (error == ERR_NONE) {
smprintf_level(s, D_TEXT, "[Connected model - \"%s\"]\n",
s->Phone.Data.Model);
}
return error;
}
GSM_Error GNAPGEN_GetFirmware (GSM_StateMachine *s)
{
unsigned char req[2] = {0x00,0x01};
GSM_Error error;
if (strlen(s->Phone.Data.Version)>0) return ERR_NONE;
smprintf(s, "Getting firmware version\n");
error = GSM_WaitFor(s, req, 2, 0x01, 2, ID_GetFirmware);
if (error==ERR_NONE) {
smprintf_level(s, D_TEXT, "[Firmware version - \"%s\"]\n",
s->Phone.Data.Version);
smprintf_level(s, D_TEXT, "[Firmware date - \"%s\"]\n",
s->Phone.Data.VerDate);
}
return error;
}
static GSM_Error GNAPGEN_Initialise (GSM_StateMachine *s)
{
<API key> *Priv = &s->Phone.Data.Priv.GNAPGEN;
GSM_Error error;
error = <API key>(s);
if (error != ERR_NONE) return error;
if (Priv->GNAPPLETVer == 18) return ERR_NONE;
return ERR_GNAPPLETWRONG;
}
static GSM_Reply_Function <API key>[] = {
/* informations */
{<API key>, "\x01",0x01,0x02,ID_GetIMEI },
{GNAPGEN_ReplyGetHW, "\x01",0x01,0x02,ID_GetHardware },
{<API key>, "\x01",0x01,0x02,ID_GetManufacturer },
{GNAPGEN_ReplyGetID, "\x01",0x01,0x02,ID_GetModel },
{GNAPGEN_ReplyGetID, "\x01",0x01,0x02,ID_GetFirmware },
{<API key>, "\x02",0x01,0x02,ID_GetMemory },
{<API key>, "\x02",0x01,0x08,ID_GetMemoryStatus },
{<API key>, "\x02",0x01,0x06,ID_DeleteMemory },
{<API key>, "\x02",0x01,0x04,ID_SetMemory },
{<API key>, "\x02",0x01,10 ,ID_DialVoice },
{<API key>, "\x02",0x01,12 ,ID_GetMemory },
{<API key>, "\x03",0x01,0x02,ID_GetNetworkInfo },
{<API key>, "\x03",0x01,0x04,ID_GetSignalQuality },
{<API key>, "\x04",0x01,0x02,ID_GetBatteryCharge },
/* type 5 is DEBUG */
{<API key>, "\x05",0x01,0x02,ID_IncomingFrame },
/* type 6 is SMS */
{<API key>, "\x06",0x01,0x02,ID_GetSMSFolders },
{<API key>, "\x06",0x01,0x0A,ID_GetSMSStatus },
{<API key>, "\x06",0x01,0x16,ID_GetSMSC },
{<API key>,"\x06",0x01,0x04,<API key> },
{<API key>, "\x06",0x01,18,ID_DeleteSMSMessage },
{GNAPGEN_ReplyGetSMS, "\x06",0x01,12,ID_GetSMSMessage },
{GNAPGEN_ReplySetSMS, "\x06",0x01,14,ID_SaveSMSMessage },
/* calendar */
{<API key>, "\x07",0x01,0x02,ID_GetCalendarNote },
{NONEFUNCTION, "\x07",0x01,0x06,<API key> },
{<API key>, "\x07",0x01,0x08,ID_GetToDo },
/* time */
{<API key>, "\x08",0x01,0x02,ID_GetDateTime },
{<API key>, "\x08",0x01,0x06,ID_GetAlarm },
{NULL, "\x00",0x00,0x00,ID_None }
};
GSM_Phone_Functions GNAPGENPhone = {
"gnap",
<API key>,
NOTIMPLEMENTED, /* Install */
GNAPGEN_Initialise,
NONEFUNCTION, /* Terminate */
GSM_DispatchMessage,
NOTSUPPORTED, /* ShowStartInfo */
<API key>,
GNAPGEN_GetModel,
GNAPGEN_GetFirmware,
GNAPGEN_GetIMEI,
NOTSUPPORTED, /* GetOriginalIMEI */
NOTSUPPORTED, /* GetManufactureMonth */
NOTSUPPORTED, /* GetProductCode */
GNAPGEN_GetHW,
NOTSUPPORTED, /* GetPPM */
NOTSUPPORTED, /* GetSIMIMSI */
GNAPGEN_GetDateTime,
NOTSUPPORTED, /* SetDateTime */
GNAPGEN_GetAlarm,
NOTSUPPORTED, /* SetAlarm */
NOTSUPPORTED, /* GetLocale */
NOTSUPPORTED, /* SetLocale */
NOTSUPPORTED, /* PressKey */
NOTSUPPORTED, /* Reset */
NOTSUPPORTED, /* ResetPhoneSettings */
NOTSUPPORTED, /* EnterSecurityCode */
NOTSUPPORTED, /* GetSecurityStatus */
NOTSUPPORTED, /* GetDisplayStatus */
NOTSUPPORTED, /* SetAutoNetworkLogin */
<API key>,
<API key>,
<API key>,
NOTSUPPORTED, /* GetCategory */
NOTSUPPORTED, /* AddCategory */
NOTSUPPORTED, /* GetCategoryStatus */
<API key>,
GNAPGEN_GetMemory,
<API key>,
GNAPGEN_SetMemory,
GNAPGEN_AddMemory,
<API key>,
NOTIMPLEMENTED, /* DeleteAllMemory */
NOTSUPPORTED, /* GetSpeedDial */
NOTSUPPORTED, /* SetSpeedDial */
GNAPGEN_GetSMSC,
NOTSUPPORTED, /* SetSMSC */
<API key>,
NOTSUPPORTED, /* GetSMS */
GNAPGEN_GetNextSMS,
NOTSUPPORTED, /* SetSMS */
GNAPGEN_AddSMS,
<API key>,
<API key>,
NOTSUPPORTED, /* SendSavedSMS */
NOTSUPPORTED, /* SetFastSMSSending */
NOTSUPPORTED, /* SetIncomingSMS */
NOTSUPPORTED, /* SetIncomingCB */
<API key>,
NOTSUPPORTED, /* AddSMSFolder */
NOTSUPPORTED, /* DeleteSMSFolder */
GNAPGEN_DialVoice, /* DialVoice */
NOTIMPLEMENTED, /* DialService */
NOTSUPPORTED, /* AnswerCall */
NOTSUPPORTED, /* CancelCall */
NOTSUPPORTED, /* HoldCall */
NOTSUPPORTED, /* UnholdCall */
NOTSUPPORTED, /* ConferenceCall */
NOTSUPPORTED, /* SplitCall */
NOTSUPPORTED, /* TransferCall */
NOTSUPPORTED, /* SwitchCall */
NOTSUPPORTED, /* GetCallDivert */
NOTSUPPORTED, /* SetCallDivert */
NOTSUPPORTED, /* CancelAllDiverts */
NOTSUPPORTED, /* SetIncomingCall */
NOTSUPPORTED, /* SetIncomingUSSD */
NOTSUPPORTED, /* SendDTMF */
NOTSUPPORTED, /* GetRingtone */
NOTSUPPORTED, /* SetRingtone */
NOTSUPPORTED, /* GetRingtonesInfo */
NOTSUPPORTED, /* DeleteUserRingtones */
NOTSUPPORTED, /* PlayTone */
NOTSUPPORTED, /* GetWAPBookmark */
NOTSUPPORTED, /* SetWAPBookmark */
NOTSUPPORTED, /* DeleteWAPBookmark */
NOTSUPPORTED, /* GetWAPSettings */
NOTSUPPORTED, /* SetWAPSettings */
NOTSUPPORTED, /* GetSyncMLSettings */
NOTSUPPORTED, /* SetSyncMLSettings */
NOTSUPPORTED, /* GetChatSettings */
NOTSUPPORTED, /* SetChatSettings */
NOTSUPPORTED, /* GetMMSSettings */
NOTSUPPORTED, /* SetMMSSettings */
NOTSUPPORTED, /* GetMMSFolders */
NOTSUPPORTED, /* GetNextMMSFileInfo */
NOTSUPPORTED, /* GetBitmap */
NOTSUPPORTED, /* SetBitmap */
NOTSUPPORTED, /* GetToDoStatus */
NOTSUPPORTED, /* GetToDo */
GNAPGEN_GetNextToDo,
NOTSUPPORTED, /* SetToDo */
NOTSUPPORTED, /* AddToDo */
NOTSUPPORTED, /* DeleteToDo */
NOTSUPPORTED, /* DeleteAllToDo */
NOTSUPPORTED, /* GetCalendarStatus */
NOTSUPPORTED, /* GetCalendar */
<API key>,
NOTSUPPORTED, /* SetCalendar */
GNAPGEN_AddCalendar,
<API key>,
NOTSUPPORTED, /* DeleteAllCalendar */
NOTSUPPORTED, /* GetCalendarSettings */
NOTSUPPORTED, /* SetCalendarSettings */
NOTSUPPORTED, /* GetNoteStatus */
NOTSUPPORTED, /* GetNote */
NOTSUPPORTED, /* GetNextNote */
NOTSUPPORTED, /* SetNote */
NOTSUPPORTED, /* AddNote */
NOTSUPPORTED, /* DeleteNote */
NOTSUPPORTED, /* DeleteAllNotes */
NOTSUPPORTED, /* GetProfile */
NOTSUPPORTED, /* SetProfile */
NOTSUPPORTED, /* GetFMStation */
NOTSUPPORTED, /* SetFMStation */
NOTSUPPORTED, /* ClearFMStations */
NOTSUPPORTED, /* GetNextFileFolder */
NOTSUPPORTED, /* GetFolderListing */
NOTSUPPORTED, /* GetNextRootFolder */
NOTSUPPORTED, /* SetFileAttributes */
NOTSUPPORTED, /* GetFilePart */
NOTSUPPORTED, /* AddFilePart */
NOTSUPPORTED, /* SendFilePart */
NOTSUPPORTED, /* GetFileSystemStatus */
NOTSUPPORTED, /* DeleteFile */
NOTSUPPORTED, /* AddFolder */
NOTSUPPORTED, /* DeleteFolder */
NOTSUPPORTED, /* GetGPRSAccessPoint */
NOTSUPPORTED, /* SetGPRSAccessPoint */
NOTSUPPORTED, /* GetScreenshot */
NOTSUPPORTED /* SetPower */
};
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/ |
import {<API key>, <API key>} from '@angular/common/http/testing';
import {inject, TestBed} from '@angular/core/testing';
import {ScheduleService} from './schedule-service';
import {HTTP_INTERCEPTORS} from '@angular/common/http';
import {ErrorInterceptor} from '../shared/<API key>';
import {NO_ERRORS_SCHEMA} from '@angular/core';
import {SaeService} from '../shared/sae-service';
import {ScheduleTestdata} from './schedule-testdata';
import {ApplianceTestdata} from '../appliance/appliance-testdata';
import {Logger, Options} from '../log/logger';
import {Level} from '../log/level';
describe('ScheduleService', () => {
beforeEach(() => TestBed.<API key>({
imports: [<API key>],
providers: [
ScheduleService,
{
provide: HTTP_INTERCEPTORS,
useClass: ErrorInterceptor,
multi: true,
},
Logger,
{provide: Options, useValue: {level: Level.DEBUG}},
],
schemas: [NO_ERRORS_SCHEMA],
}));
afterEach(inject([<API key>], (httpMock: <API key>) => {
httpMock.verify();
}));
it('should return an empty array if the appliance has no schedules', (done: any) => {
const service = TestBed.get(ScheduleService);
const httpMock = TestBed.get(<API key>);
const applianceId = ApplianceTestdata.getApplianceId();
service.getSchedules(applianceId).subscribe(
(res) => expect(res).toEqual([]),
() => {},
() => { done(); }
);
const req = httpMock.expectOne(`${SaeService.API}/schedules?id=${applianceId}`);
expect(req.request.method).toEqual('GET');
req.flush('', { status: 204, statusText: 'Not content' });
});
it('should return a day time frame schedule', () => {
const service = TestBed.get(ScheduleService);
const httpMock = TestBed.get(<API key>);
const applianceId = ApplianceTestdata.getApplianceId();
service.getSchedules(applianceId).subscribe(res => expect(res).toEqual([ScheduleTestdata.<API key>()]));
const req = httpMock.expectOne(`${SaeService.API}/schedules?id=${applianceId}`);
expect(req.request.method).toEqual('GET');
req.flush([ScheduleTestdata.<API key>(true)]);
});
it('should return a consecutive days time frame schedule', () => {
const service = TestBed.get(ScheduleService);
const httpMock = TestBed.get(<API key>);
const applianceId = ApplianceTestdata.getApplianceId();
service.getSchedules(applianceId).subscribe(res => expect(res).toEqual([ScheduleTestdata.<API key>()]));
const req = httpMock.expectOne(`${SaeService.API}/schedules?id=${applianceId}`);
expect(req.request.method).toEqual('GET');
req.flush([ScheduleTestdata.<API key>(true)]);
});
xit('should update the schedules', () => {
const service = TestBed.get(ScheduleService);
const httpMock = TestBed.get(<API key>);
const applianceId = ApplianceTestdata.getApplianceId();
service.setSchedules(applianceId, [ScheduleTestdata.<API key>()]).subscribe(res => expect(res).toBeTruthy());
const req = httpMock.expectOne(`${SaeService.API}/schedules?id=${applianceId}`);
expect(req.request.method).toEqual('PUT');
expect(JSON.parse(req.request.body)).toEqual(jasmine.objectContaining([ScheduleTestdata.<API key>(false)]));
});
}); |
#include <iostream>
#include "Menu.h"
int main()
{
Menu m;
m.MainMenu();
return 42;
} |
// ReSharper disable All
using MixERP.Net.Framework;
using MixERP.Net.Entities.Transactions;
using MixERP.Net.Schemas.Transactions.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using MixERP.Net.ApplicationState.Cache;
using MixERP.Net.Common.Extensions;
using PetaPoco;
namespace MixERP.Net.Api.Transactions
{
<summary>
Provides a direct HTTP access to execute the function GetProductView.
</summary>
[RoutePrefix("api/v1.5/transactions/procedures/get-product-view")]
public class <API key> : ApiController
{
<summary>
Login id of application user accessing this API.
</summary>
public long _LoginId { get; set; }
<summary>
User id of application user accessing this API.
</summary>
public int _UserId { get; set; }
<summary>
Currently logged in office id of application user accessing this API.
</summary>
public int _OfficeId { get; set; }
<summary>
The name of the database where queries are being executed on.
</summary>
public string _Catalog { get; set; }
private <API key> procedure;
public class Annotation
{
public int UserId { get; set; }
public string Book { get; set; }
public int OfficeId { get; set; }
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public string Office { get; set; }
public string Party { get; set; }
public string PriceType { get; set; }
public string User { get; set; }
public string ReferenceNumber { get; set; }
public string StatementReference { get; set; }
}
public <API key>()
{
this._LoginId = AppUsers.GetCurrent().View.LoginId.ToLong();
this._UserId = AppUsers.GetCurrent().View.UserId.ToInt();
this._OfficeId = AppUsers.GetCurrent().View.OfficeId.ToInt();
this._Catalog = AppUsers.GetCurrentUserDB();
this.procedure = new <API key>
{
_Catalog = this._Catalog,
_LoginId = this._LoginId,
_UserId = this._UserId
};
}
[AcceptVerbs("POST")]
[Route("execute")]
[Route("~/api/transactions/procedures/get-product-view/execute")]
public IEnumerable<<API key>> Execute([FromBody] Annotation annotation)
{
try
{
this.procedure.UserId = annotation.UserId;
this.procedure.Book = annotation.Book;
this.procedure.OfficeId = annotation.OfficeId;
this.procedure.DateFrom = annotation.DateFrom;
this.procedure.DateTo = annotation.DateTo;
this.procedure.Office = annotation.Office;
this.procedure.Party = annotation.Party;
this.procedure.PriceType = annotation.PriceType;
this.procedure.User = annotation.User;
this.procedure.ReferenceNumber = annotation.ReferenceNumber;
this.procedure.StatementReference = annotation.StatementReference;
return this.procedure.Execute();
}
catch (<API key>)
{
throw new <API key>(new HttpResponseMessage(HttpStatusCode.Forbidden));
}
catch (MixERPException ex)
{
throw new <API key>(new HttpResponseMessage
{
Content = new StringContent(ex.Message),
StatusCode = HttpStatusCode.InternalServerError
});
}
catch
{
throw new <API key>(new HttpResponseMessage(HttpStatusCode.InternalServerError));
}
}
}
} |
<!DOCTYPE html PUBLIC "-
<html xmlns="http:
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="your description goes here" />
<meta name="keywords" content="your,keywords,goes,here" />
<meta name="author" content="Your Name / Original design: Andreas Viklund - http://andreasviklund.com/" />
<link rel="stylesheet" type="text/css" href="variant.css" media="screen,projection" title="Variant Portal" />
<title>Variant Portal v1.0</title>
</head>
<body>
<div id="container">
<div id="toplinks">
<p><a href="#">Link 1</a> · <a href="#">Link 2</a> · <a href="#">Link 3</a> · <a href="#">Link 4</a></p>
</div>
<div id="logo">
<h1><a href="index.html">Variant Portal</a></h1>
<p>A free website template by Andreas...</p>
</div>
<h2 class="hide">Site menu:</h2>
<ul id="navitab">
<li><a class="current" href="index.html">Start</a></li>
<li><a href="#">Bio</a></li>
<li><a href="#">Downloads</a></li>
<li><a href="#">Photos</a></li>
<li><a href="#">Tour</a></li>
<li><a href="#">Interviews</a></li>
</ul>
<div id="desc">
<div class="splitleft">
<h2>Welcome to Variant!</h2>
<p>Simple, clean and accessible. Valid code (XHTML 1.0 Strict), small file size and tested to work with all major web browsers and common mobile devices. Variant Portal is a starting point, open for changes and free to download and use. Get your message out to the world without visual distractions or annoying effects...</p>
<p class="right">/ Andreas, template designer</p>
</div>
<div class="splitright">
<h2>Sample links:</h2>
<ul>
<li><a href="http://andreasviklund.com/templates/">More free templates</a> (andreasviklund.com)</li>
<li><a href="http:
<li><a href="http://andreasviklund.com/">Articles, tips and tricks on web design</a></li>
</ul>
<p class="right"><a href="#">Read more »</a></p>
</div>
<hr />
</div>
<div id="main">
<h2>The idea behind the design:</h2>
<p>For this first free template release on andreasviklund.com in 2010, I have paid a tribute to the simple and useful kind of design which I am a fan of myself. With minimal use of images, a simple code structure and small number of CSS ID:s and classes, this template should be easy to learn and easy to work with. The template can be customized for use with different content management systems, or used to build plain HTML websites directly. The small file size creates a design which loads fast even on slow internet connections, and the design has been tested with recent versions of Mozilla Firefox, Internet Explorer, Safari and Chrome - as well as on several mobile devices.</p>
<p class="block"><strong>Please note:</strong> I have not aimed at making any kind of trendy or shiny look for this design. I prefer to keep it clean and simple, and let others add the details that will make the design special and unique. By default, it degrades well with full functionality even in browsers that do not support CSS, so in theory it works just as well on a 10 year old computer as it does on a new machine or on your mobile phone (provided that it supports XHTML).</p>
<h3>What is a free website template?</h3>
<p>If you like this layout and would like to use it in any way, you are free to do so. You can make any changes you may want to, and there is no cost involved for using the template for commercial projects. All I ask for is that you leave the "Template design by Andreas Viklund" link in the footer of the site.</p>
<p>Version: 1.0 (June 26, 2010)</p>
</div>
<div id="sidebar">
<h2>Sidebar presentation:</h2>
<p>Space for advertisements, presentation material, logotype or anything else you may want to keep in focus.</p>
<div class="splitleft">
<h2>Sample links</h2>
<ul class="sidelink">
<li><a href="#">Assignments</a></li>
<li><a href="#">Events</a></li>
<li><a href="#">General</a></li>
<li><a href="#">Releases</a></li>
<li><a href="#">Surprises</a></li>
<li><a href="#">Themes</a>
<ul>
<li><a href="#">WordPress</a></li>
<li><a href="#">Mobile</a></li>
</ul>
</li>
<li><a href="#">Wild things</a></li>
</ul>
</div>
<div class="splitright">
<h2>More templates</h2>
<ul class="sidelink">
<li><a href="http://andreasviklund.com/templates/1024px/">1024px</a></li>
<li><a href="http://andreasviklund.com/templates/andreas00/">andreas00</a></li>
<li><a href="http://andreasviklund.com/templates/andreas01/">andreas01</a></li>
<li><a href="http://andreasviklund.com/templates/andreas02/">andreas02</a></li>
<li><a href="http://andreasviklund.com/templates/andreas03/">andreas03</a></li>
<li><a href="http://andreasviklund.com/templates/andreas04/">andreas04</a></li>
<li><a href="http://andreasviklund.com/templates/andreas05/">andreas05</a></li>
</ul>
<h2>Recent posts</h2>
<ul>
<li>Jun 26: <a href="#">Template released!</a></li>
<li>Jun 24: <a href="#">Browser compability testing</a></li>
</ul>
</div>
<hr />
</div>
<div id="footer">
<p>Copyright © 2010 Your Name · Template design by <a href="http://andreasviklund.com/">Andreas Viklund</a></p>
</div>
</div>
</body>
</html> |
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/* Mutter interface for talking to GTK+ UI module */
#ifndef META_UI_H
#define META_UI_H
/* Don't include gtk.h or gdk.h here */
#include <meta/common.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <cairo.h>
#include <glib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
typedef struct _MetaUI MetaUI;
typedef gboolean (* MetaEventFunc) (XEvent *xevent, gpointer data);
typedef enum
{
<API key>,
<API key>
} MetaUIDirection;
void meta_ui_init (void);
Display* meta_ui_get_display (void);
gint <API key> (void);
void <API key> (Display *xdisplay,
MetaEventFunc func,
gpointer data);
void <API key> (Display *xdisplay,
MetaEventFunc func,
gpointer data);
MetaUI* meta_ui_new (Display *xdisplay,
Screen *screen);
void meta_ui_free (MetaUI *ui);
void <API key> (MetaUI *ui,
MetaFrameType type,
MetaFrameFlags flags,
MetaFrameBorders *borders);
void <API key> (MetaUI *ui,
Window frame_xwindow,
MetaFrameBorders *borders);
void <API key> (MetaUI *ui,
Window frame_xwindow,
guint width,
guint height,
cairo_t *cr);
Window <API key> (MetaUI *ui,
Display *xdisplay,
Visual *xvisual,
gint x,
gint y,
gint width,
gint height,
gint screen_no,
gulong *create_serial);
void <API key> (MetaUI *ui,
Window xwindow);
void <API key> (MetaUI *ui,
Window frame,
int x,
int y,
int width,
int height);
/* GDK insists on tracking map/unmap */
void meta_ui_map_frame (MetaUI *ui,
Window xwindow);
void meta_ui_unmap_frame (MetaUI *ui,
Window xwindow);
void <API key> (MetaUI *ui,
Window xwindow,
int target_width,
int target_height);
void <API key> (MetaUI *ui,
Window xwindow);
cairo_region_t *<API key> (MetaUI *ui,
Window xwindow,
int window_width,
int window_height);
void <API key> (MetaUI *ui,
Window xwindow);
void <API key> (MetaUI *ui,
Window xwindow,
const char *title);
void <API key> (MetaUI *ui,
Window window);
void <API key> (MetaUI *ui,
Window xwindow);
MetaWindowMenu* <API key> (MetaUI *ui,
Window client_xwindow,
MetaMenuOp ops,
MetaMenuOp insensitive,
unsigned long active_workspace,
int n_workspaces,
MetaWindowMenuFunc func,
gpointer data);
void <API key> (MetaWindowMenu *menu,
int root_x,
int root_y,
int button,
guint32 timestamp);
void <API key> (MetaWindowMenu *menu);
/* FIXME these lack a display arg */
GdkPixbuf* <API key> (Pixmap xpixmap,
int src_x,
int src_y,
int width,
int height);
GdkPixbuf* <API key> (MetaUI *ui);
GdkPixbuf* <API key> (MetaUI *ui);
gboolean <API key> (Display *xdisplay,
Window xwindow);
char* <API key> (Display *xdisplay,
const XTextProperty *prop);
void <API key> (const char *name);
gboolean <API key> (void);
/* Not a real key symbol but means "key above the tab key"; this is
* used as the default keybinding for cycle_group.
* 0x2xxxxxxx is a range not used by GDK or X. the remaining digits are
* randomly chosen */
#define META_KEY_ABOVE_TAB 0x2f7259c9
gboolean <API key> (const char *accel,
unsigned int *keysym,
unsigned int *keycode,
MetaVirtualModifier *mask);
gboolean <API key> (const char *accel,
MetaVirtualModifier *mask);
/* Caller responsible for freeing return string of <API key>! */
gchar* <API key> (unsigned int keysym,
MetaVirtualModifier mask);
gboolean <API key> (MetaUI *ui,
Window xwindow);
int <API key> (MetaUI *ui);
MetaUIDirection <API key> (void);
#include "tabpopup.h"
#include "tile-preview.h"
#endif |
#include "hisax.h"
#include "isdnl2.h"
#include <linux/init.h>
#include <linux/random.h>
const char *tei_revision = "$Revision: 2.20.2.3 $";
#define ID_REQUEST 1
#define ID_ASSIGNED 2
#define ID_DENIED 3
#define ID_CHK_REQ 4
#define ID_CHK_RES 5
#define ID_REMOVE 6
#define ID_VERIFY 7
#define TEI_ENTITY_ID 0xf
static struct Fsm teifsm;
void tei_handler(struct PStack *st, u_char pr, struct sk_buff *skb);
enum {
ST_TEI_NOP,
ST_TEI_IDREQ,
ST_TEI_IDVERIFY,
};
#define TEI_STATE_COUNT (ST_TEI_IDVERIFY+1)
static char *strTeiState[] =
{
"ST_TEI_NOP",
"ST_TEI_IDREQ",
"ST_TEI_IDVERIFY",
};
enum {
EV_IDREQ,
EV_ASSIGN,
EV_DENIED,
EV_CHKREQ,
EV_REMOVE,
EV_VERIFY,
EV_T202,
};
#define TEI_EVENT_COUNT (EV_T202+1)
static char *strTeiEvent[] =
{
"EV_IDREQ",
"EV_ASSIGN",
"EV_DENIED",
"EV_CHKREQ",
"EV_REMOVE",
"EV_VERIFY",
"EV_T202",
};
unsigned int
random_ri(void)
{
unsigned int x;
get_random_bytes(&x, sizeof(x));
return (x & 0xffff);
}
static struct PStack *
findtei(struct PStack *st, int tei)
{
struct PStack *ptr = *(st->l1.stlistp);
if (tei == 127)
return (NULL);
while (ptr)
if (ptr->l2.tei == tei)
return (ptr);
else
ptr = ptr->next;
return (NULL);
}
static void
put_tei_msg(struct PStack *st, u_char m_id, unsigned int ri, u_char tei)
{
struct sk_buff *skb;
u_char *bp;
if (!(skb = alloc_skb(8, GFP_ATOMIC))) {
printk(KERN_WARNING "HiSax: No skb for TEI manager\n");
return;
}
bp = skb_put(skb, 3);
bp[0] = (TEI_SAPI << 2);
bp[1] = (GROUP_TEI << 1) | 0x1;
bp[2] = UI;
bp = skb_put(skb, 5);
bp[0] = TEI_ENTITY_ID;
bp[1] = ri >> 8;
bp[2] = ri & 0xff;
bp[3] = m_id;
bp[4] = (tei << 1) | 1;
st->l2.l2l1(st, PH_DATA | REQUEST, skb);
}
static void
tei_id_request(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
if (st->l2.tei != -1) {
st->ma.tei_m.printdebug(&st->ma.tei_m,
"assign request for allready asigned tei %d",
st->l2.tei);
return;
}
st->ma.ri = random_ri();
if (st->ma.debug)
st->ma.tei_m.printdebug(&st->ma.tei_m,
"assign request ri %d", st->ma.ri);
put_tei_msg(st, ID_REQUEST, st->ma.ri, 127);
FsmChangeState(&st->ma.tei_m, ST_TEI_IDREQ);
FsmAddTimer(&st->ma.t202, st->ma.T202, EV_T202, NULL, 1);
st->ma.N202 = 3;
}
static void
tei_id_assign(struct FsmInst *fi, int event, void *arg)
{
struct PStack *ost, *st = fi->userdata;
struct sk_buff *skb = arg;
struct IsdnCardState *cs;
int ri, tei;
ri = ((unsigned int) skb->data[1] << 8) + skb->data[2];
tei = skb->data[4] >> 1;
if (st->ma.debug)
st->ma.tei_m.printdebug(&st->ma.tei_m,
"identity assign ri %d tei %d", ri, tei);
if ((ost = findtei(st, tei))) { /* same tei is in use */
if (ri != ost->ma.ri) {
st->ma.tei_m.printdebug(&st->ma.tei_m,
"possible duplicate assignment tei %d", tei);
ost->l2.l2tei(ost, MDL_ERROR | RESPONSE, NULL);
}
} else if (ri == st->ma.ri) {
FsmDelTimer(&st->ma.t202, 1);
FsmChangeState(&st->ma.tei_m, ST_TEI_NOP);
st->l3.l3l2(st, MDL_ASSIGN | REQUEST, (void *) (long) tei);
cs = (struct IsdnCardState *) st->l1.hardware;
cs->cardmsg(cs, MDL_ASSIGN | REQUEST, NULL);
}
}
static void
tei_id_test_dup(struct FsmInst *fi, int event, void *arg)
{
struct PStack *ost, *st = fi->userdata;
struct sk_buff *skb = arg;
int tei, ri;
ri = ((unsigned int) skb->data[1] << 8) + skb->data[2];
tei = skb->data[4] >> 1;
if (st->ma.debug)
st->ma.tei_m.printdebug(&st->ma.tei_m,
"foreign identity assign ri %d tei %d", ri, tei);
if ((ost = findtei(st, tei))) { /* same tei is in use */
if (ri != ost->ma.ri) { /* and it wasn't our request */
st->ma.tei_m.printdebug(&st->ma.tei_m,
"possible duplicate assignment tei %d", tei);
FsmEvent(&ost->ma.tei_m, EV_VERIFY, NULL);
}
}
}
static void
tei_id_denied(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
struct sk_buff *skb = arg;
int ri, tei;
ri = ((unsigned int) skb->data[1] << 8) + skb->data[2];
tei = skb->data[4] >> 1;
if (st->ma.debug)
st->ma.tei_m.printdebug(&st->ma.tei_m,
"identity denied ri %d tei %d", ri, tei);
}
static void
tei_id_chk_req(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
struct sk_buff *skb = arg;
int tei;
tei = skb->data[4] >> 1;
if (st->ma.debug)
st->ma.tei_m.printdebug(&st->ma.tei_m,
"identity check req tei %d", tei);
if ((st->l2.tei != -1) && ((tei == GROUP_TEI) || (tei == st->l2.tei))) {
FsmDelTimer(&st->ma.t202, 4);
FsmChangeState(&st->ma.tei_m, ST_TEI_NOP);
put_tei_msg(st, ID_CHK_RES, random_ri(), st->l2.tei);
}
}
static void
tei_id_remove(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
struct sk_buff *skb = arg;
struct IsdnCardState *cs;
int tei;
tei = skb->data[4] >> 1;
if (st->ma.debug)
st->ma.tei_m.printdebug(&st->ma.tei_m,
"identity remove tei %d", tei);
if ((st->l2.tei != -1) && ((tei == GROUP_TEI) || (tei == st->l2.tei))) {
FsmDelTimer(&st->ma.t202, 5);
FsmChangeState(&st->ma.tei_m, ST_TEI_NOP);
st->l3.l3l2(st, MDL_REMOVE | REQUEST, 0);
cs = (struct IsdnCardState *) st->l1.hardware;
cs->cardmsg(cs, MDL_REMOVE | REQUEST, NULL);
}
}
static void
tei_id_verify(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
if (st->ma.debug)
st->ma.tei_m.printdebug(&st->ma.tei_m,
"id verify request for tei %d", st->l2.tei);
put_tei_msg(st, ID_VERIFY, 0, st->l2.tei);
FsmChangeState(&st->ma.tei_m, ST_TEI_IDVERIFY);
FsmAddTimer(&st->ma.t202, st->ma.T202, EV_T202, NULL, 2);
st->ma.N202 = 2;
}
static void
tei_id_req_tout(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
struct IsdnCardState *cs;
if (--st->ma.N202) {
st->ma.ri = random_ri();
if (st->ma.debug)
st->ma.tei_m.printdebug(&st->ma.tei_m,
"assign req(%d) ri %d", 4 - st->ma.N202,
st->ma.ri);
put_tei_msg(st, ID_REQUEST, st->ma.ri, 127);
FsmAddTimer(&st->ma.t202, st->ma.T202, EV_T202, NULL, 3);
} else {
st->ma.tei_m.printdebug(&st->ma.tei_m, "assign req failed");
st->l3.l3l2(st, MDL_ERROR | RESPONSE, 0);
cs = (struct IsdnCardState *) st->l1.hardware;
cs->cardmsg(cs, MDL_REMOVE | REQUEST, NULL);
FsmChangeState(fi, ST_TEI_NOP);
}
}
static void
tei_id_ver_tout(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
struct IsdnCardState *cs;
if (--st->ma.N202) {
if (st->ma.debug)
st->ma.tei_m.printdebug(&st->ma.tei_m,
"id verify req(%d) for tei %d",
3 - st->ma.N202, st->l2.tei);
put_tei_msg(st, ID_VERIFY, 0, st->l2.tei);
FsmAddTimer(&st->ma.t202, st->ma.T202, EV_T202, NULL, 4);
} else {
st->ma.tei_m.printdebug(&st->ma.tei_m,
"verify req for tei %d failed", st->l2.tei);
st->l3.l3l2(st, MDL_REMOVE | REQUEST, 0);
cs = (struct IsdnCardState *) st->l1.hardware;
cs->cardmsg(cs, MDL_REMOVE | REQUEST, NULL);
FsmChangeState(fi, ST_TEI_NOP);
}
}
static void
tei_l1l2(struct PStack *st, int pr, void *arg)
{
struct sk_buff *skb = arg;
int mt;
if (test_bit(FLG_FIXED_TEI, &st->l2.flag)) {
dev_kfree_skb(skb);
return;
}
if (pr == (PH_DATA | INDICATION)) {
if (skb->len < 3) {
st->ma.tei_m.printdebug(&st->ma.tei_m,
"short mgr frame %ld/3", skb->len);
} else if ((skb->data[0] != ((TEI_SAPI << 2) | 2)) ||
(skb->data[1] != ((GROUP_TEI << 1) | 1))) {
st->ma.tei_m.printdebug(&st->ma.tei_m,
"wrong mgr sapi/tei %x/%x",
skb->data[0], skb->data[1]);
} else if ((skb->data[2] & 0xef) != UI) {
st->ma.tei_m.printdebug(&st->ma.tei_m,
"mgr frame is not ui %x", skb->data[2]);
} else {
skb_pull(skb, 3);
if (skb->len < 5) {
st->ma.tei_m.printdebug(&st->ma.tei_m,
"short mgr frame %ld/5", skb->len);
} else if (skb->data[0] != TEI_ENTITY_ID) {
/* wrong management entity identifier, ignore */
st->ma.tei_m.printdebug(&st->ma.tei_m,
"tei handler wrong entity id %x",
skb->data[0]);
} else {
mt = skb->data[3];
if (mt == ID_ASSIGNED)
FsmEvent(&st->ma.tei_m, EV_ASSIGN, skb);
else if (mt == ID_DENIED)
FsmEvent(&st->ma.tei_m, EV_DENIED, skb);
else if (mt == ID_CHK_REQ)
FsmEvent(&st->ma.tei_m, EV_CHKREQ, skb);
else if (mt == ID_REMOVE)
FsmEvent(&st->ma.tei_m, EV_REMOVE, skb);
else {
st->ma.tei_m.printdebug(&st->ma.tei_m,
"tei handler wrong mt %x\n", mt);
}
}
}
} else {
st->ma.tei_m.printdebug(&st->ma.tei_m,
"tei handler wrong pr %x\n", pr);
}
dev_kfree_skb(skb);
}
static void
tei_l2tei(struct PStack *st, int pr, void *arg)
{
struct IsdnCardState *cs;
if (test_bit(FLG_FIXED_TEI, &st->l2.flag)) {
if (pr == (MDL_ASSIGN | INDICATION)) {
if (st->ma.debug)
st->ma.tei_m.printdebug(&st->ma.tei_m,
"fixed assign tei %d", st->l2.tei);
st->l3.l3l2(st, MDL_ASSIGN | REQUEST, (void *) (long) st->l2.tei);
cs = (struct IsdnCardState *) st->l1.hardware;
cs->cardmsg(cs, MDL_ASSIGN | REQUEST, NULL);
}
return;
}
switch (pr) {
case (MDL_ASSIGN | INDICATION):
FsmEvent(&st->ma.tei_m, EV_IDREQ, arg);
break;
case (MDL_ERROR | REQUEST):
FsmEvent(&st->ma.tei_m, EV_VERIFY, arg);
break;
default:
break;
}
}
static void
tei_debug(struct FsmInst *fi, char *fmt, ...)
{
va_list args;
struct PStack *st = fi->userdata;
va_start(args, fmt);
VHiSax_putstatus(st->l1.hardware, "tei ", fmt, args);
va_end(args);
}
void
setstack_tei(struct PStack *st)
{
st->l2.l2tei = tei_l2tei;
st->ma.T202 = 2000; /* T202 2000 milliseconds */
st->l1.l1tei = tei_l1l2;
st->ma.debug = 1;
st->ma.tei_m.fsm = &teifsm;
st->ma.tei_m.state = ST_TEI_NOP;
st->ma.tei_m.debug = 1;
st->ma.tei_m.userdata = st;
st->ma.tei_m.userint = 0;
st->ma.tei_m.printdebug = tei_debug;
FsmInitTimer(&st->ma.tei_m, &st->ma.t202);
}
void
init_tei(struct IsdnCardState *cs, int protocol)
{
}
void
release_tei(struct IsdnCardState *cs)
{
struct PStack *st = cs->stlist;
while (st) {
FsmDelTimer(&st->ma.t202, 1);
st = st->next;
}
}
static struct FsmNode TeiFnList[] __initdata =
{
{ST_TEI_NOP, EV_IDREQ, tei_id_request},
{ST_TEI_NOP, EV_ASSIGN, tei_id_test_dup},
{ST_TEI_NOP, EV_VERIFY, tei_id_verify},
{ST_TEI_NOP, EV_REMOVE, tei_id_remove},
{ST_TEI_NOP, EV_CHKREQ, tei_id_chk_req},
{ST_TEI_IDREQ, EV_T202, tei_id_req_tout},
{ST_TEI_IDREQ, EV_ASSIGN, tei_id_assign},
{ST_TEI_IDREQ, EV_DENIED, tei_id_denied},
{ST_TEI_IDVERIFY, EV_T202, tei_id_ver_tout},
{ST_TEI_IDVERIFY, EV_REMOVE, tei_id_remove},
{ST_TEI_IDVERIFY, EV_CHKREQ, tei_id_chk_req},
};
#define TEI_FN_COUNT (sizeof(TeiFnList)/sizeof(struct FsmNode))
int __init
TeiNew(void)
{
teifsm.state_count = TEI_STATE_COUNT;
teifsm.event_count = TEI_EVENT_COUNT;
teifsm.strEvent = strTeiEvent;
teifsm.strState = strTeiState;
return FsmNew(&teifsm, TeiFnList, TEI_FN_COUNT);
}
void
TeiFree(void)
{
FsmFree(&teifsm);
} |
<?php
/**
\file htdocs/includes/modules/action/rapport.pdf.php
\ingroup commercial
\brief Fichier de generation de PDF pour les rapports d'actions
\version $Id$
*/
require_once(DOL_DOCUMENT_ROOT.'/includes/fpdf/fpdfi/fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
/**
\class CommActionRapport
\brief Classe permettant la generation des rapports d'actions
*/
class CommActionRapport
{
var $db;
var $description;
var $date_edition;
var $year;
var $month;
var $title;
var $subject;
function CommActionRapport($db=0, $month, $year)
{
global $langs;
$langs->load("commercial");
$this->db = $db;
$this->description = "";
$this->date_edition = time();
$this->month = $month;
$this->year = $year;
// Dimension page pour format A4
$this->type = 'pdf';
$this->page_largeur = 210;
$this->page_hauteur = 297;
$this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=5;
$this->marge_droite=5;
$this->marge_haute=10;
$this->marge_basse=10;
$this->title=$langs->trans("ActionsReport").' '.$this->year."-".$this->month;
$this->subject=$langs->trans("ActionsReport").' '.$this->year."-".$this->month;
}
function generate($socid = 0, $catid = 0, $outputlangs='')
{
global $user,$conf,$langs;
if (! is_object($outputlangs)) $outputlangs=$langs;
// Force output charset to ISO, because, FPDF expect text encoded in ISO
$outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("bills");
$outputlangs->load("products");
$dir = $conf->agenda->dir_temp."/";
$file = $dir . "actions-".$this->month."-".$this->year.".pdf";
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
{
$this->error=$langs->trans("<API key>",$dir);
return 0;
}
}
if (file_exists($dir))
{
// Protection et encryption du pdf
if ($conf->global-><API key>)
{
$pdf=new FPDI_Protection('P','mm',$this->format);
$pdfrights = array('print'); // Ne permet que l'impression du document
$pdfuserpass = ''; // Mot de passe pour l'utilisateur final
$pdfownerpass = NULL; // Mot de passe du proprietaire, cree aleatoirement si pas defini
$pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass);
}
else
{
$pdf=new FPDI('P','mm',$this->format);
}
$pdf->Open();
$pagenb=0;
$pdf->SetDrawColor(128,128,128);
$pdf->SetFillColor(220,220,220);
$pdf->SetTitle($outputlangs->convToOutputCharset($this->title));
$pdf->SetSubject($outputlangs->convToOutputCharset($this->subject));
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->fullname));
$pdf->SetKeywords($outputlangs->convToOutputCharset($this->title." ".$this->subject));
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
$nbpage = $this->_pages($pdf, $outputlangs);
$pdf->AliasNbPages();
$pdf->Close();
$pdf->Output($file);
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
return 1;
}
}
/**
* Write content of pages
*
* @param unknown_type $pdf
* @return int 1
*/
function _pages(&$pdf, $outputlangs)
{
$height=3; // height for text separation
$pagenb=1;
$y=$this->_pagehead($pdf, $outputlangs, $pagenb);
$y++;
$pdf->SetFont('Arial','',8);
$sql = "SELECT s.nom as societe, s.rowid as socid, s.client,";
$sql.= " a.id,".$this->db->pdate("a.datep")." as dp, ".$this->db->pdate("a.datep2")." as dp2,";
$sql.= " a.fk_contact, a.note, a.percent as percent,";
$sql.= " c.libelle,";
$sql.= " u.login";
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE a.fk_soc = s.rowid AND c.id=a.fk_action AND a.fk_user_author = u.rowid";
$sql.= " AND date_format(a.datep, '%m') = ".$this->month;
$sql.= " AND date_format(a.datep, '%Y') = ".$this->year;
$sql.= " ORDER BY a.datep DESC";
dol_syslog("Rapport.pdf::_page sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
$y0=$y1=$y2=$y3=0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$y = max($y, $pdf->GetY(), $y0, $y1, $y2, $y3);
// Calculate height of text
$text=dol_trunc(<API key>($obj->note),150);
//print 'd'.$text; exit;
$nboflines=dol_nboflines($text);
$heightlinemax=max(2*$height,$nboflines*$height);
// Check if there is enough space to print record
if ((1+$y+$heightlinemax) >= ($this->page_hauteur - $this->marge_haute))
{
// We need to break page
$pagenb++;
$y=$this->_pagehead($pdf, $outputlangs, $pagenb);
$y++;
$pdf->SetFont('Arial','',8);
}
$y++;
$pdf->SetXY($this->marge_gauche, $y);
$pdf->MultiCell(22, $height, dol_print_date($obj->dp,"day")."\n".dol_print_date($obj->dp,"hour"), 0, 'L', 0);
$y0 = $pdf->GetY();
$pdf->SetXY(26, $y);
$pdf->MultiCell(32, $height, dol_trunc($outputlangs->convToOutputCharset($obj->societe),32), 0, 'L', 0);
$y1 = $pdf->GetY();
$pdf->SetXY(60,$y);
$pdf->MultiCell(32, $height, dol_trunc($outputlangs->convToOutputCharset($obj->libelle),32), 0, 'L', 0);
$y2 = $pdf->GetY();
$pdf->SetXY(106,$y);
$pdf->MultiCell(94, $height, $outputlangs->convToOutputCharset($text), 0, 'L', 0);
$y3 = $pdf->GetY();
//$pdf->MultiCell(94,2,"y=$y y3=$y3",0,'L',0);
$i++;
}
}
return 1;
}
/**
* \brief Affiche en-tete facture
* \param pdf Objet PDF
* \param outputlang Objet lang cible
* \param pagenb Page nb
*/
function _pagehead(&$pdf, $outputlangs, $pagenb)
{
global $conf,$langs;
// Do not add the BACKGROUND as this is a report
//pdf_pagehead($pdf,$outputlangs,$pdf->page_hauteur);
// New page
$pdf->AddPage();
// Show title
$pdf->SetFont('Arial','B',10);
$pdf->SetXY($this->marge_gauche, $this->marge_haute);
$pdf->MultiCell(80, 1, $this->title, 0, 'L', 0);
$pdf->SetXY($this->page_largeur-$this->marge_droite-40, $this->marge_haute);
$pdf->MultiCell(40, 1, $pagenb.'/{nb}', 0, 'R', 0);
$y=$pdf->GetY()+2;
$pdf->Rect($this->marge_gauche, $y,
$this->page_largeur - $this->marge_gauche - $this->marge_droite,
$this->page_hauteur - $this->marge_haute - $this->marge_basse);
$y=$pdf->GetY()+1;
return $y;
}
}
?> |
/*
* Scripts for spells with SPELLFAMILY_SHAMAN and SPELLFAMILY_GENERIC spells used by shaman players.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_sha_".
*/
#include "Player.h"
#include "ScriptMgr.h"
#include "GridNotifiers.h"
#include "Unit.h"
#include "SpellScript.h"
#include "SpellAuraEffects.h"
enum ShamanSpells
{
<API key> = 52752,
<API key> = 6277,
<API key> = 52025,
<API key> = 379,
<API key> = 16166,
<API key> = 57723,
<API key> = 1535,
<API key> = 8349,
<API key> = 63279,
<API key> = 55456,
<API key> = 55441,
<API key> = 62132,
<API key> = 23552,
<API key> = 27635,
<API key> = 23571,
<API key> = 51480,
<API key> = 64694,
<API key> = 52032,
<API key> = 39609,
SPELL_SHAMAN_SATED = 57724,
<API key> = 51483,
<API key> = 64695,
<API key> = 6474,
<API key> = 59566,
<API key> = 52042
};
enum ShamanSpellIcons
{
<API key> = 338,
<API key> = 3087
};
// 52759 - Ancestral Awakening (Proc)
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public SpellScript
{
PrepareSpellScript(<API key>);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(<API key>))
return false;
return true;
}
void FilterTargets(std::list<WorldObject*>& targets)
{
if (targets.size() < 2)
return;
targets.sort(Trinity::HealthPctOrderPred());
WorldObject* target = targets.front();
targets.clear();
targets.push_back(target);
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
int32 damage = GetEffectValue();
if (GetHitUnit())
GetCaster()->CastCustomSpell(GetHitUnit(), <API key>, &damage, NULL, NULL, true);
}
void Register() override
{
<API key> += <API key>(<API key>::FilterTargets, EFFECT_0, <API key>);
OnEffectHitTarget += SpellEffectFn(<API key>::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new <API key>();
}
};
// 51474 - Astral Shift
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public AuraScript
{
PrepareAuraScript(<API key>);
public:
<API key>()
{
absorbPct = 0;
}
private:
uint32 absorbPct;
bool Load() override
{
absorbPct = GetSpellInfo()->Effects[EFFECT_0].CalcValue(GetCaster());
return true;
}
void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/)
{
// Set absorbtion amount to unlimited
amount = -1;
}
void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
{
// reduces all damage taken while stun, fear or silence
if (GetTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & (UNIT_FLAG_FLEEING | UNIT_FLAG_SILENCED) || (GetTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & (UNIT_FLAG_STUNNED) && GetTarget()->HasAuraWithMechanic(1<<MECHANIC_STUN)))
absorbAmount = CalculatePct(dmgInfo.GetDamage(), absorbPct);
}
void Register() override
{
DoEffectCalcAmount += <API key>(<API key>::CalculateAmount, EFFECT_0, <API key>);
OnEffectAbsorb += AuraEffectAbsorbFn(<API key>::Absorb, EFFECT_0);
}
};
AuraScript* GetAuraScript() const override
{
return new <API key>();
}
};
// 2825 - Bloodlust
class spell_sha_bloodlust : public SpellScriptLoader
{
public:
spell_sha_bloodlust() : SpellScriptLoader("spell_sha_bloodlust") { }
class <API key> : public SpellScript
{
PrepareSpellScript(<API key>);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_SHAMAN_SATED))
return false;
return true;
}
void <API key>(std::list<WorldObject*>& targets)
{
targets.remove_if(Trinity::UnitAuraCheck(true, SPELL_SHAMAN_SATED));
}
void ApplyDebuff()
{
if (Unit* target = GetHitUnit())
target->CastSpell(target, SPELL_SHAMAN_SATED, true);
}
void Register() override
{
<API key> += <API key>(<API key>::<API key>, EFFECT_0, <API key>);
<API key> += <API key>(<API key>::<API key>, EFFECT_1, <API key>);
<API key> += <API key>(<API key>::<API key>, EFFECT_2, <API key>);
AfterHit += SpellHitFn(<API key>::ApplyDebuff);
}
};
SpellScript* GetSpellScript() const override
{
return new <API key>();
}
};
// -1064 - Chain Heal
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public SpellScript
{
PrepareSpellScript(<API key>);
public:
<API key>()
{
firstHeal = true;
riptide = false;
}
private:
void HandleHeal(SpellEffIndex /*effIndex*/)
{
if (firstHeal)
{
// Check if the target has Riptide
if (AuraEffect* aurEff = GetHitUnit()->GetAuraEffect(<API key>, SPELLFAMILY_SHAMAN, 0, 0, 0x10, GetCaster()->GetGUID()))
{
riptide = true;
// Consume it
GetHitUnit()->RemoveAura(aurEff->GetBase());
}
firstHeal = false;
}
// Riptide increases the Chain Heal effect by 25%
if (riptide)
SetHitHeal(GetHitHeal() * 1.25f);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(<API key>::HandleHeal, EFFECT_0, SPELL_EFFECT_HEAL);
}
bool firstHeal;
bool riptide;
};
SpellScript* GetSpellScript() const override
{
return new <API key>();
}
};
// 8171 - Cleansing Totem (Pulse)
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public SpellScript
{
PrepareSpellScript(<API key>);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(<API key>))
return false;
return true;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
int32 bp = 1;
if (GetCaster() && GetHitUnit() && GetOriginalCaster())
GetCaster()->CastCustomSpell(GetHitUnit(), <API key>, NULL, &bp, NULL, true, NULL, NULL, GetOriginalCaster()->GetGUID());
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(<API key>::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new <API key>();
}
};
// -974 - Earth Shield
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public AuraScript
{
PrepareAuraScript(<API key>);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(<API key>))
return false;
if (!sSpellMgr->GetSpellInfo(<API key>))
return false;
return true;
}
void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool & /*canBeRecalculated*/)
{
if (Unit* caster = GetCaster())
{
amount = caster-><API key>(GetUnitOwner(), GetSpellInfo(), amount, HEAL);
amount = GetUnitOwner()-><API key>(caster, GetSpellInfo(), amount, HEAL);
//! WORKAROUND
// If target is affected by healing reduction, modifier is guaranteed to be negative
// value (e.g. -50). To revert the effect, multiply amount with reciprocal of relative value:
// (100 / ((-1) * modifier)) * 100 = (-1) * 100 * 100 / modifier = -10000 / modifier
if (int32 modifier = GetUnitOwner()-><API key>(<API key>))
ApplyPct(amount, -10000.0f / float(modifier));
// Glyph of Earth Shield
//! WORKAROUND
//! this glyph is a proc
if (AuraEffect* glyph = caster->GetAuraEffect(<API key>, EFFECT_0))
AddPct(amount, glyph->GetAmount());
}
}
bool CheckProc(ProcEventInfo& /*eventInfo*/)
{
//! HACK due to currenct proc system implementation
if (Player* player = GetTarget()->ToPlayer())
if (player->HasSpellCooldown(<API key>))
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
{
<API key>();
GetTarget()->CastCustomSpell(<API key>, <API key>, aurEff->GetAmount(), GetTarget(), true, NULL, aurEff, GetCasterGUID());
@hack: due to currenct proc system implementation
if (Player* player = GetTarget()->ToPlayer())
player->AddSpellCooldown(<API key>, 0, time(NULL) + 3);
}
void Register() override
{
DoEffectCalcAmount += <API key>(<API key>::CalculateAmount, EFFECT_0, SPELL_AURA_DUMMY);
DoCheckProc += AuraCheckProcFn(<API key>::CheckProc);
OnEffectProc += AuraEffectProcFn(<API key>::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new <API key>();
}
};
// 6474 - Earthbind Totem - Fix Talent: Earthen Power
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public AuraScript
{
PrepareAuraScript(<API key>);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(<API key>) || !sSpellMgr->GetSpellInfo(<API key>))
return false;
return true;
}
void <API key>(AuraEffect const* /*aurEff*/)
{
if (!GetCaster())
return;
if (Player* owner = GetCaster()-><API key>())
if (AuraEffect* aur = owner->GetDummyAuraEffect(SPELLFAMILY_SHAMAN, 2289, 0))
if (roll_chance_i(aur->GetBaseAmount()))
GetTarget()->CastSpell((Unit*)NULL, <API key>, true);
}
void Apply(AuraEffect const* /*aurEff*/, <API key> /*mode*/)
{
if (!GetCaster())
return;
Player* owner = GetCaster()-><API key>();
if (!owner)
return;
// Storm, Earth and Fire
if (AuraEffect* aurEff = owner-><API key>(<API key>, EFFECT_1))
{
if (roll_chance_i(aurEff->GetAmount()))
GetCaster()->CastSpell(GetCaster(), <API key>, false);
}
}
void Register() override
{
OnEffectPeriodic += <API key>(<API key>::<API key>, EFFECT_0, <API key>);
OnEffectApply += AuraEffectApplyFn(<API key>::Apply, EFFECT_0, <API key>, <API key>);
}
};
AuraScript* GetAuraScript() const override
{
return new <API key>();
}
};
class <API key>
{
public:
<API key>() { }
bool operator() (WorldObject* target)
{
if (!target->ToUnit())
return true;
if (!target->ToUnit()->HasAuraWithMechanic(1 << MECHANIC_SNARE))
return true;
return false;
}
};
// 59566 - Earthen Power
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public SpellScript
{
PrepareSpellScript(<API key>);
void FilterTargets(std::list<WorldObject*>& unitList)
{
unitList.remove_if(<API key>());
}
void Register() override
{
<API key> += <API key>(<API key>::FilterTargets, EFFECT_0, <API key>);
}
};
SpellScript* GetSpellScript() const override
{
return new <API key>();
}
};
// -1535 - Fire Nova
class spell_sha_fire_nova : public SpellScriptLoader
{
public:
spell_sha_fire_nova() : SpellScriptLoader("spell_sha_fire_nova") { }
class <API key> : public SpellScript
{
PrepareSpellScript(<API key>);
bool Validate(SpellInfo const* spellInfo) override
{
SpellInfo const* firstRankSpellInfo = sSpellMgr->GetSpellInfo(<API key>);
if (!firstRankSpellInfo || !spellInfo->IsRankOf(firstRankSpellInfo))
return false;
uint8 rank = spellInfo->GetRank();
if (!sSpellMgr->GetSpellWithRank(<API key>, rank, true))
return false;
return true;
}
SpellCastResult CheckFireTotem()
{
// fire totem
if (!GetCaster()->m_SummonSlot[1])
{
<API key>(<API key>);
return <API key>;
}
return SPELL_CAST_OK;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
if (Creature* totem = caster->GetMap()->GetCreature(caster->m_SummonSlot[1]))
{
uint8 rank = GetSpellInfo()->GetRank();
if (totem->IsTotem())
caster->CastSpell(totem, sSpellMgr->GetSpellWithRank(<API key>, rank), true);
}
}
void Register() override
{
OnCheckCast += SpellCheckCastFn(<API key>::CheckFireTotem);
OnEffectHitTarget += SpellEffectFn(<API key>::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new <API key>();
}
};
// -8050 - Flame Shock
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public AuraScript
{
PrepareAuraScript(<API key>);
bool Validate(SpellInfo const* /*spell*/) override
{
if (!sSpellMgr->GetSpellInfo(<API key>))
return false;
if (!sSpellMgr->GetSpellInfo(<API key>))
return false;
return true;
}
void HandleDispel(DispelInfo* /*dispelInfo*/)
{
if (Unit* caster = GetCaster())
// Lava Flows
if (AuraEffect const* aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_SHAMAN, <API key>, EFFECT_0))
{
if (SpellInfo const* firstRankSpellInfo = sSpellMgr->GetSpellInfo(<API key>))
if (!aurEff->GetSpellInfo()->IsRankOf(firstRankSpellInfo))
return;
uint8 rank = aurEff->GetSpellInfo()->GetRank();
caster->CastSpell(caster, sSpellMgr->GetSpellWithRank(<API key>, rank), true);
}
}
void Register() override
{
AfterDispel += AuraDispelFn(<API key>::HandleDispel);
}
};
AuraScript* GetAuraScript() const override
{
return new <API key>();
}
};
// 52041, 52046, 52047, 52048, 52049, 52050, 58759, 58760, 58761 - Healing Stream Totem
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public SpellScript
{
PrepareSpellScript(<API key>);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(<API key>) || !sSpellMgr->GetSpellInfo(<API key>))
return false;
return true;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
int32 damage = GetEffectValue();
SpellInfo const* triggeringSpell = GetTriggeringSpell();
if (Unit* target = GetHitUnit())
if (Unit* caster = GetCaster())
{
if (Unit* owner = caster->GetOwner())
{
if (triggeringSpell)
damage = int32(owner-><API key>(target, triggeringSpell, damage, HEAL));
// Restorative Totems
if (AuraEffect* dummy = owner->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, <API key>, 1))
AddPct(damage, dummy->GetAmount());
// Glyph of Healing Stream Totem
if (AuraEffect const* aurEff = owner->GetAuraEffect(<API key>, EFFECT_0))
AddPct(damage, aurEff->GetAmount());
damage = int32(target-><API key>(owner, triggeringSpell, damage, HEAL));
}
caster->CastCustomSpell(target, <API key>, &damage, 0, 0, true, 0, 0, GetOriginalCaster()->GetGUID());
}
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(<API key>::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new <API key>();
}
};
// 32182 - Heroism
class spell_sha_heroism : public SpellScriptLoader
{
public:
spell_sha_heroism() : SpellScriptLoader("spell_sha_heroism") { }
class <API key> : public SpellScript
{
PrepareSpellScript(<API key>);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(<API key>))
return false;
return true;
}
void <API key>(std::list<WorldObject*>& targets)
{
targets.remove_if(Trinity::UnitAuraCheck(true, <API key>));
}
void ApplyDebuff()
{
if (Unit* target = GetHitUnit())
target->CastSpell(target, <API key>, true);
}
void Register() override
{
<API key> += <API key>(<API key>::<API key>, EFFECT_0, <API key>);
<API key> += <API key>(<API key>::<API key>, EFFECT_1, <API key>);
<API key> += <API key>(<API key>::<API key>, EFFECT_2, <API key>);
AfterHit += SpellHitFn(<API key>::ApplyDebuff);
}
};
SpellScript* GetSpellScript() const override
{
return new <API key>();
}
};
// 23551 - Lightning Shield
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public AuraScript
{
PrepareAuraScript(<API key>);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(<API key>))
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
<API key>();
GetTarget()->CastSpell(eventInfo.GetProcTarget(), <API key>, true, NULL, aurEff);
}
void Register() override
{
OnEffectProc += AuraEffectProcFn(<API key>::HandleProc, EFFECT_0, <API key>);
}
};
AuraScript* GetAuraScript() const override
{
return new <API key>();
}
};
// 23552 - Lightning Shield
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public AuraScript
{
PrepareAuraScript(<API key>);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(<API key>))
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
{
<API key>();
GetTarget()->CastSpell(GetTarget(), <API key>, true, NULL, aurEff);
}
void Register() override
{
OnEffectProc += AuraEffectProcFn(<API key>::HandleProc, EFFECT_0, <API key>);
}
};
AuraScript* GetAuraScript() const override
{
return new <API key>();
}
};
// 23572 - Mana Surge
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public AuraScript
{
PrepareAuraScript(<API key>);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(<API key>))
return false;
return true;
}
bool CheckProc(ProcEventInfo& eventInfo)
{
return eventInfo.GetDamageInfo()->GetSpellInfo() != nullptr;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
<API key>();
int32 mana = eventInfo.GetDamageInfo()->GetSpellInfo()->CalcPowerCost(GetTarget(), eventInfo.GetSchoolMask());
int32 damage = CalculatePct(mana, 35);
GetTarget()->CastCustomSpell(<API key>, <API key>, damage, GetTarget(), true, NULL, aurEff);
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(<API key>::CheckProc);
OnEffectProc += AuraEffectProcFn(<API key>::HandleProc, EFFECT_0, <API key>);
}
};
AuraScript* GetAuraScript() const override
{
return new <API key>();
}
};
// 70811 - Item - Shaman T10 Elemental 2P Bonus
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public AuraScript
{
PrepareAuraScript(<API key>);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(<API key>))
return false;
return true;
}
void HandleEffectProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
{
<API key>();
if (Player* target = GetTarget()->ToPlayer())
target->ModifySpellCooldown(<API key>, -aurEff->GetAmount());
}
void Register() override
{
OnEffectProc += AuraEffectProcFn(<API key>::HandleEffectProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new <API key>();
}
};
// 60103 - Lava Lash
class spell_sha_lava_lash : public SpellScriptLoader
{
public:
spell_sha_lava_lash() : SpellScriptLoader("spell_sha_lava_lash") { }
class <API key> : public SpellScript
{
PrepareSpellScript(<API key>);
bool Load() override
{
return GetCaster()->GetTypeId() == TYPEID_PLAYER;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
if (Player* caster = GetCaster()->ToPlayer())
{
int32 damage = GetEffectValue();
int32 hitDamage = GetHitDamage();
if (caster->GetItemByPos(<API key>, <API key>))
{
// Damage is increased by 25% if your off-hand weapon is enchanted with Flametongue.
if (caster->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, 0x200000, 0, 0))
AddPct(hitDamage, damage);
SetHitDamage(hitDamage);
}
}
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(<API key>::HandleDummy, EFFECT_1, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new <API key>();
}
};
// 52031, 52033, 52034, 52035, 52036, 58778, 58779, 58780 - Mana Spring Totem
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public SpellScript
{
PrepareSpellScript(<API key>);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(<API key>))
return false;
return true;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
int32 damage = GetEffectValue();
if (Unit* target = GetHitUnit())
if (Unit* caster = GetCaster())
if (target->getPowerType() == POWER_MANA)
caster->CastCustomSpell(target, <API key>, &damage, nullptr, nullptr, true, nullptr, nullptr, GetOriginalCaster()->GetGUID());
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(<API key>::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new <API key>();
}
};
// 39610 - Mana Tide Totem
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public SpellScript
{
PrepareSpellScript(<API key>);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(<API key>) || !sSpellMgr->GetSpellInfo(<API key>))
return false;
return true;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
if (Unit* caster = GetCaster())
if (Unit* unitTarget = GetHitUnit())
{
if (unitTarget->getPowerType() == POWER_MANA)
{
int32 effValue = GetEffectValue();
// Glyph of Mana Tide
if (Unit* owner = caster->GetOwner())
if (AuraEffect* dummy = owner->GetAuraEffect(<API key>, 0))
effValue += dummy->GetAmount();
// Regenerate 6% of Total Mana Every 3 secs
int32 effBasePoints0 = int32(CalculatePct(unitTarget->GetMaxPower(POWER_MANA), effValue));
caster->CastCustomSpell(unitTarget, <API key>, &effBasePoints0, NULL, NULL, true, NULL, NULL, GetOriginalCaster()->GetGUID());
}
}
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(<API key>::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new <API key>();
}
};
// 6495 - Sentry Totem
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public AuraScript
{
PrepareAuraScript(<API key>);
bool Validate(SpellInfo const* /*spell*/) override
{
if (!sSpellMgr->GetSpellInfo(<API key>))
return false;
return true;
}
void AfterApply(AuraEffect const* /*aurEff*/, <API key> /*mode*/)
{
if (Unit* caster = GetCaster())
if (Creature* totem = caster->GetMap()->GetCreature(caster->m_SummonSlot[4]))
if (totem->IsTotem())
caster->CastSpell(totem, <API key>, true);
}
void AfterRemove(AuraEffect const* /*aurEff*/, <API key> /*mode*/)
{
if (Unit* caster = GetCaster())
if (caster->GetTypeId() == TYPEID_PLAYER)
caster->ToPlayer()-><API key>();
}
void Register() override
{
AfterEffectApply += AuraEffectApplyFn(<API key>::AfterApply, EFFECT_1, SPELL_AURA_DUMMY, <API key>);
AfterEffectRemove += AuraEffectRemoveFn(<API key>::AfterRemove, EFFECT_1, SPELL_AURA_DUMMY, <API key>);
}
};
AuraScript* GetAuraScript() const override
{
return new <API key>();
}
};
// -51490 - Thunderstorm
class <API key> : public SpellScriptLoader
{
public:
<API key>() : SpellScriptLoader("<API key>") { }
class <API key> : public SpellScript
{
PrepareSpellScript(<API key>);
void HandleKnockBack(SpellEffIndex effIndex)
{
// Glyph of Thunderstorm
if (GetCaster()->HasAura(<API key>))
<API key>(effIndex);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(<API key>::HandleKnockBack, EFFECT_2, <API key>);
}
};
SpellScript* GetSpellScript() const override
{
return new <API key>();
}
};
void <API key>()
{
new <API key>();
new <API key>();
new spell_sha_bloodlust();
new <API key>();
new <API key>();
new <API key>();
new <API key>();
new <API key>();
new spell_sha_fire_nova();
new <API key>();
new <API key>();
new spell_sha_heroism();
new <API key>();
new <API key>();
new <API key>();
new <API key>();
new spell_sha_lava_lash();
new <API key>();
new <API key>();
new <API key>();
new <API key>();
} |
#ifndef MOTIONTREE_H_
#define MOTIONTREE_H_
#include <StructuredTree.h>
#include "MotionPatch.h"
/** One Structured Tree for the motion prediction task.
*/
template <class M,class T,class F,class N,class U>
class MotionTree:public StructuredTree<M,T,F,N,U>{
public:
typedef typename std::vector<std::vector<const T*> >::const_iterator vectConstIterT;
typedef typename std::vector<const T*>::const_iterator constIterT;
typedef typename std::vector<std::vector<const T*> >::iterator vectIterT;
typedef typename std::vector<const T*>::iterator IterT;
MotionTree(const char* filename,unsigned treeid,bool binary);
MotionTree(unsigned minS,unsigned maxD,CvRNG* pRNG,unsigned labSz,\
unsigned patchW,unsigned patchH,unsigned patchCh,unsigned treeId,const \
char *path2models,const std::string &runName,typename StructuredTree\
<M,T,F,N,U>::ENTROPY entropy,unsigned consideredCls,bool binary,\
bool leafavg=false,bool parentfreq=true,bool leafParentFreq=true,\
const std::string &runname="",float entropythresh=1e-1,bool usepick=false,\
bool hogOrSift=true,unsigned growthtype=1):StructuredTree<M,T,F,N,U>\
(minS,maxD,pRNG,labSz,patchW,patchH,patchCh,treeId,path2models,runName,\
entropy,consideredCls,binary){
this->motionW_ = 0;
this->motionH_ = 0;
this->parentFreq_ = parentfreq;
this->leafParentFreq_ = leafParentFreq;
this->leafavg_ = leafavg;
this->path2models_ = path2models;
this->treeId_ = treeId;
this->binary_ = binary;
this->runname_ = runname;
this->entropythresh_ = entropythresh;
this->clockbegin_ = clock();
this->usepick_ = usepick;
this->hogOrSift_ = hogOrSift;
this->growthtype_ = growthtype;
};
virtual ~MotionTree(){};
/** Reads the tree from a binary file.
*/
void readTreeBin();
/** Reads the tree from a regular text file.
*/
void readTree();
/** Decides for a split based on the cosine similarity.
*/
float stopCosSimilarity(const std::vector<std::vector<const T*> > &SetA,\
const F *features);
/** Check if all patches have converged to a single pattern by looking as MSE.
*/
float <API key>(const std::vector<std::vector<const T*> > \
&trainSet,const F *features);
/** Check if all patches have converged to a single pattern by looking as MSE.
*/
float <API key>(const std::vector<std::vector<const T*> > \
&trainSet,const F *features);
/** Check if all patches have converged to a single pattern by looking as MSE.
*/
float stopEuclDist(const std::vector<std::vector<const T*> > &trainSet,\
const F *features);
/** Check if all patches have converged to a single pattern by looking as MSE.
*/
float stopEuclDistFlows(const std::vector<std::vector<const T*> > \
&trainSet,const F *features);
/** Check if all patches have converged to a single pattern by looking as MSE.
*/
float <API key>(const std::vector<std::vector<const T*> > \
&trainSet,const F *features);
/** In split: <API key> to the mean of the samples at the
* picked position.
*/
float splitDistance2mean(const std::vector<std::vector<const T*> > &SetA,\
const F *features,float &sizeA);
/** <API key> to the mean of the samples at the picked position.
*/
float <API key>(const std::vector<std::vector\
<const T*> > &SetA,const F *features,float &sizeA);
/** <API key> to the mean of the samples at the picked position.
*/
float <API key>(const std::vector<std::vector<const T*> > \
&SetA,const F *features,float &sizeA);
/** Approximating continuous entropy with sum over sample probability, in turn
* approximated the density kernel estimation with pixel-wise kernels.
*/
float splitApproxKernel(const std::vector<std::vector<const T*> > \
&SetA,const F *features,float &sizeA,std::vector<cv::Mat> &prevfreq);
/** Approximating continuous entropy with sum over sample probability, in turn
* approximated the density kernel estimation with pixel-wise kernels over
* complete patch.
*/
float <API key>(const std::vector<std::vector<const T*> > \
&SetA,const F *features,float &sizeA,std::vector<cv::Mat> &prevfreq);
/** show the mean to the samples for the picked best test.
*/
float <API key>(const std::vector<std::vector<const T*> > \
&SetA,const std::vector<std::vector<const T*> > &SetB,\
const F *features,long unsigned nodeid);
/** show the mean to the samples for the picked best test.
*/
float showPickedSplitFlow(const std::vector<std::vector<const T*> > &SetA,\
const std::vector<std::vector<const T*> > &SetB,\
const F *features,long unsigned nodeid);
/** show the mean to the samples for the picked best test.
*/
float showPickedSplit(const std::vector<std::vector<const T*> > &SetA,\
const std::vector<std::vector<const T*> > &SetB,const F *features,\
long unsigned nodeid);
/** Take the mean of all patches arriving to the leaf.
*/
void leafMean(const F* features,const std::vector<std::vector<const T*> > \
&trainSet,int first,unsigned totsize,float &bestAppProb,float \
&bestMotionProb,cv::Mat *bestMotion,cv::Mat *bestApp);
/** Keeps the most likely patch in the leaf given the approximation of kernel
* density estimation for the patch probability.
*/
void leafApprox(const F* features,const std::vector<std::vector\
<const T*> > &trainSet,int first,unsigned totsize,float &bestAppProb,\
float &bestMotionProb,cv::Mat *bestApp,cv::Mat *bestMotion,\
std::vector<cv::Mat> &bestHisto,const std::vector<cv::Mat> &prevfreq,\
long unsigned nodeid,bool writeprobs=true);
/** Writes down the probability for each leaf. As a check.
*/
void writeprobs(const std::vector<std::vector<float> > &mProb,\
long unsigned nodeid,unsigned bestPatchId);
/** Gets the appearance probabilities in the leaf based on similarity.
*/
std::vector<std::vector<float> > patchAppearanceSim(const std::vector\
<std::vector<const T*> > &trainSet,const F* features,unsigned totPatches);
/** Gets the closest patch to the mean-motion in the leaf (euclidian distance).
*/
std::vector<std::vector<float> > patchDist2Mean(const std::vector\
<std::vector<const T*> > &trainSet,const F* features,unsigned totsize,\
const std::vector<float> &prevfreq);
/** Gets the closest patch to the mean-motion in the leaf (euclidian distance).
*/
std::vector<std::vector<float> > <API key>(const \
std::vector<std::vector<const T*> > &trainSet,const F* features,\
unsigned totsize,const std::vector<float> &prevfreq);
/** Gets the closest patch to the mean-motion in the leaf (euclidian distance).
*/
std::vector<std::vector<float> > patchDist2MeanFlows(const \
std::vector<std::vector<const T*> > &trainSet,const F* features,\
unsigned totsize,const std::vector<float> &prevfreq);
/** For each patch finds it probability as 1/#bins sum_bins k(sample-bin).
*/
std::vector<std::vector<float> > patchApprox(const F* features,const \
std::vector<std::vector<const T*> > &trainSet,unsigned totPatches,\
const std::vector<cv::Mat> &prevfreq);
/** Given and input sample, find its corresponding inverse frequency.
*/
static float getProbMagni(const std::vector<cv::Mat> &probs,const std::vector\
<float> &bininfo,const std::vector<float> &values,const cv::Point &pos);
/** Given and input sample, find its corresponding inverse frequency.
*/
static float getProbAngle(const std::vector<cv::Mat> &probs,const std::vector\
<float> &bininfo,const std::vector<float> &values,const cv::Point &pos);
/** Displays the set of predicted leaves.
*/
static void <API key>(const std::vector<const U*> &leaves,\
unsigned sampleW,unsigned sampleH,const cv::Point &point);
/** Displays the set of predicted leaves.
*/
static void showSamplesFlows(const std::vector<const U*> &leaves,\
unsigned sampleW,unsigned sampleH,const cv::Point &point);
/** Displays the samples among which we need to choose to make a leaf
*/
void showSamplesFlows(const std::vector<std::vector<const T*> > &trainSet,\
const F* features,long unsigned nodeid,float entropy,const cv::Mat* bestMotion,\
const cv::Mat *bestApp,bool justdisplay);
/** Just dot product between vectors.
*/
static float dotProd(const std::vector<float> &asmpl,const \
std::vector<float> &dimprobs);
/** Gets the patch probabilities as sum_px log p(px)
*/
float patchProb(const std::vector<cv::Mat> &probs,const T *patch,\
const F *features);
std::vector<cv::Mat> setFreq(const F* features,const std::vector\
<std::vector<const T*> > &allTrainSet);
/** Get the node info. Does all administrative bits to get the info be saved in the node.
*/
bool addNodeInfo(N*current,N *parent,const typename Tree<N,U>::SIDE side,\
const F *features,unsigned &countA,unsigned &countB,float &entropyA,\
float &entropyB,unsigned nodeiters,bool showsplits);
/** Recursively read tree from binary file.
*/
virtual void readNodeBin(N *parent,std::ifstream &in,typename \
Tree<N,U>::SIDE side);
/** Recursively read tree from file.
*/
virtual void readNode(N *parent,std::ifstream &in,typename \
Tree<N,U>::SIDE side);
/** Writes the current tree into a given binary file.
*/
virtual bool saveTree();
/** Writes the current tree into a given binary file.
*/
virtual bool saveTreeBin();
/** Writes the current tree into a given file.
*/
virtual bool saveTreeTxt();
/** Initializes the size of the labels, number of channels, etc.
*/
virtual void initDataSizes(const M& trData);
/** Implementing the <<growTee>> with multiple labels.
*/
virtual void growTree(const M& trData,unsigned nodeiters,long unsigned maxleaves=5e+3);
/** Creates the actual tree from the samples.
*/
virtual void grow(const std::vector<std::vector<const T*> > &trainSet,\
const F *features,long unsigned &nodeid,unsigned int depth,unsigned nodeiters,\
N* parent,typename Tree<N,U>::SIDE side,std::vector<cv::Mat> &prevfreq,\
std::vector<cv::Mat> &prevprevfreq,long unsigned maxleaves,bool showSplits=false);
/** Grow the tree on the depth.
*/
virtual void growDepth(const std::vector<std::vector<const T*> > &trainSet,\
const F *features,long unsigned &nodeid,unsigned int depth,unsigned nodeiters,\
N* parent,typename Tree<N,U>::SIDE side,std::vector<cv::Mat> &prevfreq,\
std::vector<cv::Mat> &prevprevfreq,bool showSplits=false);
/** Grows the tree either breath-first or worst-first until a leaf is reached.
*/
virtual void growLimit(const std::vector<std::vector<const T*> > &trainSet,\
const F *features,const std::vector<cv::Mat> &prevfreq,long unsigned \
maxleaves,unsigned nodeiters,bool showSplits=false);
/** Optimizes tests and thresholds.
* [1] Generate a 5 random values (for x1 y1 x2 y2 channel) in the <<test>> vector.
* [2] Evaluates the thresholds and finds the minimum and maximum index value [?].
* [3] Iteratively generate random thresholds to split the index values
* [4] Split the data according to each threshold.
* [5] Find the best threshold and store it on the 6th position in <<test>>
*/
virtual bool optimizeTest(std::vector<std::vector<const T*> >& SetA,\
std::vector<std::vector<const T*> >& SetB,const std::vector\
<std::vector<const T*> >& TrainSet,const F* features,long double* test,\
unsigned int iter,unsigned pick,std::vector<cv::Mat> &freqA,\
std::vector<cv::Mat> &freqB,float &best,float &entropyA,float &entropyB);
/** Just splits the data into subsets and makes sure the subsets are not empty
*/
virtual float performSplit(std::vector<std::vector<const T*> >& tmpA,\
std::vector<std::vector<const T*> >& tmpB,const std::vector\
<std::vector<const T*> >& TrainSet,const F* features,const \
std::vector<std::vector<Index> > &valSet,unsigned pick,\
long double threshold,unsigned &sizeA,unsigned &sizeB,std::vector\
<cv::Mat> &parentfreqA,std::vector<cv::Mat> &parentfreqB,\
float &entropyA,float &entropyB);
/** Overloading the function to carry around the labels matrices.
*/
virtual float measureSet(const std::vector<std::vector<const T*> > &SetA,\
const std::vector<std::vector<const T*> > &SetB,const F *features,\
unsigned pick,std::vector<cv::Mat> &parentfreqA,std::vector<cv::Mat> \
&parentfreqB,float &motionA,float &motionB);
/** Create leaf node from all patches.
*/
virtual void makeLeaf(const F* features,const std::vector<std::vector<const T*> >\
&trainSet,long unsigned nodeid,N* parent,typename Tree<N,U>::SIDE side,\
unsigned nopatches,const std::vector<cv::Mat> &prevfreq,float entropy,\
bool showLeaves=false);
/** Displays the samples among which we need to choose to make a leaf
*/
virtual void showSamples(const std::vector<std::vector<const T*> > &trainSet,\
const F* features,long unsigned nodeid,float entropy=0,\
const cv::Mat* bestMotion=NULL,const cv::Mat *bestApp=NULL,\
bool justdisplay=false);
/** Displays the samples among which we need to choose to make a leaf
*/
virtual void <API key>(const std::vector<std::vector\
<const T*> > &trainSet,const F* features,long unsigned nodeid,float entropy=0,\
const cv::Mat* bestMotion=NULL,const cv::Mat *bestApp=NULL,\
bool justdisplay=false);
/** Applied the test on a feature patch. The center is fixed and we look at the
* sift dimensions/channels.
*/
virtual bool siftapplyTest(const long double *test,const T* testPatch,\
const F* features) const;
/** Generates a random test of a random type.
*/
virtual void siftgenerateTest(long double* test,unsigned int max_w,\
unsigned int max_h,unsigned int max_c);
/** Evaluates 1 test (given by 5 numbers: x1, y1, x2, y2, channel).
* It gets the feature channel and then it accesses it at the 2 randomly selected
* points and gets the difference between them.
*/
virtual void siftevaluateTest(std::vector<std::vector<Index> >& valSet,\
const long double* test,const std::vector<std::vector<const T*> > \
&TrainSet,const F *features);
/** Predicts on a one single test patch.
* A node contains: [0] -- node type (0,1,-1),[1] -- x1,[2] -- y1,[3] -- x2,
* [4] -- y2,[5] -- channel,[6] -- threshold, [7] -- test type,
* [8] -- node ID
*/
virtual const U* siftregression(const T* testPatch,const F* features,\
N* node,unsigned treeId);
/** Adds a node to the tree given the parent node and the side.
*/
virtual N* addNode(N *current,N *parent,typename Tree<N,U>::SIDE side);
cv::Point mpick() const {return this->mpick_;}
unsigned motionW() const {return this->motionW_;}
unsigned motionH() const {return this->motionH_;}
bool parentFreq() const {return this->parentFreq_;}
bool leafParentFreq() const {return this->leafParentFreq_;}
bool leafavg() const {return this->leafavg_;}
std::string runname() const {return this->runname_;}
float entropythresh() const {return this->entropythresh_;}
float usepick() const {return this->usepick_;}
clock_t clockbegin() const {return this->clockbegin_;}
std::vector<float> histinfo() const {return this->histinfo_;}
bool hogOrSift() const {return this->hogOrSift_;}
void mpick(const cv::Point &mpick){this->mpick_ = mpick;}
void hogOrSift(bool hogOrSift){this->hogOrSift_ = hogOrSift;}
void motionW(unsigned motionW){this->motionW_ = motionW;};
void motionH(unsigned motionH){this->motionH_ = motionH;};
void parentFreq(bool parentFreq){this->parentFreq_ = parentFreq;}
void leafParentFreq(bool leafParentFreq){this->leafParentFreq_ = leafParentFreq;}
void leafavg(bool leafavg){this->leafavg_ = leafavg;}
void runname(const std::string &runname){this->runname_ = runname;}
void entropythresh(float entropythresh){this->entropythresh_ = entropythresh_;}
void usepick(float usepick){this->usepick_ = usepick_;}
void clockbegin(const clock_t &clockbegin){this->clockbegin_ = clockbegin;}
void histinfo(const std::vector<float> &histinfo){this->histinfo_ = histinfo;}
/** Copy constructors for trees (to put them in the forest).
*/
MotionTree(MotionTree const &rhs):StructuredTree<M,T,F,N,U>(rhs){
this->labSz_ = rhs.labSz();
this->patchW_ = rhs.patchW();
this->patchH_ = rhs.patchH();
this->patchCh_ = rhs.patchCh();
this->nodeSize_ = rhs.nodeSize();
this->minSamples_ = rhs.minSamples();
this->cvRNG_ = rhs.cvRNG();
this->maxDepth_ = rhs.maxDepth();
this->entropy_ = rhs.entropy();
this->consideredCls_ = rhs.consideredCls();
this->motionW_ = rhs.motionW();
this->motionH_ = rhs.motionH();
this->parentFreq_ = rhs.parentFreq();
this->leafParentFreq_ = rhs.leafParentFreq();
this->leafavg_ = rhs.leafavg();
this->runname_ = rhs.runname();
this->entropythresh_ = rhs.entropythresh();
this->clockbegin_ = rhs.clockbegin();
this->histinfo(rhs.histinfo());
this->usepick(rhs.usepick());
this->mpick(rhs.mpick());
this->hogOrSift(rhs.hogOrSift());
this->clsFreq(rhs.clsFreq());
}
MotionTree& operator=(MotionTree const &rhs){
if(this == &rhs) return *this;
if(this){delete this;}
this->labSz_ = rhs.labSz();
this->patchW_ = rhs.patchW();
this->patchH_ = rhs.patchH();
this->patchCh_ = rhs.patchCh();
this->nodeSize_ = rhs.nodeSize();
this->minSamples_ = rhs.minSamples();
this->cvRNG_ = rhs.cvRNG();
this->maxDepth_ = rhs.maxDepth();
this->entropy_ = rhs.entropy();
this->consideredCls_ = rhs.consideredCls();
this->motionW_ = rhs.motionW();
this->motionH_ = rhs.motionH();
this->parentFreq_ = rhs.parentFreq();
this->leafParentFreq_ = rhs.leafParentFreq();
this->leafavg_ = rhs.leafavg();
this->runname_ = rhs.runname();
this->entropythresh_ = rhs.entropythresh();
this->clockbegin_ = rhs.clockbegin();
this->histinfo(rhs.histinfo());
this->usepick(rhs.usepick());
this->mpick(rhs.mpick());
this->hogOrSift(rhs.hogOrSift());
this->clsFreq(rhs.clsFreq());
return *this;
}
private:
/** @var parentFreq_
* Whether we weight by parent frequencies or not.
*/
bool parentFreq_;
/** @var leafParentFreq_
* Whether we weight by parent frequencies or not in the leaves.
*/
bool leafParentFreq_;
/** @var mpick_
* The picked position from the motion patch.
*/
cv::Point mpick_;
/** @var motionW_
* The width of the motion patch.
*/
unsigned motionW_;
/** @var motionH_
* The height of the motion patch.
*/
unsigned motionH_;
/** @var leafavg_
* Weighting the leaves by parent frequencies.
*/
bool leafavg_;
/** @var runname_
* The name of the run for logging.
*/
std::string runname_;
/** @var entropythresh_
* The entropy ratio for leaf making.
*/
float entropythresh_;
/** @var usepick_
* If we pick a random position or assume independence.
*/
bool usepick_;
/** @var clockbegin_
* To check how long it takes to train 1 tree.
*/
clock_t clockbegin_;
/** @var histinfo_
* The information about the histograms in the RF.
*/
std::vector<float> histinfo_;
/** @var hogOrSift_
* Hog - 1, sift - 0
*/
bool hogOrSift_;
/** @var queueinfo_
* The queue in which to store the nodes to be processed.
*/
std::vector<std::pair<unsigned,N*> > queueinfo_;
};
#endif /* MOTIONTREE_H_ */ |
#include <QtGlobal>
#include "UI/TiffModeDialog.h"
#include "UI/ui_TiffModeDialog.h"
namespace {
const static QString TIFF_MODE_HDR_KEY =
QStringLiteral("tiffmodedialog/mode/hdr");
const static int TIFF_MODE_HDR_VALUE = 0;
const static QString TIFF_MODE_LDR_KEY =
QStringLiteral("tiffmodedialog/mode/ldr");
const static int TIFF_MODE_LDR_VALUE = 0;
}
TiffModeDialog::TiffModeDialog(bool hdrMode, int defaultValue, QWidget *parent)
: QDialog(parent),
m_hdrMode(hdrMode),
m_ui(new Ui::TiffModeDialog),
m_options(new LuminanceOptions()) {
m_ui->setupUi(this);
if (m_hdrMode) {
m_ui->comboBox->insertItem(
0, QStringLiteral("TIFF 32 bit/channel floating point"));
m_ui->comboBox->insertItem(1, QStringLiteral("TIFF LogLuv"));
if (defaultValue >= 0) {
m_ui->comboBox->setCurrentIndex(defaultValue - 2);
} else
m_ui->comboBox->setCurrentIndex(
m_options->value(TIFF_MODE_HDR_KEY, TIFF_MODE_HDR_VALUE)
.toInt());
} else {
m_ui->comboBox->insertItem(0, QStringLiteral("TIFF 8 bit/channel"));
m_ui->comboBox->insertItem(1, QStringLiteral("TIFF 16 bit/channel"));
m_ui->comboBox->insertItem(
2, QStringLiteral("TIFF 32 bit/channel floating point"));
if (defaultValue >= 0) {
m_ui->comboBox->setCurrentIndex(defaultValue);
} else
m_ui->comboBox->setCurrentIndex(
m_options->value(TIFF_MODE_LDR_KEY, TIFF_MODE_LDR_VALUE)
.toInt());
}
#ifdef Q_OS_MACOS
this->setWindowModality(
Qt::WindowModal); // In OS X, the QMessageBox is modal to the window
#endif
}
TiffModeDialog::~TiffModeDialog() {
if (m_hdrMode) {
m_options->setValue(TIFF_MODE_HDR_KEY, m_ui->comboBox->currentIndex());
} else {
m_options->setValue(TIFF_MODE_LDR_KEY, m_ui->comboBox->currentIndex());
}
}
int TiffModeDialog::getTiffWriterMode() {
if (m_hdrMode) {
return m_ui->comboBox->currentIndex() + 2;
} else {
return m_ui->comboBox->currentIndex();
}
} |
import { ActionTypes } from "../actionTypes";
const timezones = (state = [], action) => {
switch (action.type) {
case ActionTypes.SET_TIMEZONES:
return [...action.timezones];
default:
return state;
}
}
export default timezones; |
#include "sys/sdt.h"
#include "stdio.h"
#ifdef LISTING_MODE_MAIN
int globalvar = 1;
extern libfoo(int lf);
__attribute__((always_inline))
inline int inln(int i) {
return i % 5;
}
int bar(int b) {
int i = inln(b);
printf("inln returned %d\n", i);
return i * 3;
}
int foo(int f) {
int b = bar(f);
return b * 2;
}
int main(void) {
globalvar = foo(globalvar);
globalvar = libfoo(globalvar);
main_label:
STAP_PROBE1(main, mark, globalvar);
while (1) {sleep(5000);}
return 0;
}
#elif LISTING_MODE_LIB
__attribute__((always_inline))
inline int libinln(int i) {
return i % 5;
}
int libbar(int lb) {
int i = libinln(lb);
printf("inln returned %d\n", i);
return i * 3;
}
int libfoo(int lf) {
int lb = libbar(lf);
lib_label:
STAP_PROBE1(lib, mark, lb);
return lb * 2;
}
#else
#error must define LISTING_MODE_MAIN or LISTING_MODE_LIB
#endif |
#ifndef __RTW_MLME_EXT_H_
#define __RTW_MLME_EXT_H_
#include <drv_conf.h>
#include <osdep_service.h>
#include <drv_types.h>
#include <wlan_bssdef.h>
// Commented by Albert 20101105
// Increase the SURVEY_TO value from 100 to 150 ( 100ms to 150ms )
// The Realtek 8188CE SoftAP will spend around 100ms to send the probe response after receiving the probe request.
// So, this driver tried to extend the dwell time for each scanning channel.
// This will increase the chance to receive the probe response from SoftAP.
#if (!(defined ANDROID_2X) && (defined <API key>))
#define SURVEY_TO (50)
#define SURVEY_TO_PASSIVE (100)
#else
#define SURVEY_TO (100)
#endif
#define REAUTH_TO (300)
#define REASSOC_TO (300)
//#define DISCONNECT_TO (3000)
#define ADDBA_TO (2000)
#define LINKED_TO (1) //unit:2 sec, 1x2=2 sec
#define REAUTH_LIMIT (4)
#define REASSOC_LIMIT (4)
#define READDBA_LIMIT (2)
#define DISCONNECT_LIMIT 8
#if defined(DBG_ROAMING_TEST) || defined(CONFIG_INTEL_WIDI)
#undef DISCONNECT_LIMIT
#define DISCONNECT_LIMIT 1
#endif
/* 1. wpa_supplicant scan list bss exprire time is 10s */
/* or 2 times scan without this bss */
/* 2. cfg80211 scan list bss exprire time is <API key> */
/* 3. we should del cfg80211 scan list bss use cfg80211_unlink_bss when */
/* disconnect or android aoto connect will connect power off AP again */
/* 4. so 10s disconnect(in no cfg80211) or cfg80211_unlink_bss is perfect*/
#if (!(defined ANDROID_2X) && (defined <API key>))
#undef DISCONNECT_LIMIT
#define DISCONNECT_LIMIT 5
#endif
#ifdef CONFIG_CMCC_TEST
#undef SURVEY_TO
#undef DISCONNECT_LIMIT
#define SURVEY_TO (50)
#define DISCONNECT_LIMIT 10
#endif
//#define IOCMD_REG0 0x10250370
//#define IOCMD_REG1 0x10250374
//#define IOCMD_REG2 0x10250378
//#define <API key> 0x10250364
//#define WRITE_BB_CMD 0xF0000001
//#define SET_CHANNEL_CMD 0xF3000000
//#define UPDATE_RA_CMD 0xFD0000A2
#define <API key> (0x0)
// BB ODM section BIT 0-15
#define DYNAMIC_BB_DIG BIT(0)
#define DYNAMIC_BB_RA_MASK BIT(1)
#define <API key> BIT(2)
#define <API key> BIT(3)
#define <API key> BIT(4)
#define DYNAMIC_BB_CCK_PD BIT(5)
#define DYNAMIC_BB_ANT_DIV BIT(6)
#define DYNAMIC_BB_PWR_SAVE BIT(7)
#define <API key> BIT(8)
#define <API key> BIT(9)
#define DYNAMIC_BB_PATH_DIV BIT(10)
#define DYNAMIC_BB_PSD BIT(11)
// MAC DM section BIT 16-23
#define <API key> BIT(16)
#define <API key> BIT(17)
// RF ODM section BIT 24-31
#define <API key> BIT(24)
#define <API key> BIT(25)
#define <API key> BIT(26)
#define <API key> 0xFFFFFFF
#define _HW_STATE_NOLINK_ 0x00
#define _HW_STATE_ADHOC_ 0x01
#define _HW_STATE_STATION_ 0x02
#define _HW_STATE_AP_ 0x03
#define _1M_RATE_ 0
#define _2M_RATE_ 1
#define _5M_RATE_ 2
#define _11M_RATE_ 3
#define _6M_RATE_ 4
#define _9M_RATE_ 5
#define _12M_RATE_ 6
#define _18M_RATE_ 7
#define _24M_RATE_ 8
#define _36M_RATE_ 9
#define _48M_RATE_ 10
#define _54M_RATE_ 11
extern unsigned char RTW_WPA_OUI[];
extern unsigned char WMM_OUI[];
extern unsigned char WPS_OUI[];
extern unsigned char WFD_OUI[];
extern unsigned char P2P_OUI[];
extern unsigned char WMM_INFO_OUI[];
extern unsigned char WMM_PARA_OUI[];
// Channel Plan Type.
// Note:
// We just add new channel plan when the new channel plan is different from any of the following
// channel plan.
// If you just wnat to customize the acitions(scan period or join actions) about one of the channel plan,
// customize them in RT_CHANNEL_INFO in the RT_CHANNEL_LIST.
typedef enum _RT_CHANNEL_DOMAIN
{
<API key> = 0x00,
<API key> = 0x01,
<API key> = 0x02,
<API key> = 0x03,
<API key> = 0x04,
<API key> = 0x05,
<API key> = 0x06,
<API key> = 0x07,
<API key> = 0x08,
<API key> = 0x09,
<API key> = 0x0A,
<API key> = 0x0B,
<API key> = 0x0C,
<API key> = 0x0D,
<API key> = 0x0E,
<API key> = 0x0F,
<API key> = 0x10,
<API key> = 0x11,
<API key> = 0x12,
<API key> = 0x13,
<API key> = 0x14,
<API key> = 0x20,
<API key> = 0x21,
<API key> = 0x22,
<API key> = 0x23,
<API key> = 0x24,
<API key> = 0x25,
<API key> = 0x26,
<API key> = 0x27,
<API key> = 0x28,
<API key> = 0x29,
<API key> = 0x30,
<API key> = 0x31,
<API key> = 0x32,
<API key> = 0x33,
<API key> = 0x34,
<API key> = 0x35,
<API key> = 0x36,
<API key> = 0x37,
<API key> = 0x38,
<API key> = 0x39,
<API key> = 0x40,
<API key>,
<API key> = 0x7F,
}RT_CHANNEL_DOMAIN, *PRT_CHANNEL_DOMAIN;
typedef enum <API key>
{
<API key> = 0x00, //Worldwird 13
<API key> = 0x01, //Europe
<API key> = 0x02,
<API key> = 0x03, //Japan
<API key> = 0x04, //France
<API key>,
}<API key>, *<API key>;
typedef enum <API key>
{
<API key> = 0x00,
<API key> = 0x01, //Europe
<API key> = 0x02, //Australia, New Zealand
<API key> = 0x03, //Russia
<API key> = 0x04,
<API key> = 0x05, //FCC o/w DFS Channels
<API key> = 0x06, //India, Mexico
<API key> = 0x07, //Venezuela
<API key> = 0x08, //China
<API key> = 0x09, //Israel
<API key> = 0x0A, //US, Canada
<API key> = 0x0B, //Korea
<API key> = 0x0C, //Japan
<API key> = 0x0D, //Japan (W52, W53)
<API key> = 0x0E, //Japan (W56)
<API key> = 0x0F, //Taiwan
<API key> = 0x10, //Taiwan o/w DFS
<API key> = 0x11,
<API key> = 0x12,
<API key>,
}<API key>, *<API key>;
#define <API key>(chplan) (chplan<<API key> || chplan == <API key>)
typedef struct _RT_CHANNEL_PLAN
{
unsigned char Channel[MAX_CHANNEL_NUM];
unsigned char Len;
}RT_CHANNEL_PLAN, *PRT_CHANNEL_PLAN;
typedef struct _RT_CHANNEL_PLAN_2G
{
unsigned char Channel[MAX_CHANNEL_NUM_2G];
unsigned char Len;
}RT_CHANNEL_PLAN_2G, *PRT_CHANNEL_PLAN_2G;
typedef struct _RT_CHANNEL_PLAN_5G
{
unsigned char Channel[MAX_CHANNEL_NUM_5G];
unsigned char Len;
}RT_CHANNEL_PLAN_5G, *PRT_CHANNEL_PLAN_5G;
typedef struct <API key>
{
unsigned char Index2G;
unsigned char Index5G;
}RT_CHANNEL_PLAN_MAP, *<API key>;
enum Associated_AP
{
atherosAP = 0,
broadcomAP = 1,
ciscoAP = 2,
marvellAP = 3,
ralinkAP = 4,
realtekAP = 5,
airgocapAP = 6,
unknownAP = 7,
maxAP,
};
typedef enum _HT_IOT_PEER
{
HT_IOT_PEER_UNKNOWN = 0,
HT_IOT_PEER_REALTEK = 1,
<API key> = 2,
<API key> = 3,
HT_IOT_PEER_RALINK = 4,
HT_IOT_PEER_ATHEROS = 5,
HT_IOT_PEER_CISCO = 6,
HT_IOT_PEER_MERU = 7,
HT_IOT_PEER_MARVELL = 8,
<API key> = 9,// peer is RealTek SOFT_AP, by Bohn, 2009.12.17
<API key> = 10, // Self is SoftAP
HT_IOT_PEER_AIRGO = 11,
HT_IOT_PEER_INTEL = 12,
<API key> = 13,
<API key> = 14,
<API key> = 15,
HT_IOT_PEER_TENDA = 16,
HT_IOT_PEER_MAX = 17
}HT_IOT_PEER_E, *PHTIOT_PEER_E;
enum SCAN_STATE
{
SCAN_DISABLE = 0,
SCAN_START = 1,
SCAN_TXNULL = 2,
SCAN_PROCESS = 3,
SCAN_COMPLETE = 4,
SCAN_STATE_MAX,
};
struct mlme_handler {
unsigned int num;
char* str;
unsigned int (*func)(_adapter *padapter, union recv_frame *precv_frame);
};
struct action_handler {
unsigned int num;
char* str;
unsigned int (*func)(_adapter *padapter, union recv_frame *precv_frame);
};
struct ss_res
{
int state;
int bss_cnt;
int channel_idx;
int scan_mode;
u8 ssid_num;
u8 ch_num;
NDIS_802_11_SSID ssid[<API key>];
struct <API key> ch[<API key>];
};
//#define AP_MODE 0x0C
//#define STATION_MODE 0x08
//#define AD_HOC_MODE 0x04
//#define NO_LINK_MODE 0x00
#define WIFI_FW_NULL_STATE _HW_STATE_NOLINK_
#define <API key> _HW_STATE_STATION_
#define WIFI_FW_AP_STATE _HW_STATE_AP_
#define WIFI_FW_ADHOC_STATE _HW_STATE_ADHOC_
#define WIFI_FW_AUTH_NULL 0x00000100
#define WIFI_FW_AUTH_STATE 0x00000200
#define <API key> 0x00000400
#define WIFI_FW_ASSOC_STATE 0x00002000
#define <API key> 0x00004000
#define <API key> (WIFI_FW_AUTH_NULL | WIFI_FW_AUTH_STATE | <API key> |WIFI_FW_ASSOC_STATE)
#ifdef CONFIG_TDLS
// 1: Write RCR DATA BIT
// 2: Issue peer traffic indication
// 3: Go back to the channel linked with AP, terminating channel switch procedure
// 4: Init channel sensing, receive all data and mgnt frame
// 5: Channel sensing and report candidate channel
// 6: First time set channel to off channel
// 7: Go back tp the channel linked with AP when set base channel as target channel
// 8: Set channel back to base channel
// 9: Set channel back to off channel
// 10: Restore RCR DATA BIT
// 11: Check alive
// 12: Check alive
// 13: Free TDLS sta
enum TDLS_option
{
TDLS_WRCR = 1,
TDLS_SD_PTI = 2,
TDLS_CS_OFF = 3,
TDLS_INIT_CH_SEN = 4,
TDLS_DONE_CH_SEN = 5,
TDLS_OFF_CH = 6,
TDLS_BASE_CH = 7,
TDLS_P_OFF_CH = 8,
TDLS_P_BASE_CH = 9,
TDLS_RS_RCR = 10,
TDLS_CKALV_PH1 = 11,
TDLS_CKALV_PH2 = 12,
TDLS_FREE_STA = 13,
maxTDLS,
};
#endif //CONFIG_TDLS
struct FW_Sta_Info
{
struct sta_info *psta;
u32 status;
u32 rx_pkt;
u32 retry;
<API key> SupportedRates;
};
/*
* Usage:
* When one iface acted as AP mode and the other iface is STA mode and scanning,
* it should switch back to AP's operating channel periodically.
* Parameters info:
* When the driver scanned RTW_SCAN_NUM_OF_CH channels, it would switch back to AP's operating channel for
* <API key> * SURVEY_TO milliseconds.
* Example:
* For chip supports 2.4G + 5GHz and AP mode is operating in channel 1,
* RTW_SCAN_NUM_OF_CH is 8, <API key> is 3 and SURVEY_TO is 100.
* When it's STA mode gets set_scan command,
* it would
* 1. Doing the scan on channel 1.2.3.4.5.6.7.8
* 2. Back to channel 1 for 300 milliseconds
* 3. Go through doing site survey on channel 9.10.11.36.40.44.48.52
* 4. Back to channel 1 for 300 milliseconds
* 5. ... and so on, till survey done.
*/
#if defined <API key> && defined <API key>
#define RTW_SCAN_NUM_OF_CH 8
#define <API key> 3 // this value is a multiplier,for example, when this value is 3, it would stay AP's op ch for
// 3 * SURVEY_TO millisecond.
#endif //defined <API key> && defined <API key>
struct mlme_ext_info
{
u32 state;
u32 reauth_count;
u32 reassoc_count;
u32 link_count;
u32 auth_seq;
u32 auth_algo; // 802.11 auth, could be open, shared, auto
u32 authModeToggle;
u32 enc_algo;//encrypt algorithm;
u32 key_index; // this is only valid for legendary wep, 0~3 for key id.
u32 iv;
u8 chg_txt[128];
u16 aid;
u16 bcn_interval;
u16 capability;
u8 assoc_AP_vendor;
u8 slotTime;
u8 preamble_mode;
u8 WMM_enable;
u8 ERP_enable;
u8 ERP_IE;
u8 HT_enable;
u8 HT_caps_enable;
u8 HT_info_enable;
u8 HT_protection;
u8 turboMode_cts2self;
u8 turboMode_rtsen;
u8 SM_PS;
u8 agg_enable_bitmap;
u8 ADDBA_retry_count;
u8 <API key>;
u8 dialogToken;
// Accept ADDBA Request
BOOLEAN bAcceptAddbaReq;
u8 bwmode_updated;
u8 hidden_ssid_mode;
struct ADDBA_request ADDBA_req;
struct WMM_para_element WMM_param;
struct HT_caps_element HT_caps;
struct HT_info_element HT_info;
WLAN_BSSID_EX network;//join network or bss_network, if in ap mode, it is the same to cur_network.network
struct FW_Sta_Info FW_sta_info[NUM_STA];
#ifdef <API key>
u8 scan_cnt;
#endif //<API key>
};
// The channel information about this channel including joining, scanning, and power constraints.
typedef struct _RT_CHANNEL_INFO
{
u8 ChannelNum; // The channel number.
RT_SCAN_TYPE ScanType; // Scan type such as passive or active scan.
//u16 ScanPeriod; // Listen time in millisecond in this channel.
//s32 MaxTxPwrDbm; // Max allowed tx power.
//u32 ExInfo; // Extended Information for this channel.
#ifdef <API key>
u32 rx_count;
#endif
}RT_CHANNEL_INFO, *PRT_CHANNEL_INFO;
int <API key>(RT_CHANNEL_INFO *ch_set, const u32 ch);
struct mlme_ext_priv
{
_adapter *padapter;
u8 mlmeext_init;
ATOMIC_T event_seq;
u16 mgnt_seq;
//struct fw_priv fwpriv;
unsigned char cur_channel;
unsigned char cur_bwmode;
unsigned char cur_ch_offset;//PRIME_CHNL_OFFSET
unsigned char cur_wireless_mode; // NETWORK_TYPE
unsigned char oper_channel; //saved channel info when call set_channel_bw
unsigned char max_chan_nums;
RT_CHANNEL_INFO channel_set[MAX_CHANNEL_NUM];
unsigned char basicrate[NumRates];
unsigned char datarate[NumRates];
struct ss_res sitesurvey_res;
struct mlme_ext_info mlmext_info;//for sta/adhoc mode, including current scanning/connecting/connected related info.
//for ap mode, network includes ap's cap_info
_timer survey_timer;
//this timer was set by set_link_timer 3 times:
//1. after find network, and decide to
// wait beacon for link
// in start_clnt_join TO is WAIT_FOR_BCN_TO_MIN = 6s
//2. start auth TO is REAUTH_TO = 0.3s 4 times
//3. start asso TO is REASSOC_TO = 0.3s 4 times
_timer link_timer;
//_timer ADDBA_timer;
u16 chan_scan_time;
u8 scan_abort;
u8 tx_rate; // TXRATE when USERATE is set.
u32 retry; //retry for issue probereq
u64 TSFValue;
//follwing for fw try AP function
u8 check_ap_processing;
u8 try_ap_c2h_wait;
#ifdef CONFIG_AP_MODE
unsigned char bstart_bss;
#endif
#ifdef CONFIG_80211D
u8 <API key>;
#endif
//recv_decache check for Action_public frame
u16 action_public_rxseq;
/* for softap power save */
u8 <API key>;
u32 onauth_time;
};
int init_mlme_ext_priv(_adapter* padapter);
int init_hw_mlme_ext(_adapter *padapter);
void free_mlme_ext_priv (struct mlme_ext_priv *pmlmeext);
extern void init_mlme_ext_timer(_adapter *padapter);
extern void <API key>(_adapter *padapter, struct sta_info *psta);
extern struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv);
//void fill_fwpriv(_adapter * padapter, struct fw_priv *pfwpriv);
unsigned char networktype_to_raid(unsigned char network_type);
u8 judge_network_type(_adapter *padapter, unsigned char *rate, int ratelen);
void get_rate_set(_adapter *padapter, unsigned char *pbssrate, int *bssrate_len);
void UpdateBrateTbl(_adapter *padapter,u8 *mBratesOS);
void <API key>(u8 *bssrateset, u32 bssratelen);
void Save_DM_Func_Flag(_adapter *padapter);
void <API key>(_adapter *padapter);
void Switch_DM_Func(_adapter *padapter, u32 mode, u8 enable);
//void Set_NETYPE1_MSR(_adapter *padapter, u8 type);
//void Set_NETYPE0_MSR(_adapter *padapter, u8 type);
void Set_MSR(_adapter *padapter, u8 type);
void set_channel_bwmode(_adapter *padapter, unsigned char channel, unsigned char channel_offset, unsigned short bwmode);
void SelectChannel(_adapter *padapter, unsigned char channel);
void SetBWMode(_adapter *padapter, unsigned short bwmode, unsigned char channel_offset);
unsigned int <API key>(unsigned int bcn_interval);
void write_cam(_adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key);
void clear_cam_entry(_adapter *padapter, u8 entry);
void invalidate_cam_all(_adapter *padapter);
void CAM_empty_entry(PADAPTER Adapter, u8 ucIndex);
int <API key>(_adapter *padapter);
void flush_all_cam_entry(_adapter *padapter);
BOOLEAN IsLegal5GChannel(PADAPTER Adapter, u8 channel);
void site_survey(_adapter *padapter);
u8 collect_bss_info(_adapter *padapter, union recv_frame *precv_frame, WLAN_BSSID_EX *bssid);
void update_network(WLAN_BSSID_EX *dst, WLAN_BSSID_EX *src, _adapter * padapter, bool update_ie);
int get_bsstype(unsigned short capability);
u8* get_my_bssid(WLAN_BSSID_EX *pnetwork);
u16 get_beacon_interval(WLAN_BSSID_EX *bss);
int <API key>(_adapter *padapter);
int <API key>(_adapter *padapter);
int is_IBSS_empty(_adapter *padapter);
unsigned char check_assoc_AP(u8 *pframe, uint len);
int WMM_param_handler(_adapter *padapter, <API key> pIE);
#ifdef CONFIG_WFD
int WFD_info_handler(_adapter *padapter, <API key> pIE);
#endif
void WMMOnAssocRsp(_adapter *padapter);
void HT_caps_handler(_adapter *padapter, <API key> pIE);
void HT_info_handler(_adapter *padapter, <API key> pIE);
void HTOnAssocRsp(_adapter *padapter);
void ERP_IE_handler(_adapter *padapter, <API key> pIE);
void VCS_update(_adapter *padapter, struct sta_info *psta);
int is_IWN2410_AP(<API key> *MacAddr);
void update_beacon_info(_adapter *padapter, u8 *pframe, uint len, struct sta_info *psta);
int rtw_check_bcn_info(ADAPTER *Adapter, u8 *pframe, u32 packet_len);
#ifdef CONFIG_DFS
void process_csa_ie(_adapter *padapter, u8 *pframe, uint len);
#endif //CONFIG_DFS
void update_IOT_info(_adapter *padapter);
void update_capinfo(PADAPTER Adapter, u16 updateCap);
void <API key>(_adapter * padapter);
void <API key>(_adapter *padapter, u8 modulation);
void <API key>(_adapter *padapter, u32 mac_id);
int <API key>(_adapter *padapter, u8* pvar_ie, uint var_ie_len, int cam_idx);
//for sta/adhoc mode
void update_sta_info(_adapter *padapter, struct sta_info *psta);
unsigned int update_basic_rate(unsigned char *ptn, unsigned int ptn_sz);
unsigned int <API key>(unsigned char *ptn, unsigned int ptn_sz);
unsigned int update_MSC_rate(struct HT_caps_element *pHT_caps);
void Update_RA_Entry(_adapter *padapter, u32 mac_id);
void set_sta_rate(_adapter *padapter, struct sta_info *psta);
unsigned int receive_disconnect(_adapter *padapter, unsigned char *MacAddr, unsigned short reason);
unsigned char <API key>(u32 mask);
int support_short_GI(_adapter *padapter, struct HT_caps_element *pHT_caps);
unsigned int is_ap_in_tkip(_adapter *padapter);
unsigned int is_ap_in_wep(_adapter *padapter);
unsigned int <API key>(_adapter * padapter);
void report_join_res(_adapter *padapter, int res);
void report_survey_event(_adapter *padapter, union recv_frame *precv_frame);
void <API key>(_adapter *padapter);
void <API key>(_adapter *padapter, unsigned char* MacAddr, unsigned short reason);
void <API key>(_adapter *padapter, unsigned char* MacAddr, int cam_idx);
void <API key>(_adapter *padapter);
extern u8 set_tx_beacon_cmd(_adapter*padapter);
unsigned int setup_beacon_frame(_adapter *padapter, unsigned char *beacon_frame);
void update_mgnt_tx_rate(_adapter *padapter, u8 rate);
void <API key>(_adapter *padapter, struct pkt_attrib *pattrib);
void dump_mgntframe(_adapter *padapter, struct xmit_frame *pmgntframe);
s32 <API key>(_adapter *padapter, struct xmit_frame *pmgntframe, int timeout_ms);
s32 <API key>(_adapter *padapter, struct xmit_frame *pmgntframe);
#ifdef CONFIG_P2P
void issue_probersp_p2p(_adapter *padapter, unsigned char *da);
void <API key>( _adapter *padapter, u8* pssid, u8 ussidlen, u8* pdev_raddr);
void <API key>(_adapter *padapter, u8* raddr);
void issue_probereq_p2p(_adapter *padapter);
void <API key>(_adapter *padapter, u8* raddr, u8 dialogToken, u8 success);
void <API key>(_adapter *padapter, u8* raddr );
#endif //CONFIG_P2P
void issue_beacon(_adapter *padapter);
void issue_probersp(_adapter *padapter, unsigned char *da, u8 <API key>);
void issue_assocreq(_adapter *padapter);
void issue_asocrsp(_adapter *padapter, unsigned short status, struct sta_info *pstat, int pkt_type);
void issue_auth(_adapter *padapter, struct sta_info *psta, unsigned short status);
// Added by Albert 2010/07/26
// blnbc: 1 -> broadcast probe request
// blnbc: 0 -> unicast probe request. The address 1 will be the BSSID.
void issue_probereq(_adapter *padapter, NDIS_802_11_SSID *pssid, u8 blnbc);
void issue_nulldata(_adapter *padapter, unsigned int power_mode);
void issue_qos_nulldata(_adapter *padapter, unsigned char *da, u16 tid);
void issue_deauth(_adapter *padapter, unsigned char *da, unsigned short reason);
void issue_action_BA(_adapter *padapter, unsigned char *raddr, unsigned char action, unsigned short status);
unsigned int send_delba(_adapter *padapter, u8 initiator, u8 *addr);
unsigned int send_beacon(_adapter *padapter);
void start_clnt_assoc(_adapter *padapter);
void start_clnt_auth(_adapter* padapter);
void start_clnt_join(_adapter* padapter);
void start_create_ibss(_adapter* padapter);
unsigned int OnAssocReq(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAssocRsp(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnProbeReq(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnProbeRsp(_adapter *padapter, union recv_frame *precv_frame);
unsigned int DoReserved(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnBeacon(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAtim(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnDisassoc(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAuth(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAuthClient(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnDeAuth(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAction(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAction_qos(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAction_dls(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAction_back(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAction_public(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAction_ht(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAction_wmm(_adapter *padapter, union recv_frame *precv_frame);
unsigned int OnAction_p2p(_adapter *padapter, union recv_frame *precv_frame);
void <API key>(_adapter *padapter, int join_res);
void <API key>(_adapter *padapter);
void <API key>(_adapter *padapter, struct sta_info *psta);
void linked_status_chk(_adapter *padapter);
void survey_timer_hdl (_adapter *padapter);
void link_timer_hdl (_adapter *padapter);
void addba_timer_hdl(struct sta_info *psta);
//void reauth_timer_hdl(_adapter *padapter);
//void reassoc_timer_hdl(_adapter *padapter);
#define set_survey_timer(mlmeext, ms) \
do { \
/*DBG_871X("%s set_survey_timer(%p, %d)\n", __FUNCTION__, (mlmeext), (ms));*/ \
_set_timer(&(mlmeext)->survey_timer, (ms)); \
} while(0)
#define set_link_timer(mlmeext, ms) \
do { \
/*DBG_871X("%s set_link_timer(%p, %d)\n", __FUNCTION__, (mlmeext), (ms));*/ \
_set_timer(&(mlmeext)->link_timer, (ms)); \
} while(0)
extern int cckrates_included(unsigned char *rate, int ratelen);
extern int <API key>(unsigned char *rate, int ratelen);
extern void process_addba_req(_adapter *padapter, u8 *paddba_req, u8 *addr);
extern void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len);
extern void correct_TSF(_adapter *padapter, struct mlme_ext_priv *pmlmeext);
#ifdef <API key>
sint <API key>(_adapter *padapter, u32 state);
int <API key>(_adapter *padapter);
void <API key>(_adapter *padapter, int join_res);
#endif //<API key>
#ifdef <API key>
void dc_SelectChannel(_adapter *padapter, unsigned char channel);
void dc_SetBWMode(_adapter *padapter, unsigned short bwmode, unsigned char channel_offset);
void <API key>(_adapter *padapter);
u8 <API key>(_adapter *padapter);
void dc_handle_join_done(_adapter *padapter, u8 join_res);
sint dc_check_fwstate(_adapter *padapter, sint fw_state);
u8 <API key>(_adapter *padapter);
void <API key>(_adapter *padapter, union recv_frame *precv_frame);
void <API key>(_adapter *padapter);
void <API key>(_adapter *padapter, u8 channel, u8 channel_offset, u8 bwmode);
void dc_resume_xmit(_adapter *padapter);
u8 dc_check_xmit(_adapter *padapter);
#endif
struct cmd_hdl {
uint parmsize;
u8 (*h2cfuns)(struct _ADAPTER *padapter, u8 *pbuf);
};
u8 read_macreg_hdl(_adapter *padapter, u8 *pbuf);
u8 write_macreg_hdl(_adapter *padapter, u8 *pbuf);
u8 read_bbreg_hdl(_adapter *padapter, u8 *pbuf);
u8 write_bbreg_hdl(_adapter *padapter, u8 *pbuf);
u8 read_rfreg_hdl(_adapter *padapter, u8 *pbuf);
u8 write_rfreg_hdl(_adapter *padapter, u8 *pbuf);
u8 NULL_hdl(_adapter *padapter, u8 *pbuf);
u8 join_cmd_hdl(_adapter *padapter, u8 *pbuf);
u8 disconnect_hdl(_adapter *padapter, u8 *pbuf);
u8 createbss_hdl(_adapter *padapter, u8 *pbuf);
u8 setopmode_hdl(_adapter *padapter, u8 *pbuf);
u8 sitesurvey_cmd_hdl(_adapter *padapter, u8 *pbuf);
u8 setauth_hdl(_adapter *padapter, u8 *pbuf);
u8 setkey_hdl(_adapter *padapter, u8 *pbuf);
u8 set_stakey_hdl(_adapter *padapter, u8 *pbuf);
u8 set_assocsta_hdl(_adapter *padapter, u8 *pbuf);
u8 del_assocsta_hdl(_adapter *padapter, u8 *pbuf);
u8 add_ba_hdl(_adapter *padapter, unsigned char *pbuf);
u8 mlme_evt_hdl(_adapter *padapter, unsigned char *pbuf);
u8 h2c_msg_hdl(_adapter *padapter, unsigned char *pbuf);
u8 tx_beacon_hdl(_adapter *padapter, unsigned char *pbuf);
u8 set_chplan_hdl(_adapter *padapter, unsigned char *pbuf);
u8 led_blink_hdl(_adapter *padapter, unsigned char *pbuf);
u8 set_csa_hdl(_adapter *padapter, unsigned char *pbuf); //Kurt: Handling DFS channel switch announcement ie.
u8 tdls_hdl(_adapter *padapter, unsigned char *pbuf);
#define GEN_DRV_CMD_HANDLER(size, cmd) {size, &cmd ## _hdl},
#define <API key>(size, cmd) {size, cmd},
#ifdef _RTW_CMD_C_
struct cmd_hdl wlancmds[] =
{
GEN_DRV_CMD_HANDLER(0, NULL)
GEN_DRV_CMD_HANDLER(0, NULL)
GEN_DRV_CMD_HANDLER(0, NULL)
GEN_DRV_CMD_HANDLER(0, NULL)
GEN_DRV_CMD_HANDLER(0, NULL)
GEN_DRV_CMD_HANDLER(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(sizeof (struct joinbss_parm), join_cmd_hdl)
<API key>(sizeof (struct disconnect_parm), disconnect_hdl)
<API key>(sizeof (struct createbss_parm), createbss_hdl)
<API key>(sizeof (struct setopmode_parm), setopmode_hdl)
<API key>(sizeof (struct sitesurvey_parm), sitesurvey_cmd_hdl)
<API key>(sizeof (struct setauth_parm), setauth_hdl)
<API key>(sizeof (struct setkey_parm), setkey_hdl)
<API key>(sizeof (struct set_stakey_parm), set_stakey_hdl)
<API key>(sizeof (struct set_assocsta_parm), NULL)
<API key>(sizeof (struct del_assocsta_parm), NULL)
<API key>(sizeof (struct setstapwrstate_parm), NULL)
<API key>(sizeof (struct setbasicrate_parm), NULL)
<API key>(sizeof (struct getbasicrate_parm), NULL)
<API key>(sizeof (struct setdatarate_parm), NULL)
<API key>(sizeof (struct getdatarate_parm), NULL)
<API key>(sizeof (struct setphyinfo_parm), NULL)
<API key>(sizeof (struct getphyinfo_parm), NULL)
<API key>(sizeof (struct setphy_parm), NULL)
<API key>(sizeof (struct getphy_parm), NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(sizeof(struct addBaReq_parm), add_ba_hdl)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(0, NULL)
<API key>(sizeof(struct Tx_Beacon_param), tx_beacon_hdl)
<API key>(0, mlme_evt_hdl)
<API key>(0, <API key>)
<API key>(0, h2c_msg_hdl)
<API key>(sizeof(struct <API key>), set_chplan_hdl)
<API key>(sizeof(struct LedBlink_param), led_blink_hdl)
<API key>(sizeof(struct <API key>), set_csa_hdl)
<API key>(sizeof(struct TDLSoption_param), tdls_hdl)
};
#endif
struct C2HEvent_Header
{
#ifdef <API key>
unsigned int len:16;
unsigned int ID:8;
unsigned int seq:8;
#elif defined(CONFIG_BIG_ENDIAN)
unsigned int seq:8;
unsigned int ID:8;
unsigned int len:16;
#else
# error "Must be LITTLE or BIG Endian"
#endif
unsigned int rsvd;
};
void <API key>(_adapter *adapter , u8 *pbuf);
void <API key>(_adapter *adapter , u8 *pbuf);
enum rtw_c2h_event
{
GEN_EVT_CODE(_Read_MACREG)=0,
GEN_EVT_CODE(_Read_BBREG),
GEN_EVT_CODE(_Read_RFREG),
GEN_EVT_CODE(_Read_EEPROM),
GEN_EVT_CODE(_Read_EFUSE),
GEN_EVT_CODE(_Read_CAM),
GEN_EVT_CODE(_Get_BasicRate),
GEN_EVT_CODE(_Get_DataRate),
GEN_EVT_CODE(_Survey),
GEN_EVT_CODE(_SurveyDone),
GEN_EVT_CODE(_JoinBss) ,
GEN_EVT_CODE(_AddSTA),
GEN_EVT_CODE(_DelSTA),
GEN_EVT_CODE(_AtimDone) ,
GEN_EVT_CODE(_TX_Report),
GEN_EVT_CODE(_CCX_Report),
GEN_EVT_CODE(_DTM_Report),
GEN_EVT_CODE(_TX_Rate_Statistics),
GEN_EVT_CODE(_C2HLBK),
GEN_EVT_CODE(_FWDBG),
GEN_EVT_CODE(_C2HFEEDBACK),
GEN_EVT_CODE(_ADDBA),
GEN_EVT_CODE(_C2HBCN),
GEN_EVT_CODE(_ReportPwrState), //filen: only for PCIE, USB
GEN_EVT_CODE(_CloseRF), //filen: only for PCIE, work around ASPM
MAX_C2HEVT
};
#ifdef _RTW_MLME_EXT_C_
static struct fwevent wlanevents[] =
{
{0, <API key>},
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL},
{0, &<API key>},
{sizeof (struct surveydone_event), &<API key>},
{0, &<API key>},
{sizeof(struct stassoc_event), &<API key>},
{sizeof(struct stadel_event), &<API key>},
{0, &<API key>},
{0, <API key>},
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL},
{0, <API key>},
{0, NULL},
{0, NULL},
{0, NULL},
{0, &<API key>},
};
#endif//_RTL8192C_CMD_C_
#endif |
interface Clearable {
clear(): void;
}
/**
* Wraps a function in a utility method that remembers the last invocation's
* arguments and results, and returns the latter if the former match.
*
* @param fn The function to be wrapped.
*
* @returns The wrapped function.
*/
export default function memoizeLast< T extends ( ...args: any[] ) => any >( fn: T ): T & Clearable {
let lastArgs: Parameters< T > | undefined;
let lastResult: ReturnType< T > | undefined;
const func = ( ( ...args: Parameters< T > ) => {
const isSame =
lastArgs &&
args.length === lastArgs.length &&
args.every( ( arg, index ) => arg === ( lastArgs as Parameters< T > )[ index ] );
if ( ! isSame ) {
lastArgs = args;
lastResult = fn( ...args );
}
return lastResult;
} ) as T & Clearable;
func.clear = () => {
lastArgs = undefined;
lastResult = undefined;
};
return func;
}
/**
* A stricter-typed alias of `memoizeLast`, for functions without arguments.
* Since it only accepts functions without arguments, it effectively guarantees
* that the provided function will only be run once, as the check for whether
* the arguments have not changed will always pass.
*
* @param fn The function to be wrapped.
*
* @returns The wrapped function.
*/
export function once< T extends () => any >( fn: T ) {
// Runtime validation. Useful when static validation is unavailable.
if ( process.env.NODE_ENV !== 'production' && fn.length !== 0 ) {
throw new Error( 'memoize-last: The `once` method expects a function with no arguments.' );
}
return memoizeLast( fn );
} |
CKEDITOR.dialog.add('jiraDialog', function(editor) {"use strict";
var jql;
var startAt;
var maxResults;
var showHeader;
var pluginPath = CKEDITOR.plugins.getFilePath('jira');
pluginPath = pluginPath.substring(0, pluginPath.lastIndexOf('/'));
var headerFields = {
'T' : true,
'Key' : true,
'P' : true,
'Summary' : true,
//'Assignee' : false,
//'Reporter' : false,
'Status' : true,
'Created' : false,
'Updated' : false
};
var date = new Date();
var dateStr = date.getMonth() + '/' + date.getDate() + '/' + date.getFullYear();
var dummyRow = {
'T' : '<img src="' + pluginPath + '/icons/type_demo.png">',
'Key' : 'CONTENT-1234',
'P' : '<img src="' + pluginPath +'/icons/priority_demo.png">',
'Summary' : 'This is a dummy issue',
//'Assignee' : 'Bob',
//'Reporter' : 'Alice',
'Status' : '<img src="' + pluginPath +'/icons/status_demo">Open',
'Created' : dateStr,
'Updated' : dateStr
};
var dialog = {
// Basic properties of the dialog window: title, minimum size.
title : Drupal.t('Insert JIRA Issues'),
minWidth : 400,
minHeight : 300,
// Dialog window contents definition.
contents : [{
id : 'tab-advance',
label : Drupal.t('Insert Issues by JQL'),
elements : [{
type : 'text',
id : 'jql',
label : Drupal.t('JQL'),
widths : ['20%', '80%'],
labelLayout : 'horizontal',
align : 'center',
setup : function(element) {
this.setValue(jql);
},
validate : function() {
var key = this.getValue().trim();
if (key == null || key.length <= 0) {
alert('You must specify a JQL string');
return false;
}
},
commit : function(element) {
jql = this.getValue();
}
}, {
type : 'hbox',
widths : ['45%', '55%'],
children : [{
type : 'text',
id : 'start-at',
label : Drupal.t('Start At'),
widths : ['40%', '60%'],
labelLayout : 'horizontal',
align : 'center',
setup : function(element) {
this.setValue(startAt);
},
validate : function() {
var intRegex = /^\d+$/;
if (!intRegex.test(this.getValue().trim())) {
alert('Start At must be an non-negtive integer');
return false;
}
},
commit : function(element) {
startAt = this.getValue().trim();
}
}, {
type : 'text',
id : 'max-results',
label : Drupal.t('Max Results'),
widths : ['40%', '60%'],
labelLayout : 'horizontal',
align : 'center',
setup : function(element) {
this.setValue(maxResults);
},
validate : function() {
var intRegex = /^\d+$/;
if (!intRegex.test(this.getValue().trim())) {
alert('Max Results must be an non-negtive integer');
return false;
}
},
commit : function(element) {
maxResults = this.getValue().trim();
}
}]
}]
}],
onShow : function() {
// default settings
jql = '';
startAt = '0';
maxResults = '10';
showHeader = true;
// get the selection
var selection = editor.getSelection();
// get the entire element
var element = selection.getStartElement();
// looking for the div parent tag
if (element) {
element = element.getAscendant('div', true);
}
// check the class
if (!element || !element.hasClass('editor-inline-jira')) {
// it is a addtion
element = new CKEDITOR.dom.element('div');
element.addClass('editor-inline-jira');
this.insertMode = true;
} else {
jql = element.getText();
var data = element.getAttribute('jql_options');
var options = data.split(',');
for (var i = 0; i < options.length; i++) {
var pair = options[i].split('=');
if (pair[0].trim() == 'startAt') {
startAt = pair[1].trim();
}
if (pair[0].trim() == 'maxResults') {
maxResults = pair[1].trim();
}
}
data = element.getAttribute('table_options');
options = data.split(',');
for (var i = 0; i < options.length; i++) {
var pair = options[i].split('=');
var key = pair[0].trim();
var value = pair[1].trim();
if (key === 'showHeader') {
showHeader = value === 'true';
}else if (headerFields.hasOwnProperty(key)) {
headerFields[key] = value === 'true';
}
}
console.log(headerFields);
console.log(showHeader);
//console.log(maxResults);
this.insertMode = false;
}
this.element = element;
this.setupContent(this.element);
},
onOk : function() {
var element = this.element;
this.commitContent(element);
//console.log(jql);
//console.log(startAt);
//console.log(maxResults);
var imgPath = pluginPath + '/icons/jira.png';
element.setHtml('<img src="' + imgPath + '"><span>' + jql + '</span>');
element.setAttribute('jql_options', 'startAt=' + startAt + ',maxResults=' + maxResults);
var fields = '';
var keys = Object.keys(headerFields);
for (var i = 0; i < keys.length; i++) {
fields += ',' + keys[i] + '=' + headerFields[keys[i]];
}
element.setAttribute('table_options', 'showHeader=' + showHeader + fields);
for (var i = 0; i < element.getChildCount(); i++) {
element.getChild(i).unselectable();
}
if (this.insertMode) {
editor.insertElement(element);
}
}
};
var generateDummyTable = function (sHeader) {
var table = '<table style="border: 1px solid #BEBFB9; font-size: 0.9em; margin: 0 0 10px; width: 100%">';
var header = '';
var row = '';
var keys = Object.keys(headerFields);
for (var i = 0; i < keys.length; i++) {
if (headerFields[keys[i]]) {
header += '<th style="background: none-rpeat scroll 0 0 #E1E2DC; border: 1px solid #BEBFB9;">' + keys[i] + '</th>';
row += '<td style="border: 1px solid #BEBFB9;">' + dummyRow[keys[i]] + '</td>';
}
}
if (sHeader) {
table += '<tr>' + header + '</tr>';
}
table += '<tr>' + row + '</tr>';
table += '</table>';
return table;
};
var createChboxLabel = function() {
var obj = {};
obj.type = 'html';
obj.id = 'instruction-html';
obj.html = '<p>Check the blow checkboxes to include the columns in table.</p>';
return obj;
};
var <API key> = function (label, val) {
var obj = {};
obj.type = 'checkbox';
obj.id = 'header-' + label;
if (label === 'T') {
obj.label = Drupal.t(label + '(Issue Type)');
}else if (label === 'P'){
obj.label = Drupal.t(label + '(Priority)');
}else {
obj.label = Drupal.t(label);
}
obj.setup = function (element) {
this.setValue(headerFields[label]);
};
obj.onClick = function (element) {
headerFields[label] = this.getValue();
var demoTable = document.getElementById('demo-table');
if (demoTable) {
demoTable.innerHTML = generateDummyTable(showHeader);
}
};
return obj;
};
var createHtmlInDialog = function () {
var htmlObj = {};
htmlObj.type = 'html';
htmlObj.id = 'demo-table';
htmlObj.html = '<div id="demo-table">' + generateDummyTable(true) + '</div>';
htmlObj.onShow = function (element) {
var newHTML = generateDummyTable(showHeader);
document.getElementById('demo-table').innerHTML = newHTML;
this.html = '<div id="demo-table">' + newHTML + '</div>';
};
return htmlObj;
};
var <API key> = function () {
var obj = {};
obj.type = 'checkbox';
obj.id = 'show-header';
obj.label = Drupal.t('Show Table Header');
obj.setup = function (element) {
this.setValue(showHeader);
};
obj.onClick = function (element) {
showHeader = this.getValue();
var demoTable = document.getElementById('demo-table');
if (demoTable) {
demoTable.innerHTML = generateDummyTable(showHeader);
}
};
return obj;
};
var showHeaderChbox = <API key>();
dialog.contents[0].elements.push(<API key>());
dialog.contents[0].elements.push(createHtmlInDialog());
dialog.contents[0].elements.push(createChboxLabel());
var labels = Object.keys(headerFields);
for (var i = 0; i < labels.length; i++) {
if (labels[i] !== 'Key' && labels[i] !== 'Summary') {
dialog.contents[0].elements.push(<API key>(labels[i], headerFields[labels[i]]));
}
}
return dialog;
}); |
#include "QuestDef.h"
#include "Player.h"
#include "World.h"
#include "DBCStores.h"
Quest::Quest(Field* questRecord)
{
QuestId = questRecord[0].GetUInt32();
QuestMethod = questRecord[1].GetUInt32();
ZoneOrSort = questRecord[2].GetInt32();
MinLevel = questRecord[3].GetUInt32();
QuestLevel = questRecord[4].GetInt32();
Type = questRecord[5].GetUInt32();
RequiredClasses = questRecord[6].GetUInt32();
RequiredRaces = questRecord[7].GetUInt32();
RequiredSkill = questRecord[8].GetUInt32();
RequiredSkillValue = questRecord[9].GetUInt32();
RepObjectiveFaction = questRecord[10].GetUInt32();
RepObjectiveValue = questRecord[11].GetInt32();
<API key> = questRecord[12].GetUInt32();
RequiredMinRepValue = questRecord[13].GetInt32();
<API key> = questRecord[14].GetUInt32();
RequiredMaxRepValue = questRecord[15].GetInt32();
SuggestedPlayers = questRecord[16].GetUInt32();
LimitTime = questRecord[17].GetUInt32();
m_QuestFlags = questRecord[18].GetUInt16();
m_SpecialFlags = questRecord[19].GetUInt16();
CharTitleId = questRecord[20].GetUInt32();
PlayersSlain = questRecord[21].GetUInt32();
BonusTalents = questRecord[22].GetUInt32();
PortraitGiver = questRecord[23].GetUInt32();
PortraitTurnIn = questRecord[24].GetUInt32();
PrevQuestId = questRecord[25].GetInt32();
NextQuestId = questRecord[26].GetInt32();
ExclusiveGroup = questRecord[27].GetInt32();
NextQuestInChain = questRecord[28].GetUInt32();
RewXPId = questRecord[29].GetUInt32();
SrcItemId = questRecord[30].GetUInt32();
SrcItemCount = questRecord[31].GetUInt32();
SrcSpell = questRecord[32].GetUInt32();
Title = questRecord[33].GetCppString();
Details = questRecord[34].GetCppString();
Objectives = questRecord[35].GetCppString();
OfferRewardText = questRecord[36].GetCppString();
RequestItemsText = questRecord[37].GetCppString();
EndText = questRecord[38].GetCppString();
CompletedText = questRecord[39].GetCppString();
PortraitGiverName = questRecord[40].GetCppString();
PortraitGiverText = questRecord[41].GetCppString();
PortraitTurnInName = questRecord[42].GetCppString();
PortraitTurnInText = questRecord[43].GetCppString();
for (int i = 0; i < <API key>; ++i)
{
ObjectiveText[i] = questRecord[44 + i].GetCppString();
}
for (int i = 0; i < <API key>; ++i)
{
ReqItemId[i] = questRecord[48 + i].GetUInt32();
}
for (int i = 0; i < <API key>; ++i)
{
ReqItemCount[i] = questRecord[54 + i].GetUInt32();
}
for (int i = 0; i < <API key>; ++i)
{
ReqSourceId[i] = questRecord[60 + i].GetUInt32();
}
for (int i = 0; i < <API key>; ++i)
{
ReqSourceCount[i] = questRecord[64 + i].GetUInt32();
}
for (int i = 0; i < <API key>; ++i)
{
ReqCreatureOrGOId[i] = questRecord[68 + i].GetInt32();
}
for (int i = 0; i < <API key>; ++i)
{
<API key>[i] = questRecord[72 + i].GetUInt32();
}
for (int i = 0; i < <API key>; ++i)
{
ReqCurrencyId[i] = questRecord[76 + i].GetUInt32();
}
for (int i = 0; i < <API key>; ++i)
{
ReqCurrencyCount[i] = questRecord[80 + i].GetUInt32();
}
for (int i = 0; i < <API key>; ++i)
{
ReqSpell[i] = questRecord[84 + i].GetUInt32();
}
ReqSpellLearned = questRecord[88].GetUInt32();
for (int i = 0; i < <API key>; ++i)
{
RewChoiceItemId[i] = questRecord[89 + i].GetUInt32();
}
for (int i = 0; i < <API key>; ++i)
{
RewChoiceItemCount[i] = questRecord[95 + i].GetUInt32();
}
for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
{
RewItemId[i] = questRecord[101 + i].GetUInt32();
}
for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
{
RewItemCount[i] = questRecord[105 + i].GetUInt32();
}
for (int i = 0; i < <API key>; ++i)
{
RewCurrencyId[i] = questRecord[109 + i].GetUInt32();
}
for (int i = 0; i < <API key>; ++i)
{
RewCurrencyCount[i] = questRecord[113 + i].GetUInt32();
}
RewSkill = questRecord[117].GetUInt32();
RewSkillValue = questRecord[118].GetUInt32();
for (int i = 0; i < <API key>; ++i)
{
RewRepFaction[i] = questRecord[119 + i].GetUInt32();
}
for (int i = 0; i < <API key>; ++i)
{
RewRepValueId[i] = questRecord[124 + i].GetInt32();
}
for (int i = 0; i < <API key>; ++i)
{
RewRepValue[i] = questRecord[129 + i].GetInt32();
}
RewHonorAddition = questRecord[134].GetUInt32();
RewHonorMultiplier = questRecord[135].GetFloat();
RewOrReqMoney = questRecord[136].GetInt32();
RewMoneyMaxLevel = questRecord[137].GetUInt32();
RewSpell = questRecord[138].GetUInt32();
RewSpellCast = questRecord[139].GetUInt32();
RewMailTemplateId = questRecord[140].GetUInt32();
RewMailDelaySecs = questRecord[141].GetUInt32();
PointMapId = questRecord[142].GetUInt32();
PointX = questRecord[143].GetFloat();
PointY = questRecord[144].GetFloat();
PointOpt = questRecord[145].GetUInt32();
for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
{
DetailsEmote[i] = questRecord[146 + i].GetUInt32();
}
for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
{
DetailsEmoteDelay[i] = questRecord[150 + i].GetUInt32();
}
IncompleteEmote = questRecord[154].GetUInt32();
CompleteEmote = questRecord[155].GetUInt32();
for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
{
OfferRewardEmote[i] = questRecord[156 + i].GetInt32();
}
for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
{
<API key>[i] = questRecord[160 + i].GetInt32();
}
SoundAcceptId = questRecord[164].GetUInt32();
SoundTurnInId = questRecord[165].GetUInt32();
QuestStartScript = questRecord[166].GetUInt32();
QuestCompleteScript = questRecord[167].GetUInt32();
m_isActive = true;
m_reqitemscount = 0;
<API key> = 0;
m_rewitemscount = 0;
<API key> = 0;
m_reqCurrencyCount = 0;
for (int i = 0; i < <API key>; ++i)
{
if (ReqItemId[i])
{
++m_reqitemscount;
}
}
for (int i = 0; i < <API key>; ++i)
{
if (ReqCreatureOrGOId[i])
{
++<API key>;
}
}
for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
{
if (RewItemId[i])
{
++m_rewitemscount;
}
}
for (int i = 0; i < <API key>; ++i)
{
if (RewChoiceItemId[i])
{
++<API key>;
}
}
for (int i = 0; i < <API key>; ++i)
{
if (ReqCurrencyId[i])
{
++m_reqCurrencyCount;
}
}
}
uint32 Quest::XPValue(Player* pPlayer) const
{
if (pPlayer)
{
uint32 realXP = 0;
uint32 xpMultiplier = 0;
int32 baseLevel = 0;
int32 playerLevel = pPlayer->getLevel();
// formula can possibly be organized better, using less if's and simplify some.
if (QuestLevel != -1)
{
baseLevel = QuestLevel;
}
if (((baseLevel - playerLevel) + 10) * 2 > 10)
{
baseLevel = playerLevel;
if (QuestLevel != -1)
{
baseLevel = QuestLevel;
}
if (((baseLevel - playerLevel) + 10) * 2 <= 10)
{
if (QuestLevel == -1)
{
baseLevel = playerLevel;
}
xpMultiplier = 2 * (baseLevel - playerLevel) + 20;
}
else
{
xpMultiplier = 10;
}
}
else
{
baseLevel = playerLevel;
if (QuestLevel != -1)
{
baseLevel = QuestLevel;
}
if (((baseLevel - playerLevel) + 10) * 2 >= 1)
{
baseLevel = playerLevel;
if (QuestLevel != -1)
{
baseLevel = QuestLevel;
}
if (((baseLevel - playerLevel) + 10) * 2 <= 10)
{
if (QuestLevel == -1)
{
baseLevel = playerLevel;
}
xpMultiplier = 2 * (baseLevel - playerLevel) + 20;
}
else
{
xpMultiplier = 10;
}
}
else
{
xpMultiplier = 1;
}
}
// not possible to reward XP when baseLevel does not exist in dbc
if (const QuestXPLevel* pXPData = sQuestXPLevelStore.LookupEntry(baseLevel))
{
uint32 rawXP = xpMultiplier * pXPData->xpIndex[RewXPId] / 10;
// round values
if (rawXP > 1000)
{
realXP = ((rawXP + 25) / 50 * 50);
}
else if (rawXP > 500)
{
realXP = ((rawXP + 12) / 25 * 25);
}
else if (rawXP > 100)
{
realXP = ((rawXP + 5) / 10 * 10);
}
else
{
realXP = ((rawXP + 2) / 5 * 5);
}
}
return realXP;
}
return 0;
}
int32 Quest::GetRewOrReqMoney() const
{
if (RewOrReqMoney <= 0)
{
return RewOrReqMoney;
}
return int32(RewOrReqMoney * sWorld.getConfig(<API key>));
}
bool Quest::IsAllowedInRaid() const
{
if (Type == QUEST_TYPE_RAID || Type == QUEST_TYPE_RAID_10 || Type == QUEST_TYPE_RAID_25)
{
return true;
}
return sWorld.getConfig(<API key>);
}
uint32 Quest::<API key>(uint32 level) const
{
if (level > GT_MAX_LEVEL)
{
level = GT_MAX_LEVEL;
}
uint32 honor = 0;
if (GetRewHonorAddition() > 0 || <API key>() > 0.0f)
{
// values stored from 0.. for 1...
/* not exist in 4.x
<API key> const* tc = <API key>.LookupEntry(level-1);
if(!tc)
{
return 0;
}
*/
uint32 i_honor = uint32(/*tc->Value*/1.0f * <API key>() * 0.1f);
honor = i_honor + GetRewHonorAddition();
}
return honor;
} |
package org.n52.ses.wsn.dissemination;
import org.apache.muse.ws.addressing.EndpointReference;
import org.apache.muse.ws.notification.NotificationMessage;
import org.apache.muse.ws.notification.remote.<API key>;
/**
* Default implementation. Simple HTTP Post to consumer with
* no delay.
*
* @author matthes rieke
*
*/
public class <API key> extends <API key> {
@Override
public boolean newMessage(NotificationMessage message, <API key> client,
EndpointReference <API key>, EndpointReference producerReference,
EndpointReference consumerReference) {
return sendMessage(message, client, consumerReference, this.numberOfTries, producerReference, <API key>);
}
@Override
public void shutdown() {
}
} |
#include <linux/slab.h>
#include <linux/string.h>
#include "agent.h"
#include "smi.h"
#define SPFX "ib_agent: "
struct <API key> {
struct list_head port_list;
struct ib_mad_agent *agent[2];
};
static DEFINE_SPINLOCK(<API key>);
static LIST_HEAD(ib_agent_port_list);
static struct <API key> *
__ib_get_agent_port(struct ib_device *device, int port_num)
{
struct <API key> *entry;
list_for_each_entry(entry, &ib_agent_port_list, port_list) {
if (entry->agent[0]->device == device &&
entry->agent[0]->port_num == port_num)
return entry;
}
return NULL;
}
static struct <API key> *
ib_get_agent_port(struct ib_device *device, int port_num)
{
struct <API key> *entry;
unsigned long flags;
spin_lock_irqsave(&<API key>, flags);
entry = __ib_get_agent_port(device, port_num);
<API key>(&<API key>, flags);
return entry;
}
int agent_send_response(struct ib_mad *mad, struct ib_grh *grh,
struct ib_wc *wc, struct ib_device *device,
int port_num, int qpn)
{
struct <API key> *port_priv;
struct ib_mad_agent *agent;
struct ib_mad_send_buf *send_buf;
struct ib_ah *ah;
int ret;
port_priv = ib_get_agent_port(device, port_num);
if (!port_priv) {
printk(KERN_ERR SPFX "Unable to find port agent\n");
return -ENODEV;
}
agent = port_priv->agent[qpn];
ah = <API key>(agent->qp->pd, wc, grh, port_num);
if (IS_ERR(ah)) {
ret = PTR_ERR(ah);
printk(KERN_ERR SPFX "<API key> error:%d\n", ret);
return ret;
}
send_buf = ib_create_send_mad(agent, wc->src_qp, wc->pkey_index, 0,
IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,
GFP_KERNEL);
if (IS_ERR(send_buf)) {
ret = PTR_ERR(send_buf);
printk(KERN_ERR SPFX "ib_create_send_mad error:%d\n", ret);
goto err1;
}
memcpy(send_buf->mad, mad, sizeof *mad);
send_buf->ah = ah;
if ((ret = ib_post_send_mad(send_buf, NULL))) {
printk(KERN_ERR SPFX "ib_post_send_mad error:%d\n", ret);
goto err2;
}
return 0;
err2:
ib_free_send_mad(send_buf);
err1:
ib_destroy_ah(ah);
return ret;
}
static void agent_send_handler(struct ib_mad_agent *mad_agent,
struct ib_mad_send_wc *mad_send_wc)
{
ib_destroy_ah(mad_send_wc->send_buf->ah);
ib_free_send_mad(mad_send_wc->send_buf);
}
int ib_agent_port_open(struct ib_device *device, int port_num)
{
struct <API key> *port_priv;
unsigned long flags;
int ret;
/* Create new device info */
port_priv = kzalloc(sizeof *port_priv, GFP_KERNEL);
if (!port_priv) {
printk(KERN_ERR SPFX "No memory for <API key>\n");
ret = -ENOMEM;
goto error1;
}
/* Obtain send only MAD agent for SMI QP */
port_priv->agent[0] = <API key>(device, port_num,
IB_QPT_SMI, NULL, 0,
&agent_send_handler,
NULL, NULL);
if (IS_ERR(port_priv->agent[0])) {
ret = PTR_ERR(port_priv->agent[0]);
goto error2;
}
/* Obtain send only MAD agent for GSI QP */
port_priv->agent[1] = <API key>(device, port_num,
IB_QPT_GSI, NULL, 0,
&agent_send_handler,
NULL, NULL);
if (IS_ERR(port_priv->agent[1])) {
ret = PTR_ERR(port_priv->agent[1]);
goto error3;
}
spin_lock_irqsave(&<API key>, flags);
list_add_tail(&port_priv->port_list, &ib_agent_port_list);
<API key>(&<API key>, flags);
return 0;
error3:
<API key>(port_priv->agent[0]);
error2:
kfree(port_priv);
error1:
return ret;
}
int ib_agent_port_close(struct ib_device *device, int port_num)
{
struct <API key> *port_priv;
unsigned long flags;
spin_lock_irqsave(&<API key>, flags);
port_priv = __ib_get_agent_port(device, port_num);
if (port_priv == NULL) {
<API key>(&<API key>, flags);
printk(KERN_ERR SPFX "Port %d not found\n", port_num);
return -ENODEV;
}
list_del(&port_priv->port_list);
<API key>(&<API key>, flags);
<API key>(port_priv->agent[1]);
<API key>(port_priv->agent[0]);
kfree(port_priv);
return 0;
} |
/*
* Further development / testing that should be done :
* 1. Cleanup the <API key> function and DMA operation complete
* code so that everything does the same thing that's done at the
* end of a pseudo-DMA read operation.
*
* 2. Fix REAL_DMA (interrupt driven, polled works fine) -
* basically, transfer size needs to be reduced by one
* and the last byte read as is done with PSEUDO_DMA.
*
* 4. Test SCSI-II tagged queueing (I have no devices which support
* tagged queueing)
*
* 5. Test linked command handling code after Eric is ready with
* the high level code.
*/
#include <scsi/scsi_dbg.h>
#include <scsi/scsi_transport_spi.h>
#ifndef NDEBUG
#define NDEBUG 0
#endif
#ifndef NDEBUG_ABORT
#define NDEBUG_ABORT 0
#endif
#if (NDEBUG & NDEBUG_LISTS)
#define LIST(x,y) {printk("LINE:%d Adding %p to %p\n", __LINE__, (void*)(x), (void*)(y)); if ((x)==(y)) udelay(5); }
#define REMOVE(w,x,y,z) {printk("LINE:%d Removing: %p->%p %p->%p \n", __LINE__, (void*)(w), (void*)(x), (void*)(y), (void*)(z)); if ((x)==(y)) udelay(5); }
#else
#define LIST(x,y)
#define REMOVE(w,x,y,z)
#endif
#ifndef notyet
#undef LINKED
#undef REAL_DMA
#endif
#ifdef REAL_DMA_POLL
#undef READ_OVERRUNS
#define READ_OVERRUNS
#endif
#ifdef <API key>
#define io_recovery_delay(x)
#else
#define io_recovery_delay(x) udelay(x)
#endif
/*
* Design
*
* This is a generic 5380 driver. To use it on a different platform,
* one simply writes appropriate system specific macros (ie, data
* transfer - some PC's will use the I/O bus, 68K's must use
* memory mapped) and drops this file in their 'C' wrapper.
*
* (Note from hch: unfortunately it was not enough for the different
* m68k folks and instead of improving this driver they copied it
* and hacked it up for their needs. As a consequence they lost
* most updates to this driver. Maybe someone will fix all these
* drivers to use a common core one day..)
*
* As far as command queueing, two queues are maintained for
* each 5380 in the system - commands that haven't been issued yet,
* and commands that are currently executing. This means that an
* unlimited number of commands may be queued, letting
* more commands propagate from the higher driver levels giving higher
* throughput. Note that both I_T_L and I_T_L_Q nexuses are supported,
* allowing multiple commands to propagate all the way to a SCSI-II device
* while a command is already executing.
*
*
* Issues specific to the NCR5380 :
*
* When used in a PIO or pseudo-dma mode, the NCR5380 is a braindead
* piece of hardware that requires you to sit in a loop polling for
* the REQ signal as long as you are connected. Some devices are
* brain dead (ie, many TEXEL CD ROM drives) and won't disconnect
* while doing long seek operations.
*
* The workaround for this is to keep track of devices that have
* disconnected. If the device hasn't disconnected, for commands that
* should disconnect, we do something like
*
* while (!REQ is asserted) { sleep for N usecs; poll for M usecs }
*
* Some tweaking of N and M needs to be done. An algorithm based
* on "time to data" would give the best results as long as short time
* to datas (ie, on the same track) were considered, however these
* broken devices are the exception rather than the rule and I'd rather
* spend my time optimizing for the normal case.
*
* Architecture :
*
* At the heart of the design is a coroutine, NCR5380_main,
* which is started from a workqueue for each NCR5380 host in the
* system. It attempts to establish I_T_L or I_T_L_Q nexuses by
* removing the commands from the issue queue and calling
* NCR5380_select() if a nexus is not established.
*
* Once a nexus is established, the <API key>()
* phase goes through the various phases as instructed by the target.
* if the target goes into MSG IN and sends a DISCONNECT message,
* the command structure is placed into the per instance disconnected
* queue, and NCR5380_main tries to find more work. If the target is
* idle for too long, the system will try to sleep.
*
* If a command has disconnected, eventually an interrupt will trigger,
* calling NCR5380_intr() which will in turn call NCR5380_reselect
* to reestablish a nexus. This will run main if necessary.
*
* On command termination, the done function will be called as
* appropriate.
*
* SCSI pointers are maintained in the SCp field of SCSI command
* structures, being initialized after the command is connected
* in NCR5380_select, and set as appropriate in <API key>.
* Note that in violation of the standard, an implicit SAVE POINTERS operation
* is done, since some BROKEN disks fail to issue an explicit SAVE POINTERS.
*/
/*
* Using this file :
* This file a skeleton Linux SCSI driver for the NCR 5380 series
* of chips. To use it, you write an architecture specific functions
* and macros and include this file in your driver.
*
* These macros control options :
* AUTOPROBE_IRQ - if defined, the NCR5380_probe_irq() function will be
* defined.
*
* AUTOSENSE - if defined, REQUEST SENSE will be performed automatically
* for commands that return with a CHECK CONDITION status.
*
* DIFFERENTIAL - if defined, NCR53c81 chips will use external differential
* transceivers.
*
* DONT_USE_INTR - if defined, never use interrupts, even if we probe or
* override-configure an IRQ.
*
* LIMIT_TRANSFERSIZE - if defined, limit the pseudo-dma transfers to 512
* bytes at a time. Since interrupts are disabled by default during
* these transfers, we might need this to give reasonable interrupt
* service time if the transfer size gets too large.
*
* LINKED - if defined, linked commands are supported.
*
* PSEUDO_DMA - if defined, PSEUDO DMA is used during the data transfer phases.
*
* REAL_DMA - if defined, REAL DMA is used during the data transfer phases.
*
* REAL_DMA_POLL - if defined, REAL DMA is used but the driver doesn't
* rely on phase mismatch and EOP interrupts to determine end
* of phase.
*
* UNSAFE - leave interrupts enabled during pseudo-DMA transfers. You
* only really want to use this if you're having a problem with
* dropped characters during high speed communications, and even
* then, you're going to be better off twiddling with transfersize
* in the high level code.
*
* Defaults for these will be provided although the user may want to adjust
* these to allocate CPU resources to the SCSI driver or "real" code.
*
* USLEEP_SLEEP - amount of time, in jiffies, to sleep
*
* USLEEP_POLL - amount of time, in jiffies, to poll
*
* These macros MUST be defined :
* <API key>() - declare any local variables needed for your
* transfer routines.
*
* NCR5380_setup(instance) - initialize any local variables needed from a given
* instance of the host adapter for NCR5380_{read,write,pread,pwrite}
*
* NCR5380_read(register) - read from the specified register
*
* NCR5380_write(register, value) - write to the specific register
*
* <API key> - additional fields needed for this
* specific implementation of the NCR5380
*
* Either real DMA *or* pseudo DMA may be implemented
* REAL functions :
* NCR5380_REAL_DMA should be defined if real DMA is to be used.
* Note that the DMA setup functions should return the number of bytes
* that they were able to program the controller for.
*
* Also note that generic i386/PC versions of these macros are
* available as <API key>,
* <API key>, and <API key>.
*
* <API key>(instance, src, count) - initialize
* <API key>(instance, dst, count) - initialize
* <API key>(instance); - residual count
*
* PSEUDO functions :
* NCR5380_pwrite(instance, src, count)
* NCR5380_pread(instance, dst, count);
*
* The generic driver is initialized by calling NCR5380_init(instance),
* after setting the appropriate host specific fields and ID. If the
* driver wishes to autoprobe for an IRQ line, the NCR5380_probe_irq(instance,
* possible) function may be used.
*/
static int do_abort(struct Scsi_Host *host);
static void do_reset(struct Scsi_Host *host);
/*
* initialize_SCp - init the scsi pointer field
* @cmd: command block to set up
*
* Set up the internal fields in the SCSI command.
*/
static __inline__ void initialize_SCp(Scsi_Cmnd * cmd)
{
/*
* Initialize the Scsi Pointer field so that all of the commands in the
* various queues are valid.
*/
if (cmd->use_sg) {
cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer;
cmd->SCp.buffers_residual = cmd->use_sg - 1;
cmd->SCp.ptr = page_address(cmd->SCp.buffer->page)+
cmd->SCp.buffer->offset;
cmd->SCp.this_residual = cmd->SCp.buffer->length;
} else {
cmd->SCp.buffer = NULL;
cmd->SCp.buffers_residual = 0;
cmd->SCp.ptr = (char *) cmd->request_buffer;
cmd->SCp.this_residual = cmd->request_bufflen;
}
}
/**
* <API key> - wait for NCR5380 status bits
* @instance: controller to poll
* @reg: 5380 register to poll
* @bit: Bitmask to check
* @val: Value required to exit
*
* Polls the NCR5380 in a reasonably efficient manner waiting for
* an event to occur, after a short quick poll we begin giving the
* CPU back in non IRQ contexts
*
* Returns the value of the register or a negative error code.
*/
static int <API key>(struct Scsi_Host *instance, int reg, int bit, int val, int t)
{
<API key>();
int n = 500; /* At about 8uS a cycle for the cpu access */
unsigned long end = jiffies + t;
int r;
NCR5380_setup(instance);
while( n
{
r = NCR5380_read(reg);
if((r & bit) == val)
return 0;
cpu_relax();
}
/* t time yet ? */
while(time_before(jiffies, end))
{
r = NCR5380_read(reg);
if((r & bit) == val)
return 0;
if(!in_interrupt())
yield();
else
cpu_relax();
}
return -ETIMEDOUT;
}
static struct {
unsigned char value;
const char *name;
} phases[] = {
{PHASE_DATAOUT, "DATAOUT"},
{PHASE_DATAIN, "DATAIN"},
{PHASE_CMDOUT, "CMDOUT"},
{PHASE_STATIN, "STATIN"},
{PHASE_MSGOUT, "MSGOUT"},
{PHASE_MSGIN, "MSGIN"},
{PHASE_UNKNOWN, "UNKNOWN"}
};
#if NDEBUG
static struct {
unsigned char mask;
const char *name;
} signals[] = {
{SR_DBP, "PARITY"},
{SR_RST, "RST"},
{SR_BSY, "BSY"},
{SR_REQ, "REQ"},
{SR_MSG, "MSG"},
{SR_CD, "CD"},
{SR_IO, "IO"},
{SR_SEL, "SEL"},
{0, NULL}
},
basrs[] = {
{BASR_ATN, "ATN"},
{BASR_ACK, "ACK"},
{0, NULL}
},
icrs[] = {
{ICR_ASSERT_RST, "ASSERT RST"},
{ICR_ASSERT_ACK, "ASSERT ACK"},
{ICR_ASSERT_BSY, "ASSERT BSY"},
{ICR_ASSERT_SEL, "ASSERT SEL"},
{ICR_ASSERT_ATN, "ASSERT ATN"},
{ICR_ASSERT_DATA, "ASSERT DATA"},
{0, NULL}
},
mrs[] = {
{MR_BLOCK_DMA_MODE, "MODE BLOCK DMA"},
{MR_TARGET, "MODE TARGET"},
{MR_ENABLE_PAR_CHECK, "MODE PARITY CHECK"},
{MR_ENABLE_PAR_INTR, "MODE PARITY INTR"},
{MR_MONITOR_BSY, "MODE MONITOR BSY"},
{MR_DMA_MODE, "MODE DMA"},
{MR_ARBITRATE, "MODE ARBITRATION"},
{0, NULL}
};
/**
* NCR5380_print - print scsi bus signals
* @instance: adapter state to dump
*
* Print the SCSI bus signals for debugging purposes
*
* Locks: caller holds hostdata lock (not essential)
*/
static void NCR5380_print(struct Scsi_Host *instance)
{
<API key>();
unsigned char status, data, basr, mr, icr, i;
NCR5380_setup(instance);
data = NCR5380_read(<API key>);
status = NCR5380_read(STATUS_REG);
mr = NCR5380_read(MODE_REG);
icr = NCR5380_read(<API key>);
basr = NCR5380_read(BUS_AND_STATUS_REG);
printk("STATUS_REG: %02x ", status);
for (i = 0; signals[i].mask; ++i)
if (status & signals[i].mask)
printk(",%s", signals[i].name);
printk("\nBASR: %02x ", basr);
for (i = 0; basrs[i].mask; ++i)
if (basr & basrs[i].mask)
printk(",%s", basrs[i].name);
printk("\nICR: %02x ", icr);
for (i = 0; icrs[i].mask; ++i)
if (icr & icrs[i].mask)
printk(",%s", icrs[i].name);
printk("\nMODE: %02x ", mr);
for (i = 0; mrs[i].mask; ++i)
if (mr & mrs[i].mask)
printk(",%s", mrs[i].name);
printk("\n");
}
/*
* NCR5380_print_phase - show SCSI phase
* @instance: adapter to dump
*
* Print the current SCSI phase for debugging purposes
*
* Locks: none
*/
static void NCR5380_print_phase(struct Scsi_Host *instance)
{
<API key>();
unsigned char status;
int i;
NCR5380_setup(instance);
status = NCR5380_read(STATUS_REG);
if (!(status & SR_REQ))
printk("scsi%d : REQ not asserted, phase unknown.\n", instance->host_no);
else {
for (i = 0; (phases[i].value != PHASE_UNKNOWN) && (phases[i].value != (status & PHASE_MASK)); ++i);
printk("scsi%d : phase %s\n", instance->host_no, phases[i].name);
}
}
#endif
/*
* These need tweaking, and would probably work best as per-device
* flags initialized differently for disk, tape, cd, etc devices.
* People with broken devices are free to experiment as to what gives
* the best results for them.
*
* USLEEP_SLEEP should be a minimum seek time.
*
* USLEEP_POLL should be a maximum rotational latency.
*/
#ifndef USLEEP_SLEEP
/* 20 ms (reasonable hard disk speed) */
#define USLEEP_SLEEP (20*HZ/1000)
#endif
/* 300 RPM (floppy speed) */
#ifndef USLEEP_POLL
#define USLEEP_POLL (200*HZ/1000)
#endif
#ifndef USLEEP_WAITLONG
/* RvC: (reasonable time to wait on select error) */
#define USLEEP_WAITLONG USLEEP_SLEEP
#endif
/*
* Function : int should_disconnect (unsigned char cmd)
*
* Purpose : decide whether a command would normally disconnect or
* not, since if it won't disconnect we should go to sleep.
*
* Input : cmd - opcode of SCSI command
*
* Returns : DISCONNECT_LONG if we should disconnect for a really long
* time (ie always, sleep, look for REQ active, sleep),
* <API key> if we would only disconnect for a normal
* time-to-data delay, DISCONNECT_NONE if this command would return
* immediately.
*
* Future sleep algorithms based on time to data can exploit
* something like this so they can differentiate between "normal"
* (ie, read, write, seek) and unusual commands (ie, * format).
*
* Note : We don't deal with commands that handle an immediate disconnect,
*
*/
static int should_disconnect(unsigned char cmd)
{
switch (cmd) {
case READ_6:
case WRITE_6:
case SEEK_6:
case READ_10:
case WRITE_10:
case SEEK_10:
return <API key>;
case FORMAT_UNIT:
case SEARCH_HIGH:
case SEARCH_LOW:
case SEARCH_EQUAL:
return DISCONNECT_LONG;
default:
return DISCONNECT_NONE;
}
}
static void NCR5380_set_timer(struct NCR5380_hostdata *hostdata, unsigned long timeout)
{
hostdata->time_expires = jiffies + timeout;
<API key>(&hostdata->coroutine, timeout);
}
static int probe_irq __initdata = 0;
/**
* probe_intr - helper for IRQ autoprobe
* @irq: interrupt number
* @dev_id: unused
* @regs: unused
*
* Set a flag to indicate the IRQ in question was received. This is
* used by the IRQ probe code.
*/
static irqreturn_t __init probe_intr(int irq, void *dev_id)
{
probe_irq = irq;
return IRQ_HANDLED;
}
/**
* NCR5380_probe_irq - find the IRQ of an NCR5380
* @instance: NCR5380 controller
* @possible: bitmask of ISA IRQ lines
*
* Autoprobe for the IRQ line used by the NCR5380 by triggering an IRQ
* and then looking to see what interrupt actually turned up.
*
* Locks: none, irqs must be enabled on entry
*/
static int __init NCR5380_probe_irq(struct Scsi_Host *instance, int possible)
{
<API key>();
struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
unsigned long timeout;
int trying_irqs, i, mask;
NCR5380_setup(instance);
for (trying_irqs = i = 0, mask = 1; i < 16; ++i, mask <<= 1)
if ((mask & possible) && (request_irq(i, &probe_intr, IRQF_DISABLED, "NCR-probe", NULL) == 0))
trying_irqs |= mask;
timeout = jiffies + (250 * HZ / 1000);
probe_irq = SCSI_IRQ_NONE;
/*
* A interrupt is triggered whenever BSY = false, SEL = true
* and a bit set in the SELECT_ENABLE_REG is asserted on the
* SCSI bus.
*
* Note that the bus is only driven when the phase control signals
* (I/O, C/D, and MSG) match those in the TCR, so we must reset that
* to zero.
*/
NCR5380_write(TARGET_COMMAND_REG, 0);
NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask);
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_SEL);
while (probe_irq == SCSI_IRQ_NONE && time_before(jiffies, timeout))
<API key>(1);
NCR5380_write(SELECT_ENABLE_REG, 0);
NCR5380_write(<API key>, ICR_BASE);
for (i = 0, mask = 1; i < 16; ++i, mask <<= 1)
if (trying_irqs & mask)
free_irq(i, NULL);
return probe_irq;
}
/**
* <API key> - show options
* @instance: unused for now
*
* Called by probe code indicating the NCR5380 driver options that
* were selected. At some point this will switch to runtime options
* read from the adapter in question
*
* Locks: none
*/
static void __init <API key>(struct Scsi_Host *instance)
{
printk(" generic options"
#ifdef AUTOPROBE_IRQ
" AUTOPROBE_IRQ"
#endif
#ifdef AUTOSENSE
" AUTOSENSE"
#endif
#ifdef DIFFERENTIAL
" DIFFERENTIAL"
#endif
#ifdef REAL_DMA
" REAL DMA"
#endif
#ifdef REAL_DMA_POLL
" REAL DMA POLL"
#endif
#ifdef PARITY
" PARITY"
#endif
#ifdef PSEUDO_DMA
" PSEUDO DMA"
#endif
#ifdef UNSAFE
" UNSAFE "
#endif
);
printk(" USLEEP, USLEEP_POLL=%d USLEEP_SLEEP=%d", USLEEP_POLL, USLEEP_SLEEP);
printk(" generic release=%d", <API key>);
if (((struct NCR5380_hostdata *) instance->hostdata)->flags & FLAG_NCR53C400) {
printk(" ncr53c400 release=%d", <API key>);
}
}
/**
* <API key> - dump controller info
* @instance: controller to dump
*
* Print commands in the various queues, called from NCR5380_abort
* and NCR5380_debug to aid debugging.
*
* Locks: called functions disable irqs
*/
static void <API key>(struct Scsi_Host *instance)
{
NCR5380_dprint(NDEBUG_ANY, instance);
<API key>(NDEBUG_ANY, instance);
}
/*
* /proc/scsi/[dtc pas16 t128 generic]/[<API key>]
*
* *buffer: I/O buffer
* **start: if inout == FALSE pointer into buffer where user read should start
* offset: current offset
* length: length of buffer
* hostno: Scsi_Host host_no
* inout: TRUE - user is writing; FALSE - user is reading
*
* Return the number of bytes read from or written
*/
#undef SPRINTF
#define SPRINTF(args...) do { if(pos < buffer + length-80) pos += sprintf(pos, ## args); } while(0)
static
char *lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, char *pos, char *buffer, int length);
static
char *lprint_command(unsigned char *cmd, char *pos, char *buffer, int len);
static
char *lprint_opcode(int opcode, char *pos, char *buffer, int length);
static
int NCR5380_proc_info(struct Scsi_Host *instance, char *buffer, char **start, off_t offset, int length, int inout)
{
char *pos = buffer;
struct NCR5380_hostdata *hostdata;
Scsi_Cmnd *ptr;
hostdata = (struct NCR5380_hostdata *) instance->hostdata;
if (inout) { /* Has data been written to the file ? */
#ifdef DTC_PUBLIC_RELEASE
dtc_wmaxi = dtc_maxi = 0;
#endif
#ifdef <API key>
pas_wmaxi = pas_maxi = 0;
#endif
return (-ENOSYS); /* Currently this is a no-op */
}
SPRINTF("NCR5380 core release=%d. ", <API key>);
if (((struct NCR5380_hostdata *) instance->hostdata)->flags & FLAG_NCR53C400)
SPRINTF("ncr53c400 release=%d. ", <API key>);
#ifdef DTC_PUBLIC_RELEASE
SPRINTF("DTC 3180/3280 release %d", DTC_PUBLIC_RELEASE);
#endif
#ifdef T128_PUBLIC_RELEASE
SPRINTF("T128 release %d", T128_PUBLIC_RELEASE);
#endif
#ifdef <API key>
SPRINTF("Generic5380 release %d", <API key>);
#endif
#ifdef <API key>
SPRINTF("PAS16 release=%d", <API key>);
#endif
SPRINTF("\nBase Addr: 0x%05lX ", (long) instance->base);
SPRINTF("io_port: %04x ", (int) instance->io_port);
if (instance->irq == SCSI_IRQ_NONE)
SPRINTF("IRQ: None.\n");
else
SPRINTF("IRQ: %d.\n", instance->irq);
#ifdef DTC_PUBLIC_RELEASE
SPRINTF("Highwater I/O busy_spin_counts -- write: %d read: %d\n", dtc_wmaxi, dtc_maxi);
#endif
#ifdef <API key>
SPRINTF("Highwater I/O busy_spin_counts -- write: %d read: %d\n", pas_wmaxi, pas_maxi);
#endif
spin_lock_irq(instance->host_lock);
if (!hostdata->connected)
SPRINTF("scsi%d: no currently connected command\n", instance->host_no);
else
pos = lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, pos, buffer, length);
SPRINTF("scsi%d: issue_queue\n", instance->host_no);
for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
pos = lprint_Scsi_Cmnd(ptr, pos, buffer, length);
SPRINTF("scsi%d: disconnected_queue\n", instance->host_no);
for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
pos = lprint_Scsi_Cmnd(ptr, pos, buffer, length);
spin_unlock_irq(instance->host_lock);
*start = buffer;
if (pos - buffer < offset)
return 0;
else if (pos - buffer - offset < length)
return pos - buffer - offset;
return length;
}
static char *lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, char *pos, char *buffer, int length)
{
SPRINTF("scsi%d : destination target %d, lun %d\n", cmd->device->host->host_no, cmd->device->id, cmd->device->lun);
SPRINTF(" command = ");
pos = lprint_command(cmd->cmnd, pos, buffer, length);
return (pos);
}
static char *lprint_command(unsigned char *command, char *pos, char *buffer, int length)
{
int i, s;
pos = lprint_opcode(command[0], pos, buffer, length);
for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
SPRINTF("%02x ", command[i]);
SPRINTF("\n");
return (pos);
}
static char *lprint_opcode(int opcode, char *pos, char *buffer, int length)
{
SPRINTF("%2d (0x%02x)", opcode, opcode);
return (pos);
}
/**
* NCR5380_init - initialise an NCR5380
* @instance: adapter to configure
* @flags: control flags
*
* Initializes *instance and corresponding 5380 chip,
* with flags OR'd into the initial flags value.
*
* Notes : I assume that the host, hostno, and id bits have been
* set correctly. I don't care about the irq and other fields.
*
* Returns 0 for success
*
* Locks: interrupts must be enabled when we are called
*/
static int __devinit NCR5380_init(struct Scsi_Host *instance, int flags)
{
<API key>();
int i, pass;
unsigned long timeout;
struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
if(in_interrupt())
printk(KERN_ERR "NCR5380_init called with interrupts off!\n");
/*
* On NCR53C400 boards, NCR5380 registers are mapped 8 past
* the base address.
*/
#ifdef NCR53C400
if (flags & FLAG_NCR53C400)
instance-><API key> += <API key>;
#endif
NCR5380_setup(instance);
hostdata->aborted = 0;
hostdata->id_mask = 1 << instance->this_id;
for (i = hostdata->id_mask; i <= 0x80; i <<= 1)
if (i > hostdata->id_mask)
hostdata->id_higher_mask |= i;
for (i = 0; i < 8; ++i)
hostdata->busy[i] = 0;
#ifdef REAL_DMA
hostdata->dmalen = 0;
#endif
hostdata->targets_present = 0;
hostdata->connected = NULL;
hostdata->issue_queue = NULL;
hostdata->disconnected_queue = NULL;
INIT_DELAYED_WORK(&hostdata->coroutine, NCR5380_main);
#ifdef NCR5380_STATS
for (i = 0; i < 8; ++i) {
hostdata->time_read[i] = 0;
hostdata->time_write[i] = 0;
hostdata->bytes_read[i] = 0;
hostdata->bytes_write[i] = 0;
}
hostdata->timebase = 0;
hostdata->pendingw = 0;
hostdata->pendingr = 0;
#endif
/* The CHECK code seems to break the 53C400. Will check it later maybe */
if (flags & FLAG_NCR53C400)
hostdata->flags = <API key> | flags;
else
hostdata->flags = <API key> | flags;
hostdata->host = instance;
hostdata->time_expires = 0;
#ifndef AUTOSENSE
if ((instance->cmd_per_lun > 1) || instance->can_queue > 1)
printk(KERN_WARNING "scsi%d : WARNING : support for multiple outstanding commands enabled\n" " without AUTOSENSE option, contingent allegiance conditions may\n"
" be incorrectly cleared.\n", instance->host_no);
#endif /* def AUTOSENSE */
NCR5380_write(<API key>, ICR_BASE);
NCR5380_write(MODE_REG, MR_BASE);
NCR5380_write(TARGET_COMMAND_REG, 0);
NCR5380_write(SELECT_ENABLE_REG, 0);
#ifdef NCR53C400
if (hostdata->flags & FLAG_NCR53C400) {
NCR5380_write(<API key>, CSR_BASE);
}
#endif
/*
* Detect and correct bus wedge problems.
*
* If the system crashed, it may have crashed in a state
* where a SCSI command was still executing, and the
* SCSI bus is not in a BUS FREE STATE.
*
* If this is the case, we'll try to abort the currently
* established nexus which we know nothing about, and that
* failing, do a hard reset of the SCSI bus
*/
for (pass = 1; (NCR5380_read(STATUS_REG) & SR_BSY) && pass <= 6; ++pass) {
switch (pass) {
case 1:
case 3:
case 5:
printk(KERN_INFO "scsi%d: SCSI bus busy, waiting up to five seconds\n", instance->host_no);
timeout = jiffies + 5 * HZ;
<API key>(instance, STATUS_REG, SR_BSY, 0, 5*HZ);
break;
case 2:
printk(KERN_WARNING "scsi%d: bus busy, attempting abort\n", instance->host_no);
do_abort(instance);
break;
case 4:
printk(KERN_WARNING "scsi%d: bus busy, attempting reset\n", instance->host_no);
do_reset(instance);
break;
case 6:
printk(KERN_ERR "scsi%d: bus locked solid or invalid override\n", instance->host_no);
return -ENXIO;
}
}
return 0;
}
/**
* NCR5380_exit - remove an NCR5380
* @instance: adapter to remove
*/
static void __devexit NCR5380_exit(struct Scsi_Host *instance)
{
struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
cancel_delayed_work(&hostdata->coroutine);
<API key>();
}
/**
* <API key> - queue a command
* @cmd: SCSI command
* @done: completion handler
*
* cmd is added to the per instance issue_queue, with minor
* twiddling done to the host specific fields of cmd. If the
* main coroutine is not running, it is restarted.
*
* Locks: host lock taken by caller
*/
static int <API key>(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
{
struct Scsi_Host *instance = cmd->device->host;
struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
Scsi_Cmnd *tmp;
#if (NDEBUG & NDEBUG_NO_WRITE)
switch (cmd->cmnd[0]) {
case WRITE_6:
case WRITE_10:
printk("scsi%d : WRITE attempted with NO_WRITE debugging flag set\n", instance->host_no);
cmd->result = (DID_ERROR << 16);
done(cmd);
return 0;
}
#endif /* (NDEBUG & NDEBUG_NO_WRITE) */
#ifdef NCR5380_STATS
switch (cmd->cmnd[0]) {
case WRITE:
case WRITE_6:
case WRITE_10:
hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase);
hostdata->bytes_write[cmd->device->id] += cmd->request_bufflen;
hostdata->pendingw++;
break;
case READ:
case READ_6:
case READ_10:
hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase);
hostdata->bytes_read[cmd->device->id] += cmd->request_bufflen;
hostdata->pendingr++;
break;
}
#endif
/*
* We use the host_scribble field as a pointer to the next command
* in a queue
*/
cmd->host_scribble = NULL;
cmd->scsi_done = done;
cmd->result = 0;
/*
* Insert the cmd into the issue queue. Note that REQUEST SENSE
* commands are added to the head of the queue since any command will
* clear the contingent allegiance condition that exists and the
* sense data is only guaranteed to be valid while the condition exists.
*/
if (!(hostdata->issue_queue) || (cmd->cmnd[0] == REQUEST_SENSE)) {
LIST(cmd, hostdata->issue_queue);
cmd->host_scribble = (unsigned char *) hostdata->issue_queue;
hostdata->issue_queue = cmd;
} else {
for (tmp = (Scsi_Cmnd *) hostdata->issue_queue; tmp->host_scribble; tmp = (Scsi_Cmnd *) tmp->host_scribble);
LIST(cmd, tmp);
tmp->host_scribble = (unsigned char *) cmd;
}
dprintk(NDEBUG_QUEUES, ("scsi%d : command added to %s of queue\n", instance->host_no, (cmd->cmnd[0] == REQUEST_SENSE) ? "head" : "tail"));
/* Run the coroutine if it isn't already running. */
/* Kick off command processing */
<API key>(&hostdata->coroutine, 0);
return 0;
}
/**
* NCR5380_main - NCR state machines
*
* NCR5380_main is a coroutine that runs as long as more work can
* be done on the NCR5380 host adapters in a system. Both
* <API key>() and NCR5380_intr() will try to start it
* in case it is not running.
*
* Locks: called as its own thread with no locks held. Takes the
* host lock and called routines may take the isa dma lock.
*/
static void NCR5380_main(struct work_struct *work)
{
struct NCR5380_hostdata *hostdata =
container_of(work, struct NCR5380_hostdata, coroutine.work);
struct Scsi_Host *instance = hostdata->host;
Scsi_Cmnd *tmp, *prev;
int done;
spin_lock_irq(instance->host_lock);
do {
/* Lock held here */
done = 1;
if (!hostdata->connected && !hostdata->selecting) {
dprintk(NDEBUG_MAIN, ("scsi%d : not connected\n", instance->host_no));
/*
* Search through the issue_queue for a command destined
* for a target that's not busy.
*/
for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, prev = NULL; tmp; prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble)
{
if (prev != tmp)
dprintk(NDEBUG_LISTS, ("MAIN tmp=%p target=%d busy=%d lun=%d\n", tmp, tmp->target, hostdata->busy[tmp->target], tmp->lun));
/* When we find one, remove it from the issue queue. */
if (!(hostdata->busy[tmp->device->id] & (1 << tmp->device->lun))) {
if (prev) {
REMOVE(prev, prev->host_scribble, tmp, tmp->host_scribble);
prev->host_scribble = tmp->host_scribble;
} else {
REMOVE(-1, hostdata->issue_queue, tmp, tmp->host_scribble);
hostdata->issue_queue = (Scsi_Cmnd *) tmp->host_scribble;
}
tmp->host_scribble = NULL;
/*
* Attempt to establish an I_T_L nexus here.
* On success, instance->hostdata->connected is set.
* On failure, we must add the command back to the
* issue queue so we can keep trying.
*/
dprintk(NDEBUG_MAIN|NDEBUG_QUEUES, ("scsi%d : main() : command for target %d lun %d removed from issue_queue\n", instance->host_no, tmp->target, tmp->lun));
/*
* A successful selection is defined as one that
* leaves us with the command connected and
* in hostdata->connected, OR has terminated the
* command.
*
* With successful commands, we fall through
* and see if we can do an information transfer,
* with failures we will restart.
*/
hostdata->selecting = NULL;
/* RvC: have to preset this to indicate a new command is being performed */
if (!NCR5380_select(instance, tmp,
/*
* REQUEST SENSE commands are issued without tagged
* queueing, even on SCSI-II devices because the
* contingent allegiance condition exists for the
* entire unit.
*/
(tmp->cmnd[0] == REQUEST_SENSE) ? TAG_NONE : TAG_NEXT)) {
break;
} else {
LIST(tmp, hostdata->issue_queue);
tmp->host_scribble = (unsigned char *) hostdata->issue_queue;
hostdata->issue_queue = tmp;
done = 0;
dprintk(NDEBUG_MAIN|NDEBUG_QUEUES, ("scsi%d : main(): select() failed, returned to issue_queue\n", instance->host_no));
}
/* lock held here still */
} /* if target/lun is not busy */
} /* for */
/* exited locked */
} /* if (!hostdata->connected) */
if (hostdata->selecting) {
tmp = (Scsi_Cmnd *) hostdata->selecting;
/* Selection will drop and retake the lock */
if (!NCR5380_select(instance, tmp, (tmp->cmnd[0] == REQUEST_SENSE) ? TAG_NONE : TAG_NEXT)) {
} else {
/* RvC: device failed, so we wait a long time
this is needed for Mustek scanners, that
do not respond to commands immediately
after a scan */
printk(KERN_DEBUG "scsi%d: device %d did not respond in time\n", instance->host_no, tmp->device->id);
LIST(tmp, hostdata->issue_queue);
tmp->host_scribble = (unsigned char *) hostdata->issue_queue;
hostdata->issue_queue = tmp;
NCR5380_set_timer(hostdata, USLEEP_WAITLONG);
}
} /* if hostdata->selecting */
if (hostdata->connected
#ifdef REAL_DMA
&& !hostdata->dmalen
#endif
&& (!hostdata->time_expires || time_before_eq(hostdata->time_expires, jiffies))
) {
dprintk(NDEBUG_MAIN, ("scsi%d : main() : performing information transfer\n", instance->host_no));
<API key>(instance);
dprintk(NDEBUG_MAIN, ("scsi%d : main() : done set false\n", instance->host_no));
done = 0;
} else
break;
} while (!done);
spin_unlock_irq(instance->host_lock);
}
#ifndef DONT_USE_INTR
/**
* NCR5380_intr - generic NCR5380 irq handler
* @irq: interrupt number
* @dev_id: device info
*
* Handle interrupts, reestablishing I_T_L or I_T_L_Q nexuses
* from the disconnected queue, and restarting NCR5380_main()
* as required.
*
* Locks: takes the needed instance locks
*/
static irqreturn_t NCR5380_intr(int irq, void *dev_id)
{
<API key>();
struct Scsi_Host *instance = (struct Scsi_Host *)dev_id;
struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
int done;
unsigned char basr;
unsigned long flags;
dprintk(NDEBUG_INTR, ("scsi : NCR5380 irq %d triggered\n", irq));
do {
done = 1;
spin_lock_irqsave(instance->host_lock, flags);
/* Look for pending interrupts */
NCR5380_setup(instance);
basr = NCR5380_read(BUS_AND_STATUS_REG);
/* XXX dispatch to appropriate routine if found and done=0 */
if (basr & BASR_IRQ) {
NCR5380_dprint(NDEBUG_INTR, instance);
if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) == (SR_SEL | SR_IO)) {
done = 0;
dprintk(NDEBUG_INTR, ("scsi%d : SEL interrupt\n", instance->host_no));
NCR5380_reselect(instance);
(void) NCR5380_read(<API key>);
} else if (basr & BASR_PARITY_ERROR) {
dprintk(NDEBUG_INTR, ("scsi%d : PARITY interrupt\n", instance->host_no));
(void) NCR5380_read(<API key>);
} else if ((NCR5380_read(STATUS_REG) & SR_RST) == SR_RST) {
dprintk(NDEBUG_INTR, ("scsi%d : RESET interrupt\n", instance->host_no));
(void) NCR5380_read(<API key>);
} else {
#if defined(REAL_DMA)
/*
* We should only get PHASE MISMATCH and EOP interrupts
* if we have DMA enabled, so do a sanity check based on
* the current setting of the MODE register.
*/
if ((NCR5380_read(MODE_REG) & MR_DMA) && ((basr & <API key>) || !(basr & BASR_PHASE_MATCH))) {
int transfered;
if (!hostdata->connected)
panic("scsi%d : received end of DMA interrupt with no connected cmd\n", instance->hostno);
transfered = (hostdata->dmalen - <API key>(instance));
hostdata->connected->SCp.this_residual -= transferred;
hostdata->connected->SCp.ptr += transferred;
hostdata->dmalen = 0;
(void) NCR5380_read(<API key>);
/* FIXME: we need to poll briefly then defer a workqueue task ! */
<API key>(hostdata, BUS_AND_STATUS_REG, BASR_ACK, 0, 2*HZ);
NCR5380_write(MODE_REG, MR_BASE);
NCR5380_write(<API key>, ICR_BASE);
}
#else
dprintk(NDEBUG_INTR, ("scsi : unknown interrupt, BASR 0x%X, MR 0x%X, SR 0x%x\n", basr, NCR5380_read(MODE_REG), NCR5380_read(STATUS_REG)));
(void) NCR5380_read(<API key>);
#endif
}
} /* if BASR_IRQ */
<API key>(instance->host_lock, flags);
if(!done)
<API key>(&hostdata->coroutine, 0);
} while (!done);
return IRQ_HANDLED;
}
#endif
/**
* collect_stats - collect stats on a scsi command
* @hostdata: adapter
* @cmd: command being issued
*
* Update the statistical data by parsing the command in question
*/
static void collect_stats(struct NCR5380_hostdata *hostdata, Scsi_Cmnd * cmd)
{
#ifdef NCR5380_STATS
switch (cmd->cmnd[0]) {
case WRITE:
case WRITE_6:
case WRITE_10:
hostdata->time_write[scmd_id(cmd)] += (jiffies - hostdata->timebase);
hostdata->pendingw
break;
case READ:
case READ_6:
case READ_10:
hostdata->time_read[scmd_id(cmd)] += (jiffies - hostdata->timebase);
hostdata->pendingr
break;
}
#endif
}
/*
* Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd,
* int tag);
*
* Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command,
* including ARBITRATION, SELECTION, and initial message out for
* IDENTIFY and queue messages.
*
* Inputs : instance - instantiation of the 5380 driver on which this
* target lives, cmd - SCSI command to execute, tag - set to TAG_NEXT for
* new tag, TAG_NONE for untagged queueing, otherwise set to the tag for
* the command that is presently connected.
*
* Returns : -1 if selection could not execute for some reason,
* 0 if selection succeeded or failed because the target
* did not respond.
*
* Side effects :
* If bus busy, arbitration failed, etc, NCR5380_select() will exit
* with registers as they should have been on entry - ie
* SELECT_ENABLE will be set appropriately, the NCR5380
* will cease to drive any SCSI bus signals.
*
* If successful : I_T_L or I_T_L_Q nexus will be established,
* instance->connected will be set to cmd.
* SELECT interrupt will be disabled.
*
* If failed (no target) : cmd->scsi_done() will be called, and the
* cmd->result host byte set to DID_BAD_TARGET.
*
* Locks: caller holds hostdata lock in IRQ mode
*/
static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag)
{
<API key>();
struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
unsigned char tmp[3], phase;
unsigned char *data;
int len;
unsigned long timeout;
unsigned char value;
int err;
NCR5380_setup(instance);
if (hostdata->selecting)
goto part2;
hostdata->restart_select = 0;
NCR5380_dprint(NDEBUG_ARBITRATION, instance);
dprintk(NDEBUG_ARBITRATION, ("scsi%d : starting arbitration, id = %d\n", instance->host_no, instance->this_id));
/*
* Set the phase bits to 0, otherwise the NCR5380 won't drive the
* data bus during SELECTION.
*/
NCR5380_write(TARGET_COMMAND_REG, 0);
/*
* Start arbitration.
*/
NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask);
NCR5380_write(MODE_REG, MR_ARBITRATE);
/* We can be relaxed here, interrupts are on, we are
in workqueue context, the birds are singing in the trees */
spin_unlock_irq(instance->host_lock);
err = <API key>(instance, <API key>, <API key>, <API key>, 5*HZ);
spin_lock_irq(instance->host_lock);
if (err < 0) {
printk(KERN_DEBUG "scsi: arbitration timeout at %d\n", __LINE__);
NCR5380_write(MODE_REG, MR_BASE);
NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
goto failed;
}
dprintk(NDEBUG_ARBITRATION, ("scsi%d : arbitration complete\n", instance->host_no));
/*
* The arbitration delay is 2.2us, but this is a minimum and there is
* no maximum so we can safely sleep for ceil(2.2) usecs to accommodate
* the integral nature of udelay().
*
*/
udelay(3);
/* Check for lost arbitration */
if ((NCR5380_read(<API key>) & <API key>) || (NCR5380_read(<API key>) & hostdata->id_higher_mask) || (NCR5380_read(<API key>) & <API key>)) {
NCR5380_write(MODE_REG, MR_BASE);
dprintk(NDEBUG_ARBITRATION, ("scsi%d : lost arbitration, deasserting MR_ARBITRATE\n", instance->host_no));
goto failed;
}
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_SEL);
if (!(hostdata->flags & FLAG_DTC3181E) &&
/* RvC: DTC3181E has some trouble with this
* so we simply removed it. Seems to work with
* only Mustek scanner attached
*/
(NCR5380_read(<API key>) & <API key>)) {
NCR5380_write(MODE_REG, MR_BASE);
NCR5380_write(<API key>, ICR_BASE);
dprintk(NDEBUG_ARBITRATION, ("scsi%d : lost arbitration, deasserting ICR_ASSERT_SEL\n", instance->host_no));
goto failed;
}
/*
* Again, bus clear + bus settle time is 1.2us, however, this is
* a minimum so we'll udelay ceil(1.2)
*/
udelay(2);
dprintk(NDEBUG_ARBITRATION, ("scsi%d : won arbitration\n", instance->host_no));
/*
* Now that we have won arbitration, start Selection process, asserting
* the host and target ID's on the SCSI bus.
*/
NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << scmd_id(cmd))));
/*
* Raise ATN while SEL is true before BSY goes false from arbitration,
* since this is the only way to guarantee that we'll get a MESSAGE OUT
* phase immediately after selection.
*/
NCR5380_write(<API key>, (ICR_BASE | ICR_ASSERT_BSY | ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_SEL));
NCR5380_write(MODE_REG, MR_BASE);
/*
* Reselect interrupts must be turned off prior to the dropping of BSY,
* otherwise we will trigger an interrupt.
*/
NCR5380_write(SELECT_ENABLE_REG, 0);
/*
* The initiator shall then wait at least two deskew delays and release
* the BSY signal.
*/
udelay(1); /* wingel -- wait two bus deskew delay >2*45ns */
/* Reset BSY */
NCR5380_write(<API key>, (ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_SEL));
/*
* Something weird happens when we cease to drive BSY - looks
* like the board/chip is letting us do another read before the
* appropriate propagation delay has expired, and we're confusing
* a BSY signal from ourselves as the target's response to SELECTION.
*
* A small delay (the 'C++' frontend breaks the pipeline with an
* unnecessary jump, making it work on my 386-33/Trantor T128, the
* tighter 'C' code breaks and requires this) solves the problem -
* the 1 us delay is arbitrary, and only used because this delay will
* be the same on other platforms and since it works here, it should
* work there.
*
* wingel suggests that this could be due to failing to wait
* one deskew delay.
*/
udelay(1);
dprintk(NDEBUG_SELECTION, ("scsi%d : selecting target %d\n", instance->host_no, scmd_id(cmd)));
/*
* The SCSI specification calls for a 250 ms timeout for the actual
* selection.
*/
timeout = jiffies + (250 * HZ / 1000);
/*
* XXX very interesting - we're seeing a bounce where the BSY we
* asserted is being reflected / still asserted (propagation delay?)
* and it's detecting as true. Sigh.
*/
hostdata->select_time = 0; /* we count the clock ticks at which we polled */
hostdata->selecting = cmd;
part2:
/* RvC: here we enter after a sleeping period, or immediately after
execution of part 1
we poll only once ech clock tick */
value = NCR5380_read(STATUS_REG) & (SR_BSY | SR_IO);
if (!value && (hostdata->select_time < HZ/4)) {
/* RvC: we still must wait for a device response */
hostdata->select_time++; /* after 25 ticks the device has failed */
NCR5380_set_timer(hostdata, 1);
return 0; /* RvC: we return here with hostdata->selecting set,
to go to sleep */
}
hostdata->selecting = NULL;/* clear this pointer, because we passed the
waiting period */
if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) == (SR_SEL | SR_IO)) {
NCR5380_write(<API key>, ICR_BASE);
NCR5380_reselect(instance);
printk("scsi%d : reselection after won arbitration?\n", instance->host_no);
NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
return -1;
}
/*
* No less than two deskew delays after the initiator detects the
* BSY signal is true, it shall release the SEL signal and may
* change the DATA BUS. -wingel
*/
udelay(1);
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_ATN);
if (!(NCR5380_read(STATUS_REG) & SR_BSY)) {
NCR5380_write(<API key>, ICR_BASE);
if (hostdata->targets_present & (1 << scmd_id(cmd))) {
printk(KERN_DEBUG "scsi%d : weirdness\n", instance->host_no);
if (hostdata->restart_select)
printk(KERN_DEBUG "\trestart select\n");
NCR5380_dprint(NDEBUG_SELECTION, instance);
NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
return -1;
}
cmd->result = DID_BAD_TARGET << 16;
collect_stats(hostdata, cmd);
cmd->scsi_done(cmd);
NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
dprintk(NDEBUG_SELECTION, ("scsi%d : target did not respond within 250ms\n", instance->host_no));
NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
return 0;
}
hostdata->targets_present |= (1 << scmd_id(cmd));
/*
* Since we followed the SCSI spec, and raised ATN while SEL
* was true but before BSY was false during selection, the information
* transfer phase should be a MESSAGE OUT phase so that we can send the
* IDENTIFY message.
*
* If SCSI-II tagged queuing is enabled, we also send a SIMPLE_QUEUE_TAG
* message (2 bytes) with a tag ID that we increment with every command
* until it wraps back to 0.
*
* XXX - it turns out that there are some broken SCSI-II devices,
* which claim to support tagged queuing but fail when more than
* some number of commands are issued at once.
*/
/* Wait for start of REQ/ACK handshake */
spin_unlock_irq(instance->host_lock);
err = <API key>(instance, STATUS_REG, SR_REQ, SR_REQ, HZ);
spin_lock_irq(instance->host_lock);
if(err) {
printk(KERN_ERR "scsi%d: timeout at NCR5380.c:%d\n", instance->host_no, __LINE__);
NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
goto failed;
}
dprintk(NDEBUG_SELECTION, ("scsi%d : target %d selected, going into MESSAGE OUT phase.\n", instance->host_no, cmd->device->id));
tmp[0] = IDENTIFY(((instance->irq == SCSI_IRQ_NONE) ? 0 : 1), cmd->device->lun);
len = 1;
cmd->tag = 0;
/* Send message(s) */
data = tmp;
phase = PHASE_MSGOUT;
<API key>(instance, &phase, &len, &data);
dprintk(NDEBUG_SELECTION, ("scsi%d : nexus established.\n", instance->host_no));
/* XXX need to handle errors here */
hostdata->connected = cmd;
hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
if (cmd->SCp.ptr != (char *)cmd->sense_buffer) {
initialize_SCp(cmd);
}
return 0;
/* Selection failed */
failed:
return -1;
}
/*
* Function : int <API key> (struct Scsi_Host *instance,
* unsigned char *phase, int *count, unsigned char **data)
*
* Purpose : transfers data in given phase using polled I/O
*
* Inputs : instance - instance of driver, *phase - pointer to
* what phase is expected, *count - pointer to number of
* bytes to transfer, **data - pointer to data pointer.
*
* Returns : -1 when different phase is entered without transferring
* maximum number of bytes, 0 if all bytes or transfered or exit
* is in same phase.
*
* Also, *phase, *count, *data are modified in place.
*
* XXX Note : handling for bus free may be useful.
*/
/*
* Note : this code is not as quick as it could be, however it
* IS 100% reliable, and for the actual data transfer where speed
* counts, we will always do a pseudo DMA or DMA transfer.
*/
static int <API key>(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data) {
<API key>();
unsigned char p = *phase, tmp;
int c = *count;
unsigned char *d = *data;
/*
* RvC: some administrative data to process polling time
*/
int break_allowed = 0;
struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
NCR5380_setup(instance);
if (!(p & SR_IO))
dprintk(NDEBUG_PIO, ("scsi%d : pio write %d bytes\n", instance->host_no, c));
else
dprintk(NDEBUG_PIO, ("scsi%d : pio read %d bytes\n", instance->host_no, c));
/*
* The NCR5380 chip will only drive the SCSI bus when the
* phase specified in the appropriate bits of the TARGET COMMAND
* REGISTER match the STATUS REGISTER
*/
NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(p));
/* RvC: don't know if this is necessary, but other SCSI I/O is short
* so breaks are not necessary there
*/
if ((p == PHASE_DATAIN) || (p == PHASE_DATAOUT)) {
break_allowed = 1;
}
do {
/*
* Wait for assertion of REQ, after which the phase bits will be
* valid
*/
/* RvC: we simply poll once, after that we stop temporarily
* and let the device buffer fill up
* if breaking is not allowed, we keep polling as long as needed
*/
/* FIXME */
while (!((tmp = NCR5380_read(STATUS_REG)) & SR_REQ) && !break_allowed);
if (!(tmp & SR_REQ)) {
/* timeout condition */
NCR5380_set_timer(hostdata, USLEEP_SLEEP);
break;
}
dprintk(NDEBUG_HANDSHAKE, ("scsi%d : REQ detected\n", instance->host_no));
/* Check for phase mismatch */
if ((tmp & PHASE_MASK) != p) {
dprintk(NDEBUG_HANDSHAKE, ("scsi%d : phase mismatch\n", instance->host_no));
<API key>(NDEBUG_HANDSHAKE, instance);
break;
}
/* Do actual transfer from SCSI bus to / from memory */
if (!(p & SR_IO))
NCR5380_write(OUTPUT_DATA_REG, *d);
else
*d = NCR5380_read(<API key>);
++d;
/*
* The SCSI standard suggests that in MSGOUT phase, the initiator
* should drop ATN on the last byte of the message phase
* after REQ has been asserted for the handshake but before
* the initiator raises ACK.
*/
if (!(p & SR_IO)) {
if (!((p & SR_MSG) && c > 1)) {
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_DATA);
NCR5380_dprint(NDEBUG_PIO, instance);
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_ACK);
} else {
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_ATN);
NCR5380_dprint(NDEBUG_PIO, instance);
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_ACK);
}
} else {
NCR5380_dprint(NDEBUG_PIO, instance);
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_ACK);
}
/* FIXME - if this fails bus reset ?? */
<API key>(instance, STATUS_REG, SR_REQ, 0, 5*HZ);
dprintk(NDEBUG_HANDSHAKE, ("scsi%d : req false, handshake complete\n", instance->host_no));
/*
* We have several special cases to consider during REQ/ACK handshaking :
* 1. We were in MSGOUT phase, and we are on the last byte of the
* message. ATN must be dropped as ACK is dropped.
*
* 2. We are in a MSGIN phase, and we are on the last byte of the
* message. We must exit with ACK asserted, so that the calling
* code may raise ATN before dropping ACK to reject the message.
*
* 3. ACK and ATN are clear and the target may proceed as normal.
*/
if (!(p == PHASE_MSGIN && c == 1)) {
if (p == PHASE_MSGOUT && c > 1)
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_ATN);
else
NCR5380_write(<API key>, ICR_BASE);
}
} while (--c);
dprintk(NDEBUG_PIO, ("scsi%d : residual %d\n", instance->host_no, c));
*count = c;
*data = d;
tmp = NCR5380_read(STATUS_REG);
if (tmp & SR_REQ)
*phase = tmp & PHASE_MASK;
else
*phase = PHASE_UNKNOWN;
if (!c || (*phase == p))
return 0;
else
return -1;
}
/**
* do_reset - issue a reset command
* @host: adapter to reset
*
* Issue a reset sequence to the NCR5380 and try and get the bus
* back into sane shape.
*
* Locks: caller holds queue lock
*/
static void do_reset(struct Scsi_Host *host) {
<API key>();
NCR5380_setup(host);
NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(NCR5380_read(STATUS_REG) & PHASE_MASK));
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_RST);
udelay(25);
NCR5380_write(<API key>, ICR_BASE);
}
/*
* Function : do_abort (Scsi_Host *host)
*
* Purpose : abort the currently established nexus. Should only be
* called from a routine which can drop into a
*
* Returns : 0 on success, -1 on failure.
*
* Locks: queue lock held by caller
* FIXME: sort this out and get new_eh running
*/
static int do_abort(struct Scsi_Host *host) {
<API key>();
unsigned char *msgptr, phase, tmp;
int len;
int rc;
NCR5380_setup(host);
/* Request message out phase */
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_ATN);
/*
* Wait for the target to indicate a valid phase by asserting
* REQ. Once this happens, we'll have either a MSGOUT phase
* and can immediately send the ABORT message, or we'll have some
* other phase and will have to source/sink data.
*
* We really don't care what value was on the bus or what value
* the target sees, so we just handshake.
*/
rc = <API key>(host, STATUS_REG, SR_REQ, SR_REQ, 60 * HZ);
if(rc < 0)
return -1;
tmp = (unsigned char)rc;
NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));
if ((tmp & PHASE_MASK) != PHASE_MSGOUT) {
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_ATN | ICR_ASSERT_ACK);
rc = <API key>(host, STATUS_REG, SR_REQ, 0, 3*HZ);
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_ATN);
if(rc == -1)
return -1;
}
tmp = ABORT;
msgptr = &tmp;
len = 1;
phase = PHASE_MSGOUT;
<API key>(host, &phase, &len, &msgptr);
/*
* If we got here, and the command completed successfully,
* we're about to go into bus free state.
*/
return len ? -1 : 0;
}
#if defined(REAL_DMA) || defined(PSEUDO_DMA) || defined (REAL_DMA_POLL)
/*
* Function : int <API key> (struct Scsi_Host *instance,
* unsigned char *phase, int *count, unsigned char **data)
*
* Purpose : transfers data in given phase using either real
* or pseudo DMA.
*
* Inputs : instance - instance of driver, *phase - pointer to
* what phase is expected, *count - pointer to number of
* bytes to transfer, **data - pointer to data pointer.
*
* Returns : -1 when different phase is entered without transferring
* maximum number of bytes, 0 if all bytes or transfered or exit
* is in same phase.
*
* Also, *phase, *count, *data are modified in place.
*
* Locks: io_request lock held by caller
*/
static int <API key>(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data) {
<API key>();
register int c = *count;
register unsigned char p = *phase;
register unsigned char *d = *data;
unsigned char tmp;
int foo;
#if defined(REAL_DMA_POLL)
int cnt, toPIO;
unsigned char saved_data = 0, overrun = 0, residue;
#endif
struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
NCR5380_setup(instance);
if ((tmp = (NCR5380_read(STATUS_REG) & PHASE_MASK)) != p) {
*phase = tmp;
return -1;
}
#if defined(REAL_DMA) || defined(REAL_DMA_POLL)
#ifdef READ_OVERRUNS
if (p & SR_IO) {
c -= 2;
}
#endif
dprintk(NDEBUG_DMA, ("scsi%d : initializing DMA channel %d for %s, %d bytes %s %0x\n", instance->host_no, instance->dma_channel, (p & SR_IO) ? "reading" : "writing", c, (p & SR_IO) ? "to" : "from", (unsigned) d));
hostdata->dma_len = (p & SR_IO) ? <API key>(instance, d, c) : <API key>(instance, d, c);
#endif
NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(p));
#ifdef REAL_DMA
NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_ENABLE_EOP_INTR | MR_MONITOR_BSY);
#elif defined(REAL_DMA_POLL)
NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE);
#else
/*
* Note : on my sample board, watch-dog timeouts occurred when interrupts
* were not disabled for the duration of a single DMA transfer, from
* before the setting of DMA mode to after transfer of the last byte.
*/
#if defined(PSEUDO_DMA) && defined(UNSAFE)
spin_unlock_irq(instance->host_lock);
#endif
/* KLL May need eop and parity in 53c400 */
if (hostdata->flags & FLAG_NCR53C400)
NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_ENABLE_PAR_CHECK | MR_ENABLE_PAR_INTR | MR_ENABLE_EOP_INTR | MR_DMA_MODE | MR_MONITOR_BSY);
else
NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE);
#endif /* def REAL_DMA */
dprintk(NDEBUG_DMA, ("scsi%d : mode reg = 0x%X\n", instance->host_no, NCR5380_read(MODE_REG)));
/*
* On the PAS16 at least I/O recovery delays are not needed here.
* Everyone else seems to want them.
*/
if (p & SR_IO) {
io_recovery_delay(1);
NCR5380_write(<API key>, 0);
} else {
io_recovery_delay(1);
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_DATA);
io_recovery_delay(1);
NCR5380_write(START_DMA_SEND_REG, 0);
io_recovery_delay(1);
}
#if defined(REAL_DMA_POLL)
do {
tmp = NCR5380_read(BUS_AND_STATUS_REG);
} while ((tmp & BASR_PHASE_MATCH) && !(tmp & (BASR_BUSY_ERROR | <API key>)));
/*
At this point, either we've completed DMA, or we have a phase mismatch,
or we've unexpectedly lost BUSY (which is a real error).
For write DMAs, we want to wait until the last byte has been
transferred out over the bus before we turn off DMA mode. Alas, there
seems to be no terribly good way of doing this on a 5380 under all
conditions. For non-scatter-gather operations, we can wait until REQ
and ACK both go false, or until a phase mismatch occurs. Gather-writes
are nastier, since the device will be expecting more data than we
are prepared to send it, and REQ will remain asserted. On a 53C8[01] we
could test LAST BIT SENT to assure transfer (I imagine this is precisely
why this signal was added to the newer chips) but on the older 538[01]
this signal does not exist. The workaround for this lack is a watchdog;
we bail out of the wait-loop after a modest amount of wait-time if
the usual exit conditions are not met. Not a terribly clean or
correct solution :-%
Reads are equally tricky due to a nasty characteristic of the NCR5380.
If the chip is in DMA mode for an READ, it will respond to a target's
REQ by latching the SCSI data into the INPUT DATA register and asserting
ACK, even if it has _already_ been notified by the DMA controller that
the current DMA transfer has completed! If the NCR5380 is then taken
out of DMA mode, this <API key> byte is lost.
This is not a problem for "one DMA transfer per command" reads, because
the situation will never arise... either all of the data is DMA'ed
properly, or the target switches to MESSAGE IN phase to signal a
disconnection (either operation bringing the DMA to a clean halt).
However, in order to handle scatter-reads, we must work around the
problem. The chosen fix is to DMA N-2 bytes, then check for the
condition before taking the NCR5380 out of DMA mode. One or two extra
bytes are transferred via PIO as necessary to fill out the original
request.
*/
if (p & SR_IO) {
#ifdef READ_OVERRUNS
udelay(10);
if (((NCR5380_read(BUS_AND_STATUS_REG) & (BASR_PHASE_MATCH | BASR_ACK)) == (BASR_PHASE_MATCH | BASR_ACK))) {
saved_data = NCR5380_read(INPUT_DATA_REGISTER);
overrun = 1;
}
#endif
} else {
int limit = 100;
while (((tmp = NCR5380_read(BUS_AND_STATUS_REG)) & BASR_ACK) || (NCR5380_read(STATUS_REG) & SR_REQ)) {
if (!(tmp & BASR_PHASE_MATCH))
break;
if (--limit < 0)
break;
}
}
dprintk(NDEBUG_DMA, ("scsi%d : polled DMA transfer complete, basr 0x%X, sr 0x%X\n", instance->host_no, tmp, NCR5380_read(STATUS_REG)));
NCR5380_write(MODE_REG, MR_BASE);
NCR5380_write(<API key>, ICR_BASE);
residue = <API key>(instance);
c -= residue;
*count -= c;
*data += c;
*phase = NCR5380_read(STATUS_REG) & PHASE_MASK;
#ifdef READ_OVERRUNS
if (*phase == p && (p & SR_IO) && residue == 0) {
if (overrun) {
dprintk(NDEBUG_DMA, ("Got an input overrun, using saved byte\n"));
**data = saved_data;
*data += 1;
*count -= 1;
cnt = toPIO = 1;
} else {
printk("No overrun??\n");
cnt = toPIO = 2;
}
dprintk(NDEBUG_DMA, ("Doing %d-byte PIO to 0x%X\n", cnt, *data));
<API key>(instance, phase, &cnt, data);
*count -= toPIO - cnt;
}
#endif
dprintk(NDEBUG_DMA, ("Return with data ptr = 0x%X, count %d, last 0x%X, next 0x%X\n", *data, *count, *(*data + *count - 1), *(*data + *count)));
return 0;
#elif defined(REAL_DMA)
return 0;
#else /* defined(REAL_DMA_POLL) */
if (p & SR_IO) {
#ifdef DMA_WORKS_RIGHT
foo = NCR5380_pread(instance, d, c);
#else
int diff = 1;
if (hostdata->flags & FLAG_NCR53C400) {
diff = 0;
}
if (!(foo = NCR5380_pread(instance, d, c - diff))) {
/*
* We can't disable DMA mode after successfully transferring
* what we plan to be the last byte, since that would open up
* a race condition where if the target asserted REQ before
* we got the DMA mode reset, the NCR5380 would have latched
* an additional byte into the INPUT DATA register and we'd
* have dropped it.
*
* The workaround was to transfer one fewer bytes than we
* intended to with the pseudo-DMA read function, wait for
* the chip to latch the last byte, read it, and then disable
* pseudo-DMA mode.
*
* After REQ is asserted, the NCR5380 asserts DRQ and ACK.
* REQ is deasserted when ACK is asserted, and not reasserted
* until ACK goes false. Since the NCR5380 won't lower ACK
* until DACK is asserted, which won't happen unless we twiddle
* the DMA port or we take the NCR5380 out of DMA mode, we
* can guarantee that we won't handshake another extra
* byte.
*/
if (!(hostdata->flags & FLAG_NCR53C400)) {
while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ));
/* Wait for clean handshake */
while (NCR5380_read(STATUS_REG) & SR_REQ);
d[c - 1] = NCR5380_read(INPUT_DATA_REG);
}
}
#endif
} else {
#ifdef DMA_WORKS_RIGHT
foo = NCR5380_pwrite(instance, d, c);
#else
int timeout;
dprintk(NDEBUG_C400_PWRITE, ("About to pwrite %d bytes\n", c));
if (!(foo = NCR5380_pwrite(instance, d, c))) {
/*
* Wait for the last byte to be sent. If REQ is being asserted for
* the byte we're interested, we'll ACK it and it will go false.
*/
if (!(hostdata->flags & <API key>)) {
timeout = 20000;
while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) && (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH));
if (!timeout)
dprintk(<API key>, ("scsi%d : timed out on last byte\n", instance->host_no));
if (hostdata->flags & <API key>) {
hostdata->flags &= ~<API key>;
if (NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT) {
hostdata->flags |= <API key>;
dprintk(<API key>, ("scsi%d : last bit sent works\n", instance->host_no));
}
}
} else {
dprintk(NDEBUG_C400_PWRITE, ("Waiting for LASTBYTE\n"));
while (!(NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT));
dprintk(NDEBUG_C400_PWRITE, ("Got LASTBYTE\n"));
}
}
#endif
}
NCR5380_write(MODE_REG, MR_BASE);
NCR5380_write(<API key>, ICR_BASE);
if ((!(p & SR_IO)) && (hostdata->flags & FLAG_NCR53C400)) {
dprintk(NDEBUG_C400_PWRITE, ("53C400w: Checking for IRQ\n"));
if (NCR5380_read(BUS_AND_STATUS_REG) & BASR_IRQ) {
dprintk(NDEBUG_C400_PWRITE, ("53C400w: got it, reading reset interrupt reg\n"));
NCR5380_read(<API key>);
} else {
printk("53C400w: IRQ NOT THERE!\n");
}
}
*data = d + c;
*count = 0;
*phase = NCR5380_read(STATUS_REG) & PHASE_MASK;
#if defined(PSEUDO_DMA) && defined(UNSAFE)
spin_lock_irq(instance->host_lock);
#endif /* defined(REAL_DMA_POLL) */
return foo;
#endif /* def REAL_DMA */
}
#endif /* defined(REAL_DMA) | defined(PSEUDO_DMA) */
/*
* Function : <API key> (struct Scsi_Host *instance)
*
* Purpose : run through the various SCSI phases and do as the target
* directs us to. Operates on the currently connected command,
* instance->connected.
*
* Inputs : instance, instance for which we are doing commands
*
* Side effects : SCSI things happen, the disconnected queue will be
* modified if a command disconnects, *instance->connected will
* change.
*
* XXX Note : we need to watch for bus free or a reset condition here
* to recover from an unexpected bus free condition.
*
* Locks: io_request_lock held by caller in IRQ mode
*/
static void <API key>(struct Scsi_Host *instance) {
<API key>();
struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)instance->hostdata;
unsigned char msgout = NOP;
int sink = 0;
int len;
#if defined(PSEUDO_DMA) || defined(REAL_DMA_POLL)
int transfersize;
#endif
unsigned char *data;
unsigned char phase, tmp, extended_msg[10], old_phase = 0xff;
Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected;
/* RvC: we need to set the end of the polling time */
unsigned long poll_time = jiffies + USLEEP_POLL;
NCR5380_setup(instance);
while (1) {
tmp = NCR5380_read(STATUS_REG);
/* We only have a valid SCSI phase when REQ is asserted */
if (tmp & SR_REQ) {
phase = (tmp & PHASE_MASK);
if (phase != old_phase) {
old_phase = phase;
<API key>(NDEBUG_INFORMATION, instance);
}
if (sink && (phase != PHASE_MSGOUT)) {
NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_ATN | ICR_ASSERT_ACK);
while (NCR5380_read(STATUS_REG) & SR_REQ);
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_ATN);
sink = 0;
continue;
}
switch (phase) {
case PHASE_DATAIN:
case PHASE_DATAOUT:
#if (NDEBUG & NDEBUG_NO_DATAOUT)
printk("scsi%d : NDEBUG_NO_DATAOUT set, attempted DATAOUT aborted\n", instance->host_no);
sink = 1;
do_abort(instance);
cmd->result = DID_ERROR << 16;
cmd->done(cmd);
return;
#endif
/*
* If there is no room left in the current buffer in the
* scatter-gather list, move onto the next one.
*/
if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) {
++cmd->SCp.buffer;
--cmd->SCp.buffers_residual;
cmd->SCp.this_residual = cmd->SCp.buffer->length;
cmd->SCp.ptr = page_address(cmd->SCp.buffer->page)+
cmd->SCp.buffer->offset;
dprintk(NDEBUG_INFORMATION, ("scsi%d : %d bytes and %d buffers left\n", instance->host_no, cmd->SCp.this_residual, cmd->SCp.buffers_residual));
}
/*
* The preferred transfer method is going to be
* PSEUDO-DMA for systems that are strictly PIO,
* since we can let the hardware do the handshaking.
*
* For this to work, we need to know the transfersize
* ahead of time, since the pseudo-DMA code will sit
* in an unconditional loop.
*/
#if defined(PSEUDO_DMA) || defined(REAL_DMA_POLL)
/* KLL
* PSEUDO_DMA is defined here. If this is the g_NCR5380
* driver then it will always be defined, so the
* FLAG_NO_PSEUDO_DMA is used to inhibit PDMA in the base
* NCR5380 case. I think this is a fairly clean solution.
* We supplement these 2 if's with the flag.
*/
#ifdef <API key>
if (!cmd->device->borken && !(hostdata->flags & FLAG_NO_PSEUDO_DMA) && (transfersize = <API key>(instance, cmd)) != 0) {
#else
transfersize = cmd->transfersize;
#ifdef LIMIT_TRANSFERSIZE /* If we have problems with interrupt service */
if (transfersize > 512)
transfersize = 512;
#endif /* LIMIT_TRANSFERSIZE */
if (!cmd->device->borken && transfersize && !(hostdata->flags & FLAG_NO_PSEUDO_DMA) && cmd->SCp.this_residual && !(cmd->SCp.this_residual % transfersize)) {
/* Limit transfers to 32K, for xx400 & xx406
* pseudoDMA that transfers in 128 bytes blocks. */
if (transfersize > 32 * 1024)
transfersize = 32 * 1024;
#endif
len = transfersize;
if (<API key>(instance, &phase, &len, (unsigned char **) &cmd->SCp.ptr)) {
/*
* If the watchdog timer fires, all future accesses to this
* device will use the polled-IO.
*/
scmd_printk(KERN_INFO, cmd,
"switching to slow handshake\n");
cmd->device->borken = 1;
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_ATN);
sink = 1;
do_abort(instance);
cmd->result = DID_ERROR << 16;
cmd->done(cmd);
/* XXX - need to source or sink data here, as appropriate */
} else
cmd->SCp.this_residual -= transfersize - len;
} else
#endif /* defined(PSEUDO_DMA) || defined(REAL_DMA_POLL) */
<API key>(instance, &phase, (int *) &cmd->SCp.this_residual, (unsigned char **)
&cmd->SCp.ptr);
break;
case PHASE_MSGIN:
len = 1;
data = &tmp;
<API key>(instance, &phase, &len, &data);
cmd->SCp.Message = tmp;
switch (tmp) {
/*
* Linking lets us reduce the time required to get the
* next command out to the device, hopefully this will
* mean we don't waste another revolution due to the delays
* required by ARBITRATION and another SELECTION.
*
* In the current implementation proposal, low level drivers
* merely have to start the next command, pointed to by
* next_link, done() is called as with unlinked commands.
*/
#ifdef LINKED
case LINKED_CMD_COMPLETE:
case <API key>:
/* Accept message by clearing ACK */
NCR5380_write(<API key>, ICR_BASE);
dprintk(NDEBUG_LINKED, ("scsi%d : target %d lun %d linked command complete.\n", instance->host_no, cmd->device->id, cmd->device->lun));
/*
* Sanity check : A linked command should only terminate with
* one of these messages if there are more linked commands
* available.
*/
if (!cmd->next_link) {
printk("scsi%d : target %d lun %d linked command complete, no next_link\n" instance->host_no, cmd->device->id, cmd->device->lun);
sink = 1;
do_abort(instance);
return;
}
initialize_SCp(cmd->next_link);
/* The next command is still part of this process */
cmd->next_link->tag = cmd->tag;
cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
dprintk(NDEBUG_LINKED, ("scsi%d : target %d lun %d linked request done, calling scsi_done().\n", instance->host_no, cmd->device->id, cmd->device->lun));
collect_stats(hostdata, cmd);
cmd->scsi_done(cmd);
cmd = hostdata->connected;
break;
#endif /* def LINKED */
case ABORT:
case COMMAND_COMPLETE:
/* Accept message by clearing ACK */
sink = 1;
NCR5380_write(<API key>, ICR_BASE);
hostdata->connected = NULL;
dprintk(NDEBUG_QUEUES, ("scsi%d : command for target %d, lun %d completed\n", instance->host_no, cmd->device->id, cmd->device->lun));
hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
/*
* I'm not sure what the correct thing to do here is :
*
* If the command that just executed is NOT a request
* sense, the obvious thing to do is to set the result
* code to the values of the stored parameters.
*
* If it was a REQUEST SENSE command, we need some way
* to differentiate between the failure code of the original
* and the failure code of the REQUEST sense - the obvious
* case is success, where we fall through and leave the result
* code unchanged.
*
* The non-obvious place is where the REQUEST SENSE failed
*/
if (cmd->cmnd[0] != REQUEST_SENSE)
cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
else if (status_byte(cmd->SCp.Status) != GOOD)
cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
#ifdef AUTOSENSE
if ((cmd->cmnd[0] != REQUEST_SENSE) && (status_byte(cmd->SCp.Status) == CHECK_CONDITION)) {
dprintk(NDEBUG_AUTOSENSE, ("scsi%d : performing request sense\n", instance->host_no));
cmd->cmnd[0] = REQUEST_SENSE;
cmd->cmnd[1] &= 0xe0;
cmd->cmnd[2] = 0;
cmd->cmnd[3] = 0;
cmd->cmnd[4] = sizeof(cmd->sense_buffer);
cmd->cmnd[5] = 0;
cmd->SCp.buffer = NULL;
cmd->SCp.buffers_residual = 0;
cmd->SCp.ptr = (char *) cmd->sense_buffer;
cmd->SCp.this_residual = sizeof(cmd->sense_buffer);
LIST(cmd, hostdata->issue_queue);
cmd->host_scribble = (unsigned char *)
hostdata->issue_queue;
hostdata->issue_queue = (Scsi_Cmnd *) cmd;
dprintk(NDEBUG_QUEUES, ("scsi%d : REQUEST SENSE added to head of issue queue\n", instance->host_no));
} else
#endif /* def AUTOSENSE */
{
collect_stats(hostdata, cmd);
cmd->scsi_done(cmd);
}
NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
/*
* Restore phase bits to 0 so an interrupted selection,
* arbitration can resume.
*/
NCR5380_write(TARGET_COMMAND_REG, 0);
while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected)
barrier();
return;
case MESSAGE_REJECT:
/* Accept message by clearing ACK */
NCR5380_write(<API key>, ICR_BASE);
switch (hostdata->last_message) {
case HEAD_OF_QUEUE_TAG:
case ORDERED_QUEUE_TAG:
case SIMPLE_QUEUE_TAG:
cmd->device->simple_tags = 0;
hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
break;
default:
break;
}
case DISCONNECT:{
/* Accept message by clearing ACK */
NCR5380_write(<API key>, ICR_BASE);
cmd->device->disconnect = 1;
LIST(cmd, hostdata->disconnected_queue);
cmd->host_scribble = (unsigned char *)
hostdata->disconnected_queue;
hostdata->connected = NULL;
hostdata->disconnected_queue = cmd;
dprintk(NDEBUG_QUEUES, ("scsi%d : command for target %d lun %d was moved from connected to" " the disconnected_queue\n", instance->host_no, cmd->device->id, cmd->device->lun));
/*
* Restore phase bits to 0 so an interrupted selection,
* arbitration can resume.
*/
NCR5380_write(TARGET_COMMAND_REG, 0);
/* Enable reselect interrupts */
NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
/* Wait for bus free to avoid nasty timeouts - FIXME timeout !*/
/* <API key>(instance, STATUS_REG, SR_BSY, 0, 30 * HZ); */
while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected)
barrier();
return;
}
/*
* The SCSI data pointer is *IMPLICITLY* saved on a disconnect
* operation, in violation of the SCSI spec so we can safely
* ignore SAVE/RESTORE pointers calls.
*
* Unfortunately, some disks violate the SCSI spec and
* don't issue the required SAVE_POINTERS message before
* disconnecting, and we have to break spec to remain
* compatible.
*/
case SAVE_POINTERS:
case RESTORE_POINTERS:
/* Accept message by clearing ACK */
NCR5380_write(<API key>, ICR_BASE);
break;
case EXTENDED_MESSAGE:
/*
* Extended messages are sent in the following format :
* Byte
* 0 EXTENDED_MESSAGE == 1
* 1 length (includes one byte for code, doesn't
* include first two bytes)
* 2 code
* 3..length+1 arguments
*
* Start the extended message buffer with the EXTENDED_MESSAGE
* byte, since spi_print_msg() wants the whole thing.
*/
extended_msg[0] = EXTENDED_MESSAGE;
/* Accept first byte by clearing ACK */
NCR5380_write(<API key>, ICR_BASE);
dprintk(NDEBUG_EXTENDED, ("scsi%d : receiving extended message\n", instance->host_no));
len = 2;
data = extended_msg + 1;
phase = PHASE_MSGIN;
<API key>(instance, &phase, &len, &data);
dprintk(NDEBUG_EXTENDED, ("scsi%d : length=%d, code=0x%02x\n", instance->host_no, (int) extended_msg[1], (int) extended_msg[2]));
if (!len && extended_msg[1] <= (sizeof(extended_msg) - 1)) {
/* Accept third byte by clearing ACK */
NCR5380_write(<API key>, ICR_BASE);
len = extended_msg[1] - 1;
data = extended_msg + 3;
phase = PHASE_MSGIN;
<API key>(instance, &phase, &len, &data);
dprintk(NDEBUG_EXTENDED, ("scsi%d : message received, residual %d\n", instance->host_no, len));
switch (extended_msg[2]) {
case EXTENDED_SDTR:
case EXTENDED_WDTR:
case <API key>:
case <API key>:
tmp = 0;
}
} else if (len) {
printk("scsi%d: error receiving extended message\n", instance->host_no);
tmp = 0;
} else {
printk("scsi%d: extended message code %02x length %d is too long\n", instance->host_no, extended_msg[2], extended_msg[1]);
tmp = 0;
}
/* Fall through to reject message */
/*
* If we get something weird that we aren't expecting,
* reject it.
*/
default:
if (!tmp) {
printk("scsi%d: rejecting message ", instance->host_no);
spi_print_msg(extended_msg);
printk("\n");
} else if (tmp != EXTENDED_MESSAGE)
scmd_printk(KERN_INFO, cmd,
"rejecting unknown message %02x\n",tmp);
else
scmd_printk(KERN_INFO, cmd,
"rejecting unknown extended message code %02x, length %d\n", extended_msg[1], extended_msg[0]);
msgout = MESSAGE_REJECT;
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_ATN);
break;
} /* switch (tmp) */
break;
case PHASE_MSGOUT:
len = 1;
data = &msgout;
hostdata->last_message = msgout;
<API key>(instance, &phase, &len, &data);
if (msgout == ABORT) {
hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
hostdata->connected = NULL;
cmd->result = DID_ERROR << 16;
collect_stats(hostdata, cmd);
cmd->scsi_done(cmd);
NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
return;
}
msgout = NOP;
break;
case PHASE_CMDOUT:
len = cmd->cmd_len;
data = cmd->cmnd;
/*
* XXX for performance reasons, on machines with a
* PSEUDO-DMA architecture we should probably
* use the dma transfer function.
*/
<API key>(instance, &phase, &len, &data);
if (!cmd->device->disconnect && should_disconnect(cmd->cmnd[0])) {
NCR5380_set_timer(hostdata, USLEEP_SLEEP);
dprintk(NDEBUG_USLEEP, ("scsi%d : issued command, sleeping until %ul\n", instance->host_no, hostdata->time_expires));
return;
}
break;
case PHASE_STATIN:
len = 1;
data = &tmp;
<API key>(instance, &phase, &len, &data);
cmd->SCp.Status = tmp;
break;
default:
printk("scsi%d : unknown phase\n", instance->host_no);
NCR5380_dprint(NDEBUG_ALL, instance);
} /* switch(phase) */
} /* if (tmp * SR_REQ) */
else {
/* RvC: go to sleep if polling time expired
*/
if (!cmd->device->disconnect && time_after_eq(jiffies, poll_time)) {
NCR5380_set_timer(hostdata, USLEEP_SLEEP);
dprintk(NDEBUG_USLEEP, ("scsi%d : poll timed out, sleeping until %ul\n", instance->host_no, hostdata->time_expires));
return;
}
}
} /* while (1) */
}
/*
* Function : void NCR5380_reselect (struct Scsi_Host *instance)
*
* Purpose : does reselection, initializing the instance->connected
* field to point to the Scsi_Cmnd for which the I_T_L or I_T_L_Q
* nexus has been reestablished,
*
* Inputs : instance - this instance of the NCR5380.
*
* Locks: io_request_lock held by caller if IRQ driven
*/
static void NCR5380_reselect(struct Scsi_Host *instance) {
<API key>();
struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)
instance->hostdata;
unsigned char target_mask;
unsigned char lun, phase;
int len;
unsigned char msg[3];
unsigned char *data;
Scsi_Cmnd *tmp = NULL, *prev;
int abort = 0;
NCR5380_setup(instance);
/*
* Disable arbitration, etc. since the host adapter obviously
* lost, and tell an interrupted NCR5380_select() to restart.
*/
NCR5380_write(MODE_REG, MR_BASE);
hostdata->restart_select = 1;
target_mask = NCR5380_read(<API key>) & ~(hostdata->id_mask);
dprintk(NDEBUG_SELECTION, ("scsi%d : reselect\n", instance->host_no));
/*
* At this point, we have detected that our SCSI ID is on the bus,
* SEL is true and BSY was false for at least one bus settle delay
* (400 ns).
*
* We must assert BSY ourselves, until the target drops the SEL
* signal.
*/
NCR5380_write(<API key>, ICR_BASE | ICR_ASSERT_BSY);
/* FIXME: timeout too long, must fail to workqueue */
if(<API key>(instance, STATUS_REG, SR_SEL, 0, 2*HZ)<0)
abort = 1;
NCR5380_write(<API key>, ICR_BASE);
/*
* Wait for target to go into MSGIN.
* FIXME: timeout needed and fail to work queeu
*/
if(<API key>(instance, STATUS_REG, SR_REQ, SR_REQ, 2*HZ))
abort = 1;
len = 1;
data = msg;
phase = PHASE_MSGIN;
<API key>(instance, &phase, &len, &data);
if (!(msg[0] & 0x80)) {
printk(KERN_ERR "scsi%d : expecting IDENTIFY message, got ", instance->host_no);
spi_print_msg(msg);
abort = 1;
} else {
/* Accept message by clearing ACK */
NCR5380_write(<API key>, ICR_BASE);
lun = (msg[0] & 0x07);
/*
* We need to add code for SCSI-II to track which devices have
* I_T_L_Q nexuses established, and which have simple I_T_L
* nexuses so we can chose to do additional data transfer.
*/
/*
* Find the command corresponding to the I_T_L or I_T_L_Q nexus we
* just reestablished, and remove it from the disconnected queue.
*/
for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL; tmp; prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble)
if ((target_mask == (1 << tmp->device->id)) && (lun == tmp->device->lun)
) {
if (prev) {
REMOVE(prev, prev->host_scribble, tmp, tmp->host_scribble);
prev->host_scribble = tmp->host_scribble;
} else {
REMOVE(-1, hostdata->disconnected_queue, tmp, tmp->host_scribble);
hostdata->disconnected_queue = (Scsi_Cmnd *) tmp->host_scribble;
}
tmp->host_scribble = NULL;
break;
}
if (!tmp) {
printk(KERN_ERR "scsi%d : warning : target bitmask %02x lun %d not in disconnect_queue.\n", instance->host_no, target_mask, lun);
/*
* Since we have an established nexus that we can't do anything with,
* we must abort it.
*/
abort = 1;
}
}
if (abort) {
do_abort(instance);
} else {
hostdata->connected = tmp;
dprintk(NDEBUG_RESELECTION, ("scsi%d : nexus established, target = %d, lun = %d, tag = %d\n", instance->host_no, tmp->target, tmp->lun, tmp->tag));
}
}
/*
* Function : void <API key> (struct Scsi_Host *instance)
*
* Purpose : called by interrupt handler when DMA finishes or a phase
* mismatch occurs (which would finish the DMA transfer).
*
* Inputs : instance - this instance of the NCR5380.
*
* Returns : pointer to the Scsi_Cmnd structure for which the I_T_L
* nexus has been reestablished, on failure NULL is returned.
*/
#ifdef REAL_DMA
static void <API key>(NCR5380_instance * instance) {
<API key>();
struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata * instance->hostdata);
int transferred;
NCR5380_setup(instance);
/*
* XXX this might not be right.
*
* Wait for final byte to transfer, ie wait for ACK to go false.
*
* We should use the Last Byte Sent bit, unfortunately this is
* not available on the 5380/5381 (only the various CMOS chips)
*
* FIXME: timeout, and need to handle long timeout/irq case
*/
<API key>(instance, BUS_AND_STATUS_REG, BASR_ACK, 0, 5*HZ);
NCR5380_write(MODE_REG, MR_BASE);
NCR5380_write(<API key>, ICR_BASE);
/*
* The only places we should see a phase mismatch and have to send
* data from the same set of pointers will be the data transfer
* phases. So, residual, requested length are only important here.
*/
if (!(hostdata->connected->SCp.phase & SR_CD)) {
transferred = instance->dmalen - <API key>();
hostdata->connected->SCp.this_residual -= transferred;
hostdata->connected->SCp.ptr += transferred;
}
}
#endif /* def REAL_DMA */
/*
* Function : int NCR5380_abort (Scsi_Cmnd *cmd)
*
* Purpose : abort a command
*
* Inputs : cmd - the Scsi_Cmnd to abort, code - code to set the
* host byte of the result field to, if zero DID_ABORTED is
* used.
*
* Returns : 0 - success, -1 on failure.
*
* XXX - there is no way to abort the command that is currently
* connected, you have to wait for it to complete. If this is
* a problem, we could implement longjmp() / setjmp(), setjmp()
* called where the loop started in NCR5380_main().
*
* Locks: host lock taken by caller
*/
static int NCR5380_abort(Scsi_Cmnd * cmd) {
<API key>();
struct Scsi_Host *instance = cmd->device->host;
struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
Scsi_Cmnd *tmp, **prev;
printk(KERN_WARNING "scsi%d : aborting command\n", instance->host_no);
scsi_print_command(cmd);
<API key>(instance);
NCR5380_setup(instance);
dprintk(NDEBUG_ABORT, ("scsi%d : abort called\n", instance->host_no));
dprintk(NDEBUG_ABORT, (" basr 0x%X, sr 0x%X\n", NCR5380_read(BUS_AND_STATUS_REG), NCR5380_read(STATUS_REG)));
#if 0
/*
* Case 1 : If the command is the currently executing command,
* we'll set the aborted flag and return control so that
* information transfer routine can exit cleanly.
*/
if (hostdata->connected == cmd) {
dprintk(NDEBUG_ABORT, ("scsi%d : aborting connected command\n", instance->host_no));
hostdata->aborted = 1;
/*
* We should perform BSY checking, and make sure we haven't slipped
* into BUS FREE.
*/
NCR5380_write(<API key>, ICR_ASSERT_ATN);
/*
* Since we can't change phases until we've completed the current
* handshake, we have to source or sink a byte of data if the current
* phase is not MSGOUT.
*/
/*
* Return control to the executing NCR drive so we can clear the
* aborted flag and get back into our main loop.
*/
return 0;
}
#endif
/*
* Case 2 : If the command hasn't been issued yet, we simply remove it
* from the issue queue.
*/
dprintk(NDEBUG_ABORT, ("scsi%d : abort going into loop.\n", instance->host_no));
for (prev = (Scsi_Cmnd **) & (hostdata->issue_queue), tmp = (Scsi_Cmnd *) hostdata->issue_queue; tmp; prev = (Scsi_Cmnd **) & (tmp->host_scribble), tmp = (Scsi_Cmnd *) tmp->host_scribble)
if (cmd == tmp) {
REMOVE(5, *prev, tmp, tmp->host_scribble);
(*prev) = (Scsi_Cmnd *) tmp->host_scribble;
tmp->host_scribble = NULL;
tmp->result = DID_ABORT << 16;
dprintk(NDEBUG_ABORT, ("scsi%d : abort removed command from issue queue.\n", instance->host_no));
tmp->done(tmp);
return SUCCESS;
}
#if (NDEBUG & NDEBUG_ABORT)
/* KLL */
else if (prev == tmp)
printk(KERN_ERR "scsi%d : LOOP\n", instance->host_no);
#endif
/*
* Case 3 : If any commands are connected, we're going to fail the abort
* and let the high level SCSI driver retry at a later time or
* issue a reset.
*
* Timeouts, and therefore aborted commands, will be highly unlikely
* and handling them cleanly in this situation would make the common
* case of noresets less efficient, and would pollute our code. So,
* we fail.
*/
if (hostdata->connected) {
dprintk(NDEBUG_ABORT, ("scsi%d : abort failed, command connected.\n", instance->host_no));
return FAILED;
}
/*
* Case 4: If the command is currently disconnected from the bus, and
* there are no connected commands, we reconnect the I_T_L or
* I_T_L_Q nexus associated with it, go into message out, and send
* an abort message.
*
* This case is especially ugly. In order to reestablish the nexus, we
* need to call NCR5380_select(). The easiest way to implement this
* function was to abort if the bus was busy, and let the interrupt
* handler triggered on the SEL for reselect take care of lost arbitrations
* where necessary, meaning interrupts need to be enabled.
*
* When interrupts are enabled, the queues may change - so we
* can't remove it from the disconnected queue before selecting it
* because that could cause a failure in hashing the nexus if that
* device reselected.
*
* Since the queues may change, we can't use the pointers from when we
* first locate it.
*
* So, we must first locate the command, and if NCR5380_select()
* succeeds, then issue the abort, relocate the command and remove
* it from the disconnected queue.
*/
for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp; tmp = (Scsi_Cmnd *) tmp->host_scribble)
if (cmd == tmp) {
dprintk(NDEBUG_ABORT, ("scsi%d : aborting disconnected command.\n", instance->host_no));
if (NCR5380_select(instance, cmd, (int) cmd->tag))
return FAILED;
dprintk(NDEBUG_ABORT, ("scsi%d : nexus reestablished.\n", instance->host_no));
do_abort(instance);
for (prev = (Scsi_Cmnd **) & (hostdata->disconnected_queue), tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp; prev = (Scsi_Cmnd **) & (tmp->host_scribble), tmp = (Scsi_Cmnd *) tmp->host_scribble)
if (cmd == tmp) {
REMOVE(5, *prev, tmp, tmp->host_scribble);
*prev = (Scsi_Cmnd *) tmp->host_scribble;
tmp->host_scribble = NULL;
tmp->result = DID_ABORT << 16;
tmp->done(tmp);
return SUCCESS;
}
}
/*
* Case 5 : If we reached this point, the command was not found in any of
* the queues.
*
* We probably reached this point because of an unlikely race condition
* between the command completing successfully and the abortion code,
* so we won't panic, but we will notify the user in case something really
* broke.
*/
printk(KERN_WARNING "scsi%d : warning : SCSI command probably completed successfully\n"
" before abortion\n", instance->host_no);
return FAILED;
}
/*
* Function : int NCR5380_bus_reset (Scsi_Cmnd *cmd)
*
* Purpose : reset the SCSI bus.
*
* Returns : SUCCESS
*
* Locks: host lock taken by caller
*/
static int NCR5380_bus_reset(Scsi_Cmnd * cmd)
{
struct Scsi_Host *instance = cmd->device->host;
<API key>();
NCR5380_setup(instance);
<API key>(instance);
spin_lock_irq(instance->host_lock);
do_reset(instance);
spin_unlock_irq(instance->host_lock);
return SUCCESS;
} |
<?php
if($_SESSION['my_login'] == 'alexx' || $_SESSION['my_login'] == 'mathieu')
{
$image_path = build_image_path($url_id, false);
$thumb_path = build_thumb_path($url_id, false);;
$db->query('UPDATE user SET photo=? WHERE id=?', array('n', $url_id));
$db->query('UPDATE cache_user SET photo=? WHERE id=?', array('n', $url_id));
unlink($image_path);
unlink($thumb_path);
auto_mail(MODERATOR_ID, $url_id, 'Photo deleted', "Your profile's photo has been deleted/ La photo de votre profil a été supprimé\n\nReason/Raison: <API key>\n\n".stripslashes($_POST['reason'])."\n\n===========================================\n\n.node Team / L'équipe .node");
header('Location: /profile/'.$url_id);
}
else
header('Location: /');
?> |
#pragma once
#include "ofMain.h"
#include "Scene.h"
#include "ofxSyphon.h"
/*
requires Syphon Framework added to build phases of app
*/
class Syphon : public Scene
{
public:
Syphon() : Scene() {setName("Syphon");}
void setup(int width, int height, bool clearControls=true);
void update();
void draw(int x, int y);
void setClient(string serverName, string appName);
private:
ofxSyphonClient client;
}; |
cmd_fs/libfs.o := <API key> -Wp,-MD,fs/.libfs.o.d -nostdinc -isystem /usr/lib/gcc/arm-linux-gnueabihf/4.6/include -I/home/tyler/dev/rk3188/tylermk908/arch/arm/include -Iarch/arm/include/generated -Iinclude -include include/generated/autoconf.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-rk3188/include -Iarch/arm/plat-rk/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -<API key> -Wno-format-security -<API key> -O2 -marm -fno-dwarf2-cfi-asm -mabi=aapcs-linux -mno-thumb-interwork -funwind-tables -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -Wframe-larger-than=1024 -fno-stack-protector -<API key> -fomit-frame-pointer -<API key> -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -DCC_HAVE_ASM_GOTO -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(libfs)" -D"KBUILD_MODNAME=KBUILD_STR(libfs)" -c -o fs/libfs.o fs/libfs.c
source_fs/libfs.o := fs/libfs.c
deps_fs/libfs.o := \
include/linux/module.h \
$(wildcard include/config/sysfs.h) \
$(wildcard include/config/modules.h) \
$(wildcard include/config/unused/symbols.h) \
$(wildcard include/config/generic/bug.h) \
$(wildcard include/config/kallsyms.h) \
$(wildcard include/config/smp.h) \
$(wildcard include/config/tracepoints.h) \
$(wildcard include/config/tracing.h) \
$(wildcard include/config/event/tracing.h) \
$(wildcard include/config/ftrace/mcount/record.h) \
$(wildcard include/config/module/unload.h) \
$(wildcard include/config/constructors.h) \
$(wildcard include/config/debug/set/module/ronx.h) \
include/linux/list.h \
$(wildcard include/config/debug/list.h) \
include/linux/types.h \
$(wildcard include/config/uid16.h) \
$(wildcard include/config/lbdaf.h) \
$(wildcard include/config/arch/dma/addr/t/64bit.h) \
$(wildcard include/config/phys/addr/t/64bit.h) \
$(wildcard include/config/64bit.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/types.h \
include/asm-generic/int-ll64.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/bitsperlong.h \
include/asm-generic/bitsperlong.h \
include/linux/posix_types.h \
include/linux/stddef.h \
include/linux/compiler.h \
$(wildcard include/config/sparse/rcu/pointer.h) \
$(wildcard include/config/trace/branch/profiling.h) \
$(wildcard include/config/profile/all/branches.h) \
$(wildcard include/config/enable/must/check.h) \
$(wildcard include/config/enable/warn/deprecated.h) \
include/linux/compiler-gcc.h \
$(wildcard include/config/arch/supports/optimized/inlining.h) \
$(wildcard include/config/optimize/inlining.h) \
include/linux/compiler-gcc4.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/posix_types.h \
include/linux/poison.h \
$(wildcard include/config/illegal/pointer/value.h) \
include/linux/const.h \
include/linux/stat.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/stat.h \
include/linux/time.h \
$(wildcard include/config/arch/uses/gettimeoffset.h) \
include/linux/cache.h \
$(wildcard include/config/arch/has/cache/line/size.h) \
include/linux/kernel.h \
$(wildcard include/config/preempt/voluntary.h) \
$(wildcard include/config/debug/spinlock/sleep.h) \
$(wildcard include/config/prove/locking.h) \
$(wildcard include/config/ring/buffer.h) \
$(wildcard include/config/numa.h) \
$(wildcard include/config/compaction.h) \
/usr/lib/gcc/arm-linux-gnueabihf/4.6/include/stdarg.h \
include/linux/linkage.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/linkage.h \
include/linux/bitops.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/bitops.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/system.h \
$(wildcard include/config/function/graph/tracer.h) \
$(wildcard include/config/cpu/32v6k.h) \
$(wildcard include/config/cpu/xsc3.h) \
$(wildcard include/config/cpu/fa526.h) \
$(wildcard include/config/arch/has/barriers.h) \
$(wildcard include/config/arm/dma/mem/bufferable.h) \
$(wildcard include/config/cpu/sa1100.h) \
$(wildcard include/config/cpu/sa110.h) \
$(wildcard include/config/cpu/v6.h) \
include/linux/irqflags.h \
$(wildcard include/config/trace/irqflags.h) \
$(wildcard include/config/irqsoff/tracer.h) \
$(wildcard include/config/preempt/tracer.h) \
$(wildcard include/config/trace/irqflags/support.h) \
include/linux/typecheck.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/irqflags.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/ptrace.h \
$(wildcard include/config/cpu/endian/be8.h) \
$(wildcard include/config/arm/thumb.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/hwcap.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/outercache.h \
$(wildcard include/config/outer/cache/sync.h) \
$(wildcard include/config/outer/cache.h) \
include/asm-generic/cmpxchg-local.h \
include/asm-generic/bitops/non-atomic.h \
include/asm-generic/bitops/fls64.h \
include/asm-generic/bitops/sched.h \
include/asm-generic/bitops/hweight.h \
include/asm-generic/bitops/arch_hweight.h \
include/asm-generic/bitops/const_hweight.h \
include/asm-generic/bitops/lock.h \
include/asm-generic/bitops/le.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/byteorder.h \
include/linux/byteorder/little_endian.h \
include/linux/swab.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/swab.h \
include/linux/byteorder/generic.h \
include/linux/log2.h \
$(wildcard include/config/arch/has/ilog2/u32.h) \
$(wildcard include/config/arch/has/ilog2/u64.h) \
include/linux/printk.h \
$(wildcard include/config/printk.h) \
$(wildcard include/config/dynamic/debug.h) \
include/linux/init.h \
$(wildcard include/config/hotplug.h) \
include/linux/dynamic_debug.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/bug.h \
$(wildcard include/config/bug.h) \
$(wildcard include/config/debug/bugverbose.h) \
include/asm-generic/bug.h \
$(wildcard include/config/generic/bug/relative/pointers.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/div64.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/cache.h \
$(wildcard include/config/arm/l1/cache/shift.h) \
$(wildcard include/config/aeabi.h) \
include/linux/seqlock.h \
include/linux/spinlock.h \
$(wildcard include/config/debug/spinlock.h) \
$(wildcard include/config/generic/lockbreak.h) \
$(wildcard include/config/preempt.h) \
$(wildcard include/config/debug/lock/alloc.h) \
include/linux/preempt.h \
$(wildcard include/config/debug/preempt.h) \
$(wildcard include/config/preempt/notifiers.h) \
include/linux/thread_info.h \
$(wildcard include/config/compat.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/thread_info.h \
$(wildcard include/config/arm/thumbee.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/fpstate.h \
$(wildcard include/config/vfpv3.h) \
$(wildcard include/config/iwmmxt.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/domain.h \
$(wildcard include/config/io/36.h) \
$(wildcard include/config/cpu/use/domains.h) \
include/linux/stringify.h \
include/linux/bottom_half.h \
include/linux/spinlock_types.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/spinlock_types.h \
include/linux/lockdep.h \
$(wildcard include/config/lockdep.h) \
$(wildcard include/config/lock/stat.h) \
$(wildcard include/config/prove/rcu.h) \
include/linux/rwlock_types.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/spinlock.h \
$(wildcard include/config/thumb2/kernel.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/processor.h \
$(wildcard include/config/have/hw/breakpoint.h) \
$(wildcard include/config/mmu.h) \
$(wildcard include/config/arm/errata/754327.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/hw_breakpoint.h \
include/linux/rwlock.h \
include/linux/spinlock_api_smp.h \
$(wildcard include/config/inline/spin/lock.h) \
$(wildcard include/config/inline/spin/lock/bh.h) \
$(wildcard include/config/inline/spin/lock/irq.h) \
$(wildcard include/config/inline/spin/lock/irqsave.h) \
$(wildcard include/config/inline/spin/trylock.h) \
$(wildcard include/config/inline/spin/trylock/bh.h) \
$(wildcard include/config/inline/spin/unlock.h) \
$(wildcard include/config/inline/spin/unlock/bh.h) \
$(wildcard include/config/inline/spin/unlock/irq.h) \
$(wildcard include/config/inline/spin/unlock/irqrestore.h) \
include/linux/rwlock_api_smp.h \
$(wildcard include/config/inline/read/lock.h) \
$(wildcard include/config/inline/write/lock.h) \
$(wildcard include/config/inline/read/lock/bh.h) \
$(wildcard include/config/inline/write/lock/bh.h) \
$(wildcard include/config/inline/read/lock/irq.h) \
$(wildcard include/config/inline/write/lock/irq.h) \
$(wildcard include/config/inline/read/lock/irqsave.h) \
$(wildcard include/config/inline/write/lock/irqsave.h) \
$(wildcard include/config/inline/read/trylock.h) \
$(wildcard include/config/inline/write/trylock.h) \
$(wildcard include/config/inline/read/unlock.h) \
$(wildcard include/config/inline/write/unlock.h) \
$(wildcard include/config/inline/read/unlock/bh.h) \
$(wildcard include/config/inline/write/unlock/bh.h) \
$(wildcard include/config/inline/read/unlock/irq.h) \
$(wildcard include/config/inline/write/unlock/irq.h) \
$(wildcard include/config/inline/read/unlock/irqrestore.h) \
$(wildcard include/config/inline/write/unlock/irqrestore.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/atomic.h \
$(wildcard include/config/generic/atomic64.h) \
include/asm-generic/atomic-long.h \
include/linux/math64.h \
include/linux/kmod.h \
include/linux/gfp.h \
$(wildcard include/config/kmemcheck.h) \
$(wildcard include/config/highmem.h) \
$(wildcard include/config/zone/dma.h) \
$(wildcard include/config/zone/dma32.h) \
include/linux/mmzone.h \
$(wildcard include/config/force/max/zoneorder.h) \
$(wildcard include/config/memory/hotplug.h) \
$(wildcard include/config/sparsemem.h) \
$(wildcard include/config/arch/populates/node/map.h) \
$(wildcard include/config/discontigmem.h) \
$(wildcard include/config/flat/node/mem/map.h) \
$(wildcard include/config/cgroup/mem/res/ctlr.h) \
$(wildcard include/config/no/bootmem.h) \
$(wildcard include/config/have/memory/present.h) \
$(wildcard include/config/have/memoryless/nodes.h) \
$(wildcard include/config/need/node/memmap/size.h) \
$(wildcard include/config/need/multiple/nodes.h) \
$(wildcard include/config/have/arch/early/pfn/to/nid.h) \
$(wildcard include/config/flatmem.h) \
$(wildcard include/config/sparsemem/extreme.h) \
$(wildcard include/config/have/arch/pfn/valid.h) \
$(wildcard include/config/nodes/span/other/nodes.h) \
$(wildcard include/config/holes/in/zone.h) \
$(wildcard include/config/arch/has/holes/memorymodel.h) \
include/linux/wait.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/current.h \
include/linux/threads.h \
$(wildcard include/config/nr/cpus.h) \
$(wildcard include/config/base/small.h) \
include/linux/numa.h \
$(wildcard include/config/nodes/shift.h) \
include/linux/nodemask.h \
include/linux/bitmap.h \
include/linux/string.h \
$(wildcard include/config/binary/printf.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/string.h \
include/linux/pageblock-flags.h \
$(wildcard include/config/hugetlb/page.h) \
$(wildcard include/config/hugetlb/page/size/variable.h) \
include/generated/bounds.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/page.h \
$(wildcard include/config/cpu/copy/v3.h) \
$(wildcard include/config/cpu/copy/v4wt.h) \
$(wildcard include/config/cpu/copy/v4wb.h) \
$(wildcard include/config/cpu/copy/feroceon.h) \
$(wildcard include/config/cpu/copy/fa.h) \
$(wildcard include/config/cpu/xscale.h) \
$(wildcard include/config/cpu/copy/v6.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/glue.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/memory.h \
$(wildcard include/config/page/offset.h) \
$(wildcard include/config/dram/size.h) \
$(wildcard include/config/dram/base.h) \
$(wildcard include/config/have/tcm.h) \
$(wildcard include/config/arm/patch/phys/virt.h) \
$(wildcard include/config/arm/patch/phys/virt/16bit.h) \
arch/arm/mach-rk3188/include/mach/memory.h \
arch/arm/plat-rk/include/plat/memory.h \
include/linux/version.h \
arch/arm/mach-rk3188/include/mach/io.h \
arch/arm/plat-rk/include/plat/io.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/sizes.h \
include/asm-generic/sizes.h \
include/asm-generic/memory_model.h \
$(wildcard include/config/sparsemem/vmemmap.h) \
include/asm-generic/getorder.h \
include/linux/memory_hotplug.h \
$(wildcard include/config/memory/hotremove.h) \
$(wildcard include/config/have/arch/nodedata/extension.h) \
include/linux/notifier.h \
include/linux/errno.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/errno.h \
include/asm-generic/errno.h \
include/asm-generic/errno-base.h \
include/linux/mutex.h \
$(wildcard include/config/debug/mutexes.h) \
$(wildcard include/config/have/arch/mutex/cpu/relax.h) \
include/linux/rwsem.h \
$(wildcard include/config/rwsem/generic/spinlock.h) \
include/linux/rwsem-spinlock.h \
include/linux/srcu.h \
include/linux/topology.h \
$(wildcard include/config/sched/smt.h) \
$(wildcard include/config/sched/mc.h) \
$(wildcard include/config/sched/book.h) \
$(wildcard include/config/use/percpu/numa/node/id.h) \
include/linux/cpumask.h \
$(wildcard include/config/cpumask/offstack.h) \
$(wildcard include/config/hotplug/cpu.h) \
$(wildcard include/config/debug/per/cpu/maps.h) \
$(wildcard include/config/disable/obsolete/cpumask/functions.h) \
include/linux/smp.h \
$(wildcard include/config/use/generic/smp/helpers.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/smp.h \
include/linux/percpu.h \
$(wildcard include/config/need/per/cpu/embed/first/chunk.h) \
$(wildcard include/config/need/per/cpu/page/first/chunk.h) \
$(wildcard include/config/have/setup/per/cpu/area.h) \
include/linux/pfn.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/percpu.h \
include/asm-generic/percpu.h \
include/linux/percpu-defs.h \
$(wildcard include/config/debug/force/weak/per/cpu.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/topology.h \
include/asm-generic/topology.h \
include/linux/mmdebug.h \
$(wildcard include/config/debug/vm.h) \
$(wildcard include/config/debug/virtual.h) \
include/linux/workqueue.h \
$(wildcard include/config/debug/objects/work.h) \
$(wildcard include/config/freezer.h) \
include/linux/timer.h \
$(wildcard include/config/timer/stats.h) \
$(wildcard include/config/debug/objects/timers.h) \
include/linux/ktime.h \
$(wildcard include/config/ktime/scalar.h) \
include/linux/jiffies.h \
include/linux/timex.h \
include/linux/param.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/param.h \
$(wildcard include/config/hz.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/timex.h \
arch/arm/mach-rk3188/include/mach/timex.h \
arch/arm/plat-rk/include/plat/timex.h \
include/linux/debugobjects.h \
$(wildcard include/config/debug/objects.h) \
$(wildcard include/config/debug/objects/free.h) \
include/linux/sysctl.h \
include/linux/rcupdate.h \
$(wildcard include/config/rcu/torture/test.h) \
$(wildcard include/config/tree/rcu.h) \
$(wildcard include/config/tree/preempt/rcu.h) \
$(wildcard include/config/preempt/rcu.h) \
$(wildcard include/config/no/hz.h) \
$(wildcard include/config/tiny/rcu.h) \
$(wildcard include/config/tiny/preempt/rcu.h) \
$(wildcard include/config/debug/objects/rcu/head.h) \
$(wildcard include/config/preempt/rt.h) \
include/linux/completion.h \
include/linux/rcutree.h \
include/linux/elf.h \
include/linux/elf-em.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/elf.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/user.h \
include/linux/kobject.h \
include/linux/sysfs.h \
include/linux/kobject_ns.h \
include/linux/kref.h \
include/linux/moduleparam.h \
$(wildcard include/config/alpha.h) \
$(wildcard include/config/ia64.h) \
$(wildcard include/config/ppc64.h) \
include/linux/tracepoint.h \
include/linux/jump_label.h \
$(wildcard include/config/jump/label.h) \
include/linux/export.h \
$(wildcard include/config/symbol/prefix.h) \
$(wildcard include/config/modversions.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/module.h \
$(wildcard include/config/arm/unwind.h) \
include/trace/events/module.h \
include/trace/define_trace.h \
include/linux/pagemap.h \
include/linux/mm.h \
$(wildcard include/config/sysctl.h) \
$(wildcard include/config/stack/growsup.h) \
$(wildcard include/config/transparent/hugepage.h) \
$(wildcard include/config/ksm.h) \
$(wildcard include/config/proc/fs.h) \
$(wildcard include/config/debug/pagealloc.h) \
$(wildcard include/config/hibernation.h) \
$(wildcard include/config/hugetlbfs.h) \
include/linux/rbtree.h \
include/linux/prio_tree.h \
include/linux/debug_locks.h \
$(wildcard include/config/debug/locking/api/selftests.h) \
include/linux/mm_types.h \
$(wildcard include/config/split/ptlock/cpus.h) \
$(wildcard include/config/want/page/debug/flags.h) \
$(wildcard include/config/aio.h) \
$(wildcard include/config/mm/owner.h) \
$(wildcard include/config/mmu/notifier.h) \
include/linux/auxvec.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/auxvec.h \
include/linux/page-debug-flags.h \
$(wildcard include/config/page/poisoning.h) \
$(wildcard include/config/page/debug/something/else.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/mmu.h \
$(wildcard include/config/cpu/has/asid.h) \
include/linux/range.h \
include/linux/bit_spinlock.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/pgtable.h \
$(wildcard include/config/highpte.h) \
include/asm-generic/4level-fixup.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/proc-fns.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/glue-proc.h \
$(wildcard include/config/cpu/arm610.h) \
$(wildcard include/config/cpu/arm7tdmi.h) \
$(wildcard include/config/cpu/arm710.h) \
$(wildcard include/config/cpu/arm720t.h) \
$(wildcard include/config/cpu/arm740t.h) \
$(wildcard include/config/cpu/arm9tdmi.h) \
$(wildcard include/config/cpu/arm920t.h) \
$(wildcard include/config/cpu/arm922t.h) \
$(wildcard include/config/cpu/arm925t.h) \
$(wildcard include/config/cpu/arm926t.h) \
$(wildcard include/config/cpu/arm940t.h) \
$(wildcard include/config/cpu/arm946e.h) \
$(wildcard include/config/cpu/arm1020.h) \
$(wildcard include/config/cpu/arm1020e.h) \
$(wildcard include/config/cpu/arm1022.h) \
$(wildcard include/config/cpu/arm1026.h) \
$(wildcard include/config/cpu/mohawk.h) \
$(wildcard include/config/cpu/feroceon.h) \
$(wildcard include/config/cpu/v6k.h) \
$(wildcard include/config/cpu/v7.h) \
arch/arm/mach-rk3188/include/mach/vmalloc.h \
arch/arm/include/generated/../../mach-rk30/include/mach/vmalloc.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/pgtable-hwdef.h \
include/asm-generic/pgtable.h \
include/linux/page-flags.h \
$(wildcard include/config/pageflags/extended.h) \
$(wildcard include/config/arch/uses/pg/uncached.h) \
$(wildcard include/config/memory/failure.h) \
$(wildcard include/config/swap.h) \
$(wildcard include/config/s390.h) \
include/linux/huge_mm.h \
include/linux/vmstat.h \
$(wildcard include/config/vm/event/counters.h) \
include/linux/vm_event_item.h \
include/linux/fs.h \
$(wildcard include/config/security.h) \
$(wildcard include/config/quota.h) \
$(wildcard include/config/fsnotify.h) \
$(wildcard include/config/ima.h) \
$(wildcard include/config/fs/posix/acl.h) \
$(wildcard include/config/epoll.h) \
$(wildcard include/config/debug/writecount.h) \
$(wildcard include/config/file/locking.h) \
$(wildcard include/config/auditsyscall.h) \
$(wildcard include/config/block.h) \
$(wildcard include/config/fs/xip.h) \
$(wildcard include/config/migration.h) \
include/linux/limits.h \
include/linux/ioctl.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/ioctl.h \
include/asm-generic/ioctl.h \
include/linux/blk_types.h \
$(wildcard include/config/blk/dev/integrity.h) \
include/linux/kdev_t.h \
include/linux/dcache.h \
include/linux/rculist.h \
include/linux/rculist_bl.h \
include/linux/list_bl.h \
include/linux/path.h \
include/linux/radix-tree.h \
include/linux/pid.h \
include/linux/capability.h \
include/linux/semaphore.h \
include/linux/fiemap.h \
include/linux/quota.h \
$(wildcard include/config/quota/netlink/interface.h) \
include/linux/percpu_counter.h \
include/linux/dqblk_xfs.h \
include/linux/dqblk_v1.h \
include/linux/dqblk_v2.h \
include/linux/dqblk_qtree.h \
include/linux/nfs_fs_i.h \
include/linux/nfs.h \
include/linux/sunrpc/msg_prot.h \
include/linux/inet.h \
include/linux/fcntl.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/fcntl.h \
include/asm-generic/fcntl.h \
include/linux/err.h \
include/linux/highmem.h \
$(wildcard include/config/x86/32.h) \
$(wildcard include/config/debug/highmem.h) \
include/linux/uaccess.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/uaccess.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/unified.h \
$(wildcard include/config/arm/asm/unified.h) \
include/linux/hardirq.h \
$(wildcard include/config/generic/hardirqs.h) \
$(wildcard include/config/virt/cpu/accounting.h) \
$(wildcard include/config/irq/time/accounting.h) \
include/linux/ftrace_irq.h \
$(wildcard include/config/ftrace/nmi/enter.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/hardirq.h \
$(wildcard include/config/local/timers.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/irq.h \
arch/arm/mach-rk3188/include/mach/irqs.h \
include/linux/irq_cpustat.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/cacheflush.h \
$(wildcard include/config/smp/on/up.h) \
$(wildcard include/config/arm/errata/411920.h) \
$(wildcard include/config/cpu/cache/vipt.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/glue-cache.h \
$(wildcard include/config/cpu/cache/v3.h) \
$(wildcard include/config/cpu/cache/v4.h) \
$(wildcard include/config/cpu/cache/v4wb.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/shmparam.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/cachetype.h \
$(wildcard include/config/cpu/cache/vivt.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/kmap_types.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/highmem.h \
$(wildcard include/config/cpu/tlb/v6.h) \
include/linux/hugetlb_inline.h \
include/linux/slab.h \
$(wildcard include/config/slab/debug.h) \
$(wildcard include/config/failslab.h) \
$(wildcard include/config/slub.h) \
$(wildcard include/config/slob.h) \
$(wildcard include/config/debug/slab.h) \
$(wildcard include/config/slab.h) \
include/linux/slub_def.h \
$(wildcard include/config/slub/stats.h) \
$(wildcard include/config/slub/debug.h) \
include/linux/kmemleak.h \
$(wildcard include/config/debug/kmemleak.h) \
include/linux/mount.h \
include/linux/vfs.h \
include/linux/statfs.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/statfs.h \
include/asm-generic/statfs.h \
include/linux/quotaops.h \
include/linux/exportfs.h \
include/linux/writeback.h \
include/linux/sched.h \
$(wildcard include/config/sched/debug.h) \
$(wildcard include/config/lockup/detector.h) \
$(wildcard include/config/detect/hung/task.h) \
$(wildcard include/config/core/dump/default/elf/headers.h) \
$(wildcard include/config/sched/autogroup.h) \
$(wildcard include/config/bsd/process/acct.h) \
$(wildcard include/config/taskstats.h) \
$(wildcard include/config/audit.h) \
$(wildcard include/config/cgroups.h) \
$(wildcard include/config/inotify/user.h) \
$(wildcard include/config/fanotify.h) \
$(wildcard include/config/posix/mqueue.h) \
$(wildcard include/config/keys.h) \
$(wildcard include/config/perf/events.h) \
$(wildcard include/config/schedstats.h) \
$(wildcard include/config/task/delay/acct.h) \
$(wildcard include/config/fair/group/sched.h) \
$(wildcard include/config/rt/group/sched.h) \
$(wildcard include/config/cgroup/sched.h) \
$(wildcard include/config/blk/dev/io/trace.h) \
$(wildcard include/config/rcu/boost.h) \
$(wildcard include/config/compat/brk.h) \
$(wildcard include/config/cc/stackprotector.h) \
$(wildcard include/config/sysvipc.h) \
$(wildcard include/config/rt/mutexes.h) \
$(wildcard include/config/task/xacct.h) \
$(wildcard include/config/cpusets.h) \
$(wildcard include/config/futex.h) \
$(wildcard include/config/fault/injection.h) \
$(wildcard include/config/latencytop.h) \
$(wildcard include/config/have/unstable/sched/clock.h) \
$(wildcard include/config/debug/stack/usage.h) \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/cputime.h \
include/asm-generic/cputime.h \
include/linux/sem.h \
include/linux/ipc.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/ipcbuf.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/sembuf.h \
include/linux/signal.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/signal.h \
include/asm-generic/signal-defs.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/sigcontext.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/siginfo.h \
include/asm-generic/siginfo.h \
include/linux/proportions.h \
include/linux/seccomp.h \
$(wildcard include/config/seccomp.h) \
include/linux/rtmutex.h \
$(wildcard include/config/debug/rt/mutexes.h) \
include/linux/plist.h \
$(wildcard include/config/debug/pi/list.h) \
include/linux/resource.h \
/home/tyler/dev/rk3188/tylermk908/arch/arm/include/asm/resource.h \
include/asm-generic/resource.h \
include/linux/hrtimer.h \
$(wildcard include/config/high/res/timers.h) \
$(wildcard include/config/timerfd.h) \
include/linux/timerqueue.h \
include/linux/task_io_accounting.h \
$(wildcard include/config/task/io/accounting.h) \
include/linux/latencytop.h \
include/linux/cred.h \
$(wildcard include/config/debug/credentials.h) \
$(wildcard include/config/user/ns.h) \
include/linux/key.h \
include/linux/selinux.h \
$(wildcard include/config/security/selinux.h) \
include/linux/aio.h \
include/linux/aio_abi.h \
include/linux/uio.h \
include/linux/buffer_head.h \
fs/libfs.o: $(deps_fs/libfs.o)
$(deps_fs/libfs.o): |
// formatter_defaults.hpp
// Boost Logging library
#ifndef <API key>
#define <API key>
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/logging/detail/fwd.hpp>
#include <boost/logging/detail/manipulator.hpp>
#include <boost/logging/format/formatter/time.hpp>
#include <stdio.h>
#include <time.h>
#include <sstream>
namespace boost { namespace logging { namespace formatter {
/**
@brief prefixes each message with an index.
Example:
@code
L_ << "my message";
L_ << "my 2nd message";
@endcode
This will output something similar to:
@code
[1] my message
[2] my 2nd message
@endcode
@param convert [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format.
For instance, you might use @ref boost::logging::optimize::<API key> "a cached_string class" (see @ref boost::logging::optimize "optimize namespace").
*/
template<class convert = do_convert_format::prepend> struct idx_t : is_generic, formatter::non_const_context<int>, boost::logging::op_equal::always_equal {
typedef formatter::non_const_context<int> <API key>;
idx_t() : <API key>((int)0) {}
template<class msg_type> void operator()(msg_type & str) const {
std::basic_ostringstream<char_type> idx;
idx << BOOST_LOG_STR("[") << ++context() << BOOST_LOG_STR("] ");
convert::write( idx.str(), str );
}
};
/**
@brief Appends a new line
@param convert [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format.
For instance, you might use @ref boost::logging::optimize::<API key> "a cached_string class" (see @ref boost::logging::optimize "optimize namespace").
*/
template<class convert = do_convert_format::append> struct append_newline_t : is_generic, boost::logging::op_equal::always_equal {
template<class msg_type> void operator()(msg_type & str) const {
convert::write( BOOST_LOG_STR("\n"), str );
}
};
/**
@brief Appends a new line, if not already there
@param convert [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format.
For instance, you might use @ref boost::logging::optimize::<API key> "a cached_string class" (see @ref boost::logging::optimize "optimize namespace").
*/
template<class convert = do_convert_format::append> struct <API key> : is_generic, boost::logging::op_equal::always_equal {
template<class msg_type> void operator()(msg_type & str) const {
bool is_needed = true;
if ( ! convert::<API key>(str).empty())
if ( *(convert::<API key>(str).rbegin()) == '\n')
is_needed = false;
if ( is_needed)
convert::write( BOOST_LOG_STR("\n"), str );
}
};
/** @brief idx_t with default values. See idx_t
@copydoc idx_t
*/
typedef idx_t<> idx;
/** @brief append_newline_t with default values. See append_newline_t
@copydoc append_newline_t
*/
typedef append_newline_t<> append_newline;
/** @brief <API key> with default values. See <API key>
@copydoc <API key>
*/
typedef <API key><> <API key>;
}}}
#endif |
class Notifier:
""" Base abstract class for different notifiers like EmailNotifier or TextNotifier.
"""
def __init__(self, client, notified_conf, owner):
self.client = client
self.owner_name = owner["name"]
self.owner_email = owner["email"]
self.owner_phone = owner["phone"]
def notify(self, menace, menace_info, applied_at, applied_duration):
self._do_notify(menace.get_name(),
menace_info.get("Instance", None),
menace_info.get("Process", None),
menace_info.get("Volume", None),
applied_at,
applied_duration)
def _do_notify(self, menace_name, instance_name, process_name, volume_name, applied_at, applied_duration):
raise NotImplementedError |
Ext.define ('Sistema.view.Produccion.TipoDeProducto.ListadoController', {
extend: 'Ext.app.ViewController',
alias: 'controller.<API key>',
requires:[
'Sistema.view.Produccion.TipoDeProducto.ListadoGrillaStore'
],
// Asignacion de EventHandlers para los controles de la vista.
init: function () {
<API key>.InyectarDependencia (this, 'Produccion:TipoDeProducto');
this.params = {
<API key>: 'Server/Sysgran/Aplicacion/Modulos/Produccion/TipoDeProducto/<API key>.php',
nuevaEntidad : 'Sistema.view.Produccion.TipoDeProducto.Formulario',
editarEntidad : 'Sistema.view.Produccion.TipoDeProducto.Formulario',
storeGrilla : 'Sistema.view.Produccion.TipoDeProducto.ListadoGrillaStore',
xtypeListado : 'prod-tprod-Listado',
ventanaMaximizable : false,
ventanaMaximized : false,
ventanaModal : false,
verColEditar : true,
verColBorrar : true,
anchoVentana : 800,
altoVentana : 500
};
this.control({
"grid": {
celldblclick: this.<API key>
},
"button[name='btnBuscar']": {
click: this.onBtnBuscarClick
},
"button[name='btnLimpiarFiltros']": {
click: this.<API key>
},
"button[name='btnNuevo']": {
click: this.onBtnNuevoClick
},
"button[name='btnRecargarListado']": {
click: this.<API key>
},
"button[name='btnAceptar']": {
click: this.onBtnAceptarClick
},
"button[name='btnCancelar']": {
click: this.onBtnCancelarClick
},
"prod-tprod-Listado": {
render: this.onRender
}
});
},
SetupFiltros: function () {
this.AgregarFiltro (new <API key> ('codigo', this, 'tbCodigo', 'codigo'));
this.AgregarFiltro (new FiltroTexto ('nombre', this, 'cbNombre', 'tbNombre', 'tnom', 'nom'));
this.AgregarFiltro (new FiltroCheckBox ('es_ventas', this, 'ckVentas', 'esVentas'));
this.AgregarFiltro (new FiltroCheckBox ('es_fabricacion', this, 'ckFabricacion', 'esFabricacion'));
this.AgregarFiltro (new FiltroCheckBox ('es_compras', this, 'ckCompras', 'esCompras'));
},
<API key>: function (params) {
return ManejadorDeVentanas.ReqFormularioWS (null);
},
<API key>: function (item, params) {
return ManejadorDeVentanas.ReqFormularioWS (item.get ('id'));
}
}); |
package com.caucho.v5.amp.thread;
import java.util.concurrent.TimeUnit;
/**
* Executor throttling threads to the cpu max, allowing extras to be
* created slowly as timeouts.
*/
public final class RunnableItem
{
private final Runnable _task;
private final ClassLoader _classLoader;
private final long _timeout;
public RunnableItem(Runnable task,
ClassLoader classLoader,
long timeout)
{
_task = task;
_classLoader = classLoader;
_timeout = timeout;
}
public RunnableItem(Runnable task,
ClassLoader classLoader)
{
this(task, classLoader, TimeUnit.MILLISECONDS.toMillis(100));
}
final Runnable getTask()
{
return _task;
}
final ClassLoader getClassLoader()
{
return _classLoader;
}
final long getTimeout()
{
return _timeout;
}
@Override
public String toString()
{
return getClass().getSimpleName() + "[" + _task + "]";
}
} |
Joomla.submitbutton = (task) => {
'use strict';
if (task === 'actionlogs.exportLogs') {
Joomla.submitform(task, document.getElementById('exportForm'));
return;
}
if (task === 'actionlogs.exportSelectedLogs') {
// Get id of selected action logs item and pass it to export form hidden input
const cids = [];
const elements = [].slice.call(document.querySelectorAll("input[name='cid[]']:checked"));
if (elements.length) {
elements.forEach((element) => {
cids.push(element.value);
});
}
document.exportForm.cids.value = cids.join(',');
Joomla.submitform(task, document.getElementById('exportForm'));
return;
}
Joomla.submitform(task);
}; |
#!/Users/shreyashirday/Personal/openmdao-0.13.0/bin/python
# EASY-INSTALL-SCRIPT: 'docutils==0.10','rst2odt_prepstyles.py'
__requires__ = 'docutils==0.10'
__import__('pkg_resources').run_script('docutils==0.10', 'rst2odt_prepstyles.py') |
<?php
namespace DataStructures;
class <API key> extends \TestHelpers\TestCase {
/**
* Tests that the polymorphic behavior is as expected.
*/
public function testType() {
$instance = SerializableQueue::factory();
if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
$this->assertInstanceOf('\SplQueue', $instance);
}
else {
$this->assertInstanceOf(
'DataStructures\SerializableQueue', $instance
);
}
}
/**
* Tests stability during serialization and deserialization.
*/
public function testSerialization() {
$values = array(
'foo', 'bar', null, array('a', 'b', 3), 5, new \StdClass()
);
$instance = SerializableQueue::factory();
foreach ($values as $value) {
$instance->enqueue($value);
}
$<API key> = unserialize(serialize($instance));
for ($i = 0; $i < count($instance); $i++) {
$this->assertEquals($instance[$i], $<API key>[$i]);
}
$this->assertEquals($i, count($values));
}
}
?> |
({"buttonOk":"","buttonCancel":"","buttonSave":"","itemClose":""}) |
<?php
// Accordions
require_once(gp_admin . '/shortcodes/accordions.php');
// Activity
require_once(gp_admin . '/shortcodes/activity-stream.php');
// Author Info
require_once(gp_admin . '/shortcodes/author-info.php');
// Blockquotes
require_once(gp_admin . '/shortcodes/blockquotes.php');
// Buttons
require_once(gp_admin . '/shortcodes/buttons.php');
// Columns
require_once(gp_admin . '/shortcodes/columns.php');
// Contact Form
require_once(gp_admin . '/shortcodes/contact-form.php');
// Dividers
require_once(gp_admin . '/shortcodes/dividers.php');
// Dropcaps
require_once(gp_admin . '/shortcodes/dropcaps.php');
// Images
require_once(gp_admin . '/shortcodes/images.php');
// Lists
require_once(gp_admin . '/shortcodes/lists.php');
// Logged In
require_once(gp_admin . '/shortcodes/logged-in.php');
// Logged Out
require_once(gp_admin . '/shortcodes/logged-out.php');
// Login Form
require_once(gp_admin . '/shortcodes/login-form.php');
// Notifications
require_once(gp_admin . '/shortcodes/notifications.php');
// Posts
require_once(gp_admin . '/shortcodes/posts.php');
// Register Form
require_once(gp_admin . '/shortcodes/register-form.php');
// Related Posts
require_once(gp_admin . '/shortcodes/related-posts.php');
// Sidebars
require_once(gp_admin . '/shortcodes/sidebars.php');
// Slider
require_once(gp_admin . '/shortcodes/slider.php');
// Tabs
require_once(gp_admin . '/shortcodes/tabs.php');
// Text Boxes
require_once(gp_admin . '/shortcodes/text-boxes.php');
// Toggle Boxes
require_once(gp_admin . '/shortcodes/toggle-boxes.php');
// Videos
require_once(gp_admin . '/shortcodes/videos.php');
?> |
#define USE_INIT(...) __VA_ARGS__ |
#ifndef _QAT_H_
#define _QAT_H_
#include <iostream>
#include <vector>
#include <math.h>
#include "matrix2x2.hpp"
#include "../common/mathematic.hpp"
#include "paving.hpp"
#include "image.hpp"
enum InterpolationType
{
NO_BM,
LINEAR ,
NN
};
class QAT
{
private:
Matrix2x2 m_matrix;
int m_omega;
Vector2D m_vector;
int a0, b0, c0, d0, e0, f0;
int a1, b1, c1, d1;
int b10, b11;
Matrix2x2 H, H0;
int alpha0, alpha1, beta1;
Vector2D U0, U1;
std::vector<Paving> pavings;
std::vector<Paving> pavingsRemainder; // remainders of the canonical paving points
public:
QAT();
QAT(Matrix2x2, int, Vector2D);
bool isContracting() const;
bool isInversible() const;
void inverse();
const Paving determinePaving(int, int) const;
const Paving <API key>(int, int) const;
const Paving <API key>(int, int) const;
void setPaving(const Vector2D, const Vector2D);
void setPavingRemainder ( const Vector2D I, const Vector2D Rem, const Vector2D P );
void setPaving(int, int, const Paving);
const Paving getPaving(int, int) const;
const Paving getPavingRemainder ( int , int ) const;
void determinePavings();
void <API key>();
void <API key>();
void <API key>();
const Color backwardColorLinear(const Vector2D, Image) const;
const Color backwardColorNN(const Vector2D, Image) const;
const Image applyToImage(Image, InterpolationType , bool, bool, bool,bool, bool);
const Matrix2x2 getImageBound(const Image);
void compute();
const Vector2D calculate(const Vector2D) const;
const Vector2D calculateRemainder ( const Vector2D) const;
};
#endif //_QAT_H_ |
/* ScriptData
Name: <API key>
%Complete: 100
Comment: All instance related commands
Category: commandscripts
EndScriptData */
#include "ScriptMgr.h"
#include "Chat.h"
#include "Group.h"
#include "InstanceSaveMgr.h"
#include "InstanceScript.h"
#include "MapManager.h"
#include "Player.h"
#include "Language.h"
class <API key> : public CommandScript
{
public:
<API key>() : CommandScript("<API key>") { }
ChatCommand* GetCommands() const override
{
static ChatCommand <API key>[] =
{
{ "listbinds", rbac::<API key>, false, &<API key>, "", NULL },
{ "unbind", rbac::<API key>, false, &<API key>, "", NULL },
{ "stats", rbac::<API key>, true, &<API key>, "", NULL },
{ "savedata", rbac::<API key>, false, &<API key>, "", NULL },
{ "setbossstate", rbac::<API key>, true, &<API key>, "", NULL },
{ "getbossstate", rbac::<API key>, true, &<API key>, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
{
{ "instance", rbac::<API key>, true, NULL, "", <API key> },
{ NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
static std::string GetTimeString(uint64 time)
{
uint64 days = time / DAY, hours = (time % DAY) / HOUR, minute = (time % HOUR) / MINUTE;
std::ostringstream ss;
if (days)
ss << days << "d ";
if (hours)
ss << hours << "h ";
ss << minute << 'm';
return ss.str();
}
static bool <API key>(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->getSelectedPlayer();
if (!player)
player = handler->GetSession()->GetPlayer();
uint32 counter = 0;
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
{
Player::BoundInstancesMap &binds = player->GetBoundInstances(Difficulty(i));
for (Player::BoundInstancesMap::const_iterator itr = binds.begin(); itr != binds.end(); ++itr)
{
InstanceSave* save = itr->second.save;
std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL));
handler->PSendSysMessage(<API key>, itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str());
counter++;
}
}
handler->PSendSysMessage(<API key>, counter);
counter = 0;
if (Group* group = player->GetGroup())
{
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
{
Group::BoundInstancesMap &binds = group->GetBoundInstances(Difficulty(i));
for (Group::BoundInstancesMap::const_iterator itr = binds.begin(); itr != binds.end(); ++itr)
{
InstanceSave* save = itr->second.save;
std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL));
handler->PSendSysMessage(<API key>, itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str());
counter++;
}
}
}
handler->PSendSysMessage(<API key>, counter);
return true;
}
static bool <API key>(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
Player* player = handler->getSelectedPlayer();
if (!player)
player = handler->GetSession()->GetPlayer();
char* map = strtok((char*)args, " ");
char* pDiff = strtok(NULL, " ");
int8 diff = -1;
if (pDiff)
diff = atoi(pDiff);
uint16 counter = 0;
uint16 MapId = 0;
if (strcmp(map, "all") != 0)
{
MapId = uint16(atoi(map));
if (!MapId)
return false;
}
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
{
Player::BoundInstancesMap &binds = player->GetBoundInstances(Difficulty(i));
for (Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end();)
{
InstanceSave* save = itr->second.save;
if (itr->first != player->GetMapId() && (!MapId || MapId == itr->first) && (diff == -1 || diff == save->GetDifficulty()))
{
std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL));
handler->PSendSysMessage(<API key>, itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str());
player->UnbindInstance(itr, Difficulty(i));
counter++;
}
else
++itr;
}
}
handler->PSendSysMessage(<API key>, counter);
return true;
}
static bool <API key>(ChatHandler* handler, char const* /*args*/)
{
handler->PSendSysMessage(<API key>, sMapMgr->GetNumInstances());
handler->PSendSysMessage(<API key>, sMapMgr-><API key>());
handler->PSendSysMessage(<API key>, sInstanceSaveMgr->GetNumInstanceSaves());
handler->PSendSysMessage(<API key>, sInstanceSaveMgr-><API key>());
handler->PSendSysMessage(<API key>, sInstanceSaveMgr-><API key>());
return true;
}
static bool <API key>(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
Map* map = player->GetMap();
if (!map->IsDungeon())
{
handler->PSendSysMessage(LANG_NOT_DUNGEON);
handler->SetSentErrorMessage(true);
return false;
}
if (!((InstanceMap*)map)->GetInstanceScript())
{
handler->PSendSysMessage(<API key>);
handler->SetSentErrorMessage(true);
return false;
}
((InstanceMap*)map)->GetInstanceScript()->SaveToDB();
return true;
}
static bool <API key>(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
char* param1 = strtok((char*)args, " ");
char* param2 = strtok(nullptr, " ");
char* param3 = strtok(nullptr, " ");
uint32 encounterId = 0;
int32 state = 0;
Player* player = nullptr;
std::string playerName;
// Character name must be provided when using this from console.
if (!param2 || (!param3 && !handler->GetSession()))
{
handler->PSendSysMessage(LANG_CMD_SYNTAX);
handler->SetSentErrorMessage(true);
return false;
}
if (!param3)
player = handler->GetSession()->GetPlayer();
else
{
playerName = param3;
if (normalizePlayerName(playerName))
player = ObjectAccessor::FindPlayerByName(playerName);
}
if (!player)
{
handler->PSendSysMessage(<API key>);
handler->SetSentErrorMessage(true);
return false;
}
Map* map = player->GetMap();
if (!map->IsDungeon())
{
handler->PSendSysMessage(LANG_NOT_DUNGEON);
handler->SetSentErrorMessage(true);
return false;
}
if (!map->ToInstanceMap()->GetInstanceScript())
{
handler->PSendSysMessage(<API key>);
handler->SetSentErrorMessage(true);
return false;
}
encounterId = atoi(param1);
state = atoi(param2);
// Reject improper values.
if (state > TO_BE_DECIDED || encounterId > map->ToInstanceMap()->GetInstanceScript()->GetEncounterCount())
{
handler->PSendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
map->ToInstanceMap()->GetInstanceScript()->SetBossState(encounterId, (EncounterState)state);
std::string stateName = InstanceScript::GetBossStateName(state);
handler->PSendSysMessage(<API key>, encounterId, state, stateName);
return true;
}
static bool <API key>(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
char* param1 = strtok((char*)args, " ");
char* param2 = strtok(nullptr, " ");
uint32 encounterId = 0;
Player* player = nullptr;
std::string playerName;
// Character name must be provided when using this from console.
if (!param1 || (!param2 && !handler->GetSession()))
{
handler->PSendSysMessage(LANG_CMD_SYNTAX);
handler->SetSentErrorMessage(true);
return false;
}
if (!param2)
player = handler->GetSession()->GetPlayer();
else
{
playerName = param2;
if (normalizePlayerName(playerName))
player = ObjectAccessor::FindPlayerByName(playerName);
}
if (!player)
{
handler->PSendSysMessage(<API key>);
handler->SetSentErrorMessage(true);
return false;
}
Map* map = player->GetMap();
if (!map->IsDungeon())
{
handler->PSendSysMessage(LANG_NOT_DUNGEON);
handler->SetSentErrorMessage(true);
return false;
}
if (!map->ToInstanceMap()->GetInstanceScript())
{
handler->PSendSysMessage(<API key>);
handler->SetSentErrorMessage(true);
return false;
}
encounterId = atoi(param1);
if (encounterId > map->ToInstanceMap()->GetInstanceScript()->GetEncounterCount())
{
handler->PSendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
uint8 state = map->ToInstanceMap()->GetInstanceScript()->GetBossState(encounterId);
std::string stateName = InstanceScript::GetBossStateName(state);
handler->PSendSysMessage(<API key>, encounterId, state, stateName);
return true;
}
};
void <API key>()
{
new <API key>();
} |
#include "includes.h"
#ifndef DISABLE_X11FWD
#include "x11fwd.h"
#include "session.h"
#include "ssh.h"
#include "util.h"
#include "chansession.h"
#include "channel.h"
#include "packet.h"
#include "buffer.h"
#define X11BASEPORT 6010
static int bindport(int fd);
static int <API key>(int fd, struct sockaddr_in* addr);
/* called as a request for a session channel, sets up listening X11 */
/* returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
int x11req(struct ChanSess * chansess) {
/* we already have an x11 connection */
if (chansess->x11fd != -1) {
return DROPBEAR_FAILURE;
}
chansess->x11singleconn = buf_getbyte(ses.payload);
chansess->x11authprot = buf_getstring(ses.payload, NULL);
chansess->x11authcookie = buf_getstring(ses.payload, NULL);
chansess->x11screennum = buf_getint(ses.payload);
/* create listening socket */
chansess->x11fd = socket(PF_INET, SOCK_STREAM, 0);
if (chansess->x11fd < 0) {
goto fail;
}
/* allocate port and bind */
chansess->x11port = bindport(chansess->x11fd);
if (chansess->x11port < 0) {
goto fail;
}
/* listen */
if (listen(chansess->x11fd, 20) < 0) {
goto fail;
}
/* set non-blocking */
if (fcntl(chansess->x11fd, F_SETFL, O_NONBLOCK) < 0) {
goto fail;
}
/* channel.c's channel fd code will handle the socket now */
/* set the maxfd so that select() loop will notice it */
ses.maxfd = MAX(ses.maxfd, chansess->x11fd);
return DROPBEAR_SUCCESS;
fail:
/* cleanup */
x11cleanup(chansess);
return DROPBEAR_FAILURE;
}
/* accepts a new X11 socket */
/* returns DROPBEAR_FAILURE or DROPBEAR_SUCCESS */
int x11accept(struct ChanSess * chansess) {
int fd;
struct sockaddr_in addr;
int len;
len = sizeof(addr);
fd = accept(chansess->x11fd, (struct sockaddr*)&addr, &len);
if (fd < 0) {
return DROPBEAR_FAILURE;
}
/* if single-connection we close it up */
if (chansess->x11singleconn) {
x11cleanup(chansess);
}
return <API key>(fd, &addr);
}
/* This is called after switching to the user, and sets up the xauth
* and environment variables. */
void x11setauth(struct ChanSess *chansess) {
char display[20]; /* space for "localhost:12345.123" */
FILE * authprog;
int val;
if (chansess->x11fd == -1) {
return;
}
/* create the DISPLAY string */
val = snprintf(display, sizeof(display), "localhost:%d.%d",
chansess->x11port - 6000, chansess->x11screennum);
if (val < 0 || val >= (int)sizeof(display)) {
/* string was truncated */
return;
}
addnewvar("DISPLAY", display);
/* create the xauth string */
val = snprintf(display, sizeof(display), "unix:%d.%d",
chansess->x11port - 6000, chansess->x11screennum);
if (val < 0 || val >= (int)sizeof(display)) {
/* string was truncated */
return;
}
/* popen is a nice function - code is strongly based on OpenSSH's */
authprog = popen(XAUTH_COMMAND, "w");
if (authprog) {
fprintf(authprog, "add %s %s %s\n",
display, chansess->x11authprot, chansess->x11authcookie);
pclose(authprog);
} else {
fprintf(stderr, "Failed to run %s\n", XAUTH_COMMAND);
}
}
void x11cleanup(struct ChanSess * chansess) {
if (chansess->x11fd == -1) {
return;
}
m_free(chansess->x11authprot);
m_free(chansess->x11authcookie);
close(chansess->x11fd);
chansess->x11fd = -1;
}
static int <API key>(int fd, struct sockaddr_in* addr) {
char* ipstring;
if (<API key>(fd, "x11") == DROPBEAR_SUCCESS) {
ipstring = inet_ntoa(addr->sin_addr);
buf_putstring(ses.writepayload, ipstring, strlen(ipstring));
buf_putint(ses.writepayload, addr->sin_port);
encrypt_packet();
return DROPBEAR_SUCCESS;
} else {
return DROPBEAR_FAILURE;
}
}
/* returns the port bound to, or -1 on failure.
* Will attempt to bind to a port X11BASEPORT (6010 usually) or upwards */
static int bindport(int fd) {
struct sockaddr_in addr;
uint16_t port;
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
/* if we can't find one in 2000 ports free, something's wrong */
for (port = X11BASEPORT; port < X11BASEPORT + 2000; port++) {
addr.sin_port = htons(port);
if (bind(fd, (struct sockaddr*)&addr,
sizeof(struct sockaddr_in)) == 0) {
/* success */
return port;
}
if (errno == EADDRINUSE) {
/* try the next port */
continue;
}
/* otherwise it was an error we don't know about */
break;
}
return -1;
}
#endif /* DROPBEAR_X11FWD */ |
package oscar.oscarLab.ca.all.upload.handlers;
import com.lowagie.text.pdf.PdfReader;
import java.io.FileInputStream;
import java.io.<API key>;
import java.io.IOException;
import java.io.InputStream;
import org.apache.log4j.Logger;
import org.oscarehr.common.dao.<API key>;
import org.oscarehr.common.dao.<API key>;
import org.oscarehr.util.LoggedInInfo;
import org.oscarehr.util.SpringUtils;
import oscar.OscarProperties;
import oscar.dms.EDoc;
import oscar.dms.EDocUtil;
import oscar.log.LogAction;
import oscar.log.LogConst;
/**
*
* @author mweston4
*/
public class PDFHandler implements MessageHandler{
private Logger logger = Logger.getLogger(PDFHandler.class);
@Override
public String parse(LoggedInInfo loggedInInfo, String serviceName, String fileName, int fileId, String ipAddr) {
String providerNo = "-1";
String filePath = fileName;
if (!(fileName.endsWith(".pdf") || fileName.endsWith(".PDF"))) {
logger.error("Document " + fileName + "does not have pdf extension");
return null;
}
else {
int fileNameIdx = fileName.lastIndexOf("/");
fileName = fileName.substring(fileNameIdx+1);
}
EDoc newDoc = new EDoc("", "", fileName, "", providerNo, providerNo, "", 'A',
oscar.util.UtilDateUtilities.getToday("yyyy-MM-dd"), "", "", "demographic", "-1", false);
newDoc.setDocPublic("0");
InputStream fis = null;
try {
fis = new FileInputStream(filePath);
newDoc.setContentType("application/pdf");
//Find the number of pages
PdfReader reader = new PdfReader(filePath);
int numPages = reader.getNumberOfPages();
reader.close();
newDoc.setNumberOfPages(numPages);
String doc_no = EDocUtil.addDocumentSQL(newDoc);
LogAction.addLog(providerNo, LogConst.ADD, LogConst.CON_DOCUMENT, doc_no, ipAddr,"","DocUpload");
//Get provider to route document to
String batchPDFProviderNo = OscarProperties.getInstance().getProperty("<API key>");
if ((batchPDFProviderNo != null) && !batchPDFProviderNo.isEmpty()) {
<API key> <API key> = (<API key>) SpringUtils.getBean("<API key>");
<API key>.addToProviderInbox(batchPDFProviderNo, Integer.parseInt(doc_no), "DOC");
//Add to default queue for now, not sure how or if any other queues can be used anyway (MAB)
<API key> <API key> = (<API key>) SpringUtils.getBean("<API key>");
Integer did=Integer.parseInt(doc_no.trim());
<API key>.<API key>(1,did);
}
}
catch (<API key> e) {
logger.info("An unexpected error has occurred:" + e.toString());
return null;
}
catch (Exception e) {
logger.info("An unexpected error has occurred:" + e.toString());
return null;
} finally {
try {
if (fis != null) {
fis.close();
}
} catch (IOException e1) {
logger.info("An unexpected error has occurred:" + e1.toString());
}
}
return "success";
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.