code
stringlengths
3
1.01M
repo_name
stringlengths
5
116
path
stringlengths
3
311
language
stringclasses
30 values
license
stringclasses
15 values
size
int64
3
1.01M
<?php /*************************************************************** * Copyright notice * * (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com) * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project 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. * * The GNU General Public License can be found at * http://www.gnu.org/copyleft/gpl.html. * A copy is found in the textfile GPL.txt and important notices to the license * from the author is found in LICENSE.txt distributed with these scripts. * * * This script 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. * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ /** * Module: Advanced functions * Advanced Functions related to pages * * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj * XHTML compliant * * @author Kasper Skårhøj <kasperYYYY@typo3.com> */ unset($MCONF); require 'conf.php'; require $BACK_PATH . 'init.php'; $LANG->includeLLFile('EXT:lang/locallang_mod_web_func.xlf'); $BE_USER->modAccess($MCONF, 1); /* * @deprecated since 6.0, the classname SC_mod_web_func_index and this file is obsolete * and will be removed with 6.2. The class was renamed and is now located at: * typo3/sysext/func/Classes/Controller/PageFunctionsController.php */ require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('func') . 'Classes/Controller/PageFunctionsController.php'; // Make instance: /** @var $SOBE \TYPO3\CMS\Func\Controller\PageFunctionsController */ $SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Func\\Controller\\PageFunctionsController'); $SOBE->init(); // Include files? foreach ($SOBE->include_once as $INC_FILE) { include_once $INC_FILE; } // Checking for first level external objects $SOBE->checkExtObj(); // Repeat Include files! - if any files has been added by second-level extensions foreach ($SOBE->include_once as $INC_FILE) { include_once $INC_FILE; } // Checking second level external objects $SOBE->checkSubExtObj(); $SOBE->main(); $SOBE->printContent(); ?>
tonglin/pdPm
public_html/typo3_src-6.1.7/typo3/sysext/func/mod1/index.php
PHP
gpl-2.0
2,517
<?php /** * Elgg groups plugin * * @package ElggGroups * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author Curverider Ltd * @copyright Curverider Ltd 2008-2009 * @link http://elgg.com/ */ $event = $vars['entity']; $owner = get_entity($vars['entity']->owner_guid); $forward_url = $event->getURL(); ?> <div class="contentWrapper"> <form action="<?php echo $vars['url']; ?>action/eventrequest/invite" method="post"> <?php if ($friends = get_entities_from_relationship('friend',$_SESSION['guid'],false,'user','',0,'',9999)) { echo elgg_view('friends/picker',array('entities' => $friends, 'internalname' => 'user_guid', 'highlight' => 'all')); } // echo elgg_view('sharing/invite',array('shares' => $shares, 'owner' => $owner, 'group' => $group)); ?> <input type="hidden" name="forward_url" value="<?php echo $forward_url; ?>" /> <input type="hidden" name="event_guid" value="<?php echo $event->guid; ?>" /> <input type="submit" value="<?php echo elgg_echo('invite'); ?>" /> </form> </div>
kimkha/snorg
mod/event_calendar/views/default/eventrequest/invite.php
PHP
gpl-2.0
1,114
#ifndef SCGRAPH_MATERIAL_HH #define SCGRAPH_MATERIAL_HH #include "color_rgba.h" /** a material */ struct Material { float _shinyness; ColorRGBA _ambient_reflection; ColorRGBA _diffuse_reflection; ColorRGBA _specular_reflection; ColorRGBA _emissive_color; Material (); }; #endif
miguel-negrao/SCGraph
src/material.h
C
gpl-2.0
292
# -*- coding: utf-8 -*- """ translate variance and its formated character which have regularities for example: raw input: v={'aa': 12345, 'bbbb': [1, 2, 3, 4, {'flag': 'vvvv||||xxxxx'}, set(['y', 'x', 'z'])]} after `var2str.var2str(v)` v_str=<aa::12345##bbbb::<1||2||3||4||<flag::vvvv|xxxxx>||<y|||x|||z>>> then reverse back: `var2str.str2var(v_str)` v_var={'aa': '12345', 'bbbb': ['1', '2', '3', '4', {'flag': 'vvvv|xxxxx'}, set(['y', 'x', 'z'])]} NOTATION: 1, KEY of DICT should be string. 2, SET amd TUPLE automatically are transformed to LIST 3, INT/FLOAT/LONG etc. are automatically transformed to STRING 4, SEPERATORS would be replace to '' in character. """ import types # TAKE notation of sequence, which has one order sep_dict = { "dict_sep": "##", # seperator of elements of dict "dict_k_v_sep": "::", # k::v "list_sep": "||", # list seperator "set_sep": "|||", # set seperator "tuple_sep": "||" # tuple seperator } sep_nest = ("<", ">") # better not repeated char, e.x. ("<-", "->") # internal operations sep_values = sep_dict.values() def erase_sep(s): for v in sep_values: s = s.replace(v, "") for v in sep_nest: s=s.replace(v, "") return s _s=sep_nest[0] _e=sep_nest[1] class var2str(object): @staticmethod def var2str(var): if not var: return "" if type(var) == types.DictType: result = [] for key,value in var.items(): v_str = var2str.var2str(value) k_str = erase_sep("{0}".format(key)) result.append("{key}{sep}{value}".format( key=k_str, sep=sep_dict["dict_k_v_sep"], value=v_str)) return _s+sep_dict["dict_sep"].join(result)+_e #return sep_dict["dict_sep"].join(result) elif type(var) == types.ListType: result = [var2str.var2str(v) for v in var] return _s+sep_dict["list_sep"].join(result)+_e #return sep_dict["list_sep"].join(result) elif type(var) == type(set([])): result = [var2str.var2str(v) for v in var] return _s+sep_dict["set_sep"].join(result)+_e #return sep_dict["set_sep"].join(result) elif type(var) == types.TupleType: result = [var2str.var2str(v) for v in var] return _s+sep_dict["tuple_sep"].join(result)+_e #return sep_dict["tuple_sep"].join(result) elif type(var) in [types.StringType, types.IntType, types.LongType, types.FloatType]: return erase_sep("{0}".format(var)) else: raise TypeError("Type is not supported. var: {0}, type: {1}".format( var, type(var))) @staticmethod def str2var(value): # certain the outer nested elements' type if NestType.is_nest_type(value, _s, _e): _var = NestType(value) _var.replace_nest_vars() var = _var.parse_var() if type(var) == types.DictType: for k, v in var.items(): if type(v)==NestType: var[k] = var2str.str2var(str(v)) if type(var) == types.ListType: for n, v in enumerate(var): if type(v) == NestType: var[n] = var2str.str2var(str(v)) if type(var) == type(set()): # because element in set must be hashable, so there is no meaning for # for parsing set pass return var else: return value class NestType(object): def __init__(self, s, s_tag=_s, e_tag=_e): self.value = str(s) self.s_tag = s_tag self.e_tag = e_tag self.replace_s = None @staticmethod def is_nest_type(value, s_tag, e_tag): if (not value.startswith(s_tag) or not value.endswith(e_tag)): return 0 return 1 def _get_obj_str(self, var): return "[NestType]"+str(hash(var)) def has_nest_element(self): if self.replace_s is None: self.replace_nest_vars() return self.repalce_s == self.value def _replace_nest_var(self, s, nest_dic={}): s_len = len(s) tag_index = 0 s_tag_len, e_tag_len = len(self.s_tag), len(self.e_tag) nest_index =[] for i in range(s_len): if s[i:i+s_tag_len] == self.s_tag: tag_index +=1 if tag_index == 1: nest_index.append(i) if s[i:i+e_tag_len] == self.e_tag: tag_index -=1 if tag_index == 0: nest_index.append(i) if len(nest_index) == 2: break if len(nest_index) <2: return s nest_index_s = nest_index[0] nest_index_e = nest_index[1] + e_tag_len nest_str = s[nest_index_s:nest_index_e] nest_var = NestType(nest_str, s_tag=self.s_tag, e_tag = self.e_tag) nest_var_str = self._get_obj_str(nest_var) nest_dic[nest_var_str] = nest_var return s[0:nest_index_s] + nest_var_str + s[nest_index_e:] def replace_nest_vars(self): # trim sign in start and end nest_dic = {} if not NestType.is_nest_type(self.value, self.s_tag, self.e_tag): raise Exception( "[ERROR] `{0}` does not match NestType format".format(self.value)) s = _trim_tag(self.value, self.s_tag, self.e_tag) while 1: replace_s = self._replace_nest_var(s,nest_dic) if replace_s == s: break s = replace_s self.replace_s = replace_s self.nest_dic = nest_dic def parse_var(self): """string `replace_s` has no nestType at all""" s = self.replace_s var = None dict_sep = sep_dict["dict_sep"] dict_k_v_sep = sep_dict["dict_k_v_sep"] list_sep = sep_dict["list_sep"] set_sep = sep_dict["set_sep"] if dict_k_v_sep in s: # dict var = {} items = s.split(dict_sep) for item in items: if not item: continue k,v=item.split(dict_k_v_sep) var[k] = self.nest_dic.get(v, v) elif set_sep in s: var = set([self.nest_dic.get(t, t) for t in s.split(set_sep)]) elif list_sep in s: var = [self.nest_dic.get(t, t) for t in s.split(list_sep)] else: # just one string var = s return var def __str__(self): return self.value def __unicode__(self): return self.value def _trim_tag(str, s, e): """trim the `str` off start `s` and end `e`""" return str[len(s):(len(str)-len(e))] def test(): a = {"aa": 12345, "bbbb":[1,2,3,4,{'flag':"vvvv||||世界是我的"},set(['x', 'y','z'])]} #a = {} print a a_str = var2str.var2str(a) print ">>", a_str a_var = var2str.str2var(a_str) print ">>", a_var if __name__ == "__main__": test()
mavarick/spider-python
webspider/utils/var2str.py
Python
gpl-2.0
6,752
/* * Copyright (C) 2005 - 2011 MaNGOS <http://www.getmangos.org/> * * Copyright (C) 2008 - 2011 TrinityCore <http://www.trinitycore.org/> * * Copyright (C) 2011 - 2012 TrilliumEMU <http://trilliumx.code-engine.org/> * * 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://www.gnu.org/licenses/>. */ #include "ScriptMgr.h" #include "Chat.h" class achievement_commandscript : public CommandScript { public: achievement_commandscript() : CommandScript("achievement_commandscript") { } ChatCommand* GetCommands() const { static ChatCommand achievementCommandTable[] = { { "add", SEC_ADMINISTRATOR, false, &HandleAchievementAddCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; static ChatCommand commandTable[] = { { "achievement", SEC_ADMINISTRATOR, false, NULL, "", achievementCommandTable }, { NULL, 0, false, NULL, "", NULL } }; return commandTable; } static bool HandleAchievementAddCommand(ChatHandler* handler, const char *args) { if (!*args) return false; uint32 achievementId = atoi((char*)args); if (!achievementId) { if (char* cId = handler->extractKeyFromLink((char*)args, "Hachievement")) achievementId = atoi(cId); if (!achievementId) return false; } Player* target = handler->getSelectedPlayer(); if (!target) { handler->SendSysMessage(LANG_NO_CHAR_SELECTED); handler->SetSentErrorMessage(true); return false; } if (AchievementEntry const* pAE = GetAchievementStore()->LookupEntry(achievementId)) target->CompletedAchievement(pAE); return true; } }; void AddSC_achievement_commandscript() { new achievement_commandscript(); }
Kr4v3n5/Core
src/server/scripts/Commands/cs_achievement.cpp
C++
gpl-2.0
2,618
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_23) on Tue Oct 18 12:39:05 CEST 2011 --> <TITLE> OutputProvider </TITLE> <META NAME="date" CONTENT="2011-10-18"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="OutputProvider"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= START OF TOP NAVBAR ======= --> <A NAME="navbar_top"><!-- --></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;<A HREF="../../../../com/sun/btrace/spi/ClasspathProvider.html" title="interface in com.sun.btrace.spi"><B>PREV CLASS</B></A>&nbsp; &nbsp;<A HREF="../../../../com/sun/btrace/spi/PortLocator.html" title="interface in com.sun.btrace.spi"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?com/sun/btrace/spi/OutputProvider.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="OutputProvider.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <!-- ======== START OF CLASS DATA ======== --> <H2> <FONT SIZE="-1"> com.sun.btrace.spi</FONT> <BR> Interface OutputProvider</H2> <HR> <DL> <DT><PRE>public interface <B>OutputProvider</B></DL> </PRE> <P> <DL> <DT><B>Author:</B></DT> <DD>Jaroslav Bachorik <yardus@netbeans.org></DD> </DL> <HR> <P> <!-- =========== FIELD SUMMARY =========== --> <A NAME="field_summary"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Field Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static&nbsp;<A HREF="../../../../com/sun/btrace/spi/OutputProvider.html" title="interface in com.sun.btrace.spi">OutputProvider</A></CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/sun/btrace/spi/OutputProvider.html#DEFAULT">DEFAULT</A></B></CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> </TABLE> &nbsp; <!-- ========== METHOD SUMMARY =========== --> <A NAME="method_summary"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Method Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.io.PrintWriter</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/sun/btrace/spi/OutputProvider.html#getStdErr(com.sun.btrace.api.BTraceTask)">getStdErr</A></B>(<A HREF="../../../../com/sun/btrace/api/BTraceTask.html" title="class in com.sun.btrace.api">BTraceTask</A>&nbsp;task)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.io.PrintWriter</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/sun/btrace/spi/OutputProvider.html#getStdOut(com.sun.btrace.api.BTraceTask)">getStdOut</A></B>(<A HREF="../../../../com/sun/btrace/api/BTraceTask.html" title="class in com.sun.btrace.api">BTraceTask</A>&nbsp;task)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> </TABLE> &nbsp; <P> <!-- ============ FIELD DETAIL =========== --> <A NAME="field_detail"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Field Detail</B></FONT></TH> </TR> </TABLE> <A NAME="DEFAULT"><!-- --></A><H3> DEFAULT</H3> <PRE> static final <A HREF="../../../../com/sun/btrace/spi/OutputProvider.html" title="interface in com.sun.btrace.spi">OutputProvider</A> <B>DEFAULT</B></PRE> <DL> <DL> </DL> </DL> <!-- ============ METHOD DETAIL ========== --> <A NAME="method_detail"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Method Detail</B></FONT></TH> </TR> </TABLE> <A NAME="getStdOut(com.sun.btrace.api.BTraceTask)"><!-- --></A><H3> getStdOut</H3> <PRE> java.io.PrintWriter <B>getStdOut</B>(<A HREF="../../../../com/sun/btrace/api/BTraceTask.html" title="class in com.sun.btrace.api">BTraceTask</A>&nbsp;task)</PRE> <DL> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="getStdErr(com.sun.btrace.api.BTraceTask)"><!-- --></A><H3> getStdErr</H3> <PRE> java.io.PrintWriter <B>getStdErr</B>(<A HREF="../../../../com/sun/btrace/api/BTraceTask.html" title="class in com.sun.btrace.api">BTraceTask</A>&nbsp;task)</PRE> <DL> <DD><DL> </DL> </DD> </DL> <!-- ========= END OF CLASS DATA ========= --> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <A NAME="navbar_bottom"><!-- --></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;<A HREF="../../../../com/sun/btrace/spi/ClasspathProvider.html" title="interface in com.sun.btrace.spi"><B>PREV CLASS</B></A>&nbsp; &nbsp;<A HREF="../../../../com/sun/btrace/spi/PortLocator.html" title="interface in com.sun.btrace.spi"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?com/sun/btrace/spi/OutputProvider.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="OutputProvider.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> </BODY> </HTML>
xxzmxx/btrace_extend
docs/javadoc/com/sun/btrace/spi/OutputProvider.html
HTML
gpl-2.0
10,247
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Source: timelapse.js</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Source: timelapse.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>/* * align2seq: Pairwise alignements algorithms in JavaScript, html5, and css3 * Copyright (C) 2015 * * This file is part of align2seq. * * align2seq 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 3 of the License, or * (at your option) any later version. * * align2seq 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 align2seq. If not, see &lt;http://www.gnu.org/licenses/> * * Authors: * Rudy Anne * Aurelien Beliard * Emeline Duquenne * Aurore Perdriau */ "use strict" var nbValuesToDisplay = 0; var nbValuesAlignToDisplay = 0; var nbAlign; var title; /** *[First function executed after data treatment in case of step by step] * */ function next(){ nbValuesToDisplay++; //Limit check value if(nbValuesToDisplay>=matscore.length){ nbValuesToDisplay=matscore.length; nbValuesAlignToDisplay++; if (nbValuesAlignToDisplay>=listalign.length){ nbValuesAlignToDisplay=listalign.length; } } launch_nstep(nbValuesToDisplay); launch_nstep_align(nbValuesAlignToDisplay); } /** * [this function allow to return to the previous step of the step by step] * */ function prev(){ nbValuesAlignToDisplay--; if(nbValuesAlignToDisplay&lt;0){ nbValuesAlignToDisplay=0 nbValuesToDisplay--; } launch_nstep(nbValuesToDisplay); launch_nstep_align(nbValuesAlignToDisplay); } /** * [this function allow to return to the next state] * */ function fastnext(){ if(nbValuesToDisplay&lt;=matscore.length){ nbValuesToDisplay=matscore.length } if (nbValuesAlignToDisplay&lt;=listalign.length &amp;&amp; nbValuesAlignToDisplay!==0){ nbValuesAlignToDisplay=listalign.length; } launch_nstep(nbValuesToDisplay); launch_nstep_align(nbValuesAlignToDisplay); nbValuesAlignToDisplay++ } /** * [this function allow to return to the previous state] */ function fastpreview(){ if (nbValuesAlignToDisplay!==0){ nbValuesAlignToDisplay=0 nbValuesToDisplay=matscore.length; } else if (nbValuesToDisplay&lt;=matscore.length){ nbValuesAlignToDisplay=0 nbValuesToDisplay=0 } launch_nstep(nbValuesToDisplay); launch_nstep_align(nbValuesAlignToDisplay); } /** Step by step function with next and preview possibilities @param {[number]} nbValuesToDisplay - counter for the scoring matrix */ function launch_nstep(nbValuesToDisplay){ var matrixs=document.getElementById("matrixtime"); //The table is empty while (matrixs.firstChild) { matrixs.removeChild(matrixs.firstChild); } // Filling the array with the desired number of cells for (var i =0;i&lt;=(size2-1);i++){ matrixs.insertRow(i); for(var j=0;j&lt;=(size1);j++){ matrixs.rows[i].insertCell(j); } } for(var i=0;i&lt;matrixs.rows.length;i++){ var currentRow = matrixs.rows[i]; for(var j=0;j&lt;currentRow.cells.length;j++){ var currentCell=currentRow.cells[j]; //Filling the array with the first sequence (first column) if (i>=2 &amp;&amp; j===0){ currentCell.innerHTML=s2[i-2]; } //Filling the array with the second sequence (first ligne) if (i===0 &amp;&amp; j>=2){ currentCell.innerHTML=s1[j-2]; } } } var nbDisplayedValues= 0; for(var i=1;i&lt;matrixs.rows.length;i++){ var currentRow = matrixs.rows[i]; for(var j=1;j&lt;currentRow.cells.length;j++){ var currentCell=currentRow.cells[j]; if ((nbDisplayedValues>=1) &amp;&amp; (nbDisplayedValues&lt;nbValuesToDisplay)){ var i2,j2; if (j==1){ i2=i-1; j2=(currentRow.cells.length)-1 } else{ i2=i; j2=j-1; } var previousCell=matrixs.rows[i2].cells[j2] var cellprevious=nbDisplayedValues-1; previousCell.innerHTML=matpatharrows[cellprevious]; previousCell.innerHTML+=matsumtot[cellprevious]; } //The table is filled with the assumption that it is filled from left to right currentCell.innerHTML=matscore[nbDisplayedValues]; nbDisplayedValues++; if (nbDisplayedValues>nbValuesToDisplay) { currentCell.style.visibility="hidden"; } if (nbDisplayedValues==matscore.length){ currentCell.innerHTML=matpatharrows[(matscore.length)-1]+" "+matsumtot[(matscore.length)-1]; } } } title=document.getElementById("matrixtime").createCaption(); title.innerHTML="&lt;b>Sum matrix&lt;/b>"; if(nbValuesToDisplay>size1) { if ((nbValuesToDisplay-1)%size1!==0){ var cellvert=size1; var celldia=size1+1; var cellcurrent=nbValuesToDisplay-1; var posj=(nbValuesToDisplay-1)%(len1+1); var posi=Math.floor((nbValuesToDisplay-1)/(len1+1)); explain.innerHTML="Value of M("+posi+","+posj+") = maximal value between : &lt;br>"; explain.innerHTML+="M("+(posi-1)+","+(posj-1)+") + S("+posi+","+posj+") = "+matsumtot[cellcurrent-celldia]+" + "+matscore[cellcurrent]+" = " +"&lt;b>"+matsumdia[cellcurrent]+"&lt;/b>"+"&lt;br>"; explain.innerHTML+="M("+(posi)+","+(posj-1)+") + gap = "+matsumtot[cellcurrent-1]+"+"+gap2[posi]+" = "+"&lt;b>"+matsumhor[cellcurrent]+"&lt;/b>"+"&lt;br>"; explain.innerHTML+="M("+(posi-1)+","+(posj)+") + gap = "+matsumtot[cellcurrent-cellvert]+"+"+gap[posj]+"= "+"&lt;b>"+matsumvert[cellcurrent]+"&lt;/b>"+"&lt;br>"; explain.innerHTML+="Maximum value of the three : &lt;b>"+matsumtot[cellcurrent]+"&lt;/b>&lt;br>"; explain.innerHTML+="Corresponding path : "+matpatharrows[cellcurrent]+"&lt;br>"; } else{ explain.innerHTML=""; } } } /** * display the alignment step by step * @param {integer} nbValuesToDisplayAlign number of value in the alignment * */ function launch_nstep_align(nbValuesToDisplayAlign){ if (nbValuesAlignToDisplay>=1){ title.innerHTML="&lt;b>Alignment matrix&lt;/b>"; explain.innerHTML=" "; } var matrixs=document.getElementById("matrixtime") var nbDisplayedValuesAlign= 0; for(var i=1;i&lt;matrixs.rows.length;i++){ var currentRow = matrixs.rows[i]; for(var j=1;j&lt;currentRow.cells.length;j++){ var currentCell=currentRow.cells[j]; } } for(var posalign=1;posalign&lt;=nbValuesToDisplayAlign;posalign++){ var alignpos=listalign[posalign-1]; console.log(alignpos); if (alignpos >= listalign[posalign-2]){ launch_nstep(matscore.length) } var posj=(alignpos%(len1+1)-1)+2; var posi=Math.floor((alignpos/(len1+1)-1)+2); var alignCell=matrixs.rows[posi].cells[posj]; alignCell.innerHTML=matpatharrowsalign[alignpos]; } }</code></pre> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#fastnext">fastnext</a></li><li><a href="global.html#fastpreview">fastpreview</a></li><li><a href="global.html#launch_nstep">launch_nstep</a></li><li><a href="global.html#launch_nstep_align">launch_nstep_align</a></li><li><a href="global.html#next">next</a></li><li><a href="global.html#prev">prev</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-beta3</a> on Sat May 09 2015 10:51:42 GMT+0200 (CEST) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>
crazybiocomputing/align2seq
doc/timelapse.js.html
HTML
gpl-2.0
8,318
/* * input.h: header for input.c * * Written By Michael Sandrof * * Copyright (c) 1990 Michael Sandrof. * Copyright (c) 1991, 1992 Troy Rollo. * Copyright (c) 1992-2014 Matthew R. Green. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)$eterna: input.h,v 1.27 2014/03/14 20:59:19 mrg Exp $ */ #ifndef irc__input_h_ #define irc__input_h_ typedef struct ScreenInputData ScreenInputData; void set_input(u_char *); void set_input_raw(u_char *); void set_input_prompt(u_char *); u_char *get_input_prompt(void); u_char *get_input(void); u_char *get_input_raw(void); void update_input(int); void init_input(void); void input_reset_screen(Screen *); void input_move_cursor(int); void change_input_prompt(int); void cursor_to_input(void); void input_add_character(u_int, u_char *); void input_backward_word(u_int, u_char *); void input_forward_word(u_int, u_char *); void input_delete_previous_word(u_int, u_char *); void input_delete_next_word(u_int, u_char *); void input_clear_to_bol(u_int, u_char *); void input_clear_line(u_int, u_char *); void input_end_of_line(u_int, u_char *); void input_clear_to_eol(u_int, u_char *); void input_beginning_of_line(u_int, u_char *); void refresh_inputline(u_int, u_char *); void input_delete_character(u_int, u_char *); void input_backspace(u_int, u_char *); void input_transpose_characters(u_int, u_char *); void input_yank_cut_buffer(u_int, u_char *); u_char *function_curpos(u_char *); /* used by update_input */ #define NO_UPDATE 0 #define UPDATE_ALL 1 #define UPDATE_FROM_CURSOR 2 #define UPDATE_JUST_CURSOR 3 #endif /* irc__input_h_ */
princeofdream/debug_src_full
network_utils/irc/ircii/include/input.h
C
gpl-2.0
3,012
class CreateUsers < ActiveRecord::Migration #http://github.com/binarylogic/authlogic_example/blob/9b22672cd64fb31b405c000e207b2cae281baa58/README.rdoc def self.up create_table :users do |t| t.string :login t.string :persistence_token t.string :single_access_token t.integer :failed_login_count t.integer :login_count t.datetime :last_login_at t.datetime :last_request_at t.belongs_to :contact #TODO pick one or the other t.timestamps end end def self.down drop_table :users end end
YSATools/The-Ward-Menu
db/migrate/005_create_users.rb
Ruby
gpl-2.0
561
{% extends "neuroelectro/base.html" %} {% block title %}NeuroElectro :: API{% endblock %} {% block headerIncludes %} <style type="text/css"> h4 { margin-left:20px; } li { margin-top:5px; margin-left:30px; } #api_list, #mailing_list_info{ padding-left:25px; width:800px; position:relative; } </style> {% endblock %} {% block content %} <h1>Data Download and Application Programmer's Interface (API)</h1> <ol id="api_list"> <lh>We provide access to NeuroElectro data in two forms:</lh> <li>As a simple bulk download of the neurophysiological database content represented in Excel spreadsheets (~100Kb total). We expect that this will be sufficient for the majority of uses for the NeuroElectro data. <a href='{{ STATIC_URL }}src/neuroelectro_data_download.zip'>Download Link</a></li> <li>Through a RESTful API, allowing live, web-based dynamic query of the database's content. <a href='https://docs.google.com/document/d/1eeWTrr1sKDoqXJtPayBgKR9WvPwzdaXDdfat2Y_nZmY/edit?usp=sharing' target="_blank">RESTful API Documentation.</a></li> </ol> <p id="mailing_list_info"> If you have questions using the NeuroElectro data or accessing data from the API, please submit your question to the <a href="https://groups.google.com/forum/#!forum/neuroelectro" target="_blank">NeuroElectro Google Groups mailing list.</a> </br> </br> Please view the <a href="/publications">Publications Page</a> for guidelines on how to cite data obtained from this resource. </p> {% endblock %}
lessc0de/neuroelectro_org
html_templates/neuroelectro/api_docs.html
HTML
gpl-2.0
1,579
#region License /* * Copyright (C) 1999-2015 John Källén. * * 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, 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; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #endregion using Reko.Core; using Reko.Core.Code; using Reko.Core.Expressions; using Reko.Core.Lib; using Reko.Core.Machine; using Reko.Core.Operators; using Reko.Core.Rtl; using Reko.Core.Types; using System; using System.Collections.Generic; using System.Diagnostics; namespace Reko.Arch.X86 { /// <summary> /// The state of an X86 processor. Used in the Scanning phase of the decompiler. /// </summary> public class X86State : ProcessorState { private ulong [] regs; private bool [] valid; private uint flags; private uint validFlags; private IntelArchitecture arch; private const int StackItemSize = 2; public X86State(IntelArchitecture arch) { this.arch = arch; this.regs = new ulong[(int)Registers.Max]; this.valid = new bool[(int)Registers.Max]; } public X86State(X86State st) : base(st) { arch = st.arch; FpuStackItems = st.FpuStackItems; regs = (ulong[])st.regs.Clone(); valid = (bool []) st.valid.Clone(); } public override IProcessorArchitecture Architecture { get { return arch; } } public int FpuStackItems { get; set; } public Address AddressFromSegOffset(RegisterStorage seg, uint offset) { Constant c = GetRegister(seg); if (c.IsValid) { return Address.SegPtr((ushort) c.ToUInt32(), offset & 0xFFFF); } else return null; } public Address AddressFromSegReg(RegisterStorage seg, RegisterStorage reg) { Constant c = GetRegister(reg); if (c.IsValid) { return AddressFromSegOffset(seg, c.ToUInt32()); } else return null; } public override ProcessorState Clone() { return new X86State(this); } public override Constant GetRegister(RegisterStorage reg) { if (valid[reg.Number]) return Constant.Create(reg.DataType, regs[reg.Number]); else return Constant.Invalid; } public override void SetRegister(RegisterStorage reg, Constant c) { if (c == null || !c.IsValid) { valid[reg.Number] = false; } else { reg.SetRegisterFileValues(regs, c.ToUInt64(), valid); } } public override void SetInstructionPointer(Address addr) { var segAddr = addr as SegAddress32; if (segAddr != null) SetRegister(Registers.cs, Constant.Word16(segAddr.Selector)); } public override void OnProcedureEntered() { FpuStackItems = 0; // We're making an assumption that the direction flag is always clear // when a procedure is entered. This is true of the vast majority of // x86 code out there, and the assumption is certainly made by most // compilers and code libraries. SetFlagGroup(arch.GetFlagGroup((uint) FlagM.DF), Constant.False()); } public override void OnProcedureLeft(ProcedureSignature sig) { sig.FpuStackDelta = FpuStackItems; } public override CallSite OnBeforeCall(Identifier sp, int returnAddressSize) { if (returnAddressSize > 0) { var spVal = GetValue(sp); SetValue( arch.StackRegister, new BinaryExpression( Operator.ISub, spVal.DataType, sp, Constant.Create( PrimitiveType.CreateWord(returnAddressSize), returnAddressSize))); } return new CallSite(returnAddressSize, FpuStackItems); } public override void OnAfterCall(Identifier sp, ProcedureSignature sig, ExpressionVisitor<Expression> eval) { if (sig == null) return; var spReg = (RegisterStorage)sp.Storage; var spVal = GetValue(spReg); var stackOffset = SetValue( spReg, new BinaryExpression( Operator.IAdd, spVal.DataType, sp, Constant.Create( PrimitiveType.CreateWord(spReg.DataType.Size), sig.StackDelta)).Accept(eval)); if (stackOffset.IsValid) { if (stackOffset.ToInt32() > 0) ErrorListener("Possible stack underflow detected."); } ShrinkFpuStack(-sig.FpuStackDelta); } public bool HasSameValues(X86State st2) { for (int i = 0; i < valid.Length; ++i) { if (valid[i] != st2.valid[i]) return false; if (valid[i]) { RegisterStorage reg = Registers.GetRegister(i); ulong u1 = (ulong)(regs[reg.Number] & ((1UL << reg.DataType.BitSize) - 1UL)); ulong u2 = (ulong)(st2.regs[reg.Number] & ((1UL << reg.DataType.BitSize) - 1UL)); if (u1 != u2) return false; } } return true; } public void GrowFpuStack(Address addrInstr) { ++FpuStackItems; if (FpuStackItems > 7) { Debug.WriteLine(string.Format("Possible FPU stack overflow at address {0}", addrInstr)); //$BUGBUG: should be an exception } } public void ShrinkFpuStack(int cItems) { FpuStackItems -= cItems; } public Constant GetFlagGroup(uint mask) { bool sigle = Bits.IsSingleBitSet(mask); if ((mask & validFlags) == mask) { if (sigle) { return Constant.Bool((flags & mask) != 0); } else { return Constant.Byte((byte)(flags & mask)); } } else { return Constant.Invalid; } } public void SetFlagGroup(FlagGroupStorage reg, Constant value) { uint mask = reg.FlagGroupBits; if (value.IsValid) { validFlags |= mask; if (value.ToBoolean()) { this.flags |= mask; } else { this.flags &= ~mask; } } else { validFlags &= ~mask; } } } }
MavenRain/reko
src/Arch/X86/X86State.cs
C#
gpl-2.0
7,413
<?php defined('_JEXEC') or die('Restricted access'); class PlatformModelMain extends JModelItem { public function getItemuserid(){ $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('*') ->from($db->quoteName('#__reports_userlimits')); //->where('unset_id ='.$id .' and published = 1'); $db->setQuery($query); //print_r($db->loadObjectList()); return $db->loadObjectList() ? : array(); } public function getInseretLimit(){ $input = JFactory::getApplication()->input; $view = $input->get('view'); $layout = $input->get('layout'); $userid = $input->get('userid'); $db = JFactory::getDbo(); $sql ="INSERT INTO `#__users`(`view`,`layout`,`username`) VALUES ('".$view."','".$layout."','".$username."')"; $db->setQuery($sql); return $db->loadObjectList() ? : array(); } public function getUpdateLimit(){ $input = JFactory::getApplication()->input; $view = $input->get('view'); $layout = $input->get('layout'); $userid = $input->get('userid'); $db = JFactory::getDbo(); $sql ="UPDATE `#__users`SET`view`='".$view."',`layout`='".$layout."' WHERE `username`='".$username."'"; $db->setQuery($sql); return $db->loadObjectList() ? : array(); } public function getDeleteLimit(){ $input = JFactory::getApplication()->input; $view = $input->get('view'); $layout = $input->get('layout'); $userid = $input->get('userid'); $db = JFactory::getDbo(); $sql ="DELETE from `#__users` WHERE `username`='".$username."'"; $db->setQuery($sql); return $db->loadObjectList() ? : array(); } }
jq153387/THS
components/com_platform/models/main.php
PHP
gpl-2.0
1,639
<?php // If the user does not have the required permissions... if (!current_user_can('manage_options')) { wp_die( __('You do not have sufficient permissions to access this page.') ); } // Get GroupDocs plug-in options from database. $userId = get_option('userId'); $privateKey = get_option('privateKey'); if (isset ($_POST['login']) && ($_POST['password'])) { $login = trim($_POST['login']); $password = trim($_POST['password']); include_once(dirname(__FILE__) . '/tree_viewer/lib/groupdocs-php/APIClient.php'); include_once(dirname(__FILE__) . '/tree_viewer/lib/groupdocs-php/StorageApi.php'); include_once(dirname(__FILE__) . '/tree_viewer/lib/groupdocs-php/GroupDocsRequestSigner.php'); include_once(dirname(__FILE__) . '/tree_viewer/lib/groupdocs-php/FileStream.php'); if ($basePath == "") { //If base base is empty seting base path to prod server $basePath = 'https://api.groupdocs.com/v2.0'; } //Create signer object $signer = new GroupDocsRequestSigner("123"); //Create apiClient object $apiClient = new APIClient($signer); //Creaet Shared object $shared = new SharedApi($apiClient); //Set base path $shared->setBasePath($basePath); //Set empty variable for result $result = ""; //Login and get user data $userData = $shared->LoginUser($login, $password); //Check status if ($userData->status == "Ok") { //If status Ok get all user data $result = $userData->result->user; $privateKey = $result->pkey; $userId = $result->guid; } else { ?> <div class="updated"><p><strong><?php _e('Enter the correct Login and Password!', 'menu-test' ); ?></strong></p></div> <?php } } // If data was posted to the page... if( isset($_POST['grpdocs_assembly_submit_hidden']) && $_POST['grpdocs_assembly_submit_hidden'] == 1) { // Save the API key to the Options table. $userId = trim($_POST['userId']); $privateKey = trim($_POST['privateKey']); update_option( 'userId', $userId); update_option( 'privateKey', $privateKey); // Display an 'updated' message. ?> <div class="updated"><p><strong><?php _e('Settings saved!', 'menu-test' ); ?></strong></p></div> <?php } ?> <div> <h2>GroupDocs Options</h2> <form name="form_assembly" method="post" action=""> <h3>Login and Password</h3> <table> <tr><td>Login:</td> <td><input type="text" name="login" value="<?php echo $login; ?>"></td></tr> <tr><td>Password:</td> <td><input type="password" name="password" value="<?php echo $password; ?>"></td></tr> </table> <p class="submit"> <input type="submit" name="Submit" class="button-primary" value="Get User Id and Private Key" /> </p> </form> <form name="form" method="post" action=""> <input type="hidden" name="grpdocs_assembly_submit_hidden" value="1"> <h3>API Settings</h3> <table> <tr><td>User Id:</td> <td><input type="text" name="userId" value="<?php echo $userId; ?>"></td></tr> <tr><td>Private Key:</td> <td><input type="text" name="privateKey" value="<?php echo $privateKey; ?>"></td></tr> </table> <p class="submit"> <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" /> </p> </form> </div>
sharpmachine/bjm.org
wp-content/plugins/groupdocs-assembly/options.php
PHP
gpl-2.0
3,436
/* * Convert PEM to DER * * Copyright (C) 2006-2013, ARM Limited, All Rights Reserved * * This file is part of mbed TLS (https://tls.mbed.org) * * 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, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #if !defined(ROUGE_CONFIG_FILE) #include "rouge/config.h" #else #include ROUGE_CONFIG_FILE #endif #if defined(ROUGE_PLATFORM_C) #include "rouge/platform.h" #else #include <stdio.h> #define rouge_free free #define rouge_malloc malloc #define rouge_printf printf #endif #if defined(ROUGE_BASE64_C) && defined(ROUGE_FS_IO) #include "rouge/error.h" #include "rouge/base64.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #endif #define DFL_FILENAME "file.pem" #define DFL_OUTPUT_FILENAME "file.der" #define USAGE \ "\n usage: pem2der param=<>...\n" \ "\n acceptable parameters:\n" \ " filename=%%s default: file.pem\n" \ " output_file=%%s default: file.der\n" \ "\n" #if !defined(ROUGE_BASE64_C) || !defined(ROUGE_FS_IO) int main( void ) { rouge_printf("ROUGE_BASE64_C and/or ROUGE_FS_IO not defined.\n"); return( 0 ); } #else /* * global options */ struct options { const char *filename; /* filename of the input file */ const char *output_file; /* where to store the output */ } opt; int convert_pem_to_der( const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen ) { int ret; const unsigned char *s1, *s2, *end = input + ilen; size_t len = 0; s1 = (unsigned char *) strstr( (const char *) input, "-----BEGIN" ); if( s1 == NULL ) return( -1 ); s2 = (unsigned char *) strstr( (const char *) input, "-----END" ); if( s2 == NULL ) return( -1 ); s1 += 10; while( s1 < end && *s1 != '-' ) s1++; while( s1 < end && *s1 == '-' ) s1++; if( *s1 == '\r' ) s1++; if( *s1 == '\n' ) s1++; if( s2 <= s1 || s2 > end ) return( -1 ); ret = base64_decode( NULL, &len, (const unsigned char *) s1, s2 - s1 ); if( ret == ROUGE_ERR_BASE64_INVALID_CHARACTER ) return( ret ); if( len > *olen ) return( -1 ); if( ( ret = base64_decode( output, &len, (const unsigned char *) s1, s2 - s1 ) ) != 0 ) { return( ret ); } *olen = len; return( 0 ); } /* * Load all data from a file into a given buffer. */ static int load_file( const char *path, unsigned char **buf, size_t *n ) { FILE *f; long size; if( ( f = fopen( path, "rb" ) ) == NULL ) return( -1 ); fseek( f, 0, SEEK_END ); if( ( size = ftell( f ) ) == -1 ) { fclose( f ); return( -1 ); } fseek( f, 0, SEEK_SET ); *n = (size_t) size; if( *n + 1 == 0 || ( *buf = rouge_malloc( *n + 1 ) ) == NULL ) { fclose( f ); return( -1 ); } if( fread( *buf, 1, *n, f ) != *n ) { fclose( f ); free( *buf ); *buf = NULL; return( -1 ); } fclose( f ); (*buf)[*n] = '\0'; return( 0 ); } /* * Write buffer to a file */ static int write_file( const char *path, unsigned char *buf, size_t n ) { FILE *f; if( ( f = fopen( path, "wb" ) ) == NULL ) return( -1 ); if( fwrite( buf, 1, n, f ) != n ) { fclose( f ); return( -1 ); } fclose( f ); return( 0 ); } int main( int argc, char *argv[] ) { int ret = 0; unsigned char *pem_buffer = NULL; unsigned char der_buffer[4096]; char buf[1024]; size_t pem_size, der_size = sizeof(der_buffer); int i; char *p, *q; /* * Set to sane values */ memset( buf, 0, sizeof(buf) ); memset( der_buffer, 0, sizeof(der_buffer) ); if( argc == 0 ) { usage: rouge_printf( USAGE ); goto exit; } opt.filename = DFL_FILENAME; opt.output_file = DFL_OUTPUT_FILENAME; for( i = 1; i < argc; i++ ) { p = argv[i]; if( ( q = strchr( p, '=' ) ) == NULL ) goto usage; *q++ = '\0'; if( strcmp( p, "filename" ) == 0 ) opt.filename = q; else if( strcmp( p, "output_file" ) == 0 ) opt.output_file = q; else goto usage; } /* * 1.1. Load the PEM file */ rouge_printf( "\n . Loading the PEM file ..." ); fflush( stdout ); ret = load_file( opt.filename, &pem_buffer, &pem_size ); if( ret != 0 ) { #ifdef ROUGE_ERROR_C rouge_strerror( ret, buf, 1024 ); #endif rouge_printf( " failed\n ! load_file returned %d - %s\n\n", ret, buf ); goto exit; } rouge_printf( " ok\n" ); /* * 1.2. Convert from PEM to DER */ rouge_printf( " . Converting from PEM to DER ..." ); fflush( stdout ); if( ( ret = convert_pem_to_der( pem_buffer, pem_size, der_buffer, &der_size ) ) != 0 ) { #ifdef ROUGE_ERROR_C rouge_strerror( ret, buf, 1024 ); #endif rouge_printf( " failed\n ! convert_pem_to_der %d - %s\n\n", ret, buf ); goto exit; } rouge_printf( " ok\n" ); /* * 1.3. Write the DER file */ rouge_printf( " . Writing the DER file ..." ); fflush( stdout ); ret = write_file( opt.output_file, der_buffer, der_size ); if( ret != 0 ) { #ifdef ROUGE_ERROR_C rouge_strerror( ret, buf, 1024 ); #endif rouge_printf( " failed\n ! write_file returned %d - %s\n\n", ret, buf ); goto exit; } rouge_printf( " ok\n" ); exit: free( pem_buffer ); #if defined(_WIN32) rouge_printf( " + Press Enter to exit this program.\n" ); fflush( stdout ); getchar(); #endif return( ret ); } #endif /* ROUGE_BASE64_C && ROUGE_FS_IO */
guiquanz/rouge
programs/util/pem2der.c
C
gpl-2.0
6,579
/* * Seven Kingdoms 2: The Fryhtan War * * Copyright 1999 Enlight Software Ltd. * * 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://www.gnu.org/licenses/>. * */ //Filename : OSPY.CPP //Description : Object Spy #include <ospy.h> #include <opower.h> #include <ogame.h> #include <odate.h> #include <onews.h> #include <ofont.h> #include <oimgres.h> #include <ounit.h> #include <oworld.h> #include <obutton.h> #include <obutt3d.h> #include <obuttcus.h> #include <ofirm.h> #include <ofirmall.h> #include <otown.h> #include <onation.h> #include <oraceres.h> #include <ovga.h> #include <omodeid.h> #include <osys.h> #include <otechres.h> #include <otech.h> #include <ose.h> #include <ot_firm.h> #include <ot_reps.h> //----- Define constants for viewing secret menu ------// //#define SECRET_REPORT_COUNT 7 //static char* secret_report_str_array[] = { "Kingdoms", "Towns", "Economy", "Trade", "Military", "Technology", "Espionage" }; //static char secret_view_mode_array[] = { MODE_NATION, MODE_TOWN, MODE_ECONOMY, MODE_TRADE, MODE_MILITARY, MODE_TECH, MODE_SPY }; //static char secret_view_skill_array[] = { 40, 20, 30, 30, 50, 40, 90 }; #define SECRET_REPORT_COUNT 6 //static char* secret_report_str_array[] = { "Kingdoms", "Towns", "Economy", "Trade", "Military", "Technology" }; static char secret_view_mode_array[] = { MODE_NATION, MODE_TOWN, MODE_ECONOMY, MODE_TRADE, MODE_MILITARY, MODE_TECH }; static char secret_view_skill_array[] = { 40, 20, 30, 30, 50, 40 }; static ButtonCustomGroup button_secret_report_array(SECRET_REPORT_COUNT); static Button3D button_view_secret; static Button3D button_secret_report_cancel; // ---------- declare static function -------------// static void disp_text_button(ButtonCustom *, int); //--------- Begin of function SpyArray::SpyArray ----------// SpyArray::SpyArray() : DynArrayB(sizeof(Spy), 10) { } //--------- End of function SpyArray::SpyArary ----------// //------- Begin of function SpyArray::~SpyArray ----------// // SpyArray::~SpyArray() { deinit(); } //--------- End of function SpyArray::~SpyArray ----------// //--------- Begin of function SpyArray::init ----------// // void SpyArray::init() { } //---------- End of function SpyArray::init ----------// //--------- Begin of function SpyArray::deinit ----------// // void SpyArray::deinit() { if( size()==0 ) return; // ####### begin Gilbert 22/3 #######// //----- delete units ------// for( int i=1 ; i<=size() ; i++ ) { if( is_deleted(i) ) continue; del_spy(i); } // ####### end Gilbert 22/3 #######// //-------- zap the array -----------// zap(); } //---------- End of function SpyArray::deinit ----------// //--------- Begin of function SpyArray::add_spy ----------// // // <int> unitRecno - unit recno of the spy // <int> spySkill - spying skill of the unit // [int] trueNation - true nation recno (default -1:unit's nation) // // return: <int> recno of the spy record added // int SpyArray::add_spy(int unitRecno, int spySkill, int trueNation) { Spy spy; Unit* unitPtr = unit_array[unitRecno]; memset( &spy, 0, sizeof(spy) ); spy.spy_place = SPY_MOBILE; spy.spy_place_para = unitRecno; spy.spy_skill = spySkill; spy.spy_loyalty = unitPtr->loyalty; spy.race_id = unitPtr->race_id; spy.is_civilian = unitPtr->is_civilian(); spy.name_id = unitPtr->name_id; // ####### begin Gilbert 24/2 #######// spy.unique_id = unitPtr->unique_id; // ####### end Gilbert 24/2 #######// err_when( unitPtr->race_id < 1 || unitPtr->race_id > MAX_RACE ); err_when( nation_array.is_deleted(unitPtr->nation_recno) ); err_when( trueNation == 0 ); if( trueNation < 0 ) trueNation = unitPtr->nation_recno; spy.true_nation_recno = trueNation; spy.cloaked_nation_recno = unitPtr->nation_recno; //--- spies hold a use right of the name id even though the unit itself will register the usage right of the name already ---// race_res[spy.race_id]->use_name_id(spy.name_id); // the spy will free it up in deinit(). Keep an additional right because when a spy is assigned to a town, the normal program will free up the name id., so we have to keep an additional copy // ------- set camouflage vars --------// spy.camouflage_count = 0; spy.camouflage_power = spySkill / 4; //------- link in the spy_array -------// linkin( &spy ); ((Spy*)get())->spy_recno = recno(); return recno(); } //---------- End of function SpyArray::add_spy ----------// //--------- Begin of function SpyArray::add_spy ----------// // // This overloaded version of add_spy() just add a spy without // setting parameters of the Spy. // // return: <int> recno of the spy record added // int SpyArray::add_spy() { Spy spy; memset( &spy, 0, sizeof(spy) ); linkin( &spy ); ((Spy*)get())->spy_recno = recno(); return recno(); } //---------- End of function SpyArray::add_spy ----------// //--------- Begin of function SpyArray::del_spy ----------// // // <int> spyRecno - recno of the spy to be deleted // void SpyArray::del_spy(int spyRecno) { spy_array[spyRecno]->deinit(); linkout(spyRecno); } //---------- End of function SpyArray::del_spy ----------// //--------- Begin of function SpyArray::next_day ----------// // void SpyArray::next_day() { int spyCount = size(); Spy* spyPtr; for( int i=1 ; i<=spyCount ; i++ ) { if( spy_array.is_deleted(i) ) continue; spyPtr = spy_array[i]; spyPtr->next_day(); if( spy_array.is_deleted(i) ) continue; if( nation_array[spyPtr->true_nation_recno]->is_ai() ) spyPtr->process_ai(); } //---------- update Firm::sabotage_level ----------// if( info.game_date%15==0 ) process_sabotage(); } //---------- End of function SpyArray::next_day ----------// //--------- Begin of function SpyArray::find_town_spy ----------// // // Find a spy meeting the specific criteria // // <int> townRecno - town recno of the spy to find // <int> raceId - race id. of the spy to find // <int> spySeq - sequence id. of the spy in spy_array // // return: <int> recno of the spy found // int SpyArray::find_town_spy(int townRecno, int spySeq) { int spyCount=size(), matchCount=0; Spy* spyPtr; for( int i=1 ; i<=spyCount ; i++ ) { if( spy_array.is_deleted(i) ) continue; spyPtr = spy_array[i]; if( spyPtr->spy_place==SPY_TOWN && spyPtr->spy_place_para==townRecno ) { if( ++matchCount == spySeq ) return i; } } return 0; } //---------- End of function SpyArray::find_town_spy ----------// //--------- Begin of function SpyArray::process_sabotage ----------// // void SpyArray::process_sabotage() { /* Spy* spyPtr; Firm* firmPtr; //-------- reset firms' sabotage_level -------// for( int i=firm_array.size() ; i>0 ; i-- ) { if( firm_array.is_deleted(i) ) continue; firm_array[i]->sabotage_level = 0; } //------- increase firms' sabotage_level -----// for( i=spy_array.size() ; i>0 ; i-- ) { if( spy_array.is_deleted(i) ) continue; spyPtr = spy_array[i]; if( spyPtr->action_mode == SPY_SABOTAGE ) { err_when( spyPtr->spy_place != SPY_FIRM ); firmPtr = firm_array[spyPtr->spy_place_para]; firmPtr->sabotage_level += spyPtr->spy_skill/5; if( firmPtr->sabotage_level > 100 ) firmPtr->sabotage_level = 100; } } */ } //---------- End of function SpyArray::process_sabotage ----------// //--------- Begin of function SpyArray::mobilize_all_spy ----------// // // Mobilize all spies of the specific nation in the specific place. // // <int> spyPlace - place id. of the spy // <int> spyPlacePara - town or firm recno of the spy's staying // <int> nationRecno - recno of the nation which the spy should // be mobilized. // void SpyArray::mobilize_all_spy(int spyPlace, int spyPlacePara, int nationRecno) { Spy* spyPtr; for( int i=size() ; i>0 ; i-- ) { if( spy_array.is_deleted(i) ) continue; spyPtr = spy_array[i]; if( spyPtr->spy_place == spyPlace && spyPtr->spy_place_para == spyPlacePara && spyPtr->true_nation_recno == nationRecno ) { if( spyPtr->spy_place == SPY_TOWN ) spyPtr->mobilize_town_spy(); else if( spyPtr->spy_place == SPY_FIRM ) spyPtr->mobilize_firm_spy(); } } } //---------- End of function SpyArray::mobilize_all_spy ----------// //--------- Begin of function SpyArray::disp_view_secret_menu ---------// // void SpyArray::disp_view_secret_menu(int spyRecno, int refreshFlag) { // vga.active_buf->put_bitmap( INFO_X1, INFO_Y1, image_gameif.read("BLDGBASE") ); vga.active_buf->put_bitmap( INFO_X1, INFO_Y1, image_gameif.read("MISSBASE") ); //------------------------------------// // vga.d3_panel_up( INFO_X1, INFO_Y1, INFO_X2, INFO_Y1+42 ); // font_san.put_paragraph( INFO_X1+7, INFO_Y1+5, INFO_X2-7, INFO_Y2-5, // "Steal which type of secrets?" ); font_whbl.put_paragraph( INFO_X1+18, INFO_Y1+12, INFO_X2-14, INFO_Y1+72, text_firm.str_spy_steal_info() ); // "Which category of information do you wish to view?" ); //------------------------------------// int y=INFO_Y1+45; err_when( spy_array.is_deleted(spyRecno) ); Spy* spyPtr = spy_array[spyRecno]; int i; for( i=0 ; i<SECRET_REPORT_COUNT ; i++ ) { // button_secret_report_array[i].create( INFO_X1+18, y, INFO_X2-10, y+21, // disp_text_button, ButtonCustomPara( secret_report_str_array[i], i), 0 ); button_secret_report_array[i].create( INFO_X1+18, y, INFO_X2-10, y+21, disp_text_button, ButtonCustomPara( text_reports.str_report_mode(i+1), i), 0 ); button_secret_report_array[i].enable_flag = tech_res[TECH_INFO_THEFT]->get_nation_tech_level(spyPtr->true_nation_recno) && spyPtr->spy_skill >= secret_view_skill_array[i]; y+=23; } // push the first enabled button for( i = 0; i < SECRET_REPORT_COUNT; i++ ) { if( button_secret_report_array[i].enable_flag ) { button_secret_report_array.push(i, 0); break; } } button_secret_report_array.paint(); button_view_secret.create( INFO_X1+13, INFO_Y1+281, 'A', "VSECRET" ); button_secret_report_cancel.create( INFO_X1+13+3*BUTTON_DISTANCE, INFO_Y1+281, 'A', "PREVMENU" ); button_view_secret.enable_flag = button_secret_report_array[button_secret_report_array()].enable_flag; button_view_secret.paint(); button_secret_report_cancel.paint(); } //----------- End of function SpyArray::disp_view_secret_menu -----------// //--------- Begin of function SpyArray::detect_view_secret_menu ---------// // // <int> spyRecno - recno of the spy to view secret info. // <int> nationRecno - recno of the nation which this spy is going to investigate // int SpyArray::detect_view_secret_menu(int spyRecno, int nationRecno) { //---- detect secret report button ----// int rc=0; button_secret_report_array.detect(); if( button_view_secret.detect() ) { sys.set_view_mode( secret_view_mode_array[button_secret_report_array()], nationRecno, spyRecno ); rc=1; se_ctrl.immediate_sound("TURN_ON"); } //-------- detect cancel button --------// if( button_secret_report_cancel.detect() ) { rc = 1; se_ctrl.immediate_sound("TURN_OFF"); } return rc; } //----------- End of function SpyArray::detect_view_secret_menu -----------// //--------- Begin of function SpyArray::update_firm_spy_count ---------// // // Update the player_spy_count of this firm. This function is called // when the firm change its nation. // // <int> firmRecno - recno of the firm to be updated. // void SpyArray::update_firm_spy_count(int firmRecno) { //---- recalculate Firm::player_spy_count -----// Spy* spyPtr; Firm* firmPtr = firm_array[firmRecno]; if( firmPtr->cast_to_FirmCamp() ) { FirmCamp *firmCamp = firmPtr->cast_to_FirmCamp(); firmCamp->player_spy_count = 0; for( int i=spy_array.size() ; i>0 ; i-- ) { if( spy_array.is_deleted(i) ) continue; spyPtr = spy_array[i]; if( spyPtr->spy_place == SPY_FIRM && spyPtr->spy_place_para == firmRecno && spyPtr->true_nation_recno == nation_array.player_recno ) { firmCamp->player_spy_count++; } } } else if( firmPtr->cast_to_FirmTrain() ) { FirmTrain *firmTrain = firmPtr->cast_to_FirmTrain(); firmTrain->player_spy_count = 0; for( int i=spy_array.size() ; i>0 ; i-- ) { if( spy_array.is_deleted(i) ) continue; spyPtr = spy_array[i]; if( spyPtr->spy_place == SPY_FIRM && spyPtr->spy_place_para == firmRecno && spyPtr->true_nation_recno == nation_array.player_recno ) { firmTrain->player_spy_count++; } } } return; } //----------- End of function SpyArray::update_firm_spy_count -----------// //--------- Begin of function SpyArray::change_cloaked_nation ---------// // // Change the cloak of all the spies in the specific place. // // This function is called when a firm or town change nation. // // <int> spyPlace - spy place // <int> spyPlacePara - spy place para // <int> fromNationRecno - change any spies in the place whose cloaked_nation_recno // <int> toNationRecno is fromNationRecno to toNationRecno. // void SpyArray::change_cloaked_nation(int spyPlace, int spyPlacePara, int fromNationRecno, int toNationRecno) { Spy* spyPtr; for( int i=spy_array.size() ; i>0 ; i-- ) { if( spy_array.is_deleted(i) ) continue; spyPtr = spy_array[i]; if( spyPtr->cloaked_nation_recno != fromNationRecno ) continue; if( spyPtr->spy_place != spyPlace ) continue; //--- check if the spy is in the specific firm or town ---// if( spyPlace == SPY_FIRM || spyPlace == SPY_TOWN ) // only check spy_place_para when spyPlace is SPY_TOWN or SPY_FIRM { if( spyPtr->spy_place_para != spyPlacePara ) continue; } if(spyPlace==spyPtr->spy_place && spyPlacePara==spyPtr->spy_place_para && spyPtr->true_nation_recno==toNationRecno) spyPtr->set_action_mode(SPY_IDLE); //----- if the spy is associated with a unit (mobile or firm overseer), we call Unit::spy_chnage_nation() ---// if( spyPlace == SPY_FIRM ) { FirmCamp *firmCamp = firm_array[spyPtr->spy_place_para]->cast_to_FirmCamp(); if( firmCamp ) { int firmOverseerRecno = firmCamp->overseer_recno; if( firmOverseerRecno && unit_array[firmOverseerRecno]->spy_recno == i ) { unit_array[firmOverseerRecno]->spy_change_nation(toNationRecno, COMMAND_AUTO); continue; } } } else if( spyPlace == SPY_MOBILE ) { unit_array[spyPtr->spy_place_para]->spy_change_nation(toNationRecno, COMMAND_AUTO); continue; } //---- otherwise, just change the spy cloak ----// spyPtr->cloaked_nation_recno = toNationRecno; } } //----------- End of function SpyArray::change_cloaked_nation -----------// //--------- Begin of function SpyArray::total_spy_skill_level ---------// // // Calculate the combined skill levels of all the spies of the // specific nation in the specific place. // // <int> spyPlace - spy place // <int> spyPlacePara - spy place para // <int> spyNationRecno - nation recno // <int&> spyCount - the total no. of spies meeting the criteria. // int SpyArray::total_spy_skill_level(int spyPlace, int spyPlacePara, int spyNationRecno, int& spyCount) { int totalSpyLevel=0; Spy* spyPtr; spyCount = 0; for( int i=spy_array.size() ; i>0 ; i-- ) { if( spy_array.is_deleted(i) ) continue; spyPtr = spy_array[i]; if( spyPtr->true_nation_recno != spyNationRecno ) continue; if( spyPtr->spy_place != spyPlace ) continue; if( spyPtr->spy_place_para != spyPlacePara ) continue; spyCount++; totalSpyLevel += spyPtr->spy_skill; } return totalSpyLevel; } //----------- End of function SpyArray::total_spy_skill_level -----------// //-------- Begin of function SpyArray::catch_spy ------// // // <int> spyPlace - either SPY_TOWN or SPY_FIRM // <int> spyPlacePara - town_recno or firm_recno // int SpyArray::catch_spy(int spyPlace, int spyPlacePara) { int nationRecno, totalPop; if( spyPlace == SPY_TOWN ) { Town* townPtr = town_array[spyPlacePara]; nationRecno = townPtr->nation_recno; totalPop = townPtr->population; } else if( spyPlace == SPY_FIRM ) { Firm* firmPtr = firm_array[spyPlacePara]; nationRecno = firmPtr->nation_recno; if( firmPtr->cast_to_FirmCamp() ) { FirmCamp *firmCamp = firmPtr->cast_to_FirmCamp(); totalPop = firmCamp->soldier_count + (firmCamp->overseer_recno>0); } else if( firmPtr->cast_to_FirmWork() ) { FirmWork *firmWork = firmPtr->cast_to_FirmWork(); totalPop = firmWork->worker_count; } else if( firmPtr->cast_to_FirmTrain() ) { totalPop = firmPtr->cast_to_FirmTrain()->trainee_count; return 0; // don't catch spy } else if( firmPtr->cast_to_FirmInn() ) { totalPop = firmPtr->cast_to_FirmInn()->inn_unit_count; return 0; // don't catch spy } else if( firmPtr->cast_to_FirmMarket() ) { totalPop = 0; return 0; } else if( firmPtr->cast_to_FirmMonsterTrain() ) { totalPop = firmPtr->cast_to_FirmMonsterTrain()->trainee_count; return 0; // don't catch spy } else if( firmPtr->cast_to_FirmMonsterAlchemy() ) { totalPop = 0; return 0; } else if( firmPtr->cast_to_FirmLishorr() ) { totalPop = 0; return 0; } else if( firmPtr->cast_to_FirmMonsterFortress() ) { FirmMonsterFortress *firmMonsterFortress = firmPtr->cast_to_FirmMonsterFortress(); totalPop = firmMonsterFortress->archer_count + firmMonsterFortress->extra_builder_count; } else if( firmPtr->cast_to_FirmAnimal() ) { totalPop = 0; return 0; } else if( firmPtr->cast_to_FirmIncubator() ) { totalPop = 0; return 0; } else if( firmPtr->cast_to_FirmMagic() ) { totalPop = 0; return 0; } else if( firmPtr->cast_to_FirmOffensive() ) { totalPop = 0; return 0; } else if( firmPtr->cast_to_FirmOffensive2() ) { totalPop = 0; return 0; } else { err_here(); totalPop = 0; } } else err_here(); //--- calculate the total of anti-spy skill in this town ----// int enemySpyCount=0, counterSpySkill=0; Spy* spyPtr; int techLevel = 0; if( nationRecno ) techLevel = tech_res[TECH_COUNTER_SPY]->get_nation_tech_level(nationRecno); int i; for( i=size() ; i>0 ; i-- ) { if( is_deleted(i) ) continue; spyPtr = spy_array[i]; if( spyPtr->spy_place == spyPlace && spyPtr->spy_place_para == spyPlacePara ) { if( spyPtr->true_nation_recno == nationRecno ) counterSpySkill += spyPtr->spy_skill + spyPtr->spy_skill * techLevel / 2; else enemySpyCount++; } } //----- if all citizens are enemy spies ----// if( enemySpyCount == totalPop ) return 0; err_when( enemySpyCount > totalPop ); //-------- try to catch enemy spies now ------// for( i=spy_array.size() ; i>0 ; i-- ) { if( spy_array.is_deleted(i) ) continue; spyPtr = spy_array[i]; if( spyPtr->action_mode == SPY_IDLE ) // it is very hard to get caught in sleep mode continue; if( spyPtr->spy_place == spyPlace && spyPtr->spy_place_para == spyPlacePara && spyPtr->true_nation_recno != nationRecno ) // doesn't get caught in sleep mode { int escapeChance = 100 + spyPtr->spy_skill - counterSpySkill; escapeChance = max( spyPtr->spy_skill/10, escapeChance ); if( m.random(escapeChance) == 0 ) { spyPtr->get_killed(); // only catch one spy per calling return 1; } } } return 0; } //---------- End of function SpyArray::catch_spy --------// //--------- Begin of function SpyArray::set_action_mode ----------// // // Set all spies in the given place to the specific action mode. // void SpyArray::set_action_mode(int spyPlace, int spyPlacePara, int actionMode) { int spyCount=size(); Spy* spyPtr; for( int i=1 ; i<=spyCount ; i++ ) { if( spy_array.is_deleted(i) ) continue; spyPtr = spy_array[i]; if( spyPtr->spy_place==spyPlace && spyPtr->spy_place_para==spyPlacePara ) { spyPtr->set_action_mode(actionMode); } } } //---------- End of function SpyArray::set_action_mode ----------// //--------- Begin of function SpyArray::ai_spy_town_rebel ----------// // // Tell the AI spies in the town that a rebellion is happening. // // When a rebellion happens, all the AI spies in the town will mobilize // and turn its cloak back to a nation that is not at war with the enemy // (and notification flag should be off.) and move to a safe place // (near to one of your towns). Then the spy reaches thedestination, it will // become idle and then the AI processing function on idle spy will be // called and handle the spy. // // <int> townRecno - recno of the town with rebellion happening. // void SpyArray::ai_spy_town_rebel(int townRecno) { int spyCount=size(); Spy* spyPtr; for( int i=1 ; i<=spyCount ; i++ ) { if( spy_array.is_deleted(i) ) continue; spyPtr = spy_array[i]; if( spyPtr->spy_place==SPY_TOWN && spyPtr->spy_place_para==townRecno && nation_array[spyPtr->true_nation_recno]->is_ai() ) { //-------- mobilize the spy ----------// int unitRecno = spyPtr->mobilize_town_spy(); //----- think new action for the spy ------// if( unitRecno ) spyPtr->think_mobile_spy_new_action(); } } } //---------- End of function SpyArray::ai_spy_town_rebel ----------// //--------- Begin of function SpyArray::needed_view_secret_skill ----------// // int SpyArray::needed_view_secret_skill(int viewMode) { for( int i=0 ; i<SECRET_REPORT_COUNT ; i++ ) { if( secret_view_mode_array[i] == viewMode ) return secret_view_skill_array[i]; } return 0; } //---------- End of function SpyArray::needed_view_secret_skill ----------// #ifdef DEBUG //------- Begin of function SpyArray::operator[] -----// Spy* SpyArray::operator[](int recNo) { Spy* spyPtr = (Spy*) get(recNo); if( !spyPtr || spyPtr->spy_recno==0 ) err.run( "SpyArray[] is deleted" ); return spyPtr; } //--------- End of function SpyArray::operator[] ----// #endif static void disp_text_button(ButtonCustom *button, int) { int x1 = button->x1; int y1 = button->y1; int x2 = button->x2; int y2 = button->y2; // modify x1,y1, x2,y2 to the button body if( button->pushed_flag ) { vga.active_buf->d3_panel_down(x1, y1, x2, y2); x1++; y1++; } else { vga.active_buf->d3_panel_up(x1, y1, x2, y2); x2--; y2--; } // put name font_bld.center_put(x1, y1, x2, y2, (char *)button->custom_para.ptr ); if( !button->enable_flag ) { vga.active_buf->bar_alpha(x1+3, y1+3, x2-3, y2-3, 1, 0); } }
mecirt/7k2
src/ospya.cpp
C++
gpl-2.0
22,900
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only version 2 as published by the Free Software Foundation. * * 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. * */ #ifndef MDSS_DSI_H #define MDSS_DSI_H #include <linux/list.h> #include <linux/mdss_io_util.h> #include <mach/scm-io.h> #include <linux/irqreturn.h> #include <linux/pinctrl/consumer.h> #include "mdss_panel.h" #include "mdss_dsi_cmd.h" #define MMSS_SERDES_BASE_PHY 0x04f01000 /* mmss (De)Serializer CFG */ #define MIPI_OUTP(addr, data) writel_relaxed((data), (addr)) #define MIPI_INP(addr) readl_relaxed(addr) #define MIPI_OUTP_SECURE(addr, data) writel_relaxed((data), (addr)) #define MIPI_INP_SECURE(addr) readl_relaxed(addr) #define MIPI_DSI_PRIM 1 #define MIPI_DSI_SECD 2 #define MIPI_DSI_PANEL_VGA 0 #define MIPI_DSI_PANEL_WVGA 1 #define MIPI_DSI_PANEL_WVGA_PT 2 #define MIPI_DSI_PANEL_FWVGA_PT 3 #define MIPI_DSI_PANEL_WSVGA_PT 4 #define MIPI_DSI_PANEL_QHD_PT 5 #define MIPI_DSI_PANEL_WXGA 6 #define MIPI_DSI_PANEL_WUXGA 7 #define MIPI_DSI_PANEL_720P_PT 8 #define DSI_PANEL_MAX 8 enum { /* mipi dsi panel */ DSI_VIDEO_MODE, DSI_CMD_MODE, }; enum { ST_DSI_CLK_OFF, ST_DSI_SUSPEND, ST_DSI_RESUME, ST_DSI_PLAYING, ST_DSI_NUM }; enum { EV_DSI_UPDATE, EV_DSI_DONE, EV_DSI_TOUT, EV_DSI_NUM }; enum { LANDSCAPE = 1, PORTRAIT = 2, }; enum dsi_trigger_type { DSI_CMD_MODE_DMA, DSI_CMD_MODE_MDP, }; enum dsi_panel_bl_ctrl { BL_PWM, BL_WLED, BL_DCS_CMD, UNKNOWN_CTRL, }; enum dsi_panel_status_mode { ESD_BTA, ESD_REG, ESD_REG_ZTE, ESD_MAX, }; enum dsi_ctrl_op_mode { DSI_LP_MODE, DSI_HS_MODE, }; enum dsi_lane_map_type { DSI_LANE_MAP_0123, DSI_LANE_MAP_3012, DSI_LANE_MAP_2301, DSI_LANE_MAP_1230, DSI_LANE_MAP_0321, DSI_LANE_MAP_1032, DSI_LANE_MAP_2103, DSI_LANE_MAP_3210, }; enum dsi_pm_type { DSI_CORE_PM, DSI_CTRL_PM, DSI_PANEL_PM, DSI_MAX_PM }; #define CTRL_STATE_UNKNOWN 0x00 #define CTRL_STATE_PANEL_INIT BIT(0) #define CTRL_STATE_MDP_ACTIVE BIT(1) #define DSI_NON_BURST_SYNCH_PULSE 0 #define DSI_NON_BURST_SYNCH_EVENT 1 #define DSI_BURST_MODE 2 #define DSI_RGB_SWAP_RGB 0 #define DSI_RGB_SWAP_RBG 1 #define DSI_RGB_SWAP_BGR 2 #define DSI_RGB_SWAP_BRG 3 #define DSI_RGB_SWAP_GRB 4 #define DSI_RGB_SWAP_GBR 5 #define DSI_VIDEO_DST_FORMAT_RGB565 0 #define DSI_VIDEO_DST_FORMAT_RGB666 1 #define DSI_VIDEO_DST_FORMAT_RGB666_LOOSE 2 #define DSI_VIDEO_DST_FORMAT_RGB888 3 #define DSI_CMD_DST_FORMAT_RGB111 0 #define DSI_CMD_DST_FORMAT_RGB332 3 #define DSI_CMD_DST_FORMAT_RGB444 4 #define DSI_CMD_DST_FORMAT_RGB565 6 #define DSI_CMD_DST_FORMAT_RGB666 7 #define DSI_CMD_DST_FORMAT_RGB888 8 #define DSI_INTR_ERROR_MASK BIT(25) #define DSI_INTR_ERROR BIT(24) #define DSI_INTR_BTA_DONE_MASK BIT(21) #define DSI_INTR_BTA_DONE BIT(20) #define DSI_INTR_VIDEO_DONE_MASK BIT(17) #define DSI_INTR_VIDEO_DONE BIT(16) #define DSI_INTR_CMD_MDP_DONE_MASK BIT(9) #define DSI_INTR_CMD_MDP_DONE BIT(8) #define DSI_INTR_CMD_DMA_DONE_MASK BIT(1) #define DSI_INTR_CMD_DMA_DONE BIT(0) #define DSI_CMD_TRIGGER_NONE 0x0 /* mdp trigger */ #define DSI_CMD_TRIGGER_TE 0x02 #define DSI_CMD_TRIGGER_SW 0x04 #define DSI_CMD_TRIGGER_SW_SEOF 0x05 /* cmd dma only */ #define DSI_CMD_TRIGGER_SW_TE 0x06 #define DSI_VIDEO_TERM BIT(16) #define DSI_MDP_TERM BIT(8) #define DSI_BTA_TERM BIT(1) #define DSI_CMD_TERM BIT(0) extern struct device dsi_dev; extern u32 dsi_irq; extern struct mdss_dsi_ctrl_pdata *ctrl_list[]; struct dsiphy_pll_divider_config { u32 clk_rate; u32 fb_divider; u32 ref_divider_ratio; u32 bit_clk_divider; /* oCLK1 */ u32 byte_clk_divider; /* oCLK2 */ u32 analog_posDiv; u32 digital_posDiv; }; extern struct dsiphy_pll_divider_config pll_divider_config; struct dsi_clk_mnd_table { u8 lanes; u8 bpp; u8 pll_digital_posDiv; u8 pclk_m; u8 pclk_n; u8 pclk_d; }; static const struct dsi_clk_mnd_table mnd_table[] = { { 1, 2, 8, 1, 1, 0}, { 1, 3, 12, 1, 1, 0}, { 2, 2, 4, 1, 1, 0}, { 2, 3, 6, 1, 1, 0}, { 3, 2, 1, 3, 8, 4}, { 3, 3, 4, 1, 1, 0}, { 4, 2, 2, 1, 1, 0}, { 4, 3, 3, 1, 1, 0}, }; struct dsi_clk_desc { u32 src; u32 m; u32 n; u32 d; u32 mnd_mode; u32 pre_div_func; }; struct dsi_panel_cmds { char *buf; int blen; struct dsi_cmd_desc *cmds; int cmd_cnt; int link_state; }; struct dsi_kickoff_action { struct list_head act_entry; void (*action) (void *); void *data; }; struct dsi_drv_cm_data { struct regulator *vdd_vreg; struct regulator *vdd_io_vreg; struct regulator *vdda_vreg; int broadcast_enable; }; struct panel_horizontal_idle { int min; int max; int idle; }; struct dsi_pinctrl_res { struct pinctrl *pinctrl; struct pinctrl_state *gpio_state_active; struct pinctrl_state *gpio_state_suspend; }; enum { DSI_CTRL_0, DSI_CTRL_1, DSI_CTRL_MAX, }; #define DSI_CTRL_LEFT DSI_CTRL_0 #define DSI_CTRL_RIGHT DSI_CTRL_1 /* DSI controller #0 is always treated as a master in broadcast mode */ #define DSI_CTRL_MASTER DSI_CTRL_0 #define DSI_CTRL_SLAVE DSI_CTRL_1 #define DSI_BUS_CLKS BIT(0) #define DSI_LINK_CLKS BIT(1) #define DSI_ALL_CLKS ((DSI_BUS_CLKS) | (DSI_LINK_CLKS)) #define DSI_EV_PLL_UNLOCKED 0x0001 #define DSI_EV_MDP_FIFO_UNDERFLOW 0x0002 #define DSI_EV_MDP_BUSY_RELEASE 0x80000000 struct mdss_dsi_ctrl_pdata { int ndx; /* panel_num */ //#if defined(CONFIG_ZTEMT_LCD_ESD_TE_CHECK) char *panel_name; //#endif int (*on) (struct mdss_panel_data *pdata); int (*off) (struct mdss_panel_data *pdata); int (*set_col_page_addr) (struct mdss_panel_data *pdata); int (*check_status) (struct mdss_dsi_ctrl_pdata *pdata); int (*cmdlist_commit)(struct mdss_dsi_ctrl_pdata *ctrl, int from_mdp); void (*switch_mode) (struct mdss_panel_data *pdata, int mode); struct mdss_panel_data panel_data; unsigned char *ctrl_base; struct dss_io_data ctrl_io; struct dss_io_data mmss_misc_io; struct dss_io_data phy_io; int reg_size; u32 bus_clk_cnt; u32 link_clk_cnt; u32 flags; struct clk *mdp_core_clk; struct clk *ahb_clk; struct clk *axi_clk; struct clk *mmss_misc_ahb_clk; struct clk *byte_clk; struct clk *esc_clk; struct clk *pixel_clk; u8 ctrl_state; int panel_mode; int irq_cnt; int rst_gpio; int disp_en_gpio; #ifdef CONFIG_ZTEMT_LCD_ESD_TE_CHECK int lcd_te_irq; #endif int bklt_en_gpio; int disp_te_gpio; int mode_gpio; int bklt_ctrl; /* backlight ctrl */ int pwm_period; int pwm_pmic_gpio; int pwm_lpg_chan; int bklt_max; int new_fps; int pwm_enabled; struct mdss_rect roi; struct pwm_device *pwm_bl; struct dsi_drv_cm_data shared_pdata; u32 pclk_rate; u32 byte_clk_rate; struct dss_module_power power_data[DSI_MAX_PM]; u32 dsi_irq_mask; struct mdss_hw *dsi_hw; struct mdss_panel_recovery *recovery; struct dsi_panel_cmds on_cmds; struct dsi_panel_cmds off_cmds; struct dsi_panel_cmds status_cmds; u32 status_value; struct dsi_panel_cmds video2cmd; struct dsi_panel_cmds cmd2video; #if defined(CONFIG_ZTEMT_LCD_ESD_TE_CHECK) struct dsi_panel_cmds on_cmds_esd; #endif struct dcs_cmd_list cmdlist; struct completion dma_comp; struct completion mdp_comp; struct completion video_comp; struct completion bta_comp; spinlock_t irq_lock; spinlock_t mdp_lock; int mdp_busy; struct mutex mutex; struct mutex cmd_mutex; bool ulps; struct dsi_buf tx_buf; struct dsi_buf rx_buf; int horizontal_idle_cnt; struct panel_horizontal_idle *line_idle; struct dsi_buf status_buf; int status_mode; struct dsi_pinctrl_res pin_res; }; struct dsi_status_data { struct notifier_block fb_notifier; struct delayed_work check_status; struct msm_fb_data_type *mfd; }; int dsi_panel_device_register(struct device_node *pan_node, struct mdss_dsi_ctrl_pdata *ctrl_pdata); int mdss_dsi_cmds_tx(struct mdss_dsi_ctrl_pdata *ctrl, struct dsi_cmd_desc *cmds, int cnt); int mdss_dsi_cmds_rx(struct mdss_dsi_ctrl_pdata *ctrl, struct dsi_cmd_desc *cmds, int rlen); void mdss_dsi_host_init(struct mdss_panel_data *pdata); void mdss_dsi_op_mode_config(int mode, struct mdss_panel_data *pdata); void mdss_dsi_cmd_mode_ctrl(int enable); void mdp4_dsi_cmd_trigger(void); void mdss_dsi_cmd_mdp_start(struct mdss_dsi_ctrl_pdata *ctrl); void mdss_dsi_cmd_bta_sw_trigger(struct mdss_panel_data *pdata); void mdss_dsi_ack_err_status(struct mdss_dsi_ctrl_pdata *ctrl); int mdss_dsi_clk_ctrl(struct mdss_dsi_ctrl_pdata *ctrl, u8 clk_type, int enable); void mdss_dsi_clk_req(struct mdss_dsi_ctrl_pdata *ctrl, int enable); void mdss_dsi_controller_cfg(int enable, struct mdss_panel_data *pdata); void mdss_dsi_sw_reset(struct mdss_panel_data *pdata); irqreturn_t mdss_dsi_isr(int irq, void *ptr); void mdss_dsi_irq_handler_config(struct mdss_dsi_ctrl_pdata *ctrl_pdata); void mdss_dsi_set_tx_power_mode(int mode, struct mdss_panel_data *pdata); int mdss_dsi_clk_div_config(struct mdss_panel_info *panel_info, int frame_rate); int mdss_dsi_clk_init(struct platform_device *pdev, struct mdss_dsi_ctrl_pdata *ctrl_pdata); void mdss_dsi_clk_deinit(struct mdss_dsi_ctrl_pdata *ctrl_pdata); int mdss_dsi_enable_bus_clocks(struct mdss_dsi_ctrl_pdata *ctrl_pdata); void mdss_dsi_disable_bus_clocks(struct mdss_dsi_ctrl_pdata *ctrl_pdata); int mdss_dsi_panel_reset(struct mdss_panel_data *pdata, int enable); void mdss_dsi_phy_disable(struct mdss_dsi_ctrl_pdata *ctrl); void mdss_dsi_phy_init(struct mdss_panel_data *pdata); void mdss_dsi_phy_sw_reset(unsigned char *ctrl_base); void mdss_dsi_cmd_test_pattern(struct mdss_dsi_ctrl_pdata *ctrl); void mdss_dsi_video_test_pattern(struct mdss_dsi_ctrl_pdata *ctrl); void mdss_dsi_panel_pwm_cfg(struct mdss_dsi_ctrl_pdata *ctrl); void mdss_dsi_ctrl_init(struct mdss_dsi_ctrl_pdata *ctrl); void mdss_dsi_cmd_mdp_busy(struct mdss_dsi_ctrl_pdata *ctrl); void mdss_dsi_wait4video_done(struct mdss_dsi_ctrl_pdata *ctrl); int mdss_dsi_cmdlist_commit(struct mdss_dsi_ctrl_pdata *ctrl, int from_mdp); void mdss_dsi_cmdlist_kickoff(int intf); int mdss_dsi_bta_status_check(struct mdss_dsi_ctrl_pdata *ctrl); int mdss_dsi_reg_status_check(struct mdss_dsi_ctrl_pdata *ctrl); bool __mdss_dsi_clk_enabled(struct mdss_dsi_ctrl_pdata *ctrl, u8 clk_type); int mdss_dsi_ulps_config(struct mdss_dsi_ctrl_pdata *ctrl, int enable); int mdss_dsi_panel_init(struct device_node *node, struct mdss_dsi_ctrl_pdata *ctrl_pdata, bool cmd_cfg_cont_splash); int mdss_panel_get_dst_fmt(u32 bpp, char mipi_mode, u32 pixel_packing, char *dst_format); //+++ #ifdef CONFIG_ZTEMT_LCD_ESD_TE_CHECK int mipi_lcd_esd_command(struct mdss_dsi_ctrl_pdata *ctrl_pdata); #endif //--- static inline const char *__mdss_dsi_pm_name(enum dsi_pm_type module) { switch (module) { case DSI_CORE_PM: return "DSI_CORE_PM"; case DSI_CTRL_PM: return "DSI_CTRL_PM"; case DSI_PANEL_PM: return "PANEL_PM"; default: return "???"; } } static inline const char *__mdss_dsi_pm_supply_node_name( enum dsi_pm_type module) { switch (module) { case DSI_CORE_PM: return "qcom,core-supply-entries"; case DSI_CTRL_PM: return "qcom,ctrl-supply-entries"; case DSI_PANEL_PM: return "qcom,panel-supply-entries"; default: return "???"; } } static inline bool mdss_dsi_broadcast_mode_enabled(void) { return ctrl_list[DSI_CTRL_MASTER]->shared_pdata.broadcast_enable && ctrl_list[DSI_CTRL_SLAVE] && ctrl_list[DSI_CTRL_SLAVE]->shared_pdata.broadcast_enable; } static inline struct mdss_dsi_ctrl_pdata *mdss_dsi_get_master_ctrl(void) { if (mdss_dsi_broadcast_mode_enabled()) return ctrl_list[DSI_CTRL_MASTER]; else return NULL; } static inline struct mdss_dsi_ctrl_pdata *mdss_dsi_get_slave_ctrl(void) { if (mdss_dsi_broadcast_mode_enabled()) return ctrl_list[DSI_CTRL_SLAVE]; else return NULL; } static inline bool mdss_dsi_is_master_ctrl(struct mdss_dsi_ctrl_pdata *ctrl) { return mdss_dsi_broadcast_mode_enabled() && (ctrl->ndx == DSI_CTRL_MASTER); } static inline bool mdss_dsi_is_slave_ctrl(struct mdss_dsi_ctrl_pdata *ctrl) { return mdss_dsi_broadcast_mode_enabled() && (ctrl->ndx == DSI_CTRL_SLAVE); } static inline struct mdss_dsi_ctrl_pdata *mdss_dsi_get_ctrl_by_index(int ndx) { if (ndx >= DSI_CTRL_MAX) return NULL; return ctrl_list[ndx]; } static inline bool mdss_dsi_ulps_feature_enabled( struct mdss_panel_data *pdata) { return pdata->panel_info.ulps_feature_enabled; } #endif /* MDSS_DSI_H */
Dazzworld/android_kernel_zte_hn8916
drivers/video/msm/mdss/mdss_dsi.h
C
gpl-2.0
12,637
# CMAKE generated file: DO NOT EDIT! # Generated by "Unix Makefiles" Generator, CMake Version 2.8 # Default target executed when no arguments are given to make. default_target: all .PHONY : default_target #============================================================================= # Special targets provided by cmake. # Disable implicit rules so canoncical targets will work. .SUFFIXES: # Remove some rules from gmake that .SUFFIXES does not remove. SUFFIXES = .SUFFIXES: .hpux_make_needs_suffix_list # Suppress display of executed commands. $(VERBOSE).SILENT: # A target that is always out of date. cmake_force: .PHONY : cmake_force #============================================================================= # Set environment variables for the build. # The shell in which to execute make rules. SHELL = /bin/sh # The CMake executable. CMAKE_COMMAND = /usr/bin/cmake # The command to remove a file. RM = /usr/bin/cmake -E remove -f # The top-level source directory on which CMake was run. CMAKE_SOURCE_DIR = /opt/stellarium-0.11.4 # The top-level build directory on which CMake was run. CMAKE_BINARY_DIR = /opt/stellarium-0.11.4 #============================================================================= # Targets provided globally by CMake. # Special rule for the target edit_cache edit_cache: @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running interactive CMake command-line interface..." /usr/bin/cmake -i . .PHONY : edit_cache # Special rule for the target edit_cache edit_cache/fast: edit_cache .PHONY : edit_cache/fast # Special rule for the target install install: preinstall @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." /usr/bin/cmake -P cmake_install.cmake .PHONY : install # Special rule for the target install install/fast: preinstall/fast @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." /usr/bin/cmake -P cmake_install.cmake .PHONY : install/fast # Special rule for the target install/local install/local: preinstall @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..." /usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake .PHONY : install/local # Special rule for the target install/local install/local/fast: install/local .PHONY : install/local/fast # Special rule for the target install/strip install/strip: preinstall @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..." /usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake .PHONY : install/strip # Special rule for the target install/strip install/strip/fast: install/strip .PHONY : install/strip/fast # Special rule for the target list_install_components list_install_components: @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\"" .PHONY : list_install_components # Special rule for the target list_install_components list_install_components/fast: list_install_components .PHONY : list_install_components/fast # Special rule for the target package package: preinstall @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Run CPack packaging tool..." cd /opt/stellarium-0.11.4 && /usr/bin/cpack --config ./CPackConfig.cmake .PHONY : package # Special rule for the target package package/fast: package .PHONY : package/fast # Special rule for the target package_source package_source: @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Run CPack packaging tool for source..." cd /opt/stellarium-0.11.4 && /usr/bin/cpack --config ./CPackSourceConfig.cmake /opt/stellarium-0.11.4/CPackSourceConfig.cmake .PHONY : package_source # Special rule for the target package_source package_source/fast: package_source .PHONY : package_source/fast # Special rule for the target rebuild_cache rebuild_cache: @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) .PHONY : rebuild_cache # Special rule for the target rebuild_cache rebuild_cache/fast: rebuild_cache .PHONY : rebuild_cache/fast # The main all target all: cmake_check_build_system cd /opt/stellarium-0.11.4 && $(CMAKE_COMMAND) -E cmake_progress_start /opt/stellarium-0.11.4/CMakeFiles /opt/stellarium-0.11.4/skycultures/aztec/CMakeFiles/progress.marks cd /opt/stellarium-0.11.4 && $(MAKE) -f CMakeFiles/Makefile2 skycultures/aztec/all $(CMAKE_COMMAND) -E cmake_progress_start /opt/stellarium-0.11.4/CMakeFiles 0 .PHONY : all # The main clean target clean: cd /opt/stellarium-0.11.4 && $(MAKE) -f CMakeFiles/Makefile2 skycultures/aztec/clean .PHONY : clean # The main clean target clean/fast: clean .PHONY : clean/fast # Prepare targets for installation. preinstall: all cd /opt/stellarium-0.11.4 && $(MAKE) -f CMakeFiles/Makefile2 skycultures/aztec/preinstall .PHONY : preinstall # Prepare targets for installation. preinstall/fast: cd /opt/stellarium-0.11.4 && $(MAKE) -f CMakeFiles/Makefile2 skycultures/aztec/preinstall .PHONY : preinstall/fast # clear depends depend: cd /opt/stellarium-0.11.4 && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 .PHONY : depend # Help Target help: @echo "The following are some of the valid targets for this Makefile:" @echo "... all (the default if no target is provided)" @echo "... clean" @echo "... depend" @echo "... edit_cache" @echo "... install" @echo "... install/local" @echo "... install/strip" @echo "... list_install_components" @echo "... package" @echo "... package_source" @echo "... rebuild_cache" .PHONY : help #============================================================================= # Special targets to cleanup operation of make. # Special rule to run CMake to check the build system integrity. # No rule that depends on this can have commands that come from listfiles # because they might be regenerated. cmake_check_build_system: cd /opt/stellarium-0.11.4 && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 .PHONY : cmake_check_build_system
ammarshadiq/stellarium-0.11.4
skycultures/aztec/Makefile
Makefile
gpl-2.0
6,265
/* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved. * * This file is part of the device-mapper userspace tools. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU Lesser General Public License v.2.1. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "dmlib.h" #include "libdm-targets.h" #include "libdm-common.h" #include "kdev_t.h" #include "dm-ioctl.h" #include <stdarg.h> #include <sys/param.h> #include <sys/ioctl.h> #include <fcntl.h> #include <dirent.h> #ifdef UDEV_SYNC_SUPPORT # include <sys/types.h> # include <sys/ipc.h> # include <sys/sem.h> # include <libudev.h> #endif #ifdef linux # include <linux/fs.h> #endif #ifdef HAVE_SELINUX # include <selinux/selinux.h> #endif #ifdef HAVE_SELINUX_LABEL_H # include <selinux/label.h> #endif #define DM_DEFAULT_NAME_MANGLING_MODE_ENV_VAR_NAME "DM_DEFAULT_NAME_MANGLING_MODE" #define DEV_DIR "/dev/" #ifdef UDEV_SYNC_SUPPORT #ifdef _SEM_SEMUN_UNDEFINED union semun { int val; /* value for SETVAL */ struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */ unsigned short int *array; /* array for GETALL & SETALL */ struct seminfo *__buf; /* buffer for IPC_INFO */ }; #endif #endif static char _dm_dir[PATH_MAX] = DEV_DIR DM_DIR; static char _sysfs_dir[PATH_MAX] = "/sys/"; static char _path0[PATH_MAX]; /* path buffer, safe 4kB on stack */ static const char _mountinfo[] = "/proc/self/mountinfo"; #define DM_MAX_UUID_PREFIX_LEN 15 static char _default_uuid_prefix[DM_MAX_UUID_PREFIX_LEN + 1] = "LVM-"; static int _verbose = 0; static int _suspended_dev_counter = 0; static dm_string_mangling_t _name_mangling_mode = DEFAULT_DM_NAME_MANGLING; #ifdef HAVE_SELINUX_LABEL_H static struct selabel_handle *_selabel_handle = NULL; #endif static int _udev_disabled = 0; #ifdef UDEV_SYNC_SUPPORT static int _semaphore_supported = -1; static int _udev_running = -1; static int _sync_with_udev = 1; static int _udev_checking = 1; #endif void dm_lib_init(void) { const char *env; if (getenv("DM_DISABLE_UDEV")) _udev_disabled = 1; env = getenv(DM_DEFAULT_NAME_MANGLING_MODE_ENV_VAR_NAME); if (env && *env) { if (!strcasecmp(env, "none")) _name_mangling_mode = DM_STRING_MANGLING_NONE; else if (!strcasecmp(env, "auto")) _name_mangling_mode = DM_STRING_MANGLING_AUTO; else if (!strcasecmp(env, "hex")) _name_mangling_mode = DM_STRING_MANGLING_HEX; } else _name_mangling_mode = DEFAULT_DM_NAME_MANGLING; } /* * Library users can provide their own logging * function. */ __attribute__((format(printf, 5, 0))) static void _default_log_line(int level, const char *file __attribute__((unused)), int line __attribute__((unused)), int dm_errno_or_class, const char *f, va_list ap) { int use_stderr = level & _LOG_STDERR; level &= ~_LOG_STDERR; if (level > _LOG_WARN && !_verbose) return; if (level < _LOG_WARN) vfprintf(stderr, f, ap); else vfprintf(use_stderr ? stderr : stdout, f, ap); if (level < _LOG_WARN) fprintf(stderr, "\n"); else fprintf(use_stderr ? stderr : stdout, "\n"); } __attribute__((format(printf, 5, 6))) static void _default_log_with_errno(int level, const char *file __attribute__((unused)), int line __attribute__((unused)), int dm_errno_or_class, const char *f, ...) { va_list ap; va_start(ap, f); _default_log_line(level, file, line, dm_errno_or_class, f, ap); va_end(ap); } __attribute__((format(printf, 4, 5))) static void _default_log(int level, const char *file, int line, const char *f, ...) { va_list ap; va_start(ap, f); _default_log_line(level, file, line, 0, f, ap); va_end(ap); } dm_log_fn dm_log = _default_log; dm_log_with_errno_fn dm_log_with_errno = _default_log_with_errno; void dm_log_init(dm_log_fn fn) { if (fn) dm_log = fn; else dm_log = _default_log; dm_log_with_errno = _default_log_with_errno; } int dm_log_is_non_default(void) { return (dm_log == _default_log) ? 0 : 1; } void dm_log_with_errno_init(dm_log_with_errno_fn fn) { if (fn) dm_log_with_errno = fn; else dm_log_with_errno = _default_log_with_errno; dm_log = _default_log; } void dm_log_init_verbose(int level) { _verbose = level; } static void _build_dev_path(char *buffer, size_t len, const char *dev_name) { /* If there's a /, assume caller knows what they're doing */ if (strchr(dev_name, '/')) snprintf(buffer, len, "%s", dev_name); else snprintf(buffer, len, "%s/%s", _dm_dir, dev_name); } int dm_get_library_version(char *version, size_t size) { strncpy(version, DM_LIB_VERSION, size); return 1; } void inc_suspended(void) { _suspended_dev_counter++; log_debug_activation("Suspended device counter increased to %d", _suspended_dev_counter); } void dec_suspended(void) { if (!_suspended_dev_counter) { log_error("Attempted to decrement suspended device counter below zero."); return; } _suspended_dev_counter--; log_debug_activation("Suspended device counter reduced to %d", _suspended_dev_counter); } int dm_get_suspended_counter(void) { return _suspended_dev_counter; } int dm_set_name_mangling_mode(dm_string_mangling_t name_mangling_mode) { _name_mangling_mode = name_mangling_mode; return 1; } dm_string_mangling_t dm_get_name_mangling_mode(void) { return _name_mangling_mode; } struct dm_task *dm_task_create(int type) { struct dm_task *dmt = dm_zalloc(sizeof(*dmt)); if (!dmt) { log_error("dm_task_create: malloc(%" PRIsize_t ") failed", sizeof(*dmt)); return NULL; } if (!dm_check_version()) { dm_free(dmt); return_NULL; } dmt->type = type; dmt->minor = -1; dmt->major = -1; dmt->allow_default_major_fallback = 1; dmt->uid = DM_DEVICE_UID; dmt->gid = DM_DEVICE_GID; dmt->mode = DM_DEVICE_MODE; dmt->no_open_count = 0; dmt->read_ahead = DM_READ_AHEAD_AUTO; dmt->read_ahead_flags = 0; dmt->event_nr = 0; dmt->cookie_set = 0; dmt->query_inactive_table = 0; dmt->new_uuid = 0; dmt->secure_data = 0; return dmt; } /* * Find the name associated with a given device number by scanning _dm_dir. */ static int _find_dm_name_of_device(dev_t st_rdev, char *buf, size_t buf_len) { const char *name; char path[PATH_MAX]; struct dirent *dirent; DIR *d; struct stat st; int r = 0; if (!(d = opendir(_dm_dir))) { log_sys_error("opendir", _dm_dir); return 0; } while ((dirent = readdir(d))) { name = dirent->d_name; if (!strcmp(name, ".") || !strcmp(name, "..")) continue; if (dm_snprintf(path, sizeof(path), "%s/%s", _dm_dir, name) == -1) { log_error("Couldn't create path for %s", name); continue; } if (stat(path, &st)) continue; if (st.st_rdev == st_rdev) { strncpy(buf, name, buf_len); r = 1; break; } } if (closedir(d)) log_sys_error("closedir", _dm_dir); return r; } static int _is_whitelisted_char(char c) { /* * Actually, DM supports any character in a device name. * This whitelist is just for proper integration with udev. */ if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || strchr("#+-.:=@_", c) != NULL) return 1; return 0; } int check_multiple_mangled_string_allowed(const char *str, const char *str_name, dm_string_mangling_t mode) { if (mode == DM_STRING_MANGLING_AUTO && strstr(str, "\\x5cx")) { log_error("The %s \"%s\" seems to be mangled more than once. " "This is not allowed in auto mode.", str_name, str); return 0; } return 1; } /* * Mangle all characters in the input string which are not on a whitelist * with '\xNN' format where NN is the hex value of the character. */ int mangle_string(const char *str, const char *str_name, size_t len, char *buf, size_t buf_len, dm_string_mangling_t mode) { int need_mangling = -1; /* -1 don't know yet, 0 no, 1 yes */ size_t i, j; if (!str || !buf) return -1; /* Is there anything to do at all? */ if (!*str || !len) return 0; if (buf_len < DM_NAME_LEN) { log_error(INTERNAL_ERROR "mangle_string: supplied buffer too small"); return -1; } if (mode == DM_STRING_MANGLING_NONE) mode = DM_STRING_MANGLING_AUTO; for (i = 0, j = 0; str[i]; i++) { if (mode == DM_STRING_MANGLING_AUTO) { /* * Detect already mangled part of the string and keep it. * Return error on mixture of mangled/not mangled! */ if (str[i] == '\\' && str[i+1] == 'x') { if ((len - i < 4) || (need_mangling == 1)) goto bad1; if (buf_len - j < 4) goto bad2; memcpy(&buf[j], &str[i], 4); i+=3; j+=4; need_mangling = 0; continue; } } if (_is_whitelisted_char(str[i])) { /* whitelisted, keep it. */ if (buf_len - j < 1) goto bad2; buf[j] = str[i]; j++; } else { /* * Not on a whitelist, mangle it. * Return error on mixture of mangled/not mangled * unless a DM_STRING_MANGLING_HEX is used!. */ if ((mode != DM_STRING_MANGLING_HEX) && (need_mangling == 0)) goto bad1; if (buf_len - j < 4) goto bad2; sprintf(&buf[j], "\\x%02x", (unsigned char) str[i]); j+=4; need_mangling = 1; } } if (buf_len - j < 1) goto bad2; buf[j] = '\0'; /* All chars in the string whitelisted? */ if (need_mangling == -1) need_mangling = 0; return need_mangling; bad1: log_error("The %s \"%s\" contains mixed mangled and unmangled " "characters or it's already mangled improperly.", str_name, str); return -1; bad2: log_error("Mangled form of the %s too long for \"%s\".", str_name, str); return -1; } /* * Try to unmangle supplied string. * Return value: -1 on error, 0 when no unmangling needed, 1 when unmangling applied */ int unmangle_string(const char *str, const char *str_name, size_t len, char *buf, size_t buf_len, dm_string_mangling_t mode) { int strict = mode != DM_STRING_MANGLING_NONE; char str_rest[DM_NAME_LEN]; size_t i, j; int code; int r = 0; if (!str || !buf) return -1; /* Is there anything to do at all? */ if (!*str || !len) return 0; if (buf_len < DM_NAME_LEN) { log_error(INTERNAL_ERROR "unmangle_string: supplied buffer too small"); return -1; } for (i = 0, j = 0; str[i]; i++, j++) { if (strict && !(_is_whitelisted_char(str[i]) || str[i]=='\\')) { log_error("The %s \"%s\" should be mangled but " "it contains blacklisted characters.", str_name, str); j=0; r=-1; goto out; } if (str[i] == '\\' && str[i+1] == 'x') { if (!sscanf(&str[i+2], "%2x%s", &code, str_rest)) { log_debug_activation("Hex encoding mismatch detected in %s \"%s\" " "while trying to unmangle it.", str_name, str); goto out; } buf[j] = (unsigned char) code; /* skip the encoded part we've just decoded! */ i+= 3; /* unmangling applied */ r = 1; } else buf[j] = str[i]; } out: buf[j] = '\0'; return r; } static int _dm_task_set_name(struct dm_task *dmt, const char *name, dm_string_mangling_t mangling_mode) { char mangled_name[DM_NAME_LEN]; int r = 0; dm_free(dmt->dev_name); dmt->dev_name = NULL; dm_free(dmt->mangled_dev_name); dmt->mangled_dev_name = NULL; if (strlen(name) >= DM_NAME_LEN) { log_error("Name \"%s\" too long.", name); return 0; } if (!check_multiple_mangled_string_allowed(name, "name", mangling_mode)) return_0; if (mangling_mode != DM_STRING_MANGLING_NONE && (r = mangle_string(name, "name", strlen(name), mangled_name, sizeof(mangled_name), mangling_mode)) < 0) { log_error("Failed to mangle device name \"%s\".", name); return 0; } /* Store mangled_dev_name only if it differs from dev_name! */ if (r) { log_debug_activation("Device name mangled [%s]: %s --> %s", mangling_mode == DM_STRING_MANGLING_AUTO ? "auto" : "hex", name, mangled_name); if (!(dmt->mangled_dev_name = dm_strdup(mangled_name))) { log_error("_dm_task_set_name: dm_strdup(%s) failed", mangled_name); return 0; } } if (!(dmt->dev_name = dm_strdup(name))) { log_error("_dm_task_set_name: strdup(%s) failed", name); return 0; } return 1; } static int _dm_task_set_name_from_path(struct dm_task *dmt, const char *path, const char *name) { char buf[PATH_MAX]; struct stat st1, st2; const char *final_name; if (dmt->type == DM_DEVICE_CREATE) { log_error("Name \"%s\" invalid. It contains \"/\".", path); return 0; } if (stat(path, &st1)) { log_error("Device %s not found", path); return 0; } /* * If supplied path points to same device as last component * under /dev/mapper, use that name directly. Otherwise call * _find_dm_name_of_device() to scan _dm_dir for a match. */ if (dm_snprintf(buf, sizeof(buf), "%s/%s", _dm_dir, name) == -1) { log_error("Couldn't create path for %s", name); return 0; } if (!stat(buf, &st2) && (st1.st_rdev == st2.st_rdev)) final_name = name; else if (_find_dm_name_of_device(st1.st_rdev, buf, sizeof(buf))) final_name = buf; else { log_error("Device %s not found", name); return 0; } /* This is an already existing path - do not mangle! */ return _dm_task_set_name(dmt, final_name, DM_STRING_MANGLING_NONE); } int dm_task_set_name(struct dm_task *dmt, const char *name) { char *pos; /* Path supplied for existing device? */ if ((pos = strrchr(name, '/'))) return _dm_task_set_name_from_path(dmt, name, pos + 1); return _dm_task_set_name(dmt, name, dm_get_name_mangling_mode()); } const char *dm_task_get_name(const struct dm_task *dmt) { return (dmt->dmi.v4->name); } static char *_task_get_string_mangled(const char *str, const char *str_name, char *buf, size_t buf_size, dm_string_mangling_t mode) { char *rs; int r; if ((r = mangle_string(str, str_name, strlen(str), buf, buf_size, mode)) < 0) return NULL; if (!(rs = r ? dm_strdup(buf) : dm_strdup(str))) log_error("_task_get_string_mangled: dm_strdup failed"); return rs; } static char *_task_get_string_unmangled(const char *str, const char *str_name, char *buf, size_t buf_size, dm_string_mangling_t mode) { char *rs; int r = 0; /* * Unless the mode used is 'none', the string * is *already* unmangled on ioctl return! */ if (mode == DM_STRING_MANGLING_NONE && (r = unmangle_string(str, str_name, strlen(str), buf, buf_size, mode)) < 0) return NULL; if (!(rs = r ? dm_strdup(buf) : dm_strdup(str))) log_error("_task_get_string_unmangled: dm_strdup failed"); return rs; } char *dm_task_get_name_mangled(const struct dm_task *dmt) { const char *s = dm_task_get_name(dmt); char buf[DM_NAME_LEN]; char *rs; if (!(rs = _task_get_string_mangled(s, "name", buf, sizeof(buf), dm_get_name_mangling_mode()))) log_error("Failed to mangle device name \"%s\".", s); return rs; } char *dm_task_get_name_unmangled(const struct dm_task *dmt) { const char *s = dm_task_get_name(dmt); char buf[DM_NAME_LEN]; char *rs; if (!(rs = _task_get_string_unmangled(s, "name", buf, sizeof(buf), dm_get_name_mangling_mode()))) log_error("Failed to unmangle device name \"%s\".", s); return rs; } const char *dm_task_get_uuid(const struct dm_task *dmt) { return (dmt->dmi.v4->uuid); } char *dm_task_get_uuid_mangled(const struct dm_task *dmt) { const char *s = dm_task_get_uuid(dmt); char buf[DM_UUID_LEN]; char *rs; if (!(rs = _task_get_string_mangled(s, "UUID", buf, sizeof(buf), dm_get_name_mangling_mode()))) log_error("Failed to mangle device uuid \"%s\".", s); return rs; } char *dm_task_get_uuid_unmangled(const struct dm_task *dmt) { const char *s = dm_task_get_uuid(dmt); char buf[DM_UUID_LEN]; char *rs; if (!(rs = _task_get_string_unmangled(s, "UUID", buf, sizeof(buf), dm_get_name_mangling_mode()))) log_error("Failed to unmangle device uuid \"%s\".", s); return rs; } int dm_task_set_newname(struct dm_task *dmt, const char *newname) { dm_string_mangling_t mangling_mode = dm_get_name_mangling_mode(); char mangled_name[DM_NAME_LEN]; int r = 0; if (strchr(newname, '/')) { log_error("Name \"%s\" invalid. It contains \"/\".", newname); return 0; } if (strlen(newname) >= DM_NAME_LEN) { log_error("Name \"%s\" too long", newname); return 0; } if (!check_multiple_mangled_string_allowed(newname, "new name", mangling_mode)) return_0; if (mangling_mode != DM_STRING_MANGLING_NONE && (r = mangle_string(newname, "new name", strlen(newname), mangled_name, sizeof(mangled_name), mangling_mode)) < 0) { log_error("Failed to mangle new device name \"%s\"", newname); return 0; } if (r) { log_debug_activation("New device name mangled [%s]: %s --> %s", mangling_mode == DM_STRING_MANGLING_AUTO ? "auto" : "hex", newname, mangled_name); newname = mangled_name; } if (!(dmt->newname = dm_strdup(newname))) { log_error("dm_task_set_newname: strdup(%s) failed", newname); return 0; } dmt->new_uuid = 0; return 1; } int dm_task_set_uuid(struct dm_task *dmt, const char *uuid) { char mangled_uuid[DM_UUID_LEN]; dm_string_mangling_t mangling_mode = dm_get_name_mangling_mode(); int r = 0; dm_free(dmt->uuid); dmt->uuid = NULL; dm_free(dmt->mangled_uuid); dmt->mangled_uuid = NULL; if (!check_multiple_mangled_string_allowed(uuid, "UUID", mangling_mode)) return_0; if (mangling_mode != DM_STRING_MANGLING_NONE && (r = mangle_string(uuid, "UUID", strlen(uuid), mangled_uuid, sizeof(mangled_uuid), mangling_mode)) < 0) { log_error("Failed to mangle device uuid \"%s\".", uuid); return 0; } if (r) { log_debug_activation("Device uuid mangled [%s]: %s --> %s", mangling_mode == DM_STRING_MANGLING_AUTO ? "auto" : "hex", uuid, mangled_uuid); if (!(dmt->mangled_uuid = dm_strdup(mangled_uuid))) { log_error("dm_task_set_uuid: dm_strdup(%s) failed", mangled_uuid); return 0; } } if (!(dmt->uuid = dm_strdup(uuid))) { log_error("dm_task_set_uuid: strdup(%s) failed", uuid); return 0; } return 1; } int dm_task_set_major(struct dm_task *dmt, int major) { dmt->major = major; dmt->allow_default_major_fallback = 0; return 1; } int dm_task_set_minor(struct dm_task *dmt, int minor) { dmt->minor = minor; return 1; } int dm_task_set_major_minor(struct dm_task *dmt, int major, int minor, int allow_default_major_fallback) { dmt->major = major; dmt->minor = minor; dmt->allow_default_major_fallback = allow_default_major_fallback; return 1; } int dm_task_set_uid(struct dm_task *dmt, uid_t uid) { dmt->uid = uid; return 1; } int dm_task_set_gid(struct dm_task *dmt, gid_t gid) { dmt->gid = gid; return 1; } int dm_task_set_mode(struct dm_task *dmt, mode_t mode) { dmt->mode = mode; return 1; } int dm_task_enable_checks(struct dm_task *dmt) { dmt->enable_checks = 1; return 1; } int dm_task_add_target(struct dm_task *dmt, uint64_t start, uint64_t size, const char *ttype, const char *params) { struct target *t = create_target(start, size, ttype, params); if (!t) return_0; if (!dmt->head) dmt->head = dmt->tail = t; else { dmt->tail->next = t; dmt->tail = t; } return 1; } #ifdef HAVE_SELINUX static int _selabel_lookup(const char *path, mode_t mode, security_context_t *scontext) { #ifdef HAVE_SELINUX_LABEL_H if (!_selabel_handle && !(_selabel_handle = selabel_open(SELABEL_CTX_FILE, NULL, 0))) { log_error("selabel_open failed: %s", strerror(errno)); return 0; } if (selabel_lookup(_selabel_handle, scontext, path, mode)) { log_debug_activation("selabel_lookup failed for %s: %s", path, strerror(errno)); return 0; } #else if (matchpathcon(path, mode, scontext)) { log_debug_activation("matchpathcon failed for %s: %s", path, strerror(errno)); return 0; } #endif return 1; } #endif int dm_prepare_selinux_context(const char *path, mode_t mode) { #ifdef HAVE_SELINUX security_context_t scontext = NULL; if (is_selinux_enabled() <= 0) return 1; if (path) { if (!_selabel_lookup(path, mode, &scontext)) return_0; log_debug_activation("Preparing SELinux context for %s to %s.", path, scontext); } else log_debug_activation("Resetting SELinux context to default value."); if (setfscreatecon(scontext) < 0) { log_sys_error("setfscreatecon", path); freecon(scontext); return 0; } freecon(scontext); #endif return 1; } int dm_set_selinux_context(const char *path, mode_t mode) { #ifdef HAVE_SELINUX security_context_t scontext; if (is_selinux_enabled() <= 0) return 1; if (!_selabel_lookup(path, mode, &scontext)) return_0; log_debug_activation("Setting SELinux context for %s to %s.", path, scontext); if ((lsetfilecon(path, scontext) < 0) && (errno != ENOTSUP)) { log_sys_error("lsetfilecon", path); freecon(scontext); return 0; } freecon(scontext); #endif return 1; } void selinux_release(void) { #ifdef HAVE_SELINUX_LABEL_H if (_selabel_handle) selabel_close(_selabel_handle); _selabel_handle = NULL; #endif } static int _warn_if_op_needed(int warn_if_udev_failed) { return warn_if_udev_failed && dm_udev_get_sync_support() && dm_udev_get_checking(); } static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor, uid_t uid, gid_t gid, mode_t mode, int warn_if_udev_failed) { char path[PATH_MAX]; struct stat info; dev_t dev = MKDEV((dev_t)major, minor); mode_t old_mask; _build_dev_path(path, sizeof(path), dev_name); if (stat(path, &info) >= 0) { if (!S_ISBLK(info.st_mode)) { log_error("A non-block device file at '%s' " "is already present", path); return 0; } /* If right inode already exists we don't touch uid etc. */ if (info.st_rdev == dev) return 1; if (unlink(path) < 0) { log_error("Unable to unlink device node for '%s'", dev_name); return 0; } } else if (_warn_if_op_needed(warn_if_udev_failed)) log_warn("%s not set up by udev: Falling back to direct " "node creation.", path); (void) dm_prepare_selinux_context(path, S_IFBLK); old_mask = umask(0); if (mknod(path, S_IFBLK | mode, dev) < 0) { log_error("%s: mknod for %s failed: %s", path, dev_name, strerror(errno)); umask(old_mask); (void) dm_prepare_selinux_context(NULL, 0); return 0; } umask(old_mask); (void) dm_prepare_selinux_context(NULL, 0); if (chown(path, uid, gid) < 0) { log_sys_error("chown", path); return 0; } log_debug_activation("Created %s", path); return 1; } static int _rm_dev_node(const char *dev_name, int warn_if_udev_failed) { char path[PATH_MAX]; struct stat info; _build_dev_path(path, sizeof(path), dev_name); if (stat(path, &info) < 0) return 1; else if (_warn_if_op_needed(warn_if_udev_failed)) log_warn("Node %s was not removed by udev. " "Falling back to direct node removal.", path); if (unlink(path) < 0) { log_error("Unable to unlink device node for '%s'", dev_name); return 0; } log_debug_activation("Removed %s", path); return 1; } static int _rename_dev_node(const char *old_name, const char *new_name, int warn_if_udev_failed) { char oldpath[PATH_MAX]; char newpath[PATH_MAX]; struct stat info; _build_dev_path(oldpath, sizeof(oldpath), old_name); _build_dev_path(newpath, sizeof(newpath), new_name); if (stat(newpath, &info) == 0) { if (!S_ISBLK(info.st_mode)) { log_error("A non-block device file at '%s' " "is already present", newpath); return 0; } else if (_warn_if_op_needed(warn_if_udev_failed)) { if (stat(oldpath, &info) < 0 && errno == ENOENT) /* assume udev already deleted this */ return 1; else { log_warn("The node %s should have been renamed to %s " "by udev but old node is still present. " "Falling back to direct old node removal.", oldpath, newpath); return _rm_dev_node(old_name, 0); } } if (unlink(newpath) < 0) { if (errno == EPERM) { /* devfs, entry has already been renamed */ return 1; } log_error("Unable to unlink device node for '%s'", new_name); return 0; } } else if (_warn_if_op_needed(warn_if_udev_failed)) log_warn("The node %s should have been renamed to %s " "by udev but new node is not present. " "Falling back to direct node rename.", oldpath, newpath); if (rename(oldpath, newpath) < 0) { log_error("Unable to rename device node from '%s' to '%s'", old_name, new_name); return 0; } log_debug_activation("Renamed %s to %s", oldpath, newpath); return 1; } #ifdef linux static int _open_dev_node(const char *dev_name) { int fd = -1; char path[PATH_MAX]; _build_dev_path(path, sizeof(path), dev_name); if ((fd = open(path, O_RDONLY, 0)) < 0) log_sys_error("open", path); return fd; } int get_dev_node_read_ahead(const char *dev_name, uint32_t major, uint32_t minor, uint32_t *read_ahead) { char buf[24]; int len; int r = 1; int fd; long read_ahead_long; /* * If we know the device number, use sysfs if we can. * Otherwise use BLKRAGET ioctl. */ if (*_sysfs_dir && major != 0) { if (dm_snprintf(_path0, sizeof(_path0), "%sdev/block/%" PRIu32 ":%" PRIu32 "/bdi/read_ahead_kb", _sysfs_dir, major, minor) < 0) { log_error("Failed to build sysfs_path."); return 0; } if ((fd = open(_path0, O_RDONLY, 0)) != -1) { /* Reading from sysfs, expecting number\n */ if ((len = read(fd, buf, sizeof(buf) - 1)) < 1) { log_sys_error("read", _path0); r = 0; } else { buf[len] = 0; /* kill \n and ensure \0 */ *read_ahead = atoi(buf) * 2; log_debug_activation("%s (%d:%d): read ahead is %" PRIu32, dev_name, major, minor, *read_ahead); } if (close(fd)) log_sys_debug("close", _path0); return r; } log_sys_debug("open", _path0); /* Fall back to use dev_name */ } /* * Open/close dev_name may block the process * (i.e. overfilled thin pool volume) */ if (!*dev_name) { log_error("Empty device name passed to BLKRAGET"); return 0; } if ((fd = _open_dev_node(dev_name)) < 0) return_0; if (ioctl(fd, BLKRAGET, &read_ahead_long)) { log_sys_error("BLKRAGET", dev_name); *read_ahead = 0; r = 0; } else { *read_ahead = (uint32_t) read_ahead_long; log_debug_activation("%s: read ahead is %" PRIu32, dev_name, *read_ahead); } if (close(fd)) log_sys_debug("close", dev_name); return r; } static int _set_read_ahead(const char *dev_name, uint32_t major, uint32_t minor, uint32_t read_ahead) { char buf[24]; int len; int r = 1; int fd; long read_ahead_long = (long) read_ahead; log_debug_activation("%s (%d:%d): Setting read ahead to %" PRIu32, dev_name, major, minor, read_ahead); /* * If we know the device number, use sysfs if we can. * Otherwise use BLKRASET ioctl. RA is set after resume. */ if (*_sysfs_dir && major != 0) { if (dm_snprintf(_path0, sizeof(_path0), "%sdev/block/%" PRIu32 ":%" PRIu32 "/bdi/read_ahead_kb", _sysfs_dir, major, minor) < 0) { log_error("Failed to build sysfs_path."); return 0; } /* Sysfs is kB based, round up to kB */ if ((len = dm_snprintf(buf, sizeof(buf), "%" PRIu32, (read_ahead + 1) / 2)) < 0) { log_error("Failed to build size in kB."); return 0; } if ((fd = open(_path0, O_WRONLY, 0)) != -1) { if (write(fd, buf, len) < len) { log_sys_error("write", _path0); r = 0; } if (close(fd)) log_sys_debug("close", _path0); return r; } log_sys_debug("open", _path0); /* Fall back to use dev_name */ } if (!*dev_name) { log_error("Empty device name passed to BLKRAGET"); return 0; } if ((fd = _open_dev_node(dev_name)) < 0) return_0; if (ioctl(fd, BLKRASET, read_ahead_long)) { log_sys_error("BLKRASET", dev_name); r = 0; } if (close(fd)) log_sys_debug("close", dev_name); return r; } static int _set_dev_node_read_ahead(const char *dev_name, uint32_t major, uint32_t minor, uint32_t read_ahead, uint32_t read_ahead_flags) { uint32_t current_read_ahead; if (read_ahead == DM_READ_AHEAD_AUTO) return 1; if (read_ahead == DM_READ_AHEAD_NONE) read_ahead = 0; if (read_ahead_flags & DM_READ_AHEAD_MINIMUM_FLAG) { if (!get_dev_node_read_ahead(dev_name, major, minor, &current_read_ahead)) return_0; if (current_read_ahead >= read_ahead) { log_debug_activation("%s: retaining kernel read ahead of %" PRIu32 " (requested %" PRIu32 ")", dev_name, current_read_ahead, read_ahead); return 1; } } return _set_read_ahead(dev_name, major, minor, read_ahead); } #else int get_dev_node_read_ahead(const char *dev_name, uint32_t *read_ahead) { *read_ahead = 0; return 1; } static int _set_dev_node_read_ahead(const char *dev_name, uint32_t major, uint32_t minor, uint32_t read_ahead, uint32_t read_ahead_flags) { return 1; } #endif typedef enum { NODE_ADD, NODE_DEL, NODE_RENAME, NODE_READ_AHEAD, NUM_NODES } node_op_t; static int _do_node_op(node_op_t type, const char *dev_name, uint32_t major, uint32_t minor, uid_t uid, gid_t gid, mode_t mode, const char *old_name, uint32_t read_ahead, uint32_t read_ahead_flags, int warn_if_udev_failed) { switch (type) { case NODE_ADD: return _add_dev_node(dev_name, major, minor, uid, gid, mode, warn_if_udev_failed); case NODE_DEL: return _rm_dev_node(dev_name, warn_if_udev_failed); case NODE_RENAME: return _rename_dev_node(old_name, dev_name, warn_if_udev_failed); case NODE_READ_AHEAD: return _set_dev_node_read_ahead(dev_name, major, minor, read_ahead, read_ahead_flags); default: ; /* NOTREACHED */ } return 1; } static DM_LIST_INIT(_node_ops); static int _count_node_ops[NUM_NODES]; struct node_op_parms { struct dm_list list; node_op_t type; char *dev_name; uint32_t major; uint32_t minor; uid_t uid; gid_t gid; mode_t mode; uint32_t read_ahead; uint32_t read_ahead_flags; char *old_name; int warn_if_udev_failed; unsigned rely_on_udev; char names[0]; }; static void _store_str(char **pos, char **ptr, const char *str) { strcpy(*pos, str); *ptr = *pos; *pos += strlen(*ptr) + 1; } static void _del_node_op(struct node_op_parms *nop) { _count_node_ops[nop->type]--; dm_list_del(&nop->list); dm_free(nop); } /* Check if there is other the type of node operation stacked */ static int _other_node_ops(node_op_t type) { unsigned i; for (i = 0; i < NUM_NODES; i++) if (type != i && _count_node_ops[i]) return 1; return 0; } static void _log_node_op(const char *action_str, struct node_op_parms *nop) { const char *rely = nop->rely_on_udev ? " [trust_udev]" : "" ; const char *verify = nop->warn_if_udev_failed ? " [verify_udev]" : ""; switch (nop->type) { case NODE_ADD: log_debug_activation("%s: %s NODE_ADD (%" PRIu32 ",%" PRIu32 ") %u:%u 0%o%s%s", nop->dev_name, action_str, nop->major, nop->minor, nop->uid, nop->gid, nop->mode, rely, verify); break; case NODE_DEL: log_debug_activation("%s: %s NODE_DEL%s%s", nop->dev_name, action_str, rely, verify); break; case NODE_RENAME: log_debug_activation("%s: %s NODE_RENAME to %s%s%s", nop->old_name, action_str, nop->dev_name, rely, verify); break; case NODE_READ_AHEAD: log_debug_activation("%s: %s NODE_READ_AHEAD %" PRIu32 " (flags=%" PRIu32 ")%s%s", nop->dev_name, action_str, nop->read_ahead, nop->read_ahead_flags, rely, verify); break; default: ; /* NOTREACHED */ } } static int _stack_node_op(node_op_t type, const char *dev_name, uint32_t major, uint32_t minor, uid_t uid, gid_t gid, mode_t mode, const char *old_name, uint32_t read_ahead, uint32_t read_ahead_flags, int warn_if_udev_failed, unsigned rely_on_udev) { struct node_op_parms *nop; struct dm_list *noph, *nopht; size_t len = strlen(dev_name) + strlen(old_name) + 2; char *pos; /* * Note: warn_if_udev_failed must have valid content */ if ((type == NODE_DEL) && _other_node_ops(type)) /* * Ignore any outstanding operations on the node if deleting it. */ dm_list_iterate_safe(noph, nopht, &_node_ops) { nop = dm_list_item(noph, struct node_op_parms); if (!strcmp(dev_name, nop->dev_name)) { _log_node_op("Unstacking", nop); _del_node_op(nop); if (!_other_node_ops(type)) break; /* no other non DEL ops */ } } else if ((type == NODE_ADD) && _count_node_ops[NODE_DEL]) /* * Ignore previous DEL operation on added node. * (No other operations for this device then DEL could be stacked here). */ dm_list_iterate_safe(noph, nopht, &_node_ops) { nop = dm_list_item(noph, struct node_op_parms); if ((nop->type == NODE_DEL) && !strcmp(dev_name, nop->dev_name)) { _log_node_op("Unstacking", nop); _del_node_op(nop); break; /* no other DEL ops */ } } else if (type == NODE_RENAME) /* * Ignore any outstanding operations if renaming it. * * Currently RENAME operation happens through 'suspend -> resume'. * On 'resume' device is added with read_ahead settings, so it is * safe to remove any stacked ADD, RENAME, READ_AHEAD operation * There cannot be any DEL operation on the renamed device. */ dm_list_iterate_safe(noph, nopht, &_node_ops) { nop = dm_list_item(noph, struct node_op_parms); if (!strcmp(old_name, nop->dev_name)) { _log_node_op("Unstacking", nop); _del_node_op(nop); } } else if (type == NODE_READ_AHEAD) { /* udev doesn't process readahead */ rely_on_udev = 0; warn_if_udev_failed = 0; } if (!(nop = dm_malloc(sizeof(*nop) + len))) { log_error("Insufficient memory to stack mknod operation"); return 0; } pos = nop->names; nop->type = type; nop->major = major; nop->minor = minor; nop->uid = uid; nop->gid = gid; nop->mode = mode; nop->read_ahead = read_ahead; nop->read_ahead_flags = read_ahead_flags; nop->rely_on_udev = rely_on_udev; /* * Clear warn_if_udev_failed if rely_on_udev is set. It doesn't get * checked in this case - this just removes the flag from log messages. */ nop->warn_if_udev_failed = rely_on_udev ? 0 : warn_if_udev_failed; _store_str(&pos, &nop->dev_name, dev_name); _store_str(&pos, &nop->old_name, old_name); _count_node_ops[type]++; dm_list_add(&_node_ops, &nop->list); _log_node_op("Stacking", nop); return 1; } static void _pop_node_ops(void) { struct dm_list *noph, *nopht; struct node_op_parms *nop; dm_list_iterate_safe(noph, nopht, &_node_ops) { nop = dm_list_item(noph, struct node_op_parms); if (!nop->rely_on_udev) { _log_node_op("Processing", nop); _do_node_op(nop->type, nop->dev_name, nop->major, nop->minor, nop->uid, nop->gid, nop->mode, nop->old_name, nop->read_ahead, nop->read_ahead_flags, nop->warn_if_udev_failed); } else _log_node_op("Skipping", nop); _del_node_op(nop); } } int add_dev_node(const char *dev_name, uint32_t major, uint32_t minor, uid_t uid, gid_t gid, mode_t mode, int check_udev, unsigned rely_on_udev) { return _stack_node_op(NODE_ADD, dev_name, major, minor, uid, gid, mode, "", 0, 0, check_udev, rely_on_udev); } int rename_dev_node(const char *old_name, const char *new_name, int check_udev, unsigned rely_on_udev) { return _stack_node_op(NODE_RENAME, new_name, 0, 0, 0, 0, 0, old_name, 0, 0, check_udev, rely_on_udev); } int rm_dev_node(const char *dev_name, int check_udev, unsigned rely_on_udev) { return _stack_node_op(NODE_DEL, dev_name, 0, 0, 0, 0, 0, "", 0, 0, check_udev, rely_on_udev); } int set_dev_node_read_ahead(const char *dev_name, uint32_t major, uint32_t minor, uint32_t read_ahead, uint32_t read_ahead_flags) { if (read_ahead == DM_READ_AHEAD_AUTO) return 1; return _stack_node_op(NODE_READ_AHEAD, dev_name, major, minor, 0, 0, 0, "", read_ahead, read_ahead_flags, 0, 0); } void update_devs(void) { _pop_node_ops(); } static int _canonicalize_and_set_dir(const char *src, const char *suffix, size_t max_len, char *dir) { size_t len; const char *slash; if (*src != '/') { log_debug_activation("Invalid directory value, %s: " "not an absolute name.", src); return 0; } len = strlen(src); slash = src[len-1] == '/' ? "" : "/"; if (dm_snprintf(dir, max_len, "%s%s%s", src, slash, suffix ? suffix : "") < 0) { log_debug_activation("Invalid directory value, %s: name too long.", src); return 0; } return 1; } int dm_set_dev_dir(const char *dev_dir) { return _canonicalize_and_set_dir(dev_dir, DM_DIR, sizeof _dm_dir, _dm_dir); } const char *dm_dir(void) { return _dm_dir; } int dm_set_sysfs_dir(const char *sysfs_dir) { if (!sysfs_dir || !*sysfs_dir) { _sysfs_dir[0] = '\0'; return 1; } else return _canonicalize_and_set_dir(sysfs_dir, NULL, sizeof _sysfs_dir, _sysfs_dir); } const char *dm_sysfs_dir(void) { return _sysfs_dir; } /* * Replace existing uuid_prefix provided it isn't too long. */ int dm_set_uuid_prefix(const char *uuid_prefix) { if (!uuid_prefix) return_0; if (strlen(uuid_prefix) > DM_MAX_UUID_PREFIX_LEN) { log_error("New uuid prefix %s too long.", uuid_prefix); return 0; } strcpy(_default_uuid_prefix, uuid_prefix); return 1; } const char *dm_uuid_prefix(void) { return _default_uuid_prefix; } static int _is_octal(int a) { return (((a) & ~7) == '0'); } /* Convert mangled mountinfo into normal ASCII string */ static void _unmangle_mountinfo_string(const char *src, char *buf) { while (*src) { if ((*src == '\\') && _is_octal(src[1]) && _is_octal(src[2]) && _is_octal(src[3])) { *buf++ = 64 * (src[1] & 7) + 8 * (src[2] & 7) + (src[3] & 7); src += 4; } else *buf++ = *src++; } *buf = '\0'; } /* Parse one line of mountinfo and unmangled target line */ static int _mountinfo_parse_line(const char *line, unsigned *maj, unsigned *min, char *buf) { char root[PATH_MAX + 1]; char target[PATH_MAX + 1]; /* TODO: maybe detect availability of %ms glib support ? */ if (sscanf(line, "%*u %*u %u:%u %" DM_TO_STRING(PATH_MAX) "s %" DM_TO_STRING(PATH_MAX) "s", maj, min, root, target) < 4) { log_error("Failed to parse mountinfo line."); return 0; } _unmangle_mountinfo_string(target, buf); return 1; } /* * Function to operate on individal mountinfo line, * minor, major and mount target are parsed and unmangled */ int dm_mountinfo_read(dm_mountinfo_line_callback_fn read_fn, void *cb_data) { FILE *minfo; char buffer[2 * PATH_MAX]; char target[PATH_MAX]; unsigned maj, min; int r = 1; if (!(minfo = fopen(_mountinfo, "r"))) { if (errno != ENOENT) log_sys_error("fopen", _mountinfo); else log_sys_debug("fopen", _mountinfo); return 0; } while (!feof(minfo) && fgets(buffer, sizeof(buffer), minfo)) if (!_mountinfo_parse_line(buffer, &maj, &min, target) || !read_fn(buffer, maj, min, target, cb_data)) { stack; r = 0; break; } if (fclose(minfo)) log_sys_error("fclose", _mountinfo); return r; } static int _sysfs_get_dm_name(uint32_t major, uint32_t minor, char *buf, size_t buf_size) { char *sysfs_path, *temp_buf = NULL; FILE *fp = NULL; int r = 0; size_t len; if (!(sysfs_path = dm_malloc(PATH_MAX)) || !(temp_buf = dm_malloc(PATH_MAX))) { log_error("_sysfs_get_dm_name: failed to allocate temporary buffers"); goto bad; } if (dm_snprintf(sysfs_path, PATH_MAX, "%sdev/block/%" PRIu32 ":%" PRIu32 "/dm/name", _sysfs_dir, major, minor) < 0) { log_error("_sysfs_get_dm_name: dm_snprintf failed"); goto bad; } if (!(fp = fopen(sysfs_path, "r"))) { if (errno != ENOENT) log_sys_error("fopen", sysfs_path); else log_sys_debug("fopen", sysfs_path); goto bad; } if (!fgets(temp_buf, PATH_MAX, fp)) { log_sys_error("fgets", sysfs_path); goto bad; } len = strlen(temp_buf); if (len > buf_size) { log_error("_sysfs_get_dm_name: supplied buffer too small"); goto bad; } temp_buf[len ? len - 1 : 0] = '\0'; /* \n */ strcpy(buf, temp_buf); r = 1; bad: if (fp && fclose(fp)) log_sys_error("fclose", sysfs_path); dm_free(temp_buf); dm_free(sysfs_path); return r; } static int _sysfs_get_kernel_name(uint32_t major, uint32_t minor, char *buf, size_t buf_size) { char *name, *sysfs_path, *temp_buf = NULL; ssize_t size; size_t len; int r = 0; if (!(sysfs_path = dm_malloc(PATH_MAX)) || !(temp_buf = dm_malloc(PATH_MAX))) { log_error("_sysfs_get_kernel_name: failed to allocate temporary buffers"); goto bad; } if (dm_snprintf(sysfs_path, PATH_MAX, "%sdev/block/%" PRIu32 ":%" PRIu32, _sysfs_dir, major, minor) < 0) { log_error("_sysfs_get_kernel_name: dm_snprintf failed"); goto bad; } if ((size = readlink(sysfs_path, temp_buf, PATH_MAX - 1)) < 0) { if (errno != ENOENT) log_sys_error("readlink", sysfs_path); else log_sys_debug("readlink", sysfs_path); goto bad; } temp_buf[size] = '\0'; if (!(name = strrchr(temp_buf, '/'))) { log_error("Could not locate device kernel name in sysfs path %s", temp_buf); goto bad; } name += 1; len = size - (name - temp_buf) + 1; if (len > buf_size) { log_error("_sysfs_get_kernel_name: output buffer too small"); goto bad; } strcpy(buf, name); r = 1; bad: dm_free(temp_buf); dm_free(sysfs_path); return r; } int dm_device_get_name(uint32_t major, uint32_t minor, int prefer_kernel_name, char *buf, size_t buf_size) { if (!*_sysfs_dir) return 0; /* * device-mapper devices and prefer_kernel_name = 0 * get dm name by reading /sys/dev/block/major:minor/dm/name, * fallback to _sysfs_get_kernel_name if not successful */ if (dm_is_dm_major(major) && !prefer_kernel_name) { if (_sysfs_get_dm_name(major, minor, buf, buf_size)) return 1; else stack; } /* * non-device-mapper devices or prefer_kernel_name = 1 * get kernel name using readlink /sys/dev/block/major:minor -> .../dm-X */ return _sysfs_get_kernel_name(major, minor, buf, buf_size); } int dm_device_has_holders(uint32_t major, uint32_t minor) { char sysfs_path[PATH_MAX]; struct stat st; if (!*_sysfs_dir) return 0; if (dm_snprintf(sysfs_path, PATH_MAX, "%sdev/block/%" PRIu32 ":%" PRIu32 "/holders", _sysfs_dir, major, minor) < 0) { log_error("sysfs_path dm_snprintf failed"); return 0; } if (stat(sysfs_path, &st)) { log_sys_error("stat", sysfs_path); return 0; } return !dm_is_empty_dir(sysfs_path); } static int _mounted_fs_on_device(const char *kernel_dev_name) { char sysfs_path[PATH_MAX]; struct dirent *dirent; DIR *d; struct stat st; int r = 0; if (dm_snprintf(sysfs_path, PATH_MAX, "%sfs", _sysfs_dir) < 0) { log_error("sysfs_path dm_snprintf failed"); return 0; } if (!(d = opendir(sysfs_path))) { if (errno != ENOENT) log_sys_error("opendir", sysfs_path); return 0; } while ((dirent = readdir(d))) { if (!strcmp(dirent->d_name, ".") || !strcmp(dirent->d_name, "..")) continue; if (dm_snprintf(sysfs_path, PATH_MAX, "%sfs/%s/%s", _sysfs_dir, dirent->d_name, kernel_dev_name) < 0) { log_error("sysfs_path dm_snprintf failed"); break; } if (!stat(sysfs_path, &st)) { /* found! */ r = 1; break; } else if (errno != ENOENT) { log_sys_error("stat", sysfs_path); break; } } if (closedir(d)) log_error("_fs_present_on_device: %s: closedir failed", kernel_dev_name); return r; } struct mountinfo_s { unsigned maj; unsigned min; int mounted; }; static int _device_has_mounted_fs(char *buffer, unsigned major, unsigned minor, char *target, void *cb_data) { struct mountinfo_s *data = cb_data; char kernel_dev_name[PATH_MAX]; if ((major == data->maj) && (minor == data->min)) { if (!dm_device_get_name(major, minor, 1, kernel_dev_name, PATH_MAX)) { stack; *kernel_dev_name = '\0'; } log_verbose("Device %s (%u:%u) appears to be mounted on %s.", kernel_dev_name, major, minor, target); data->mounted = 1; } return 1; } int dm_device_has_mounted_fs(uint32_t major, uint32_t minor) { char kernel_dev_name[PATH_MAX]; struct mountinfo_s data = { .maj = major, .min = minor, }; if (!dm_mountinfo_read(_device_has_mounted_fs, &data)) stack; if (data.mounted) return 1; /* * TODO: Verify dm_mountinfo_read() is superset * and remove sysfs check (namespaces) */ /* Get kernel device name first */ if (!dm_device_get_name(major, minor, 1, kernel_dev_name, PATH_MAX)) return 0; /* Check /sys/fs/<fs_name>/<kernel_dev_name> presence */ return _mounted_fs_on_device(kernel_dev_name); } int dm_mknodes(const char *name) { struct dm_task *dmt; int r = 0; if (!(dmt = dm_task_create(DM_DEVICE_MKNODES))) return 0; if (name && !dm_task_set_name(dmt, name)) goto out; if (!dm_task_no_open_count(dmt)) goto out; r = dm_task_run(dmt); out: dm_task_destroy(dmt); return r; } int dm_driver_version(char *version, size_t size) { struct dm_task *dmt; int r = 0; if (!(dmt = dm_task_create(DM_DEVICE_VERSION))) return 0; if (!dm_task_run(dmt)) log_error("Failed to get driver version"); if (!dm_task_get_driver_version(dmt, version, size)) goto out; r = 1; out: dm_task_destroy(dmt); return r; } static void _set_cookie_flags(struct dm_task *dmt, uint16_t flags) { if (!dm_cookie_supported()) return; if (_udev_disabled) { /* * If udev is disabled, hardcode this functionality: * - we want libdm to create the nodes * - we don't want the /dev/mapper and any subsystem * related content to be created by udev if udev * rules are installed */ flags &= ~DM_UDEV_DISABLE_LIBRARY_FALLBACK; flags |= DM_UDEV_DISABLE_DM_RULES_FLAG | DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG; } dmt->event_nr = flags << DM_UDEV_FLAGS_SHIFT; } #ifndef UDEV_SYNC_SUPPORT void dm_udev_set_sync_support(int sync_with_udev) { } int dm_udev_get_sync_support(void) { return 0; } void dm_udev_set_checking(int checking) { } int dm_udev_get_checking(void) { return 0; } int dm_task_set_cookie(struct dm_task *dmt, uint32_t *cookie, uint16_t flags) { _set_cookie_flags(dmt, flags); *cookie = 0; dmt->cookie_set = 1; return 1; } int dm_udev_complete(uint32_t cookie) { return 1; } int dm_udev_wait(uint32_t cookie) { update_devs(); return 1; } #else /* UDEV_SYNC_SUPPORT */ static int _check_semaphore_is_supported(void) { int maxid; union semun arg; struct seminfo seminfo; arg.__buf = &seminfo; maxid = semctl(0, 0, SEM_INFO, arg); if (maxid < 0) { log_warn("Kernel not configured for semaphores (System V IPC). " "Not using udev synchronisation code."); return 0; } return 1; } static int _check_udev_is_running(void) { struct udev *udev; struct udev_queue *udev_queue; int r; if (!(udev = udev_new())) goto_bad; if (!(udev_queue = udev_queue_new(udev))) { udev_unref(udev); goto_bad; } if (!(r = udev_queue_get_udev_is_active(udev_queue))) log_debug_activation("Udev is not running. " "Not using udev synchronisation code."); udev_queue_unref(udev_queue); udev_unref(udev); return r; bad: log_error("Could not get udev state. Assuming udev is not running."); return 0; } static void _check_udev_sync_requirements_once(void) { if (_semaphore_supported < 0) _semaphore_supported = _check_semaphore_is_supported(); if (_udev_running < 0) { _udev_running = _check_udev_is_running(); if (_udev_disabled && _udev_running) log_warn("Udev is running and DM_DISABLE_UDEV environment variable is set. " "Bypassing udev, device-mapper library will manage device " "nodes in device directory."); } } void dm_udev_set_sync_support(int sync_with_udev) { _check_udev_sync_requirements_once(); _sync_with_udev = sync_with_udev; } int dm_udev_get_sync_support(void) { _check_udev_sync_requirements_once(); return !_udev_disabled && _semaphore_supported && dm_cookie_supported() &&_udev_running && _sync_with_udev; } void dm_udev_set_checking(int checking) { if ((_udev_checking = checking)) log_debug_activation("DM udev checking enabled"); else log_debug_activation("DM udev checking disabled"); } int dm_udev_get_checking(void) { return _udev_checking; } static int _get_cookie_sem(uint32_t cookie, int *semid) { if (cookie >> 16 != DM_COOKIE_MAGIC) { log_error("Could not continue to access notification " "semaphore identified by cookie value %" PRIu32 " (0x%x). Incorrect cookie prefix.", cookie, cookie); return 0; } if ((*semid = semget((key_t) cookie, 1, 0)) >= 0) return 1; switch (errno) { case ENOENT: log_error("Could not find notification " "semaphore identified by cookie " "value %" PRIu32 " (0x%x)", cookie, cookie); break; case EACCES: log_error("No permission to access " "notificaton semaphore identified " "by cookie value %" PRIu32 " (0x%x)", cookie, cookie); break; default: log_error("Failed to access notification " "semaphore identified by cookie " "value %" PRIu32 " (0x%x): %s", cookie, cookie, strerror(errno)); break; } return 0; } static int _udev_notify_sem_inc(uint32_t cookie, int semid) { struct sembuf sb = {0, 1, 0}; int val; if (semop(semid, &sb, 1) < 0) { log_error("semid %d: semop failed for cookie 0x%" PRIx32 ": %s", semid, cookie, strerror(errno)); return 0; } if ((val = semctl(semid, 0, GETVAL)) < 0) { log_error("semid %d: sem_ctl GETVAL failed for " "cookie 0x%" PRIx32 ": %s", semid, cookie, strerror(errno)); return 0; } log_debug_activation("Udev cookie 0x%" PRIx32 " (semid %d) incremented to %d", cookie, semid, val); return 1; } static int _udev_notify_sem_dec(uint32_t cookie, int semid) { struct sembuf sb = {0, -1, IPC_NOWAIT}; int val; if ((val = semctl(semid, 0, GETVAL)) < 0) { log_error("semid %d: sem_ctl GETVAL failed for " "cookie 0x%" PRIx32 ": %s", semid, cookie, strerror(errno)); return 0; } if (semop(semid, &sb, 1) < 0) { switch (errno) { case EAGAIN: log_error("semid %d: semop failed for cookie " "0x%" PRIx32 ": " "incorrect semaphore state", semid, cookie); break; default: log_error("semid %d: semop failed for cookie " "0x%" PRIx32 ": %s", semid, cookie, strerror(errno)); break; } return 0; } log_debug_activation("Udev cookie 0x%" PRIx32 " (semid %d) decremented to %d", cookie, semid, val - 1); return 1; } static int _udev_notify_sem_destroy(uint32_t cookie, int semid) { if (semctl(semid, 0, IPC_RMID, 0) < 0) { log_error("Could not cleanup notification semaphore " "identified by cookie value %" PRIu32 " (0x%x): %s", cookie, cookie, strerror(errno)); return 0; } log_debug_activation("Udev cookie 0x%" PRIx32 " (semid %d) destroyed", cookie, semid); return 1; } static int _udev_notify_sem_create(uint32_t *cookie, int *semid) { int fd; int gen_semid; int val; uint16_t base_cookie; uint32_t gen_cookie; union semun sem_arg; if ((fd = open("/dev/urandom", O_RDONLY)) < 0) { log_error("Failed to open /dev/urandom " "to create random cookie value"); *cookie = 0; return 0; } /* Generate random cookie value. Be sure it is unique and non-zero. */ do { /* FIXME Handle non-error returns from read(). Move _io() into libdm? */ if (read(fd, &base_cookie, sizeof(base_cookie)) != sizeof(base_cookie)) { log_error("Failed to initialize notification cookie"); goto bad; } gen_cookie = DM_COOKIE_MAGIC << 16 | base_cookie; if (base_cookie && (gen_semid = semget((key_t) gen_cookie, 1, 0600 | IPC_CREAT | IPC_EXCL)) < 0) { switch (errno) { case EEXIST: /* if the semaphore key exists, we * simply generate another random one */ base_cookie = 0; break; case ENOMEM: log_error("Not enough memory to create " "notification semaphore"); goto bad; case ENOSPC: log_error("Limit for the maximum number " "of semaphores reached. You can " "check and set the limits in " "/proc/sys/kernel/sem."); goto bad; default: log_error("Failed to create notification " "semaphore: %s", strerror(errno)); goto bad; } } } while (!base_cookie); log_debug_activation("Udev cookie 0x%" PRIx32 " (semid %d) created", gen_cookie, gen_semid); sem_arg.val = 1; if (semctl(gen_semid, 0, SETVAL, sem_arg) < 0) { log_error("semid %d: semctl failed: %s", gen_semid, strerror(errno)); /* We have to destroy just created semaphore * so it won't stay in the system. */ (void) _udev_notify_sem_destroy(gen_cookie, gen_semid); goto bad; } if ((val = semctl(gen_semid, 0, GETVAL)) < 0) { log_error("semid %d: sem_ctl GETVAL failed for " "cookie 0x%" PRIx32 ": %s", gen_semid, gen_cookie, strerror(errno)); goto bad; } log_debug_activation("Udev cookie 0x%" PRIx32 " (semid %d) incremented to %d", gen_cookie, gen_semid, val); if (close(fd)) stack; *semid = gen_semid; *cookie = gen_cookie; return 1; bad: if (close(fd)) stack; *cookie = 0; return 0; } int dm_udev_create_cookie(uint32_t *cookie) { int semid; if (!dm_udev_get_sync_support()) { *cookie = 0; return 1; } return _udev_notify_sem_create(cookie, &semid); } static const char *_task_type_disp(int type) { switch(type) { case DM_DEVICE_CREATE: return "CREATE"; case DM_DEVICE_RELOAD: return "RELOAD"; case DM_DEVICE_REMOVE: return "REMOVE"; case DM_DEVICE_REMOVE_ALL: return "REMOVE_ALL"; case DM_DEVICE_SUSPEND: return "SUSPEND"; case DM_DEVICE_RESUME: return "RESUME"; case DM_DEVICE_INFO: return "INFO"; case DM_DEVICE_DEPS: return "DEPS"; case DM_DEVICE_RENAME: return "RENAME"; case DM_DEVICE_VERSION: return "VERSION"; case DM_DEVICE_STATUS: return "STATUS"; case DM_DEVICE_TABLE: return "TABLE"; case DM_DEVICE_WAITEVENT: return "WAITEVENT"; case DM_DEVICE_LIST: return "LIST"; case DM_DEVICE_CLEAR: return "CLEAR"; case DM_DEVICE_MKNODES: return "MKNODES"; case DM_DEVICE_LIST_VERSIONS: return "LIST_VERSIONS"; case DM_DEVICE_TARGET_MSG: return "TARGET_MSG"; case DM_DEVICE_SET_GEOMETRY: return "SET_GEOMETRY"; } return "unknown"; } int dm_task_set_cookie(struct dm_task *dmt, uint32_t *cookie, uint16_t flags) { int semid; _set_cookie_flags(dmt, flags); if (!dm_udev_get_sync_support()) { *cookie = 0; dmt->cookie_set = 1; return 1; } if (*cookie) { if (!_get_cookie_sem(*cookie, &semid)) goto_bad; } else if (!_udev_notify_sem_create(cookie, &semid)) goto_bad; if (!_udev_notify_sem_inc(*cookie, semid)) { log_error("Could not set notification semaphore " "identified by cookie value %" PRIu32 " (0x%x)", *cookie, *cookie); goto bad; } dmt->event_nr |= ~DM_UDEV_FLAGS_MASK & *cookie; dmt->cookie_set = 1; log_debug_activation("Udev cookie 0x%" PRIx32 " (semid %d) assigned to " "%s task(%d) with flags%s%s%s%s%s%s%s (0x%" PRIx16 ")", *cookie, semid, _task_type_disp(dmt->type), dmt->type, (flags & DM_UDEV_DISABLE_DM_RULES_FLAG) ? " DISABLE_DM_RULES" : "", (flags & DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG) ? " DISABLE_SUBSYSTEM_RULES" : "", (flags & DM_UDEV_DISABLE_DISK_RULES_FLAG) ? " DISABLE_DISK_RULES" : "", (flags & DM_UDEV_DISABLE_OTHER_RULES_FLAG) ? " DISABLE_OTHER_RULES" : "", (flags & DM_UDEV_LOW_PRIORITY_FLAG) ? " LOW_PRIORITY" : "", (flags & DM_UDEV_DISABLE_LIBRARY_FALLBACK) ? " DISABLE_LIBRARY_FALLBACK" : "", (flags & DM_UDEV_PRIMARY_SOURCE_FLAG) ? " PRIMARY_SOURCE" : "", flags); return 1; bad: dmt->event_nr = 0; return 0; } int dm_udev_complete(uint32_t cookie) { int semid; if (!cookie || !dm_udev_get_sync_support()) return 1; if (!_get_cookie_sem(cookie, &semid)) return_0; if (!_udev_notify_sem_dec(cookie, semid)) { log_error("Could not signal waiting process using notification " "semaphore identified by cookie value %" PRIu32 " (0x%x)", cookie, cookie); return 0; } return 1; } static int _udev_wait(uint32_t cookie) { int semid; struct sembuf sb = {0, 0, 0}; if (!cookie || !dm_udev_get_sync_support()) return 1; if (!_get_cookie_sem(cookie, &semid)) return_0; if (!_udev_notify_sem_dec(cookie, semid)) { log_error("Failed to set a proper state for notification " "semaphore identified by cookie value %" PRIu32 " (0x%x) " "to initialize waiting for incoming notifications.", cookie, cookie); (void) _udev_notify_sem_destroy(cookie, semid); return 0; } log_debug_activation("Udev cookie 0x%" PRIx32 " (semid %d) waiting for zero", cookie, semid); repeat_wait: if (semop(semid, &sb, 1) < 0) { if (errno == EINTR) goto repeat_wait; else if (errno == EIDRM) return 1; log_error("Could not set wait state for notification semaphore " "identified by cookie value %" PRIu32 " (0x%x): %s", cookie, cookie, strerror(errno)); (void) _udev_notify_sem_destroy(cookie, semid); return 0; } return _udev_notify_sem_destroy(cookie, semid); } int dm_udev_wait(uint32_t cookie) { int r = _udev_wait(cookie); update_devs(); return r; } #endif /* UDEV_SYNC_SUPPORT */
Distrotech/LVM2
libdm/libdm-common.c
C
gpl-2.0
57,403
/* Coalesce SSA_NAMES together for the out-of-ssa pass. Copyright (C) 2004-2015 Free Software Foundation, Inc. Contributed by Andrew MacLeod <amacleod@redhat.com> This file is part of GCC. GCC 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 3, or (at your option) any later version. GCC 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 GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ #include "config.h" #include "system.h" #include "coretypes.h" #include "backend.h" #include "predict.h" #include "tree.h" #include "gimple.h" #include "hard-reg-set.h" #include "ssa.h" #include "alias.h" #include "fold-const.h" #include "flags.h" #include "tree-pretty-print.h" #include "dumpfile.h" #include "internal-fn.h" #include "gimple-iterator.h" #include "tree-ssa-live.h" #include "tree-ssa-coalesce.h" #include "cfgexpand.h" #include "explow.h" #include "diagnostic-core.h" /* This set of routines implements a coalesce_list. This is an object which is used to track pairs of ssa_names which are desirable to coalesce together to avoid copies. Costs are associated with each pair, and when all desired information has been collected, the object can be used to order the pairs for processing. */ /* This structure defines a pair entry. */ typedef struct coalesce_pair { int first_element; int second_element; int cost; } * coalesce_pair_p; typedef const struct coalesce_pair *const_coalesce_pair_p; /* Coalesce pair hashtable helpers. */ struct coalesce_pair_hasher : nofree_ptr_hash <coalesce_pair> { static inline hashval_t hash (const coalesce_pair *); static inline bool equal (const coalesce_pair *, const coalesce_pair *); }; /* Hash function for coalesce list. Calculate hash for PAIR. */ inline hashval_t coalesce_pair_hasher::hash (const coalesce_pair *pair) { hashval_t a = (hashval_t)(pair->first_element); hashval_t b = (hashval_t)(pair->second_element); return b * (b - 1) / 2 + a; } /* Equality function for coalesce list hash table. Compare PAIR1 and PAIR2, returning TRUE if the two pairs are equivalent. */ inline bool coalesce_pair_hasher::equal (const coalesce_pair *p1, const coalesce_pair *p2) { return (p1->first_element == p2->first_element && p1->second_element == p2->second_element); } typedef hash_table<coalesce_pair_hasher> coalesce_table_type; typedef coalesce_table_type::iterator coalesce_iterator_type; typedef struct cost_one_pair_d { int first_element; int second_element; struct cost_one_pair_d *next; } * cost_one_pair_p; /* This structure maintains the list of coalesce pairs. */ typedef struct coalesce_list_d { coalesce_table_type *list; /* Hash table. */ coalesce_pair_p *sorted; /* List when sorted. */ int num_sorted; /* Number in the sorted list. */ cost_one_pair_p cost_one_list;/* Single use coalesces with cost 1. */ } *coalesce_list_p; #define NO_BEST_COALESCE -1 #define MUST_COALESCE_COST INT_MAX /* Return cost of execution of copy instruction with FREQUENCY. */ static inline int coalesce_cost (int frequency, bool optimize_for_size) { /* Base costs on BB frequencies bounded by 1. */ int cost = frequency; if (!cost) cost = 1; if (optimize_for_size) cost = 1; return cost; } /* Return the cost of executing a copy instruction in basic block BB. */ static inline int coalesce_cost_bb (basic_block bb) { return coalesce_cost (bb->frequency, optimize_bb_for_size_p (bb)); } /* Return the cost of executing a copy instruction on edge E. */ static inline int coalesce_cost_edge (edge e) { int mult = 1; /* Inserting copy on critical edge costs more than inserting it elsewhere. */ if (EDGE_CRITICAL_P (e)) mult = 2; if (e->flags & EDGE_ABNORMAL) return MUST_COALESCE_COST; if (e->flags & EDGE_EH) { edge e2; edge_iterator ei; FOR_EACH_EDGE (e2, ei, e->dest->preds) if (e2 != e) { /* Putting code on EH edge that leads to BB with multiple predecestors imply splitting of edge too. */ if (mult < 2) mult = 2; /* If there are multiple EH predecestors, we also copy EH regions and produce separate landing pad. This is expensive. */ if (e2->flags & EDGE_EH) { mult = 5; break; } } } return coalesce_cost (EDGE_FREQUENCY (e), optimize_edge_for_size_p (e)) * mult; } /* Retrieve a pair to coalesce from the cost_one_list in CL. Returns the 2 elements via P1 and P2. 1 is returned by the function if there is a pair, NO_BEST_COALESCE is returned if there aren't any. */ static inline int pop_cost_one_pair (coalesce_list_p cl, int *p1, int *p2) { cost_one_pair_p ptr; ptr = cl->cost_one_list; if (!ptr) return NO_BEST_COALESCE; *p1 = ptr->first_element; *p2 = ptr->second_element; cl->cost_one_list = ptr->next; free (ptr); return 1; } /* Retrieve the most expensive remaining pair to coalesce from CL. Returns the 2 elements via P1 and P2. Their calculated cost is returned by the function. NO_BEST_COALESCE is returned if the coalesce list is empty. */ static inline int pop_best_coalesce (coalesce_list_p cl, int *p1, int *p2) { coalesce_pair_p node; int ret; if (cl->sorted == NULL) return pop_cost_one_pair (cl, p1, p2); if (cl->num_sorted == 0) return pop_cost_one_pair (cl, p1, p2); node = cl->sorted[--(cl->num_sorted)]; *p1 = node->first_element; *p2 = node->second_element; ret = node->cost; free (node); return ret; } /* Create a new empty coalesce list object and return it. */ static inline coalesce_list_p create_coalesce_list (void) { coalesce_list_p list; unsigned size = num_ssa_names * 3; if (size < 40) size = 40; list = (coalesce_list_p) xmalloc (sizeof (struct coalesce_list_d)); list->list = new coalesce_table_type (size); list->sorted = NULL; list->num_sorted = 0; list->cost_one_list = NULL; return list; } /* Delete coalesce list CL. */ static inline void delete_coalesce_list (coalesce_list_p cl) { gcc_assert (cl->cost_one_list == NULL); delete cl->list; cl->list = NULL; free (cl->sorted); gcc_assert (cl->num_sorted == 0); free (cl); } /* Find a matching coalesce pair object in CL for the pair P1 and P2. If one isn't found, return NULL if CREATE is false, otherwise create a new coalesce pair object and return it. */ static coalesce_pair_p find_coalesce_pair (coalesce_list_p cl, int p1, int p2, bool create) { struct coalesce_pair p; coalesce_pair **slot; unsigned int hash; /* Normalize so that p1 is the smaller value. */ if (p2 < p1) { p.first_element = p2; p.second_element = p1; } else { p.first_element = p1; p.second_element = p2; } hash = coalesce_pair_hasher::hash (&p); slot = cl->list->find_slot_with_hash (&p, hash, create ? INSERT : NO_INSERT); if (!slot) return NULL; if (!*slot) { struct coalesce_pair * pair = XNEW (struct coalesce_pair); gcc_assert (cl->sorted == NULL); pair->first_element = p.first_element; pair->second_element = p.second_element; pair->cost = 0; *slot = pair; } return (struct coalesce_pair *) *slot; } static inline void add_cost_one_coalesce (coalesce_list_p cl, int p1, int p2) { cost_one_pair_p pair; pair = XNEW (struct cost_one_pair_d); pair->first_element = p1; pair->second_element = p2; pair->next = cl->cost_one_list; cl->cost_one_list = pair; } /* Add a coalesce between P1 and P2 in list CL with a cost of VALUE. */ static inline void add_coalesce (coalesce_list_p cl, int p1, int p2, int value) { coalesce_pair_p node; gcc_assert (cl->sorted == NULL); if (p1 == p2) return; node = find_coalesce_pair (cl, p1, p2, true); /* Once the value is at least MUST_COALESCE_COST - 1, leave it that way. */ if (node->cost < MUST_COALESCE_COST - 1) { if (value < MUST_COALESCE_COST - 1) node->cost += value; else node->cost = value; } } /* Comparison function to allow qsort to sort P1 and P2 in Ascending order. */ static int compare_pairs (const void *p1, const void *p2) { const_coalesce_pair_p const *const pp1 = (const_coalesce_pair_p const *) p1; const_coalesce_pair_p const *const pp2 = (const_coalesce_pair_p const *) p2; int result; result = (* pp1)->cost - (* pp2)->cost; /* Since qsort does not guarantee stability we use the elements as a secondary key. This provides us with independence from the host's implementation of the sorting algorithm. */ if (result == 0) { result = (* pp2)->first_element - (* pp1)->first_element; if (result == 0) result = (* pp2)->second_element - (* pp1)->second_element; } return result; } /* Return the number of unique coalesce pairs in CL. */ static inline int num_coalesce_pairs (coalesce_list_p cl) { return cl->list->elements (); } /* Iterate over CL using ITER, returning values in PAIR. */ #define FOR_EACH_PARTITION_PAIR(PAIR, ITER, CL) \ FOR_EACH_HASH_TABLE_ELEMENT (*(CL)->list, (PAIR), coalesce_pair_p, (ITER)) /* Prepare CL for removal of preferred pairs. When finished they are sorted in order from most important coalesce to least important. */ static void sort_coalesce_list (coalesce_list_p cl) { unsigned x, num; coalesce_pair_p p; coalesce_iterator_type ppi; gcc_assert (cl->sorted == NULL); num = num_coalesce_pairs (cl); cl->num_sorted = num; if (num == 0) return; /* Allocate a vector for the pair pointers. */ cl->sorted = XNEWVEC (coalesce_pair_p, num); /* Populate the vector with pointers to the pairs. */ x = 0; FOR_EACH_PARTITION_PAIR (p, ppi, cl) cl->sorted[x++] = p; gcc_assert (x == num); /* Already sorted. */ if (num == 1) return; /* If there are only 2, just pick swap them if the order isn't correct. */ if (num == 2) { if (cl->sorted[0]->cost > cl->sorted[1]->cost) std::swap (cl->sorted[0], cl->sorted[1]); return; } /* Only call qsort if there are more than 2 items. ??? Maybe std::sort will do better, provided that compare_pairs can be inlined. */ if (num > 2) qsort (cl->sorted, num, sizeof (coalesce_pair_p), compare_pairs); } /* Send debug info for coalesce list CL to file F. */ static void dump_coalesce_list (FILE *f, coalesce_list_p cl) { coalesce_pair_p node; coalesce_iterator_type ppi; int x; tree var; if (cl->sorted == NULL) { fprintf (f, "Coalesce List:\n"); FOR_EACH_PARTITION_PAIR (node, ppi, cl) { tree var1 = ssa_name (node->first_element); tree var2 = ssa_name (node->second_element); print_generic_expr (f, var1, TDF_SLIM); fprintf (f, " <-> "); print_generic_expr (f, var2, TDF_SLIM); fprintf (f, " (%1d), ", node->cost); fprintf (f, "\n"); } } else { fprintf (f, "Sorted Coalesce list:\n"); for (x = cl->num_sorted - 1 ; x >=0; x--) { node = cl->sorted[x]; fprintf (f, "(%d) ", node->cost); var = ssa_name (node->first_element); print_generic_expr (f, var, TDF_SLIM); fprintf (f, " <-> "); var = ssa_name (node->second_element); print_generic_expr (f, var, TDF_SLIM); fprintf (f, "\n"); } } } /* This represents a conflict graph. Implemented as an array of bitmaps. A full matrix is used for conflicts rather than just upper triangular form. this make sit much simpler and faster to perform conflict merges. */ typedef struct ssa_conflicts_d { bitmap_obstack obstack; /* A place to allocate our bitmaps. */ vec<bitmap> conflicts; } * ssa_conflicts_p; /* Return an empty new conflict graph for SIZE elements. */ static inline ssa_conflicts_p ssa_conflicts_new (unsigned size) { ssa_conflicts_p ptr; ptr = XNEW (struct ssa_conflicts_d); bitmap_obstack_initialize (&ptr->obstack); ptr->conflicts.create (size); ptr->conflicts.safe_grow_cleared (size); return ptr; } /* Free storage for conflict graph PTR. */ static inline void ssa_conflicts_delete (ssa_conflicts_p ptr) { bitmap_obstack_release (&ptr->obstack); ptr->conflicts.release (); free (ptr); } /* Test if elements X and Y conflict in graph PTR. */ static inline bool ssa_conflicts_test_p (ssa_conflicts_p ptr, unsigned x, unsigned y) { bitmap bx = ptr->conflicts[x]; bitmap by = ptr->conflicts[y]; gcc_checking_assert (x != y); if (bx) /* Avoid the lookup if Y has no conflicts. */ return by ? bitmap_bit_p (bx, y) : false; else return false; } /* Add a conflict with Y to the bitmap for X in graph PTR. */ static inline void ssa_conflicts_add_one (ssa_conflicts_p ptr, unsigned x, unsigned y) { bitmap bx = ptr->conflicts[x]; /* If there are no conflicts yet, allocate the bitmap and set bit. */ if (! bx) bx = ptr->conflicts[x] = BITMAP_ALLOC (&ptr->obstack); bitmap_set_bit (bx, y); } /* Add conflicts between X and Y in graph PTR. */ static inline void ssa_conflicts_add (ssa_conflicts_p ptr, unsigned x, unsigned y) { gcc_checking_assert (x != y); ssa_conflicts_add_one (ptr, x, y); ssa_conflicts_add_one (ptr, y, x); } /* Merge all Y's conflict into X in graph PTR. */ static inline void ssa_conflicts_merge (ssa_conflicts_p ptr, unsigned x, unsigned y) { unsigned z; bitmap_iterator bi; bitmap bx = ptr->conflicts[x]; bitmap by = ptr->conflicts[y]; gcc_checking_assert (x != y); if (! by) return; /* Add a conflict between X and every one Y has. If the bitmap doesn't exist, then it has already been coalesced, and we don't need to add a conflict. */ EXECUTE_IF_SET_IN_BITMAP (by, 0, z, bi) { bitmap bz = ptr->conflicts[z]; if (bz) bitmap_set_bit (bz, x); } if (bx) { /* If X has conflicts, add Y's to X. */ bitmap_ior_into (bx, by); BITMAP_FREE (by); ptr->conflicts[y] = NULL; } else { /* If X has no conflicts, simply use Y's. */ ptr->conflicts[x] = by; ptr->conflicts[y] = NULL; } } /* Dump a conflicts graph. */ static void ssa_conflicts_dump (FILE *file, ssa_conflicts_p ptr) { unsigned x; bitmap b; fprintf (file, "\nConflict graph:\n"); FOR_EACH_VEC_ELT (ptr->conflicts, x, b) if (b) { fprintf (file, "%d: ", x); dump_bitmap (file, b); } } /* This structure is used to efficiently record the current status of live SSA_NAMES when building a conflict graph. LIVE_BASE_VAR has a bit set for each base variable which has at least one ssa version live. LIVE_BASE_PARTITIONS is an array of bitmaps using the basevar table as an index, and is used to track what partitions of each base variable are live. This makes it easy to add conflicts between just live partitions with the same base variable. The values in LIVE_BASE_PARTITIONS are only valid if the base variable is marked as being live. This delays clearing of these bitmaps until they are actually needed again. */ typedef struct live_track_d { bitmap_obstack obstack; /* A place to allocate our bitmaps. */ bitmap live_base_var; /* Indicates if a basevar is live. */ bitmap *live_base_partitions; /* Live partitions for each basevar. */ var_map map; /* Var_map being used for partition mapping. */ } * live_track_p; /* This routine will create a new live track structure based on the partitions in MAP. */ static live_track_p new_live_track (var_map map) { live_track_p ptr; int lim, x; /* Make sure there is a partition view in place. */ gcc_assert (map->partition_to_base_index != NULL); ptr = (live_track_p) xmalloc (sizeof (struct live_track_d)); ptr->map = map; lim = num_basevars (map); bitmap_obstack_initialize (&ptr->obstack); ptr->live_base_partitions = (bitmap *) xmalloc (sizeof (bitmap *) * lim); ptr->live_base_var = BITMAP_ALLOC (&ptr->obstack); for (x = 0; x < lim; x++) ptr->live_base_partitions[x] = BITMAP_ALLOC (&ptr->obstack); return ptr; } /* This routine will free the memory associated with PTR. */ static void delete_live_track (live_track_p ptr) { bitmap_obstack_release (&ptr->obstack); free (ptr->live_base_partitions); free (ptr); } /* This function will remove PARTITION from the live list in PTR. */ static inline void live_track_remove_partition (live_track_p ptr, int partition) { int root; root = basevar_index (ptr->map, partition); bitmap_clear_bit (ptr->live_base_partitions[root], partition); /* If the element list is empty, make the base variable not live either. */ if (bitmap_empty_p (ptr->live_base_partitions[root])) bitmap_clear_bit (ptr->live_base_var, root); } /* This function will adds PARTITION to the live list in PTR. */ static inline void live_track_add_partition (live_track_p ptr, int partition) { int root; root = basevar_index (ptr->map, partition); /* If this base var wasn't live before, it is now. Clear the element list since it was delayed until needed. */ if (bitmap_set_bit (ptr->live_base_var, root)) bitmap_clear (ptr->live_base_partitions[root]); bitmap_set_bit (ptr->live_base_partitions[root], partition); } /* Clear the live bit for VAR in PTR. */ static inline void live_track_clear_var (live_track_p ptr, tree var) { int p; p = var_to_partition (ptr->map, var); if (p != NO_PARTITION) live_track_remove_partition (ptr, p); } /* Return TRUE if VAR is live in PTR. */ static inline bool live_track_live_p (live_track_p ptr, tree var) { int p, root; p = var_to_partition (ptr->map, var); if (p != NO_PARTITION) { root = basevar_index (ptr->map, p); if (bitmap_bit_p (ptr->live_base_var, root)) return bitmap_bit_p (ptr->live_base_partitions[root], p); } return false; } /* This routine will add USE to PTR. USE will be marked as live in both the ssa live map and the live bitmap for the root of USE. */ static inline void live_track_process_use (live_track_p ptr, tree use) { int p; p = var_to_partition (ptr->map, use); if (p == NO_PARTITION) return; /* Mark as live in the appropriate live list. */ live_track_add_partition (ptr, p); } /* This routine will process a DEF in PTR. DEF will be removed from the live lists, and if there are any other live partitions with the same base variable, conflicts will be added to GRAPH. */ static inline void live_track_process_def (live_track_p ptr, tree def, ssa_conflicts_p graph) { int p, root; bitmap b; unsigned x; bitmap_iterator bi; p = var_to_partition (ptr->map, def); if (p == NO_PARTITION) return; /* Clear the liveness bit. */ live_track_remove_partition (ptr, p); /* If the bitmap isn't empty now, conflicts need to be added. */ root = basevar_index (ptr->map, p); if (bitmap_bit_p (ptr->live_base_var, root)) { b = ptr->live_base_partitions[root]; EXECUTE_IF_SET_IN_BITMAP (b, 0, x, bi) ssa_conflicts_add (graph, p, x); } } /* Initialize PTR with the partitions set in INIT. */ static inline void live_track_init (live_track_p ptr, bitmap init) { unsigned p; bitmap_iterator bi; /* Mark all live on exit partitions. */ EXECUTE_IF_SET_IN_BITMAP (init, 0, p, bi) live_track_add_partition (ptr, p); } /* This routine will clear all live partitions in PTR. */ static inline void live_track_clear_base_vars (live_track_p ptr) { /* Simply clear the live base list. Anything marked as live in the element lists will be cleared later if/when the base variable ever comes alive again. */ bitmap_clear (ptr->live_base_var); } /* Build a conflict graph based on LIVEINFO. Any partitions which are in the partition view of the var_map liveinfo is based on get entries in the conflict graph. Only conflicts between ssa_name partitions with the same base variable are added. */ static ssa_conflicts_p build_ssa_conflict_graph (tree_live_info_p liveinfo) { ssa_conflicts_p graph; var_map map; basic_block bb; ssa_op_iter iter; live_track_p live; basic_block entry; /* If inter-variable coalescing is enabled, we may attempt to coalesce variables from different base variables, including different parameters, so we have to make sure default defs live at the entry block conflict with each other. */ if (flag_tree_coalesce_vars) entry = single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)); else entry = NULL; map = live_var_map (liveinfo); graph = ssa_conflicts_new (num_var_partitions (map)); live = new_live_track (map); FOR_EACH_BB_FN (bb, cfun) { /* Start with live on exit temporaries. */ live_track_init (live, live_on_exit (liveinfo, bb)); for (gimple_stmt_iterator gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi)) { tree var; gimple stmt = gsi_stmt (gsi); /* A copy between 2 partitions does not introduce an interference by itself. If they did, you would never be able to coalesce two things which are copied. If the two variables really do conflict, they will conflict elsewhere in the program. This is handled by simply removing the SRC of the copy from the live list, and processing the stmt normally. */ if (is_gimple_assign (stmt)) { tree lhs = gimple_assign_lhs (stmt); tree rhs1 = gimple_assign_rhs1 (stmt); if (gimple_assign_copy_p (stmt) && TREE_CODE (lhs) == SSA_NAME && TREE_CODE (rhs1) == SSA_NAME) live_track_clear_var (live, rhs1); } else if (is_gimple_debug (stmt)) continue; FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_DEF) live_track_process_def (live, var, graph); FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_USE) live_track_process_use (live, var); } /* If result of a PHI is unused, looping over the statements will not record any conflicts since the def was never live. Since the PHI node is going to be translated out of SSA form, it will insert a copy. There must be a conflict recorded between the result of the PHI and any variables that are live. Otherwise the out-of-ssa translation may create incorrect code. */ for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { gphi *phi = gsi.phi (); tree result = PHI_RESULT (phi); if (live_track_live_p (live, result)) live_track_process_def (live, result, graph); } /* Pretend there are defs for params' default defs at the start of the (post-)entry block. */ if (bb == entry) { unsigned base; bitmap_iterator bi; EXECUTE_IF_SET_IN_BITMAP (live->live_base_var, 0, base, bi) { bitmap_iterator bi2; unsigned part; EXECUTE_IF_SET_IN_BITMAP (live->live_base_partitions[base], 0, part, bi2) { tree var = partition_to_var (map, part); if (!SSA_NAME_VAR (var) || (TREE_CODE (SSA_NAME_VAR (var)) != PARM_DECL && TREE_CODE (SSA_NAME_VAR (var)) != RESULT_DECL) || !SSA_NAME_IS_DEFAULT_DEF (var)) continue; live_track_process_def (live, var, graph); } } } live_track_clear_base_vars (live); } delete_live_track (live); return graph; } /* Shortcut routine to print messages to file F of the form: "STR1 EXPR1 STR2 EXPR2 STR3." */ static inline void print_exprs (FILE *f, const char *str1, tree expr1, const char *str2, tree expr2, const char *str3) { fprintf (f, "%s", str1); print_generic_expr (f, expr1, TDF_SLIM); fprintf (f, "%s", str2); print_generic_expr (f, expr2, TDF_SLIM); fprintf (f, "%s", str3); } /* Print a failure to coalesce a MUST_COALESCE pair X and Y. */ static inline void fail_abnormal_edge_coalesce (int x, int y) { fprintf (stderr, "\nUnable to coalesce ssa_names %d and %d",x, y); fprintf (stderr, " which are marked as MUST COALESCE.\n"); print_generic_expr (stderr, ssa_name (x), TDF_SLIM); fprintf (stderr, " and "); print_generic_stmt (stderr, ssa_name (y), TDF_SLIM); internal_error ("SSA corruption"); } /* This function creates a var_map for the current function as well as creating a coalesce list for use later in the out of ssa process. */ static var_map create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy) { gimple_stmt_iterator gsi; basic_block bb; tree var; gimple stmt; tree first; var_map map; ssa_op_iter iter; int v1, v2, cost; unsigned i; map = init_var_map (num_ssa_names); FOR_EACH_BB_FN (bb, cfun) { tree arg; for (gphi_iterator gpi = gsi_start_phis (bb); !gsi_end_p (gpi); gsi_next (&gpi)) { gphi *phi = gpi.phi (); size_t i; int ver; tree res; bool saw_copy = false; res = gimple_phi_result (phi); ver = SSA_NAME_VERSION (res); register_ssa_partition (map, res); /* Register ssa_names and coalesces between the args and the result of all PHI. */ for (i = 0; i < gimple_phi_num_args (phi); i++) { edge e = gimple_phi_arg_edge (phi, i); arg = PHI_ARG_DEF (phi, i); if (TREE_CODE (arg) != SSA_NAME) continue; register_ssa_partition (map, arg); if (gimple_can_coalesce_p (arg, res) || (e->flags & EDGE_ABNORMAL)) { saw_copy = true; bitmap_set_bit (used_in_copy, SSA_NAME_VERSION (arg)); if ((e->flags & EDGE_ABNORMAL) == 0) { int cost = coalesce_cost_edge (e); if (cost == 1 && has_single_use (arg)) add_cost_one_coalesce (cl, ver, SSA_NAME_VERSION (arg)); else add_coalesce (cl, ver, SSA_NAME_VERSION (arg), cost); } } } if (saw_copy) bitmap_set_bit (used_in_copy, ver); } for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { stmt = gsi_stmt (gsi); if (is_gimple_debug (stmt)) continue; /* Register USE and DEF operands in each statement. */ FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, (SSA_OP_DEF|SSA_OP_USE)) register_ssa_partition (map, var); /* Check for copy coalesces. */ switch (gimple_code (stmt)) { case GIMPLE_ASSIGN: { tree lhs = gimple_assign_lhs (stmt); tree rhs1 = gimple_assign_rhs1 (stmt); if (gimple_assign_ssa_name_copy_p (stmt) && gimple_can_coalesce_p (lhs, rhs1)) { v1 = SSA_NAME_VERSION (lhs); v2 = SSA_NAME_VERSION (rhs1); cost = coalesce_cost_bb (bb); add_coalesce (cl, v1, v2, cost); bitmap_set_bit (used_in_copy, v1); bitmap_set_bit (used_in_copy, v2); } } break; case GIMPLE_ASM: { gasm *asm_stmt = as_a <gasm *> (stmt); unsigned long noutputs, i; unsigned long ninputs; tree *outputs, link; noutputs = gimple_asm_noutputs (asm_stmt); ninputs = gimple_asm_ninputs (asm_stmt); outputs = (tree *) alloca (noutputs * sizeof (tree)); for (i = 0; i < noutputs; ++i) { link = gimple_asm_output_op (asm_stmt, i); outputs[i] = TREE_VALUE (link); } for (i = 0; i < ninputs; ++i) { const char *constraint; tree input; char *end; unsigned long match; link = gimple_asm_input_op (asm_stmt, i); constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (link))); input = TREE_VALUE (link); if (TREE_CODE (input) != SSA_NAME) continue; match = strtoul (constraint, &end, 10); if (match >= noutputs || end == constraint) continue; if (TREE_CODE (outputs[match]) != SSA_NAME) continue; v1 = SSA_NAME_VERSION (outputs[match]); v2 = SSA_NAME_VERSION (input); if (gimple_can_coalesce_p (outputs[match], input)) { cost = coalesce_cost (REG_BR_PROB_BASE, optimize_bb_for_size_p (bb)); add_coalesce (cl, v1, v2, cost); bitmap_set_bit (used_in_copy, v1); bitmap_set_bit (used_in_copy, v2); } } break; } default: break; } } } /* Now process result decls and live on entry variables for entry into the coalesce list. */ first = NULL_TREE; for (i = 1; i < num_ssa_names; i++) { var = ssa_name (i); if (var != NULL_TREE && !virtual_operand_p (var)) { /* Add coalesces between all the result decls. */ if (SSA_NAME_VAR (var) && TREE_CODE (SSA_NAME_VAR (var)) == RESULT_DECL) { if (first == NULL_TREE) first = var; else { gcc_assert (gimple_can_coalesce_p (var, first)); v1 = SSA_NAME_VERSION (first); v2 = SSA_NAME_VERSION (var); bitmap_set_bit (used_in_copy, v1); bitmap_set_bit (used_in_copy, v2); cost = coalesce_cost_bb (EXIT_BLOCK_PTR_FOR_FN (cfun)); add_coalesce (cl, v1, v2, cost); } } /* Mark any default_def variables as being in the coalesce list since they will have to be coalesced with the base variable. If not marked as present, they won't be in the coalesce view. */ if (SSA_NAME_IS_DEFAULT_DEF (var) && !has_zero_uses (var)) bitmap_set_bit (used_in_copy, SSA_NAME_VERSION (var)); } } return map; } /* Attempt to coalesce ssa versions X and Y together using the partition mapping in MAP and checking conflicts in GRAPH. Output any debug info to DEBUG, if it is nun-NULL. */ static inline bool attempt_coalesce (var_map map, ssa_conflicts_p graph, int x, int y, FILE *debug) { int z; tree var1, var2; int p1, p2; p1 = var_to_partition (map, ssa_name (x)); p2 = var_to_partition (map, ssa_name (y)); if (debug) { fprintf (debug, "(%d)", x); print_generic_expr (debug, partition_to_var (map, p1), TDF_SLIM); fprintf (debug, " & (%d)", y); print_generic_expr (debug, partition_to_var (map, p2), TDF_SLIM); } if (p1 == p2) { if (debug) fprintf (debug, ": Already Coalesced.\n"); return true; } if (debug) fprintf (debug, " [map: %d, %d] ", p1, p2); if (!ssa_conflicts_test_p (graph, p1, p2)) { var1 = partition_to_var (map, p1); var2 = partition_to_var (map, p2); z = var_union (map, var1, var2); if (z == NO_PARTITION) { if (debug) fprintf (debug, ": Unable to perform partition union.\n"); return false; } /* z is the new combined partition. Remove the other partition from the list, and merge the conflicts. */ if (z == p1) ssa_conflicts_merge (graph, p1, p2); else ssa_conflicts_merge (graph, p2, p1); if (debug) fprintf (debug, ": Success -> %d\n", z); return true; } if (debug) fprintf (debug, ": Fail due to conflict\n"); return false; } /* Attempt to Coalesce partitions in MAP which occur in the list CL using GRAPH. Debug output is sent to DEBUG if it is non-NULL. */ static void coalesce_partitions (var_map map, ssa_conflicts_p graph, coalesce_list_p cl, FILE *debug) { int x = 0, y = 0; tree var1, var2; int cost; basic_block bb; edge e; edge_iterator ei; /* First, coalesce all the copies across abnormal edges. These are not placed in the coalesce list because they do not need to be sorted, and simply consume extra memory/compilation time in large programs. */ FOR_EACH_BB_FN (bb, cfun) { FOR_EACH_EDGE (e, ei, bb->preds) if (e->flags & EDGE_ABNORMAL) { gphi_iterator gsi; for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { gphi *phi = gsi.phi (); tree arg = PHI_ARG_DEF (phi, e->dest_idx); if (SSA_NAME_IS_DEFAULT_DEF (arg) && (!SSA_NAME_VAR (arg) || TREE_CODE (SSA_NAME_VAR (arg)) != PARM_DECL)) continue; tree res = PHI_RESULT (phi); int v1 = SSA_NAME_VERSION (res); int v2 = SSA_NAME_VERSION (arg); if (debug) fprintf (debug, "Abnormal coalesce: "); if (!attempt_coalesce (map, graph, v1, v2, debug)) fail_abnormal_edge_coalesce (v1, v2); } } } /* Now process the items in the coalesce list. */ while ((cost = pop_best_coalesce (cl, &x, &y)) != NO_BEST_COALESCE) { var1 = ssa_name (x); var2 = ssa_name (y); /* Assert the coalesces have the same base variable. */ gcc_assert (gimple_can_coalesce_p (var1, var2)); if (debug) fprintf (debug, "Coalesce list: "); attempt_coalesce (map, graph, x, y, debug); } } /* Hashtable support for storing SSA names hashed by their SSA_NAME_VAR. */ struct ssa_name_var_hash : nofree_ptr_hash <tree_node> { static inline hashval_t hash (const tree_node *); static inline int equal (const tree_node *, const tree_node *); }; inline hashval_t ssa_name_var_hash::hash (const_tree n) { return DECL_UID (SSA_NAME_VAR (n)); } inline int ssa_name_var_hash::equal (const tree_node *n1, const tree_node *n2) { return SSA_NAME_VAR (n1) == SSA_NAME_VAR (n2); } /* Output partition map MAP with coalescing plan PART to file F. */ void dump_part_var_map (FILE *f, partition part, var_map map) { int t; unsigned x, y; int p; fprintf (f, "\nCoalescible Partition map \n\n"); for (x = 0; x < map->num_partitions; x++) { if (map->view_to_partition != NULL) p = map->view_to_partition[x]; else p = x; if (ssa_name (p) == NULL_TREE || virtual_operand_p (ssa_name (p))) continue; t = 0; for (y = 1; y < num_ssa_names; y++) { tree var = version_to_var (map, y); if (!var) continue; int q = var_to_partition (map, var); p = partition_find (part, q); gcc_assert (map->partition_to_base_index[q] == map->partition_to_base_index[p]); if (p == (int)x) { if (t++ == 0) { fprintf (f, "Partition %d, base %d (", x, map->partition_to_base_index[q]); print_generic_expr (f, partition_to_var (map, q), TDF_SLIM); fprintf (f, " - "); } fprintf (f, "%d ", y); } } if (t != 0) fprintf (f, ")\n"); } fprintf (f, "\n"); } /* Given SSA_NAMEs NAME1 and NAME2, return true if they are candidates for coalescing together, false otherwise. This must stay consistent with var_map_base_init in tree-ssa-live.c. */ bool gimple_can_coalesce_p (tree name1, tree name2) { /* First check the SSA_NAME's associated DECL. Without optimization, we only want to coalesce if they have the same DECL or both have no associated DECL. */ tree var1 = SSA_NAME_VAR (name1); tree var2 = SSA_NAME_VAR (name2); var1 = (var1 && (!VAR_P (var1) || !DECL_IGNORED_P (var1))) ? var1 : NULL_TREE; var2 = (var2 && (!VAR_P (var2) || !DECL_IGNORED_P (var2))) ? var2 : NULL_TREE; if (var1 != var2 && !flag_tree_coalesce_vars) return false; /* Now check the types. If the types are the same, then we should try to coalesce V1 and V2. */ tree t1 = TREE_TYPE (name1); tree t2 = TREE_TYPE (name2); if (t1 == t2) { check_modes: /* If the base variables are the same, we're good: none of the other tests below could possibly fail. */ var1 = SSA_NAME_VAR (name1); var2 = SSA_NAME_VAR (name2); if (var1 == var2) return true; /* We don't want to coalesce two SSA names if one of the base variables is supposed to be a register while the other is supposed to be on the stack. Anonymous SSA names take registers, but when not optimizing, user variables should go on the stack, so coalescing them with the anonymous variable as the partition leader would end up assigning the user variable to a register. Don't do that! */ bool reg1 = !var1 || use_register_for_decl (var1); bool reg2 = !var2 || use_register_for_decl (var2); if (reg1 != reg2) return false; /* Check that the promoted modes are the same. We don't want to coalesce if the promoted modes would be different. Only PARM_DECLs and RESULT_DECLs have different promotion rules, so skip the test if both are variables, or both are anonymous SSA_NAMEs. Now, if a parm or result has BLKmode, do not coalesce its SSA versions with those of any other variables, because it may be passed by reference. */ return ((!var1 || VAR_P (var1)) && (!var2 || VAR_P (var2))) || (/* The case var1 == var2 is already covered above. */ !parm_maybe_byref_p (var1) && !parm_maybe_byref_p (var2) && promote_ssa_mode (name1, NULL) == promote_ssa_mode (name2, NULL)); } /* If the types are not the same, check for a canonical type match. This (for example) allows coalescing when the types are fundamentally the same, but just have different names. Note pointer types with different address spaces may have the same canonical type. Those are rejected for coalescing by the types_compatible_p check. */ if (TYPE_CANONICAL (t1) && TYPE_CANONICAL (t1) == TYPE_CANONICAL (t2) && types_compatible_p (t1, t2)) goto check_modes; return false; } /* Fill in MAP's partition_to_base_index, with one index for each partition of SSA names USED_IN_COPIES and related by CL coalesce possibilities. This must match gimple_can_coalesce_p in the optimized case. */ static void compute_optimized_partition_bases (var_map map, bitmap used_in_copies, coalesce_list_p cl) { int parts = num_var_partitions (map); partition tentative = partition_new (parts); /* Partition the SSA versions so that, for each coalescible pair, both of its members are in the same partition in TENTATIVE. */ gcc_assert (!cl->sorted); coalesce_pair_p node; coalesce_iterator_type ppi; FOR_EACH_PARTITION_PAIR (node, ppi, cl) { tree v1 = ssa_name (node->first_element); int p1 = partition_find (tentative, var_to_partition (map, v1)); tree v2 = ssa_name (node->second_element); int p2 = partition_find (tentative, var_to_partition (map, v2)); if (p1 == p2) continue; partition_union (tentative, p1, p2); } /* We have to deal with cost one pairs too. */ for (cost_one_pair_d *co = cl->cost_one_list; co; co = co->next) { tree v1 = ssa_name (co->first_element); int p1 = partition_find (tentative, var_to_partition (map, v1)); tree v2 = ssa_name (co->second_element); int p2 = partition_find (tentative, var_to_partition (map, v2)); if (p1 == p2) continue; partition_union (tentative, p1, p2); } /* And also with abnormal edges. */ basic_block bb; edge e; edge_iterator ei; FOR_EACH_BB_FN (bb, cfun) { FOR_EACH_EDGE (e, ei, bb->preds) if (e->flags & EDGE_ABNORMAL) { gphi_iterator gsi; for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { gphi *phi = gsi.phi (); tree arg = PHI_ARG_DEF (phi, e->dest_idx); if (SSA_NAME_IS_DEFAULT_DEF (arg) && (!SSA_NAME_VAR (arg) || TREE_CODE (SSA_NAME_VAR (arg)) != PARM_DECL)) continue; tree res = PHI_RESULT (phi); int p1 = partition_find (tentative, var_to_partition (map, res)); int p2 = partition_find (tentative, var_to_partition (map, arg)); if (p1 == p2) continue; partition_union (tentative, p1, p2); } } } map->partition_to_base_index = XCNEWVEC (int, parts); auto_vec<unsigned int> index_map (parts); if (parts) index_map.quick_grow (parts); const unsigned no_part = -1; unsigned count = parts; while (count) index_map[--count] = no_part; /* Initialize MAP's mapping from partition to base index, using as base indices an enumeration of the TENTATIVE partitions in which each SSA version ended up, so that we compute conflicts between all SSA versions that ended up in the same potential coalesce partition. */ bitmap_iterator bi; unsigned i; EXECUTE_IF_SET_IN_BITMAP (used_in_copies, 0, i, bi) { int pidx = var_to_partition (map, ssa_name (i)); int base = partition_find (tentative, pidx); if (index_map[base] != no_part) continue; index_map[base] = count++; } map->num_basevars = count; EXECUTE_IF_SET_IN_BITMAP (used_in_copies, 0, i, bi) { int pidx = var_to_partition (map, ssa_name (i)); int base = partition_find (tentative, pidx); gcc_assert (index_map[base] < count); map->partition_to_base_index[pidx] = index_map[base]; } if (dump_file && (dump_flags & TDF_DETAILS)) dump_part_var_map (dump_file, tentative, map); partition_delete (tentative); } /* Hashtable helpers. */ struct tree_int_map_hasher : nofree_ptr_hash <tree_int_map> { static inline hashval_t hash (const tree_int_map *); static inline bool equal (const tree_int_map *, const tree_int_map *); }; inline hashval_t tree_int_map_hasher::hash (const tree_int_map *v) { return tree_map_base_hash (v); } inline bool tree_int_map_hasher::equal (const tree_int_map *v, const tree_int_map *c) { return tree_int_map_eq (v, c); } /* This routine will initialize the basevar fields of MAP with base names. Partitions will share the same base if they have the same SSA_NAME_VAR, or, being anonymous variables, the same type. This must match gimple_can_coalesce_p in the non-optimized case. */ static void compute_samebase_partition_bases (var_map map) { int x, num_part; tree var; struct tree_int_map *m, *mapstorage; num_part = num_var_partitions (map); hash_table<tree_int_map_hasher> tree_to_index (num_part); /* We can have at most num_part entries in the hash tables, so it's enough to allocate so many map elements once, saving some malloc calls. */ mapstorage = m = XNEWVEC (struct tree_int_map, num_part); /* If a base table already exists, clear it, otherwise create it. */ free (map->partition_to_base_index); map->partition_to_base_index = (int *) xmalloc (sizeof (int) * num_part); /* Build the base variable list, and point partitions at their bases. */ for (x = 0; x < num_part; x++) { struct tree_int_map **slot; unsigned baseindex; var = partition_to_var (map, x); if (SSA_NAME_VAR (var) && (!VAR_P (SSA_NAME_VAR (var)) || !DECL_IGNORED_P (SSA_NAME_VAR (var)))) m->base.from = SSA_NAME_VAR (var); else /* This restricts what anonymous SSA names we can coalesce as it restricts the sets we compute conflicts for. Using TREE_TYPE to generate sets is the easies as type equivalency also holds for SSA names with the same underlying decl. Check gimple_can_coalesce_p when changing this code. */ m->base.from = (TYPE_CANONICAL (TREE_TYPE (var)) ? TYPE_CANONICAL (TREE_TYPE (var)) : TREE_TYPE (var)); /* If base variable hasn't been seen, set it up. */ slot = tree_to_index.find_slot (m, INSERT); if (!*slot) { baseindex = m - mapstorage; m->to = baseindex; *slot = m; m++; } else baseindex = (*slot)->to; map->partition_to_base_index[x] = baseindex; } map->num_basevars = m - mapstorage; free (mapstorage); } /* Reduce the number of copies by coalescing variables in the function. Return a partition map with the resulting coalesces. */ extern var_map coalesce_ssa_name (void) { tree_live_info_p liveinfo; ssa_conflicts_p graph; coalesce_list_p cl; bitmap used_in_copies = BITMAP_ALLOC (NULL); var_map map; unsigned int i; cl = create_coalesce_list (); map = create_outofssa_var_map (cl, used_in_copies); /* If this optimization is disabled, we need to coalesce all the names originating from the same SSA_NAME_VAR so debug info remains undisturbed. */ if (!flag_tree_coalesce_vars) { hash_table<ssa_name_var_hash> ssa_name_hash (10); for (i = 1; i < num_ssa_names; i++) { tree a = ssa_name (i); if (a && SSA_NAME_VAR (a) && !DECL_IGNORED_P (SSA_NAME_VAR (a)) && (!has_zero_uses (a) || !SSA_NAME_IS_DEFAULT_DEF (a))) { tree *slot = ssa_name_hash.find_slot (a, INSERT); if (!*slot) *slot = a; else { /* If the variable is a PARM_DECL or a RESULT_DECL, we _require_ that all the names originating from it be coalesced, because there must be a single partition containing all the names so that it can be assigned the canonical RTL location of the DECL safely. If in_lto_p, a function could have been compiled originally with optimizations and only the link performed at -O0, so we can't actually require it. */ const int cost = (TREE_CODE (SSA_NAME_VAR (a)) == VAR_DECL || in_lto_p) ? MUST_COALESCE_COST - 1 : MUST_COALESCE_COST; add_coalesce (cl, SSA_NAME_VERSION (a), SSA_NAME_VERSION (*slot), cost); bitmap_set_bit (used_in_copies, SSA_NAME_VERSION (a)); bitmap_set_bit (used_in_copies, SSA_NAME_VERSION (*slot)); } } } } if (dump_file && (dump_flags & TDF_DETAILS)) dump_var_map (dump_file, map); partition_view_bitmap (map, used_in_copies); if (flag_tree_coalesce_vars) compute_optimized_partition_bases (map, used_in_copies, cl); else compute_samebase_partition_bases (map); BITMAP_FREE (used_in_copies); if (num_var_partitions (map) < 1) { delete_coalesce_list (cl); return map; } if (dump_file && (dump_flags & TDF_DETAILS)) dump_var_map (dump_file, map); liveinfo = calculate_live_ranges (map, false); if (dump_file && (dump_flags & TDF_DETAILS)) dump_live_info (dump_file, liveinfo, LIVEDUMP_ENTRY); /* Build a conflict graph. */ graph = build_ssa_conflict_graph (liveinfo); delete_tree_live_info (liveinfo); if (dump_file && (dump_flags & TDF_DETAILS)) ssa_conflicts_dump (dump_file, graph); sort_coalesce_list (cl); if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "\nAfter sorting:\n"); dump_coalesce_list (dump_file, cl); } /* First, coalesce all live on entry variables to their base variable. This will ensure the first use is coming from the correct location. */ if (dump_file && (dump_flags & TDF_DETAILS)) dump_var_map (dump_file, map); /* Now coalesce everything in the list. */ coalesce_partitions (map, graph, cl, ((dump_flags & TDF_DETAILS) ? dump_file : NULL)); delete_coalesce_list (cl); ssa_conflicts_delete (graph); return map; }
tuxillo/aarch64-dragonfly-gcc
gcc/tree-ssa-coalesce.c
C
gpl-2.0
46,662
/* * PS3 Media Server, for streaming any medias to your PS3. * Copyright (C) 2008 A.Brochard * * 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; version 2 * of the License only. * * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package net.pms.network; import net.pms.PMS; import net.pms.configuration.PmsConfiguration; import org.apache.commons.lang.StringUtils; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelFactory; import org.jboss.netty.channel.group.ChannelGroup; import org.jboss.netty.channel.group.DefaultChannelGroup; import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.net.*; import java.nio.channels.ClosedByInterruptException; import java.nio.channels.ServerSocketChannel; import java.util.concurrent.Executors; public class HTTPServer implements Runnable { private static final Logger logger = LoggerFactory.getLogger(HTTPServer.class); private final int port; private String hostName; private ServerSocketChannel serverSocketChannel; private ServerSocket serverSocket; private boolean stop; private Thread runnable; private InetAddress iafinal = null; private ChannelFactory factory; private Channel channel; private NetworkInterface ni = null; private ChannelGroup group; public InetAddress getIafinal() { return iafinal; } public NetworkInterface getNi() { return ni; } public HTTPServer(int port) { this.port = port; } public boolean start() throws IOException { final PmsConfiguration configuration = PMS.getConfiguration(); hostName = configuration.getServerHostname(); InetSocketAddress address = null; if (hostName != null && hostName.length() > 0) { logger.info("Using forced address " + hostName); InetAddress tempIA = InetAddress.getByName(hostName); if (tempIA != null && ni != null && ni.equals(NetworkInterface.getByInetAddress(tempIA))) { address = new InetSocketAddress(tempIA, port); } else { address = new InetSocketAddress(hostName, port); } } else if (isAddressFromInterfaceFound(configuration.getNetworkInterface())) { logger.info("Using address " + iafinal + " found on network interface: " + ni.toString().trim().replace('\n', ' ')); address = new InetSocketAddress(iafinal, port); } else { logger.info("Using localhost address"); address = new InetSocketAddress(port); } logger.info("Created socket: " + address); if (!configuration.isHTTPEngineV2()) { serverSocketChannel = ServerSocketChannel.open(); serverSocket = serverSocketChannel.socket(); serverSocket.setReuseAddress(true); serverSocket.bind(address); if (hostName == null && iafinal != null) { hostName = iafinal.getHostAddress(); } else if (hostName == null) { hostName = InetAddress.getLocalHost().getHostAddress(); } runnable = new Thread(this, "HTTP Server"); runnable.setDaemon(false); runnable.start(); } else { group = new DefaultChannelGroup("myServer"); factory = new NioServerSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool() ); ServerBootstrap bootstrap = new ServerBootstrap(factory); HttpServerPipelineFactory pipeline = new HttpServerPipelineFactory(group); bootstrap.setPipelineFactory(pipeline); bootstrap.setOption("child.tcpNoDelay", true); bootstrap.setOption("child.keepAlive", true); bootstrap.setOption("reuseAddress", true); bootstrap.setOption("child.reuseAddress", true); bootstrap.setOption("child.sendBufferSize", 65536); bootstrap.setOption("child.receiveBufferSize", 65536); channel = bootstrap.bind(address); group.add(channel); if (hostName == null && iafinal != null) { hostName = iafinal.getHostAddress(); } else if (hostName == null) { hostName = InetAddress.getLocalHost().getHostAddress(); } } return true; } private boolean isAddressFromInterfaceFound(String networkInterfaceName) { NetworkConfiguration.InterfaceAssociation ia = !StringUtils.isEmpty(networkInterfaceName) ? NetworkConfiguration.getInstance() .getAddressForNetworkInterfaceName(networkInterfaceName) : null; if (ia == null) { ia = NetworkConfiguration.getInstance().getDefaultNetworkInterfaceAddress(); } if (ia != null) { iafinal = ia.getAddr(); ni = ia.getIface(); } return ia != null; } // http://www.ps3mediaserver.org/forum/viewtopic.php?f=6&t=10689&p=48811#p48811 // // avoid a NPE when a) switching HTTP Engine versions and b) restarting the HTTP server // by cleaning up based on what's in use (not null) rather than the config state, which // might be inconsistent. // // NOTE: there's little in the way of cleanup to do here as PMS.reset() discards the old // server and creates a new one public void stop() { logger.info("Stopping server on host " + hostName + " and port " + port + "..."); if (runnable != null) { // HTTP Engine V1 runnable.interrupt(); } if (serverSocket != null) { // HTTP Engine V1 try { serverSocket.close(); serverSocketChannel.close(); } catch (IOException e) { logger.debug("Caught exception", e); } } else if (channel != null) { // HTTP Engine V2 if (group != null) { group.close().awaitUninterruptibly(); } if (factory != null) { factory.releaseExternalResources(); } } NetworkConfiguration.forgetConfiguration(); } public void run() { logger.info("Starting DLNA Server on host " + hostName + " and port " + port + "..."); while (!stop) { try { Socket socket = serverSocket.accept(); InetAddress inetAddress = socket.getInetAddress(); String ip = inetAddress.getHostAddress(); // basic ipfilter: solntcev at gmail dot com boolean ignore = false; if (!PMS.getConfiguration().getIpFiltering().allowed(inetAddress)) { ignore = true; socket.close(); logger.trace("Ignoring request from: " + ip); } else { logger.trace("Receiving a request from: " + ip); } if (!ignore) { RequestHandler request = new RequestHandler(socket); Thread thread = new Thread(request, "Request Handler"); thread.start(); } } catch (ClosedByInterruptException e) { stop = true; } catch (IOException e) { logger.debug("Caught exception", e); } finally { try { if (stop && serverSocket != null) { serverSocket.close(); } if (stop && serverSocketChannel != null) { serverSocketChannel.close(); } } catch (IOException e) { logger.debug("Caught exception", e); } } } } public String getURL() { return "http://" + hostName + ":" + port; } public String getHost() { return hostName; } public int getPort() { return port; } }
TheLQ/ps3mediaserver
src/main/java/net/pms/network/HTTPServer.java
Java
gpl-2.0
7,398
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); $lang['weblink_name'] = 'Name'; $lang['news_title'] = 'Title'; $lang['news_list_title'] = 'List'; $lang['web_links'] = 'Link'; $lang['news_priority'] = 'Order'; $lang['news_active'] = 'Active'; $lang['weblink_module'] = 'Web Link'; $lang['comment_module'] = 'Comments'; $lang['news_delete_warning'] = 'Make sure you want to delete this item! The action cannot be undone'; // btn $lang['add_btn_new'] = 'Create New'; ?>
tidusant/isuzu
application/modules_core/weblinks/language/english/weblink_lang.php
PHP
gpl-2.0
495
#include <linux/module.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/string.h> #include <linux/mm.h> #include <linux/socket.h> #include <linux/sockios.h> #include <linux/in.h> #include <linux/errno.h> #include <linux/interrupt.h> #include <linux/if_ether.h> #include <linux/netdevice.h> #include <linux/inetdevice.h> #include <linux/route.h> #include <linux/inet.h> #include <linux/etherdevice.h> #include <linux/if_arp.h> #include <linux/wireless.h> #include <linux/skbuff.h> #include <linux/udp.h> #include <net/sock.h> #include <net/inet_common.h> #include <linux/stat.h> #include <linux/init.h> #include <linux/if_ec.h> #include <net/udp.h> #include <net/ip.h> #include <linux/spinlock.h> #include <linux/rcupdate.h> #include <linux/bitops.h> #include <linux/mutex.h> #include <asm/uaccess.h> #include <asm/system.h> static const struct proto_ops econet_ops; static struct hlist_head econet_sklist; static DEFINE_RWLOCK(econet_lock); static DEFINE_MUTEX(econet_mutex); static struct net_device *net2dev_map[256]; #define EC_PORT_IP 0xd2 #ifdef CONFIG_ECONET_AUNUDP static DEFINE_SPINLOCK(aun_queue_lock); static struct socket *udpsock; #define AUN_PORT 0x8000 struct aunhdr { unsigned char code; unsigned char port; unsigned char cb; unsigned char pad; unsigned long handle; }; static unsigned long aun_seq; static struct sk_buff_head aun_queue; static struct timer_list ab_cleanup_timer; #endif struct ec_cb { struct sockaddr_ec sec; unsigned long cookie; #ifdef CONFIG_ECONET_AUNUDP int done; unsigned long seq; unsigned long timeout; unsigned long start; #endif #ifdef CONFIG_ECONET_NATIVE void (*sent)(struct sk_buff *, int result); #endif }; static void econet_remove_socket(struct hlist_head *list, struct sock *sk) { write_lock_bh(&econet_lock); sk_del_node_init(sk); write_unlock_bh(&econet_lock); } static void econet_insert_socket(struct hlist_head *list, struct sock *sk) { write_lock_bh(&econet_lock); sk_add_node(sk, list); write_unlock_bh(&econet_lock); } static int econet_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags) { struct sock *sk = sock->sk; struct sk_buff *skb; size_t copied; int err; msg->msg_namelen = sizeof(struct sockaddr_ec); mutex_lock(&econet_mutex); skb=skb_recv_datagram(sk,flags,flags&MSG_DONTWAIT,&err); if(skb==NULL) goto out; copied = skb->len; if (copied > len) { copied=len; msg->msg_flags|=MSG_TRUNC; } err = memcpy_toiovec(msg->msg_iov, skb->data, copied); if (err) goto out_free; sk->sk_stamp = skb->tstamp; if (msg->msg_name) memcpy(msg->msg_name, skb->cb, msg->msg_namelen); err = copied; out_free: skb_free_datagram(sk, skb); out: mutex_unlock(&econet_mutex); return err; } static int econet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) { struct sockaddr_ec *sec = (struct sockaddr_ec *)uaddr; struct sock *sk; struct econet_sock *eo; if (addr_len < sizeof(struct sockaddr_ec) || sec->sec_family != AF_ECONET) return -EINVAL; mutex_lock(&econet_mutex); sk = sock->sk; eo = ec_sk(sk); eo->cb = sec->cb; eo->port = sec->port; eo->station = sec->addr.station; eo->net = sec->addr.net; mutex_unlock(&econet_mutex); return 0; } #if defined(CONFIG_ECONET_AUNUDP) || defined(CONFIG_ECONET_NATIVE) static void tx_result(struct sock *sk, unsigned long cookie, int result) { struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC); struct ec_cb *eb; struct sockaddr_ec *sec; if (skb == NULL) { printk(KERN_DEBUG "ec: memory squeeze, transmit result dropped.\n"); return; } eb = (struct ec_cb *)&skb->cb; sec = (struct sockaddr_ec *)&eb->sec; memset(sec, 0, sizeof(struct sockaddr_ec)); sec->cookie = cookie; sec->type = ECTYPE_TRANSMIT_STATUS | result; sec->sec_family = AF_ECONET; if (sock_queue_rcv_skb(sk, skb) < 0) kfree_skb(skb); } #endif #ifdef CONFIG_ECONET_NATIVE static void ec_tx_done(struct sk_buff *skb, int result) { struct ec_cb *eb = (struct ec_cb *)&skb->cb; tx_result(skb->sk, eb->cookie, result); } #endif static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len) { struct sock *sk = sock->sk; struct sockaddr_ec *saddr=(struct sockaddr_ec *)msg->msg_name; struct net_device *dev; struct ec_addr addr; int err; unsigned char port, cb; #if defined(CONFIG_ECONET_AUNUDP) || defined(CONFIG_ECONET_NATIVE) struct sk_buff *skb; struct ec_cb *eb; #endif #ifdef CONFIG_ECONET_AUNUDP struct msghdr udpmsg; struct iovec iov[msg->msg_iovlen+1]; struct aunhdr ah; struct sockaddr_in udpdest; __kernel_size_t size; int i; mm_segment_t oldfs; #endif if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT)) return -EINVAL; mutex_lock(&econet_mutex); if (saddr == NULL) { struct econet_sock *eo = ec_sk(sk); addr.station = eo->station; addr.net = eo->net; port = eo->port; cb = eo->cb; } else { if (msg->msg_namelen < sizeof(struct sockaddr_ec)) { mutex_unlock(&econet_mutex); return -EINVAL; } addr.station = saddr->addr.station; addr.net = saddr->addr.net; port = saddr->port; cb = saddr->cb; } dev = net2dev_map[addr.net]; if (dev == NULL) { dev = net2dev_map[0]; if (dev == NULL) { mutex_unlock(&econet_mutex); return -ENETDOWN; } } if (len + 15 > dev->mtu) { mutex_unlock(&econet_mutex); return -EMSGSIZE; } if (dev->type == ARPHRD_ECONET) { #ifdef CONFIG_ECONET_NATIVE unsigned short proto = 0; int res; dev_hold(dev); skb = sock_alloc_send_skb(sk, len+LL_ALLOCATED_SPACE(dev), msg->msg_flags & MSG_DONTWAIT, &err); if (skb==NULL) goto out_unlock; skb_reserve(skb, LL_RESERVED_SPACE(dev)); skb_reset_network_header(skb); eb = (struct ec_cb *)&skb->cb; eb->cookie = saddr->cookie; eb->sec = *saddr; eb->sent = ec_tx_done; err = -EINVAL; res = dev_hard_header(skb, dev, ntohs(proto), &addr, NULL, len); if (res < 0) goto out_free; if (res > 0) { struct ec_framehdr *fh; fh = (struct ec_framehdr *)(skb->data); fh->cb = cb; fh->port = port; if (sock->type != SOCK_DGRAM) { skb_reset_tail_pointer(skb); skb->len = 0; } } err = memcpy_fromiovec(skb_put(skb,len), msg->msg_iov, len); skb->protocol = proto; skb->dev = dev; skb->priority = sk->sk_priority; if (err) goto out_free; err = -ENETDOWN; if (!(dev->flags & IFF_UP)) goto out_free; dev_queue_xmit(skb); dev_put(dev); mutex_unlock(&econet_mutex); return(len); out_free: kfree_skb(skb); out_unlock: if (dev) dev_put(dev); #else err = -EPROTOTYPE; #endif mutex_unlock(&econet_mutex); return err; } #ifdef CONFIG_ECONET_AUNUDP if (udpsock == NULL) { mutex_unlock(&econet_mutex); return -ENETDOWN; } memset(&udpdest, 0, sizeof(udpdest)); udpdest.sin_family = AF_INET; udpdest.sin_port = htons(AUN_PORT); { struct in_device *idev; unsigned long network = 0; rcu_read_lock(); idev = __in_dev_get_rcu(dev); if (idev) { if (idev->ifa_list) network = ntohl(idev->ifa_list->ifa_address) & 0xffffff00; } rcu_read_unlock(); udpdest.sin_addr.s_addr = htonl(network | addr.station); } ah.port = port; ah.cb = cb & 0x7f; ah.code = 2; ah.pad = 0; size = sizeof(struct aunhdr); iov[0].iov_base = (void *)&ah; iov[0].iov_len = size; for (i = 0; i < msg->msg_iovlen; i++) { void __user *base = msg->msg_iov[i].iov_base; size_t len = msg->msg_iov[i].iov_len; if (!access_ok(VERIFY_READ, base, len)) { mutex_unlock(&econet_mutex); return -EFAULT; } iov[i+1].iov_base = base; iov[i+1].iov_len = len; size += len; } if ((skb = sock_alloc_send_skb(sk, 0, msg->msg_flags & MSG_DONTWAIT, &err)) == NULL) { mutex_unlock(&econet_mutex); return err; } eb = (struct ec_cb *)&skb->cb; eb->cookie = saddr->cookie; eb->timeout = (5*HZ); eb->start = jiffies; ah.handle = aun_seq; eb->seq = (aun_seq++); eb->sec = *saddr; skb_queue_tail(&aun_queue, skb); udpmsg.msg_name = (void *)&udpdest; udpmsg.msg_namelen = sizeof(udpdest); udpmsg.msg_iov = &iov[0]; udpmsg.msg_iovlen = msg->msg_iovlen + 1; udpmsg.msg_control = NULL; udpmsg.msg_controllen = 0; udpmsg.msg_flags=0; oldfs = get_fs(); set_fs(KERNEL_DS); err = sock_sendmsg(udpsock, &udpmsg, size); set_fs(oldfs); #else err = -EPROTOTYPE; #endif mutex_unlock(&econet_mutex); return err; } static int econet_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_len, int peer) { struct sock *sk; struct econet_sock *eo; struct sockaddr_ec *sec = (struct sockaddr_ec *)uaddr; if (peer) return -EOPNOTSUPP; memset(sec, 0, sizeof(*sec)); mutex_lock(&econet_mutex); sk = sock->sk; eo = ec_sk(sk); sec->sec_family = AF_ECONET; sec->port = eo->port; sec->addr.station = eo->station; sec->addr.net = eo->net; mutex_unlock(&econet_mutex); *uaddr_len = sizeof(*sec); return 0; } static void econet_destroy_timer(unsigned long data) { struct sock *sk=(struct sock *)data; if (!sk_has_allocations(sk)) { sk_free(sk); return; } sk->sk_timer.expires = jiffies + 10 * HZ; add_timer(&sk->sk_timer); printk(KERN_DEBUG "econet socket destroy delayed\n"); } static int econet_release(struct socket *sock) { struct sock *sk; mutex_lock(&econet_mutex); sk = sock->sk; if (!sk) goto out_unlock; econet_remove_socket(&econet_sklist, sk); sk->sk_state_change(sk); sock_orphan(sk); skb_queue_purge(&sk->sk_receive_queue); if (sk_has_allocations(sk)) { sk->sk_timer.data = (unsigned long)sk; sk->sk_timer.expires = jiffies + HZ; sk->sk_timer.function = econet_destroy_timer; add_timer(&sk->sk_timer); goto out_unlock; } sk_free(sk); out_unlock: mutex_unlock(&econet_mutex); return 0; } static struct proto econet_proto = { .name = "ECONET", .owner = THIS_MODULE, .obj_size = sizeof(struct econet_sock), }; static int econet_create(struct net *net, struct socket *sock, int protocol) { struct sock *sk; struct econet_sock *eo; int err; if (net != &init_net) return -EAFNOSUPPORT; if (sock->type != SOCK_DGRAM) return -ESOCKTNOSUPPORT; sock->state = SS_UNCONNECTED; err = -ENOBUFS; sk = sk_alloc(net, PF_ECONET, GFP_KERNEL, &econet_proto); if (sk == NULL) goto out; sk->sk_reuse = 1; sock->ops = &econet_ops; sock_init_data(sock, sk); eo = ec_sk(sk); sock_reset_flag(sk, SOCK_ZAPPED); sk->sk_family = PF_ECONET; eo->num = protocol; econet_insert_socket(&econet_sklist, sk); return(0); out: return err; } static int ec_dev_ioctl(struct socket *sock, unsigned int cmd, void __user *arg) { struct ifreq ifr; struct ec_device *edev; struct net_device *dev; struct sockaddr_ec *sec; int err; if (copy_from_user(&ifr, arg, sizeof(struct ifreq))) return -EFAULT; if ((dev = dev_get_by_name(&init_net, ifr.ifr_name)) == NULL) return -ENODEV; sec = (struct sockaddr_ec *)&ifr.ifr_addr; mutex_lock(&econet_mutex); err = 0; switch (cmd) { case SIOCSIFADDR: edev = dev->ec_ptr; if (edev == NULL) { edev = kzalloc(sizeof(struct ec_device), GFP_KERNEL); if (edev == NULL) { err = -ENOMEM; break; } dev->ec_ptr = edev; } else net2dev_map[edev->net] = NULL; edev->station = sec->addr.station; edev->net = sec->addr.net; net2dev_map[sec->addr.net] = dev; if (!net2dev_map[0]) net2dev_map[0] = dev; break; case SIOCGIFADDR: edev = dev->ec_ptr; if (edev == NULL) { err = -ENODEV; break; } memset(sec, 0, sizeof(struct sockaddr_ec)); sec->addr.station = edev->station; sec->addr.net = edev->net; sec->sec_family = AF_ECONET; dev_put(dev); if (copy_to_user(arg, &ifr, sizeof(struct ifreq))) err = -EFAULT; break; default: err = -EINVAL; break; } mutex_unlock(&econet_mutex); dev_put(dev); return err; } static int econet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { struct sock *sk = sock->sk; void __user *argp = (void __user *)arg; switch(cmd) { case SIOCGSTAMP: return sock_get_timestamp(sk, argp); case SIOCGSTAMPNS: return sock_get_timestampns(sk, argp); case SIOCSIFADDR: case SIOCGIFADDR: return ec_dev_ioctl(sock, cmd, argp); break; default: return -ENOIOCTLCMD; } return 0; } static struct net_proto_family econet_family_ops = { .family = PF_ECONET, .create = econet_create, .owner = THIS_MODULE, }; static const struct proto_ops econet_ops = { .family = PF_ECONET, .owner = THIS_MODULE, .release = econet_release, .bind = econet_bind, .connect = sock_no_connect, .socketpair = sock_no_socketpair, .accept = sock_no_accept, .getname = econet_getname, .poll = datagram_poll, .ioctl = econet_ioctl, .listen = sock_no_listen, .shutdown = sock_no_shutdown, .setsockopt = sock_no_setsockopt, .getsockopt = sock_no_getsockopt, .sendmsg = econet_sendmsg, .recvmsg = econet_recvmsg, .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, }; #if defined(CONFIG_ECONET_AUNUDP) || defined(CONFIG_ECONET_NATIVE) static struct sock *ec_listening_socket(unsigned char port, unsigned char station, unsigned char net) { struct sock *sk; struct hlist_node *node; sk_for_each(sk, node, &econet_sklist) { struct econet_sock *opt = ec_sk(sk); if ((opt->port == port || opt->port == 0) && (opt->station == station || opt->station == 0) && (opt->net == net || opt->net == 0)) goto found; } sk = NULL; found: return sk; } static int ec_queue_packet(struct sock *sk, struct sk_buff *skb, unsigned char stn, unsigned char net, unsigned char cb, unsigned char port) { struct ec_cb *eb = (struct ec_cb *)&skb->cb; struct sockaddr_ec *sec = (struct sockaddr_ec *)&eb->sec; memset(sec, 0, sizeof(struct sockaddr_ec)); sec->sec_family = AF_ECONET; sec->type = ECTYPE_PACKET_RECEIVED; sec->port = port; sec->cb = cb; sec->addr.net = net; sec->addr.station = stn; return sock_queue_rcv_skb(sk, skb); } #endif #ifdef CONFIG_ECONET_AUNUDP static void aun_send_response(__u32 addr, unsigned long seq, int code, int cb) { struct sockaddr_in sin = { .sin_family = AF_INET, .sin_port = htons(AUN_PORT), .sin_addr = {.s_addr = addr} }; struct aunhdr ah = {.code = code, .cb = cb, .handle = seq}; struct kvec iov = {.iov_base = (void *)&ah, .iov_len = sizeof(ah)}; struct msghdr udpmsg; udpmsg.msg_name = (void *)&sin; udpmsg.msg_namelen = sizeof(sin); udpmsg.msg_control = NULL; udpmsg.msg_controllen = 0; udpmsg.msg_flags=0; kernel_sendmsg(udpsock, &udpmsg, &iov, 1, sizeof(ah)); } static void aun_incoming(struct sk_buff *skb, struct aunhdr *ah, size_t len) { struct iphdr *ip = ip_hdr(skb); unsigned char stn = ntohl(ip->saddr) & 0xff; struct sock *sk; struct sk_buff *newskb; struct ec_device *edev = skb->dev->ec_ptr; if (! edev) goto bad; if ((sk = ec_listening_socket(ah->port, stn, edev->net)) == NULL) goto bad; newskb = alloc_skb((len - sizeof(struct aunhdr) + 15) & ~15, GFP_ATOMIC); if (newskb == NULL) { printk(KERN_DEBUG "AUN: memory squeeze, dropping packet.\n"); goto bad; } memcpy(skb_put(newskb, len - sizeof(struct aunhdr)), (void *)(ah+1), len - sizeof(struct aunhdr)); if (ec_queue_packet(sk, newskb, stn, edev->net, ah->cb, ah->port)) { kfree_skb(newskb); goto bad; } aun_send_response(ip->saddr, ah->handle, 3, 0); return; bad: aun_send_response(ip->saddr, ah->handle, 4, 0); } static void aun_tx_ack(unsigned long seq, int result) { struct sk_buff *skb; unsigned long flags; struct ec_cb *eb; spin_lock_irqsave(&aun_queue_lock, flags); skb_queue_walk(&aun_queue, skb) { eb = (struct ec_cb *)&skb->cb; if (eb->seq == seq) goto foundit; } spin_unlock_irqrestore(&aun_queue_lock, flags); printk(KERN_DEBUG "AUN: unknown sequence %ld\n", seq); return; foundit: tx_result(skb->sk, eb->cookie, result); skb_unlink(skb, &aun_queue); spin_unlock_irqrestore(&aun_queue_lock, flags); kfree_skb(skb); } static void aun_data_available(struct sock *sk, int slen) { int err; struct sk_buff *skb; unsigned char *data; struct aunhdr *ah; struct iphdr *ip; size_t len; while ((skb = skb_recv_datagram(sk, 0, 1, &err)) == NULL) { if (err == -EAGAIN) { printk(KERN_ERR "AUN: no data available?!"); return; } printk(KERN_DEBUG "AUN: recvfrom() error %d\n", -err); } data = skb_transport_header(skb) + sizeof(struct udphdr); ah = (struct aunhdr *)data; len = skb->len - sizeof(struct udphdr); ip = ip_hdr(skb); switch (ah->code) { case 2: aun_incoming(skb, ah, len); break; case 3: aun_tx_ack(ah->handle, ECTYPE_TRANSMIT_OK); break; case 4: aun_tx_ack(ah->handle, ECTYPE_TRANSMIT_NOT_LISTENING); break; #if 0 case 5: aun_send_response(ip->saddr, ah->handle, 6, ah->cb); break; #endif default: printk(KERN_DEBUG "unknown AUN packet (type %d)\n", data[0]); } skb_free_datagram(sk, skb); } static void ab_cleanup(unsigned long h) { struct sk_buff *skb, *n; unsigned long flags; spin_lock_irqsave(&aun_queue_lock, flags); skb_queue_walk_safe(&aun_queue, skb, n) { struct ec_cb *eb = (struct ec_cb *)&skb->cb; if ((jiffies - eb->start) > eb->timeout) { tx_result(skb->sk, eb->cookie, ECTYPE_TRANSMIT_NOT_PRESENT); skb_unlink(skb, &aun_queue); kfree_skb(skb); } } spin_unlock_irqrestore(&aun_queue_lock, flags); mod_timer(&ab_cleanup_timer, jiffies + (HZ*2)); } static int __init aun_udp_initialise(void) { int error; struct sockaddr_in sin; skb_queue_head_init(&aun_queue); spin_lock_init(&aun_queue_lock); setup_timer(&ab_cleanup_timer, ab_cleanup, 0); ab_cleanup_timer.expires = jiffies + (HZ*2); add_timer(&ab_cleanup_timer); memset(&sin, 0, sizeof(sin)); sin.sin_port = htons(AUN_PORT); if ((error = sock_create_kern(PF_INET, SOCK_DGRAM, 0, &udpsock)) < 0) { printk("AUN: socket error %d\n", -error); return error; } udpsock->sk->sk_reuse = 1; udpsock->sk->sk_allocation = GFP_ATOMIC; error = udpsock->ops->bind(udpsock, (struct sockaddr *)&sin, sizeof(sin)); if (error < 0) { printk("AUN: bind error %d\n", -error); goto release; } udpsock->sk->sk_data_ready = aun_data_available; return 0; release: sock_release(udpsock); udpsock = NULL; return error; } #endif #ifdef CONFIG_ECONET_NATIVE static int econet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) { struct ec_framehdr *hdr; struct sock *sk; struct ec_device *edev = dev->ec_ptr; if (!net_eq(dev_net(dev), &init_net)) goto drop; if (skb->pkt_type == PACKET_OTHERHOST) goto drop; if (!edev) goto drop; if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) return NET_RX_DROP; if (!pskb_may_pull(skb, sizeof(struct ec_framehdr))) goto drop; hdr = (struct ec_framehdr *) skb->data; if (hdr->port == EC_PORT_IP) { skb->protocol = htons(ETH_P_IP); skb_pull(skb, sizeof(struct ec_framehdr)); netif_rx(skb); return NET_RX_SUCCESS; } sk = ec_listening_socket(hdr->port, hdr->src_stn, hdr->src_net); if (!sk) goto drop; if (ec_queue_packet(sk, skb, edev->net, hdr->src_stn, hdr->cb, hdr->port)) goto drop; return NET_RX_SUCCESS; drop: kfree_skb(skb); return NET_RX_DROP; } static struct packet_type econet_packet_type __read_mostly = { .type = cpu_to_be16(ETH_P_ECONET), .func = econet_rcv, }; static void econet_hw_initialise(void) { dev_add_pack(&econet_packet_type); } #endif static int econet_notifier(struct notifier_block *this, unsigned long msg, void *data) { struct net_device *dev = (struct net_device *)data; struct ec_device *edev; if (!net_eq(dev_net(dev), &init_net)) return NOTIFY_DONE; switch (msg) { case NETDEV_UNREGISTER: edev = dev->ec_ptr; if (edev) { if (net2dev_map[0] == dev) net2dev_map[0] = NULL; net2dev_map[edev->net] = NULL; kfree(edev); dev->ec_ptr = NULL; } break; } return NOTIFY_DONE; } static struct notifier_block econet_netdev_notifier = { .notifier_call =econet_notifier, }; static void __exit econet_proto_exit(void) { #ifdef CONFIG_ECONET_AUNUDP del_timer(&ab_cleanup_timer); if (udpsock) sock_release(udpsock); #endif unregister_netdevice_notifier(&econet_netdev_notifier); #ifdef CONFIG_ECONET_NATIVE dev_remove_pack(&econet_packet_type); #endif sock_unregister(econet_family_ops.family); proto_unregister(&econet_proto); } static int __init econet_proto_init(void) { int err = proto_register(&econet_proto, 0); if (err != 0) goto out; sock_register(&econet_family_ops); #ifdef CONFIG_ECONET_AUNUDP spin_lock_init(&aun_queue_lock); aun_udp_initialise(); #endif #ifdef CONFIG_ECONET_NATIVE econet_hw_initialise(); #endif register_netdevice_notifier(&econet_netdev_notifier); out: return err; } module_init(econet_proto_init); module_exit(econet_proto_exit); MODULE_LICENSE("GPL"); MODULE_ALIAS_NETPROTO(PF_ECONET);
leemgs/OptimusOneKernel-KandroidCommunity
net/econet/af_econet.c
C
gpl-2.0
21,017
<?php session_start(); require_once 'xmlrpc.inc'; $xmlrpc_internalencoding = 'UTF-8'; require_once './constants.php'; $GLOBALS['alert']=''; function add_alert($text,$type='success',$dismissable=TRUE){ $GLOBALS['alert'].='<div class="alert alert-'.$type.($dismissable?' alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>':'">'). $text.'</div>'; } function set_post_from_until($interval){ switch($interval){ case 'last 24 hours': $_POST['from']=date('y-m-d H:i',time()-3600*24); $_POST['until']=date('y-m-d H:i',time()); break; case 'last 3 days': $_POST['from']=date('y-m-d 00:00',time()-3600*24*3); $_POST['until']=date('y-m-d H:i',time()); break; case 'last 7 days': $_POST['from']=date('y-m-d 00:00',time()-3600*24*7); $_POST['until']=date('y-m-d H:i',time()); break; case 'last 30 days': $_POST['from']=date('y-m-d 00:00',time()-3600*24*30); $_POST['until']=date('y-m-d H:i',time()); break; case 'today': $_POST['from']=date('y-m-d 00:00'); $_POST['until']=date('y-m-d 00:00',time()+3600*24); break; case 'yesterday': $_POST['from']=date('y-m-d 00:00',time()-3600*24); $_POST['until']=date('y-m-d 00:00'); break; case 'this week': $weekday=date('N'); $_POST['from']=date('y-m-d 00:00',time()-3600*24*($weekday-1)); $_POST['until']=date('y-m-d 00:00',time()+3600*24); break; case 'last week': $weekday=date('N'); $_POST['from']=date('y-m-d 00:00',time()-3600*24*($weekday+6)); $_POST['until']=date('y-m-d 00:00',time()-3600*24*($weekday-1)); break; case 'this month': $_POST['from']=date('y-m-01 00:00'); $_POST['until']=date('y-m-d 00:00',time()+3600*24); break; case 'last month': $last_month=date('m')-1; $year=date('y'); if($last_month==0){ $last_month=12; $year--; } $_POST['from']=$year.'-'.$last_month.'-01 00:00'; $_POST['until']=date('y-m-01 00:00'); break; case 'this year': $_POST['from']=date('y-01-01 00:00'); $_POST['until']=date('y-m-d 00:00',time()+3600*24); break; case 'last year': $_POST['from']=date('y-01-01 00:00',time()-365*3600*24); $_POST['until']=date('y-12-31 00:00',time()-365*3600*24); break; } } function DBQueryParams($query,$params){ if(! $GLOBALS['conn']) $GLOBALS['conn']=pg_connect($_SESSION['dbConnection']); if(! $GLOBALS['conn']){ add_alert('Could not get database connection','danger'); return false; } $res=pg_query_params($GLOBALS['conn'],$query, $params); if(! $res){ add_alert(pg_last_error($GLOBALS['conn']),'danger'); } return $res; } function updateCookies(){ setcookie('max_cols',$_SESSION['max_cols'],time()+3600*24*180); setcookie('max_rows',$_SESSION['max_rows'],time()+3600*24*180); setcookie('gnuplot',$_SESSION['gnuplot'],time()+3600*24*180); setcookie('cb2db',$_SESSION['cb2db'],time()+3600*24*180); if($_SESSION['cb2db']){ xml_call('PreferenceHandler.setPreference', array(new xmlrpcval('bayeosviewer','string'), new xmlrpcval('cb_saved','string'), new xmlrpcval(serialize($_SESSION['cb_saved']),'string'))); setcookie('cb_saved',null,-1); } else setcookie('cb_saved',serialize($_SESSION['cb_saved']),time()+3600*24*180); if($_SESSION['cb2db']) xml_call('PreferenceHandler.setPreference', array(new xmlrpcval('bayeosviewer','string'), new xmlrpcval('bookmarks','string'), new xmlrpcval(serialize($_SESSION['bookmarks']),'string'))); else setcookie('homefolder',serialize($_SESSION['bookmarks']),time()+3600*24*180); } function get_object_fields($uname){ switch($uname){ case 'messung_ordner': case 'messung_massendaten': $ofields=array( array('name'=>'Plan Start','nr'=>15,'cols'=>6,'type'=>'dateTime.iso8601','unr'=>3), array('name'=>'Plan End','nr'=>16,'cols'=>6,'type'=>'dateTime.iso8601','unr'=>4), array('name'=>'Description','nr'=>21,'cols'=>12,'type'=>'text','unr'=>1,'xmltype'=>'string'), array('name'=>'Resolution (sec)','nr'=>22,'cols'=>4,'type'=>'int','unr'=>2), array('name'=>'Interval Type','nr'=>23,'cols'=>4,'type'=>'IntervalTypes','unr'=>5,'xmltype'=>'int','default'=>0), array('name'=>'Time Zone','nr'=>24,'cols'=>4,'type'=>'TimeZones','unr'=>6,'xmltype'=>'int','default'=>1) ); break; case 'mess_geraet': $ofields=array( array('name'=>'Description','nr'=>21,'cols'=>12,'type'=>'text','unr'=>1,'xmltype'=>'string'), array('name'=>'Serial Number','nr'=>22,'cols'=>4,'type'=>'string','unr'=>2) ); break; case 'mess_einheit': $ofields=array( array('name'=>'Description','nr'=>21,'cols'=>12,'type'=>'text','unr'=>1,'xmltype'=>'string'), array('name'=>'Symbol','nr'=>22,'cols'=>4,'type'=>'string','unr'=>2) ); break; case 'mess_ziel': $ofields=array( array('name'=>'Description','nr'=>21,'cols'=>12,'type'=>'text','unr'=>1,'xmltype'=>'string'), array('name'=>'Formel','nr'=>22,'cols'=>4,'type'=>'string','unr'=>2) ); break; case 'mess_kompartiment': $ofields=array( array('name'=>'Description','nr'=>21,'cols'=>12,'type'=>'text','unr'=>1,'xmltype'=>'string') ); break; case 'mess_ort': $ofields=array( array('name'=>'Description','nr'=>21,'cols'=>12,'type'=>'text','unr'=>1,'xmltype'=>'string'), array('name'=>'x','nr'=>22,'cols'=>3,'type'=>'double','unr'=>2), array('name'=>'y','nr'=>23,'cols'=>3,'type'=>'double','unr'=>3), array('name'=>'z','nr'=>24,'cols'=>3,'type'=>'double','unr'=>4), array('name'=>'CRS','nr'=>25,'cols'=>3,'type'=>'CRS','unr'=>5,'xmltype'=>'int') ); break; case 'data_frame': case 'data_column': $ofields=array( array('name'=>'Plan Start','nr'=>15,'cols'=>6,'type'=>'dateTime.iso8601','unr'=>0), array('name'=>'Plan End','nr'=>16,'cols'=>6,'type'=>'dateTime.iso8601','unr'=>1), array('name'=>'Rec Start','nr'=>17,'cols'=>6,'type'=>'dateTime.iso8601','unr'=>2), array('name'=>'Rec End','nr'=>18,'cols'=>6,'type'=>'dateTime.iso8601','unr'=>3), array('name'=>'Name','nr'=>13,'cols'=>0,'type'=>'hidden','unr'=>4,'xmltype'=>'string'), array('name'=>'Description','nr'=>21,'cols'=>12,'type'=>'text','unr'=>5,'xmltype'=>'string'), array('name'=>'Time Zone','nr'=>22,'cols'=>4,'type'=>'TimeZones','unr'=>6,'xmltype'=>'int','default'=>1) ); $_POST['o13']=$_POST['t5']; //Hack! Set Name=Node-Name!! break; } if($uname=='data_column'){ $ofields[6]=array('name'=>'Column Index','nr'=>22,'cols'=>6,'type'=>'int','unr'=>6,'default'=>1); $ofields[7]=array('name'=>'Data Type','nr'=>23,'cols'=>6,'type'=>'DataTypes','unr'=>7,'xmltype'=>'string'); } return $ofields; } function getUserGroups($tag,$select=''){ if(! isset($_SESSION['Benutzer'])) $_SESSION['Benutzer']=xml_call('LookUpTableHandler.getBenutzer',array()); if(! isset($_SESSION['Gruppen'])) $_SESSION['Gruppen']=xml_call('LookUpTableHandler.getGruppen',array()); $res=array(); if($select=='' || $select=='Gruppen'){ for($i=0;$i<count($_SESSION['Gruppen']);$i++){ if(strstr($_SESSION['Gruppen'][$i][20],$tag)) $res[]=array('label'=>$_SESSION['Gruppen'][$i][20],'value'=>$_SESSION['Gruppen'][$i][20],'id'=>$_SESSION['Gruppen'][$i][2]); } } if($select=='' || $select=='Benutzer'){ for($i=0;$i<count($_SESSION['Benutzer']);$i++){ if(strstr($_SESSION['Benutzer'][$i][20],$tag)) $res[]=array('label'=>$_SESSION['Benutzer'][$i][20],'value'=>$_SESSION['Benutzer'][$i][20],'id'=>$_SESSION['Benutzer'][$i][2]); } } reset($_SESSION['Benutzer']); reset($_SESSION['Gruppen']); return($res); } //Extract common path from clipboard series function get_folder_subfolders(){ $folders=array(); $res=array(); for($i=0;$i<count($_SESSION['clipboard']);$i++){ $folders[$i]=explode('/',$_SESSION['clipboard'][$i]['path'][1]); } $max=count($folders[0])-1; for($i=1;$i<count($folders);$i++){ $j=0; while($j<=$max && isset($folders[$i][$j]) && isset($folders[0][$j]) && $folders[$i][$j]==$folders[0][$j]) $j++; $j--; if($j<$max) $max=$j; } $res['folder']=implode('/',array_slice($folders[0],0,$max+1)); $has_subpath=FALSE; $subfolders=array(); for($i=0;$i<count($folders);$i++){ if(count($folders[$i])>($max+1)){ $subfolders[$i]=implode('/',array_slice($folders[$i],$max+1)); $has_subpath=TRUE; } else $subfolders[$i]=''; } if($has_subpath) $res['subfolders']=$subfolders; return $res; } function get_root_id($uname){ if(! isset($_SESSION['rootids'][$uname])){ $res=xml_call("TreeHandler.getRoot", array(new xmlrpcval($uname,'string'), new xmlrpcval(FALSE,'boolean'), new xmlrpcval('week','string'), new xmlrpcval(null,'null'))); $_SESSION['rootids'][$uname]=$res[2]; } return $_SESSION['rootids'][$uname]; } function ft($t){ if($t<10) $t="0$t"; return $t; } function xmlrpc_array($values,$type='string'){ $val=array(); while(list($key,$value)=each($values)){ $val[]=new xmlrpcval($value,$type); } return new xmlrpcval($val,'array'); } function xml_call($method,$args){ $request = new xmlrpcmsg($method,$args); //echo htmlspecialchars($request->serialize()); $context = stream_context_create(array('http' => array( 'method' => "POST", 'header' => "Content-Type: text/xml charset=UTF-8". (isset($_SESSION['bayeosauth'])?"\r\nAuthentication:".$_SESSION['bayeosauth']:''), 'content' => $request->serialize() ))); $file = file_get_contents($_SESSION['bayeosurl'], false, $context); if($file===false){ $error=error_get_last(); $GLOBALS['alert'].='<div class="alert alert-danger">XMLRPC-Error: No response from BayEOS-Server using URL '.$_SESSION['bayeosurl'].'<br/> <b>This is the error message:</b> '.$error['message'].'</div>'; return false; } //echo htmlspecialchars($file); $response = xmlrpc_decode($file,'UTF-8'); if ($response && is_array($response) && xmlrpc_is_fault($response)) { $GLOBALS['alert'].='<div class="alert alert-danger">'."xmlrpc $method: $response[faultString] ($response[faultCode])".'</div>'; return false; } else { return $response; } } function toios8601FromEpoch($epoch){ return(gmdate('Ymd\TH:i:s',$epoch+3600)); } function toEpoch($isodate){ $tmp=date_parse($isodate); return gmmktime($tmp['hour'],$tmp['minute'],$tmp['second'],$tmp['month'],$tmp['day'],$tmp['year'])-3600; } function toDateFromString($isodate){ $tmp=date_parse($isodate); $timestamp=gmmktime($tmp['hour'],$tmp['minute'],$tmp['second'],$tmp['month'],$tmp['day'],$tmp['year']); return ($timestamp?date('Y-m-d H:i',$timestamp-3600):''); } function toDate($isodate){ return( (is_object($isodate) && $isodate->timestamp?date('Y-m-d H:i',$isodate->timestamp-3600):'') ); } function toiso8601($date){ if(! $date) return NULL; $tmp=date_parse($date); return(gmdate('Ymd\TH:i:s',mktime($tmp['hour'],$tmp['minute'],$tmp['second'],$tmp['month'],$tmp['day'],$tmp['year'])+3600)); } function getName($id){ if(! isset($GLOBALS['treehash'][$id])){ $node=xml_call('TreeHandler.getNode',array(new xmlrpcval($id,'int'))); $GLOBALS['treehash'][$id]=array($node[3],$node[5]); } return $GLOBALS['treehash'][$id]; } function getPath($id_parent){ if($_SESSION['id']==$id_parent) return $_SESSION['currentpath']; $path=''; while($id_parent){ list($id_parent,$name)=getName($id_parent); $path='/'.$name.$path; if($id_parent==$_SESSION['id']) return $_SESSION['currentpath'].$path; } return $path; } function addToClipboard($node,$alert=1){ for($i=0;$i<count($_SESSION['clipboard']);$i++){ if($_SESSION['clipboard'][$i][2]==$node){ add_alert($_SESSION['clipboard'][$i][5]. "(ID $node) is already on your <a href=\"?tab=Clipboard\" class=\"alert-link\">clipboard</a>",'warning'); return 1; } } $node=xml_call('TreeHandler.getNode',array(new xmlrpcval($node,'int'))); if($node[4]=='messung_massendaten'){ $object=xml_call('ObjektHandler.getObjekt',array(new xmlrpcval($node[2],'int'), new xmlrpcval('messung_massendaten','string'))); $node['res']=$object[22]; $node['path']=array($node[3],getPath($node[3])); $_SESSION['clipboard'][]=$node; if($alert) add_alert($node[5].' (ID '.$node[2].') added to your <a href="?tab=Clipboard" class="alert-link">clipboard</a>'); return 1; } return 0; } function getSeries($ids,$aggfunc,$aggint,$timefilter,$filter_arg){ $res=array(); if(! is_array($ids)) $ids=array($ids); if(count($ids)==1){ if($aggfunc && $aggint) { $val=xml_call('AggregationTableHandler.getRows', array(new xmlrpcval($ids[0],'int'), $timefilter, $filter_arg)); $val=$val[1]; for($j=0;$j<count($val);$j++){ $res['datetime'][$j]=$val[$j][0]->timestamp-3600; $res[0][$j]=$val[$j][1]; } if($j==0){ //aggregation not activ?? //Switch back to full resolution display $aggfunc=''; $aggint=''; $filter_arg=xmlrpc_array($_SESSION['StatusFilter'],'int'); } } if(! $aggfunc || !$aggint){ $val=xml_call('MassenTableHandler.getRows', array(new xmlrpcval($ids[0],'int'), $timefilter, $filter_arg)); $val=$val[1]->scalar; $pos=0; $i=0; while($pos<strlen($val)){ $tmp=unpack('N',substr($val,$pos,4)); $res['datetime'][$i]=$tmp[1]; $tmp=unpack('N',substr($val,$pos+4,4)); $t=pack('L',$tmp[1]); $tmp=unpack('f',$t); $res[0][$i]=$tmp[1]; $tmp=unpack('c',substr($val,$pos+8,1)); $res['status'][$i]=$tmp[1]; $pos+=9; $i++; } } } else { if(!$aggfunc || !$aggint){ $func='MassenTableHandler.getMatrix'; } else { $func='AggregationTableHandler.getMatrix'; } $val=xml_call($func, array(xmlrpc_array($ids,'int'), $timefilter, $filter_arg, new xmlrpcval(false,'boolean'))); $val=$val[1]->scalar; $pos=0; $i=0; $cols=count($ids); while($pos<strlen($val)){ $tmp=unpack('N',substr($val,$pos,4)); $pos+=4; $res['datetime'][$i]=$tmp[1]; for($j=0;$j<$cols;$j++){ $tmp=unpack('N',substr($val,$pos,4)); $t=pack('L',$tmp[1]); $tmp=unpack('f',$t); $res[$j][$i]=$tmp[1]; $pos+=4; } $i++; } } return $res; } ?>
BayCEER/bayeos-viewer-php
BayEOS-Viewer/www/functions.php
PHP
gpl-2.0
14,289
<?php /** * Class map file for this directory used by WordPoints's autoloader. * * @package WordPoints * @since 2.2.0 */ return array( 'wordpoints_modules_list_table' => 'class-wordpoints-modules-list-table.php', ); // EOF
WordPoints/wordpoints
src/admin/includes/index.php
PHP
gpl-2.0
232
/*************************************************************************** qgswmsdataitems.cpp --------------------- begin : October 2011 copyright : (C) 2011 by Martin Dobias email : wonder dot sk at gmail dot com *************************************************************************** * * * 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. * * * ***************************************************************************/ #include "qgswmsdataitems.h" #include "qgslogger.h" #include "qgsdataitemproviderregistry.h" #include "qgsdatasourceuri.h" #include "qgswmscapabilities.h" #include "qgswmsconnection.h" #include "qgsxyzconnection.h" #ifdef HAVE_GUI #include "qgswmssourceselect.h" #endif #include "qgsgeonodeconnection.h" #include "qgsgeonoderequest.h" #include "qgssettings.h" // --------------------------------------------------------------------------- QgsWMSConnectionItem::QgsWMSConnectionItem( QgsDataItem *parent, QString name, QString path, QString uri ) : QgsDataCollectionItem( parent, name, path, QStringLiteral( "WMS" ) ) , mUri( uri ) { mIconName = QStringLiteral( "mIconConnect.svg" ); mCapabilities |= Collapse; mCapabilitiesDownload = new QgsWmsCapabilitiesDownload( false ); } QgsWMSConnectionItem::~QgsWMSConnectionItem() { delete mCapabilitiesDownload; } void QgsWMSConnectionItem::deleteLater() { if ( mCapabilitiesDownload ) { mCapabilitiesDownload->abort(); } QgsDataCollectionItem::deleteLater(); } QVector<QgsDataItem *> QgsWMSConnectionItem::createChildren() { QVector<QgsDataItem *> children; QgsDataSourceUri uri; uri.setEncodedUri( mUri ); QgsDebugMsgLevel( "mUri = " + mUri, 2 ); QgsWmsSettings wmsSettings; if ( !wmsSettings.parseUri( mUri ) ) { children.append( new QgsErrorItem( this, tr( "Failed to parse WMS URI" ), mPath + "/error" ) ); return children; } bool res = mCapabilitiesDownload->downloadCapabilities( wmsSettings.baseUrl(), wmsSettings.authorization() ); if ( !res ) { children.append( new QgsErrorItem( this, tr( "Failed to download capabilities" ), mPath + "/error" ) ); return children; } QgsWmsCapabilities caps; if ( !caps.parseResponse( mCapabilitiesDownload->response(), wmsSettings.parserSettings() ) ) { children.append( new QgsErrorItem( this, tr( "Failed to parse capabilities" ), mPath + "/error" ) ); return children; } // Attention: supportedLayers() gives tree leafs, not top level QVector<QgsWmsLayerProperty> layerProperties = caps.supportedLayers(); if ( !layerProperties.isEmpty() ) { QgsWmsCapabilitiesProperty capabilitiesProperty = caps.capabilitiesProperty(); const QgsWmsCapabilityProperty &capabilityProperty = capabilitiesProperty.capability; for ( const QgsWmsLayerProperty &layerProperty : qgis::as_const( capabilityProperty.layers ) ) { // Attention, the name may be empty QgsDebugMsgLevel( QString::number( layerProperty.orderId ) + ' ' + layerProperty.name + ' ' + layerProperty.title, 2 ); QString pathName = layerProperty.name.isEmpty() ? QString::number( layerProperty.orderId ) : layerProperty.name; QgsDataItem *layer = nullptr; if ( layerProperty.name.isEmpty() || !layerProperty.layer.isEmpty() ) layer = new QgsWMSLayerCollectionItem( this, layerProperty.title, mPath + '/' + pathName, capabilitiesProperty, uri, layerProperty ); else layer = new QgsWMSLayerItem( this, layerProperty.title, mPath + '/' + pathName, capabilitiesProperty, uri, layerProperty ); children.append( layer ); } } QStringList styleIdentifiers; QStringList linkIdentifiers; QList<QgsWmtsTileLayer> tileLayers = caps.supportedTileLayers(); if ( !tileLayers.isEmpty() ) { QHash<QString, QgsWmtsTileMatrixSet> tileMatrixSets = caps.supportedTileMatrixSets(); const auto constTileLayers = tileLayers; for ( const QgsWmtsTileLayer &l : constTileLayers ) { QString title = l.title.isEmpty() ? l.identifier : l.title; QgsDataItem *layerItem = l.styles.size() == 1 ? static_cast< QgsDataItem * >( this ) : static_cast< QgsDataItem * >( new QgsWMTSRootItem( this, title, mPath + '/' + l.identifier ) ); if ( layerItem != this ) { layerItem->setCapabilities( layerItem->capabilities2() & ~QgsDataItem::Fertile ); layerItem->setState( QgsDataItem::Populated ); layerItem->setToolTip( title ); children << layerItem; } for ( const QgsWmtsStyle &style : qgis::as_const( l.styles ) ) { QString styleName = style.title.isEmpty() ? style.identifier : style.title; if ( layerItem == this ) styleName = title; // just one style so no need to display it // Ensure style path is unique QString stylePathIdentifier { style.identifier }; int i = 0; while ( styleIdentifiers.contains( stylePathIdentifier ) ) { stylePathIdentifier = QStringLiteral( "%1_%2" ).arg( style.identifier ).arg( ++i ); } styleIdentifiers.push_back( stylePathIdentifier ); QgsDataItem *styleItem = l.setLinks.size() == 1 ? static_cast< QgsDataItem * >( layerItem ) : static_cast< QgsDataItem * >( new QgsWMTSRootItem( layerItem, styleName, layerItem->path() + '/' + stylePathIdentifier ) ); if ( styleItem != layerItem ) { styleItem->setCapabilities( styleItem->capabilities2() & ~QgsDataItem::Fertile ); styleItem->setState( QgsDataItem::Populated ); styleItem->setToolTip( styleName ); if ( layerItem == this ) { children << styleItem; } else { layerItem->addChildItem( styleItem ); } } for ( const QgsWmtsTileMatrixSetLink &setLink : qgis::as_const( l.setLinks ) ) { QString linkName = setLink.tileMatrixSet; if ( styleItem == layerItem ) linkName = styleName; // just one link so no need to display it // Ensure link path is unique QString linkPathIdentifier { linkName }; int i = 0; while ( linkIdentifiers.contains( linkPathIdentifier ) ) { linkPathIdentifier = QStringLiteral( "%1_%2" ).arg( linkName ).arg( ++i ); } linkIdentifiers.push_back( linkPathIdentifier ); QgsDataItem *linkItem = l.formats.size() == 1 ? static_cast< QgsDataItem * >( styleItem ) : static_cast< QgsDataItem * >( new QgsWMTSRootItem( styleItem, linkName, styleItem->path() + '/' + linkPathIdentifier ) ); if ( linkItem != styleItem ) { linkItem->setCapabilities( linkItem->capabilities2() & ~QgsDataItem::Fertile ); linkItem->setState( QgsDataItem::Populated ); linkItem->setToolTip( linkName ); if ( styleItem == this ) { children << linkItem; } else { styleItem->addChildItem( linkItem ); } } for ( const QString &format : qgis::as_const( l.formats ) ) { QString name = format; if ( linkItem == styleItem ) name = linkName; // just one format so no need to display it QgsDataItem *tileLayerItem = new QgsWMTSLayerItem( linkItem, name, linkItem->path() + '/' + name, uri, l.identifier, format, style.identifier, setLink.tileMatrixSet, tileMatrixSets[ setLink.tileMatrixSet ].crs, title ); tileLayerItem->setToolTip( name ); if ( linkItem == this ) { children << tileLayerItem; } else { linkItem->addChildItem( tileLayerItem ); } } } } } } return children; } bool QgsWMSConnectionItem::equal( const QgsDataItem *other ) { if ( type() != other->type() ) { return false; } const QgsWMSConnectionItem *otherConnectionItem = qobject_cast<const QgsWMSConnectionItem *>( other ); if ( !otherConnectionItem ) { return false; } bool samePathAndName = ( mPath == otherConnectionItem->mPath && mName == otherConnectionItem->mName ); if ( samePathAndName ) { // Check if the children are not the same then they are not equal if ( mChildren.size() != otherConnectionItem->mChildren.size() ) return false; // compare children content, if the content differs then the parents are not equal for ( QgsDataItem *child : mChildren ) { if ( !child ) continue; for ( QgsDataItem *otherChild : otherConnectionItem->mChildren ) { if ( !otherChild ) continue; // In case they have same path, check if they have same content if ( child->path() == otherChild->path() ) { if ( !child->equal( otherChild ) ) return false; } else { continue; } } } } return samePathAndName; } // --------------------------------------------------------------------------- QgsWMSItemBase::QgsWMSItemBase( const QgsWmsCapabilitiesProperty &capabilitiesProperty, const QgsDataSourceUri &dataSourceUri, const QgsWmsLayerProperty &layerProperty ) : mCapabilitiesProperty( capabilitiesProperty ) , mDataSourceUri( dataSourceUri ) , mLayerProperty( layerProperty ) { } QString QgsWMSItemBase::createUri() { if ( mLayerProperty.name.isEmpty() ) return QString(); // layer collection // Number of styles must match number of layers mDataSourceUri.setParam( QStringLiteral( "layers" ), mLayerProperty.name ); QString style = !mLayerProperty.style.isEmpty() ? mLayerProperty.style.at( 0 ).name : QString(); mDataSourceUri.setParam( QStringLiteral( "styles" ), style ); // Check for layer dimensions for ( const QgsWmsDimensionProperty &dimension : qgis::as_const( mLayerProperty.dimensions ) ) { // add temporal dimensions only if ( dimension.name == QLatin1String( "time" ) || dimension.name == QLatin1String( "reference_time" ) ) { QString name = dimension.name == QLatin1String( "time" ) ? QString( "timeDimensionExtent" ) : QString( "referenceTimeDimensionExtent" ); if ( !( mDataSourceUri.param( QLatin1String( "type" ) ) == QLatin1String( "wmst" ) ) ) mDataSourceUri.setParam( QLatin1String( "type" ), QLatin1String( "wmst" ) ); mDataSourceUri.setParam( name, dimension.extent ); } } // WMS-T defaults settings if ( mDataSourceUri.param( QLatin1String( "type" ) ) == QLatin1String( "wmst" ) ) { mDataSourceUri.setParam( QLatin1String( "temporalSource" ), QLatin1String( "provider" ) ); } QString format; // get first supported by qt and server QVector<QgsWmsSupportedFormat> formats( QgsWmsProvider::supportedFormats() ); const auto constFormats = formats; for ( const QgsWmsSupportedFormat &f : constFormats ) { if ( mCapabilitiesProperty.capability.request.getMap.format.indexOf( f.format ) >= 0 ) { format = f.format; break; } } mDataSourceUri.setParam( QStringLiteral( "format" ), format ); QString crs; // get first known if possible QgsCoordinateReferenceSystem testCrs; for ( const QString &c : qgis::as_const( mLayerProperty.crs ) ) { testCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( c ); if ( testCrs.isValid() ) { crs = c; break; } } if ( crs.isEmpty() && !mLayerProperty.crs.isEmpty() ) { crs = mLayerProperty.crs[0]; } mDataSourceUri.setParam( QStringLiteral( "crs" ), crs ); //uri = rasterLayerPath + "|layers=" + layers.join( "," ) + "|styles=" + styles.join( "," ) + "|format=" + format + "|crs=" + crs; return mDataSourceUri.encodedUri(); } // --------------------------------------------------------------------------- QgsWMSLayerCollectionItem::QgsWMSLayerCollectionItem( QgsDataItem *parent, QString name, QString path, const QgsWmsCapabilitiesProperty &capabilitiesProperty, const QgsDataSourceUri &dataSourceUri, const QgsWmsLayerProperty &layerProperty ) : QgsDataCollectionItem( parent, name, path, QStringLiteral( "wms" ) ) , QgsWMSItemBase( capabilitiesProperty, dataSourceUri, layerProperty ) { mIconName = QStringLiteral( "mIconWms.svg" ); mUri = createUri(); // Populate everything, it costs nothing, all info about layers is collected for ( const QgsWmsLayerProperty &layerProperty : qgis::as_const( mLayerProperty.layer ) ) { // Attention, the name may be empty QgsDebugMsgLevel( QString::number( layerProperty.orderId ) + ' ' + layerProperty.name + ' ' + layerProperty.title, 2 ); QString pathName = layerProperty.name.isEmpty() ? QString::number( layerProperty.orderId ) : layerProperty.name; QgsDataItem *layer = nullptr; if ( layerProperty.name.isEmpty() || !layerProperty.layer.isEmpty() ) layer = new QgsWMSLayerCollectionItem( this, layerProperty.title, mPath + '/' + pathName, capabilitiesProperty, dataSourceUri, layerProperty ); else layer = new QgsWMSLayerItem( this, layerProperty.title, mPath + '/' + pathName, mCapabilitiesProperty, dataSourceUri, layerProperty ); addChildItem( layer ); } setState( Populated ); } bool QgsWMSLayerCollectionItem::equal( const QgsDataItem *other ) { if ( type() != other->type() ) { return false; } const QgsWMSLayerCollectionItem *otherCollectionItem = qobject_cast<const QgsWMSLayerCollectionItem *>( other ); if ( !otherCollectionItem ) { return false; } // Check if the children are not the same then they are not equal if ( mChildren.size() != otherCollectionItem->mChildren.size() ) return false; // compare children content, if the content differs then the parents are not equal for ( QgsDataItem *child : mChildren ) { if ( !child ) continue; for ( QgsDataItem *otherChild : otherCollectionItem->mChildren ) { if ( !otherChild ) continue; // In case they have same path, check if they have same content if ( child->path() == otherChild->path() ) { if ( !child->equal( otherChild ) ) return false; } else { continue; } } } return ( mPath == otherCollectionItem->mPath && mName == otherCollectionItem->mName ); } bool QgsWMSLayerCollectionItem::hasDragEnabled() const { if ( !mLayerProperty.name.isEmpty() ) return true; return false; } QgsMimeDataUtils::Uri QgsWMSLayerCollectionItem::mimeUri() const { QgsMimeDataUtils::Uri u; u.layerType = QStringLiteral( "raster" ); u.providerKey = providerKey(); u.name = name(); u.uri = mUri; u.supportedCrs = mLayerProperty.crs; u.supportedFormats = mCapabilitiesProperty.capability.request.getMap.format; return u; } // --------------------------------------------------------------------------- QgsWMSLayerItem::QgsWMSLayerItem( QgsDataItem *parent, QString name, QString path, const QgsWmsCapabilitiesProperty &capabilitiesProperty, const QgsDataSourceUri &dataSourceUri, const QgsWmsLayerProperty &layerProperty ) : QgsLayerItem( parent, name, path, QString(), QgsLayerItem::Raster, QStringLiteral( "wms" ) ) , QgsWMSItemBase( capabilitiesProperty, dataSourceUri, layerProperty ) { mSupportedCRS = mLayerProperty.crs; mSupportFormats = mCapabilitiesProperty.capability.request.getMap.format; QgsDebugMsgLevel( "uri = " + mDataSourceUri.encodedUri(), 2 ); mUri = createUri(); mIconName = QStringLiteral( "mIconWms.svg" ); setState( Populated ); } bool QgsWMSLayerItem::equal( const QgsDataItem *other ) { if ( type() != other->type() ) { return false; } const QgsWMSLayerItem *otherLayer = qobject_cast<const QgsWMSLayerItem *>( other ); if ( !otherLayer ) { return false; } if ( !mLayerProperty.equal( otherLayer->mLayerProperty ) ) return false; return ( mPath == otherLayer->mPath && mName == otherLayer->mName ); } // --------------------------------------------------------------------------- QgsWMTSLayerItem::QgsWMTSLayerItem( QgsDataItem *parent, const QString &name, const QString &path, const QgsDataSourceUri &uri, const QString &id, const QString &format, const QString &style, const QString &tileMatrixSet, const QString &crs, const QString &title ) : QgsLayerItem( parent, name, path, QString(), QgsLayerItem::Raster, QStringLiteral( "wms" ) ) , mDataSourceUri( uri ) , mId( id ) , mFormat( format ) , mStyle( style ) , mTileMatrixSet( tileMatrixSet ) , mCrs( crs ) , mTitle( title ) { mUri = createUri(); setState( Populated ); } QString QgsWMTSLayerItem::createUri() { // TODO dimensions QgsDataSourceUri uri( mDataSourceUri ); uri.setParam( QStringLiteral( "layers" ), mId ); uri.setParam( QStringLiteral( "styles" ), mStyle ); uri.setParam( QStringLiteral( "format" ), mFormat ); uri.setParam( QStringLiteral( "crs" ), mCrs ); uri.setParam( QStringLiteral( "tileMatrixSet" ), mTileMatrixSet ); return uri.encodedUri(); } // --------------------------------------------------------------------------- QgsWMSRootItem::QgsWMSRootItem( QgsDataItem *parent, QString name, QString path ) : QgsDataCollectionItem( parent, name, path, QStringLiteral( "WMS" ) ) { mCapabilities |= Fast; mIconName = QStringLiteral( "mIconWms.svg" ); populate(); } QVector<QgsDataItem *> QgsWMSRootItem::createChildren() { QVector<QgsDataItem *> connections; const auto connectionList = QgsWMSConnection::connectionList(); for ( const QString &connName : connectionList ) { QgsWMSConnection connection( connName ); QgsDataItem *conn = new QgsWMSConnectionItem( this, connName, mPath + '/' + connName, connection.uri().encodedUri() ); connections.append( conn ); } return connections; } // --------------------------------------------------------------------------- QgsWMTSRootItem::QgsWMTSRootItem( QgsDataItem *parent, QString name, QString path ) : QgsDataCollectionItem( parent, name, path, QStringLiteral( "WMS" ) ) { mCapabilities |= Fast; mIconName = QStringLiteral( "mIconWms.svg" ); populate(); } // --------------------------------------------------------------------------- QString QgsWmsDataItemProvider::dataProviderKey() const { return QStringLiteral( "wms" ); } QgsDataItem *QgsWmsDataItemProvider::createDataItem( const QString &path, QgsDataItem *parentItem ) { QgsDebugMsgLevel( "path = " + path, 2 ); if ( path.isEmpty() ) { return new QgsWMSRootItem( parentItem, QStringLiteral( "WMS/WMTS" ), QStringLiteral( "wms:" ) ); } // path schema: wms:/connection name (used by OWS) if ( path.startsWith( QLatin1String( "wms:/" ) ) ) { QString connectionName = path.split( '/' ).last(); if ( QgsWMSConnection::connectionList().contains( connectionName ) ) { QgsWMSConnection connection( connectionName ); return new QgsWMSConnectionItem( parentItem, QStringLiteral( "WMS/WMTS" ), path, connection.uri().encodedUri() ); } } return nullptr; } // --------------------------------------------------------------------------- QgsXyzTileRootItem::QgsXyzTileRootItem( QgsDataItem *parent, QString name, QString path ) : QgsDataCollectionItem( parent, name, path, QStringLiteral( "WMS" ) ) { mCapabilities |= Fast; mIconName = QStringLiteral( "mIconXyz.svg" ); populate(); } QVector<QgsDataItem *> QgsXyzTileRootItem::createChildren() { QVector<QgsDataItem *> connections; const auto connectionList = QgsXyzConnectionUtils::connectionList(); for ( const QString &connName : connectionList ) { QgsXyzConnection connection( QgsXyzConnectionUtils::connection( connName ) ); QgsDataItem *conn = new QgsXyzLayerItem( this, connName, mPath + '/' + connName, connection.encodedUri() ); connections.append( conn ); } return connections; } // --------------------------------------------------------------------------- QgsXyzLayerItem::QgsXyzLayerItem( QgsDataItem *parent, QString name, QString path, const QString &encodedUri ) : QgsLayerItem( parent, name, path, encodedUri, QgsLayerItem::Raster, QStringLiteral( "wms" ) ) { mIconName = QStringLiteral( "mIconXyz.svg" ); setState( Populated ); } // --------------------------------------------------------------------------- QVector<QgsDataItem *> QgsWmsDataItemProvider::createDataItems( const QString &path, QgsDataItem *parentItem ) { QVector<QgsDataItem *> items; if ( path.startsWith( QLatin1String( "geonode:/" ) ) ) { QString connectionName = path.split( '/' ).last(); if ( QgsGeoNodeConnectionUtils::connectionList().contains( connectionName ) ) { QgsGeoNodeConnection connection( connectionName ); QString url = connection.uri().param( QStringLiteral( "url" ) ); QgsGeoNodeRequest geonodeRequest( url, true ); const QStringList encodedUris( geonodeRequest.fetchServiceUrlsBlocking( QStringLiteral( "WMS" ) ) ); if ( !encodedUris.isEmpty() ) { for ( const QString &encodedUri : encodedUris ) { QgsDebugMsgLevel( encodedUri, 3 ); QgsDataSourceUri uri; QgsSettings settings; QString key( QgsGeoNodeConnectionUtils::pathGeoNodeConnection() + "/" + connectionName ); QString dpiMode = settings.value( key + "/wms/dpiMode", "all" ).toString(); uri.setParam( QStringLiteral( "url" ), encodedUri ); if ( !dpiMode.isEmpty() ) { uri.setParam( QStringLiteral( "dpiMode" ), dpiMode ); } QgsDebugMsgLevel( QStringLiteral( "WMS full uri: '%1'." ).arg( QString( uri.encodedUri() ) ), 2 ); QgsDataItem *item = new QgsWMSConnectionItem( parentItem, QStringLiteral( "WMS" ), path, uri.encodedUri() ); if ( item ) { items.append( item ); } } } } } return items; } QString QgsXyzTileDataItemProvider::name() { return QStringLiteral( "XYZ Tiles" ); } QString QgsXyzTileDataItemProvider::dataProviderKey() const { return QStringLiteral( "wms" ); } int QgsXyzTileDataItemProvider::capabilities() const { return QgsDataProvider::Net; } QgsDataItem *QgsXyzTileDataItemProvider::createDataItem( const QString &path, QgsDataItem *parentItem ) { if ( path.isEmpty() ) return new QgsXyzTileRootItem( parentItem, QStringLiteral( "XYZ Tiles" ), QStringLiteral( "xyz:" ) ); return nullptr; } QVector<QgsDataItem *> QgsXyzTileDataItemProvider::createDataItems( const QString &path, QgsDataItem *parentItem ) { QVector<QgsDataItem *> items; if ( path.startsWith( QLatin1String( "geonode:/" ) ) ) { QString connectionName = path.split( '/' ).last(); if ( QgsGeoNodeConnectionUtils::connectionList().contains( connectionName ) ) { QgsGeoNodeConnection connection( connectionName ); QString url = connection.uri().param( QStringLiteral( "url" ) ); QgsGeoNodeRequest geonodeRequest( url, true ); const QgsStringMap urlData( geonodeRequest.fetchServiceUrlDataBlocking( QStringLiteral( "XYZ" ) ) ); if ( !urlData.isEmpty() ) { auto urlDataIt = urlData.constBegin(); for ( ; urlDataIt != urlData.constEnd(); ++urlDataIt ) { const QString layerName = urlDataIt.key(); QgsDebugMsgLevel( urlDataIt.value(), 2 ); QgsDataSourceUri uri; uri.setParam( QStringLiteral( "type" ), QStringLiteral( "xyz" ) ); uri.setParam( QStringLiteral( "url" ), urlDataIt.value() ); QgsDataItem *item = new QgsXyzLayerItem( parentItem, layerName, path, uri.encodedUri() ); if ( item ) { items.append( item ); } } } } } return items; } bool QgsWMSLayerCollectionItem::layerCollection() const { return true; }
jef-n/QGIS
src/providers/wms/qgswmsdataitems.cpp
C++
gpl-2.0
24,624
/* The Balsa Asynchronous Hardware Synthesis System Copyright (C) 1995-2003 Department of Computer Science The University of Manchester, Oxford Road, Manchester, UK, M13 9PL 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, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA `BalsaScanSource.h' Modified automatically generated rex Source.c file Added code to track file inclusion */ #ifndef BALSA_SOURCE_HEADER #define BALSA_SOURCE_HEADER #include "rSystem.h" extern int Balsa (void); #define BalsaScan_GetLine(file, buffer, size) rRead ((file), (buffer), (size)) #define BalsaScan_CloseSource(file) rClose (file) extern int BalsaScan_BeginSource (char *fileName); #endif /* BALSA_SOURCE_HEADER */
kristofferkoch/Balsa
src/balsa-c/BalsaScanSource.h
C
gpl-2.0
1,302
-- phpMyAdmin SQL Dump -- version 4.2.7.1 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: 02-Ago-2015 às 03:17 -- Versão do servidor: 5.6.20 -- PHP Version: 5.5.15 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `rbc` -- -- -------------------------------------------------------- -- -- Estrutura da tabela `casos` -- CREATE TABLE IF NOT EXISTS `casos` ( `nivel3` varchar(100) DEFAULT NULL, `nivel2` varchar(100) DEFAULT NULL, `nivel1` varchar(100) NOT NULL, `proxima` varchar(100) NOT NULL, `id` int(11) NOT NULL, `peso` tinyint(2) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Estrutura da tabela `conversa` -- CREATE TABLE IF NOT EXISTS `conversa` ( `id` int(11) NOT NULL, `idEnviador` int(11) NOT NULL, `idReceptor` int(11) NOT NULL, `mensagem` varchar(2000) NOT NULL, `data` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Extraindo dados da tabela `conversa` -- INSERT INTO `conversa` (`id`, `idEnviador`, `idReceptor`, `mensagem`, `data`) VALUES (1, 1, 2, 'Olá!', '2015-08-01 21:17:00'); -- -------------------------------------------------------- -- -- Estrutura da tabela `usuarios` -- CREATE TABLE IF NOT EXISTS `usuarios` ( `login` varchar(50) NOT NULL, `senha` varchar(32) NOT NULL, `id` int(11) NOT NULL, `nome` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; -- -- Extraindo dados da tabela `usuarios` -- INSERT INTO `usuarios` (`login`, `senha`, `id`, `nome`) VALUES ('rodrigo', '3953526f726b29fae75e5fb9f411c26e', 1, 'Rodrigo'), ('igor', '3953526f726b29fae75e5fb9f411c26e', 2, 'Igor'); -- -- Indexes for dumped tables -- -- -- Indexes for table `casos` -- ALTER TABLE `casos` ADD PRIMARY KEY (`id`); -- -- Indexes for table `conversa` -- ALTER TABLE `conversa` ADD PRIMARY KEY (`id`); -- -- Indexes for table `usuarios` -- ALTER TABLE `usuarios` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `login` (`login`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `casos` -- ALTER TABLE `casos` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `conversa` -- ALTER TABLE `conversa` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `usuarios` -- ALTER TABLE `usuarios` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
rodrigozietlow/Sistema-de-chat-por-RBC---2015
rbc.sql
SQL
gpl-2.0
2,915
#import <Foundation/Foundation.h> #import <CoreData/CoreData.h> #import <WordPressApi/WordPressApi.h> #import "WordPressComApi.h" @class Blog; @interface WPAccount : NSManagedObject ///----------------- /// @name Properties ///----------------- @property (nonatomic, strong) NSNumber *userID; @property (nonatomic, strong) NSString *avatarURL; @property (nonatomic, copy) NSString *username; @property (nonatomic, copy) NSString *uuid; @property (nonatomic, strong) NSString *email; @property (nonatomic, strong) NSSet *blogs; @property (nonatomic, strong) NSSet *jetpackBlogs; @property (nonatomic, readonly) NSArray *visibleBlogs; @property (nonatomic, strong) Blog *defaultBlog; /** The OAuth2 auth token for WordPress.com accounts */ @property (nonatomic, copy) NSString *authToken; ///------------------ /// @name API Helpers ///------------------ /** A WordPressComApi object if the account is a WordPress.com account. Otherwise, it returns `nil` */ @property (nonatomic, readonly) WordPressComApi *restApi; @end @interface WPAccount (CoreDataGeneratedAccessors) - (void)addBlogsObject:(Blog *)value; - (void)removeBlogsObject:(Blog *)value; - (void)addBlogs:(NSSet *)values; - (void)removeBlogs:(NSSet *)values; - (void)addJetpackBlogsObject:(Blog *)value; - (void)removeJetpackBlogsObject:(Blog *)value; - (void)addJetpackBlogs:(NSSet *)values; - (void)removeJetpackBlogs:(NSSet *)values; @end
argon/WordPress-iOS
WordPress/Classes/Models/WPAccount.h
C
gpl-2.0
1,479
/* * FreeGuide J2 * * Copyright (c) 2001-2004 by Andy Balaam and the FreeGuide contributors * * freeguide-tv.sourceforge.net * * Released under the GNU General Public License * with ABSOLUTELY NO WARRANTY. * * See the file COPYING for more information. */ package freeguide.plugins.program.freeguide.wizard; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JPanel; /** * A JPanel to go on a FreeGuideWizard to choose a boolean option with a * checkbox. * * @author Andy Balaam * @version 1 */ public class BooleanWizardPanel extends WizardPanel { // ------------------------------------------- private JCheckBox checkbox; /** * Constructor for the BooleanWizardPanel object */ BooleanWizardPanel( ) { super( ); } /** * Construct the GUI of this Wizard Panel. */ public void construct( ) { java.awt.GridBagConstraints gridBagConstraints; JPanel midPanel = new JPanel( ); JLabel topLabel = new JLabel( ); JLabel bottomLabel = new JLabel( ); checkbox = new JCheckBox( ); setLayout( new java.awt.GridLayout( 3, 0 ) ); topLabel.setFont( new java.awt.Font( "Dialog", 0, 12 ) ); topLabel.setHorizontalAlignment( javax.swing.SwingConstants.CENTER ); add( topLabel ); midPanel.setLayout( new java.awt.GridBagLayout( ) ); checkbox.setText( topMessage ); checkbox.setMnemonic( topMnemonic ); gridBagConstraints = new java.awt.GridBagConstraints( ); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.9; gridBagConstraints.insets = new java.awt.Insets( 5, 5, 5, 5 ); midPanel.add( checkbox, gridBagConstraints ); add( midPanel ); bottomLabel.setFont( new java.awt.Font( "Dialog", 0, 12 ) ); bottomLabel.setHorizontalAlignment( javax.swing.SwingConstants.CENTER ); bottomLabel.setText( bottomMessage ); add( bottomLabel ); } /** * Gets the boxValue attribute of the BooleanWizardPanel object * * @return The boxValue value */ protected Object getBoxValue( ) { return new Boolean( checkbox.isSelected( ) ); } /** * Sets the boxValue attribute of the BooleanWizardPanel object * * @param val The new boxValue value */ protected void setBoxValue( Object val ) { checkbox.setSelected( ( (Boolean)val ).booleanValue( ) ); } // The checkbox for the choice }
andybalaam/freeguide
src/freeguide/plugins/program/freeguide/wizard/BooleanWizardPanel.java
Java
gpl-2.0
2,693
/* ///////////////////////////////////////////////////////////////////// */ /*! \file \brief Implements a RK-midpoint time stepping routine. The RK-midpoing advance the system of conservation law by first evolving the solution at the half-time level and then doing a full step using midpoint quadrature rule: \f[ \left\{\begin{array}{lcl} U^{n+\HALF} &=& U^n + \frac{\Delta t}{2} R^n \\ \noalign{\medskip} U^{n+1} &=& U^n + \Delta t R^{n+\HALF} \end{array}\right. \f] \authors A. Mignone (mignone@ph.unito.it)\n C. Zanni (zanni@oato.inaf.it) \date Sep 20, 2012 */ /* ///////////////////////////////////////////////////////////////////// */ #include <cstdio> #include <string> using std::string; #include "PatchPluto.H" #include "LoHiSide.H" /* ********************************************************************* */ void PatchPluto::updateSolution(FArrayBox& a_U, FArrayBox& a_Utmp, FArrayBox& split_tags, BaseFab<unsigned char>& a_Flags, FluxBox& a_F, Time_Step *Dts, const Box& UBox, Grid *grid) /* * * * * *********************************************************************** */ { CH_assert(isDefined()); CH_assert(UBox == m_currentBox); int nv, in; int nxf, nyf, nzf, indf; int nxb, nyb, nzb; int *i, *j, *k; int ii, jj, kk; double ***UU[NVAR]; #ifdef SKIP_SPLIT_CELLS double ***splitcells; #endif double *inv_dl, dl2; static Data d; static Data_Arr UU_1; static double ***C_dt[NVAR]; static double **u; #if (PARABOLIC_FLUX & EXPLICIT) static double **dcoeff; #endif Index indx; static State_1D state; Riemann_Solver *Riemann; Riemann = rsolver; /* ----------------------------------------------------------------- Check algorithm compatibilities ----------------------------------------------------------------- */ #if !(GEOMETRY == CARTESIAN || GEOMETRY == CYLINDRICAL || GEOMETRY == SPHERICAL) print1 ("! RK only works in cartesian or cylindrical/spherical coordinates\n"); QUIT_PLUTO(1); #endif if (NX1_TOT > NMAX_POINT || NX2_TOT > NMAX_POINT || NX3_TOT > NMAX_POINT){ print ("!updateSolution (RK_MID): need to re-allocate matrix\n"); QUIT_PLUTO(1); } /* ----------------------------------------------------------------- Allocate memory ----------------------------------------------------------------- */ for (nv = 0; nv < NVAR; nv++){ UU[nv] = ArrayMap(NX3_TOT, NX2_TOT, NX1_TOT, a_U.dataPtr(nv)); } #ifdef SKIP_SPLIT_CELLS splitcells = ArrayBoxMap(KBEG, KEND, JBEG, JEND, IBEG, IEND, split_tags.dataPtr(0)); #endif /* ----------------------------------------------------------- Allocate static memory areas ----------------------------------------------------------- */ if (state.flux == NULL){ MakeState (&state); nxf = nyf = nzf = 1; D_EXPAND(nxf = NMAX_POINT; , nyf = NMAX_POINT; , nzf = NMAX_POINT;) u = ARRAY_2D(NMAX_POINT, NVAR, double); d.Vc = ARRAY_4D(NVAR, nzf, nyf, nxf, double); UU_1 = ARRAY_4D(nzf, nyf, nxf, NVAR, double); d.flag = ARRAY_3D(nzf, nyf, nxf, unsigned char); #if (PARABOLIC_FLUX & EXPLICIT) dcoeff = ARRAY_2D(NMAX_POINT, NVAR, double); #endif /* ------------------------------------------------------- C_dt is an array used to storee the inverse time step for advection and diffusion. We use C_dt[RHO] for advection, C_dt[MX1] for viscosity, C_dt[BX1...BX3] for resistivity and C_dt[ENG] for thermal conduction. ------------------------------------------------------- */ C_dt[RHO] = ARRAY_3D(nzf, nyf, nxf, double); #if VISCOSITY == EXPLICIT C_dt[MX1] = ARRAY_3D(nzf, nyf, nxf, double); #endif #if RESISTIVE_MHD == EXPLICIT EXPAND(C_dt[BX1] = ARRAY_3D(nzf, nyf, nxf, double); , C_dt[BX2] = ARRAY_3D(nzf, nyf, nxf, double); , C_dt[BX3] = ARRAY_3D(nzf, nyf, nxf, double);) #endif #if THERMAL_CONDUCTION == EXPLICIT C_dt[ENG] = ARRAY_3D(nzf, nyf, nxf, double); #endif } g_intStage = 1; FlagReset (&d); getPrimitiveVars (UU, &d, grid); #if SHOCK_FLATTENING == MULTID FindShock (&d, grid); #endif #ifdef SKIP_SPLIT_CELLS DOM_LOOP(kk,jj,ii){ if (splitcells[kk][jj][ii] < 0.5){ d.flag[kk][jj][ii] |= FLAG_SPLIT_CELL; } } #endif /* ---------------------------------------------------- STEP 1: Predictor ---------------------------------------------------- */ for (g_dir = 0; g_dir < DIMENSIONS; g_dir++){ SetIndexes (&indx, grid); D_EXPAND(indx.beg -= 2; indx.end += 2; , indx.t1_beg -= 2; indx.t1_end += 2; , indx.t2_beg -= 2; indx.t2_end += 2;) ResetState (&d, &state, grid); TRANSVERSE_LOOP(indx,in,i,j,k){ inv_dl = GetInverse_dl(grid); for (in = 0; in < indx.ntot; in++) { for (nv = 0; nv < NVAR; nv++) { state.v[in][nv] = d.Vc[nv][*k][*j][*i]; }} CheckNaN (state.v, indx.beg-1, indx.end+1, 0); PrimToCons (state.v, u, 0, indx.ntot-1); for (in = 0; in < indx.ntot; in++){ for (nv = NVAR; nv--; ){ state.vp[in][nv] = state.vm[in][nv] = state.v[in][nv]; }} PrimToCons (state.vp, state.up, 0, indx.ntot-1); PrimToCons (state.vm, state.um, 0, indx.ntot-1); Riemann (&state, indx.beg - 1, indx.end, Dts->cmax, grid); #if (PARABOLIC_FLUX & EXPLICIT) ParabolicFlux(d->Vc, &state, dcoeff, indx.beg - 1, indx.end, grid); #endif RightHandSide (&state, Dts, indx.beg, indx.end, 0.5*g_dt, grid); if (g_dir == IDIR){ for (in = indx.beg; in <= indx.end; in++){ #if !GET_MAX_DT C_dt[0][*k][*j][*i] = 0.5*(Dts->cmax[in-1] + Dts->cmax[in])*inv_dl[in]; #endif #if VISCOSITY == EXPLICIT dl2 = 0.5*inv_dl[in]*inv_dl[in]; C_dt[MX1][*k][*j][*i] = (dcoeff[in][MX1]+dcoeff[in-1][MX1])*dl2; #endif #if RESISTIVE_MHD == EXPLICIT dl2 = 0.5*inv_dl[in]*inv_dl[in]; EXPAND(C_dt[BX1][*k][*j][*i] = (dcoeff[in-1][BX1]+dcoeff[in][BX1])*dl2; , C_dt[BX2][*k][*j][*i] = (dcoeff[in-1][BX2]+dcoeff[in][BX2])*dl2; , C_dt[BX3][*k][*j][*i] = (dcoeff[in-1][BX3]+dcoeff[in][BX3])*dl2;) #endif #if THERMAL_CONDUCTION == EXPLICIT dl2 = 0.5*inv_dl[in]*inv_dl[in]; C_dt[ENG][*k][*j][*i] = (dcoeff[in-1][ENG] + dcoeff[in][ENG])*dl2; #endif for (nv = NVAR; nv--; ) UU_1[*k][*j][*i][nv] = u[in][nv] + state.rhs[in][nv]; } }else{ for (in = indx.beg; in <= indx.end; in++) { #if !GET_MAX_DT C_dt[0][*k][*j][*i] += 0.5*(Dts->cmax[in-1] + Dts->cmax[in])*inv_dl[in]; #endif #if VISCOSITY == EXPLICIT dl2 = 0.5*inv_dl[in]*inv_dl[in]; C_dt[MX1][*k][*j][*i] += (dcoeff[in][MX1]+dcoeff[in-1][MX1])*dl2; #endif #if RESISTIVE_MHD == EXPLICIT dl2 = 0.5*inv_dl[in]*inv_dl[in]; EXPAND(C_dt[BX1][*k][*j][*i] += (dcoeff[in-1][BX1]+dcoeff[in][BX1])*dl2; , C_dt[BX2][*k][*j][*i] += (dcoeff[in-1][BX2]+dcoeff[in][BX2])*dl2; , C_dt[BX3][*k][*j][*i] += (dcoeff[in-1][BX3]+dcoeff[in][BX3])*dl2;) #endif #if THERMAL_CONDUCTION == EXPLICIT dl2 = 0.5*inv_dl[in]*inv_dl[in]; C_dt[ENG][*k][*j][*i] += (dcoeff[in-1][ENG] + dcoeff[in][ENG])*dl2; #endif for (nv = NVAR; nv--; ) UU_1[*k][*j][*i][nv] += state.rhs[in][nv]; } } } } /* ---- convert predictor state to primitive ---- */ g_dir = IDIR; SetIndexes (&indx, grid); for (kk = KBEG - 2*KOFFSET; kk <= KEND + 2*KOFFSET; kk++){ g_k = &kk; for (jj = JBEG - 2*JOFFSET; jj <= JEND + 2*JOFFSET; jj++){ g_j = &jj; ConsToPrim (UU_1[kk][jj], state.v, IBEG-2, IEND+2, state.flag); for (ii = IBEG-2; ii <= IEND+2; ii++){ for (nv = 0; nv < NVAR; nv++) d.Vc[nv][kk][jj][ii] = state.v[ii][nv]; #if !GET_MAX_DT Dts->inv_dta = MAX(Dts->inv_dta, C_dt[0][kk][jj][ii]); #endif #if VISCOSITY == EXPLICIT Dts->inv_dtp = MAX(Dts->inv_dtp, C_dt[MX1][kk][jj][ii]); #endif #if RESISTIVE_MHD == EXPLICIT EXPAND(Dts->inv_dtp = MAX(Dts->inv_dtp, C_dt[BX1][kk][jj][ii]); , Dts->inv_dtp = MAX(Dts->inv_dtp, C_dt[BX2][kk][jj][ii]); , Dts->inv_dtp = MAX(Dts->inv_dtp, C_dt[BX3][kk][jj][ii]);) #endif #if THERMAL_CONDUCTION == EXPLICIT Dts->inv_dtp = MAX(Dts->inv_dtp, C_dt[ENG][kk][jj][ii]); #endif } }} #if !GET_MAX_DT Dts->inv_dta /= (double)DIMENSIONS; #endif #if (PARABOLIC_FLUX & EXPLICIT) Dts->inv_dtp /= (double)DIMENSIONS; #endif #ifdef GLM_MHD ch_max_loc = MAX(ch_max_loc, Dts->inv_dta*m_currentDlMin); #endif /* ---------------------------------------------------- STEP 2: Corrector ---------------------------------------------------- */ int numFlux = numFluxes(); a_F.resize(UBox,numFlux); a_F.setVal(0.0); g_intStage = 2; for (g_dir = 0; g_dir < DIMENSIONS; g_dir++){ SetIndexes (&indx, grid); nxf = grid[IDIR].np_int + (g_dir == IDIR); nyf = grid[JDIR].np_int + (g_dir == JDIR); nzf = grid[KDIR].np_int + (g_dir == KDIR); nxb = grid[IDIR].lbeg - (g_dir == IDIR); nyb = grid[JDIR].lbeg - (g_dir == JDIR); nzb = grid[KDIR].lbeg - (g_dir == KDIR); ResetState (&d, &state, grid); TRANSVERSE_LOOP(indx,in,i,j,k){ for (in = 0; in < indx.ntot; in++) { for (nv = NVAR; nv--; ) state.v[in][nv] = d.Vc[nv][*k][*j][*i]; } States (&state, indx.beg - 1, indx.end + 1, grid); Riemann (&state, indx.beg - 1, indx.end, Dts->cmax, grid); #if (PARABOLIC_FLUX & EXPLICIT) ParabolicFlux (d->Vc, &state, dcoeff, indx.beg - 1, indx.end, grid); #endif RightHandSide (&state, Dts, indx.beg, indx.end, g_dt, grid); saveFluxes (&state, indx.beg-1, indx.end, grid); for (in = indx.beg; in <= indx.end; in++) { for (nv = NVAR; nv--; ) { UU[nv][*k][*j][*i] += state.rhs[in][nv]; }} // Put fluxes in the FarrayBox a_F to be passed to Chombo for (in = indx.beg-1; in <= indx.end; in++) { #if AMR_EN_SWITCH == YES state.flux[in][ENG] = 0.0; #endif #if ENTROPY_SWITCH == YES state.flux[in][ENTR] = 0.0; #endif for (nv = 0; nv < NVAR; nv++) { indf = nv*nzf*nyf*nxf + (*k - nzb)*nyf*nxf + (*j - nyb)*nxf + (*i - nxb); a_F[g_dir].dataPtr(0)[indf] = state.flux[in][nv]; } } } } #ifdef GLM_MHD double dtdx = g_dt/coeff_dl_min/m_dx; GLM_Source (UU, dtdx, grid); #endif /* ---------------------------------------------- Source terms included via operator splitting ---------------------------------------------- */ #if COOLING != NO convertConsToPrim(UU, d.Vc, IBEG, JBEG, KBEG, IEND, JEND, KEND, grid); SplitSource (&d, g_dt, Dts, grid); convertPrimToCons(d.Vc, UU, IBEG, JBEG, KBEG, IEND, JEND, KEND, grid); #endif /* ---------------------------------------------------------- Convert total energy before returning to Chombo. This should be done only inside the computational domain and physical boundaries. For ease of implementation we carry it out everywhere (internal boundaries will be overwritten later). ---------------------------------------------------------- */ #if AMR_EN_SWITCH == YES totEnergySwitch (UU, IBEG-IOFFSET, IEND+IOFFSET, JBEG-JOFFSET, JEND+JOFFSET, KBEG-KOFFSET, KEND+KOFFSET, -1); #if ENTROPY_SWITCH == YES totEnergySwitch (UU, IBEG-IOFFSET, IEND+IOFFSET, JBEG-JOFFSET, JEND+JOFFSET, KBEG-KOFFSET, KEND+KOFFSET, 0); #endif #endif /* --------------------------------------------------------------- In cylindrical geom. we pass U*r back to Chombo rather than U. --------------------------------------------------------------- */ #if GEOMETRY == CYLINDRICAL for (nv = NVAR; nv--; ){ for (kk = KBEG-KOFFSET; kk <= KEND+KOFFSET; kk++){ for (jj = JBEG-JOFFSET; jj <= JEND+JOFFSET; jj++){ for (ii = IBEG-IOFFSET; ii <= IEND+IOFFSET; ii++){ UU[nv][kk][jj][ii] *= grid[IDIR].x[ii]; }}}} #endif #if GEOMETRY == SPHERICAL for (nv = NVAR; nv--; ){ for (kk = KBEG-KOFFSET; kk <= KEND+KOFFSET; kk++){ for (jj = JBEG-JOFFSET; jj <= JEND+JOFFSET; jj++){ for (ii = IBEG-IOFFSET; ii <= IEND+IOFFSET; ii++){ UU[nv][kk][jj][ii] *= grid[IDIR].dV[ii]*grid[JDIR].dV[jj]/m_dx/m_dx; }}}} #endif /* ------------------------------------------------- Free memory ------------------------------------------------- */ for (nv = 0; nv < NVAR; nv++) FreeArrayMap(UU[nv]); #ifdef SKIP_SPLIT_CELLS FreeArrayBoxMap (splitcells, KBEG, KEND, JBEG, JEND, IBEG, IEND); #endif }
kylekanos/mypluto
Src/Chombo/PatchRK.3D.cpp
C++
gpl-2.0
13,574
<?php /** * Amazon Webservices Client Class * http://www.amazon.country * ========================= * * @package aaAmazonWS * @author AA-Team */ if ( !class_exists('aaAmazonWS') ) { class aaAmazonWS { const RETURN_TYPE_ARRAY = 1; const RETURN_TYPE_OBJECT = 2; private $protocol = 'SOAP'; /** * Baseconfigurationstorage * * @var array */ private $requestConfig = array(); /** * The Session Key used for cart tracking * @access protected * @var string */ private $_sessionKey = 'amzCart'; /** * Responseconfigurationstorage * * @var array */ private $responseConfig = array( 'returnType' => self::RETURN_TYPE_ARRAY, 'responseGroup' => 'Small', 'optionalParameters' => array() ); /** * All possible locations * * @var array */ private $possibleLocations = array('de', 'com', 'co.uk', 'ca', 'fr', 'co.jp', 'it', 'cn', 'es', 'in'); /** * The WSDL File * * @var string */ protected $webserviceWsdl = 'http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl'; /** * The SOAP Endpoint * * @var string */ protected $webserviceEndpoint = 'https://webservices.amazon.%%COUNTRY%%/onca/%%PROTOCOL%%?Service=AWSECommerceService'; /** * @param string $accessKey * @param string $secretKey * @param string $country * @param string $associateTag */ public function __construct($accessKey, $secretKey, $country, $associateTag='' ) { if (!session_id()) { @session_start(); } // private setter helper $this->setProtocol(); $this->webserviceEndpoint = str_replace( '%%PROTOCOL%%', strtolower( $this->protocol ), $this->webserviceEndpoint ); if (empty($accessKey) || empty($secretKey)) { throw new Exception('No Access Key or Secret Key has been set'); } $this->requestConfig['accessKey'] = $accessKey; $this->requestConfig['secretKey'] = $secretKey; $this->associateTag( $associateTag ); $this->country( $country ); } private function setProtocol() { $db_protocol_setting = @unserialize( get_option("WooZoneLight_amazon", true) ); $db_protocol_setting = isset( $db_protocol_setting['protocol'] ) ? $db_protocol_setting['protocol'] : 'auto'; if( $db_protocol_setting == 'soap' ){ // if soap extension are not installed, load as XML if ( extension_loaded('soap') ) { $this->protocol = 'SOAP'; }else{ // if not soap installed, force to XML $this->protocol = 'XML'; } } if( $db_protocol_setting == 'auto' ){ // if soap extension are not installed, load as XML if ( !extension_loaded('soap') ) { $this->protocol = 'XML'; } } if( $db_protocol_setting == 'xml' ){ $this->protocol = 'XML'; } } /** * execute search * * @param string $pattern * * @return array|object return type depends on setting * * @see returnType() */ public function search($pattern, $nodeId = null) { if (false === isset($this->requestConfig['category'])) { throw new Exception('No Category given: Please set it up before'); } $browseNode = array(); if (null !== $nodeId && true === $this->validateNodeId($nodeId)) { $browseNode = array('BrowseNode' => $nodeId); } $params = $this->buildRequestParams('ItemSearch', array_merge( array( 'Keywords' => $pattern, 'SearchIndex' => $this->requestConfig['category'] ), $browseNode )); return $this->returnData( $this->performTheRequest("ItemSearch", $params) ); } /** * Convenience method to bulk submit a couple items, or just one single item. This will create a cart if necessary. * * Example: $this->Amazon->cartThem(array(array('offerId' => 'asdasd...', 'quantity' => 3), array(...))); * * @access public * @param array $selectedItems A array with offerIds and quantity keys. * @return mixed Response or FALSE if nothing to do or bad input */ function cartThem($selectedItems) { $result = false; if (!empty($selectedItems) && is_array($selectedItems)) { if (!isset($_SESSION[$this->_sessionKey]["cartId"])) { // new cart $firstItem = array_shift($selectedItems); $result = $this->cartCreate($firstItem['offerId'], $firstItem['quantity']); } if (count($selectedItems)) { // add foreach ($selectedItems as $item) { $result = $this->cartAdd($item['offerId'], $item['quantity']); } } } return $result; } /** * Creates a new Remote Cart. A new cart is initialized once you add at least 1 item. The HMAC and CartID * is used in all further communications. BEFORE YOU CAN USE THE CART, YOU HAVE TO ADD 1 ITEM AT LEAST! * * @access public * @param array $offerListingId An OfferListing->OfferListingId from Lookup or Search. You'll need "Offer" response group! * @param integer $quantity The amount the user wants from this item. * @return array */ function cartCreate($offerListingId, $quantity = 1) { $params = $this->buildRequestParams('CartCreate', array( 'Items' => array( 'Item' => array('ASIN' => $offerListingId, 'Quantity' => $quantity) ) ) ); $response = $this->returnData( $this->performTheRequest("CartCreate", $params) ); $response = $response['Cart']; // first if return some error if( isset($response['Request']['Errors']) ) { die(json_encode(array( 'status' => 'invalid', 'msg' => ( isset($response['Request']['Errors']['Error']['Message']) ? $response['Request']['Errors']['Error']['Message'] : 'Unable to add this product to cart. Please contact shop administrator. ' ) ))); } // save the result in the session $_SESSION[$this->_sessionKey] = array( 'HMAC' => $response['HMAC'], 'cartId' => $response['CartId'], 'PurchaseUrl' => $response['PurchaseURL'], ); return $this->__formatCartItems($response); } /** * Adds a new Item with given quantity to the remote cart. * * @access public * @param string $offerListingId An ItemID from Lookup or Search Offer * @param integer $quantity As the name says.. * @param string $HMAC (optional) HMAC If empty, uses session. * @param string $cartId (optional) Remote cart ID. If empty, uses session. * @return mixed Response or FALSE on missing HMAC/ID */ function cartAdd($offerListingId, $quantity = 1, $HMAC = null, $cartId = null) { if (!$HMAC) { $HMAC = $_SESSION[$this->_sessionKey]['HMAC']; } if (!$cartId) { $cartId = $_SESSION[$this->_sessionKey]['cartId']; } if (!$HMAC || !$cartId) { return false; } $params = $this->buildRequestParams('CartAdd', array( 'CartId' => $cartId, 'HMAC' => $HMAC, 'Items' => array( 'Item' => array('ASIN' => $offerListingId, 'Quantity' => $quantity) ) ) ); $response = $this->returnData( $this->performTheRequest("CartAdd", $params) ); // first if return some error if( isset($response['Cart']['Request']['Errors']) ) { die(json_encode(array( 'status' => 'invalid', 'msg' => ( isset($response['Cart']['Request']['Errors']['Error']['Message']) ? $response['Cart']['Request']['Errors']['Error']['Message'] : 'Unable to add this product to cart. Please contact shop administrator. ' ) ))); } return $this->__formatCartItems($response['Cart']); } /** * Update the Quantity of a CartItem * * @access public * @param string $cartItemId As the name says.. [CartItem][CartItemId] * @param integer $quantity As the name says.. * @param string $HMAC (optional) HMAC which was returned with cartCreate. If empty, uses session. * @param string $cartId (optional) The ID of the remote cart. If empty, uses session. * @return mixed Response or FALSE on missing HMAC/ID */ function cartUpdate($cartItemId, $quantity, $HMAC = null, $cartId = null) { if (!$HMAC) { $HMAC = isset($_SESSION[$this->_sessionKey]['HMAC']) ? $_SESSION[$this->_sessionKey]['HMAC'] : ''; } if (!$cartId) { $cartId = isset($_SESSION[$this->_sessionKey]['cartId']) ? $_SESSION[$this->_sessionKey]['cartId'] : ''; } if (!$HMAC || !$cartId) { return false; } $params = $this->buildRequestParams('CartModify', array( 'CartId' => $cartId, 'HMAC' => $HMAC, 'Items' => array( 'Item' => array('CartItemId' => $cartItemId, 'Quantity' => $quantity) ) ) ); $response = $this->returnData( $this->performTheRequest("CartModify", $params) ); return $this->__formatCartItems($response['Cart']['Request']['CartModifyRequest']); } /** * Gets the current remote cart contents * * @access public * @param string $HMAC (optional) HMAC which was returned with cartCreate. If empty, uses session. * @param string $cartId (optional) The ID of the remote cart. If empty, uses session. * @return mixed Response or FALSE on missing HMAC/ID */ function cartGet($HMAC = null, $cartId = null) { if (!$HMAC) { $HMAC = isset($_SESSION[$this->_sessionKey]['HMAC']) ? $_SESSION[$this->_sessionKey]['HMAC'] : ''; } if (!$cartId) { $cartId = isset($_SESSION[$this->_sessionKey]['cartId']) ? $_SESSION[$this->_sessionKey]['cartId'] : ''; } if (!$HMAC || !$cartId) { return false; } $params = $this->buildRequestParams('CartGet', array( 'CartId' => $cartId, 'HMAC' => $HMAC ) ); return $this->returnData( $this->performTheRequest("CartGet", $params) ); } /** * Check if an remote cart is available based on last/given response * * @access public * @param array $cart A cart response * @return boolean */ function cartIsActive($cart = null) { if (!$cart) { $cart = $this->__lastCart; } return ($cart && isset($cart['CartId'])); } /** * Check if Cart-Response has any Items * * @access public * @author Kjell Bublitz <m3nt0r.de@gmail.com> * @param array $cart A cart response * @return boolean */ function cartHasItems($cart = null) { if (!$cart) { $cart = $this->__lastCart; } return ($cart && isset($cart['CartItems'])); } /** * Remove Cart from Session. * * @access public * @return boolean */ public function cartKill() { unset($_SESSION[$this->_sessionKey]); unset($_SESSION['aaCartProd']); } /** * Makes sure that CartItem is always a single dim array. * * @access private * @param array $cart Cart Response * @return array Cart Response */ function __formatCartItems($cart) { unset($cart['Request']); if (isset($cart['CartItems'])) { $_cartItem = $cart['CartItems']['CartItem']; $items = array_keys($_cartItem); if (!is_numeric(array_shift($items))) { $cart['CartItems']['CartItem'] = array($_cartItem); } } $this->__lastCart = $cart; // for easier working with helper methods return $cart; } /** * execute ItemLookup request * * @param string $asin * * @return array|object return type depends on setting * * @see returnType() */ public function lookup($asin) { $params = $this->buildRequestParams('ItemLookup', array( 'ItemId' => $asin, )); return $this->returnData( $this->performTheRequest("ItemLookup", $params) ); } /** * Implementation of BrowseNodeLookup * This allows to fetch information about nodes (children anchestors, etc.) * * @param integer $nodeId */ public function browseNode($nodeId) { $this->validateNodeId($nodeId); $this->responseConfig['BrowseNode'] = $nodeId; } /** * Implementation of BrowseNodeLookup * This allows to fetch information about nodes (children anchestors, etc.) * * @param integer $nodeId */ public function browseNodeLookup($nodeId) { $this->validateNodeId($nodeId); $params = $this->buildRequestParams('BrowseNodeLookup', array( 'BrowseNodeId' => $nodeId )); return $this->returnData( $this->performTheRequest("BrowseNodeLookup", $params) ); } /** * Implementation of SimilarityLookup * This allows to fetch information about product related to the parameter product * * @param string $asin */ public function similarityLookup($asin) { $params = $this->buildRequestParams('SimilarityLookup', array( 'ItemId' => $asin )); return $this->returnData( $this->performTheRequest("SimilarityLookup", $params) ); } /** * Builds the request parameters * * @param string $function * @param array $params * * @return array */ protected function buildRequestParams($function, array $params) { $associateTag = array(); if(false === empty($this->requestConfig['associateTag'])) { $associateTag = array('AssociateTag' => $this->requestConfig['associateTag']); } return array_merge( $associateTag, array( 'AWSAccessKeyId' => $this->requestConfig['accessKey'], 'Request' => array_merge( array('Operation' => $function), $params, $this->responseConfig['optionalParameters'], array('ResponseGroup' => $this->prepareResponseGroup()) ))); } /** * Prepares the responsegroups and returns them as array * * @return array|prepared responsegroups */ protected function prepareResponseGroup() { if (false === strstr($this->responseConfig['responseGroup'], ',')) return $this->responseConfig['responseGroup']; return explode(',', $this->responseConfig['responseGroup']); } /** * @param string $function Name of the function which should be called * @param array $params Requestparameters 'ParameterName' => 'ParameterValue' * * @return array The response as an array with stdClass objects */ protected function performXMLRequest($function, $params) { $_params = $params['Request']; $params = array_merge($params, $_params); unset($params['Request']); if( is_array($params['ResponseGroup']) ){ $params['ResponseGroup'] = implode(",", $params['ResponseGroup']); } $sign_params = array(); if( $params['Operation'] == 'ItemLookup' ){ $sign_params['Operation'] = $params['Operation']; $sign_params['ItemId'] = $params['ItemId']; $sign_params['ResponseGroup'] = $params['ResponseGroup']; } if( $params['Operation'] == 'SimilarityLookup' ){ $sign_params['Operation'] = $params['Operation']; $sign_params['ItemId'] = $params['ItemId']; $sign_params['Condition'] = $params['Condition']; $sign_params['MerchantId'] = $params['MerchantId']; $sign_params['ResponseGroup'] = $params['ResponseGroup']; } if( $params['Operation'] == 'ItemSearch' ){ $sign_params['Operation'] = $params['Operation']; $sign_params['Keywords'] = $params['Keywords']; $sign_params['SearchIndex'] = $params['SearchIndex']; $sign_params['ItemPage'] = $params['ItemPage']; $sign_params['MinPercentageOff'] = $params['MinPercentageOff']; $sign_params['ResponseGroup'] = $params['ResponseGroup']; if( $sign_params['SearchIndex'] != "All" ){ $sign_params['BrowseNode'] = $params['BrowseNode']; } } // http://docs.aws.amazon.com/AWSECommerceService/latest/DG/CartCreate.html if( $params['Operation'] == 'CartCreate' ){ $sign_params['Operation'] = $params['Operation']; /** * Item.1.ASIN=[ASIN]& * Item.1.Quantity=2& */ if( count($params['Items']) > 0 ){ $c = 1; foreach ($params['Items'] as $key => $value){ $sign_params['Item.' . $c . '.ASIN'] = $value['ASIN']; $sign_params['Item.' . $c . '.Quantity'] = $value['Quantity']; $c++; } } } // http://docs.aws.amazon.com/AWSECommerceService/latest/DG/CartModify.html if( $params['Operation'] == 'CartModify' ){ $sign_params['Operation'] = $params['Operation']; $sign_params['CartId'] = $params['CartId']; $sign_params['HMAC'] = $params['HMAC']; /** * Item.1.ASIN=[ASIN]& * Item.1.Quantity=2& */ if( count($params['Items']) > 0 ){ $c = 1; foreach ($params['Items'] as $key => $value){ $sign_params['Item.' . $c . '.CartItemId'] = $value['CartItemId']; $sign_params['Item.' . $c . '.Quantity'] = $value['Quantity']; $c++; } } } // http://docs.aws.amazon.com/AWSECommerceService/latest/DG/CartAdd.html if( $params['Operation'] == 'CartAdd' ){ $sign_params['Operation'] = $params['Operation']; $sign_params['CartId'] = $params['CartId']; $sign_params['HMAC'] = $params['HMAC']; /** * Item.1.ASIN=[ASIN]& * Item.1.Quantity=2& */ if( count($params['Items']) > 0 ){ $c = 1; foreach ($params['Items'] as $key => $value){ $sign_params['Item.' . $c . '.ASIN'] = $value['ASIN']; $sign_params['Item.' . $c . '.Quantity'] = $value['Quantity']; $c++; } } } // http://docs.aws.amazon.com/AWSECommerceService/latest/DG/CartGet.html if( $params['Operation'] == 'CartGet' ){ $sign_params['Operation'] = $params['Operation']; $sign_params['CartId'] = $params['CartId']; $sign_params['HMAC'] = $params['HMAC']; } $amzLink = $this->aws_signed_request( $this->responseConfig['country'], $sign_params, $this->requestConfig['accessKey'], $this->requestConfig['secretKey'], $this->requestConfig['associateTag'] ); //var_dump('<pre>', $amzLink,str_replace("&", "\n", $amzLink),'</pre>'); //echo __FILE__ . ":" . __LINE__;die . PHP_EOL; $ret = wp_remote_request( $amzLink ); //var_dump('<pre>',$amzLink,'</pre>'); die; return json_decode(json_encode((array)simplexml_load_string($ret['body'])),1); } function aws_signed_request($region, $params, $public_key, $private_key, $associate_tag=NULL, $version='2011-08-01') { // some paramters $method = 'GET'; $host = 'webservices.amazon.'.$region; $uri = '/onca/xml'; // additional parameters $params['Service'] = 'AWSECommerceService'; $params['AWSAccessKeyId'] = $public_key; // GMT timestamp $params['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z'); // API version $params['Version'] = $version; if ($associate_tag !== NULL) { $params['AssociateTag'] = $associate_tag; } // sort the parameters ksort($params); // create the canonicalized query $canonicalized_query = array(); foreach ($params as $param=>$value) { $param = str_replace('%7E', '~', rawurlencode($param)); $value = str_replace('%7E', '~', rawurlencode($value)); $canonicalized_query[] = $param.'='.$value; } $canonicalized_query = implode('&', $canonicalized_query); // create the string to sign $string_to_sign = $method."\n".$host."\n".$uri."\n".$canonicalized_query; // calculate HMAC with SHA256 and base64-encoding $signature = base64_encode(hash_hmac('sha256', $string_to_sign, $private_key, TRUE)); // encode the signature for the request $signature = str_replace('%7E', '~', rawurlencode($signature)); // create request $request = 'http://'.$host.$uri.'?'.$canonicalized_query.'&Signature='.$signature; return $request; } /** * @param string $function Name of the function which should be called * @param array $params Requestparameters 'ParameterName' => 'ParameterValue' * * @return array The response as an array with stdClass objects */ protected function performSoapRequest($function, $params) { $soapClient = new SoapClient( $this->webserviceWsdl, array('exceptions' => 1) ); $soapClient->__setLocation(str_replace( '%%COUNTRY%%', $this->responseConfig['country'], $this->webserviceEndpoint )); $soapClient->__setSoapHeaders($this->buildSoapHeader($function)); //var_dump('<pre>',$soapClient->__soapCall($function, array($params)),'</pre>'); die; return $soapClient->__soapCall($function, array($params)); } /** * Provides some necessary soap headers * * @param string $function * * @return array Each element is a concrete SoapHeader object */ protected function buildSoapHeader($function) { $timeStamp = $this->getTimestamp(); $signature = $this->buildSignature($function . $timeStamp); return array( new SoapHeader( 'http://security.amazonaws.com/doc/2007-01-01/', 'AWSAccessKeyId', $this->requestConfig['accessKey'] ), new SoapHeader( 'http://security.amazonaws.com/doc/2007-01-01/', 'Timestamp', $timeStamp ), new SoapHeader( 'http://security.amazonaws.com/doc/2007-01-01/', 'Signature', $signature ) ); } protected function performTheRequest($function, $params) { if( $this->protocol == 'XML' ) { //echo 'xml'; return $this->returnData( $this->performXMLRequest($function, $params) ); } if( $this->protocol == 'SOAP' ) { //echo 'soap'; return $this->returnData( $this->performSoapRequest($function, $params) ); } } /** * provides current gm date * * primary needed for the signature * * @return string */ final protected function getTimestamp() { return gmdate("Y-m-d\TH:i:s\Z"); } /** * provides the signature * * @return string */ final protected function buildSignature($request) { return base64_encode(hash_hmac("sha256", $request, $this->requestConfig['secretKey'], true)); } /** * Basic validation of the nodeId * * @param integer $nodeId * * @return boolean */ final protected function validateNodeId($nodeId) { //if (false === is_numeric($nodeId) || $nodeId <= 0) if (false === is_numeric($nodeId)) { throw new InvalidArgumentException(sprintf('Node has to be a positive Integer.')); } return true; } /** * Returns the response either as Array or Array/Object * * @param object $object * * @return mixed */ protected function returnData($object) { switch ($this->responseConfig['returnType']) { case self::RETURN_TYPE_OBJECT: return $object; break; case self::RETURN_TYPE_ARRAY: return $this->objectToArray($object); break; default: throw new InvalidArgumentException(sprintf( "Unknwon return type %s", $this->responseConfig['returnType'] )); break; } } /** * Transforms the responseobject to an array * * @param object $object * * @return array An arrayrepresentation of the given object */ protected function objectToArray($object) { $out = array(); foreach ($object as $key => $value) { switch (true) { case is_object($value): $out[$key] = $this->objectToArray($value); break; case is_array($value): $out[$key] = $this->objectToArray($value); break; default: $out[$key] = $value; break; } } return $out; } /** * set or get optional parameters * * if the argument params is null it will reutrn the current parameters, * otherwise it will set the params and return itself. * * @param array $params the optional parameters * * @return array|aaAmazonWS depends on params argument */ public function optionalParameters($params = null) { if (null === $params) { return $this->responseConfig['optionalParameters']; } if (false === is_array($params)) { throw new InvalidArgumentException(sprintf( "%s is no valid parameter: Use an array with Key => Value Pairs", $params )); } $this->responseConfig['optionalParameters'] = $params; return $this; } /** * Set or get the country * * if the country argument is null it will return the current * country, otherwise it will set the country and return itself. * * @param string|null $country * * @return string|aaAmazonWS depends on country argument */ public function country($country = null) { if (null === $country) { return $this->responseConfig['country']; } if (false === in_array(strtolower($country), $this->possibleLocations)) { throw new InvalidArgumentException(sprintf( "Invalid Country-Code: %s! Possible Country-Codes: %s", $country, implode(', ', $this->possibleLocations) )); } $this->responseConfig['country'] = strtolower($country); return $this; } /** * Setting/Getting the amazon category * * @param string $category * * @return string|aaAmazonWS depends on category argument */ public function category($category = null) { if (null === $category) { return isset($this->requestConfig['category']) ? $this->requestConfig['category'] : null; } $this->requestConfig['category'] = $category; return $this; } /** * Setting/Getting the responsegroup * * @param string $responseGroup Comma separated groups * * @return string|aaAmazonWS depends on responseGroup argument */ public function responseGroup($responseGroup = null) { if (null === $responseGroup) { return $this->responseConfig['responseGroup']; } $this->responseConfig['responseGroup'] = $responseGroup; return $this; } /** * Setting/Getting the returntype * It can be an object or an array * * @param integer $type Use the constants RETURN_TYPE_ARRAY or RETURN_TYPE_OBJECT * * @return integer|aaAmazonWS depends on type argument */ public function returnType($type = null) { if (null === $type) { return $this->responseConfig['returnType']; } $this->responseConfig['returnType'] = $type; return $this; } /** * Setter/Getter of the AssociateTag. * This could be used for late bindings of this attribute * * @param string $associateTag * * @return string|aaAmazonWS depends on associateTag argument */ public function associateTag($associateTag = null) { if (null === $associateTag) { return $this->requestConfig['associateTag']; } $this->requestConfig['associateTag'] = $associateTag; return $this; } /** * @deprecated use returnType() instead */ public function setReturnType($type) { return $this->returnType($type); } /** * Setting the resultpage to a specified value. * Allows to browse resultsets which have more than one page. * * @param integer $page * * @return aaAmazonWS */ public function page($page) { if (false === is_numeric($page) || $page <= 0) { throw new InvalidArgumentException(sprintf( '%s is an invalid page value. It has to be numeric and positive', $page )); } $this->responseConfig['optionalParameters'] = array_merge( $this->responseConfig['optionalParameters'], array("ItemPage" => $page) ); return $this; } } } // end class exists!
Abh430/roostash-wp
wp-content/plugins/woocommerce-amazon-affiliates-light-version/lib/scripts/amazon/aaAmazonWS.class.php
PHP
gpl-2.0
27,001
/* * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> * * 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://www.gnu.org/licenses/>. */ /* * An example of a spell script file * to bind a script to spell you have to add entry for it in `spell_script_names` * where `spell_id` is id of the spell to bind * and `ScriptName` is the name of a script assigned on registration */ #include "ScriptPCH.h" #include "SpellAuras.h" #include "SpellAuraEffects.h" enum Spells { SPELL_TRIGGERED = 18282 }; class spell_ex_5581 : public SpellScriptLoader { public: spell_ex_5581() : SpellScriptLoader("spell_ex_5581") { } class spell_ex_5581SpellScript : public SpellScript { // initialize script, this macro does compile time check for type of the function - prevents possible issues // if you have assigned wrong type of function to a hook you'll receive type conversion error during build // this line is required, otherwise you'll get XXXHandlerFunction - identifier not found errors PrepareSpellScript(spell_ex_5581SpellScript); std::string localVariable; char* localVariable2; // function called on server startup // checks if script has data required for it to work bool Validate(SpellInfo const* /*spellEntry*/) { // check if spellid 70522 exists in dbc, we will trigger it later if (!sSpellMgr->GetSpellInfo(SPELL_TRIGGERED)) return false; return true; } // function called just after script is added to spell // we initialize local variables if needed bool Load() { localVariable = "we're using local variable"; localVariable2 = new char(); return true; // return false - script will be immediately removed from the spell // for example - we don't want this script to be executed on a creature // if (GetCaster()->GetTypeID() != TYPEID_PLAYER) // return false; } // function called just before script delete // we free allocated memory void Unload() { delete localVariable2; } void HandleBeforeCast() { // this hook is executed before anything about casting the spell is done // after this hook is executed all the machinery starts sLog->outString("Caster just finished preparing the spell (cast bar has expired)"); } void HandleOnCast() { // cast is validated and spell targets are selected at this moment // this is a last place when the spell can be safely interrupted sLog->outString("Spell is about to do take reagents, power, launch missile, do visuals and instant spell effects"); } void HandleAfterCast() { sLog->outString("All immediate actions for the spell are finished now"); // this is a safe for triggering additional effects for a spell without interfering // with visuals or with other effects of the spell //GetCaster()->CastSpell(target, SPELL_TRIGGERED, true); } SpellCastResult CheckRequirement() { // in this hook you can add additional requirements for spell caster (and throw a client error if reqs're not passed) // in this case we're disallowing to select non-player as a target of the spell //if (!GetTargetUnit() || GetTargetUnit()->ToPlayer()) //return SPELL_FAILED_BAD_TARGETS; return SPELL_CAST_OK; } void HandleDummyLaunch(SpellEffIndex /*effIndex*/) { sLog->outString("Spell %u with SPELL_EFFECT_DUMMY is just launched!", GetSpellInfo()->Id); } void HandleDummyLaunchTarget(SpellEffIndex /*effIndex*/) { uint64 targetGUID = 0; if (Unit* unitTarget = GetHitUnit()) targetGUID = unitTarget->GetGUID(); // we're handling SPELL_EFFECT_DUMMY in effIndex 0 here sLog->outString("Spell %u with SPELL_EFFECT_DUMMY is just launched at it's target: " UI64FMTD "!", GetSpellInfo()->Id, targetGUID); } void HandleDummyHit(SpellEffIndex /*effIndex*/) { sLog->outString("Spell %u with SPELL_EFFECT_DUMMY has hit!", GetSpellInfo()->Id); } void HandleDummyHitTarget(SpellEffIndex /*effIndex*/) { sLog->outString("SPELL_EFFECT_DUMMY is hits it's target!"); // make caster cast a spell on a unit target of effect if (Unit* target = GetHitUnit()) GetCaster()->CastSpell(target, SPELL_TRIGGERED, true); } void HandleBeforeHit() { sLog->outString("Spell is about to hit target!"); } void HandleOnHit() { sLog->outString("Spell just hit target!"); } void HandleAfterHit() { sLog->outString("Spell just finished hitting target!"); } void FilterTargets(std::list<Unit*>& /*targetList*/) { // usually you want this call for Area Target spells sLog->outString("Spell is about to add targets from targetList to final targets!"); } // register functions used in spell script - names of these functions do not matter void Register() { // we're registering our functions here BeforeCast += SpellCastFn(spell_ex_5581SpellScript::HandleBeforeCast); OnCast += SpellCastFn(spell_ex_5581SpellScript::HandleOnCast); AfterCast += SpellCastFn(spell_ex_5581SpellScript::HandleAfterCast); OnCheckCast += SpellCheckCastFn(spell_ex_5581SpellScript::CheckRequirement); // function HandleDummy will be called when spell is launched, independant from targets selected for spell, just before default effect 0 launch handler OnEffectLaunch += SpellEffectFn(spell_ex_5581SpellScript::HandleDummyLaunch, EFFECT_0, SPELL_EFFECT_DUMMY); // function HandleDummy will be called when spell is launched at target, just before default effect 0 launch at target handler OnEffectLaunchTarget += SpellEffectFn(spell_ex_5581SpellScript::HandleDummyLaunchTarget, EFFECT_0, SPELL_EFFECT_DUMMY); // function HandleDummy will be called when spell hits it's destination, independant from targets selected for spell, just before default effect 0 hit handler OnEffectHit += SpellEffectFn(spell_ex_5581SpellScript::HandleDummyHit, EFFECT_0, SPELL_EFFECT_DUMMY); // function HandleDummy will be called when unit is hit by spell, just before default effect 0 hit target handler OnEffectHitTarget += SpellEffectFn(spell_ex_5581SpellScript::HandleDummyHitTarget, EFFECT_0, SPELL_EFFECT_DUMMY); // this will prompt an error on startup because effect 0 of spell 49375 is set to SPELL_EFFECT_DUMMY, not SPELL_EFFECT_APPLY_AURA //OnEffectHitTarget += SpellEffectFn(spell_gen_49375SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_APPLY_AURA); // this will make HandleDummy function to be called on first != 0 effect of spell 49375 //OnEffectHitTarget += SpellEffectFn(spell_gen_49375SpellScript::HandleDummy, EFFECT_FIRST_FOUND, SPELL_EFFECT_ANY); // this will make HandleDummy function to be called on all != 0 effect of spell 49375 //OnEffectHitTarget += SpellEffectFn(spell_gen_49375SpellScript::HandleDummy, EFFECT_ALL, SPELL_EFFECT_ANY); // bind handler to BeforeHit event of the spell BeforeHit += SpellHitFn(spell_ex_5581SpellScript::HandleBeforeHit); // bind handler to OnHit event of the spell OnHit += SpellHitFn(spell_ex_5581SpellScript::HandleOnHit); // bind handler to AfterHit event of the spell AfterHit += SpellHitFn(spell_ex_5581SpellScript::HandleAfterHit); // bind handler to OnUnitTargetSelect event of the spell //OnUnitTargetSelect += SpellUnitTargetFn(spell_ex_5581SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_CASTER); } }; // function which creates SpellScript SpellScript* GetSpellScript() const { return new spell_ex_5581SpellScript(); } }; class spell_ex_66244 : public SpellScriptLoader { public: spell_ex_66244() : SpellScriptLoader("spell_ex_66244") { } class spell_ex_66244AuraScript : public AuraScript { PrepareAuraScript(spell_ex_66244AuraScript); // function called on server startup // checks if script has data required for it to work bool Validate(SpellInfo const* /*spellEntry*/) { // check if spellid exists in dbc, we will trigger it later if (!sSpellMgr->GetSpellInfo(SPELL_TRIGGERED)) return false; return true; } // function called in aura constructor // we initialize local variables if needed bool Load() { // do not load script if aura is casted by player or caster not avalible if (Unit* caster = GetCaster()) if (caster->GetTypeId() == TYPEID_PLAYER) return true; return false; } void HandleOnEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { sLog->outString("Aura Effect is about to be applied on target!"); // this hook allows you to prevent execution of AuraEffect handler, or to replace it with your own handler //PreventDefaultAction(); } void HandleOnEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { sLog->outString("Aura Effect is about to be removed from target!"); // this hook allows you to prevent execution of AuraEffect handler, or to replace it with your own handler //PreventDefaultAction(); } void HandleAfterEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { sLog->outString("Aura Effect has just been applied on target!"); Unit* target = GetTarget(); // cast spell on target on aura apply target->CastSpell(target, SPELL_TRIGGERED, true); } void HandleAfterEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { sLog->outString("Aura Effect has just been just removed from target!"); Unit* target = GetTarget(); Unit* caster = GetCaster(); // caster may be not avalible (logged out for example) if (!caster) return; // cast spell on caster on aura remove target->CastSpell(caster, SPELL_TRIGGERED, true); } void HandleEffectPeriodic(AuraEffect const* /*aurEff*/) { sLog->outString("Perioidic Aura Effect is does a tick on target!"); Unit* target = GetTarget(); // aura targets damage self on tick target->DealDamage(target, 100); } void HandleEffectPeriodicUpdate(AuraEffect* aurEff) { sLog->outString("Perioidic Aura Effect is now updated!"); // we're doubling aura amount every tick aurEff->ChangeAmount(aurEff->GetAmount() * 2); } void HandleEffectCalcAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) { sLog->outString("Amount of Aura Effect is being calculated now!"); // we're setting amount to 100 amount = 100; // amount will be never recalculated due to applying passive aura canBeRecalculated = false; } void HandleEffectCalcPeriodic(AuraEffect const* /*aurEff*/, bool& isPeriodic, int32& amplitude) { sLog->outString("Periodic data of Aura Effect is being calculated now!"); // we're setting aura to be periodic and tick every 10 seconds isPeriodic = true; amplitude = 2 * IN_MILLISECONDS; } void HandleEffectCalcSpellMod(AuraEffect const* /*aurEff*/, SpellModifier*& spellMod) { sLog->outString("SpellMod data of Aura Effect is being calculated now!"); // we don't want spellmod for example if (spellMod) { delete spellMod; spellMod = NULL; } /* // alternative: we want spellmod for spell which doesn't have it if (!spellMod) { spellMod = new SpellModifier(GetAura()); spellMod->op = SPELLMOD_DOT; spellMod->type = SPELLMOD_PCT; spellMod->spellId = GetId(); spellMod->mask[1] = 0x00002000; } */ } // function registering void Register() { OnEffectApply += AuraEffectApplyFn(spell_ex_66244AuraScript::HandleOnEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); OnEffectRemove += AuraEffectRemoveFn(spell_ex_66244AuraScript::HandleOnEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); // AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK - makes handler to be called when aura is reapplied on target AfterEffectApply += AuraEffectApplyFn(spell_ex_66244AuraScript::HandleAfterEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); AfterEffectRemove += AuraEffectRemoveFn(spell_ex_66244AuraScript::HandleAfterEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); OnEffectPeriodic += AuraEffectPeriodicFn(spell_ex_66244AuraScript::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_DUMMY); OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_ex_66244AuraScript::HandleEffectPeriodicUpdate, EFFECT_0, SPELL_AURA_DUMMY); DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ex_66244AuraScript::HandleEffectCalcAmount, EFFECT_0, SPELL_AURA_DUMMY); DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_ex_66244AuraScript::HandleEffectCalcPeriodic, EFFECT_0, SPELL_AURA_DUMMY); DoEffectCalcSpellMod += AuraEffectCalcSpellModFn(spell_ex_66244AuraScript::HandleEffectCalcSpellMod, EFFECT_0, SPELL_AURA_DUMMY); /*OnApply += AuraEffectApplyFn(); OnRemove += AuraEffectRemoveFn(); DoCheckAreaTarget += AuraCheckAreaTargetFn();*/ } /* void OnApply() { } void OnRemove() { } bool DoCheckAreaTarget(Unit* proposedTarget) { }*/ }; // function which creates AuraScript AuraScript* GetAuraScript() const { return new spell_ex_66244AuraScript(); } }; // example usage of OnEffectManaShield and AfterEffectManaShield hooks // see spell_ex_absorb_aura, these hooks work the same as OnEffectAbsorb and AfterEffectAbsorb // example usage of OnEffectAbsorb and AfterEffectAbsorb hooks class spell_ex_absorb_aura : public SpellScriptLoader { public: spell_ex_absorb_aura() : SpellScriptLoader("spell_ex_absorb_aura") { } class spell_ex_absorb_auraAuraScript : public AuraScript { PrepareAuraScript(spell_ex_absorb_auraAuraScript); void HandleOnEffectAbsorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount) { sLog->outString("Our aura is now absorbing damage done to us!"); // absorb whole damage done to us absorbAmount = dmgInfo.GetDamage(); } void HandleAfterEffectAbsorb(AuraEffect* /*aurEff*/, DamageInfo & /*dmgInfo*/, uint32 & absorbAmount) { sLog->outString("Our aura has absorbed %u damage!", absorbAmount); } // function registering void Register() { OnEffectAbsorb += AuraEffectAbsorbFn(spell_ex_absorb_auraAuraScript::HandleOnEffectAbsorb, EFFECT_0); AfterEffectAbsorb += AuraEffectAbsorbFn(spell_ex_absorb_auraAuraScript::HandleAfterEffectAbsorb, EFFECT_0); } }; // function which creates AuraScript AuraScript* GetAuraScript() const { return new spell_ex_absorb_auraAuraScript(); } }; class spell_ex_463 : public SpellScriptLoader { public: spell_ex_463() : SpellScriptLoader("spell_ex_463") { } class spell_ex_463AuraScript : public AuraScript { PrepareAuraScript(spell_ex_463AuraScript); bool CheckAreaTarget(Unit* target) { sLog->outString("Area aura checks if unit is a valid target for it!"); // in our script we allow only players to be affected return target->GetTypeId() == TYPEID_PLAYER; } void Register() { DoCheckAreaTarget += AuraCheckAreaTargetFn(spell_ex_463AuraScript::CheckAreaTarget); } }; // function which creates AuraScript AuraScript* GetAuraScript() const { return new spell_ex_463AuraScript(); } }; // this function has to be added to function set in ScriptLoader.cpp void AddSC_example_spell_scripts() { new spell_ex_5581; new spell_ex_66244; new spell_ex_absorb_aura; new spell_ex_463; } /* empty script for copypasting class spell_ex : public SpellScriptLoader { public: spell_ex() : SpellScriptLoader("spell_ex") { } class spell_ex_SpellScript : public SpellScript { PrepareSpellScript(spell_ex_SpellScript); //bool Validate(SpellInfo const* spellEntry){return true;} //bool Load(){return true;} //void Unload(){} //void Function(SpellEffIndex effIndex) //OnEffect += SpellEffectFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_EFFECT_ANY); //void Function() //OnHit += SpellEffectFn(spell_ex_SpellScript::Function); void Register() { } }; SpellScript* GetSpellScript() const { return new spell_ex_SpellScript(); } }; */ /* empty script for copypasting class spell_ex : public SpellScriptLoader { public: spell_ex() : SpellScriptLoader("spell_ex") { } class spell_ex_AuraScript : public AuraScript { PrepareAuraScript(spell_ex) //bool Validate(SpellInfo const* spellEntry){return true;} //bool Load(){return true;} //void Unload(){} //void spell_ex_SpellScript::Function(AuraEffect const* aurEff, AuraEffectHandleModes mode) //OnEffectApply += AuraEffectApplyFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY, AURA_EFFECT_HANDLE_REAL); //void spell_ex_SpellScript::Function(AuraEffect const* aurEff, AuraEffectHandleModes mode) //OnEffectRemove += AuraEffectRemoveFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY, AURA_EFFECT_HANDLE_REAL); //void spell_ex_SpellScript::Function(AuraEffect const* aurEff) //OnEffectPeriodic += AuraEffectPeriodicFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY); //void spell_ex_SpellScript::Function(AuraEffect* aurEff) //OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY); //void spell_ex_SpellScript::Function(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated) //DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY); //void spell_ex_SpellScript::Function(AuraEffect const* aurEff, bool& isPeriodic, int32& amplitude) //OnEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY); //void spell_ex_SpellScript::Function(AuraEffect const* aurEff, SpellModifier*& spellMod) //OnEffectCalcSpellMod += AuraEffectCalcSpellModFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY); void Register() { } }; AuraScript* GetAuraScript() const { return new spell_ex_AuraScript(); } }; */
Jildor/ZoneLimit
src/server/scripts/Examples/example_spell.cpp
C++
gpl-2.0
22,311
/* * tiwlan_loader.c * * Copyright 2001-2010 Texas Instruments, Inc. - http://www.ti.com/ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * \file tiwlan_loader.c * \brief Loader implementation - sends FW image, NVS image and ini file to the driver */ #ifdef ANDROID #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <unistd.h> #include <string.h> #include <cutils/properties.h> #include <hardware_legacy/power.h> #define PROGRAM_NAME "wlan_loader" #endif #include "STADExternalIf.h" #include "cu_osapi.h" #include "ipc_sta.h" #include "WlanDrvCommon.h" #define TIWLAN_DRV_NAME "tiwlan" S8 g_drv_name[IF_NAME_SIZE + 1]; S32 print_usage(VOID) { os_error_printf (CU_MSG_INFO1, (PS8)"Usage: ./wlan_loader [driver_name] [options]\n"); os_error_printf (CU_MSG_INFO1, (PS8)" -e <filename> - eeprom image file name. default=./nvs_map.bin\n"); os_error_printf (CU_MSG_INFO1, (PS8)" -n - no eeprom file\n"); os_error_printf (CU_MSG_INFO1, (PS8)" -i <filename> - init file name. default=tiwlan.ini\n"); os_error_printf (CU_MSG_INFO1, (PS8)" -f <filename> - firmware image file name. default=firmware.bin\n"); return 1; } /* Return '0' if success */ S32 init_driver( PS8 adapter_name, PS8 eeprom_file_name, PS8 init_file_name, PS8 firmware_file_name ) { PVOID f1=NULL, f2=NULL, f3 = NULL; U32 eeprom_image_length=0; U32 init_file_length=0; U32 firmware_image_length = 0; U32 req_size=0; TLoaderFilesData *init_info = NULL; S32 rc = -1; THandle hIpcSta; if( !adapter_name || !*adapter_name ) return rc; os_error_printf(CU_MSG_INFO1, (PS8)"+---------------------------+\n"); os_error_printf(CU_MSG_INFO1, (PS8)"| wlan_loader: initializing |\n"); os_error_printf(CU_MSG_INFO1, (PS8)"+---------------------------+\n"); hIpcSta = IpcSta_Create(adapter_name); if (hIpcSta == NULL) { os_error_printf (CU_MSG_ERROR, (PS8)"wlan_loader: cant allocate IpcSta context\n", eeprom_file_name); goto init_driver_end; } /* Send init request to the driver */ if ( (NULL != eeprom_file_name) && (f1 = os_fopen (eeprom_file_name, OS_FOPEN_READ)) != NULL) { eeprom_image_length = os_getFileSize(f1); if (-1 == eeprom_image_length) { os_error_printf(CU_MSG_ERROR, (PS8)"Cannot get eeprom image file length <%s>\n", eeprom_file_name); goto init_driver_end; } } if ( (NULL != firmware_file_name) && (f2 = os_fopen (firmware_file_name, OS_FOPEN_READ)) != NULL) { firmware_image_length = os_getFileSize(f2); if (-1 == firmware_image_length) { os_error_printf(CU_MSG_ERROR, (PS8)"Cannot get firmware image file length <%s>\n", firmware_file_name); goto init_driver_end; } } if ( (NULL != init_file_name) && (f3 = os_fopen (init_file_name, OS_FOPEN_READ)) != NULL) { init_file_length = os_getFileSize(f3); if (-1 == init_file_length) { os_error_printf(CU_MSG_ERROR, (PS8)"Cannot get init file length <%s>\n", init_file_name); goto init_driver_end; } } /* Now when we can calculate the request length. allocate it and read the files */ req_size = sizeof(TLoaderFilesData) + eeprom_image_length + (init_file_length+1) + firmware_image_length; init_info = (TLoaderFilesData *)os_MemoryAlloc(req_size); if (!init_info) { os_error_printf(CU_MSG_ERROR, (PS8)"No memory to allocate init request (%d bytes)\n", req_size); goto init_driver_end; } init_info->uNvsFileLength = eeprom_image_length; init_info->uFwFileLength = firmware_image_length; init_info->uIniFileLength = init_file_length; if (!f1 || (eeprom_image_length && os_fread(&init_info->data[0], 1, eeprom_image_length, f1)<eeprom_image_length)) { }else os_error_printf(CU_MSG_INFO1, (PS8)"**** nvs file found %s **** \n", eeprom_file_name); if (!f2 || (firmware_image_length && os_fread(&init_info->data[eeprom_image_length], 1, firmware_image_length, f2)<firmware_image_length)) { os_error_printf(CU_MSG_ERROR, (PS8)"Error reading firmware image %s - Aborting...\n", firmware_file_name); goto init_driver_end; } if (!f3 || (init_file_length && os_fread(&init_info->data[eeprom_image_length+firmware_image_length], 1, init_file_length, f3)<init_file_length)) { os_error_printf(CU_MSG_ERROR, (PS8)"Warning: Error in reading init_file %s - Using defaults\n", init_file_name); } /* Load driver defaults */ if(EOALERR_IPC_STA_ERROR_SENDING_WEXT == IPC_STA_Private_Send(hIpcSta, DRIVER_INIT_PARAM, init_info, req_size, NULL, 0)) { os_error_printf(CU_MSG_ERROR, (PS8)"Wlan_loader: Error sending init command (DRIVER_INIT_PARAM) to driver\n"); goto init_driver_end; } /* No Error Found */ rc = 0; init_driver_end: if (f1) os_fclose(f1); if (f2) os_fclose(f2); if (f3) os_fclose(f3); if (init_info) os_MemoryFree(init_info); if (hIpcSta) IpcSta_Destroy(hIpcSta); return rc; } #ifdef ANDROID int check_and_set_property(char *prop_name, char * prop_val) { char prop_status [PROPERTY_VALUE_MAX]; int count; for(count=4; (count != 0); count--) { property_set (prop_name, prop_val); if ( property_get (prop_name, prop_status, NULL) && (strcmp( prop_status, prop_val) == 0) ) break; } if( count ) { os_error_printf (CU_MSG_ERROR, (PS8 )"Set property %s = %s - Ok\n" , prop_name, prop_val); } else { os_error_printf( CU_MSG_ERROR, (PS8)"Set property %s = %s - Fail\n", prop_name, prop_val); } return ( count ); } #endif S32 user_main(S32 argc, PPS8 argv) { S32 i; PS8 eeprom_file_name = (PS8)"./nvs_map.bin"; PS8 init_file_name = (PS8)"tiwlan.ini"; PS8 firmware_file_name = (PS8)"firmware.bin"; /* Parse command line parameters */ if( argc > 1 ) { i=1; if( argv[i][0] != '-' ) { os_strcpy( g_drv_name, argv[i++] ); } for( ;i < argc; i++ ) { if( !os_strcmp(argv[i], (PS8)"-h" ) || !os_strcmp(argv[i], (PS8)"--help") ) return print_usage(); else if(!os_strcmp(argv[i], (PS8)"-f" ) ) { firmware_file_name = argv[++i]; } else if(!os_strcmp(argv[i], (PS8)"-e") && (i+1<argc)) { eeprom_file_name = argv[++i]; } else if(!os_strcmp(argv[i], (PS8)"-i") && (i+1<argc)) { init_file_name = argv[++i]; } else if(!os_strcmp(argv[i], (PS8)"-n" ) ) { eeprom_file_name = NULL; } else { os_error_printf (CU_MSG_ERROR, (PS8)"Loader: unknow parameter '%s'\n", argv[i]); #ifdef ANDROID check_and_set_property("wlan.driver.status", "failed"); #endif return 0; } } } if( !g_drv_name[0] ) { os_strcpy(g_drv_name, (PS8)TIWLAN_DRV_NAME "0" ); } #ifdef ANDROID acquire_wake_lock(PARTIAL_WAKE_LOCK, PROGRAM_NAME); #endif if (init_driver (g_drv_name, eeprom_file_name, init_file_name, firmware_file_name) != 0) { #ifdef ANDROID check_and_set_property ("wlan.driver.status", "failed"); release_wake_lock(PROGRAM_NAME); #endif return -1; } #ifdef ANDROID check_and_set_property ("wlan.driver.status", "ok"); release_wake_lock(PROGRAM_NAME); #endif return 1; }
stevelord/PR30
linux-2.6.31/ti/WiLink62_AP/CUDK/tiwlan_loader/tiwlan_loader.c
C
gpl-2.0
8,347
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>N-ary Trees</title> <meta name="generator" content="DocBook XSL Stylesheets V1.69.1"> <link rel="start" href="index.html" title="GLib Reference Manual"> <link rel="up" href="glib-data-types.html" title="GLib Data Types"> <link rel="prev" href="glib-Balanced-Binary-Trees.html" title="Balanced Binary Trees"> <link rel="next" href="glib-Quarks.html" title="Quarks"> <meta name="generator" content="GTK-Doc V1.7 (XML mode)"> <link rel="stylesheet" href="style.css" type="text/css"> <link rel="chapter" href="glib.html" title="GLib Overview"> <link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals"> <link rel="chapter" href="glib-core.html" title="GLib Core Application Support"> <link rel="chapter" href="glib-utilities.html" title="GLib Utilities"> <link rel="chapter" href="glib-data-types.html" title="GLib Data Types"> <link rel="chapter" href="tools.html" title="GLib Tools"> <link rel="index" href="ix01.html" title="Index"> <link rel="index" href="ix02.html" title="Index of deprecated symbols"> <link rel="index" href="ix03.html" title="Index of new symbols in 2.2"> <link rel="index" href="ix04.html" title="Index of new symbols in 2.4"> <link rel="index" href="ix05.html" title="Index of new symbols in 2.6"> <link rel="index" href="ix06.html" title="Index of new symbols in 2.8"> <link rel="index" href="ix07.html" title="Index of new symbols in 2.10"> <link rel="index" href="ix08.html" title="Index of new symbols in 2.12"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"> <tr valign="middle"> <td><a accesskey="p" href="glib-Balanced-Binary-Trees.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td> <td><a accesskey="u" href="glib-data-types.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td> <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td> <th width="100%" align="center">GLib Reference Manual</th> <td><a accesskey="n" href="glib-Quarks.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td> </tr> <tr><td colspan="5" class="shortcuts"><nobr><a href="#id3199251" class="shortcut">Top</a> &#160;|&#160; <a href="#id3200294" class="shortcut">Description</a></nobr></td></tr> </table> <div class="refentry" lang="en"> <a name="glib-N-ary-Trees"></a><div class="titlepage"></div> <div class="refnamediv"><table width="100%"><tr> <td valign="top"> <h2> <a name="id3199251"></a><span class="refentrytitle">N-ary Trees</span> </h2> <p>N-ary Trees &#8212; trees of data with any number of branches.</p> </td> <td valign="top" align="right"></td> </tr></table></div> <div class="refsynopsisdiv"> <h2>Synopsis</h2> <pre class="synopsis"> #include &lt;glib.h&gt; <a href="glib-N-ary-Trees.html#GNode">GNode</a>; <a href="glib-N-ary-Trees.html#GNode">GNode</a>* <a href="glib-N-ary-Trees.html#g-node-new">g_node_new</a> (<a href="glib-Basic-Types.html#gpointer">gpointer</a> data); <a href="glib-N-ary-Trees.html#GNode">GNode</a>* <a href="glib-N-ary-Trees.html#g-node-copy">g_node_copy</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node); <a href="glib-Basic-Types.html#gpointer">gpointer</a> (<a href="glib-N-ary-Trees.html#GCopyFunc">*GCopyFunc</a>) (<a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> src, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data); <a href="glib-N-ary-Trees.html#GNode">GNode</a>* <a href="glib-N-ary-Trees.html#g-node-copy-deep">g_node_copy_deep</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-N-ary-Trees.html#GCopyFunc">GCopyFunc</a> copy_func, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data); <a href="glib-N-ary-Trees.html#GNode">GNode</a>* <a href="glib-N-ary-Trees.html#g-node-insert">g_node_insert</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *parent, <a href="glib-Basic-Types.html#gint">gint</a> position, <a href="glib-N-ary-Trees.html#GNode">GNode</a> *node); <a href="glib-N-ary-Trees.html#GNode">GNode</a>* <a href="glib-N-ary-Trees.html#g-node-insert-before">g_node_insert_before</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *parent, <a href="glib-N-ary-Trees.html#GNode">GNode</a> *sibling, <a href="glib-N-ary-Trees.html#GNode">GNode</a> *node); <a href="glib-N-ary-Trees.html#GNode">GNode</a>* <a href="glib-N-ary-Trees.html#g-node-insert-after">g_node_insert_after</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *parent, <a href="glib-N-ary-Trees.html#GNode">GNode</a> *sibling, <a href="glib-N-ary-Trees.html#GNode">GNode</a> *node); #define <a href="glib-N-ary-Trees.html#g-node-append">g_node_append</a> (parent, node) <a href="glib-N-ary-Trees.html#GNode">GNode</a>* <a href="glib-N-ary-Trees.html#g-node-prepend">g_node_prepend</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *parent, <a href="glib-N-ary-Trees.html#GNode">GNode</a> *node); #define <a href="glib-N-ary-Trees.html#g-node-insert-data">g_node_insert_data</a> (parent, position, data) #define <a href="glib-N-ary-Trees.html#g-node-insert-data-before">g_node_insert_data_before</a> (parent, sibling, data) #define <a href="glib-N-ary-Trees.html#g-node-append-data">g_node_append_data</a> (parent, data) #define <a href="glib-N-ary-Trees.html#g-node-prepend-data">g_node_prepend_data</a> (parent, data) void <a href="glib-N-ary-Trees.html#g-node-reverse-children">g_node_reverse_children</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node); void <a href="glib-N-ary-Trees.html#g-node-traverse">g_node_traverse</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *root, <a href="glib-Balanced-Binary-Trees.html#GTraverseType">GTraverseType</a> order, <a href="glib-N-ary-Trees.html#GTraverseFlags">GTraverseFlags</a> flags, <a href="glib-Basic-Types.html#gint">gint</a> max_depth, <a href="glib-N-ary-Trees.html#GNodeTraverseFunc">GNodeTraverseFunc</a> func, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data); enum <a href="glib-N-ary-Trees.html#GTraverseFlags">GTraverseFlags</a>; <a href="glib-Basic-Types.html#gboolean">gboolean</a> (<a href="glib-N-ary-Trees.html#GNodeTraverseFunc">*GNodeTraverseFunc</a>) (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data); void <a href="glib-N-ary-Trees.html#g-node-children-foreach">g_node_children_foreach</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-N-ary-Trees.html#GTraverseFlags">GTraverseFlags</a> flags, <a href="glib-N-ary-Trees.html#GNodeForeachFunc">GNodeForeachFunc</a> func, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data); void (<a href="glib-N-ary-Trees.html#GNodeForeachFunc">*GNodeForeachFunc</a>) (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data); <a href="glib-N-ary-Trees.html#GNode">GNode</a>* <a href="glib-N-ary-Trees.html#g-node-get-root">g_node_get_root</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node); <a href="glib-N-ary-Trees.html#GNode">GNode</a>* <a href="glib-N-ary-Trees.html#g-node-find">g_node_find</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *root, <a href="glib-Balanced-Binary-Trees.html#GTraverseType">GTraverseType</a> order, <a href="glib-N-ary-Trees.html#GTraverseFlags">GTraverseFlags</a> flags, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data); <a href="glib-N-ary-Trees.html#GNode">GNode</a>* <a href="glib-N-ary-Trees.html#g-node-find-child">g_node_find_child</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-N-ary-Trees.html#GTraverseFlags">GTraverseFlags</a> flags, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data); <a href="glib-Basic-Types.html#gint">gint</a> <a href="glib-N-ary-Trees.html#g-node-child-index">g_node_child_index</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data); <a href="glib-Basic-Types.html#gint">gint</a> <a href="glib-N-ary-Trees.html#g-node-child-position">g_node_child_position</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-N-ary-Trees.html#GNode">GNode</a> *child); #define <a href="glib-N-ary-Trees.html#g-node-first-child">g_node_first_child</a> (node) <a href="glib-N-ary-Trees.html#GNode">GNode</a>* <a href="glib-N-ary-Trees.html#g-node-last-child">g_node_last_child</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node); <a href="glib-N-ary-Trees.html#GNode">GNode</a>* <a href="glib-N-ary-Trees.html#g-node-nth-child">g_node_nth_child</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-Basic-Types.html#guint">guint</a> n); <a href="glib-N-ary-Trees.html#GNode">GNode</a>* <a href="glib-N-ary-Trees.html#g-node-first-sibling">g_node_first_sibling</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node); #define <a href="glib-N-ary-Trees.html#g-node-next-sibling">g_node_next_sibling</a> (node) #define <a href="glib-N-ary-Trees.html#g-node-prev-sibling">g_node_prev_sibling</a> (node) <a href="glib-N-ary-Trees.html#GNode">GNode</a>* <a href="glib-N-ary-Trees.html#g-node-last-sibling">g_node_last_sibling</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node); #define <a href="glib-N-ary-Trees.html#G-NODE-IS-LEAF:CAPS">G_NODE_IS_LEAF</a> (node) #define <a href="glib-N-ary-Trees.html#G-NODE-IS-ROOT:CAPS">G_NODE_IS_ROOT</a> (node) <a href="glib-Basic-Types.html#guint">guint</a> <a href="glib-N-ary-Trees.html#g-node-depth">g_node_depth</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node); <a href="glib-Basic-Types.html#guint">guint</a> <a href="glib-N-ary-Trees.html#g-node-n-nodes">g_node_n_nodes</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *root, <a href="glib-N-ary-Trees.html#GTraverseFlags">GTraverseFlags</a> flags); <a href="glib-Basic-Types.html#guint">guint</a> <a href="glib-N-ary-Trees.html#g-node-n-children">g_node_n_children</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node); <a href="glib-Basic-Types.html#gboolean">gboolean</a> <a href="glib-N-ary-Trees.html#g-node-is-ancestor">g_node_is_ancestor</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-N-ary-Trees.html#GNode">GNode</a> *descendant); <a href="glib-Basic-Types.html#guint">guint</a> <a href="glib-N-ary-Trees.html#g-node-max-height">g_node_max_height</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *root); void <a href="glib-N-ary-Trees.html#g-node-unlink">g_node_unlink</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node); void <a href="glib-N-ary-Trees.html#g-node-destroy">g_node_destroy</a> (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *root); void <a href="glib-N-ary-Trees.html#g-node-push-allocator">g_node_push_allocator</a> (<a href="glib-Basic-Types.html#gpointer">gpointer</a> dummy); void <a href="glib-N-ary-Trees.html#g-node-pop-allocator">g_node_pop_allocator</a> (void); </pre> </div> <div class="refsect1" lang="en"> <a name="id3200294"></a><h2>Description</h2> <p> The <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> struct and its associated functions provide a N-ary tree data structure, where nodes in the tree can contain arbitrary data. </p> <p> To create a new tree use <a href="glib-N-ary-Trees.html#g-node-new"><code class="function">g_node_new()</code></a>. </p> <p> To insert a node into a tree use <a href="glib-N-ary-Trees.html#g-node-insert"><code class="function">g_node_insert()</code></a>, <a href="glib-N-ary-Trees.html#g-node-insert-before"><code class="function">g_node_insert_before()</code></a>, <a href="glib-N-ary-Trees.html#g-node-append"><code class="function">g_node_append()</code></a> and <a href="glib-N-ary-Trees.html#g-node-prepend"><code class="function">g_node_prepend()</code></a>. </p> <p> To create a new node and insert it into a tree use <a href="glib-N-ary-Trees.html#g-node-insert-data"><code class="function">g_node_insert_data()</code></a>, <a href="glib-N-ary-Trees.html#g-node-insert-data-before"><code class="function">g_node_insert_data_before()</code></a>, <a href="glib-N-ary-Trees.html#g-node-append-data"><code class="function">g_node_append_data()</code></a> and <a href="glib-N-ary-Trees.html#g-node-prepend-data"><code class="function">g_node_prepend_data()</code></a>. </p> <p> To reverse the children of a node use <a href="glib-N-ary-Trees.html#g-node-reverse-children"><code class="function">g_node_reverse_children()</code></a>. </p> <p> To find a node use <a href="glib-N-ary-Trees.html#g-node-get-root"><code class="function">g_node_get_root()</code></a>, <a href="glib-N-ary-Trees.html#g-node-find"><code class="function">g_node_find()</code></a>, <a href="glib-N-ary-Trees.html#g-node-find-child"><code class="function">g_node_find_child()</code></a>, <a href="glib-N-ary-Trees.html#g-node-child-index"><code class="function">g_node_child_index()</code></a>, <a href="glib-N-ary-Trees.html#g-node-child-position"><code class="function">g_node_child_position()</code></a>, <a href="glib-N-ary-Trees.html#g-node-first-child"><code class="function">g_node_first_child()</code></a>, <a href="glib-N-ary-Trees.html#g-node-last-child"><code class="function">g_node_last_child()</code></a>, <a href="glib-N-ary-Trees.html#g-node-nth-child"><code class="function">g_node_nth_child()</code></a>, <a href="glib-N-ary-Trees.html#g-node-first-sibling"><code class="function">g_node_first_sibling()</code></a>, <a href="glib-N-ary-Trees.html#g-node-prev-sibling"><code class="function">g_node_prev_sibling()</code></a>, <a href="glib-N-ary-Trees.html#g-node-next-sibling"><code class="function">g_node_next_sibling()</code></a> or <a href="glib-N-ary-Trees.html#g-node-last-sibling"><code class="function">g_node_last_sibling()</code></a>. </p> <p> To get information about a node or tree use <a href="glib-N-ary-Trees.html#G-NODE-IS-LEAF:CAPS"><code class="function">G_NODE_IS_LEAF()</code></a>, <a href="glib-N-ary-Trees.html#G-NODE-IS-ROOT:CAPS"><code class="function">G_NODE_IS_ROOT()</code></a>, <a href="glib-N-ary-Trees.html#g-node-depth"><code class="function">g_node_depth()</code></a>, <a href="glib-N-ary-Trees.html#g-node-n-nodes"><code class="function">g_node_n_nodes()</code></a>, <a href="glib-N-ary-Trees.html#g-node-n-children"><code class="function">g_node_n_children()</code></a>, <a href="glib-N-ary-Trees.html#g-node-is-ancestor"><code class="function">g_node_is_ancestor()</code></a> or <a href="glib-N-ary-Trees.html#g-node-max-height"><code class="function">g_node_max_height()</code></a>. </p> <p> To traverse a tree, calling a function for each node visited in the traversal, use <a href="glib-N-ary-Trees.html#g-node-traverse"><code class="function">g_node_traverse()</code></a> or <a href="glib-N-ary-Trees.html#g-node-children-foreach"><code class="function">g_node_children_foreach()</code></a>. </p> <p> To remove a node or subtree from a tree use <a href="glib-N-ary-Trees.html#g-node-unlink"><code class="function">g_node_unlink()</code></a> or <a href="glib-N-ary-Trees.html#g-node-destroy"><code class="function">g_node_destroy()</code></a>. </p> </div> <div class="refsect1" lang="en"> <a name="id3200699"></a><h2>Details</h2> <div class="refsect2" lang="en"> <a name="id3200710"></a><h3> <a name="GNode"></a>GNode</h3> <a class="indexterm" name="id3200722"></a><pre class="programlisting">typedef struct { gpointer data; GNode *next; GNode *prev; GNode *parent; GNode *children; } GNode; </pre> <p> The <span class="structname">GNode</span> struct represents one node in a <a href="glib-N-ary-Trees.html" title="N-ary Trees">N-ary Tree</a>. The <em class="structfield"><code>data</code></em> field contains the actual data of the node. The <em class="structfield"><code>next</code></em> and <em class="structfield"><code>prev</code></em> fields point to the node's siblings (a sibling is another <span class="structname">GNode</span> with the same parent). The <em class="structfield"><code>parent</code></em> field points to the parent of the <span class="structname">GNode</span>, or is <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the <span class="structname">GNode</span> is the root of the tree. The <em class="structfield"><code>children</code></em> field points to the first child of the <span class="structname">GNode</span>. The other children are accessed by using the <em class="structfield"><code>next</code></em> pointer of each child. </p> </div> <hr> <div class="refsect2" lang="en"> <a name="id3200802"></a><h3> <a name="g-node-new"></a>g_node_new ()</h3> <a class="indexterm" name="id3200814"></a><pre class="programlisting"><a href="glib-N-ary-Trees.html#GNode">GNode</a>* g_node_new (<a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre> <p> Creates a new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> containing the given data. Used to create the first node in a tree. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></td> <td>the data of the new node. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>a new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3200888"></a><h3> <a name="g-node-copy"></a>g_node_copy ()</h3> <a class="indexterm" name="id3200901"></a><pre class="programlisting"><a href="glib-N-ary-Trees.html#GNode">GNode</a>* g_node_copy (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node);</pre> <p> Recursively copies a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> (but does not deep-copy the data inside the nodes, see <a href="glib-N-ary-Trees.html#g-node-copy-deep"><code class="function">g_node_copy_deep()</code></a> if you need that). </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>a new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> containing the same data pointers. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3200993"></a><h3> <a name="GCopyFunc"></a>GCopyFunc ()</h3> <a class="indexterm" name="id3201008"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gpointer">gpointer</a> (*GCopyFunc) (<a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> src, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre> <p> A function of this signature is used to copy the node data when doing a deep-copy of a tree. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>src</code></em>&#160;:</span></td> <td>A pointer to the data which should be copied. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></td> <td>Additional data. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>A pointer to the copy. </td> </tr> </tbody> </table></div> <p class="since">Since 2.4 </p> </div> <hr> <div class="refsect2" lang="en"> <a name="id3201096"></a><h3> <a name="g-node-copy-deep"></a>g_node_copy_deep ()</h3> <a class="indexterm" name="id3201110"></a><pre class="programlisting"><a href="glib-N-ary-Trees.html#GNode">GNode</a>* g_node_copy_deep (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-N-ary-Trees.html#GCopyFunc">GCopyFunc</a> copy_func, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre> <p> Recursively copies a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> and its data.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td> a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>copy_func</code></em>&#160;:</span></td> <td> the function which is called to copy the data inside each node, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to use the original data. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></td> <td> data to pass to <em class="parameter"><code>copy_func</code></em> </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td> a new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> containing copies of the data in <em class="parameter"><code>node</code></em>. </td> </tr> </tbody> </table></div> <p class="since">Since 2.4 </p> </div> <hr> <div class="refsect2" lang="en"> <a name="id3201267"></a><h3> <a name="g-node-insert"></a>g_node_insert ()</h3> <a class="indexterm" name="id3201280"></a><pre class="programlisting"><a href="glib-N-ary-Trees.html#GNode">GNode</a>* g_node_insert (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *parent, <a href="glib-Basic-Types.html#gint">gint</a> position, <a href="glib-N-ary-Trees.html#GNode">GNode</a> *node);</pre> <p> Inserts a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> beneath the parent at the given position. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>parent</code></em>&#160;:</span></td> <td>the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to place <em class="parameter"><code>node</code></em> under. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>position</code></em>&#160;:</span></td> <td>the position to place <em class="parameter"><code>node</code></em> at, with respect to its siblings. If position is -1, <em class="parameter"><code>node</code></em> is inserted as the last child of <em class="parameter"><code>parent</code></em>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to insert. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the inserted <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3201438"></a><h3> <a name="g-node-insert-before"></a>g_node_insert_before ()</h3> <a class="indexterm" name="id3201451"></a><pre class="programlisting"><a href="glib-N-ary-Trees.html#GNode">GNode</a>* g_node_insert_before (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *parent, <a href="glib-N-ary-Trees.html#GNode">GNode</a> *sibling, <a href="glib-N-ary-Trees.html#GNode">GNode</a> *node);</pre> <p> Inserts a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> beneath the parent before the given sibling. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>parent</code></em>&#160;:</span></td> <td>the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to place <em class="parameter"><code>node</code></em> under. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>sibling</code></em>&#160;:</span></td> <td>the sibling <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to place <em class="parameter"><code>node</code></em> before. If sibling is <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, the node is inserted as the last child of <em class="parameter"><code>parent</code></em>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to insert. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the inserted <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3201621"></a><h3> <a name="g-node-insert-after"></a>g_node_insert_after ()</h3> <a class="indexterm" name="id3201635"></a><pre class="programlisting"><a href="glib-N-ary-Trees.html#GNode">GNode</a>* g_node_insert_after (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *parent, <a href="glib-N-ary-Trees.html#GNode">GNode</a> *sibling, <a href="glib-N-ary-Trees.html#GNode">GNode</a> *node);</pre> <p> Inserts a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> beneath the parent after the given sibling. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>parent</code></em>&#160;:</span></td> <td>the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to place <em class="parameter"><code>node</code></em> under. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>sibling</code></em>&#160;:</span></td> <td>the sibling <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to place <em class="parameter"><code>node</code></em> after. If sibling is <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, the node is inserted as the first child of <em class="parameter"><code>parent</code></em>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to insert. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the inserted <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3201804"></a><h3> <a name="g-node-append"></a>g_node_append()</h3> <a class="indexterm" name="id3201817"></a><pre class="programlisting">#define g_node_append(parent, node)</pre> <p> Inserts a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> as the last child of the given parent. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>parent</code></em>&#160;:</span></td> <td>the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to place the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> under. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to insert. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the inserted <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3201916"></a><h3> <a name="g-node-prepend"></a>g_node_prepend ()</h3> <a class="indexterm" name="id3201928"></a><pre class="programlisting"><a href="glib-N-ary-Trees.html#GNode">GNode</a>* g_node_prepend (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *parent, <a href="glib-N-ary-Trees.html#GNode">GNode</a> *node);</pre> <p> Inserts a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> as the first child of the given parent. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>parent</code></em>&#160;:</span></td> <td>the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to place the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> under. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to insert. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the inserted <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3202048"></a><h3> <a name="g-node-insert-data"></a>g_node_insert_data()</h3> <a class="indexterm" name="id3202061"></a><pre class="programlisting">#define g_node_insert_data(parent, position, data)</pre> <p> Inserts a new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> at the given position. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>parent</code></em>&#160;:</span></td> <td>the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to place the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> under. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>position</code></em>&#160;:</span></td> <td>the position to place the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> at. If position is -1, the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> is inserted as the last child of <em class="parameter"><code>parent</code></em>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></td> <td>the data for the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3202196"></a><h3> <a name="g-node-insert-data-before"></a>g_node_insert_data_before()</h3> <a class="indexterm" name="id3202209"></a><pre class="programlisting">#define g_node_insert_data_before(parent, sibling, data)</pre> <p> Inserts a new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> before the given sibling. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>parent</code></em>&#160;:</span></td> <td>the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to place the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> under. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>sibling</code></em>&#160;:</span></td> <td>the sibling <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to place the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> before. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></td> <td>the data for the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3202338"></a><h3> <a name="g-node-append-data"></a>g_node_append_data()</h3> <a class="indexterm" name="id3202351"></a><pre class="programlisting">#define g_node_append_data(parent, data)</pre> <p> Inserts a new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> as the last child of the given parent. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>parent</code></em>&#160;:</span></td> <td>the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to place the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> under. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></td> <td>the data for the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3202449"></a><h3> <a name="g-node-prepend-data"></a>g_node_prepend_data()</h3> <a class="indexterm" name="id3202462"></a><pre class="programlisting">#define g_node_prepend_data(parent, data)</pre> <p> Inserts a new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> as the first child of the given parent. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>parent</code></em>&#160;:</span></td> <td>the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to place the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> under. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></td> <td>the data for the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the new <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3202561"></a><h3> <a name="g-node-reverse-children"></a>g_node_reverse_children ()</h3> <a class="indexterm" name="id3202574"></a><pre class="programlisting">void g_node_reverse_children (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node);</pre> <p> Reverses the order of the children of a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. (It doesn't change the order of the grandchildren.) </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody><tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr></tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3202638"></a><h3> <a name="g-node-traverse"></a>g_node_traverse ()</h3> <a class="indexterm" name="id3202650"></a><pre class="programlisting">void g_node_traverse (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *root, <a href="glib-Balanced-Binary-Trees.html#GTraverseType">GTraverseType</a> order, <a href="glib-N-ary-Trees.html#GTraverseFlags">GTraverseFlags</a> flags, <a href="glib-Basic-Types.html#gint">gint</a> max_depth, <a href="glib-N-ary-Trees.html#GNodeTraverseFunc">GNodeTraverseFunc</a> func, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre> <p> Traverses a tree starting at the given root <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. It calls the given function for each node visited. The traversal can be halted at any point by returning <a href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> from <em class="parameter"><code>func</code></em>. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>root</code></em>&#160;:</span></td> <td>the root <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> of the tree to traverse. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>order</code></em>&#160;:</span></td> <td>the order in which nodes are visited - <a href="glib-Balanced-Binary-Trees.html#G-IN-ORDER:CAPS"><code class="literal">G_IN_ORDER</code></a>, <a href="glib-Balanced-Binary-Trees.html#G-PRE-ORDER:CAPS"><code class="literal">G_PRE_ORDER</code></a>, <a href="glib-Balanced-Binary-Trees.html#G-POST-ORDER:CAPS"><code class="literal">G_POST_ORDER</code></a>, or <a href="glib-Balanced-Binary-Trees.html#G-LEVEL-ORDER:CAPS"><code class="literal">G_LEVEL_ORDER</code></a>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>flags</code></em>&#160;:</span></td> <td>which types of children are to be visited, one of <a href="glib-N-ary-Trees.html#G-TRAVERSE-ALL:CAPS"><code class="literal">G_TRAVERSE_ALL</code></a>, <a href="glib-N-ary-Trees.html#G-TRAVERSE-LEAVES:CAPS"><code class="literal">G_TRAVERSE_LEAVES</code></a> and <a href="glib-N-ary-Trees.html#G-TRAVERSE-NON-LEAVES:CAPS"><code class="literal">G_TRAVERSE_NON_LEAVES</code></a>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>max_depth</code></em>&#160;:</span></td> <td>the maximum depth of the traversal. Nodes below this depth will not be visited. If max_depth is -1 all nodes in the tree are visited. If depth is 1, only the root is visited. If depth is 2, the root and its children are visited. And so on. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>func</code></em>&#160;:</span></td> <td>the function to call for each visited <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></td> <td>user data to pass to the function. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3202931"></a><h3> <a name="GTraverseFlags"></a>enum GTraverseFlags</h3> <a class="indexterm" name="id3202944"></a><pre class="programlisting">typedef enum { G_TRAVERSE_LEAVES = 1 &lt;&lt; 0, G_TRAVERSE_NON_LEAVES = 1 &lt;&lt; 1, G_TRAVERSE_ALL = G_TRAVERSE_LEAVES | G_TRAVERSE_NON_LEAVES, G_TRAVERSE_MASK = 0x03, G_TRAVERSE_LEAFS = G_TRAVERSE_LEAVES, G_TRAVERSE_NON_LEAFS = G_TRAVERSE_NON_LEAVES } GTraverseFlags; </pre> <p> Specifies which nodes are visited during several of the tree functions, including <a href="glib-N-ary-Trees.html#g-node-traverse"><code class="function">g_node_traverse()</code></a> and <a href="glib-N-ary-Trees.html#g-node-find"><code class="function">g_node_find()</code></a>. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><a name="G-TRAVERSE-LEAVES:CAPS"></a><code class="literal">G_TRAVERSE_LEAVES</code></span></td> <td>only leaf nodes should be visited. This name has been introduced in 2.6, for older version use <a href="glib-N-ary-Trees.html#G-TRAVERSE-LEAFS:CAPS"><code class="literal">G_TRAVERSE_LEAFS</code></a>. </td> </tr> <tr> <td><span class="term"><a name="G-TRAVERSE-NON-LEAVES:CAPS"></a><code class="literal">G_TRAVERSE_NON_LEAVES</code></span></td> <td>only non-leaf nodes should be visited. This name has been introduced in 2.6, for older version use <a href="glib-N-ary-Trees.html#G-TRAVERSE-NON-LEAFS:CAPS"><code class="literal">G_TRAVERSE_NON_LEAFS</code></a>. </td> </tr> <tr> <td><span class="term"><a name="G-TRAVERSE-ALL:CAPS"></a><code class="literal">G_TRAVERSE_ALL</code></span></td> <td>all nodes should be visited. </td> </tr> <tr> <td><span class="term"><a name="G-TRAVERSE-MASK:CAPS"></a><code class="literal">G_TRAVERSE_MASK</code></span></td> <td> </td> </tr> <tr> <td><span class="term"><a name="G-TRAVERSE-LEAFS:CAPS"></a><code class="literal">G_TRAVERSE_LEAFS</code></span></td> <td>identical to <a href="glib-N-ary-Trees.html#G-TRAVERSE-LEAVES:CAPS"><code class="literal">G_TRAVERSE_LEAVES</code></a> </td> </tr> <tr> <td><span class="term"><a name="G-TRAVERSE-NON-LEAFS:CAPS"></a><code class="literal">G_TRAVERSE_NON_LEAFS</code></span></td> <td>identical to <a href="glib-N-ary-Trees.html#G-TRAVERSE-NON-LEAVES:CAPS"><code class="literal">G_TRAVERSE_NON_LEAVES</code></a> </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3203173"></a><h3> <a name="GNodeTraverseFunc"></a>GNodeTraverseFunc ()</h3> <a class="indexterm" name="id3203187"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a> (*GNodeTraverseFunc) (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre> <p> Specifies the type of function passed to <a href="glib-N-ary-Trees.html#g-node-traverse"><code class="function">g_node_traverse()</code></a>. The function is called with each of the nodes visited, together with the user data passed to <a href="glib-N-ary-Trees.html#g-node-traverse"><code class="function">g_node_traverse()</code></a>. If the function returns <a href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, then the traversal is stopped. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></td> <td>user data passed to <a href="glib-N-ary-Trees.html#g-node-traverse"><code class="function">g_node_traverse()</code></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td> <a href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> to stop the traversal. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3203326"></a><h3> <a name="g-node-children-foreach"></a>g_node_children_foreach ()</h3> <a class="indexterm" name="id3203340"></a><pre class="programlisting">void g_node_children_foreach (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-N-ary-Trees.html#GTraverseFlags">GTraverseFlags</a> flags, <a href="glib-N-ary-Trees.html#GNodeForeachFunc">GNodeForeachFunc</a> func, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre> <p> Calls a function for each of the children of a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. Note that it doesn't descend beneath the child nodes. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>flags</code></em>&#160;:</span></td> <td>which types of children are to be visited, one of <a href="glib-N-ary-Trees.html#G-TRAVERSE-ALL:CAPS"><code class="literal">G_TRAVERSE_ALL</code></a>, <a href="glib-N-ary-Trees.html#G-TRAVERSE-LEAVES:CAPS"><code class="literal">G_TRAVERSE_LEAVES</code></a> and <a href="glib-N-ary-Trees.html#G-TRAVERSE-NON-LEAVES:CAPS"><code class="literal">G_TRAVERSE_NON_LEAVES</code></a>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>func</code></em>&#160;:</span></td> <td>the function to call for each visited node. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></td> <td>user data to pass to the function. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3203502"></a><h3> <a name="GNodeForeachFunc"></a>GNodeForeachFunc ()</h3> <a class="indexterm" name="id3203515"></a><pre class="programlisting">void (*GNodeForeachFunc) (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre> <p> Specifies the type of function passed to <a href="glib-N-ary-Trees.html#g-node-children-foreach"><code class="function">g_node_children_foreach()</code></a>. The function is called with each child node, together with the user data passed to <a href="glib-N-ary-Trees.html#g-node-children-foreach"><code class="function">g_node_children_foreach()</code></a>. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></td> <td>user data passed to <a href="glib-N-ary-Trees.html#g-node-children-foreach"><code class="function">g_node_children_foreach()</code></a>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3203626"></a><h3> <a name="g-node-get-root"></a>g_node_get_root ()</h3> <a class="indexterm" name="id3203638"></a><pre class="programlisting"><a href="glib-N-ary-Trees.html#GNode">GNode</a>* g_node_get_root (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node);</pre> <p> Gets the root of a tree. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the root of the tree. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3203703"></a><h3> <a name="g-node-find"></a>g_node_find ()</h3> <a class="indexterm" name="id3203715"></a><pre class="programlisting"><a href="glib-N-ary-Trees.html#GNode">GNode</a>* g_node_find (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *root, <a href="glib-Balanced-Binary-Trees.html#GTraverseType">GTraverseType</a> order, <a href="glib-N-ary-Trees.html#GTraverseFlags">GTraverseFlags</a> flags, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre> <p> Finds a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> in a tree. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>root</code></em>&#160;:</span></td> <td>the root <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> of the tree to search. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>order</code></em>&#160;:</span></td> <td>the order in which nodes are visited - <a href="glib-Balanced-Binary-Trees.html#G-IN-ORDER:CAPS"><code class="literal">G_IN_ORDER</code></a>, <a href="glib-Balanced-Binary-Trees.html#G-PRE-ORDER:CAPS"><code class="literal">G_PRE_ORDER</code></a>, <a href="glib-Balanced-Binary-Trees.html#G-POST-ORDER:CAPS"><code class="literal">G_POST_ORDER</code></a>, or <a href="glib-Balanced-Binary-Trees.html#G-LEVEL-ORDER:CAPS"><code class="literal">G_LEVEL_ORDER</code></a>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>flags</code></em>&#160;:</span></td> <td>which types of children are to be searched, one of <a href="glib-N-ary-Trees.html#G-TRAVERSE-ALL:CAPS"><code class="literal">G_TRAVERSE_ALL</code></a>, <a href="glib-N-ary-Trees.html#G-TRAVERSE-LEAVES:CAPS"><code class="literal">G_TRAVERSE_LEAVES</code></a> and <a href="glib-N-ary-Trees.html#G-TRAVERSE-NON-LEAVES:CAPS"><code class="literal">G_TRAVERSE_NON_LEAVES</code></a>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></td> <td>the data to find. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the found <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the data is not found. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3203947"></a><h3> <a name="g-node-find-child"></a>g_node_find_child ()</h3> <a class="indexterm" name="id3203960"></a><pre class="programlisting"><a href="glib-N-ary-Trees.html#GNode">GNode</a>* g_node_find_child (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-N-ary-Trees.html#GTraverseFlags">GTraverseFlags</a> flags, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre> <p> Finds the first child of a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> with the given data. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>flags</code></em>&#160;:</span></td> <td>which types of children are to be searched, one of <a href="glib-N-ary-Trees.html#G-TRAVERSE-ALL:CAPS"><code class="literal">G_TRAVERSE_ALL</code></a>, <a href="glib-N-ary-Trees.html#G-TRAVERSE-LEAVES:CAPS"><code class="literal">G_TRAVERSE_LEAVES</code></a> and <a href="glib-N-ary-Trees.html#G-TRAVERSE-NON-LEAVES:CAPS"><code class="literal">G_TRAVERSE_NON_LEAVES</code></a>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></td> <td>the data to find. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the found child <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the data is not found. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3204128"></a><h3> <a name="g-node-child-index"></a>g_node_child_index ()</h3> <a class="indexterm" name="id3204142"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gint">gint</a> g_node_child_index (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre> <p> Gets the position of the first child of a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> which contains the given data. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></td> <td>the data to find. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the index of the child of <em class="parameter"><code>node</code></em> which contains <em class="parameter"><code>data</code></em>, or -1 if the data is not found. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3204249"></a><h3> <a name="g-node-child-position"></a>g_node_child_position ()</h3> <a class="indexterm" name="id3204262"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gint">gint</a> g_node_child_position (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-N-ary-Trees.html#GNode">GNode</a> *child);</pre> <p> Gets the position of a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> with respect to its siblings. <em class="parameter"><code>child</code></em> must be a child of <em class="parameter"><code>node</code></em>. The first child is numbered 0, the second 1, and so on. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>child</code></em>&#160;:</span></td> <td>a child of <em class="parameter"><code>node</code></em>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the position of <em class="parameter"><code>child</code></em> with respect to its siblings. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3204382"></a><h3> <a name="g-node-first-child"></a>g_node_first_child()</h3> <a class="indexterm" name="id3204396"></a><pre class="programlisting">#define g_node_first_child(node)</pre> <p> Gets the first child of a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the last child of <em class="parameter"><code>node</code></em>, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if <em class="parameter"><code>node</code></em> is <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> or has no children. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3204488"></a><h3> <a name="g-node-last-child"></a>g_node_last_child ()</h3> <a class="indexterm" name="id3204501"></a><pre class="programlisting"><a href="glib-N-ary-Trees.html#GNode">GNode</a>* g_node_last_child (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node);</pre> <p> Gets the last child of a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> (must not be <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>). </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the last child of <em class="parameter"><code>node</code></em>, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if <em class="parameter"><code>node</code></em> has no children. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3204606"></a><h3> <a name="g-node-nth-child"></a>g_node_nth_child ()</h3> <a class="indexterm" name="id3204619"></a><pre class="programlisting"><a href="glib-N-ary-Trees.html#GNode">GNode</a>* g_node_nth_child (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-Basic-Types.html#guint">guint</a> n);</pre> <p> Gets a child of a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>, using the given index. The first child is at index 0. If the index is too big, <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> is returned. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>n</code></em>&#160;:</span></td> <td>the index of the desired child. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the child of <em class="parameter"><code>node</code></em> at index <em class="parameter"><code>n</code></em>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3204736"></a><h3> <a name="g-node-first-sibling"></a>g_node_first_sibling ()</h3> <a class="indexterm" name="id3204749"></a><pre class="programlisting"><a href="glib-N-ary-Trees.html#GNode">GNode</a>* g_node_first_sibling (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node);</pre> <p> Gets the first sibling of a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. This could possibly be the node itself. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the first sibling of <em class="parameter"><code>node</code></em>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3204828"></a><h3> <a name="g-node-next-sibling"></a>g_node_next_sibling()</h3> <a class="indexterm" name="id3204842"></a><pre class="programlisting">#define g_node_next_sibling(node)</pre> <p> Gets the next sibling of a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the next sibling of <em class="parameter"><code>node</code></em>, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if <em class="parameter"><code>node</code></em> is <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3204934"></a><h3> <a name="g-node-prev-sibling"></a>g_node_prev_sibling()</h3> <a class="indexterm" name="id3204948"></a><pre class="programlisting">#define g_node_prev_sibling(node)</pre> <p> Gets the previous sibling of a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the previous sibling of <em class="parameter"><code>node</code></em>, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if <em class="parameter"><code>node</code></em> is <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3205040"></a><h3> <a name="g-node-last-sibling"></a>g_node_last_sibling ()</h3> <a class="indexterm" name="id3205053"></a><pre class="programlisting"><a href="glib-N-ary-Trees.html#GNode">GNode</a>* g_node_last_sibling (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node);</pre> <p> Gets the last sibling of a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. This could possibly be the node itself. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the last sibling of <em class="parameter"><code>node</code></em>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3205132"></a><h3> <a name="G-NODE-IS-LEAF:CAPS"></a>G_NODE_IS_LEAF()</h3> <a class="indexterm" name="id3205144"></a><pre class="programlisting">#define G_NODE_IS_LEAF(node) (((GNode*) (node))-&gt;children == NULL) </pre> <p> Returns <a href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> is a leaf node. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td> <a href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> is a leaf node (i.e. it has no children). </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3205233"></a><h3> <a name="G-NODE-IS-ROOT:CAPS"></a>G_NODE_IS_ROOT()</h3> <a class="indexterm" name="id3205246"></a><pre class="programlisting">#define G_NODE_IS_ROOT(node)</pre> <p> Returns <a href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> is the root of a tree. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td> <a href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> is the root of a tree (i.e. it has no parent or siblings). </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3205334"></a><h3> <a name="g-node-depth"></a>g_node_depth ()</h3> <a class="indexterm" name="id3205346"></a><pre class="programlisting"><a href="glib-Basic-Types.html#guint">guint</a> g_node_depth (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node);</pre> <p> Gets the depth of a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </p> <p> If <em class="parameter"><code>node</code></em> is <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> the depth is 0. The root node has a depth of 1. For the children of the root node the depth is 2. And so on. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the depth of the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3205448"></a><h3> <a name="g-node-n-nodes"></a>g_node_n_nodes ()</h3> <a class="indexterm" name="id3205460"></a><pre class="programlisting"><a href="glib-Basic-Types.html#guint">guint</a> g_node_n_nodes (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *root, <a href="glib-N-ary-Trees.html#GTraverseFlags">GTraverseFlags</a> flags);</pre> <p> Gets the number of nodes in a tree. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>root</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>flags</code></em>&#160;:</span></td> <td>which types of children are to be counted, one of <a href="glib-N-ary-Trees.html#G-TRAVERSE-ALL:CAPS"><code class="literal">G_TRAVERSE_ALL</code></a>, <a href="glib-N-ary-Trees.html#G-TRAVERSE-LEAVES:CAPS"><code class="literal">G_TRAVERSE_LEAVES</code></a> and <a href="glib-N-ary-Trees.html#G-TRAVERSE-NON-LEAVES:CAPS"><code class="literal">G_TRAVERSE_NON_LEAVES</code></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the number of nodes in the tree. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3205580"></a><h3> <a name="g-node-n-children"></a>g_node_n_children ()</h3> <a class="indexterm" name="id3205593"></a><pre class="programlisting"><a href="glib-Basic-Types.html#guint">guint</a> g_node_n_children (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node);</pre> <p> Gets the number of children of a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the number of children of <em class="parameter"><code>node</code></em>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3205671"></a><h3> <a name="g-node-is-ancestor"></a>g_node_is_ancestor ()</h3> <a class="indexterm" name="id3205685"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a> g_node_is_ancestor (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node, <a href="glib-N-ary-Trees.html#GNode">GNode</a> *descendant);</pre> <p> Returns <a href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if <em class="parameter"><code>node</code></em> is an ancestor of <em class="parameter"><code>descendant</code></em>. This is true if node is the parent of <em class="parameter"><code>descendant</code></em>, or if node is the grandparent of <em class="parameter"><code>descendant</code></em> etc. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>descendant</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td> <a href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if <em class="parameter"><code>node</code></em> is an ancestor of <em class="parameter"><code>descendant</code></em>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3205834"></a><h3> <a name="g-node-max-height"></a>g_node_max_height ()</h3> <a class="indexterm" name="id3205848"></a><pre class="programlisting"><a href="glib-Basic-Types.html#guint">guint</a> g_node_max_height (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *root);</pre> <p> Gets the maximum height of all branches beneath a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. This is the maximum distance from the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to all leaf nodes. </p> <p> If <em class="parameter"><code>root</code></em> is <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, 0 is returned. If <em class="parameter"><code>root</code></em> has no children, 1 is returned. If <em class="parameter"><code>root</code></em> has children, 2 is returned. And so on. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>root</code></em>&#160;:</span></td> <td>a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a>. </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td> <td>the maximum height of the tree beneath <em class="parameter"><code>root</code></em>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3205968"></a><h3> <a name="g-node-unlink"></a>g_node_unlink ()</h3> <a class="indexterm" name="id3205981"></a><pre class="programlisting">void g_node_unlink (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *node);</pre> <p> Unlinks a <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> from a tree, resulting in two separate trees. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody><tr> <td><span class="term"><em class="parameter"><code>node</code></em>&#160;:</span></td> <td>the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> to unlink, which becomes the root of a new tree. </td> </tr></tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3206045"></a><h3> <a name="g-node-destroy"></a>g_node_destroy ()</h3> <a class="indexterm" name="id3206058"></a><pre class="programlisting">void g_node_destroy (<a href="glib-N-ary-Trees.html#GNode">GNode</a> *root);</pre> <p> Removes the <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> and its children from the tree, freeing any memory allocated. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody><tr> <td><span class="term"><em class="parameter"><code>root</code></em>&#160;:</span></td> <td>the root of the tree/subtree to destroy. </td> </tr></tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3206114"></a><h3> <a name="g-node-push-allocator"></a>g_node_push_allocator ()</h3> <a class="indexterm" name="id3206129"></a><pre class="programlisting">void g_node_push_allocator (<a href="glib-Basic-Types.html#gpointer">gpointer</a> dummy);</pre> <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"> <h3 class="title">Warning</h3> <p><code class="literal">g_node_push_allocator</code> has been deprecated since version 2.10 and should not be used in newly-written code. It does nothing, since <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> has been converted to the <a href="glib-Memory-Slices.html" title="Memory Slices">slice allocator</a></p> </div> <p> Sets the allocator to use to allocate <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> elements. Use <a href="glib-N-ary-Trees.html#g-node-pop-allocator"><code class="function">g_node_pop_allocator()</code></a> to restore the previous allocator. </p> <p> Note that this function is not available if GLib has been compiled with <code class="option">--disable-mem-pools</code> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody><tr> <td><span class="term"><em class="parameter"><code>dummy</code></em>&#160;:</span></td> <td>the <a href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a> to use when allocating <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> elements. </td> </tr></tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id3206248"></a><h3> <a name="g-node-pop-allocator"></a>g_node_pop_allocator ()</h3> <a class="indexterm" name="id3206263"></a><pre class="programlisting">void g_node_pop_allocator (void);</pre> <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"> <h3 class="title">Warning</h3> <p><code class="literal">g_node_pop_allocator</code> has been deprecated since version 2.10 and should not be used in newly-written code. It does nothing, since <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> has been converted to the <a href="glib-Memory-Slices.html" title="Memory Slices">slice allocator</a></p> </div> <p> Restores the previous <a href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a>, used when allocating <a href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> elements. </p> <p> Note that this function is not available if GLib has been compiled with <code class="option">--disable-mem-pools</code> </p> </div> </div> </div> </body> </html>
gabrieldelsaint/uol-messenger
src/public/win32-dev/glib-dev-2.12.7/share/gtk-doc/html/glib/glib-N-ary-Trees.html
HTML
gpl-2.0
77,796
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % TTTTT H H RRRR EEEEE SSSSS H H OOO L DDDD % % T H H R R E SS H H O O L D D % % T HHHHH RRRR EEE SSS HHHHH O O L D D % % T H H R R E SS H H O O L D D % % T H H R R EEEEE SSSSS H H OOO LLLLL DDDD % % % % % % MagickCore Image Threshold Methods % % % % Software Design % % John Cristy % % October 1996 % % % % % % Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization % % dedicated to making software imaging solutions freely available. % % % % You may not use this file except in compliance with the License. You may % % obtain a copy of the License at % % % % http://www.imagemagick.org/script/license.php % % % % Unless required by applicable law or agreed to in writing, software % % distributed under the License is distributed on an "AS IS" BASIS, % % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % % See the License for the specific language governing permissions and % % limitations under the License. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % */ /* Include declarations. */ #include "magick/studio.h" #include "magick/property.h" #include "magick/blob.h" #include "magick/cache-view.h" #include "magick/color.h" #include "magick/color-private.h" #include "magick/colormap.h" #include "magick/colorspace.h" #include "magick/colorspace-private.h" #include "magick/configure.h" #include "magick/constitute.h" #include "magick/decorate.h" #include "magick/draw.h" #include "magick/enhance.h" #include "magick/exception.h" #include "magick/exception-private.h" #include "magick/effect.h" #include "magick/fx.h" #include "magick/gem.h" #include "magick/geometry.h" #include "magick/image-private.h" #include "magick/list.h" #include "magick/log.h" #include "magick/memory_.h" #include "magick/monitor.h" #include "magick/monitor-private.h" #include "magick/montage.h" #include "magick/option.h" #include "magick/pixel-private.h" #include "magick/quantize.h" #include "magick/quantum.h" #include "magick/random_.h" #include "magick/random-private.h" #include "magick/resize.h" #include "magick/resource_.h" #include "magick/segment.h" #include "magick/shear.h" #include "magick/signature-private.h" #include "magick/string_.h" #include "magick/string-private.h" #include "magick/thread-private.h" #include "magick/threshold.h" #include "magick/transform.h" #include "magick/xml-tree.h" /* Define declarations. */ #define ThresholdsFilename "thresholds.xml" /* Typedef declarations. */ struct _ThresholdMap { char *map_id, *description; size_t width, height; ssize_t divisor, *levels; }; /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % A d a p t i v e T h r e s h o l d I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % AdaptiveThresholdImage() selects an individual threshold for each pixel % based on the range of intensity values in its local neighborhood. This % allows for thresholding of an image whose global intensity histogram % doesn't contain distinctive peaks. % % The format of the AdaptiveThresholdImage method is: % % Image *AdaptiveThresholdImage(const Image *image, % const size_t width,const size_t height, % const ssize_t offset,ExceptionInfo *exception) % % A description of each parameter follows: % % o image: the image. % % o width: the width of the local neighborhood. % % o height: the height of the local neighborhood. % % o offset: the mean offset. % % o exception: return any errors or warnings in this structure. % */ MagickExport Image *AdaptiveThresholdImage(const Image *image, const size_t width,const size_t height,const ssize_t offset, ExceptionInfo *exception) { #define ThresholdImageTag "Threshold/Image" CacheView *image_view, *threshold_view; Image *threshold_image; MagickBooleanType status; MagickOffsetType progress; MagickPixelPacket zero; MagickRealType number_pixels; ssize_t y; assert(image != (const Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); threshold_image=CloneImage(image,0,0,MagickTrue,exception); if (threshold_image == (Image *) NULL) return((Image *) NULL); if (SetImageStorageClass(threshold_image,DirectClass) == MagickFalse) { InheritException(exception,&threshold_image->exception); threshold_image=DestroyImage(threshold_image); return((Image *) NULL); } /* Local adaptive threshold. */ status=MagickTrue; progress=0; GetMagickPixelPacket(image,&zero); number_pixels=(MagickRealType) width*height; image_view=AcquireVirtualCacheView(image,exception); threshold_view=AcquireAuthenticCacheView(threshold_image,exception); #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp parallel for schedule(static,4) shared(progress,status) \ dynamic_number_threads(image,image->columns,image->rows,1) #endif for (y=0; y < (ssize_t) image->rows; y++) { MagickBooleanType sync; register const IndexPacket *restrict indexes; register const PixelPacket *restrict p; register IndexPacket *restrict threshold_indexes; register ssize_t x; register PixelPacket *restrict q; if (status == MagickFalse) continue; p=GetCacheViewVirtualPixels(image_view,-((ssize_t) width/2L),y-(ssize_t) height/2L,image->columns+width,height,exception); q=GetCacheViewAuthenticPixels(threshold_view,0,y,threshold_image->columns,1, exception); if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL)) { status=MagickFalse; continue; } indexes=GetCacheViewVirtualIndexQueue(image_view); threshold_indexes=GetCacheViewAuthenticIndexQueue(threshold_view); for (x=0; x < (ssize_t) image->columns; x++) { MagickPixelPacket mean, pixel; register const PixelPacket *r; register ssize_t u; ssize_t v; pixel=zero; mean=zero; r=p; for (v=0; v < (ssize_t) height; v++) { for (u=0; u < (ssize_t) width; u++) { pixel.red+=r[u].red; pixel.green+=r[u].green; pixel.blue+=r[u].blue; pixel.opacity+=r[u].opacity; if (image->colorspace == CMYKColorspace) pixel.index=(MagickRealType) GetPixelIndex(indexes+x+(r-p)+u); } r+=image->columns+width; } mean.red=(MagickRealType) (pixel.red/number_pixels+offset); mean.green=(MagickRealType) (pixel.green/number_pixels+offset); mean.blue=(MagickRealType) (pixel.blue/number_pixels+offset); mean.opacity=(MagickRealType) (pixel.opacity/number_pixels+offset); if (image->colorspace == CMYKColorspace) mean.index=(MagickRealType) (pixel.index/number_pixels+offset); SetPixelRed(q,((MagickRealType) GetPixelRed(q) <= mean.red) ? 0 : QuantumRange); SetPixelGreen(q,((MagickRealType) GetPixelGreen(q) <= mean.green) ? 0 : QuantumRange); SetPixelBlue(q,((MagickRealType) GetPixelBlue(q) <= mean.blue) ? 0 : QuantumRange); SetPixelOpacity(q,((MagickRealType) GetPixelOpacity(q) <= mean.opacity) ? 0 : QuantumRange); if (image->colorspace == CMYKColorspace) SetPixelIndex(threshold_indexes+x,(((MagickRealType) GetPixelIndex(threshold_indexes+x) <= mean.index) ? 0 : QuantumRange)); p++; q++; } sync=SyncCacheViewAuthenticPixels(threshold_view,exception); if (sync == MagickFalse) status=MagickFalse; if (image->progress_monitor != (MagickProgressMonitor) NULL) { MagickBooleanType proceed; #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp critical (MagickCore_AdaptiveThresholdImage) #endif proceed=SetImageProgress(image,ThresholdImageTag,progress++, image->rows); if (proceed == MagickFalse) status=MagickFalse; } } threshold_view=DestroyCacheView(threshold_view); image_view=DestroyCacheView(image_view); if (status == MagickFalse) threshold_image=DestroyImage(threshold_image); return(threshold_image); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % B i l e v e l I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % BilevelImage() changes the value of individual pixels based on the % intensity of each pixel channel. The result is a high-contrast image. % % More precisely each channel value of the image is 'thresholded' so that if % it is equal to or less than the given value it is set to zero, while any % value greater than that give is set to it maximum or QuantumRange. % % This function is what is used to implement the "-threshold" operator for % the command line API. % % If the default channel setting is given the image is thresholded using just % the gray 'intensity' of the image, rather than the individual channels. % % The format of the BilevelImageChannel method is: % % MagickBooleanType BilevelImage(Image *image,const double threshold) % MagickBooleanType BilevelImageChannel(Image *image, % const ChannelType channel,const double threshold) % % A description of each parameter follows: % % o image: the image. % % o channel: the channel type. % % o threshold: define the threshold values. % % Aside: You can get the same results as operator using LevelImageChannels() % with the 'threshold' value for both the black_point and the white_point. % */ MagickExport MagickBooleanType BilevelImage(Image *image,const double threshold) { MagickBooleanType status; status=BilevelImageChannel(image,DefaultChannels,threshold); return(status); } MagickExport MagickBooleanType BilevelImageChannel(Image *image, const ChannelType channel,const double threshold) { #define ThresholdImageTag "Threshold/Image" CacheView *image_view; ExceptionInfo *exception; MagickBooleanType status; MagickOffsetType progress; ssize_t y; assert(image != (Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); if (SetImageStorageClass(image,DirectClass) == MagickFalse) return(MagickFalse); /* Bilevel threshold image. */ status=MagickTrue; progress=0; exception=(&image->exception); image_view=AcquireAuthenticCacheView(image,exception); #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp parallel for schedule(static,8) shared(progress,status) \ dynamic_number_threads(image,image->columns,image->rows,1) #endif for (y=0; y < (ssize_t) image->rows; y++) { register IndexPacket *restrict indexes; register ssize_t x; register PixelPacket *restrict q; if (status == MagickFalse) continue; q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) { status=MagickFalse; continue; } indexes=GetCacheViewAuthenticIndexQueue(image_view); if ((channel & SyncChannels) != 0) { for (x=0; x < (ssize_t) image->columns; x++) { SetPixelRed(q,(MagickRealType) PixelIntensityToQuantum(image,q) <= threshold ? 0 : QuantumRange); SetPixelGreen(q,GetPixelRed(q)); SetPixelBlue(q,GetPixelRed(q)); q++; } } else for (x=0; x < (ssize_t) image->columns; x++) { if ((channel & RedChannel) != 0) SetPixelRed(q,(MagickRealType) GetPixelRed(q) <= threshold ? 0 : QuantumRange); if ((channel & GreenChannel) != 0) SetPixelGreen(q,(MagickRealType) GetPixelGreen(q) <= threshold ? 0 : QuantumRange); if ((channel & BlueChannel) != 0) SetPixelBlue(q,(MagickRealType) GetPixelBlue(q) <= threshold ? 0 : QuantumRange); if ((channel & OpacityChannel) != 0) { if (image->matte == MagickFalse) SetPixelOpacity(q,(MagickRealType) GetPixelOpacity(q) <= threshold ? 0 : QuantumRange); else SetPixelOpacity(q,(MagickRealType) GetPixelOpacity(q) <= threshold ? OpaqueOpacity : TransparentOpacity); } if (((channel & IndexChannel) != 0) && (image->colorspace == CMYKColorspace)) SetPixelIndex(indexes+x,(MagickRealType) GetPixelIndex(indexes+x) <= threshold ? 0 : QuantumRange); q++; } if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) status=MagickFalse; if (image->progress_monitor != (MagickProgressMonitor) NULL) { MagickBooleanType proceed; #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp critical (MagickCore_BilevelImageChannel) #endif proceed=SetImageProgress(image,ThresholdImageTag,progress++, image->rows); if (proceed == MagickFalse) status=MagickFalse; } } image_view=DestroyCacheView(image_view); return(status); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % B l a c k T h r e s h o l d I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % BlackThresholdImage() is like ThresholdImage() but forces all pixels below % the threshold into black while leaving all pixels at or above the threshold % unchanged. % % The format of the BlackThresholdImage method is: % % MagickBooleanType BlackThresholdImage(Image *image,const char *threshold) % MagickBooleanType BlackThresholdImageChannel(Image *image, % const ChannelType channel,const char *threshold, % ExceptionInfo *exception) % % A description of each parameter follows: % % o image: the image. % % o channel: the channel or channels to be thresholded. % % o threshold: Define the threshold value. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickBooleanType BlackThresholdImage(Image *image, const char *threshold) { MagickBooleanType status; status=BlackThresholdImageChannel(image,DefaultChannels,threshold, &image->exception); return(status); } MagickExport MagickBooleanType BlackThresholdImageChannel(Image *image, const ChannelType channel,const char *thresholds,ExceptionInfo *exception) { #define ThresholdImageTag "Threshold/Image" CacheView *image_view; GeometryInfo geometry_info; MagickBooleanType status; MagickOffsetType progress; MagickPixelPacket threshold; MagickRealType intensity; MagickStatusType flags; ssize_t y; assert(image != (Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); if (thresholds == (const char *) NULL) return(MagickTrue); if (SetImageStorageClass(image,DirectClass) == MagickFalse) return(MagickFalse); GetMagickPixelPacket(image,&threshold); flags=ParseGeometry(thresholds,&geometry_info); threshold.red=geometry_info.rho; threshold.green=geometry_info.sigma; if ((flags & SigmaValue) == 0) threshold.green=threshold.red; threshold.blue=geometry_info.xi; if ((flags & XiValue) == 0) threshold.blue=threshold.red; threshold.opacity=geometry_info.psi; if ((flags & PsiValue) == 0) threshold.opacity=threshold.red; threshold.index=geometry_info.chi; if ((flags & ChiValue) == 0) threshold.index=threshold.red; if ((flags & PercentValue) != 0) { threshold.red*=(QuantumRange/100.0); threshold.green*=(QuantumRange/100.0); threshold.blue*=(QuantumRange/100.0); threshold.opacity*=(QuantumRange/100.0); threshold.index*=(QuantumRange/100.0); } intensity=MagickPixelIntensity(&threshold); if ((IsMagickGray(&threshold) == MagickFalse) && (IsGrayColorspace(image->colorspace) != MagickFalse)) (void) TransformImageColorspace(image,RGBColorspace); /* Black threshold image. */ status=MagickTrue; progress=0; image_view=AcquireAuthenticCacheView(image,exception); #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp parallel for schedule(static,8) shared(progress,status) \ dynamic_number_threads(image,image->columns,image->rows,1) #endif for (y=0; y < (ssize_t) image->rows; y++) { register IndexPacket *restrict indexes; register ssize_t x; register PixelPacket *restrict q; if (status == MagickFalse) continue; q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) { status=MagickFalse; continue; } indexes=GetCacheViewAuthenticIndexQueue(image_view); for (x=0; x < (ssize_t) image->columns; x++) { if ((channel & SyncChannels) != 0) { if (PixelIntensity(image,q) < intensity) { SetPixelRed(q,0); SetPixelGreen(q,0); SetPixelBlue(q,0); if (image->colorspace == CMYKColorspace) SetPixelIndex(indexes+x,0); } } else { if (((channel & RedChannel) != 0) && ((MagickRealType) GetPixelRed(q) < threshold.red)) SetPixelRed(q,0); if (((channel & GreenChannel) != 0) && ((MagickRealType) GetPixelGreen(q) < threshold.green)) SetPixelGreen(q,0); if (((channel & BlueChannel) != 0) && ((MagickRealType) GetPixelBlue(q) < threshold.blue)) SetPixelBlue(q,0); if (((channel & OpacityChannel) != 0) && ((MagickRealType) GetPixelOpacity(q) < threshold.opacity)) SetPixelOpacity(q,0); if (((channel & IndexChannel) != 0) && (image->colorspace == CMYKColorspace) && ((MagickRealType) GetPixelIndex(indexes+x) < threshold.index)) SetPixelIndex(indexes+x,0); } q++; } if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) status=MagickFalse; if (image->progress_monitor != (MagickProgressMonitor) NULL) { MagickBooleanType proceed; #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp critical (MagickCore_BlackThresholdImageChannel) #endif proceed=SetImageProgress(image,ThresholdImageTag,progress++, image->rows); if (proceed == MagickFalse) status=MagickFalse; } } image_view=DestroyCacheView(image_view); return(status); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % C l a m p I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ClampImage() restricts the color range from 0 to the quantum depth. % % The format of the ClampImageChannel method is: % % MagickBooleanType ClampImage(Image *image) % MagickBooleanType ClampImageChannel(Image *image, % const ChannelType channel) % % A description of each parameter follows: % % o image: the image. % % o channel: the channel type. % */ static inline Quantum ClampToUnsignedQuantum(const Quantum quantum) { #if defined(MAGICKCORE_HDRI_SUPPORT) if (quantum <= 0) return(0); if (quantum >= QuantumRange) return(QuantumRange); return(quantum); #else return(quantum); #endif } MagickExport MagickBooleanType ClampImage(Image *image) { MagickBooleanType status; status=ClampImageChannel(image,DefaultChannels); return(status); } MagickExport MagickBooleanType ClampImageChannel(Image *image, const ChannelType channel) { #define ClampImageTag "Clamp/Image" CacheView *image_view; ExceptionInfo *exception; MagickBooleanType status; MagickOffsetType progress; ssize_t y; assert(image != (Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); if (image->storage_class == PseudoClass) { register ssize_t i; register PixelPacket *restrict q; q=image->colormap; for (i=0; i < (ssize_t) image->colors; i++) { SetPixelRed(q,ClampToUnsignedQuantum(GetPixelRed(q))); SetPixelGreen(q,ClampToUnsignedQuantum(GetPixelGreen(q))); SetPixelBlue(q,ClampToUnsignedQuantum(GetPixelBlue(q))); SetPixelOpacity(q,ClampToUnsignedQuantum(GetPixelOpacity(q))); q++; } return(SyncImage(image)); } /* Clamp image. */ status=MagickTrue; progress=0; exception=(&image->exception); image_view=AcquireAuthenticCacheView(image,exception); #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp parallel for schedule(static,8) shared(progress,status) \ dynamic_number_threads(image,image->columns,image->rows,1) #endif for (y=0; y < (ssize_t) image->rows; y++) { register IndexPacket *restrict indexes; register ssize_t x; register PixelPacket *restrict q; if (status == MagickFalse) continue; q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) { status=MagickFalse; continue; } indexes=GetCacheViewAuthenticIndexQueue(image_view); for (x=0; x < (ssize_t) image->columns; x++) { if ((channel & RedChannel) != 0) SetPixelRed(q,ClampToUnsignedQuantum(GetPixelRed(q))); if ((channel & GreenChannel) != 0) SetPixelGreen(q,ClampToUnsignedQuantum(GetPixelGreen(q))); if ((channel & BlueChannel) != 0) SetPixelBlue(q,ClampToUnsignedQuantum(GetPixelBlue(q))); if ((channel & OpacityChannel) != 0) SetPixelOpacity(q,ClampToUnsignedQuantum(GetPixelOpacity(q))); if (((channel & IndexChannel) != 0) && (image->colorspace == CMYKColorspace)) SetPixelIndex(indexes+x,ClampToUnsignedQuantum( GetPixelIndex(indexes+x))); q++; } if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) status=MagickFalse; if (image->progress_monitor != (MagickProgressMonitor) NULL) { MagickBooleanType proceed; #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp critical (MagickCore_ClampImageChannel) #endif proceed=SetImageProgress(image,ClampImageTag,progress++,image->rows); if (proceed == MagickFalse) status=MagickFalse; } } image_view=DestroyCacheView(image_view); return(status); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % D e s t r o y T h r e s h o l d M a p % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % DestroyThresholdMap() de-allocate the given ThresholdMap % % The format of the ListThresholdMaps method is: % % ThresholdMap *DestroyThresholdMap(Threshold *map) % % A description of each parameter follows. % % o map: Pointer to the Threshold map to destroy % */ MagickExport ThresholdMap *DestroyThresholdMap(ThresholdMap *map) { assert(map != (ThresholdMap *) NULL); if (map->map_id != (char *) NULL) map->map_id=DestroyString(map->map_id); if (map->description != (char *) NULL) map->description=DestroyString(map->description); if (map->levels != (ssize_t *) NULL) map->levels=(ssize_t *) RelinquishMagickMemory(map->levels); map=(ThresholdMap *) RelinquishMagickMemory(map); return(map); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + G e t T h r e s h o l d M a p F i l e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetThresholdMapFile() look for a given threshold map name or alias in the % given XML file data, and return the allocated the map when found. % % The format of the ListThresholdMaps method is: % % ThresholdMap *GetThresholdMap(const char *xml,const char *filename, % const char *map_id,ExceptionInfo *exception) % % A description of each parameter follows. % % o xml: The threshold map list in XML format. % % o filename: The threshold map XML filename. % % o map_id: ID of the map to look for in XML list. % % o exception: return any errors or warnings in this structure. % */ MagickExport ThresholdMap *GetThresholdMapFile(const char *xml, const char *filename,const char *map_id,ExceptionInfo *exception) { const char *attr, *content; double value; ThresholdMap *map; XMLTreeInfo *description, *levels, *threshold, *thresholds; map = (ThresholdMap *)NULL; (void) LogMagickEvent(ConfigureEvent,GetMagickModule(), "Loading threshold map file \"%s\" ...",filename); thresholds=NewXMLTree(xml,exception); if ( thresholds == (XMLTreeInfo *)NULL ) return(map); for( threshold = GetXMLTreeChild(thresholds,"threshold"); threshold != (XMLTreeInfo *)NULL; threshold = GetNextXMLTreeTag(threshold) ) { attr = GetXMLTreeAttribute(threshold, "map"); if ( (attr != (char *)NULL) && (LocaleCompare(map_id,attr) == 0) ) break; attr = GetXMLTreeAttribute(threshold, "alias"); if ( (attr != (char *)NULL) && (LocaleCompare(map_id,attr) == 0) ) break; } if ( threshold == (XMLTreeInfo *)NULL ) { return(map); } description = GetXMLTreeChild(threshold,"description"); if ( description == (XMLTreeInfo *)NULL ) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "XmlMissingElement", "<description>, map \"%s\"", map_id); thresholds = DestroyXMLTree(thresholds); return(map); } levels = GetXMLTreeChild(threshold,"levels"); if ( levels == (XMLTreeInfo *)NULL ) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "XmlMissingElement", "<levels>, map \"%s\"", map_id); thresholds = DestroyXMLTree(thresholds); return(map); } /* The map has been found -- Allocate a Threshold Map to return */ map = (ThresholdMap *)AcquireMagickMemory(sizeof(ThresholdMap)); if ( map == (ThresholdMap *)NULL ) ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireThresholdMap"); map->map_id = (char *)NULL; map->description = (char *)NULL; map->levels = (ssize_t *) NULL; /* Assign Basic Attributes */ attr = GetXMLTreeAttribute(threshold, "map"); if ( attr != (char *)NULL ) map->map_id = ConstantString(attr); content = GetXMLTreeContent(description); if ( content != (char *)NULL ) map->description = ConstantString(content); attr = GetXMLTreeAttribute(levels, "width"); if ( attr == (char *)NULL ) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "XmlMissingAttribute", "<levels width>, map \"%s\"", map_id); thresholds = DestroyXMLTree(thresholds); map = DestroyThresholdMap(map); return(map); } map->width = StringToUnsignedLong(attr); if ( map->width == 0 ) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "XmlInvalidAttribute", "<levels width>, map \"%s\"", map_id); thresholds = DestroyXMLTree(thresholds); map = DestroyThresholdMap(map); return(map); } attr = GetXMLTreeAttribute(levels, "height"); if ( attr == (char *)NULL ) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "XmlMissingAttribute", "<levels height>, map \"%s\"", map_id); thresholds = DestroyXMLTree(thresholds); map = DestroyThresholdMap(map); return(map); } map->height = StringToUnsignedLong(attr); if ( map->height == 0 ) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "XmlInvalidAttribute", "<levels height>, map \"%s\"", map_id); thresholds = DestroyXMLTree(thresholds); map = DestroyThresholdMap(map); return(map); } attr = GetXMLTreeAttribute(levels, "divisor"); if ( attr == (char *)NULL ) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "XmlMissingAttribute", "<levels divisor>, map \"%s\"", map_id); thresholds = DestroyXMLTree(thresholds); map = DestroyThresholdMap(map); return(map); } map->divisor = (ssize_t) StringToLong(attr); if ( map->divisor < 2 ) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "XmlInvalidAttribute", "<levels divisor>, map \"%s\"", map_id); thresholds = DestroyXMLTree(thresholds); map = DestroyThresholdMap(map); return(map); } /* Allocate theshold levels array */ content = GetXMLTreeContent(levels); if ( content == (char *)NULL ) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "XmlMissingContent", "<levels>, map \"%s\"", map_id); thresholds = DestroyXMLTree(thresholds); map = DestroyThresholdMap(map); return(map); } map->levels=(ssize_t *) AcquireQuantumMemory((size_t) map->width,map->height* sizeof(*map->levels)); if ( map->levels == (ssize_t *)NULL ) ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireThresholdMap"); { /* parse levels into integer array */ ssize_t i; char *p; for( i=0; i< (ssize_t) (map->width*map->height); i++) { map->levels[i] = (ssize_t)strtol(content, &p, 10); if ( p == content ) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "XmlInvalidContent", "<level> too few values, map \"%s\"", map_id); thresholds = DestroyXMLTree(thresholds); map = DestroyThresholdMap(map); return(map); } if ( map->levels[i] < 0 || map->levels[i] > map->divisor ) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "XmlInvalidContent", "<level> %.20g out of range, map \"%s\"", (double) map->levels[i],map_id); thresholds = DestroyXMLTree(thresholds); map = DestroyThresholdMap(map); return(map); } content = p; } value=(double) strtol(content,&p,10); (void) value; if (p != content) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "XmlInvalidContent", "<level> too many values, map \"%s\"", map_id); thresholds=DestroyXMLTree(thresholds); map=DestroyThresholdMap(map); return(map); } } thresholds = DestroyXMLTree(thresholds); return(map); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % G e t T h r e s h o l d M a p % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetThresholdMap() load and search one or more threshold map files for the % a map matching the given name or aliase. % % The format of the GetThresholdMap method is: % % ThresholdMap *GetThresholdMap(const char *map_id, % ExceptionInfo *exception) % % A description of each parameter follows. % % o map_id: ID of the map to look for. % % o exception: return any errors or warnings in this structure. % */ MagickExport ThresholdMap *GetThresholdMap(const char *map_id, ExceptionInfo *exception) { const StringInfo *option; LinkedListInfo *options; ThresholdMap *map; map=(ThresholdMap *)NULL; options=GetConfigureOptions(ThresholdsFilename,exception); while (( option=(const StringInfo *) GetNextValueInLinkedList(options) ) != (const StringInfo *) NULL && map == (ThresholdMap *)NULL ) map=GetThresholdMapFile((const char *) GetStringInfoDatum(option), GetStringInfoPath(option),map_id,exception); options=DestroyConfigureOptions(options); return(map); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + L i s t T h r e s h o l d M a p F i l e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ListThresholdMapFile() lists the threshold maps and their descriptions % in the given XML file data. % % The format of the ListThresholdMaps method is: % % MagickBooleanType ListThresholdMaps(FILE *file,const char*xml, % const char *filename,ExceptionInfo *exception) % % A description of each parameter follows. % % o file: An pointer to the output FILE. % % o xml: The threshold map list in XML format. % % o filename: The threshold map XML filename. % % o exception: return any errors or warnings in this structure. % */ MagickBooleanType ListThresholdMapFile(FILE *file,const char *xml, const char *filename,ExceptionInfo *exception) { XMLTreeInfo *thresholds,*threshold,*description; const char *map,*alias,*content; assert( xml != (char *)NULL ); assert( file != (FILE *)NULL ); (void) LogMagickEvent(ConfigureEvent,GetMagickModule(), "Loading threshold map file \"%s\" ...",filename); thresholds=NewXMLTree(xml,exception); if ( thresholds == (XMLTreeInfo *)NULL ) return(MagickFalse); (void) FormatLocaleFile(file,"%-16s %-12s %s\n","Map","Alias","Description"); (void) FormatLocaleFile(file, "----------------------------------------------------\n"); for( threshold = GetXMLTreeChild(thresholds,"threshold"); threshold != (XMLTreeInfo *)NULL; threshold = GetNextXMLTreeTag(threshold) ) { map = GetXMLTreeAttribute(threshold, "map"); if (map == (char *) NULL) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "XmlMissingAttribute", "<map>"); thresholds=DestroyXMLTree(thresholds); return(MagickFalse); } alias = GetXMLTreeAttribute(threshold, "alias"); /* alias is optional, no if test needed */ description=GetXMLTreeChild(threshold,"description"); if ( description == (XMLTreeInfo *)NULL ) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "XmlMissingElement", "<description>, map \"%s\"", map); thresholds=DestroyXMLTree(thresholds); return(MagickFalse); } content=GetXMLTreeContent(description); if ( content == (char *)NULL ) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "XmlMissingContent", "<description>, map \"%s\"", map); thresholds=DestroyXMLTree(thresholds); return(MagickFalse); } (void) FormatLocaleFile(file,"%-16s %-12s %s\n",map,alias ? alias : "", content); } thresholds=DestroyXMLTree(thresholds); return(MagickTrue); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L i s t T h r e s h o l d M a p s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ListThresholdMaps() lists the threshold maps and their descriptions % as defined by "threshold.xml" to a file. % % The format of the ListThresholdMaps method is: % % MagickBooleanType ListThresholdMaps(FILE *file,ExceptionInfo *exception) % % A description of each parameter follows. % % o file: An pointer to the output FILE. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickBooleanType ListThresholdMaps(FILE *file, ExceptionInfo *exception) { const StringInfo *option; LinkedListInfo *options; MagickStatusType status; status=MagickFalse; if ( file == (FILE *)NULL ) file = stdout; options=GetConfigureOptions(ThresholdsFilename,exception); (void) FormatLocaleFile(file, "\n Threshold Maps for Ordered Dither Operations\n"); while ( ( option=(const StringInfo *) GetNextValueInLinkedList(options) ) != (const StringInfo *) NULL) { (void) FormatLocaleFile(file,"\nPATH: %s\n\n",GetStringInfoPath(option)); status|=ListThresholdMapFile(file,(const char *) GetStringInfoDatum(option), GetStringInfoPath(option),exception); } options=DestroyConfigureOptions(options); return(status != 0 ? MagickTrue : MagickFalse); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % O r d e r e d D i t h e r I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % OrderedDitherImage() uses the ordered dithering technique of reducing color % images to monochrome using positional information to retain as much % information as possible. % % WARNING: This function is deprecated, and is now just a call to % the more more powerful OrderedPosterizeImage(); function. % % The format of the OrderedDitherImage method is: % % MagickBooleanType OrderedDitherImage(Image *image) % MagickBooleanType OrderedDitherImageChannel(Image *image, % const ChannelType channel,ExceptionInfo *exception) % % A description of each parameter follows: % % o image: the image. % % o channel: the channel or channels to be thresholded. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickBooleanType OrderedDitherImage(Image *image) { MagickBooleanType status; status=OrderedDitherImageChannel(image,DefaultChannels,&image->exception); return(status); } MagickExport MagickBooleanType OrderedDitherImageChannel(Image *image, const ChannelType channel,ExceptionInfo *exception) { MagickBooleanType status; /* Call the augumented function OrderedPosterizeImage() */ status=OrderedPosterizeImageChannel(image,channel,"o8x8",exception); return(status); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % O r d e r e d P o s t e r i z e I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % OrderedPosterizeImage() will perform a ordered dither based on a number % of pre-defined dithering threshold maps, but over multiple intensity % levels, which can be different for different channels, according to the % input argument. % % The format of the OrderedPosterizeImage method is: % % MagickBooleanType OrderedPosterizeImage(Image *image, % const char *threshold_map,ExceptionInfo *exception) % MagickBooleanType OrderedPosterizeImageChannel(Image *image, % const ChannelType channel,const char *threshold_map, % ExceptionInfo *exception) % % A description of each parameter follows: % % o image: the image. % % o channel: the channel or channels to be thresholded. % % o threshold_map: A string containing the name of the threshold dither % map to use, followed by zero or more numbers representing the number % of color levels tho dither between. % % Any level number less than 2 will be equivalent to 2, and means only % binary dithering will be applied to each color channel. % % No numbers also means a 2 level (bitmap) dither will be applied to all % channels, while a single number is the number of levels applied to each % channel in sequence. More numbers will be applied in turn to each of % the color channels. % % For example: "o3x3,6" will generate a 6 level posterization of the % image with a ordered 3x3 diffused pixel dither being applied between % each level. While checker,8,8,4 will produce a 332 colormaped image % with only a single checkerboard hash pattern (50% grey) between each % color level, to basically double the number of color levels with % a bare minimim of dithering. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickBooleanType OrderedPosterizeImage(Image *image, const char *threshold_map,ExceptionInfo *exception) { MagickBooleanType status; status=OrderedPosterizeImageChannel(image,DefaultChannels,threshold_map, exception); return(status); } MagickExport MagickBooleanType OrderedPosterizeImageChannel(Image *image, const ChannelType channel,const char *threshold_map,ExceptionInfo *exception) { #define DitherImageTag "Dither/Image" CacheView *image_view; LongPixelPacket levels; MagickBooleanType status; MagickOffsetType progress; ssize_t y; ThresholdMap *map; assert(image != (Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); if (threshold_map == (const char *) NULL) return(MagickTrue); { char token[MaxTextExtent]; register const char *p; p=(char *)threshold_map; while (((isspace((int) ((unsigned char) *p)) != 0) || (*p == ',')) && (*p != '\0')) p++; threshold_map=p; while (((isspace((int) ((unsigned char) *p)) == 0) && (*p != ',')) && (*p != '\0')) { if ((p-threshold_map) >= (MaxTextExtent-1)) break; token[p-threshold_map] = *p; p++; } token[p-threshold_map] = '\0'; map = GetThresholdMap(token, exception); if ( map == (ThresholdMap *)NULL ) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "InvalidArgument","%s : '%s'","ordered-dither",threshold_map); return(MagickFalse); } } /* Set channel levels from extra comma separated arguments Default to 2, the single value given, or individual channel values */ #if 1 { /* parse directly as a comma separated list of integers */ char *p; p = strchr((char *) threshold_map,','); if ( p != (char *)NULL && isdigit((int) ((unsigned char) *(++p))) ) levels.index = (unsigned int) strtoul(p, &p, 10); else levels.index = 2; levels.red = ((channel & RedChannel ) != 0) ? levels.index : 0; levels.green = ((channel & GreenChannel) != 0) ? levels.index : 0; levels.blue = ((channel & BlueChannel) != 0) ? levels.index : 0; levels.opacity = ((channel & OpacityChannel) != 0) ? levels.index : 0; levels.index = ((channel & IndexChannel) != 0 && (image->colorspace == CMYKColorspace)) ? levels.index : 0; /* if more than a single number, each channel has a separate value */ if ( p != (char *) NULL && *p == ',' ) { p=strchr((char *) threshold_map,','); p++; if ((channel & RedChannel) != 0) levels.red = (unsigned int) strtoul(p, &p, 10), (void)(*p == ',' && p++); if ((channel & GreenChannel) != 0) levels.green = (unsigned int) strtoul(p, &p, 10), (void)(*p == ',' && p++); if ((channel & BlueChannel) != 0) levels.blue = (unsigned int) strtoul(p, &p, 10), (void)(*p == ',' && p++); if ((channel & IndexChannel) != 0 && image->colorspace == CMYKColorspace) levels.index=(unsigned int) strtoul(p, &p, 10), (void)(*p == ',' && p++); if ((channel & OpacityChannel) != 0) levels.opacity = (unsigned int) strtoul(p, &p, 10), (void)(*p == ',' && p++); } } #else /* Parse level values as a geometry */ /* This difficult! * How to map GeometryInfo structure elements into * LongPixelPacket structure elements, but according to channel? * Note the channels list may skip elements!!!! * EG -channel BA -ordered-dither map,2,3 * will need to map g.rho -> l.blue, and g.sigma -> l.opacity * A simpler way is needed, probably converting geometry to a temporary * array, then using channel to advance the index into ssize_t pixel packet. */ #endif #if 0 printf("DEBUG levels r=%u g=%u b=%u a=%u i=%u\n", levels.red, levels.green, levels.blue, levels.opacity, levels.index); #endif { /* Do the posterized ordered dithering of the image */ ssize_t d; /* d = number of psuedo-level divisions added between color levels */ d = map->divisor-1; /* reduce levels to levels - 1 */ levels.red = levels.red ? levels.red-1 : 0; levels.green = levels.green ? levels.green-1 : 0; levels.blue = levels.blue ? levels.blue-1 : 0; levels.opacity = levels.opacity ? levels.opacity-1 : 0; levels.index = levels.index ? levels.index-1 : 0; if (SetImageStorageClass(image,DirectClass) == MagickFalse) { InheritException(exception,&image->exception); return(MagickFalse); } status=MagickTrue; progress=0; image_view=AcquireAuthenticCacheView(image,exception); #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp parallel for schedule(static,8) shared(progress,status) \ dynamic_number_threads(image,image->columns,image->rows,1) #endif for (y=0; y < (ssize_t) image->rows; y++) { register IndexPacket *restrict indexes; register ssize_t x; register PixelPacket *restrict q; if (status == MagickFalse) continue; q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) { status=MagickFalse; continue; } indexes=GetCacheViewAuthenticIndexQueue(image_view); for (x=0; x < (ssize_t) image->columns; x++) { register ssize_t threshold, t, l; /* Figure out the dither threshold for this pixel This must be a integer from 1 to map->divisor-1 */ threshold = map->levels[(x%map->width) +map->width*(y%map->height)]; /* Dither each channel in the image as appropriate Notes on the integer Math... total number of divisions = (levels-1)*(divisor-1)+1) t1 = this colors psuedo_level = q->red * total_divisions / (QuantumRange+1) l = posterization level 0..levels t = dither threshold level 0..divisor-1 NB: 0 only on last Each color_level is of size QuantumRange / (levels-1) NB: All input levels and divisor are already had 1 subtracted Opacity is inverted so 'off' represents transparent. */ if (levels.red) { t = (ssize_t) (QuantumScale*GetPixelRed(q)*(levels.red*d+1)); l = t/d; t = t-l*d; SetPixelRed(q,ClampToQuantum((MagickRealType) ((l+(t >= threshold))*(MagickRealType) QuantumRange/levels.red))); } if (levels.green) { t = (ssize_t) (QuantumScale*GetPixelGreen(q)* (levels.green*d+1)); l = t/d; t = t-l*d; SetPixelGreen(q,ClampToQuantum((MagickRealType) ((l+(t >= threshold))*(MagickRealType) QuantumRange/levels.green))); } if (levels.blue) { t = (ssize_t) (QuantumScale*GetPixelBlue(q)* (levels.blue*d+1)); l = t/d; t = t-l*d; SetPixelBlue(q,ClampToQuantum((MagickRealType) ((l+(t >= threshold))*(MagickRealType) QuantumRange/levels.blue))); } if (levels.opacity) { t = (ssize_t) ((1.0-QuantumScale*GetPixelOpacity(q))* (levels.opacity*d+1)); l = t/d; t = t-l*d; SetPixelOpacity(q,ClampToQuantum((MagickRealType) ((1.0-l-(t >= threshold))*(MagickRealType) QuantumRange/ levels.opacity))); } if (levels.index) { t = (ssize_t) (QuantumScale*GetPixelIndex(indexes+x)* (levels.index*d+1)); l = t/d; t = t-l*d; SetPixelIndex(indexes+x,ClampToQuantum((MagickRealType) ((l+ (t>=threshold))*(MagickRealType) QuantumRange/levels.index))); } q++; } if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) status=MagickFalse; if (image->progress_monitor != (MagickProgressMonitor) NULL) { MagickBooleanType proceed; #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp critical (MagickCore_OrderedPosterizeImageChannel) #endif proceed=SetImageProgress(image,DitherImageTag,progress++,image->rows); if (proceed == MagickFalse) status=MagickFalse; } } image_view=DestroyCacheView(image_view); } map=DestroyThresholdMap(map); return(MagickTrue); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R a n d o m T h r e s h o l d I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % RandomThresholdImage() changes the value of individual pixels based on the % intensity of each pixel compared to a random threshold. The result is a % low-contrast, two color image. % % The format of the RandomThresholdImage method is: % % MagickBooleanType RandomThresholdImageChannel(Image *image, % const char *thresholds,ExceptionInfo *exception) % MagickBooleanType RandomThresholdImageChannel(Image *image, % const ChannelType channel,const char *thresholds, % ExceptionInfo *exception) % % A description of each parameter follows: % % o image: the image. % % o channel: the channel or channels to be thresholded. % % o thresholds: a geometry string containing low,high thresholds. If the % string contains 2x2, 3x3, or 4x4, an ordered dither of order 2, 3, or 4 % is performed instead. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickBooleanType RandomThresholdImage(Image *image, const char *thresholds,ExceptionInfo *exception) { MagickBooleanType status; status=RandomThresholdImageChannel(image,DefaultChannels,thresholds, exception); return(status); } MagickExport MagickBooleanType RandomThresholdImageChannel(Image *image, const ChannelType channel,const char *thresholds,ExceptionInfo *exception) { #define ThresholdImageTag "Threshold/Image" CacheView *image_view; GeometryInfo geometry_info; MagickStatusType flags; MagickBooleanType status; MagickOffsetType progress; MagickPixelPacket threshold; MagickRealType min_threshold, max_threshold; RandomInfo **restrict random_info; ssize_t y; unsigned long key; assert(image != (Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); if (thresholds == (const char *) NULL) return(MagickTrue); GetMagickPixelPacket(image,&threshold); min_threshold=0.0; max_threshold=(MagickRealType) QuantumRange; flags=ParseGeometry(thresholds,&geometry_info); min_threshold=geometry_info.rho; max_threshold=geometry_info.sigma; if ((flags & SigmaValue) == 0) max_threshold=min_threshold; if (strchr(thresholds,'%') != (char *) NULL) { max_threshold*=(MagickRealType) (0.01*QuantumRange); min_threshold*=(MagickRealType) (0.01*QuantumRange); } else if (((max_threshold == min_threshold) || (max_threshold == 1)) && (min_threshold <= 8)) { /* Backward Compatibility -- ordered-dither -- IM v 6.2.9-6. */ status=OrderedPosterizeImageChannel(image,channel,thresholds,exception); return(status); } /* Random threshold image. */ status=MagickTrue; progress=0; if (channel == CompositeChannels) { if (AcquireImageColormap(image,2) == MagickFalse) ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); random_info=AcquireRandomInfoThreadSet(); key=GetRandomSecretKey(random_info[0]); image_view=AcquireAuthenticCacheView(image,exception); #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp parallel for schedule(static,8) shared(progress,status) \ dynamic_number_threads(image,image->columns,image->rows,key == ~0UL) #endif for (y=0; y < (ssize_t) image->rows; y++) { const int id = GetOpenMPThreadId(); MagickBooleanType sync; register IndexPacket *restrict indexes; register ssize_t x; register PixelPacket *restrict q; if (status == MagickFalse) continue; q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, exception); if (q == (PixelPacket *) NULL) { status=MagickFalse; continue; } indexes=GetCacheViewAuthenticIndexQueue(image_view); for (x=0; x < (ssize_t) image->columns; x++) { IndexPacket index; MagickRealType intensity; intensity=(MagickRealType) PixelIntensityToQuantum(image,q); if (intensity < min_threshold) threshold.index=min_threshold; else if (intensity > max_threshold) threshold.index=max_threshold; else threshold.index=(MagickRealType)(QuantumRange* GetPseudoRandomValue(random_info[id])); index=(IndexPacket) (intensity <= threshold.index ? 0 : 1); SetPixelIndex(indexes+x,index); SetPixelRGBO(q,image->colormap+(ssize_t) index); q++; } sync=SyncCacheViewAuthenticPixels(image_view,exception); if (sync == MagickFalse) status=MagickFalse; if (image->progress_monitor != (MagickProgressMonitor) NULL) { MagickBooleanType proceed; #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp critical (MagickCore_RandomThresholdImageChannel) #endif proceed=SetImageProgress(image,ThresholdImageTag,progress++, image->rows); if (proceed == MagickFalse) status=MagickFalse; } } image_view=DestroyCacheView(image_view); random_info=DestroyRandomInfoThreadSet(random_info); return(status); } if (SetImageStorageClass(image,DirectClass) == MagickFalse) { InheritException(exception,&image->exception); return(MagickFalse); } random_info=AcquireRandomInfoThreadSet(); key=GetRandomSecretKey(random_info[0]); image_view=AcquireAuthenticCacheView(image,exception); #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp parallel for schedule(static,8) shared(progress,status) \ dynamic_number_threads(image,image->columns,image->rows,key == ~0UL) #endif for (y=0; y < (ssize_t) image->rows; y++) { const int id = GetOpenMPThreadId(); register IndexPacket *restrict indexes; register PixelPacket *restrict q; register ssize_t x; if (status == MagickFalse) continue; q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) { status=MagickFalse; continue; } indexes=GetCacheViewAuthenticIndexQueue(image_view); for (x=0; x < (ssize_t) image->columns; x++) { if ((channel & RedChannel) != 0) { if ((MagickRealType) GetPixelRed(q) < min_threshold) threshold.red=min_threshold; else if ((MagickRealType) GetPixelRed(q) > max_threshold) threshold.red=max_threshold; else threshold.red=(MagickRealType) (QuantumRange* GetPseudoRandomValue(random_info[id])); } if ((channel & GreenChannel) != 0) { if ((MagickRealType) GetPixelGreen(q) < min_threshold) threshold.green=min_threshold; else if ((MagickRealType) GetPixelGreen(q) > max_threshold) threshold.green=max_threshold; else threshold.green=(MagickRealType) (QuantumRange* GetPseudoRandomValue(random_info[id])); } if ((channel & BlueChannel) != 0) { if ((MagickRealType) GetPixelBlue(q) < min_threshold) threshold.blue=min_threshold; else if ((MagickRealType) GetPixelBlue(q) > max_threshold) threshold.blue=max_threshold; else threshold.blue=(MagickRealType) (QuantumRange* GetPseudoRandomValue(random_info[id])); } if ((channel & OpacityChannel) != 0) { if ((MagickRealType) GetPixelOpacity(q) < min_threshold) threshold.opacity=min_threshold; else if ((MagickRealType) GetPixelOpacity(q) > max_threshold) threshold.opacity=max_threshold; else threshold.opacity=(MagickRealType) (QuantumRange* GetPseudoRandomValue(random_info[id])); } if (((channel & IndexChannel) != 0) && (image->colorspace == CMYKColorspace)) { if ((MagickRealType) GetPixelIndex(indexes+x) < min_threshold) threshold.index=min_threshold; else if ((MagickRealType) GetPixelIndex(indexes+x) > max_threshold) threshold.index=max_threshold; else threshold.index=(MagickRealType) (QuantumRange* GetPseudoRandomValue(random_info[id])); } if ((channel & RedChannel) != 0) SetPixelRed(q,(MagickRealType) GetPixelRed(q) <= threshold.red ? 0 : QuantumRange); if ((channel & GreenChannel) != 0) SetPixelGreen(q,(MagickRealType) GetPixelGreen(q) <= threshold.green ? 0 : QuantumRange); if ((channel & BlueChannel) != 0) SetPixelBlue(q,(MagickRealType) GetPixelBlue(q) <= threshold.blue ? 0 : QuantumRange); if ((channel & OpacityChannel) != 0) SetPixelOpacity(q,(MagickRealType) GetPixelOpacity(q) <= threshold.opacity ? 0 : QuantumRange); if (((channel & IndexChannel) != 0) && (image->colorspace == CMYKColorspace)) SetPixelIndex(indexes+x,(MagickRealType) GetPixelIndex(indexes+x) <= threshold.index ? 0 : QuantumRange); q++; } if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) status=MagickFalse; if (image->progress_monitor != (MagickProgressMonitor) NULL) { MagickBooleanType proceed; #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp critical (MagickCore_RandomThresholdImageChannel) #endif proceed=SetImageProgress(image,ThresholdImageTag,progress++, image->rows); if (proceed == MagickFalse) status=MagickFalse; } } image_view=DestroyCacheView(image_view); random_info=DestroyRandomInfoThreadSet(random_info); return(status); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % W h i t e T h r e s h o l d I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % WhiteThresholdImage() is like ThresholdImage() but forces all pixels above % the threshold into white while leaving all pixels at or below the threshold % unchanged. % % The format of the WhiteThresholdImage method is: % % MagickBooleanType WhiteThresholdImage(Image *image,const char *threshold) % MagickBooleanType WhiteThresholdImageChannel(Image *image, % const ChannelType channel,const char *threshold, % ExceptionInfo *exception) % % A description of each parameter follows: % % o image: the image. % % o channel: the channel or channels to be thresholded. % % o threshold: Define the threshold value. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickBooleanType WhiteThresholdImage(Image *image, const char *threshold) { MagickBooleanType status; status=WhiteThresholdImageChannel(image,DefaultChannels,threshold, &image->exception); return(status); } MagickExport MagickBooleanType WhiteThresholdImageChannel(Image *image, const ChannelType channel,const char *thresholds,ExceptionInfo *exception) { #define ThresholdImageTag "Threshold/Image" CacheView *image_view; GeometryInfo geometry_info; MagickBooleanType status; MagickOffsetType progress; MagickPixelPacket threshold; MagickRealType intensity; MagickStatusType flags; ssize_t y; assert(image != (Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); if (thresholds == (const char *) NULL) return(MagickTrue); if (SetImageStorageClass(image,DirectClass) == MagickFalse) return(MagickFalse); flags=ParseGeometry(thresholds,&geometry_info); GetMagickPixelPacket(image,&threshold); threshold.red=geometry_info.rho; threshold.green=geometry_info.sigma; if ((flags & SigmaValue) == 0) threshold.green=threshold.red; threshold.blue=geometry_info.xi; if ((flags & XiValue) == 0) threshold.blue=threshold.red; threshold.opacity=geometry_info.psi; if ((flags & PsiValue) == 0) threshold.opacity=threshold.red; threshold.index=geometry_info.chi; if ((flags & ChiValue) == 0) threshold.index=threshold.red; if ((flags & PercentValue) != 0) { threshold.red*=(QuantumRange/100.0); threshold.green*=(QuantumRange/100.0); threshold.blue*=(QuantumRange/100.0); threshold.opacity*=(QuantumRange/100.0); threshold.index*=(QuantumRange/100.0); } intensity=MagickPixelIntensity(&threshold); if ((IsMagickGray(&threshold) == MagickFalse) && (IsGrayColorspace(image->colorspace) != MagickFalse)) (void) TransformImageColorspace(image,RGBColorspace); /* White threshold image. */ status=MagickTrue; progress=0; image_view=AcquireAuthenticCacheView(image,exception); #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp parallel for schedule(static,8) shared(progress,status) \ dynamic_number_threads(image,image->columns,image->rows,1) #endif for (y=0; y < (ssize_t) image->rows; y++) { register IndexPacket *restrict indexes; register ssize_t x; register PixelPacket *restrict q; if (status == MagickFalse) continue; q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) { status=MagickFalse; continue; } indexes=GetCacheViewAuthenticIndexQueue(image_view); for (x=0; x < (ssize_t) image->columns; x++) { if ((channel & SyncChannels) != 0) { if (PixelIntensity(image,q) > intensity) { SetPixelRed(q,QuantumRange); SetPixelGreen(q,QuantumRange); SetPixelBlue(q,QuantumRange); if (image->colorspace == CMYKColorspace) SetPixelIndex(indexes+x,QuantumRange); } } else { if (((channel & RedChannel) != 0) && ((MagickRealType) GetPixelRed(q) > threshold.red)) SetPixelRed(q,QuantumRange); if (((channel & GreenChannel) != 0) && ((MagickRealType) GetPixelGreen(q) > threshold.green)) SetPixelGreen(q,QuantumRange); if (((channel & BlueChannel) != 0) && ((MagickRealType) GetPixelBlue(q) > threshold.blue)) SetPixelBlue(q,QuantumRange); if (((channel & OpacityChannel) != 0) && ((MagickRealType) GetPixelOpacity(q) > threshold.opacity)) SetPixelOpacity(q,QuantumRange); if (((channel & IndexChannel) != 0) && (image->colorspace == CMYKColorspace) && ((MagickRealType) GetPixelIndex(indexes+x)) > threshold.index) SetPixelIndex(indexes+x,QuantumRange); } q++; } if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) status=MagickFalse; if (image->progress_monitor != (MagickProgressMonitor) NULL) { MagickBooleanType proceed; #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp critical (MagickCore_WhiteThresholdImageChannel) #endif proceed=SetImageProgress(image,ThresholdImageTag,progress++, image->rows); if (proceed == MagickFalse) status=MagickFalse; } } image_view=DestroyCacheView(image_view); return(status); }
twobob/buildroot-kindle
output/build/imagemagick-6.7.8-8/magick/threshold.c
C
gpl-2.0
73,219
/* ----- Login with Fb/Tw ----- */ (function ($) { function rsvp_after_wordpress_login (data) { var status = 0; try { status = parseInt(data.status, 10); } catch (e) { status = 0; } if (!status) { // ... handle error //update error by Hoang if ($("#eab-wordpress_login-registration_wrapper").is(":visible")){ $('#eab-wordpress-signup-status').text(l10nEabApi.wp_signup_error); } else if ($("#eab-wordpress_login-login_wrapper").is(":visible")){ $('#eab-wordpress-login-status').text(l10nEabApi.wp_username_pass_invalid); } return false; } var $me = $("#eab-wordpress_login-wrapper"); var post_id = $me.attr("data-post_id"); // Get form if all went well $.post(_eab_data.ajax_url, { "action": "eab_get_form", "post_id": post_id }, function (data) { $("body").append('<div id="eab-wordpress_form">' + data + '</div>'); $("#eab-wordpress_form").find("." + $me.attr("class")).click(); }); } function send_wordpress_registration_request () { var deferred = $.Deferred(), $root = $("#eab-wordpress_login-registration_wrapper"), data = { username: $("#eab-wordpress_login-registration_username").val(), email: $("#eab-wordpress_login-registration_email").val() } ; deferred.done(function () { // Client-side validation first if (!data.username || !data.email) { $('#eab-wordpress-signup-status').text(l10nEabApi.wp_missing_user_email); return false; } $root.append('<img class="eab-waiting" src="' + _eab_data.root_url + '/waiting.gif" />'); $.post(_eab_data.ajax_url, { "action": "eab_wordpress_register", "data": data }, function (data) { rsvp_after_wordpress_login(data); }).always(function () { $root.find("img.eab-waiting").remove(); }); }); $(document).trigger("eab-api-registration-data", [data, deferred]); setTimeout(function () { if ('pending' === deferred.state()) deferred.resolve(); }, 500); } function send_wordpress_login_request () { // Client-side validation first var username = $("#eab-wordpress_login-login_username").val(); var password = $("#eab-wordpress_login-login_password").val(); //if (!username) return false; //if (!password) return false; if(!username || !password){ //output error here,update by Hoang $('#eab-wordpress-login-status').text(l10nEabApi.wp_missing_username_password); return false; } $.post(_eab_data.ajax_url, { "action": "eab_wordpress_login", "data": { "username": username, "password": password } }, function (data) { rsvp_after_wordpress_login(data); }); } function dispatch_login_register () { if ($("#eab-wordpress_login-registration_wrapper").is(":visible")) return send_wordpress_registration_request(); else if ($("#eab-wordpress_login-login_wrapper").is(":visible")) return send_wordpress_login_request(); return false; } function create_wordpress_login_popup ($action, post_id) { if (!$("#eab-wordpress_login-background").length) { $("body").append( "<div id='eab-wordpress_login-background'></div>" + "<div id='eab-wordpress_login-wrapper' class='" + $action.removeClass("active").attr("class") + "' data-post_id='" + post_id + "'>" + "<div id='eab-wordpress_login-registration_wrapper' class='eab-wordpress_login-element_wrapper'>" + "<h4>" + l10nEabApi.wp_register + "</h4>" + "<p class='eab-wordpress_login-element eab-wordpress_login-element-message'>" + l10nEabApi.wp_registration_msg + "</p>" + "<p id='eab-wordpress-signup-status'></p>"+ "<p class='eab-wordpress_login-element'>" + "<label for='eab-wordpress_login-registration_username'>" + l10nEabApi.wp_username + "</label>" + "<input type='text' id='eab-wordpress_login-registration_username' placeholder='' />" + "</p>" + "<p class='eab-wordpress_login-element'>" + "<label for='eab-wordpress_login-registration_email'>" + l10nEabApi.wp_email + "</label>" + "<input type='text' id='eab-wordpress_login-registration_email' placeholder='' />" + "</p>" + "</div>" + "<div id='eab-wordpress_login-login_wrapper' class='eab-wordpress_login-element_wrapper' style='display:none'>" + "<h4>" + l10nEabApi.wp_login + "</h4>" + "<p class='eab-wordpress_login-element eab-wordpress_login-element-message'>" + l10nEabApi.wp_login_msg + "</p>" + "<p id='eab-wordpress-login-status'></p>"+ "<p class='eab-wordpress_login-element'>" + "<label for='eab-wordpress_login-login_username'>" + l10nEabApi.wp_username + "</label>" + "<input type='text' id='eab-wordpress_login-login_username' placeholder='' />" + "</p>" + "<p class='eab-wordpress_login-element'>" + "<label for='eab-wordpress_login-login_password'>" + l10nEabApi.wp_password + "</label>" + "<input type='password' id='eab-wordpress_login-login_password' placeholder='' />" + "</p>" + "</div>" + "<div id='eab-wordpress_login-mode_toggle'><a href='#' data-on='" + l10nEabApi.wp_toggle_on + "' data-off='" + l10nEabApi.wp_toggle_off + "'>" + l10nEabApi.wp_toggle_on + "</a></div>" + "<div id='eab-wordpress_login-command_wrapper'>" + "<input type='button' id='eab-wordpress_login-command-ok' value='" + l10nEabApi.wp_submit + "' />" + "<input type='button' id='eab-wordpress_login-command-cancel' value='" + l10nEabApi.wp_cancel + "' />" + "</div>" + "</div>" ); $(document).trigger("eab-api-registration-form_rendered"); } var $background = $("#eab-wordpress_login-background"); var $wrapper = $("#eab-wordpress_login-wrapper"); $background.css({ "width": $(document).width(), "height": $(document).height() }); $wrapper.css({ "left": ($(document).width() - 300) / 2 }); //$("#eab-wordpress_login-mode_toggle a").on('click', function () { $("#eab-wordpress_login-mode_toggle a").click(function () { var $me = $(this); if ($("#eab-wordpress_login-registration_wrapper").is(":visible")) { $me.text($me.attr("data-off")); $("#eab-wordpress_login-registration_wrapper").hide(); $("#eab-wordpress_login-login_wrapper").show(); } else { $me.text($me.attr("data-on")); $("#eab-wordpress_login-login_wrapper").hide(); $("#eab-wordpress_login-registration_wrapper").show(); } return false; }); //$("#eab-wordpress_login-command-ok").on('click', dispatch_login_register); $("#eab-wordpress_login-command-ok").click(dispatch_login_register); //$("#eab-wordpress_login-command-cancel, #eab-wordpress_login-background").on('click', function () { $("#eab-wordpress_login-command-cancel, #eab-wordpress_login-background").click(function () { $wrapper.remove(); $background.remove(); return false; }); } function create_login_interface ($me) { if ($("#wpmudevevents-login_links-wrapper").length) { $("#wpmudevevents-login_links-wrapper").remove(); } $me.parents('.wpmudevevents-buttons').after('<div id="wpmudevevents-login_links-wrapper" />'); var $root = $("#wpmudevevents-login_links-wrapper"); var post_id = $me.parents(".wpmudevevents-buttons").find('input:hidden[name="event_id"]').val(); $root.html( '<ul class="wpmudevevents-login_links">' + (l10nEabApi.show_facebook ? '<li><a href="#" class="wpmudevevents-login_link wpmudevevents-login_link-facebook">' + l10nEabApi.facebook + '</a></li>' : '') + (l10nEabApi.show_twitter ? '<li><a href="#" class="wpmudevevents-login_link wpmudevevents-login_link-twitter">' + l10nEabApi.twitter + '</a></li>' : '') + (l10nEabApi.show_google ? '<li><a href="#" class="wpmudevevents-login_link wpmudevevents-login_link-google">' + l10nEabApi.google + '</a></li>' : '') + (l10nEabApi.show_wordpress ? '<li><a href="#" class="wpmudevevents-login_link wpmudevevents-login_link-wordpress">' + l10nEabApi.wordpress + '</a></li>' : '') + '<li><a href="#" class="wpmudevevents-login_link wpmudevevents-login_link-cancel">' + l10nEabApi.cancel + '</a></li>' + '</ul>' ); $me.addClass("active"); $root.find(".wpmudevevents-login_link").each(function () { var $lnk = $(this); var callback = false; if ($lnk.is(".wpmudevevents-login_link-facebook")) { // Facebook login callback = function () { FB.login(function (resp) { if (resp.authResponse && resp.authResponse.userID) { // change UI $root.html('<img src="' + _eab_data.root_url + 'waiting.gif" /> ' + l10nEabApi.please_wait); $.post(_eab_data.ajax_url, { "action": "eab_facebook_login", "user_id": resp.authResponse.userID, "token": FB.getAccessToken() }, function (data) { var status = 0; try { status = parseInt(data.status, 10); } catch (e) { status = 0; } if (!status) { // ... handle error $root.remove(); $me.click(); return false; } // Get form if all went well $.post(_eab_data.ajax_url, { "action": "eab_get_form", "post_id": post_id }, function (data) { $("body").append('<div id="eab-facebook_form">' + data + '</div>'); $("#eab-facebook_form").find("." + $me.removeClass("active").attr("class")).click(); }); }); } }, {scope: _eab_data.fb_scope}); return false; }; } else if ($lnk.is(".wpmudevevents-login_link-twitter")) { callback = function () { var init_url = '//api.twitter.com/'; var twLogin = window.open(init_url, "twitter_login", "scrollbars=no,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no,height=400,width=600"); $.post(_eab_data.ajax_url, { "action": "eab_get_twitter_auth_url", "url": window.location.toString() }, function (data) { try { twLogin.location = data.url; } catch (e) { twLogin.location.replace(data.url); } var tTimer = setInterval(function () { try { if (twLogin.location.hostname == window.location.hostname) { // We're back! var location = twLogin.location; var search = ''; try { search = location.search; } catch (e) { search = ''; } clearInterval(tTimer); twLogin.close(); // change UI $root.html('<img src="' + _eab_data.root_url + 'waiting.gif" /> ' + l10nEabApi.please_wait); $.post(_eab_data.ajax_url, { "action": "eab_twitter_login", "secret": data.secret, "data": search }, function (data) { var status = 0; try { status = parseInt(data.status, 10); } catch (e) { status = 0; } if (!status) { // ... handle error $root.remove(); $me.click(); return false; } // Get form if all went well $.post(_eab_data.ajax_url, { "action": "eab_get_form", "post_id": post_id }, function (data) { $("body").append('<div id="eab-twitter_form">' + data + '</div>'); $("#eab-twitter_form").find("." + $me.removeClass("active").attr("class")).click(); }); }); } } catch (e) {} }, 300); }); return false; }; } else if ($lnk.is(".wpmudevevents-login_link-google")) { callback = function () { var googleLogin = window.open('https://www.google.com/accounts', "google_login", "scrollbars=no,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no,height=400,width=800"); $.post(_eab_data.ajax_url, { "action": "eab_get_google_auth_url", "url": window.location.href }, function (data) { var href = data.url; googleLogin.location = href; var gTimer = setInterval(function () { try { if (googleLogin.location.hostname == window.location.hostname) { // We're back! clearInterval(gTimer); googleLogin.close(); // change UI $root.html('<img src="' + _eab_data.root_url + 'waiting.gif" /> ' + l10nEabApi.please_wait); $.post(_eab_data.ajax_url, { "action": "eab_google_login" }, function (data) { var status = 0; try { status = parseInt(data.status, 10); } catch (e) { status = 0; } if (!status) { // ... handle error $root.remove(); $me.click(); return false; } // Get form if all went well $.post(_eab_data.ajax_url, { "action": "eab_get_form", "post_id": post_id }, function (data) { $("body").append('<div id="eab-google_form">' + data + '</div>'); $("#eab-google_form").find("." + $me.removeClass("active").attr("class")).click(); }); }); } } catch (e) {} }, 300); }); return false; }; } else if ($lnk.is(".wpmudevevents-login_link-wordpress")) { // Pass on to wordpress login callback = function () { //window.location = $me.attr("href"); create_wordpress_login_popup($me, post_id); return false; }; } else if ($lnk.is(".wpmudevevents-login_link-cancel")) { // Drop entire thing callback = function () { $me.removeClass("active"); $root.remove(); return false; }; } if (callback) $lnk .unbind('click') .bind('click', callback) ; }); } // Init $(function () { $( "a.wpmudevevents-yes-submit, " + "a.wpmudevevents-maybe-submit, " + "a.wpmudevevents-no-submit" ) .css("float", "left") .unbind('click') .click(function () { $( "a.wpmudevevents-yes-submit, " + "a.wpmudevevents-maybe-submit, " + "a.wpmudevevents-no-submit" ).removeClass("active"); create_login_interface($(this)); return false; }) ; }); })(jQuery);
HSrcWrld/DKWP
wp-content/plugins/events-and-bookings/js/eab-api.js
JavaScript
gpl-2.0
13,507
// UK lang variables tinyMCE.addI18n('en.pastecode',{ paste_code_desc : _('Insert HTML code as text'), paste_code_title : _('Use CTRL+V on your keyboard to paste the code into the window.'), paste_html_desc : _('Paste HTML fragment (embed code)'), paste_html_title : _('Use CTRL+V on your keyboard to paste the code into the window.'), paste_include_wrapper : _('Include wrapper (improves presentation)'), highlight_syntax : _('Highlight syntax'), options : _('Options'), language : _('Markup language'), language_missing : _('Please select a language'), not_defined : _('-- Not Set --'), markup : _('Markup (HTML, etc.)'), c_type : _('C type'), presentation : _('Appearance'), presentation_bright : _('Light'), presentation_dark : _('Dark'), line_numbers : _('Line numbers'), line_highlight : _('Line highlight'), example : _('Example') });
pedropena/iteexe
exe/webui/scripts/tinymce_3.5.11/jscripts/tiny_mce/plugins/pastecode/langs/en.js
JavaScript
gpl-2.0
842
/****************************************************************************/ /* * uclinux.c -- generic memory mapped MTD driver for uclinux * * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com) * * $Id: uclinux.c,v 1.1.1.1 2010/03/11 21:07:58 kris Exp $ */ /****************************************************************************/ #include <linux/module.h> #include <linux/types.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/fs.h> #include <linux/major.h> #include <linux/mtd/mtd.h> #include <linux/mtd/map.h> #include <linux/mtd/partitions.h> #include <asm/io.h> /****************************************************************************/ struct map_info uclinux_ram_map = { .name = "RAM", }; struct mtd_info *uclinux_ram_mtdinfo; /****************************************************************************/ struct mtd_partition uclinux_romfs[] = { { .name = "ROMfs" } }; #define NUM_PARTITIONS ARRAY_SIZE(uclinux_romfs) /****************************************************************************/ int uclinux_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf) { struct map_info *map = mtd->priv; *mtdbuf = (u_char *) (map->virt + ((int) from)); *retlen = len; return(0); } /****************************************************************************/ int __init uclinux_mtd_init(void) { struct mtd_info *mtd; struct map_info *mapp; extern char _ebss; unsigned long addr = (unsigned long) &_ebss; mapp = &uclinux_ram_map; mapp->phys = addr; mapp->size = PAGE_ALIGN(ntohl(*((unsigned long *)(addr + 8)))); mapp->bankwidth = 4; printk("uclinux[mtd]: RAM probe address=0x%x size=0x%x\n", (int) mapp->phys, (int) mapp->size); mapp->virt = ioremap_nocache(mapp->phys, mapp->size); if (mapp->virt == 0) { printk("uclinux[mtd]: ioremap_nocache() failed\n"); return(-EIO); } simple_map_init(mapp); mtd = do_map_probe("map_ram", mapp); if (!mtd) { printk("uclinux[mtd]: failed to find a mapping?\n"); iounmap(mapp->virt); return(-ENXIO); } mtd->owner = THIS_MODULE; mtd->point = uclinux_point; mtd->priv = mapp; uclinux_ram_mtdinfo = mtd; add_mtd_partitions(mtd, uclinux_romfs, NUM_PARTITIONS); return(0); } /****************************************************************************/ void __exit uclinux_mtd_cleanup(void) { if (uclinux_ram_mtdinfo) { del_mtd_partitions(uclinux_ram_mtdinfo); map_destroy(uclinux_ram_mtdinfo); uclinux_ram_mtdinfo = NULL; } if (uclinux_ram_map.virt) { iounmap((void *) uclinux_ram_map.virt); uclinux_ram_map.virt = 0; } } /****************************************************************************/ module_init(uclinux_mtd_init); module_exit(uclinux_mtd_cleanup); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Greg Ungerer <gerg@snapgear.com>"); MODULE_DESCRIPTION("Generic RAM based MTD for uClinux"); /****************************************************************************/
fgoncalves/Modified-TS7500-Kernel
drivers/mtd/maps/uclinux.c
C
gpl-2.0
2,976
run-it ====== Example plugin to run incremental functions from within the plugin and in extensions.
jeffikus/run-it
README.md
Markdown
gpl-2.0
101
SUBROUTINE ZERRBD( PATH, NUNIT ) * * -- LAPACK test routine (version 3.1) -- * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. * November 2006 * * .. Scalar Arguments .. CHARACTER*3 PATH INTEGER NUNIT * .. * * Purpose * ======= * * ZERRBD tests the error exits for ZGEBRD, ZUNGBR, ZUNMBR, and ZBDSQR. * * Arguments * ========= * * PATH (input) CHARACTER*3 * The LAPACK path name for the routines to be tested. * * NUNIT (input) INTEGER * The unit number for output. * * ===================================================================== * * .. Parameters .. INTEGER NMAX, LW PARAMETER ( NMAX = 4, LW = NMAX ) * .. * .. Local Scalars .. CHARACTER*2 C2 INTEGER I, INFO, J, NT * .. * .. Local Arrays .. DOUBLE PRECISION D( NMAX ), E( NMAX ), RW( 4*NMAX ) COMPLEX*16 A( NMAX, NMAX ), TP( NMAX ), TQ( NMAX ), $ U( NMAX, NMAX ), V( NMAX, NMAX ), W( LW ) * .. * .. External Functions .. LOGICAL LSAMEN EXTERNAL LSAMEN * .. * .. External Subroutines .. EXTERNAL CHKXER, ZBDSQR, ZGEBRD, ZUNGBR, ZUNMBR * .. * .. Scalars in Common .. LOGICAL LERR, OK CHARACTER*32 SRNAMT INTEGER INFOT, NOUT * .. * .. Common blocks .. COMMON / INFOC / INFOT, NOUT, OK, LERR COMMON / SRNAMC / SRNAMT * .. * .. Intrinsic Functions .. INTRINSIC DBLE * .. * .. Executable Statements .. * NOUT = NUNIT WRITE( NOUT, FMT = * ) C2 = PATH( 2: 3 ) * * Set the variables to innocuous values. * DO 20 J = 1, NMAX DO 10 I = 1, NMAX A( I, J ) = 1.D0 / DBLE( I+J ) 10 CONTINUE 20 CONTINUE OK = .TRUE. NT = 0 * * Test error exits of the SVD routines. * IF( LSAMEN( 2, C2, 'BD' ) ) THEN * * ZGEBRD * SRNAMT = 'ZGEBRD' INFOT = 1 CALL ZGEBRD( -1, 0, A, 1, D, E, TQ, TP, W, 1, INFO ) CALL CHKXER( 'ZGEBRD', INFOT, NOUT, LERR, OK ) INFOT = 2 CALL ZGEBRD( 0, -1, A, 1, D, E, TQ, TP, W, 1, INFO ) CALL CHKXER( 'ZGEBRD', INFOT, NOUT, LERR, OK ) INFOT = 4 CALL ZGEBRD( 2, 1, A, 1, D, E, TQ, TP, W, 2, INFO ) CALL CHKXER( 'ZGEBRD', INFOT, NOUT, LERR, OK ) INFOT = 10 CALL ZGEBRD( 2, 1, A, 2, D, E, TQ, TP, W, 1, INFO ) CALL CHKXER( 'ZGEBRD', INFOT, NOUT, LERR, OK ) NT = NT + 4 * * ZUNGBR * SRNAMT = 'ZUNGBR' INFOT = 1 CALL ZUNGBR( '/', 0, 0, 0, A, 1, TQ, W, 1, INFO ) CALL CHKXER( 'ZUNGBR', INFOT, NOUT, LERR, OK ) INFOT = 2 CALL ZUNGBR( 'Q', -1, 0, 0, A, 1, TQ, W, 1, INFO ) CALL CHKXER( 'ZUNGBR', INFOT, NOUT, LERR, OK ) INFOT = 3 CALL ZUNGBR( 'Q', 0, -1, 0, A, 1, TQ, W, 1, INFO ) CALL CHKXER( 'ZUNGBR', INFOT, NOUT, LERR, OK ) INFOT = 3 CALL ZUNGBR( 'Q', 0, 1, 0, A, 1, TQ, W, 1, INFO ) CALL CHKXER( 'ZUNGBR', INFOT, NOUT, LERR, OK ) INFOT = 3 CALL ZUNGBR( 'Q', 1, 0, 1, A, 1, TQ, W, 1, INFO ) CALL CHKXER( 'ZUNGBR', INFOT, NOUT, LERR, OK ) INFOT = 3 CALL ZUNGBR( 'P', 1, 0, 0, A, 1, TQ, W, 1, INFO ) CALL CHKXER( 'ZUNGBR', INFOT, NOUT, LERR, OK ) INFOT = 3 CALL ZUNGBR( 'P', 0, 1, 1, A, 1, TQ, W, 1, INFO ) CALL CHKXER( 'ZUNGBR', INFOT, NOUT, LERR, OK ) INFOT = 4 CALL ZUNGBR( 'Q', 0, 0, -1, A, 1, TQ, W, 1, INFO ) CALL CHKXER( 'ZUNGBR', INFOT, NOUT, LERR, OK ) INFOT = 6 CALL ZUNGBR( 'Q', 2, 1, 1, A, 1, TQ, W, 1, INFO ) CALL CHKXER( 'ZUNGBR', INFOT, NOUT, LERR, OK ) INFOT = 9 CALL ZUNGBR( 'Q', 2, 2, 1, A, 2, TQ, W, 1, INFO ) CALL CHKXER( 'ZUNGBR', INFOT, NOUT, LERR, OK ) NT = NT + 10 * * ZUNMBR * SRNAMT = 'ZUNMBR' INFOT = 1 CALL ZUNMBR( '/', 'L', 'T', 0, 0, 0, A, 1, TQ, U, 1, W, 1, $ INFO ) CALL CHKXER( 'ZUNMBR', INFOT, NOUT, LERR, OK ) INFOT = 2 CALL ZUNMBR( 'Q', '/', 'T', 0, 0, 0, A, 1, TQ, U, 1, W, 1, $ INFO ) CALL CHKXER( 'ZUNMBR', INFOT, NOUT, LERR, OK ) INFOT = 3 CALL ZUNMBR( 'Q', 'L', '/', 0, 0, 0, A, 1, TQ, U, 1, W, 1, $ INFO ) CALL CHKXER( 'ZUNMBR', INFOT, NOUT, LERR, OK ) INFOT = 4 CALL ZUNMBR( 'Q', 'L', 'C', -1, 0, 0, A, 1, TQ, U, 1, W, 1, $ INFO ) CALL CHKXER( 'ZUNMBR', INFOT, NOUT, LERR, OK ) INFOT = 5 CALL ZUNMBR( 'Q', 'L', 'C', 0, -1, 0, A, 1, TQ, U, 1, W, 1, $ INFO ) CALL CHKXER( 'ZUNMBR', INFOT, NOUT, LERR, OK ) INFOT = 6 CALL ZUNMBR( 'Q', 'L', 'C', 0, 0, -1, A, 1, TQ, U, 1, W, 1, $ INFO ) CALL CHKXER( 'ZUNMBR', INFOT, NOUT, LERR, OK ) INFOT = 8 CALL ZUNMBR( 'Q', 'L', 'C', 2, 0, 0, A, 1, TQ, U, 2, W, 1, $ INFO ) CALL CHKXER( 'ZUNMBR', INFOT, NOUT, LERR, OK ) INFOT = 8 CALL ZUNMBR( 'Q', 'R', 'C', 0, 2, 0, A, 1, TQ, U, 1, W, 1, $ INFO ) CALL CHKXER( 'ZUNMBR', INFOT, NOUT, LERR, OK ) INFOT = 8 CALL ZUNMBR( 'P', 'L', 'C', 2, 0, 2, A, 1, TQ, U, 2, W, 1, $ INFO ) CALL CHKXER( 'ZUNMBR', INFOT, NOUT, LERR, OK ) INFOT = 8 CALL ZUNMBR( 'P', 'R', 'C', 0, 2, 2, A, 1, TQ, U, 1, W, 1, $ INFO ) CALL CHKXER( 'ZUNMBR', INFOT, NOUT, LERR, OK ) INFOT = 11 CALL ZUNMBR( 'Q', 'R', 'C', 2, 0, 0, A, 1, TQ, U, 1, W, 1, $ INFO ) CALL CHKXER( 'ZUNMBR', INFOT, NOUT, LERR, OK ) INFOT = 13 CALL ZUNMBR( 'Q', 'L', 'C', 0, 2, 0, A, 1, TQ, U, 1, W, 0, $ INFO ) CALL CHKXER( 'ZUNMBR', INFOT, NOUT, LERR, OK ) INFOT = 13 CALL ZUNMBR( 'Q', 'R', 'C', 2, 0, 0, A, 1, TQ, U, 2, W, 0, $ INFO ) CALL CHKXER( 'ZUNMBR', INFOT, NOUT, LERR, OK ) NT = NT + 13 * * ZBDSQR * SRNAMT = 'ZBDSQR' INFOT = 1 CALL ZBDSQR( '/', 0, 0, 0, 0, D, E, V, 1, U, 1, A, 1, RW, $ INFO ) CALL CHKXER( 'ZBDSQR', INFOT, NOUT, LERR, OK ) INFOT = 2 CALL ZBDSQR( 'U', -1, 0, 0, 0, D, E, V, 1, U, 1, A, 1, RW, $ INFO ) CALL CHKXER( 'ZBDSQR', INFOT, NOUT, LERR, OK ) INFOT = 3 CALL ZBDSQR( 'U', 0, -1, 0, 0, D, E, V, 1, U, 1, A, 1, RW, $ INFO ) CALL CHKXER( 'ZBDSQR', INFOT, NOUT, LERR, OK ) INFOT = 4 CALL ZBDSQR( 'U', 0, 0, -1, 0, D, E, V, 1, U, 1, A, 1, RW, $ INFO ) CALL CHKXER( 'ZBDSQR', INFOT, NOUT, LERR, OK ) INFOT = 5 CALL ZBDSQR( 'U', 0, 0, 0, -1, D, E, V, 1, U, 1, A, 1, RW, $ INFO ) CALL CHKXER( 'ZBDSQR', INFOT, NOUT, LERR, OK ) INFOT = 9 CALL ZBDSQR( 'U', 2, 1, 0, 0, D, E, V, 1, U, 1, A, 1, RW, $ INFO ) CALL CHKXER( 'ZBDSQR', INFOT, NOUT, LERR, OK ) INFOT = 11 CALL ZBDSQR( 'U', 0, 0, 2, 0, D, E, V, 1, U, 1, A, 1, RW, $ INFO ) CALL CHKXER( 'ZBDSQR', INFOT, NOUT, LERR, OK ) INFOT = 13 CALL ZBDSQR( 'U', 2, 0, 0, 1, D, E, V, 1, U, 1, A, 1, RW, $ INFO ) CALL CHKXER( 'ZBDSQR', INFOT, NOUT, LERR, OK ) NT = NT + 8 END IF * * Print a summary line. * IF( OK ) THEN WRITE( NOUT, FMT = 9999 )PATH, NT ELSE WRITE( NOUT, FMT = 9998 )PATH END IF * 9999 FORMAT( 1X, A3, ' routines passed the tests of the error exits (', $ I3, ' tests done)' ) 9998 FORMAT( ' *** ', A3, ' routines failed the tests of the error ', $ 'exits ***' ) * RETURN * * End of ZERRBD * END
apollos/Quantum-ESPRESSO
lapack-3.2/TESTING/EIG/zerrbd.f
FORTRAN
gpl-2.0
8,255
package matchers import ( "fmt" "github.com/obieq/goar/db/couchbase/Godeps/_workspace/src/github.com/onsi/gomega/format" "time" ) type BeTemporallyMatcher struct { Comparator string CompareTo time.Time Threshold []time.Duration } func (matcher *BeTemporallyMatcher) FailureMessage(actual interface{}) (message string) { return format.Message(actual, fmt.Sprintf("to be %s", matcher.Comparator), matcher.CompareTo) } func (matcher *BeTemporallyMatcher) NegatedFailureMessage(actual interface{}) (message string) { return format.Message(actual, fmt.Sprintf("not to be %s", matcher.Comparator), matcher.CompareTo) } func (matcher *BeTemporallyMatcher) Match(actual interface{}) (bool, error) { // predicate to test for time.Time type isTime := func(t interface{}) bool { _, ok := t.(time.Time) return ok } if !isTime(actual) { return false, fmt.Errorf("Expected a time.Time. Got:\n%s", format.Object(actual, 1)) } switch matcher.Comparator { case "==", "~", ">", ">=", "<", "<=": default: return false, fmt.Errorf("Unknown comparator: %s", matcher.Comparator) } var threshold = time.Millisecond if len(matcher.Threshold) == 1 { threshold = matcher.Threshold[0] } return matcher.matchTimes(actual.(time.Time), matcher.CompareTo, threshold), nil } func (matcher *BeTemporallyMatcher) matchTimes(actual, compareTo time.Time, threshold time.Duration) (success bool) { switch matcher.Comparator { case "==": return actual.Equal(compareTo) case "~": diff := actual.Sub(compareTo) return -threshold <= diff && diff <= threshold case ">": return actual.After(compareTo) case ">=": return !actual.Before(compareTo) case "<": return actual.Before(compareTo) case "<=": return !actual.After(compareTo) } return false }
obieq/goar
db/couchbase/Godeps/_workspace/src/github.com/onsi/gomega/matchers/be_temporally_matcher.go
GO
gpl-2.0
1,772
/* This is the style sheet used when Gallery running standalone and 'bars002' is selected. If you would like to customize the styles please create copy of this file called "screen.css" (same name without ".default") If that file is found in this directory it will be used instead of this one. Some of the styles below are overriden by specific album properties. These are noted $Id$ */ /* default text styles - background and colors overriden by album 'bgcolor', 'background', and 'textcolor' properties. */ BODY { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; color:#404040; font-weight:bold; background-image: url(../images/background9.jpg); background-color: #ffffff; margin-top: 0px; margin-left: 0px; margin-right: 0px; } TD, P { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; } /* link colors - overridden by the album 'linkcolor' property. */ A { color: #404040; text-decoration: none; } A:link { color: #404040; text-decoration: none; } A:visited { color: #404040; text-decoration: none; } A:active { color: #404040; } A:hover { color: #202020; } /* text styles */ .menu /* Side menu text only */ { line-height:140%; padding-right:3px; padding-left:5px; padding_bottom:10px; } .menu a, .menu a:link, .menu a:visited, .menu a:active { font-family:verdana, arial, sans-serif; color:#404040; font-size:9pt; font-weight:400; text-decoration: none; text-align: center; } .menu a:hover { color: #381212; text-decoration: none; } .onnav2 /* side menu background */ { background-color: #c0c0c0; height:31px; width:138px; border-bottom: 2px groove #606060; border-top: 2px groove #404040; border-left: 3px solid #00000; border-right: 1px solid #707070; } .offnav2 /* side menu background */ { background-color: #BFBFBF; border-bottom: 3px groove #c0c0c0; border-left: 3px groove #00000; height:31px; width:138px; } .jd_mainheader /* skin header */ { background-image: url(../images/gallery9.jpg); background-repeat:no-repeat; width: 272px; height: 75px; } .jd_head_left { background-image: url(../images/headbg9.jpg); } .jd_title_right { padding-right: 15px; } .jd_title_left { background-image: url(../images/navbg9.jpg); } .title /* album titles on main page */ { line-height:140%; padding-right:2px; padding-left:3px; } .title a, .title a:link, .title a:visited, .title a:active { font-family:verdana, arial, sans-serif; color:#000000; font-size:x-small; font-weight:bold; text-decoration: none; } .title a:hover { color: #900000; text-decoration: none; } .mod_title /* album title Text is controled by .title */ { background-image: url(../images/titlehead9.jpg); width: 100%; height: 28px; } .mod_title_bg /* album title hightlight Text is controled by .title */ { } .mod_title_right /* album title hightlight Text is controled by .title*/ { } .mod_title_left /* album title hightlight Text is controled by .title */ { } .albumdesc /*album description includes all text and background*/ { font-family:verdana, arial, sans-serif; color:#404040; font-size:x-small; font-weight:bold; background-color: #BFBFBF; line-height:140%; padding:2px; margin-top:2px; border:1px solid #404040; width: 80%; height: 184px; } .desc /* album descriptions on main page just description and author*/ { font-family:verdana, arial, sans-serif; color:#404040; font-size:x-small; font-weight:bold; line-height:140%; padding:2px; margin-top:2px; } .caption /* photo captions on all pages */ { font-size: 10px; } .modcaption /* modifies background & caption text on album view */ { font-family:verdana, arial, sans-serif; color: #404040; font-size: 10px; font-weight:bold; text-align: center; line-height:140%; padding:2px; margin-top:2px; border:0px dashed #404040; } .pview /* surrounds all info under photo view */ { font-family:verdana, arial, sans-serif; color: #404040; font-size: 10px; font-weight:bold; line-height:140%; background-color: #BFBFBF; border:1px solid #404040; } .pcaption /* modifies background & caption text on photo view */ { font-family:verdana, arial, sans-serif; color: #404040; font-size: 10px; font-weight:bold; line-height:140%; padding:2px; margin-top:2px; background-color: #BFBFBF; border:1px solid #404040; } .error /* all error text */ { color: red; font-size: 12px; } .attention /*voting instructions */ { } .headbox /* box around the page headers */ { } .head /* page headers behind the Gallery title*/ { font-family:verdana, arial, sans-serif; color:#404040; font-size: 16px; font-weight:bold; padding-left:2px; padding-right:2px; line-height:140%; border:0px dashed #404040; height: 28px; } .mod_headliner /* Gallery & Album titles. Text is controled by .head */ { } .mod_toplight_bg /* Gallery & Album titles. Text is controled by .head */ { } .mod_toplight_right /* Gallery & Album titles. Text is controled by .head*/ { } .leftspacer /* amount of space to the left of the header and titles */ { width: 50px; } .mod_toplight_left /* Gallery & Album titles. Text is controled by .head */ { } .bread /* used in breadcrumb bars */ { font-size: 10px; } .nav /* used in navigation bars */ { font-size: 12px; } .bordertop { } .borderright { } .borderleft { } .fineprint /* used for fine print */ { font-size: 10px; } .popupbody { margin: 25px; background-color: #808080; } .popuphead { font-size: 14px; font-weight: bold; line-height: 150%; color: #202020; padding-left: 5px; border-top: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; background-color: #c0c0c0; } .popup { font-size: 12px; font-weight: normal; color: #202020; padding: 5px; border: 1px solid #000000; background-color: #ffffff; margin-bottom: 10px; } .popupform { font-size: 12px; font-weight: normal; line-height: 120%; color: #202020; padding: 2px; border: 1px solid #000000; background-color: #c0c0c0; } .vapoll { border: 1px solid #404040; background-color: #BFBFBF; padding: 7px; } .vathumbs /* full background bracket for images and text - veiw albums */ { border: 1px solid #404040; background-color: #BFBFBF; padding: 7px; } .vatable /* width of the div set for all photo sets - view albums */ { width: 100%; } .vafloat /* float for view album - text */ { float: left; padding: 5px; } .vafloat2 /* float for view album - images */ { padding: 5px; float: left; } .editlink, /* Used for the [edit] tags */ .editlink a, .editlink a:link, .editlink a:visited, .editlink a:active { font-size: 10px; font-weight: normal; color: #404040; } .modnavbox /* main navigation bar next and previous */ { font-family:verdana, arial, sans-serif; color:#404040; font-size: 12px; font-weight:bold; line-height:140%; } .modnavbox a, .modnavbox a:link, .modnavbox a:visited, .modnavbox a:active { font-weight: normal; color:#404040; text-decoration: none; } .modnavbox a:hover { font-weight: normal; color: #900000; text-decoration: underline; } .admin { font-size: 10px; font-weight: bold; color: #404040; } .adminform { font-size: 10px; font-weight: bold; color: #404040 ; } .search /* used in admin bars - the search text*/ { font-size: 10px; color: #404040; font-weight: bold; } .modnavboxtop /*navagation bar top of screen where admin buttons show*/ { font-family:verdana, arial, sans-serif; color: #404040; font-size: 10px; font-weight:bold; background-color: #BFBFBF; line-height:140%; border:0px dashed #404040; width: 100% } .modnavboxtop a, .modnavboxtop a:link, .modnavboxtop a:visited, .modnavboxtop a:active { font-weight: normal; color: #404040; text-decoration: none; } .modnavboxtop a:hover { font-weight: normal; color: #900000; text-decoration: none; } .modnavboxmid /*navagation bar middle where the link for the albums show*/ { font-family:verdana, arial, sans-serif; color: #404040; font-size: 10px; font-weight:bold; background-color: #BFBFBF; line-height:140%; border:0px dashed #404040; width: 100% } .modnavboxmid a, .modnavboxmid a:link, .modnavboxmid a:visited, .modnavboxmid a:active { font-weight: normal; color:#404040; text-decoration: none; } .modnavboxmid a:hover { font-weight: normal; color: #900000; text-decoration: underline; } .modfooter /*footer where the Gallery version is located*/ { font-family:verdana, arial, sans-serif; color:#404040; font-size: 8px; font-weight:normal; line-height:140%; padding:2px; border:0px dashed #404040; width:100% } .modfooter a, .modfooter a:link, .modfooter a:visited, .modfooter a:active { color:#ffffff; text-decoration: none; } .modfooter a:hover { color: #900000; text-decoration: none; } #adminbox { background-color: #c0c0c0; } #adminbox td { background-color: #c0c0c0; padding: 2px; }
jmullan/Gallery1
skins/madmod1/css/screen.css
CSS
gpl-2.0
9,356
package Moose::Exception::DoesRequiresRoleName; our $VERSION = '2.1603'; use Moose; extends 'Moose::Exception'; with 'Moose::Exception::Role::Class'; sub _build_message { "You must supply a role name to does()"; } 1;
mishin/dwimperl-windows
strawberry-perl-5.20.0.1-32bit-portable/perl/site/lib/Moose/Exception/DoesRequiresRoleName.pm
Perl
gpl-2.0
224
#download-selector {padding: .5em; border: 1px solid #ddd; display: block; height: 50px;} #download-selector > span { font-weight: bold; position: relative; top: .5em; } #download-selector > * { float: left; } #download-selector ul { list-style-type: none; } #download-selector li { display: block; width: 8em; padding: 0 2em; } #download-selector li span { display: block; text-align: center; } #download-selector a { display: block; float: left; } .container { clear: both; padding: 1em 0; } img.view { float: left; clear:left; padding: 3px; border: 1px solid #8abb46; margin-right: 1em; margin-bottom: 1em;} .container .description p { margin: .5em 0; line-height: 1.1; font-size: 0.9em; } .container .description p:first-child { margin-top: 0; } .fields { font-size: .9em; } .fields dt { float: left; font-weight: bold; width: 7em; } #asset_title { font-weight: bold; font-size: 1.3em; padding-left: 20px; display: block; width: 100%; height: 2em;} #asset_title .show {padding: 1px 1px 2px 2px; display: block; border: 1px solid #fff; margin-bottom: .5em;} #asset_title input { font-size: 1em; font-weight: bold; width: 30em; margin-bottom: .5em; } #asset_title .throbber { display: absolute; left: 0; top: 0; } .actions { margin-top: 2em; } .action a { display: block; } .asset_description {float: left; width: 300px; font-size: 11px;} .description .show {} .description .edit {} .fields {clear: both;} .fields dd ul { list-style-type: none; }
xlsuite/xlsuite
public/stylesheets/assets/show.css
CSS
gpl-2.0
1,494
package sk.hackcraft.als.utils; import java.util.NoSuchElementException; import java.util.Set; /** * Interface representing configuration, divided by sections containing key * value pairs. */ public interface Config { /** * Check section availability. * * @param section name of section * @return true if section exists, false otherwise */ boolean hasSection(String section); /** * Returns section. * * @param section name of section * @return requested section * @throws NoSuchElementException if section doesn't exists */ Section getSection(String section); /** * Returns all sections. * * @return all sections */ Set<? extends Section> getAllSections(); /** * Interface representing configuration section. */ interface Section { /** * Gets section name. * * @return section name */ String getName(); /** * Check if section contains pair with specified key. * * @param key specified key * @return true if section contains pair with specified key, false * otherwise */ boolean hasPair(String key); /** * Gets specified pair. * * @param key pair key * @return specified pair */ Pair getPair(String key); /** * Returns all pairs. * * @return all pairs */ Set<? extends Pair> getAllPairs(); } /** * Interface representing configuration key value pair. */ interface Pair { /** * Gets pair key. * * @return pair key */ String getKey(); /** * Gets pair value as string. * * @return value as string */ String getStringValue(); /** * Gets pair value as array of strings. Delimiter for parsing value is * ','. Whitespaces before and after each value are trimmed. * * @return value as array of strings */ String[] getStringValueAsArray(); /** * Gets pair value as int. * * @return value as int * @throws NumberFormatException if it's not possible to convert value to int */ int getIntValue(); /** * Gets pair value as boolean * * @return value as boolean */ boolean getBooleanValue(); /** * Gets pair value as double. * * @return value as double * @throws NumberFormatException if it's not possible to convert value to double */ double getDoubleValue(); } }
hackcraft-sk/swarm
utils/src/sk/hackcraft/als/utils/Config.java
Java
gpl-2.0
2,786
@import url(http://fonts.googleapis.com/css?family=Exo+2:600&subset=latin,cyrillic); .header { width: 100%; background: white; margin: 0 auto; background: #fffced; } .header h1{ width: 1000px; margin: 0 auto; text-align: center; margin-top:5px; padding-top:20px; padding-bottom:20px; } #main h1{ width: 1000px; margin: 0 auto; text-align: center; margin-top:5px; padding-top:20px; padding-bottom:20px; }
Artenka/DressRoom
wp-content/themes/DressRoom/css/header.css
CSS
gpl-2.0
460
/* * Copyright (C) 1996-2015 The Squid Software Foundation and contributors * * Squid software is distributed under GPLv2+ license and includes * contributions from numerous individuals and organizations. * Please see the COPYING and CONTRIBUTORS files for details. */ /* NT_auth - Version 2.0 Modified to act as a Squid authenticator module. Returns OK for a successful authentication, or ERR upon error. Guido Serassio, Torino - Italy Uses code from - Antonino Iannella 2000 Andrew Tridgell 1997 Richard Sharpe 1996 Bill Welliver 1999 * Distributed freely under the terms of the GNU General Public License, * version 2 or later. See the file COPYING for licensing details * * 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, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. */ #ifndef _VALID_H_ #define _VALID_H_ #include "sspwin32.h" #if HAVE_WINDOWS_H #include <windows.h> #endif #include <lm.h> #include <sys/types.h> #undef debug /************* CONFIGURATION ***************/ /* SMB User verification function */ #define NTV_NO_ERROR 0 #define NTV_SERVER_ERROR 1 #define NTV_GROUP_ERROR 2 #define NTV_LOGON_ERROR 3 #ifndef LOGON32_LOGON_NETWORK #define LOGON32_LOGON_NETWORK 3 #endif #define NTV_DEFAULT_DOMAIN "." extern char * NTAllowedGroup; extern char * NTDisAllowedGroup; extern int UseDisallowedGroup; extern int UseAllowedGroup; extern int debug_enabled; extern char Default_NTDomain[DNLEN+1]; extern const char * errormsg; /** * Valid_User return codes. * * \retval 0 User authenticated successfully. * \retval 1 Server error. * \retval 2 Group membership error. * \retval 3 Logon error; Incorrect password or username given. */ int Valid_User(char *UserName, char *Password, char *Group); /* Debugging stuff */ #if defined(__GNUC__) /* this is really a gcc-ism */ #include <unistd.h> static char *__foo; #define debug(X...) if (debug_enabled) { \ fprintf(stderr,"nt_auth[%d](%s:%d): ", getpid(), \ ((__foo=strrchr(__FILE__,'/'))==NULL?__FILE__:__foo+1),\ __LINE__);\ fprintf(stderr,X); } #else /* __GNUC__ */ static void debug(char *format,...) { if (debug_enabled) { va_list args; va_start(args,format); fprintf(stderr, "nt_auth[%d]: ",getpid()); vfprintf(stderr, format, args); va_end(args); } } #endif /* __GNUC__ */ #endif
krichter722/squid
helpers/basic_auth/SSPI/valid.h
C
gpl-2.0
2,807
from triple_draw_poker.model.Pot import Pot class HandDetails: def __init__(self): self.pot = Pot() self.raised = 0 self.street = 0 self.number_of_streets = 4 self.in_draw = False self.hands = [] self.dealt_cards_index = 0 def getDealtCardsIndex(self): return dealt_cards_index def getHands(self): return self.hands def getPot(self): return self.pot def getRaised(self): return self.raised def getStreet(self): return self.street def getStreetPremium(self): if self.street < 3: return 2 return 1 def getNumberOfStreets(self): return self.number_of_streets def getInDraw(self): return self.in_draw def setDealtCardsIndex(self, index): self.dealt_cards_index = index def addHand(self, hand): self.hands.append(hand) def incrementRaised(self): self.raised += 1 def incrementStreet(self): self.street += 1 def changeInDraw(self): self.in_draw = not self.in_draw
zmetcalf/Triple-Draw-Deuce-to-Seven-Lowball-Limit
triple_draw_poker/model/HandDetails.py
Python
gpl-2.0
1,109
<?php /** * @package AcyMailing for Joomla! * @version 4.5.0 * @author acyba.com * @copyright (C) 2009-2013 ACYBA S.A.R.L. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?><div id="acy_content"> <div id="iframedoc"></div> <form action="index.php?tmpl=component&amp;option=<?php echo ACYMAILING_COMPONENT ?>" method="post" name="adminForm" id="adminForm" autocomplete="off" enctype="multipart/form-data"> <fieldset class="acyheaderarea"> <div class="acyheader icon-48-newsletter" style="float: left;"><?php echo JText::_('EMAIL_NAME').' : '.$this->mail->subject; ?></div> <div class="toolbar" id="toolbar" style="float: right;"> <table><tr> <td><a onclick="displayTemplates(); return false;" href="#" ><span class="icon-32-acytemplate" title="<?php echo JText::_('ACY_TEMPLATES',true); ?>"></span><?php echo JText::_('ACY_TEMPLATES'); ?></a></td> <td><a onclick="try{IeCursorFix();}catch(e){}; displayTags(); return false;" href="#" ><span class="icon-32-tag" title="<?php echo JText::_('TAGS',true); ?>"></span><?php echo JText::_('TAGS'); ?></a></td> <td><span class="divider"></span></td> <td><a onclick="javascript:submitbutton('test'); return false;" href="#" ><span class="icon-32-acysend" title="<?php echo JText::_('SEND_TEST',true); ?>"></span><?php echo JText::_('SEND_TEST'); ?></a></td> <td><a onclick="javascript:submitbutton('apply'); return false;" href="#" ><span class="icon-32-save" title="<?php echo JText::_('ACY_SAVE',true); ?>"></span><?php echo JText::_('ACY_SAVE'); ?></a></td> </tr></table> </div> </fieldset> <div id="iframetemplate"></div><div id="iframetag"></div> <?php include(dirname(__FILE__).DS.'param.'.basename(__FILE__)); ?> <br/> <fieldset class="adminform" style="width:90%" id="htmlfieldset"> <legend><?php echo JText::_( 'HTML_VERSION' ); ?></legend> <?php echo $this->editor->display(); ?> </fieldset> <fieldset class="adminform" style="width:90%" id="textfieldset"> <legend><?php echo JText::_( 'TEXT_VERSION' ); ?></legend> <textarea style="width:98%" rows="20" name="data[mail][altbody]" id="altbody" placeholder="<?php echo JText::_('AUTO_GENERATED_HTML'); ?>" ><?php echo @$this->mail->altbody; ?></textarea> </fieldset> <div class="clr"></div> <input type="hidden" name="cid[]" value="<?php echo @$this->mail->mailid; ?>" /> <?php if(!empty($this->mail->type)){ ?> <input type="hidden" name="data[mail][type]" value="<?php echo $this->mail->type; ?>" /> <?php } ?> <input type="hidden" id="tempid" name="data[mail][tempid]" value="<?php echo @$this->mail->tempid; ?>" /> <input type="hidden" name="option" value="<?php echo ACYMAILING_COMPONENT; ?>" /> <input type="hidden" name="task" value="" /> <input type="hidden" name="ctrl" value="email" /> <?php echo JHTML::_( 'form.token' ); ?> </form> </div>
QuyICDAC/icdacgov
administrator/components/com_acymailing/views/email/tmpl/form.php
PHP
gpl-2.0
2,957
/* * The 3D Studio File Format Library * Copyright (C) 1996-2001 by J.E. Hoffmann <je-h@gmx.net> * All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 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 Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: mesh.c 1651 2004-05-31 08:01:30Z andi75 $ */ #define LIB3DS_EXPORT #include <lib3ds/mesh.h> #include <lib3ds/io.h> #include <lib3ds/chunk.h> #include <lib3ds/vector.h> #include <lib3ds/matrix.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <config.h> #ifdef WITH_DMALLOC #include <dmalloc.h> #endif /*! * \defgroup mesh Meshes * * \author J.E. Hoffmann <je-h@gmx.net> */ static Lib3dsBool face_array_read(Lib3dsMesh *mesh, Lib3dsIo *io) { Lib3dsChunk c; Lib3dsWord chunk; int i; int faces; if (!lib3ds_chunk_read_start(&c, LIB3DS_FACE_ARRAY, io)) { return(LIB3DS_FALSE); } lib3ds_mesh_free_face_list(mesh); faces=lib3ds_io_read_word(io); if (faces) { if (!lib3ds_mesh_new_face_list(mesh, faces)) { LIB3DS_ERROR_LOG; return(LIB3DS_FALSE); } for (i=0; i<faces; ++i) { strcpy(mesh->faceL[i].material, ""); mesh->faceL[i].points[0]=lib3ds_io_read_word(io); mesh->faceL[i].points[1]=lib3ds_io_read_word(io); mesh->faceL[i].points[2]=lib3ds_io_read_word(io); mesh->faceL[i].flags=lib3ds_io_read_word(io); } lib3ds_chunk_read_tell(&c, io); while ((chunk=lib3ds_chunk_read_next(&c, io))!=0) { switch (chunk) { case LIB3DS_SMOOTH_GROUP: { unsigned i; for (i=0; i<mesh->faces; ++i) { mesh->faceL[i].smoothing=lib3ds_io_read_dword(io); } } break; case LIB3DS_MSH_MAT_GROUP: { char name[64]; unsigned faces; unsigned i; unsigned index; if (!lib3ds_io_read_string(io, name, 64)) { return(LIB3DS_FALSE); } faces=lib3ds_io_read_word(io); for (i=0; i<faces; ++i) { index=lib3ds_io_read_word(io); ASSERT(index<mesh->faces); strcpy(mesh->faceL[index].material, name); } } break; case LIB3DS_MSH_BOXMAP: { char name[64]; if (!lib3ds_io_read_string(io, name, 64)) { return(LIB3DS_FALSE); } strcpy(mesh->box_map.front, name); if (!lib3ds_io_read_string(io, name, 64)) { return(LIB3DS_FALSE); } strcpy(mesh->box_map.back, name); if (!lib3ds_io_read_string(io, name, 64)) { return(LIB3DS_FALSE); } strcpy(mesh->box_map.left, name); if (!lib3ds_io_read_string(io, name, 64)) { return(LIB3DS_FALSE); } strcpy(mesh->box_map.right, name); if (!lib3ds_io_read_string(io, name, 64)) { return(LIB3DS_FALSE); } strcpy(mesh->box_map.top, name); if (!lib3ds_io_read_string(io, name, 64)) { return(LIB3DS_FALSE); } strcpy(mesh->box_map.bottom, name); } break; default: lib3ds_chunk_unknown(chunk); } } } lib3ds_chunk_read_end(&c, io); return(LIB3DS_TRUE); } /*! * \ingroup mesh */ Lib3dsMesh* lib3ds_mesh_new(const char *name) { Lib3dsMesh *mesh; ASSERT(name); ASSERT(strlen(name)<64); mesh=(Lib3dsMesh*)calloc(sizeof(Lib3dsMesh), 1); if (!mesh) { return(0); } strcpy(mesh->name, name); lib3ds_matrix_identity(mesh->matrix); mesh->map_data.maptype=LIB3DS_MAP_NONE; return(mesh); } /*! * \ingroup mesh */ void lib3ds_mesh_free(Lib3dsMesh *mesh) { lib3ds_mesh_free_point_list(mesh); lib3ds_mesh_free_flag_list(mesh); lib3ds_mesh_free_texel_list(mesh); lib3ds_mesh_free_face_list(mesh); memset(mesh, 0, sizeof(Lib3dsMesh)); free(mesh); } /*! * \ingroup mesh */ Lib3dsBool lib3ds_mesh_new_point_list(Lib3dsMesh *mesh, Lib3dsDword points) { ASSERT(mesh); if (mesh->pointL) { ASSERT(mesh->points); lib3ds_mesh_free_point_list(mesh); } ASSERT(!mesh->pointL && !mesh->points); mesh->points=0; mesh->pointL=calloc(sizeof(Lib3dsPoint)*points,1); if (!mesh->pointL) { LIB3DS_ERROR_LOG; return(LIB3DS_FALSE); } mesh->points=points; return(LIB3DS_TRUE); } /*! * \ingroup mesh */ void lib3ds_mesh_free_point_list(Lib3dsMesh *mesh) { ASSERT(mesh); if (mesh->pointL) { ASSERT(mesh->points); free(mesh->pointL); mesh->pointL=0; mesh->points=0; } else { ASSERT(!mesh->points); } } /*! * \ingroup mesh */ Lib3dsBool lib3ds_mesh_new_flag_list(Lib3dsMesh *mesh, Lib3dsDword flags) { ASSERT(mesh); if (mesh->flagL) { ASSERT(mesh->flags); lib3ds_mesh_free_flag_list(mesh); } ASSERT(!mesh->flagL && !mesh->flags); mesh->flags=0; mesh->flagL=calloc(sizeof(Lib3dsWord)*flags,1); if (!mesh->flagL) { LIB3DS_ERROR_LOG; return(LIB3DS_FALSE); } mesh->flags=flags; return(LIB3DS_TRUE); } /*! * \ingroup mesh */ void lib3ds_mesh_free_flag_list(Lib3dsMesh *mesh) { ASSERT(mesh); if (mesh->flagL) { ASSERT(mesh->flags); free(mesh->flagL); mesh->flagL=0; mesh->flags=0; } else { ASSERT(!mesh->flags); } } /*! * \ingroup mesh */ Lib3dsBool lib3ds_mesh_new_texel_list(Lib3dsMesh *mesh, Lib3dsDword texels) { ASSERT(mesh); if (mesh->texelL) { ASSERT(mesh->texels); lib3ds_mesh_free_texel_list(mesh); } ASSERT(!mesh->texelL && !mesh->texels); mesh->texels=0; mesh->texelL=calloc(sizeof(Lib3dsTexel)*texels,1); if (!mesh->texelL) { LIB3DS_ERROR_LOG; return(LIB3DS_FALSE); } mesh->texels=texels; return(LIB3DS_TRUE); } /*! * \ingroup mesh */ void lib3ds_mesh_free_texel_list(Lib3dsMesh *mesh) { ASSERT(mesh); if (mesh->texelL) { ASSERT(mesh->texels); free(mesh->texelL); mesh->texelL=0; mesh->texels=0; } else { ASSERT(!mesh->texels); } } /*! * \ingroup mesh */ Lib3dsBool lib3ds_mesh_new_face_list(Lib3dsMesh *mesh, Lib3dsDword faces) { ASSERT(mesh); if (mesh->faceL) { ASSERT(mesh->faces); lib3ds_mesh_free_face_list(mesh); } ASSERT(!mesh->faceL && !mesh->faces); mesh->faces=0; mesh->faceL=calloc(sizeof(Lib3dsFace)*faces,1); if (!mesh->faceL) { LIB3DS_ERROR_LOG; return(LIB3DS_FALSE); } mesh->faces=faces; return(LIB3DS_TRUE); } /*! * \ingroup mesh */ void lib3ds_mesh_free_face_list(Lib3dsMesh *mesh) { ASSERT(mesh); if (mesh->faceL) { ASSERT(mesh->faces); free(mesh->faceL); mesh->faceL=0; mesh->faces=0; } else { ASSERT(!mesh->faces); } } typedef struct _Lib3dsFaces Lib3dsFaces; struct _Lib3dsFaces { Lib3dsFaces *next; Lib3dsFace *face; }; /*! * \ingroup mesh */ void lib3ds_mesh_bounding_box(Lib3dsMesh *mesh, Lib3dsVector min, Lib3dsVector max) { unsigned i,j; Lib3dsFloat v; if (!mesh->points) { lib3ds_vector_zero(min); lib3ds_vector_zero(max); return; } lib3ds_vector_copy(min, mesh->pointL[0].pos); lib3ds_vector_copy(max, mesh->pointL[0].pos); for (i=1; i<mesh->points; ++i) { for (j=0; j<3; ++j) { v=mesh->pointL[i].pos[j]; if (v<min[j]) { min[j]=v; } if (v>max[j]) { max[j]=v; } } }; } /*! * Calculates the vertex normals corresponding to the smoothing group * settings for each face of a mesh. * * \param mesh A pointer to the mesh to calculate the normals for. * \param normalL A pointer to a buffer to store the calculated * normals. The buffer must have the size: * 3*sizeof(Lib3dsVector)*mesh->faces. * * To allocate the normal buffer do for example the following: * \code * Lib3dsVector *normalL = malloc(3*sizeof(Lib3dsVector)*mesh->faces); * \endcode * * To access the normal of the i-th vertex of the j-th face do the * following: * \code * normalL[3*j+i] * \endcode */ void lib3ds_mesh_calculate_normals(Lib3dsMesh *mesh, Lib3dsVector *normalL) { Lib3dsFaces **fl; Lib3dsFaces *fa; unsigned i,j,k; if (!mesh->faces) { return; } fl=calloc(sizeof(Lib3dsFaces*),mesh->points); ASSERT(fl); fa=calloc(sizeof(Lib3dsFaces),3*mesh->faces); ASSERT(fa); k=0; for (i=0; i<mesh->faces; ++i) { Lib3dsFace *f=&mesh->faceL[i]; for (j=0; j<3; ++j) { Lib3dsFaces* l=&fa[k++]; ASSERT(f->points[j]<mesh->points); l->face=f; l->next=fl[f->points[j]]; fl[f->points[j]]=l; } } for (i=0; i<mesh->faces; ++i) { Lib3dsFace *f=&mesh->faceL[i]; for (j=0; j<3; ++j) { // FIXME: static array needs at least check!! Lib3dsVector n,N[64]; Lib3dsFaces *p; int k,l; int found; ASSERT(f->points[j]<mesh->points); if (f->smoothing) { lib3ds_vector_zero(n); k=0; for (p=fl[f->points[j]]; p; p=p->next) { found=0; for (l=0; l<k; ++l) { if (fabs(lib3ds_vector_dot(N[l], p->face->normal)-1.0)<1e-5) { found=1; break; } } if (!found) { if (f->smoothing & p->face->smoothing) { lib3ds_vector_add(n,n, p->face->normal); lib3ds_vector_copy(N[k], p->face->normal); ++k; } } } } else { lib3ds_vector_copy(n, f->normal); } lib3ds_vector_normalize(n); lib3ds_vector_copy(normalL[3*i+j], n); } } free(fa); free(fl); } /*! * This function prints data associated with the specified mesh such as * vertex and point lists. * * \param mesh Points to a mesh that you wish to view the data for. * * \return None * * \warning WIN32: Should only be used in a console window not in a GUI. * * \ingroup mesh */ void lib3ds_mesh_dump(Lib3dsMesh *mesh) { unsigned i; Lib3dsVector p; ASSERT(mesh); printf(" %s vertices=%ld faces=%ld\n", mesh->name, mesh->points, mesh->faces ); printf(" matrix:\n"); lib3ds_matrix_dump(mesh->matrix); printf(" point list:\n"); for (i=0; i<mesh->points; ++i) { lib3ds_vector_copy(p, mesh->pointL[i].pos); printf (" %8f %8f %8f\n", p[0], p[1], p[2]); } printf(" facelist:\n"); for (i=0; i<mesh->faces; ++i) { printf (" %4d %4d %4d smoothing:%X\n", mesh->faceL[i].points[0], mesh->faceL[i].points[1], mesh->faceL[i].points[2], (unsigned)mesh->faceL[i].smoothing ); } } /*! * \ingroup mesh */ Lib3dsBool lib3ds_mesh_read(Lib3dsMesh *mesh, Lib3dsIo *io) { Lib3dsChunk c; Lib3dsWord chunk; if (!lib3ds_chunk_read_start(&c, LIB3DS_N_TRI_OBJECT, io)) { return(LIB3DS_FALSE); } while ((chunk=lib3ds_chunk_read_next(&c, io))!=0) { switch (chunk) { case LIB3DS_MESH_MATRIX: { int i,j; lib3ds_matrix_identity(mesh->matrix); for (i=0; i<4; i++) { for (j=0; j<3; j++) { mesh->matrix[i][j]=lib3ds_io_read_float(io); } } } break; case LIB3DS_MESH_COLOR: { mesh->color=lib3ds_io_read_byte(io); } break; case LIB3DS_POINT_ARRAY: { unsigned i,j; unsigned points; lib3ds_mesh_free_point_list(mesh); points=lib3ds_io_read_word(io); if (points) { if (!lib3ds_mesh_new_point_list(mesh, points)) { LIB3DS_ERROR_LOG; return(LIB3DS_FALSE); } for (i=0; i<mesh->points; ++i) { for (j=0; j<3; ++j) { mesh->pointL[i].pos[j]=lib3ds_io_read_float(io); } } ASSERT((!mesh->flags) || (mesh->points==mesh->flags)); ASSERT((!mesh->texels) || (mesh->points==mesh->texels)); } } break; case LIB3DS_POINT_FLAG_ARRAY: { unsigned i; unsigned flags; lib3ds_mesh_free_flag_list(mesh); flags=lib3ds_io_read_word(io); if (flags) { if (!lib3ds_mesh_new_flag_list(mesh, flags)) { LIB3DS_ERROR_LOG; return(LIB3DS_FALSE); } for (i=0; i<mesh->flags; ++i) { mesh->flagL[i]=lib3ds_io_read_word(io); } ASSERT((!mesh->points) || (mesh->flags==mesh->points)); ASSERT((!mesh->texels) || (mesh->flags==mesh->texels)); } } break; case LIB3DS_FACE_ARRAY: { lib3ds_chunk_read_reset(&c, io); if (!face_array_read(mesh, io)) { return(LIB3DS_FALSE); } } break; case LIB3DS_MESH_TEXTURE_INFO: { int i,j; for (i=0; i<2; ++i) { mesh->map_data.tile[i]=lib3ds_io_read_float(io); } for (i=0; i<3; ++i) { mesh->map_data.pos[i]=lib3ds_io_read_float(io); } mesh->map_data.scale=lib3ds_io_read_float(io); lib3ds_matrix_identity(mesh->map_data.matrix); for (i=0; i<4; i++) { for (j=0; j<3; j++) { mesh->map_data.matrix[i][j]=lib3ds_io_read_float(io); } } for (i=0; i<2; ++i) { mesh->map_data.planar_size[i]=lib3ds_io_read_float(io); } mesh->map_data.cylinder_height=lib3ds_io_read_float(io); } break; case LIB3DS_TEX_VERTS: { unsigned i; unsigned texels; lib3ds_mesh_free_texel_list(mesh); texels=lib3ds_io_read_word(io); if (texels) { if (!lib3ds_mesh_new_texel_list(mesh, texels)) { LIB3DS_ERROR_LOG; return(LIB3DS_FALSE); } for (i=0; i<mesh->texels; ++i) { mesh->texelL[i][0]=lib3ds_io_read_float(io); mesh->texelL[i][1]=lib3ds_io_read_float(io); } ASSERT((!mesh->points) || (mesh->texels==mesh->points)); ASSERT((!mesh->flags) || (mesh->texels==mesh->flags)); } } break; default: lib3ds_chunk_unknown(chunk); } } { unsigned j; for (j=0; j<mesh->faces; ++j) { ASSERT(mesh->faceL[j].points[0]<mesh->points); ASSERT(mesh->faceL[j].points[1]<mesh->points); ASSERT(mesh->faceL[j].points[2]<mesh->points); lib3ds_vector_normal( mesh->faceL[j].normal, mesh->pointL[mesh->faceL[j].points[0]].pos, mesh->pointL[mesh->faceL[j].points[1]].pos, mesh->pointL[mesh->faceL[j].points[2]].pos ); } } lib3ds_chunk_read_end(&c, io); return(LIB3DS_TRUE); } static Lib3dsBool point_array_write(Lib3dsMesh *mesh, Lib3dsIo *io) { Lib3dsChunk c; unsigned i; if (!mesh->points || !mesh->pointL) { return(LIB3DS_TRUE); } ASSERT(mesh->points<0x10000); c.chunk=LIB3DS_POINT_ARRAY; c.size=8+12*mesh->points; lib3ds_chunk_write(&c, io); lib3ds_io_write_word(io, (Lib3dsWord)mesh->points); for (i=0; i<mesh->points; ++i) { lib3ds_io_write_vector(io, mesh->pointL[i].pos); } return(LIB3DS_TRUE); } static Lib3dsBool flag_array_write(Lib3dsMesh *mesh, Lib3dsIo *io) { Lib3dsChunk c; unsigned i; if (!mesh->flags || !mesh->flagL) { return(LIB3DS_TRUE); } ASSERT(mesh->flags<0x10000); c.chunk=LIB3DS_POINT_FLAG_ARRAY; c.size=8+2*mesh->flags; lib3ds_chunk_write(&c, io); lib3ds_io_write_word(io, (Lib3dsWord)mesh->flags); for (i=0; i<mesh->flags; ++i) { lib3ds_io_write_word(io, mesh->flagL[i]); } return(LIB3DS_TRUE); } static Lib3dsBool face_array_write(Lib3dsMesh *mesh, Lib3dsIo *io) { Lib3dsChunk c; if (!mesh->faces || !mesh->faceL) { return(LIB3DS_TRUE); } ASSERT(mesh->faces<0x10000); c.chunk=LIB3DS_FACE_ARRAY; if (!lib3ds_chunk_write_start(&c, io)) { return(LIB3DS_FALSE); } { unsigned i; lib3ds_io_write_word(io, (Lib3dsWord)mesh->faces); for (i=0; i<mesh->faces; ++i) { lib3ds_io_write_word(io, mesh->faceL[i].points[0]); lib3ds_io_write_word(io, mesh->faceL[i].points[1]); lib3ds_io_write_word(io, mesh->faceL[i].points[2]); lib3ds_io_write_word(io, mesh->faceL[i].flags); } } { /*---- MSH_MAT_GROUP ----*/ Lib3dsChunk c; unsigned i,j; Lib3dsWord num; char *matf=calloc(sizeof(char), mesh->faces); if (!matf) { return(LIB3DS_FALSE); } for (i=0; i<mesh->faces; ++i) { if (!matf[i] && strlen(mesh->faceL[i].material)) { matf[i]=1; num=1; for (j=i+1; j<mesh->faces; ++j) { if (strcmp(mesh->faceL[i].material, mesh->faceL[j].material)==0) ++num; } c.chunk=LIB3DS_MSH_MAT_GROUP; c.size=6+ strlen(mesh->faceL[i].material)+1 +2+2*num; lib3ds_chunk_write(&c, io); lib3ds_io_write_string(io, mesh->faceL[i].material); lib3ds_io_write_word(io, num); lib3ds_io_write_word(io, (Lib3dsWord)i); for (j=i+1; j<mesh->faces; ++j) { if (strcmp(mesh->faceL[i].material, mesh->faceL[j].material)==0) { lib3ds_io_write_word(io, (Lib3dsWord)j); matf[j]=1; } } } } free(matf); } { /*---- SMOOTH_GROUP ----*/ Lib3dsChunk c; unsigned i; c.chunk=LIB3DS_SMOOTH_GROUP; c.size=6+4*mesh->faces; lib3ds_chunk_write(&c, io); for (i=0; i<mesh->faces; ++i) { lib3ds_io_write_dword(io, mesh->faceL[i].smoothing); } } { /*---- MSH_BOXMAP ----*/ Lib3dsChunk c; if (strlen(mesh->box_map.front) || strlen(mesh->box_map.back) || strlen(mesh->box_map.left) || strlen(mesh->box_map.right) || strlen(mesh->box_map.top) || strlen(mesh->box_map.bottom)) { c.chunk=LIB3DS_MSH_BOXMAP; if (!lib3ds_chunk_write_start(&c, io)) { return(LIB3DS_FALSE); } lib3ds_io_write_string(io, mesh->box_map.front); lib3ds_io_write_string(io, mesh->box_map.back); lib3ds_io_write_string(io, mesh->box_map.left); lib3ds_io_write_string(io, mesh->box_map.right); lib3ds_io_write_string(io, mesh->box_map.top); lib3ds_io_write_string(io, mesh->box_map.bottom); if (!lib3ds_chunk_write_end(&c, io)) { return(LIB3DS_FALSE); } } } if (!lib3ds_chunk_write_end(&c, io)) { return(LIB3DS_FALSE); } return(LIB3DS_TRUE); } static Lib3dsBool texel_array_write(Lib3dsMesh *mesh, Lib3dsIo *io) { Lib3dsChunk c; unsigned i; if (!mesh->texels || !mesh->texelL) { return(LIB3DS_TRUE); } ASSERT(mesh->texels<0x10000); c.chunk=LIB3DS_TEX_VERTS; c.size=8+8*mesh->texels; lib3ds_chunk_write(&c, io); lib3ds_io_write_word(io, (Lib3dsWord)mesh->texels); for (i=0; i<mesh->texels; ++i) { lib3ds_io_write_float(io, mesh->texelL[i][0]); lib3ds_io_write_float(io, mesh->texelL[i][1]); } return(LIB3DS_TRUE); } /*! * \ingroup mesh */ Lib3dsBool lib3ds_mesh_write(Lib3dsMesh *mesh, Lib3dsIo *io) { Lib3dsChunk c; c.chunk=LIB3DS_N_TRI_OBJECT; if (!lib3ds_chunk_write_start(&c,io)) { return(LIB3DS_FALSE); } if (!point_array_write(mesh, io)) { return(LIB3DS_FALSE); } if (!texel_array_write(mesh, io)) { return(LIB3DS_FALSE); } if (mesh->map_data.maptype!=LIB3DS_MAP_NONE) { /*---- LIB3DS_MESH_TEXTURE_INFO ----*/ Lib3dsChunk c; int i,j; c.chunk=LIB3DS_MESH_TEXTURE_INFO; c.size=92; if (!lib3ds_chunk_write(&c,io)) { return(LIB3DS_FALSE); } lib3ds_io_write_word(io, mesh->map_data.maptype); for (i=0; i<2; ++i) { lib3ds_io_write_float(io, mesh->map_data.tile[i]); } for (i=0; i<3; ++i) { lib3ds_io_write_float(io, mesh->map_data.pos[i]); } lib3ds_io_write_float(io, mesh->map_data.scale); for (i=0; i<4; i++) { for (j=0; j<3; j++) { lib3ds_io_write_float(io, mesh->map_data.matrix[i][j]); } } for (i=0; i<2; ++i) { lib3ds_io_write_float(io, mesh->map_data.planar_size[i]); } lib3ds_io_write_float(io, mesh->map_data.cylinder_height); } if (!flag_array_write(mesh, io)) { return(LIB3DS_FALSE); } { /*---- LIB3DS_MESH_MATRIX ----*/ Lib3dsChunk c; int i,j; c.chunk=LIB3DS_MESH_MATRIX; c.size=54; if (!lib3ds_chunk_write(&c,io)) { return(LIB3DS_FALSE); } for (i=0; i<4; i++) { for (j=0; j<3; j++) { lib3ds_io_write_float(io, mesh->matrix[i][j]); } } } if (mesh->color) { /*---- LIB3DS_MESH_COLOR ----*/ Lib3dsChunk c; c.chunk=LIB3DS_MESH_COLOR; c.size=7; if (!lib3ds_chunk_write(&c,io)) { return(LIB3DS_FALSE); } lib3ds_io_write_byte(io, mesh->color); } if (!face_array_write(mesh, io)) { return(LIB3DS_FALSE); } if (!lib3ds_chunk_write_end(&c,io)) { return(LIB3DS_FALSE); } return(LIB3DS_TRUE); } /*! \typedef Lib3dsFace \ingroup mesh \sa _Lib3dsFace */ /*! \typedef Lib3dsBoxMap \ingroup mesh \sa _Lib3dsBoxMap */ /*! \typedef Lib3dsMapData \ingroup mesh \sa _Lib3dsMapData */ /*! \typedef Lib3dsMesh \ingroup mesh \sa _Lib3dsMesh */
sugao516/gltron-code
lib3ds/mesh.c
C
gpl-2.0
22,101
/** * \file * Copyright (C) 2006-2010 Jedox AG * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as published * by the Free Software Foundation at http://www.gnu.org/copyleft/gpl.html. * * 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, write to the Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA * * You may obtain a copy of the License at * * <a href="http://www.jedox.com/license_palo_bi_suite.txt"> * http://www.jedox.com/license_palo_bi_suite.txt * </a> * * If you are developing and distributing open source applications under the * GPL License, then you are free to use Worksheetserver under the GPL License. * For OEMs, ISVs, and VARs who distribute Worksheetserver with their products, * and do not license and distribute their source code under the GPL, Jedox provides * a flexible OEM Commercial License. * * \author * Frieder Hofmann <frieder.hofmann@jedox.com> */ #pragma once #include <wss/define.hpp> #include <wss/rectangle.hpp> #include <wss/variant.hpp> #include <wss/type.hpp> #include <wss/border_types.hpp> #include <wss/conditional_format_manager.hpp> #if !defined(HAS_PRECOMPILED_HEADER ) || HAS_PRECOMPILED_HEADER == 0 # include <boost/cstdint.hpp> #endif namespace cf { struct format_style_unlock_type; typedef boost::shared_ptr<format_style_unlock_type> shared_format_style_unlock_type; } /*! * \brief * struct to set a conditional format rule * * \author * Frieder Hofmann <frieder.hofmann@jedox.com> */ class WSS_MODULE set_conditional_format { public: typedef boost::int_fast32_t lookup_id_type; typedef sheet_range::rectangles_type selected_ranges_type; typedef std::map<conditional_format_border_types::type, border_style_flyweight_type> border_map_type; set_conditional_format(); set_conditional_format( const variant& operands, const std::string& rule, const std::string& s, const set_conditional_format::selected_ranges_type& selected_ranges, border_map_type& borders ); inline const variant& operands() const { return m_operands; } inline void operands( const variant& val ) { m_operands = val; } inline const std::string& rule() const { return m_rule; } inline void rule( const std::string& val ) { m_rule = val; } inline const selected_ranges_type& selected_range() const { return m_selected_range; } inline void selected_range( const set_conditional_format::selected_ranges_type& val ) { m_selected_range = val; } inline void selected_range( const set_conditional_format::selected_ranges_type::value_type& val ) { m_selected_range.push_back( val ); } bool unlock_cells() const; void unlock_cells( const bool unlock ); inline const sheet_point& position() const { static const sheet_point dummy = sheet_point( 0, 0 ); return !selected_range().empty() ? selected_range().begin()->upper_left() : dummy; } const cf::shared_format_style_unlock_type& format_style_unlock_information() const; void format( const std::string& f ); void style( const std::string& s ); void add_border( const conditional_format_border_types::type t, const std::string& style ); void format_style_unlock_information( const cf::shared_format_style_unlock_type& val ); private: variant m_operands; std::string m_rule; selected_ranges_type m_selected_range; cf::shared_format_style_unlock_type m_format_style_unlock_information; };
fschaper/netcell
core/server/include/wss/set_conditional_format.hpp
C++
gpl-2.0
4,082
/* * $Copyright Open Broadcom Corporation$ * * Fundamental types and constants relating to WFA P2P (aka WiFi Direct) * * $Id: p2p.h 338828 2012-06-14 17:24:45Z harveysm $ */ #ifndef _P2P_H_ #define _P2P_H_ #ifndef _TYPEDEFS_H_ #include <typedefs.h> #endif #include <wlioctl.h> #include <proto/802.11.h> /* This marks the start of a packed structure section. */ #include <packed_section_start.h> /* WiFi P2P OUI values */ #define P2P_OUI WFA_OUI /* WiFi P2P OUI */ #define P2P_VER WFA_OUI_TYPE_P2P /* P2P version: 9=WiFi P2P v1.0 */ #define P2P_IE_ID 0xdd /* P2P IE element ID */ /* WiFi P2P IE */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_ie { uint8 id; /* IE ID: 0xDD */ uint8 len; /* IE length */ uint8 OUI[3]; /* WiFi P2P specific OUI: P2P_OUI */ uint8 oui_type; /* Identifies P2P version: P2P_VER */ uint8 subelts[1]; /* variable length subelements */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_ie wifi_p2p_ie_t; #define P2P_IE_FIXED_LEN 6 #define P2P_ATTR_ID_OFF 0 #define P2P_ATTR_LEN_OFF 1 #define P2P_ATTR_DATA_OFF 3 #define P2P_ATTR_HDR_LEN 3 /* ID + 2-byte length field spec 1.02 */ /* P2P IE Subelement IDs from WiFi P2P Technical Spec 1.00 */ #define P2P_SEID_STATUS 0 /* Status */ #define P2P_SEID_MINOR_RC 1 /* Minor Reason Code */ #define P2P_SEID_P2P_INFO 2 /* P2P Capability (capabilities info) */ #define P2P_SEID_DEV_ID 3 /* P2P Device ID */ #define P2P_SEID_INTENT 4 /* Group Owner Intent */ #define P2P_SEID_CFG_TIMEOUT 5 /* Configuration Timeout */ #define P2P_SEID_CHANNEL 6 /* Listen channel */ #define P2P_SEID_GRP_BSSID 7 /* P2P Group BSSID */ #define P2P_SEID_XT_TIMING 8 /* Extended Listen Timing */ #define P2P_SEID_INTINTADDR 9 /* Intended P2P Interface Address */ #define P2P_SEID_P2P_MGBTY 10 /* P2P Manageability */ #define P2P_SEID_CHAN_LIST 11 /* Channel List */ #define P2P_SEID_ABSENCE 12 /* Notice of Absence */ #define P2P_SEID_DEV_INFO 13 /* Device Info */ #define P2P_SEID_GROUP_INFO 14 /* Group Info */ #define P2P_SEID_GROUP_ID 15 /* Group ID */ #define P2P_SEID_P2P_IF 16 /* P2P Interface */ #define P2P_SEID_OP_CHANNEL 17 /* Operating channel */ #define P2P_SEID_INVITE_FLAGS 18 /* Invitation flags */ #define P2P_SEID_VNDR 221 /* Vendor-specific subelement */ #define P2P_SE_VS_ID_SERVICES 0x1b /* BRCM proprietary subel: L2 Services */ /* WiFi P2P IE subelement: P2P Capability (capabilities info) */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_info_se_s { uint8 eltId; /* SE ID: P2P_SEID_P2P_INFO */ uint8 len[2]; /* SE length not including eltId, len fields */ uint8 dev; /* Device Capability Bitmap */ uint8 group; /* Group Capability Bitmap */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_info_se_s wifi_p2p_info_se_t; /* P2P Capability subelement's Device Capability Bitmap bit values */ #define P2P_CAPSE_DEV_SERVICE_DIS 0x1 /* Service Discovery */ #define P2P_CAPSE_DEV_CLIENT_DIS 0x2 /* Client Discoverability */ #define P2P_CAPSE_DEV_CONCURRENT 0x4 /* Concurrent Operation */ #define P2P_CAPSE_DEV_INFRA_MAN 0x8 /* P2P Infrastructure Managed */ #define P2P_CAPSE_DEV_LIMIT 0x10 /* P2P Device Limit */ #define P2P_CAPSE_INVITE_PROC 0x20 /* P2P Invitation Procedure */ /* P2P Capability subelement's Group Capability Bitmap bit values */ #define P2P_CAPSE_GRP_OWNER 0x1 /* P2P Group Owner */ #define P2P_CAPSE_PERSIST_GRP 0x2 /* Persistent P2P Group */ #define P2P_CAPSE_GRP_LIMIT 0x4 /* P2P Group Limit */ #define P2P_CAPSE_GRP_INTRA_BSS 0x8 /* Intra-BSS Distribution */ #define P2P_CAPSE_GRP_X_CONNECT 0x10 /* Cross Connection */ #define P2P_CAPSE_GRP_PERSISTENT 0x20 /* Persistent Reconnect */ #define P2P_CAPSE_GRP_FORMATION 0x40 /* Group Formation */ /* WiFi P2P IE subelement: Group Owner Intent */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_intent_se_s { uint8 eltId; /* SE ID: P2P_SEID_INTENT */ uint8 len[2]; /* SE length not including eltId, len fields */ uint8 intent; /* Intent Value 0...15 (0=legacy 15=master only) */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_intent_se_s wifi_p2p_intent_se_t; /* WiFi P2P IE subelement: Configuration Timeout */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_cfg_tmo_se_s { uint8 eltId; /* SE ID: P2P_SEID_CFG_TIMEOUT */ uint8 len[2]; /* SE length not including eltId, len fields */ uint8 go_tmo; /* GO config timeout in units of 10 ms */ uint8 client_tmo; /* Client config timeout in units of 10 ms */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_cfg_tmo_se_s wifi_p2p_cfg_tmo_se_t; /* WiFi P2P IE subelement: Status */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_status_se_s { uint8 eltId; /* SE ID: P2P_SEID_STATUS */ uint8 len[2]; /* SE length not including eltId, len fields */ uint8 status; /* Status Code: P2P_STATSE_* */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_status_se_s wifi_p2p_status_se_t; /* Status subelement Status Code definitions */ #define P2P_STATSE_SUCCESS 0 /* Success */ #define P2P_STATSE_FAIL_INFO_CURR_UNAVAIL 1 /* Failed, information currently unavailable */ #define P2P_STATSE_PASSED_UP P2P_STATSE_FAIL_INFO_CURR_UNAVAIL /* Old name for above in P2P spec 1.08 and older */ #define P2P_STATSE_FAIL_INCOMPAT_PARAMS 2 /* Failed, incompatible parameters */ #define P2P_STATSE_FAIL_LIMIT_REACHED 3 /* Failed, limit reached */ #define P2P_STATSE_FAIL_INVALID_PARAMS 4 /* Failed, invalid parameters */ #define P2P_STATSE_FAIL_UNABLE_TO_ACCOM 5 /* Failed, unable to accomodate request */ #define P2P_STATSE_FAIL_PROTO_ERROR 6 /* Failed, previous protocol error or disruptive behaviour */ #define P2P_STATSE_FAIL_NO_COMMON_CHAN 7 /* Failed, no common channels */ #define P2P_STATSE_FAIL_UNKNOWN_GROUP 8 /* Failed, unknown P2P Group */ #define P2P_STATSE_FAIL_INTENT 9 /* Failed, both peers indicated Intent 15 in GO Negotiation */ #define P2P_STATSE_FAIL_INCOMPAT_PROVIS 10 /* Failed, incompatible provisioning method */ #define P2P_STATSE_FAIL_USER_REJECT 11 /* Failed, rejected by user */ /* WiFi P2P IE attribute: Extended Listen Timing */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_ext_se_s { uint8 eltId; /* ID: P2P_SEID_EXT_TIMING */ uint8 len[2]; /* length not including eltId, len fields */ uint8 avail[2]; /* availibility period */ uint8 interval[2]; /* availibility interval */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_ext_se_s wifi_p2p_ext_se_t; #define P2P_EXT_MIN 10 /* minimum 10ms */ /* WiFi P2P IE subelement: Intended P2P Interface Address */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_intintad_se_s { uint8 eltId; /* SE ID: P2P_SEID_INTINTADDR */ uint8 len[2]; /* SE length not including eltId, len fields */ uint8 mac[6]; /* intended P2P interface MAC address */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_intintad_se_s wifi_p2p_intintad_se_t; /* WiFi P2P IE subelement: Channel */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_channel_se_s { uint8 eltId; /* SE ID: P2P_SEID_STATUS */ uint8 len[2]; /* SE length not including eltId, len fields */ uint8 band; /* Regulatory Class (band) */ uint8 channel; /* Channel */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_channel_se_s wifi_p2p_channel_se_t; /* Channel Entry structure within the Channel List SE */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_chanlist_entry_s { uint8 band; /* Regulatory Class (band) */ uint8 num_channels; /* # of channels in the channel list */ uint8 channels[WL_NUMCHANNELS]; /* Channel List */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_chanlist_entry_s wifi_p2p_chanlist_entry_t; #define WIFI_P2P_CHANLIST_SE_MAX_ENTRIES 2 /* WiFi P2P IE subelement: Channel List */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_chanlist_se_s { uint8 eltId; /* SE ID: P2P_SEID_STATUS */ uint8 len[2]; /* SE length not including eltId, len fields */ uint8 country[3]; /* Country String */ uint8 num_entries; /* # of channel entries */ wifi_p2p_chanlist_entry_t entries[WIFI_P2P_CHANLIST_SE_MAX_ENTRIES]; /* Channel Entry List */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_chanlist_se_s wifi_p2p_chanlist_se_t; /* WiFi P2P IE's Device Info subelement */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_devinfo_se_s { uint8 eltId; /* SE ID: P2P_SEID_DEVINFO */ uint8 len[2]; /* SE length not including eltId, len fields */ uint8 mac[6]; /* P2P Device MAC address */ uint16 wps_cfg_meths; /* Config Methods: reg_prototlv.h WPS_CONFMET_* */ uint8 pri_devtype[8]; /* Primary Device Type */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_devinfo_se_s wifi_p2p_devinfo_se_t; #define P2P_DEV_TYPE_LEN 8 /* WiFi P2P IE's Group Info subelement Client Info Descriptor */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_cid_fixed_s { uint8 len; uint8 devaddr[ETHER_ADDR_LEN]; /* P2P Device Address */ uint8 ifaddr[ETHER_ADDR_LEN]; /* P2P Interface Address */ uint8 devcap; /* Device Capability */ uint8 cfg_meths[2]; /* Config Methods: reg_prototlv.h WPS_CONFMET_* */ uint8 pridt[P2P_DEV_TYPE_LEN]; /* Primary Device Type */ uint8 secdts; /* Number of Secondary Device Types */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_cid_fixed_s wifi_p2p_cid_fixed_t; /* WiFi P2P IE's Device ID subelement */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_devid_se_s { uint8 eltId; uint8 len[2]; struct ether_addr addr; /* P2P Device MAC address */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_devid_se_s wifi_p2p_devid_se_t; /* WiFi P2P IE subelement: P2P Manageability */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_mgbt_se_s { uint8 eltId; /* SE ID: P2P_SEID_P2P_MGBTY */ uint8 len[2]; /* SE length not including eltId, len fields */ uint8 mg_bitmap; /* manageability bitmap */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_mgbt_se_s wifi_p2p_mgbt_se_t; /* mg_bitmap field bit values */ #define P2P_MGBTSE_P2PDEVMGMT_FLAG 0x1 /* AP supports Managed P2P Device */ /* WiFi P2P IE subelement: Group Info */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_grpinfo_se_s { uint8 eltId; /* SE ID: P2P_SEID_GROUP_INFO */ uint8 len[2]; /* SE length not including eltId, len fields */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_grpinfo_se_s wifi_p2p_grpinfo_se_t; /* WiFi P2P Action Frame */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_action_frame { uint8 category; /* P2P_AF_CATEGORY */ uint8 OUI[3]; /* OUI - P2P_OUI */ uint8 type; /* OUI Type - P2P_VER */ uint8 subtype; /* OUI Subtype - P2P_AF_* */ uint8 dialog_token; /* nonzero, identifies req/resp tranaction */ uint8 elts[1]; /* Variable length information elements. Max size = * ACTION_FRAME_SIZE - sizeof(this structure) - 1 */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_action_frame wifi_p2p_action_frame_t; #define P2P_AF_CATEGORY 0x7f #define P2P_AF_FIXED_LEN 7 /* WiFi P2P Action Frame OUI Subtypes */ #define P2P_AF_NOTICE_OF_ABSENCE 0 /* Notice of Absence */ #define P2P_AF_PRESENCE_REQ 1 /* P2P Presence Request */ #define P2P_AF_PRESENCE_RSP 2 /* P2P Presence Response */ #define P2P_AF_GO_DISC_REQ 3 /* GO Discoverability Request */ /* WiFi P2P Public Action Frame */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_pub_act_frame { uint8 category; /* P2P_PUB_AF_CATEGORY */ uint8 action; /* P2P_PUB_AF_ACTION */ uint8 oui[3]; /* P2P_OUI */ uint8 oui_type; /* OUI type - P2P_VER */ uint8 subtype; /* OUI subtype - P2P_TYPE_* */ uint8 dialog_token; /* nonzero, identifies req/rsp transaction */ uint8 elts[1]; /* Variable length information elements. Max size = * ACTION_FRAME_SIZE - sizeof(this structure) - 1 */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_pub_act_frame wifi_p2p_pub_act_frame_t; #define P2P_PUB_AF_FIXED_LEN 8 #define P2P_PUB_AF_CATEGORY 0x04 #define P2P_PUB_AF_ACTION 0x09 /* WiFi P2P Public Action Frame OUI Subtypes */ #define P2P_PAF_GON_REQ 0 /* Group Owner Negotiation Req */ #define P2P_PAF_GON_RSP 1 /* Group Owner Negotiation Rsp */ #define P2P_PAF_GON_CONF 2 /* Group Owner Negotiation Confirm */ #define P2P_PAF_INVITE_REQ 3 /* P2P Invitation Request */ #define P2P_PAF_INVITE_RSP 4 /* P2P Invitation Response */ #define P2P_PAF_DEVDIS_REQ 5 /* Device Discoverability Request */ #define P2P_PAF_DEVDIS_RSP 6 /* Device Discoverability Response */ #define P2P_PAF_PROVDIS_REQ 7 /* Provision Discovery Request */ #define P2P_PAF_PROVDIS_RSP 8 /* Provision Discovery Request */ /* TODO: Stop using these obsolete aliases for P2P_PAF_GON_* */ #define P2P_TYPE_MNREQ P2P_PAF_GON_REQ #define P2P_TYPE_MNRSP P2P_PAF_GON_RSP #define P2P_TYPE_MNCONF P2P_PAF_GON_CONF /* WiFi P2P IE subelement: Notice of Absence */ BWL_PRE_PACKED_STRUCT struct wifi_p2p_noa_desc { uint8 cnt_type; /* Count/Type */ uint32 duration; /* Duration */ uint32 interval; /* Interval */ uint32 start; /* Start Time */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_noa_desc wifi_p2p_noa_desc_t; BWL_PRE_PACKED_STRUCT struct wifi_p2p_noa_se { uint8 eltId; /* Subelement ID */ uint8 len[2]; /* Length */ uint8 index; /* Index */ uint8 ops_ctw_parms; /* CTWindow and OppPS Parameters */ wifi_p2p_noa_desc_t desc[1]; /* Notice of Absence Descriptor(s) */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2p_noa_se wifi_p2p_noa_se_t; #define P2P_NOA_SE_FIXED_LEN 5 /* cnt_type field values */ #define P2P_NOA_DESC_CNT_RESERVED 0 /* reserved and should not be used */ #define P2P_NOA_DESC_CNT_REPEAT 255 /* continuous schedule */ #define P2P_NOA_DESC_TYPE_PREFERRED 1 /* preferred values */ #define P2P_NOA_DESC_TYPE_ACCEPTABLE 2 /* acceptable limits */ /* ctw_ops_parms field values */ #define P2P_NOA_CTW_MASK 0x7f #define P2P_NOA_OPS_MASK 0x80 #define P2P_NOA_OPS_SHIFT 7 #define P2P_CTW_MIN 10 /* minimum 10TU */ /* * P2P Service Discovery related */ #define P2PSD_ACTION_CATEGORY 0x04 /* Public action frame */ #define P2PSD_ACTION_ID_GAS_IREQ 0x0a /* Action value for GAS Initial Request AF */ #define P2PSD_ACTION_ID_GAS_IRESP 0x0b /* Action value for GAS Initial Response AF */ #define P2PSD_ACTION_ID_GAS_CREQ 0x0c /* Action value for GAS Comback Request AF */ #define P2PSD_ACTION_ID_GAS_CRESP 0x0d /* Action value for GAS Comback Response AF */ #define P2PSD_AD_EID 0x6c /* Advertisement Protocol IE ID */ #define P2PSD_ADP_TUPLE_QLMT_PAMEBI 0x00 /* Query Response Length Limit 7 bits plus PAME-BI 1 bit */ #define P2PSD_ADP_PROTO_ID 0x00 /* Advertisement Protocol ID. Always 0 for P2P SD */ #define P2PSD_GAS_OUI P2P_OUI /* WFA OUI */ #define P2PSD_GAS_OUI_SUBTYPE P2P_VER /* OUI Subtype for GAS IE */ #define P2PSD_GAS_NQP_INFOID 0xDDDD /* NQP Query Info ID: 56797 */ #define P2PSD_GAS_COMEBACKDEALY 0x00 /* Not used in the Native GAS protocol */ /* Service Protocol Type */ typedef enum p2psd_svc_protype { SVC_RPOTYPE_ALL = 0, SVC_RPOTYPE_BONJOUR = 1, SVC_RPOTYPE_UPNP = 2, SVC_RPOTYPE_WSD = 3, SVC_RPOTYPE_VENDOR = 255 } p2psd_svc_protype_t; /* Service Discovery response status code */ typedef enum { P2PSD_RESP_STATUS_SUCCESS = 0, P2PSD_RESP_STATUS_PROTYPE_NA = 1, P2PSD_RESP_STATUS_DATA_NA = 2, P2PSD_RESP_STATUS_BAD_REQUEST = 3 } p2psd_resp_status_t; /* Advertisement Protocol IE tuple field */ BWL_PRE_PACKED_STRUCT struct wifi_p2psd_adp_tpl { uint8 llm_pamebi; /* Query Response Length Limit bit 0-6, set to 0 plus * Pre-Associated Message Exchange BSSID Independent bit 7, set to 0 */ uint8 adp_id; /* Advertisement Protocol ID: 0 for NQP Native Query Protocol */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2psd_adp_tpl wifi_p2psd_adp_tpl_t; /* Advertisement Protocol IE */ BWL_PRE_PACKED_STRUCT struct wifi_p2psd_adp_ie { uint8 id; /* IE ID: 0x6c - 108 */ uint8 len; /* IE length */ wifi_p2psd_adp_tpl_t adp_tpl; /* Advertisement Protocol Tuple field. Only one * tuple is defined for P2P Service Discovery */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2psd_adp_ie wifi_p2psd_adp_ie_t; /* NQP Vendor-specific Content */ BWL_PRE_PACKED_STRUCT struct wifi_p2psd_nqp_query_vsc { uint8 oui_subtype; /* OUI Subtype: 0x09 */ uint16 svc_updi; /* Service Update Indicator */ uint8 svc_tlvs[1]; /* wifi_p2psd_qreq_tlv_t type for service request, * wifi_p2psd_qresp_tlv_t type for service response */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2psd_nqp_query_vsc wifi_p2psd_nqp_query_vsc_t; /* Service Request TLV */ BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qreq_tlv { uint16 len; /* Length: 5 plus size of Query Data */ uint8 svc_prot; /* Service Protocol Type */ uint8 svc_tscid; /* Service Transaction ID */ uint8 query_data[1]; /* Query Data, passed in from above Layer 2 */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2psd_qreq_tlv wifi_p2psd_qreq_tlv_t; /* Query Request Frame, defined in generic format, instead of NQP specific */ BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qreq_frame { uint16 info_id; /* Info ID: 0xDDDD */ uint16 len; /* Length of service request TLV, 5 plus the size of request data */ uint8 oui[3]; /* WFA OUI: 0x0050F2 */ uint8 qreq_vsc[1]; /* Vendor-specific Content: wifi_p2psd_nqp_query_vsc_t type for NQP */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2psd_qreq_frame wifi_p2psd_qreq_frame_t; /* GAS Initial Request AF body, "elts" in wifi_p2p_pub_act_frame */ BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_ireq_frame { wifi_p2psd_adp_ie_t adp_ie; /* Advertisement Protocol IE */ uint16 qreq_len; /* Query Request Length */ uint8 qreq_frm[1]; /* Query Request Frame wifi_p2psd_qreq_frame_t */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2psd_gas_ireq_frame wifi_p2psd_gas_ireq_frame_t; /* Service Response TLV */ BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qresp_tlv { uint16 len; /* Length: 5 plus size of Query Data */ uint8 svc_prot; /* Service Protocol Type */ uint8 svc_tscid; /* Service Transaction ID */ uint8 status; /* Value defined in Table 57 of P2P spec. */ uint8 query_data[1]; /* Response Data, passed in from above Layer 2 */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2psd_qresp_tlv wifi_p2psd_qresp_tlv_t; /* Query Response Frame, defined in generic format, instead of NQP specific */ BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qresp_frame { uint16 info_id; /* Info ID: 0xDDDD */ uint16 len; /* Lenth of service response TLV, 6 plus the size of resp data */ uint8 oui[3]; /* WFA OUI: 0x0050F2 */ uint8 qresp_vsc[1]; /* Vendor-specific Content: wifi_p2psd_qresp_tlv_t type for NQP */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2psd_qresp_frame wifi_p2psd_qresp_frame_t; /* GAS Initial Response AF body, "elts" in wifi_p2p_pub_act_frame */ BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_iresp_frame { uint16 status; /* Value defined in Table 7-23 of IEEE P802.11u */ uint16 cb_delay; /* GAS Comeback Delay */ wifi_p2psd_adp_ie_t adp_ie; /* Advertisement Protocol IE */ uint16 qresp_len; /* Query Response Length */ uint8 qresp_frm[1]; /* Query Response Frame wifi_p2psd_qresp_frame_t */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2psd_gas_iresp_frame wifi_p2psd_gas_iresp_frame_t; /* GAS Comeback Response AF body, "elts" in wifi_p2p_pub_act_frame */ BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_cresp_frame { uint16 status; /* Value defined in Table 7-23 of IEEE P802.11u */ uint8 fragment_id; /* Fragmentation ID */ uint16 cb_delay; /* GAS Comeback Delay */ wifi_p2psd_adp_ie_t adp_ie; /* Advertisement Protocol IE */ uint16 qresp_len; /* Query Response Length */ uint8 qresp_frm[1]; /* Query Response Frame wifi_p2psd_qresp_frame_t */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2psd_gas_cresp_frame wifi_p2psd_gas_cresp_frame_t; /* Wi-Fi GAS Public Action Frame */ BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_pub_act_frame { uint8 category; /* 0x04 Public Action Frame */ uint8 action; /* 0x6c Advertisement Protocol */ uint8 dialog_token; /* nonzero, identifies req/rsp transaction */ uint8 query_data[1]; /* Query Data. wifi_p2psd_gas_ireq_frame_t * or wifi_p2psd_gas_iresp_frame_t format */ } BWL_POST_PACKED_STRUCT; typedef struct wifi_p2psd_gas_pub_act_frame wifi_p2psd_gas_pub_act_frame_t; /* This marks the end of a packed structure section. */ #include <packed_section_end.h> #endif /* _P2P_H_ */
princeofdream/debug_src_full
network_utils/wl/include/proto/p2p.h
C
gpl-2.0
20,067
from src.tools.enum import enum import pyxbmct.addonwindow as pyxbmct from src.tools.dialog import dialog EnumMode = enum(SELECT=0, ROTATE=1) class EnumButton(object): def __init__(self, label, values, current, default, changeCallback=None, saveCallback=None, customLabels=None, mode=EnumMode.SELECT, returnValue=False, alignment=pyxbmct.ALIGN_CENTER): self.label = label self.values = values self.customLabels = customLabels self.mode = mode self.returnValue = returnValue self.changeCallback = changeCallback self.saveCallback = saveCallback self.currentValue = current self.defaultValue = default self.currentIndex = None self.defaultIndex = None self.assignedValue = False if saveCallback is None: self.onSave = None if customLabels: self._findCurrentIndex() label = str(customLabels[self.currentIndex]) else: label = str(current) if alignment is not None: self.button = pyxbmct.Button(label, alignment=alignment) else: self.button = pyxbmct.Button(label) def update(self, value): if self.currentValue != value: self.currentValue = value if self.customLabels: self._findCurrentIndex() label = str(self.customLabels[self.currentIndex]) else: self.currentIndex = None label = str(value) self.button.setLabel(label) self.assignedValue = True def onClick(self): if self.mode == EnumMode.SELECT: if self.customLabels: values = self.customLabels else: values = self.values selectedIndex = dialog.select(self.label, list((str(value) for value in values))) if selectedIndex == -1: return index = selectedIndex else: if self.currentIndex is None: self._findCurrentIndex() if self.currentIndex == len(self.values) - 1: index = 0 else: index = self.currentIndex + 1 self.assign(index) def onDefault(self): if self.defaultIndex is None: self._findDefaultIndex() self.assign(self.defaultIndex) def onSave(self): if self.assignedValue: if self.returnValue: self.saveCallback(self.currentValue) else: self.saveCallback(self.currentIndex) def assign(self, index): value = self.values[index] self.currentIndex = index self.currentValue = value if self.customLabels: label = str(self.customLabels[index]) else: label = str(value) self.button.setLabel(label) self.assignedValue = True if self.changeCallback: if self.returnValue: self.changeCallback(value) else: self.changeCallback(index) def _findDefaultIndex(self): for i in range(0, len(self.values)): value = self.values[i] if value == self.defaultValue: self.defaultIndex = i if self.defaultIndex is None: raise ValueError ('Default value not found in value list') def _findCurrentIndex(self): for i in range(0, len(self.values)): value = self.values[i] if value == self.currentValue: self.currentIndex = i if self.currentIndex is None: raise ValueError ('Current value not found in value list')
SportySpice/Collections
src/gui/EnumButton.py
Python
gpl-2.0
4,537
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <title>lldp: /home/evan/lldpd-0.7.11/libevent/include/event2/http.h File Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">lldp &#160;<span id="projectnumber">0.7.11</span> </div> </td> </tr> </tbody> </table> </div> <!-- Generated by Doxygen 1.7.6.1 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main&#160;Page</span></a></li> <li><a href="pages.html"><span>Related&#160;Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File&#160;List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> </div> <div class="header"> <div class="summary"> <a href="#define-members">Defines</a> &#124; <a href="#enum-members">Enumerations</a> &#124; <a href="#func-members">Functions</a> </div> <div class="headertitle"> <div class="title">/home/evan/lldpd-0.7.11/libevent/include/event2/http.h File Reference</div> </div> </div><!--header--> <div class="contents"> <div class="textblock"><code>#include &lt;<a class="el" href="util_8h_source.html">event2/util.h</a>&gt;</code><br/> </div><div class="textblock"><div class="dynheader"> Include dependency graph for http.h:</div> <div class="dyncontent"> <div class="center"><img src="http_8h__incl.png" border="0" usemap="#_2home_2evan_2lldpd-0_87_811_2libevent_2include_2event2_2http_8h" alt=""/></div> <map name="_2home_2evan_2lldpd-0_87_811_2libevent_2include_2event2_2http_8h" id="_2home_2evan_2lldpd-0_87_811_2libevent_2include_2event2_2http_8h"> </map> </div> </div><div class="textblock"><div class="dynheader"> This graph shows which files directly or indirectly include this file:</div> <div class="dyncontent"> <div class="center"><img src="http_8h__dep__incl.png" border="0" usemap="#_2home_2evan_2lldpd-0_87_811_2libevent_2include_2event2_2http_8hdep" alt=""/></div> <map name="_2home_2evan_2lldpd-0_87_811_2libevent_2include_2event2_2http_8hdep" id="_2home_2evan_2lldpd-0_87_811_2libevent_2include_2event2_2http_8hdep"> </map> </div> </div> <p><a href="http_8h_source.html">Go to the source code of this file.</a></p> <table class="memberdecls"> <tr><td colspan="2"><h2><a name="define-members"></a> Defines</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a02e6d59009dee759528ec81fc9a8eeff">HTTP_OK</a>&#160;&#160;&#160;200</td></tr> <tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ac5e3a483119375a05d199c30709f2b8e">HTTP_NOCONTENT</a>&#160;&#160;&#160;204</td></tr> <tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ac6ffbb7b69889f1eee0d413576c609a9">HTTP_MOVEPERM</a>&#160;&#160;&#160;301</td></tr> <tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a7d2a7341ba2af15babe8c25df67e563f">HTTP_MOVETEMP</a>&#160;&#160;&#160;302</td></tr> <tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a3112d58297965db46a04fe288bf1d0da">HTTP_NOTMODIFIED</a>&#160;&#160;&#160;304</td></tr> <tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#af9f070802de32cd2f820059fc42cbf39">HTTP_BADREQUEST</a>&#160;&#160;&#160;400</td></tr> <tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a1f5b9c02b018640c890e5f27207fa6c0">HTTP_NOTFOUND</a>&#160;&#160;&#160;404</td></tr> <tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a8d93bc2b08ddc194c213682c4726b0e6">HTTP_BADMETHOD</a>&#160;&#160;&#160;405</td></tr> <tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a64236d9bad703199d84a08bee90e00f0">HTTP_ENTITYTOOLARGE</a>&#160;&#160;&#160;413</td></tr> <tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a4eac9f52d3d8de9b3deadaec6ad0bee9">HTTP_EXPECTATIONFAILED</a>&#160;&#160;&#160;417</td></tr> <tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a15eac402986428a8125d364b7ae569b1">HTTP_INTERNAL</a>&#160;&#160;&#160;500</td></tr> <tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a9759dd4ad026a688142afb7b4e4542cc">HTTP_NOTIMPLEMENTED</a>&#160;&#160;&#160;501</td></tr> <tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a5fd6829fe2bb38dd13288f11dcb2025f">HTTP_SERVUNAVAIL</a>&#160;&#160;&#160;503</td></tr> <tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ace576911d436a163584f4942907270a5">EVHTTP_URI_NONCONFORMANT</a>&#160;&#160;&#160;0x01</td></tr> <tr><td colspan="2"><h2><a name="enum-members"></a> Enumerations</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ac858319d667267f9fc848c2bb6931aa3">evhttp_cmd_type</a> { <br/> &#160;&#160;<b>EVHTTP_REQ_GET</b> = 1 &lt;&lt; 0, <b>EVHTTP_REQ_POST</b> = 1 &lt;&lt; 1, <b>EVHTTP_REQ_HEAD</b> = 1 &lt;&lt; 2, <b>EVHTTP_REQ_PUT</b> = 1 &lt;&lt; 3, <br/> &#160;&#160;<b>EVHTTP_REQ_DELETE</b> = 1 &lt;&lt; 4, <b>EVHTTP_REQ_OPTIONS</b> = 1 &lt;&lt; 5, <b>EVHTTP_REQ_TRACE</b> = 1 &lt;&lt; 6, <b>EVHTTP_REQ_CONNECT</b> = 1 &lt;&lt; 7, <br/> &#160;&#160;<b>EVHTTP_REQ_PATCH</b> = 1 &lt;&lt; 8 <br/> }</td></tr> <tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a47ca41a942899d019bf59cf32301ae4f">evhttp_request_kind</a> { <b>EVHTTP_REQUEST</b>, <b>EVHTTP_RESPONSE</b> }</td></tr> <tr><td colspan="2"><h2><a name="func-members"></a> Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ab8c84271a97fd85957cf72b1161b8216">evhttp_new</a> (struct <a class="el" href="structevent__base.html">event_base</a> *base)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a80ea2b819c0997a0ecc0d915446aeaa4">evhttp_bind_socket</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http, const char *address, ev_uint16_t port)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structevhttp__bound__socket.html">evhttp_bound_socket</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a7b2e494399364cfb8071e69564c33db9">evhttp_bind_socket_with_handle</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http, const char *address, ev_uint16_t port)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#aa5719654012b143ebfc0dfc9d4a8490d">evhttp_accept_socket</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http, <a class="el" href="util_8h.html#a7ef0023565082a65020f6e56be59fd0b">evutil_socket_t</a> fd)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structevhttp__bound__socket.html">evhttp_bound_socket</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ae0b17d7e600e87cadda2352ea2135d8f">evhttp_accept_socket_with_handle</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http, <a class="el" href="util_8h.html#a7ef0023565082a65020f6e56be59fd0b">evutil_socket_t</a> fd)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structevhttp__bound__socket.html">evhttp_bound_socket</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#aa86abe883e71049f03534d984dd8c625">evhttp_bind_listener</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http, struct <a class="el" href="structevconnlistener.html">evconnlistener</a> *listener)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structevconnlistener.html">evconnlistener</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a7b9ba15b143ece0f69a2b4c52ff9d788">evhttp_bound_socket_get_listener</a> (struct <a class="el" href="structevhttp__bound__socket.html">evhttp_bound_socket</a> *bound)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a5404c30f3b50a664f2ec1500ebb30d86">evhttp_del_accept_socket</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http, struct <a class="el" href="structevhttp__bound__socket.html">evhttp_bound_socket</a> *bound_socket)</td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="util_8h.html#a7ef0023565082a65020f6e56be59fd0b">evutil_socket_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a5b5912e3d764bbd8f4952aba0f0604fa">evhttp_bound_socket_get_fd</a> (struct <a class="el" href="structevhttp__bound__socket.html">evhttp_bound_socket</a> *bound_socket)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a849acf0f233772b486b8057fcf3aaf4a">evhttp_free</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ae936aa6e7b0cb9617d0548a952db93cf">evhttp_set_max_headers_size</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http, ev_ssize_t max_headers_size)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a8406065dcb34f9a058b2a7a6988ac351">evhttp_set_max_body_size</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http, ev_ssize_t max_body_size)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ae63a0370f59570e00753f7fb512a7f59">evhttp_set_allowed_methods</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http, ev_uint16_t methods)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a5b685afe43d7f4c3bfcc7dcba72d41e0">evhttp_set_cb</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http, const char *path, void(*cb)(struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *, void *), void *cb_arg)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a26b24365ab036cbce853fedc7818bc49">evhttp_del_cb</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *, const char *)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ad3466287c0054d32dfd538a3bdfb0374">evhttp_set_gencb</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http, void(*cb)(struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *, void *), void *arg)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a82d8fb72c5e8c76b787987ba5de5b141">evhttp_add_virtual_host</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http, const char *pattern, struct <a class="el" href="structevhttp.html">evhttp</a> *vhost)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ab2eb1ac82f36e7f0180b18d4553d3994">evhttp_remove_virtual_host</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http, struct <a class="el" href="structevhttp.html">evhttp</a> *vhost)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a58fe001925e7f65d7678bf90b31fc2a5">evhttp_add_server_alias</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http, const char *alias)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a88fe4c5507e88c4db284ea30a0478e5d">evhttp_remove_server_alias</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http, const char *alias)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#acc8bb4d9e196f957510b5db9f6a02e44">evhttp_set_timeout</a> (struct <a class="el" href="structevhttp.html">evhttp</a> *http, int timeout_in_secs)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a629ef7f70ed916e162dee3bd12e397c9">evhttp_send_error</a> (struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req, int error, const char *reason)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a9df5ec9adc9bc664db5d6b161a293525">evhttp_send_reply</a> (struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req, int code, const char *reason, struct <a class="el" href="structevbuffer.html">evbuffer</a> *databuf)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a69c93aab46133521997cdfb8c2e07195">evhttp_send_reply_start</a> (struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req, int code, const char *reason)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a7950f70e66678fda56fdf8288811639c">evhttp_send_reply_chunk</a> (struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req, struct <a class="el" href="structevbuffer.html">evbuffer</a> *databuf)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a77024706313626c5857089b08ec5e0ae">evhttp_send_reply_end</a> (struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a2f40f147e37f9a40f8ef684fb8f2d6b0">evhttp_request_new</a> (void(*cb)(struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *, void *), void *arg)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a3dd375d81eac9baabc53749ed025ec12">evhttp_request_set_chunked_cb</a> (struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *, void(*cb)(struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *, void *))</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#aad0392c873fa034be3ff09d4f8b68aba">evhttp_request_free</a> (struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#af5913a2851880df25cf9ef43f7646074">evhttp_connection_base_new</a> (struct <a class="el" href="structevent__base.html">event_base</a> *base, struct <a class="el" href="structevdns__base.html">evdns_base</a> *dnsbase, const char *address, unsigned short port)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structbufferevent.html">bufferevent</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a39cc41e2c07c0a2042ecdd05248bd645">evhttp_connection_get_bufferevent</a> (struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *evcon)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a93a13d12f579bf22af35e2f1a6d82f4c">evhttp_request_own</a> (struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a25516c0fb1b0ef47c81f623da3782bd1">evhttp_request_is_owned</a> (struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a92a534f00172fa452c45c9f3fc42d6f5">evhttp_request_get_connection</a> (struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structevent__base.html">event_base</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#aeeec8fa8b1c5836d05a0e552793b0945">evhttp_connection_get_base</a> (struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *req)</td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aeea564828181bbd3879b6af92224d4f6"></a><!-- doxytag: member="http.h::evhttp_connection_set_max_headers_size" ref="aeea564828181bbd3879b6af92224d4f6" args="(struct evhttp_connection *evcon, ev_ssize_t new_max_headers_size)" --> void&#160;</td><td class="memItemRight" valign="bottom"><b>evhttp_connection_set_max_headers_size</b> (struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *evcon, ev_ssize_t new_max_headers_size)</td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a05e5fc3a7488c3a32f28fde45d15c6e4"></a><!-- doxytag: member="http.h::evhttp_connection_set_max_body_size" ref="a05e5fc3a7488c3a32f28fde45d15c6e4" args="(struct evhttp_connection *evcon, ev_ssize_t new_max_body_size)" --> void&#160;</td><td class="memItemRight" valign="bottom"><b>evhttp_connection_set_max_body_size</b> (struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *evcon, ev_ssize_t new_max_body_size)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ab5afe0ffd71e479a9d830ac3800ba599">evhttp_connection_free</a> (struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *evcon)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a839b6cd03f4377fead26e8b680e9cd7e">evhttp_connection_set_local_address</a> (struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *evcon, const char *address)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a3a325b818c5c4f48a8ba1f3cf6a49d7f">evhttp_connection_set_local_port</a> (struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *evcon, ev_uint16_t port)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#aa145623b7f58efe51908c6e48060db8c">evhttp_connection_set_timeout</a> (struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *evcon, int timeout_in_secs)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a9356b2a28a3b08bf273d027d1c40f470">evhttp_connection_set_retries</a> (struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *evcon, int retry_max)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#af62e12b843002e6eace204cc68da2277">evhttp_connection_set_closecb</a> (struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *evcon, void(*)(struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *, void *), void *)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#afa866e15c757e815a2e66cba7c8aa161">evhttp_connection_get_peer</a> (struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *evcon, char **address, ev_uint16_t *port)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a70af2a5e67da78782e06c640b9f85d4e">evhttp_make_request</a> (struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *evcon, struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req, enum <a class="el" href="http_8h.html#ac858319d667267f9fc848c2bb6931aa3">evhttp_cmd_type</a> type, const char *uri)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ab323fe297168f0f87af832f2bddc40a0">evhttp_cancel_request</a> (struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a78ce0bb30083afddb525cb9fa0b30ae0">evhttp_request_get_uri</a> (const struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a4cc0812787263e4473b2bd25fcade9c2">evhttp_request_get_evhttp_uri</a> (const struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">enum <a class="el" href="http_8h.html#ac858319d667267f9fc848c2bb6931aa3">evhttp_cmd_type</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a552bcfe23acec6858742e44a1b932dad">evhttp_request_get_command</a> (const struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req)</td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac1452ea8db0ddb07f52d5de739f026af"></a><!-- doxytag: member="http.h::evhttp_request_get_response_code" ref="ac1452ea8db0ddb07f52d5de739f026af" args="(const struct evhttp_request *req)" --> int&#160;</td><td class="memItemRight" valign="bottom"><b>evhttp_request_get_response_code</b> (const struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct evkeyvalq *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a034fca99ce0cc5ff3b7f56744915a8be">evhttp_request_get_input_headers</a> (struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct evkeyvalq *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ae1321a89525b6336fce624e28de41b49">evhttp_request_get_output_headers</a> (struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structevbuffer.html">evbuffer</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#aa939f28c8da2a8122097de23c7670321">evhttp_request_get_input_buffer</a> (struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structevbuffer.html">evbuffer</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a8dc23de32b242457db98ab566c53f71f">evhttp_request_get_output_buffer</a> (struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#aac84865e4848b8d9089e4182e12d185e">evhttp_request_get_host</a> (struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *req)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a3a36842fd6f74977c9c0fb7aa5578832">evhttp_find_header</a> (const struct evkeyvalq *headers, const char *key)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ab87600f14a6f8c36beedbeed8267b856">evhttp_remove_header</a> (struct evkeyvalq *headers, const char *key)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a04e3f41c14b8e0e74da13a8d308b93b7">evhttp_add_header</a> (struct evkeyvalq *headers, const char *key, const char *value)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#adfd33f73c8d7af63a0da05ebb32b7e72">evhttp_clear_headers</a> (struct evkeyvalq *headers)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a2b6d14272efe8d5f6bb110666a2032fd">evhttp_encode_uri</a> (const char *str)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ab64229249a981ccfea09161a199972da">evhttp_uriencode</a> (const char *str, ev_ssize_t size, int space_to_plus)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a681a8e967dec9f73fb8e27f465fdae4b">evhttp_decode_uri</a> (const char *uri)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ac2914389616f04199aded10444fd8e42">evhttp_uridecode</a> (const char *uri, int decode_plus, size_t *size_out)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a12d3940d23fb53c38106f8ac0d3dfff6">evhttp_parse_query</a> (const char *uri, struct evkeyvalq *headers)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a1598fb5757f39dde6dc43dee9a2e7fca">evhttp_parse_query_str</a> (const char *uri, struct evkeyvalq *headers)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ac9318bd77cb5f4030b434bea99b3828e">evhttp_htmlescape</a> (const char *html)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a2847be10a24befd3c65d412690475110">evhttp_uri_new</a> (void)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#aea0b990f1ca5ba71feffa96c8f6bd06b">evhttp_uri_set_flags</a> (struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri, unsigned flags)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a6f49cc20f421d2f66907c613d24ad3dc">evhttp_uri_get_scheme</a> (const struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#adfc9eeca8691a9f55dad523e60f1a467">evhttp_uri_get_userinfo</a> (const struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a2d45134ab552432fbe25eb2ff646f906">evhttp_uri_get_host</a> (const struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a60d456504f4f93f61384eb0b526f5a4c">evhttp_uri_get_port</a> (const struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a49e685022515780b3dfb4d944b4cce4d">evhttp_uri_get_path</a> (const struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a9a8c53b664a23dbdebd99d768a17590e">evhttp_uri_get_query</a> (const struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ad7fcd64c02bb074bc9c754e8107550c1">evhttp_uri_get_fragment</a> (const struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#abf5f82fb9c8f8df0b1b4c73691791dd5">evhttp_uri_set_scheme</a> (struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri, const char *scheme)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ac7b10b8ef8ee94d14674f9329486d355">evhttp_uri_set_userinfo</a> (struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri, const char *userinfo)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a103c447efb9f41a5897b3aa130424734">evhttp_uri_set_host</a> (struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri, const char *host)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a8cc430f9b8fb4c6aa11692d5ef0b383c">evhttp_uri_set_port</a> (struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri, int port)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ae6bbfc5cf62df674ba72800ea46c5828">evhttp_uri_set_path</a> (struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri, const char *path)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#aaf999637136bc1785e5d75c191c671ba">evhttp_uri_set_query</a> (struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri, const char *query)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a36b844028058c82b6709d1e0fe7e1cf9">evhttp_uri_set_fragment</a> (struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri, const char *fragment)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#ad9f9447cb1c3c92e40478b98ff30db60">evhttp_uri_parse_with_flags</a> (const char *source_uri, unsigned flags)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a47bc072177c8e839083c511a618a422c">evhttp_uri_parse</a> (const char *source_uri)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a5ee82311278b8fda3ed93a8e358683bb">evhttp_uri_free</a> (struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="http_8h.html#a60f7217fccc2bdfb9cb6abeb1c4ad102">evhttp_uri_join</a> (struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *uri, char *buf, size_t limit)</td></tr> </table> <hr/><a name="details" id="details"></a><h2>Detailed Description</h2> <div class="textblock"><p>Basic support for HTTP serving.</p> <p>As Libevent is a library for dealing with event notification and most interesting applications are networked today, I have often found the need to write HTTP code. The following prototypes and definitions provide an application with a minimal interface for making HTTP requests and for creating a very simple HTTP server. </p> </div><hr/><h2>Define Documentation</h2> <a class="anchor" id="ace576911d436a163584f4942907270a5"></a><!-- doxytag: member="http.h::EVHTTP_URI_NONCONFORMANT" ref="ace576911d436a163584f4942907270a5" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define <a class="el" href="http_8h.html#ace576911d436a163584f4942907270a5">EVHTTP_URI_NONCONFORMANT</a>&#160;&#160;&#160;0x01</td> </tr> </table> </div> <div class="memdoc"> <p>Tolerate URIs that do not conform to RFC3986.</p> <p>Unfortunately, some HTTP clients generate URIs that, according to RFC3986, are not conformant URIs. If you need to support these URIs, you can do so by passing this flag to evhttp_uri_parse_with_flags.</p> <p>Currently, these changes are: </p> <ul> <li> Nonconformant URIs are allowed to contain otherwise unreasonable characters in their path, query, and fragment components. </li> </ul> </div> </div> <a class="anchor" id="a8d93bc2b08ddc194c213682c4726b0e6"></a><!-- doxytag: member="http.h::HTTP_BADMETHOD" ref="a8d93bc2b08ddc194c213682c4726b0e6" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define <a class="el" href="http_8h.html#a8d93bc2b08ddc194c213682c4726b0e6">HTTP_BADMETHOD</a>&#160;&#160;&#160;405</td> </tr> </table> </div> <div class="memdoc"> <p>method not allowed for this uri </p> </div> </div> <a class="anchor" id="af9f070802de32cd2f820059fc42cbf39"></a><!-- doxytag: member="http.h::HTTP_BADREQUEST" ref="af9f070802de32cd2f820059fc42cbf39" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define <a class="el" href="http_8h.html#af9f070802de32cd2f820059fc42cbf39">HTTP_BADREQUEST</a>&#160;&#160;&#160;400</td> </tr> </table> </div> <div class="memdoc"> <p>invalid http request was made </p> </div> </div> <a class="anchor" id="a64236d9bad703199d84a08bee90e00f0"></a><!-- doxytag: member="http.h::HTTP_ENTITYTOOLARGE" ref="a64236d9bad703199d84a08bee90e00f0" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define <a class="el" href="http_8h.html#a64236d9bad703199d84a08bee90e00f0">HTTP_ENTITYTOOLARGE</a>&#160;&#160;&#160;413</td> </tr> </table> </div> <div class="memdoc"> </div> </div> <a class="anchor" id="a4eac9f52d3d8de9b3deadaec6ad0bee9"></a><!-- doxytag: member="http.h::HTTP_EXPECTATIONFAILED" ref="a4eac9f52d3d8de9b3deadaec6ad0bee9" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define <a class="el" href="http_8h.html#a4eac9f52d3d8de9b3deadaec6ad0bee9">HTTP_EXPECTATIONFAILED</a>&#160;&#160;&#160;417</td> </tr> </table> </div> <div class="memdoc"> <p>we can't handle this expectation </p> </div> </div> <a class="anchor" id="a15eac402986428a8125d364b7ae569b1"></a><!-- doxytag: member="http.h::HTTP_INTERNAL" ref="a15eac402986428a8125d364b7ae569b1" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define <a class="el" href="http_8h.html#a15eac402986428a8125d364b7ae569b1">HTTP_INTERNAL</a>&#160;&#160;&#160;500</td> </tr> </table> </div> <div class="memdoc"> <p>internal error </p> </div> </div> <a class="anchor" id="ac6ffbb7b69889f1eee0d413576c609a9"></a><!-- doxytag: member="http.h::HTTP_MOVEPERM" ref="ac6ffbb7b69889f1eee0d413576c609a9" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define <a class="el" href="http_8h.html#ac6ffbb7b69889f1eee0d413576c609a9">HTTP_MOVEPERM</a>&#160;&#160;&#160;301</td> </tr> </table> </div> <div class="memdoc"> <p>the uri moved permanently </p> </div> </div> <a class="anchor" id="a7d2a7341ba2af15babe8c25df67e563f"></a><!-- doxytag: member="http.h::HTTP_MOVETEMP" ref="a7d2a7341ba2af15babe8c25df67e563f" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define <a class="el" href="http_8h.html#a7d2a7341ba2af15babe8c25df67e563f">HTTP_MOVETEMP</a>&#160;&#160;&#160;302</td> </tr> </table> </div> <div class="memdoc"> <p>the uri moved temporarily </p> </div> </div> <a class="anchor" id="ac5e3a483119375a05d199c30709f2b8e"></a><!-- doxytag: member="http.h::HTTP_NOCONTENT" ref="ac5e3a483119375a05d199c30709f2b8e" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define <a class="el" href="http_8h.html#ac5e3a483119375a05d199c30709f2b8e">HTTP_NOCONTENT</a>&#160;&#160;&#160;204</td> </tr> </table> </div> <div class="memdoc"> <p>request does not have content </p> </div> </div> <a class="anchor" id="a1f5b9c02b018640c890e5f27207fa6c0"></a><!-- doxytag: member="http.h::HTTP_NOTFOUND" ref="a1f5b9c02b018640c890e5f27207fa6c0" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define <a class="el" href="http_8h.html#a1f5b9c02b018640c890e5f27207fa6c0">HTTP_NOTFOUND</a>&#160;&#160;&#160;404</td> </tr> </table> </div> <div class="memdoc"> <p>could not find content for uri </p> </div> </div> <a class="anchor" id="a9759dd4ad026a688142afb7b4e4542cc"></a><!-- doxytag: member="http.h::HTTP_NOTIMPLEMENTED" ref="a9759dd4ad026a688142afb7b4e4542cc" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define <a class="el" href="http_8h.html#a9759dd4ad026a688142afb7b4e4542cc">HTTP_NOTIMPLEMENTED</a>&#160;&#160;&#160;501</td> </tr> </table> </div> <div class="memdoc"> <p>not implemented </p> </div> </div> <a class="anchor" id="a3112d58297965db46a04fe288bf1d0da"></a><!-- doxytag: member="http.h::HTTP_NOTMODIFIED" ref="a3112d58297965db46a04fe288bf1d0da" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define <a class="el" href="http_8h.html#a3112d58297965db46a04fe288bf1d0da">HTTP_NOTMODIFIED</a>&#160;&#160;&#160;304</td> </tr> </table> </div> <div class="memdoc"> <p>page was not modified from last </p> </div> </div> <a class="anchor" id="a02e6d59009dee759528ec81fc9a8eeff"></a><!-- doxytag: member="http.h::HTTP_OK" ref="a02e6d59009dee759528ec81fc9a8eeff" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define <a class="el" href="http_8h.html#a02e6d59009dee759528ec81fc9a8eeff">HTTP_OK</a>&#160;&#160;&#160;200</td> </tr> </table> </div> <div class="memdoc"> <p>request completed ok </p> </div> </div> <a class="anchor" id="a5fd6829fe2bb38dd13288f11dcb2025f"></a><!-- doxytag: member="http.h::HTTP_SERVUNAVAIL" ref="a5fd6829fe2bb38dd13288f11dcb2025f" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define <a class="el" href="http_8h.html#a5fd6829fe2bb38dd13288f11dcb2025f">HTTP_SERVUNAVAIL</a>&#160;&#160;&#160;503</td> </tr> </table> </div> <div class="memdoc"> <p>the server is not available </p> </div> </div> <hr/><h2>Enumeration Type Documentation</h2> <a class="anchor" id="ac858319d667267f9fc848c2bb6931aa3"></a><!-- doxytag: member="http.h::evhttp_cmd_type" ref="ac858319d667267f9fc848c2bb6931aa3" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">enum <a class="el" href="http_8h.html#ac858319d667267f9fc848c2bb6931aa3">evhttp_cmd_type</a></td> </tr> </table> </div> <div class="memdoc"> <p>The different request types supported by evhttp. These are as specified in RFC2616, except for PATCH which is specified by RFC5789.</p> <p>By default, only some of these methods are accepted and passed to user callbacks; use <a class="el" href="http_8h.html#ae63a0370f59570e00753f7fb512a7f59">evhttp_set_allowed_methods()</a> to change which methods are allowed. </p> </div> </div> <a class="anchor" id="a47ca41a942899d019bf59cf32301ae4f"></a><!-- doxytag: member="http.h::evhttp_request_kind" ref="a47ca41a942899d019bf59cf32301ae4f" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">enum <a class="el" href="http_8h.html#a47ca41a942899d019bf59cf32301ae4f">evhttp_request_kind</a></td> </tr> </table> </div> <div class="memdoc"> <p>a request object can represent either a request or a reply </p> </div> </div> <hr/><h2>Function Documentation</h2> <a class="anchor" id="aa5719654012b143ebfc0dfc9d4a8490d"></a><!-- doxytag: member="http.h::evhttp_accept_socket" ref="aa5719654012b143ebfc0dfc9d4a8490d" args="(struct evhttp *http, evutil_socket_t fd)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#aa5719654012b143ebfc0dfc9d4a8490d">evhttp_accept_socket</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="util_8h.html#a7ef0023565082a65020f6e56be59fd0b">evutil_socket_t</a>&#160;</td> <td class="paramname"><em>fd</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Makes an HTTP server accept connections on the specified socket.</p> <p>This may be useful to create a socket and then fork multiple instances of an http server, or when a socket has been communicated via file descriptor passing in situations where an http servers does not have permissions to bind to a low-numbered port.</p> <p>Can be called multiple times to have the http server listen to multiple different sockets.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">http</td><td>a pointer to an evhttp object </td></tr> <tr><td class="paramname">fd</td><td>a socket fd that is ready for accepting connections </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>0 on success, -1 on failure. </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#a80ea2b819c0997a0ecc0d915446aeaa4">evhttp_bind_socket()</a> </dd></dl> </div> </div> <a class="anchor" id="ae0b17d7e600e87cadda2352ea2135d8f"></a><!-- doxytag: member="http.h::evhttp_accept_socket_with_handle" ref="ae0b17d7e600e87cadda2352ea2135d8f" args="(struct evhttp *http, evutil_socket_t fd)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct <a class="el" href="structevhttp__bound__socket.html">evhttp_bound_socket</a>* <a class="el" href="http_8h.html#ae0b17d7e600e87cadda2352ea2135d8f">evhttp_accept_socket_with_handle</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="util_8h.html#a7ef0023565082a65020f6e56be59fd0b">evutil_socket_t</a>&#160;</td> <td class="paramname"><em>fd</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Like <a class="el" href="http_8h.html#aa5719654012b143ebfc0dfc9d4a8490d">evhttp_accept_socket()</a>, but returns a handle for referencing the socket.</p> <p>The returned pointer is not valid after <em>http</em> is freed.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">http</td><td>a pointer to an evhttp object </td></tr> <tr><td class="paramname">fd</td><td>a socket fd that is ready for accepting connections </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>Handle for the socket on success, NULL on failure. </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#aa5719654012b143ebfc0dfc9d4a8490d">evhttp_accept_socket()</a>, <a class="el" href="http_8h.html#a5404c30f3b50a664f2ec1500ebb30d86">evhttp_del_accept_socket()</a> </dd></dl> </div> </div> <a class="anchor" id="a04e3f41c14b8e0e74da13a8d308b93b7"></a><!-- doxytag: member="http.h::evhttp_add_header" ref="a04e3f41c14b8e0e74da13a8d308b93b7" args="(struct evkeyvalq *headers, const char *key, const char *value)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#a04e3f41c14b8e0e74da13a8d308b93b7">evhttp_add_header</a> </td> <td>(</td> <td class="paramtype">struct evkeyvalq *&#160;</td> <td class="paramname"><em>headers</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>key</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>value</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Adds a header to a list of existing headers.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">headers</td><td>the evkeyvalq object to which to add a header </td></tr> <tr><td class="paramname">key</td><td>the name of the header </td></tr> <tr><td class="paramname">value</td><td>the value belonging to the header </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>0 on success, -1 otherwise. </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#a3a36842fd6f74977c9c0fb7aa5578832">evhttp_find_header()</a>, <a class="el" href="http_8h.html#adfd33f73c8d7af63a0da05ebb32b7e72">evhttp_clear_headers()</a> </dd></dl> </div> </div> <a class="anchor" id="a58fe001925e7f65d7678bf90b31fc2a5"></a><!-- doxytag: member="http.h::evhttp_add_server_alias" ref="a58fe001925e7f65d7678bf90b31fc2a5" args="(struct evhttp *http, const char *alias)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#a58fe001925e7f65d7678bf90b31fc2a5">evhttp_add_server_alias</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>alias</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Add a server alias to an http object. The http object can be a virtual host or the main server.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">http</td><td>the evhttp object </td></tr> <tr><td class="paramname">alias</td><td>the alias to add </td></tr> </table> </dd> </dl> <dl class="see"><dt><b>See also:</b></dt><dd>evhttp_add_remove_alias() </dd></dl> </div> </div> <a class="anchor" id="a82d8fb72c5e8c76b787987ba5de5b141"></a><!-- doxytag: member="http.h::evhttp_add_virtual_host" ref="a82d8fb72c5e8c76b787987ba5de5b141" args="(struct evhttp *http, const char *pattern, struct evhttp *vhost)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#a82d8fb72c5e8c76b787987ba5de5b141">evhttp_add_virtual_host</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>pattern</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>vhost</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Adds a virtual host to the http server.</p> <p>A virtual host is a newly initialized evhttp object that has request callbacks set on it via <a class="el" href="http_8h.html#a5b685afe43d7f4c3bfcc7dcba72d41e0">evhttp_set_cb()</a> or <a class="el" href="http_8h.html#ad3466287c0054d32dfd538a3bdfb0374">evhttp_set_gencb()</a>. It most not have any listing sockets associated with it.</p> <p>If the virtual host has not been removed by the time that <a class="el" href="http_8h.html#a849acf0f233772b486b8057fcf3aaf4a">evhttp_free()</a> is called on the main http server, it will be automatically freed, too.</p> <p>It is possible to have hierarchical vhosts. For example: A vhost with the pattern *.example.com may have other vhosts with patterns foo.example.com and bar.example.com associated with it.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">http</td><td>the evhttp object to which to add a virtual host </td></tr> <tr><td class="paramname">pattern</td><td>the glob pattern against which the hostname is matched. The match is case insensitive and follows otherwise regular shell matching. </td></tr> <tr><td class="paramname">vhost</td><td>the virtual host to add the regular http server. </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>0 on success, -1 on failure </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#ab2eb1ac82f36e7f0180b18d4553d3994">evhttp_remove_virtual_host()</a> </dd></dl> </div> </div> <a class="anchor" id="aa86abe883e71049f03534d984dd8c625"></a><!-- doxytag: member="http.h::evhttp_bind_listener" ref="aa86abe883e71049f03534d984dd8c625" args="(struct evhttp *http, struct evconnlistener *listener)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct <a class="el" href="structevhttp__bound__socket.html">evhttp_bound_socket</a>* <a class="el" href="http_8h.html#aa86abe883e71049f03534d984dd8c625">evhttp_bind_listener</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">struct <a class="el" href="structevconnlistener.html">evconnlistener</a> *&#160;</td> <td class="paramname"><em>listener</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>The most low-level evhttp_bind/accept method: takes an evconnlistener, and returns an <a class="el" href="structevhttp__bound__socket.html">evhttp_bound_socket</a>. The listener will be freed when the bound socket is freed. </p> </div> </div> <a class="anchor" id="a80ea2b819c0997a0ecc0d915446aeaa4"></a><!-- doxytag: member="http.h::evhttp_bind_socket" ref="a80ea2b819c0997a0ecc0d915446aeaa4" args="(struct evhttp *http, const char *address, ev_uint16_t port)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#a80ea2b819c0997a0ecc0d915446aeaa4">evhttp_bind_socket</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>address</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">ev_uint16_t&#160;</td> <td class="paramname"><em>port</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Binds an HTTP server on the specified address and port.</p> <p>Can be called multiple times to bind the same http server to multiple different ports.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">http</td><td>a pointer to an evhttp object </td></tr> <tr><td class="paramname">address</td><td>a string containing the IP address to listen(2) on </td></tr> <tr><td class="paramname">port</td><td>the port number to listen on </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>0 on success, -1 on failure. </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#aa5719654012b143ebfc0dfc9d4a8490d">evhttp_accept_socket()</a> </dd></dl> </div> </div> <a class="anchor" id="a7b2e494399364cfb8071e69564c33db9"></a><!-- doxytag: member="http.h::evhttp_bind_socket_with_handle" ref="a7b2e494399364cfb8071e69564c33db9" args="(struct evhttp *http, const char *address, ev_uint16_t port)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct <a class="el" href="structevhttp__bound__socket.html">evhttp_bound_socket</a>* <a class="el" href="http_8h.html#a7b2e494399364cfb8071e69564c33db9">evhttp_bind_socket_with_handle</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>address</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">ev_uint16_t&#160;</td> <td class="paramname"><em>port</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Like <a class="el" href="http_8h.html#a80ea2b819c0997a0ecc0d915446aeaa4">evhttp_bind_socket()</a>, but returns a handle for referencing the socket.</p> <p>The returned pointer is not valid after <em>http</em> is freed.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">http</td><td>a pointer to an evhttp object </td></tr> <tr><td class="paramname">address</td><td>a string containing the IP address to listen(2) on </td></tr> <tr><td class="paramname">port</td><td>the port number to listen on </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>Handle for the socket on success, NULL on failure. </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#a80ea2b819c0997a0ecc0d915446aeaa4">evhttp_bind_socket()</a>, <a class="el" href="http_8h.html#a5404c30f3b50a664f2ec1500ebb30d86">evhttp_del_accept_socket()</a> </dd></dl> </div> </div> <a class="anchor" id="a5b5912e3d764bbd8f4952aba0f0604fa"></a><!-- doxytag: member="http.h::evhttp_bound_socket_get_fd" ref="a5b5912e3d764bbd8f4952aba0f0604fa" args="(struct evhttp_bound_socket *bound_socket)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="util_8h.html#a7ef0023565082a65020f6e56be59fd0b">evutil_socket_t</a> <a class="el" href="http_8h.html#a5b5912e3d764bbd8f4952aba0f0604fa">evhttp_bound_socket_get_fd</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__bound__socket.html">evhttp_bound_socket</a> *&#160;</td> <td class="paramname"><em>bound_socket</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Get the raw file descriptor referenced by an <a class="el" href="structevhttp__bound__socket.html">evhttp_bound_socket</a>.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">bound_socket</td><td>a handle returned by evhttp_{bind,accept}_socket_with_handle </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>the file descriptor used by the bound socket </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#a7b2e494399364cfb8071e69564c33db9">evhttp_bind_socket_with_handle()</a>, <a class="el" href="http_8h.html#ae0b17d7e600e87cadda2352ea2135d8f">evhttp_accept_socket_with_handle()</a> </dd></dl> </div> </div> <a class="anchor" id="a7b9ba15b143ece0f69a2b4c52ff9d788"></a><!-- doxytag: member="http.h::evhttp_bound_socket_get_listener" ref="a7b9ba15b143ece0f69a2b4c52ff9d788" args="(struct evhttp_bound_socket *bound)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct <a class="el" href="structevconnlistener.html">evconnlistener</a>* <a class="el" href="http_8h.html#a7b9ba15b143ece0f69a2b4c52ff9d788">evhttp_bound_socket_get_listener</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__bound__socket.html">evhttp_bound_socket</a> *&#160;</td> <td class="paramname"><em>bound</em></td><td>)</td> <td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Return the listener used to implement a bound socket. </p> </div> </div> <a class="anchor" id="ab323fe297168f0f87af832f2bddc40a0"></a><!-- doxytag: member="http.h::evhttp_cancel_request" ref="ab323fe297168f0f87af832f2bddc40a0" args="(struct evhttp_request *req)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#ab323fe297168f0f87af832f2bddc40a0">evhttp_cancel_request</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Cancels a pending HTTP request.</p> <p>Cancels an ongoing HTTP request. The callback associated with this request is not executed and the request object is freed. If the request is currently being processed, e.g. it is ongoing, the corresponding <a class="el" href="structevhttp__connection.html">evhttp_connection</a> object is going to get reset.</p> <p>A request cannot be canceled if its callback has executed already. A request may be canceled reentrantly from its chunked callback.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">req</td><td>the <a class="el" href="structevhttp__request.html">evhttp_request</a> to cancel; req becomes invalid after this call. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="adfd33f73c8d7af63a0da05ebb32b7e72"></a><!-- doxytag: member="http.h::evhttp_clear_headers" ref="adfd33f73c8d7af63a0da05ebb32b7e72" args="(struct evkeyvalq *headers)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#adfd33f73c8d7af63a0da05ebb32b7e72">evhttp_clear_headers</a> </td> <td>(</td> <td class="paramtype">struct evkeyvalq *&#160;</td> <td class="paramname"><em>headers</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Removes all headers from the header list.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">headers</td><td>the evkeyvalq object from which to remove all headers </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="af5913a2851880df25cf9ef43f7646074"></a><!-- doxytag: member="http.h::evhttp_connection_base_new" ref="af5913a2851880df25cf9ef43f7646074" args="(struct event_base *base, struct evdns_base *dnsbase, const char *address, unsigned short port)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a>* <a class="el" href="http_8h.html#af5913a2851880df25cf9ef43f7646074">evhttp_connection_base_new</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevent__base.html">event_base</a> *&#160;</td> <td class="paramname"><em>base</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">struct <a class="el" href="structevdns__base.html">evdns_base</a> *&#160;</td> <td class="paramname"><em>dnsbase</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>address</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">unsigned short&#160;</td> <td class="paramname"><em>port</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>A connection object that can be used to for making HTTP requests. The connection object tries to resolve address and establish the connection when it is given an http request object.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">base</td><td>the <a class="el" href="structevent__base.html">event_base</a> to use for handling the connection </td></tr> <tr><td class="paramname">dnsbase</td><td>the dns_base to use for resolving host names; if not specified host name resolution will block. </td></tr> <tr><td class="paramname">address</td><td>the address to which to connect </td></tr> <tr><td class="paramname">port</td><td>the port to connect to </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>an <a class="el" href="structevhttp__connection.html">evhttp_connection</a> object that can be used for making requests </dd></dl> </div> </div> <a class="anchor" id="ab5afe0ffd71e479a9d830ac3800ba599"></a><!-- doxytag: member="http.h::evhttp_connection_free" ref="ab5afe0ffd71e479a9d830ac3800ba599" args="(struct evhttp_connection *evcon)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#ab5afe0ffd71e479a9d830ac3800ba599">evhttp_connection_free</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *&#160;</td> <td class="paramname"><em>evcon</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Frees an http connection </p> </div> </div> <a class="anchor" id="aeeec8fa8b1c5836d05a0e552793b0945"></a><!-- doxytag: member="http.h::evhttp_connection_get_base" ref="aeeec8fa8b1c5836d05a0e552793b0945" args="(struct evhttp_connection *req)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct <a class="el" href="structevent__base.html">event_base</a>* <a class="el" href="http_8h.html#aeeec8fa8b1c5836d05a0e552793b0945">evhttp_connection_get_base</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *&#160;</td> <td class="paramname"><em>req</em></td><td>)</td> <td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the underlying <a class="el" href="structevent__base.html">event_base</a> for this connection </p> </div> </div> <a class="anchor" id="a39cc41e2c07c0a2042ecdd05248bd645"></a><!-- doxytag: member="http.h::evhttp_connection_get_bufferevent" ref="a39cc41e2c07c0a2042ecdd05248bd645" args="(struct evhttp_connection *evcon)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct <a class="el" href="structbufferevent.html">bufferevent</a>* <a class="el" href="http_8h.html#a39cc41e2c07c0a2042ecdd05248bd645">evhttp_connection_get_bufferevent</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *&#160;</td> <td class="paramname"><em>evcon</em></td><td>)</td> <td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Return the bufferevent that an <a class="el" href="structevhttp__connection.html">evhttp_connection</a> is using. </p> </div> </div> <a class="anchor" id="afa866e15c757e815a2e66cba7c8aa161"></a><!-- doxytag: member="http.h::evhttp_connection_get_peer" ref="afa866e15c757e815a2e66cba7c8aa161" args="(struct evhttp_connection *evcon, char **address, ev_uint16_t *port)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#afa866e15c757e815a2e66cba7c8aa161">evhttp_connection_get_peer</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *&#160;</td> <td class="paramname"><em>evcon</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">char **&#160;</td> <td class="paramname"><em>address</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">ev_uint16_t *&#160;</td> <td class="paramname"><em>port</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Get the remote address and port associated with this connection. </p> </div> </div> <a class="anchor" id="af62e12b843002e6eace204cc68da2277"></a><!-- doxytag: member="http.h::evhttp_connection_set_closecb" ref="af62e12b843002e6eace204cc68da2277" args="(struct evhttp_connection *evcon, void(*)(struct evhttp_connection *, void *), void *)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#af62e12b843002e6eace204cc68da2277">evhttp_connection_set_closecb</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *&#160;</td> <td class="paramname"><em>evcon</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">void(*)(struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *, void *)&#160;</td> <td class="paramname">, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">void *&#160;</td> <td class="paramname">&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Set a callback for connection close. </p> </div> </div> <a class="anchor" id="a839b6cd03f4377fead26e8b680e9cd7e"></a><!-- doxytag: member="http.h::evhttp_connection_set_local_address" ref="a839b6cd03f4377fead26e8b680e9cd7e" args="(struct evhttp_connection *evcon, const char *address)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#a839b6cd03f4377fead26e8b680e9cd7e">evhttp_connection_set_local_address</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *&#160;</td> <td class="paramname"><em>evcon</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>address</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>sets the ip address from which http connections are made </p> </div> </div> <a class="anchor" id="a3a325b818c5c4f48a8ba1f3cf6a49d7f"></a><!-- doxytag: member="http.h::evhttp_connection_set_local_port" ref="a3a325b818c5c4f48a8ba1f3cf6a49d7f" args="(struct evhttp_connection *evcon, ev_uint16_t port)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#a3a325b818c5c4f48a8ba1f3cf6a49d7f">evhttp_connection_set_local_port</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *&#160;</td> <td class="paramname"><em>evcon</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">ev_uint16_t&#160;</td> <td class="paramname"><em>port</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>sets the local port from which http connections are made </p> </div> </div> <a class="anchor" id="a9356b2a28a3b08bf273d027d1c40f470"></a><!-- doxytag: member="http.h::evhttp_connection_set_retries" ref="a9356b2a28a3b08bf273d027d1c40f470" args="(struct evhttp_connection *evcon, int retry_max)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#a9356b2a28a3b08bf273d027d1c40f470">evhttp_connection_set_retries</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *&#160;</td> <td class="paramname"><em>evcon</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>retry_max</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Sets the retry limit for this connection - -1 repeats indefinitely </p> </div> </div> <a class="anchor" id="aa145623b7f58efe51908c6e48060db8c"></a><!-- doxytag: member="http.h::evhttp_connection_set_timeout" ref="aa145623b7f58efe51908c6e48060db8c" args="(struct evhttp_connection *evcon, int timeout_in_secs)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#aa145623b7f58efe51908c6e48060db8c">evhttp_connection_set_timeout</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *&#160;</td> <td class="paramname"><em>evcon</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>timeout_in_secs</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Sets the timeout for events related to this connection </p> </div> </div> <a class="anchor" id="a681a8e967dec9f73fb8e27f465fdae4b"></a><!-- doxytag: member="http.h::evhttp_decode_uri" ref="a681a8e967dec9f73fb8e27f465fdae4b" args="(const char *uri)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char* <a class="el" href="http_8h.html#a681a8e967dec9f73fb8e27f465fdae4b">evhttp_decode_uri</a> </td> <td>(</td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>uri</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Helper function to sort of decode a URI-encoded string. Unlike evhttp_get_decoded_uri, it decodes all plus characters that appear _after_ the first question mark character, but no plusses that occur before. This is not a good way to decode URIs in whole or in part.</p> <p>The returned string must be freed by the caller</p> <dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000034">Deprecated:</a></b></dt><dd>This function is deprecated; you probably want to use evhttp_get_decoded_uri instead.</dd></dl> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">uri</td><td>an encoded URI </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>a newly allocated unencoded URI or NULL on failure </dd></dl> </div> </div> <a class="anchor" id="a5404c30f3b50a664f2ec1500ebb30d86"></a><!-- doxytag: member="http.h::evhttp_del_accept_socket" ref="a5404c30f3b50a664f2ec1500ebb30d86" args="(struct evhttp *http, struct evhttp_bound_socket *bound_socket)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#a5404c30f3b50a664f2ec1500ebb30d86">evhttp_del_accept_socket</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">struct <a class="el" href="structevhttp__bound__socket.html">evhttp_bound_socket</a> *&#160;</td> <td class="paramname"><em>bound_socket</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Makes an HTTP server stop accepting connections on the specified socket</p> <p>This may be useful when a socket has been sent via file descriptor passing and is no longer needed by the current process.</p> <p>If you created this bound socket with evhttp_bind_socket_with_handle or evhttp_accept_socket_with_handle, this function closes the fd you provided. If you created this bound socket with evhttp_bind_listener, this function frees the listener you provided.</p> <p><em>bound_socket</em> is an invalid pointer after this call returns.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">http</td><td>a pointer to an evhttp object </td></tr> <tr><td class="paramname">bound_socket</td><td>a handle returned by evhttp_{bind,accept}_socket_with_handle </td></tr> </table> </dd> </dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#a7b2e494399364cfb8071e69564c33db9">evhttp_bind_socket_with_handle()</a>, <a class="el" href="http_8h.html#ae0b17d7e600e87cadda2352ea2135d8f">evhttp_accept_socket_with_handle()</a> </dd></dl> </div> </div> <a class="anchor" id="a26b24365ab036cbce853fedc7818bc49"></a><!-- doxytag: member="http.h::evhttp_del_cb" ref="a26b24365ab036cbce853fedc7818bc49" args="(struct evhttp *, const char *)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#a26b24365ab036cbce853fedc7818bc49">evhttp_del_cb</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname">, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname">&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Removes the callback for a specified URI </p> </div> </div> <a class="anchor" id="a2b6d14272efe8d5f6bb110666a2032fd"></a><!-- doxytag: member="http.h::evhttp_encode_uri" ref="a2b6d14272efe8d5f6bb110666a2032fd" args="(const char *str)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char* <a class="el" href="http_8h.html#a2b6d14272efe8d5f6bb110666a2032fd">evhttp_encode_uri</a> </td> <td>(</td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>str</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Helper function to encode a string for inclusion in a URI. All characters are replaced by their hex-escaped (%22) equivalents, except for characters explicitly unreserved by RFC3986 -- that is, ASCII alphanumeric characters, hyphen, dot, underscore, and tilde.</p> <p>The returned string must be freed by the caller.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">str</td><td>an unencoded string </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>a newly allocated URI-encoded string or NULL on failure </dd></dl> </div> </div> <a class="anchor" id="a3a36842fd6f74977c9c0fb7aa5578832"></a><!-- doxytag: member="http.h::evhttp_find_header" ref="a3a36842fd6f74977c9c0fb7aa5578832" args="(const struct evkeyvalq *headers, const char *key)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const char* <a class="el" href="http_8h.html#a3a36842fd6f74977c9c0fb7aa5578832">evhttp_find_header</a> </td> <td>(</td> <td class="paramtype">const struct evkeyvalq *&#160;</td> <td class="paramname"><em>headers</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>key</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Finds the value belonging to a header.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">headers</td><td>the evkeyvalq object in which to find the header </td></tr> <tr><td class="paramname">key</td><td>the name of the header to find </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>a pointer to the value for the header or NULL if the header count not be found. </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#a04e3f41c14b8e0e74da13a8d308b93b7">evhttp_add_header()</a>, <a class="el" href="http_8h.html#ab87600f14a6f8c36beedbeed8267b856">evhttp_remove_header()</a> </dd></dl> </div> </div> <a class="anchor" id="a849acf0f233772b486b8057fcf3aaf4a"></a><!-- doxytag: member="http.h::evhttp_free" ref="a849acf0f233772b486b8057fcf3aaf4a" args="(struct evhttp *http)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#a849acf0f233772b486b8057fcf3aaf4a">evhttp_free</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Free the previously created HTTP server.</p> <p>Works only if no requests are currently being served.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">http</td><td>the evhttp server object to be freed </td></tr> </table> </dd> </dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http__compat_8h.html#aff4e96ef72ca014740878e3e5f02befc">evhttp_start()</a> </dd></dl> </div> </div> <a class="anchor" id="ac9318bd77cb5f4030b434bea99b3828e"></a><!-- doxytag: member="http.h::evhttp_htmlescape" ref="ac9318bd77cb5f4030b434bea99b3828e" args="(const char *html)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char* <a class="el" href="http_8h.html#ac9318bd77cb5f4030b434bea99b3828e">evhttp_htmlescape</a> </td> <td>(</td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>html</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Escape HTML character entities in a string.</p> <p>Replaces &lt;, &gt;, ", ' and &amp; with &lt;, &gt;, ", &amp;#039; and &amp; correspondingly.</p> <p>The returned string needs to be freed by the caller.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">html</td><td>an unescaped HTML string </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>an escaped HTML string or NULL on error </dd></dl> </div> </div> <a class="anchor" id="a70af2a5e67da78782e06c640b9f85d4e"></a><!-- doxytag: member="http.h::evhttp_make_request" ref="a70af2a5e67da78782e06c640b9f85d4e" args="(struct evhttp_connection *evcon, struct evhttp_request *req, enum evhttp_cmd_type type, const char *uri)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#a70af2a5e67da78782e06c640b9f85d4e">evhttp_make_request</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a> *&#160;</td> <td class="paramname"><em>evcon</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">enum <a class="el" href="http_8h.html#ac858319d667267f9fc848c2bb6931aa3">evhttp_cmd_type</a>&#160;</td> <td class="paramname"><em>type</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>uri</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Make an HTTP request over the specified connection.</p> <p>The connection gets ownership of the request. On failure, the request object is no longer valid as it has been freed.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">evcon</td><td>the <a class="el" href="structevhttp__connection.html">evhttp_connection</a> object over which to send the request </td></tr> <tr><td class="paramname">req</td><td>the previously created and configured request object </td></tr> <tr><td class="paramname">type</td><td>the request type EVHTTP_REQ_GET, EVHTTP_REQ_POST, etc. </td></tr> <tr><td class="paramname">uri</td><td>the URI associated with the request </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>0 on success, -1 on failure </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#ab323fe297168f0f87af832f2bddc40a0">evhttp_cancel_request()</a> </dd></dl> </div> </div> <a class="anchor" id="ab8c84271a97fd85957cf72b1161b8216"></a><!-- doxytag: member="http.h::evhttp_new" ref="ab8c84271a97fd85957cf72b1161b8216" args="(struct event_base *base)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct <a class="el" href="structevhttp.html">evhttp</a>* <a class="el" href="http_8h.html#ab8c84271a97fd85957cf72b1161b8216">evhttp_new</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevent__base.html">event_base</a> *&#160;</td> <td class="paramname"><em>base</em></td><td>)</td> <td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Create a new HTTP server.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">base</td><td>(optional) the event base to receive the HTTP events </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>a pointer to a newly initialized evhttp server structure </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#a849acf0f233772b486b8057fcf3aaf4a">evhttp_free()</a> </dd></dl> </div> </div> <a class="anchor" id="a12d3940d23fb53c38106f8ac0d3dfff6"></a><!-- doxytag: member="http.h::evhttp_parse_query" ref="a12d3940d23fb53c38106f8ac0d3dfff6" args="(const char *uri, struct evkeyvalq *headers)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#a12d3940d23fb53c38106f8ac0d3dfff6">evhttp_parse_query</a> </td> <td>(</td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>uri</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">struct evkeyvalq *&#160;</td> <td class="paramname"><em>headers</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Helper function to parse out arguments in a query.</p> <p>Parsing a URI like</p> <p><a href="http://foo.com/?q=test&s=some+thing">http://foo.com/?q=test&amp;s=some+thing</a></p> <p>will result in two entries in the key value queue.</p> <p>The first entry is: key="q", value="test" The second entry is: key="s", value="some thing"</p> <dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000035">Deprecated:</a></b></dt><dd>This function is deprecated as of Libevent 2.0.9. Use evhttp_uri_parse and evhttp_parse_query_str instead.</dd></dl> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">uri</td><td>the request URI </td></tr> <tr><td class="paramname">headers</td><td>the head of the evkeyval queue </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>0 on success, -1 on failure </dd></dl> </div> </div> <a class="anchor" id="a1598fb5757f39dde6dc43dee9a2e7fca"></a><!-- doxytag: member="http.h::evhttp_parse_query_str" ref="a1598fb5757f39dde6dc43dee9a2e7fca" args="(const char *uri, struct evkeyvalq *headers)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#a1598fb5757f39dde6dc43dee9a2e7fca">evhttp_parse_query_str</a> </td> <td>(</td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>uri</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">struct evkeyvalq *&#160;</td> <td class="paramname"><em>headers</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Helper function to parse out arguments from the query portion of an HTTP URI.</p> <p>Parsing a query string like</p> <p>q=test&amp;s=some+thing</p> <p>will result in two entries in the key value queue.</p> <p>The first entry is: key="q", value="test" The second entry is: key="s", value="some thing"</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">query_parse</td><td>the query portion of the URI </td></tr> <tr><td class="paramname">headers</td><td>the head of the evkeyval queue </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>0 on success, -1 on failure </dd></dl> </div> </div> <a class="anchor" id="ab87600f14a6f8c36beedbeed8267b856"></a><!-- doxytag: member="http.h::evhttp_remove_header" ref="ab87600f14a6f8c36beedbeed8267b856" args="(struct evkeyvalq *headers, const char *key)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#ab87600f14a6f8c36beedbeed8267b856">evhttp_remove_header</a> </td> <td>(</td> <td class="paramtype">struct evkeyvalq *&#160;</td> <td class="paramname"><em>headers</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>key</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Removes a header from a list of existing headers.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">headers</td><td>the evkeyvalq object from which to remove a header </td></tr> <tr><td class="paramname">key</td><td>the name of the header to remove </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>0 if the header was removed, -1 otherwise. </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#a3a36842fd6f74977c9c0fb7aa5578832">evhttp_find_header()</a>, <a class="el" href="http_8h.html#a04e3f41c14b8e0e74da13a8d308b93b7">evhttp_add_header()</a> </dd></dl> </div> </div> <a class="anchor" id="a88fe4c5507e88c4db284ea30a0478e5d"></a><!-- doxytag: member="http.h::evhttp_remove_server_alias" ref="a88fe4c5507e88c4db284ea30a0478e5d" args="(struct evhttp *http, const char *alias)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#a88fe4c5507e88c4db284ea30a0478e5d">evhttp_remove_server_alias</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>alias</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Remove a server alias from an http object.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">http</td><td>the evhttp object </td></tr> <tr><td class="paramname">alias</td><td>the alias to remove </td></tr> </table> </dd> </dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#a58fe001925e7f65d7678bf90b31fc2a5">evhttp_add_server_alias()</a> </dd></dl> </div> </div> <a class="anchor" id="ab2eb1ac82f36e7f0180b18d4553d3994"></a><!-- doxytag: member="http.h::evhttp_remove_virtual_host" ref="ab2eb1ac82f36e7f0180b18d4553d3994" args="(struct evhttp *http, struct evhttp *vhost)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#ab2eb1ac82f36e7f0180b18d4553d3994">evhttp_remove_virtual_host</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>vhost</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Removes a virtual host from the http server.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">http</td><td>the evhttp object from which to remove the virtual host </td></tr> <tr><td class="paramname">vhost</td><td>the virtual host to remove from the regular http server. </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>0 on success, -1 on failure </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#a82d8fb72c5e8c76b787987ba5de5b141">evhttp_add_virtual_host()</a> </dd></dl> </div> </div> <a class="anchor" id="aad0392c873fa034be3ff09d4f8b68aba"></a><!-- doxytag: member="http.h::evhttp_request_free" ref="aad0392c873fa034be3ff09d4f8b68aba" args="(struct evhttp_request *req)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#aad0392c873fa034be3ff09d4f8b68aba">evhttp_request_free</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Frees the request object and removes associated events. </p> </div> </div> <a class="anchor" id="a552bcfe23acec6858742e44a1b932dad"></a><!-- doxytag: member="http.h::evhttp_request_get_command" ref="a552bcfe23acec6858742e44a1b932dad" args="(const struct evhttp_request *req)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">enum <a class="el" href="http_8h.html#ac858319d667267f9fc848c2bb6931aa3">evhttp_cmd_type</a> <a class="el" href="http_8h.html#a552bcfe23acec6858742e44a1b932dad">evhttp_request_get_command</a> </td> <td>(</td> <td class="paramtype">const struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the request command </p> </div> </div> <a class="anchor" id="a92a534f00172fa452c45c9f3fc42d6f5"></a><!-- doxytag: member="http.h::evhttp_request_get_connection" ref="a92a534f00172fa452c45c9f3fc42d6f5" args="(struct evhttp_request *req)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct <a class="el" href="structevhttp__connection.html">evhttp_connection</a>* <a class="el" href="http_8h.html#a92a534f00172fa452c45c9f3fc42d6f5">evhttp_request_get_connection</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em></td><td>)</td> <td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the connection object associated with the request or NULL</p> <p>The user needs to either free the request explicitly or call <a class="el" href="http_8h.html#a77024706313626c5857089b08ec5e0ae">evhttp_send_reply_end()</a>. </p> </div> </div> <a class="anchor" id="a4cc0812787263e4473b2bd25fcade9c2"></a><!-- doxytag: member="http.h::evhttp_request_get_evhttp_uri" ref="a4cc0812787263e4473b2bd25fcade9c2" args="(const struct evhttp_request *req)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a>* <a class="el" href="http_8h.html#a4cc0812787263e4473b2bd25fcade9c2">evhttp_request_get_evhttp_uri</a> </td> <td>(</td> <td class="paramtype">const struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em></td><td>)</td> <td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the request URI (parsed) </p> </div> </div> <a class="anchor" id="aac84865e4848b8d9089e4182e12d185e"></a><!-- doxytag: member="http.h::evhttp_request_get_host" ref="aac84865e4848b8d9089e4182e12d185e" args="(struct evhttp_request *req)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const char* <a class="el" href="http_8h.html#aac84865e4848b8d9089e4182e12d185e">evhttp_request_get_host</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the host associated with the request. If a client sends an absolute URI, the host part of that is preferred. Otherwise, the input headers are searched for a Host: header. NULL is returned if no absolute URI or Host: header is provided. </p> </div> </div> <a class="anchor" id="aa939f28c8da2a8122097de23c7670321"></a><!-- doxytag: member="http.h::evhttp_request_get_input_buffer" ref="aa939f28c8da2a8122097de23c7670321" args="(struct evhttp_request *req)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct <a class="el" href="structevbuffer.html">evbuffer</a>* <a class="el" href="http_8h.html#aa939f28c8da2a8122097de23c7670321">evhttp_request_get_input_buffer</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em></td><td>)</td> <td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the input buffer </p> </div> </div> <a class="anchor" id="a034fca99ce0cc5ff3b7f56744915a8be"></a><!-- doxytag: member="http.h::evhttp_request_get_input_headers" ref="a034fca99ce0cc5ff3b7f56744915a8be" args="(struct evhttp_request *req)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct evkeyvalq* <a class="el" href="http_8h.html#a034fca99ce0cc5ff3b7f56744915a8be">evhttp_request_get_input_headers</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em></td><td>)</td> <td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the input headers </p> </div> </div> <a class="anchor" id="a8dc23de32b242457db98ab566c53f71f"></a><!-- doxytag: member="http.h::evhttp_request_get_output_buffer" ref="a8dc23de32b242457db98ab566c53f71f" args="(struct evhttp_request *req)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct <a class="el" href="structevbuffer.html">evbuffer</a>* <a class="el" href="http_8h.html#a8dc23de32b242457db98ab566c53f71f">evhttp_request_get_output_buffer</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em></td><td>)</td> <td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the output buffer </p> </div> </div> <a class="anchor" id="ae1321a89525b6336fce624e28de41b49"></a><!-- doxytag: member="http.h::evhttp_request_get_output_headers" ref="ae1321a89525b6336fce624e28de41b49" args="(struct evhttp_request *req)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct evkeyvalq* <a class="el" href="http_8h.html#ae1321a89525b6336fce624e28de41b49">evhttp_request_get_output_headers</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em></td><td>)</td> <td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the output headers </p> </div> </div> <a class="anchor" id="a78ce0bb30083afddb525cb9fa0b30ae0"></a><!-- doxytag: member="http.h::evhttp_request_get_uri" ref="a78ce0bb30083afddb525cb9fa0b30ae0" args="(const struct evhttp_request *req)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const char* <a class="el" href="http_8h.html#a78ce0bb30083afddb525cb9fa0b30ae0">evhttp_request_get_uri</a> </td> <td>(</td> <td class="paramtype">const struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the request URI </p> </div> </div> <a class="anchor" id="a25516c0fb1b0ef47c81f623da3782bd1"></a><!-- doxytag: member="http.h::evhttp_request_is_owned" ref="a25516c0fb1b0ef47c81f623da3782bd1" args="(struct evhttp_request *req)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#a25516c0fb1b0ef47c81f623da3782bd1">evhttp_request_is_owned</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Returns 1 if the request is owned by the user </p> </div> </div> <a class="anchor" id="a2f40f147e37f9a40f8ef684fb8f2d6b0"></a><!-- doxytag: member="http.h::evhttp_request_new" ref="a2f40f147e37f9a40f8ef684fb8f2d6b0" args="(void(*cb)(struct evhttp_request *, void *), void *arg)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct <a class="el" href="structevhttp__request.html">evhttp_request</a>* <a class="el" href="http_8h.html#a2f40f147e37f9a40f8ef684fb8f2d6b0">evhttp_request_new</a> </td> <td>(</td> <td class="paramtype">void(*)(struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *, void *)&#160;</td> <td class="paramname"><em>cb</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">void *&#160;</td> <td class="paramname"><em>arg</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Creates a new request object that needs to be filled in with the request parameters. The callback is executed when the request completed or an error occurred. </p> </div> </div> <a class="anchor" id="a93a13d12f579bf22af35e2f1a6d82f4c"></a><!-- doxytag: member="http.h::evhttp_request_own" ref="a93a13d12f579bf22af35e2f1a6d82f4c" args="(struct evhttp_request *req)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#a93a13d12f579bf22af35e2f1a6d82f4c">evhttp_request_own</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Takes ownership of the request object</p> <p>Can be used in a request callback to keep onto the request until <a class="el" href="http_8h.html#aad0392c873fa034be3ff09d4f8b68aba">evhttp_request_free()</a> is explicitly called by the user. </p> </div> </div> <a class="anchor" id="a3dd375d81eac9baabc53749ed025ec12"></a><!-- doxytag: member="http.h::evhttp_request_set_chunked_cb" ref="a3dd375d81eac9baabc53749ed025ec12" args="(struct evhttp_request *, void(*cb)(struct evhttp_request *, void *))" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#a3dd375d81eac9baabc53749ed025ec12">evhttp_request_set_chunked_cb</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname">, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">void(*)(struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *, void *)&#160;</td> <td class="paramname"><em>cb</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Enable delivery of chunks to requestor. </p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">cb</td><td>will be called after every read of data with the same argument as the completion callback. Will never be called on an empty response. May drain the input buffer; it will be drained automatically on return. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a629ef7f70ed916e162dee3bd12e397c9"></a><!-- doxytag: member="http.h::evhttp_send_error" ref="a629ef7f70ed916e162dee3bd12e397c9" args="(struct evhttp_request *req, int error, const char *reason)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#a629ef7f70ed916e162dee3bd12e397c9">evhttp_send_error</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>error</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>reason</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Send an HTML error message to the client.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">req</td><td>a request object </td></tr> <tr><td class="paramname">error</td><td>the HTTP error code </td></tr> <tr><td class="paramname">reason</td><td>a brief explanation of the error. If this is NULL, we'll just use the standard meaning of the error code. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a9df5ec9adc9bc664db5d6b161a293525"></a><!-- doxytag: member="http.h::evhttp_send_reply" ref="a9df5ec9adc9bc664db5d6b161a293525" args="(struct evhttp_request *req, int code, const char *reason, struct evbuffer *databuf)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#a9df5ec9adc9bc664db5d6b161a293525">evhttp_send_reply</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>code</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>reason</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">struct <a class="el" href="structevbuffer.html">evbuffer</a> *&#160;</td> <td class="paramname"><em>databuf</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Send an HTML reply to the client.</p> <p>The body of the reply consists of the data in databuf. After calling <a class="el" href="http_8h.html#a9df5ec9adc9bc664db5d6b161a293525">evhttp_send_reply()</a> databuf will be empty, but the buffer is still owned by the caller and needs to be deallocated by the caller if necessary.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">req</td><td>a request object </td></tr> <tr><td class="paramname">code</td><td>the HTTP response code to send </td></tr> <tr><td class="paramname">reason</td><td>a brief message to send with the response code </td></tr> <tr><td class="paramname">databuf</td><td>the body of the response </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a7950f70e66678fda56fdf8288811639c"></a><!-- doxytag: member="http.h::evhttp_send_reply_chunk" ref="a7950f70e66678fda56fdf8288811639c" args="(struct evhttp_request *req, struct evbuffer *databuf)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#a7950f70e66678fda56fdf8288811639c">evhttp_send_reply_chunk</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">struct <a class="el" href="structevbuffer.html">evbuffer</a> *&#160;</td> <td class="paramname"><em>databuf</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Send another data chunk as part of an ongoing chunked reply.</p> <p>The reply chunk consists of the data in databuf. After calling <a class="el" href="http_8h.html#a7950f70e66678fda56fdf8288811639c">evhttp_send_reply_chunk()</a> databuf will be empty, but the buffer is still owned by the caller and needs to be deallocated by the caller if necessary.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">req</td><td>a request object </td></tr> <tr><td class="paramname">databuf</td><td>the data chunk to send as part of the reply. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a77024706313626c5857089b08ec5e0ae"></a><!-- doxytag: member="http.h::evhttp_send_reply_end" ref="a77024706313626c5857089b08ec5e0ae" args="(struct evhttp_request *req)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#a77024706313626c5857089b08ec5e0ae">evhttp_send_reply_end</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Complete a chunked reply, freeing the request as appropriate.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">req</td><td>a request object </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a69c93aab46133521997cdfb8c2e07195"></a><!-- doxytag: member="http.h::evhttp_send_reply_start" ref="a69c93aab46133521997cdfb8c2e07195" args="(struct evhttp_request *req, int code, const char *reason)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#a69c93aab46133521997cdfb8c2e07195">evhttp_send_reply_start</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *&#160;</td> <td class="paramname"><em>req</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>code</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>reason</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Initiate a reply that uses Transfer-Encoding chunked.</p> <p>This allows the caller to stream the reply back to the client and is useful when either not all of the reply data is immediately available or when sending very large replies.</p> <p>The caller needs to supply data chunks with <a class="el" href="http_8h.html#a7950f70e66678fda56fdf8288811639c">evhttp_send_reply_chunk()</a> and complete the reply by calling <a class="el" href="http_8h.html#a77024706313626c5857089b08ec5e0ae">evhttp_send_reply_end()</a>.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">req</td><td>a request object </td></tr> <tr><td class="paramname">code</td><td>the HTTP response code to send </td></tr> <tr><td class="paramname">reason</td><td>a brief message to send with the response code </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="ae63a0370f59570e00753f7fb512a7f59"></a><!-- doxytag: member="http.h::evhttp_set_allowed_methods" ref="ae63a0370f59570e00753f7fb512a7f59" args="(struct evhttp *http, ev_uint16_t methods)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#ae63a0370f59570e00753f7fb512a7f59">evhttp_set_allowed_methods</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">ev_uint16_t&#160;</td> <td class="paramname"><em>methods</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Sets the what HTTP methods are supported in requests accepted by this server, and passed to user callbacks.</p> <p>If not supported they will generate a "405 Method not allowed" response.</p> <p>By default this includes the following methods: GET, POST, HEAD, PUT, DELETE</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">http</td><td>the http server on which to set the methods </td></tr> <tr><td class="paramname">methods</td><td>bit mask constructed from evhttp_cmd_type values </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a5b685afe43d7f4c3bfcc7dcba72d41e0"></a><!-- doxytag: member="http.h::evhttp_set_cb" ref="a5b685afe43d7f4c3bfcc7dcba72d41e0" args="(struct evhttp *http, const char *path, void(*cb)(struct evhttp_request *, void *), void *cb_arg)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#a5b685afe43d7f4c3bfcc7dcba72d41e0">evhttp_set_cb</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>path</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">void(*)(struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *, void *)&#160;</td> <td class="paramname"><em>cb</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">void *&#160;</td> <td class="paramname"><em>cb_arg</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Set a callback for a specified URI</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">http</td><td>the http sever on which to set the callback </td></tr> <tr><td class="paramname">path</td><td>the path for which to invoke the callback </td></tr> <tr><td class="paramname">cb</td><td>the callback function that gets invoked on requesting path </td></tr> <tr><td class="paramname">cb_arg</td><td>an additional context argument for the callback </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>0 on success, -1 if the callback existed already, -2 on failure </dd></dl> </div> </div> <a class="anchor" id="ad3466287c0054d32dfd538a3bdfb0374"></a><!-- doxytag: member="http.h::evhttp_set_gencb" ref="ad3466287c0054d32dfd538a3bdfb0374" args="(struct evhttp *http, void(*cb)(struct evhttp_request *, void *), void *arg)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#ad3466287c0054d32dfd538a3bdfb0374">evhttp_set_gencb</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">void(*)(struct <a class="el" href="structevhttp__request.html">evhttp_request</a> *, void *)&#160;</td> <td class="paramname"><em>cb</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">void *&#160;</td> <td class="paramname"><em>arg</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Set a callback for all requests that are not caught by specific callbacks</p> <p>Invokes the specified callback for all requests that do not match any of the previously specified request paths. This is catchall for requests not specifically configured with <a class="el" href="http_8h.html#a5b685afe43d7f4c3bfcc7dcba72d41e0">evhttp_set_cb()</a>.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">http</td><td>the evhttp server object for which to set the callback </td></tr> <tr><td class="paramname">cb</td><td>the callback to invoke for any unmatched requests </td></tr> <tr><td class="paramname">arg</td><td>an context argument for the callback </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a8406065dcb34f9a058b2a7a6988ac351"></a><!-- doxytag: member="http.h::evhttp_set_max_body_size" ref="a8406065dcb34f9a058b2a7a6988ac351" args="(struct evhttp *http, ev_ssize_t max_body_size)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#a8406065dcb34f9a058b2a7a6988ac351">evhttp_set_max_body_size</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">ev_ssize_t&#160;</td> <td class="paramname"><em>max_body_size</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>XXX Document. </p> </div> </div> <a class="anchor" id="ae936aa6e7b0cb9617d0548a952db93cf"></a><!-- doxytag: member="http.h::evhttp_set_max_headers_size" ref="ae936aa6e7b0cb9617d0548a952db93cf" args="(struct evhttp *http, ev_ssize_t max_headers_size)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#ae936aa6e7b0cb9617d0548a952db93cf">evhttp_set_max_headers_size</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">ev_ssize_t&#160;</td> <td class="paramname"><em>max_headers_size</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>XXX Document. </p> </div> </div> <a class="anchor" id="acc8bb4d9e196f957510b5db9f6a02e44"></a><!-- doxytag: member="http.h::evhttp_set_timeout" ref="acc8bb4d9e196f957510b5db9f6a02e44" args="(struct evhttp *http, int timeout_in_secs)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#acc8bb4d9e196f957510b5db9f6a02e44">evhttp_set_timeout</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp.html">evhttp</a> *&#160;</td> <td class="paramname"><em>http</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>timeout_in_secs</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Set the timeout for an HTTP request.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">http</td><td>an evhttp object </td></tr> <tr><td class="paramname">timeout_in_secs</td><td>the timeout, in seconds </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a5ee82311278b8fda3ed93a8e358683bb"></a><!-- doxytag: member="http.h::evhttp_uri_free" ref="a5ee82311278b8fda3ed93a8e358683bb" args="(struct evhttp_uri *uri)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#a5ee82311278b8fda3ed93a8e358683bb">evhttp_uri_free</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Free all memory allocated for a parsed uri. Only use this for URIs generated by evhttp_uri_parse.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">uri</td><td>container with parsed data </td></tr> </table> </dd> </dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#a47bc072177c8e839083c511a618a422c">evhttp_uri_parse()</a> </dd></dl> </div> </div> <a class="anchor" id="ad7fcd64c02bb074bc9c754e8107550c1"></a><!-- doxytag: member="http.h::evhttp_uri_get_fragment" ref="ad7fcd64c02bb074bc9c754e8107550c1" args="(const struct evhttp_uri *uri)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const char* <a class="el" href="http_8h.html#ad7fcd64c02bb074bc9c754e8107550c1">evhttp_uri_get_fragment</a> </td> <td>(</td> <td class="paramtype">const struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Return the fragment part of an <a class="el" href="structevhttp__uri.html">evhttp_uri</a> (excluding the leading "#"), or NULL if it has no fragment set </p> </div> </div> <a class="anchor" id="a2d45134ab552432fbe25eb2ff646f906"></a><!-- doxytag: member="http.h::evhttp_uri_get_host" ref="a2d45134ab552432fbe25eb2ff646f906" args="(const struct evhttp_uri *uri)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const char* <a class="el" href="http_8h.html#a2d45134ab552432fbe25eb2ff646f906">evhttp_uri_get_host</a> </td> <td>(</td> <td class="paramtype">const struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Return the host part of an <a class="el" href="structevhttp__uri.html">evhttp_uri</a>, or NULL if it has no host set. The host may either be a regular hostname (conforming to the RFC 3986 "regname" production), or an IPv4 address, or the empty string, or a bracketed IPv6 address, or a bracketed 'IP-Future' address.</p> <p>Note that having a NULL host means that the URI has no authority section, but having an empty-string host means that the URI has an authority section with no host part. For example, "mailto:user@example.com" has a host of NULL, but "file:///etc/motd" has a host of "". </p> </div> </div> <a class="anchor" id="a49e685022515780b3dfb4d944b4cce4d"></a><!-- doxytag: member="http.h::evhttp_uri_get_path" ref="a49e685022515780b3dfb4d944b4cce4d" args="(const struct evhttp_uri *uri)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const char* <a class="el" href="http_8h.html#a49e685022515780b3dfb4d944b4cce4d">evhttp_uri_get_path</a> </td> <td>(</td> <td class="paramtype">const struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Return the path part of an <a class="el" href="structevhttp__uri.html">evhttp_uri</a>, or NULL if it has no path set </p> </div> </div> <a class="anchor" id="a60d456504f4f93f61384eb0b526f5a4c"></a><!-- doxytag: member="http.h::evhttp_uri_get_port" ref="a60d456504f4f93f61384eb0b526f5a4c" args="(const struct evhttp_uri *uri)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#a60d456504f4f93f61384eb0b526f5a4c">evhttp_uri_get_port</a> </td> <td>(</td> <td class="paramtype">const struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Return the port part of an <a class="el" href="structevhttp__uri.html">evhttp_uri</a>, or -1 if there is no port set. </p> </div> </div> <a class="anchor" id="a9a8c53b664a23dbdebd99d768a17590e"></a><!-- doxytag: member="http.h::evhttp_uri_get_query" ref="a9a8c53b664a23dbdebd99d768a17590e" args="(const struct evhttp_uri *uri)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const char* <a class="el" href="http_8h.html#a9a8c53b664a23dbdebd99d768a17590e">evhttp_uri_get_query</a> </td> <td>(</td> <td class="paramtype">const struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Return the query part of an <a class="el" href="structevhttp__uri.html">evhttp_uri</a> (excluding the leading "?"), or NULL if it has no query set </p> </div> </div> <a class="anchor" id="a6f49cc20f421d2f66907c613d24ad3dc"></a><!-- doxytag: member="http.h::evhttp_uri_get_scheme" ref="a6f49cc20f421d2f66907c613d24ad3dc" args="(const struct evhttp_uri *uri)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const char* <a class="el" href="http_8h.html#a6f49cc20f421d2f66907c613d24ad3dc">evhttp_uri_get_scheme</a> </td> <td>(</td> <td class="paramtype">const struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Return the scheme of an <a class="el" href="structevhttp__uri.html">evhttp_uri</a>, or NULL if there is no scheme has been set and the <a class="el" href="structevhttp__uri.html">evhttp_uri</a> contains a Relative-Ref. </p> </div> </div> <a class="anchor" id="adfc9eeca8691a9f55dad523e60f1a467"></a><!-- doxytag: member="http.h::evhttp_uri_get_userinfo" ref="adfc9eeca8691a9f55dad523e60f1a467" args="(const struct evhttp_uri *uri)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const char* <a class="el" href="http_8h.html#adfc9eeca8691a9f55dad523e60f1a467">evhttp_uri_get_userinfo</a> </td> <td>(</td> <td class="paramtype">const struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Return the userinfo part of an <a class="el" href="structevhttp__uri.html">evhttp_uri</a>, or NULL if it has no userinfo set. </p> </div> </div> <a class="anchor" id="a60f7217fccc2bdfb9cb6abeb1c4ad102"></a><!-- doxytag: member="http.h::evhttp_uri_join" ref="a60f7217fccc2bdfb9cb6abeb1c4ad102" args="(struct evhttp_uri *uri, char *buf, size_t limit)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char* <a class="el" href="http_8h.html#a60f7217fccc2bdfb9cb6abeb1c4ad102">evhttp_uri_join</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">char *&#160;</td> <td class="paramname"><em>buf</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">size_t&#160;</td> <td class="paramname"><em>limit</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Join together the uri parts from parsed data to form a URI-Reference.</p> <p>Note that no escaping of reserved characters is done on the members of the <a class="el" href="structevhttp__uri.html">evhttp_uri</a>, so the generated string might not be a valid URI unless the members of <a class="el" href="structevhttp__uri.html">evhttp_uri</a> are themselves valid.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">uri</td><td>container with parsed data </td></tr> <tr><td class="paramname">buf</td><td>destination buffer </td></tr> <tr><td class="paramname">limit</td><td>destination buffer size </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>an joined uri as string or NULL on error </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#a47bc072177c8e839083c511a618a422c">evhttp_uri_parse()</a> </dd></dl> </div> </div> <a class="anchor" id="a2847be10a24befd3c65d412690475110"></a><!-- doxytag: member="http.h::evhttp_uri_new" ref="a2847be10a24befd3c65d412690475110" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a>* <a class="el" href="http_8h.html#a2847be10a24befd3c65d412690475110">evhttp_uri_new</a> </td> <td>(</td> <td class="paramtype">void&#160;</td> <td class="paramname"></td><td>)</td> <td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Return a new empty <a class="el" href="structevhttp__uri.html">evhttp_uri</a> with no fields set. </p> </div> </div> <a class="anchor" id="a47bc072177c8e839083c511a618a422c"></a><!-- doxytag: member="http.h::evhttp_uri_parse" ref="a47bc072177c8e839083c511a618a422c" args="(const char *source_uri)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a>* <a class="el" href="http_8h.html#a47bc072177c8e839083c511a618a422c">evhttp_uri_parse</a> </td> <td>(</td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>source_uri</em></td><td>)</td> <td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Alias for evhttp_uri_parse_with_flags(source_uri, 0) </p> </div> </div> <a class="anchor" id="ad9f9447cb1c3c92e40478b98ff30db60"></a><!-- doxytag: member="http.h::evhttp_uri_parse_with_flags" ref="ad9f9447cb1c3c92e40478b98ff30db60" args="(const char *source_uri, unsigned flags)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a>* <a class="el" href="http_8h.html#ad9f9447cb1c3c92e40478b98ff30db60">evhttp_uri_parse_with_flags</a> </td> <td>(</td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>source_uri</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">unsigned&#160;</td> <td class="paramname"><em>flags</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [read]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Helper function to parse a URI-Reference as specified by RFC3986.</p> <p>This function matches the URI-Reference production from RFC3986, which includes both URIs like</p> <p>scheme://[[userinfo]@]foo.com[:port]]/[path][?query][#fragment]</p> <p>and relative-refs like</p> <p>[path][?query][#fragment]</p> <p>Any optional elements portions not present in the original URI are left set to NULL in the resulting <a class="el" href="structevhttp__uri.html">evhttp_uri</a>. If no port is specified, the port is set to -1.</p> <p>Note that no decoding is performed on percent-escaped characters in the string; if you want to parse them, use evhttp_uridecode or evhttp_parse_query_str as appropriate.</p> <p>Note also that most URI schemes will have additional constraints that this function does not know about, and cannot check. For example, mailto://www.example.com/cgi-bin/fortune.pl is not a reasonable mailto url, <a href="http://www.example.com:99999/">http://www.example.com:99999/</a> is not a reasonable HTTP URL, and <a href="ftp:username@example.com">ftp:username@example.com</a> is not a reasonable FTP URL. Nevertheless, all of these URLs conform to RFC3986, and this function accepts all of them as valid.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">source_uri</td><td>the request URI </td></tr> <tr><td class="paramname">flags</td><td>Zero or more EVHTTP_URI_* flags to affect the behavior of the parser. </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>uri container to hold parsed data, or NULL if there is error </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="http_8h.html#a5ee82311278b8fda3ed93a8e358683bb">evhttp_uri_free()</a> </dd></dl> </div> </div> <a class="anchor" id="aea0b990f1ca5ba71feffa96c8f6bd06b"></a><!-- doxytag: member="http.h::evhttp_uri_set_flags" ref="aea0b990f1ca5ba71feffa96c8f6bd06b" args="(struct evhttp_uri *uri, unsigned flags)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void <a class="el" href="http_8h.html#aea0b990f1ca5ba71feffa96c8f6bd06b">evhttp_uri_set_flags</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">unsigned&#160;</td> <td class="paramname"><em>flags</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Changes the flags set on a given URI. See EVHTTP_URI_* for a list of flags. </p> </div> </div> <a class="anchor" id="a36b844028058c82b6709d1e0fe7e1cf9"></a><!-- doxytag: member="http.h::evhttp_uri_set_fragment" ref="a36b844028058c82b6709d1e0fe7e1cf9" args="(struct evhttp_uri *uri, const char *fragment)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#a36b844028058c82b6709d1e0fe7e1cf9">evhttp_uri_set_fragment</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>fragment</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Set the fragment of an <a class="el" href="structevhttp__uri.html">evhttp_uri</a>, or clear the fragment if fragment==NULL. The fragment should not include a leading "#". Returns 0 on success, -1 if fragment is not well-formed. </p> </div> </div> <a class="anchor" id="a103c447efb9f41a5897b3aa130424734"></a><!-- doxytag: member="http.h::evhttp_uri_set_host" ref="a103c447efb9f41a5897b3aa130424734" args="(struct evhttp_uri *uri, const char *host)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#a103c447efb9f41a5897b3aa130424734">evhttp_uri_set_host</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>host</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Set the host of an <a class="el" href="structevhttp__uri.html">evhttp_uri</a>, or clear the host if host==NULL. Returns 0 on success, -1 if host is not well-formed. </p> </div> </div> <a class="anchor" id="ae6bbfc5cf62df674ba72800ea46c5828"></a><!-- doxytag: member="http.h::evhttp_uri_set_path" ref="ae6bbfc5cf62df674ba72800ea46c5828" args="(struct evhttp_uri *uri, const char *path)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#ae6bbfc5cf62df674ba72800ea46c5828">evhttp_uri_set_path</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>path</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Set the path of an <a class="el" href="structevhttp__uri.html">evhttp_uri</a>, or clear the path if path==NULL. Returns 0 on success, -1 if path is not well-formed. </p> </div> </div> <a class="anchor" id="a8cc430f9b8fb4c6aa11692d5ef0b383c"></a><!-- doxytag: member="http.h::evhttp_uri_set_port" ref="a8cc430f9b8fb4c6aa11692d5ef0b383c" args="(struct evhttp_uri *uri, int port)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#a8cc430f9b8fb4c6aa11692d5ef0b383c">evhttp_uri_set_port</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>port</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Set the port of an <a class="el" href="structevhttp__uri.html">evhttp_uri</a>, or clear the port if port==-1. Returns 0 on success, -1 if port is not well-formed. </p> </div> </div> <a class="anchor" id="aaf999637136bc1785e5d75c191c671ba"></a><!-- doxytag: member="http.h::evhttp_uri_set_query" ref="aaf999637136bc1785e5d75c191c671ba" args="(struct evhttp_uri *uri, const char *query)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#aaf999637136bc1785e5d75c191c671ba">evhttp_uri_set_query</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>query</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Set the query of an <a class="el" href="structevhttp__uri.html">evhttp_uri</a>, or clear the query if query==NULL. The query should not include a leading "?". Returns 0 on success, -1 if query is not well-formed. </p> </div> </div> <a class="anchor" id="abf5f82fb9c8f8df0b1b4c73691791dd5"></a><!-- doxytag: member="http.h::evhttp_uri_set_scheme" ref="abf5f82fb9c8f8df0b1b4c73691791dd5" args="(struct evhttp_uri *uri, const char *scheme)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#abf5f82fb9c8f8df0b1b4c73691791dd5">evhttp_uri_set_scheme</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>scheme</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Set the scheme of an <a class="el" href="structevhttp__uri.html">evhttp_uri</a>, or clear the scheme if scheme==NULL. Returns 0 on success, -1 if scheme is not well-formed. </p> </div> </div> <a class="anchor" id="ac7b10b8ef8ee94d14674f9329486d355"></a><!-- doxytag: member="http.h::evhttp_uri_set_userinfo" ref="ac7b10b8ef8ee94d14674f9329486d355" args="(struct evhttp_uri *uri, const char *userinfo)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="http_8h.html#ac7b10b8ef8ee94d14674f9329486d355">evhttp_uri_set_userinfo</a> </td> <td>(</td> <td class="paramtype">struct <a class="el" href="structevhttp__uri.html">evhttp_uri</a> *&#160;</td> <td class="paramname"><em>uri</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>userinfo</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Set the userinfo of an <a class="el" href="structevhttp__uri.html">evhttp_uri</a>, or clear the userinfo if userinfo==NULL. Returns 0 on success, -1 if userinfo is not well-formed. </p> </div> </div> <a class="anchor" id="ac2914389616f04199aded10444fd8e42"></a><!-- doxytag: member="http.h::evhttp_uridecode" ref="ac2914389616f04199aded10444fd8e42" args="(const char *uri, int decode_plus, size_t *size_out)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char* <a class="el" href="http_8h.html#ac2914389616f04199aded10444fd8e42">evhttp_uridecode</a> </td> <td>(</td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>uri</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>decode_plus</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">size_t *&#160;</td> <td class="paramname"><em>size_out</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Helper function to decode a URI-escaped string or HTTP parameter.</p> <p>If 'decode_plus' is 1, then we decode the string as an HTTP parameter value, and convert all plus ('+') characters to spaces. If 'decode_plus' is 0, we leave all plus characters unchanged.</p> <p>The returned string must be freed by the caller.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">uri</td><td>a URI-encode encoded URI </td></tr> <tr><td class="paramname">decode_plus</td><td>determines whether we convert '+' to sapce. </td></tr> <tr><td class="paramname">size_out</td><td>if size_out is not NULL, *size_out is set to the size of the returned string </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>a newly allocated unencoded URI or NULL on failure </dd></dl> </div> </div> <a class="anchor" id="ab64229249a981ccfea09161a199972da"></a><!-- doxytag: member="http.h::evhttp_uriencode" ref="ab64229249a981ccfea09161a199972da" args="(const char *str, ev_ssize_t size, int space_to_plus)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char* <a class="el" href="http_8h.html#ab64229249a981ccfea09161a199972da">evhttp_uriencode</a> </td> <td>(</td> <td class="paramtype">const char *&#160;</td> <td class="paramname"><em>str</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">ev_ssize_t&#160;</td> <td class="paramname"><em>size</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>space_to_plus</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>As evhttp_encode_uri, but if 'size' is nonnegative, treat the string as being 'size' bytes long. This allows you to encode strings that may contain 0-valued bytes.</p> <p>The returned string must be freed by the caller.</p> <dl class="params"><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">str</td><td>an unencoded string </td></tr> <tr><td class="paramname">size</td><td>the length of the string to encode, or -1 if the string is NUL-terminated </td></tr> <tr><td class="paramname">space_to_plus</td><td>if true, space characters in 'str' are encoded as +, not %20. </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>a newly allocate URI-encoded string, or NULL on failure. </dd></dl> </div> </div> </div><!-- contents --> <hr class="footer"/><address class="footer"><small> Generated on Mon Nov 17 2014 22:16:07 for lldp by &#160;<a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.7.6.1 </small></address> </body> </html>
diy19901030/lldpd
doc/html/http_8h.html
HTML
gpl-2.0
158,273
<!DOCTYPE html> <html lang="pt"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <!-- Meta, title, CSS, favicons, etc. --> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>To de Olho</title> <!-- Bootstrap core CSS --> <link href="css/bootstrap.min.css" rel="stylesheet"> <link href="fonts/css/font-awesome.min.css" rel="stylesheet"> <link href="css/animate.min.css" rel="stylesheet"> <!-- Custom styling plus plugins --> <link href="css/custom.css" rel="stylesheet"> <link href="css/icheck/flat/green.css" rel="stylesheet"> <script src="js/jquery.min.js"></script> <!--[if lt IE 9]> <script src="../assets/js/ie8-responsive-file-warning.js"></script> <![endif]--> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body class="nav-md"> <div class="container body"> <div class="main_container"> <div class="col-md-3 left_col"> <div class="left_col scroll-view"> <div class="navbar nav_title" style="border: 0;"> <a href="index.html" class="site_title"><img src="images/lupa-todeolho.png" width="40px"> Tô de Olho</span></a> </div> <div class="clearfix"></div> <!-- menu prile quick info --> <div class="profile"> <div class="profile_pic"> <img src="images/img.jpg" alt="..." class="img-circle profile_img"> </div> <div class="profile_info"> <span>Seja bem vindo,</span> <h2>Administrador</h2> </div> </div> <!-- /menu prile quick info --> <br/> <!-- sidebar menu --> <div id="sidebar-menu" class="main_menu_side hidden-print main_menu"> <div class="menu_section"> <h3>Menu</h3> <ul class="nav side-menu"> <li><a href="index.html"><i class="fa fa-home"></i> Início </a></li> <li><a href="projects.html"><i class="fa fa-institution"></i> Obras </a></li> <li><a href="denuncias.html"><i class="fa fa-bullhorn"></i> Denúncias <span class="label label-success">+ 124</span></a> </li> <li><a href="usuarios.html"><i class="fa fa-users"></i> Usuários <span class="label label-success">+ 439</span></a> </li> </ul> </div> </div> <!-- /sidebar menu --> <!-- /menu footer buttons --> <div class="sidebar-footer hidden-small"> <a data-toggle="tooltip" data-placement="top" title="Settings"> <span class="glyphicon glyphicon-cog" aria-hidden="true"></span> </a> <a data-toggle="tooltip" data-placement="top" title="FullScreen"> <span class="glyphicon glyphicon-fullscreen" aria-hidden="true"></span> </a> <a data-toggle="tooltip" data-placement="top" title="Lock"> <span class="glyphicon glyphicon-eye-close" aria-hidden="true"></span> </a> <a data-toggle="tooltip" data-placement="top" title="Logout"> <span class="glyphicon glyphicon-off" aria-hidden="true"></span> </a> </div> <!-- /menu footer buttons --> </div> </div> <!-- top navigation --> <div class="top_nav"> <div class="nav_menu"> <nav class="" role="navigation"> <div class="nav toggle"> <a id="menu_toggle"><i class="fa fa-bars"></i></a> </div> </nav> </div> </div> <!-- /top navigation --> <!-- page content --> <div class="right_col" role="main"> <!-- top tiles --> <div class="row top_tiles"> <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12" onclick="location.href='projects.html'"> <div class="tile-stats"> <div class="icon"><i class="fa fa-map-marker"></i> </div> <div class="count">125.312</div> <h3>Obras</h3> <p class="text-center"><i class="green"><i class="fa fa-sort-asc"></i> 2% </i> Último mês </p> </div> </div> <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12" onclick="location.href='denuncias.html'"> <div class="tile-stats"> <div class="icon"><i class="fa fa-search"></i> </div> <div class="count">640.589</div> <h3>Interações</h3> <p class="text-center"> <i class="green"> 17% </i> Contentes | <i class="red"> 71% </i> Aborrecidos </p> </div> </div> <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12" onclick="location.href='projects.html'"> <div class="tile-stats"> <div class="icon"><i class="fa fa-anchor"></i> </div> <div class="count">12.045</div> <h3>Obras Paradas</h3> <p class="text-center"><i class="red"><i class="fa fa-sort-desc"></i> 5% </i> Último mês </p> </div> </div> <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12" onclick="location.href='usuarios.html'"> <div class="tile-stats"> <div class="icon"><i class="fa fa-users"></i> </div> <div class="count">1.1 mi</div> <h3>Usuários</h3> <p class="text-center"><i class="green"><i class="fa fa-sort-asc"></i> 4,5% </i> Último mês</p> </div> </div> </div> <!-- /top tiles --> <div class=""> <div class="page-title"> <div class="title_left"> <h3>Obras <small>Relação de Obras</small> </h3> </div> <div class="title_right"> <div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search"> <div class="input-group"> <input type="text" class="form-control" placeholder="Procurando por..."> <span class="input-group-btn"> <button class="btn btn-default" type="button">Ok!</button> </span> </div> </div> </div> </div> <div class="clearfix"></div> <div class="row"> <div class="col-md-12"> <div class="x_panel"> <div class="x_title"> <h2>Últimas</h2> <ul class="nav navbar-right panel_toolbox"> <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a> <ul class="dropdown-menu" role="menu"> <li><a href="#">Settings 1</a> </li> <li><a href="#">Settings 2</a> </li> </ul> </li> <li><a class="close-link"><i class="fa fa-close"></i></a> </li> </ul> <div class="clearfix"></div> </div> <div class="x_content"> <p>Relação de Obras/Progresso</p> <!-- start project list --> <table class="table table-striped projects"> <thead> <tr> <th style="width: 1%">#</th> <th style="width: 20%">Obra</th> <th>Responsáveis</th> <th>Progresso</th> <th>Categoria</th> <th style="width: 20%">Edição</th> </tr> </thead> <tbody> <tr> <td>#</td> <td> <a>Revitalização do São Francisco</a> <br/> <small>Iniciada em 01/02/2015</small> </td> <td> <ul class="list-inline"> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> </ul> </td> <td class="project_progress"> <div class="progress progress_sm"> <div class="progress-bar bg-green" role="progressbar" data-transitiongoal="57"></div> </div> <small>57% Complete</small> </td> <td> <button type="button" class="btn btn-success btn-xs">Ambiental</button> </td> <td> <a href="project_detail.html" class="btn btn-primary btn-xs"><i class="fa fa-folder"></i> Ver </a> <a href="#" class="btn btn-info btn-xs"><i class="fa fa-pencil"></i> Editar </a> <a href="#" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i> Excluir </a> </td> </tr> <tr> <td>#</td> <td> <a>Construção de Linha Férrea/TO</a> <br/> <small>Iniciada em 01/01/2015</small> </td> <td> <ul class="list-inline"> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> </ul> </td> <td class="project_progress"> <div class="progress progress_sm"> <div class="progress-bar bg-green" role="progressbar" data-transitiongoal="47"></div> </div> <small>47% Complete</small> </td> <td> <button type="button" class="btn btn-danger btn-xs">Transporte</button> </td> <td> <a href="project_detail.html" class="btn btn-primary btn-xs"><i class="fa fa-folder"></i> Ver </a> <a href="#" class="btn btn-info btn-xs"><i class="fa fa-pencil"></i> Editar </a> <a href="#" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i> Excluir </a> </td> </tr> <tr> <td>#</td> <td> <a>Construção do Hospital Geral de Palmas</a> <br/> <small>Iniciada em 01/01/2015</small> </td> <td> <ul class="list-inline"> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> </ul> </td> <td class="project_progress"> <div class="progress progress_sm"> <div class="progress-bar bg-green" role="progressbar" data-transitiongoal="77"></div> </div> <small>77% Complete</small> </td> <td> <button type="button" class="btn btn-info btn-xs">Saúde</button> </td> <td> <a href="project_detail.html" class="btn btn-primary btn-xs"><i class="fa fa-folder"></i> Ver </a> <a href="#" class="btn btn-info btn-xs"><i class="fa fa-pencil"></i> Editar </a> <a href="#" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i> Excluir </a> </td> </tr> <tr> <td>#</td> <td> <a>Revitalização do Parque Ibirapuera</a> <br/> <small>Iniciada em 01/01/2015</small> </td> <td> <ul class="list-inline"> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> </ul> </td> <td class="project_progress"> <div class="progress progress_sm"> <div class="progress-bar bg-green" role="progressbar" data-transitiongoal="60"></div> </div> <small>60% Complete</small> </td> <td> <button type="button" class="btn btn-success btn-xs">Ambiental</button> </td> <td> <a href="project_detail.html" class="btn btn-primary btn-xs"><i class="fa fa-folder"></i> Ver </a> <a href="#" class="btn btn-info btn-xs"><i class="fa fa-pencil"></i> Editar </a> <a href="#" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i> Excluir </a> </td> </tr> <tr> <td>#</td> <td> <a>Construção Quadra de Esportes</a> <br/> <small>Iniciada em 01/01/2015</small> </td> <td> <ul class="list-inline"> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> </ul> </td> <td class="project_progress"> <div class="progress progress_sm"> <div class="progress-bar bg-green" role="progressbar" data-transitiongoal="12"></div> </div> <small>12% Complete</small> </td> <td> <button type="button" class="btn btn-warning btn-xs">Esporte</button> </td> <td> <a href="project_detail.html" class="btn btn-primary btn-xs"><i class="fa fa-folder"></i> Ver </a> <a href="#" class="btn btn-info btn-xs"><i class="fa fa-pencil"></i> Editar </a> <a href="#" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i> Excluir </a> </td> </tr> <tr> <td>#</td> <td> <a>Reforma Casa Prisão Provisória</a> <br/> <small>Iniciada em 01/012015</small> </td> <td> <ul class="list-inline"> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> </ul> </td> <td class="project_progress"> <div class="progress progress_sm"> <div class="progress-bar bg-green" role="progressbar" data-transitiongoal="35"></div> </div> <small>35% Complete</small> </td> <td> <button type="button" class="btn btn-default btn-xs">Segurança</button> </td> <td> <a href="project_detail.html" class="btn btn-primary btn-xs"><i class="fa fa-folder"></i> Ver </a> <a href="#" class="btn btn-info btn-xs"><i class="fa fa-pencil"></i> Editar </a> <a href="#" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i> Excluir </a> </td> </tr> <tr> <td>#</td> <td> <a>Ponte sobre o Rio Taborda</a> <br/> <small>Iniciada em 01/01/2015</small> </td> <td> <ul class="list-inline"> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> </ul> </td> <td class="project_progress"> <div class="progress progress_sm"> <div class="progress-bar bg-green" role="progressbar" data-transitiongoal="87"></div> </div> <small>87% Complete</small> </td> <td> <button type="button" class="btn btn-danger btn-xs">Transporte</button> </td> <td> <a href="project_detail.html" class="btn btn-primary btn-xs"><i class="fa fa-folder"></i> Ver </a> <a href="#" class="btn btn-info btn-xs"><i class="fa fa-pencil"></i> Editar </a> <a href="#" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i> Excluir </a> </td> </tr> <tr> <td>#</td> <td> <a>Construção de Pronto Atendimento</a> <br/> <small>Iniciada em 01/01/2015</small> </td> <td> <ul class="list-inline"> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> </ul> </td> <td class="project_progress"> <div class="progress progress_sm"> <div class="progress-bar bg-green" role="progressbar" data-transitiongoal="77"></div> </div> <small>77% Complete</small> </td> <td> <button type="button" class="btn btn-info btn-xs">Saúde</button> </td> <td> <a href="project_detail.html" class="btn btn-primary btn-xs"><i class="fa fa-folder"></i> Ver </a> <a href="#" class="btn btn-info btn-xs"><i class="fa fa-pencil"></i> Editar </a> <a href="#" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i> Excluir </a> </td> </tr> <tr> <td>#</td> <td> <a>Contrução de Colégio Militar</a> <br/> <small>Iniciada em 01/01/2015</small> </td> <td> <ul class="list-inline"> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> <li> <img src="images/user.png" class="avatar" alt="Avatar"> </li> </ul> </td> <td class="project_progress"> <div class="progress progress_sm"> <div class="progress-bar bg-green" role="progressbar" data-transitiongoal="77"></div> </div> <small>77% Complete</small> </td> <td> <button type="button" class="btn btn-primary btn-xs">Educação</button> </td> <td> <a href="project_detail.html" class="btn btn-primary btn-xs"><i class="fa fa-folder"></i> Ver </a> <a href="#" class="btn btn-info btn-xs"><i class="fa fa-pencil"></i> Editar </a> <a href="#" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i> Excluir </a> </td> </tr> </tbody> </table> <!-- end project list --> </div> </div> </div> </div> </div> <!-- footer content --> <footer> <div class="copyright-info"> <p class="pull-right">Controladoria Geral da União <a href="http://www.cgu.gov.br/">CGU</a> </p> </div> <div class="clearfix"></div> </footer> <!-- /footer content --> </div> <!-- /page content --> </div> </div> <div id="custom_notifications" class="custom-notifications dsp_none"> <ul class="list-unstyled notifications clearfix" data-tabbed_notifications="notif-group"> </ul> <div class="clearfix"></div> <div id="notif-group" class="tabbed_notifications"></div> </div> <script src="js/bootstrap.min.js"></script> <!-- bootstrap progress js --> <script src="js/progressbar/bootstrap-progressbar.min.js"></script> <script src="js/nicescroll/jquery.nicescroll.min.js"></script> <!-- icheck --> <script src="js/icheck/icheck.min.js"></script> <script src="js/custom.js"></script> <!-- pace --> <script src="js/pace/pace.min.js"></script> </body> </html>
brunosm08/AppToDeOlho
Web/todeolho/projects.html
HTML
gpl-2.0
36,304
/* * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the LICENSE file that accompanied this code. * * This code 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 * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ package javax.swing.plaf.metal; import sun.swing.SwingUtilities2; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; import javax.swing.event.InternalFrameEvent; import java.util.EventListener; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; import javax.swing.plaf.basic.BasicInternalFrameTitlePane; /** * Class that manages a JLF title bar * @author Steve Wilson * @author Brian Beck * @since 1.3 */ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane { protected boolean isPalette = false; protected Icon paletteCloseIcon; protected int paletteTitleHeight; private static final Border handyEmptyBorder = new EmptyBorder(0,0,0,0); /** * Key used to lookup Color from UIManager. If this is null, * <code>getWindowTitleBackground</code> is used. */ private String selectedBackgroundKey; /** * Key used to lookup Color from UIManager. If this is null, * <code>getWindowTitleForeground</code> is used. */ private String selectedForegroundKey; /** * Key used to lookup shadow color from UIManager. If this is null, * <code>getPrimaryControlDarkShadow</code> is used. */ private String selectedShadowKey; /** * Boolean indicating the state of the <code>JInternalFrame</code>s * closable property at <code>updateUI</code> time. */ private boolean wasClosable; int buttonsWidth = 0; MetalBumps activeBumps = new MetalBumps( 0, 0, MetalLookAndFeel.getPrimaryControlHighlight(), MetalLookAndFeel.getPrimaryControlDarkShadow(), (UIManager.get("InternalFrame.activeTitleGradient") != null) ? null : MetalLookAndFeel.getPrimaryControl() ); MetalBumps inactiveBumps = new MetalBumps( 0, 0, MetalLookAndFeel.getControlHighlight(), MetalLookAndFeel.getControlDarkShadow(), (UIManager.get("InternalFrame.inactiveTitleGradient") != null) ? null : MetalLookAndFeel.getControl() ); MetalBumps paletteBumps; private Color activeBumpsHighlight = MetalLookAndFeel. getPrimaryControlHighlight(); private Color activeBumpsShadow = MetalLookAndFeel. getPrimaryControlDarkShadow(); public MetalInternalFrameTitlePane(JInternalFrame f) { super( f ); } public void addNotify() { super.addNotify(); // This is done here instead of in installDefaults as I was worried // that the BasicInternalFrameUI might not be fully initialized, and // that if this resets the closable state the BasicInternalFrameUI // Listeners that get notified might be in an odd/uninitialized state. updateOptionPaneState(); } protected void installDefaults() { super.installDefaults(); setFont( UIManager.getFont("InternalFrame.titleFont") ); paletteTitleHeight = UIManager.getInt("InternalFrame.paletteTitleHeight"); paletteCloseIcon = UIManager.getIcon("InternalFrame.paletteCloseIcon"); wasClosable = frame.isClosable(); selectedForegroundKey = selectedBackgroundKey = null; if (MetalLookAndFeel.usingOcean()) { setOpaque(true); } } protected void uninstallDefaults() { super.uninstallDefaults(); if (wasClosable != frame.isClosable()) { frame.setClosable(wasClosable); } } protected void createButtons() { super.createButtons(); Boolean paintActive = frame.isSelected() ? Boolean.TRUE:Boolean.FALSE; iconButton.putClientProperty("paintActive", paintActive); iconButton.setBorder(handyEmptyBorder); maxButton.putClientProperty("paintActive", paintActive); maxButton.setBorder(handyEmptyBorder); closeButton.putClientProperty("paintActive", paintActive); closeButton.setBorder(handyEmptyBorder); // The palette close icon isn't opaque while the regular close icon is. // This makes sure palette close buttons have the right background. closeButton.setBackground(MetalLookAndFeel.getPrimaryControlShadow()); if (MetalLookAndFeel.usingOcean()) { iconButton.setContentAreaFilled(false); maxButton.setContentAreaFilled(false); closeButton.setContentAreaFilled(false); } } /** * Override the parent's method to do nothing. Metal frames do not * have system menus. */ protected void assembleSystemMenu() {} /** * Override the parent's method to do nothing. Metal frames do not * have system menus. */ protected void addSystemMenuItems(JMenu systemMenu) {} /** * Override the parent's method to do nothing. Metal frames do not * have system menus. */ protected void showSystemMenu() {} /** * Override the parent's method avoid creating a menu bar. Metal frames * do not have system menus. */ protected void addSubComponents() { add(iconButton); add(maxButton); add(closeButton); } protected PropertyChangeListener createPropertyChangeListener() { return new MetalPropertyChangeHandler(); } protected LayoutManager createLayout() { return new MetalTitlePaneLayout(); } class MetalPropertyChangeHandler extends BasicInternalFrameTitlePane.PropertyChangeHandler { public void propertyChange(PropertyChangeEvent evt) { String prop = evt.getPropertyName(); if( prop.equals(JInternalFrame.IS_SELECTED_PROPERTY) ) { Boolean b = (Boolean)evt.getNewValue(); iconButton.putClientProperty("paintActive", b); closeButton.putClientProperty("paintActive", b); maxButton.putClientProperty("paintActive", b); } else if ("JInternalFrame.messageType".equals(prop)) { updateOptionPaneState(); frame.repaint(); } super.propertyChange(evt); } } class MetalTitlePaneLayout extends TitlePaneLayout { public void addLayoutComponent(String name, Component c) {} public void removeLayoutComponent(Component c) {} public Dimension preferredLayoutSize(Container c) { return minimumLayoutSize(c); } public Dimension minimumLayoutSize(Container c) { // Compute width. int width = 30; if (frame.isClosable()) { width += 21; } if (frame.isMaximizable()) { width += 16 + (frame.isClosable() ? 10 : 4); } if (frame.isIconifiable()) { width += 16 + (frame.isMaximizable() ? 2 : (frame.isClosable() ? 10 : 4)); } FontMetrics fm = frame.getFontMetrics(getFont()); String frameTitle = frame.getTitle(); int title_w = frameTitle != null ? SwingUtilities2.stringWidth( frame, fm, frameTitle) : 0; int title_length = frameTitle != null ? frameTitle.length() : 0; if (title_length > 2) { int subtitle_w = SwingUtilities2.stringWidth(frame, fm, frame.getTitle().substring(0, 2) + "..."); width += (title_w < subtitle_w) ? title_w : subtitle_w; } else { width += title_w; } // Compute height. int height; if (isPalette) { height = paletteTitleHeight; } else { int fontHeight = fm.getHeight(); fontHeight += 7; Icon icon = frame.getFrameIcon(); int iconHeight = 0; if (icon != null) { // SystemMenuBar forces the icon to be 16x16 or less. iconHeight = Math.min(icon.getIconHeight(), 16); } iconHeight += 5; height = Math.max(fontHeight, iconHeight); } return new Dimension(width, height); } public void layoutContainer(Container c) { boolean leftToRight = MetalUtils.isLeftToRight(frame); int w = getWidth(); int x = leftToRight ? w : 0; int y = 2; int spacing; // assumes all buttons have the same dimensions // these dimensions include the borders int buttonHeight = closeButton.getIcon().getIconHeight(); int buttonWidth = closeButton.getIcon().getIconWidth(); if(frame.isClosable()) { if (isPalette) { spacing = 3; x += leftToRight ? -spacing -(buttonWidth+2) : spacing; closeButton.setBounds(x, y, buttonWidth+2, getHeight()-4); if( !leftToRight ) x += (buttonWidth+2); } else { spacing = 4; x += leftToRight ? -spacing -buttonWidth : spacing; closeButton.setBounds(x, y, buttonWidth, buttonHeight); if( !leftToRight ) x += buttonWidth; } } if(frame.isMaximizable() && !isPalette ) { spacing = frame.isClosable() ? 10 : 4; x += leftToRight ? -spacing -buttonWidth : spacing; maxButton.setBounds(x, y, buttonWidth, buttonHeight); if( !leftToRight ) x += buttonWidth; } if(frame.isIconifiable() && !isPalette ) { spacing = frame.isMaximizable() ? 2 : (frame.isClosable() ? 10 : 4); x += leftToRight ? -spacing -buttonWidth : spacing; iconButton.setBounds(x, y, buttonWidth, buttonHeight); if( !leftToRight ) x += buttonWidth; } buttonsWidth = leftToRight ? w - x : x; } } public void paintPalette(Graphics g) { boolean leftToRight = MetalUtils.isLeftToRight(frame); int width = getWidth(); int height = getHeight(); if (paletteBumps == null) { paletteBumps = new MetalBumps(0, 0, MetalLookAndFeel.getPrimaryControlHighlight(), MetalLookAndFeel.getPrimaryControlInfo(), MetalLookAndFeel.getPrimaryControlShadow() ); } Color background = MetalLookAndFeel.getPrimaryControlShadow(); Color darkShadow = MetalLookAndFeel.getPrimaryControlDarkShadow(); g.setColor(background); g.fillRect(0, 0, width, height); g.setColor( darkShadow ); g.drawLine ( 0, height - 1, width, height -1); int xOffset = leftToRight ? 4 : buttonsWidth + 4; int bumpLength = width - buttonsWidth -2*4; int bumpHeight = getHeight() - 4; paletteBumps.setBumpArea( bumpLength, bumpHeight ); paletteBumps.paintIcon( this, g, xOffset, 2); } public void paintComponent(Graphics g) { if(isPalette) { paintPalette(g); return; } boolean leftToRight = MetalUtils.isLeftToRight(frame); boolean isSelected = frame.isSelected(); int width = getWidth(); int height = getHeight(); Color background = null; Color foreground = null; Color shadow = null; MetalBumps bumps; String gradientKey; if (isSelected) { if (!MetalLookAndFeel.usingOcean()) { closeButton.setContentAreaFilled(true); maxButton.setContentAreaFilled(true); iconButton.setContentAreaFilled(true); } if (selectedBackgroundKey != null) { background = UIManager.getColor(selectedBackgroundKey); } if (background == null) { background = MetalLookAndFeel.getWindowTitleBackground(); } if (selectedForegroundKey != null) { foreground = UIManager.getColor(selectedForegroundKey); } if (selectedShadowKey != null) { shadow = UIManager.getColor(selectedShadowKey); } if (shadow == null) { shadow = MetalLookAndFeel.getPrimaryControlDarkShadow(); } if (foreground == null) { foreground = MetalLookAndFeel.getWindowTitleForeground(); } activeBumps.setBumpColors(activeBumpsHighlight, activeBumpsShadow, UIManager.get("InternalFrame.activeTitleGradient") != null ? null : background); bumps = activeBumps; gradientKey = "InternalFrame.activeTitleGradient"; } else { if (!MetalLookAndFeel.usingOcean()) { closeButton.setContentAreaFilled(false); maxButton.setContentAreaFilled(false); iconButton.setContentAreaFilled(false); } background = MetalLookAndFeel.getWindowTitleInactiveBackground(); foreground = MetalLookAndFeel.getWindowTitleInactiveForeground(); shadow = MetalLookAndFeel.getControlDarkShadow(); bumps = inactiveBumps; gradientKey = "InternalFrame.inactiveTitleGradient"; } if (!MetalUtils.drawGradient(this, g, gradientKey, 0, 0, width, height, true)) { g.setColor(background); g.fillRect(0, 0, width, height); } g.setColor( shadow ); g.drawLine ( 0, height - 1, width, height -1); g.drawLine ( 0, 0, 0 ,0); g.drawLine ( width - 1, 0 , width -1, 0); int titleLength; int xOffset = leftToRight ? 5 : width - 5; String frameTitle = frame.getTitle(); Icon icon = frame.getFrameIcon(); if ( icon != null ) { if( !leftToRight ) xOffset -= icon.getIconWidth(); int iconY = ((height / 2) - (icon.getIconHeight() /2)); icon.paintIcon(frame, g, xOffset, iconY); xOffset += leftToRight ? icon.getIconWidth() + 5 : -5; } if(frameTitle != null) { Font f = getFont(); g.setFont(f); FontMetrics fm = SwingUtilities2.getFontMetrics(frame, g, f); int fHeight = fm.getHeight(); g.setColor(foreground); int yOffset = ( (height - fm.getHeight() ) / 2 ) + fm.getAscent(); Rectangle rect = new Rectangle(0, 0, 0, 0); if (frame.isIconifiable()) { rect = iconButton.getBounds(); } else if (frame.isMaximizable()) { rect = maxButton.getBounds(); } else if (frame.isClosable()) { rect = closeButton.getBounds(); } int titleW; if( leftToRight ) { if (rect.x == 0) { rect.x = frame.getWidth()-frame.getInsets().right-2; } titleW = rect.x - xOffset - 4; frameTitle = getTitle(frameTitle, fm, titleW); } else { titleW = xOffset - rect.x - rect.width - 4; frameTitle = getTitle(frameTitle, fm, titleW); xOffset -= SwingUtilities2.stringWidth(frame, fm, frameTitle); } titleLength = SwingUtilities2.stringWidth(frame, fm, frameTitle); SwingUtilities2.drawString(frame, g, frameTitle, xOffset, yOffset); xOffset += leftToRight ? titleLength + 5 : -5; } int bumpXOffset; int bumpLength; if( leftToRight ) { bumpLength = width - buttonsWidth - xOffset - 5; bumpXOffset = xOffset; } else { bumpLength = xOffset - buttonsWidth - 5; bumpXOffset = buttonsWidth + 5; } int bumpYOffset = 3; int bumpHeight = getHeight() - (2 * bumpYOffset); bumps.setBumpArea( bumpLength, bumpHeight ); bumps.paintIcon(this, g, bumpXOffset, bumpYOffset); } public void setPalette(boolean b) { isPalette = b; if (isPalette) { closeButton.setIcon(paletteCloseIcon); if( frame.isMaximizable() ) remove(maxButton); if( frame.isIconifiable() ) remove(iconButton); } else { closeButton.setIcon(closeIcon); if( frame.isMaximizable() ) add(maxButton); if( frame.isIconifiable() ) add(iconButton); } revalidate(); repaint(); } /** * Updates any state dependant upon the JInternalFrame being shown in * a <code>JOptionPane</code>. */ private void updateOptionPaneState() { int type = -2; boolean closable = wasClosable; Object obj = frame.getClientProperty("JInternalFrame.messageType"); if (obj == null) { // Don't change the closable state unless in an JOptionPane. return; } if (obj instanceof Integer) { type = ((Integer) obj).intValue(); } switch (type) { case JOptionPane.ERROR_MESSAGE: selectedBackgroundKey = "OptionPane.errorDialog.titlePane.background"; selectedForegroundKey = "OptionPane.errorDialog.titlePane.foreground"; selectedShadowKey = "OptionPane.errorDialog.titlePane.shadow"; closable = false; break; case JOptionPane.QUESTION_MESSAGE: selectedBackgroundKey = "OptionPane.questionDialog.titlePane.background"; selectedForegroundKey = "OptionPane.questionDialog.titlePane.foreground"; selectedShadowKey = "OptionPane.questionDialog.titlePane.shadow"; closable = false; break; case JOptionPane.WARNING_MESSAGE: selectedBackgroundKey = "OptionPane.warningDialog.titlePane.background"; selectedForegroundKey = "OptionPane.warningDialog.titlePane.foreground"; selectedShadowKey = "OptionPane.warningDialog.titlePane.shadow"; closable = false; break; case JOptionPane.INFORMATION_MESSAGE: case JOptionPane.PLAIN_MESSAGE: selectedBackgroundKey = selectedForegroundKey = selectedShadowKey = null; closable = false; break; default: selectedBackgroundKey = selectedForegroundKey = selectedShadowKey = null; break; } if (closable != frame.isClosable()) { frame.setClosable(closable); } } }
TheTypoMaster/Scaper
openjdk/jdk/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
Java
gpl-2.0
20,539
SET IDENTITY_INSERT [PaymentProcess] ON GO IF NOT EXISTS(SELECT 1 FROM PaymentProcess WHERE ProcessName = 'Payments Import') AND EXISTS(SELECT 1 FROM Setting WHERE Id = 'PushpayAccessToken' AND Setting IS NOT NULL) AND EXISTS(SELECT 1 FROM Setting WHERE Id = 'PushpayRefreshToken' AND Setting IS NOT NULL) AND EXISTS(SELECT 1 FROM Setting WHERE Id = 'PushPayEnableImport' AND Setting = 'true') BEGIN INSERT INTO [dbo].[PaymentProcess] (ProcessId ,[ProcessName] ,[GatewayAccountId] ,[AcceptACH] ,[AcceptCredit] ,[AcceptDebit]) VALUES (5, 'Payments Import', NULL, 1, 1, 1) END SET IDENTITY_INSERT [PaymentProcess] OFF GO
bvcms/bvcms
CmsData/Migrations/20200831_insert_paymentsImport_in_PaymentProcess_table.sql
SQL
gpl-2.0
709
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible"content="IE=9; IE=8; IE=7; IE=EDGE"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <meta name="descRiPtion" content="±±¾©Èü³µpk10Ö®°ËÂë¹öÑ©Çò¼Æ»®»¶Ó­´ó¼ÒÀ´µ½dld158.comÓéÀÖÆ½Ì¨" /> <title>±±¾©Èü³µpk10Ö®°ËÂë¹öÑ©Çò¼Æ»®_±±¾©Èü³µpk10Ö®°ËÂë¹öÑ©Çò¼Æ»®-dld158ÓéÀÖ{°Ù¶ÈÐÂÎÅ}°Ù¶ÈÈÏÖ¤</title> <!--ÈÈÁ¦Í¼¿ªÊ¼--> <meta name="uctk" content="enabled"> <!--ÈÈÁ¦Í¼½áÊø--> <meta name="keywords" content="±±¾©Èü³µpk10Ö®°ËÂë¹öÑ©Çò¼Æ»®"/> <meta name="descRiPtion" content="»¶Ó­´ó¼ÒÀ´µ½dld158.comÓéÀÖÆ½Ì¨"/> <meta name="sitename" content="Ê×¶¼Ö®´°-±±¾©ÊÐÕþÎñÃÅ»§ÍøÕ¾"> <meta name="siteurl" content="http://www.beijing.gov.cn"> <meta name="district" content="±±¾©" > <meta name="filetype" content="0"> <meta name="publishedtype" content="1"> <meta name="pagetype" content="2"> <meta name="subject" content="28428;1"> <!-- Le styles --> <link href="http://www.beijing.gov.cn/images/zhuanti/xysym/bootstrap150609.css" rel="stylesheet"> <link href="http://www.beijing.gov.cn/images/zhuanti/xysym/bootstrap-responsive150609.css" rel="stylesheet"> <style> body { background:#E8E8E8; /* 60px to make the container go all the way to the bottom of the topbar */ } .navbar .btn-navbar { position:absolute; right:0; margin-top:50px;} #othermessage p {width:50%;} #othermessage dl { width:50%;} #breadcrumbnav ul { width:100%;} #breadcrumbnav ul li { line-height:14px; font-family:"ËÎÌå"; padding:0px 10px; margin:0; background:none; } #othermessage span { padding:0px 10px;} #footer { margin:20px -20px 0px -20px;} .navbar .nav li a { font-family:"Microsoft YaHei";} #div_zhengwen { font-family:"SimSun";} #div_zhengwen p{ font-family:"SimSun"; padding:0;} select { width:75px; float:left; height:35px;} .search .input{ border:1px solid #c1c1c1; width:290px;} .bdsharebuttonbox { float:left; width:80%;} .navbar .nav li a { padding: 10px 48px 11px 49px;} .nav_weather span { float:right;} #footer { position:absolute; left:0; right:0; margin:20px 0 0 0;} #essaybottom {font-family:"simsun"; } #pic { text-align:center; } #pic ul { padding-top:10px; display:none; } #pic li {font-family:"SimSun";} .content_text h1 {line-height:150%;} .version { float:right; padding:48px 50px 0 0} .search { padding: 50px 0 0 70px;} .nav_weather a { font-family:simsun;} .version li a { font-family:simsun;} .footer-class { font-family:simsun;} @media only screen and (max-width: 480px) { #pic img { width:100%;} } @media only screen and (max-width: 320px) { #pic img { width:100%;} } @media only screen and (max-width: 640px) { #pic img { width:100%;} } #filerider .filelink {font-family:"SimSun";} #filerider .filelink a:link { color:#0000ff; font-family:"SimSun";} </style> <scRiPt type="text/javascRiPt"> var pageName = "t1424135"; var pageExt = "htm"; var pageIndex = 0 + 1; var pageCount = 1; function getCurrentPage() { document.write(pageIndex); } function generatePageList() { for (i=0;i<1;i++) { var curPage = i+1; document.write('<option value=' + curPage); if (curPage == pageIndex) document.write(' selected'); document.write('>' + curPage + '</option>'); } } function preVious(n) { if (pageIndex == 1) { alert('ÒѾ­ÊÇÊ×Ò³£¡'); } else { getPageLocation(pageIndex-1); } } function next(n) { if (pageIndex == pageCount) { alert('ÒѾ­ÊÇβҳ£¡'); } else { nextPage(pageIndex); } } function nextPage(page) { var gotoPage = ""; if (page == 0) { gotoPage = pageName + "." + pageExt; } else { gotoPage = pageName + "_" + page + "." + pageExt; } location.href = gotoPage; } function getPageLocation(page) { var gotoPage = ""; var tpage; if (page == 1) { gotoPage = pageName + "." + pageExt; } else { tpage=page-1; gotoPage = pageName + "_" + tpage + "." + pageExt; } location.href = gotoPage; } </scRiPt> <SCRIPT type=text/javascRiPt> function $(xixi) { return document.getElementById(xixi); } //ת»»×ֺŠfunction doZoom(size){ if(size==12){ $("contentText").style.fontSize = size + "px"; $("fs12").style.display = ""; $("fs14").style.display = "none"; $("fs16").style.display = "none"; } if(size==14){ $("contentText").style.fontSize = size + "px"; $("fs12").style.display = "none"; $("fs14").style.display = ""; $("fs16").style.display = "none"; } if(size==16){ $("contentText").style.fontSize = size + "px"; $("fs12").style.display = "none"; $("fs14").style.display = "none"; $("fs16").style.display = ""; } } </SCRIPT> <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <scRiPt src="//html5shim.googlecode.com/svn/trunk/html5.js"></scRiPt> <![endif]--> <!-- Le fav and touch icons --> <link rel="shortcut icon" href="images/favicon.ico"> <link rel="apple-touch-icon" href="images/apple-touch-icon.png"> <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png"> <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png"> <scRiPt type="text/javascRiPt"> window.onload = function(){ var picurl = [ "", "", "", "", "", "", "", "", "", "" ]; var i=0; for(i=0;i<picurl.length;i++) { picurl[i].index=i; if(picurl[i]!="") { document.getElementById("pic_"+i).style.display = "block"; } } } </scRiPt> </head> <body> <div class="navbar navbar-fixed-top"> <div class="navbar-inner"> <div class="nav_weather"> <div class="container"><a href="http://zhengwu.beijing.gov.cn/sld/swld/swsj/t1232150.htm" title="ÊÐί" target="_blank">ÊÐί</a> | <a href="http://www.bjrd.gov.cn/" title="ÊÐÈË´ó" target="_blank">ÊÐÈË´ó</a> | <a href="http://www.beijing.gov.cn/" title="ÊÐÕþ¸®" target="_blank">ÊÐÕþ¸®</a> | <a href="http://www.bjzx.gov.cn/" title="ÊÐÕþЭ" target="_blank">ÊÐÕþЭ</a></div> </div> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a> <div class="span12"> <a class="brand" href="http://www.beijing.gov.cn/"><img src="http://www.beijing.gov.cn/images/zhuanti/xysym/logo.png" /></a> <div class="search"> <scRiPt language="JavaScript" type="text/javascRiPt"> function checkForm(){ var temp = searchForm.temp.value; var database = searchForm.database.value; if(temp==null || temp==""){ alert("ÇëÊäÈëËÑË÷Ìõ¼þ"); } else{ var url="http://so.beijing.gov.cn/Query?qt="+encodeURIComponent(temp)+"&database="+encodeURIComponent(database); window.open(url); } return false; } </scRiPt> <form id="search" method="get" name="searchForm" action="" target="_blank" onSubmit="return checkForm()"> <input type="hidden" value="bj" id="database" name="database" /> <input name="temp" id="keyword" type="text" value="È«ÎÄËÑË÷" class="input" title="È«ÎÄËÑË÷¹Ø¼ü×Ö" /> <input id="searchbutton" type="image" src="http://www.beijing.gov.cn/images/zhuanti/xysym/search_btn.gif" width="66" height="35" title="µã»÷ËÑË÷" alt="ËÑË÷" /> </form> </div> <div class="version"><ul> <li><a title="ÎÞÕϰ­" href="http://wza.beijing.gov.cn/" target="_blank" id="yx_style_nav">ÎÞÕϰ­</a></li> <li><a target="_blank" title="·±Ìå°æ" href="http://210.75.193.158/gate/big5/www.beijing.gov.cn">·±Ìå</a></li> <li><a target="_blank" title="¼òÌå°æ" href="http://www.beijing.gov.cn">¼òÌå</a></li> <li class="last"><a target="_blank" title="English Version" href="http://www.ebeijing.gov.cn">English</a></li></ul><ul> <li><a href="javascRiPt:void(0)" onclick="SetHome(this,window.location)" title="ÉèΪÊ×Ò³">ÉèΪÊ×Ò³</a></li> <li><a title="¼ÓÈëÊÕ²Ø" href="javascRiPt:void(0)" onclick="shoucang(document.title,window.location)">¼ÓÈëÊÕ²Ø</a></li> <li class="last"><a target="_blank" title="ÒÆ¶¯°æ" href="http://www.beijing.gov.cn/sjbsy/">ÒÆ¶¯°æ</a></li></ul></div> </div> </div> <div class="nav-collapse"> <div class="container"> <ul class="nav"> <li ><a href="http://www.beijing.gov.cn/" class="normal" title="Ê×Ò³">Ê×Ò³</a></li> <li><a href="http://zhengwu.beijing.gov.cn/" class="normal" title="ÕþÎñÐÅÏ¢">ÕþÎñÐÅÏ¢</a></li> <li><a href="http://www.beijing.gov.cn/sqmy/default.htm" class="normal" title="ÉçÇéÃñÒâ">ÉçÇéÃñÒâ</a></li> <li><a href="http://banshi.beijing.gov.cn" class="normal" title="ÕþÎñ·þÎñ">ÕþÎñ·þÎñ</a></li> <li><a href="http://www.beijing.gov.cn/bmfw" class="normal" title="±ãÃñ·þÎñ">±ãÃñ·þÎñ</a></li> <li style="background:none;"><a href="http://www.beijing.gov.cn/rwbj/default.htm" class="normal" title="ÈËÎı±¾©">ÈËÎı±¾©</a></li> </ul> </div> </div><!--/.nav-collapse --> </div> </div> </div> <div class="container" style="background:#fff; margin-top:24px;"> <div class="content_text"> <div id="breadcrumbnav"> <ul> <li>Ê×Ò³¡¡>¡¡±ãÃñ·þÎñ¡¡>¡¡×îÐÂÌáʾ</li> </ul> <div class="clearboth"></div> </div> <h1>±±¾©Èü³µpk10Ö®°ËÂë¹öÑ©Çò¼Æ»® <div id="othermessage"> <p> <span>À´Ô´£º±±¾©ÈÕ±¨</span> <span>ÈÕÆÚ£º2017-04-21 08:35:47</span></p> <dl> <scRiPt language='JavaScript' type="text/javascRiPt"> function changeSize(size){document.getElementById('div_zhengwen').style.fontSize=size+'px'}</scRiPt> ¡¾×ÖºÅ&nbsp;&nbsp;<a href='javascRiPt:changeSize(18)' style="font-size:16px;">´ó</a>&nbsp;&nbsp;<a href='javascRiPt:changeSize(14)' style="font-size:14px;">ÖÐ</a>&nbsp;&nbsp;<a href='javascRiPt:changeSize(12)' style="font-size:12px;">С</a>¡¿</dl> </div> </h1> <div id="div_zhengwen"> <div id="pic"> <ul id="pic_0"> <li><img src="" border="0" alt="" title="" /></li> <li></li> </ul> <ul id="pic_1"> <li><img src="" border="0" alt="" title="" /></li> <li></li> </ul> <ul id="pic_2"> <li><img src="" border="0" alt="" title="" /></li> <li></li> </ul> <ul id="pic_3"> <li><img src="" border="0" alt="" title="" /></li> <li></li> </ul> <ul id="pic_4"> <li><img src="" border="0" alt="" title="" /></li> <li></li> </ul> <ul id="pic_5"> <li><img src="" border="0" alt="" title="" /></li> <li></li> </ul> <ul id="pic_6"> <li><img src="" border="0" alt="" title="" /></li> <li></li> </ul> <ul id="pic_7"> <li><img src="" border="0" alt="" title="" /></li> <li></li> </ul> <ul id="pic_8"> <li><img src="" border="0" alt="" title="" /></li> <li></li> </ul> <ul id="pic_9"> <li><img src="" border="0" alt="" title="" /></li> <li></li> </ul> </div> <div class=TRS_Editor><p align="justify">¡¡¡¡±±¾©Èü³µpk10Ö®°ËÂë¹öÑ©Çò¼Æ»® »¶Ó­´ó¼ÒÀ´µ½dld158.comÓéÀÖÆ½Ì¨</p> <img src="{img}" width="300" height="330"/> <p align="justify">¡¡¡¡<a href="http://sapience.com.tw/logs/meng/q0302734.html">±±¾©Èü³µpk10Ö®°ËÂë¹öÑ©Çò¼Æ»®</a></p>±±¾©Èü³µpk10Ö®°ËÂë¹öÑ©Çò¼Æ»® <p align="justify">¡¡¡¡<a href="http://sapience.com.tw/logs/meng/q629356.html">±±¾©Èü³µpk10Ö®°ËÂë¹öÑ©Çò¼Æ»®</a></p>±±¾©Èü³µpk10Ö®°ËÂë¹öÑ©Çò¼Æ»® <p align="justify">¡¡¡¡<a href="http://sapience.com.tw/logs/meng/q0281323.html">±±¾©Èü³µpk10Ö®°ËÂë¹öÑ©Çò¼Æ»®</a></p>±±¾©Èü³µpk10Ö®°ËÂë¹öÑ©Çò¼Æ»® <p align="justify">¡¡¡¡<a href="http://sapience.com.tw/logs/meng/q2321059.html">±±¾©Èü³µpk10Ö®°ËÂë¹öÑ©Çò¼Æ»®</a></p>±±¾©Èü³µpk10Ö®°ËÂë¹öÑ©Çò¼Æ»® <p align="justify">¡¡¡¡<a href="http://sapience.com.tw/logs/meng/q338708.html">±±¾©Èü³µpk10Ö®°ËÂë¹öÑ©Çò¼Æ»®</a></p>±±¾©Èü³µpk10Ö®°ËÂë¹öÑ©Çò¼Æ»® <p align="justify">¡¡¡¡<p>¡¡¡¡Ð»ªÉç´óÂíÊ¿¸ï3ÔÂ29Èյ磨¼ÇÕß³µºêÁÁ£©ÐðÀûÑÇÖв¿³ÇÊлôķ˹һÁ¾Ð¡ÐͿͳµ29ÈÕÔâÕ¨µ¯Ï®»÷£¬Ôì³ÉÖÁÉÙ5ÈËËÀÍö£¬ÁíÓÐ6ÈËÊÜÉË¡£<br /><br />¡¡¡¡¾ÝÐðͨÉ籨µÀ£¬¿Í³µÔâÏ®µØµãλÓÚ»ôķ˹ÊÐÔú¹þÀ­Çø¡£Ä¿Ç°ÉÐÎÞ×éÖ¯Ðû³ÆÖÆÔì´Ë´ÎÏ®»÷¡£<br /><br />¡¡¡¡Ôú¹þÀ­ÇøÊÇÐð×Üͳ°Íɳ¶û¡¤°¢ÈøµÂËùÊô°¢À­Î¬ÅÉÄÂ˹ÁÖ¾Û¾ÓÇø£¬¾ÓÃñ¶àΪÕþ¸®Ö§³ÖÕߣ¬µ±µØÒѶà´Î·¢ÉúÏ®»÷ʼþ¡£<br /><br />¡¡¡¡½ñÄê2Ôµ×ÒÔÀ´£¬»ôķ˹¡¢´óÂíÊ¿¸ïµÈµØ±©Á¦Ï®»÷Ƶ·¢£¬ÉËÍöÇé¿öÑÏÖØ¡£±¾ÔÂ23ÈÕ£¬»ôķ˹һ×ù¾üʼì²éÕ¾Ôâ×ÔɱʽÆû³µÕ¨µ¯Ï®»÷£¬Ôì³É3ÃûÊ¿±øËÀÍö¡£ÉÏÔÂ25ÈÕ£¬»ôķ˹ÔâÁ¬»·±¬Õ¨Ï®»÷£¬Ôì³ÉÊýÊ®ÈËËÀÍö¡£<br /><br />¡¡¡¡×÷Õߣº³µºêÁÁ (À´Ô´£ºÐ»ªÉç)</p><SCRIPT>media_span_url('http://news.xinhuanet.com/world/2017-03/30/c_1120720568.htm')</SCRIPT</p></div> <div id="filerider"> <div class="filelink" style="margin:10px 0 0 0;"><a href="./P020160207382291268334.doc">¸½¼þ£º2016Äê±±¾©µØÇø²©Îï¹Ý´º½ÚϵÁлһÀÀ±í</a></div> </div> </div> <div id="essaybottom" style="border:0; overflow:hidden; margin-bottom:0;"> <div style="padding-bottom:8px;" id="proclaim"><p style="float:left; line-height:30px;">·ÖÏíµ½£º</p><div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone"></a><a href="#" class="bds_tsina" data-cmd="tsina"></a><a href="#" class="bds_tqq" data-cmd="tqq"></a><a href="#" class="bds_renren" data-cmd="renren"></a><a href="#" class="bds_weixin" data-cmd="weixin"></a></div> <scRiPt>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdPic":"","bdStyle":"0","bdSize":"16"},"share":{},"image":{"viewList":["qzone","tsina","tqq","renren","weixin"],"viewText":"·ÖÏíµ½£º","viewSize":"16"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["qzone","tsina","tqq","renren","weixin"]}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('scRiPt')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</scRiPt></div> </div> <div id="essaybottom" style="margin-top:0;"> <div style="padding-bottom:8px;" id="proclaim">תժÉùÃ÷£º×ªÕªÇë×¢Ã÷³ö´¦²¢×ö»ØÁ´</div> </div> </div> </div> <!-- /container --> <div id="footer"> <div class="container"> <div class="span1" style="text-align:center"><scRiPt type="text/javascRiPt">document.write(unescape("%3Cspan id='_ideConac' %3E%3C/span%3E%3CscRiPt src='http://dcs.conac.cn/js/01/000/0000/60429971/CA010000000604299710004.js' type='text/javascRiPt'%3E%3C/scRiPt%3E"));</scRiPt></div> <div class="span8"> <div class="footer-top"> <div class="footer-class"> <p> <a title="¹ØÓÚÎÒÃÇ" href="http://www.beijing.gov.cn/zdxx/sdzcjs/t1306339.htm" style=" background:0">¹ØÓÚÎÒÃÇ</a><a target="_blank" title="Õ¾µãµØÍ¼" href="http://www.beijing.gov.cn/zdxx/sdzcjs/t1306342.htm">Õ¾µãµØÍ¼</a><a target="_blank" title="ÁªÏµÎÒÃÇ" href="http://www.beijing.gov.cn/zdxx/sdzcjs/t1306343.htm">ÁªÏµÎÒÃÇ</a><a target="_blank" title="ÆÀ¼ÛÊ×¶¼Ö®´°" href="mailto:service@beijing.gov.cn">ÆÀ¼ÛÊ×¶¼Ö®´°</a><a target="_blank" title="·¨ÂÉÉùÃ÷" href="http://www.beijing.gov.cn/zdxx/t709204.htm">·¨ÂÉÉùÃ÷</a> </p> <p>Ö÷°ì£º±±¾©ÊÐÈËÃñÕþ¸® °æÈ¨ËùÓга죺±±¾©Êо­¼ÃºÍÐÅÏ¢»¯Î¯Ô±»á ¾©ICP±¸05060933ºÅ ÔËÐйÜÀí£ºÊ×¶¼Ö®´°ÔËÐйÜÀíÖÐÐÄ</p> <p>¾©¹«Íø°²±¸ 110105000722 µØÖ·£º±±¾©Êг¯ÑôÇø±±³½Î÷·Êý×Ö±±¾©´óÏÃÄϰ˲㠴«Õ棺84371700 ¿Í·þÖÐÐĵ绰£º59321109</p> </div> </div> </div> </div> </div> <div style="display:none"> <scRiPt type="text/javascRiPt">document.write(unescape("%3CscRiPt src='http://yhfx.beijing.gov.cn/webdig.js?z=12' type='text/javascRiPt'%3E%3C/scRiPt%3E"));</scRiPt> <scRiPt type="text/javascRiPt">wd_paramtracker("_wdxid=000000000000000000000000000000000000000000")</scRiPt> </div> <scRiPt src="http://static.gridsumdissector.com/js/Clients/GWD-800003-C99186/gs.js" language="JavaScript"></scRiPt> <scRiPt type="text/javascRiPt"> // ÉèÖÃΪÖ÷Ò³ function SetHome(obj,vrl){ try{ obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl); } catch(e){ if(window.netscape) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e) { alert("´Ë²Ù×÷±»ä¯ÀÀÆ÷¾Ü¾ø£¡\nÇëÔÚä¯ÀÀÆ÷µØÖ·À¸ÊäÈë¡°about:config¡±²¢»Ø³µ\nÈ»ºó½« [signed.applets.codebase_principal_support]µÄÖµÉèÖÃΪ'true',Ë«»÷¼´¿É¡£"); } var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); prefs.setCharPref('browser.startup.homepage',vrl); }else{ alert("ÄúµÄä¯ÀÀÆ÷²»Ö§³Ö£¬Çë°´ÕÕÏÂÃæ²½Öè²Ù×÷£º1.´ò¿ªä¯ÀÀÆ÷ÉèÖá£2.µã»÷ÉèÖÃÍøÒ³¡£3.ÊäÈ룺"+vrl+"µã»÷È·¶¨¡£"); } } } // ¼ÓÈëÊÕ²Ø ¼æÈÝ360ºÍIE6 function shoucang(sTitle,sURL) { try { window.external.addFavorite(sURL, sTitle); } catch (e) { try { window.sidebar.addPanel(sTitle, sURL, ""); } catch (e) { alert("¼ÓÈëÊÕ²ØÊ§°Ü£¬ÇëʹÓÃCtrl+D½øÐÐÌí¼Ó"); } } } </scRiPt> <!-- Le javascRiPt ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <scRiPt src="/images/zhuanti/xysym/jquery.js"></scRiPt> <scRiPt src="/images/zhuanti/xysym/bootstrap-collapse.js"></scRiPt> <scRiPt> $(document).ready(function(){ $(".ui-select").selectWidget({ change : function (changes) { return changes; }, effect : "slide", keyControl : true, speed : 200, scrollHeight : 250 }); }); </scRiPt> </body> </html>
ForAEdesWeb/AEW25
logs/meng/q5321793.html
HTML
gpl-2.0
17,733
/* * Apple USB BCM5974 (Macbook Air and Penryn Macbook Pro) multitouch driver * * Copyright (C) 2008 Henrik Rydberg (rydberg@euromail.se) * * The USB initialization and package decoding was made by * Scott Shawcroft as part of the touchd user-space driver project: * Copyright (C) 2008 Scott Shawcroft (scott.shawcroft@gmail.com) * * The BCM5974 driver is based on the appletouch driver: * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com) * Copyright (C) 2005 Johannes Berg (johannes@sipsolutions.net) * Copyright (C) 2005 Stelian Pop (stelian@popies.net) * Copyright (C) 2005 Frank Arnold (frank@scirocco-5v-turbo.de) * Copyright (C) 2005 Peter Osterlund (petero2@telia.com) * Copyright (C) 2005 Michael Hanselmann (linux-kernel@hansmi.ch) * Copyright (C) 2006 Nicolas Boichat (nicolas@boichat.ch) * * 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, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include <linux/kernel.h> #include <linux/errno.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/module.h> #include <linux/usb/input.h> #include <linux/hid.h> #include <linux/mutex.h> #define USB_VENDOR_ID_APPLE 0x05ac /* MacbookAir, aka wellspring */ #define USB_DEVICE_ID_APPLE_WELLSPRING_ANSI 0x0223 #define USB_DEVICE_ID_APPLE_WELLSPRING_ISO 0x0224 #define USB_DEVICE_ID_APPLE_WELLSPRING_JIS 0x0225 /* MacbookProPenryn, aka wellspring2 */ #define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230 #define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231 #define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232 /* Macbook5,1 (unibody), aka wellspring3 */ #define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236 #define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237 #define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238 /* MacbookAir3,2 (unibody), aka wellspring5 */ #define USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI 0x023f #define USB_DEVICE_ID_APPLE_WELLSPRING4_ISO 0x0240 #define USB_DEVICE_ID_APPLE_WELLSPRING4_JIS 0x0241 /* MacbookAir3,1 (unibody), aka wellspring4 */ #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI 0x0242 #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO 0x0243 #define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS 0x0244 #define BCM5974_DEVICE(prod) { \ .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \ USB_DEVICE_ID_MATCH_INT_CLASS | \ USB_DEVICE_ID_MATCH_INT_PROTOCOL), \ .idVendor = USB_VENDOR_ID_APPLE, \ .idProduct = (prod), \ .bInterfaceClass = USB_INTERFACE_CLASS_HID, \ .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE \ } /* table of devices that work with this driver */ static const struct usb_device_id bcm5974_table[] = { /* MacbookAir1.1 */ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ISO), BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_JIS), /* MacbookProPenryn */ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI), BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ISO), BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_JIS), /* Macbook5,1 */ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI), BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ISO), BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_JIS), /* MacbookAir3,2 */ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI), BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_ISO), BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_JIS), /* MacbookAir3,1 */ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI), BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO), BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS), /* Terminating entry */ {} }; MODULE_DEVICE_TABLE(usb, bcm5974_table); MODULE_AUTHOR("Henrik Rydberg"); MODULE_DESCRIPTION("Apple USB BCM5974 multitouch driver"); MODULE_LICENSE("GPL"); #define dprintk(level, format, a...)\ { if (debug >= level) printk(KERN_DEBUG format, ##a); } static int debug = 1; module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Activate debugging output"); /* button data structure */ struct bt_data { u8 unknown1; /* constant */ u8 button; /* left button */ u8 rel_x; /* relative x coordinate */ u8 rel_y; /* relative y coordinate */ }; /* trackpad header types */ enum tp_type { TYPE1, /* plain trackpad */ TYPE2 /* button integrated in trackpad */ }; /* trackpad finger data offsets, le16-aligned */ #define FINGER_TYPE1 (13 * sizeof(__le16)) #define FINGER_TYPE2 (15 * sizeof(__le16)) /* trackpad button data offsets */ #define BUTTON_TYPE2 15 /* list of device capability bits */ #define HAS_INTEGRATED_BUTTON 1 /* trackpad finger structure, le16-aligned */ struct tp_finger { __le16 origin; /* zero when switching track finger */ __le16 abs_x; /* absolute x coodinate */ __le16 abs_y; /* absolute y coodinate */ __le16 rel_x; /* relative x coodinate */ __le16 rel_y; /* relative y coodinate */ __le16 size_major; /* finger size, major axis? */ __le16 size_minor; /* finger size, minor axis? */ __le16 orientation; /* 16384 when point, else 15 bit angle */ __le16 force_major; /* trackpad force, major axis? */ __le16 force_minor; /* trackpad force, minor axis? */ __le16 unused[3]; /* zeros */ __le16 multi; /* one finger: varies, more fingers: constant */ } __attribute__((packed,aligned(2))); /* trackpad finger data size, empirically at least ten fingers */ #define SIZEOF_FINGER sizeof(struct tp_finger) #define SIZEOF_ALL_FINGERS (16 * SIZEOF_FINGER) /* device-specific parameters */ struct bcm5974_param { int dim; /* logical dimension */ int fuzz; /* logical noise value */ int devmin; /* device minimum reading */ int devmax; /* device maximum reading */ }; /* device-specific configuration */ struct bcm5974_config { int ansi, iso, jis; /* the product id of this device */ int caps; /* device capability bitmask */ int bt_ep; /* the endpoint of the button interface */ int bt_datalen; /* data length of the button interface */ int tp_ep; /* the endpoint of the trackpad interface */ enum tp_type tp_type; /* type of trackpad interface */ int tp_offset; /* offset to trackpad finger data */ int tp_datalen; /* data length of the trackpad interface */ struct bcm5974_param p; /* finger pressure limits */ struct bcm5974_param w; /* finger width limits */ struct bcm5974_param x; /* horizontal limits */ struct bcm5974_param y; /* vertical limits */ }; /* logical device structure */ struct bcm5974 { char phys[64]; struct usb_device *udev; /* usb device */ struct usb_interface *intf; /* our interface */ struct input_dev *input; /* input dev */ struct bcm5974_config cfg; /* device configuration */ struct mutex pm_mutex; /* serialize access to open/suspend */ int opened; /* 1: opened, 0: closed */ struct urb *bt_urb; /* button usb request block */ struct bt_data *bt_data; /* button transferred data */ struct urb *tp_urb; /* trackpad usb request block */ u8 *tp_data; /* trackpad transferred data */ int fingers; /* number of fingers on trackpad */ }; /* logical dimensions */ #define DIM_PRESSURE 256 /* maximum finger pressure */ #define DIM_WIDTH 16 /* maximum finger width */ #define DIM_X 1280 /* maximum trackpad x value */ #define DIM_Y 800 /* maximum trackpad y value */ /* logical signal quality */ #define SN_PRESSURE 45 /* pressure signal-to-noise ratio */ #define SN_WIDTH 100 /* width signal-to-noise ratio */ #define SN_COORD 250 /* coordinate signal-to-noise ratio */ /* pressure thresholds */ #define PRESSURE_LOW (2 * DIM_PRESSURE / SN_PRESSURE) #define PRESSURE_HIGH (3 * PRESSURE_LOW) /* device constants */ static const struct bcm5974_config bcm5974_config_table[] = { { USB_DEVICE_ID_APPLE_WELLSPRING_ANSI, USB_DEVICE_ID_APPLE_WELLSPRING_ISO, USB_DEVICE_ID_APPLE_WELLSPRING_JIS, 0, 0x84, sizeof(struct bt_data), 0x81, TYPE1, FINGER_TYPE1, FINGER_TYPE1 + SIZEOF_ALL_FINGERS, { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 }, { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, { DIM_X, DIM_X / SN_COORD, -4824, 5342 }, { DIM_Y, DIM_Y / SN_COORD, -172, 5820 } }, { USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS, 0, 0x84, sizeof(struct bt_data), 0x81, TYPE1, FINGER_TYPE1, FINGER_TYPE1 + SIZEOF_ALL_FINGERS, { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 }, { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, { DIM_X, DIM_X / SN_COORD, -4824, 4824 }, { DIM_Y, DIM_Y / SN_COORD, -172, 4290 } }, { USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS, HAS_INTEGRATED_BUTTON, 0x84, sizeof(struct bt_data), 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS, { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 }, { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, { DIM_X, DIM_X / SN_COORD, -4460, 5166 }, { DIM_Y, DIM_Y / SN_COORD, -75, 6700 } }, { USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS, HAS_INTEGRATED_BUTTON, 0x84, sizeof(struct bt_data), 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS, { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 }, { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, { DIM_X, DIM_X / SN_COORD, -4620, 5140 }, { DIM_Y, DIM_Y / SN_COORD, -150, 6600 } }, { USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS, HAS_INTEGRATED_BUTTON, 0x84, sizeof(struct bt_data), 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS, { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 }, { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, { DIM_X, DIM_X / SN_COORD, -4616, 5112 }, { DIM_Y, DIM_Y / SN_COORD, -142, 5234 } }, {} }; /* return the device-specific configuration by device */ static const struct bcm5974_config *bcm5974_get_config(struct usb_device *udev) { u16 id = le16_to_cpu(udev->descriptor.idProduct); const struct bcm5974_config *cfg; for (cfg = bcm5974_config_table; cfg->ansi; ++cfg) if (cfg->ansi == id || cfg->iso == id || cfg->jis == id) return cfg; return bcm5974_config_table; } /* convert 16-bit little endian to signed integer */ static inline int raw2int(__le16 x) { return (signed short)le16_to_cpu(x); } /* scale device data to logical dimensions (asserts devmin < devmax) */ static inline int int2scale(const struct bcm5974_param *p, int x) { return x * p->dim / (p->devmax - p->devmin); } /* all logical value ranges are [0,dim). */ static inline int int2bound(const struct bcm5974_param *p, int x) { int s = int2scale(p, x); return clamp_val(s, 0, p->dim - 1); } /* setup which logical events to report */ static void setup_events_to_report(struct input_dev *input_dev, const struct bcm5974_config *cfg) { __set_bit(EV_ABS, input_dev->evbit); input_set_abs_params(input_dev, ABS_PRESSURE, 0, cfg->p.dim, cfg->p.fuzz, 0); input_set_abs_params(input_dev, ABS_TOOL_WIDTH, 0, cfg->w.dim, cfg->w.fuzz, 0); input_set_abs_params(input_dev, ABS_X, 0, cfg->x.dim, cfg->x.fuzz, 0); input_set_abs_params(input_dev, ABS_Y, 0, cfg->y.dim, cfg->y.fuzz, 0); __set_bit(EV_KEY, input_dev->evbit); __set_bit(BTN_TOUCH, input_dev->keybit); __set_bit(BTN_TOOL_FINGER, input_dev->keybit); __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit); __set_bit(BTN_LEFT, input_dev->keybit); } /* report button data as logical button state */ static int report_bt_state(struct bcm5974 *dev, int size) { if (size != sizeof(struct bt_data)) return -EIO; dprintk(7, "bcm5974: button data: %x %x %x %x\n", dev->bt_data->unknown1, dev->bt_data->button, dev->bt_data->rel_x, dev->bt_data->rel_y); input_report_key(dev->input, BTN_LEFT, dev->bt_data->button); input_sync(dev->input); return 0; } /* report trackpad data as logical trackpad state */ static int report_tp_state(struct bcm5974 *dev, int size) { const struct bcm5974_config *c = &dev->cfg; const struct tp_finger *f; struct input_dev *input = dev->input; int raw_p, raw_w, raw_x, raw_y, raw_n; int ptest, origin, ibt = 0, nmin = 0, nmax = 0; int abs_p = 0, abs_w = 0, abs_x = 0, abs_y = 0; if (size < c->tp_offset || (size - c->tp_offset) % SIZEOF_FINGER != 0) return -EIO; /* finger data, le16-aligned */ f = (const struct tp_finger *)(dev->tp_data + c->tp_offset); raw_n = (size - c->tp_offset) / SIZEOF_FINGER; /* always track the first finger; when detached, start over */ if (raw_n) { raw_p = raw2int(f->force_major); raw_w = raw2int(f->size_major); raw_x = raw2int(f->abs_x); raw_y = raw2int(f->abs_y); dprintk(9, "bcm5974: " "raw: p: %+05d w: %+05d x: %+05d y: %+05d n: %d\n", raw_p, raw_w, raw_x, raw_y, raw_n); ptest = int2bound(&c->p, raw_p); origin = raw2int(f->origin); /* set the integrated button if applicable */ if (c->tp_type == TYPE2) ibt = raw2int(dev->tp_data[BUTTON_TYPE2]); /* while tracking finger still valid, count all fingers */ if (ptest > PRESSURE_LOW && origin) { abs_p = ptest; abs_w = int2bound(&c->w, raw_w); abs_x = int2bound(&c->x, raw_x - c->x.devmin); abs_y = int2bound(&c->y, c->y.devmax - raw_y); while (raw_n--) { ptest = int2bound(&c->p, raw2int(f->force_major)); if (ptest > PRESSURE_LOW) nmax++; if (ptest > PRESSURE_HIGH) nmin++; f++; } } } if (dev->fingers < nmin) dev->fingers = nmin; if (dev->fingers > nmax) dev->fingers = nmax; input_report_key(input, BTN_TOUCH, dev->fingers > 0); input_report_key(input, BTN_TOOL_FINGER, dev->fingers == 1); input_report_key(input, BTN_TOOL_DOUBLETAP, dev->fingers == 2); input_report_key(input, BTN_TOOL_TRIPLETAP, dev->fingers == 3); input_report_key(input, BTN_TOOL_QUADTAP, dev->fingers > 3); input_report_abs(input, ABS_PRESSURE, abs_p); input_report_abs(input, ABS_TOOL_WIDTH, abs_w); if (abs_p) { input_report_abs(input, ABS_X, abs_x); input_report_abs(input, ABS_Y, abs_y); dprintk(8, "bcm5974: abs: p: %+05d w: %+05d x: %+05d y: %+05d " "nmin: %d nmax: %d n: %d ibt: %d\n", abs_p, abs_w, abs_x, abs_y, nmin, nmax, dev->fingers, ibt); } /* type 2 reports button events via ibt only */ if (c->tp_type == TYPE2) input_report_key(input, BTN_LEFT, ibt); input_sync(input); return 0; } /* Wellspring initialization constants */ #define BCM5974_WELLSPRING_MODE_READ_REQUEST_ID 1 #define BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID 9 #define BCM5974_WELLSPRING_MODE_REQUEST_VALUE 0x300 #define BCM5974_WELLSPRING_MODE_REQUEST_INDEX 0 #define BCM5974_WELLSPRING_MODE_VENDOR_VALUE 0x01 #define BCM5974_WELLSPRING_MODE_NORMAL_VALUE 0x08 static int bcm5974_wellspring_mode(struct bcm5974 *dev, bool on) { char *data = kmalloc(8, GFP_KERNEL); int retval = 0, size; if (!data) { err("bcm5974: out of memory"); retval = -ENOMEM; goto out; } /* read configuration */ size = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), BCM5974_WELLSPRING_MODE_READ_REQUEST_ID, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, BCM5974_WELLSPRING_MODE_REQUEST_VALUE, BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000); if (size != 8) { err("bcm5974: could not read from device"); retval = -EIO; goto out; } /* apply the mode switch */ data[0] = on ? BCM5974_WELLSPRING_MODE_VENDOR_VALUE : BCM5974_WELLSPRING_MODE_NORMAL_VALUE; /* write configuration */ size = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID, USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, BCM5974_WELLSPRING_MODE_REQUEST_VALUE, BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000); if (size != 8) { err("bcm5974: could not write to device"); retval = -EIO; goto out; } dprintk(2, "bcm5974: switched to %s mode.\n", on ? "wellspring" : "normal"); out: kfree(data); return retval; } static void bcm5974_irq_button(struct urb *urb) { struct bcm5974 *dev = urb->context; int error; switch (urb->status) { case 0: break; case -EOVERFLOW: case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: dbg("bcm5974: button urb shutting down: %d", urb->status); return; default: dbg("bcm5974: button urb status: %d", urb->status); goto exit; } if (report_bt_state(dev, dev->bt_urb->actual_length)) dprintk(1, "bcm5974: bad button package, length: %d\n", dev->bt_urb->actual_length); exit: error = usb_submit_urb(dev->bt_urb, GFP_ATOMIC); if (error) err("bcm5974: button urb failed: %d", error); } static void bcm5974_irq_trackpad(struct urb *urb) { struct bcm5974 *dev = urb->context; int error; switch (urb->status) { case 0: break; case -EOVERFLOW: case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: dbg("bcm5974: trackpad urb shutting down: %d", urb->status); return; default: dbg("bcm5974: trackpad urb status: %d", urb->status); goto exit; } /* control response ignored */ if (dev->tp_urb->actual_length == 2) goto exit; if (report_tp_state(dev, dev->tp_urb->actual_length)) dprintk(1, "bcm5974: bad trackpad package, length: %d\n", dev->tp_urb->actual_length); exit: error = usb_submit_urb(dev->tp_urb, GFP_ATOMIC); if (error) err("bcm5974: trackpad urb failed: %d", error); } /* * The Wellspring trackpad, like many recent Apple trackpads, share * the usb device with the keyboard. Since keyboards are usually * handled by the HID system, the device ends up being handled by two * modules. Setting up the device therefore becomes slightly * complicated. To enable multitouch features, a mode switch is * required, which is usually applied via the control interface of the * device. It can be argued where this switch should take place. In * some drivers, like appletouch, the switch is made during * probe. However, the hid module may also alter the state of the * device, resulting in trackpad malfunction under certain * circumstances. To get around this problem, there is at least one * example that utilizes the USB_QUIRK_RESET_RESUME quirk in order to * recieve a reset_resume request rather than the normal resume. * Since the implementation of reset_resume is equal to mode switch * plus start_traffic, it seems easier to always do the switch when * starting traffic on the device. */ static int bcm5974_start_traffic(struct bcm5974 *dev) { if (bcm5974_wellspring_mode(dev, true)) { dprintk(1, "bcm5974: mode switch failed\n"); goto error; } if (usb_submit_urb(dev->bt_urb, GFP_KERNEL)) goto error; if (usb_submit_urb(dev->tp_urb, GFP_KERNEL)) goto err_kill_bt; return 0; err_kill_bt: usb_kill_urb(dev->bt_urb); error: return -EIO; } static void bcm5974_pause_traffic(struct bcm5974 *dev) { usb_kill_urb(dev->tp_urb); usb_kill_urb(dev->bt_urb); bcm5974_wellspring_mode(dev, false); } /* * The code below implements open/close and manual suspend/resume. * All functions may be called in random order. * * Opening a suspended device fails with EACCES - permission denied. * * Failing a resume leaves the device resumed but closed. */ static int bcm5974_open(struct input_dev *input) { struct bcm5974 *dev = input_get_drvdata(input); int error; error = usb_autopm_get_interface(dev->intf); if (error) return error; mutex_lock(&dev->pm_mutex); error = bcm5974_start_traffic(dev); if (!error) dev->opened = 1; mutex_unlock(&dev->pm_mutex); if (error) usb_autopm_put_interface(dev->intf); return error; } static void bcm5974_close(struct input_dev *input) { struct bcm5974 *dev = input_get_drvdata(input); mutex_lock(&dev->pm_mutex); bcm5974_pause_traffic(dev); dev->opened = 0; mutex_unlock(&dev->pm_mutex); usb_autopm_put_interface(dev->intf); } static int bcm5974_suspend(struct usb_interface *iface, pm_message_t message) { struct bcm5974 *dev = usb_get_intfdata(iface); mutex_lock(&dev->pm_mutex); if (dev->opened) bcm5974_pause_traffic(dev); mutex_unlock(&dev->pm_mutex); return 0; } static int bcm5974_resume(struct usb_interface *iface) { struct bcm5974 *dev = usb_get_intfdata(iface); int error = 0; mutex_lock(&dev->pm_mutex); if (dev->opened) error = bcm5974_start_traffic(dev); mutex_unlock(&dev->pm_mutex); return error; } static int bcm5974_probe(struct usb_interface *iface, const struct usb_device_id *id) { struct usb_device *udev = interface_to_usbdev(iface); const struct bcm5974_config *cfg; struct bcm5974 *dev; struct input_dev *input_dev; int error = -ENOMEM; /* find the product index */ cfg = bcm5974_get_config(udev); /* allocate memory for our device state and initialize it */ dev = kzalloc(sizeof(struct bcm5974), GFP_KERNEL); input_dev = input_allocate_device(); if (!dev || !input_dev) { err("bcm5974: out of memory"); goto err_free_devs; } dev->udev = udev; dev->intf = iface; dev->input = input_dev; dev->cfg = *cfg; mutex_init(&dev->pm_mutex); /* setup urbs */ dev->bt_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->bt_urb) goto err_free_devs; dev->tp_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->tp_urb) goto err_free_bt_urb; dev->bt_data = usb_buffer_alloc(dev->udev, dev->cfg.bt_datalen, GFP_KERNEL, &dev->bt_urb->transfer_dma); if (!dev->bt_data) goto err_free_urb; dev->tp_data = usb_buffer_alloc(dev->udev, dev->cfg.tp_datalen, GFP_KERNEL, &dev->tp_urb->transfer_dma); if (!dev->tp_data) goto err_free_bt_buffer; usb_fill_int_urb(dev->bt_urb, udev, usb_rcvintpipe(udev, cfg->bt_ep), dev->bt_data, dev->cfg.bt_datalen, bcm5974_irq_button, dev, 1); usb_fill_int_urb(dev->tp_urb, udev, usb_rcvintpipe(udev, cfg->tp_ep), dev->tp_data, dev->cfg.tp_datalen, bcm5974_irq_trackpad, dev, 1); /* create bcm5974 device */ usb_make_path(udev, dev->phys, sizeof(dev->phys)); strlcat(dev->phys, "/input0", sizeof(dev->phys)); input_dev->name = "bcm5974"; input_dev->phys = dev->phys; usb_to_input_id(dev->udev, &input_dev->id); /* report driver capabilities via the version field */ input_dev->id.version = cfg->caps; input_dev->dev.parent = &iface->dev; input_set_drvdata(input_dev, dev); input_dev->open = bcm5974_open; input_dev->close = bcm5974_close; setup_events_to_report(input_dev, cfg); error = input_register_device(dev->input); if (error) goto err_free_buffer; /* save our data pointer in this interface device */ usb_set_intfdata(iface, dev); return 0; err_free_buffer: usb_buffer_free(dev->udev, dev->cfg.tp_datalen, dev->tp_data, dev->tp_urb->transfer_dma); err_free_bt_buffer: usb_buffer_free(dev->udev, dev->cfg.bt_datalen, dev->bt_data, dev->bt_urb->transfer_dma); err_free_urb: usb_free_urb(dev->tp_urb); err_free_bt_urb: usb_free_urb(dev->bt_urb); err_free_devs: usb_set_intfdata(iface, NULL); input_free_device(input_dev); kfree(dev); return error; } static void bcm5974_disconnect(struct usb_interface *iface) { struct bcm5974 *dev = usb_get_intfdata(iface); usb_set_intfdata(iface, NULL); input_unregister_device(dev->input); usb_buffer_free(dev->udev, dev->cfg.tp_datalen, dev->tp_data, dev->tp_urb->transfer_dma); usb_buffer_free(dev->udev, dev->cfg.bt_datalen, dev->bt_data, dev->bt_urb->transfer_dma); usb_free_urb(dev->tp_urb); usb_free_urb(dev->bt_urb); kfree(dev); } static struct usb_driver bcm5974_driver = { .name = "bcm5974", .probe = bcm5974_probe, .disconnect = bcm5974_disconnect, .suspend = bcm5974_suspend, .resume = bcm5974_resume, .reset_resume = bcm5974_resume, .id_table = bcm5974_table, .supports_autosuspend = 1, }; static int __init bcm5974_init(void) { return usb_register(&bcm5974_driver); } static void __exit bcm5974_exit(void) { usb_deregister(&bcm5974_driver); } module_init(bcm5974_init); module_exit(bcm5974_exit);
kylon/Buzz-kernel
drivers/input/mouse/bcm5974.c
C
gpl-2.0
24,772
package wusc.edu.pay.common.utils.export; import java.util.List; /** * 描述: 数据导出,数据源 * @author Hill * */ public interface ExportDataSource<T>{ <T> List<T> getData(); }
piaolinzhi/fight
dubbo/pay/pay-common/src/main/java/wusc/edu/pay/common/utils/export/ExportDataSource.java
Java
gpl-2.0
208
<?php /** * @author tshirtecommerce - www.tshirtecommerce.com * @date: March 2015 * * @copyright Copyright (C) 2015 tshirtecommerce.com. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE * */ /** * Simple PHP upload class * */ class Uploader { private $destinationPath; private $errorMessage; private $extensions; private $allowAll; private $maxSize = 10; private $uploadName; private $seqnence; public $name = 'Uploader'; public $imageSeq = 'dg-designer'; public $useTable = false; // set path upload function setDir($path){ $this->destinationPath = $path; $this->allowAll = false; } function allowAllFormats(){ $this->allowAll = true; } function setMaxSize($sizeMB){ $this->maxSize = $sizeMB * (1024*1024); } function setExtensions($options){ $this->extensions = $options; } function setSameFileName(){ $this->sameFileName = true; $this->sameName = true; } function getExtension($string){ $ext = ""; try{ $parts = explode(".",$string); $ext = strtolower($parts[count($parts)-1]); }catch(Exception $c){ $ext = ""; } return $ext; } function setMessage($message){ $this->errorMessage = $message; } function getMessage(){ return $this->errorMessage; } function getUploadName(){ return $this->uploadName; } function setSequence($seq){ $this->imageSeq = $seq; } function getRandom(){ return strtotime(date('Y-m-d H:i:s')).rand(1111,9999).rand(11,99).rand(111,999); } function sameName($true = true){ $this->sameName = $true; } function uploadFile($fileBrowse){ $result = false; $size = $_FILES[$fileBrowse]["size"]; $name = $_FILES[$fileBrowse]["name"]; $ext = $this->getExtension($name); if(!is_dir($this->destinationPath)) { $this->setMessage("Destination folder is not a directory "); } else if(!is_writable($this->destinationPath)) { $this->setMessage("Destination is not writable !"); } else if(empty($name)) { $this->setMessage("File not selected "); } else if($size>$this->maxSize) { $this->setMessage("Too large file !"); } else if($this->allowAll || (!$this->allowAll && in_array($ext,$this->extensions))) { if($this->sameName==false) { $this->uploadName = $this->imageSeq."-".substr(md5(rand(1111,9999)),0,8).$this->getRandom().rand(1111,1000).rand(99,9999).".".$ext; } else { $this->uploadName = $name; } if(move_uploaded_file($_FILES[$fileBrowse]["tmp_name"],$this->destinationPath.$this->uploadName)) { $result = true; } else { $this->setMessage("Upload failed , try later !"); } } else { $this->setMessage("Invalid file format !"); } return $result; } function deleteUploaded() { unlink($this->destinationPath.$this->uploadName); } } // end of Upload
lieison/Blu-Nova
tshirtecommerce/includes/upload.php
PHP
gpl-2.0
2,919
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width" /> <link rel="shortcut icon" type="image/x-icon" href="../../../../../../../favicon.ico" /> <title>Invitations.LoadInvitationsResult | Android Developers</title> <!-- STYLESHEETS --> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto+Condensed"> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:light,regular,medium,thin,italic,mediumitalic,bold" title="roboto"> <link href="../../../../../../../assets/css/default.css?v=2" rel="stylesheet" type="text/css"> <!-- FULLSCREEN STYLESHEET --> <link href="../../../../../../../assets/css/fullscreen.css" rel="stylesheet" class="fullscreen" type="text/css"> <!-- JAVASCRIPT --> <script src="http://www.google.com/jsapi" type="text/javascript"></script> <script src="../../../../../../../assets/js/android_3p-bundle.js" type="text/javascript"></script> <script type="text/javascript"> var toRoot = "../../../../../../../"; var metaTags = []; var devsite = false; </script> <script src="../../../../../../../assets/js/docs.js?v=2" type="text/javascript"></script> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-5831155-1', 'android.com'); ga('create', 'UA-49880327-2', 'android.com', {'name': 'universal'}); // New tracker); ga('send', 'pageview'); ga('universal.send', 'pageview'); // Send page view for new tracker. </script> </head> <body class="gc-documentation develop" itemscope itemtype="http://schema.org/Article"> <div id="doc-api-level" class="" style="display:none"></div> <a name="top"></a> <a name="top"></a> <!-- Header --> <div id="header-wrapper"> <div id="header"> <div class="wrap" id="header-wrap"> <div class="col-3 logo"> <a href="../../../../../../../index.html"> <img src="../../../../../../../assets/images/dac_logo.png" srcset="../../../../../../../assets/images/dac_logo@2x.png 2x" width="123" height="25" alt="Android Developers" /> </a> <div class="btn-quicknav" id="btn-quicknav"> <a href="#" class="arrow-inactive">Quicknav</a> <a href="#" class="arrow-active">Quicknav</a> </div> </div> <ul class="nav-x col-9"> <li class="design"> <a href="../../../../../../../design/index.html" zh-tw-lang="設計" zh-cn-lang="设计" ru-lang="Проектирование" ko-lang="디자인" ja-lang="設計" es-lang="Diseñar" >Design</a></li> <li class="develop"><a href="../../../../../../../develop/index.html" zh-tw-lang="開發" zh-cn-lang="开发" ru-lang="Разработка" ko-lang="개발" ja-lang="開発" es-lang="Desarrollar" >Develop</a></li> <li class="distribute last"><a href="../../../../../../../distribute/googleplay/index.html" zh-tw-lang="發佈" zh-cn-lang="分发" ru-lang="Распространение" ko-lang="배포" ja-lang="配布" es-lang="Distribuir" >Distribute</a></li> </ul> <div class="menu-container"> <div class="moremenu"> <div id="more-btn"></div> </div> <div class="morehover" id="moremenu"> <div class="top"></div> <div class="mid"> <div class="header">Links</div> <ul> <li><a href="https://play.google.com/apps/publish/" target="_googleplay">Google Play Developer Console</a></li> <li><a href="http://android-developers.blogspot.com/">Android Developers Blog</a></li> <li><a href="../../../../../../../about/index.html">About Android</a></li> </ul> <div class="header">Android Sites</div> <ul> <li><a href="http://www.android.com">Android.com</a></li> <li class="active"><a>Android Developers</a></li> <li><a href="http://source.android.com">Android Open Source Project</a></li> </ul> <br class="clearfix" /> </div><!-- end 'mid' --> <div class="bottom"></div> </div><!-- end 'moremenu' --> <div class="search" id="search-container"> <div class="search-inner"> <div id="search-btn"></div> <div class="left"></div> <form onsubmit="return submit_search()"> <input id="search_autocomplete" type="text" value="" autocomplete="off" name="q" onfocus="search_focus_changed(this, true)" onblur="search_focus_changed(this, false)" onkeydown="return search_changed(event, true, '../../../../../../../')" onkeyup="return search_changed(event, false, '../../../../../../../')" /> </form> <div class="right"></div> <a class="close hide">close</a> <div class="left"></div> <div class="right"></div> </div><!-- end search-inner --> </div><!-- end search-container --> <div class="search_filtered_wrapper reference"> <div class="suggest-card reference no-display"> <ul class="search_filtered"> </ul> </div> </div> <div class="search_filtered_wrapper docs"> <div class="suggest-card dummy no-display">&nbsp;</div> <div class="suggest-card develop no-display"> <ul class="search_filtered"> </ul> <div class="child-card guides no-display"> </div> <div class="child-card training no-display"> </div> <div class="child-card samples no-display"> </div> </div> <div class="suggest-card design no-display"> <ul class="search_filtered"> </ul> </div> <div class="suggest-card distribute no-display"> <ul class="search_filtered"> </ul> </div> </div> </div><!-- end menu-container (search and menu widget) --> <!-- Expanded quicknav --> <div id="quicknav" class="col-13"> <ul> <li class="about"> <ul> <li><a href="../../../../../../../about/index.html">About</a></li> <li><a href="../../../../../../../wear/index.html">Wear</a></li> <li><a href="../../../../../../../tv/index.html">TV</a></li> <li><a href="../../../../../../../auto/index.html">Auto</a></li> </ul> </li> <li class="design"> <ul> <li><a href="../../../../../../../design/index.html">Get Started</a></li> <li><a href="../../../../../../../design/devices.html">Devices</a></li> <li><a href="../../../../../../../design/style/index.html">Style</a></li> <li><a href="../../../../../../../design/patterns/index.html">Patterns</a></li> <li><a href="../../../../../../../design/building-blocks/index.html">Building Blocks</a></li> <li><a href="../../../../../../../design/downloads/index.html">Downloads</a></li> <li><a href="../../../../../../../design/videos/index.html">Videos</a></li> </ul> </li> <li class="develop"> <ul> <li><a href="../../../../../../../training/index.html" zh-tw-lang="訓練課程" zh-cn-lang="培训" ru-lang="Курсы" ko-lang="교육" ja-lang="トレーニング" es-lang="Capacitación" >Training</a></li> <li><a href="../../../../../../../guide/index.html" zh-tw-lang="API 指南" zh-cn-lang="API 指南" ru-lang="Руководства по API" ko-lang="API 가이드" ja-lang="API ガイド" es-lang="Guías de la API" >API Guides</a></li> <li><a href="../../../../../../../reference/packages.html" zh-tw-lang="參考資源" zh-cn-lang="参考" ru-lang="Справочник" ko-lang="참조문서" ja-lang="リファレンス" es-lang="Referencia" >Reference</a></li> <li><a href="../../../../../../../sdk/index.html" zh-tw-lang="相關工具" zh-cn-lang="工具" ru-lang="Инструменты" ko-lang="도구" ja-lang="ツール" es-lang="Herramientas" >Tools</a> </li> <li><a href="../../../../../../../google/index.html">Google Services</a> </li> </ul> </li> <li class="distribute last"> <ul> <li><a href="../../../../../../../distribute/googleplay/index.html">Google Play</a></li> <li><a href="../../../../../../../distribute/essentials/index.html">Essentials</a></li> <li><a href="../../../../../../../distribute/users/index.html">Get Users</a></li> <li><a href="../../../../../../../distribute/engage/index.html">Engage &amp; Retain</a></li> <li><a href="../../../../../../../distribute/monetize/index.html">Monetize</a></li> <li><a href="../../../../../../../distribute/tools/index.html">Tools &amp; Reference</a></li> <li><a href="../../../../../../../distribute/stories/index.html">Developer Stories</a></li> </ul> </li> </ul> </div><!-- /Expanded quicknav --> </div><!-- end header-wrap.wrap --> </div><!-- end header --> <!-- Secondary x-nav --> <div id="nav-x"> <div class="wrap"> <ul class="nav-x col-9 develop" style="width:100%"> <li class="training"><a href="../../../../../../../training/index.html" zh-tw-lang="訓練課程" zh-cn-lang="培训" ru-lang="Курсы" ko-lang="교육" ja-lang="トレーニング" es-lang="Capacitación" >Training</a></li> <li class="guide"><a href="../../../../../../../guide/index.html" zh-tw-lang="API 指南" zh-cn-lang="API 指南" ru-lang="Руководства по API" ko-lang="API 가이드" ja-lang="API ガイド" es-lang="Guías de la API" >API Guides</a></li> <li class="reference"><a href="../../../../../../../reference/packages.html" zh-tw-lang="參考資源" zh-cn-lang="参考" ru-lang="Справочник" ko-lang="참조문서" ja-lang="リファレンス" es-lang="Referencia" >Reference</a></li> <li class="tools"><a href="../../../../../../../sdk/index.html" zh-tw-lang="相關工具" zh-cn-lang="工具" ru-lang="Инструменты" ko-lang="도구" ja-lang="ツール" es-lang="Herramientas" >Tools</a></li> <li class="google"><a href="../../../../../../../google/index.html" >Google Services</a> </li> </ul> </div> </div> <!-- /Sendondary x-nav DEVELOP --> <div id="searchResults" class="wrap" style="display:none;"> <h2 id="searchTitle">Results</h2> <div id="leftSearchControl" class="search-control">Loading...</div> </div> </div> <!--end header-wrapper --> <div id="sticky-header"> <div> <a class="logo" href="#top"></a> <a class="top" href="#top"></a> <ul class="breadcrumb"> <li class="current">Invitations.LoadInvitationsResult</li> </ul> </div> </div> <div class="wrap clearfix" id="body-content"> <div class="col-4" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement"> <div id="devdoc-nav"> <div id="api-nav-header"> <div id="api-level-toggle"> <label for="apiLevelCheckbox" class="disabled" title="Select your target API level to dim unavailable APIs">API level: </label> <div class="select-wrapper"> <select id="apiLevelSelector"> <!-- option elements added by buildApiLevelSelector() --> </select> </div> </div><!-- end toggle --> <div id="api-nav-title">Android APIs</div> </div><!-- end nav header --> <script> var SINCE_DATA = [ ]; buildApiLevelSelector(); </script> <div id="swapper"> <div id="nav-panels"> <div id="resize-packages-nav"> <div id="packages-nav" class="scroll-pane"> <ul> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/package-summary.html">com.google.android.gms</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/actions/package-summary.html">com.google.android.gms.actions</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/ads/package-summary.html">com.google.android.gms.ads</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/ads/doubleclick/package-summary.html">com.google.android.gms.ads.doubleclick</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/ads/identifier/package-summary.html">com.google.android.gms.ads.identifier</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/ads/mediation/package-summary.html">com.google.android.gms.ads.mediation</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/ads/mediation/admob/package-summary.html">com.google.android.gms.ads.mediation.admob</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/ads/mediation/customevent/package-summary.html">com.google.android.gms.ads.mediation.customevent</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/ads/purchase/package-summary.html">com.google.android.gms.ads.purchase</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/ads/search/package-summary.html">com.google.android.gms.ads.search</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/analytics/package-summary.html">com.google.android.gms.analytics</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/analytics/ecommerce/package-summary.html">com.google.android.gms.analytics.ecommerce</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/appindexing/package-summary.html">com.google.android.gms.appindexing</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/appstate/package-summary.html">com.google.android.gms.appstate</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/auth/package-summary.html">com.google.android.gms.auth</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/auth/api/package-summary.html">com.google.android.gms.auth.api</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/cast/package-summary.html">com.google.android.gms.cast</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/common/package-summary.html">com.google.android.gms.common</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/common/annotation/package-summary.html">com.google.android.gms.common.annotation</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/common/api/package-summary.html">com.google.android.gms.common.api</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/common/data/package-summary.html">com.google.android.gms.common.data</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/common/images/package-summary.html">com.google.android.gms.common.images</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/drive/package-summary.html">com.google.android.gms.drive</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/drive/events/package-summary.html">com.google.android.gms.drive.events</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/drive/metadata/package-summary.html">com.google.android.gms.drive.metadata</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/drive/query/package-summary.html">com.google.android.gms.drive.query</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/drive/widget/package-summary.html">com.google.android.gms.drive.widget</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/fitness/package-summary.html">com.google.android.gms.fitness</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/fitness/data/package-summary.html">com.google.android.gms.fitness.data</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/fitness/request/package-summary.html">com.google.android.gms.fitness.request</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/fitness/result/package-summary.html">com.google.android.gms.fitness.result</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/fitness/service/package-summary.html">com.google.android.gms.fitness.service</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/games/package-summary.html">com.google.android.gms.games</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/games/achievement/package-summary.html">com.google.android.gms.games.achievement</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/games/event/package-summary.html">com.google.android.gms.games.event</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/games/leaderboard/package-summary.html">com.google.android.gms.games.leaderboard</a></li> <li class="selected api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/package-summary.html">com.google.android.gms.games.multiplayer</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/realtime/package-summary.html">com.google.android.gms.games.multiplayer.realtime</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/turnbased/package-summary.html">com.google.android.gms.games.multiplayer.turnbased</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/games/quest/package-summary.html">com.google.android.gms.games.quest</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/games/request/package-summary.html">com.google.android.gms.games.request</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/games/snapshot/package-summary.html">com.google.android.gms.games.snapshot</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/gcm/package-summary.html">com.google.android.gms.gcm</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/identity/intents/package-summary.html">com.google.android.gms.identity.intents</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/identity/intents/model/package-summary.html">com.google.android.gms.identity.intents.model</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/location/package-summary.html">com.google.android.gms.location</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/maps/package-summary.html">com.google.android.gms.maps</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/maps/model/package-summary.html">com.google.android.gms.maps.model</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/panorama/package-summary.html">com.google.android.gms.panorama</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/plus/package-summary.html">com.google.android.gms.plus</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/plus/model/moments/package-summary.html">com.google.android.gms.plus.model.moments</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/plus/model/people/package-summary.html">com.google.android.gms.plus.model.people</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/security/package-summary.html">com.google.android.gms.security</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/tagmanager/package-summary.html">com.google.android.gms.tagmanager</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/wallet/package-summary.html">com.google.android.gms.wallet</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/wallet/fragment/package-summary.html">com.google.android.gms.wallet.fragment</a></li> <li class="api apilevel-"> <a href="../../../../../../../reference/com/google/android/gms/wearable/package-summary.html">com.google.android.gms.wearable</a></li> </ul><br/> </div> <!-- end packages-nav --> </div> <!-- end resize-packages --> <div id="classes-nav" class="scroll-pane"> <ul> <li><h2>Interfaces</h2> <ul> <li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/Invitation.html">Invitation</a></li> <li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/Invitations.html">Invitations</a></li> <li class="selected api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/Invitations.LoadInvitationsResult.html">Invitations.LoadInvitationsResult</a></li> <li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/Multiplayer.html">Multiplayer</a></li> <li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/OnInvitationReceivedListener.html">OnInvitationReceivedListener</a></li> <li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/Participant.html">Participant</a></li> <li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/Participatable.html">Participatable</a></li> </ul> </li> <li><h2>Classes</h2> <ul> <li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/InvitationBuffer.html">InvitationBuffer</a></li> <li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/InvitationEntity.html">InvitationEntity</a></li> <li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/ParticipantBuffer.html">ParticipantBuffer</a></li> <li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/ParticipantEntity.html">ParticipantEntity</a></li> <li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/ParticipantResult.html">ParticipantResult</a></li> <li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/ParticipantUtils.html">ParticipantUtils</a></li> </ul> </li> </ul><br/> </div><!-- end classes --> </div><!-- end nav-panels --> <div id="nav-tree" style="display:none" class="scroll-pane"> <div id="tree-list"></div> </div><!-- end nav-tree --> </div><!-- end swapper --> <div id="nav-swap"> <a class="fullscreen">fullscreen</a> <a href='#' onclick='swapNav();return false;'><span id='tree-link'>Use Tree Navigation</span><span id='panel-link' style='display:none'>Use Panel Navigation</span></a> </div> </div> <!-- end devdoc-nav --> </div> <!-- end side-nav --> <script type="text/javascript"> // init fullscreen based on user pref var fullscreen = readCookie("fullscreen"); if (fullscreen != 0) { if (fullscreen == "false") { toggleFullscreen(false); } else { toggleFullscreen(true); } } // init nav version for mobile if (isMobile) { swapNav(); // tree view should be used on mobile $('#nav-swap').hide(); } else { chooseDefaultNav(); if ($("#nav-tree").is(':visible')) { init_default_navtree("../../../../../../../"); } } // scroll the selected page into view $(document).ready(function() { scrollIntoView("packages-nav"); scrollIntoView("classes-nav"); }); </script> <div class="col-12" id="doc-col"> <div id="api-info-block"> <div class="sum-details-links"> Summary: <a href="#pubmethods">Methods</a> &#124; <a href="#inhmethods">Inherited Methods</a> &#124; <a href="#" onclick="return toggleAllClassInherited()" id="toggleAllClassInherited">[Expand All]</a> </div><!-- end sum-details-links --> <div class="api-level"> </div> </div><!-- end api-info-block --> <!-- ======== START OF CLASS DATA ======== --> <div id="jd-header"> public static interface <h1 itemprop="name">Invitations.LoadInvitationsResult</h1> implements <a href="../../../../../../../reference/com/google/android/gms/common/api/Releasable.html">Releasable</a> <a href="../../../../../../../reference/com/google/android/gms/common/api/Result.html">Result</a> </div><!-- end header --> <div id="naMessage"></div> <div id="jd-content" class="api apilevel-"> <table class="jd-inheritance-table"> <tr> <td colspan="1" class="jd-inheritance-class-cell">com.google.android.gms.games.multiplayer.Invitations.LoadInvitationsResult</td> </tr> </table> <div class="jd-descr"> <h2>Class Overview</h2> <p itemprop="articleBody">Result delivered when invitations have been loaded. Possible status codes include: <ul> <li><code><a href="../../../../../../../reference/com/google/android/gms/games/GamesStatusCodes.html#STATUS_OK">STATUS_OK</a></code> if data was successfully loaded and is up-to-date. </li> <li><code><a href="../../../../../../../reference/com/google/android/gms/games/GamesStatusCodes.html#STATUS_NETWORK_ERROR_NO_DATA">STATUS_NETWORK_ERROR_NO_DATA</a></code> if the device was unable to retrieve any data from the network and has no data cached locally.</li> <li><code><a href="../../../../../../../reference/com/google/android/gms/games/GamesStatusCodes.html#STATUS_NETWORK_ERROR_STALE_DATA">STATUS_NETWORK_ERROR_STALE_DATA</a></code> if the device was unable to retrieve the latest data from the network, but has some data cached locally.</li> <li><code><a href="../../../../../../../reference/com/google/android/gms/games/GamesStatusCodes.html#STATUS_CLIENT_RECONNECT_REQUIRED">STATUS_CLIENT_RECONNECT_REQUIRED</a></code> if the client needs to reconnect to the service to access this data.</li> <li><code><a href="../../../../../../../reference/com/google/android/gms/games/GamesStatusCodes.html#STATUS_INTERNAL_ERROR">STATUS_INTERNAL_ERROR</a></code> if an unexpected error occurred in the service.</li> </ul> </p> </div><!-- jd-descr --> <div class="jd-descr"> <h2>Summary</h2> <!-- ========== METHOD SUMMARY =========== --> <table id="pubmethods" class="jd-sumtable"><tr><th colspan="12">Public Methods</th></tr> <tr class="alt-color api apilevel-" > <td class="jd-typecol"><nobr> abstract <a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/InvitationBuffer.html">InvitationBuffer</a></nobr> </td> <td class="jd-linkcol" width="100%"><nobr> <span class="sympad"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/Invitations.LoadInvitationsResult.html#getInvitations()">getInvitations</a></span>()</nobr> </td></tr> </table> <!-- ========== METHOD SUMMARY =========== --> <table id="inhmethods" class="jd-sumtable"><tr><th> <a href="#" class="toggle-all" onclick="return toggleAllInherited(this, null)">[Expand]</a> <div style="clear:left;">Inherited Methods</div></th></tr> <tr class="api apilevel-" > <td colspan="12"> <a href="#" onclick="return toggleInherited(this, null)" id="inherited-methods-com.google.android.gms.common.api.Releasable" class="jd-expando-trigger closed" ><img id="inherited-methods-com.google.android.gms.common.api.Releasable-trigger" src="../../../../../../../assets/images/triangle-closed.png" class="jd-expando-trigger-img" /></a> From interface <a href="../../../../../../../reference/com/google/android/gms/common/api/Releasable.html">com.google.android.gms.common.api.Releasable</a> <div id="inherited-methods-com.google.android.gms.common.api.Releasable"> <div id="inherited-methods-com.google.android.gms.common.api.Releasable-list" class="jd-inheritedlinks"> </div> <div id="inherited-methods-com.google.android.gms.common.api.Releasable-summary" style="display: none;"> <table class="jd-sumtable-expando"> <tr class="alt-color api apilevel-" > <td class="jd-typecol"><nobr> abstract void</nobr> </td> <td class="jd-linkcol" width="100%"><nobr> <span class="sympad"><a href="../../../../../../../reference/com/google/android/gms/common/api/Releasable.html#release()">release</a></span>()</nobr> </td></tr> </table> </div> </div> </td></tr> <tr class="api apilevel-" > <td colspan="12"> <a href="#" onclick="return toggleInherited(this, null)" id="inherited-methods-com.google.android.gms.common.api.Result" class="jd-expando-trigger closed" ><img id="inherited-methods-com.google.android.gms.common.api.Result-trigger" src="../../../../../../../assets/images/triangle-closed.png" class="jd-expando-trigger-img" /></a> From interface <a href="../../../../../../../reference/com/google/android/gms/common/api/Result.html">com.google.android.gms.common.api.Result</a> <div id="inherited-methods-com.google.android.gms.common.api.Result"> <div id="inherited-methods-com.google.android.gms.common.api.Result-list" class="jd-inheritedlinks"> </div> <div id="inherited-methods-com.google.android.gms.common.api.Result-summary" style="display: none;"> <table class="jd-sumtable-expando"> <tr class="alt-color api apilevel-" > <td class="jd-typecol"><nobr> abstract <a href="../../../../../../../reference/com/google/android/gms/common/api/Status.html">Status</a></nobr> </td> <td class="jd-linkcol" width="100%"><nobr> <span class="sympad"><a href="../../../../../../../reference/com/google/android/gms/common/api/Result.html#getStatus()">getStatus</a></span>()</nobr> </td></tr> </table> </div> </div> </td></tr> </table> </div><!-- jd-descr (summary) --> <!-- Details --> <!-- XML Attributes --> <!-- Enum Values --> <!-- Constants --> <!-- Fields --> <!-- Public ctors --> <!-- ========= CONSTRUCTOR DETAIL ======== --> <!-- Protected ctors --> <!-- ========= METHOD DETAIL ======== --> <!-- Public methdos --> <h2>Public Methods</h2> <A NAME="getInvitations()"></A> <div class="jd-details api apilevel-"> <h4 class="jd-details-title"> <span class="normal"> public abstract <a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/InvitationBuffer.html">InvitationBuffer</a> </span> <span class="sympad">getInvitations</span> <span class="normal">()</span> </h4> <div class="api-level"> <div></div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p></p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>The invitations that were requested. This is guaranteed to be non-null, though it may be empty. The listener must close this object when finished. </li></ul> </div> </div> </div> <!-- ========= METHOD DETAIL ======== --> <!-- ========= END OF CLASS DATA ========= --> <A NAME="navbar_top"></A> <div id="footer" class="wrap" > <div id="copyright"> Except as noted, this content is licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>. For details and restrictions, see the <a href="../../../../../../../license.html"> Content License</a>. </div> <div id="build_info"> Android GmsCore 1474901&nbsp;r &mdash; <script src="../../../../../../../timestamp.js" type="text/javascript"></script> <script>document.write(BUILD_TIMESTAMP)</script> </div> <div id="footerlinks"> <p> <a href="../../../../../../../about/index.html">About Android</a>&nbsp;&nbsp;|&nbsp; <a href="../../../../../../../legal.html">Legal</a>&nbsp;&nbsp;|&nbsp; <a href="../../../../../../../support.html">Support</a> </p> </div> </div> <!-- end footer --> </div> <!-- jd-content --> </div><!-- end doc-content --> </div> <!-- end body-content --> </body> </html>
DarkoDanchev/BeerDrop-Game-
BeerDrop-android/libs/google_play_services/docs/reference/com/google/android/gms/games/multiplayer/Invitations.LoadInvitationsResult.html
HTML
gpl-2.0
36,676
class Catalogcategorywork < ActiveRecord::Base #attr_accessible :nombre, :unit_id, :precio_unitario_normal, :precio_unitario_60, :precio_unitario_100 has_many :workers has_many :catalogofworks belongs_to :unit validates :nombre, :presence => {:message => 'NOMBRE, no puede estar vacio.'} validates :unit_id, :presence => {:message => 'UNIDAD, no puede estar vacia.'} validates :precio_unitario_normal, :presence => {:message => 'PRECIO NORMAL, no puede estar vacio.'} validates :precio_unitario_60, :presence => {:message => 'PRECIO 60, no puede estar vacio.'} validates :precio_unitario_100, :presence => {:message => 'PRECIO 100, no puede estar vacio.'} end
Zakeru/arsac_production
app/models/catalogcategorywork.rb
Ruby
gpl-2.0
679
#include <stdio.h> void main(int argc, const char *argv[]){ printf("Mea Error! =P\n"); return 0; }
IntelBUAP/GCC5
codigo10.c
C
gpl-2.0
102
<!DOCTYPE html> <html lang="zh-cn"> <!-- Mirrored from www.w3school.com.cn/tiy/t.asp?f=csse_padding-top_percent by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 02 Dec 2015 00:36:40 GMT --> <!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=GB2312" /><!-- /Added by HTTrack --> <head> <meta charset="utf-8" /> <meta name="robots" content="all" /> <meta name="author" content="w3school.com.cn" /> <link rel="stylesheet" type="text/css" href="tc.css" /> <title>W3School在线测试工具 V2</title> </head> <body id="editor"> <div id="wrapper"> <div id="header"> <h1>W3School TIY</h1> <div id="ad"> <script type="text/javascript"><!-- google_ad_client = "pub-3381531532877742"; /* 728x90, tiy_big */ google_ad_slot = "7947784850"; google_ad_width = 728; google_ad_height = 90; //--> </script> <script type="text/javascript" src="../../pagead2.googlesyndication.com/pagead/f.txt"> </script> </div> </div> <form action="http://www.w3school.com.cn/tiy/v.asp" method="post" id="tryitform" name="tryitform" onSubmit="validateForm();" target="i"> <div id="butt"> <input type="button" value="提交代码" onClick="submitTryit()"> </div> <div id="CodeArea"> <h2>编辑您的代码:</h2> <textarea id="TestCode" wrap="logical"> <html> <head> <style type="text/css"> td { padding-top: 10% } </style> </head> <body> <table border="1"> <tr> <td> 这个表格单元拥有上内边距。 </td> </tr> </table> </body> <!-- Mirrored from www.w3school.com.cn/tiy/t.asp?f=csse_padding-top_percent by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 02 Dec 2015 00:36:40 GMT --> </html> </textarea> </div> <input type="hidden" id="code" name="code" /> <input type="hidden" id="bt" name="bt" /> </form> <div id="result"> <h2>查看结果:</h2> <iframe frameborder="0" name="i" src="loadtextf2fd.asp?f=csse_padding-top_percent"></iframe> </div> <div id="footer"> <p>请在上面的文本框中编辑您的代码,然后单击提交按钮测试结果。<a href="../index-2.html" title="W3School 在线教程">w3school.com.cn</a></p> </div> </div> <script type="text/javascript"> function submitTryit() { var t=document.getElementById("TestCode").value; t=t.replace(/=/gi,"w3equalsign"); t=t.replace(/script/gi,"w3scrw3ipttag"); document.getElementById("code").value=t; document.getElementById("tryitform").action="v.html"; validateForm(); document.getElementById("tryitform").submit(); } function validateForm() { var code=document.getElementById("code").value; if (code.length>5000) { document.getElementById("code").value="<h1>Error</h1>"; } } </script> </body> </html>
platinhom/ManualHom
Coding/W3School/W3CN/www.w3school.com.cn/tiy/tf2fd.html
HTML
gpl-2.0
2,609
# Copyright 2018-2020 SUSE LLC # SPDX-License-Identifier: GPL-2.0-or-later package OpenQA::Shared::GruJob; use Mojo::Base 'Minion::Job'; use Mojo::Util qw(dumper); sub execute { my $self = shift; my $gru_id = $self->info->{notes}{gru_id}; my $err = $self->SUPER::execute; # Non-Gru tasks return $err unless $gru_id; my $info = $self->info; my $state = $info->{state}; if ($state eq 'failed' || defined $err) { $err //= $info->{result}; $err = dumper($err) if ref $err; $self->app->log->error("Gru job error: $err"); $self->fail($err); $self->_fail_gru($gru_id => $err); } # Avoid a possible race condition where the task retries the job and it gets # picked up by a new worker before we reach this line (by checking the # "finish" return value) elsif ($state eq 'active') { $self->_delete_gru($gru_id) if $self->finish('Job successfully executed') } elsif ($state eq 'finished') { $self->_delete_gru($gru_id) } return undef; } sub _delete_gru { my ($self, $id) = @_; my $gru = $self->minion->app->schema->resultset('GruTasks')->find($id); $gru->delete() if $gru; } sub _fail_gru { my ($self, $id, $reason) = @_; my $gru = $self->minion->app->schema->resultset('GruTasks')->find($id); $gru->fail($reason) if $gru; } 1; =encoding utf8 =head1 NAME OpenQA::Shared::GruJob - A Gru Job =head1 SYNOPSIS use OpenQA::Shared::GruJob; =head1 DESCRIPTION L<OpenQA::Shared::GruJob> is a subclass of L<Minion::Job> used by L<OpenQA::Shared::Plugin::Gru> that adds Gru metadata handling and TTL support. =cut
os-autoinst/openQA
lib/OpenQA/Shared/GruJob.pm
Perl
gpl-2.0
1,642
<html> <head> <title>Test for the sticky div</title> <style> html, body{ overflow: hidden; } .slide { -webkit-transition: all .30s ease-in-out; -moz-transition: all .30s ease-in-out; -o-transition: all .30s ease-in-out; transition: all .30s ease-in-out; -webkit-transform: translate3D(0px, 0px, 0px); -ms-transform: translate3D(0px, 0px, 0px); transform: translate3D(0px, 0px, 0px); } .slide-up { -webkit-transform: translate3D(0px, -100%, 0px); -ms-transform: translate3D(0px, -100%, 0px); transform: translate3D(0px, -100%, 0px); } </style> <script src="../bower_components/jquery/dist/jquery.js"></script> <script src="../src/weasely.js"></script> </head> <body> <button id="disable_weasely" > BOOm!!! </button> <button id="enable_weasely" > POW!!!! </button> <div id="wrapper" style="overflow:hidden; position:relative; height: 500px; margin: 100px; background: yellow;"> <div id="weasely-element" class="slide" style="z-index: 1; height: 50px; background: green; padding: 1px 0; position: absolute; width: 100%;">I'ma hide like a weasel!</div> <div class="weasely-scroller" style="-webkit-overflow-scrolling: touch; overflow-y: auto; height:100%; position: relative;"> <div style="height: 5000px; background: yellow; border: 1px solid blue; margin-top: 50px;"> <p style="margin-top: 10px">Hello there !</p> <p style="margin-top: 300px">Whoop!</p> </div> </div> </div> <script> $('#weasely-element').weasely({ hideClass: 'slide-up' }); ws = $('#weasely-element').data('weasely') $('#disable_weasely').click(function(){ ws.off() }) $('#enable_weasely').click(function(){ ws.on() }) document.ontouchmove = function(event){ if(event.target.tagName == "BODY"){ event.preventDefault(); } } </script> </body> </html>
easytobook/weasely.js
test/test.html
HTML
gpl-2.0
1,953
<?php // Integria 1.1 - http://integria.sourceforge.net // ================================================== // Copyright (c) 2008 Artica Soluciones Tecnologicas // Copyright (c) 2008 Esteban Sanchez, estebans@artica.es // 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; version 2 // 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. check_login (); $id_profile = (int) get_parameter ('user_profile_search'); $id_group = (int) get_parameter ('user_group_search'); $search_string = (string) get_parameter ('search_string'); $search = (bool) get_parameter ('search'); if ($search) { $users = get_user_visible_users ($config['id_user'], "IR", false); $total_users = 0; foreach ($users as $user) { if ($search_string != '') { if (stripos ($user['id_usuario'], $search_string) === false && stripos ($user['nombre_real'], $search_string) === false) continue; } if ($id_profile) { $sql = sprintf ("SELECT COUNT(*) FROM tusuario_perfil WHERE id_perfil = %d AND id_usuario = '%s'", $id_profile, $user['id_usuario']); $has_profile = get_db_sql ($sql); if (! $has_profile) continue; } if ($id_group != -1) { $sql = sprintf ("SELECT COUNT(*) FROM tusuario_perfil WHERE id_grupo = %d AND id_usuario = '%s'", $id_group, $user['id_usuario']); $has_profile = get_db_sql ($sql); if (! $has_profile) continue; } echo '<tr id="result-'.$user['id_usuario'].'">'; echo '<td>'.$user['id_usuario'].'</td>'; echo '<td>'.$user['nombre_real'].'</td>'; echo '<td>'.$user['comentarios'].'</td>'; echo '</tr>'; $total_users++; } if ($total_users == 0) { echo '<tr colspan="4">'.__('No users found').'</tr>'; } if (defined ('AJAX')) return; } $table->data = array (); $table->width = '90%'; $table->data[0][0] = print_select_from_sql ('SELECT id, name FROM trole ORDER BY 2', 'user_profile_search', $id_profile, '', __('Any'), 0, true, false, false, __('Role')); $table->data[0][1] = print_select (get_user_groups (), 'user_group_search', $id_group, '', __('Any'), -1, true, false, false, __('Group')); $table->data[2][0] = print_input_text ('search_string', '', '', 20, 255, true, __('Name')); $table->data[2][1] = print_submit_button (__('Search'), 'search_button', false, 'class="sub search"', true); echo '<form id="user_search_form" method="post">'; print_table ($table); print_input_hidden ('search', 1); echo '</form>'; unset ($table); $table->class = 'hide result_table listing'; $table->width = '90%'; $table->id = 'user_search_result_table'; $table->head = array (); $table->head[0] = __('Username'); $table->head[1] = __('Real name'); $table->head[2] = __('Comments'); print_table ($table); echo '<div id="users-pager" class="hide pager">'; echo '<form>'; echo '<img src="images/control_start_blue.png" class="first" />'; echo '<img src="images/control_rewind_blue.png" class="prev" />'; echo '<input type="text" class="pagedisplay" />'; echo '<img src="images/control_fastforward_blue.png" class="next" />'; echo '<img src="images/control_end_blue.png" class="last" />'; echo '<select class="pagesize" style="display: none">'; echo '<option selected="selected" value="10">10</option>'; echo '</select>'; echo '</form>'; echo '</div>'; ?>
articaST/integriaims
operation/users/user_search.php
PHP
gpl-2.0
3,592
/* * Atheros CARL9170 driver * * PHY and RF code * * Copyright 2008, Johannes Berg <johannes@sipsolutions.net> * * 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; see the file COPYING. If not, see * http://www.gnu.org/licenses/. * * This file incorporates work covered by the following copyright and * permission notice: * Copyright (c) 2007-2008 Atheros Communications, Inc. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <linux/bitrev.h> #include "carl9170.h" #include "cmd.h" #include "phy.h" static int carl9170_init_power_cal(struct ar9170 *ar) { carl9170_regwrite_begin(ar); carl9170_regwrite(AR9170_PHY_REG_POWER_TX_RATE_MAX, 0x7f); carl9170_regwrite(AR9170_PHY_REG_POWER_TX_RATE1, 0x3f3f3f3f); carl9170_regwrite(AR9170_PHY_REG_POWER_TX_RATE2, 0x3f3f3f3f); carl9170_regwrite(AR9170_PHY_REG_POWER_TX_RATE3, 0x3f3f3f3f); carl9170_regwrite(AR9170_PHY_REG_POWER_TX_RATE4, 0x3f3f3f3f); carl9170_regwrite(AR9170_PHY_REG_POWER_TX_RATE5, 0x3f3f3f3f); carl9170_regwrite(AR9170_PHY_REG_POWER_TX_RATE6, 0x3f3f3f3f); carl9170_regwrite(AR9170_PHY_REG_POWER_TX_RATE7, 0x3f3f3f3f); carl9170_regwrite(AR9170_PHY_REG_POWER_TX_RATE8, 0x3f3f3f3f); carl9170_regwrite(AR9170_PHY_REG_POWER_TX_RATE9, 0x3f3f3f3f); carl9170_regwrite_finish(); return carl9170_regwrite_result(); } struct carl9170_phy_init { u32 reg, _5ghz_20, _5ghz_40, _2ghz_40, _2ghz_20; }; static struct carl9170_phy_init ar5416_phy_init[] = { { 0x1c5800, 0x00000007, 0x00000007, 0x00000007, 0x00000007, }, { 0x1c5804, 0x00000300, 0x000003c4, 0x000003c4, 0x00000300, }, { 0x1c5808, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c580c, 0xad848e19, 0xad848e19, 0xad848e19, 0xad848e19, }, { 0x1c5810, 0x7d14e000, 0x7d14e000, 0x7d14e000, 0x7d14e000, }, { 0x1c5814, 0x9c0a9f6b, 0x9c0a9f6b, 0x9c0a9f6b, 0x9c0a9f6b, }, { 0x1c5818, 0x00000090, 0x00000090, 0x00000090, 0x00000090, }, { 0x1c581c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5820, 0x02020200, 0x02020200, 0x02020200, 0x02020200, }, { 0x1c5824, 0x00000e0e, 0x00000e0e, 0x00000e0e, 0x00000e0e, }, { 0x1c5828, 0x0a020001, 0x0a020001, 0x0a020001, 0x0a020001, }, { 0x1c582c, 0x0000a000, 0x0000a000, 0x0000a000, 0x0000a000, }, { 0x1c5830, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5834, 0x00000e0e, 0x00000e0e, 0x00000e0e, 0x00000e0e, }, { 0x1c5838, 0x00000007, 0x00000007, 0x00000007, 0x00000007, }, { 0x1c583c, 0x00200400, 0x00200400, 0x00200400, 0x00200400, }, { 0x1c5840, 0x206a002e, 0x206a002e, 0x206a002e, 0x206a002e, }, { 0x1c5844, 0x1372161e, 0x13721c1e, 0x13721c24, 0x137216a4, }, { 0x1c5848, 0x001a6a65, 0x001a6a65, 0x00197a68, 0x00197a68, }, { 0x1c584c, 0x1284233c, 0x1284233c, 0x1284233c, 0x1284233c, }, { 0x1c5850, 0x6c48b4e4, 0x6d48b4e4, 0x6d48b0e4, 0x6c48b0e4, }, { 0x1c5854, 0x00000859, 0x00000859, 0x00000859, 0x00000859, }, { 0x1c5858, 0x7ec80d2e, 0x7ec80d2e, 0x7ec80d2e, 0x7ec80d2e, }, { 0x1c585c, 0x31395c5e, 0x3139605e, 0x3139605e, 0x31395c5e, }, { 0x1c5860, 0x0004dd10, 0x0004dd10, 0x0004dd20, 0x0004dd20, }, { 0x1c5864, 0x0001c600, 0x0001c600, 0x0001c600, 0x0001c600, }, { 0x1c5868, 0x409a4190, 0x409a4190, 0x409a4190, 0x409a4190, }, { 0x1c586c, 0x050cb081, 0x050cb081, 0x050cb081, 0x050cb081, }, { 0x1c5900, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5904, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5908, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c590c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5914, 0x000007d0, 0x000007d0, 0x00000898, 0x00000898, }, { 0x1c5918, 0x00000118, 0x00000230, 0x00000268, 0x00000134, }, { 0x1c591c, 0x10000fff, 0x10000fff, 0x10000fff, 0x10000fff, }, { 0x1c5920, 0x0510081c, 0x0510081c, 0x0510001c, 0x0510001c, }, { 0x1c5924, 0xd0058a15, 0xd0058a15, 0xd0058a15, 0xd0058a15, }, { 0x1c5928, 0x00000001, 0x00000001, 0x00000001, 0x00000001, }, { 0x1c592c, 0x00000004, 0x00000004, 0x00000004, 0x00000004, }, { 0x1c5934, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, }, { 0x1c5938, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, }, { 0x1c593c, 0x0000007f, 0x0000007f, 0x0000007f, 0x0000007f, }, { 0x1c5944, 0xdfb81020, 0xdfb81020, 0xdfb81020, 0xdfb81020, }, { 0x1c5948, 0x9280b212, 0x9280b212, 0x9280b212, 0x9280b212, }, { 0x1c594c, 0x00020028, 0x00020028, 0x00020028, 0x00020028, }, { 0x1c5954, 0x5d50e188, 0x5d50e188, 0x5d50e188, 0x5d50e188, }, { 0x1c5958, 0x00081fff, 0x00081fff, 0x00081fff, 0x00081fff, }, { 0x1c5960, 0x00009b40, 0x00009b40, 0x00009b40, 0x00009b40, }, { 0x1c5964, 0x00001120, 0x00001120, 0x00001120, 0x00001120, }, { 0x1c5970, 0x190fb515, 0x190fb515, 0x190fb515, 0x190fb515, }, { 0x1c5974, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5978, 0x00000001, 0x00000001, 0x00000001, 0x00000001, }, { 0x1c597c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5980, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5984, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5988, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c598c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5990, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5994, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5998, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c599c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c59a0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c59a4, 0x00000007, 0x00000007, 0x00000007, 0x00000007, }, { 0x1c59a8, 0x001fff00, 0x001fff00, 0x001fff00, 0x001fff00, }, { 0x1c59ac, 0x006f00c4, 0x006f00c4, 0x006f00c4, 0x006f00c4, }, { 0x1c59b0, 0x03051000, 0x03051000, 0x03051000, 0x03051000, }, { 0x1c59b4, 0x00000820, 0x00000820, 0x00000820, 0x00000820, }, { 0x1c59bc, 0x00181400, 0x00181400, 0x00181400, 0x00181400, }, { 0x1c59c0, 0x038919be, 0x038919be, 0x038919be, 0x038919be, }, { 0x1c59c4, 0x06336f77, 0x06336f77, 0x06336f77, 0x06336f77, }, { 0x1c59c8, 0x6af6532c, 0x6af6532c, 0x6af6532c, 0x6af6532c, }, { 0x1c59cc, 0x08f186c8, 0x08f186c8, 0x08f186c8, 0x08f186c8, }, { 0x1c59d0, 0x00046384, 0x00046384, 0x00046384, 0x00046384, }, { 0x1c59d4, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c59d8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c59dc, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c59e0, 0x00000200, 0x00000200, 0x00000200, 0x00000200, }, { 0x1c59e4, 0x64646464, 0x64646464, 0x64646464, 0x64646464, }, { 0x1c59e8, 0x3c787878, 0x3c787878, 0x3c787878, 0x3c787878, }, { 0x1c59ec, 0x000000aa, 0x000000aa, 0x000000aa, 0x000000aa, }, { 0x1c59f0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c59fc, 0x00001042, 0x00001042, 0x00001042, 0x00001042, }, { 0x1c5a00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5a04, 0x00000040, 0x00000040, 0x00000040, 0x00000040, }, { 0x1c5a08, 0x00000080, 0x00000080, 0x00000080, 0x00000080, }, { 0x1c5a0c, 0x000001a1, 0x000001a1, 0x00000141, 0x00000141, }, { 0x1c5a10, 0x000001e1, 0x000001e1, 0x00000181, 0x00000181, }, { 0x1c5a14, 0x00000021, 0x00000021, 0x000001c1, 0x000001c1, }, { 0x1c5a18, 0x00000061, 0x00000061, 0x00000001, 0x00000001, }, { 0x1c5a1c, 0x00000168, 0x00000168, 0x00000041, 0x00000041, }, { 0x1c5a20, 0x000001a8, 0x000001a8, 0x000001a8, 0x000001a8, }, { 0x1c5a24, 0x000001e8, 0x000001e8, 0x000001e8, 0x000001e8, }, { 0x1c5a28, 0x00000028, 0x00000028, 0x00000028, 0x00000028, }, { 0x1c5a2c, 0x00000068, 0x00000068, 0x00000068, 0x00000068, }, { 0x1c5a30, 0x00000189, 0x00000189, 0x000000a8, 0x000000a8, }, { 0x1c5a34, 0x000001c9, 0x000001c9, 0x00000169, 0x00000169, }, { 0x1c5a38, 0x00000009, 0x00000009, 0x000001a9, 0x000001a9, }, { 0x1c5a3c, 0x00000049, 0x00000049, 0x000001e9, 0x000001e9, }, { 0x1c5a40, 0x00000089, 0x00000089, 0x00000029, 0x00000029, }, { 0x1c5a44, 0x00000170, 0x00000170, 0x00000069, 0x00000069, }, { 0x1c5a48, 0x000001b0, 0x000001b0, 0x00000190, 0x00000190, }, { 0x1c5a4c, 0x000001f0, 0x000001f0, 0x000001d0, 0x000001d0, }, { 0x1c5a50, 0x00000030, 0x00000030, 0x00000010, 0x00000010, }, { 0x1c5a54, 0x00000070, 0x00000070, 0x00000050, 0x00000050, }, { 0x1c5a58, 0x00000191, 0x00000191, 0x00000090, 0x00000090, }, { 0x1c5a5c, 0x000001d1, 0x000001d1, 0x00000151, 0x00000151, }, { 0x1c5a60, 0x00000011, 0x00000011, 0x00000191, 0x00000191, }, { 0x1c5a64, 0x00000051, 0x00000051, 0x000001d1, 0x000001d1, }, { 0x1c5a68, 0x00000091, 0x00000091, 0x00000011, 0x00000011, }, { 0x1c5a6c, 0x000001b8, 0x000001b8, 0x00000051, 0x00000051, }, { 0x1c5a70, 0x000001f8, 0x000001f8, 0x00000198, 0x00000198, }, { 0x1c5a74, 0x00000038, 0x00000038, 0x000001d8, 0x000001d8, }, { 0x1c5a78, 0x00000078, 0x00000078, 0x00000018, 0x00000018, }, { 0x1c5a7c, 0x00000199, 0x00000199, 0x00000058, 0x00000058, }, { 0x1c5a80, 0x000001d9, 0x000001d9, 0x00000098, 0x00000098, }, { 0x1c5a84, 0x00000019, 0x00000019, 0x00000159, 0x00000159, }, { 0x1c5a88, 0x00000059, 0x00000059, 0x00000199, 0x00000199, }, { 0x1c5a8c, 0x00000099, 0x00000099, 0x000001d9, 0x000001d9, }, { 0x1c5a90, 0x000000d9, 0x000000d9, 0x00000019, 0x00000019, }, { 0x1c5a94, 0x000000f9, 0x000000f9, 0x00000059, 0x00000059, }, { 0x1c5a98, 0x000000f9, 0x000000f9, 0x00000099, 0x00000099, }, { 0x1c5a9c, 0x000000f9, 0x000000f9, 0x000000d9, 0x000000d9, }, { 0x1c5aa0, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5aa4, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5aa8, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5aac, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5ab0, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5ab4, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5ab8, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5abc, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5ac0, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5ac4, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5ac8, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5acc, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5ad0, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5ad4, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5ad8, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5adc, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5ae0, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5ae4, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5ae8, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5aec, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5af0, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5af4, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5af8, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5afc, 0x000000f9, 0x000000f9, 0x000000f9, 0x000000f9, }, { 0x1c5b00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5b04, 0x00000001, 0x00000001, 0x00000001, 0x00000001, }, { 0x1c5b08, 0x00000002, 0x00000002, 0x00000002, 0x00000002, }, { 0x1c5b0c, 0x00000003, 0x00000003, 0x00000003, 0x00000003, }, { 0x1c5b10, 0x00000004, 0x00000004, 0x00000004, 0x00000004, }, { 0x1c5b14, 0x00000005, 0x00000005, 0x00000005, 0x00000005, }, { 0x1c5b18, 0x00000008, 0x00000008, 0x00000008, 0x00000008, }, { 0x1c5b1c, 0x00000009, 0x00000009, 0x00000009, 0x00000009, }, { 0x1c5b20, 0x0000000a, 0x0000000a, 0x0000000a, 0x0000000a, }, { 0x1c5b24, 0x0000000b, 0x0000000b, 0x0000000b, 0x0000000b, }, { 0x1c5b28, 0x0000000c, 0x0000000c, 0x0000000c, 0x0000000c, }, { 0x1c5b2c, 0x0000000d, 0x0000000d, 0x0000000d, 0x0000000d, }, { 0x1c5b30, 0x00000010, 0x00000010, 0x00000010, 0x00000010, }, { 0x1c5b34, 0x00000011, 0x00000011, 0x00000011, 0x00000011, }, { 0x1c5b38, 0x00000012, 0x00000012, 0x00000012, 0x00000012, }, { 0x1c5b3c, 0x00000013, 0x00000013, 0x00000013, 0x00000013, }, { 0x1c5b40, 0x00000014, 0x00000014, 0x00000014, 0x00000014, }, { 0x1c5b44, 0x00000015, 0x00000015, 0x00000015, 0x00000015, }, { 0x1c5b48, 0x00000018, 0x00000018, 0x00000018, 0x00000018, }, { 0x1c5b4c, 0x00000019, 0x00000019, 0x00000019, 0x00000019, }, { 0x1c5b50, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a, }, { 0x1c5b54, 0x0000001b, 0x0000001b, 0x0000001b, 0x0000001b, }, { 0x1c5b58, 0x0000001c, 0x0000001c, 0x0000001c, 0x0000001c, }, { 0x1c5b5c, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, }, { 0x1c5b60, 0x00000020, 0x00000020, 0x00000020, 0x00000020, }, { 0x1c5b64, 0x00000021, 0x00000021, 0x00000021, 0x00000021, }, { 0x1c5b68, 0x00000022, 0x00000022, 0x00000022, 0x00000022, }, { 0x1c5b6c, 0x00000023, 0x00000023, 0x00000023, 0x00000023, }, { 0x1c5b70, 0x00000024, 0x00000024, 0x00000024, 0x00000024, }, { 0x1c5b74, 0x00000025, 0x00000025, 0x00000025, 0x00000025, }, { 0x1c5b78, 0x00000028, 0x00000028, 0x00000028, 0x00000028, }, { 0x1c5b7c, 0x00000029, 0x00000029, 0x00000029, 0x00000029, }, { 0x1c5b80, 0x0000002a, 0x0000002a, 0x0000002a, 0x0000002a, }, { 0x1c5b84, 0x0000002b, 0x0000002b, 0x0000002b, 0x0000002b, }, { 0x1c5b88, 0x0000002c, 0x0000002c, 0x0000002c, 0x0000002c, }, { 0x1c5b8c, 0x0000002d, 0x0000002d, 0x0000002d, 0x0000002d, }, { 0x1c5b90, 0x00000030, 0x00000030, 0x00000030, 0x00000030, }, { 0x1c5b94, 0x00000031, 0x00000031, 0x00000031, 0x00000031, }, { 0x1c5b98, 0x00000032, 0x00000032, 0x00000032, 0x00000032, }, { 0x1c5b9c, 0x00000033, 0x00000033, 0x00000033, 0x00000033, }, { 0x1c5ba0, 0x00000034, 0x00000034, 0x00000034, 0x00000034, }, { 0x1c5ba4, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5ba8, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bac, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bb0, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bb4, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bb8, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bbc, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bc0, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bc4, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bc8, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bcc, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bd0, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bd4, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bd8, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bdc, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5be0, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5be4, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5be8, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bec, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bf0, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bf4, 0x00000035, 0x00000035, 0x00000035, 0x00000035, }, { 0x1c5bf8, 0x00000010, 0x00000010, 0x00000010, 0x00000010, }, { 0x1c5bfc, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a, }, { 0x1c5c00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5c0c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5c10, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5c14, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5c18, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5c1c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5c20, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5c24, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5c28, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5c2c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5c30, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5c34, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5c38, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5c3c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5cf0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5cf4, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5cf8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c5cfc, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c6200, 0x00000008, 0x00000008, 0x0000000e, 0x0000000e, }, { 0x1c6204, 0x00000440, 0x00000440, 0x00000440, 0x00000440, }, { 0x1c6208, 0xd6be4788, 0xd6be4788, 0xd03e4788, 0xd03e4788, }, { 0x1c620c, 0x012e8160, 0x012e8160, 0x012a8160, 0x012a8160, }, { 0x1c6210, 0x40806333, 0x40806333, 0x40806333, 0x40806333, }, { 0x1c6214, 0x00106c10, 0x00106c10, 0x00106c10, 0x00106c10, }, { 0x1c6218, 0x009c4060, 0x009c4060, 0x009c4060, 0x009c4060, }, { 0x1c621c, 0x1883800a, 0x1883800a, 0x1883800a, 0x1883800a, }, { 0x1c6220, 0x018830c6, 0x018830c6, 0x018830c6, 0x018830c6, }, { 0x1c6224, 0x00000400, 0x00000400, 0x00000400, 0x00000400, }, { 0x1c6228, 0x000009b5, 0x000009b5, 0x000009b5, 0x000009b5, }, { 0x1c622c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c6230, 0x00000108, 0x00000210, 0x00000210, 0x00000108, }, { 0x1c6234, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, }, { 0x1c6238, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, }, { 0x1c623c, 0x13c889af, 0x13c889af, 0x13c889af, 0x13c889af, }, { 0x1c6240, 0x38490a20, 0x38490a20, 0x38490a20, 0x38490a20, }, { 0x1c6244, 0x00007bb6, 0x00007bb6, 0x00007bb6, 0x00007bb6, }, { 0x1c6248, 0x0fff3ffc, 0x0fff3ffc, 0x0fff3ffc, 0x0fff3ffc, }, { 0x1c624c, 0x00000001, 0x00000001, 0x00000001, 0x00000001, }, { 0x1c6250, 0x0000a000, 0x0000a000, 0x0000a000, 0x0000a000, }, { 0x1c6254, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c6258, 0x0cc75380, 0x0cc75380, 0x0cc75380, 0x0cc75380, }, { 0x1c625c, 0x0f0f0f01, 0x0f0f0f01, 0x0f0f0f01, 0x0f0f0f01, }, { 0x1c6260, 0xdfa91f01, 0xdfa91f01, 0xdfa91f01, 0xdfa91f01, }, { 0x1c6264, 0x00418a11, 0x00418a11, 0x00418a11, 0x00418a11, }, { 0x1c6268, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c626c, 0x09249126, 0x09249126, 0x09249126, 0x09249126, }, { 0x1c6274, 0x0a1a9caa, 0x0a1a9caa, 0x0a1a7caa, 0x0a1a7caa, }, { 0x1c6278, 0x1ce739ce, 0x1ce739ce, 0x1ce739ce, 0x1ce739ce, }, { 0x1c627c, 0x051701ce, 0x051701ce, 0x051701ce, 0x051701ce, }, { 0x1c6300, 0x18010000, 0x18010000, 0x18010000, 0x18010000, }, { 0x1c6304, 0x30032602, 0x30032602, 0x2e032402, 0x2e032402, }, { 0x1c6308, 0x48073e06, 0x48073e06, 0x4a0a3c06, 0x4a0a3c06, }, { 0x1c630c, 0x560b4c0a, 0x560b4c0a, 0x621a540b, 0x621a540b, }, { 0x1c6310, 0x641a600f, 0x641a600f, 0x764f6c1b, 0x764f6c1b, }, { 0x1c6314, 0x7a4f6e1b, 0x7a4f6e1b, 0x845b7a5a, 0x845b7a5a, }, { 0x1c6318, 0x8c5b7e5a, 0x8c5b7e5a, 0x950f8ccf, 0x950f8ccf, }, { 0x1c631c, 0x9d0f96cf, 0x9d0f96cf, 0xa5cf9b4f, 0xa5cf9b4f, }, { 0x1c6320, 0xb51fa69f, 0xb51fa69f, 0xbddfaf1f, 0xbddfaf1f, }, { 0x1c6324, 0xcb3fbd07, 0xcb3fbcbf, 0xd1ffc93f, 0xd1ffc93f, }, { 0x1c6328, 0x0000d7bf, 0x0000d7bf, 0x00000000, 0x00000000, }, { 0x1c632c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c6330, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c6334, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c6338, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c633c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c6340, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c6344, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c6348, 0x3fffffff, 0x3fffffff, 0x3fffffff, 0x3fffffff, }, { 0x1c634c, 0x3fffffff, 0x3fffffff, 0x3fffffff, 0x3fffffff, }, { 0x1c6350, 0x3fffffff, 0x3fffffff, 0x3fffffff, 0x3fffffff, }, { 0x1c6354, 0x0003ffff, 0x0003ffff, 0x0003ffff, 0x0003ffff, }, { 0x1c6358, 0x79a8aa1f, 0x79a8aa1f, 0x79a8aa1f, 0x79a8aa1f, }, { 0x1c6388, 0x08000000, 0x08000000, 0x08000000, 0x08000000, }, { 0x1c638c, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, }, { 0x1c6390, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, }, { 0x1c6394, 0x1ce739ce, 0x1ce739ce, 0x1ce739ce, 0x1ce739ce, }, { 0x1c6398, 0x000001ce, 0x000001ce, 0x000001ce, 0x000001ce, }, { 0x1c639c, 0x00000007, 0x00000007, 0x00000007, 0x00000007, }, { 0x1c63a0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c63a4, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c63a8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c63ac, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c63b0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c63b4, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c63b8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c63bc, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c63c0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c63c4, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c63c8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c63cc, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, }, { 0x1c63d0, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, }, { 0x1c63d4, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f, }, { 0x1c63d8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, { 0x1c63dc, 0x1ce739ce, 0x1ce739ce, 0x1ce739ce, 0x1ce739ce, }, { 0x1c63e0, 0x000000c0, 0x000000c0, 0x000000c0, 0x000000c0, }, { 0x1c6848, 0x00180a65, 0x00180a65, 0x00180a68, 0x00180a68, }, { 0x1c6920, 0x0510001c, 0x0510001c, 0x0510001c, 0x0510001c, }, { 0x1c6960, 0x00009b40, 0x00009b40, 0x00009b40, 0x00009b40, }, { 0x1c720c, 0x012e8160, 0x012e8160, 0x012a8160, 0x012a8160, }, { 0x1c726c, 0x09249126, 0x09249126, 0x09249126, 0x09249126, }, { 0x1c7848, 0x00180a65, 0x00180a65, 0x00180a68, 0x00180a68, }, { 0x1c7920, 0x0510001c, 0x0510001c, 0x0510001c, 0x0510001c, }, { 0x1c7960, 0x00009b40, 0x00009b40, 0x00009b40, 0x00009b40, }, { 0x1c820c, 0x012e8160, 0x012e8160, 0x012a8160, 0x012a8160, }, { 0x1c826c, 0x09249126, 0x09249126, 0x09249126, 0x09249126, }, /* { 0x1c8864, 0x0001ce00, 0x0001ce00, 0x0001ce00, 0x0001ce00, }, */ { 0x1c8864, 0x0001c600, 0x0001c600, 0x0001c600, 0x0001c600, }, { 0x1c895c, 0x004b6a8e, 0x004b6a8e, 0x004b6a8e, 0x004b6a8e, }, { 0x1c8968, 0x000003ce, 0x000003ce, 0x000003ce, 0x000003ce, }, { 0x1c89bc, 0x00181400, 0x00181400, 0x00181400, 0x00181400, }, { 0x1c9270, 0x00820820, 0x00820820, 0x00820820, 0x00820820, }, { 0x1c935c, 0x066c420f, 0x066c420f, 0x066c420f, 0x066c420f, }, { 0x1c9360, 0x0f282207, 0x0f282207, 0x0f282207, 0x0f282207, }, { 0x1c9364, 0x17601685, 0x17601685, 0x17601685, 0x17601685, }, { 0x1c9368, 0x1f801104, 0x1f801104, 0x1f801104, 0x1f801104, }, { 0x1c936c, 0x37a00c03, 0x37a00c03, 0x37a00c03, 0x37a00c03, }, { 0x1c9370, 0x3fc40883, 0x3fc40883, 0x3fc40883, 0x3fc40883, }, { 0x1c9374, 0x57c00803, 0x57c00803, 0x57c00803, 0x57c00803, }, { 0x1c9378, 0x5fd80682, 0x5fd80682, 0x5fd80682, 0x5fd80682, }, { 0x1c937c, 0x7fe00482, 0x7fe00482, 0x7fe00482, 0x7fe00482, }, { 0x1c9380, 0x7f3c7bba, 0x7f3c7bba, 0x7f3c7bba, 0x7f3c7bba, }, { 0x1c9384, 0xf3307ff0, 0xf3307ff0, 0xf3307ff0, 0xf3307ff0, } }; /* * look up a certain register in ar5416_phy_init[] and return the init. value * for the band and bandwidth given. Return 0 if register address not found. */ static u32 carl9170_def_val(u32 reg, bool is_2ghz, bool is_40mhz) { unsigned int i; for (i = 0; i < ARRAY_SIZE(ar5416_phy_init); i++) { if (ar5416_phy_init[i].reg != reg) continue; if (is_2ghz) { if (is_40mhz) return ar5416_phy_init[i]._2ghz_40; else return ar5416_phy_init[i]._2ghz_20; } else { if (is_40mhz) return ar5416_phy_init[i]._5ghz_40; else return ar5416_phy_init[i]._5ghz_20; } } return 0; } /* * initialize some phy regs from eeprom values in modal_header[] * acc. to band and bandwidth */ static int carl9170_init_phy_from_eeprom(struct ar9170 *ar, bool is_2ghz, bool is_40mhz) { static const u8 xpd2pd[16] = { 0x2, 0x2, 0x2, 0x1, 0x2, 0x2, 0x6, 0x2, 0x2, 0x3, 0x7, 0x2, 0xb, 0x2, 0x2, 0x2 }; /* pointer to the modal_header acc. to band */ struct ar9170_eeprom_modal *m = &ar->eeprom.modal_header[is_2ghz]; u32 val; carl9170_regwrite_begin(ar); /* ant common control (index 0) */ carl9170_regwrite(AR9170_PHY_REG_SWITCH_COM, le32_to_cpu(m->antCtrlCommon)); /* ant control chain 0 (index 1) */ carl9170_regwrite(AR9170_PHY_REG_SWITCH_CHAIN_0, le32_to_cpu(m->antCtrlChain[0])); /* ant control chain 2 (index 2) */ carl9170_regwrite(AR9170_PHY_REG_SWITCH_CHAIN_2, le32_to_cpu(m->antCtrlChain[1])); /* SwSettle (index 3) */ if (!is_40mhz) { val = carl9170_def_val(AR9170_PHY_REG_SETTLING, is_2ghz, is_40mhz); SET_VAL(AR9170_PHY_SETTLING_SWITCH, val, m->switchSettling); carl9170_regwrite(AR9170_PHY_REG_SETTLING, val); } /* adcDesired, pdaDesired (index 4) */ val = carl9170_def_val(AR9170_PHY_REG_DESIRED_SZ, is_2ghz, is_40mhz); SET_VAL(AR9170_PHY_DESIRED_SZ_PGA, val, m->pgaDesiredSize); SET_VAL(AR9170_PHY_DESIRED_SZ_ADC, val, m->adcDesiredSize); carl9170_regwrite(AR9170_PHY_REG_DESIRED_SZ, val); /* TxEndToXpaOff, TxFrameToXpaOn (index 5) */ val = carl9170_def_val(AR9170_PHY_REG_RF_CTL4, is_2ghz, is_40mhz); SET_VAL(AR9170_PHY_RF_CTL4_TX_END_XPAB_OFF, val, m->txEndToXpaOff); SET_VAL(AR9170_PHY_RF_CTL4_TX_END_XPAA_OFF, val, m->txEndToXpaOff); SET_VAL(AR9170_PHY_RF_CTL4_FRAME_XPAB_ON, val, m->txFrameToXpaOn); SET_VAL(AR9170_PHY_RF_CTL4_FRAME_XPAA_ON, val, m->txFrameToXpaOn); carl9170_regwrite(AR9170_PHY_REG_RF_CTL4, val); /* TxEndToRxOn (index 6) */ val = carl9170_def_val(AR9170_PHY_REG_RF_CTL3, is_2ghz, is_40mhz); SET_VAL(AR9170_PHY_RF_CTL3_TX_END_TO_A2_RX_ON, val, m->txEndToRxOn); carl9170_regwrite(AR9170_PHY_REG_RF_CTL3, val); /* thresh62 (index 7) */ val = carl9170_def_val(0x1c8864, is_2ghz, is_40mhz); val = (val & ~0x7f000) | (m->thresh62 << 12); carl9170_regwrite(0x1c8864, val); /* tx/rx attenuation chain 0 (index 8) */ val = carl9170_def_val(AR9170_PHY_REG_RXGAIN, is_2ghz, is_40mhz); SET_VAL(AR9170_PHY_RXGAIN_TXRX_ATTEN, val, m->txRxAttenCh[0]); carl9170_regwrite(AR9170_PHY_REG_RXGAIN, val); /* tx/rx attenuation chain 2 (index 9) */ val = carl9170_def_val(AR9170_PHY_REG_RXGAIN_CHAIN_2, is_2ghz, is_40mhz); SET_VAL(AR9170_PHY_RXGAIN_TXRX_ATTEN, val, m->txRxAttenCh[1]); carl9170_regwrite(AR9170_PHY_REG_RXGAIN_CHAIN_2, val); /* tx/rx margin chain 0 (index 10) */ val = carl9170_def_val(AR9170_PHY_REG_GAIN_2GHZ, is_2ghz, is_40mhz); SET_VAL(AR9170_PHY_GAIN_2GHZ_RXTX_MARGIN, val, m->rxTxMarginCh[0]); /* bsw margin chain 0 for 5GHz only */ if (!is_2ghz) SET_VAL(AR9170_PHY_GAIN_2GHZ_BSW_MARGIN, val, m->bswMargin[0]); carl9170_regwrite(AR9170_PHY_REG_GAIN_2GHZ, val); /* tx/rx margin chain 2 (index 11) */ val = carl9170_def_val(AR9170_PHY_REG_GAIN_2GHZ_CHAIN_2, is_2ghz, is_40mhz); SET_VAL(AR9170_PHY_GAIN_2GHZ_RXTX_MARGIN, val, m->rxTxMarginCh[1]); carl9170_regwrite(AR9170_PHY_REG_GAIN_2GHZ_CHAIN_2, val); /* iqCall, iqCallq chain 0 (index 12) */ val = carl9170_def_val(AR9170_PHY_REG_TIMING_CTRL4(0), is_2ghz, is_40mhz); SET_VAL(AR9170_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF, val, m->iqCalICh[0]); SET_VAL(AR9170_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF, val, m->iqCalQCh[0]); carl9170_regwrite(AR9170_PHY_REG_TIMING_CTRL4(0), val); /* iqCall, iqCallq chain 2 (index 13) */ val = carl9170_def_val(AR9170_PHY_REG_TIMING_CTRL4(2), is_2ghz, is_40mhz); SET_VAL(AR9170_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF, val, m->iqCalICh[1]); SET_VAL(AR9170_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF, val, m->iqCalQCh[1]); carl9170_regwrite(AR9170_PHY_REG_TIMING_CTRL4(2), val); /* xpd gain mask (index 14) */ val = carl9170_def_val(AR9170_PHY_REG_TPCRG1, is_2ghz, is_40mhz); SET_VAL(AR9170_PHY_TPCRG1_PD_GAIN_1, val, xpd2pd[m->xpdGain & 0xf] & 3); SET_VAL(AR9170_PHY_TPCRG1_PD_GAIN_2, val, xpd2pd[m->xpdGain & 0xf] >> 2); carl9170_regwrite(AR9170_PHY_REG_TPCRG1, val); carl9170_regwrite(AR9170_PHY_REG_RX_CHAINMASK, ar->eeprom.rx_mask); carl9170_regwrite(AR9170_PHY_REG_CAL_CHAINMASK, ar->eeprom.rx_mask); carl9170_regwrite_finish(); return carl9170_regwrite_result(); } static int carl9170_init_phy(struct ar9170 *ar, enum ieee80211_band band) { int i, err; u32 val; bool is_2ghz = band == IEEE80211_BAND_2GHZ; bool is_40mhz = conf_is_ht40(&ar->hw->conf); carl9170_regwrite_begin(ar); for (i = 0; i < ARRAY_SIZE(ar5416_phy_init); i++) { if (is_40mhz) { if (is_2ghz) val = ar5416_phy_init[i]._2ghz_40; else val = ar5416_phy_init[i]._5ghz_40; } else { if (is_2ghz) val = ar5416_phy_init[i]._2ghz_20; else val = ar5416_phy_init[i]._5ghz_20; } carl9170_regwrite(ar5416_phy_init[i].reg, val); } carl9170_regwrite_finish(); err = carl9170_regwrite_result(); if (err) return err; err = carl9170_init_phy_from_eeprom(ar, is_2ghz, is_40mhz); if (err) return err; err = carl9170_init_power_cal(ar); if (err) return err; /* XXX: remove magic! */ if (is_2ghz) err = carl9170_write_reg(ar, AR9170_PWR_REG_PLL_ADDAC, 0x5163); else err = carl9170_write_reg(ar, AR9170_PWR_REG_PLL_ADDAC, 0x5143); return err; } struct carl9170_rf_initvals { u32 reg, _5ghz, _2ghz; }; static struct carl9170_rf_initvals carl9170_rf_initval[] = { /* bank 0 */ { 0x1c58b0, 0x1e5795e5, 0x1e5795e5}, { 0x1c58e0, 0x02008020, 0x02008020}, /* bank 1 */ { 0x1c58b0, 0x02108421, 0x02108421}, { 0x1c58ec, 0x00000008, 0x00000008}, /* bank 2 */ { 0x1c58b0, 0x0e73ff17, 0x0e73ff17}, { 0x1c58e0, 0x00000420, 0x00000420}, /* bank 3 */ { 0x1c58f0, 0x01400018, 0x01c00018}, /* bank 4 */ { 0x1c58b0, 0x000001a1, 0x000001a1}, { 0x1c58e8, 0x00000001, 0x00000001}, /* bank 5 */ { 0x1c58b0, 0x00000013, 0x00000013}, { 0x1c58e4, 0x00000002, 0x00000002}, /* bank 6 */ { 0x1c58b0, 0x00000000, 0x00000000}, { 0x1c58b0, 0x00000000, 0x00000000}, { 0x1c58b0, 0x00000000, 0x00000000}, { 0x1c58b0, 0x00000000, 0x00000000}, { 0x1c58b0, 0x00000000, 0x00000000}, { 0x1c58b0, 0x00004000, 0x00004000}, { 0x1c58b0, 0x00006c00, 0x00006c00}, { 0x1c58b0, 0x00002c00, 0x00002c00}, { 0x1c58b0, 0x00004800, 0x00004800}, { 0x1c58b0, 0x00004000, 0x00004000}, { 0x1c58b0, 0x00006000, 0x00006000}, { 0x1c58b0, 0x00001000, 0x00001000}, { 0x1c58b0, 0x00004000, 0x00004000}, { 0x1c58b0, 0x00007c00, 0x00007c00}, { 0x1c58b0, 0x00007c00, 0x00007c00}, { 0x1c58b0, 0x00007c00, 0x00007c00}, { 0x1c58b0, 0x00007c00, 0x00007c00}, { 0x1c58b0, 0x00007c00, 0x00007c00}, { 0x1c58b0, 0x00087c00, 0x00087c00}, { 0x1c58b0, 0x00007c00, 0x00007c00}, { 0x1c58b0, 0x00005400, 0x00005400}, { 0x1c58b0, 0x00000c00, 0x00000c00}, { 0x1c58b0, 0x00001800, 0x00001800}, { 0x1c58b0, 0x00007c00, 0x00007c00}, { 0x1c58b0, 0x00006c00, 0x00006c00}, { 0x1c58b0, 0x00006c00, 0x00006c00}, { 0x1c58b0, 0x00007c00, 0x00007c00}, { 0x1c58b0, 0x00002c00, 0x00002c00}, { 0x1c58b0, 0x00003c00, 0x00003c00}, { 0x1c58b0, 0x00003800, 0x00003800}, { 0x1c58b0, 0x00001c00, 0x00001c00}, { 0x1c58b0, 0x00000800, 0x00000800}, { 0x1c58b0, 0x00000408, 0x00000408}, { 0x1c58b0, 0x00004c15, 0x00004c15}, { 0x1c58b0, 0x00004188, 0x00004188}, { 0x1c58b0, 0x0000201e, 0x0000201e}, { 0x1c58b0, 0x00010408, 0x00010408}, { 0x1c58b0, 0x00000801, 0x00000801}, { 0x1c58b0, 0x00000c08, 0x00000c08}, { 0x1c58b0, 0x0000181e, 0x0000181e}, { 0x1c58b0, 0x00001016, 0x00001016}, { 0x1c58b0, 0x00002800, 0x00002800}, { 0x1c58b0, 0x00004010, 0x00004010}, { 0x1c58b0, 0x0000081c, 0x0000081c}, { 0x1c58b0, 0x00000115, 0x00000115}, { 0x1c58b0, 0x00000015, 0x00000015}, { 0x1c58b0, 0x00000066, 0x00000066}, { 0x1c58b0, 0x0000001c, 0x0000001c}, { 0x1c58b0, 0x00000000, 0x00000000}, { 0x1c58b0, 0x00000004, 0x00000004}, { 0x1c58b0, 0x00000015, 0x00000015}, { 0x1c58b0, 0x0000001f, 0x0000001f}, { 0x1c58e0, 0x00000000, 0x00000400}, /* bank 7 */ { 0x1c58b0, 0x000000a0, 0x000000a0}, { 0x1c58b0, 0x00000000, 0x00000000}, { 0x1c58b0, 0x00000040, 0x00000040}, { 0x1c58f0, 0x0000001c, 0x0000001c}, }; static int carl9170_init_rf_banks_0_7(struct ar9170 *ar, bool band5ghz) { int err, i; carl9170_regwrite_begin(ar); for (i = 0; i < ARRAY_SIZE(carl9170_rf_initval); i++) carl9170_regwrite(carl9170_rf_initval[i].reg, band5ghz ? carl9170_rf_initval[i]._5ghz : carl9170_rf_initval[i]._2ghz); carl9170_regwrite_finish(); err = carl9170_regwrite_result(); if (err) wiphy_err(ar->hw->wiphy, "rf init failed\n"); return err; } struct carl9170_phy_freq_params { u8 coeff_exp; u16 coeff_man; u8 coeff_exp_shgi; u16 coeff_man_shgi; }; enum carl9170_bw { CARL9170_BW_20, CARL9170_BW_40_BELOW, CARL9170_BW_40_ABOVE, __CARL9170_NUM_BW, }; struct carl9170_phy_freq_entry { u16 freq; struct carl9170_phy_freq_params params[__CARL9170_NUM_BW]; }; /* NB: must be in sync with channel tables in main! */ static const struct carl9170_phy_freq_entry carl9170_phy_freq_params[] = { /* * freq, * 20MHz, * 40MHz (below), * 40Mhz (above), */ { 2412, { { 3, 21737, 3, 19563, }, { 3, 21827, 3, 19644, }, { 3, 21647, 3, 19482, }, } }, { 2417, { { 3, 21692, 3, 19523, }, { 3, 21782, 3, 19604, }, { 3, 21602, 3, 19442, }, } }, { 2422, { { 3, 21647, 3, 19482, }, { 3, 21737, 3, 19563, }, { 3, 21558, 3, 19402, }, } }, { 2427, { { 3, 21602, 3, 19442, }, { 3, 21692, 3, 19523, }, { 3, 21514, 3, 19362, }, } }, { 2432, { { 3, 21558, 3, 19402, }, { 3, 21647, 3, 19482, }, { 3, 21470, 3, 19323, }, } }, { 2437, { { 3, 21514, 3, 19362, }, { 3, 21602, 3, 19442, }, { 3, 21426, 3, 19283, }, } }, { 2442, { { 3, 21470, 3, 19323, }, { 3, 21558, 3, 19402, }, { 3, 21382, 3, 19244, }, } }, { 2447, { { 3, 21426, 3, 19283, }, { 3, 21514, 3, 19362, }, { 3, 21339, 3, 19205, }, } }, { 2452, { { 3, 21382, 3, 19244, }, { 3, 21470, 3, 19323, }, { 3, 21295, 3, 19166, }, } }, { 2457, { { 3, 21339, 3, 19205, }, { 3, 21426, 3, 19283, }, { 3, 21252, 3, 19127, }, } }, { 2462, { { 3, 21295, 3, 19166, }, { 3, 21382, 3, 19244, }, { 3, 21209, 3, 19088, }, } }, { 2467, { { 3, 21252, 3, 19127, }, { 3, 21339, 3, 19205, }, { 3, 21166, 3, 19050, }, } }, { 2472, { { 3, 21209, 3, 19088, }, { 3, 21295, 3, 19166, }, { 3, 21124, 3, 19011, }, } }, { 2484, { { 3, 21107, 3, 18996, }, { 3, 21192, 3, 19073, }, { 3, 21022, 3, 18920, }, } }, { 4920, { { 4, 21313, 4, 19181, }, { 4, 21356, 4, 19220, }, { 4, 21269, 4, 19142, }, } }, { 4940, { { 4, 21226, 4, 19104, }, { 4, 21269, 4, 19142, }, { 4, 21183, 4, 19065, }, } }, { 4960, { { 4, 21141, 4, 19027, }, { 4, 21183, 4, 19065, }, { 4, 21098, 4, 18988, }, } }, { 4980, { { 4, 21056, 4, 18950, }, { 4, 21098, 4, 18988, }, { 4, 21014, 4, 18912, }, } }, { 5040, { { 4, 20805, 4, 18725, }, { 4, 20846, 4, 18762, }, { 4, 20764, 4, 18687, }, } }, { 5060, { { 4, 20723, 4, 18651, }, { 4, 20764, 4, 18687, }, { 4, 20682, 4, 18614, }, } }, { 5080, { { 4, 20641, 4, 18577, }, { 4, 20682, 4, 18614, }, { 4, 20601, 4, 18541, }, } }, { 5180, { { 4, 20243, 4, 18219, }, { 4, 20282, 4, 18254, }, { 4, 20204, 4, 18183, }, } }, { 5200, { { 4, 20165, 4, 18148, }, { 4, 20204, 4, 18183, }, { 4, 20126, 4, 18114, }, } }, { 5220, { { 4, 20088, 4, 18079, }, { 4, 20126, 4, 18114, }, { 4, 20049, 4, 18044, }, } }, { 5240, { { 4, 20011, 4, 18010, }, { 4, 20049, 4, 18044, }, { 4, 19973, 4, 17976, }, } }, { 5260, { { 4, 19935, 4, 17941, }, { 4, 19973, 4, 17976, }, { 4, 19897, 4, 17907, }, } }, { 5280, { { 4, 19859, 4, 17873, }, { 4, 19897, 4, 17907, }, { 4, 19822, 4, 17840, }, } }, { 5300, { { 4, 19784, 4, 17806, }, { 4, 19822, 4, 17840, }, { 4, 19747, 4, 17772, }, } }, { 5320, { { 4, 19710, 4, 17739, }, { 4, 19747, 4, 17772, }, { 4, 19673, 4, 17706, }, } }, { 5500, { { 4, 19065, 4, 17159, }, { 4, 19100, 4, 17190, }, { 4, 19030, 4, 17127, }, } }, { 5520, { { 4, 18996, 4, 17096, }, { 4, 19030, 4, 17127, }, { 4, 18962, 4, 17065, }, } }, { 5540, { { 4, 18927, 4, 17035, }, { 4, 18962, 4, 17065, }, { 4, 18893, 4, 17004, }, } }, { 5560, { { 4, 18859, 4, 16973, }, { 4, 18893, 4, 17004, }, { 4, 18825, 4, 16943, }, } }, { 5580, { { 4, 18792, 4, 16913, }, { 4, 18825, 4, 16943, }, { 4, 18758, 4, 16882, }, } }, { 5600, { { 4, 18725, 4, 16852, }, { 4, 18758, 4, 16882, }, { 4, 18691, 4, 16822, }, } }, { 5620, { { 4, 18658, 4, 16792, }, { 4, 18691, 4, 16822, }, { 4, 18625, 4, 16762, }, } }, { 5640, { { 4, 18592, 4, 16733, }, { 4, 18625, 4, 16762, }, { 4, 18559, 4, 16703, }, } }, { 5660, { { 4, 18526, 4, 16673, }, { 4, 18559, 4, 16703, }, { 4, 18493, 4, 16644, }, } }, { 5680, { { 4, 18461, 4, 16615, }, { 4, 18493, 4, 16644, }, { 4, 18428, 4, 16586, }, } }, { 5700, { { 4, 18396, 4, 16556, }, { 4, 18428, 4, 16586, }, { 4, 18364, 4, 16527, }, } }, { 5745, { { 4, 18252, 4, 16427, }, { 4, 18284, 4, 16455, }, { 4, 18220, 4, 16398, }, } }, { 5765, { { 4, 18189, 5, 32740, }, { 4, 18220, 4, 16398, }, { 4, 18157, 5, 32683, }, } }, { 5785, { { 4, 18126, 5, 32626, }, { 4, 18157, 5, 32683, }, { 4, 18094, 5, 32570, }, } }, { 5805, { { 4, 18063, 5, 32514, }, { 4, 18094, 5, 32570, }, { 4, 18032, 5, 32458, }, } }, { 5825, { { 4, 18001, 5, 32402, }, { 4, 18032, 5, 32458, }, { 4, 17970, 5, 32347, }, } }, { 5170, { { 4, 20282, 4, 18254, }, { 4, 20321, 4, 18289, }, { 4, 20243, 4, 18219, }, } }, { 5190, { { 4, 20204, 4, 18183, }, { 4, 20243, 4, 18219, }, { 4, 20165, 4, 18148, }, } }, { 5210, { { 4, 20126, 4, 18114, }, { 4, 20165, 4, 18148, }, { 4, 20088, 4, 18079, }, } }, { 5230, { { 4, 20049, 4, 18044, }, { 4, 20088, 4, 18079, }, { 4, 20011, 4, 18010, }, } }, }; static int carl9170_init_rf_bank4_pwr(struct ar9170 *ar, bool band5ghz, u32 freq, enum carl9170_bw bw) { int err; u32 d0, d1, td0, td1, fd0, fd1; u8 chansel; u8 refsel0 = 1, refsel1 = 0; u8 lf_synth = 0; switch (bw) { case CARL9170_BW_40_ABOVE: freq += 10; break; case CARL9170_BW_40_BELOW: freq -= 10; break; case CARL9170_BW_20: break; default: BUG(); return -ENOSYS; } if (band5ghz) { if (freq % 10) { chansel = (freq - 4800) / 5; } else { chansel = ((freq - 4800) / 10) * 2; refsel0 = 0; refsel1 = 1; } chansel = byte_rev_table[chansel]; } else { if (freq == 2484) { chansel = 10 + (freq - 2274) / 5; lf_synth = 1; } else chansel = 16 + (freq - 2272) / 5; chansel *= 4; chansel = byte_rev_table[chansel]; } d1 = chansel; d0 = 0x21 | refsel0 << 3 | refsel1 << 2 | lf_synth << 1; td0 = d0 & 0x1f; td1 = d1 & 0x1f; fd0 = td1 << 5 | td0; td0 = (d0 >> 5) & 0x7; td1 = (d1 >> 5) & 0x7; fd1 = td1 << 5 | td0; carl9170_regwrite_begin(ar); carl9170_regwrite(0x1c58b0, fd0); carl9170_regwrite(0x1c58e8, fd1); carl9170_regwrite_finish(); err = carl9170_regwrite_result(); if (err) return err; return 0; } static const struct carl9170_phy_freq_params * carl9170_get_hw_dyn_params(struct ieee80211_channel *channel, enum carl9170_bw bw) { unsigned int chanidx = 0; u16 freq = 2412; if (channel) { chanidx = channel->hw_value; freq = channel->center_freq; } BUG_ON(chanidx >= ARRAY_SIZE(carl9170_phy_freq_params)); BUILD_BUG_ON(__CARL9170_NUM_BW != 3); WARN_ON(carl9170_phy_freq_params[chanidx].freq != freq); return &carl9170_phy_freq_params[chanidx].params[bw]; } static int carl9170_find_freq_idx(int nfreqs, u8 *freqs, u8 f) { int idx = nfreqs - 2; while (idx >= 0) { if (f >= freqs[idx]) return idx; idx--; } return 0; } static s32 carl9170_interpolate_s32(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) { /* nothing to interpolate, it's horizontal */ if (y2 == y1) return y1; /* check if we hit one of the edges */ if (x == x1) return y1; if (x == x2) return y2; /* x1 == x2 is bad, hopefully == x */ if (x2 == x1) return y1; return y1 + (((y2 - y1) * (x - x1)) / (x2 - x1)); } static u8 carl9170_interpolate_u8(u8 x, u8 x1, u8 y1, u8 x2, u8 y2) { #define SHIFT 8 s32 y; y = carl9170_interpolate_s32(x << SHIFT, x1 << SHIFT, y1 << SHIFT, x2 << SHIFT, y2 << SHIFT); /* * XXX: unwrap this expression * Isn't it just DIV_ROUND_UP(y, 1<<SHIFT)? * Can we rely on the compiler to optimise away the div? */ return (y >> SHIFT) + ((y & (1<<(SHIFT-1))) >> (SHIFT - 1)); #undef SHIFT } static u8 carl9170_interpolate_val(u8 x, u8 *x_array, u8 *y_array) { int i; for (i = 0; i < 3; i++) { if (x <= x_array[i + 1]) break; } return carl9170_interpolate_u8(x, x_array[i], y_array[i], x_array[i + 1], y_array[i + 1]); } static int carl9170_set_freq_cal_data(struct ar9170 *ar, struct ieee80211_channel *channel) { u8 *cal_freq_pier; u8 vpds[2][AR5416_PD_GAIN_ICEPTS]; u8 pwrs[2][AR5416_PD_GAIN_ICEPTS]; int chain, idx, i; u32 phy_data = 0; u8 f, tmp; switch (channel->band) { case IEEE80211_BAND_2GHZ: f = channel->center_freq - 2300; cal_freq_pier = ar->eeprom.cal_freq_pier_2G; i = AR5416_NUM_2G_CAL_PIERS - 1; break; case IEEE80211_BAND_5GHZ: f = (channel->center_freq - 4800) / 5; cal_freq_pier = ar->eeprom.cal_freq_pier_5G; i = AR5416_NUM_5G_CAL_PIERS - 1; break; default: return -EINVAL; break; } for (; i >= 0; i--) { if (cal_freq_pier[i] != 0xff) break; } if (i < 0) return -EINVAL; idx = carl9170_find_freq_idx(i, cal_freq_pier, f); carl9170_regwrite_begin(ar); for (chain = 0; chain < AR5416_MAX_CHAINS; chain++) { for (i = 0; i < AR5416_PD_GAIN_ICEPTS; i++) { struct ar9170_calibration_data_per_freq *cal_pier_data; int j; switch (channel->band) { case IEEE80211_BAND_2GHZ: cal_pier_data = &ar->eeprom. cal_pier_data_2G[chain][idx]; break; case IEEE80211_BAND_5GHZ: cal_pier_data = &ar->eeprom. cal_pier_data_5G[chain][idx]; break; default: return -EINVAL; } for (j = 0; j < 2; j++) { vpds[j][i] = carl9170_interpolate_u8(f, cal_freq_pier[idx], cal_pier_data->vpd_pdg[j][i], cal_freq_pier[idx + 1], cal_pier_data[1].vpd_pdg[j][i]); pwrs[j][i] = carl9170_interpolate_u8(f, cal_freq_pier[idx], cal_pier_data->pwr_pdg[j][i], cal_freq_pier[idx + 1], cal_pier_data[1].pwr_pdg[j][i]) / 2; } } for (i = 0; i < 76; i++) { if (i < 25) { tmp = carl9170_interpolate_val(i, &pwrs[0][0], &vpds[0][0]); } else { tmp = carl9170_interpolate_val(i - 12, &pwrs[1][0], &vpds[1][0]); } phy_data |= tmp << ((i & 3) << 3); if ((i & 3) == 3) { carl9170_regwrite(0x1c6280 + chain * 0x1000 + (i & ~3), phy_data); phy_data = 0; } } for (i = 19; i < 32; i++) carl9170_regwrite(0x1c6280 + chain * 0x1000 + (i << 2), 0x0); } carl9170_regwrite_finish(); return carl9170_regwrite_result(); } static u8 carl9170_get_max_edge_power(struct ar9170 *ar, u32 freq, struct ar9170_calctl_edges edges[]) { int i; u8 rc = AR5416_MAX_RATE_POWER; u8 f; if (freq < 3000) f = freq - 2300; else f = (freq - 4800) / 5; for (i = 0; i < AR5416_NUM_BAND_EDGES; i++) { if (edges[i].channel == 0xff) break; if (f == edges[i].channel) { /* exact freq match */ rc = edges[i].power_flags & ~AR9170_CALCTL_EDGE_FLAGS; break; } if (i > 0 && f < edges[i].channel) { if (f > edges[i - 1].channel && edges[i - 1].power_flags & AR9170_CALCTL_EDGE_FLAGS) { /* lower channel has the inband flag set */ rc = edges[i - 1].power_flags & ~AR9170_CALCTL_EDGE_FLAGS; } break; } } if (i == AR5416_NUM_BAND_EDGES) { if (f > edges[i - 1].channel && edges[i - 1].power_flags & AR9170_CALCTL_EDGE_FLAGS) { /* lower channel has the inband flag set */ rc = edges[i - 1].power_flags & ~AR9170_CALCTL_EDGE_FLAGS; } } return rc; } static u8 carl9170_get_heavy_clip(struct ar9170 *ar, u32 freq, enum carl9170_bw bw, struct ar9170_calctl_edges edges[]) { u8 f; int i; u8 rc = 0; if (freq < 3000) f = freq - 2300; else f = (freq - 4800) / 5; if (bw == CARL9170_BW_40_BELOW || bw == CARL9170_BW_40_ABOVE) rc |= 0xf0; for (i = 0; i < AR5416_NUM_BAND_EDGES; i++) { if (edges[i].channel == 0xff) break; if (f == edges[i].channel) { if (!(edges[i].power_flags & AR9170_CALCTL_EDGE_FLAGS)) rc |= 0x0f; break; } } return rc; } /* * calculate the conformance test limits and the heavy clip parameter * and apply them to ar->power* (derived from otus hal/hpmain.c, line 3706) */ static void carl9170_calc_ctl(struct ar9170 *ar, u32 freq, enum carl9170_bw bw) { u8 ctl_grp; /* CTL group */ u8 ctl_idx; /* CTL index */ int i, j; struct ctl_modes { u8 ctl_mode; u8 max_power; u8 *pwr_cal_data; int pwr_cal_len; } *modes; /* * order is relevant in the mode_list_*: we fall back to the * lower indices if any mode is missed in the EEPROM. */ struct ctl_modes mode_list_2ghz[] = { { CTL_11B, 0, ar->power_2G_cck, 4 }, { CTL_11G, 0, ar->power_2G_ofdm, 4 }, { CTL_2GHT20, 0, ar->power_2G_ht20, 8 }, { CTL_2GHT40, 0, ar->power_2G_ht40, 8 }, }; struct ctl_modes mode_list_5ghz[] = { { CTL_11A, 0, ar->power_5G_leg, 4 }, { CTL_5GHT20, 0, ar->power_5G_ht20, 8 }, { CTL_5GHT40, 0, ar->power_5G_ht40, 8 }, }; int nr_modes; #define EDGES(c, n) (ar->eeprom.ctl_data[c].control_edges[n]) ar->heavy_clip = 0; /* * TODO: investigate the differences between OTUS' * hpreg.c::zfHpGetRegulatoryDomain() and * ath/regd.c::ath_regd_get_band_ctl() - * e.g. for FCC3_WORLD the OTUS procedure * always returns CTL_FCC, while the one in ath/ delivers * CTL_ETSI for 2GHz and CTL_FCC for 5GHz. */ ctl_grp = ath_regd_get_band_ctl(&ar->common.regulatory, ar->hw->conf.channel->band); /* ctl group not found - either invalid band (NO_CTL) or ww roaming */ if (ctl_grp == NO_CTL || ctl_grp == SD_NO_CTL) ctl_grp = CTL_FCC; if (ctl_grp != CTL_FCC) /* skip CTL and heavy clip for CTL_MKK and CTL_ETSI */ return; if (ar->hw->conf.channel->band == IEEE80211_BAND_2GHZ) { modes = mode_list_2ghz; nr_modes = ARRAY_SIZE(mode_list_2ghz); } else { modes = mode_list_5ghz; nr_modes = ARRAY_SIZE(mode_list_5ghz); } for (i = 0; i < nr_modes; i++) { u8 c = ctl_grp | modes[i].ctl_mode; for (ctl_idx = 0; ctl_idx < AR5416_NUM_CTLS; ctl_idx++) if (c == ar->eeprom.ctl_index[ctl_idx]) break; if (ctl_idx < AR5416_NUM_CTLS) { int f_off = 0; /* * determine heavy clip parameter * from the 11G edges array */ if (modes[i].ctl_mode == CTL_11G) { ar->heavy_clip = carl9170_get_heavy_clip(ar, freq, bw, EDGES(ctl_idx, 1)); } /* adjust freq for 40MHz */ if (modes[i].ctl_mode == CTL_2GHT40 || modes[i].ctl_mode == CTL_5GHT40) { if (bw == CARL9170_BW_40_BELOW) f_off = -10; else f_off = 10; } modes[i].max_power = carl9170_get_max_edge_power(ar, freq+f_off, EDGES(ctl_idx, 1)); /* * TODO: check if the regulatory max. power is * controlled by cfg80211 for DFS. * (hpmain applies it to max_power itself for DFS freq) */ } else { /* * Workaround in otus driver, hpmain.c, line 3906: * if no data for 5GHT20 are found, take the * legacy 5G value. We extend this here to fallback * from any other HT* or 11G, too. */ int k = i; modes[i].max_power = AR5416_MAX_RATE_POWER; while (k-- > 0) { if (modes[k].max_power != AR5416_MAX_RATE_POWER) { modes[i].max_power = modes[k].max_power; break; } } } /* apply max power to pwr_cal_data (ar->power_*) */ for (j = 0; j < modes[i].pwr_cal_len; j++) { modes[i].pwr_cal_data[j] = min(modes[i].pwr_cal_data[j], modes[i].max_power); } } if (ar->heavy_clip & 0xf0) { ar->power_2G_ht40[0]--; ar->power_2G_ht40[1]--; ar->power_2G_ht40[2]--; } if (ar->heavy_clip & 0xf) { ar->power_2G_ht20[0]++; ar->power_2G_ht20[1]++; ar->power_2G_ht20[2]++; } #undef EDGES } static int carl9170_set_power_cal(struct ar9170 *ar, u32 freq, enum carl9170_bw bw) { struct ar9170_calibration_target_power_legacy *ctpl; struct ar9170_calibration_target_power_ht *ctph; u8 *ctpres; int ntargets; int idx, i, n; u8 ackpower, ackchains, f; u8 pwr_freqs[AR5416_MAX_NUM_TGT_PWRS]; if (freq < 3000) f = freq - 2300; else f = (freq - 4800)/5; /* * cycle through the various modes * * legacy modes first: 5G, 2G CCK, 2G OFDM */ for (i = 0; i < 3; i++) { switch (i) { case 0: /* 5 GHz legacy */ ctpl = &ar->eeprom.cal_tgt_pwr_5G[0]; ntargets = AR5416_NUM_5G_TARGET_PWRS; ctpres = ar->power_5G_leg; break; case 1: /* 2.4 GHz CCK */ ctpl = &ar->eeprom.cal_tgt_pwr_2G_cck[0]; ntargets = AR5416_NUM_2G_CCK_TARGET_PWRS; ctpres = ar->power_2G_cck; break; case 2: /* 2.4 GHz OFDM */ ctpl = &ar->eeprom.cal_tgt_pwr_2G_ofdm[0]; ntargets = AR5416_NUM_2G_OFDM_TARGET_PWRS; ctpres = ar->power_2G_ofdm; break; default: BUG(); } for (n = 0; n < ntargets; n++) { if (ctpl[n].freq == 0xff) break; pwr_freqs[n] = ctpl[n].freq; } ntargets = n; idx = carl9170_find_freq_idx(ntargets, pwr_freqs, f); for (n = 0; n < 4; n++) ctpres[n] = carl9170_interpolate_u8(f, ctpl[idx + 0].freq, ctpl[idx + 0].power[n], ctpl[idx + 1].freq, ctpl[idx + 1].power[n]); } /* HT modes now: 5G HT20, 5G HT40, 2G CCK, 2G OFDM, 2G HT20, 2G HT40 */ for (i = 0; i < 4; i++) { switch (i) { case 0: /* 5 GHz HT 20 */ ctph = &ar->eeprom.cal_tgt_pwr_5G_ht20[0]; ntargets = AR5416_NUM_5G_TARGET_PWRS; ctpres = ar->power_5G_ht20; break; case 1: /* 5 GHz HT 40 */ ctph = &ar->eeprom.cal_tgt_pwr_5G_ht40[0]; ntargets = AR5416_NUM_5G_TARGET_PWRS; ctpres = ar->power_5G_ht40; break; case 2: /* 2.4 GHz HT 20 */ ctph = &ar->eeprom.cal_tgt_pwr_2G_ht20[0]; ntargets = AR5416_NUM_2G_OFDM_TARGET_PWRS; ctpres = ar->power_2G_ht20; break; case 3: /* 2.4 GHz HT 40 */ ctph = &ar->eeprom.cal_tgt_pwr_2G_ht40[0]; ntargets = AR5416_NUM_2G_OFDM_TARGET_PWRS; ctpres = ar->power_2G_ht40; break; default: BUG(); } for (n = 0; n < ntargets; n++) { if (ctph[n].freq == 0xff) break; pwr_freqs[n] = ctph[n].freq; } ntargets = n; idx = carl9170_find_freq_idx(ntargets, pwr_freqs, f); for (n = 0; n < 8; n++) ctpres[n] = carl9170_interpolate_u8(f, ctph[idx + 0].freq, ctph[idx + 0].power[n], ctph[idx + 1].freq, ctph[idx + 1].power[n]); } /* calc. conformance test limits and apply to ar->power*[] */ carl9170_calc_ctl(ar, freq, bw); /* set ACK/CTS TX power */ carl9170_regwrite_begin(ar); if (ar->eeprom.tx_mask != 1) ackchains = AR9170_TX_PHY_TXCHAIN_2; else ackchains = AR9170_TX_PHY_TXCHAIN_1; if (freq < 3000) ackpower = ar->power_2G_ofdm[0] & 0x3f; else ackpower = ar->power_5G_leg[0] & 0x3f; carl9170_regwrite(AR9170_MAC_REG_ACK_TPC, 0x3c1e | ackpower << 20 | ackchains << 26); carl9170_regwrite(AR9170_MAC_REG_RTS_CTS_TPC, ackpower << 5 | ackchains << 11 | ackpower << 21 | ackchains << 27); carl9170_regwrite(AR9170_MAC_REG_CFEND_QOSNULL_TPC, ackpower << 5 | ackchains << 11 | ackpower << 21 | ackchains << 27); carl9170_regwrite_finish(); return carl9170_regwrite_result(); } int carl9170_get_noisefloor(struct ar9170 *ar) { static const u32 phy_regs[] = { AR9170_PHY_REG_CCA, AR9170_PHY_REG_CH2_CCA, AR9170_PHY_REG_EXT_CCA, AR9170_PHY_REG_CH2_EXT_CCA }; u32 phy_res[ARRAY_SIZE(phy_regs)]; int err, i; BUILD_BUG_ON(ARRAY_SIZE(phy_regs) != ARRAY_SIZE(ar->noise)); err = carl9170_read_mreg(ar, ARRAY_SIZE(phy_regs), phy_regs, phy_res); if (err) return err; for (i = 0; i < 2; i++) { ar->noise[i] = sign_extend32(GET_VAL( AR9170_PHY_CCA_MIN_PWR, phy_res[i]), 8); ar->noise[i + 2] = sign_extend32(GET_VAL( AR9170_PHY_EXT_CCA_MIN_PWR, phy_res[i + 2]), 8); } return 0; } static enum carl9170_bw nl80211_to_carl(enum nl80211_channel_type type) { switch (type) { case NL80211_CHAN_NO_HT: case NL80211_CHAN_HT20: return CARL9170_BW_20; case NL80211_CHAN_HT40MINUS: return CARL9170_BW_40_BELOW; case NL80211_CHAN_HT40PLUS: return CARL9170_BW_40_ABOVE; default: BUG(); } } int carl9170_set_channel(struct ar9170 *ar, struct ieee80211_channel *channel, enum nl80211_channel_type _bw, enum carl9170_rf_init_mode rfi) { const struct carl9170_phy_freq_params *freqpar; struct carl9170_rf_init_result rf_res; struct carl9170_rf_init rf; u32 cmd, tmp, offs = 0, new_ht = 0; int err; enum carl9170_bw bw; bool warm_reset; struct ieee80211_channel *old_channel = NULL; bw = nl80211_to_carl(_bw); if (conf_is_ht(&ar->hw->conf)) new_ht |= CARL9170FW_PHY_HT_ENABLE; if (conf_is_ht40(&ar->hw->conf)) new_ht |= CARL9170FW_PHY_HT_DYN2040; /* may be NULL at first setup */ if (ar->channel) { old_channel = ar->channel; warm_reset = (old_channel->band != channel->band) || (old_channel->center_freq == channel->center_freq) || (ar->ht_settings != new_ht); ar->channel = NULL; } else { warm_reset = true; } /* HW workaround */ if (!ar->hw->wiphy->bands[IEEE80211_BAND_5GHZ] && channel->center_freq <= 2417) warm_reset = true; if (rfi != CARL9170_RFI_NONE || warm_reset) { u32 val; if (rfi == CARL9170_RFI_COLD) val = AR9170_PWR_RESET_BB_COLD_RESET; else val = AR9170_PWR_RESET_BB_WARM_RESET; /* warm/cold reset BB/ADDA */ err = carl9170_write_reg(ar, AR9170_PWR_REG_RESET, val); if (err) return err; err = carl9170_write_reg(ar, AR9170_PWR_REG_RESET, 0x0); if (err) return err; err = carl9170_init_phy(ar, channel->band); if (err) return err; err = carl9170_init_rf_banks_0_7(ar, channel->band == IEEE80211_BAND_5GHZ); if (err) return err; cmd = CARL9170_CMD_RF_INIT; } else { cmd = CARL9170_CMD_FREQUENCY; } err = carl9170_exec_cmd(ar, CARL9170_CMD_FREQ_START, 0, NULL, 0, NULL); if (err) return err; err = carl9170_write_reg(ar, AR9170_PHY_REG_HEAVY_CLIP_ENABLE, 0x200); if (err) return err; err = carl9170_init_rf_bank4_pwr(ar, channel->band == IEEE80211_BAND_5GHZ, channel->center_freq, bw); if (err) return err; tmp = AR9170_PHY_TURBO_FC_SINGLE_HT_LTF1 | AR9170_PHY_TURBO_FC_HT_EN; switch (bw) { case CARL9170_BW_20: break; case CARL9170_BW_40_BELOW: tmp |= AR9170_PHY_TURBO_FC_DYN2040_EN | AR9170_PHY_TURBO_FC_SHORT_GI_40; offs = 3; break; case CARL9170_BW_40_ABOVE: tmp |= AR9170_PHY_TURBO_FC_DYN2040_EN | AR9170_PHY_TURBO_FC_SHORT_GI_40 | AR9170_PHY_TURBO_FC_DYN2040_PRI_CH; offs = 1; break; default: BUG(); return -ENOSYS; } if (ar->eeprom.tx_mask != 1) tmp |= AR9170_PHY_TURBO_FC_WALSH; err = carl9170_write_reg(ar, AR9170_PHY_REG_TURBO, tmp); if (err) return err; err = carl9170_set_freq_cal_data(ar, channel); if (err) return err; err = carl9170_set_power_cal(ar, channel->center_freq, bw); if (err) return err; freqpar = carl9170_get_hw_dyn_params(channel, bw); rf.ht_settings = new_ht; if (conf_is_ht40(&ar->hw->conf)) SET_VAL(CARL9170FW_PHY_HT_EXT_CHAN_OFF, rf.ht_settings, offs); rf.freq = cpu_to_le32(channel->center_freq * 1000); rf.delta_slope_coeff_exp = cpu_to_le32(freqpar->coeff_exp); rf.delta_slope_coeff_man = cpu_to_le32(freqpar->coeff_man); rf.delta_slope_coeff_exp_shgi = cpu_to_le32(freqpar->coeff_exp_shgi); rf.delta_slope_coeff_man_shgi = cpu_to_le32(freqpar->coeff_man_shgi); if (rfi != CARL9170_RFI_NONE) rf.finiteLoopCount = cpu_to_le32(2000); else rf.finiteLoopCount = cpu_to_le32(1000); err = carl9170_exec_cmd(ar, cmd, sizeof(rf), &rf, sizeof(rf_res), &rf_res); if (err) return err; err = le32_to_cpu(rf_res.ret); if (err != 0) { ar->chan_fail++; ar->total_chan_fail++; wiphy_err(ar->hw->wiphy, "channel change: %d -> %d " "failed (%d).\n", old_channel ? old_channel->center_freq : -1, channel->center_freq, err); if ((rfi == CARL9170_RFI_COLD) || (ar->chan_fail > 3)) { /* * We have tried very hard to change to _another_ * channel and we've failed to do so! * Chances are that the PHY/RF is no longer * operable (due to corruptions/fatal events/bugs?) * and we need to reset at a higher level. */ carl9170_restart(ar, CARL9170_RR_TOO_MANY_PHY_ERRORS); return 0; } err = carl9170_set_channel(ar, channel, _bw, CARL9170_RFI_COLD); if (err) return err; } else { ar->chan_fail = 0; } err = carl9170_get_noisefloor(ar); if (err) return err; if (ar->heavy_clip) { err = carl9170_write_reg(ar, AR9170_PHY_REG_HEAVY_CLIP_ENABLE, 0x200 | ar->heavy_clip); if (err) { if (net_ratelimit()) { wiphy_err(ar->hw->wiphy, "failed to set " "heavy clip\n"); } return err; } } ar->channel = channel; ar->ht_settings = new_ht; return 0; }
lioux/AK-tuna
drivers/net/wireless/ath/carl9170/phy.c
C
gpl-2.0
57,749
/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // How to: // To add a new format, // Fill includes, SelectFromExtension, ListFormats and LibraryIsModified // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/MediaInfo_Internal.h" #include "MediaInfo/File__Analyze.h" #include "MediaInfo/Reader/Reader_File.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // Multiple #if defined(MEDIAINFO_AAF_YES) #include "MediaInfo/Multiple/File_Aaf.h" #endif #if defined(MEDIAINFO_BDMV_YES) #include "MediaInfo/Multiple/File_Bdmv.h" #endif #if defined(MEDIAINFO_CDXA_YES) #include "MediaInfo/Multiple/File_Cdxa.h" #endif #if defined(MEDIAINFO_DASHMPD_YES) #include "MediaInfo/Multiple/File_DashMpd.h" #endif #if defined(MEDIAINFO_DCP_YES) #include "MediaInfo/Multiple/File_DcpAm.h" #endif #if defined(MEDIAINFO_DCP_YES) #include "MediaInfo/Multiple/File_DcpCpl.h" #endif #if defined(MEDIAINFO_DCP_YES) #include "MediaInfo/Multiple/File_DcpPkl.h" #endif #if defined(MEDIAINFO_DVDIF_YES) #include "MediaInfo/Multiple/File_DvDif.h" #endif #if defined(MEDIAINFO_DVDV_YES) #include "MediaInfo/Multiple/File_Dvdv.h" #endif #if defined(MEDIAINFO_DXW_YES) #include "MediaInfo/Multiple/File_Dxw.h" #endif #if defined(MEDIAINFO_FLV_YES) #include "MediaInfo/Multiple/File_Flv.h" #endif #if defined(MEDIAINFO_GXF_YES) #include "MediaInfo/Multiple/File_Gxf.h" #endif #if defined(MEDIAINFO_HDSF4M_YES) #include "MediaInfo/Multiple/File_HdsF4m.h" #endif #if defined(MEDIAINFO_HLS_YES) #include "MediaInfo/Multiple/File_Hls.h" #endif #if defined(MEDIAINFO_IBI_YES) #include "MediaInfo/Multiple/File_Ibi.h" #endif #if defined(MEDIAINFO_ISM_YES) #include "MediaInfo/Multiple/File_Ism.h" #endif #if defined(MEDIAINFO_IMF_YES) #include "MediaInfo/Multiple/File_ImfCpl.h" #endif #if defined(MEDIAINFO_IVF_YES) #include "MediaInfo/Multiple/File_Ivf.h" #endif #if defined(MEDIAINFO_LXF_YES) #include "MediaInfo/Multiple/File_Lxf.h" #endif #if defined(MEDIAINFO_MK_YES) #include "MediaInfo/Multiple/File_Mk.h" #endif #if defined(MEDIAINFO_MIXML_YES) #include "MediaInfo/Multiple/File_MiXml.h" #endif #if defined(MEDIAINFO_MPEG4_YES) #include "MediaInfo/Multiple/File_Mpeg4.h" #endif #if defined(MEDIAINFO_MPEG4_YES) #include "MediaInfo/Multiple/File_Mpeg4_TimeCode.h" #endif #if defined(MEDIAINFO_MPEGPS_YES) #include "MediaInfo/Multiple/File_MpegPs.h" #endif #if defined(MEDIAINFO_MPEGTS_YES) || defined(MEDIAINFO_BDAV_YES) || defined(MEDIAINFO_TSP_YES) #include "MediaInfo/Multiple/File_MpegTs.h" #endif #if defined(MEDIAINFO_MXF_YES) #include "MediaInfo/Multiple/File_Mxf.h" #endif #if defined(MEDIAINFO_NUT_YES) #include "MediaInfo/Multiple/File_Nut.h" #endif #if defined(MEDIAINFO_OGG_YES) #include "MediaInfo/Multiple/File_Ogg.h" #endif #if defined(MEDIAINFO_P2_YES) #include "MediaInfo/Multiple/File_P2_Clip.h" #endif #if defined(MEDIAINFO_PMP_YES) #include "MediaInfo/Multiple/File_Pmp.h" #endif #if defined(MEDIAINFO_PTX_YES) #include "MediaInfo/Multiple/File_Ptx.h" #endif #if defined(MEDIAINFO_RIFF_YES) #include "MediaInfo/Multiple/File_Riff.h" #endif #if defined(MEDIAINFO_RM_YES) #include "MediaInfo/Multiple/File_Rm.h" #endif #if defined(MEDIAINFO_SEQUENCEINFO_YES) #include "MediaInfo/Multiple/File_SequenceInfo.h" #endif #if defined(MEDIAINFO_SKM_YES) #include "MediaInfo/Multiple/File_Skm.h" #endif #if defined(MEDIAINFO_SWF_YES) #include "MediaInfo/Multiple/File_Swf.h" #endif #if defined(MEDIAINFO_WM_YES) #include "MediaInfo/Multiple/File_Wm.h" #endif #if defined(MEDIAINFO_WTV_YES) #include "MediaInfo/Multiple/File_Wtv.h" #endif #if defined(MEDIAINFO_XDCAM_YES) #include "MediaInfo/Multiple/File_Xdcam_Clip.h" #endif #if defined(MEDIAINFO_DPG_YES) #include "MediaInfo/Multiple/File_Dpg.h" #endif //--------------------------------------------------------------------------- // Video #if defined(MEDIAINFO_AV1_YES) #include "MediaInfo/Video/File_Av1.h" #endif #if defined(MEDIAINFO_AVC_YES) #include "MediaInfo/Video/File_Avc.h" #endif #if defined(MEDIAINFO_AVSV_YES) #include "MediaInfo/Video/File_AvsV.h" #endif #if defined(MEDIAINFO_DIRAC_YES) #include "MediaInfo/Video/File_Dirac.h" #endif #if defined(MEDIAINFO_FLIC_YES) #include "MediaInfo/Video/File_Flic.h" #endif #if defined(MEDIAINFO_H263_YES) #include "MediaInfo/Video/File_H263.h" #endif #if defined(MEDIAINFO_HEVC_YES) #include "MediaInfo/Video/File_Hevc.h" #endif #if defined(MEDIAINFO_MPEG4V_YES) #include "MediaInfo/Video/File_Mpeg4v.h" #endif #if defined(MEDIAINFO_MPEGV_YES) #include "MediaInfo/Video/File_Mpegv.h" #endif #if defined(MEDIAINFO_VC1_YES) #include "MediaInfo/Video/File_Vc1.h" #endif #if defined(MEDIAINFO_VC3_YES) #include "MediaInfo/Video/File_Vc3.h" #endif #if defined(MEDIAINFO_Y4M_YES) #include "MediaInfo/Video/File_Y4m.h" #endif //--------------------------------------------------------------------------- // Audio #if defined(MEDIAINFO_AAC_YES) #include "MediaInfo/Audio/File_Aac.h" #endif #if defined(MEDIAINFO_AC3_YES) #include "MediaInfo/Audio/File_Ac3.h" #endif #if defined(MEDIAINFO_AC4_YES) #include "MediaInfo/Audio/File_Ac4.h" #endif #if defined(MEDIAINFO_ALS_YES) #include "MediaInfo/Audio/File_Als.h" #endif #if defined(MEDIAINFO_AMR_YES) #include "MediaInfo/Audio/File_Amr.h" #endif #if defined(MEDIAINFO_AMV_YES) #include "MediaInfo/Audio/File_Amv.h" #endif #if defined(MEDIAINFO_APE_YES) #include "MediaInfo/Audio/File_Ape.h" #endif #if defined(MEDIAINFO_AU_YES) #include "MediaInfo/Audio/File_Au.h" #endif #if defined(MEDIAINFO_CAF_YES) #include "MediaInfo/Audio/File_Caf.h" #endif #if defined(MEDIAINFO_DSF_YES) #include "MediaInfo/Audio/File_Dsf.h" #endif #if defined(MEDIAINFO_DSDIFF_YES) #include "MediaInfo/Audio/File_Dsdiff.h" #endif #if defined(MEDIAINFO_DTS_YES) #include "MediaInfo/Audio/File_Dts.h" #endif #if defined(MEDIAINFO_DOLBYE_YES) #include "MediaInfo/Audio/File_DolbyE.h" #endif #if defined(MEDIAINFO_FLAC_YES) #include "MediaInfo/Audio/File_Flac.h" #endif #if defined(MEDIAINFO_IT_YES) #include "MediaInfo/Audio/File_ImpulseTracker.h" #endif #if defined(MEDIAINFO_LA_YES) #include "MediaInfo/Audio/File_La.h" #endif #if defined(MEDIAINFO_MIDI_YES) #include "MediaInfo/Audio/File_Midi.h" #endif #if defined(MEDIAINFO_MOD_YES) #include "MediaInfo/Audio/File_Module.h" #endif #if defined(MEDIAINFO_MPC_YES) #include "MediaInfo/Audio/File_Mpc.h" #endif #if defined(MEDIAINFO_MPCSV8_YES) #include "MediaInfo/Audio/File_MpcSv8.h" #endif #if defined(MEDIAINFO_MPEGA_YES) #include "MediaInfo/Audio/File_Mpega.h" #endif #if defined(MEDIAINFO_OPENMG_YES) #include "MediaInfo/Audio/File_OpenMG.h" #endif #if defined(MEDIAINFO_RKAU_YES) #include "MediaInfo/Audio/File_Rkau.h" #endif #if defined(MEDIAINFO_S3M_YES) #include "MediaInfo/Audio/File_ScreamTracker3.h" #endif #if defined(MEDIAINFO_SMPTEST0337_YES) #include "MediaInfo/Audio/File_SmpteSt0337.h" #endif #if defined(MEDIAINFO_TAK_YES) #include "MediaInfo/Audio/File_Tak.h" #endif #if defined(MEDIAINFO_TTA_YES) #include "MediaInfo/Audio/File_Tta.h" #endif #if defined(MEDIAINFO_TWINVQ_YES) #include "MediaInfo/Audio/File_TwinVQ.h" #endif #if defined(MEDIAINFO_WVPK_YES) #include "MediaInfo/Audio/File_Wvpk.h" #endif #if defined(MEDIAINFO_XM_YES) #include "MediaInfo/Audio/File_ExtendedModule.h" #endif //--------------------------------------------------------------------------- // Text #if defined(MEDIAINFO_EIA608_YES) #include "MediaInfo/Text/File_Eia608.h" #endif #if defined(MEDIAINFO_N19_YES) #include "MediaInfo/Text/File_N19.h" #endif #if defined(MEDIAINFO_PDF_YES) #include "MediaInfo/Text/File_Pdf.h" #endif #if defined(MEDIAINFO_SCC_YES) #include "MediaInfo/Text/File_Scc.h" #endif #if defined(MEDIAINFO_SDP_YES) #include "MediaInfo/Text/File_Sdp.h" #endif #if defined(MEDIAINFO_SUBRIP_YES) #include "MediaInfo/Text/File_SubRip.h" #endif #if defined(MEDIAINFO_TELETEXT_YES) #include "MediaInfo/Text/File_Teletext.h" #endif #if defined(MEDIAINFO_TTML_YES) #include "MediaInfo/Text/File_Ttml.h" #endif #if defined(MEDIAINFO_OTHERTEXT_YES) #include "MediaInfo/Text/File_OtherText.h" #endif //--------------------------------------------------------------------------- // Image #if defined(MEDIAINFO_ARRIRAW_YES) #include "MediaInfo/Image/File_ArriRaw.h" #endif #if defined(MEDIAINFO_BMP_YES) #include "MediaInfo/Image/File_Bmp.h" #endif #if defined(MEDIAINFO_BPG_YES) #include "MediaInfo/Image/File_Bpg.h" #endif #if defined(MEDIAINFO_DDS_YES) #include "MediaInfo/Image/File_Dds.h" #endif #if defined(MEDIAINFO_DPX_YES) #include "MediaInfo/Image/File_Dpx.h" #endif #if defined(MEDIAINFO_EXR_YES) #include "MediaInfo/Image/File_Exr.h" #endif #if defined(MEDIAINFO_GIF_YES) #include "MediaInfo/Image/File_Gif.h" #endif #if defined(MEDIAINFO_ICO_YES) #include "MediaInfo/Image/File_Ico.h" #endif #if defined(MEDIAINFO_JPEG_YES) #include "MediaInfo/Image/File_Jpeg.h" #endif #if defined(MEDIAINFO_PCX_YES) #include "MediaInfo/Image/File_Pcx.h" #endif #if defined(MEDIAINFO_PNG_YES) #include "MediaInfo/Image/File_Png.h" #endif #if defined(MEDIAINFO_PSD_YES) #include "MediaInfo/Image/File_Psd.h" #endif #if defined(MEDIAINFO_TIFF_YES) #include "MediaInfo/Image/File_Tiff.h" #endif #if defined(MEDIAINFO_TGA_YES) #include "MediaInfo/Image/File_Tga.h" #endif //--------------------------------------------------------------------------- // Archive #if defined(MEDIAINFO_7Z_YES) #include "MediaInfo/Archive/File_7z.h" #endif #if defined(MEDIAINFO_ACE_YES) #include "MediaInfo/Archive/File_Ace.h" #endif #if defined(MEDIAINFO_BZIP2_YES) #include "MediaInfo/Archive/File_Bzip2.h" #endif #if defined(MEDIAINFO_ELF_YES) #include "MediaInfo/Archive/File_Elf.h" #endif #if defined(MEDIAINFO_GZIP_YES) #include "MediaInfo/Archive/File_Gzip.h" #endif #if defined(MEDIAINFO_ISO9660_YES) #include "MediaInfo/Archive/File_Iso9660.h" #endif #if defined(MEDIAINFO_MZ_YES) #include "MediaInfo/Archive/File_Mz.h" #endif #if defined(MEDIAINFO_RAR_YES) #include "MediaInfo/Archive/File_Rar.h" #endif #if defined(MEDIAINFO_TAR_YES) #include "MediaInfo/Archive/File_Tar.h" #endif #if defined(MEDIAINFO_ZIP_YES) #include "MediaInfo/Archive/File_Zip.h" #endif //--------------------------------------------------------------------------- // Other #if defined(MEDIAINFO_OTHER_YES) #include "MediaInfo/File_Other.h" #endif #if defined(MEDIAINFO_UNKNOWN_YES) #include "MediaInfo/File_Unknown.h" #endif #if defined(MEDIAINFO_DUMMY_YES) #include "MediaInfo/File_Dummy.h" #endif //--------------------------------------------------------------------------- namespace MediaInfoLib { //--------------------------------------------------------------------------- extern MediaInfo_Config Config; //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- bool MediaInfo_Internal::SelectFromExtension (const String &Parser) { CriticalSectionLocker CSL(CS); //Clear last value delete Info; Info=NULL; //Searching the right File_* if (0) {} //For #defines // Multiple #if defined(MEDIAINFO_AAF_YES) else if (Parser==__T("Aaf")) Info=new File_Aaf(); #endif #if defined(MEDIAINFO_BDAV_YES) else if (Parser==__T("Bdav")) {Info=new File_MpegTs(); ((File_MpegTs*)Info)->BDAV_Size=4;} #endif #if defined(MEDIAINFO_BDMV_YES) else if (Parser==__T("Bdmv")) Info=new File_Bdmv(); #endif #if defined(MEDIAINFO_CDXA_YES) else if (Parser==__T("Cdxa")) Info=new File_Cdxa(); #endif #if defined(MEDIAINFO_DASHMPD_YES) else if (Parser==__T("DashMpd")) Info=new File_DashMpd(); #endif #if defined(MEDIAINFO_DCP_YES) else if (Parser==__T("DcpAm")) Info=new File_DcpAm(); #endif #if defined(MEDIAINFO_DCP_YES) else if (Parser==__T("DcpCpl")) Info=new File_DcpCpl(); #endif #if defined(MEDIAINFO_DCP_YES) else if (Parser==__T("DcpPkg")) Info=new File_DcpPkl(); #endif #if defined(MEDIAINFO_DPG_YES) else if (Parser==__T("Dpg")) Info=new File_Dpg(); #endif #if defined(MEDIAINFO_DVDIF_YES) else if (Parser==__T("DvDif")) Info=new File_DvDif(); #endif #if defined(MEDIAINFO_DVDV_YES) else if (Parser==__T("Dvdv")) Info=new File_Dvdv(); #endif #if defined(MEDIAINFO_DXW_YES) else if (Parser==__T("Dxw")) Info=new File_Dxw(); #endif #if defined(MEDIAINFO_FLV_YES) else if (Parser==__T("Flv")) Info=new File_Flv(); #endif #if defined(MEDIAINFO_GXF_YES) else if (Parser==__T("Gxf")) Info=new File_Gxf(); #endif #if defined(MEDIAINFO_HDSF4M_YES) else if (Parser==__T("HdsF4m")) Info=new File_HdsF4m(); #endif #if defined(MEDIAINFO_HLS_YES) else if (Parser==__T("Hls")) Info=new File_Hls(); #endif #if defined(MEDIAINFO_ISM_YES) else if (Parser==__T("Ism")) Info=new File_Ism(); #endif #if defined(MEDIAINFO_IVF_YES) else if (Parser==__T("Ivf")) Info=new File_Ivf(); #endif #if defined(MEDIAINFO_LXF_YES) else if (Parser==__T("Lxf")) Info=new File_Lxf(); #endif #if defined(MEDIAINFO_MIXML_YES) else if (Parser==__T("MiXml")) Info=new File_MiXml(); #endif #if defined(MEDIAINFO_MK_YES) else if (Parser==__T("Mk")) Info=new File_Mk(); #endif #if defined(MEDIAINFO_MPEG4_YES) else if (Parser==__T("Mpeg4")) Info=new File_Mpeg4(); #endif #if defined(MEDIAINFO_MPEG4_YES) else if (Parser==__T("QuickTimeTC")) Info=new File_Mpeg4_TimeCode(); #endif #if defined(MEDIAINFO_MPEGPS_YES) else if (Parser==__T("MpegPs")) Info=new File_MpegPs(); #endif #if defined(MEDIAINFO_MPEGTS_YES) else if (Parser==__T("MpegTs")) Info=new File_MpegTs(); #endif #if defined(MEDIAINFO_MXF_YES) else if (Parser==__T("Mxf")) Info=new File_Mxf(); #endif #if defined(MEDIAINFO_NUT_YES) else if (Parser==__T("Nut")) Info=new File_Nut(); #endif #if defined(MEDIAINFO_OGG_YES) else if (Parser==__T("Ogg")) Info=new File_Ogg(); #endif #if defined(MEDIAINFO_P2_YES) else if (Parser==__T("P2_Clip")) Info=new File_P2_Clip(); #endif #if defined(MEDIAINFO_PMP_YES) else if (Parser==__T("Pmp")) Info=new File_Pmp(); #endif #if defined(MEDIAINFO_PTX_YES) else if (Parser==__T("Ptx")) Info=new File_Ptx(); #endif #if defined(MEDIAINFO_RIFF_YES) else if (Parser==__T("Riff")) Info=new File_Riff(); #endif #if defined(MEDIAINFO_RM_YES) else if (Parser==__T("Rm")) Info=new File_Rm(); #endif #if defined(MEDIAINFO_SEQUENCEINFO_YES) else if (Parser==__T("SequenceInfo")) Info=new File_SequenceInfo(); #endif #if defined(MEDIAINFO_SKM_YES) else if (Parser==__T("Skm")) Info=new File_Skm(); #endif #if defined(MEDIAINFO_SWF_YES) else if (Parser==__T("Swf")) Info=new File_Swf(); #endif #if defined(MEDIAINFO_WM_YES) else if (Parser==__T("Wm")) Info=new File_Wm(); #endif #if defined(MEDIAINFO_WTV_YES) else if (Parser==__T("Wtv")) Info=new File_Wtv(); #endif #if defined(MEDIAINFO_XDCAM_YES) else if (Parser==__T("Xdcam_Clip")) Info=new File_Xdcam_Clip(); #endif // Video #if defined(MEDIAINFO_AV1_YES) else if (Parser==__T("Av1")) Info=new File_Av1(); #endif #if defined(MEDIAINFO_AVC_YES) else if (Parser==__T("Avc")) Info=new File_Avc(); #endif #if defined(MEDIAINFO_HEVC_YES) else if (Parser==__T("Hevc")) Info=new File_Hevc(); #endif #if defined(MEDIAINFO_AVSV_YES) else if (Parser==__T("AvsV")) Info=new File_AvsV(); #endif #if defined(MEDIAINFO_DIRAC_YES) else if (Parser==__T("Dirac")) Info=new File_Dirac(); #endif #if defined(MEDIAINFO_FLIC_YES) else if (Parser==__T("Flic")) Info=new File_Flic(); #endif #if defined(MEDIAINFO_H263_YES) else if (Parser==__T("H263")) Info=new File_H263(); #endif #if defined(MEDIAINFO_MPEG4V_YES) else if (Parser==__T("Mpeg4v")) Info=new File_Mpeg4v(); #endif #if defined(MEDIAINFO_MPEGV_YES) else if (Parser==__T("Mpegv")) Info=new File_Mpegv(); #endif #if defined(MEDIAINFO_VC1_YES) else if (Parser==__T("Vc1")) Info=new File_Vc1(); #endif #if defined(MEDIAINFO_VC3_YES) else if (Parser==__T("Vc3")) Info=new File_Vc3(); #endif #if defined(MEDIAINFO_Y4M_YES) else if (Parser==__T("Y4m")) Info=new File_Y4m(); #endif // Audio #if defined(MEDIAINFO_AAC_YES) else if (Parser==__T("Adts")) {Info=new File_Aac(); ((File_Aac*)Info)->Mode=File_Aac::Mode_ADTS;} // Prioritization against ADIF #endif #if defined(MEDIAINFO_AC3_YES) else if (Parser==__T("Ac3")) Info=new File_Ac3(); #endif #if defined(MEDIAINFO_AC4_YES) else if (Parser==__T("Ac4")) Info=new File_Ac4(); #endif #if defined(MEDIAINFO_SMPTEST0337_YES) else if (Parser==__T("Aes3")) Info=new File_SmpteSt0337(); #endif #if defined(MEDIAINFO_ALS_YES) else if (Parser==__T("Als")) Info=new File_Als(); #endif #if defined(MEDIAINFO_AMR_YES) else if (Parser==__T("Amr")) Info=new File_Amr(); #endif #if defined(MEDIAINFO_AMV_YES) else if (Parser==__T("Amv")) Info=new File_Amv(); #endif #if defined(MEDIAINFO_APE_YES) else if (Parser==__T("Ape")) Info=new File_Ape(); #endif #if defined(MEDIAINFO_AU_YES) else if (Parser==__T("Au")) Info=new File_Au(); #endif #if defined(MEDIAINFO_CAF_YES) else if (Parser==__T("Caf")) Info=new File_Caf(); #endif #if defined(MEDIAINFO_DSF_YES) else if (Parser==__T("Dsf")) Info=new File_Dsf(); #endif #if defined(MEDIAINFO_DTS_YES) else if (Parser==__T("Dsdiff")) Info=new File_Dsdiff(); #endif #if defined(MEDIAINFO_DTS_YES) else if (Parser==__T("Dts")) Info=new File_Dts(); #endif #if defined(MEDIAINFO_DOLBYE_YES) else if (Parser==__T("DolbyE")) Info=new File_DolbyE(); #endif #if defined(MEDIAINFO_FLAC_YES) else if (Parser==__T("Flac")) Info=new File_Flac(); #endif #if defined(MEDIAINFO_IT_YES) else if (Parser==__T("It")) Info=new File_ImpulseTracker(); #endif #if defined(MEDIAINFO_LA_YES) else if (Parser==__T("La")) Info=new File_La(); #endif #if defined(MEDIAINFO_MIDI_YES) else if (Parser==__T("Midi")) Info=new File_Midi(); #endif #if defined(MEDIAINFO_MOD_YES) else if (Parser==__T("Mod")) Info=new File_Module(); #endif #if defined(MEDIAINFO_MPC_YES) else if (Parser==__T("Mpc")) Info=new File_Mpc(); //-V517 #endif #if defined(MEDIAINFO_MPCSV8_YES) else if (Parser==__T("MpcSv8")) Info=new File_MpcSv8(); #endif #if defined(MEDIAINFO_MPEGA_YES) else if (Parser==__T("Mpega")) Info=new File_Mpega(); #endif #if defined(MEDIAINFO_OPENMG_YES) else if (Parser==__T("OpenMG")) Info=new File_OpenMG(); #endif #if defined(MEDIAINFO_RKAU_YES) else if (Parser==__T("Rkau")) Info=new File_Rkau(); #endif #if defined(MEDIAINFO_S3M_YES) else if (Parser==__T("S3m")) Info=new File_ScreamTracker3(); #endif #if defined(MEDIAINFO_TAK_YES) else if (Parser==__T("Tak")) Info=new File_Tak(); #endif #if defined(MEDIAINFO_TTA_YES) else if (Parser==__T("Tta")) Info=new File_Tta(); #endif #if defined(MEDIAINFO_TWINVQ_YES) else if (Parser==__T("TwinVQ")) Info=new File_TwinVQ(); #endif #if defined(MEDIAINFO_WVPK_YES) else if (Parser==__T("Wvpk")) Info=new File_Wvpk(); #endif #if defined(MEDIAINFO_XM_YES) else if (Parser==__T("Xm")) Info=new File_ExtendedModule(); #endif // Text #if defined(MEDIAINFO_EIA608_YES) else if (Parser==__T("CEA-608")) Info=new File_Eia608(); else if (Parser==__T("EIA-608")) Info=new File_Eia608(); #endif #if defined(MEDIAINFO_N19_YES) else if (Parser==__T("N19")) Info=new File_N19(); #endif #if defined(MEDIAINFO_PDF_YES) else if (Parser==__T("PDF")) Info=new File_Pdf(); #endif #if defined(MEDIAINFO_SCC_YES) else if (Parser==__T("SCC")) Info=new File_Scc(); #endif #if defined(MEDIAINFO_SDP_YES) else if (Parser==__T("SDP")) Info=new File_Sdp(); #endif #if defined(MEDIAINFO_SUBRIP_YES) else if (Parser==__T("SubRip") || Parser == __T("WebVTT")) Info=new File_SubRip(); #endif #if defined(MEDIAINFO_TELETEXT_YES) else if (Parser==__T("Teletext")) Info=new File_Teletext(); #endif #if defined(MEDIAINFO_TTML_YES) else if (Parser==__T("TTML")) Info=new File_Ttml(); #endif #if defined(MEDIAINFO_OTHERTEXT_YES) else if (Parser==__T("OtherText")) Info=new File_OtherText(); #endif // Image #if defined(MEDIAINFO_ARRIRAW_YES) else if (Parser==__T("Arri Raw")) Info=new File_ArriRaw(); #endif #if defined(MEDIAINFO_BMP_YES) else if (Parser==__T("Bmp")) Info=new File_Bmp(); #endif #if defined(MEDIAINFO_BPG_YES) else if (Parser==__T("Bpg")) Info=new File_Bpg(); #endif #if defined(MEDIAINFO_DDS_YES) else if (Parser==__T("Dds")) Info=new File_Dds(); #endif #if defined(MEDIAINFO_DPX_YES) else if (Parser==__T("Dpx")) Info=new File_Dpx(); #endif #if defined(MEDIAINFO_EXR_YES) else if (Parser==__T("Exr")) Info=new File_Exr(); #endif #if defined(MEDIAINFO_GIF_YES) else if (Parser==__T("Gif")) Info=new File_Gif(); #endif #if defined(MEDIAINFO_ICO_YES) else if (Parser==__T("Ico")) Info=new File_Ico(); #endif #if defined(MEDIAINFO_JPEG_YES) else if (Parser==__T("Jpeg")) Info=new File_Jpeg(); #endif #if defined(MEDIAINFO_PCX_YES) else if (Parser==__T("PCX")) Info=new File_Pcx(); #endif #if defined(MEDIAINFO_PNG_YES) else if (Parser==__T("Png")) Info=new File_Png(); #endif #if defined(MEDIAINFO_PSD_YES) else if (Parser==__T("Psd")) Info=new File_Psd(); #endif #if defined(MEDIAINFO_TIFF_YES) else if (Parser==__T("Tiff")) Info=new File_Tiff(); #endif #if defined(MEDIAINFO_TGA_YES) else if (Parser==__T("Tga")) Info=new File_Tga(); #endif // Archive #if defined(MEDIAINFO_7Z_YES) else if (Parser==__T("7z")) Info=new File_7z(); #endif #if defined(MEDIAINFO_ACE_YES) else if (Parser==__T("Ace")) Info=new File_Ace(); #endif #if defined(MEDIAINFO_BZIP2_YES) else if (Parser==__T("Bzip2")) Info=new File_Bzip2(); #endif #if defined(MEDIAINFO_ELF_YES) else if (Parser==__T("Elf")) Info=new File_Elf(); #endif #if defined(MEDIAINFO_GZIP_YES) else if (Parser==__T("Gzip")) Info=new File_Gzip(); #endif #if defined(MEDIAINFO_ISO9660_YES) else if (Parser==__T("Iso9660")) Info=new File_Iso9660(); #endif #if defined(MEDIAINFO_MZ_YES) else if (Parser==__T("Mz")) Info=new File_Mz(); #endif #if defined(MEDIAINFO_RAR_YES) else if (Parser==__T("Rar")) Info=new File_Rar(); #endif #if defined(MEDIAINFO_TAR_YES) else if (Parser==__T("Tar")) Info=new File_Tar(); #endif #if defined(MEDIAINFO_ZIP_YES) else if (Parser==__T("Zip")) Info=new File_Zip(); #endif // Other #if defined(MEDIAINFO_OTHER_YES) else if (Parser==__T("Other")) Info=new File_Other(); #endif //No parser else return false; return true; } //--------------------------------------------------------------------------- #if defined(MEDIAINFO_FILE_YES) int MediaInfo_Internal::ListFormats(const String &File_Name) { // Multiple #if defined(MEDIAINFO_AAF_YES) delete Info; Info=new File_Aaf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_BDAV_YES) delete Info; Info=new File_MpegTs(); ((File_MpegTs*)Info)->BDAV_Size=4; if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; delete Info; Info=new File_MpegTs(); ((File_MpegTs*)Info)->BDAV_Size=4; ((File_MpegTs*)Info)->NoPatPmt=true; if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_BDMV_YES) delete Info; Info=new File_Bdmv(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_CDXA_YES) delete Info; Info=new File_Cdxa(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DASHMPD_YES) delete Info; Info=new File_DashMpd(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DCP_YES) delete Info; Info=new File_DcpAm(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DCP_YES) delete Info; Info=new File_DcpCpl(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DCP_YES) delete Info; Info=new File_DcpPkl(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DVDIF_YES) delete Info; Info=new File_DvDif(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DVDV_YES) delete Info; Info=new File_Dvdv(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DXW_YES) delete Info; Info=new File_Dxw(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_FLV_YES) delete Info; Info=new File_Flv(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_GXF_YES) delete Info; Info=new File_Gxf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_HDSF4M_YES) delete Info; Info=new File_HdsF4m(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_HLS_YES) delete Info; Info=new File_Hls(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_IBI_YES) delete Info; Info=new File_Ibi(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_ISM_YES) delete Info; Info=new File_Ism(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_IVF_YES) delete Info; Info=new File_Ivf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_LXF_YES) delete Info; Info=new File_Lxf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_MK_YES) delete Info; Info=new File_Mk(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_MIXML_YES) delete Info; Info=new File_MiXml(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_MPEG4_YES) delete Info; Info=new File_Mpeg4(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_MPEGPS_YES) delete Info; Info=new File_MpegPs(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_MPEGTS_YES) delete Info; Info=new File_MpegTs(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; delete Info; Info=new File_MpegTs(); ((File_MpegTs*)Info)->NoPatPmt=true; if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_MPLI_YES) delete Info; Info=new File_Mpli(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_MXF_YES) delete Info; Info=new File_Mxf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_NUT_YES) delete Info; Info=new File_Nut(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_OGG_YES) delete Info; Info=new File_Ogg(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_P2_YES) delete Info; Info=new File_P2_Clip(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_PMP_YES) delete Info; Info=new File_Pmp(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_PTX_YES) delete Info; Info=new File_Ptx(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_RIFF_YES) delete Info; Info=new File_Riff(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_RM_YES) delete Info; Info=new File_Rm(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_SEQUENCEINFO_YES) delete Info; Info=new File_SequenceInfo(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_SKM_YES) delete Info; Info=new File_Skm(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_SWF_YES) delete Info; Info=new File_Swf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_TSP_YES) delete Info; Info=new File_MpegTs(); ((File_MpegTs*)Info)->TSP_Size=16; if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; delete Info; Info=new File_MpegTs(); ((File_MpegTs*)Info)->TSP_Size=16; ((File_MpegTs*)Info)->NoPatPmt=true; if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_WM_YES) delete Info; Info=new File_Wm(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_WTV_YES) delete Info; Info=new File_Wtv(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_XDCAM_YES) delete Info; Info=new File_Xdcam_Clip(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DPG_YES) delete Info; Info=new File_Dpg(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif // Video #if defined(MEDIAINFO_AV1_YES) delete Info; Info=new File_Av1(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_AVC_YES) delete Info; Info=new File_Avc(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_HEVC_YES) delete Info; Info=new File_Hevc(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_AVSV_YES) delete Info; Info=new File_AvsV(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DIRAC_YES) delete Info; Info=new File_Dirac(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_FLIC_YES) delete Info; Info=new File_Flic(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_H263_YES) //delete Info; Info=new File_H263(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; //At the end, too much sensible #endif #if defined(MEDIAINFO_MPEG4V_YES) delete Info; Info=new File_Mpeg4v(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_MPEGV_YES) delete Info; Info=new File_Mpegv(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_VC1_YES) delete Info; Info=new File_Vc1(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_VC3_YES) delete Info; Info=new File_Vc3(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_Y4M_YES) delete Info; Info=new File_Y4m(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif // Audio #if defined(MEDIAINFO_AAC_YES) delete Info; Info=new File_Aac(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_AC3_YES) delete Info; Info=new File_Ac3(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_AC4_YES) delete Info; Info=new File_Ac4(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_SMPTEST0337_YES) delete Info; Info=new File_SmpteSt0337(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_ALS_YES) delete Info; Info=new File_Als(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_AMR_YES) delete Info; Info=new File_Amr(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_AMV_YES) delete Info; Info=new File_Amv(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_APE_YES) delete Info; Info=new File_Ape(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_AU_YES) delete Info; Info=new File_Au(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_CAF_YES) delete Info; Info=new File_Caf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DSF_YES) delete Info; Info=new File_Dsf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DSDIFF_YES) delete Info; Info=new File_Dsdiff(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DTS_YES) delete Info; Info=new File_Dts(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif // Too many false-positives // #if defined(MEDIAINFO_DOLBYE_YES) // delete Info; Info=new File_DolbyE(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; // #endif #if defined(MEDIAINFO_FLAC_YES) delete Info; Info=new File_Flac(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_IT_YES) delete Info; Info=new File_ImpulseTracker(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_LA_YES) delete Info; Info=new File_La(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_MIDI_YES) delete Info; Info=new File_Midi(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_MOD_YES) delete Info; Info=new File_Module(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_MPC_YES) delete Info; Info=new File_Mpc(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_MPCSV8_YES) delete Info; Info=new File_MpcSv8(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_MPEGA_YES) delete Info; Info=new File_Mpega(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_OPENMG_YES) delete Info; Info=new File_OpenMG(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_RKAU_YES) delete Info; Info=new File_Rkau(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_TAK_YES) delete Info; Info=new File_Tak(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_S3M_YES) delete Info; Info=new File_ScreamTracker3(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_TTA_YES) delete Info; Info=new File_Tta(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_TWINVQ_YES) delete Info; Info=new File_TwinVQ(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_WVPK_YES) delete Info; Info=new File_Wvpk(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_XM_YES) delete Info; Info=new File_ExtendedModule(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif // Text #if defined(MEDIAINFO_N19_YES) delete Info; Info=new File_N19(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_PDF_YES) delete Info; Info=new File_Pdf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_SCC_YES) delete Info; Info=new File_Scc(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_SDP_YES) delete Info; Info=new File_Sdp(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_SUBRIP_YES) delete Info; Info=new File_SubRip(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_TELETEXT_YES) delete Info; Info=new File_Teletext(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_TTML_YES) delete Info; Info=new File_Ttml(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_OTHERTEXT_YES) delete Info; Info=new File_OtherText(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif // Image #if defined(MEDIAINFO_ARRIRAW_YES) delete Info; Info=new File_ArriRaw(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_BMP_YES) delete Info; Info=new File_Bmp(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_BPG_YES) delete Info; Info=new File_Bpg(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DDS_YES) delete Info; Info=new File_Dds(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DPX_YES) delete Info; Info=new File_Dpx(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_GIF_YES) delete Info; Info=new File_Gif(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_ICO_YES) delete Info; Info=new File_Ico(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_JPEG_YES) delete Info; Info=new File_Jpeg(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_PCX_YES) delete Info; Info=new File_Pcx(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_PNG_YES) delete Info; Info=new File_Png(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_PSD_YES) delete Info; Info=new File_Psd(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_TIFF_YES) delete Info; Info=new File_Tiff(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_TGA_YES) //delete Info; Info=new File_Tga(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; //At the end, too much sensible #endif // Archive #if defined(MEDIAINFO_ACE_YES) delete Info; Info=new File_Ace(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_7Z_YES) delete Info; Info=new File_7z(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_BZIP2_YES) delete Info; Info=new File_Bzip2(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_ELF_YES) delete Info; Info=new File_Elf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_GZIP_YES) delete Info; Info=new File_Gzip(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_ISO9660_YES) delete Info; Info=new File_Iso9660(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_MZ_YES) delete Info; Info=new File_Mz(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_RAR_YES) delete Info; Info=new File_Rar(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_TAR_YES) delete Info; Info=new File_Tar(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_ZIP_YES) delete Info; Info=new File_Zip(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif // Other #if !defined(MEDIAINFO_OTHER_NO) delete Info; Info=new File_Other(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif //At the end, too much sensible #if defined(MEDIAINFO_TGA_YES) delete Info; Info=new File_Tga(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; //At the end, too much sensible #endif #if defined(MEDIAINFO_H263_YES) delete Info; Info=new File_H263(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif // Default (empty) delete Info; Info=new File_Unknown(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; return 0; } #endif //!defined(MEDIAINFO_FILE_YES) //--------------------------------------------------------------------------- bool MediaInfo_Internal::LibraryIsModified () { #if defined(MEDIAINFO_MULTI_NO) || defined(MEDIAINFO_VIDEO_NO) || defined(MEDIAINFO_AUDIO_NO) || defined(MEDIAINFO_TEXT_NO) || defined(MEDIAINFO_IMAGE_NO) || defined(MEDIAINFO_ARCHIVE_NO) \ || defined(MEDIAINFO_BDAV_NO) || defined(MEDIAINFO_MK_NO) || defined(MEDIAINFO_OGG_NO) || defined(MEDIAINFO_RIFF_NO) || defined(MEDIAINFO_MPEG4_NO) || defined(MEDIAINFO_MPEGPS_NO) || defined(MEDIAINFO_MPEGTS_NO) || defined(MEDIAINFO_DXW_NO) || defined(MEDIAINFO_FLV_NO) || defined(MEDIAINFO_GXF_NO) || defined(MEDIAINFO_HDSF4M_NO) || defined(MEDIAINFO_HLS_NO) || defined(MEDIAINFO_ISM_NO) || defined(MEDIAINFO_IVF_NO) || defined(MEDIAINFO_LXF_NO) || defined(MEDIAINFO_SWF_NO) || defined(MEDIAINFO_MXF_NO) || defined(MEDIAINFO_NUT_NO) || defined(MEDIAINFO_WM_NO) || defined(MEDIAINFO_WTV_NO) || defined(MEDIAINFO_QT_NO) || defined(MEDIAINFO_RM_NO) || defined(MEDIAINFO_DVDIF_NO) || defined(MEDIAINFO_DVDV_NO) || defined(MEDIAINFO_AAF_NO) || defined(MEDIAINFO_CDXA_NO) || defined(MEDIAINFO_DPG_NO) || defined(MEDIAINFO_TSP_NO) \ || defined(MEDIAINFO_AV1_NO) || defined(MEDIAINFO_AVC_NO) || defined(MEDIAINFO_AVSV_NO) || defined(MEDIAINFO_HEVC_NO) || defined(MEDIAINFO_MPEG4V_NO) || defined(MEDIAINFO_MPEGV_NO) || defined(MEDIAINFO_FLIC_NO) || defined(MEDIAINFO_THEORA_NO) || defined(MEDIAINFO_Y4M_NO) \ || defined(MEDIAINFO_AC3_NO) || defined(MEDIAINFO_AC4_NO) || defined(MEDIAINFO_ADIF_NO) || defined(MEDIAINFO_ADTS_NO) || defined(MEDIAINFO_SMPTEST0337_NO) || defined(MEDIAINFO_AMR_NO) || defined(MEDIAINFO_DTS_NO) || defined(MEDIAINFO_DOLBYE_NO) || defined(MEDIAINFO_FLAC_NO) || defined(MEDIAINFO_APE_NO) || defined(MEDIAINFO_MPC_NO) || defined(MEDIAINFO_MPCSV8_NO) || defined(MEDIAINFO_MPEGA_NO) || defined(MEDIAINFO_OPENMG_NO) || defined(MEDIAINFO_TWINVQ_NO) || defined(MEDIAINFO_XM_NO) || defined(MEDIAINFO_MOD_NO) || defined(MEDIAINFO_S3M_NO) || defined(MEDIAINFO_IT_NO) || defined(MEDIAINFO_SPEEX_NO) || defined(MEDIAINFO_TAK_NO) || defined(MEDIAINFO_PS2A_NO) \ || defined(MEDIAINFO_CMML_NO) || defined(MEDIAINFO_KATE_NO) || defined(MEDIAINFO_PGS_NO) || defined(MEDIAINFO_OTHERTEXT_NO) \ || defined(MEDIAINFO_ARRIRAW_NO) || defined(MEDIAINFO_BMP_NO) || defined(MEDIAINFO_DDS_NO) || defined(MEDIAINFO_DPX_NO) || defined(MEDIAINFO_EXR_NO) || defined(MEDIAINFO_GIF_NO) || defined(MEDIAINFO_ICO_NO) || defined(MEDIAINFO_JPEG_NO) || defined(MEDIAINFO_PNG_NO) || defined(MEDIAINFO_TGA_NO) || defined(MEDIAINFO_TIFF_NO) \ || defined(MEDIAINFO_7Z_NO) || defined(MEDIAINFO_ZIP_NO) || defined(MEDIAINFO_RAR_NO) || defined(MEDIAINFO_ACE_NO) || defined(MEDIAINFO_ELF_NO) || defined(MEDIAINFO_MZ_NO) \ || defined(MEDIAINFO_OTHER_NO) || defined(MEDIAINFO_DUMMY_NO) return true; #else return false; #endif } //--------------------------------------------------------------------------- void MediaInfo_Internal::CreateDummy (const String&) { #if defined(MEDIAINFO_DUMMY_YES) Info=new File_Dummy(); ((File_Dummy*)Info)->KindOfDummy=Value; #endif } } //NameSpace
pavel-pimenov/flylinkdc-r5xx
MediaInfoLib/Source/MediaInfo/MediaInfo_File.cpp
C++
gpl-2.0
51,680
<?php /************************************************************************************* * avisynth.php * -------- * Author: Ryan Jones (sciguyryan@gmail.com) * Copyright: (c) 2008 Ryan Jones * Release Version: 1.0.8.10 * Date Started: 2008/10/08 * * AviSynth language file for GeSHi. * * CHANGES * ------- * 2008/10/08 (1.0.8.1) * - First Release * * TODO (updated 2008/10/08) * ------------------------- * * There are also some special words that can't currently be specified directly in GeSHi as they may * also be used as variables which would really mess things up. * * Also there is an issue with the escape character as this language uses a muti-character escape system. Escape char should be """ but has been left * as empty due to this restiction. * ************************************************************************************* * * This file is part of GeSHi. * * GeSHi 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. * * GeSHi 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 GeSHi; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ************************************************************************************/ $language_data = array ( 'LANG_NAME' => 'AviSynth', 'COMMENT_SINGLE' => array(1 => '#'), 'COMMENT_MULTI' => array('/*' => '*/', '[*' => '*]'), 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, 'QUOTEMARKS' => array('"'), 'ESCAPE_CHAR' => '', 'KEYWORDS' => array( // Reserved words. 1 => array( 'try', 'cache', 'function', 'global', 'return' ), // Constants / special variables. 2 => array( 'true', 'yes', 'false', 'no', '__END__' ), // Internal Filters. 3 => array( 'AviSource', 'AviFileSource', 'AddBorders', 'AlignedSplice', 'AssumeFPS', 'AssumeScaledFPS', 'AssumeFrameBased', 'AssumeFieldBased', 'AssumeBFF', 'AssumeTFF', 'Amplify', 'AmplifydB', 'AssumeSampleRate', 'AudioDub', 'AudioDubEx', 'Animate', 'ApplyRange', 'BicubicResize', 'BilinearResize', 'BlackmanResize', 'Blur', 'Bob', 'BlankClip', 'Blackness', 'ColorYUV', 'ConvertBackToYUY2', 'ConvertToRGB', 'ConvertToRGB24', 'ConvertToRGB32', 'ConvertToYUY2', 'ConvertToY8', 'ConvertToYV411', 'ConvertToYV12', 'ConvertToYV16', 'ConvertToYV24', 'ColorKeyMask', 'Crop', 'CropBottom', 'ChangeFPS', 'ConvertFPS', 'ComplementParity', 'ConvertAudioTo8bit', 'ConvertAudioTo16bit', 'ConvertAudioTo24bit', 'ConvertAudioTo32bit', 'ConvertAudioToFloat', 'ConvertToMono', 'ConditionalFilter', 'ConditionalReader', 'ColorBars', 'Compare', 'DirectShowSource', 'DeleteFrame', 'Dissolve', 'DuplicateFrame', 'DoubleWeave', 'DelayAudio', 'EnsureVBRMP3Sync', 'FixLuminance', 'FlipHorizontal', 'FlipVertical', 'FixBrokenChromaUpsampling', 'FadeIn0', 'FadeIn', 'FadeIn2', 'FadeOut0', 'FadeOut', 'FadeOut2', 'FadeIO0', 'FadeIO', 'FadeIO2', 'FreezeFrame', 'FrameEvaluate', 'GreyScale', 'GaussResize', 'GeneralConvolution', 'GetChannel', 'GetLeftChannel', 'GetRightChannel', 'HorizontalReduceBy2', 'Histogram', 'ImageReader', 'ImageSource', 'ImageWriter', 'Invert', 'Interleave', 'Info', 'KillAudio', 'KillVideo', 'Levels', 'Limiter', 'Layer', 'Letterbox', 'LanczosResize', 'Lanczos4Resize', 'Loop', 'MergeARGB', 'MergeRGB', 'MergeChroma', 'MergeLuma', 'Merge', 'Mask', 'MaskHS', 'MergeChannels', 'MixAudio', 'MonoToStereo', 'MessageClip', 'Normalize', 'OpenDMLSource', 'Overlay', 'PointResize', 'PeculiarBlend', 'Pulldown', 'RGBAdjust', 'ResetMask', 'Reverse', 'ResampleAudio', 'ReduceBy2', 'SegmentedAviSource', 'SegmentedDirectShowSource', 'SoundOut', 'ShowAlpha', 'ShowRed', 'ShowGreen', 'ShowBlue', 'SwapUV', 'Subtract', 'SincResize', 'Spline16Resize', 'Spline36Resize', 'Spline64Resize', 'SelectEven', 'SelectOdd', 'SelectEvery', 'SelectRangeEvery', 'Sharpen', 'SpatialSoften', 'SeparateFields', 'ShowFiveVersions', 'ShowFrameNumber', 'ShowSMPTE', 'ShowTime', 'StackHorizontal', 'StackVertical', 'Subtitle', 'SwapFields', 'SuperEQ', 'SSRC', 'ScriptClip', 'Tweak', 'TurnLeft', 'TurnRight', 'Turn180', 'TemporalSoften', 'TimeStretch', 'TCPServer', 'TCPSource', 'Trim', 'Tone', 'UToY', 'UToY8', 'UnalignedSplice', 'VToY', 'VToY8', 'VerticalReduceBy2', 'Version', 'WavSource', 'Weave', 'WriteFile', 'WriteFileIf', 'WriteFileStart', 'WriteFileEnd', 'YToUV' ), // Internal functions. 4 => array( 'Abs', 'Apply', 'Assert', 'AverageLuma', 'AverageChromaU', 'AverageChromaV', 'Ceil', 'Cos', 'Chr', 'ChromaUDifference', 'ChromaVDifference', 'Defined', 'Default', 'Exp', 'Exist', 'Eval', 'Floor', 'Frac', 'Float', 'Findstr', 'GetMTMode', 'HexValue', 'Int', 'IsBool', 'IsClip', 'IsFloat', 'IsInt', 'IsString', 'Import', 'LoadPlugin', 'Log', 'LCase', 'LeftStr', 'LumaDifference', 'LoadVirtualDubPlugin', 'LoadVFAPIPlugin', 'LoadCPlugin', 'Load_Stdcall_Plugin', 'Max', 'MulDiv', 'MidStr', 'NOP', 'OPT_AllowFloatAudio', 'OPT_UseWaveExtensible', 'Pi', 'Pow', 'Round', 'Rand', 'RevStr', 'RightStr', 'RGBDifference', 'RGBDifferenceFromPrevious', 'RGBDifferenceToNext', 'Sin', 'Sqrt', 'Sign', 'Spline', 'StrLen', 'String', 'Select', 'SetMemoryMax', 'SetWorkingDir', 'SetMTMode', 'SetPlanarLegacyAlignment', 'Time', 'UCase', 'UDifferenceFromPrevious', 'UDifferenceToNext', 'UPlaneMax', 'UPlaneMin', 'UPlaneMedian', 'UPlaneMinMaxDifference', 'Value', 'VersionNumber', 'VersionString', 'VDifferenceFromPrevious', 'VDifferenceToNext', 'VPlaneMax', 'VPlaneMin', 'VPlaneMedian', 'VPlaneMinMaxDifference', 'YDifferenceFromPrevious', 'YDifferenceToNext', 'YPlaneMax', 'YPlaneMin', 'YPlaneMedian', 'YPlaneMinMaxDifference' ) ), 'SYMBOLS' => array( '+', '++', '-', '--', '/', '*', '%', '=', '==', '<', '<=', '>', '>=', '<>', '!=', '!', '?', ':', '|', '||', '&&', '\\', '(', ')', '{', '}', '.', ',' ), 'CASE_SENSITIVE' => array( GESHI_COMMENTS => false, 1 => false, 2 => false, 3 => false, 4 => true, ), 'STYLES' => array( 'KEYWORDS' => array( 1 => 'color:#9966CC; font-weight:bold;', 2 => 'color:#0000FF; font-weight:bold;', 3 => 'color:#CC3300; font-weight:bold;', 4 => 'color:#660000; font-weight:bold;' ), 'COMMENTS' => array( 1 => 'color:#008000; font-style:italic;', 'MULTI' => 'color:#000080; font-style:italic;' ), 'ESCAPE_CHAR' => array( 0 => 'color:#000099;' ), 'BRACKETS' => array( 0 => 'color:#006600; font-weight:bold;' ), 'STRINGS' => array( 0 => 'color:#996600;' ), 'NUMBERS' => array( 0 => 'color:#006666;' ), 'METHODS' => array( 1 => 'color:#9900CC;' ), 'SYMBOLS' => array( 0 => 'color:#006600; font-weight:bold;' ), 'REGEXPS' => array( ), 'SCRIPT' => array( ) ), 'URLS' => array( 1 => '', 2 => '', 3 => 'http://avisynth.org/mediawiki/{FNAME}', 4 => '' ), 'REGEXPS' => array( ), 'OOLANG' => true, 'OBJECT_SPLITTERS' => array( 1 => '.' ), 'STRICT_MODE_APPLIES' => GESHI_MAYBE, 'SCRIPT_DELIMITERS' => array( ), 'HIGHLIGHT_STRICT_BLOCK' => array( ), 'TAB_WIDTH' => 4 ); ?>
deleomotosho/iamdele.com
wp-content/plugins/codecolorer/lib/geshi/avisynth.php
PHP
gpl-2.0
8,866
/*global describe, it */ define( ["underscore", "jquery", "utils/date"], function (_, $, date) { describe("date", function () { describe("formatYearAsTimestamp", function () { it("should pad the year so it is 4 digits when the year is < 100AD", function () { date.formatYearAsTimestamp(99, "").should.equal("0099"); }); it("should pad the year so it is 4 digits when the year is < 1000AD", function () { date.formatYearAsTimestamp(999, "").should.equal("0999"); }); it("should format the year appropriately when it is BC", function () { date.formatYearAsTimestamp(-48, "").should.equal("0048 BC"); }); }); }); } );
twistedvisions/anaximander
test/webapp/utils/date.js
JavaScript
gpl-2.0
721
package org.dcu.net; /** * Interface for http callback. * @author Brendan Dodd */ public interface CallbackListener { public void onComplete(String jsonResponse); }
ubjelly/DCU
src/org/dcu/net/CallbackListener.java
Java
gpl-2.0
174
<div class="announce instapaper_body rdoc" data-path="README.rdoc" id="readme"><article class="markdown-body entry-content" itemprop="mainContentOfPage"> <h1> <a name="user-content-mechanize-" class="anchor" href="#mechanize-" aria-hidden="true"><span class="octicon octicon-link"></span></a>Mechanize <a href="http://travis-ci.org/sparklemotion/mechanize"><img src="https://camo.githubusercontent.com/5541688642efe00ff56263f4c1d7cf7f71674d04/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f737061726b6c656d6f74696f6e2f6d656368616e697a652e706e673f72766d3d312e392e33" data-canonical-src="https://secure.travis-ci.org/sparklemotion/mechanize.png?rvm=1.9.3" style="max-width:100%;"></a> </h1> <ul> <li> <p><a href="http://docs.seattlerb.org/mechanize">docs.seattlerb.org/mechanize</a></p> </li> <li> <p><a href="https://github.com/sparklemotion/mechanize">github.com/sparklemotion/mechanize</a></p> </li> </ul><h2> <a name="user-content-description" class="anchor" href="#description" aria-hidden="true"><span class="octicon octicon-link"></span></a>Description</h2> <p>The Mechanize library is used for automating interaction with websites. Mechanize automatically stores and sends cookies, follows redirects, and can follow links and submit forms. Form fields can be populated and submitted. Mechanize also keeps track of the sites that you have visited as a history.</p> <h2> <a name="user-content-dependencies" class="anchor" href="#dependencies" aria-hidden="true"><span class="octicon octicon-link"></span></a>Dependencies</h2> <ul> <li> <p>ruby 1.9.2 or newer</p> </li> <li> <p><a href="http://nokogiri.rubyforge.org">nokogiri</a></p> </li> </ul><h2> <a name="user-content-support" class="anchor" href="#support" aria-hidden="true"><span class="octicon octicon-link"></span></a>Support:</h2> <p>The bug tracker is available here:</p> <ul><li> <p><a href="https://github.com/sparklemotion/mechanize/issues">github.com/sparklemotion/mechanize/issues</a></p> </li></ul><h2> <a name="user-content-examples" class="anchor" href="#examples" aria-hidden="true"><span class="octicon octicon-link"></span></a>Examples</h2> <p>If you are just starting, check out the <a href="http://docs.seattlerb.org/mechanize/GUIDE_rdoc.html">GUIDE</a> or the <a href="http://docs.seattlerb.org/mechanize/EXAMPLES_rdoc.html">EXAMPLES</a> file.</p> <h2> <a name="user-content-developers" class="anchor" href="#developers" aria-hidden="true"><span class="octicon octicon-link"></span></a>Developers</h2> <p>To run the tests for the first time:</p> <pre>bundle install</pre> <p>This will install all the required dependencies for running the tests. For subsequent test runs:</p> <pre>rake test</pre> <p>You can also use <tt>autotest</tt> from the ZenTest gem to run tests.</p> <p>See also Mechanize::TestCase to read about the built-in testing infrastructure.</p> <h2> <a name="user-content-authors" class="anchor" href="#authors" aria-hidden="true"><span class="octicon octicon-link"></span></a>Authors</h2> <p>Copyright © 2005 by Michael Neumann (mneumann@ntecs.de)</p> <p>Copyright © 2006-2011:</p> <ul> <li> <p><a href="http://tenderlovemaking.com">Aaron Patterson</a> (aaronp@rubyforge.org)</p> </li> <li> <p><a href="http://mike.daless.io">Mike Dalessio</a> (mike@csa.net)</p> </li> </ul><p>Copyright © 2011-2013:</p> <ul> <li> <p><a href="http://blog.segment7.net">Eric Hodel</a> (drbrain@segment7.net)</p> </li> <li> <p><a href="http://blog.akinori.org">Akinori MUSHA</a> (knu@idaemons.org)</p> </li> <li> <p><a href="http://twitter.com/lee_jarvis">Lee Jarvis</a> (ljjarvis@gmail.com)</p> </li> </ul><p>This library comes with a shameless plug for employing me (<a href="http://tenderlovemaking.com/">Aaron</a>) programming Ruby, my favorite language!</p> <h2> <a name="user-content-acknowledgments" class="anchor" href="#acknowledgments" aria-hidden="true"><span class="octicon octicon-link"></span></a>Acknowledgments</h2> <p>This library was heavily influenced by its namesake in the Perl world. A big thanks goes to <a href="http://petdance.com">Andy Lester</a>, the author of the original Perl module WWW::Mechanize which is available <a href="http://search.cpan.org/dist/WWW-Mechanize/">here</a>. Ruby Mechanize would not be around without you!</p> <p>Thank you to Michael Neumann for starting the Ruby version. Thanks to everyone who's helped out in various ways. Finally, thank you to the people using this library!</p> <h2> <a name="user-content-license" class="anchor" href="#license" aria-hidden="true"><span class="octicon octicon-link"></span></a>License</h2> <p>This library is distributed under the MIT license. Please see the <a href="http://docs.seattlerb.org/mechanize/LICENSE_rdoc.html">LICENSE</a> file.</p></article></div>
lalo/readme-fads
readme_files/ruby/125-readme.html
HTML
gpl-2.0
4,768
/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: net command * FILE: base/applications/network/net/cmdContinue.c * PURPOSE: * * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org> */ #include "net.h" INT cmdContinue(INT argc, WCHAR **argv) { SC_HANDLE hManager = NULL; SC_HANDLE hService = NULL; SERVICE_STATUS status; INT nError = 0; INT i; if (argc != 3) { PrintResourceString(IDS_CONTINUE_SYNTAX); return 1; } for (i = 2; i < argc; i++) { if (_wcsicmp(argv[i], L"/help") == 0) { PrintResourceString(IDS_CONTINUE_HELP); return 1; } } hManager = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ENUMERATE_SERVICE); if (hManager == NULL) { printf("[OpenSCManager] Error: %ld\n", GetLastError()); nError = 1; goto done; } hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE); if (hService == NULL) { printf("[OpenService] Error: %ld\n", GetLastError()); nError = 1; goto done; } if (!ControlService(hService, SERVICE_CONTROL_CONTINUE, &status)) { printf("[ControlService] Error: %ld\n", GetLastError()); nError = 1; } done: if (hService != NULL) CloseServiceHandle(hService); if (hManager != NULL) CloseServiceHandle(hManager); return nError; } /* EOF */
GreenteaOS/Kernel
third-party/reactos/base/applications/network/net/cmdContinue.c
C
gpl-2.0
1,506
# -*- coding: utf-8 -*- # @Author: Marco Benzi <marco.benzi@alumnos.usm.cl> # @Date: 2015-06-07 19:44:12 # @Last Modified 2015-06-09 # @Last Modified time: 2015-06-09 16:07:05 # ========================================================================== # 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 3 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://www.gnu.org/licenses/>. # ========================================================================== import math """ Speed of light constant """ c = 3E8 """ Vacuum permittivity """ e0 = 8.8541E-12 """ Vacuum permeability """ u0 = 4E-7*math.pi def getEffectivePermitivity(WHratio, er): """ Returns the effective permitivity for a given W/H ratio. This function assumes that the thickenss of conductors is insignificant. Parameters: - `WHratio` : W/H ratio. - `er` : Relative permitivity of the dielectric. """ if WHratio <= 1: return (er + 1)/2 + ((1 + 12/WHratio)**(-0.5) + 0.04*(1-WHratio)**2)*(er -1)/2 else: return (er + 1)/2 + ((1 + 12/WHratio)**(-0.5))*(er -1)/2 def getAuxVarA(Zo,er): """ Returns the auxiliary variable A = (Zo)/60 * math.sqrt((er + 1)/2) + (er-1)/(er+1)*(0.23+0.11/er) This function assumes that the thickenss of conductors is insignificant. Parameters: - `Zo` : Real impedance of the line. - `er` : Relative permitivity of the dielectric. """ return (Zo)/60 * math.sqrt((er + 1)/2) + (er-1)/(er+1)*(0.23+0.11/er) def getAuxVarB(Zo,er): """ Returns the auxiliary variable B = (377*math.pi)/(2*Zo*math.sqrt(er)) This function assumes that the thickenss of conductors is insignificant. Parameters: - `Zo` : Real impedance of the line. - `er` : Relative permitivity of the dielectric. """ return (377*math.pi)/(2*Zo*math.sqrt(er)) def getWHRatioA(Zo,er): """ Returns the W/H ratio for W/H < 2. If the result is > 2, then other method should be used. This function assumes that the thickenss of conductors is insignificant. Parameters: - `Zo` : Real impedance of the line. - `er` : Relative permitivity of the dielectric. """ A = getAuxVarA(Zo,er) return (8*math.e**A)/(math.e**(2*A) - 2) def getWHRatioB(Zo,er): """ Returns the W/H ratio for W/H > 2. If the result is < 2, then other method should be used. This function assumes that the thickenss of conductors is insignificant. Parameters: - `Zo` : Real impedance of the line. - `er` : Relative permitivity of the dielectric. """ B = getAuxVarB(Zo,er) return (2/math.pi)*(B-1 - math.log(2*B - 1) + (er - 1)*(math.log(B-1) + 0.39 - 0.61/er)/(2*er)) def getCharacteristicImpedance(WHratio, ef): """ Returns the characteristic impedance of the medium, based on the effective permitivity and W/H ratio. This function assumes that the thickenss of conductors is insignificant. Parameters: - `WHratio` : W/H ratio. - `ef` : Effective permitivity of the dielectric. """ if WHratio <= 1: return (60/math.sqrt(ef))*math.log(8/WHratio + WHratio/4) else: return (120*math.pi/math.sqrt(ef))/(WHratio + 1.393 + 0.667*math.log(WHratio +1.444)) def getWHRatio(Zo,er): """ Returns the W/H ratio, after trying with the two possible set of solutions, for when W/H < 2 or else. When no solution, returns zero. This function assumes that the thickenss of conductors is insignificant. Parameters: - `Zo` : Real impedance of the line. - `er` : Relative permitivity of the dielectric. """ efa = er efb = er Zoa = Zo Zob = Zo while 1: rA = getWHRatioA(Zoa,efa) rB = getWHRatioB(Zob,efb) if rA < 2: return rA if rB > 2: return rB Zoa = math.sqrt(efa)*Zoa Zob = math.sqrt(efb)*Zob def getCorrectedWidth(W,H,t): """ For significant conductor thickness, this returns the corrected width. Paramenters: - `W` : Width - `H` : Height - `t` : Conductor thickness """ if t < H and t < W/2: if W/H <= math.pi/2: return W + (1 + math.log(2*H/t))*(t/math.pi) else: return W + (1 + math.log(4*math.pi*H/t))*(t/math.pi) else: print "The conductor is too thick!!" def getConductorLoss(W,H,t,sigma,f,Zo): """ Returns the conductor loss in [Np/m]. Parameters: - `W` : Width - `H` : Height - `t` : Conductor thickness - `sigma` : Conductance of medium - `f` : Operating frequency - `Zo` : Characteristic impedance """ We = getCorrectedWidth(W,H,t) P = 1 - (We/4/H)**2 Rs = math.sqrt((math.pi*f*u0)/sigma) Q = 1 + H/We + (math.log((2*H)/t)-t/W)*H/(We*math.pi) if W/H <= 1/(2*math.pi): return (1 + H/We + (math.log(4*pi*W/t) + t/W)*H/(math.pi*We))*(8.68*Rs*P)/(2*pi*Zo*H) elif W/H <= 2: return (8.68*Rs*P*Q)/(2*math.pi*Zo*H) else: return ((8.68*Rs*Q)/(Zo*H))*(We/H + (We/math.pi/H)/(We/2/H)+0.94)*((H/We + 2*math.log(We/2/H + 0.94)/math.pi)**(-2)) def getDielectricLoss(er,ef,tanD,f): """ Returns the dielectric loss in [dB/cm]. Paramenters: - `er` : Relative permitivity of the dielectric - `ef` : Effective permitivity - `tanD` : tan \delta - `f` : Operating frequency """ lam = c/math.sqrt(ef)/f return 27.3*(er*(ef-1)*tanD)/(lam*math.sqrt(er)*(er-1))
Lisergishnu/LTXKit
uStripDesign.py
Python
gpl-2.0
5,581
/* * arch/arm/mach-netx/generic.c * * Copyright (C) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * 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, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <linux/device.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/io.h> #include <mach/hardware.h> #include <asm/mach/map.h> #include <asm/hardware/vic.h> #include <mach/netx-regs.h> #include <asm/mach/irq.h> static struct map_desc netx_io_desc[] __initdata = { { .virtual = NETX_IO_VIRT, .pfn = __phys_to_pfn(NETX_IO_PHYS), .length = NETX_IO_SIZE, .type = MT_DEVICE } }; void __init netx_map_io(void) { iotable_init(netx_io_desc, ARRAY_SIZE(netx_io_desc)); } static struct resource netx_rtc_resources[] = { [0] = { .start = 0x00101200, .end = 0x00101220, .flags = IORESOURCE_MEM, }, }; static struct platform_device netx_rtc_device = { .name = "netx-rtc", .id = 0, .num_resources = ARRAY_SIZE(netx_rtc_resources), .resource = netx_rtc_resources, }; static struct platform_device *devices[] __initdata = { &netx_rtc_device, }; #if 0 #define DEBUG_IRQ(fmt...) printk(fmt) #else #define DEBUG_IRQ(fmt...) while (0) {} #endif static void netx_hif_demux_handler(unsigned int irq_unused, struct irq_desc *desc) { unsigned int irq = NETX_IRQ_HIF_CHAINED(0); unsigned int stat; stat = ((readl(NETX_DPMAS_INT_EN) & readl(NETX_DPMAS_INT_STAT)) >> 24) & 0x1f; while (stat) { if (stat & 1) { DEBUG_IRQ("handling irq %d\n", irq); generic_handle_irq(irq); } irq++; stat >>= 1; } } static int <<<<<<< HEAD netx_hif_irq_type(struct irq_data *d, unsigned int type) ======= netx_hif_irq_type(unsigned int _irq, unsigned int type) >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a { unsigned int val, irq; val = readl(NETX_DPMAS_IF_CONF1); <<<<<<< HEAD irq = d->irq - NETX_IRQ_HIF_CHAINED(0); ======= irq = _irq - NETX_IRQ_HIF_CHAINED(0); >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a if (type & IRQ_TYPE_EDGE_RISING) { DEBUG_IRQ("rising edges\n"); val |= (1 << 26) << irq; } if (type & IRQ_TYPE_EDGE_FALLING) { DEBUG_IRQ("falling edges\n"); val &= ~((1 << 26) << irq); } if (type & IRQ_TYPE_LEVEL_LOW) { DEBUG_IRQ("low level\n"); val &= ~((1 << 26) << irq); } if (type & IRQ_TYPE_LEVEL_HIGH) { DEBUG_IRQ("high level\n"); val |= (1 << 26) << irq; } writel(val, NETX_DPMAS_IF_CONF1); return 0; } static void <<<<<<< HEAD netx_hif_ack_irq(struct irq_data *d) { unsigned int val, irq; irq = d->irq - NETX_IRQ_HIF_CHAINED(0); ======= netx_hif_ack_irq(unsigned int _irq) { unsigned int val, irq; irq = _irq - NETX_IRQ_HIF_CHAINED(0); >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a writel((1 << 24) << irq, NETX_DPMAS_INT_STAT); val = readl(NETX_DPMAS_INT_EN); val &= ~((1 << 24) << irq); writel(val, NETX_DPMAS_INT_EN); <<<<<<< HEAD DEBUG_IRQ("%s: irq %d\n", __func__, d->irq); } static void netx_hif_mask_irq(struct irq_data *d) { unsigned int val, irq; irq = d->irq - NETX_IRQ_HIF_CHAINED(0); val = readl(NETX_DPMAS_INT_EN); val &= ~((1 << 24) << irq); writel(val, NETX_DPMAS_INT_EN); DEBUG_IRQ("%s: irq %d\n", __func__, d->irq); } static void netx_hif_unmask_irq(struct irq_data *d) { unsigned int val, irq; irq = d->irq - NETX_IRQ_HIF_CHAINED(0); val = readl(NETX_DPMAS_INT_EN); val |= (1 << 24) << irq; writel(val, NETX_DPMAS_INT_EN); DEBUG_IRQ("%s: irq %d\n", __func__, d->irq); } static struct irq_chip netx_hif_chip = { .irq_ack = netx_hif_ack_irq, .irq_mask = netx_hif_mask_irq, .irq_unmask = netx_hif_unmask_irq, .irq_set_type = netx_hif_irq_type, ======= DEBUG_IRQ("%s: irq %d\n", __func__, _irq); } static void netx_hif_mask_irq(unsigned int _irq) { unsigned int val, irq; irq = _irq - NETX_IRQ_HIF_CHAINED(0); val = readl(NETX_DPMAS_INT_EN); val &= ~((1 << 24) << irq); writel(val, NETX_DPMAS_INT_EN); DEBUG_IRQ("%s: irq %d\n", __func__, _irq); } static void netx_hif_unmask_irq(unsigned int _irq) { unsigned int val, irq; irq = _irq - NETX_IRQ_HIF_CHAINED(0); val = readl(NETX_DPMAS_INT_EN); val |= (1 << 24) << irq; writel(val, NETX_DPMAS_INT_EN); DEBUG_IRQ("%s: irq %d\n", __func__, _irq); } static struct irq_chip netx_hif_chip = { .ack = netx_hif_ack_irq, .mask = netx_hif_mask_irq, .unmask = netx_hif_unmask_irq, .set_type = netx_hif_irq_type, >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a }; void __init netx_init_irq(void) { int irq; vic_init(__io(io_p2v(NETX_PA_VIC)), 0, ~0, 0); for (irq = NETX_IRQ_HIF_CHAINED(0); irq <= NETX_IRQ_HIF_LAST; irq++) { <<<<<<< HEAD irq_set_chip_and_handler(irq, &netx_hif_chip, handle_level_irq); ======= set_irq_chip(irq, &netx_hif_chip); set_irq_handler(irq, handle_level_irq); >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a set_irq_flags(irq, IRQF_VALID); } writel(NETX_DPMAS_INT_EN_GLB_EN, NETX_DPMAS_INT_EN); <<<<<<< HEAD irq_set_chained_handler(NETX_IRQ_HIF, netx_hif_demux_handler); ======= set_irq_chained_handler(NETX_IRQ_HIF, netx_hif_demux_handler); >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a } static int __init netx_init(void) { return platform_add_devices(devices, ARRAY_SIZE(devices)); } subsys_initcall(netx_init);
Core2idiot/Kernel-Samsung-3.0...-
arch/arm/mach-netx/generic.c
C
gpl-2.0
5,845
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="incudine.css" /> <title>Incudine Command</title> </head> <body> <div id="content"> <table class="navtutor"> <tr> <th class="center">Incudine Command</th> </tr> </table> <hr> <p> Incudine is also the name of a standalone executable. Please consult the <code>INSTALL</code> file if you'd like to install it. </p> <p> Here is a basic tutorial to introduce the command. </p> <pre class="src src-sh">mkdir incudine_tut <span style="color: #b0c4de;">cd</span> !$ <span style="color: #ff7f24;"># </span><span style="color: #ff7f24;">usage</span> incudine -h <span style="color: #ff7f24;"># </span><span style="color: #ff7f24;">Simple files for the test</span> cat &gt;foo.cudo &lt;&lt;'---' (dsp! simple (freq db (env envelope) gate) (stereo (* (envelope env gate 1 #'free) (sine freq (db-&gt;linear db) 0)))) --- cat &gt;quux.rego &lt;&lt;'---' with (env1 (make-adsr .1 .09 .9 .5)) 0 simple 440 -14 env1 1 0 simple 220 -20 env1 1 0.5 simple 225 -26 env1 1 1 simple 448 -14 env1 1 3 simple 450 -20 (make-adsr 1 .2 .7 1 :curve :sin) 1 5 set-control 0 :gate 0 ---</pre> <p> Note: the package is <code>INCUDINE.SCRATCH</code> (nickname <code>SCRATCH</code>) by default. </p> <pre class="src src-sh">incudine foo.cudo -s quux.rego</pre> <p> It remembers orchestra+score in Csound, however we can use multiple files and a lisp file can contain what you want, not necessarily specific code for Incudine. A rego file (see <a href="tutorial_03.html#rego-file">Getting Start - Part 3</a>) is transformed in an intermediate lisp file containing also the code to execute the score in realtime or to write a soundfile to disk. </p> <p> We get a soundfile `quux.wav' and two FASL called `foo.fasl' and `quux.fasl'. If we run again the previous command line&#x2026; </p> <pre class="src src-sh">incudine foo.cudo -s quux.rego</pre> <p> &#x2026; the execution is faster, because we are using the compiled files. A source file is re-compiled if: </p> <ol> <li>the source is modified after the compilation</li> <li>the command line arguments before the name of the source file are changed</li> </ol> <p> There aren't options before foo.cudo, therefore it also works without re-compilation: </p> <pre class="src src-sh">incudine foo quux</pre> <p> The sound is truncated after 5 beats; we can add some padding: </p> <pre class="src src-sh">incudine foo.cudo --pad 1.2 -s quux.rego</pre> <p> and only <code>quux.rego</code> is re-compiled, because the new argument <code>`&#x2013;pad 1.2'</code> doesn't precede <code>foo.cudo</code>. </p> <p> Changing the name of the output file: </p> <pre class="src src-sh">incudine foo.cudo -o <span style="color: #ffa07a;">"battimenti zincati.wav"</span> -s quux.rego</pre> <p> Score from standard input: </p> <pre class="src src-sh">echo '0 simple 1000 -6 (make-perc .1 1.5) 1' \ | incudine foo.cudo -d 2 -s - > rego-from-stdin-1.wav cat quux.rego | incudine foo.cudo -o rego-from-stdin-2.wav -s -</pre> <p> Redirection of the audio to the standard output: </p> <pre class="src src-sh">incudine foo.cudo --pad 1.2 -o - -H ircam -F float <span style="color: #ffa07a;">\</span> -s quux.rego | sox - quux.wv</pre> <p> We can also decide to use an absolute duration for the output file: </p> <pre class="src src-sh">incudine foo.cudo -d 6.5 -s quux.rego</pre> <p> For realtime, please start Jack on Linux and set the rt priorities of Incudine. You can change them in <code>$HOME/.incudinerc</code> or use the options </p> <pre class="example"> --rt-priority prio for rt thread (default: 68) --nrt-priority prio for nrt thread (default: 60) --receiver-priority prio for receiver thread (default: 63)</pre> <p> In my case, jackd is run with <code>`-R -P70'</code>. </p> <pre class="src src-sh">incudine foo.cudo -d 6.5 -R -s quux.rego</pre> <p> We can use multiple files and switch from realtime (-R) to non-rt (-N) and vice versa. In the following example, quux is in realtime and bar writes a soundfile to disk. </p> <pre class="src src-sh">cp quux.rego bar.rego incudine foo.cudo -d 6.5 -R -s quux.rego -N -s bar.rego</pre> <p> Incudine uses Erik de Castro Lopo's libsndfile to read/write a soundfile from/to disk. </p> <pre class="src src-sh">incudine --header-type-list incudine --data-format-list</pre> <p> Header type and format of the sample are respectively `wav' (`aiff' on big endian machines) and `pcm-24'. </p> <p> The following example produces a flac file <code>quux.flac</code> </p> <pre class="src src-sh">incudine foo.cudo --pad 1.2 -H flac -s quux.rego</pre> <p> and a ogg file <code>quux.ogg</code> </p> <pre class="src src-sh">incudine foo.cudo --pad 1.2 -H ogg -F vorbis -s quux.rego</pre> <p> There is the possibility to add metadata. It is important to notice the comment in <code>sndfile.h</code>, the c header of libsndfile: </p> <blockquote> <p> &#x2026; Not all file types support this and even the file types which support one, may not support all string types. </p> </blockquote> <p> Example: </p> <pre class="src src-sh">incudine foo.cudo --pad 1.2 --title <span style="color: #ffa07a;">"Passame n'elettrodo"</span> <span style="color: #ffa07a;">\</span> --artist <span style="color: #ffa07a;">"Fabro Cadabro Band"</span> -s quux.rego sndfile-metadata-get --str-{title,artist} quux.wav</pre> <p> Often we want manipulate an input file. The next example shows how to use incudine for the convolution between two soundfiles. We put in conv.cudo the code to parse the user options and the definition of the DSP for the convolver. </p> <pre class="src src-sh">cat &gt; conv.cudo &lt;&lt;'---' (defvar *pvbuf* (let ((buf (buffer-load (read-arg 1 nil)))) (cond (buf (make-part-convolve-buffer buf 2048)) (t (msg error "Failed to open the IR") (exit 1))))) (defvar *scale* (sample (or (read-arg 2) 1))) (dsp! convolve () (with-samples ((scale *scale*)) (foreach-channel (cout (* scale (part-convolve (audio-in 0) *pvbuf*)))))) --- <span style="color: #ff7f24;"># </span><span style="color: #ff7f24;">Trivial rego file</span> <span style="color: #b0c4de;">echo</span> 0 convolve &gt; forge.rego</pre> <p> I use `&#x2013;' to separate toplevel and user options. reverb.wav is the impulse response of a stereo reverb, sampled with sample rate 96 kHz, and voice.wav is an input file. The second user option is a scale factor for the output. </p> <pre class="src src-sh">incudine conv.cudo -i voice.wav -r 96000 -s forge.rego -- reverb.wav 0.4</pre> <p> A function for the shell is immediate. </p> <pre class="src src-sh"><span style="color: #ff7f24;"># </span><span style="color: #ff7f24;">Usage: convolve inputfile irfile [scale] [srate] [pad]</span> <span style="color: #87cefa;">convolve</span>() { incudine conv.cudo -i <span style="color: #ffa07a;">"$1"</span> ${<span style="color: #eedd82;">4</span>:+-r $<span style="color: #eedd82;">4</span>} --pad ${<span style="color: #eedd82;">5</span>:-2} <span style="color: #ffa07a;">\</span> -s forge.rego -- <span style="color: #ffa07a;">"$2"</span> <span style="color: #ffa07a;">"$3"</span> ; } convolve voice.wav reverb.wav 0.4 96000 convolve voice48.wav ir48.wav 0.53 48000 2.5 <span style="color: #ff7f24;"># </span><span style="color: #ff7f24;">Remove the traces</span> <span style="color: #b0c4de;">unset</span> -f convolve</pre> <p> If you have created the incudine command with the support for LV2, you can use LV2 plugins in your scripts. A trivial example: </p> <pre class="src src-sh">cat &gt; amp.cudo &lt;&lt;'---' (lv2-&gt;vug "http://plugin.org.uk/swh-plugins/amp" swh.amp) (dsp! amp-test (gain) (stereo (swh.amp gain (white-noise 1)))) --- cat &gt; amp-test.rego &lt;&lt;'---' 0 amp-test -6 :id 1 1 set-control 1 :gain -12 2 set-control 1 :gain -4 3 set-control 1 :gain -20 4 set-control 1 :gain -5 5 free 1 --- incudine amp.cudo -s amp-test.rego</pre> <p> Another example, where a multi output plugin returns a FRAME: </p> <pre class="src src-sh">cat &gt; gverb.cudo &lt;&lt;'---' (lv2-&gt;vug "http://plugin.org.uk/swh-plugins/gverb" gverb) (dsp! gverb-test (room-size rev-time damping input-bw dry early-level tail-level scale) (frame-out (gverb room-size rev-time damping input-bw dry early-level tail-level (audio-in 0)) 2 0 scale)) --- cat &gt; gverb-test.rego &lt;&lt;'---' 0 gverb-test 80 8 0.5 0.75 -70 0 -17 .4 :id 1 3 set-controls 1 :freq .3 :dt .05 :dry -77 :rev-time 30 :tail-level -7 6 set-control 1 :rev-time 1 --- incudine gverb.cudo -i voice.wav --pad 3 -r 96000 -s gverb-test.rego</pre> <p> If you have also created the incudine command with the support for LADSPA, here is an example to use LADSPA plugins: </p> <pre class="src src-sh">cat &gt; plate-rev.cudo &lt;&lt;'---' (ladspa-&gt;vug "caps" "Plate" plate-reverb) (dsp! plate-reverb-test (trig-freq input-decay input-scale bw tail damping blend) "Test of the Plate reverb developed by Tim Goetze." (with-samples ((in (* (decay (impulse trig-freq) input-decay) (white-noise input-scale)))) ;; PLATE-REVERB returns a frame because there are two outputs. (multiple-sample-bind (l r) (plate-reverb bw tail damping blend in) (out l r)))) --- cat &gt; plate-rev-test.rego &lt;&lt;'---' 0 plate-reverb-test 4 .165 .5 .75 .5 .25 .25 2 set-controls 1 :trig-freq 1.5 :tail .8 :dumping .1 :blend .5 5 set-control 1 :trig-freq .1 8 free 1 --- incudine plate-rev.cudo -v -s plate-rev-test.rego </pre> <hr> <table class="navtutor"> <tr> <td style="width: 20%" class="left"> <a href="tutorial_01.html">Getting Started with Incudine</a> </td> <td style="width: 60%" class="center"><a href="index.html">Home</a></td> <td style="width: 20%" class="right"></td> </tr> </table> </div> <div id="postamble"> <a href="http://sourceforge.net/projects/incudine">Sourceforge project page</a> </div> </body> </html>
titola/incudine
doc/html/tutorial_cmd.html
HTML
gpl-2.0
11,311
<?php /** * 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; under version 2 * of the License (non-upgradable). * * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Copyright (c) 2021 (original work) Open Assessment Technologies SA; * * @author Sergei Mikhailov <sergei.mikhailov@taotesting.com> */ declare(strict_types=1); namespace oat\taoDeliveryRdf\test\unit\model\Delivery\DataAccess; use InvalidArgumentException; use oat\generis\test\TestCase; use oat\taoDeliveryRdf\model\Delivery\Business\Domain\DeliveryNamespace; use oat\taoDeliveryRdf\model\Delivery\DataAccess\DeliveryNamespaceRegistry; class DeliveryNamespaceRegistryTest extends TestCase { public function testDifferentDeliveryNamespace(): void { $deliveryNamespace = new DeliveryNamespace('https://taotesting.com'); $sut = new DeliveryNamespaceRegistry( new DeliveryNamespace('https://hub.taotesting.com'), $deliveryNamespace ); static::assertSame( $deliveryNamespace, $sut->get() ); } public function testNullDeliveryNamespace(): void { $sut = new DeliveryNamespaceRegistry( new DeliveryNamespace('https://hub.taotesting.com') ); static::assertNull( $sut->get() ); } public function testSameDeliveryNamespace(): void { $this->expectException(InvalidArgumentException::class); $deliveryNamespace = new DeliveryNamespace('https://taotesting.com'); new DeliveryNamespaceRegistry( clone $deliveryNamespace, $deliveryNamespace ); } }
oat-sa/extension-tao-delivery-rdf
test/unit/model/Delivery/DataAccess/DeliveryNamespaceRegistryTest.php
PHP
gpl-2.0
2,194
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Struct yard_base_unit</title> <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> <link rel="home" href="../../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> <link rel="up" href="../../../boost_units/Reference.html#header.boost.units.base_units.us.yard_hpp" title="Header &lt;boost/units/base_units/us/yard.hpp&gt;"> <link rel="prev" href="../base_uni_idm45443285482160.html" title="Struct base_unit_info&lt;us::ton_base_unit&gt;"> <link rel="next" href="../../../boost_units/Installation.html" title="Installation"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table cellpadding="2" width="100%"><tr> <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> <td align="center"><a href="../../../../../index.html">Home</a></td> <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> <td align="center"><a href="../../../../../more/index.htm">More</a></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="../base_uni_idm45443285482160.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../boost_units/Reference.html#header.boost.units.base_units.us.yard_hpp"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../../../boost_units/Installation.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> </div> <div class="refentry"> <a name="boost.units.us.yard_base_unit"></a><div class="titlepage"></div> <div class="refnamediv"> <h2><span class="refentrytitle">Struct yard_base_unit</span></h2> <p>boost::units::us::yard_base_unit</p> </div> <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../../boost_units/Reference.html#header.boost.units.base_units.us.yard_hpp" title="Header &lt;boost/units/base_units/us/yard.hpp&gt;">boost/units/base_units/us/yard.hpp</a>&gt; </span> <span class="keyword">struct</span> <a class="link" href="yard_base_unit.html" title="Struct yard_base_unit">yard_base_unit</a> <span class="special">:</span> <span class="keyword">public</span> boost::units::base_unit&lt; yard_base_unit, si::meter_base_unit::dimension_type,-501 &gt; <span class="special">{</span> <span class="comment">// <a class="link" href="yard_base_unit.html#idm45443285472304-bb">public static functions</a></span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <a class="link" href="yard_base_unit.html#idm45443285471744-bb"><span class="identifier">name</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <a class="link" href="yard_base_unit.html#idm45443285470624-bb"><span class="identifier">symbol</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span> <span class="special">}</span><span class="special">;</span></pre></div> <div class="refsect1"> <a name="idm45946261399168"></a><h2>Description</h2> <div class="refsect2"> <a name="idm45946261398752"></a><h3> <a name="idm45443285472304-bb"></a><code class="computeroutput">yard_base_unit</code> public static functions</h3> <div class="orderedlist"><ol class="orderedlist" type="1"> <li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <a name="idm45443285471744-bb"></a><span class="identifier">name</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li> <li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <a name="idm45443285470624-bb"></a><span class="identifier">symbol</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li> </ol></div> </div> </div> </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> <td align="right"><div class="copyright-footer">Copyright &#169; 2003-2008 Matthias Christian Schabel<br>Copyright &#169; 2007-2010 Steven Watanabe<p> Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) </p> </div></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="../base_uni_idm45443285482160.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../boost_units/Reference.html#header.boost.units.base_units.us.yard_hpp"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../../../boost_units/Installation.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> </div> </body> </html>
FFMG/myoddweb.piger
myodd/boost/doc/html/boost/units/us/yard_base_unit.html
HTML
gpl-2.0
6,120
<?php namespace SolidLaravel\Events; abstract class Event { // }
pdavila13/solid_laravel
app/Events/Event.php
PHP
gpl-2.0
69
#!/bin/sh if [ "$1" == "" OR "$2" == "" OR "$3" ]; then echo usage: echo " s2 LEMMA BASE FORM" sma2.plx -no-ext -lemma $1 -base $2 -form $3
oracc/oracc
misc/sma2/s2.sh
Shell
gpl-2.0
149
/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the config.tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Commercial License Agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. ** $QT_END_LICENSE$ ** ****************************************************************************/ #include <mmintrin.h> #if defined(__GNUC__) && __GNUC__ < 4 && __GNUC_MINOR__ < 3 #error GCC < 3.2 is known to create internal compiler errors with our MMX code #endif int main(int, char**) { _mm_empty(); return 0; }
librelab/qtmoko-test
qtopiacore/qt/config.tests/unix/mmx/mmx.cpp
C++
gpl-2.0
2,169
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="ru"> <head> <title>Uses of Class org.apache.poi.ss.formula.eval.NameEval (POI API Documentation)</title> <link rel="stylesheet" type="text/css" href="../../../../../../../stylesheet.css" title="Style"> </head> <body> <script type="text/javascript"><!-- if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Uses of Class org.apache.poi.ss.formula.eval.NameEval (POI API Documentation)"; } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar_top"> <!-- --> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../../../overview-summary.html">Overview</a></li> <li><a href="../package-summary.html">Package</a></li> <li><a href="../../../../../../../org/apache/poi/ss/formula/eval/NameEval.html" title="class in org.apache.poi.ss.formula.eval">Class</a></li> <li class="navBarCell1Rev">Use</li> <li><a href="../package-tree.html">Tree</a></li> <li><a href="../../../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../../../index-all.html">Index</a></li> <li><a href="../../../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="../../../../../../../index.html?org/apache/poi/ss/formula/eval/class-use/NameEval.html" target="_top">Frames</a></li> <li><a href="NameEval.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../../../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <div class="header"> <h2 title="Uses of Class org.apache.poi.ss.formula.eval.NameEval" class="title">Uses of Class<br>org.apache.poi.ss.formula.eval.NameEval</h2> </div> <div class="classUseContainer">No usage of org.apache.poi.ss.formula.eval.NameEval</div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar_bottom"> <!-- --> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../../../overview-summary.html">Overview</a></li> <li><a href="../package-summary.html">Package</a></li> <li><a href="../../../../../../../org/apache/poi/ss/formula/eval/NameEval.html" title="class in org.apache.poi.ss.formula.eval">Class</a></li> <li class="navBarCell1Rev">Use</li> <li><a href="../package-tree.html">Tree</a></li> <li><a href="../../../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../../../index-all.html">Index</a></li> <li><a href="../../../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="../../../../../../../index.html?org/apache/poi/ss/formula/eval/class-use/NameEval.html" target="_top">Frames</a></li> <li><a href="NameEval.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../../../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> <p class="legalCopy"><small> <i>Copyright 2014 The Apache Software Foundation or its licensors, as applicable.</i> </small></p> </body> </html>
setu9760/Jade_project_repo
lib/docs/apidocs/org/apache/poi/ss/formula/eval/class-use/NameEval.html
HTML
gpl-2.0
4,449
/* * drivers/cpufreq/cpufreq_darkness.c * * Copyright (C) 2011 Samsung Electronics co. ltd * ByungChang Cha <bc.cha@samsung.com> * * Based on ondemand governor * Copyright (C) 2001 Russell King * (C) 2003 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>. * Jun Nakajima <jun.nakajima@intel.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Created by Alucard_24@xda */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h> #include <linux/cpufreq.h> #include <linux/cpu.h> #include <linux/jiffies.h> #include <linux/kernel_stat.h> #include <linux/mutex.h> #include <linux/hrtimer.h> #include <linux/tick.h> #include <linux/ktime.h> #include <linux/sched.h> #include <linux/slab.h> #define MIN_SAMPLING_RATE 10000 /* * dbs is used in this file as a shortform for demandbased switching * It helps to keep variable names smaller, simpler */ static void do_darkness_timer(struct work_struct *work); struct cpufreq_darkness_cpuinfo { u64 prev_cpu_wall; u64 prev_cpu_idle; struct cpufreq_frequency_table *freq_table; struct delayed_work work; struct cpufreq_policy *cur_policy; bool governor_enabled; unsigned int cpu; /* * percpu mutex that serializes governor limit change with * do_dbs_timer invocation. We do not want do_dbs_timer to run * when user is changing the governor or limits. */ struct mutex timer_mutex; }; /* * mutex that serializes governor limit change with * do_darkness_timer invocation. We do not want do_darkness_timer to run * when user is changing the governor or limits. */ static DEFINE_PER_CPU(struct cpufreq_darkness_cpuinfo, od_darkness_cpuinfo); static unsigned int darkness_enable; /* number of CPUs using this policy */ /* * darkness_mutex protects darkness_enable in governor start/stop. */ static DEFINE_MUTEX(darkness_mutex); /* darkness tuners */ static struct darkness_tuners { unsigned int sampling_rate; unsigned int io_is_busy; } darkness_tuners_ins = { .sampling_rate = 60000, .io_is_busy = 0, }; /************************** sysfs interface ************************/ /* cpufreq_darkness Governor Tunables */ #define show_one(file_name, object) \ static ssize_t show_##file_name \ (struct kobject *kobj, struct attribute *attr, char *buf) \ { \ return sprintf(buf, "%d\n", darkness_tuners_ins.object); \ } show_one(sampling_rate, sampling_rate); show_one(io_is_busy, io_is_busy); /* sampling_rate */ static ssize_t store_sampling_rate(struct kobject *a, struct attribute *b, const char *buf, size_t count) { int input; int ret = 0; int mpd = strcmp(current->comm, "mpdecision"); if (mpd == 0) return ret; ret = sscanf(buf, "%u", &input); if (ret != 1) return -EINVAL; input = max(input,10000); if (input == darkness_tuners_ins.sampling_rate) return count; darkness_tuners_ins.sampling_rate = input; return count; } /* io_is_busy */ static ssize_t store_io_is_busy(struct kobject *a, struct attribute *b, const char *buf, size_t count) { unsigned int input, cpu; int ret; ret = sscanf(buf, "%u", &input); if (ret != 1) return -EINVAL; if (input > 1) input = 1; if (input == darkness_tuners_ins.io_is_busy) return count; darkness_tuners_ins.io_is_busy = !!input; /* we need to re-evaluate prev_cpu_idle */ get_online_cpus(); for_each_online_cpu(cpu) { struct cpufreq_darkness_cpuinfo *this_darkness_cpuinfo = &per_cpu(od_darkness_cpuinfo, cpu); this_darkness_cpuinfo->prev_cpu_idle = get_cpu_idle_time(cpu, &this_darkness_cpuinfo->prev_cpu_wall, darkness_tuners_ins.io_is_busy); } put_online_cpus(); return count; } define_one_global_rw(sampling_rate); define_one_global_rw(io_is_busy); static struct attribute *darkness_attributes[] = { &sampling_rate.attr, &io_is_busy.attr, NULL }; static struct attribute_group darkness_attr_group = { .attrs = darkness_attributes, .name = "darkness", }; /************************** sysfs end ************************/ static unsigned int adjust_cpufreq_frequency_target(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table, unsigned int tmp_freq) { unsigned int i = 0, l_freq = 0, h_freq = 0, target_freq = 0; if (tmp_freq < policy->min) tmp_freq = policy->min; if (tmp_freq > policy->max) tmp_freq = policy->max; for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { unsigned int freq = table[i].frequency; if (freq == CPUFREQ_ENTRY_INVALID) { continue; } if (freq < tmp_freq) { h_freq = freq; } if (freq == tmp_freq) { target_freq = freq; break; } if (freq > tmp_freq) { l_freq = freq; break; } } if (!target_freq) { if (policy->cur >= h_freq && policy->cur <= l_freq) target_freq = policy->cur; else target_freq = l_freq; } return target_freq; } static void darkness_check_cpu(struct cpufreq_darkness_cpuinfo *this_darkness_cpuinfo) { struct cpufreq_policy *policy; unsigned int max_load = 0; unsigned int next_freq = 0; int io_busy = darkness_tuners_ins.io_is_busy; unsigned int cpu = this_darkness_cpuinfo->cpu; unsigned int j; policy = this_darkness_cpuinfo->cur_policy; if (!policy->cur) return; for_each_cpu(j, policy->cpus) { struct cpufreq_darkness_cpuinfo *j_darkness_cpuinfo; u64 cur_wall_time, cur_idle_time; unsigned int idle_time, wall_time; unsigned int load; j_darkness_cpuinfo = &per_cpu(od_darkness_cpuinfo, j); if (!j_darkness_cpuinfo->governor_enabled) continue; cur_idle_time = get_cpu_idle_time(j, &cur_wall_time, io_busy); wall_time = (unsigned int) (cur_wall_time - j_darkness_cpuinfo->prev_cpu_wall); idle_time = (unsigned int) (cur_idle_time - j_darkness_cpuinfo->prev_cpu_idle); if (j == cpu) { j_darkness_cpuinfo->prev_cpu_wall = cur_wall_time; j_darkness_cpuinfo->prev_cpu_idle = cur_idle_time; } if (unlikely(!wall_time || wall_time < idle_time)) continue; load = 100 * (wall_time - idle_time) / wall_time; if (load > max_load) max_load = load; } cpufreq_notify_utilization(policy, max_load); /* CPUs Online Scale Frequency*/ next_freq = adjust_cpufreq_frequency_target(policy, this_darkness_cpuinfo->freq_table, max_load * (policy->max / 100)); if (next_freq != policy->cur && next_freq > 0) __cpufreq_driver_target(policy, next_freq, CPUFREQ_RELATION_L); } static void do_darkness_timer(struct work_struct *work) { struct cpufreq_darkness_cpuinfo *this_darkness_cpuinfo = container_of(work, struct cpufreq_darkness_cpuinfo, work.work); int delay; mutex_lock(&this_darkness_cpuinfo->timer_mutex); darkness_check_cpu(this_darkness_cpuinfo); delay = usecs_to_jiffies(darkness_tuners_ins.sampling_rate); /* We want all CPUs to do sampling nearly on * same jiffy */ if (num_online_cpus() > 1) { delay = max(delay - (jiffies % delay), usecs_to_jiffies(darkness_tuners_ins.sampling_rate / 2)); } mod_delayed_work_on(this_darkness_cpuinfo->cpu, system_wq, &this_darkness_cpuinfo->work, delay); mutex_unlock(&this_darkness_cpuinfo->timer_mutex); } static int cpufreq_governor_darkness(struct cpufreq_policy *policy, unsigned int event) { struct cpufreq_darkness_cpuinfo *this_darkness_cpuinfo = &per_cpu(od_darkness_cpuinfo, policy->cpu); unsigned int cpu = policy->cpu; int io_busy = darkness_tuners_ins.io_is_busy; int rc, delay; switch (event) { case CPUFREQ_GOV_START: if (!policy->cur) return -EINVAL; mutex_lock(&darkness_mutex); this_darkness_cpuinfo->freq_table = cpufreq_frequency_get_table(cpu); if (!this_darkness_cpuinfo->freq_table) { mutex_unlock(&darkness_mutex); return -EINVAL; } this_darkness_cpuinfo->cpu = cpu; this_darkness_cpuinfo->cur_policy = policy; this_darkness_cpuinfo->prev_cpu_idle = get_cpu_idle_time(cpu, &this_darkness_cpuinfo->prev_cpu_wall, io_busy); darkness_enable++; /* * Start the timerschedule work, when this governor * is used for first time */ if (darkness_enable == 1) { rc = sysfs_create_group(cpufreq_global_kobject, &darkness_attr_group); if (rc) { darkness_enable--; mutex_unlock(&darkness_mutex); return rc; } } this_darkness_cpuinfo->governor_enabled = true; mutex_unlock(&darkness_mutex); mutex_init(&this_darkness_cpuinfo->timer_mutex); delay = usecs_to_jiffies(darkness_tuners_ins.sampling_rate); /* We want all CPUs to do sampling nearly on same jiffy */ if (num_online_cpus() > 1) { delay = max(delay - (jiffies % delay), usecs_to_jiffies(darkness_tuners_ins.sampling_rate / 2)); } INIT_DEFERRABLE_WORK(&this_darkness_cpuinfo->work, do_darkness_timer); mod_delayed_work_on(cpu, system_wq, &this_darkness_cpuinfo->work, delay); break; case CPUFREQ_GOV_STOP: cancel_delayed_work_sync(&this_darkness_cpuinfo->work); mutex_lock(&darkness_mutex); mutex_destroy(&this_darkness_cpuinfo->timer_mutex); this_darkness_cpuinfo->governor_enabled = false; this_darkness_cpuinfo->cur_policy = NULL; darkness_enable--; if (!darkness_enable) { sysfs_remove_group(cpufreq_global_kobject, &darkness_attr_group); } mutex_unlock(&darkness_mutex); break; case CPUFREQ_GOV_LIMITS: mutex_lock(&this_darkness_cpuinfo->timer_mutex); if (!this_darkness_cpuinfo->cur_policy->cur || !policy->cur) { pr_debug("Unable to limit cpu freq due to cur_policy == NULL\n"); mutex_unlock(&this_darkness_cpuinfo->timer_mutex); return -EPERM; } __cpufreq_driver_target(this_darkness_cpuinfo->cur_policy, policy->cur, CPUFREQ_RELATION_L); mutex_unlock(&this_darkness_cpuinfo->timer_mutex); break; } return 0; } #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_DARKNESS static #endif struct cpufreq_governor cpufreq_gov_darkness = { .name = "darkness", .governor = cpufreq_governor_darkness, .owner = THIS_MODULE, }; static int __init cpufreq_gov_darkness_init(void) { return cpufreq_register_governor(&cpufreq_gov_darkness); } static void __exit cpufreq_gov_darkness_exit(void) { cpufreq_unregister_governor(&cpufreq_gov_darkness); } MODULE_AUTHOR("Alucard24@XDA"); MODULE_DESCRIPTION("'cpufreq_darkness' - A dynamic cpufreq/cpuhotplug governor v4.5 (SnapDragon)"); MODULE_LICENSE("GPL"); #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_DARKNESS fs_initcall(cpufreq_gov_darkness_init); #else module_init(cpufreq_gov_darkness_init); #endif module_exit(cpufreq_gov_darkness_exit);
lawnn/Dorimanx-LG-G2-D802-Kernel
drivers/cpufreq/cpufreq_darkness.c
C
gpl-2.0
10,599
/* * (C) 2007-2010 Taobao Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * * Version: $Id$ * * Authors: * duolong <duolong@taobao.com> * */ #include "tbsys.h" namespace tbsys { /* ¹¹Ô캯Êý */ CFileQueueThread::CFileQueueThread(CFileQueue* queue, int threadCount, IQueueHandler* handler, void* args) : CDefaultRunnable(threadCount) { assert(queue != NULL); _queue = queue; _handler = handler; _args = args; } /* Îö¹¹º¯Êý */ CFileQueueThread::~CFileQueueThread(void) { stop(); } /* дÈëÊý¾Ý */ int CFileQueueThread::writeData(void* data, int len) { if (data == NULL || len <= 0) { return EXIT_FAILURE; } _mutex.lock(); _queue->push(data, len); _mutex.signal(); _mutex.unlock(); return EXIT_SUCCESS; } /* Í£Ö¹ */ void CFileQueueThread::stop() { _mutex.lock(); _stop = true; _mutex.broadcast(); _mutex.unlock(); } /* ÔËÐÐÈë¿Úº¯Êý */ void CFileQueueThread::run(CThread __attribute__((unused)) *thread, void* args) { int threadIndex = (int)((long)(args)); int total_count = 0; int64_t end_time = 0; int64_t start_time = CTimeUtil::getTime(); bool dosuc = true; _mutex.lock(); while (!_stop) { while (_stop == 0 && _queue->isEmpty()) { _mutex.wait(); } if (_stop) { break; } queue_item* item = _queue->pop(threadIndex); int cnt = ++total_count; if (total_count >= 1000) { total_count = 0; end_time = CTimeUtil::getTime(); } _mutex.unlock(); if (item != NULL) { if (_handler != NULL) { _handler->handleQueue(&item->data[0], item->len, threadIndex, _args); } dosuc = true; free(item); } else { dosuc = false; } if (end_time > start_time) { TBSYS_LOG(INFO, "task execute speed: %d task/s", (int)((int64_t)1000000 * cnt / (end_time - start_time))); start_time = end_time; } _mutex.lock(); if (dosuc) _queue->finish(threadIndex); } _mutex.unlock(); } } //////////////////END
mrunix/streambase
external/tb-common-utils/tbsys/src/filequeuethread.cc
C++
gpl-2.0
2,126
#include "Python.h" #include <glib.h> #include "net_flow.hh" extern "C" { void init_net_flow(); } void _net_flow_free(void * p) { net_flow_free((NetFlow *) p); } static PyObject* new_flowobj(PyObject * self, PyObject * args) { // no args. if (!PyArg_ParseTuple(args, "")) { return NULL; } NetFlow * flow = net_flow_new(); return PyCObject_FromVoidPtr(flow, _net_flow_free); // @CTB } static PyObject * add_edge(PyObject * self, PyObject * args) { PyObject * flow_o; char * from, * to; if (!PyArg_ParseTuple(args, "Oss", &flow_o, &from, &to)) { return NULL; } NetFlow * flow = (NetFlow *) PyCObject_AsVoidPtr(flow_o); net_flow_add_edge(flow, from, to); Py_INCREF(Py_None); return Py_None; } static PyObject * calc_max_flow(PyObject * self, PyObject * args) { PyObject * flow_o, * capacities_o; char * seed_name; if (!PyArg_ParseTuple(args, "OsO", &flow_o, &seed_name, &capacities_o)) { return NULL; } if (!PyList_Check(capacities_o)) { return NULL; } int n_capacities = PyList_Size(capacities_o); int capacities[n_capacities]; for (int i = 0; i < n_capacities; i++) { PyObject * capacity_o = PyList_GetItem(capacities_o, i); int capacity = (int) PyInt_AsLong(capacity_o); capacities[i] = capacity; } NetFlow * flow = (NetFlow *) PyCObject_AsVoidPtr(flow_o); int seed_n = net_flow_find_node(flow, seed_name); net_flow_max_flow(flow, seed_n, &capacities[0], n_capacities); Py_INCREF(Py_None); return Py_None; } static PyObject * extract(PyObject * self, PyObject * args) { PyObject * flow_o; int n_nodes; if (!PyArg_ParseTuple(args, "Oi", &flow_o, &n_nodes)) { return NULL; } NetFlow * flow = (NetFlow *) PyCObject_AsVoidPtr(flow_o); int * result = net_flow_extract(flow); PyObject * result_o = PyList_New(n_nodes); for (int i = 0; i < n_nodes; i++) { PyList_SET_ITEM(result_o, i, PyInt_FromLong(result[i])); } g_free(result); return result_o; } static PyMethodDef NetFlowMethods[] = { { "new_flowobj", new_flowobj, METH_VARARGS, "create a new trust network" }, { "add_edge", add_edge, METH_VARARGS, "add an edge to the trust network" }, { "calc_max_flow", calc_max_flow, METH_VARARGS, "calculate the network flow" }, { "extract", extract, METH_VARARGS, "extract node trust information" }, { NULL, NULL, 0, NULL } }; DL_EXPORT(void) init_net_flow(void) { PyObject * m; m = Py_InitModule("_net_flow", NetFlowMethods); }
guaka/trust-metrics
trustlet/net_flow/lib/_net_flowmodule.cc
C++
gpl-2.0
2,470
/******************************************** * * * Eyüp Can KILINÇDEMİR * * KARADENİZ TEKNİK UNİVERSİTESİ * * ceksoft.wordpress.com * * eyupcankilincdemir@gmail.com * * * ********************************************/ #include <stdio.h> #include <stdlib.h> int main() { int sifreli_sayi,sayi,binler,yuzler,onlar,birler,ara_degisken; printf("Programdan cikmak icin -1 giriniz.\n"); printf("Sifrelenicek sayiyi giriniz:"); scanf("%d",&sayi); while (sayi!=-1) { binler = sayi / 1000; //sayinin binler basamagindaki rakam degiskene atanir binler = binler + 7; binler = binler % 10; yuzler = sayi / 100; //sayinin yuzler basamagindaki rakam degiskene atanir yuzler = yuzler + 7; yuzler = yuzler % 10; onlar = sayi / 10; //sayinin onlar basamagindaki rakam degiskene atanir onlar = onlar + 7; onlar = onlar % 10; birler = sayi % 10; //sayinin birler basamagindaki rakam degiskene atanir birler = birler + 7; birler = birler % 10; ara_degisken = birler; //birler basamagi yuzler basamagiyla yer degistirir birler = yuzler; yuzler = ara_degisken; ara_degisken = onlar; //onlar basamagi birler basamagiyla yer degistirir onlar = binler; binler = ara_degisken; sifreli_sayi = (1000*binler) + (100*yuzler) + (10*onlar) + (birler); //rakamlar basamak degerleriyle carpilip toplanir printf("Girdiginiz sayi %d dir Sifreli sayiniz %d dir.\n",sayi,sifreli_sayi); printf("Sifrelenicek sayiyi giriniz:"); scanf("%d",&sayi); } printf("Programdan Sonlandirilmistir."); return 0; }
EyupCan/C-codes
36-yedi_eklemeli_sifre.c
C
gpl-2.0
1,931
<?php /** * * NOTICE OF LICENSE * * This source file is subject to the GNU General Public License (GPL 2) * that is bundled with this package in the file LICENSE.txt * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Payone to newer * versions in the future. If you wish to customize Payone for your * needs please refer to http://www.payone.de for more information. * * @category Payone * @package Payone_Api * @subpackage Enum * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com * @author Matthias Walter <info@noovias.com> * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 2) * @link http://www.noovias.com */ /** * * @category Payone * @package Payone_Api * @subpackage Enum * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 2) * @link http://www.noovias.com */ class Payone_Api_Enum_AddressCheckPersonstatus { const NONE = 'NONE'; //NONE: no verification of personal data carried out const PPB = 'PPB'; //PPB: first name & surname unknown const PHB = 'PHB'; //PHB: surname known const PAB = 'PAB'; //PAB: first name & surname unknown const PKI = 'PKI'; //PKI: ambiguity in name and address const PNZ = 'PNZ'; //PNZ: cannot be delivered (any longer) const PPV = 'PPV'; //PPV: person deceased const PPF = 'PPF'; //PPF: postal address details incorrect }
carlosway89/testshop
ext/payone/php/Payone/Api/Enum/AddressCheckPersonstatus.php
PHP
gpl-2.0
1,574
# eTechBuddy eTechBuddy code repository
aryashree/eTechBuddy
README.md
Markdown
gpl-2.0
40
<?php /** * @file * page layout with header & footer markup */ ?> <?php if( theme_get_setting('mothership_poorthemers_helper') ){ ?> <!-- tpl: layout-contact.tpl.php --> <?php } ?> <?php /* Use Drupals basic markup for the backend */ if (arg(0) =="admin"){ ?> <div class="panel-display" <?php if (!empty($css_id)) { print "id=\"$css_id\""; } ?>> <div class="panel-panel panel-col-100"> <div class="inside"><?php print $content['top']; ?></div> </div> <div class="panel-panel panel-col-100"> <div class="panel-panel panel-col-33"> <div class="inside"><?php print $content['left']; ?></div> </div> <div class="panel-panel panel-col-33"> <div class="inside"><?php print $content['middle']; ?></div> </div> <div class="panel-panel panel-col-33"> <div class="inside"><?php print $content['right']; ?></div> </div> </div> <div class="panel-panel panel-col-100"> <div class="inside"><?php print $content['bottom']; ?></div> </div> </div> </div> <?php }else{ /* and a clean mean markup for the frontend w*/ ?> <?php $css_sneaky = !empty($settings['sneaky_class']) ? ' '.$settings['sneaky_class'] : ''; ?> <article class="<?php print $css_sneaky; ?>" <?php if (!empty($css_id)) { print "id=\"$css_id\""; } ?>> <?php if(!empty($variables['display']->title)){ ?> <header> <h2><?php print $variables['display']->title; ?></h2> </header> <?php } ?> <?php if(!empty($content['top'])) { ?> <div class=""><?php print $content['top']; ?></div> <?php }; ?> <div class=""><?php print $content['left']; ?></div> <div class=""><?php print $content['middle']; ?></div> <div class=""><?php print $content['right']; ?></div> <?php if(!empty($content['bottom'])) { ?> <div class=""><?php print $content['bottom']; ?></div> <?php } ?> </article> <?php } ?> <?php if( theme_get_setting('mothership_poorthemers_helper') ){ ?> <!-- / tpl: layout-contact.tpl.php --> <?php } ?>
graysadler/gvod
sites/all/themes/mothership/mothership/templates/panels/mothership-3colstacked/mothership-3colstacked.tpl.php
PHP
gpl-2.0
1,988
/** * this interface specifies the methods of a BindListener; it is only useful if you want * to develop a bus monitor (Ivy Probe, spy, ivymon) * * @author Yannick Jestin * @author <a href="http://www.tls.cena.fr/products/ivy/">http://www.tls.cena.fr/products/ivy/</a> * * Changelog: * 1.2.8 * - removed the public abstract modifiers, which are redundant */ package fr.dgac.ivy; public interface IvyBindListener extends java.util.EventListener { /** * invoked when a Ivy Client performs a bind * @param client the peer * @param id the regexp ID * @param regexp the regexp */ void bindPerformed(IvyClient client,int id, String regexp); /** * invoked when a Ivy Client performs a unbind * @param client the peer * @param id the regexp ID * @param regexp the regexp */ void unbindPerformed(IvyClient client,int id,String regexp); }
prajdheeraj/CS557Project
Code/ivy/src/IvyBindListener.java
Java
gpl-2.0
883
# contrib/pg_part/Makefile EXTENSION = pg_fkpart DATA = pg_fkpart--1.7.sql pg_fkpart--unpackaged--1.1.sql pg_fkpart--1.0--1.1.sql pg_fkpart--1.1--1.2.sql pg_fkpart--1.2--1.3.sql pg_fkpart--1.3--1.4.sql pg_fkpart--1.4--1.5.sql pg_fkpart--1.5--1.6.sql pg_fkpart--1.6--1.7.sql PG_CONFIG = pg_config PGXS := $(shell $(PG_CONFIG) --pgxs) include $(PGXS)
lemoineat/pg_fkpart
Makefile
Makefile
gpl-2.0
351
/* * NEC PC-9801 keyboard controller driver for Linux * * Copyright (c) 1999-2002 Osamu Tomita <tomita@cinet.co.jp> * Based on i8042.c written by Vojtech Pavlik */ /* * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. */ #include <linux/config.h> #include <linux/delay.h> #include <linux/module.h> #include <linux/interrupt.h> #include <linux/ioport.h> #include <linux/init.h> #include <linux/serio.h> #include <linux/sched.h> #include <asm/io.h> MODULE_AUTHOR("Osamu Tomita <tomita@cinet.co.jp>"); MODULE_DESCRIPTION("NEC PC-9801 keyboard controller driver"); MODULE_LICENSE("GPL"); /* * Names. */ #define KBD98_PHYS_DESC "isa0041/serio0" /* * IRQs. */ #define KBD98_IRQ 1 /* * Register numbers. */ #define KBD98_COMMAND_REG 0x43 #define KBD98_STATUS_REG 0x43 #define KBD98_DATA_REG 0x41 spinlock_t kbd98io_lock = SPIN_LOCK_UNLOCKED; static struct serio kbd98_port; extern struct pt_regs *kbd_pt_regs; static irqreturn_t kbd98io_interrupt(int irq, void *dev_id, struct pt_regs *regs); /* * kbd98_flush() flushes all data that may be in the keyboard buffers */ static int kbd98_flush(void) { unsigned long flags; spin_lock_irqsave(&kbd98io_lock, flags); while (inb(KBD98_STATUS_REG) & 0x02) /* RxRDY */ inb(KBD98_DATA_REG); if (inb(KBD98_STATUS_REG) & 0x38) printk("98kbd-io: Keyboard error!\n"); spin_unlock_irqrestore(&kbd98io_lock, flags); return 0; } /* * kbd98_write() sends a byte out through the keyboard interface. */ static int kbd98_write(struct serio *port, unsigned char c) { unsigned long flags; spin_lock_irqsave(&kbd98io_lock, flags); outb(0, 0x5f); /* wait */ outb(0x17, KBD98_COMMAND_REG); /* enable send command */ outb(0, 0x5f); /* wait */ outb(c, KBD98_DATA_REG); outb(0, 0x5f); /* wait */ outb(0x16, KBD98_COMMAND_REG); /* disable send command */ outb(0, 0x5f); /* wait */ spin_unlock_irqrestore(&kbd98io_lock, flags); return 0; } /* * kbd98_open() is called when a port is open by the higher layer. * It allocates the interrupt and enables in in the chip. */ static int kbd98_open(struct serio *port) { kbd98_flush(); if (request_irq(KBD98_IRQ, kbd98io_interrupt, 0, "kbd98", NULL)) { printk(KERN_ERR "98kbd-io.c: Can't get irq %d for %s, unregistering the port.\n", KBD98_IRQ, "KBD"); serio_unregister_port(port); return -1; } return 0; } static void kbd98_close(struct serio *port) { free_irq(KBD98_IRQ, NULL); kbd98_flush(); } /* * Structures for registering the devices in the serio.c module. */ static struct serio kbd98_port = { .type = SERIO_PC9800, .write = kbd98_write, .open = kbd98_open, .close = kbd98_close, .driver = NULL, .name = "PC-9801 Kbd Port", .phys = KBD98_PHYS_DESC, }; /* * kbd98io_interrupt() is the most important function in this driver - * it handles the interrupts from keyboard, and sends incoming bytes * to the upper layers. */ static irqreturn_t kbd98io_interrupt(int irq, void *dev_id, struct pt_regs *regs) { unsigned long flags; unsigned char data; spin_lock_irqsave(&kbd98io_lock, flags); data = inb(KBD98_DATA_REG); spin_unlock_irqrestore(&kbd98io_lock, flags); serio_interrupt(&kbd98_port, data, 0, regs); return IRQ_HANDLED; } int __init kbd98io_init(void) { serio_register_port(&kbd98_port); printk(KERN_INFO "serio: PC-9801 %s port at %#lx,%#lx irq %d\n", "KBD", (unsigned long) KBD98_DATA_REG, (unsigned long) KBD98_COMMAND_REG, KBD98_IRQ); return 0; } void __exit kbd98io_exit(void) { serio_unregister_port(&kbd98_port); } module_init(kbd98io_init); module_exit(kbd98io_exit);
iPodLinux/linux-2.6.7-ipod
drivers/input/serio/98kbd-io.c
C
gpl-2.0
3,749
/* Copyright (c) 2003-2011 Gordon Gremme <gremme@zbh.uni-hamburg.de> Copyright (c) 2003-2008 Center for Bioinformatics, University of Hamburg Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "gth/ags_build.h" typedef struct { GthDbl exonscore; /* the score of this exonnode */ unsigned long lengthofscoringexon; /* the length of the exon where the exonscore came from */ } Exonscoreinfo; typedef struct { /* begin of core */ GtRange range; /* the range of the exonnode */ bool leftmergeable, /* true if the left border is mergeable */ rightmergeable; /* true if the right border is mergeable */ Introninfo *successorintron; /* points to the successor intron of this exon, if defined. points to NULL, otherwise. */ /* end of core */ GtArray *exonscores; /* all exon scores of all exons, where this node resulted from */ } Exonnode; #define SAVE_EXONSCORE_ALLOWED_DIFFERENCE 30 typedef enum { MERGEABLE_LEFTSIDE_A_BEFORE_B = 0, MERGEABLE_LEFTSIDE_A_EQUALS_B, MERGEABLE_LEFTSIDE_A_AFTER_B, NON_MERGEABLE_LEFTSIDE, } Leftsidestatus; typedef enum { MERGEABLE_RIGHTSIDE_A_BEFORE_B = 0, MERGEABLE_RIGHTSIDE_A_EQUALS_B, MERGEABLE_RIGHTSIDE_A_AFTER_B, NON_MERGEABLE_RIGHTSIDE, } Rightsidestatus; /* The following function returns the core of an Exonnode. That is, the node without the pointers to the successors of this node. The input is the spliced alignment \textit{sa}, and the index <exonindex> of the exon to be processed. */ Exonnode getcoreExonnodefromSA(GthSA *sa, unsigned long exonindex) { Exonnode node; Exonscoreinfo scoreinfo; /* alignment contains at least one exon */ gt_assert(gth_sa_num_of_exons(sa)); /* number of exons minus 1 equals number of introns */ gt_assert(gth_sa_num_of_exons(sa) - 1 == gth_sa_num_of_introns(sa)); /* exonindex is valid */ gt_assert(exonindex < gth_sa_num_of_exons(sa)); node.exonscores = gt_array_new(sizeof (Exonscoreinfo)); node.range.start = gth_sa_get_exon(sa, exonindex)->leftgenomicexonborder; node.range.end = gth_sa_get_exon(sa, exonindex)->rightgenomicexonborder; if (exonindex == 0) /* this is the first exon */ node.leftmergeable = true; else node.leftmergeable = false; if (exonindex == gth_sa_num_of_exons(sa) - 1) { /* this is the last exon */ node.rightmergeable = true; } else node.rightmergeable = false; /* save successor intron */ if (exonindex < gth_sa_num_of_exons(sa) - 1) { /* exon has successor intron */ node.successorintron = gth_sa_get_intron(sa, exonindex); } else { /* exon has no successor intron */ node.successorintron = NULL; } /* save exonscore */ scoreinfo.exonscore = gth_sa_get_exon(sa, exonindex)->exonscore; scoreinfo.lengthofscoringexon = node.range.end - node.range.start + 1; gt_array_add(node.exonscores, scoreinfo); return node; } static void freecoreExonnode(Exonnode *node) { if (!node) return; gt_array_delete(node->exonscores); } static Leftsidestatus getleftsidestatus(Exonnode *nodeA, Exonnode *nodeB) { /* -------... ]-----... */ if (nodeA->range.start < nodeB->range.start && nodeB->leftmergeable) return MERGEABLE_LEFTSIDE_A_BEFORE_B; /* -------... -------... */ if (nodeA->range.start == nodeB->range.start) return MERGEABLE_LEFTSIDE_A_EQUALS_B; /* ]-----... -------... */ if (nodeA->range.start > nodeB->range.start && nodeA->leftmergeable) return MERGEABLE_LEFTSIDE_A_AFTER_B; return NON_MERGEABLE_LEFTSIDE; } #ifndef NDEBUG static bool leftsideismergeable(Exonnode *nodeA, Exonnode *nodeB) { switch (getleftsidestatus(nodeA, nodeB)) { case MERGEABLE_LEFTSIDE_A_BEFORE_B: case MERGEABLE_LEFTSIDE_A_EQUALS_B: case MERGEABLE_LEFTSIDE_A_AFTER_B: return true; case NON_MERGEABLE_LEFTSIDE: return false; default: gt_assert(0); return false; } } #endif static Rightsidestatus getrightsidestatus(Exonnode *nodeA, Exonnode *nodeB) { /* ...-----[ ...------- */ if (nodeA->range.end < nodeB->range.end && nodeA->rightmergeable) return MERGEABLE_RIGHTSIDE_A_BEFORE_B; /* ...------- ...------- */ if (nodeA->range.end == nodeB->range.end) return MERGEABLE_RIGHTSIDE_A_EQUALS_B; /* ...------- ...-----[ */ if (nodeA->range.end > nodeB->range.end && nodeB->rightmergeable) return MERGEABLE_RIGHTSIDE_A_AFTER_B; return NON_MERGEABLE_RIGHTSIDE; } #ifndef NDEBUG static bool rightsideismergeable(Exonnode *nodeA, Exonnode *nodeB) { switch (getrightsidestatus(nodeA, nodeB)) { case MERGEABLE_RIGHTSIDE_A_BEFORE_B: case MERGEABLE_RIGHTSIDE_A_EQUALS_B: case MERGEABLE_RIGHTSIDE_A_AFTER_B: return true; case NON_MERGEABLE_RIGHTSIDE: return false; default: gt_assert(0); return false; } } #endif #ifndef NDEBUG static bool nodesaremergeable(Exonnode *nodeA, Exonnode *nodeB) { if (gt_range_overlap(&nodeA->range, &nodeB->range) && leftsideismergeable(nodeA, nodeB) && rightsideismergeable(nodeA, nodeB)) { return true; } return false; } #endif static void mergeleftside(Exonnode *nodeA, Exonnode *nodeB) { switch (getleftsidestatus(nodeA, nodeB)) { case MERGEABLE_LEFTSIDE_A_BEFORE_B: /* -------... ]-----... nothing to do */ break; case MERGEABLE_LEFTSIDE_A_EQUALS_B: /* -------... -------... */ if (!nodeA->leftmergeable || !nodeB->leftmergeable) nodeA->leftmergeable = false; break; case MERGEABLE_LEFTSIDE_A_AFTER_B: /* ]-----... -------... */ nodeA->range.start = nodeB->range.start; nodeA->leftmergeable = nodeB->leftmergeable; break; case NON_MERGEABLE_LEFTSIDE: default: gt_assert(0); } } static void mergerightside(Exonnode *nodeA, Exonnode *nodeB) { switch (getrightsidestatus(nodeA, nodeB)) { case MERGEABLE_RIGHTSIDE_A_BEFORE_B: /* ...-----[ ...------- */ nodeA->range.end = nodeB->range.end; nodeA->rightmergeable = nodeB->rightmergeable; break; case MERGEABLE_RIGHTSIDE_A_EQUALS_B: /* ...------- ...------- */ if (!nodeA->rightmergeable || !nodeB->rightmergeable) nodeA->rightmergeable = false; break; case MERGEABLE_RIGHTSIDE_A_AFTER_B: /* ...------- ...-----[ nothing to do */ break; case NON_MERGEABLE_RIGHTSIDE: default: gt_assert(0); } } /* The following function merges the exon nodes <nodeA> and <nodeB>. That is, <nodeA> is modified to the merged node and <nodeB> stays the same. */ static void mergenodes(Exonnode *nodeA, Exonnode *nodeB) { unsigned long i; gt_assert(nodesaremergeable(nodeA, nodeB)); /* merge nodes */ mergeleftside(nodeA, nodeB); mergerightside(nodeA, nodeB); /* merge successor introns */ if (nodeA->successorintron == NULL && nodeB->successorintron != NULL) { /* save successor intron of node B in node A */ nodeA->successorintron = nodeB->successorintron; } /* in the cases that (nodeA==NULL && nodeB==NULL) and that (nodeA!=NULL && nodeB==NULL) nothing has to be done */ /* merge the exonscores */ for (i = 0; i < gt_array_size(nodeB->exonscores); i++) { gt_array_add(nodeA->exonscores, *(Exonscoreinfo*) gt_array_get(nodeB->exonscores, i)); } } static GthDbl computeexonscore(Exonnode *node) { unsigned long i, maxlength = 0; GthDbl maxscore = DBL_MIN; Exonscoreinfo *exonscoreinfo; /* compute maximal length */ for (i = 0; i < gt_array_size(node->exonscores); i++) { exonscoreinfo = gt_array_get(node->exonscores, i); if (exonscoreinfo->lengthofscoringexon > maxlength) maxlength = exonscoreinfo->lengthofscoringexon; } /* save exonscore */ for (i = 0; i < gt_array_size(node->exonscores); i++) { exonscoreinfo = gt_array_get(node->exonscores, i); if ((exonscoreinfo->lengthofscoringexon + SAVE_EXONSCORE_ALLOWED_DIFFERENCE >= maxlength) && (exonscoreinfo->exonscore > maxscore)) { maxscore = exonscoreinfo->exonscore; } } return maxscore; } static void addSAtoAGS(GthAGS *ags, GthSACluster *sacluster, GtArray *nodes) { unsigned long i, currentnode = 0, currentexon = 0, numofexons = gth_sa_num_of_exons(sacluster->representative); Exonnode node; /* genomic strands equal */ gt_assert(gth_ags_is_forward(ags) == gth_sa_gen_strand_forward(sacluster->representative)); /* set genomic id */ if (!ags->gen_id) ags->gen_id = gt_str_ref(gth_sa_gen_id_str(sacluster->representative)); #ifndef NDEBUG else { /* genomic ids equal */ gt_assert(!gt_str_cmp(ags->gen_id, gth_sa_gen_id_str(sacluster->representative))); } #endif /* save SA pointers */ gt_array_add(ags->alignments, sacluster->representative); for (i = 0; i < gt_array_size(sacluster->members); i++) { gt_array_add(ags->alignments, *(GthSA**) gt_array_get(sacluster->members, i)); } ags->numofstoredsaclusters++; while (currentexon < numofexons) { node = getcoreExonnodefromSA(sacluster->representative, currentexon); if (currentnode < gt_array_size(nodes)) { /* compare current node with current exon */ if (!gt_range_overlap(&node.range, &((Exonnode*) gt_array_get(nodes, currentnode)) ->range)) { /* the current exon does not overlap with the current node, visit next node */ currentnode++; } else { /* left borders are equal, merge exon and node */ mergenodes(gt_array_get(nodes, currentnode), &node); currentnode++; currentexon++; } freecoreExonnode(&node); } else { /* save this node */ gt_array_add(nodes, node); currentnode++; currentexon++; } } } void gth_build_AGS_from_assembly(GthAGS *ags, GtBittab *assembly, GtArray *saclusters) { unsigned long i; GtArray *nodes; GthExonAGS exonAGS; GthSpliceSiteProb splicesiteprob; Exonnode *exonnode; nodes = gt_array_new(sizeof (Exonnode)); /* compute AGS, the exons are stored es Exonnodes, which are saved later (see below) */ for (i = 0; i < gt_array_size(saclusters); i++) { if (gt_bittab_bit_is_set(assembly, i)) addSAtoAGS(ags, *(GthSACluster**) gt_array_get(saclusters, i), nodes); } /* save exons */ for (i = 0; i < gt_array_size(nodes); i++) { exonnode = gt_array_get(nodes, i); exonAGS.range = exonnode->range; exonAGS.score = computeexonscore(exonnode); gt_array_add(ags->exons, exonAGS); } /* at least one exon node exists */ gt_assert(gt_array_size(nodes)); /* save the splice site probabilites (stored in the intron infos) */ for (i = 0; i < gt_array_size(nodes) - 1; i++) { exonnode = gt_array_get(nodes, i); splicesiteprob.donorsiteprob = exonnode->successorintron ->donorsiteprobability; splicesiteprob.acceptorsiteprob = exonnode->successorintron ->acceptorsiteprobability; gt_array_add(ags->splicesiteprobs, splicesiteprob); } /* last successor intron info points to null */ gt_assert(((Exonnode*) gt_array_get_last(nodes))->successorintron == NULL); /* free space for nodes */ for (i = 0; i < gt_array_size(nodes); i++) { exonnode = gt_array_get(nodes, i); freecoreExonnode(exonnode); } gt_array_delete(nodes); }
bioh4x/NeatFreq
lib/genometools-1.4.1/src/gth/ags_build.c
C
gpl-2.0
12,414
<?php header('HTTP/1.1 301 Moved Permanently'); header('Location: http://www.townsendsecurity.com/support/ticket'); ?>
mikeusry/Townsend-Security
login_frame.php
PHP
gpl-2.0
121
# Speech-recognition This is the source code for the project speech recognition system for course 188779 in CMU
smartYi/Speech-recognition
README.md
Markdown
gpl-2.0
112
// Scroll to the very bottom to see the stuff we wrote, the big giant blocks are: // froogaloop // and // fitvid.js ;(function( $ ){ 'use strict'; $.fn.fitVids = function( options ) { var settings = { customSelector: null, ignore: null }; if(!document.getElementById('fit-vids-style')) { // appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js var head = document.head || document.getElementsByTagName('head')[0]; var css = '.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}'; var div = document.createElement("div"); div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>'; head.appendChild(div.childNodes[1]); } if ( options ) { $.extend( settings, options ); } return this.each(function(){ var selectors = [ 'iframe[src*="player.vimeo.com"]', 'iframe[src*="youtube.com"]', 'iframe[src*="youtube-nocookie.com"]', 'iframe[src*="kickstarter.com"][src*="video.html"]', 'object', 'embed' ]; if (settings.customSelector) { selectors.push(settings.customSelector); } var ignoreList = '.fitvidsignore'; if(settings.ignore) { ignoreList = ignoreList + ', ' + settings.ignore; } var $allVideos = $(this).find(selectors.join(',')); $allVideos = $allVideos.not('object object'); // SwfObj conflict patch $allVideos = $allVideos.not(ignoreList); // Disable FitVids on this video. $allVideos.each(function(count){ var $this = $(this); if($this.parents(ignoreList).length > 0) { return; // Disable FitVids on this video. } if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; } if ((!$this.css('height') && !$this.css('width')) && (isNaN($this.attr('height')) || isNaN($this.attr('width')))) { $this.attr('height', 9); $this.attr('width', 16); } var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(), width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(), aspectRatio = height / width; if(!$this.attr('id')){ var videoID = 'fitvid' + count; $this.attr('id', videoID); } $this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+'%'); $this.removeAttr('height').removeAttr('width'); }); }); }; // Works with either jQuery or Zepto })( window.jQuery || window.Zepto ); // Init style shamelessly stolen from jQuery http://jquery.com var Froogaloop = (function(){ // Define a local copy of Froogaloop function Froogaloop(iframe) { console.log('hello'); // The Froogaloop object is actually just the init constructor return new Froogaloop.fn.init(iframe); } var eventCallbacks = {}, hasWindowEvent = false, isReady = false, slice = Array.prototype.slice, playerDomain = ''; Froogaloop.fn = Froogaloop.prototype = { element: null, init: function(iframe) { console.log('test'); if (typeof iframe === "string") { iframe = document.getElementById(iframe); } this.element = iframe; console.log(this.element); // Register message event listeners playerDomain = getDomainFromUrl(this.element.getAttribute('src')); return this; }, /* * Calls a function to act upon the player. * * @param {string} method The name of the Javascript API method to call. Eg: 'play'. * @param {Array|Function} valueOrCallback params Array of parameters to pass when calling an API method * or callback function when the method returns a value. */ api: function(method, valueOrCallback) { if (!this.element || !method) { return false; } var self = this, element = self.element, target_id = element.id !== '' ? element.id : null, params = !isFunction(valueOrCallback) ? valueOrCallback : null, callback = isFunction(valueOrCallback) ? valueOrCallback : null; // Store the callback for get functions if (callback) { storeCallback(method, callback, target_id); } postMessage(method, params, element); return self; }, /* * Registers an event listener and a callback function that gets called when the event fires. * * @param eventName (String): Name of the event to listen for. * @param callback (Function): Function that should be called when the event fires. */ addEvent: function(eventName, callback) { if (!this.element) { return false; } var self = this, element = self.element, target_id = element.id !== '' ? element.id : null; storeCallback(eventName, callback, target_id); // The ready event is not registered via postMessage. It fires regardless. if (eventName != 'ready') { postMessage('addEventListener', eventName, element); } else if (eventName == 'ready' && isReady) { callback.call(null, target_id); } return self; }, /* * Unregisters an event listener that gets called when the event fires. * * @param eventName (String): Name of the event to stop listening for. */ removeEvent: function(eventName) { if (!this.element) { return false; } var self = this, element = self.element, target_id = element.id !== '' ? element.id : null, removed = removeCallback(eventName, target_id); // The ready event is not registered if (eventName != 'ready' && removed) { postMessage('removeEventListener', eventName, element); } } }; /** * Handles posting a message to the parent window. * * @param method (String): name of the method to call inside the player. For api calls * this is the name of the api method (api_play or api_pause) while for events this method * is api_addEventListener. * @param params (Object or Array): List of parameters to submit to the method. Can be either * a single param or an array list of parameters. * @param target (HTMLElement): Target iframe to post the message to. */ function postMessage(method, params, target) { if (!target.contentWindow.postMessage) { return false; } var url = target.getAttribute('src').split('?')[0], data = JSON.stringify({ method: method, value: params }); if (url.substr(0, 2) === '//') { url = window.location.protocol + url; } target.contentWindow.postMessage(data, url); } /** * Event that fires whenever the window receives a message from its parent * via window.postMessage. */ function onMessageReceived(event) { var data, method; try { data = JSON.parse(event.data); method = data.event || data.method; } catch(e) { //fail silently... like a ninja! } if (method == 'ready' && !isReady) { isReady = true; } // Handles messages from moogaloop only if (event.origin != playerDomain) { return false; } var value = data.value, eventData = data.data, target_id = target_id === '' ? null : data.player_id, callback = getCallback(method, target_id), params = []; if (!callback) { return false; } if (value !== undefined) { params.push(value); } if (eventData) { params.push(eventData); } if (target_id) { params.push(target_id); } return params.length > 0 ? callback.apply(null, params) : callback.call(); } /** * Stores submitted callbacks for each iframe being tracked and each * event for that iframe. * * @param eventName (String): Name of the event. Eg. api_onPlay * @param callback (Function): Function that should get executed when the * event is fired. * @param target_id (String) [Optional]: If handling more than one iframe then * it stores the different callbacks for different iframes based on the iframe's * id. */ function storeCallback(eventName, callback, target_id) { if (target_id) { if (!eventCallbacks[target_id]) { eventCallbacks[target_id] = {}; } eventCallbacks[target_id][eventName] = callback; } else { eventCallbacks[eventName] = callback; } } /** * Retrieves stored callbacks. */ function getCallback(eventName, target_id) { if (target_id) { return eventCallbacks[target_id][eventName]; } else { return eventCallbacks[eventName]; } } function removeCallback(eventName, target_id) { if (target_id && eventCallbacks[target_id]) { if (!eventCallbacks[target_id][eventName]) { return false; } eventCallbacks[target_id][eventName] = null; } else { if (!eventCallbacks[eventName]) { return false; } eventCallbacks[eventName] = null; } return true; } /** * Returns a domain's root domain. * Eg. returns http://vimeo.com when http://vimeo.com/channels is sbumitted * * @param url (String): Url to test against. * @return url (String): Root domain of submitted url */ function getDomainFromUrl(url) { if (url.substr(0, 2) === '//') { url = window.location.protocol + url; } var url_pieces = url.split('/'), domain_str = ''; for(var i = 0, length = url_pieces.length; i < length; i++) { if(i<3) {domain_str += url_pieces[i];} else {break;} if(i<2) {domain_str += '/';} } return domain_str; } function isFunction(obj) { return !!(obj && obj.constructor && obj.call && obj.apply); } function isArray(obj) { return toString.call(obj) === '[object Array]'; } // Give the init function the Froogaloop prototype for later instantiation Froogaloop.fn.init.prototype = Froogaloop.fn; // Listens for the message event. // W3C if (window.addEventListener) { window.addEventListener('message', onMessageReceived, false); } // IE else { window.attachEvent('onmessage', onMessageReceived); } // Expose froogaloop to the global object return (window.Froogaloop = window.$f = Froogaloop); })();
robinfoe/blmk
public/scripts/froogaloop/script.js
JavaScript
gpl-2.0
11,895
/*************************************************************************** qgsvectorlayereditpassthrough.cpp --------------------- begin : Jan 12 2015 copyright : (C) 2015 by Sandro Mani email : manisandro at gmail dot com *************************************************************************** * * * 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. * * * ***************************************************************************/ #include "qgsvectorlayereditpassthrough.h" #include "qgsvectorlayer.h" #include "qgsvectordataprovider.h" #include "qgsvectorlayerundopassthroughcommand.h" QgsVectorLayerEditPassthrough::QgsVectorLayerEditPassthrough( QgsVectorLayer *layer ) : mModified( false ) { L = layer; } bool QgsVectorLayerEditPassthrough::isModified() const { return mModified; } bool QgsVectorLayerEditPassthrough::modify( QgsVectorLayerUndoPassthroughCommand *cmd ) { L->undoStack()->push( cmd ); // push takes owneship -> no need for cmd to be a smart ptr if ( cmd->hasError() ) return false; mModified = true; return true; } bool QgsVectorLayerEditPassthrough::addFeature( QgsFeature &f ) { QgsVectorLayerUndoPassthroughCommandAddFeatures *cmd = new QgsVectorLayerUndoPassthroughCommandAddFeatures( this, QgsFeatureList() << f ); if ( !modify( cmd ) ) // modify takes owneship -> no need for cmd to be a smart ptr return false; const QgsFeatureList features = cmd->features(); f = features.at( features.count() - 1 ); return true; } bool QgsVectorLayerEditPassthrough::addFeatures( QgsFeatureList &features ) { QgsVectorLayerUndoPassthroughCommandAddFeatures *cmd = new QgsVectorLayerUndoPassthroughCommandAddFeatures( this, features ); if ( !modify( cmd ) ) // modify takes owneship -> no need for cmd to be a smart ptr return false; features = cmd->features(); return true; } bool QgsVectorLayerEditPassthrough::deleteFeature( QgsFeatureId fid ) { return modify( new QgsVectorLayerUndoPassthroughCommandDeleteFeatures( this, QgsFeatureIds() << fid ) ); } bool QgsVectorLayerEditPassthrough::deleteFeatures( const QgsFeatureIds &fids ) { return modify( new QgsVectorLayerUndoPassthroughCommandDeleteFeatures( this, fids ) ); } bool QgsVectorLayerEditPassthrough::changeGeometry( QgsFeatureId fid, const QgsGeometry &geom ) { return modify( new QgsVectorLayerUndoPassthroughCommandChangeGeometry( this, fid, geom ) ); } bool QgsVectorLayerEditPassthrough::changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &/*oldValue*/ ) { return modify( new QgsVectorLayerUndoPassthroughCommandChangeAttribute( this, fid, field, newValue ) ); } bool QgsVectorLayerEditPassthrough::addAttribute( const QgsField &field ) { return modify( new QgsVectorLayerUndoPassthroughCommandAddAttribute( this, field ) ); } bool QgsVectorLayerEditPassthrough::deleteAttribute( int attr ) { return modify( new QgsVectorLayerUndoPassthroughCommandDeleteAttribute( this, attr ) ); } bool QgsVectorLayerEditPassthrough::renameAttribute( int attr, const QString &newName ) { return modify( new QgsVectorLayerUndoPassthroughCommandRenameAttribute( this, attr, newName ) ); } bool QgsVectorLayerEditPassthrough::commitChanges( QStringList & /*commitErrors*/ ) { mModified = false; return true; } void QgsVectorLayerEditPassthrough::rollBack() { mModified = false; }
GeoCat/QGIS
src/core/qgsvectorlayereditpassthrough.cpp
C++
gpl-2.0
3,835
<?php /** * Wishlist page template * * @author Your Inspiration Themes * @package YITH WooCommerce Wishlist * @version 1.0.6 */ global $wpdb, $yith_wcwl, $woocommerce, $ct_catalog_mode; $myaccount_page_id = get_option( 'woocommerce_myaccount_page_id' ); $myaccount_page_url = ""; if ( $myaccount_page_id ) { $myaccount_page_url = get_permalink( $myaccount_page_id ); } $user_id = ""; if( isset( $_GET['user_id'] ) && !empty( $_GET['user_id'] ) ) { $user_id = $_GET['user_id']; } elseif( is_user_logged_in() ) { $user_id = get_current_user_id(); } $current_page = 1; $limit_sql = ''; if( $pagination == 'yes' ) { $count = array(); if( is_user_logged_in() ) { $count = $wpdb->get_results( $wpdb->prepare( 'SELECT COUNT(*) as `cnt` FROM `' . YITH_WCWL_TABLE . '` WHERE `user_id` = %d', $user_id ), ARRAY_A ); $count = $count[0]['cnt']; } elseif( yith_usecookies() ) { $count[0]['cnt'] = count( yith_getcookie( 'yith_wcwl_products' ) ); } else { $count[0]['cnt'] = count( $_SESSION['yith_wcwl_products'] ); } $total_pages = $count/$per_page; if( $total_pages > 1 ) { $current_page = max( 1, get_query_var( 'page' ) ); $page_links = paginate_links( array( 'base' => get_pagenum_link( 1 ) . '%_%', 'format' => '&page=%#%', 'current' => $current_page, 'total' => $total_pages, 'show_all' => true ) ); } $limit_sql = "LIMIT " . ( $current_page - 1 ) * 1 . ',' . $per_page; } if ($user_id != "") { $wishlist = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `" . YITH_WCWL_TABLE . "` WHERE `user_id` = %s" . $limit_sql, $user_id ), ARRAY_A ); } elseif( yith_usecookies() ) { $wishlist = yith_getcookie( 'yith_wcwl_products' ); } else { $wishlist = isset( $_SESSION['yith_wcwl_products'] ) ? $_SESSION['yith_wcwl_products'] : array(); } // Start wishlist page printing $woocommerce->show_messages() ?> <div id="yith-wcwl-messages"></div> <?php ct_woo_help_bar(); ?> <div class="my-account-left"> <h4 class="lined-heading"><span><?php _e("My Account", "cootheme"); ?></span></h4> <ul class="nav my-account-nav"> <li><a href="<?php echo $myaccount_page_url; ?>"><?php _e("Back to my account", "cootheme"); ?></a></li> </ul> </div> <div class="my-account-right tab-content"> <form id="yith-wcwl-form" action="<?php echo esc_url( $yith_wcwl->get_wishlist_url() ) ?>" method="post"> <?php do_action( 'yith_wcwl_before_wishlist_title' ); $wishlist_title = get_option( 'yith_wcwl_wishlist_title' ); if( !empty( $wishlist_title ) ) { echo apply_filters( 'yith_wcwl_wishlist_title', '<h3>' . $wishlist_title . '</h3>' ); } do_action( 'yith_wcwl_before_wishlist' ); ?> <table class="shop_table cart wishlist_table" cellspacing="0"> <thead> <tr> <th class="product-thumbnail"><span class="nobr"><?php _e( 'Item', 'cootheme' ) ?></span></th> <th class="product-name"><span class="nobr"><?php _e( 'Product Name', 'cootheme' ) ?></span></th> <?php if( get_option( 'yith_wcwl_price_show' ) == 'yes' ) { ?><th class="product-price"><span class="nobr"><?php _e( 'Unit Price', 'cootheme' ) ?></span></th><?php } ?> <?php if( get_option( 'yith_wcwl_stock_show' ) == 'yes' ) { ?><th class="product-stock-status"><span class="nobr"><?php _e( 'Stock Status', 'cootheme' ) ?></span></th><?php } ?> <?php if (!$ct_catalog_mode && get_option( 'yith_wcwl_add_to_cart_show' ) == 'yes') { ?> <th class="product-add-to-bag"><span class="nobr"><?php _e( 'Actions', 'cootheme' ) ?></span></th> <?php } ?> <th class="product-remove"></th> </tr> </thead> <tbody> <?php if( count( $wishlist ) > 0 ) : foreach( $wishlist as $values ) : if( !is_user_logged_in() ) { if( isset( $values['add-to-wishlist'] ) && is_numeric( $values['add-to-wishlist'] ) ) { $values['prod_id'] = $values['add-to-wishlist']; $values['ID'] = $values['add-to-wishlist']; } else { $values['prod_id'] = $values['prod_id']; $values['ID'] = $values['prod_id']; } } $product_obj = get_product( $values['prod_id'] ); if( $product_obj !== false && $product_obj->exists() ) : ?> <tr id="yith-wcwl-row-<?php echo $values['ID'] ?>"> <td class="product-thumbnail"> <a href="<?php echo esc_url( get_permalink( apply_filters( 'woocommerce_in_cart_product', $values['prod_id'] ) ) ) ?>"> <?php echo $product_obj->get_image() ?> </a> </td> <td class="product-name"> <a href="<?php echo esc_url( get_permalink( apply_filters( 'woocommerce_in_cart_product', $values['prod_id'] ) ) ) ?>"><?php echo apply_filters( 'woocommerce_in_cartproduct_obj_title', $product_obj->get_title(), $product_obj ) ?></a> </td> <?php if( get_option( 'yith_wcwl_price_show' ) == 'yes' ) { ?> <td class="product-price"> <?php if( $product_obj->price != '0' ) { if( get_option( 'woocommerce_tax_display_cart' ) == 'excl' ) { echo apply_filters( 'woocommerce_cart_item_price_html', woocommerce_price( $product_obj->get_price_excluding_tax() ), $values, '' ); } else { echo apply_filters( 'woocommerce_cart_item_price_html', woocommerce_price( $product_obj->get_price() ), $values, '' ); } } else { echo apply_filters( 'yith_free_text', __( 'Free!', 'yit' ) ); } ?> </td> <?php } ?> <?php if( get_option( 'yith_wcwl_stock_show' ) == 'yes' ) { ?> <td class="product-stock-status"> <?php $availability = $product_obj->get_availability(); $stock_status = $availability['class']; if( $stock_status == 'out-of-stock' ) { $stock_status = "Out"; echo '<span class="wishlist-out-of-stock">' . __( 'Out of Stock', 'cootheme' ) . '</span>'; } else { $stock_status = "In"; echo '<span class="wishlist-in-stock">' . __( 'In Stock', 'cootheme' ) . '</span>'; } ?> </td> <?php } ?> <?php if (!$ct_catalog_mode && get_option( 'yith_wcwl_add_to_cart_show' ) == 'yes') { ?> <td class="product-add-to-cart"> <?php echo YITH_WCWL_UI::add_to_cart_button( $values['prod_id'], $availability['class'] ) ?> </td> <?php } ?> <td class="product-remove"><div><a href="javascript:void(0)" onclick="remove_item_from_wishlist( '<?php echo esc_url( $yith_wcwl->get_remove_url( $values['ID'] ) )?>', 'yith-wcwl-row-<?php echo $values['ID'] ?>');" class="remove" title="<?php _e( 'Remove this product', 'cootheme' ) ?>"><i class="ss-delete"></i></a></td> </tr> <?php endif; endforeach; else: ?> <tr> <td colspan="6" class="wishlist-empty"><?php _e( 'Your wishlist is currently empty.', 'cootheme' ) ?></td> </tr> <?php endif; if( isset( $page_links ) ) : ?> <tr> <td colspan="6"><?php echo $page_links ?></td> </tr> <?php endif ?> </tbody> </table> <?php do_action( 'yith_wcwl_after_wishlist' ); yith_wcwl_get_template( 'share.php' ); do_action( 'yith_wcwl_after_wishlist_share' ); ?> </form> </div>
chinhlv91/wp_melano
wp-content/themes/wp_melano_3.8/woocommerce/wishlist.php
PHP
gpl-2.0
8,715