answer
stringlengths
15
1.25M
<?php // Nothing for now
#!/bin/bash MYPATH=`dirname "$0"`; cd "${MYPATH}" || exit 1 SRC_DIR="`pwd`" rm -rf ../../../../build mkdir ../../../../build cd ../../../../build || exit 1 IMAGE_BUILD_DIR="`pwd`" if [ "${<API key>}" != "" ] ; then rm -rf cal-fpga mkdir cal-fpga || exit 1 cd cal-fpga || exit 1 tar xzf "${<API key>}" || exit 1 else if [ -d ../../labx-ip/cal/FPGA ] ; then cd ../../labx-ip/cal/FPGA/ || exit 1 else echo "Directory with FPGA SDK workspace is not present in the build" echo "and there is no archive of it passed as <API key>" exit 1 fi fi FPGA_BUILD_DIR="`pwd`" rm -rf Synthesis/Supervisor_Micro/SDK/SDK_Projects/mbbl rm -rf Synthesis/Supervisor_Micro/SDK/SDK_Projects/mbbl_copy cp -r "${SRC_DIR}/../../../mbbl_copy" "${SRC_DIR}/../../../mbbl" Synthesis/Supervisor_Micro/SDK/SDK_Projects/ make -f Synthesis/Supervisor_Micro/SDK/SDK_Projects/mbbl/boards/cal-ics/mbbl-images.mk || exit 1 cp Synthesis/<API key>.bit \ Synthesis/<API key>.bit \ Synthesis/Supervisor_Micro/SDK/SDK_Projects/mbbl/cal-ics/mbbl.elf \ "${IMAGE_BUILD_DIR}" || exit 1 cd "${IMAGE_BUILD_DIR}" rm -rf update mkdir update || exit 1 if [ -f ../../calamp_with_pvb.hex ] ; then cp ../../calamp_with_pvb.hex update/cal_amcu.hex fi if [ -f ../../dspapp_with_pvb.hex ] ; then cp ../../dspapp_with_pvb.hex update/cal_dmcu.hex fi mv mbbl.elf update cp ../../mb-linux-msli/uClinux-dist/linux-2.6.x/arch/microblaze/boot/linux.bin update || exit 1 gzip -9 update/linux.bin rm -rf romfs cp -r ../../mb-linux-msli/uClinux-dist/romfs romfs || exit 1 mkdir -p romfs/usr/bin mkdir -p romfs/etc/config.orig cp ../../labx-ip/cal/App_Firmware/avb_audio_ctrl \ ../../labx-ip/cal/App_Firmware/avbd \ ../../labx-ip/cal/App_Firmware/p17221d \ ../../labx-ip/cal/App_Firmware/static_avb_config \ romfs/usr/bin || exit 1 cp ../../labx-ip/cal/App_Firmware/configs/CAL_ICSPlatform.xml \ ../../labx-ip/cal/App_Firmware/configs/<API key>.xml \ ../../labx-ip/cal/App_Firmware/configs/StaticAVBStreams.xml \ romfs/etc/config.orig || exit 1 genromfs -f update/romfs.bin -d romfs || exit 1 rm -rf romfs gzip -9 update/romfs.bin dtc -f -o update/dt.dtb -O dtb "${SRC_DIR}/cal-ics.dts" cp ../../mb-linux-msli/local/logo-1.bin.gz \ ../../mb-linux-msli/local/8x12-font.bin.gz \ ../../mb-linux-msli/local/16x24-font.bin.gz \ ../../mb-linux-msli/local/identity.txt update || exit 1 ../mbbl-mkbootimage/mbbl-imagetool -s 0 -N \ -d update/dt.dtb \ -k update/linux.bin.gz \ -f update/8x12-font.bin.gz \ -f update/16x24-font.bin.gz \ -i update/identity.txt \ -l update/logo-1.bin.gz \ -r update/romfs.bin.gz \ -b <API key>.bit \ -e update/mbbl.elf \ -o bootimage-maint.bin || exit 1 ../../mb-linux-msli/mcsbin/mcsbin -m -o 0 bootimage-maint.bin bootimage-maint.mcs || exit 1 ../mbbl-mkbootimage/mbbl-imagetool -s 0x800000 -N \ -d update/dt.dtb \ -k update/linux.bin.gz \ -f update/8x12-font.bin.gz \ -f update/16x24-font.bin.gz \ -i update/identity.txt \ -l update/logo-1.bin.gz \ -r update/romfs.bin.gz \ -b <API key>.bit \ -e update/mbbl.elf \ -o bootimage-regular.bin || exit 1 ../../mb-linux-msli/mcsbin/mcsbin -m -o 0 bootimage-regular.bin bootimage-regular.mcs || exit 1 cp <API key>.bit update/download.bit tar czf cal-firmware.tar.gz update/ cp <API key>.bit update/download.bit tar czf cal-firmware-maint.tar.gz update/ rm -rf update exit 0
<?php /** * @ignore */ if (!defined('IN_PHPBB')) { exit; } /** * @package acp */ class acp_k_pages { var $u_action; function main($page_id, $mode) { global $db, $user, $auth, $template, $cache; global $k_config, $config, $SID, $phpbb_root_path, $phpbb_admin_path, $phpEx; $current_pages = array(); include($phpbb_root_path . 'includes/sgp_functions.' . $phpEx); $user->add_lang('acp/k_pages'); $this->tpl_name = 'acp_k_pages'; $this->page_filename = 'ACP_PAGES'; $this->page_title = 'ACP_K_PAGES'; $form_key = 'acp_k_pages'; add_form_key($form_key); //$s_hidden_fields = ''; $mode = request_var('mode', ''); $page_id = request_var('page_id', 0); $action = request_var('config', ''); $tag_id = request_var('tag_id', ''); $submit = (isset($_POST['submit'])) ? true : false; if ($tag_id != '') { $mode = 'add'; } switch ($action) { case 'config': $template->assign_var('MESSAGE', $user->lang['SWITCHING']); meta_refresh(1, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=k_vars&amp;mode=config&amp;switch=k_pages')); break; default: break; } if ($submit && !check_form_key($form_key)) { $submit = false; $mode = ''; trigger_error($user->lang['FORM_INVALID'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . $user->lang['LINE'] . __LINE__); } if ($submit) { $mod_pages = request_var('k_mod_folders', ''); // trap trailing commas in mod pages // if ($mod_pages && $mod_pages[strlen($mod_pages) - 1] == ',') { trigger_error($user->lang['TRAILING_COMMA'] . adm_back_link(append_sid("{$phpbb_admin_path}index.$phpEx", "i=k_pages&amp;mode=manage")), E_USER_WARNING); } // We check to see the mod folder exists, if not return... // $mod_pages = str_replace(' ', '', $mod_pages); // has mod folder been updated/modified // if (strcmp($mod_pages, $k_config['k_mod_folders'] != 0)) { $mods_folder_array = explode(',', $mod_pages); foreach($mods_folder_array as $folder) { $folder = trim($folder); if (!file_exists($phpbb_root_path . $folder)) { $submit = false; $mod_pages = ''; trigger_error($user->lang['NO_MOD_FOLDER'] . $folder . adm_back_link(append_sid("{$phpbb_admin_path}index.$phpEx", "i=k_pages&amp;mode=manage")), E_USER_WARNING); } } $template->assign_vars(array( //'MESSAGE' => $user->lang['FOLDER_ADDED'] . ' ' . $folder, 'MESSAGE' => $user->lang['FOLDER_ADDED'], )); } sgp_acp_set_config('k_mod_folders', $mod_pages); } $template->assign_vars(array( 'U_BACK' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=k_pages&amp;mode=manage"), 'U_ADD' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=k_pages&amp;mode=add"), 'U_MANAGE' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=k_pages&amp;mode=manage"), 'S_OPT' => 'S_MANAGE', 'S_PAGE' => isset($k_config['k_landing_page']) ? $k_config['k_landing_page'] : 'portal', )); switch ($mode) { case 'delete': $page_name = get_page_filename($page_id); if (confirm_box(true)) { $sql = 'DELETE FROM ' . K_PAGES_TABLE . ' WHERE page_id = ' . (int)$page_id; if (!$result = $db->sql_query($sql)) { trigger_error($user->lang['ERROR_PORTAL_PAGES'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . $user->lang['LINE'] . __LINE__); } $cache->destroy('sql', K_PAGES_TABLE); $template->assign_vars(array( 'S_OPTION' => 'processing', 'MESSAGE' => $user->lang['REMOVING_PAGES'] . $page_name, )); meta_refresh(1, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=k_pages&amp;mode=manage')); break; } else { confirm_box(false, sprintf("%s (%s)", $user->lang['DELETE_FROM_LIST'], $page_name), build_hidden_fields(array( 'id' => $page_id, 'mode' => $mode, 'action' => 'delete')) ); } $template->assign_var('MESSAGE', $user->lang['ACTION_CANCELLED']); meta_refresh(1, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=k_pages&amp;mode=manage')); break; case 'add': if ($submit) { // drop extension $tag_id = str_replace('.php', '', $tag_id); // skip the spacer // if ($tag_id == '..') { $template->assign_vars(array( 'S_OPTION' => 'processing', // not lang var 'MESSAGE' => sprintf($user->lang['ERROR_PAGE'], $tag_id), )); meta_refresh(2, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=k_pages&amp;mode=manage')); return; } if (in_array($tag_id, $current_pages)) { break; } $sql_array = array( 'page_name' => $tag_id, ); $db->sql_query('INSERT INTO ' . K_PAGES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_array)); meta_refresh(1, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=k_pages&amp;mode=manage')); $template->assign_vars(array( 'S_OPTION' => 'processing', // not lang var 'MESSAGE' => $user->lang['ADDING_PAGES'], )); $cache->destroy('sql', K_PAGES_TABLE); break; } break; case 'land': $page_name = get_page_filename($page_id); sgp_acp_set_config('k_landing_page', $page_name, 1); $template->assign_vars(array( 'S_OPTION' => 'processing', 'MESSAGE' => $user->lang['LANDING_PAGE_SET'] . ': '. $page_name, )); $cache->destroy('k_config'); $cache->destroy('sql', <API key>); meta_refresh(1, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=k_pages&amp;mode=manage')); break; case 'config': break; case 'manage': <API key>(); get_pages_data(); break; case 'default': break; } $template->assign_var('U_ACTION', $this->u_action); } } function get_pages_data() { global $db, $template, $phpbb_admin_path, $phpEx, $k_config; global $current_pages; $sql = 'SELECT * FROM ' . K_PAGES_TABLE ; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $current_pages = $row['page_name']; $template->assign_block_vars('phpbbpages', array( 'S_PAGE_ID' => $row['page_id'], 'S_PAGE_NAME' => $row['page_name'], 'U_EDIT' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=k_pages&amp;mode=edit&amp;page_id=" . $row['page_id']), 'U_DELETE' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=k_pages&amp;mode=delete&amp;page_id=" . $row['page_id']), 'U_LAND' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=k_pages&amp;mode=land&amp;page_id=" . $row['page_id']), )); } $db->sql_freeresult($result); $template->assign_vars(array( 'S_OPTION' => 'manage', 'K_MOD_FOLDERS' => $k_config['k_mod_folders'], )); } /** * get all pages * don't include code files, only include pages... */ function <API key>() { global $phpbb_root_path, $phpEx, $template, $dirslist, $db, $user, $k_config, $phpbb_admin_path; include($phpbb_root_path . 'includes/sgp_functions.' . $phpEx); $page_name = ''; $dirslist = $store = ' '; $illegal_files = array(".htaccess", "common.$phpEx", "report.$phpEx", "feed.$phpEx", "cron.$phpEx", "config.$phpEx", "csv.$phpEx", "style.$phpEx", "sgp_ajax.$phpEx", "sgpical.$phpEx", "rss.$phpEx"); if (!isset($k_config['k_mod_folders'])) { sgp_acp_set_config('k_mod_folders', ''); } $sql = 'SELECT page_name FROM ' . K_PAGES_TABLE . ' ORDER BY page_name ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $page_name .= $row['page_name'] . '.php, '; } $db->sql_freeresult($result); $arr = explode(', ', $page_name); // grab php files in phpbb_root_path // $dirs = dir($phpbb_root_path); while ($file = $dirs->read()) { if ($file != '.' && $file != '..' && stripos($file, ".php") && !stripos($file, ".bak") && !in_array($file, $arr, true)) { if (!in_array($file, $illegal_files)) { $dirslist .= "$file "; } } } closedir($dirs->handle); // grab files in phpbb_root_path/mod folders // $dirs = dir($phpbb_root_path); $mods_folder_array = explode(',', $k_config['k_mod_folders']); while ($file = $dirs->read()) { if (in_array($file, $mods_folder_array, true) && $file == '.' || $file == '..' && $k_config['k_mod_folders'] != '') { $mods_folder_array = explode(',', $k_config['k_mod_folders']); foreach($mods_folder_array as $folder) { $folder = trim($folder); if (!file_exists($phpbb_root_path . $folder)) { trigger_error($user->lang['NO_MOD_FOLDER'] . $folder . adm_back_link(append_sid("{$phpbb_admin_path}index.$phpEx", "i=k_pages&amp;mode=manage")), E_USER_WARNING); } $dirs = dir($phpbb_root_path . $folder); while ($file = $dirs->read()) { if ($file != '.' && $file != '..' && stripos($file, ".php") && !stripos($file, ".bak") && !in_array($folder .'/'. $file, $arr, true)) { $illegal_files_array = array($folder . '/' . 'dummy.' . $phpEx); $temp = $folder . '/' . $file; if (!in_array($temp, $illegal_files_array, true)) { $store .= $temp. " "; } } } } $dirslist .= $store; } } closedir($dirs->handle); // grab portal files making sure the wrapper folder exists first // $search_folder = $phpbb_root_path . 'styles/_portal_common/template/wrappers'; if (file_exists($search_folder)) { $dirs = dir($search_folder); while ($file = $dirs->read()) { if ($file != '.' && $file != '..' && stripos($file, ".html") && !stripos($file, ".bak") && !in_array($file, $arr, true)) { if (!in_array($file, $illegal_files)) { $file = str_replace('.html', '', $file); $temp = 'portal.php?page=' . $file; $dirslist .= "$temp "; } } } closedir($dirs->handle); } $dirslist = explode(" ", $dirslist); //sort($dirslist); $phpbb_files = ''; $files_found = 0; // As we use onchange event we need an empty line first // $phpbb_files .= '<option value="' . ' ' . '">' . ' ' . '</option>'; foreach ($dirslist as $file) { if ($file != '') { $files_found++; $phpbb_files .= '<option value="' . $file . '"' . (($files_found == 0) ? ' selected="selected"' : '') . '>' . $file . '</option>'; } } $template->assign_vars(array( 'S_PHPBB_FILES' => $phpbb_files, 'S_FILES_FOUND' => $files_found, )); } /** * simply return the page/file name for clarity **/ function get_page_filename($page_id) { global $db, $template; $sql = 'SELECT * FROM ' . K_PAGES_TABLE . ' WHERE page_id = ' . $db->sql_escape($page_id); $result = $db->sql_query($sql); if ($result = $db->sql_query($sql)) { $row = $db->sql_fetchrow($result); } $template->assign_vars(array( 'PAGE_ID' => $row['page_id'], 'PAGE_NAME' => $row['page_name'], )); $db->sql_freeresult($result); return($row['page_name']); } ?>
<?php // no direct access defined('_JEXEC') or die; JHtml::_('behavior.keepalive'); JHtml::_('behavior.tooltip'); JHtml::_('behavior.calendar'); JHtml::_('behavior.formvalidation'); // Create shortcut to parameters. $params = $this->state->get('params'); ?> <script type="text/javascript"> Joomla.submitbutton = function(task) { if (task == 'article.cancel' || document.formvalidator.isValid(document.id('adminForm'))) { <?php echo $this->form->getField('text')->save(); ?> Joomla.submitform(task); } else { alert('<?php echo $this->escape(JText::_('<API key>'));?>'); } } </script> <div class="edit item-page<?php echo $this->escape($params->get('pageclass_sfx')); ?>"> <?php if ($params->get('show_page_heading', 1)) : ?> <h1> <?php echo $this->escape($params->get('page_heading')); ?> </h1> <?php endif; ?> <form action="<?php echo JRoute::_('index.php?option=com_content'); ?>" method="post" name="adminForm" id="adminForm" class="form-validate"> <fieldset> <legend><?php echo JText::_('JEDITOR'); ?></legend> <div class="formelm"> <?php echo $this->form->getLabel('title'); ?> <?php echo $this->form->getInput('title'); ?> </div> <?php if (is_null($this->item->id)):?> <div class="formelm"> <?php echo $this->form->getLabel('alias'); ?> <?php echo $this->form->getInput('alias'); ?> </div> <?php endif; ?> <div class="formelm-buttons"> <button type="button" onclick="Joomla.submitbutton('article.save')"> <?php echo JText::_('JSAVE') ?> </button> <button type="button" onclick="Joomla.submitbutton('article.cancel')"> <?php echo JText::_('JCANCEL') ?> </button> </div> <?php echo $this->form->getInput('text'); ?> </fieldset> <fieldset> <legend><?php echo JText::_('<API key>'); ?></legend> <div class="formelm"> <?php echo $this->form->getLabel('catid'); ?> <?php echo $this->form->getInput('catid'); ?> </div> <div class="formelm"> <?php echo $this->form->getLabel('created_by_alias'); ?> <?php echo $this->form->getInput('created_by_alias'); ?> </div> <?php if ($this->user->authorise('core.edit.state', 'com_content.article.'.$this->item->id)): ?> <div class="formelm"> <?php echo $this->form->getLabel('state'); ?> <?php echo $this->form->getInput('state'); ?> </div> <div class="formelm"> <?php echo $this->form->getLabel('featured'); ?> <?php echo $this->form->getInput('featured'); ?> </div> <div class="formelm"> <?php echo $this->form->getLabel('publish_up'); ?> <?php echo $this->form->getInput('publish_up'); ?> </div> <div class="formelm"> <?php echo $this->form->getLabel('publish_down'); ?> <?php echo $this->form->getInput('publish_down'); ?> </div> <?php endif; ?> <div class="formelm"> <?php echo $this->form->getLabel('access'); ?> <?php echo $this->form->getInput('access'); ?> </div> <?php if (is_null($this->item->id)):?> <div class="form-note"> <p><?php echo JText::_('<API key>'); ?></p> </div> <?php endif; ?> </fieldset> <fieldset> <legend><?php echo JText::_('<API key>'); ?></legend> <div class="formelm-area"> <?php echo $this->form->getLabel('language'); ?> <?php echo $this->form->getInput('language'); ?> </div> </fieldset> <fieldset> <legend><?php echo JText::_('<API key>'); ?></legend> <div class="formelm-area"> <?php echo $this->form->getLabel('metadesc'); ?> <?php echo $this->form->getInput('metadesc'); ?> </div> <div class="formelm-area"> <?php echo $this->form->getLabel('metakey'); ?> <?php echo $this->form->getInput('metakey'); ?> </div> <input type="hidden" name="task" value="" /> <?php echo JHTML::_( 'form.token' ); ?> </fieldset> </form> </div>
#ifndef GCC_OPTABS_H #define GCC_OPTABS_H #include "insn-codes.h" /* Optabs are tables saying how to generate insn bodies for various machine modes and numbers of operands. Each optab applies to one operation. For example, add_optab applies to addition. The insn_code slot is the enum insn_code that says how to generate an insn for this operation on a particular machine mode. It is CODE_FOR_nothing if there is no such insn on the target machine. The `lib_call' slot is the name of the library function that can be used to perform the operation. A few optabs, such as move_optab and cmp_optab, are used by special code. */ struct optab_handlers { enum insn_code insn_code; }; struct optab { enum rtx_code code; const char *libcall_basename; char libcall_suffix; void (*libcall_gen)(struct optab *, const char *name, char suffix, enum machine_mode); struct optab_handlers handlers[NUM_MACHINE_MODES]; }; typedef struct optab * optab; /* A convert_optab is for some sort of conversion operation between modes. The first array index is the destination mode, the second is the source mode. */ struct convert_optab { enum rtx_code code; const char *libcall_basename; void (*libcall_gen)(struct convert_optab *, const char *name, enum machine_mode, enum machine_mode); struct optab_handlers handlers[NUM_MACHINE_MODES][NUM_MACHINE_MODES]; }; typedef struct convert_optab *convert_optab; /* Given an enum insn_code, access the function to construct the body of that kind of insn. */ #define GEN_FCN(CODE) (insn_data[CODE].genfun) /* Enumeration of valid indexes into optab_table. */ enum optab_index { /* Fixed-point operators with signed/unsigned saturation */ OTI_ssadd, OTI_usadd, OTI_sssub, OTI_ussub, OTI_ssmul, OTI_usmul, OTI_ssdiv, OTI_usdiv, OTI_ssneg, OTI_usneg, OTI_ssashl, OTI_usashl, OTI_add, OTI_addv, OTI_sub, OTI_subv, /* Signed and fp multiply */ OTI_smul, OTI_smulv, /* Signed multiply, return high word */ OTI_smul_highpart, OTI_umul_highpart, /* Signed multiply with result one machine mode wider than args */ OTI_smul_widen, OTI_umul_widen, /* Widening multiply of one unsigned and one signed operand. */ OTI_usmul_widen, /* Signed multiply and add with the result and addend one machine mode wider than the multiplicand and multiplier. */ OTI_smadd_widen, /* Unsigned multiply and add with the result and addend one machine mode wider than the multiplicand and multiplier. */ OTI_umadd_widen, /* Signed multiply and add with the result and addend one machine mode wider than the multiplicand and multiplier. All involved operations are saturating. */ OTI_ssmadd_widen, /* Unsigned multiply and add with the result and addend one machine mode wider than the multiplicand and multiplier. All involved operations are saturating. */ OTI_usmadd_widen, /* Signed multiply and subtract the result and minuend one machine mode wider than the multiplicand and multiplier. */ OTI_smsub_widen, /* Unsigned multiply and subtract the result and minuend one machine mode wider than the multiplicand and multiplier. */ OTI_umsub_widen, /* Signed multiply and subtract the result and minuend one machine mode wider than the multiplicand and multiplier. All involved operations are saturating. */ OTI_ssmsub_widen, /* Unsigned multiply and subtract the result and minuend one machine mode wider than the multiplicand and multiplier. All involved operations are saturating. */ OTI_usmsub_widen, /* Signed divide */ OTI_sdiv, OTI_sdivv, /* Signed <API key> in one */ OTI_sdivmod, OTI_udiv, OTI_udivmod, /* Signed remainder */ OTI_smod, OTI_umod, /* Floating point remainder functions */ OTI_fmod, OTI_remainder, /* Convert float to integer in float fmt */ OTI_ftrunc, /* Logical and */ OTI_and, /* Logical or */ OTI_ior, /* Logical xor */ OTI_xor, /* Arithmetic shift left */ OTI_ashl, /* Logical shift right */ OTI_lshr, /* Arithmetic shift right */ OTI_ashr, /* Rotate left */ OTI_rotl, /* Rotate right */ OTI_rotr, /* Arithmetic shift left of vector by vector */ OTI_vashl, /* Logical shift right of vector by vector */ OTI_vlshr, /* Arithmetic shift right of vector by vector */ OTI_vashr, /* Rotate left of vector by vector */ OTI_vrotl, /* Rotate right of vector by vector */ OTI_vrotr, /* Signed and floating-point minimum value */ OTI_smin, /* Signed and floating-point maximum value */ OTI_smax, /* Unsigned minimum value */ OTI_umin, /* Unsigned maximum value */ OTI_umax, /* Power */ OTI_pow, /* Arc tangent of y/x */ OTI_atan2, /* Move instruction. */ OTI_mov, /* Move, preserving high part of register. */ OTI_movstrict, /* Move, with a misaligned memory. */ OTI_movmisalign, /* Nontemporal store. */ OTI_storent, /* Unary operations */ /* Negation */ OTI_neg, OTI_negv, /* Abs value */ OTI_abs, OTI_absv, /* Byteswap */ OTI_bswap, /* Bitwise not */ OTI_one_cmpl, /* Bit scanning and counting */ OTI_ffs, OTI_clz, OTI_ctz, OTI_popcount, OTI_parity, /* Square root */ OTI_sqrt, /* Sine-Cosine */ OTI_sincos, /* Sine */ OTI_sin, /* Inverse sine */ OTI_asin, /* Cosine */ OTI_cos, /* Inverse cosine */ OTI_acos, /* Exponential */ OTI_exp, /* Base-10 Exponential */ OTI_exp10, /* Base-2 Exponential */ OTI_exp2, /* Exponential - 1*/ OTI_expm1, /* Load exponent of a floating point number */ OTI_ldexp, /* Multiply floating-point number by integral power of radix */ OTI_scalb, /* Radix-independent exponent */ OTI_logb, OTI_ilogb, /* Natural Logarithm */ OTI_log, /* Base-10 Logarithm */ OTI_log10, /* Base-2 Logarithm */ OTI_log2, /* logarithm of 1 plus argument */ OTI_log1p, /* Rounding functions */ OTI_floor, OTI_ceil, OTI_btrunc, OTI_round, OTI_nearbyint, OTI_rint, /* Tangent */ OTI_tan, /* Inverse tangent */ OTI_atan, /* Copy sign */ OTI_copysign, /* Signbit */ OTI_signbit, /* Test for infinite value */ OTI_isinf, /* Compare insn; two operands. */ OTI_cmp, /* Used only for libcalls for unsigned comparisons. */ OTI_ucmp, /* tst insn; compare one operand against 0 */ OTI_tst, /* Floating point comparison optabs - used primarily for libfuncs */ OTI_eq, OTI_ne, OTI_gt, OTI_ge, OTI_lt, OTI_le, OTI_unord, /* String length */ OTI_strlen, /* Combined compare & jump/store flags/move operations. */ OTI_cbranch, OTI_cmov, OTI_cstore, /* Push instruction. */ OTI_push, /* Conditional add instruction. */ OTI_addcc, /* Reduction operations on a vector operand. */ OTI_reduc_smax, OTI_reduc_umax, OTI_reduc_smin, OTI_reduc_umin, OTI_reduc_splus, OTI_reduc_uplus, /* Summation, with result machine mode one or more wider than args. */ OTI_ssum_widen, OTI_usum_widen, /* Dot product, with result machine mode one or more wider than args. */ OTI_sdot_prod, OTI_udot_prod, /* Set specified field of vector operand. */ OTI_vec_set, /* Extract specified field of vector operand. */ OTI_vec_extract, /* Extract even/odd fields of vector operands. */ <API key>, OTI_vec_extract_odd, /* Interleave fields of vector operands. */ <API key>, <API key>, /* Initialize vector operand. */ OTI_vec_init, /* Whole vector shift. The shift amount is in bits. */ OTI_vec_shl, OTI_vec_shr, /* Extract specified elements from vectors, for vector load. */ <API key>, /* Widening multiplication. The high/low part of the resulting vector of products is returned. */ <API key>, <API key>, <API key>, <API key>, /* Extract and widen the high/low part of a vector of signed or floating point elements. */ OTI_vec_unpacks_hi, OTI_vec_unpacks_lo, /* Extract and widen the high/low part of a vector of unsigned elements. */ OTI_vec_unpacku_hi, OTI_vec_unpacku_lo, /* Extract, convert to floating point and widen the high/low part of a vector of signed or unsigned integer elements. */ <API key>, <API key>, <API key>, <API key>, /* Narrow (demote) and merge the elements of two vectors. */ OTI_vec_pack_trunc, OTI_vec_pack_usat, OTI_vec_pack_ssat, /* Convert to signed/unsigned integer, narrow and merge elements of two vectors of floating point elements. */ <API key>, <API key>, /* Perform a raise to the power of integer. */ OTI_powi, OTI_MAX }; extern struct optab optab_table[OTI_MAX]; #define ssadd_optab (&optab_table[OTI_ssadd]) #define usadd_optab (&optab_table[OTI_usadd]) #define sssub_optab (&optab_table[OTI_sssub]) #define ussub_optab (&optab_table[OTI_ussub]) #define ssmul_optab (&optab_table[OTI_ssmul]) #define usmul_optab (&optab_table[OTI_usmul]) #define ssdiv_optab (&optab_table[OTI_ssdiv]) #define usdiv_optab (&optab_table[OTI_usdiv]) #define ssneg_optab (&optab_table[OTI_ssneg]) #define usneg_optab (&optab_table[OTI_usneg]) #define ssashl_optab (&optab_table[OTI_ssashl]) #define usashl_optab (&optab_table[OTI_usashl]) #define add_optab (&optab_table[OTI_add]) #define sub_optab (&optab_table[OTI_sub]) #define smul_optab (&optab_table[OTI_smul]) #define addv_optab (&optab_table[OTI_addv]) #define subv_optab (&optab_table[OTI_subv]) #define smul_highpart_optab (&optab_table[OTI_smul_highpart]) #define umul_highpart_optab (&optab_table[OTI_umul_highpart]) #define smul_widen_optab (&optab_table[OTI_smul_widen]) #define umul_widen_optab (&optab_table[OTI_umul_widen]) #define usmul_widen_optab (&optab_table[OTI_usmul_widen]) #define smadd_widen_optab (&optab_table[OTI_smadd_widen]) #define umadd_widen_optab (&optab_table[OTI_umadd_widen]) #define ssmadd_widen_optab (&optab_table[OTI_ssmadd_widen]) #define usmadd_widen_optab (&optab_table[OTI_usmadd_widen]) #define smsub_widen_optab (&optab_table[OTI_smsub_widen]) #define umsub_widen_optab (&optab_table[OTI_umsub_widen]) #define ssmsub_widen_optab (&optab_table[OTI_ssmsub_widen]) #define usmsub_widen_optab (&optab_table[OTI_usmsub_widen]) #define sdiv_optab (&optab_table[OTI_sdiv]) #define smulv_optab (&optab_table[OTI_smulv]) #define sdivv_optab (&optab_table[OTI_sdivv]) #define sdivmod_optab (&optab_table[OTI_sdivmod]) #define udiv_optab (&optab_table[OTI_udiv]) #define udivmod_optab (&optab_table[OTI_udivmod]) #define smod_optab (&optab_table[OTI_smod]) #define umod_optab (&optab_table[OTI_umod]) #define fmod_optab (&optab_table[OTI_fmod]) #define remainder_optab (&optab_table[OTI_remainder]) #define ftrunc_optab (&optab_table[OTI_ftrunc]) #define and_optab (&optab_table[OTI_and]) #define ior_optab (&optab_table[OTI_ior]) #define xor_optab (&optab_table[OTI_xor]) #define ashl_optab (&optab_table[OTI_ashl]) #define lshr_optab (&optab_table[OTI_lshr]) #define ashr_optab (&optab_table[OTI_ashr]) #define rotl_optab (&optab_table[OTI_rotl]) #define rotr_optab (&optab_table[OTI_rotr]) #define vashl_optab (&optab_table[OTI_vashl]) #define vlshr_optab (&optab_table[OTI_vlshr]) #define vashr_optab (&optab_table[OTI_vashr]) #define vrotl_optab (&optab_table[OTI_vrotl]) #define vrotr_optab (&optab_table[OTI_vrotr]) #define smin_optab (&optab_table[OTI_smin]) #define smax_optab (&optab_table[OTI_smax]) #define umin_optab (&optab_table[OTI_umin]) #define umax_optab (&optab_table[OTI_umax]) #define pow_optab (&optab_table[OTI_pow]) #define atan2_optab (&optab_table[OTI_atan2]) #define mov_optab (&optab_table[OTI_mov]) #define movstrict_optab (&optab_table[OTI_movstrict]) #define movmisalign_optab (&optab_table[OTI_movmisalign]) #define storent_optab (&optab_table[OTI_storent]) #define neg_optab (&optab_table[OTI_neg]) #define negv_optab (&optab_table[OTI_negv]) #define abs_optab (&optab_table[OTI_abs]) #define absv_optab (&optab_table[OTI_absv]) #define one_cmpl_optab (&optab_table[OTI_one_cmpl]) #define bswap_optab (&optab_table[OTI_bswap]) #define ffs_optab (&optab_table[OTI_ffs]) #define clz_optab (&optab_table[OTI_clz]) #define ctz_optab (&optab_table[OTI_ctz]) #define popcount_optab (&optab_table[OTI_popcount]) #define parity_optab (&optab_table[OTI_parity]) #define sqrt_optab (&optab_table[OTI_sqrt]) #define sincos_optab (&optab_table[OTI_sincos]) #define sin_optab (&optab_table[OTI_sin]) #define asin_optab (&optab_table[OTI_asin]) #define cos_optab (&optab_table[OTI_cos]) #define acos_optab (&optab_table[OTI_acos]) #define exp_optab (&optab_table[OTI_exp]) #define exp10_optab (&optab_table[OTI_exp10]) #define exp2_optab (&optab_table[OTI_exp2]) #define expm1_optab (&optab_table[OTI_expm1]) #define ldexp_optab (&optab_table[OTI_ldexp]) #define scalb_optab (&optab_table[OTI_scalb]) #define logb_optab (&optab_table[OTI_logb]) #define ilogb_optab (&optab_table[OTI_ilogb]) #define log_optab (&optab_table[OTI_log]) #define log10_optab (&optab_table[OTI_log10]) #define log2_optab (&optab_table[OTI_log2]) #define log1p_optab (&optab_table[OTI_log1p]) #define floor_optab (&optab_table[OTI_floor]) #define ceil_optab (&optab_table[OTI_ceil]) #define btrunc_optab (&optab_table[OTI_btrunc]) #define round_optab (&optab_table[OTI_round]) #define nearbyint_optab (&optab_table[OTI_nearbyint]) #define rint_optab (&optab_table[OTI_rint]) #define tan_optab (&optab_table[OTI_tan]) #define atan_optab (&optab_table[OTI_atan]) #define copysign_optab (&optab_table[OTI_copysign]) #define signbit_optab (&optab_table[OTI_signbit]) #define isinf_optab (&optab_table[OTI_isinf]) #define cmp_optab (&optab_table[OTI_cmp]) #define ucmp_optab (&optab_table[OTI_ucmp]) #define tst_optab (&optab_table[OTI_tst]) #define eq_optab (&optab_table[OTI_eq]) #define ne_optab (&optab_table[OTI_ne]) #define gt_optab (&optab_table[OTI_gt]) #define ge_optab (&optab_table[OTI_ge]) #define lt_optab (&optab_table[OTI_lt]) #define le_optab (&optab_table[OTI_le]) #define unord_optab (&optab_table[OTI_unord]) #define strlen_optab (&optab_table[OTI_strlen]) #define cbranch_optab (&optab_table[OTI_cbranch]) #define cmov_optab (&optab_table[OTI_cmov]) #define cstore_optab (&optab_table[OTI_cstore]) #define push_optab (&optab_table[OTI_push]) #define addcc_optab (&optab_table[OTI_addcc]) #define reduc_smax_optab (&optab_table[OTI_reduc_smax]) #define reduc_umax_optab (&optab_table[OTI_reduc_umax]) #define reduc_smin_optab (&optab_table[OTI_reduc_smin]) #define reduc_umin_optab (&optab_table[OTI_reduc_umin]) #define reduc_splus_optab (&optab_table[OTI_reduc_splus]) #define reduc_uplus_optab (&optab_table[OTI_reduc_uplus]) #define ssum_widen_optab (&optab_table[OTI_ssum_widen]) #define usum_widen_optab (&optab_table[OTI_usum_widen]) #define sdot_prod_optab (&optab_table[OTI_sdot_prod]) #define udot_prod_optab (&optab_table[OTI_udot_prod]) #define vec_set_optab (&optab_table[OTI_vec_set]) #define vec_extract_optab (&optab_table[OTI_vec_extract]) #define <API key> (&optab_table[<API key>]) #define <API key> (&optab_table[OTI_vec_extract_odd]) #define <API key> (&optab_table[<API key>]) #define <API key> (&optab_table[<API key>]) #define vec_init_optab (&optab_table[OTI_vec_init]) #define vec_shl_optab (&optab_table[OTI_vec_shl]) #define vec_shr_optab (&optab_table[OTI_vec_shr]) #define <API key> (&optab_table[<API key>]) #define <API key> (&optab_table[<API key>]) #define <API key> (&optab_table[<API key>]) #define <API key> (&optab_table[<API key>]) #define <API key> (&optab_table[<API key>]) #define <API key> (&optab_table[OTI_vec_unpacks_hi]) #define <API key> (&optab_table[OTI_vec_unpacks_lo]) #define <API key> (&optab_table[OTI_vec_unpacku_hi]) #define <API key> (&optab_table[OTI_vec_unpacku_lo]) #define <API key> (&optab_table[<API key>]) #define <API key> (&optab_table[<API key>]) #define <API key> (&optab_table[<API key>]) #define <API key> (&optab_table[<API key>]) #define <API key> (&optab_table[OTI_vec_pack_trunc]) #define vec_pack_ssat_optab (&optab_table[OTI_vec_pack_ssat]) #define vec_pack_usat_optab (&optab_table[OTI_vec_pack_usat]) #define <API key> (&optab_table[<API key>]) #define <API key> (&optab_table[<API key>]) #define powi_optab (&optab_table[OTI_powi]) /* Conversion optabs have their own table and indexes. */ enum convert_optab_index { COI_sext, COI_zext, COI_trunc, COI_sfix, COI_ufix, COI_sfixtrunc, COI_ufixtrunc, COI_sfloat, COI_ufloat, COI_lrint, COI_lround, COI_lfloor, COI_lceil, COI_fract, COI_fractuns, COI_satfract, COI_satfractuns, COI_MAX }; extern struct convert_optab convert_optab_table[COI_MAX]; #define sext_optab (&convert_optab_table[COI_sext]) #define zext_optab (&convert_optab_table[COI_zext]) #define trunc_optab (&convert_optab_table[COI_trunc]) #define sfix_optab (&convert_optab_table[COI_sfix]) #define ufix_optab (&convert_optab_table[COI_ufix]) #define sfixtrunc_optab (&convert_optab_table[COI_sfixtrunc]) #define ufixtrunc_optab (&convert_optab_table[COI_ufixtrunc]) #define sfloat_optab (&convert_optab_table[COI_sfloat]) #define ufloat_optab (&convert_optab_table[COI_ufloat]) #define lrint_optab (&convert_optab_table[COI_lrint]) #define lround_optab (&convert_optab_table[COI_lround]) #define lfloor_optab (&convert_optab_table[COI_lfloor]) #define lceil_optab (&convert_optab_table[COI_lceil]) #define fract_optab (&convert_optab_table[COI_fract]) #define fractuns_optab (&convert_optab_table[COI_fractuns]) #define satfract_optab (&convert_optab_table[COI_satfract]) #define satfractuns_optab (&convert_optab_table[COI_satfractuns]) /* These arrays record the insn_code of insns that may be needed to perform input and output reloads of special objects. They provide a place to pass a scratch register. */ extern enum insn_code reload_in_optab[NUM_MACHINE_MODES]; extern enum insn_code reload_out_optab[NUM_MACHINE_MODES]; /* Contains the optab used for each rtx code. */ extern optab code_to_optab[NUM_RTX_CODE + 1]; typedef rtx (*rtxfun) (rtx); /* Indexed by the rtx-code for a conditional (e.g. EQ, LT,...) gives the gen_function to make a branch to test that condition. */ extern rtxfun bcc_gen_fctn[NUM_RTX_CODE]; /* Indexed by the rtx-code for a conditional (e.g. EQ, LT,...) gives the insn code to make a store-condition insn to test that condition. */ extern enum insn_code setcc_gen_code[NUM_RTX_CODE]; #ifdef <API key> /* Indexed by the machine mode, gives the insn code to make a conditional move insn. */ extern enum insn_code movcc_gen_code[NUM_MACHINE_MODES]; #endif /* Indexed by the machine mode, gives the insn code for vector conditional operation. */ extern enum insn_code vcond_gen_code[NUM_MACHINE_MODES]; extern enum insn_code vcondu_gen_code[NUM_MACHINE_MODES]; /* This array records the insn_code of insns to perform block moves. */ extern enum insn_code movmem_optab[NUM_MACHINE_MODES]; /* This array records the insn_code of insns to perform block sets. */ extern enum insn_code setmem_optab[NUM_MACHINE_MODES]; /* These arrays record the insn_code of two different kinds of insns to perform block compares. */ extern enum insn_code cmpstr_optab[NUM_MACHINE_MODES]; extern enum insn_code cmpstrn_optab[NUM_MACHINE_MODES]; extern enum insn_code cmpmem_optab[NUM_MACHINE_MODES]; /* Synchronization primitives. This first set is atomic operation for which we don't care about the resulting value. */ extern enum insn_code sync_add_optab[NUM_MACHINE_MODES]; extern enum insn_code sync_sub_optab[NUM_MACHINE_MODES]; extern enum insn_code sync_ior_optab[NUM_MACHINE_MODES]; extern enum insn_code sync_and_optab[NUM_MACHINE_MODES]; extern enum insn_code sync_xor_optab[NUM_MACHINE_MODES]; extern enum insn_code sync_nand_optab[NUM_MACHINE_MODES]; /* This second set is atomic operations in which we return the value that existed in memory before the operation. */ extern enum insn_code sync_old_add_optab[NUM_MACHINE_MODES]; extern enum insn_code sync_old_sub_optab[NUM_MACHINE_MODES]; extern enum insn_code sync_old_ior_optab[NUM_MACHINE_MODES]; extern enum insn_code sync_old_and_optab[NUM_MACHINE_MODES]; extern enum insn_code sync_old_xor_optab[NUM_MACHINE_MODES]; extern enum insn_code sync_old_nand_optab[NUM_MACHINE_MODES]; /* This third set is atomic operations in which we return the value that resulted after performing the operation. */ extern enum insn_code sync_new_add_optab[NUM_MACHINE_MODES]; extern enum insn_code sync_new_sub_optab[NUM_MACHINE_MODES]; extern enum insn_code sync_new_ior_optab[NUM_MACHINE_MODES]; extern enum insn_code sync_new_and_optab[NUM_MACHINE_MODES]; extern enum insn_code sync_new_xor_optab[NUM_MACHINE_MODES]; extern enum insn_code sync_new_nand_optab[NUM_MACHINE_MODES]; /* Atomic compare and swap. */ extern enum insn_code <API key>[NUM_MACHINE_MODES]; extern enum insn_code <API key>[NUM_MACHINE_MODES]; /* Atomic exchange with acquire semantics. */ extern enum insn_code <API key>[NUM_MACHINE_MODES]; /* Atomic clear with release semantics. */ extern enum insn_code sync_lock_release[NUM_MACHINE_MODES]; /* Define functions given in optabs.c. */ extern rtx <API key> (tree exp, rtx op0, rtx op1, rtx wide_op, rtx target, int unsignedp); extern rtx expand_ternary_op (enum machine_mode mode, optab ternary_optab, rtx op0, rtx op1, rtx op2, rtx target, int unsignedp); /* Expand a binary operation given optab and rtx operands. */ extern rtx expand_binop (enum machine_mode, optab, rtx, rtx, rtx, int, enum optab_methods); extern bool force_expand_binop (enum machine_mode, optab, rtx, rtx, rtx, int, enum optab_methods); /* Expand a binary operation with both signed and unsigned forms. */ extern rtx sign_expand_binop (enum machine_mode, optab, optab, rtx, rtx, rtx, int, enum optab_methods); /* Generate code to perform an operation on one operand with two results. */ extern int expand_twoval_unop (optab, rtx, rtx, rtx, int); /* Generate code to perform an operation on two operands with two results. */ extern int expand_twoval_binop (optab, rtx, rtx, rtx, rtx, int); /* Generate code to perform an operation on two operands with two results, using a library function. */ extern bool <API key> (optab, rtx, rtx, rtx, rtx, enum rtx_code); /* Expand a unary arithmetic operation given optab rtx operand. */ extern rtx expand_unop (enum machine_mode, optab, rtx, rtx, int); /* Expand the absolute value operation. */ extern rtx expand_abs_nojump (enum machine_mode, rtx, rtx, int); extern rtx expand_abs (enum machine_mode, rtx, rtx, int, int); /* Expand the one's complement absolute value operation. */ extern rtx <API key> (enum machine_mode, rtx, rtx); /* Expand the copysign operation. */ extern rtx expand_copysign (rtx, rtx, rtx); /* Generate an instruction with a given INSN_CODE with an output and an input. */ extern void emit_unop_insn (int, rtx, rtx, enum rtx_code); extern bool <API key> (int, rtx, rtx, enum rtx_code); /* Emit one rtl insn to compare two rtx's. */ extern void emit_cmp_insn (rtx, rtx, enum rtx_code, rtx, enum machine_mode, int); /* An extra flag to control optab_for_tree_code's behavior. This is needed to distinguish between machines with a vector shift that takes a scalar for the shift amount vs. machines that take a vector for the shift amount. */ enum optab_subtype { optab_default, optab_scalar, optab_vector }; /* Return the optab used for computing the given operation on the type given by the second argument. The third argument distinguishes between the types of vector shifts and rotates */ extern optab optab_for_tree_code (enum tree_code, const_tree, enum optab_subtype); /* The various uses that a comparison can have; used by can_compare_p: jumps, conditional moves, store flag operations. */ enum can_compare_purpose { ccp_jump, ccp_cmov, ccp_store_flag }; /* Nonzero if a compare of mode MODE can be done straightforwardly (without splitting it into pieces). */ extern int can_compare_p (enum rtx_code, enum machine_mode, enum can_compare_purpose); /* Return the INSN_CODE to use for an extend operation. */ extern enum insn_code can_extend_p (enum machine_mode, enum machine_mode, int); /* Generate the body of an insn to extend Y (with mode MFROM) into X (with mode MTO). Do zero-extension if UNSIGNEDP is nonzero. */ extern rtx gen_extend_insn (rtx, rtx, enum machine_mode, enum machine_mode, int); /* Call this to reset the function entry for one optab. */ extern void set_optab_libfunc (optab, enum machine_mode, const char *); extern void set_conv_libfunc (convert_optab, enum machine_mode, enum machine_mode, const char *); /* Generate code for a FIXED_CONVERT_EXPR. */ extern void <API key> (rtx, rtx, int, int); /* Generate code for a FLOAT_EXPR. */ extern void expand_float (rtx, rtx, int); /* Generate code for a FIX_EXPR. */ extern void expand_fix (rtx, rtx, int); /* Generate code for float to integral conversion. */ extern bool expand_sfix_optab (rtx, rtx, convert_optab); /* Return tree if target supports vector operations for COND_EXPR. */ bool <API key> (tree, enum machine_mode); /* Generate code for VEC_COND_EXPR. */ extern rtx <API key> (tree, rtx); /* Generate code for VEC_LSHIFT_EXPR and VEC_RSHIFT_EXPR. */ extern rtx <API key> (tree, rtx); #define optab_handler(optab,mode) (&(optab)->handlers[(int) (mode)]) #define <API key>(optab,mode,mode2) \ (&(optab)->handlers[(int) (mode)][(int) (mode2)]) extern rtx optab_libfunc (optab optab, enum machine_mode mode); extern rtx optab_libfunc (optab optab, enum machine_mode mode); extern rtx <API key> (convert_optab optab, enum machine_mode mode1, enum machine_mode mode2); #endif /* GCC_OPTABS_H */
#include "includes.h" #include <stdlib.h> #include <strings.h> #include <math.h> #include <time.h> #include <unistd.h> #include <locale.h> #include <wchar.h> #include <panel.h> #include "terrain.h" #include "game.h" void DrawBorders(GameState *st) { wborder_set(st->gameScreen, &VERTICAL, &VERTICAL, &HORIZONTAL, &HORIZONTAL, &UL_CORNER, &T_UPRIGHT, &BL_CORNER, &BR_CORNER); wborder_set(st->guiScreen, &VERTICAL, &VERTICAL, &HORIZONTAL, &HORIZONTAL, &T_UPRIGHT, &UR_CORNER, &T_INVERSE, &BR_CORNER); } // State gamestate to a default, allowing for map restarts without losing points. void setState(GameState *st, Ship *sh) { sh->x = 2.0; sh->y = 2.0; sh->xvel = 1.8; sh->yvel = 2.0; sh->xaccel = 0.0; sh->yaccel = 10.0; sh->fuel = 1000; st->state = INTRO; } void GameFSM(GameState *st) { switch (st->state) { // State for the intro section, showing the welcome message. case INTRO: { mvwprintw(stdscr, 24, 20, "Lunar Lander"); mvwprintw(stdscr, 25, 20, "Press an arrow key to start"); wborder(stdscr, '|', '|', '-', '-', '+', '+', '+', '+'); if(st->ch == KEY_DOWN || st->ch == KEY_UP || st->ch == KEY_LEFT || st->ch == KEY_RIGHT) { st->state = MAPBUILD; clear(); } refresh(); break; } // State for building the map, connecting points. case MAPBUILD: { int points[21]; for(int i = 0; i < 16; i++) { float input = (float)i*(RandFloat(0.0, 1.0)*0.1); points[i] = (int)floor(PerlinNoise(input, 1, 32)); } DrawBorders(st); int padc = 3; for(int i = 0; i < 16; i++) { padc = ConnectPoint(st, points[i], points[i+1], 5, i*5, padc); } wrefresh(st->gameScreen); wrefresh(st->guiScreen); st->state = GAME; break; } // State containing game logic, checking inputs and physics. case GAME: { curs_set(0); for(int j = 0; j < st->height; j++) { for(int i = 0; i < st->width; i++) { mvwadd_wch(st->gameScreen, j, i, &st->map[j][i]); } } DrawBorders(st); int vertical = 0; int horizontal = 0; if(st->ch == KEY_DOWN) { vertical = 1; } else if (st->ch == KEY_UP) { vertical = -1; } if(st->ch == KEY_LEFT) { horizontal = -1; } else if (st->ch == KEY_RIGHT) { horizontal = 1; } if(horizontal != 0 || vertical != 0) { Thrusters(st->ship, vertical, horizontal); } int result = EnactPhysics(st); if(result == -1) { clear(); st->state = LOSE; } else if(result == 1){ clear(); st->state = WIN; } else if (result == 2) { clear(); st->state = WINBONUS; } mvwadd_wch(st->gameScreen, st->ship->y, st->ship->x, &st->ship->visual); DrawGameInfo(st); wrefresh(st->guiScreen); wrefresh(st->gameScreen); break; // Win state with bonus points for landing on a specific tile. case WINBONUS: curs_set(0); mvwprintw(st->gameScreen, 12, 12, "C O N G R A T U L A T I O N S !"); mvwprintw(st->gameScreen, 14, 12, "You earned %d points", st->ship->fuel+200); mvwprintw(st->gameScreen, 16, 12, "Press any arrow key to play again"); mvwprintw(st->gameScreen, 18, 12, "M O O N B A S E S U C C E S S !"); if(st->ch == KEY_DOWN || st->ch == KEY_UP || st->ch == KEY_LEFT || st->ch == KEY_RIGHT) { setState(st, st->ship); st->state = INTRO; st->Points = st->ship->fuel+200; clear(); } DrawGameInfo(st); wrefresh(st->gameScreen); wrefresh(st->guiScreen); break; // Normal win state for landing on any flat land under a certain speed. case WIN: curs_set(0); mvwprintw(st->gameScreen, 12, 12, "C O N G R A T U L A T I O N S !"); mvwprintw(st->gameScreen, 14, 12, "You earned %d points", st->ship->fuel+100); mvwprintw(st->gameScreen, 16, 12, "Press any arrow key to play again"); if(st->ch == KEY_DOWN || st->ch == KEY_UP || st->ch == KEY_LEFT || st->ch == KEY_RIGHT) { setState(st, st->ship); st->state = INTRO; st->Points = st->ship->fuel+100; clear(); } DrawGameInfo(st); wrefresh(st->gameScreen); wrefresh(st->guiScreen); break; // Landing at too high a speed or landing on uneven terrain. case LOSE: curs_set(0); mvwprintw(st->gameScreen, 12, 12, "Y O U L O S E"); mvwprintw(st->gameScreen, 14, 12, "You left a crater %.1f metres wide.", (float)st->ship->fuel/10); mvwprintw(st->gameScreen, 15, 12, "You lose 20 points."); mvwprintw(st->gameScreen, 16, 12, "Press any arrow key to play again"); if(st->ch == KEY_DOWN || st->ch == KEY_UP || st->ch == KEY_LEFT || st->ch == KEY_RIGHT) { setState(st, st->ship); st->state = INTRO; st->Points -= 20; clear(); } DrawGameInfo(st); wrefresh(st->gameScreen); wrefresh(st->guiScreen); break; } } } int main() { // Literally magic, not even the ncurses devs know what these things do anymore. setlocale(LC_ALL, ""); // For some reason emptying locale allows UTF-8 (?) set_altchars(); // Allows use of the keypad srand(time(NULL)); initscr(); // Initialize the screen keypad(stdscr, TRUE); // Double make sure we can use the keypad cbreak(); // These three lines ensure no garbage is printed to screen nonl(); // when inputs are used. noecho(); nodelay(stdscr, TRUE); // Don't block when waiting for input start_color(); // Enable colours init_pair(1, COLOR_WHITE, COLOR_GREEN); init_pair(2, COLOR_WHITE, COLOR_YELLOW); init_pair(3, COLOR_WHITE, COLOR_RED); WINDOW *gui_scr = newwin(20, 30, 1, 81); WINDOW *game_scr = newwin(40, 80, 1, 1); leaveok(gui_scr, TRUE); leaveok(game_scr, TRUE); Ship ship = { .visual = SHIP_SYMBOL, .x = 2.0, .y = 2.0, .xvel = 1.8, .yvel = 2, .xaccel = 0.0, .yaccel = 10.0, .fuel = 1000}; GameState state = { .state = INTRO, .ship = &ship, .gameScreen = game_scr, .guiScreen = gui_scr, .width = 80, .height = 50, .deltatime = 0 }; InitializeMap(&state.map, state.width, state.height); struct timespec elapsed; long previousTime = 0; for (;;) { clock_gettime(CLOCK_MONOTONIC, &elapsed); if(elapsed.tv_nsec > previousTime) { state.deltatime = (double)(elapsed.tv_nsec - previousTime)*1.0e-9; previousTime = elapsed.tv_nsec; } int c = getch(); if(c==27) { break; } state.ch = c; GameFSM(&state); curs_set(0); usleep(1/60); } endwin(); }
#include <xen/config.h> #include <xen/init.h> #include <xen/lib.h> #include <xen/compat.h> #include <xen/dmi.h> #include <asm/e820.h> #include <asm/page.h> /* opt_mem: Limit of physical RAM. Any RAM beyond this point is ignored. */ unsigned long long opt_mem; static void parse_mem(char *s) { opt_mem = parse_size_and_unit(s, NULL); } custom_param("mem", parse_mem); struct e820map e820; static void __init add_memory_region(unsigned long long start, unsigned long long size, int type) { int x; /*if (!efi_enabled)*/ { x = e820.nr_map; if (x == E820MAX) { printk(KERN_ERR "Ooops! Too many entries in the memory map!\n"); return; } e820.map[x].addr = start; e820.map[x].size = size; e820.map[x].type = type; e820.nr_map++; } } /* add_memory_region */ static void __init <API key>(struct e820entry *map, int entries) { int i; for (i = 0; i < entries; i++) { printk(" %016Lx - %016Lx ", (unsigned long long)(map[i].addr), (unsigned long long)(map[i].addr + map[i].size)); switch (map[i].type) { case E820_RAM: printk("(usable)\n"); break; case E820_RESERVED: printk("(reserved)\n"); break; case E820_ACPI: printk("(ACPI data)\n"); break; case E820_NVS: printk("(ACPI NVS)\n"); break; case E820_UNUSABLE: printk("(unusable)\n"); break; default: printk("type %u\n", map[i].type); break; } } } /* * Sanitize the BIOS e820 map. * * Some e820 responses include overlapping entries. The following * replaces the original e820 map with a new one, removing overlaps. * */ struct change_member { struct e820entry *pbios; /* pointer to original bios entry */ unsigned long long addr; /* address for this change point */ }; static struct change_member change_point_list[2*E820MAX] __initdata; static struct change_member *change_point[2*E820MAX] __initdata; static struct e820entry *overlap_list[E820MAX] __initdata; static struct e820entry new_bios[E820MAX] __initdata; static int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map) { struct change_member *change_tmp; unsigned long current_type, last_type; unsigned long long last_addr; int chgidx, still_changing; int overlap_entries; int new_bios_entry; int old_nr, new_nr, chg_nr; int i; /* Visually we're performing the following (1,2,3,4 = memory types)... Sample memory map (w/overlaps): <API key> <API key> <API key> <API key> <API key> <API key> <API key> <API key> <API key> <API key> <API key> <API key> <API key> Sanitized equivalent (no overlap): <API key> <API key> <API key> <API key> <API key> <API key> <API key> <API key> <API key> <API key> <API key> <API key> <API key> <API key> <API key> */ /* if there's only one memory region, don't bother */ if (*pnr_map < 2) return -1; old_nr = *pnr_map; /* bail out if we find any unreasonable addresses in bios map */ for (i=0; i<old_nr; i++) if (biosmap[i].addr + biosmap[i].size < biosmap[i].addr) return -1; /* create pointers for initial change-point information (for sorting) */ for (i=0; i < 2*old_nr; i++) change_point[i] = &change_point_list[i]; /* record all known change-points (starting and ending addresses), omitting those that are for empty memory regions */ chgidx = 0; for (i=0; i < old_nr; i++) { if (biosmap[i].size != 0) { change_point[chgidx]->addr = biosmap[i].addr; change_point[chgidx++]->pbios = &biosmap[i]; change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size; change_point[chgidx++]->pbios = &biosmap[i]; } } chg_nr = chgidx; /* true number of change-points */ /* sort change-point list by memory addresses (low -> high) */ still_changing = 1; while (still_changing) { still_changing = 0; for (i=1; i < chg_nr; i++) { /* if <current_addr> > <last_addr>, swap */ /* or, if current=<start_addr> & last=<end_addr>, swap */ if ((change_point[i]->addr < change_point[i-1]->addr) || ((change_point[i]->addr == change_point[i-1]->addr) && (change_point[i]->addr == change_point[i]->pbios->addr) && (change_point[i-1]->addr != change_point[i-1]->pbios->addr)) ) { change_tmp = change_point[i]; change_point[i] = change_point[i-1]; change_point[i-1] = change_tmp; still_changing=1; } } } /* create a new bios memory map, removing overlaps */ overlap_entries=0; /* number of entries in the overlap table */ new_bios_entry=0; /* index for creating new bios map entries */ last_type = 0; /* start with undefined memory type */ last_addr = 0; /* start with 0 as last starting address */ /* loop through change-points, determining affect on the new bios map */ for (chgidx=0; chgidx < chg_nr; chgidx++) { /* keep track of all overlapping bios entries */ if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr) { /* add map entry to overlap list (> 1 entry implies an overlap) */ overlap_list[overlap_entries++]=change_point[chgidx]->pbios; } else { /* remove entry from list (order independent, so swap with last) */ for (i=0; i<overlap_entries; i++) { if (overlap_list[i] == change_point[chgidx]->pbios) overlap_list[i] = overlap_list[overlap_entries-1]; } overlap_entries } /* if there are overlapping entries, decide which "type" to use */ /* (larger value takes precedence -- 1=usable, 2,3,4,4+=unusable) */ current_type = 0; for (i=0; i<overlap_entries; i++) if (overlap_list[i]->type > current_type) current_type = overlap_list[i]->type; /* continue building up new bios map based on this information */ if (current_type != last_type) { if (last_type != 0) { new_bios[new_bios_entry].size = change_point[chgidx]->addr - last_addr; /* move forward only if the new size was non-zero */ if (new_bios[new_bios_entry].size != 0) if (++new_bios_entry >= E820MAX) break; /* no more space left for new bios entries */ } if (current_type != 0) { new_bios[new_bios_entry].addr = change_point[chgidx]->addr; new_bios[new_bios_entry].type = current_type; last_addr=change_point[chgidx]->addr; } last_type = current_type; } } new_nr = new_bios_entry; /* retain count for new bios entries */ /* copy new bios mapping into original location */ memcpy(biosmap, new_bios, new_nr*sizeof(struct e820entry)); *pnr_map = new_nr; return 0; } /* * Copy the BIOS e820 map into a safe place. * * Sanity-check it while we're at it.. * * If we're lucky and live on a modern system, the setup code * will have given us a memory map that we can use to properly * set up memory. If we aren't, we'll fake a memory map. * * We check to see that the memory map contains at least 2 elements * before we'll use it, because the detection code in setup.S may * not be perfect and most every PC known to man has two memory * regions: one from 0 to 640k, and one from 1mb up. (The IBM * thinkpad 560x, for example, does not cooperate with the memory * detection code.) */ static int __init copy_e820_map(struct e820entry * biosmap, int nr_map) { /* Only one memory region (or negative)? Ignore it */ if (nr_map < 2) return -1; do { unsigned long long start = biosmap->addr; unsigned long long size = biosmap->size; unsigned long long end = start + size; unsigned long type = biosmap->type; /* Overflow in 64 bits? Ignore the memory map. */ if (start > end) return -1; /* * Some BIOSes claim RAM in the 640k - 1M region. * Not right. Fix it up. */ if (type == E820_RAM) { if (start < 0x100000ULL && end > 0xA0000ULL) { if (start < 0xA0000ULL) add_memory_region(start, 0xA0000ULL-start, type); if (end <= 0x100000ULL) continue; start = 0x100000ULL; size = end - start; } } add_memory_region(start, size, type); } while (biosmap++,--nr_map); return 0; } /* * Find the highest page frame number we have available */ static unsigned long __init find_max_pfn(void) { int i; unsigned long max_pfn = 0; #if 0 if (efi_enabled) { efi_memmap_walk(efi_find_max_pfn, &max_pfn); return; } #endif for (i = 0; i < e820.nr_map; i++) { unsigned long start, end; /* RAM? */ if (e820.map[i].type != E820_RAM) continue; start = PFN_UP(e820.map[i].addr); end = PFN_DOWN(e820.map[i].addr + e820.map[i].size); if (start >= end) continue; if (end > max_pfn) max_pfn = end; } return max_pfn; } static void __init clip_to_limit(uint64_t limit, char *warnmsg) { int i; char _warnmsg[160]; for ( i = 0; i < e820.nr_map; i++ ) { if ( (e820.map[i].addr + e820.map[i].size) <= limit ) continue; if ( warnmsg ) { snprintf(_warnmsg, sizeof(_warnmsg), warnmsg, (int)(limit>>30)); printk("WARNING: %s\n", _warnmsg); } printk("Truncating memory map to %lukB\n", (unsigned long)(limit >> 10)); if ( e820.map[i].addr >= limit ) { e820.nr_map = i; } else { e820.map[i].size = limit - e820.map[i].addr; e820.nr_map = i + 1; } } } static void __init reserve_dmi_region(void) { u32 base, len; if ( (dmi_get_table(&base, &len) == 0) && ((base + len) > base) && reserve_e820_ram(&e820, base, base + len) ) printk("WARNING: DMI table located in E820 RAM %08x-%08x. Fixed.\n", base, base+len); } static void __init <API key>( struct e820entry *raw, int *raw_nr) { char nr = (char)*raw_nr; sanitize_e820_map(raw, &nr); *raw_nr = nr; (void)copy_e820_map(raw, nr); if ( opt_mem ) clip_to_limit(opt_mem, NULL); #ifdef __i386__ clip_to_limit((1ULL << 30) * MACHPHYS_MBYTES, "Only the first %u GB of the physical memory map " "can be accessed by Xen in 32-bit mode."); #endif reserve_dmi_region(); } /* Reserve RAM area (@s,@e) in the specified e820 map. */ int __init reserve_e820_ram(struct e820map *e820, uint64_t s, uint64_t e) { uint64_t rs = 0, re = 0; int i; for ( i = 0; i < e820->nr_map; i++ ) { /* Have we found the e820 region that includes the specified range? */ rs = e820->map[i].addr; re = rs + e820->map[i].size; if ( (s >= rs) && (e <= re) ) break; } if ( (i == e820->nr_map) || (e820->map[i].type != E820_RAM) ) return 0; if ( (s == rs) && (e == re) ) { /* Complete excision. */ memmove(&e820->map[i], &e820->map[i+1], (e820->nr_map-i-1) * sizeof(e820->map[0])); e820->nr_map } else if ( s == rs ) { /* Truncate start. */ e820->map[i].addr += e - s; e820->map[i].size -= e - s; } else if ( e == re ) { /* Truncate end. */ e820->map[i].size -= e - s; } else if ( e820->nr_map < ARRAY_SIZE(e820->map) ) { /* Split in two. */ memmove(&e820->map[i+1], &e820->map[i], (e820->nr_map-i) * sizeof(e820->map[0])); e820->nr_map++; e820->map[i].size = s - rs; i++; e820->map[i].addr = e; e820->map[i].size = re - e; } else { /* e820map is at maximum size. We have to leak some space. */ if ( (s - rs) > (re - e) ) { printk("e820 overflow: leaking RAM %"PRIx64"-%"PRIx64"\n", e, re); e820->map[i].size = s - rs; } else { printk("e820 overflow: leaking RAM %"PRIx64"-%"PRIx64"\n", rs, s); e820->map[i].addr = e; e820->map[i].size = re - e; } } return 1; } unsigned long __init init_e820( const char *str, struct e820entry *raw, int *raw_nr) { <API key>(raw, raw_nr); printk("%s RAM map:\n", str); <API key>(e820.map, e820.nr_map); return find_max_pfn(); }
buttonui ===== a button for a ui
<?php class ElggDiskFilestore extends ElggFilestore { /** * Directory root. */ private $dir_root; /** * Default depth of file directory matrix */ private $matrix_depth = 5; /** * Construct a disk filestore using the given directory root. * * @param string $directory_root Root directory, must end in "/" */ public function __construct($directory_root = "") { global $CONFIG; if ($directory_root) { $this->dir_root = $directory_root; } else { $this->dir_root = $CONFIG->dataroot; } } /** * Open a file for reading, writing, or both. * * @note All files are opened binary safe. * @warning This will try to create the a directory if it doesn't exist, * even in read-only mode. * * @param ElggFile $file The file to open * @param string $mode read, write, or append. * * @throws <API key> * @return resource File pointer resource * @todo This really shouldn't try to create directories if not writing. */ public function open(ElggFile $file, $mode) { $fullname = $this-><API key>($file); // Split into path and name $ls = strrpos($fullname, "/"); if ($ls === false) { $ls = 0; } $path = substr($fullname, 0, $ls); $name = substr($fullname, $ls); // @todo $name is unused, remove it or do we need to fix something? // Try and create the directory try { $this->makeDirectoryRoot($path); } catch (Exception $e) { } if (($mode != 'write') && (!file_exists($fullname))) { return false; } switch ($mode) { case "read" : $mode = "rb"; break; case "write" : $mode = "w+b"; break; case "append" : $mode = "a+b"; break; default: $msg = elgg_echo('<API key>:<API key>', array($mode)); throw new <API key>($msg); } return fopen($fullname, $mode); } /** * Write data to a file. * * @param resource $f File pointer resource * @param mixed $data The data to write. * * @return bool */ public function write($f, $data) { return fwrite($f, $data); } /** * Read data from a file. * * @param resource $f File pointer resource * @param int $length The number of bytes to read * @param int $offset The number of bytes to start after * * @return mixed Contents of file or false on fail. */ public function read($f, $length, $offset = 0) { if ($offset) { $this->seek($f, $offset); } return fread($f, $length); } /** * Close a file pointer * * @param resource $f A file pointer resource * * @return bool */ public function close($f) { return fclose($f); } /** * Delete an ElggFile file. * * @param ElggFile $file File to delete * * @return bool */ public function delete(ElggFile $file) { $filename = $this-><API key>($file); if (file_exists($filename)) { return unlink($filename); } else { return true; } } /** * Seek to the specified position. * * @param resource $f File resource * @param int $position Position in bytes * * @return bool */ public function seek($f, $position) { return fseek($f, $position); } /** * Return the current location of the internal pointer * * @param resource $f File pointer resource * * @return int|false */ public function tell($f) { return ftell($f); } /** * Tests for end of file on a file pointer * * @param resource $f File pointer resource * * @return bool */ public function eof($f) { return feof($f); } /** * Returns the file size of an ElggFile file. * * @param ElggFile $file File object * * @return int The file size */ public function getFileSize(ElggFile $file) { return filesize($this-><API key>($file)); } /** * Returns the filename as saved on disk for an ElggFile object * * @param ElggFile $file File object * * @return string The full path of where the file is stored * @throws <API key> */ public function <API key>(ElggFile $file) { $owner_guid = $file->getOwnerGuid(); if (!$owner_guid) { $owner_guid = <API key>(); } if (!$owner_guid) { $msg = elgg_echo('<API key>:MissingOwner', array($file->getFilename(), $file->guid)); throw new <API key>($msg); } return $this->dir_root . $this->makefileMatrix($owner_guid) . $file->getFilename(); } /** * Returns the contents of the ElggFile file. * * @param ElggFile $file File object * * @return mixed */ public function grabFile(ElggFile $file) { return file_get_contents($file-><API key>()); } /** * Tests if an ElggFile file exists. * * @param ElggFile $file File object * * @return bool */ public function exists(ElggFile $file) { return file_exists($this-><API key>($file)); } /** * Returns the size of all data stored under a directory in the disk store. * * @param string $prefix Optional/ The prefix to check under. * @param string $container_guid The guid of the entity whose data you want to check. * * @return int|false */ public function getSize($prefix = '', $container_guid) { if ($container_guid) { return get_dir_size($this->dir_root . $this->makefileMatrix($container_guid) . $prefix); } else { return false; } } // @<API key> /** * Create a directory $dirroot * * @param string $dirroot The full path of the directory to create * * @throws IOException * @return true * @deprecated 1.8 Use ElggDiskFilestore::makeDirectoryRoot() */ protected function make_directory_root($dirroot) { <API key>('ElggDiskFilestore::make_directory_root() is deprecated by ::makeDirectoryRoot()', 1.8); return $this->makeDirectoryRoot($dirroot); } // @<API key> /** * Create a directory $dirroot * * @param string $dirroot The full path of the directory to create * * @throws IOException * @return true */ protected function makeDirectoryRoot($dirroot) { if (!file_exists($dirroot)) { if (!@mkdir($dirroot, 0700, true)) { throw new IOException(elgg_echo('IOException:CouldNotMake', array($dirroot))); } } return true; } // @<API key> /** * Multibyte string tokeniser. * * Splits a string into an array. Will fail safely if mbstring is * not installed. * * @param string $string String * @param string $charset The charset, defaults to UTF8 * * @return array * @deprecated 1.8 Files are stored by date and guid; no need for this. */ private function mb_str_split($string, $charset = 'UTF8') { <API key>('ElggDiskFilestore::mb_str_split() is deprecated.', 1.8); if (is_callable('mb_substr')) { $length = mb_strlen($string); $array = array(); while ($length) { $array[] = mb_substr($string, 0, 1, $charset); $string = mb_substr($string, 1, $length, $charset); $length = mb_strlen($string); } return $array; } else { return str_split($string); } } // @<API key> // @<API key> /** * Construct a file path matrix for an entity. * * @param int $identifier The guide of the entity to store the data under. * * @return string The path where the entity's data will be stored. * @deprecated 1.8 Use ElggDiskFilestore::makeFileMatrix() */ protected function make_file_matrix($identifier) { <API key>('ElggDiskFilestore::make_file_matrix() is deprecated by ::makeFileMatrix()', 1.8); return $this->makefileMatrix($identifier); } // @<API key> /** * Construct a file path matrix for an entity. * * @param int $guid The guide of the entity to store the data under. * * @return string The path where the entity's data will be stored. */ protected function makeFileMatrix($guid) { $entity = get_entity($guid); if (!($entity instanceof ElggEntity) || !$entity->time_created) { return false; } $time_created = date('Y/m/d', $entity->time_created); return "$time_created/$entity->guid/"; } // @<API key> /** * Construct a filename matrix. * * Generates a matrix using the entity's creation time and * unique guid. * * File path matrixes are: * YYYY/MM/DD/guid/ * * @param int $guid The entity to contrust a matrix for * * @return string The */ protected function user_file_matrix($guid) { <API key>('ElggDiskFilestore::user_file_matrix() is deprecated by ::makeFileMatrix()', 1.8); return $this->makeFileMatrix($guid); } // @<API key> /** * Returns a list of attributes to save to the database when saving * the ElggFile object using this file store. * * @return array */ public function getParameters() { return array("dir_root" => $this->dir_root); } /** * Sets parameters that should be saved to database. * * @param array $parameters Set parameters to save to DB for this filestore. * * @return bool */ public function setParameters(array $parameters) { if (isset($parameters['dir_root'])) { $this->dir_root = $parameters['dir_root']; return true; } return false; } }
# -*- coding: utf-8 -*- # tvalacarta - XBMC Plugin # Canal para Ecuador TV import urlparse,re import urllib import os from core import logger from core import scrapertools from core.item import Item DEBUG = False CHANNELNAME = "ecuadortv" def isGeneric(): return True def mainlist(item): logger.info("tvalacarta.channels.ecuadortv mainlist") return programas(item) def programas(item): logger.info("tvalacarta.channels.ecuadortv canal") item.url = "http: itemlist = [] data = scrapertools.cache_page(item.url) # Extrae las zonas de los programas patron = '<div class="field-item even"[^<]+' patron += '<a href="([^"]+)"[^<]+' patron += '<img typeof="foaf.Image" src="([^"]+)".*?' patron += '<h2>([^<]+)</h2>' matches = re.compile(patron,re.DOTALL).findall(data) for scrapedurl,scrapedthumbnail,scrapedtitle in matches: title = scrapedtitle.strip() url = urlparse.urljoin(item.url,scrapedurl) thumbnail = scrapedthumbnail plot = "" itemlist.append( Item(channel=CHANNELNAME, title=title , url=url, thumbnail=thumbnail, plot=plot, action="episodios", show=title, folder=True) ) return itemlist def episodios(item): logger.info("tvalacarta.channels.ecuadortv episodios") itemlist = [] data = scrapertools.cache_page(item.url) # Extrae las zonas de los videos patron = '<div class="item-thumbnail"[^<]+' patron += '<div class="field[^<]+' patron += '<div class="field[^<]+' patron += '<div class="field[^<]+' patron += '<a href="[^"]+" class="[^"]+" data-video-id="([^"]+)"[^<]+' patron += '<span class="img"[^<]+' patron += '<img src="([^"]+)"[^<]+' patron += '</span[^<]+' patron += '<span[^<]+</span[^<]+</a[^<]+</div[^<]+</div[^<]+</div[^<]+</div[^<]+' patron += '<div class="slider_caption[^<]+' patron += '<div class="field[^<]+' patron += '<div class="field[^<]+' patron += '<div class="field[^<]+' patron += '<h2>([^<]+)</h2' matches = re.compile(patron,re.DOTALL).findall(data) for youtube_id,scrapedthumbnail,scrapedtitle in matches: title = scrapedtitle url = "https: thumbnail = scrapedthumbnail plot = "" itemlist.append( Item(channel=CHANNELNAME, title=title , url=url, thumbnail=thumbnail, plot=plot, action="play", server="youtube", show=item.show, folder=False) ) return itemlist def test(): categorias_items = mainlist(Item()) programas_items = programas(categorias_items[0]) episodios_items = episodios(programas_items[0]) if len(episodios_items)>0: return True return False
<?php declare(strict_types=1); namespace oat\taoQtiItem\model\import\Parser; interface <API key> { public function parse(array $line, array $rules, array $fields); }
#ifndef _LINUX_CPUFREQ_H #define _LINUX_CPUFREQ_H #include <linux/mutex.h> #include <linux/notifier.h> #include <linux/threads.h> #include <linux/kobject.h> #include <linux/sysfs.h> #include <linux/completion.h> #include <linux/workqueue.h> #include <linux/cpumask.h> #include <asm/div64.h> #define CPUFREQ_NAME_LEN 16 #define <API key> (0) #define <API key> (1) #ifdef CONFIG_CPU_FREQ int <API key>(struct notifier_block *nb, unsigned int list); int <API key>(struct notifier_block *nb, unsigned int list); extern void disable_cpufreq(void); #else /* CONFIG_CPU_FREQ */ static inline int <API key>(struct notifier_block *nb, unsigned int list) { return 0; } static inline int <API key>(struct notifier_block *nb, unsigned int list) { return 0; } static inline void disable_cpufreq(void) { } #endif /* CONFIG_CPU_FREQ */ /* if (cpufreq_driver->target) exists, the ->governor decides what frequency * within the limits is used. If (cpufreq_driver->setpolicy> exists, these * two generic policies are available: */ #define <API key> (1) #define <API key> (2) /* Minimum frequency cutoff to notify the userspace about cpu utilization * changes */ #define MIN_CPU_UTIL_NOTIFY 40 /* Frequency values here are CPU kHz so that hardware which doesn't run * with some frequencies can complain without having to guess what per * cent / per mille means. * Maximum transition latency is in nanoseconds - if it's unknown, * CPUFREQ_ETERNAL shall be used. */ struct cpufreq_governor; /* /sys/devices/system/cpu/cpufreq: entry point for global variables */ extern struct kobject *<API key>; #define CPUFREQ_ETERNAL (-1) struct cpufreq_cpuinfo { unsigned int max_freq; unsigned int min_freq; /* in 10^(-9) s = nanoseconds */ unsigned int transition_latency; }; struct cpufreq_real_policy { unsigned int min; /* in kHz */ unsigned int max; /* in kHz */ unsigned int policy; /* see above */ struct cpufreq_governor *governor; /* see below */ }; struct cpufreq_policy { cpumask_var_t cpus; /* CPUs requiring sw coordination */ cpumask_var_t related_cpus; /* CPUs with any coordination */ unsigned int shared_type; /* ANY or ALL affected CPUs should set cpufreq */ unsigned int cpu; /* cpu nr of registered CPU */ struct cpufreq_cpuinfo cpuinfo;/* see above */ unsigned int min; /* in kHz */ unsigned int max; /* in kHz */ unsigned int cur; /* in kHz, only needed if cpufreq * governors are used */ unsigned int util; /* CPU utilization at max frequency */ unsigned int policy; /* see above */ struct cpufreq_governor *governor; /* see below */ struct work_struct update; /* if update_policy() needs to be * called, but you're in IRQ context */ struct cpufreq_real_policy user_policy; struct kobject kobj; struct completion kobj_unregister; }; #define CPUFREQ_ADJUST (0) #define <API key> (1) #define CPUFREQ_NOTIFY (2) #define CPUFREQ_START (3) #define <API key> (0) /* None */ #define <API key> (1) /* HW does needed coordination */ #define <API key> (2) /* All dependent CPUs should set freq */ #define <API key> (3) /* Freq can be set from any dependent CPU*/ #define CPUFREQ_PRECHANGE (0) #define CPUFREQ_POSTCHANGE (1) #define <API key> (8) #define <API key> (9) struct cpufreq_freqs { unsigned int cpu; /* cpu nr */ unsigned int old; unsigned int new; u8 flags; /* flags of cpufreq_driver, see below. */ }; /** * cpufreq_scale - "old * mult / div" calculation for large values (32-bit-arch safe) * @old: old value * @div: divisor * @mult: multiplier * * * new = old * mult / div */ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mult) { #if BITS_PER_LONG == 32 u64 result = ((u64) old) * ((u64) mult); do_div(result, div); return (unsigned long) result; #elif BITS_PER_LONG == 64 unsigned long result = old * ((u64) mult); result /= div; return result; #endif }; #define CPUFREQ_GOV_START 1 #define CPUFREQ_GOV_STOP 2 #define CPUFREQ_GOV_LIMITS 3 struct cpufreq_governor { char name[CPUFREQ_NAME_LEN]; int (*governor) (struct cpufreq_policy *policy, unsigned int event); ssize_t (*show_setspeed) (struct cpufreq_policy *policy, char *buf); int (*store_setspeed) (struct cpufreq_policy *policy, unsigned int freq); unsigned int <API key>; /* HW must be able to switch to next freq faster than this value in nano secs or we will fallback to performance governor */ struct list_head governor_list; struct module *owner; }; /* * Pass a target to the cpufreq driver. */ extern int <API key>(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation); extern int <API key>(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation); extern int <API key>(struct cpufreq_policy *policy, unsigned int cpu); int <API key>(struct cpufreq_governor *governor); void <API key>(struct cpufreq_governor *governor); int <API key>(int cpu); void <API key>(int cpu); #define CPUFREQ_RELATION_L 0 /* lowest frequency at or above target */ #define CPUFREQ_RELATION_H 1 /* highest frequency below or at target */ struct freq_attr; struct cpufreq_driver { struct module *owner; char name[CPUFREQ_NAME_LEN]; u8 flags; /* needed by all drivers */ int (*init) (struct cpufreq_policy *policy); int (*verify) (struct cpufreq_policy *policy); /* define one out of two */ int (*setpolicy) (struct cpufreq_policy *policy); int (*target) (struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation); /* should be defined, if possible */ unsigned int (*get) (unsigned int cpu); /* optional */ unsigned int (*getavg) (struct cpufreq_policy *policy, unsigned int cpu); int (*bios_limit) (int cpu, unsigned int *limit); int (*exit) (struct cpufreq_policy *policy); int (*suspend) (struct cpufreq_policy *policy); int (*resume) (struct cpufreq_policy *policy); struct freq_attr **attr; }; /* flags */ #define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if * all ->init() calls failed */ #define CPUFREQ_CONST_LOOPS 0x02 /* loops_per_jiffy or other kernel * "constants" aren't affected by * frequency transitions */ #define CPUFREQ_PM_NO_WARN 0x04 /* don't warn on suspend/resume speed * mismatches */ int <API key>(struct cpufreq_driver *driver_data); int <API key>(struct cpufreq_driver *driver_data); void <API key>(struct cpufreq_freqs *freqs, unsigned int state); void <API key>(struct cpufreq_policy *policy, unsigned int load); static inline void <API key>(struct cpufreq_policy *policy, unsigned int min, unsigned int max) { if (policy->min < min) policy->min = min; if (policy->max < min) policy->max = min; if (policy->min > max) policy->min = max; if (policy->max > max) policy->max = max; if (policy->min > policy->max) policy->min = policy->max; return; } struct freq_attr { struct attribute attr; ssize_t (*show)(struct cpufreq_policy *, char *); ssize_t (*store)(struct cpufreq_policy *, const char *, size_t count); }; #define <API key>(_name) \ static struct freq_attr _name = \ __ATTR(_name, 0444, show_##_name, NULL) #define <API key>(_name, _perm) \ static struct freq_attr _name = \ __ATTR(_name, _perm, show_##_name, NULL) #define <API key>(_name) \ static struct freq_attr _name = \ __ATTR(_name, 0644, show_##_name, store_##_name) struct global_attr { struct attribute attr; ssize_t (*show)(struct kobject *kobj, struct attribute *attr, char *buf); ssize_t (*store)(struct kobject *a, struct attribute *b, const char *c, size_t count); }; #define <API key>(_name) \ static struct global_attr _name = \ __ATTR(_name, 0444, show_##_name, NULL) #define <API key>(_name) \ static struct global_attr _name = \ __ATTR(_name, 0644, show_##_name, store_##_name) int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); int <API key>(unsigned int cpu); #ifdef CONFIG_CPU_FREQ /* query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it */ unsigned int cpufreq_get(unsigned int cpu); #else static inline unsigned int cpufreq_get(unsigned int cpu) { return 0; } #endif /* query the last known CPU freq (in kHz). If zero, cpufreq couldn't detect it */ #ifdef CONFIG_CPU_FREQ unsigned int cpufreq_quick_get(unsigned int cpu); unsigned int <API key>(unsigned int cpu); #else static inline unsigned int cpufreq_quick_get(unsigned int cpu) { return 0; } static inline unsigned int <API key>(unsigned int cpu) { return 0; } #endif /* Performance governor is fallback governor if any other gov failed to auto load due latency restrictions */ #ifdef <API key> extern struct cpufreq_governor <API key>; #endif #ifdef <API key> #define <API key> (&<API key>) #elif defined(<API key>) extern struct cpufreq_governor <API key>; #define <API key> (&<API key>) #elif defined(<API key>) extern struct cpufreq_governor <API key>; #define <API key> (&<API key>) #elif defined(<API key>) extern struct cpufreq_governor <API key>; #define <API key> (&<API key>) #elif defined(<API key>) extern struct cpufreq_governor <API key>; #define <API key> (&<API key>) #elif defined(<API key>) extern struct cpufreq_governor <API key>; #define <API key> (&<API key>) #elif defined(<API key>) extern struct cpufreq_governor <API key>; #define <API key> (&<API key>) #elif defined(<API key>) extern struct cpufreq_governor <API key>; #define <API key> (&<API key>) #endif #define <API key> ~0 #define CPUFREQ_TABLE_END ~1 struct <API key> { unsigned int index; /* any */ unsigned int frequency; /* kHz - doesn't need to be in ascending * order */ }; int <API key>(struct cpufreq_policy *policy, struct <API key> *table); int <API key>(struct cpufreq_policy *policy, struct <API key> *table); int <API key>(struct cpufreq_policy *policy, struct <API key> *table, unsigned int target_freq, unsigned int relation, unsigned int *index); /* the following 3 funtions are for cpufreq core use only */ struct <API key> *<API key>(unsigned int cpu); struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu); void cpufreq_cpu_put(struct cpufreq_policy *data); /* the following are really really optional */ extern struct freq_attr <API key>; void <API key>(struct <API key> *table, unsigned int cpu); void <API key>(unsigned int cpu); #endif /* _LINUX_CPUFREQ_H */
\file OLSR_printer.h \brief Header file which includes all printing functions related to OLSR. #ifndef __OLSR_printer_h__ #define __OLSR_printer_h__ #include <olsr/OLSR.h> #include <olsr/OLSR_pkt.h> #include <olsr/OLSR_repositories.h> #include <packet.h> #include <ip.h> #include <trace.h> Encapsulates all printing functions for OLSR data structures and messages. class OLSR_printer { friend class OLSR; protected: static void print_linkset(Trace*, linkset_t&); static void print_nbset(Trace*, nbset_t&); static void print_nb2hopset(Trace*, nb2hopset_t&); static void print_mprset(Trace*, mprset_t&); static void print_mprselset(Trace*, mprselset_t&); static void print_topologyset(Trace*, topologyset_t&); static void print_olsr_pkt(FILE*, OLSR_pkt*); static void print_olsr_msg(FILE*, OLSR_msg&); static void print_olsr_hello(FILE*, OLSR_hello&); static void print_olsr_tc(FILE*, OLSR_tc&); static void print_olsr_mid(FILE*, OLSR_mid&); public: static void print_cmn_hdr(FILE*, struct hdr_cmn*); static void print_ip_hdr(FILE*, struct hdr_ip*); }; #endif
@extends('layouts.scaffold') @section('main') <h1>Create Tag</h1> {{ Form::open(array('route' => 'tags.store')) }} <ul> <li> {{ Form::label('title', 'Title:') }} {{ Form::text('title', null, ['class' => 'form-control']) }} </li> <li> {{ Form::submit('Submit', array('class' => 'btn btn-info')) }} </li> </ul> {{ Form::close() }} @if ($errors->any()) <ul> {{ implode('', $errors->all('<li class="error">:message</li>')) }} </ul> @endif @stop
#!/bin/bash # Begin configuration section. stage=0 # End configuration section . ./utils/parse_options.sh set -e -o pipefail set -o nounset # Treat unset variables as an error . ./cmd.sh . ./path.sh . ./conf/common_vars.sh . ./lang.conf if [ $# -ne 1 ] ; then echo "Invalid number of parameters" exit 1 fi idir=$1 if [ ! -d "$idir" ] ; then echo "The directory $idir does not exist" exit 1 fi idata=${idir if [ "$idata" == ${idata%%.*} ]; then odata=${idata%%.*}.phn else odata=${idata%%.*}.phn.${idata fi if [ $stage -le -1 ] ; then local/syllab/generate_phone_lang.sh \ data/train data/local/ data/lang data/lang.phn data/local/dict.phn local/syllab/ali_to_syllabs.sh \ data/train data/lang.phn exp/tri5_ali exp/tri5_ali_phn utils/copy_data_dir.sh data/train data/train.phn cp exp/tri5_ali_phn/text data/train.phn/text #Create syllab LM local/train_lms_srilm.sh \ --words-file data/lang.phn/words.txt --train-text data/train.phn/text \ --oov-symbol "`cat data/lang.phn/oov.txt`" data data/srilm.phn local/arpa2G.sh data/srilm.phn/lm.gz data/lang.phn/ data/lang.phn/ fi if [ $stage -le 0 ] && [ -f "$idir/text" ] ; then #Create dev10h.phn.pem dir steps/align_fmllr.sh \ --boost-silence $boost_sil --nj $train_nj --cmd "$train_cmd" \ $idir data/lang exp/tri5 exp/tri5_ali/align_$idata local/syllab/ali_to_syllabs.sh \ --cmd "$decode_cmd" \ $idir data/lang.phn exp/tri5_ali/align_$idata exp/tri5_ali_phn/align_$idata fi if [ $stage -le 1 ] ; then utils/copy_data_dir.sh data/$idata data/$odata [ -f exp/tri5_ali_phn/align_$idata/text ] && \ cp exp/tri5_ali_phn/align_$idata/text data/$odata/text touch data/$odata/.plp.done touch data/$odata/.done fi
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="style/style.css"> <link rel="stylesheet" type="text/css" media="only screen and (min-device-width: 360px)" href="style-compact.css"> <script> (function(i,s,o,g,r,a,m){i['<API key>']=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.<API key>(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script',' ga('create', 'UA-74917613-1', 'auto'); ga('send', 'pageview'); </script> </head> <body> <div class="deityMessage">……</div> <br> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> ………</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> </div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage">……</div> </div> <br> <div class="dialogueSeparator" > <img src="../../BFStoryArchive/BFStoryArchive/<API key>/dialogueSeparator.png" align="middle" /> </div> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage">……</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"> </div> <div class="speakerMessage">…</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"> </div> <div class="speakerMessage"><div style="display:inline;font-size:20px"></div></div> </div> <br> <div class="dialogueSeparator" > <img src="../../BFStoryArchive/BFStoryArchive/<API key>/dialogueSeparator.png" align="middle" /> </div> <div class="<API key>"> <img class="dungeonFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/baseDungeonFrame.png" /> <img class="dungeonImage" src="../../BFStoryArchive/BFStoryArchive/<API key>/<API key>.jpg" /> </div> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_3.png" /> </div> <div class="speakerName"><a href="http://i.imgur.com/finJi4d.png"></a></div> <div class="speakerMessage">…</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"><div style="display:inline;font-size:20px"></div></div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage">……</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_3.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> …</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> …</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage">…</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage">……</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_4.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage">…… </div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> </div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"></div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_3.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage">……………</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage">“ ”</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage">……</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_1.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"></div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"></div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> </div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> </div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"></div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"></div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> </div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> </div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_1.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage">…</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_4.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage">…</div> </div> <br> <div class="dialogueSeparator" > <img src="../../BFStoryArchive/BFStoryArchive/<API key>/dialogueSeparator.png" align="middle" /> </div> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt01_5.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> </div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt03_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> ……</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"></div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt01_4.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> </div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> </div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt01_5.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> ……</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt14_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"><div style="display:inline;font-size:20px"> </div></div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt01_4.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"></div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_3.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> …</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_3.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"></div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> </div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_3.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage">……</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> </div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> …</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> </div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara_tt11_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"></div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_4.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage">……</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/<API key>/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/<API key>/navi_chara10_0.png" /> </div> <div class="speakerName"></div> <div class="speakerMessage"> …</div> </div> <br> </body> </html> <!-- contact me at reddit /u/blackrobe199 -->
#!/usr/bin/perl -w # This file is part of the Requiem library. # This program is free software; you can redistribute it and/or modify # 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, # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # along with this program; see the file COPYING. If not, write to # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. use strict; use IDMEFTree; use GenerateDebug; use <API key>; use <API key>; use <API key>; use <API key>; use <API key>; use <API key>; use <API key>; use <API key>; use <API key>; use <API key>; use <API key>; use <API key>; use <API key>; sub target_need_update { my $generator = shift; my @file_list = @_; my $source = $generator->{source}; my $target = $generator->{target}; my $source_time = (stat $source)[9]; my $target_time = (stat $target)[9]; foreach my $file ( @file_list ) { return 1 if ( (stat $file)[9] > $target_time ); } return ($source_time > $target_time); } sub target_update { my $generator = shift; my $idmef_tree = shift; my $target = $generator->{target}; my $func = $generator->{func}; $generator = &$func($target); $idmef_tree->process($generator); } my $idmef_tree; my $generator; my @generator_list = ({ source => '<API key>.pm', target => '../idmef-tree-wrap.c', func => sub { new <API key>(-filename => shift) } }, { source => '<API key>.pm', target => '../include/idmef-tree-wrap.h', func => sub { new <API key>(-filename => shift) } }, { source => '<API key>.pm', target => '../include/idmef-tree-data.h', func => sub { new <API key>(-filename => shift) } }, { source => '<API key>.pm', target => '../idmef-message-print.c', func => sub { new <API key>(-filename => shift) } }, { source => '<API key>.pm', target => '../include/idmef-message-print.h', func => sub { new <API key>(-filename => shift) } }, { source => '<API key>.pm', target => '../idmef-message-write.c', func => sub { new <API key>(-filename => shift) } }, { source => '<API key>.pm', target => '../include/idmef-message-write.h', func => sub { new <API key>(-filename => shift) } }, { source => '<API key>.pm', target => '../idmef-message-read.c', func => sub { new <API key>(-filename => shift) } }, { source => '<API key>.pm', target => '../include/idmef-message-read.h', func => sub { new <API key>(-filename => shift) } }, { source => '<API key>.pm', target => '../include/idmef-message-id.h', func => sub { new <API key>(-filename => shift) } }, { source => '<API key>.pm', target => '../../bindings/low-level/<API key>.i', func => sub { new <API key>(-filename => shift) } }, { source => '<API key>.pm', target => '../../bindings/c++/idmef-tree-wrap.cxx', func => sub { new <API key>(-filename => shift) } }, { source => '<API key>.pm', target => '../../bindings/c++/include/idmef-tree-wrap.hxx', func => sub { new <API key>(-filename => shift) } }, ); $idmef_tree = new IDMEFTree(-filename => "idmef-tree.h", -debug => 0); $idmef_tree->load(); foreach my $generator (@generator_list) { target_need_update($generator, 'idmef-tree.h', 'IDMEFTree.pm') and target_update($generator, $idmef_tree); }
.flex-container a:active, .flexslider a:active, .flex-container a:focus, .flexslider a:focus {outline: none;} .slides, .flex-control-nav, .flex-direction-nav {margin: 0; padding: 0; list-style: none;} /* Font-face Icons */ @font-face { font-family: 'flexslider-icon'; src:url('fonts/flexslider-icon.eot'); src:url('fonts/flexslider-icon.eot?#iefix') format('embedded-opentype'), url('fonts/flexslider-icon.woff') format('woff'), url('fonts/flexslider-icon.ttf') format('truetype'), url('fonts/flexslider-icon.svg#flexslider-icon') format('svg'); font-weight: normal; font-style: normal; } .flexslider { margin-top: 10px; margin-bottom: 10px; padding: 0;} .flexslider .slides > li {display: none; -<API key>: hidden;} /* Hide the slides before the JS is loaded. Avoids image jumping */ .flexslider .slides >li >.<API key> >.field-content>img { //width: 100%; margin-left:auto; margin-right:auto; display: block; margin-bottom: 40px; } .flex-pauseplay span {text-transform: capitalize;} /* Clearfix for the .slides element */ .slides:after {content: "."; display: block; clear: both; visibility: hidden; line-height: 0; height: 0;} html[xmlns] .slides {display: block;} * html .slides {height: 1%;} /* No JavaScript Fallback */ /* If you are not using another script, such as Modernizr, make sure you * include js that eliminates this class on page load */ .no-js .slides > li:first-child {display: block;} img { opacity: 1; } .flexslider { //margin: 0 0 60px; background: #fff; border: 4px solid #fff; position: relative; -<API key>: 4px; -moz-border-radius: 4px; -o-border-radius: 4px; border-radius: 0px; -webkit-box-shadow: 0 1px 4px rgba(0,0,0,.2); -moz-box-shadow: 0 1px 4px rgba(0,0,0,.2); -o-box-shadow: 0 1px 4px rgba(0,0,0,.2); box-shadow: 0 1px 4px rgba(0,0,0,.2); zoom: 1; } .flex-viewport { max-height: 2000px; -webkit-transition: all 1s ease; -moz-transition: all 1s ease; -o-transition: all 1s ease; transition: all 1s ease; } .loading .flex-viewport { max-height: 300px; } .flexslider .slides { zoom: 1; } .carousel li { margin-right: 5px; } /* Direction Nav */ .flex-direction-nav {*height: 0;} .flex-direction-nav a { text-decoration:none; display: block; width: 40px; height: 40px; margin: -20px 0 0; position: absolute; top: 40%; z-index: 10; overflow: hidden; opacity: 0; cursor: pointer; color: rgba(0,0,0,0.8); text-shadow: 1px 1px 0 rgba(255,255,255,0.3); -webkit-transition: all .3s ease; -moz-transition: all .3s ease; transition: all .3s ease; } .flex-direction-nav .flex-prev { left: -50px; } .flex-direction-nav .flex-next { right: -50px; text-align: right; } .flexslider:hover .flex-prev { opacity: 0.7; left: 10px; } .flexslider:hover .flex-next { opacity: 0.7; right: 10px; } .flexslider:hover .flex-next:hover, .flexslider:hover .flex-prev:hover { opacity: 1; } .flex-direction-nav .flex-disabled { opacity: 0!important; filter:alpha(opacity=0); cursor: default; } .flex-direction-nav a:before { font-family: "flexslider-icon"; font-size: 40px; line-height:1; display: inline-block; content: '\f001'; } .flex-direction-nav a.flex-next:before { content: '\f002'; } /* Pause/Play */ .flex-pauseplay a { display: block; width: 20px; height: 20px; position: absolute; bottom: 5px; left: 10px; opacity: 0.8; z-index: 10; overflow: hidden; cursor: pointer; color: #000; } .flex-pauseplay a:before { font-family: "flexslider-icon"; font-size: 20px; display: inline-block; content: '\f004'; } .flex-pauseplay a:hover { opacity: 1; } .flex-pauseplay a.flex-play:before { content: '\f003'; } /* Control Nav */ .flex-control-nav {width: 100%; position: absolute; top: 480px; text-align: center; z-index: 999; } /*Media Query for bullets for gallary images */ @media (max-width: 1000px){ .flex-control-nav{ top: 380px; } } @media (max-width: 730px){ .flex-control-nav{ top: 360px; } } @media (max-width: 690px){ .flex-control-nav{ top: 340px; } } @media (max-width: 650px){ .flex-control-nav{ top: 320px; } } @media (max-width: 600px){ .flex-control-nav{ top: 290px; } } @media (max-width: 550px){ .flex-control-nav{ top: 260px; } } @media (max-width: 500px){ .flex-control-nav{ top: 240px; } } @media (max-width: 450px){ .flex-control-nav{ top: 220px; } } @media (max-width: 400px){ .flex-control-nav{ top: 200px; } } @media (max-width: 380px){ .flex-control-nav{ top: 180px; } } @media (max-width: 350px){ .flex-control-nav{ top: 170px; } } @media (max-width: 320px){ .flex-control-nav{ top: 160px; } } @media (max-width: 300px){ .flex-control-nav{ top: 140px; } } @media (max-width: 290px){ .flex-control-nav{ top: 130px; } } @media (max-width: 280px){ .flex-control-nav{ top: 120px; } } /*Media Query for bullets for gallary images Ends..... */ .flex-control-nav li {margin: 0 5px; display: inline-block; zoom: 1; *display: inline;} .flex-control-paging li a {width: 8px; height: 8px; display: block; background: #666; background: rgba(35,173,225,0.5); cursor: pointer; text-indent: -9999px; -<API key>: 20px; -moz-border-radius: 20px; -o-border-radius: 20px; border-radius: 20px; -webkit-box-shadow: inset 0 0 3px rgba(0,0,0,0.3); -moz-box-shadow: inset 0 0 3px rgba(0,0,0,0.3); -o-box-shadow: inset 0 0 3px rgba(0,0,0,0.3); box-shadow: inset 0 0 3px rgba(0,0,0,0.3); } .flex-control-paging li a:hover { background: #333; background: rgba(28,169,240,0.7); } .flex-control-paging li a.flex-active { background: #000; background: rgba(28,169,240,0.9); cursor: default; } .flex-control-thumbs {margin: 5px 0 0; position: static; overflow: hidden;} .flex-control-thumbs li {width: 8.32%; float: left; margin: 0;} .flex-control-thumbs img {width: 100%; display: block; opacity: .7; cursor: pointer;} .flex-control-thumbs img:hover {opacity: 1;} .flex-control-thumbs .flex-active {opacity: 1; cursor: default;} @media screen and (max-width: 860px) { .flex-direction-nav .flex-prev { opacity: 1; left: 10px;} .flex-direction-nav .flex-next { opacity: 1; right: 10px;} } .flex-control-nav > li { padding: 2px; } .gallary_field { padding-right:3px; float:left; } .slides li.flex-active-slide { display:block; } .slides > li { // display:none; } .image_opacity a> img{ opacity:1; border: 1px solid #ccc; border-radius:0px; //padding:6px; }
package org.opennms.netmgt.poller.monitors; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.net.<API key>; import java.util.Map; import java.util.concurrent.<API key>; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.opennms.core.test.MockLogAppender; import org.opennms.core.test.<API key>; import org.opennms.core.test.http.annotations.JUnitHttpServer; import org.opennms.core.utils.InetAddressUtils; import org.opennms.netmgt.config.poller.Parameter; import org.opennms.netmgt.model.PollStatus; import org.opennms.netmgt.poller.MonitoredService; import org.opennms.netmgt.poller.ServiceMonitor; import org.opennms.netmgt.poller.mock.<API key>; import org.opennms.netmgt.poller.mock.MonitorTestUtils; import org.opennms.test.<API key>; import org.opennms.test.mock.MockUtil; import org.springframework.test.context.<API key>; @RunWith(<API key>.class) @<API key>(locations={"classpath:/META-INF/opennms/emptyContext.xml"}) @<API key> public class HttpMonitorTest { private boolean m_runTests = true; @Before public void setUp() throws Exception { MockLogAppender.setupLogging(); } /* * Test method for 'org.opennms.netmgt.poller.monitors.HttpMonitor.poll(NetworkInterface, Map, Package)' */ @Test public void <API key>() throws <API key> { if (m_runTests == false) return; Map<String, Object> m = new <API key><String, Object>(); Parameter p = new Parameter(); ServiceMonitor monitor = new HttpMonitor(); MonitoredService svc = MonitorTestUtils.getMonitoredService(99, "www.opennms.org", "HTTP"); p.setKey("port"); p.setValue("3020"); m.put(p.getKey(), p.getValue()); p.setKey("retry"); p.setValue("1"); m.put(p.getKey(), p.getValue()); p.setKey("timeout"); p.setValue("500"); m.put(p.getKey(), p.getValue()); PollStatus status = monitor.poll(svc, m); MockUtil.println("Reason: "+status.getReason()); assertEquals(PollStatus.SERVICE_UNAVAILABLE, status.getStatusCode()); assertNotNull(status.getReason()); } @Test @JUnitHttpServer(port=10342) public void testResponseRange() throws <API key> { <API key>(false); } @Test @JUnitHttpServer(port=10342) public void <API key>() throws <API key> { <API key>(true); } public void <API key>(boolean preferIPv6) throws <API key> { if (m_runTests == false) return; Map<String, Object> m = new <API key><String, Object>(); Parameter p = new Parameter(); ServiceMonitor monitor = new HttpMonitor(); MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "localhost", "HTTP", preferIPv6); p.setKey("port"); p.setValue("10342"); m.put(p.getKey(), p.getValue()); p.setKey("retry"); p.setValue("1"); m.put(p.getKey(), p.getValue()); p.setKey("timeout"); p.setValue("500"); m.put(p.getKey(), p.getValue()); p.setKey("response"); p.setValue("100-199"); m.put(p.getKey(), p.getValue()); PollStatus status = monitor.poll(svc, m); MockUtil.println("Reason: "+status.getReason()); assertEquals(PollStatus.SERVICE_UNAVAILABLE, status.getStatusCode()); assertNotNull(status.getReason()); p.setKey("response"); p.setValue("100,200,302,400-500"); m.put(p.getKey(), p.getValue()); monitor = new HttpMonitor(); status = monitor.poll(svc, m); MockUtil.println("Reason: "+status.getReason()); assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode()); assertNull(status.getReason()); p.setKey("response"); p.setValue("*"); m.put(p.getKey(), p.getValue()); monitor = new HttpMonitor(); status = monitor.poll(svc, m); MockUtil.println("Reason: "+status.getReason()); assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode()); assertNull(status.getReason()); } /** * This throws a java.net.<API key> because the {@link InetAddressUtils#UNPINGABLE_ADDRESS} * address is in an unroutable test range. :-/ Dear reader, if you can find an address that works with * this test, then please replace {@link InetAddressUtils#UNPINGABLE_ADDRESS} inside {@link #callTestTimeout(boolean)}. */ @Test @Ignore public void testTimeout() throws <API key> { callTestTimeout(false); } @Test public void testTimeoutIPv6() throws <API key> { callTestTimeout(true); } public void callTestTimeout(boolean preferIPv6) throws <API key> { if (m_runTests == false) return; Map<String, Object> m = new <API key><String, Object>(); Parameter p = new Parameter(); ServiceMonitor monitor = new HttpMonitor(); // We need a routable but unreachable address in order to simulate a timeout MonitoredService svc = MonitorTestUtils.getMonitoredService(3, preferIPv6 ? InetAddressUtils.<API key> : InetAddressUtils.UNPINGABLE_ADDRESS, "HTTP"); p.setKey("port"); p.setValue("10342"); m.put(p.getKey(), p.getValue()); p.setKey("retry"); p.setValue("1"); m.put(p.getKey(), p.getValue()); p.setKey("timeout"); p.setValue("500"); m.put(p.getKey(), p.getValue()); p.setKey("response"); p.setValue("100-199"); m.put(p.getKey(), p.getValue()); PollStatus status = monitor.poll(svc, m); MockUtil.println("Reason: "+status.getReason()); assertEquals(PollStatus.SERVICE_UNAVAILABLE, status.getStatusCode()); assertNotNull(status.getReason()); assertTrue(status.getReason().contains("HTTP connection timeout")); } @Test @JUnitHttpServer(port=10342) public void <API key>() throws <API key> { <API key>(false); } @Test @JUnitHttpServer(port=10342) public void <API key>() throws <API key> { <API key>(true); } public void <API key>(boolean preferIPv6) throws <API key> { if (m_runTests == false) return; Map<String, Object> m = new <API key><String, Object>(); Parameter p = new Parameter(); PollStatus status = null; ServiceMonitor monitor = new HttpMonitor(); MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "localhost", "HTTP", preferIPv6); p.setKey("port"); p.setValue("10342"); m.put(p.getKey(), p.getValue()); p.setKey("retry"); p.setValue("0"); m.put(p.getKey(), p.getValue()); p.setKey("timeout"); p.setValue("500"); m.put(p.getKey(), p.getValue()); p.setKey("response"); p.setValue("100-499"); m.put(p.getKey(), p.getValue()); p.setKey("verbose"); p.setValue("true"); m.put(p.getKey(), p.getValue()); p.setKey("host-name"); p.setValue("localhost"); m.put(p.getKey(), p.getValue()); p.setKey("url"); p.setValue("/"); m.put(p.getKey(), p.getValue()); p.setKey("response-text"); p.setValue("opennmsrulz"); m.put(p.getKey(), p.getValue()); status = monitor.poll(svc, m); MockUtil.println("Reason: "+status.getReason()); assertEquals(PollStatus.SERVICE_UNAVAILABLE, status.getStatusCode()); assertNotNull(status.getReason()); p.setKey("response-text"); p.setValue("written by monkeys"); m.put(p.getKey(), p.getValue()); MockUtil.println("\nliteral text check: \"written by monkeys\""); monitor = new HttpMonitor(); status = monitor.poll(svc, m); MockUtil.println("Reason: "+status.getReason()); assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode()); assertNull(status.getReason()); p.setKey("response-text"); p.setValue("~.*[Tt]est HTTP [Ss]erver.*"); m.put(p.getKey(), p.getValue()); MockUtil.println("\nregex check: \".*[Tt]est HTTP [Ss]erver.*\""); monitor = new HttpMonitor(); status = monitor.poll(svc, m); MockUtil.println("Reason: "+status.getReason()); assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode()); assertNull(status.getReason()); } @Test public void testBase64Encoding() { if (m_runTests == false) return; Map<String, Object> m = new <API key><String, Object>(); Parameter p = new Parameter(); p.setKey("<API key>"); p.setValue("Aladdin:open sesame"); m.put(p.getKey(), p.getValue()); assertEquals("<API key>==", HttpMonitor.<API key>(m)); assertFalse( "<API key>==".equals(HttpMonitor.<API key>(m))); } @Test @JUnitHttpServer(port=10342, basicAuth=true) public void <API key>() throws <API key> { <API key>(false); } @Test @JUnitHttpServer(port=10342, basicAuth=true) public void <API key>() throws <API key> { <API key>(true); } public void <API key>(boolean preferIPv6) throws <API key> { if (m_runTests == false) return; Map<String, Object> m = new <API key><String, Object>(); Parameter p = new Parameter(); PollStatus status = null; ServiceMonitor monitor = new HttpMonitor(); MonitoredService svc = MonitorTestUtils.getMonitoredService(1, "localhost", "HTTP", preferIPv6); p.setKey("port"); p.setValue("10342"); m.put(p.getKey(), p.getValue()); p.setKey("retry"); p.setValue("0"); m.put(p.getKey(), p.getValue()); p.setKey("timeout"); p.setValue("500"); m.put(p.getKey(), p.getValue()); p.setKey("response"); p.setValue("100-302"); m.put(p.getKey(), p.getValue()); p.setKey("verbose"); p.setValue("true"); m.put(p.getKey(), p.getValue()); p.setKey("host-name"); p.setValue("localhost"); m.put(p.getKey(), p.getValue()); p.setKey("url"); p.setValue("/"); m.put(p.getKey(), p.getValue()); p.setKey("<API key>"); p.setValue("admin:istrator"); m.put(p.getKey(), p.getValue()); status = monitor.poll(svc, m); MockUtil.println("Reason: "+status.getReason()); assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode()); assertNull(status.getReason()); p.setKey("<API key>"); p.setValue("admin:flagrator"); m.put(p.getKey(), p.getValue()); status = monitor.poll(svc, m); MockUtil.println("Reason: "+status.getReason()); assertEquals(PollStatus.SERVICE_UNAVAILABLE, status.getStatusCode()); assertNotNull(status.getReason()); } @Test @JUnitHttpServer(port=10342, https=true, basicAuth=true) public void testBasic<API key>() throws <API key> { callTestBasic<API key>(false); } @Test @JUnitHttpServer(port=10342, https=true, basicAuth=true) public void testBasic<API key>() throws <API key> { callTestBasic<API key>(true); } public void callTestBasic<API key>(boolean preferIPv6) throws <API key> { if (m_runTests == false) return; Map<String, Object> m = new <API key><String, Object>(); Parameter p = new Parameter(); PollStatus status = null; ServiceMonitor monitor = new HttpsMonitor(); MonitoredService svc = MonitorTestUtils.getMonitoredService(1, "localhost", "HTTPS", preferIPv6); p.setKey("port"); p.setValue("10342"); m.put(p.getKey(), p.getValue()); p.setKey("retry"); p.setValue("1"); m.put(p.getKey(), p.getValue()); p.setKey("timeout"); p.setValue("500"); m.put(p.getKey(), p.getValue()); p.setKey("response"); p.setValue("100-302"); m.put(p.getKey(), p.getValue()); p.setKey("verbose"); p.setValue("true"); m.put(p.getKey(), p.getValue()); p.setKey("host-name"); p.setValue("localhost"); m.put(p.getKey(), p.getValue()); p.setKey("url"); p.setValue("/index.html"); m.put(p.getKey(), p.getValue()); status = monitor.poll(svc, m); MockUtil.println("Reason: "+status.getReason()); assertEquals(PollStatus.SERVICE_UNAVAILABLE, status.getStatusCode()); assertEquals("HTTP response value: 401. Expecting: 100-302./Ports: 10342", status.getReason()); p.setKey("<API key>"); p.setValue("admin:istrator"); m.put(p.getKey(), p.getValue()); status = monitor.poll(svc, m); MockUtil.println("Reason: "+status.getReason()); assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode()); assertNull(status.getReason()); } @Test @JUnitHttpServer(port=10342) public void testWithUrl() throws <API key> { callTestWithUrl(false); } @Test @JUnitHttpServer(port=10342) public void testWithUrlIPv6() throws <API key> { callTestWithUrl(true); } public void callTestWithUrl(boolean preferIPv6) throws <API key> { if (m_runTests == false) return; Map<String, Object> m = new <API key><String, Object>(); Parameter p = new Parameter(); PollStatus status = null; ServiceMonitor monitor = new HttpMonitor(); MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "localhost", "HTTP", preferIPv6); p.setKey("host-name"); p.setValue("localhost"); m.put(p.getKey(), p.getValue()); p.setKey("url"); p.setValue("/twinkies.html"); m.put(p.getKey(), p.getValue()); p.setKey("port"); p.setValue("10342"); m.put(p.getKey(), p.getValue()); p.setKey("retry"); p.setValue("0"); m.put(p.getKey(), p.getValue()); p.setKey("timeout"); p.setValue("500"); m.put(p.getKey(), p.getValue()); p.setKey("response"); p.setValue("100-499"); m.put(p.getKey(), p.getValue()); p.setKey("response-text"); p.setValue("~.*Don.t you love twinkies..*"); m.put(p.getKey(), p.getValue()); p.setKey("verbose"); p.setValue("true"); m.put(p.getKey(), p.getValue()); status = monitor.poll(svc, m); MockUtil.println("Reason: "+status.getReason()); assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode()); assertNull(status.getReason()); } @Test @JUnitHttpServer(port=10342) public void <API key>() throws <API key> { <API key>(false); } @Test @JUnitHttpServer(port=10342) public void <API key>() throws <API key> { <API key>(true); } public void <API key>(boolean preferIPv6) throws <API key> { if (m_runTests == false) return; Map<String, Object> m = new <API key><String, Object>(); Parameter p = new Parameter(); PollStatus status = null; ServiceMonitor monitor = new HttpMonitor(); <API key> svc = MonitorTestUtils.getMonitoredService(3, "localhost", "HTTP", preferIPv6); svc.setNodeLabel("bad.virtual.host.example.com"); p.setKey("nodelabel-host-name"); p.setValue("true"); m.put(p.getKey(), p.getValue()); p.setKey("port"); p.setValue("10342"); m.put(p.getKey(), p.getValue()); p.setKey("retry"); p.setValue("0"); m.put(p.getKey(), p.getValue()); p.setKey("timeout"); p.setValue("500"); m.put(p.getKey(), p.getValue()); // Ensure that we get a 404 for this GET since we're using an inappropriate virtual host p.setKey("response"); p.setValue("404"); m.put(p.getKey(), p.getValue()); p.setKey("verbose"); p.setValue("true"); m.put(p.getKey(), p.getValue()); status = monitor.poll(svc, m); MockUtil.println("Reason: "+status.getReason()); assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode()); assertNull(status.getReason()); } @Test @JUnitHttpServer(port=10342, vhosts={"opennms.com"}) public void <API key>() throws <API key> { <API key>(false); } @Test @JUnitHttpServer(port=10342, vhosts={"opennms.com"}) public void <API key>() throws <API key> { <API key>(true); } public void <API key>(boolean preferIPv6) throws <API key> { if (m_runTests == false) return; Map<String, Object> m = new <API key><String, Object>(); Parameter p = new Parameter(); ServiceMonitor monitor = new HttpMonitor(); MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "localhost", "HTTP", preferIPv6); p.setKey("port"); p.setValue("10342"); m.put(p.getKey(), p.getValue()); p.setKey("retry"); p.setValue("1"); m.put(p.getKey(), p.getValue()); p.setKey("timeout"); p.setValue("500"); m.put(p.getKey(), p.getValue()); p.setKey("host-name"); p.setValue("www.google.com"); m.put(p.getKey(), p.getValue()); p.setKey("url"); p.setValue("/twinkies.html"); m.put(p.getKey(), p.getValue()); p.setKey("response-text"); p.setValue("~.*twinkies.*"); m.put(p.getKey(), p.getValue()); PollStatus status = monitor.poll(svc, m); assertEquals("poll status available", PollStatus.SERVICE_UNAVAILABLE, status.getStatusCode()); } @Test @JUnitHttpServer(port=10342, vhosts={"www.opennms.org"}) public void <API key>() throws <API key> { <API key>(false); } @Test @JUnitHttpServer(port=10342, vhosts={"www.opennms.org"}) public void <API key>() throws <API key> { <API key>(true); } public void <API key>(boolean preferIPv6) throws <API key> { if (m_runTests == false) return; Map<String, Object> m = new <API key><String, Object>(); Parameter p = new Parameter(); ServiceMonitor monitor = new HttpMonitor(); MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "localhost", "HTTP", preferIPv6); p.setKey("port"); p.setValue("10342"); m.put(p.getKey(), p.getValue()); p.setKey("retry"); p.setValue("1"); m.put(p.getKey(), p.getValue()); p.setKey("timeout"); p.setValue("500"); m.put(p.getKey(), p.getValue()); p.setKey("host-name"); p.setValue("www.opennms.org"); m.put(p.getKey(), p.getValue()); p.setKey("url"); p.setValue("/twinkies.html"); m.put(p.getKey(), p.getValue()); p.setKey("response-text"); p.setValue("~.*twinkies.*"); m.put(p.getKey(), p.getValue()); PollStatus status = monitor.poll(svc, m); assertEquals("poll status not available", PollStatus.SERVICE_AVAILABLE, status.getStatusCode()); } @Test @JUnitHttpServer(port=10342) public void testNMS2702() throws <API key> { HttpMonitor monitor = new HttpMonitor(); Map<String, Object> parameters = new <API key><String, Object>(); parameters.put("port", "10342"); parameters.put("url", "/test-NMS2702.html"); parameters.put("retry", "1"); parameters.put("timeout", "500"); parameters.put("verbose", "true"); // Match a string included on Initial Server Response parameters.put("response-text", "~.*OK.*"); MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "localhost", "HTTP", false); PollStatus status = monitor.poll(svc, parameters); assertTrue(status.isAvailable()); // Match a string included on Header parameters.put("response-text", "~.*Jetty.*"); svc = MonitorTestUtils.getMonitoredService(3, "localhost", "HTTP", false); status = monitor.poll(svc, parameters); assertTrue(status.isAvailable()); } }
<section class="sixteen columns row"> <div class="flexslider"> <ul class="slides"> <?php $args = array( 'category_name' => 'Featured', 'posts_per_page' => 3 ); $query = new WP_Query ($args); while ($query->have_posts() ) : $query->the_post(); ?> <li class="featured-game"> <?php the_post_thumbnail('featured'); ?> <div class="caption"> <a href="<?php the_permalink(); ?>" class="game-title"><?php the_title(); ?></a> <?php the_excerpt($lenght); ?> </div> </li> <?php endwhile; ?> </ul> </div> </section>
<?php defined('JPATH_PLATFORM') or die; /** * Base component routing class * * @since 3.3 */ abstract class <API key> implements <API key> { /** * Application object to use in the router * * @var JApplicationCms * @since 3.4 */ public $app; /** * Menu object to use in the router * * @var JMenu * @since 3.4 */ public $menu; /** * Class constructor. * * @param JApplicationCms $app Application-object that the router should use * @param JMenu $menu Menu-object that the router should use * * @since 3.4 */ public function __construct($app = null, $menu = null) { if ($app) { $this->app = $app; } else { $this->app = JFactory::getApplication(); } if ($menu) { $this->menu = $menu; } else { $this->menu = $this->app->getMenu(); } } /** * Generic method to preprocess a URL * * @param array $query An associative array of URL arguments * * @return array The URL arguments to use to assemble the subsequent URL. * * @since 3.3 */ public function preprocess($query) { return $query; } }
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> <TS version="2.1" language="oc"> <context> <name>PictureBox</name> <message> <source>Press to login</source> <translation>Clicar per vos connectar</translation> </message> </context> <context> <name>QObject</name> <message> <source>%1 (Wayland)</source> <translation>%1 (Wayland)</translation> </message> </context> <context> <name>TextConstants</name> <message> <source>Welcome to %1</source> <translation>La benvenguda a %1</translation> </message> <message> <source>Warning, Caps Lock is ON!</source> <translation>Atencion, las majusculas son ACTIVADAS !</translation> </message> <message> <source>Layout</source> <translation>Disposicion</translation> </message> <message> <source>Login</source> <translation>Connexion</translation> </message> <message> <source>Login failed</source> <translation>Fracàs de la connexion</translation> </message> <message> <source>Login succeeded</source> <translation>Connexion reüssida</translation> </message> <message> <source>Password</source> <translation>Senhal</translation> </message> <message> <source>Enter your username and password</source> <translation>Picatz lo nom d’utilizaire e lo senhal</translation> </message> <message> <source>Reboot</source> <translation>Reaviar</translation> </message> <message> <source>Session</source> <translation>Session</translation> </message> <message> <source>Shutdown</source> <translation>Atudar</translation> </message> <message> <source>User name</source> <translation>Nom d’utilizaire</translation> </message> <message> <source>Select your user and enter password</source> <translation>Seleccionatz vòstre nom d’utilizaire e picatz lo senhal</translation> </message> </context> </TS>
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; namespace Server.Commands { public static class GenerateGameDocs { private static CsvFile csv; private delegate void ProcessObject(object obj); public static void Initialize() { CommandSystem.Register("GenGameDocs", AccessLevel.GameMaster, new CommandEventHandler(<API key>)); } private static void <API key>(CommandEventArgs e) { csv = new CsvFile(); AppDomain.CurrentDomain.GetAssemblies() .SelectMany(t => t.GetTypes()) .Where(t => t.IsClass && t.Namespace == "Server.Mobiles" && typeof(Mobiles.BaseCreature).IsAssignableFrom(t)) .ToList() .ForEach(t => ConsumeType(t, HandleBaseCreature)); csv.Write("Creatures.csv"); csv = new CsvFile(); AppDomain.CurrentDomain.GetAssemblies() .SelectMany(t => t.GetTypes()) .Where(t => t.IsClass && t.Namespace == "Server.Items" && typeof(Items.BaseWeapon).IsAssignableFrom(t)) .ToList() .ForEach(t => ConsumeType(t, HandleBaseWeapon)); csv.Write("Weapons.csv"); csv = new CsvFile(); AppDomain.CurrentDomain.GetAssemblies() .SelectMany(t => t.GetTypes()) .Where(t => t.IsClass && t.Namespace == "Server.Items" && typeof(Items.BaseArmor).IsAssignableFrom(t)) .ToList() .ForEach(t => ConsumeType(t, HandleBaseArmor)); csv.Write("Armor.csv"); } private static void HandleBaseArmor(object obj) { Items.BaseArmor arm = obj as Items.BaseArmor; if (arm == null) return; csv.AddRow(); csv.AddValue("Type", arm.GetType().Name); csv.AddValue("Name", arm.Name); csv.AddValue("Is Artifact?", arm.IsArtifact); csv.AddValue("Pysical Resist", arm.PhysicalResistance); csv.AddValue("Fire Resist", arm.FireResistance); csv.AddValue("Cold Resist", arm.ColdResistance); csv.AddValue("Poison Resist", arm.PoisonResistance); csv.AddValue("Energy Resist", arm.EnergyResistance); csv.AddValue("DCI", arm.Attributes.DefendChance); } private static void HandleBaseWeapon(object obj) { Items.BaseWeapon wep = obj as Items.BaseWeapon; if (wep == null) return; csv.AddRow(); csv.AddValue("Type", wep.GetType().Name); csv.AddValue("Name", wep.Name); csv.AddValue("Is Artifact?", wep.IsArtifact); csv.AddValue("Str Requirement", wep.StrRequirement); csv.AddValue("Dex Requirement", wep.DexRequirement); csv.AddValue("Int Requirement", wep.IntRequirement); csv.AddValue("Skill", wep.Skill); csv.AddValue("Race", wep.RequiredRace); csv.AddValue("Speed", wep.Speed); csv.AddValue("Min Damage", wep.MinDamage); csv.AddValue("Max Damage", wep.MaxDamage); } private static void HandleBaseCreature(object obj) { Mobiles.BaseCreature creature = obj as Mobiles.BaseCreature; if (creature == null) return; Server.Items.BambooFlute flute = new Items.BambooFlute(); csv.AddRow(); csv.AddValue("Type", creature.GetType().Name); csv.AddValue("Name", creature.Name); csv.AddValue("Str", creature.Str); csv.AddValue("Dex", creature.Dex); csv.AddValue("Int", creature.Int); csv.AddValue("Hits", creature.HitsMax); csv.AddValue("Stam", creature.StamMax); csv.AddValue("Mana", creature.ManaMax); csv.AddValue("Physical Resist", creature.PhysicalResistance); csv.AddValue("Fire Resist", creature.FireResistance); csv.AddValue("Cold Resist", creature.ColdResistance); csv.AddValue("Poison Resist", creature.PoisonResistance); csv.AddValue("Energy Resist", creature.EnergyResistance); csv.AddValue("Physical Damage", creature.PhysicalDamage); csv.AddValue("Fire Damage", creature.FireDamage); csv.AddValue("Cold Damage", creature.ColdDamage); csv.AddValue("Poison Damage", creature.PoisonDamage); csv.AddValue("Energy Damage", creature.EnergyDamage); csv.AddValue("Taming Difficulty", creature.CurrentTameSkill); csv.AddValue("Barding Difficulty", flute.GetDifficultyFor(creature)); csv.AddValue("TMap Level", creature.TreasureMapLevel); csv.AddValue("Wrestling Skill", creature.Skills.Wrestling.Base); } private static void ConsumeType(Type t, ProcessObject proc) { ConstructorInfo ctor = t.GetConstructor(new Type[] { }); if (ctor == null) return; object obj; try { obj = ctor.Invoke(new object[] { }); } catch (Exception) { return; } if (obj == null) return; proc(obj); } private class CsvFile { private readonly List<Dictionary<String, String>> rows = new List<Dictionary<string, string>>(); private Dictionary<String, String> currentRow = null; private readonly HashSet<String> headerSet = new HashSet<string>(); private readonly List<String> allHeaders = new List<string>(); public CsvFile() { } public void AddRow() { currentRow = new Dictionary<String, String>(); rows.Add(currentRow); } public void AddValue(String name, object value) { if (name == null) return; String v = ""; if (value != null) v = value.ToString(); currentRow.Add(name, v.ToString()); if (headerSet.Contains(name)) return; headerSet.Add(name); allHeaders.Add(name); } public void Write(String path) { StreamWriter outf = new StreamWriter(path); bool first; first = true; foreach (String header in allHeaders) { if (first) { outf.Write(String.Format("\"{0}\"", header)); first = false; } else { outf.Write(String.Format(",\"{0}\"", header)); } } outf.WriteLine(""); foreach (Dictionary<String, String> row in rows) { first = true; foreach (String header in allHeaders) { String value = ""; row.TryGetValue(header, out value); if (first) { outf.Write(String.Format("\"{0}\"", value)); first = false; } else { outf.Write(String.Format(",\"{0}\"", value)); } } outf.WriteLine(""); } outf.Close(); } } } }
body { margin: 0 auto; padding:0; font:0.9em Verdana, Helvetica, sans-serif; background: #e5e5e5; } h2 { background-image: url('./images/titleback.png'); background-repeat:no-repeat; background-position:bottom; width:213px; height:41px; margin:0; padding:0; font:0.9em Verdana, Helvetica, sans-serif; } h2 p { margin:0; padding:10px 0 0 25px; background-image:url('./images/titlebullet.png'); background-repeat: no-repeat; background-position: 5px 12px; } .price { font:bold 1.2em Verdana, Helvetica, sans-serif;color:#c83b00; } /* detail and share */ .buttondetail { background-image:url('./images/buttonback.png'); background-repeat: no-repeat; text-align:center; padding-top:2px; width:81px; height:23px; margin:6px; } .buttondetail a, .buttondetail a:link, .buttondetail a:visited, .buttondetail li a:hover { font:1em Verdana, Helvetica, sans-serif; color:#fff; text-decoration:none; } /* add basket */ .buttonbasket { background-image:url('./images/buttonback2.png'); background-repeat: no-repeat; text-align:center; padding-top:2px; width:81px; height:23px; margin:6px; } .buttonbasket a, .buttonbasket a:link, .buttonbasket a:visited, .buttonbasket li a:hover { font:1em Verdana, Helvetica, sans-serif; color:#fff; text-decoration:none; } #container { margin:15px auto 0; position: relative; width:980px; height:1400px; background: #fff; -moz-border-radius: 10px; border-radius: 10px; } #header { background-image: url('./images/header.png'); background-repeat:no-repeat; background-position:bottom; width:980px; height:130px; } /* logo site name */ #logo { float:left; padding:20px 0 0 20px; } #header h1 { float:left; margin: 0; font-family: Arial, Times, Sans; font-size: 3em; color: #2c2c2c; padding:40px 0 0 10px; } /* site slogan */ #slogan { clear:both; margin: 0; font-family: Georgia, Times, Sans; font-size: 1em; color: #444; text-align:right; height:40px; padding:0 20px 0px 0; } /* top menu */ #topnav { background-image: url('./images/mainmenu.gif'); background-repeat:no-repeat; background-position:center; width:980px; height:44px; font:bold 1em Arial, Helvetica, sans-serif; } #topnav ul { padding: 10px; padding-top:15px; margin: 0px; list-style-type: none; } #topnav li { display: inline; list-style-type: none; margin-left: 12px; padding-right:15px; border-right:1px solid #c63800; } #topnav li a:link{ color: #fff; text-decoration: none; padding-bottom: 2px; } #topnav li a:visited { color: #fff; text-decoration: none; } #topnav li a:hover { border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: #fff; } /* top menu end */ #content-container { float: left; width: 980px; height: 100%; position: absolute; left:0; } #left-boxes { float: left; width: 210px; padding:10px 0 0 10px; margin:0; display: inline; } #left-boxes ul { margin: 0; padding: 0; } #left-boxes ul li { margin:0; padding: 0; list-style-type: none; } #cat-box ul li { padding:4px; border-bottom:1px #dedede solid; } #cat-box li a, #cat-box li a:link, #cat-box li a:visited, #cat-box li a:hover { font:0.8em Verdana, Helvetica, sans-serif; color:#515151; text-decoration:none; padding:0 0 0 15px; background-image:url('./images/catbullet.png'); background-repeat: no-repeat; background-position: 0px 0px; } #login-box .register { margin-left:10px; } #login-box .register table td { padding:1px; font-family: Verdana, Helvetica, sans-serif; font-size: 0.8em; } #login-box input { width:8em; } #login-box li { padding-right: 20px; } #login-box li a, #login-box li a:link, #login-box li a:visited, #login-box li a:hover { font:0.9em Verdana, Helvetica, sans-serif; color:#515151; text-decoration:none; } #content { float: left; width: 500px; padding: 10px 0 0 10px; margin: 0; } #content h2 { margin: 0; } #content h3 { font:bold 1.1em Tahoma, Helvetica, Arial; color:#375b91; border-bottom:1px solid #d9e6f0; } #aside { float: right; width: 220px; padding:10px 0 0 10px; margin: 0; display: inline; } #aside h3 { margin: 0; } #news-box { font:0.9em Verdana, Helvetica, sans-serif; color:#515151; } #news-box h2 p { background-position: 5px 10px; } #news-box ul { margin:0;padding:0; } #news-box li { margin:0;padding:0; padding-right: 20px; list-style-type: none; } #news-box a, #news-box a:link, #news-box a:visited, #news-box a:hover { font:bold 0.9em Verdana, Helvetica, sans-serif; color:#515151; text-decoration:none; } #footer { clear: left; text-align:center; padding: 20px; height: 1%; } #footer li { display: inline; list-style-type: none; padding-right: 20px; } #footer li a, #footer li a:link, #footer li a:visited, #footer li a:hover { font:0.8em Verdana, Helvetica, sans-serif; color:#515151; text-decoration:none; } .star { color:red; } .warn { color:red; font-size: .7em; } .register { margin-left:20px; margin-top:10px; } .register table { margin:0px; padding:0px; border-collapse: collapse; width:96%; background-color:#ffffff; } .register table tr.title td { border-collapse: collapse; padding:6px; background-color:#F3F3F3; font:bold 1.4em Verdana, Helvetica; color:#000000; } .register table td { border-collapse: collapse; padding:6px; color:#000000; border-bottom:1px #dedede solid; } #zebraTable { border-collapse:collapse; padding:0px; width:95%; } #zebraTable tbody tr td { padding: 4px; font:0.8em Verdana, Tahoma,Arial; } #zebraTable tbody tr.selected td { background-color: #FFC9D6; color: #ffffff; font:bold 1.1em Georgia, Arial, Helvetica; } #zebraTable tbody tr.title td { font:bold 1.1em Tahoma, Helvetica, Arial; color:#375b91; border-bottom:1px solid #d9e6f0; } #zebraTable tr.row { background-color: #FFFFFF; } #zebraTable tr.altrow { background:#F0F7E8; border-bottom:1px solid #E7EEDF; border-top:1px solid #E7EEDF; } #zebraTable A.btn, A.btn:link, A.btn:active, A.btn:visited { font:bold .9em Verdana; color:#515151; text-decoration:none;padding:3px;border:1px solid #dedede; background-color:#dedede; background-image:url(../img/btn.gif); } #zebraTable A.btn:hover { color:#000; }
#include <avr/interrupt.h> #include <avr/pgmspace.h> #include <avr/cpufunc.h> #include <util/delay.h> #include <util/atomic.h> #include <stdbool.h> #include <string.h> #include <limits.h> #include <inttypes.h> #define SETBITS( x, y) ((x) |= (y)) #define CLEARBITS( x, y) ((x) &= ~(y)) #define SETBIT( x, y) SETBITS( x, _BV(y)) #define CLEARBIT( x, y) CLEARBITS( x, _BV(y)) #define BITSET( x, y) bit_is_set( x, y) #define BITCLEAR( x, y) bit_is_clear( x, y) #define BITSSET( x, y) (((x) & (y)) == (y)) #define BITSCLEAR( x, y) (((x) & (y)) == 0) #define BITVAL( x, y) (((x) >> (y)) & 1) #define SETVAL( x, y, value) { if (value) SETBIT( x, y); else CLEARBIT( x, y); } #define ADC_MUX 0xC0 // Reference selection bits enabled #define ADC_PF7_INPUT 0x07 // ADC7 (PF7) Input #define ADC_SRA 0x87 // Frequency reference (ADC enabled, 128 division factor) #define DETECTORS_A_CHIP 128 #define BUFFER_HEADER 2 #define BUFFER_ANSWER 16 #define TIMER1_DIV 200 #define DEFAULT_CAPACITY '7' #define AD8400_HEADER 2 // A0,A1 values #define AD8400_BUFFER (AD8400_HEADER) + (CHAR_BIT) const char Welcome_string[] PROGMEM = "Welcome"; const char APRM003_string[] PROGMEM = "APRM003"; const char OK_string[] PROGMEM = "OK"; PGM_P const strings[] PROGMEM = { Welcome_string, APRM003_string, OK_string }; union InputBuffer { volatile uint8_t buffer[BUFFER_HEADER + DETECTORS_A_CHIP + 1]; struct { uint8_t code; uint8_t size; uint8_t data[DETECTORS_A_CHIP + 1]; }; }; struct Buffers { union InputBuffer input; uint8_t output[BUFFER_ANSWER]; } command = { { { 'N' } }, { } }; volatile uint8_t timer0_data, timer0_cnt = 0; volatile uint8_t timer1_data, timer1_inc, timer1_of_int; ISR(TIMER0_OVF_vect) { TCCR0 = 0x00; //stop T0 TCNT0 = timer0_data; // load T0_data TCCR0 = 0x07; // start T0 if (timer0_cnt == 4) { timer0_cnt = 0; if (BITVAL( PINB, PINB4)) CLEARBIT( PORTB, PB4); else SETBIT( PORTB, PB4); } timer0_cnt++; } ISR(TIMER1_OVF_vect) { TCCR1B = 0x00; TCNT1 = timer1_data; if (timer1_of_int <= TIMER1_DIV) { timer1_data += timer1_inc; timer1_of_int++; } if (BITVAL( PINB, PINB4)) CLEARBIT( PORTB, PB4); else SETBIT( PORTB, PB4); TCCR1B = 0x01; } ISR(INT0_vect) { cli(); SETBIT( PORTA, PA6); // memory HiZ PORTC = 0xFF; // Port C = in DDRC = 0x00; CLEARBIT( PORTG, PG1); SETBIT( PORTG, PG4); // Read command header for ( uint8_t i = 0; i < BUFFER_HEADER; ++i) { CLEARBIT( PORTG, PG2); // strobe _delay_us(10); command.input.buffer[i] = PINC; SETBIT( PORTG, PG2); // strobe _delay_us(10); } // Read command data for ( uint8_t i = 0; i < command.input.size; ++i) { CLEARBIT( PORTG, PG2); // strobe _delay_us(10); command.input.data[i] = PINC; SETBIT( PORTG, PG2); // strobe _delay_us(10); } PORTC = 0x00; // Port C = HiZ DDRC = 0x00; sei(); } ISR(INT4_vect) // motor 1 { if ((command.input.buffer[12] == '1') && (BITCLEAR( PINE, PINE4))) command.input.code = 'N'; } ISR(INT5_vect) // motor 1 { if ((command.input.buffer[12] == '0') && (BITCLEAR( PINE, PINE5))) command.input.code = 'N'; } ISR(INT6_vect) // motor 2 { if ((command.input.buffer[9] == '0') && (BITCLEAR( PINE, PINE6))) CLEARBIT( PORTB, PB6); } ISR(INT7_vect) // motor 2 { if ((command.input.buffer[9] == '0') && (BITCLEAR( PINE, PINE7))) CLEARBIT( PORTB, PB6); } void init() __attribute__((naked,section(".init3"))); static void chip_reset(); static void chip_select(uint8_t); static void chip_select_clock(uint8_t); static void chip_data(); static void altera_start(int8_t); static void altera_reset(); static void adc_value( /* uint8_t input, */ uint8_t *low, uint8_t *high); static void time_delay_10us(uint16_t); static void time_delay_ms(uint8_t); static void output_rom_string(PGM_P str); static void output_data( uint8_t *buf, uint8_t size); int main() { uint8_t with_xray = 0; uint8_t start_altera; uint16_t delay; uint16_t steps; uint16_t acceleration_step; uint16_t acceleration_delay; uint8_t previous_chip, current_chip = DEFAULT_CAPACITY; // During initiation - capacity 9.5 pF (0111b code) while (1) { uint8_t cmd; // Wait for interrupt do { ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { cmd = command.input.code; } } while (cmd == 'N'); switch (cmd) { case 'C': // Capacities previous_chip = current_chip; CLEARBIT( PORTD, PD2); // value from '1' to '7' current_chip = command.input.data[0]; chip_select(current_chip); // capacity select actually SETBIT( PORTD, PD2); // Write capacities CLEARBIT( PORTD, PD2); // Block capacity selection _delay_ms(200); // Restore previous chip current_chip = previous_chip; SETBIT( PORTG, PG4); // Integration mode chip_select(current_chip); SETBIT( PORTA, PA1); // Turn on altera chip_reset(); command.input.code = 'N'; break; case 'I': // Welcome command : "Welcome", Info command : "APRMXXX" { PGM_P answer = (command.input.data[0] == '0') ? (PGM_P)pgm_read_word(&(strings[0])) : (PGM_P)pgm_read_word(&(strings[1])); output_rom_string(answer); } command.input.code = 'N'; break; case 'D': // Write chip codes previous_chip = current_chip; current_chip = command.input.data[0]; DDRD = 0x04; CLEARBIT( PORTA, PA1); // OFF altera_clk CLEARBIT( PORTA, PA4); SETBIT( PORTA, PA4); // rst_n altera CLEARBIT( PORTA, PA0); // Deny MX0-3 selection chip_select(command.input.data[0]); SETBIT( PORTA, PA0); // Deny MX0-3 selection CLEARBIT( PORTA, PA1); // Allow read_clk chip_data(); SETBIT( PORTA, PA1); // ON altera_clk chip_reset(); output_rom_string((PGM_P)pgm_read_word(&(strings[2]))); command.input.code = 'N'; break; case 'G': // Chip select SETBIT( PORTG, PG4); // Integration mode current_chip = command.input.data[0]; chip_select(current_chip); SETBIT( PORTA, PA1); // Turn on altera command.input.code = 'N'; break; case 'P': // Peltier command (AD8400 256 position digitally controlled variable resistor (VR)) DDRF = 0x3F; PORTF = 0x01; _delay_us(50); // Set digital resistor value (A0,A1,bits of a byte_code) for ( uint8_t i = 0; i < AD8400_BUFFER; ++i) { if (i < AD8400_HEADER) { // A0=0 and A1=0 value PORTF = 0x04; // A0,A1 _delay_us(10); PORTF = 0x00; //strobe _delay_us(10); continue; } // bit position from 7 to 0 bool bit = (command.input.data[0] >> (AD8400_BUFFER - i - 1)) & 0x01; PORTF = bit << 3 | 0x04; _delay_us(10); PORTF = 0x00; //strobe _delay_us(10); } PORTF = 0x02; _delay_us(50); command.input.code = 'N'; break; case 'p': // Stop peltier command PORTF = 0x01; command.input.code = 'N'; break; case 'R': // reset chip chip_reset(); command.input.code = 'N'; break; case 'r': // reset Altera altera_reset(); command.input.code = 'N'; break; case 's': // start Altera for full or part amount of memory altera_start(command.input.data[0] - '0'); command.input.code = 'N'; break; case 'M': // Stepper motors command CLEARBIT( PORTA, PA3); start_altera = 0; // motor1 steps = command.input.data[2] << CHAR_BIT | command.input.data[3]; // number of steps delay = command.input.data[4] << CHAR_BIT | command.input.data[5]; // delay frequency SETVAL( PORTB, PB0, command.input.data[6] - '0'); // motor HALF=1 / FULL=0 - mode SETVAL( PORTB, PB5, command.input.data[10] - '0'); // motor CW=1 / CCW=0 - direction // motor2 timer1_data = command.input.data[8] << CHAR_BIT | command.input.data[11]; SETVAL( PORTE, PE2, command.input.data[9] - '0'); // motor HALF=1 / FULL=0 - mode SETVAL( PORTB, PB3, command.input.data[7] - '0'); // motor CW=1 / CCW=0 - direction SETVAL( PORTB, PB2, command.input.data[0] - '0'); SETVAL( PORTB, PB6, command.input.data[1] - '0'); if ((BITSET( PINE, PINE6) && (command.input.data[7] == '0')) || (BITSET( PINE, PINE7) && (command.input.data[7] == '1'))) { timer1_inc = (UINT16_MAX - timer1_data) / TIMER1_DIV; timer1_of_int = 0; timer1_data = (timer1_data << 1) - UINT16_MAX; TCNT1 = timer1_data; TCCR1A = 0; TCCR1B = 1; } time_delay_ms(command.input.data[12]); acceleration_step = TIMER1_DIV; if (with_xray) // x-ray on SETBIT( PORTB, PB7); time_delay_ms(command.input.data[13]); if ((BITSET( PINE, PINE4) && (command.input.data[10] == '1')) || (BITSET( PINE, PINE5) && (command.input.data[10] == '0'))) { uint16_t i = 0; while ((command.input.code == 'M') && (i < steps)) { CLEARBIT( PORTB, PB1); if (i <= acceleration_step) { acceleration_delay = delay * (1 + (acceleration_step - i) / acceleration_step); time_delay_10us(acceleration_delay); } else { if (!start_altera) { altera_start(0); start_altera = 1; } time_delay_10us(delay); } SETBIT( PORTB, PB1); if (i <= acceleration_step) { acceleration_delay = delay * (1 + (acceleration_step - i) / acceleration_step); time_delay_10us(acceleration_delay); } else time_delay_10us(delay); i++; } } TCCR1B = 0x00; CLEARBIT( PORTB, PB2); CLEARBIT( PORTB, PB6); CLEARBIT( PORTB, PB7); // x-ray off CLEARBIT( PORTG, PG3); with_xray = 0; command.input.code = 'N'; break; case 'T': adc_value( /* ADC_PF7_INPUT, */ command.output, command.output + 1); output_data( command.output, 2); command.input.code = 'N'; break; case 'W': // Readout data PORTC = 0x00; DDRC = 0x00; CLEARBIT( PORTA, PA6); // memory out CLEARBIT( PORTA, PA7); CLEARBIT( PORTA, PA2); for ( uint8_t i = command.input.data[0]; i != 0; --i) { for ( uint8_t j = command.input.data[1]; j != 0; --j) { for ( uint8_t k = command.input.data[2]; k != 0; --k) { for ( uint8_t l = SCHAR_MAX + 1; l != 0; --l) { // send two bytes <API key>( PIND, PIND1); // FT245 ready to read SETBIT( PORTA, PA7); // ft_strob CLEARBIT( PORTA, PA7); SETBIT( PORTA, PA2); SETBIT( PORTA, PA7); CLEARBIT( PORTA, PA7); CLEARBIT( PORTA, PA2); } } } } SETBIT( PORTA, PA6); // memory HiZ PORTC = 0x00; DDRC = 0x00; command.input.code = 'N'; break; case 'X': // X-Ray on/off CLEARBIT( PORTB, PB7); SETVAL( PORTG, PG3, command.input.data[0] -'0'); command.input.code = 'N'; break; case 'N': default: break; } } } void init() { // Ports initialization PORTA = 0xFF; DDRA = 0xFF; PORTB = 0x00; DDRB = 0xFF; PORTC = 0xFF; DDRC = 0x00; PORTD = 0x03; DDRD = 0x04; PORTE = 0xF0; DDRE = 0x03; PORTF = 0x0B; DDRF = 0x3F; PORTG = 0x14; DDRG = 0x1F; // Timer/Counter 0 initialization ASSR = 0x00; TCCR0 = 0x00; TCNT0 = 0x00; OCR0 = 0x00; // Timer/Counter 1 initialization TCCR1A = 0x00; TCCR1B = 0x00; TCNT1H = 0x00; TCNT1L = 0x00; ICR1H = 0x00; ICR1L = 0x00; OCR1AH = 0x00; OCR1AL = 0x00; OCR1BH = 0x00; OCR1BL = 0x00; OCR1CH = 0x00; OCR1CL = 0x00; // Timer/Counter 2 initialization TCCR2 = 0x00; TCNT2 = 0x00; OCR2 = 0x00; // Timer/Counter 3 initialization TCCR3A = 0x00; TCCR3B = 0x00; TCNT3H = 0x00; TCNT3L = 0x00; ICR3H = 0x00; ICR3L = 0x00; OCR3AH = 0x00; OCR3AL = 0x00; OCR3BH = 0x00; OCR3BL = 0x00; OCR3CH = 0x00; OCR3CL = 0x00; // USART0 initialization UCSR0A = 0x20; UCSR0B = 0x00; UCSR0C = 0x00; UBRR0H = 0x00; UBRR0L = 0x00; // External Interrupt(s) initialization EICRA = 0x00; // On INT0 Mode Low level EICRB = 0xAA; // INT4,5,6,7: Falling Edge EIMSK = 0xF1; // INT0,4,5,6,7: On, INT1,2,3: Off EIFR = 0x01; // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK = 0x04; // T1 int ON ETIMSK = 0x00; ADMUX = ADC_MUX | ADC_PF7_INPUT; // ADC initialization ADCSRA = ADC_SRA; // ADC Clock frequency: 62,500 kHz// ADC Voltage Reference: Int., cap. on AREF // Set 9.5 pF capacity SETBIT( PORTA, PA1); // Turn on altera sense_clk CLEARBIT( PORTD, PD2); // Deny capacity selection chip_select(DEFAULT_CAPACITY); // 9.5 pF (0111b code) SETBIT( PORTD, PD2); // Set 9.5 pF Capacity (Maximum 1 pF + 2.5 pF + 6 pF) CLEARBIT( PORTD, PD2); // Deny capacity selection // Global enable interrupts sei(); } void chip_reset() { SETBIT( PORTG, PG1); _delay_us(5); CLEARBIT( PORTG, PG1); } void chip_select(uint8_t chip) { CLEARBIT( PORTA, PA0); // Block strobes into MX0-3 CLEARBIT( PORTA, PA4); SETBIT( PORTA, PA4); // rst_n uint8_t value = 0; switch (chip) { case '0': break; case '1': value = 4; break; case '2': value = 8; break; case '3': value = 12; break; case '4': value = 16; break; case '5': value = 20; break; case '6': value = 24; break; case '7': value = 28; break; case '8': value = 32; break; case '9': value = 36; break; case 'A': value = 40; break; case 'B': value = 44; break; case 'C': value = 48; break; case 'D': value = 52; break; case 'E': value = 56; break; case 'F': value = 60; break; default: break; } if (value) chip_select_clock(value); SETBIT( PORTA, PA0); // Unblock strobes into MX0-3 } void chip_select_clock(uint8_t value) { for ( uint8_t i = value; i != 0; --i) { SETBIT( PORTA, PA2); CLEARBIT( PORTA, PA2); // read_clk } } void chip_data() { CLEARBIT( PORTG, PG4); // M1 Signal chip_reset(); // Write chip data from the input buffer in a current chip for ( uint8_t i = 0; i < DETECTORS_A_CHIP; ++i) { // write bits into chip for ( uint8_t j = 0; j < CHAR_BIT; ++j) { // DATA_out SETVAL( PORTG, PG0, BITVAL( command.input.data[i + 1], CHAR_BIT - 1 - j)); SETBIT( PORTA, PA2); _NOP(); CLEARBIT( PORTA, PA2); // read_clk SETVAL( PORTG, PG0, 0); } } CLEARBIT( PORTG, PG1); SETBIT( PORTG, PG4); SETBIT( PORTA, PA1); } void altera_reset() { SETBIT( PORTG, PG1); CLEARBIT( PORTA, PA4); SETBIT( PORTA, PA4); _delay_us(4); CLEARBIT( PORTG, PG1); } void altera_start(int8_t state) { SETVAL( PORTA, PA3, state); PORTD = 0x03; DDRD = 0x04; SETBIT( PORTA, PA0); // Altera MX0-3 ON SETBIT( PORTA, PA1); // Altera sence_clk ON CLEARBIT( PORTA, PA4); // reset SETBIT( PORTA, PA4); CLEARBIT( PORTA, PA5); // start SETBIT( PORTA, PA5); } void adc_value( /* uint8_t input, */ uint8_t *low, uint8_t *high) { // ADMUX = ADC_MUX | input; // see init function for initiation // Delay is needed for the stabilization of the ADC input voltage // _delay_us(10); // Start the AD conversion SETBIT( ADCSRA, ADSC); // Wait for the AD conversion to complete <API key>( ADCSRA, ADIF); *low = ADCL; *high = ADCH; } void time_delay_10us(uint16_t t) { for ( ; t != 0; --t) _delay_us(10); } void time_delay_ms(uint8_t t) { for ( ; t != 0; --t) _delay_ms(1); } void output_rom_string(PGM_P str) { PORTC = 0x00; // Port C - output DDRC = 0xFF; for ( size_t i = strlen_P(str); i != 0; --i) { <API key>( PIND, PIND1); // FT245 ready to read SETBIT( PORTA, PA7); PORTC = pgm_read_byte(&(str[i])); CLEARBIT( PORTA, PA7); } PORTC = 0x00; // Port C = HiZ DDRC = 0x00; } void output_data( uint8_t *buf, uint8_t size) { PORTC = 0x00; // Port C - output DDRC = 0xFF; for ( uint8_t i = size; i != 0; --i) { <API key>( PIND, PIND1); // FT245 ready to read PORTC = buf[i]; SETBIT( PORTA, PA7); CLEARBIT( PORTA, PA7); } PORTC = 0x00; // Port C = HiZ DDRC = 0x00; }
<?php /** Load WordPress Administration Bootstrap */ if (file_exists('../../../wp-load.php')) { require_once("../../../wp-load.php"); } else if (file_exists('../../wp-load.php')) { require_once("../../wp-load.php"); } else if (file_exists('../wp-load.php')) { require_once("../wp-load.php"); } else if (file_exists('wp-load.php')) { require_once("wp-load.php"); } else if (file_exists('../../../../wp-load.php')) { require_once("../../../../wp-load.php"); } else if (file_exists('../../../../wp-load.php')) { require_once("../../../../wp-load.php"); } else { if (file_exists('../../../wp-config.php')) { require_once("../../../wp-config.php"); } else if (file_exists('../../wp-config.php')) { require_once("../../wp-config.php"); } else if (file_exists('../wp-config.php')) { require_once("../wp-config.php"); } else if (file_exists('wp-config.php')) { require_once("wp-config.php"); } else if (file_exists('../../../../wp-config.php')) { require_once("../../../../wp-config.php"); } else if (file_exists('../../../../wp-config.php')) { require_once("../../../../wp-config.php"); } else { echo '<p>Failed to load bootstrap.</p>'; exit; } } global $wp_db_version; if ($wp_db_version < 8201) { // Pre 2.6 compatibility (BY Stephen Rider) if (!defined('WP_CONTENT_URL')) { if (defined('WP_SITEURL')) define('WP_CONTENT_URL', WP_SITEURL . '/wp-content'); else define('WP_CONTENT_URL', get_option('url') . '/wp-content'); } if (!defined('WP_CONTENT_DIR')) define('WP_CONTENT_DIR', ABSPATH . 'wp-content'); if (!defined('WP_PLUGIN_URL')) define('WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins'); if (!defined('WP_PLUGIN_DIR')) define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins'); } require_once(ABSPATH . 'wp-admin/admin.php'); require_once(dirname(__FILE__) . '/WebLibrarian.php'); <API key>('web-librarian', WEBLIB_BASEURL . '/languages/', basename(WEBLIB_DIR) . '/languages/'); $version = WebLibrarian::_getVersion(); // REPLACE ADMIN URL if (function_exists('admin_url')) { wp_admin_css_color('classic', __('Blue'), admin_url("css/colors-classic.css"), array('#073447', '#21759B', '#EAF3FA', '#BBD8E7')); wp_admin_css_color('fresh', __('Gray'), admin_url("css/colors-fresh.css"), array('#464646', '#6D6D6D', '#F1F1F1', '#DFDFDF')); } else { wp_admin_css_color('classic', __('Blue'), get_bloginfo('wpurl') . '/wp-admin/css/colors-classic.css', array('#073447', '#21759B', '#EAF3FA', '#BBD8E7')); wp_admin_css_color('fresh', __('Gray'), get_bloginfo('wpurl') . '/wp-admin/css/colors-fresh.css', array('#464646', '#6D6D6D', '#F1F1F1', '#DFDFDF')); } wp_enqueue_script('common'); wp_enqueue_script('jquery-color'); wp_enqueue_style('weblib-front-style', WEBLIB_CSSURL . '/front.css', null, $version); wp_enqueue_style('weblib-admin-style', WEBLIB_CSSURL . '/admin.css', array('weblib-front-style'), $version); wp_enqueue_script('front_js', WEBLIB_JSURL . '/front.js', array(), $version); wp_localize_script('front_js', 'front_js', WebLibrarian::localize_vars_front()); wp_enqueue_script('jquery-ui-resizable'); wp_enqueue_script('admin_js', WEBLIB_JSURL . '/admin.js', array('front_js', 'jquery-ui-resizable'), $version); wp_localize_script('admin_js', 'admin_js', WebLibrarian::localize_vars_admin()); wp_enqueue_script('AWSFunctions_js', WEBLIB_JSURL . '/AWSFunctions.js', array('admin_js'), $version); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http: <html xmlns="http: <head> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>"/> <title><?php bloginfo('name') ?> &rsaquo; <?php _e('Uploads'); ?> &#8212; <?php _e('WordPress'); ?></title> <?php wp_enqueue_style('global'); wp_enqueue_style('wp-admin'); wp_enqueue_style('colors'); wp_enqueue_style('media'); ?> <script type="text/javascript"> //<![CDATA[ function addLoadEvent(func) { if (typeof wpOnload != 'function') { wpOnload = func; } else { var oldonload = wpOnload; wpOnload = function () { oldonload(); func(); } } } </script> <?php do_action('admin_print_styles'); do_action('admin_print_scripts'); do_action('admin_head'); if (isset($content_func) && is_string($content_func)) do_action("admin_head_{$content_func}"); $tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : 'links'; ?> </head> <body id="aws-form" class="wp-admin branch-3-3 version-3-3-2 admin-color-fresh"> <div id="item-aws"> <span id="<API key>"></span><br clear="all"/> <div id="amazon-result-list"></div> <span id="amazon-page-buttons"> <input type="text" id="amazon-page-1" class="page-label" value="1" readonly="readonly" size="1"/> <input type="button" id="amazon-goto-page-1" value="<<" class="page-button" onclick="AWSGotoFirstPage();"/> <input type="button" id="<API key>" value="<" class="page-button" onclick="AWSGotoPrevPage();"/> <input type="button" id="amazon-goto-page" value="<?php _e('Goto Page:', 'web-librarian'); ?>" class="page-button" onclick="AWSGotoPage();"/> <input type="text" id="amazon-page-current" class="page-label" value=" " size="3"/> <input type="button" id="<API key>" value=">" class="page-button" onclick="AWSGotoNextPage();"/> <input type="button" id="<API key>" value=">>" class="page-button" onclick="AWSGotoLastPage();"/> <input type="text" id="amazon-page-N" class="page-label" value=" " readonly="readonly" size="3"/> <br/></span> <span id="amazon-search-box"> <label for="SearchIndex"><?php _e('Search In:', 'web-librarian'); ?></label> <select id="SearchIndex"> <option value="Books" selected="selected"><?php _e('Books', 'web-librarian'); ?></option> <option value="DVD"><?php _e('DVD', 'web-librarian'); ?></option> <option value="Music"><?php _e('Music', 'web-librarian'); ?></option> <option value="Video"><?php _e('Video', 'web-librarian'); ?></option> </select> <label for="FieldName"><?php _e('for', 'web-librarian'); ?></label> <select id="FieldName"> <option value="Title" selected="selected"><?php _e('Title', 'web-librarian'); ?></option> <option value="Artist"><?php _e('Artist', 'web-librarian'); ?></option> <option value="Author"><?php _e('Author', 'web-librarian'); ?></option> <option value="Keywords"><?php _e('Keywords', 'web-librarian'); ?></option> </select> <input id="SearchString" type='text' value=""/> <input type="button" id="Go" onclick="AWSSearch(1);" value="<?php _e('Go', 'web-librarian'); ?>"/> </span> </div> <a name="<API key>"></a> <div id="<API key>"></div> <span id="<API key>"></span><br clear="all"/> </body> </html>
#include "src\Engine\Shader\TexturedModelShader.h" #include "src\Engine\Model\TexturedModel.h" #include "src\Engine\Math\GLMath.h" using glm::mat4; void TexturedModelShader::installShader(){ vertexShaderID = glCreateShader(GL_VERTEX_SHADER); fragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER); const GLchar* adapter[1]; std::string temp = readShaderCode("src/Engine/Shader/GLSL/<API key>.glsl").c_str(); adapter[0] = temp.c_str(); glShaderSource(vertexShaderID, 1, adapter, 0); temp = readShaderCode("src/Engine/Shader/GLSL/<API key>.glsl").c_str(); adapter[0] = temp.c_str(); glShaderSource(fragmentShaderID, 1, adapter, 0); glCompileShader(vertexShaderID); glCompileShader(fragmentShaderID); if (!checkShaderStatus(vertexShaderID) | !checkShaderStatus(fragmentShaderID)){ return; } programID = glCreateProgram(); glAttachShader(programID, vertexShaderID); glAttachShader(programID, fragmentShaderID); glLinkProgram(programID); glValidateProgram(programID); if (!checkProgramStatus(programID)){ return; } <API key>(); } void TexturedModelShader::render(TexturedModelEntity &entity){ startProgram(); <API key>(GLMath::<API key>(entity.getPosition(), entity.getRotation(), entity.getScale())); <API key>(); loadViewMatrix(); glBindVertexArray(entity.model-><API key>()); <API key>(0); <API key>(1); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, entity.model->getTexture().bufferID); glDrawElements(GL_TRIANGLES, entity.model->getIndicies().size(), GL_UNSIGNED_INT, 0); <API key>(0); <API key>(1); glBindVertexArray(0); stopProgram(); } void TexturedModelShader::<API key>(){ std::string string = " "; string = "<API key>"; <API key> = getUniformLocation(string); string = "projectionMatrix"; <API key> = getUniformLocation(string); string = "viewMatrix"; location_viewMatrix = getUniformLocation(string); }
package com.jspxcms.ext.repository; import java.util.Collection; import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; import com.jspxcms.common.orm.Limitable; import com.jspxcms.ext.domain.VisitLog; public interface VisitLogDao extends Repository<VisitLog, Integer>, VisitLogDaoPlus { public Page<VisitLog> findAll(Specification<VisitLog> spec, Pageable pageable); public List<VisitLog> findAll(Specification<VisitLog> spec, Limitable limitable); public VisitLog findOne(Integer id); public VisitLog save(VisitLog bean); public void delete(VisitLog bean); @Query("select count(*) as _pv,count(distinct bean.cookie) as _uv,count(distinct bean.ip) as _ip from VisitLog bean where bean.date = ?1 and bean.site.id= ?2") public List<Object[]> trafficByDate(String date, Integer siteId); @Query("select bean.date as _date,count(*) as _pv,count(distinct bean.cookie) as _uv,count(distinct bean.ip) as _ip from VisitLog bean where bean.date >= ?1 and bean.date <= ?2 and bean.site.id = ?3 group by bean.date order by bean.date desc") public List<Object[]> trafficByDate(String begin, String end, Integer siteId); @Query("select bean.url as _url,count(bean.url) as _pv,count(distinct bean.cookieDate) as _uv,count(distinct bean.ipDate) as _ip from VisitLog bean where bean.date >= ?1 and bean.date <= ?2 and bean.site.id = ?3 group by bean.url order by count(bean.url) desc") public List<Object[]> urlByDate(String begin, String end, Integer siteId); @Modifying @Query("delete from VisitLog bean where bean.date <= ?1") public int deleteByDate(String before); @Modifying @Query("delete from VisitLog bean where bean.site.id in (?1)") public int deleteBySiteId(Collection<Integer> siteIds); }
import os # toolchains options ARCH='sim' #CROSS_TOOL='msvc' or 'gcc' or 'mingw' #'msvc' and 'mingw' are both for windows # 'gcc' is for linux CROSS_TOOL='mingw' # cross_tool provides the cross compiler # EXEC_PATH is the compiler execute path if CROSS_TOOL == 'gcc' or CROSS_TOOL == 'clang-analyze': CPU = 'posix' PLATFORM = 'gcc' EXEC_PATH = '' elif CROSS_TOOL == 'mingw': CPU = 'win32' PLATFORM = 'mingw' EXEC_PATH = r'D:\Program Files (x86)\CodeBlocks\MinGW\bin' elif CROSS_TOOL == 'msvc': CPU = 'win32' PLATFORM = 'cl' EXEC_PATH = '' else: print "bad CROSS TOOL!" exit(1) if os.getenv('RTT_EXEC_PATH'): EXEC_PATH = os.getenv('RTT_EXEC_PATH') BUILD = 'debug' #BUILD = '' if PLATFORM == 'gcc': # toolchains PREFIX = '' CC = PREFIX + 'gcc' AS = PREFIX + 'gcc' AR = PREFIX + 'ar' LINK = PREFIX + 'gcc' TARGET_EXT = 'axf' SIZE = PREFIX + 'size' OBJDUMP = PREFIX + 'objdump' OBJCPY = PREFIX + 'objcopy' DEVICE = ' -ffunction-sections -fdata-sections' DEVICE = ' ' CFLAGS = DEVICE + ' -I/usr/include -w -D_REENTRANT' AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp' #LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-linux.map -lpthread' LFLAGS = DEVICE + ' -Wl,-Map=rtthread-linux.map -pthread -T gcc.ld' CPATH = '' LPATH = '' if BUILD == 'debug': CFLAGS += ' -g -O0 -gdwarf-2' AFLAGS += ' -gdwarf-2' else: CFLAGS += ' -O2' POST_ACTION = '' elif PLATFORM == 'mingw': # toolchains PREFIX = '' CC = PREFIX + 'gcc' AS = PREFIX + 'gcc' AR = PREFIX + 'ar' LINK = PREFIX + 'gcc' TARGET_EXT = 'exe' SIZE = PREFIX + 'size' OBJDUMP = PREFIX + 'objdump' OBJCPY = PREFIX + 'objcopy' DEVICE = ' -ffunction-sections -fdata-sections' DEVICE = ' ' CFLAGS = DEVICE AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp' DEFFILE_LFLAGS = DEVICE + ' -Wl,-Map=rtthread-win32.map,--output-def,rtthread.def -T mingw.ld ' LFLAGS = DEVICE + ' -Wl,-Map=rtthread-win32.map -T mingw.ld ' CPATH = '' LPATH = '' if BUILD == 'debug': CFLAGS += ' -g -O0 -gdwarf-2' AFLAGS += ' -gdwarf-2' else: CFLAGS += ' -O2' POST_ACTION = '' elif PLATFORM == 'cl': # toolchains PREFIX = '' TARGET_EXT = 'exe' AS = PREFIX + 'cl' CC = PREFIX + 'cl' AR = PREFIX + 'cl' LINK = PREFIX + 'cl' AFLAGS = '' CFLAGS = '' LFLAGS = '' if BUILD == 'debug': CFLAGS += ' /MTd' LFLAGS += ' /DEBUG' else: CFLAGS += ' /MT' LFLAGS += '' CFLAGS += ' /ZI /Od /W 3 /WL ' LFLAGS += ' /SUBSYSTEM:CONSOLE /MACHINE:X86 ' CPATH = '' LPATH = '' POST_ACTION = ''
#include <linux/fs.h> #include <linux/mm.h> #include <linux/err.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/cpu.h> #include <linux/vmstat.h> #include <linux/sched.h> #include <linux/math64.h> #include <linux/writeback.h> #include <linux/compaction.h> #include <linux/mm_inline.h> #include "internal.h" #ifdef <API key> DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}}; <API key>(vm_event_states); static void sum_vm_events(unsigned long *ret) { int cpu; int i; memset(ret, 0, NR_VM_EVENT_ITEMS * sizeof(unsigned long)); for_each_online_cpu(cpu) { struct vm_event_state *this = &per_cpu(vm_event_states, cpu); for (i = 0; i < NR_VM_EVENT_ITEMS; i++) ret[i] += this->event[i]; } } /* * Accumulate the vm event counters across all CPUs. * The result is unavoidably approximate - it can change * during and after execution of this function. */ void all_vm_events(unsigned long *ret) { get_online_cpus(); sum_vm_events(ret); put_online_cpus(); } EXPORT_SYMBOL_GPL(all_vm_events); #ifdef CONFIG_HOTPLUG /* * Fold the foreign cpu events into our own. * * This is adding to the events on one processor * but keeps the global counts constant. */ void vm_events_fold_cpu(int cpu) { struct vm_event_state *fold_state = &per_cpu(vm_event_states, cpu); int i; for (i = 0; i < NR_VM_EVENT_ITEMS; i++) { count_vm_events(i, fold_state->event[i]); fold_state->event[i] = 0; } } #endif /* CONFIG_HOTPLUG */ #endif /* <API key> */ /* * Manage combined zone based / global counters * * vm_stat contains the global counters */ atomic_long_t vm_stat[<API key>] <API key>; EXPORT_SYMBOL(vm_stat); #ifdef CONFIG_SMP int <API key>(struct zone *zone) { int threshold; int watermark_distance; /* * As vmstats are not up to date, there is drift between the estimated * and real values. For high thresholds and a high number of CPUs, it * is possible for the min watermark to be breached while the estimated * value looks fine. The pressure threshold is a reduced value such * that even the maximum amount of drift will not accidentally breach * the min watermark */ watermark_distance = low_wmark_pages(zone) - min_wmark_pages(zone); threshold = max(1, (int)(watermark_distance / num_online_cpus())); /* * Maximum threshold is 125 */ threshold = min(125, threshold); return threshold; } int <API key>(struct zone *zone) { int threshold; int mem; /* memory in 128 MB units */ mem = zone->present_pages >> (27 - PAGE_SHIFT); threshold = 2 * fls(num_online_cpus()) * (1 + fls(mem)); /* * Maximum threshold is 125 */ threshold = min(125, threshold); return threshold; } /* * Refresh the thresholds for each zone. */ void <API key>(void) { struct zone *zone; int cpu; int threshold; <API key>(zone) { unsigned long max_drift, tolerate_drift; threshold = <API key>(zone); for_each_online_cpu(cpu) per_cpu_ptr(zone->pageset, cpu)->stat_threshold = threshold; /* * Only set percpu_drift_mark if there is a danger that * NR_FREE_PAGES reports the low watermark is ok when in fact * the min watermark could be breached by an allocation */ tolerate_drift = low_wmark_pages(zone) - min_wmark_pages(zone); max_drift = num_online_cpus() * threshold; if (max_drift > tolerate_drift) zone->percpu_drift_mark = high_wmark_pages(zone) + max_drift; } } void <API key>(pg_data_t *pgdat, int (*calculate_pressure)(struct zone *)) { struct zone *zone; int cpu; int threshold; int i; for (i = 0; i < pgdat->nr_zones; i++) { zone = &pgdat->node_zones[i]; if (!zone->percpu_drift_mark) continue; threshold = (*calculate_pressure)(zone); <API key>(cpu) per_cpu_ptr(zone->pageset, cpu)->stat_threshold = threshold; } } /* * For use when we know that interrupts are disabled. */ void <API key>(struct zone *zone, enum zone_stat_item item, int delta) { struct per_cpu_pageset __percpu *pcp = zone->pageset; s8 __percpu *p = pcp->vm_stat_diff + item; long x; long t; x = delta + __this_cpu_read(*p); t = __this_cpu_read(pcp->stat_threshold); if (unlikely(x > t || x < -t)) { zone_page_state_add(x, zone, item); x = 0; } __this_cpu_write(*p, x); } EXPORT_SYMBOL(<API key>); /* * Optimized increment and decrement functions. * * These are only for a single page and therefore can take a struct page * * argument instead of struct zone *. This allows the inclusion of the code * generated for page_zone(page) into the optimized functions. * * No overflow check is necessary and therefore the differential can be * incremented or decremented in place which may allow the compilers to * generate better code. * The increment or decrement is known and therefore one boundary check can * be omitted. * * NOTE: These functions are very performance sensitive. Change only * with care. * * Some processors have inc/dec instructions that are atomic vs an interrupt. * However, the code must first determine the differential location in a zone * based on the processor number and then inc/dec the counter. There is no * guarantee without disabling preemption that the processor will not change * in between and therefore the atomicity vs. interrupt cannot be exploited * in a useful way here. */ void __inc_zone_state(struct zone *zone, enum zone_stat_item item) { struct per_cpu_pageset __percpu *pcp = zone->pageset; s8 __percpu *p = pcp->vm_stat_diff + item; s8 v, t; v = <API key>(*p); t = __this_cpu_read(pcp->stat_threshold); if (unlikely(v > t)) { s8 overstep = t >> 1; zone_page_state_add(v + overstep, zone, item); __this_cpu_write(*p, -overstep); } } void <API key>(struct page *page, enum zone_stat_item item) { __inc_zone_state(page_zone(page), item); } EXPORT_SYMBOL(<API key>); void __dec_zone_state(struct zone *zone, enum zone_stat_item item) { struct per_cpu_pageset __percpu *pcp = zone->pageset; s8 __percpu *p = pcp->vm_stat_diff + item; s8 v, t; v = <API key>(*p); t = __this_cpu_read(pcp->stat_threshold); if (unlikely(v < - t)) { s8 overstep = t >> 1; zone_page_state_add(v - overstep, zone, item); __this_cpu_write(*p, overstep); } } void <API key>(struct page *page, enum zone_stat_item item) { __dec_zone_state(page_zone(page), item); } EXPORT_SYMBOL(<API key>); #ifdef <API key> /* * If we have cmpxchg_local support then we do not need to incur the overhead * that comes with local_irq_save/restore if we use this_cpu_cmpxchg. * * mod_state() modifies the zone counter state through atomic per cpu * operations. * * Overstep mode specifies how overstep should handled: * 0 No overstepping * 1 Overstepping half of threshold * -1 Overstepping minus half of threshold */ static inline void mod_state(struct zone *zone, enum zone_stat_item item, int delta, int overstep_mode) { struct per_cpu_pageset __percpu *pcp = zone->pageset; s8 __percpu *p = pcp->vm_stat_diff + item; long o, n, t, z; do { z = 0; /* overflow to zone counters */ /* * The fetching of the stat_threshold is racy. We may apply * a counter threshold to the wrong the cpu if we get * rescheduled while executing here. However, the next * counter update will apply the threshold again and * therefore bring the counter under the threshold again. * * Most of the time the thresholds are the same anyways * for all cpus in a zone. */ t = this_cpu_read(pcp->stat_threshold); o = this_cpu_read(*p); n = delta + o; if (n > t || n < -t) { int os = overstep_mode * (t >> 1) ; /* Overflow must be added to zone counters */ z = n + os; n = -os; } } while (this_cpu_cmpxchg(*p, o, n) != o); if (z) zone_page_state_add(z, zone, item); } void mod_zone_page_state(struct zone *zone, enum zone_stat_item item, int delta) { mod_state(zone, item, delta, 0); } EXPORT_SYMBOL(mod_zone_page_state); void inc_zone_state(struct zone *zone, enum zone_stat_item item) { mod_state(zone, item, 1, 1); } void inc_zone_page_state(struct page *page, enum zone_stat_item item) { mod_state(page_zone(page), item, 1, 1); } EXPORT_SYMBOL(inc_zone_page_state); void dec_zone_page_state(struct page *page, enum zone_stat_item item) { mod_state(page_zone(page), item, -1, -1); } EXPORT_SYMBOL(dec_zone_page_state); #else /* * Use interrupt disable to serialize counter updates */ void mod_zone_page_state(struct zone *zone, enum zone_stat_item item, int delta) { unsigned long flags; local_irq_save(flags); <API key>(zone, item, delta); local_irq_restore(flags); } EXPORT_SYMBOL(mod_zone_page_state); void inc_zone_state(struct zone *zone, enum zone_stat_item item) { unsigned long flags; local_irq_save(flags); __inc_zone_state(zone, item); local_irq_restore(flags); } void inc_zone_page_state(struct page *page, enum zone_stat_item item) { unsigned long flags; struct zone *zone; zone = page_zone(page); local_irq_save(flags); __inc_zone_state(zone, item); local_irq_restore(flags); } EXPORT_SYMBOL(inc_zone_page_state); void dec_zone_page_state(struct page *page, enum zone_stat_item item) { unsigned long flags; local_irq_save(flags); <API key>(page, item); local_irq_restore(flags); } EXPORT_SYMBOL(dec_zone_page_state); #endif /* * Update the zone counters for one cpu. * * The cpu specified must be either the current cpu or a processor that * is not online. If it is the current cpu then the execution thread must * be pinned to the current cpu. * * Note that <API key> strives to only access * node local memory. The per cpu pagesets on remote zones are placed * in the memory local to the processor using that pageset. So the * loop over all zones will access a series of cachelines local to * the processor. * * The call to zone_page_state_add updates the cachelines with the * statistics in the remote zone struct as well as the global cachelines * with the global counters. These could cause remote node cache line * bouncing and will have to be only done when necessary. */ void <API key>(int cpu) { struct zone *zone; int i; int global_diff[<API key>] = { 0, }; <API key>(zone) { struct per_cpu_pageset *p; p = per_cpu_ptr(zone->pageset, cpu); for (i = 0; i < <API key>; i++) if (p->vm_stat_diff[i]) { unsigned long flags; int v; local_irq_save(flags); v = p->vm_stat_diff[i]; p->vm_stat_diff[i] = 0; local_irq_restore(flags); atomic_long_add(v, &zone->vm_stat[i]); global_diff[i] += v; #ifdef CONFIG_NUMA /* 3 seconds idle till flush */ p->expire = 3; #endif } cond_resched(); #ifdef CONFIG_NUMA /* * Deal with draining the remote pageset of this * processor * * Check if there are pages remaining in this pageset * if not then there is nothing to expire. */ if (!p->expire || !p->pcp.count) continue; /* * We never drain zones local to this processor. */ if (zone_to_nid(zone) == numa_node_id()) { p->expire = 0; continue; } p->expire if (p->expire) continue; if (p->pcp.count) drain_zone_pages(zone, &p->pcp); #endif } for (i = 0; i < <API key>; i++) if (global_diff[i]) atomic_long_add(global_diff[i], &vm_stat[i]); } #endif #ifdef CONFIG_NUMA /* * zonelist = the list of zones passed to the allocator * z = the zone from which the allocation occurred. * * Must be called with interrupts disabled. * * When __GFP_OTHER_NODE is set assume the node of the preferred * zone is the local node. This is useful for daemons who allocate * memory on behalf of other processes. */ void zone_statistics(struct zone *preferred_zone, struct zone *z, gfp_t flags) { if (z->zone_pgdat == preferred_zone->zone_pgdat) { __inc_zone_state(z, NUMA_HIT); } else { __inc_zone_state(z, NUMA_MISS); __inc_zone_state(preferred_zone, NUMA_FOREIGN); } if (z->node == ((flags & __GFP_OTHER_NODE) ? preferred_zone->node : numa_node_id())) __inc_zone_state(z, NUMA_LOCAL); else __inc_zone_state(z, NUMA_OTHER); } #endif #ifdef CONFIG_COMPACTION struct contig_page_info { unsigned long free_pages; unsigned long free_blocks_total; unsigned long <API key>; }; /* * Calculate the number of free pages in a zone, how many contiguous * pages are free and how many are large enough to satisfy an allocation of * the target size. Note that this function makes no attempt to estimate * how many suitable free blocks there *might* be if MOVABLE pages were * migrated. Calculating that is possible, but expensive and can be * figured out from userspace */ static void <API key>(struct zone *zone, unsigned int suitable_order, struct contig_page_info *info) { unsigned int order; info->free_pages = 0; info->free_blocks_total = 0; info-><API key> = 0; for (order = 0; order < MAX_ORDER; order++) { unsigned long blocks; /* Count number of free blocks */ blocks = zone->free_area[order].nr_free; info->free_blocks_total += blocks; /* Count free base pages */ info->free_pages += blocks << order; /* Count the suitable free blocks */ if (order >= suitable_order) info-><API key> += blocks << (order - suitable_order); } } /* * A fragmentation index only makes sense if an allocation of a requested * size would fail. If that is true, the fragmentation index indicates * whether external fragmentation or a lack of memory was the problem. * The value can be used to determine if page reclaim or compaction * should be used */ static int <API key>(unsigned int order, struct contig_page_info *info) { unsigned long requested = 1UL << order; if (!info->free_blocks_total) return 0; /* Fragmentation index only makes sense when a request would fail */ if (info-><API key>) return -1000; /* * Index is between 0 and 1 so return within 3 decimal places * * 0 => allocation would fail due to lack of memory * 1 => allocation would fail due to fragmentation */ return 1000 - div_u64( (1000+(div_u64(info->free_pages * 1000ULL, requested))), info->free_blocks_total); } /* Same as __fragmentation index but allocs contig_page_info on stack */ int fragmentation_index(struct zone *zone, unsigned int order) { struct contig_page_info info; <API key>(zone, order, &info); return <API key>(order, &info); } #endif #if defined(CONFIG_PROC_FS) || defined(CONFIG_COMPACTION) #include <linux/proc_fs.h> #include <linux/seq_file.h> static char * const migratetype_names[MIGRATE_TYPES] = { "Unmovable", "Reclaimable", "Movable", "Reserve", #ifdef CONFIG_CMA "CMA", #endif "Isolate", }; static void *frag_start(struct seq_file *m, loff_t *pos) { pg_data_t *pgdat; loff_t node = *pos; for (pgdat = first_online_pgdat(); pgdat && node; pgdat = next_online_pgdat(pgdat)) --node; return pgdat; } static void *frag_next(struct seq_file *m, void *arg, loff_t *pos) { pg_data_t *pgdat = (pg_data_t *)arg; (*pos)++; return next_online_pgdat(pgdat); } static void frag_stop(struct seq_file *m, void *arg) { } /* Walk all the zones in a node and print using a callback */ static void walk_zones_in_node(struct seq_file *m, pg_data_t *pgdat, void (*print)(struct seq_file *m, pg_data_t *, struct zone *)) { struct zone *zone; struct zone *node_zones = pgdat->node_zones; unsigned long flags; for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) { if (!populated_zone(zone)) continue; spin_lock_irqsave(&zone->lock, flags); print(m, pgdat, zone); <API key>(&zone->lock, flags); } } #endif #if defined(CONFIG_PROC_FS) || defined(CONFIG_SYSFS) || defined(CONFIG_NUMA) #ifdef CONFIG_ZONE_DMA #define TEXT_FOR_DMA(xx) xx "_dma", #else #define TEXT_FOR_DMA(xx) #endif #ifdef CONFIG_ZONE_DMA32 #define TEXT_FOR_DMA32(xx) xx "_dma32", #else #define TEXT_FOR_DMA32(xx) #endif #ifdef CONFIG_HIGHMEM #define TEXT_FOR_HIGHMEM(xx) xx "_high", #else #define TEXT_FOR_HIGHMEM(xx) #endif #define TEXTS_FOR_ZONES(xx) TEXT_FOR_DMA(xx) TEXT_FOR_DMA32(xx) xx "_normal", \ TEXT_FOR_HIGHMEM(xx) xx "_movable", const char * const vmstat_text[] = { /* Zoned VM counters */ "nr_free_pages", "nr_inactive_anon", "nr_active_anon", "nr_inactive_file", "nr_active_file", "nr_unevictable", "nr_mlock", "nr_anon_pages", "nr_mapped", "nr_file_pages", "nr_dirty", "nr_writeback", "nr_slab_reclaimable", "<API key>", "nr_page_table_pages", "nr_kernel_stack", "nr_unstable", "nr_bounce", "nr_vmscan_write", "<API key>", "nr_writeback_temp", "nr_isolated_anon", "nr_isolated_file", "nr_shmem", "nr_dirtied", "nr_written", #ifdef CONFIG_NUMA "numa_hit", "numa_miss", "numa_foreign", "numa_interleave", "numa_local", "numa_other", #endif "<API key>", "nr_swapcache", #ifdef CONFIG_UKSM "nr_uksm_zero_pages", #endif "nr_free_cma", "nr_dirty_threshold", "<API key>", #ifdef <API key> "pgpgin", "pgpgout", "pswpin", "pswpout", TEXTS_FOR_ZONES("pgalloc") "pgfree", "pgactivate", "pgdeactivate", "pgfault", "pgmajfault", TEXTS_FOR_ZONES("pgrefill") TEXTS_FOR_ZONES("pgsteal_kswapd") TEXTS_FOR_ZONES("pgsteal_direct") TEXTS_FOR_ZONES("pgscan_kswapd") TEXTS_FOR_ZONES("pgscan_direct") #ifdef CONFIG_NUMA "zone_reclaim_failed", #endif "pginodesteal", "slabs_scanned", "kswapd_inodesteal", "<API key>", "<API key>", "<API key>", "pageoutrun", "allocstall", "pgrotated", #ifdef CONFIG_MIGRATION "pgmigrate_success", "pgmigrate_fail", #endif #ifdef CONFIG_COMPACTION "<API key>", "<API key>", "compact_isolated", "compact_stall", "compact_fail", "compact_success", #endif #ifdef CONFIG_HUGETLB_PAGE "<API key>", "<API key>", #endif "<API key>", "<API key>", "<API key>", "<API key>", "<API key>", "<API key>", "<API key>", "<API key>", #ifdef <API key> "thp_fault_alloc", "thp_fault_fallback", "thp_collapse_alloc", "<API key>", "thp_split", #endif #endif /* <API key> */ }; #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */ #ifdef CONFIG_PROC_FS static void frag_show_print(struct seq_file *m, pg_data_t *pgdat, struct zone *zone) { int order; seq_printf(m, "Node %d, zone %8s ", pgdat->node_id, zone->name); for (order = 0; order < MAX_ORDER; ++order) seq_printf(m, "%6lu ", zone->free_area[order].nr_free); seq_putc(m, '\n'); } /* * This walks the free areas for each zone. */ static int frag_show(struct seq_file *m, void *arg) { pg_data_t *pgdat = (pg_data_t *)arg; walk_zones_in_node(m, pgdat, frag_show_print); return 0; } static void <API key>(struct seq_file *m, pg_data_t *pgdat, struct zone *zone) { int order, mtype; for (mtype = 0; mtype < MIGRATE_TYPES; mtype++) { seq_printf(m, "Node %4d, zone %8s, type %12s ", pgdat->node_id, zone->name, migratetype_names[mtype]); for (order = 0; order < MAX_ORDER; ++order) { unsigned long freecount = 0; struct free_area *area; struct list_head *curr; area = &(zone->free_area[order]); list_for_each(curr, &area->free_list[mtype]) freecount++; seq_printf(m, "%6lu ", freecount); } seq_putc(m, '\n'); } } /* Print out the free pages at each order for each migatetype */ static int <API key>(struct seq_file *m, void *arg) { int order; pg_data_t *pgdat = (pg_data_t *)arg; /* Print header */ seq_printf(m, "%-43s ", "Free pages count per migrate type at order"); for (order = 0; order < MAX_ORDER; ++order) seq_printf(m, "%6d ", order); seq_putc(m, '\n'); walk_zones_in_node(m, pgdat, <API key>); return 0; } static void <API key>(struct seq_file *m, pg_data_t *pgdat, struct zone *zone) { int mtype; unsigned long pfn; unsigned long start_pfn = zone->zone_start_pfn; unsigned long end_pfn = start_pfn + zone->spanned_pages; unsigned long count[MIGRATE_TYPES] = { 0, }; for (pfn = start_pfn; pfn < end_pfn; pfn += pageblock_nr_pages) { struct page *page; if (!pfn_valid(pfn)) continue; page = pfn_to_page(pfn); /* Watch for unexpected holes punched in the memmap */ if (!memmap_valid_within(pfn, page, zone)) continue; mtype = <API key>(page); if (mtype < MIGRATE_TYPES) count[mtype]++; } /* Print counts */ seq_printf(m, "Node %d, zone %8s ", pgdat->node_id, zone->name); for (mtype = 0; mtype < MIGRATE_TYPES; mtype++) seq_printf(m, "%12lu ", count[mtype]); seq_putc(m, '\n'); } /* Print out the free pages at each order for each migratetype */ static int <API key>(struct seq_file *m, void *arg) { int mtype; pg_data_t *pgdat = (pg_data_t *)arg; seq_printf(m, "\n%-23s", "Number of blocks type "); for (mtype = 0; mtype < MIGRATE_TYPES; mtype++) seq_printf(m, "%12s ", migratetype_names[mtype]); seq_putc(m, '\n'); walk_zones_in_node(m, pgdat, <API key>); return 0; } /* * This prints out statistics in relation to grouping pages by mobility. * It is expensive to collect so do not constantly read the file. */ static int pagetypeinfo_show(struct seq_file *m, void *arg) { pg_data_t *pgdat = (pg_data_t *)arg; /* check memoryless node */ if (!node_state(pgdat->node_id, N_MEMORY)) return 0; seq_printf(m, "Page block order: %d\n", pageblock_order); seq_printf(m, "Pages per block: %lu\n", pageblock_nr_pages); seq_putc(m, '\n'); <API key>(m, pgdat); <API key>(m, pgdat); return 0; } static const struct seq_operations fragmentation_op = { .start = frag_start, .next = frag_next, .stop = frag_stop, .show = frag_show, }; static int fragmentation_open(struct inode *inode, struct file *file) { return seq_open(file, &fragmentation_op); } static const struct file_operations <API key> = { .open = fragmentation_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, }; static const struct seq_operations pagetypeinfo_op = { .start = frag_start, .next = frag_next, .stop = frag_stop, .show = pagetypeinfo_show, }; static int pagetypeinfo_open(struct inode *inode, struct file *file) { return seq_open(file, &pagetypeinfo_op); } static const struct file_operations <API key> = { .open = pagetypeinfo_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, }; static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat, struct zone *zone) { int i; seq_printf(m, "Node %d, zone %8s", pgdat->node_id, zone->name); seq_printf(m, "\n pages free %lu" "\n min %lu" "\n low %lu" "\n high %lu" "\n scanned %lu" "\n spanned %lu" "\n present %lu", zone_page_state(zone, NR_FREE_PAGES), min_wmark_pages(zone), low_wmark_pages(zone), high_wmark_pages(zone), zone->pages_scanned, zone->spanned_pages, zone->present_pages); for (i = 0; i < <API key>; i++) seq_printf(m, "\n %-12s %lu", vmstat_text[i], zone_page_state(zone, i)); seq_printf(m, "\n protection: (%lu", zone->lowmem_reserve[0]); for (i = 1; i < ARRAY_SIZE(zone->lowmem_reserve); i++) seq_printf(m, ", %lu", zone->lowmem_reserve[i]); seq_printf(m, ")" "\n pagesets"); for_each_online_cpu(i) { struct per_cpu_pageset *pageset; pageset = per_cpu_ptr(zone->pageset, i); seq_printf(m, "\n cpu: %i" "\n count: %i" "\n high: %i" "\n batch: %i", i, pageset->pcp.count, pageset->pcp.high, pageset->pcp.batch); #ifdef CONFIG_SMP seq_printf(m, "\n vm stats threshold: %d", pageset->stat_threshold); #endif } seq_printf(m, "\n all_unreclaimable: %u" "\n start_pfn: %lu" "\n inactive_ratio: %u", !zone_reclaimable(zone), zone->zone_start_pfn, zone->inactive_ratio); seq_putc(m, '\n'); } /* * Output information about zones in @pgdat. */ static int zoneinfo_show(struct seq_file *m, void *arg) { pg_data_t *pgdat = (pg_data_t *)arg; walk_zones_in_node(m, pgdat, zoneinfo_show_print); return 0; } static const struct seq_operations zoneinfo_op = { .start = frag_start, /* iterate over all zones. The same as in * fragmentation. */ .next = frag_next, .stop = frag_stop, .show = zoneinfo_show, }; static int zoneinfo_open(struct inode *inode, struct file *file) { return seq_open(file, &zoneinfo_op); } static const struct file_operations <API key> = { .open = zoneinfo_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, }; enum writeback_stat_item { NR_DIRTY_THRESHOLD, <API key>, <API key>, }; static void *vmstat_start(struct seq_file *m, loff_t *pos) { unsigned long *v; int i, stat_items_size; if (*pos >= ARRAY_SIZE(vmstat_text)) return NULL; stat_items_size = <API key> * sizeof(unsigned long) + <API key> * sizeof(unsigned long); #ifdef <API key> stat_items_size += sizeof(struct vm_event_state); #endif v = kmalloc(stat_items_size, GFP_KERNEL); m->private = v; if (!v) return ERR_PTR(-ENOMEM); for (i = 0; i < <API key>; i++) v[i] = global_page_state(i); v += <API key>; global_dirty_limits(v + <API key>, v + NR_DIRTY_THRESHOLD); v += <API key>; #ifdef <API key> all_vm_events(v); v[PGPGIN] /= 2; /* sectors -> kbytes */ v[PGPGOUT] /= 2; #endif return (unsigned long *)m->private + *pos; } static void *vmstat_next(struct seq_file *m, void *arg, loff_t *pos) { (*pos)++; if (*pos >= ARRAY_SIZE(vmstat_text)) return NULL; return (unsigned long *)m->private + *pos; } static int vmstat_show(struct seq_file *m, void *arg) { unsigned long *l = arg; unsigned long off = l - (unsigned long *)m->private; seq_printf(m, "%s %lu\n", vmstat_text[off], *l); return 0; } static void vmstat_stop(struct seq_file *m, void *arg) { kfree(m->private); m->private = NULL; } static const struct seq_operations vmstat_op = { .start = vmstat_start, .next = vmstat_next, .stop = vmstat_stop, .show = vmstat_show, }; static int vmstat_open(struct inode *inode, struct file *file) { return seq_open(file, &vmstat_op); } static const struct file_operations <API key> = { .open = vmstat_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, }; #endif /* CONFIG_PROC_FS */ #ifdef CONFIG_SMP static DEFINE_PER_CPU(struct delayed_work, vmstat_work); int <API key> __read_mostly = HZ; static void vmstat_update(struct work_struct *w) { <API key>(smp_processor_id()); <API key>(&__get_cpu_var(vmstat_work), <API key>(<API key>)); } static void __cpuinit start_cpu_timer(int cpu) { struct delayed_work *work = &per_cpu(vmstat_work, cpu); <API key>(work, vmstat_update); <API key>(cpu, work, <API key>(HZ, cpu)); } /* * Use the cpu notifier to insure that the thresholds are recalculated * when necessary. */ static int __cpuinit <API key>(struct notifier_block *nfb, unsigned long action, void *hcpu) { long cpu = (long)hcpu; switch (action) { case CPU_ONLINE: case CPU_ONLINE_FROZEN: <API key>(); start_cpu_timer(cpu); node_set_state(cpu_to_node(cpu), N_CPU); break; case CPU_DOWN_PREPARE: case <API key>: <API key>(&per_cpu(vmstat_work, cpu)); per_cpu(vmstat_work, cpu).work.func = NULL; break; case CPU_DOWN_FAILED: case <API key>: start_cpu_timer(cpu); break; case CPU_DEAD: case CPU_DEAD_FROZEN: <API key>(); break; default: break; } return NOTIFY_OK; } static struct notifier_block __cpuinitdata vmstat_notifier = { &<API key>, NULL, 0 }; #endif static int __init setup_vmstat(void) { #ifdef CONFIG_SMP int cpu; <API key>(&vmstat_notifier); for_each_online_cpu(cpu) start_cpu_timer(cpu); #endif #ifdef CONFIG_PROC_FS proc_create("buddyinfo", S_IRUGO, NULL, &<API key>); proc_create("pagetypeinfo", S_IRUGO, NULL, &<API key>); proc_create("vmstat", S_IRUGO, NULL, &<API key>); proc_create("zoneinfo", S_IRUGO, NULL, &<API key>); #endif return 0; } module_init(setup_vmstat) #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_COMPACTION) #include <linux/debugfs.h> static struct dentry *extfrag_debug_root; /* * Return an index indicating how much of the available free memory is * unusable for an allocation of the requested size. */ static int unusable_free_index(unsigned int order, struct contig_page_info *info) { /* No free memory is interpreted as all free memory is unusable */ if (info->free_pages == 0) return 1000; /* * Index should be a value between 0 and 1. Return a value to 3 * decimal places. * * 0 => no fragmentation * 1 => high fragmentation */ return div_u64((info->free_pages - (info-><API key> << order)) * 1000ULL, info->free_pages); } static void unusable_show_print(struct seq_file *m, pg_data_t *pgdat, struct zone *zone) { unsigned int order; int index; struct contig_page_info info; seq_printf(m, "Node %d, zone %8s ", pgdat->node_id, zone->name); for (order = 0; order < MAX_ORDER; ++order) { <API key>(zone, order, &info); index = unusable_free_index(order, &info); seq_printf(m, "%d.%03d ", index / 1000, index % 1000); } seq_putc(m, '\n'); } /* * Display unusable free space index * * The unusable free space index measures how much of the available free * memory cannot be used to satisfy an allocation of a given size and is a * value between 0 and 1. The higher the value, the more of free memory is * unusable and by implication, the worse the external fragmentation is. This * can be expressed as a percentage by multiplying by 100. */ static int unusable_show(struct seq_file *m, void *arg) { pg_data_t *pgdat = (pg_data_t *)arg; /* check memoryless node */ if (!node_state(pgdat->node_id, N_MEMORY)) return 0; walk_zones_in_node(m, pgdat, unusable_show_print); return 0; } static const struct seq_operations unusable_op = { .start = frag_start, .next = frag_next, .stop = frag_stop, .show = unusable_show, }; static int unusable_open(struct inode *inode, struct file *file) { return seq_open(file, &unusable_op); } static const struct file_operations unusable_file_ops = { .open = unusable_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, }; static void extfrag_show_print(struct seq_file *m, pg_data_t *pgdat, struct zone *zone) { unsigned int order; int index; /* Alloc on stack as interrupts are disabled for zone walk */ struct contig_page_info info; seq_printf(m, "Node %d, zone %8s ", pgdat->node_id, zone->name); for (order = 0; order < MAX_ORDER; ++order) { <API key>(zone, order, &info); index = <API key>(order, &info); seq_printf(m, "%d.%03d ", index / 1000, index % 1000); } seq_putc(m, '\n'); } /* * Display fragmentation index for orders that allocations would fail for */ static int extfrag_show(struct seq_file *m, void *arg) { pg_data_t *pgdat = (pg_data_t *)arg; walk_zones_in_node(m, pgdat, extfrag_show_print); return 0; } static const struct seq_operations extfrag_op = { .start = frag_start, .next = frag_next, .stop = frag_stop, .show = extfrag_show, }; static int extfrag_open(struct inode *inode, struct file *file) { return seq_open(file, &extfrag_op); } static const struct file_operations extfrag_file_ops = { .open = extfrag_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, }; static int __init extfrag_debug_init(void) { extfrag_debug_root = debugfs_create_dir("extfrag", NULL); if (!extfrag_debug_root) return -ENOMEM; if (!debugfs_create_file("unusable_index", 0444, extfrag_debug_root, NULL, &unusable_file_ops)) return -ENOMEM; if (!debugfs_create_file("extfrag_index", 0444, extfrag_debug_root, NULL, &extfrag_file_ops)) return -ENOMEM; return 0; } module_init(extfrag_debug_init); #endif
<?php // no direct access defined('_JEXEC') or die('Restricted access'); jimport('joomla.application.component.model'); /** * EventList Component Categoryelement Model * * @package Joomla * @subpackage EventList * @since 0.9 */ class <API key> extends JModel { /** * Category data array * * @var array */ var $_data = null; /** * Category total * * @var integer */ var $_total = null; /** * Pagination object * * @var object */ var $_pagination = null; /** * Constructor * * @since 0.9 */ function __construct() { parent::__construct(); global $mainframe, $option; $limit = $mainframe-><API key>( $option.'.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); $limitstart = $mainframe-><API key>( $option.JRequest::getCmd( 'view').'.limitstart', 'limitstart', 0, 'int' ); $this->setState('limit', $limit); $this->setState('limitstart', $limitstart); } /** * Method to get categories item data * * @access public * @return array */ function getData() { // Lets load the content if it doesn't already exist if (empty($this->_data)) { $this->getPagination(); // do it first to get the proper limits ! $query = $this->_buildQuery(); $this->_data = $this->_getList($query, $this->_pagination->limitstart, $this->_pagination->limit); } return $this->_data; } /** * Total nr of categories * * @access public * @return integer * @since 0.9 */ function getTotal() { // Lets load the content if it doesn't already exist if (empty($this->_total)) { $query = $this->_buildQuery(); $this->_total = $this->_getListCount($query); } return $this->_total; } /** * Method to get a pagination object for the categories * * @access public * @return integer */ function getPagination() { // Lets load the content if it doesn't already exist if (empty($this->_pagination)) { jimport('joomla.html.pagination'); $this->_pagination = new JPagination( $this->getTotal(), $this->getState('limitstart'), $this->getState('limit') ); } return $this->_pagination; } /** * Method to build the query for the categories * * @access private * @return integer * @since 0.9 */ function _buildQuery() { // Get the WHERE and ORDER BY clauses for the query $where = $this->_buildContentWhere(); $orderby = $this-><API key>(); $query = 'SELECT c.*' . ' FROM #<API key> AS c' . $where . $orderby ; return $query; } /** * Method to build the orderby clause of the query for the categories * * @access private * @return string * @since 0.9 */ function <API key>() { global $mainframe, $option; $filter_order = $mainframe-><API key>( $option.'.categoryelement.filter_order', 'filter_order', 'c.ordering', 'cmd' ); $filter_order_Dir = $mainframe-><API key>( $option.'.categoryelement.filter_order_Dir', 'filter_order_Dir', '', 'word' ); $orderby = ' ORDER BY '.$filter_order.' '.$filter_order_Dir.', c.ordering'; return $orderby; } /** * Method to build the where clause of the query for the categories * * @access private * @return string * @since 0.9 */ function _buildContentWhere() { global $mainframe, $option; $filter_state = $mainframe-><API key>( $option.'.categoryelement.filter_state', 'filter_state', '', 'word' ); $search = $mainframe-><API key>( $option.'.categoryelement.search', 'search', '', 'string' ); $search = $this->_db->getEscaped( trim(JString::strtolower( $search ) ) ); $where = array(); if ( $filter_state ) { if ( $filter_state == 'P' ) { $where[] = 'c.published = 1'; } else if ($filter_state == 'U' ) { $where[] = 'c.published = 0'; } } if ($search) { $where[] = ' LOWER(c.catname) LIKE \'%'.$search.'%\' '; } $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); return $where; } } ?>
#wrap-admin { margin: 0px; max-width: 900px; width: auto; color: #555555; float: left; } form#reset-options { background: #FCE2DA; margin: 20px 0px; padding: 2%; float: left; width: 90%; border-top: 5px solid #C6380F !important; border-bottom: 5px solid #C6380F !important; font-size: 15px !important; color: #7D0000; } form#reset-options strong { font-size: 15px !important; } #reset-options .saveme { margin: 0px; padding: 0px; float: left !important; } input.pick { margin: 3px 0px; padding: 0px; float: left; height: 20px; width: 50px; } #wrap-admin form { border-width: 0px!important; border-style: none!important; } html { line-height: 125%; } #wrap-admin em { font-style: italic; } #content-admin { margin: 0px; width: 100%; float: left; border-width: 0px; border-style: none; } #top-content-admin { margin: 0px; width: 100%; float: left; padding: 0px; } #wrap-admin #top-content-admin h4 { font-size: 1.5em; margin: 0px; padding: 0px; float: left; width: 100%; border-width: 0px!important; border-style: none!important; font-family: "Trebuchet MS", sans-serif; letter-spacing: -1px; } #content-admin h5 { font-size: 1.65em; margin: 0px; padding: 0px; letter-spacing: -1px; color: #000000; float: left; width: 100%; font-family: "Trebuchet MS", sans-serif; } #content-admin h6 { font-size: 1.25em; margin: 0px 0px 10px; padding: 0px; font-weight: normal; } #wrap-admin #top-content-admin p { font-weight: normal; margin: 0px; padding: 0px; float: left; width: 100%; font-size: 11px; color: #333333; border-width: 0px!important; border-style: none!important; } #content-admin .onlyjpg { color: #660000!important; font-size: 10px; margin: 10px 0px 2em; } #content-admin .option-box { margin: 0px 0px 2em; float: left; width: 92%; padding: 2% 3%; background: #e4f2fd; border: 2px solid #C4E2FB; } #content-admin #main-setting { background: #ECF3D1; border: 2px solid #DFEBAF; } #content-admin #main-setting h4 { border-bottom: 1px solid #CEE085; } #content-admin .upz { padding: 2px; background: #FFFFFF; border: 1px solid #CCCCCC; width: 500px; margin: 0px; clear: right; } #photo p { margin: 10px 0px 0px; padding: 0px; float: left; width: 100%; } .admin-layer { margin: 0px 10px 0px 0px; padding: 0px; float: left; width: 31%; } .option-box h4 { color: #121212; float: left; font-size: 13px; font-weight: 600; line-height: 18px; margin: 0; padding: 10px 0; width: 100%; border-bottom: 1px solid #C4E2FB; } .option-box p { font-size: 11px; margin: 0px; color: #121212; padding: 0px; float: left; width: 100%; font-weight: normal; line-height: 17px; } .option-box p em { font-size: 11px; color: #888; line-height: 17px; } .option-box .pwrap { margin: 0px; padding: 10px 0px; float: left; width: 100%; } .option-box .pwrap p { font-weight: 400; } #content-admin .ops-text { margin: 0px 0px 10px; padding: 6px 3px; float: left; width: 93%; background: #FFFFFF; font-size: 12px; font-weight: normal; border-top: 1px solid #666; border-right: 1px solid #ACACAC; border-bottom: 1px solid #ACACAC; border-left: 1px solid #666; line-height: 1.4em; } .ops-colour { margin: 0px 10px 0px 0px; padding: 5px 2px; float: left; width: 93%; background: #FFFFFF; border-top: 1px solid #666; border-right: 1px solid #ACACAC; border-bottom: 1px solid #ACACAC; border-left: 1px solid #666; font-size: 11px; font-weight: normal; } .ops-select { margin: 0px 0px 10px; padding: 5px 2px; float: left; width: 92%; background: #FFFFFF; border-top: 1px solid #666; border-right: 1px solid #ACACAC; border-bottom: 1px solid #ACACAC; border-left: 1px solid #666; font-size: 11px!important; font-weight: normal; } .ops-area { margin: 0px; padding: 5px 2px; float: left; width: 93%; background: #FFFFFF; border-top: 1px solid #666; border-right: 1px solid #ACACAC; border-bottom: 1px solid #ACACAC; border-left: 1px solid #666; font-size: 12px; height: 150px; font-weight: normal; line-height: 1.4em!important; } .admin-ops { margin: 0px; padding: 0px; float: left; width: 100%; } #option-mz-form { margin: 0px; padding: 0px; float: left; width: 100%; border-width: 0px!important; border-style: none!important; } #wrap-admin .submit { margin: 0px; padding: 0px; float: left; width: 100%; border-width: 0px!important; border-style: none!important; } #wrap-admin .saveme { font-size: 11px; font-weight: bold; margin: 8px 0px 0px; float: left; background: #EAEAEA; padding: 2px 6px; border-top: 1px solid #999999; border-right: 1px solid #666666; border-bottom: 1px solid #666666; border-left: 1px solid #999999; color: #333333; } #post-reset { margin: 0px; padding: 0px; float: left; width: 100%; } #wrap-admin .explain { font-size: 10px; line-height: 20px; margin: 0px; padding: 5px 0px; float: left; width: 100%; color: #660000; } #ColorPickerDiv { display: block; display: none; position: relative; border: 1px solid #777; background: #fff } #ColorPickerDiv TD.color { cursor: pointer; font-size: xx-small; } #ColorPickerDiv TD.color label { cursor: pointer; } .<API key> { margin: 5px 0px 0px; border: solid 1px #000; padding: 0px 10px; position: relative; cursor: pointer; float: left; width: 32px; } #crop-img h4 { font-size: 17px; margin: 0px 0px 15px; padding: 0px; float: left; width: 100%; } #crop-img img { margin: 0px 0px 15px; padding: 0px; float: left; height: auto; width: 100%; } .uperror { font-size: 14px!important; font-weight: bold!important; color: #990000!important; } #gala { margin: 0px; padding: 0px 0px 2em; float: left; width: 100%; } .gallery-box { margin: 0px 0px 10px; padding: 1%; float: left; width: 95%; background: #e4f2fd; } .gallery-box p { margin: 0px; padding: 15px 0px 0px; float: left; } .gallery-box .ops-text { margin: 0px 10px 0px 0px; padding: 4px 2px; float: left; width: 700px; background: #FFFFFF; border: 1px solid #ACACAC; font-size: 12px; color: #000000; } .gallery-box .img-left { margin: 0px 10px 0px 0px; padding: 0px; float: left; } .submit-button { padding: 2px 4px; margin: 0px; -<API key>: 3px; -<API key>: 3px; -<API key>: 3px; <API key>: 3px; -<API key>: 3px; -<API key>: 3px; -<API key>: 3px; <API key>: 3px; color: #333333; border: 1px solid #4988B6; font-family: "Lucida Grande", Arial, Verdana, "Trebuchet MS"; font-size: 12px; font-weight: bold; background: #EAEAEA; }.timg { margin: 0px 0px 15px; padding: 0px; } h4#loading-bar { background: url(loading.gif) no-repeat 15px center!important; margin: 5em 0px 0px!important; padding: 50px 0px 50px 145px!important; float: left!important; width: 80%!important; font-size: 25px!important; } /* <API key> */
<div class="content events-body"<?php print $content_attributes; ?>> <?php // Hide comments, tags, and links now so that we can render them later. hide($content['comments']); hide($content['links']); hide($content['field_tags']); if(is_array($node-><API key>)){ print render($content['<API key>']); } ?> <div class="date"><?php print render($content['field_event_date']);?></div> <?php print render($content);?> </div> <?php if (!empty($content['field_tags']) || !empty($content['links'])): ?> <footer> <?php print render($content['field_tags']); ?> <?php print render($content['links']); ?> </footer> <?php endif; ?> <?php print render($content['comments']); ?> <?php if (!$page): ?> </article> <!-- /.node --> <?php endif; ?>
#define APPNAME "dirname" #include "common.h" static void show_help(void) { printf("Usage: %s OPTION\n\ or: %s PATH [PATH...]\n\n\ Options:\n\ -h, --help\t\tdisplay this help\n\ -V, --version\tdisplay version information\n\n\ Report bugs to <bulliver@gmail.com>\n", APPNAME, APPNAME); } int main(int argc, char *argv[]) { int opt; struct option longopts[] = { {"help", 0, NULL, 'h'}, {"version", 0, NULL, 'V'}, {0,0,0,0} }; while ((opt = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1) { switch(opt) { case 'V': printf("%s (%s) version %s\n", APPNAME, APPSUITE, APPVERSION); printf("%s compiled on %s at %s\n", basename(__FILE__), __DATE__, __TIME__); exit(EXIT_SUCCESS); break; case 'h': show_help(); exit(EXIT_SUCCESS); break; case ':': /* getopt_long prints own error message */ exit(EXIT_FAILURE); break; case '?': /* getopt_long prints own error message */ exit(EXIT_FAILURE); default: show_help(); exit(EXIT_FAILURE); break; } } if (argc == 1) { show_help(); exit(EXIT_FAILURE); } char *d; while (optind < argc) { if ((d = dirname(argv[optind])) == NULL) { perror("dirname"); exit(EXIT_FAILURE); } printf("%s\n", d); optind++; } return EXIT_SUCCESS; }
//>>built define("dojox/mvc/StatefulArray",["dojo/_base/lang","dojo/Stateful"],function(_1,_2){ function _3(a){ if(a.<API key>){ a.<API key>(); } return a; }; var _4=function(a){ var _5=_1._toArray(a||[]); var _6=_4; _5.constructor=_6; return _1.mixin(_5,{pop:function(){ return this.splice(this.get("length")-1,1)[0]; },push:function(){ this.splice.apply(this,[this.get("length"),0].concat(_1._toArray(arguments))); return this.get("length"); },reverse:function(){ return _3([].reverse.apply(this,_1._toArray(arguments))); },shift:function(){ return this.splice(0,1)[0]; },sort:function(){ return _3([].sort.apply(this,_1._toArray(arguments))); },splice:function(_7,n){ var l=this.get("length"); _7+=_7<0?l:0; var p=Math.min(_7,l),_8=this.slice(_7,_7+n),_9=_1._toArray(arguments).slice(2); [].splice.apply(this,[_7,n].concat(new Array(_9.length))); for(var i=0;i<_9.length;i++){ this[p+i]=_9[i]; } if(this.<API key>){ this.<API key>(_7,_8,_9); } if(this._watchCallbacks){ this._watchCallbacks("length",l,l-_8.length+_9.length); } return _8; },unshift:function(){ this.splice.apply(this,[0,0].concat(_1._toArray(arguments))); return this.get("length"); },concat:function(a){ return new _4([].concat.apply(this,arguments)); },join:function(_a){ var _b=[]; for(var l=this.get("length"),i=0;i<l;i++){ _b.push(this.get(i)); } return _b.join(_a); },slice:function(_c,_d){ var l=this.get("length"); _c+=_c<0?l:0; _d=(_d===void 0?l:_d)+(_d<0?l:0); var _e=[]; for(var i=_c||0;i<Math.min(_d,this.get("length"));i++){ _e.push(this.get(i)); } return new _4(_e); },watchElements:function(_f){ var _10=this.<API key>,_11=this; if(!_10){ _10=this.<API key>=function(idx,_12,_13){ for(var _14=[].concat(_10.list),i=0;i<_14.length;i++){ _14[i].call(_11,idx,_12,_13); } }; _10.list=[]; } _10.list.push(_f); var h={}; h.unwatch=h.remove=function(){ for(var _15=_10.list,i=0;i<_15.length;i++){ if(_15[i]==_f){ _15.splice(i,1); break; } } }; return h; }},_2.prototype,{set:function(_16,_17){ if(_16=="length"){ var old=this.get("length"); if(old<_17){ this.splice.apply(this,[old,0].concat(new Array(_17-old))); }else{ if(_17<old){ this.splice.apply(this,[_17,old-_17]); } } return this; }else{ var _18=this.length; _2.prototype.set.call(this,_16,_17); if(_18!=this.length){ _2.prototype.set.call(this,"length",this.length); } return this; } },isInstanceOf:function(cls){ return _2.prototype.isInstanceOf.apply(this,arguments)||cls==_4; }}); }; _4._meta={bases:[_2]}; return _1.setObject("dojox.mvc.StatefulArray",_4); });
#include "config.h" #include "system.h" #include "coretypes.h" #include "tm.h" #include "tree.h" #include "diagnostic.h" #include "tree-pretty-print.h" #include "gimple-pretty-print.h" #include "hashtab.h" #include "tree-flow.h" #include "tree-pass.h" #include "gimple.h" #include "value-prof.h" #include "trans-mem.h" #define INDENT(SPACE) \ do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0) static pretty_printer buffer; static bool initialized = false; #define GIMPLE_NIY do_niy (buffer,gs) /* Try to print on BUFFER a default message for the unrecognized gimple statement GS. */ static void do_niy (pretty_printer *buffer, gimple gs) { pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n", gimple_code_name[(int) gimple_code (gs)]); } /* Initialize the pretty printer on FILE if needed. */ static void <API key> (FILE *file) { if (!initialized) { pp_construct (&buffer, NULL, 0); pp_needs_newline (&buffer) = true; initialized = true; } buffer.buffer->stream = file; } /* Emit a newline and SPC indentantion spaces to BUFFER. */ static void newline_and_indent (pretty_printer *buffer, int spc) { pp_newline (buffer); INDENT (spc); } /* Print the GIMPLE statement GS on stderr. */ DEBUG_FUNCTION void debug_gimple_stmt (gimple gs) { print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS); fprintf (stderr, "\n"); } /* Dump GIMPLE statement G to FILE using SPC indentantion spaces and FLAGS as in dump_gimple_stmt. */ void print_gimple_stmt (FILE *file, gimple g, int spc, int flags) { <API key> (file); dump_gimple_stmt (&buffer, g, spc, flags); pp_flush (&buffer); } /* Dump GIMPLE statement G to FILE using SPC indentantion spaces and FLAGS as in dump_gimple_stmt. Print only the right-hand side of the statement. */ void print_gimple_expr (FILE *file, gimple g, int spc, int flags) { flags |= TDF_RHS_ONLY; <API key> (file); dump_gimple_stmt (&buffer, g, spc, flags); } /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentantion spaces and FLAGS as in dump_gimple_stmt. */ static void dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags) { <API key> i; for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i)) { gimple gs = gsi_stmt (i); INDENT (spc); dump_gimple_stmt (buffer, gs, spc, flags); if (!<API key> (i)) pp_newline (buffer); } } /* Dump GIMPLE sequence SEQ to FILE using SPC indentantion spaces and FLAGS as in dump_gimple_stmt. */ void print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags) { <API key> (file); dump_gimple_seq (&buffer, seq, spc, flags); pp_flush (&buffer); } /* Print the GIMPLE sequence SEQ on stderr. */ DEBUG_FUNCTION void debug_gimple_seq (gimple_seq seq) { print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS); } /* A simple helper to pretty-print some of the gimple tuples in the printf style. The format modifiers are preceeded by '%' and are: 'G' - outputs a string corresponding to the code of the given gimple, 'S' - outputs a gimple_seq with indent of spc + 2, 'T' - outputs the tree t, 'd' - outputs an int as a decimal, 's' - outputs a string, 'n' - outputs a newline, 'x' - outputs an int as hexadecimal, '+' - increases indent by 2 then outputs a newline, '-' - decreases indent by 2 then outputs a newline. */ static void dump_gimple_fmt (pretty_printer *buffer, int spc, int flags, const char *fmt, ...) { va_list args; const char *c; const char *tmp; va_start (args, fmt); for (c = fmt; *c; c++) { if (*c == '%') { gimple_seq seq; tree t; gimple g; switch (*++c) { case 'G': g = va_arg (args, gimple); tmp = gimple_code_name[gimple_code (g)]; pp_string (buffer, tmp); break; case 'S': seq = va_arg (args, gimple_seq); pp_newline (buffer); dump_gimple_seq (buffer, seq, spc + 2, flags); newline_and_indent (buffer, spc); break; case 'T': t = va_arg (args, tree); if (t == NULL_TREE) pp_string (buffer, "NULL"); else dump_generic_node (buffer, t, spc, flags, false); break; case 'd': pp_decimal_int (buffer, va_arg (args, int)); break; case 's': pp_string (buffer, va_arg (args, char *)); break; case 'n': newline_and_indent (buffer, spc); break; case 'x': pp_scalar (buffer, "%x", va_arg (args, int)); break; case '+': spc += 2; newline_and_indent (buffer, spc); break; case '-': spc -= 2; newline_and_indent (buffer, spc); break; default: gcc_unreachable (); } } else pp_character (buffer, *c); } va_end (args); } /* Helper for dump_gimple_assign. Print the unary RHS of the assignment GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */ static void dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags) { enum tree_code rhs_code = <API key> (gs); tree lhs = gimple_assign_lhs (gs); tree rhs = gimple_assign_rhs1 (gs); switch (rhs_code) { case VIEW_CONVERT_EXPR: case ASSERT_EXPR: dump_generic_node (buffer, rhs, spc, flags, false); break; case FIXED_CONVERT_EXPR: case <API key>: case FIX_TRUNC_EXPR: case FLOAT_EXPR: CASE_CONVERT: pp_character (buffer, '('); dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false); pp_string (buffer, ") "); if (op_prio (rhs) < op_code_prio (rhs_code)) { pp_character (buffer, '('); dump_generic_node (buffer, rhs, spc, flags, false); pp_character (buffer, ')'); } else dump_generic_node (buffer, rhs, spc, flags, false); break; case PAREN_EXPR: pp_string (buffer, "(("); dump_generic_node (buffer, rhs, spc, flags, false); pp_string (buffer, "))"); break; case BYTESWAP_EXPR: pp_string (buffer, "BYTESWAP_EXPR <"); pp_wide_integer (buffer, TYPE_PRECISION (TREE_TYPE (rhs))); pp_string (buffer, ", "); dump_generic_node (buffer, rhs, spc, flags, false); pp_string (buffer, ">"); break; case ABS_EXPR: pp_string (buffer, "ABS_EXPR <"); dump_generic_node (buffer, rhs, spc, flags, false); pp_character (buffer, '>'); break; default: if (TREE_CODE_CLASS (rhs_code) == tcc_declaration || TREE_CODE_CLASS (rhs_code) == tcc_constant || TREE_CODE_CLASS (rhs_code) == tcc_reference || rhs_code == SSA_NAME || rhs_code == ADDR_EXPR || rhs_code == CONSTRUCTOR) { dump_generic_node (buffer, rhs, spc, flags, false); break; } else if (rhs_code == BIT_NOT_EXPR) pp_character (buffer, '~'); else if (rhs_code == TRUTH_NOT_EXPR) pp_character (buffer, '!'); else if (rhs_code == NEGATE_EXPR) pp_character (buffer, '-'); else { pp_character (buffer, '['); pp_string (buffer, tree_code_name [rhs_code]); pp_string (buffer, "] "); } if (op_prio (rhs) < op_code_prio (rhs_code)) { pp_character (buffer, '('); dump_generic_node (buffer, rhs, spc, flags, false); pp_character (buffer, ')'); } else dump_generic_node (buffer, rhs, spc, flags, false); break; } } /* Helper for dump_gimple_assign. Print the binary RHS of the assignment GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */ static void dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags) { const char *p; enum tree_code code = <API key> (gs); switch (code) { case COMPLEX_EXPR: case MIN_EXPR: case MAX_EXPR: case <API key>: case <API key>: case VEC_PACK_TRUNC_EXPR: case VEC_PACK_SAT_EXPR: case <API key>: case <API key>: case <API key>: for (p = tree_code_name [(int) code]; *p; p++) pp_character (buffer, TOUPPER (*p)); pp_string (buffer, " <"); dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); pp_string (buffer, ", "); dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); pp_character (buffer, '>'); break; default: if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code)) { pp_character (buffer, '('); dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); pp_character (buffer, ')'); } else dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); pp_space (buffer); pp_string (buffer, op_symbol_code (<API key> (gs))); pp_space (buffer); if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code)) { pp_character (buffer, '('); dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); pp_character (buffer, ')'); } else dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); } } /* Helper for dump_gimple_assign. Print the ternary RHS of the assignment GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */ static void dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags) { const char *p; enum tree_code code = <API key> (gs); switch (code) { case <API key>: case <API key>: for (p = tree_code_name [(int) code]; *p; p++) pp_character (buffer, TOUPPER (*p)); pp_string (buffer, " <"); dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); pp_string (buffer, ", "); dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); pp_string (buffer, ", "); dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); pp_character (buffer, '>'); break; case FMA_EXPR: dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); pp_string (buffer, " * "); dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); pp_string (buffer, " + "); dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); break; case DOT_PROD_EXPR: pp_string (buffer, "DOT_PROD_EXPR <"); dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); pp_string (buffer, ", "); dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); pp_string (buffer, ", "); dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); pp_string (buffer, ">"); break; case VEC_PERM_EXPR: pp_string (buffer, "VEC_PERM_EXPR <"); dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); pp_string (buffer, ", "); dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); pp_string (buffer, ", "); dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); pp_string (buffer, ">"); break; case REALIGN_LOAD_EXPR: pp_string (buffer, "REALIGN_LOAD <"); dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); pp_string (buffer, ", "); dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); pp_string (buffer, ", "); dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); pp_string (buffer, ">"); break; case COND_EXPR: dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); pp_string (buffer, " ? "); dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); pp_string (buffer, " : "); dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); break; case VEC_COND_EXPR: pp_string (buffer, "VEC_COND_EXPR <"); dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); pp_string (buffer, ", "); dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); pp_string (buffer, ", "); dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); pp_string (buffer, ">"); break; default: gcc_unreachable (); } } /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */ static void dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) { tree last; if (gimple_num_ops (gs) == 2) last = NULL_TREE; else if (gimple_num_ops (gs) == 3) last = gimple_assign_rhs2 (gs); else gcc_unreachable (); dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T>", gs, tree_code_name[<API key> (gs)], gimple_assign_lhs (gs), gimple_assign_rhs1 (gs), last); } else { if (!(flags & TDF_RHS_ONLY)) { dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false); pp_space (buffer); pp_character (buffer, '='); if (<API key> (gs)) pp_string (buffer, "{nt}"); if (<API key> (gs)) pp_string (buffer, "{v}"); pp_space (buffer); } if (gimple_num_ops (gs) == 2) dump_unary_rhs (buffer, gs, spc, flags); else if (gimple_num_ops (gs) == 3) dump_binary_rhs (buffer, gs, spc, flags); else if (gimple_num_ops (gs) == 4) dump_ternary_rhs (buffer, gs, spc, flags); else gcc_unreachable (); if (!(flags & TDF_RHS_ONLY)) pp_semicolon(buffer); } } /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */ static void dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags) { tree t; t = <API key> (gs); if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t); else { pp_string (buffer, "return"); if (t) { pp_space (buffer); dump_generic_node (buffer, t, spc, flags, false); } pp_semicolon (buffer); } } /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in dump_gimple_call. */ static void <API key> (pretty_printer *buffer, gimple gs, int flags) { size_t i; for (i = 0; i < <API key> (gs); i++) { dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false); if (i < <API key> (gs) - 1) pp_string (buffer, ", "); } if (<API key> (gs)) { if (<API key> (gs) > 0) { pp_character (buffer, ','); pp_space (buffer); } pp_string (buffer, "<API key> ()"); } } /* Dump the points-to solution *PT to BUFFER. */ static void <API key> (pretty_printer *buffer, struct pt_solution *pt) { if (pt->anything) { pp_string (buffer, "anything "); return; } if (pt->nonlocal) pp_string (buffer, "nonlocal "); if (pt->escaped) pp_string (buffer, "escaped "); if (pt->ipa_escaped) pp_string (buffer, "unit-escaped "); if (pt->null) pp_string (buffer, "null "); if (pt->vars && !bitmap_empty_p (pt->vars)) { bitmap_iterator bi; unsigned i; pp_string (buffer, "{ "); <API key> (pt->vars, 0, i, bi) { tree var = <API key> (cfun, i); if (var) { dump_generic_node (buffer, var, 0, dump_flags, false); if (DECL_PT_UID (var) != DECL_UID (var)) { pp_string (buffer, "ptD."); pp_decimal_int (buffer, DECL_PT_UID (var)); } } else { pp_string (buffer, "D."); pp_decimal_int (buffer, i); } pp_character (buffer, ' '); } pp_character (buffer, '}'); if (pt-><API key>) pp_string (buffer, " (glob)"); } } /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */ static void dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags) { tree lhs = gimple_call_lhs (gs); tree fn = gimple_call_fn (gs); if (flags & TDF_ALIAS) { struct pt_solution *pt; pt = gimple_call_use_set (gs); if (!pt_solution_empty_p (pt)) { pp_string (buffer, "# USE = "); <API key> (buffer, pt); newline_and_indent (buffer, spc); } pt = <API key> (gs); if (!pt_solution_empty_p (pt)) { pp_string (buffer, "# CLB = "); <API key> (buffer, pt); newline_and_indent (buffer, spc); } } if (flags & TDF_RAW) { if (<API key> (gs)) dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs, internal_fn_name (<API key> (gs)), lhs); else dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs); if (<API key> (gs) > 0) { pp_string (buffer, ", "); <API key> (buffer, gs, flags); } pp_character (buffer, '>'); } else { if (lhs && !(flags & TDF_RHS_ONLY)) { dump_generic_node (buffer, lhs, spc, flags, false); pp_string (buffer, " ="); if (<API key> (gs)) pp_string (buffer, "{v}"); pp_space (buffer); } if (<API key> (gs)) pp_string (buffer, internal_fn_name (<API key> (gs))); else print_call_name (buffer, fn, flags); pp_string (buffer, " ("); <API key> (buffer, gs, flags); pp_character (buffer, ')'); if (!(flags & TDF_RHS_ONLY)) pp_semicolon (buffer); } if (gimple_call_chain (gs)) { pp_string (buffer, " [static-chain: "); dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false); pp_character (buffer, ']'); } if (<API key> (gs)) pp_string (buffer, " [return slot optimization]"); if (gimple_call_tail_p (gs)) pp_string (buffer, " [tail call]"); if (fn == NULL) return; /* Dump the arguments of <API key> sanely. */ if (TREE_CODE (fn) == ADDR_EXPR) fn = TREE_OPERAND (fn, 0); if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn)) pp_string (buffer, " [tm-clone]"); if (TREE_CODE (fn) == FUNCTION_DECL && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START && <API key> (gs) > 0) { tree t = gimple_call_arg (gs, 0); unsigned HOST_WIDE_INT props; gcc_assert (TREE_CODE (t) == INTEGER_CST); pp_string (buffer, " [ "); /* Get the transaction code properties. */ props = TREE_INT_CST_LOW (t); if (props & PR_INSTRUMENTEDCODE) pp_string (buffer, "instrumentedCode "); if (props & <API key>) pp_string (buffer, "uninstrumentedCode "); if (props & PR_HASNOXMMUPDATE) pp_string (buffer, "hasNoXMMUpdate "); if (props & PR_HASNOABORT) pp_string (buffer, "hasNoAbort "); if (props & PR_HASNOIRREVOCABLE) pp_string (buffer, "hasNoIrrevocable "); if (props & <API key>) pp_string (buffer, "doesGoIrrevocable "); if (props & PR_HASNOSIMPLEREADS) pp_string (buffer, "hasNoSimpleReads "); if (props & <API key>) pp_string (buffer, "awBarriersOmitted "); if (props & <API key>) pp_string (buffer, "RaRBarriersOmitted "); if (props & PR_UNDOLOGCODE) pp_string (buffer, "undoLogCode "); if (props & <API key>) pp_string (buffer, "<API key> "); if (props & PR_EXCEPTIONBLOCK) pp_string (buffer, "exceptionBlock "); if (props & PR_HASELSE) pp_string (buffer, "hasElse "); if (props & PR_READONLY) pp_string (buffer, "readOnly "); pp_string (buffer, "]"); } } /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */ static void dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags) { unsigned int i; GIMPLE_CHECK (gs, GIMPLE_SWITCH); if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs, gimple_switch_index (gs)); else { pp_string (buffer, "switch ("); dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true); pp_string (buffer, ") <"); } for (i = 0; i < <API key> (gs); i++) { tree case_label = gimple_switch_label (gs, i); if (case_label == NULL_TREE) continue; dump_generic_node (buffer, case_label, spc, flags, false); pp_character (buffer, ' '); dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false); if (i < <API key> (gs) - 1) pp_string (buffer, ", "); } pp_character (buffer, '>'); } /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */ static void dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs, tree_code_name [gimple_cond_code (gs)], gimple_cond_lhs (gs), gimple_cond_rhs (gs), <API key> (gs), <API key> (gs)); else { if (!(flags & TDF_RHS_ONLY)) pp_string (buffer, "if ("); dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false); pp_space (buffer); pp_string (buffer, op_symbol_code (gimple_cond_code (gs))); pp_space (buffer); dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false); if (!(flags & TDF_RHS_ONLY)) { pp_character (buffer, ')'); if (<API key> (gs)) { pp_string (buffer, " goto "); dump_generic_node (buffer, <API key> (gs), spc, flags, false); pp_semicolon (buffer); } if (<API key> (gs)) { pp_string (buffer, " else goto "); dump_generic_node (buffer, <API key> (gs), spc, flags, false); pp_semicolon (buffer); } } } } /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h). */ static void dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags) { tree label = gimple_label_label (gs); if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label); else { dump_generic_node (buffer, label, spc, flags, false); pp_character (buffer, ':'); } if (DECL_NONLOCAL (label)) pp_string (buffer, " [non-local]"); if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label)) pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label)); } /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h). */ static void dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags) { tree label = gimple_goto_dest (gs); if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label); else dump_gimple_fmt (buffer, spc, flags, "goto %T;", label); } /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h). */ static void dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G <", gs); else pp_character (buffer, '{'); if (!(flags & TDF_SLIM)) { tree var; for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var)) { newline_and_indent (buffer, 2); print_declaration (buffer, var, spc, flags); } if (gimple_bind_vars (gs)) pp_newline (buffer); } pp_newline (buffer); dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags); newline_and_indent (buffer, spc); if (flags & TDF_RAW) pp_character (buffer, '>'); else pp_character (buffer, '}'); } /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h). */ static void dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) { const char *type; if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH) type = "GIMPLE_TRY_CATCH"; else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY) type = "GIMPLE_TRY_FINALLY"; else type = "UNKNOWN GIMPLE_TRY"; dump_gimple_fmt (buffer, spc, flags, "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type, gimple_try_eval (gs), gimple_try_cleanup (gs)); } else { pp_string (buffer, "try"); newline_and_indent (buffer, spc + 2); pp_character (buffer, '{'); pp_newline (buffer); dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags); newline_and_indent (buffer, spc + 2); pp_character (buffer, '}'); if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH) { newline_and_indent (buffer, spc); pp_string (buffer, "catch"); newline_and_indent (buffer, spc + 2); pp_character (buffer, '{'); } else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY) { newline_and_indent (buffer, spc); pp_string (buffer, "finally"); newline_and_indent (buffer, spc + 2); pp_character (buffer, '{'); } else pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {"); pp_newline (buffer); dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags); newline_and_indent (buffer, spc + 2); pp_character (buffer, '}'); } } /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h). */ static void dump_gimple_catch (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs, gimple_catch_types (gs), <API key> (gs)); else dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}", gimple_catch_types (gs), <API key> (gs)); } /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h). */ static void <API key> (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs, <API key> (gs), <API key> (gs)); else dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}", <API key> (gs), <API key> (gs)); } /* Dump a <API key> tuple. */ static void <API key> (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, <API key> (gs)); else dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>", <API key> (gs)); } /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h). */ static void dump_gimple_eh_else (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs, <API key> (gs), <API key> (gs)); else dump_gimple_fmt (buffer, spc, flags, "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}", <API key> (gs), <API key> (gs)); } /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h). */ static void dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs, gimple_resx_region (gs)); else dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs)); } /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */ static void <API key> (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs, <API key> (gs)); else dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d", <API key> (gs)); } /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h). */ static void dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags) { switch (gs->gsbase.subcode) { case GIMPLE_DEBUG_BIND: if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs, <API key> (gs), <API key> (gs)); else dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T", <API key> (gs), <API key> (gs)); break; case <API key>: if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs, <API key> (gs), <API key> (gs)); else dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T", <API key> (gs), <API key> (gs)); break; default: gcc_unreachable (); } } /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */ static void dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags) { size_t i; if (flags & TDF_RAW) { dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, gimple_omp_body (gs)); dump_omp_clauses (buffer, <API key> (gs), spc, flags); dump_gimple_fmt (buffer, spc, flags, " >,"); for (i = 0; i < <API key> (gs); i++) dump_gimple_fmt (buffer, spc, flags, "%+%T, %T, %T, %s, %T,%n", <API key> (gs, i), <API key> (gs, i), <API key> (gs, i), tree_code_name[gimple_omp_for_cond (gs, i)], gimple_omp_for_incr (gs, i)); dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->", <API key> (gs)); } else { pp_string (buffer, "#pragma omp for"); dump_omp_clauses (buffer, <API key> (gs), spc, flags); for (i = 0; i < <API key> (gs); i++) { if (i) spc += 2; newline_and_indent (buffer, spc); pp_string (buffer, "for ("); dump_generic_node (buffer, <API key> (gs, i), spc, flags, false); pp_string (buffer, " = "); dump_generic_node (buffer, <API key> (gs, i), spc, flags, false); pp_string (buffer, "; "); dump_generic_node (buffer, <API key> (gs, i), spc, flags, false); pp_space (buffer); switch (gimple_omp_for_cond (gs, i)) { case LT_EXPR: pp_character (buffer, '<'); break; case GT_EXPR: pp_character (buffer, '>'); break; case LE_EXPR: pp_string (buffer, "<="); break; case GE_EXPR: pp_string (buffer, ">="); break; default: gcc_unreachable (); } pp_space (buffer); dump_generic_node (buffer, <API key> (gs, i), spc, flags, false); pp_string (buffer, "; "); dump_generic_node (buffer, <API key> (gs, i), spc, flags, false); pp_string (buffer, " = "); dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc, flags, false); pp_character (buffer, ')'); } if (!gimple_seq_empty_p (gimple_omp_body (gs))) { newline_and_indent (buffer, spc + 2); pp_character (buffer, '{'); pp_newline (buffer); dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); newline_and_indent (buffer, spc + 2); pp_character (buffer, '}'); } } } /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */ static void <API key> (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) { dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs, <API key> (gs), <API key> (gs)); } else { pp_string (buffer, "#pragma omp continue ("); dump_generic_node (buffer, <API key> (gs), spc, flags, false); pp_character (buffer, ','); pp_space (buffer); dump_generic_node (buffer, <API key> (gs), spc, flags, false); pp_character (buffer, ')'); } } /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */ static void <API key> (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) { dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, gimple_omp_body (gs)); dump_omp_clauses (buffer, <API key> (gs), spc, flags); dump_gimple_fmt (buffer, spc, flags, " >"); } else { pp_string (buffer, "#pragma omp single"); dump_omp_clauses (buffer, <API key> (gs), spc, flags); if (!gimple_seq_empty_p (gimple_omp_body (gs))) { newline_and_indent (buffer, spc + 2); pp_character (buffer, '{'); pp_newline (buffer); dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); newline_and_indent (buffer, spc + 2); pp_character (buffer, '}'); } } } /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */ static void <API key> (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) { dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, gimple_omp_body (gs)); dump_omp_clauses (buffer, <API key> (gs), spc, flags); dump_gimple_fmt (buffer, spc, flags, " >"); } else { pp_string (buffer, "#pragma omp sections"); if (<API key> (gs)) { pp_string (buffer, " <"); dump_generic_node (buffer, <API key> (gs), spc, flags, false); pp_character (buffer, '>'); } dump_omp_clauses (buffer, <API key> (gs), spc, flags); if (!gimple_seq_empty_p (gimple_omp_body (gs))) { newline_and_indent (buffer, spc + 2); pp_character (buffer, '{'); pp_newline (buffer); dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); newline_and_indent (buffer, spc + 2); pp_character (buffer, '}'); } } } /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the pretty_printer BUFFER. */ static void <API key> (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs, gimple_omp_body (gs)); else { switch (gimple_code (gs)) { case GIMPLE_OMP_MASTER: pp_string (buffer, "#pragma omp master"); break; case GIMPLE_OMP_ORDERED: pp_string (buffer, "#pragma omp ordered"); break; case GIMPLE_OMP_SECTION: pp_string (buffer, "#pragma omp section"); break; default: gcc_unreachable (); } if (!gimple_seq_empty_p (gimple_omp_body (gs))) { newline_and_indent (buffer, spc + 2); pp_character (buffer, '{'); pp_newline (buffer); dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); newline_and_indent (buffer, spc + 2); pp_character (buffer, '}'); } } } /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */ static void <API key> (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs, gimple_omp_body (gs)); else { pp_string (buffer, "#pragma omp critical"); if (<API key> (gs)) { pp_string (buffer, " ("); dump_generic_node (buffer, <API key> (gs), spc, flags, false); pp_character (buffer, ')'); } if (!gimple_seq_empty_p (gimple_omp_body (gs))) { newline_and_indent (buffer, spc + 2); pp_character (buffer, '{'); pp_newline (buffer); dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); newline_and_indent (buffer, spc + 2); pp_character (buffer, '}'); } } } /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */ static void <API key> (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) { dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d>", gs, (int) <API key> (gs)); } else { pp_string (buffer, "#pragma omp return"); if (<API key> (gs)) pp_string (buffer, "(nowait)"); } } /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */ static void <API key> (pretty_printer *buffer, gimple gs, int spc, int flags) { unsigned subcode = <API key> (gs); if (flags & TDF_RAW) { dump_gimple_fmt (buffer, spc, flags, "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >", gs, subcode, <API key> (gs), <API key> (gs)); } else { if (subcode & GTMA_IS_OUTER) pp_string (buffer, "<API key> [[outer]]"); else if (subcode & GTMA_IS_RELAXED) pp_string (buffer, "<API key>"); else pp_string (buffer, "<API key>"); subcode &= ~<API key>; if (subcode || <API key> (gs)) { pp_string (buffer, " if (<API key> (gs)) { pp_string (buffer, " LABEL="); dump_generic_node (buffer, <API key> (gs), spc, flags, false); } if (subcode) { pp_string (buffer, " SUBCODE=[ "); if (subcode & GTMA_HAVE_ABORT) { pp_string (buffer, "GTMA_HAVE_ABORT "); subcode &= ~GTMA_HAVE_ABORT; } if (subcode & GTMA_HAVE_LOAD) { pp_string (buffer, "GTMA_HAVE_LOAD "); subcode &= ~GTMA_HAVE_LOAD; } if (subcode & GTMA_HAVE_STORE) { pp_string (buffer, "GTMA_HAVE_STORE "); subcode &= ~GTMA_HAVE_STORE; } if (subcode & <API key>) { pp_string (buffer, "<API key> "); subcode &= ~<API key>; } if (subcode & <API key>) { pp_string (buffer, "<API key> "); subcode &= ~<API key>; } if (subcode) pp_printf (buffer, "0x%x ", subcode); pp_string (buffer, "]"); } } if (!gimple_seq_empty_p (<API key> (gs))) { newline_and_indent (buffer, spc + 2); pp_character (buffer, '{'); pp_newline (buffer); dump_gimple_seq (buffer, <API key> (gs), spc + 4, flags); newline_and_indent (buffer, spc + 2); pp_character (buffer, '}'); } } } /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h). */ static void dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags) { unsigned int i, n, f, fields; if (flags & TDF_RAW) { dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs, gimple_asm_string (gs)); n = gimple_asm_noutputs (gs); if (n) { newline_and_indent (buffer, spc + 2); pp_string (buffer, "OUTPUT: "); for (i = 0; i < n; i++) { dump_generic_node (buffer, <API key> (gs, i), spc, flags, false); if (i < n - 1) pp_string (buffer, ", "); } } n = gimple_asm_ninputs (gs); if (n) { newline_and_indent (buffer, spc + 2); pp_string (buffer, "INPUT: "); for (i = 0; i < n; i++) { dump_generic_node (buffer, gimple_asm_input_op (gs, i), spc, flags, false); if (i < n - 1) pp_string (buffer, ", "); } } n = <API key> (gs); if (n) { newline_and_indent (buffer, spc + 2); pp_string (buffer, "CLOBBER: "); for (i = 0; i < n; i++) { dump_generic_node (buffer, <API key> (gs, i), spc, flags, false); if (i < n - 1) pp_string (buffer, ", "); } } n = gimple_asm_nlabels (gs); if (n) { newline_and_indent (buffer, spc + 2); pp_string (buffer, "LABEL: "); for (i = 0; i < n; i++) { dump_generic_node (buffer, gimple_asm_label_op (gs, i), spc, flags, false); if (i < n - 1) pp_string (buffer, ", "); } } newline_and_indent (buffer, spc); pp_character (buffer, '>'); } else { pp_string (buffer, "__asm__"); if (<API key> (gs)) pp_string (buffer, " __volatile__"); if (gimple_asm_nlabels (gs)) pp_string (buffer, " goto"); pp_string (buffer, "(\""); pp_string (buffer, gimple_asm_string (gs)); pp_string (buffer, "\""); if (gimple_asm_nlabels (gs)) fields = 4; else if (<API key> (gs)) fields = 3; else if (gimple_asm_ninputs (gs)) fields = 2; else if (gimple_asm_noutputs (gs)) fields = 1; else fields = 0; for (f = 0; f < fields; ++f) { pp_string (buffer, " : "); switch (f) { case 0: n = gimple_asm_noutputs (gs); for (i = 0; i < n; i++) { dump_generic_node (buffer, <API key> (gs, i), spc, flags, false); if (i < n - 1) pp_string (buffer, ", "); } break; case 1: n = gimple_asm_ninputs (gs); for (i = 0; i < n; i++) { dump_generic_node (buffer, gimple_asm_input_op (gs, i), spc, flags, false); if (i < n - 1) pp_string (buffer, ", "); } break; case 2: n = <API key> (gs); for (i = 0; i < n; i++) { dump_generic_node (buffer, <API key> (gs, i), spc, flags, false); if (i < n - 1) pp_string (buffer, ", "); } break; case 3: n = gimple_asm_nlabels (gs); for (i = 0; i < n; i++) { dump_generic_node (buffer, gimple_asm_label_op (gs, i), spc, flags, false); if (i < n - 1) pp_string (buffer, ", "); } break; default: gcc_unreachable (); } } pp_string (buffer, ");"); } } /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */ static void dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, int flags) { size_t i; tree lhs = gimple_phi_result (phi); if (flags & TDF_ALIAS && POINTER_TYPE_P (TREE_TYPE (lhs)) && SSA_NAME_PTR_INFO (lhs)) { struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs); pp_string (buffer, "PT = "); <API key> (buffer, &pi->pt); newline_and_indent (buffer, spc); if (pi->align != 1) { pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", pi->align, pi->misalign); newline_and_indent (buffer, spc); } pp_string (buffer, " } if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi, gimple_phi_result (phi)); else { dump_generic_node (buffer, lhs, spc, flags, false); pp_string (buffer, " = PHI <"); } for (i = 0; i < gimple_phi_num_args (phi); i++) { if ((flags & TDF_LINENO) && <API key> (phi, i)) { expanded_location xloc; xloc = expand_location (<API key> (phi, i)); pp_character (buffer, '['); if (xloc.file) { pp_string (buffer, xloc.file); pp_string (buffer, " : "); } pp_decimal_int (buffer, xloc.line); pp_string (buffer, ":"); pp_decimal_int (buffer, xloc.column); pp_string (buffer, "] "); } dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags, false); pp_character (buffer, '('); pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index); pp_character (buffer, ')'); if (i < gimple_phi_num_args (phi) - 1) pp_string (buffer, ", "); } pp_character (buffer, '>'); } /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h). */ static void <API key> (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) { dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, gimple_omp_body (gs)); dump_omp_clauses (buffer, <API key> (gs), spc, flags); dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>", <API key> (gs), <API key> (gs)); } else { gimple_seq body; pp_string (buffer, "#pragma omp parallel"); dump_omp_clauses (buffer, <API key> (gs), spc, flags); if (<API key> (gs)) { pp_string (buffer, " [child fn: "); dump_generic_node (buffer, <API key> (gs), spc, flags, false); pp_string (buffer, " ("); if (<API key> (gs)) dump_generic_node (buffer, <API key> (gs), spc, flags, false); else pp_string (buffer, "???"); pp_string (buffer, ")]"); } body = gimple_omp_body (gs); if (body && gimple_code (<API key> (body)) != GIMPLE_BIND) { newline_and_indent (buffer, spc + 2); pp_character (buffer, '{'); pp_newline (buffer); dump_gimple_seq (buffer, body, spc + 4, flags); newline_and_indent (buffer, spc + 2); pp_character (buffer, '}'); } else if (body) { pp_newline (buffer); dump_gimple_seq (buffer, body, spc + 2, flags); } } } /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h). */ static void <API key> (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) { dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, gimple_omp_body (gs)); dump_omp_clauses (buffer, <API key> (gs), spc, flags); dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>", <API key> (gs), <API key> (gs), <API key> (gs), <API key> (gs), <API key> (gs)); } else { gimple_seq body; pp_string (buffer, "#pragma omp task"); dump_omp_clauses (buffer, <API key> (gs), spc, flags); if (<API key> (gs)) { pp_string (buffer, " [child fn: "); dump_generic_node (buffer, <API key> (gs), spc, flags, false); pp_string (buffer, " ("); if (<API key> (gs)) dump_generic_node (buffer, <API key> (gs), spc, flags, false); else pp_string (buffer, "???"); pp_string (buffer, ")]"); } body = gimple_omp_body (gs); if (body && gimple_code (<API key> (body)) != GIMPLE_BIND) { newline_and_indent (buffer, spc + 2); pp_character (buffer, '{'); pp_newline (buffer); dump_gimple_seq (buffer, body, spc + 4, flags); newline_and_indent (buffer, spc + 2); pp_character (buffer, '}'); } else if (body) { pp_newline (buffer); dump_gimple_seq (buffer, body, spc + 2, flags); } } } /* Dump a <API key> tuple on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h). */ static void <API key> (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) { dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs, <API key> (gs), <API key> (gs)); } else { pp_string (buffer, "#pragma omp atomic_load"); if (<API key> (gs)) pp_string (buffer, " [needed]"); newline_and_indent (buffer, spc + 2); dump_generic_node (buffer, <API key> (gs), spc, flags, false); pp_space (buffer); pp_character (buffer, '='); pp_space (buffer); pp_character (buffer, '*'); dump_generic_node (buffer, <API key> (gs), spc, flags, false); } } /* Dump a <API key> tuple on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h). */ static void <API key> (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) { dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, <API key> (gs)); } else { pp_string (buffer, "#pragma omp atomic_store "); if (<API key> (gs)) pp_string (buffer, "[needed] "); pp_character (buffer, '('); dump_generic_node (buffer, <API key> (gs), spc, flags, false); pp_character (buffer, ')'); } } /* Dump all the memory operands for statement GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */ static void dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags) { tree vdef = gimple_vdef (gs); tree vuse = gimple_vuse (gs); if (!ssa_operands_active () || !<API key> (gs)) return; if (vdef != NULL_TREE) { pp_string (buffer, " dump_generic_node (buffer, vdef, spc + 2, flags, false); pp_string (buffer, " = VDEF <"); dump_generic_node (buffer, vuse, spc + 2, flags, false); pp_character (buffer, '>'); newline_and_indent (buffer, spc); } else if (vuse != NULL_TREE) { pp_string (buffer, "# VUSE <"); dump_generic_node (buffer, vuse, spc + 2, flags, false); pp_character (buffer, '>'); newline_and_indent (buffer, spc); } } /* Dump the gimple statement GS on the pretty printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h). */ void dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags) { if (!gs) return; if (flags & TDF_STMTADDR) pp_printf (buffer, "<&%p> ", (void *) gs); if ((flags & TDF_LINENO) && gimple_has_location (gs)) { expanded_location xloc = expand_location (gimple_location (gs)); pp_character (buffer, '['); if (xloc.file) { pp_string (buffer, xloc.file); pp_string (buffer, " : "); } pp_decimal_int (buffer, xloc.line); pp_string (buffer, ":"); pp_decimal_int (buffer, xloc.column); pp_string (buffer, "] "); } if (flags & TDF_EH) { int lp_nr = lookup_stmt_eh_lp (gs); if (lp_nr > 0) pp_printf (buffer, "[LP %d] ", lp_nr); else if (lp_nr < 0) pp_printf (buffer, "[MNT %d] ", -lp_nr); } if ((flags & (TDF_VOPS|TDF_MEMSYMS)) && gimple_has_mem_ops (gs)) dump_gimple_mem_ops (buffer, gs, spc, flags); if ((flags & TDF_ALIAS) && gimple_has_lhs (gs)) { tree lhs = gimple_get_lhs (gs); if (TREE_CODE (lhs) == SSA_NAME && POINTER_TYPE_P (TREE_TYPE (lhs)) && SSA_NAME_PTR_INFO (lhs)) { struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs); pp_string (buffer, " <API key> (buffer, &pi->pt); newline_and_indent (buffer, spc); if (pi->align != 1) { pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", pi->align, pi->misalign); newline_and_indent (buffer, spc); } } } switch (gimple_code (gs)) { case GIMPLE_ASM: dump_gimple_asm (buffer, gs, spc, flags); break; case GIMPLE_ASSIGN: dump_gimple_assign (buffer, gs, spc, flags); break; case GIMPLE_BIND: dump_gimple_bind (buffer, gs, spc, flags); break; case GIMPLE_CALL: dump_gimple_call (buffer, gs, spc, flags); break; case GIMPLE_COND: dump_gimple_cond (buffer, gs, spc, flags); break; case GIMPLE_LABEL: dump_gimple_label (buffer, gs, spc, flags); break; case GIMPLE_GOTO: dump_gimple_goto (buffer, gs, spc, flags); break; case GIMPLE_NOP: pp_string (buffer, "GIMPLE_NOP"); break; case GIMPLE_RETURN: dump_gimple_return (buffer, gs, spc, flags); break; case GIMPLE_SWITCH: dump_gimple_switch (buffer, gs, spc, flags); break; case GIMPLE_TRY: dump_gimple_try (buffer, gs, spc, flags); break; case GIMPLE_PHI: dump_gimple_phi (buffer, gs, spc, flags); break; case GIMPLE_OMP_PARALLEL: <API key> (buffer, gs, spc, flags); break; case GIMPLE_OMP_TASK: <API key> (buffer, gs, spc, flags); break; case <API key>: <API key> (buffer, gs, spc, flags); break; case <API key>: <API key> (buffer, gs, spc, flags); break; case GIMPLE_OMP_FOR: dump_gimple_omp_for (buffer, gs, spc, flags); break; case GIMPLE_OMP_CONTINUE: <API key> (buffer, gs, spc, flags); break; case GIMPLE_OMP_SINGLE: <API key> (buffer, gs, spc, flags); break; case GIMPLE_OMP_RETURN: <API key> (buffer, gs, spc, flags); break; case GIMPLE_OMP_SECTIONS: <API key> (buffer, gs, spc, flags); break; case <API key>: pp_string (buffer, "<API key>"); break; case GIMPLE_OMP_MASTER: case GIMPLE_OMP_ORDERED: case GIMPLE_OMP_SECTION: <API key> (buffer, gs, spc, flags); break; case GIMPLE_OMP_CRITICAL: <API key> (buffer, gs, spc, flags); break; case GIMPLE_CATCH: dump_gimple_catch (buffer, gs, spc, flags); break; case GIMPLE_EH_FILTER: <API key> (buffer, gs, spc, flags); break; case <API key>: <API key> (buffer, gs, spc, flags); break; case GIMPLE_EH_ELSE: dump_gimple_eh_else (buffer, gs, spc, flags); break; case GIMPLE_RESX: dump_gimple_resx (buffer, gs, spc, flags); break; case GIMPLE_EH_DISPATCH: <API key> (buffer, gs, spc, flags); break; case GIMPLE_DEBUG: dump_gimple_debug (buffer, gs, spc, flags); break; case GIMPLE_PREDICT: pp_string (buffer, "// predicted "); if (<API key> (gs)) pp_string (buffer, "likely by "); else pp_string (buffer, "unlikely by "); pp_string (buffer, predictor_name (<API key> (gs))); pp_string (buffer, " predictor."); break; case GIMPLE_TRANSACTION: <API key> (buffer, gs, spc, flags); break; default: GIMPLE_NIY; } /* If we're building a diagnostic, the formatted text will be written into BUFFER's stream by the caller; otherwise, write it now. */ if (!(flags & TDF_DIAGNOSTIC)) <API key> (buffer); } /* Dumps header of basic block BB to buffer BUFFER indented by INDENT spaces and details described by flags. */ static void dump_bb_header (pretty_printer *buffer, basic_block bb, int indent, int flags) { edge e; gimple stmt; edge_iterator ei; if (flags & TDF_BLOCKS) { INDENT (indent); pp_string (buffer, "# BLOCK "); pp_decimal_int (buffer, bb->index); if (bb->frequency) { pp_string (buffer, " freq:"); pp_decimal_int (buffer, bb->frequency); } if (bb->count) { pp_string (buffer, " count:"); pp_widest_integer (buffer, bb->count); } if (flags & TDF_LINENO) { <API key> gsi; for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) if (!is_gimple_debug (gsi_stmt (gsi)) && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION) { pp_string (buffer, ", starting at line "); pp_decimal_int (buffer, get_lineno (gsi_stmt (gsi))); break; } if (bb->discriminator) { pp_string (buffer, ", discriminator "); pp_decimal_int (buffer, bb->discriminator); } } newline_and_indent (buffer, indent); pp_string (buffer, "# PRED:"); <API key> (buffer); FOR_EACH_EDGE (e, ei, bb->preds) if (flags & TDF_SLIM) { pp_character (buffer, ' '); if (e->src == ENTRY_BLOCK_PTR) pp_string (buffer, "ENTRY"); else pp_decimal_int (buffer, e->src->index); } else dump_edge_info (buffer->buffer->stream, e, 0); pp_newline (buffer); } else { stmt = first_stmt (bb); if (!stmt || gimple_code (stmt) != GIMPLE_LABEL) { INDENT (indent - 2); pp_string (buffer, "<bb "); pp_decimal_int (buffer, bb->index); pp_string (buffer, ">:"); pp_newline (buffer); } } <API key> (buffer); if (cfun) check_bb_profile (bb, buffer->buffer->stream); } /* Dumps end of basic block BB to buffer BUFFER indented by INDENT spaces. */ static void dump_bb_end (pretty_printer *buffer, basic_block bb, int indent, int flags) { edge e; edge_iterator ei; INDENT (indent); pp_string (buffer, "# SUCC:"); <API key> (buffer); FOR_EACH_EDGE (e, ei, bb->succs) if (flags & TDF_SLIM) { pp_character (buffer, ' '); if (e->dest == EXIT_BLOCK_PTR) pp_string (buffer, "EXIT"); else pp_decimal_int (buffer, e->dest->index); } else dump_edge_info (buffer->buffer->stream, e, 1); pp_newline (buffer); } /* Dump PHI nodes of basic block BB to BUFFER with details described by FLAGS and indented by INDENT spaces. */ static void dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags) { <API key> i; for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i)) { gimple phi = gsi_stmt (i); if (is_gimple_reg (gimple_phi_result (phi)) || (flags & TDF_VOPS)) { INDENT (indent); pp_string (buffer, " dump_gimple_phi (buffer, phi, indent, flags); pp_newline (buffer); } } } /* Dump jump to basic block BB that is represented implicitly in the cfg to BUFFER. */ static void pp_cfg_jump (pretty_printer *buffer, basic_block bb) { gimple stmt; stmt = first_stmt (bb); pp_string (buffer, "goto <bb "); pp_decimal_int (buffer, bb->index); pp_character (buffer, '>'); if (stmt && gimple_code (stmt) == GIMPLE_LABEL) { pp_string (buffer, " ("); dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false); pp_character (buffer, ')'); pp_semicolon (buffer); } else pp_semicolon (buffer); } /* Dump edges represented implicitly in basic block BB to BUFFER, indented by INDENT spaces, with details given by FLAGS. */ static void dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent, int flags) { edge e; gimple stmt; stmt = last_stmt (bb); if (stmt && gimple_code (stmt) == GIMPLE_COND) { edge true_edge, false_edge; /* When we are emitting the code or changing CFG, it is possible that the edges are not yet created. When we are using debug_bb in such a situation, we do not want it to crash. */ if (EDGE_COUNT (bb->succs) != 2) return; <API key> (bb, &true_edge, &false_edge); INDENT (indent + 2); pp_cfg_jump (buffer, true_edge->dest); newline_and_indent (buffer, indent); pp_string (buffer, "else"); newline_and_indent (buffer, indent + 2); pp_cfg_jump (buffer, false_edge->dest); pp_newline (buffer); return; } /* If there is a fallthru edge, we may need to add an artificial goto to the dump. */ e = find_fallthru_edge (bb->succs); if (e && e->dest != bb->next_bb) { INDENT (indent); if ((flags & TDF_LINENO) && e->goto_locus != UNKNOWN_LOCATION ) { expanded_location goto_xloc; goto_xloc = expand_location (e->goto_locus); pp_character (buffer, '['); if (goto_xloc.file) { pp_string (buffer, goto_xloc.file); pp_string (buffer, " : "); } pp_decimal_int (buffer, goto_xloc.line); pp_string (buffer, " : "); pp_decimal_int (buffer, goto_xloc.column); pp_string (buffer, "] "); } pp_cfg_jump (buffer, e->dest); pp_newline (buffer); } } /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and indented by INDENT spaces. */ static void gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent, int flags) { <API key> gsi; gimple stmt; int label_indent = indent - 2; if (label_indent < 0) label_indent = 0; dump_bb_header (buffer, bb, indent, flags); dump_phi_nodes (buffer, bb, indent, flags); for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { int curr_indent; stmt = gsi_stmt (gsi); curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent; INDENT (curr_indent); dump_gimple_stmt (buffer, stmt, curr_indent, flags); pp_newline (buffer); <API key> (cfun, buffer->buffer->stream, stmt); } dump_implicit_edges (buffer, bb, indent, flags); if (flags & TDF_BLOCKS) dump_bb_end (buffer, bb, indent, flags); } /* Dumps basic block BB to FILE with details described by FLAGS and indented by INDENT spaces. */ void gimple_dump_bb (basic_block bb, FILE *file, int indent, int flags) { <API key> (file); gimple_dump_bb_buff (&buffer, bb, indent, flags); pp_flush (&buffer); }
%internal_labels = (); 1; # hack in case there are no entries
CFLAGS+=-D_FILE_OFFSET_BITS=64 #CXXFLAGS+=-Wall -D_FILE_OFFSET_BITS=64 -D USE_UTF16 CXXFLAGS+=-Wall -D_FILE_OFFSET_BITS=64 LDFLAGS+= LIB_NAMES=crc32 support guid gptpart mbrpart basicmbr mbr gpt bsd parttypes attributes diskio diskio-unix MBR_LIBS=support diskio diskio-unix basicmbr mbrpart LIB_OBJS=$(LIB_NAMES:=.o) MBR_LIB_OBJS=$(MBR_LIBS:=.o) LIB_HEADERS=$(LIB_NAMES:=.h) DEPEND= makedepend $(CXXFLAGS) all: cgdisk gdisk sgdisk fixparts gdisk: $(LIB_OBJS) gdisk.o gpttext.o $(CXX) $(LIB_OBJS) gdisk.o gpttext.o $(LDFLAGS) -luuid -o gdisk # $(CXX) $(LIB_OBJS) gdisk.o gpttext.o $(LDFLAGS) -licuio -licuuc -luuid -o gdisk cgdisk: $(LIB_OBJS) cgdisk.o gptcurses.o $(CXX) $(LIB_OBJS) cgdisk.o gptcurses.o $(LDFLAGS) -luuid -lncursesw -o cgdisk # $(CXX) $(LIB_OBJS) cgdisk.o gptcurses.o $(LDFLAGS) -licuio -licuuc -luuid -lncurses -o cgdisk sgdisk: $(LIB_OBJS) sgdisk.o gptcl.o $(CXX) $(LIB_OBJS) sgdisk.o gptcl.o $(LDFLAGS) -luuid -lpopt -o sgdisk # $(CXX) $(LIB_OBJS) sgdisk.o gptcl.o $(LDFLAGS) -licuio -licuuc -luuid -lpopt -o sgdisk fixparts: $(MBR_LIB_OBJS) fixparts.o $(CXX) $(MBR_LIB_OBJS) fixparts.o $(LDFLAGS) -o fixparts test: ./gdisk_test.sh lint: #no pre-reqs lint $(SRCS) clean: #no pre-reqs rm -f core *.o *~ gdisk sgdisk cgdisk fixparts # what are the source dependencies depend: $(SRCS) $(DEPEND) $(SRCS) $(OBJS): $(CRITICAL_CXX_FLAGS) # makedepend dependencies below -- type "makedepend *.cc" to regenerate.... # DO NOT DELETE
// jQuery Selector Cache !function(n,r){var $={};$$=function(u){var t=$[u];return t!==r?t:$[u]=n(u)},$$.clear=function(n){$[n]=r},$$.fresh=function(n){return $[n]=r,$$(n)}}(jQuery);
#ifndef __PVRMMAP_H__ #define __PVRMMAP_H__ PVRSRV_ERROR PVRPMapKMem(void * hModule, void **ppvLinAddr, void *pvLinAddrKM, void * *phMappingInfo, void * hMHandle); int PVRUnMapKMem(void * hModule, void * hMappingInfo, void * hMHandle); #endif
package hello.colgoogle; /*import com.google.common.collect.MapMaker; import com.google.common.base.Function; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.TimeUnit; public class MapMakeT { MapMaker mapMaker = new MapMaker(); ConcurrentMap<String, String> capthcaMap= mapMaker.expiration(15, TimeUnit.MINUTES).makeMap(); ConcurrentMap<String, Object> map1 = mapMaker.concurrencyLevel(8).makeMap(); ConcurrentMap<String, Object> map2 = mapMaker.softKeys().weakKeys().makeMap(); ConcurrentMap<String, Integer> map3 = mapMaker.makeComputingMap( new Function<String, Integer>() { public Integer apply(String key) { return 1; } }); }*/
package org.openmrs.module.accounting.web.controller.account; import org.openmrs.module.accounting.api.model.Account; import org.openmrs.module.accounting.api.model.FiscalPeriod; public class AccountCommand { private Account account; private Integer period; private FiscalPeriod fiscalPeriod; public AccountCommand(){ this.account = new Account(); } public Account getAccount() { return account; } public void setAccount(Account account) { this.account = account; } public Integer getPeriod() { return period; } public void setPeriod(Integer period) { this.period = period; } public FiscalPeriod getFiscalPeriod() { return fiscalPeriod; } public void setFiscalPeriod(FiscalPeriod fiscalPeriod) { this.fiscalPeriod = fiscalPeriod; } }
/** \addtogroup flatstore * @{ */ /** \file * The implementation of parser parsing flatstore:.. URIs. */ #include "flat_uri.h" #include "../../mem/mem.h" #include "../../ut.h" #include <stdlib.h> #include <string.h> static void flat_uri_free(db_uri_t* uri, struct flat_uri* payload) { if (payload == NULL) return; if (payload->path.s) free(payload->path.s); db_drv_free(&payload->drv); pkg_free(payload); } int flat_uri(db_uri_t* uri) { struct flat_uri* furi; if ((furi = (struct flat_uri*)pkg_malloc(sizeof(*furi))) == NULL) { ERR("flatstore: No memory left\n"); return -1; } memset(furi, '\0', sizeof(*furi)); if (db_drv_init(&furi->drv, flat_uri_free) < 0) goto error; if ((furi->path.s = get_abs_pathname(NULL, &uri->body)) == NULL) { ERR("flatstore: Error while obtaining absolute pathname for '%.*s'\n", STR_FMT(&uri->body)); goto error; } furi->path.len = strlen(furi->path.s); DB_SET_PAYLOAD(uri, furi); return 0; error: if (furi) { if (furi->path.s) pkg_free(furi->path.s); db_drv_free(&furi->drv); pkg_free(furi); } return -1; }
<?php $widget['widget_title'] = "New Products"; $widget['widget_has_settings'] = 1; $widget['widget_shrink_icon'] = 0; $widget['<API key>'] = 0; $widget['name'] = 'New Products'; $widget['desc'] = 'This widget displays the latest products available in the Pligg Pro Shop'; $widget['version'] = 0.1; $product_count = get_misc_data('product_count'); if ($product_count<=0) $product_count='3'; if ($_REQUEST['widget']=='pligg_products'){ if(isset($_REQUEST['products'])) $product_count = sanitize($_REQUEST['products'], 3); misc_data_update('product_count', $product_count); } if ($main_smarty){ $main_smarty->assign('product_count', $product_count); } ?>
#ifndef <API key> #define <API key> #define MAX_AURAS 64 // client support up to 255, but it will cause problems with group auras updating // 5.0.5 enum AURA_FLAGS { AFLAG_NONE = 0x00, AFLAG_CASTER = 0x01, AFLAG_POSITIVE = 0x02, AFLAG_DURATION = 0x04, <API key> = 0x08, AFLAG_NEGATIVE = 0x10, }; // these are modes, in which aura effect handler may be called enum <API key> { <API key> = 0x0, <API key> = 0x01, // handler applies/removes effect from unit <API key> = 0x02, // handler sends apply/remove packet to unit <API key> = 0x04, // handler updates effect on target after effect amount change <API key> = 0x08, // handler updates effect on target after aura is reapplied on target <API key> = 0x10, // handler updates effect on target when stat removal/apply is needed for calculations by core <API key> = 0x20, // handler updates effect on target when skill removal/apply is needed for calculations by core <API key> = (<API key> | <API key>), // any case handler need to send packet <API key> = (<API key> | <API key>), // any case handler applies effect depending on amount <API key> = (<API key> | <API key>), <API key> = (<API key> | <API key>), }; //m_schoolAbsorb enum DAMAGE_ABSORB_TYPE { ALL_DAMAGE_ABSORB = -2, ONLY_MAGIC_ABSORB = -1, }; enum AuraType { SPELL_AURA_NONE = 0, <API key> = 1, <API key> = 2, <API key> = 3, SPELL_AURA_DUMMY = 4, <API key> = 5, <API key> = 6, SPELL_AURA_MOD_FEAR = 7, <API key> = 8, <API key> = 9, <API key> = 10, <API key> = 11, SPELL_AURA_MOD_STUN = 12, <API key> = 13, <API key> = 14, <API key> = 15, <API key> = 16, <API key> = 17, <API key> = 18, <API key> = 19, <API key> = 20, // 20, 21 unofficial <API key> = 21, <API key> = 22, <API key> = 23, <API key> = 24, <API key> = 25, SPELL_AURA_MOD_ROOT = 26, <API key> = 27, <API key> = 28, SPELL_AURA_MOD_STAT = 29, <API key> = 30, <API key> = 31, <API key> = 32, <API key> = 33, <API key> = 34, <API key> = 35, <API key> = 36, <API key> = 37, <API key> = 38, <API key> = 39, <API key> = 40, <API key> = 41, <API key> = 42, <API key> = 43, <API key> = 44, <API key> = 45, SPELL_AURA_46 = 46, // Ignore all Gear test spells <API key> = 47, <API key> = 48, // Client periodic trigger spell by self (3 spells in 3.3.5a) <API key> = 49, <API key> = 50, <API key> = 51, <API key> = 52, <API key> = 53, <API key> = 54, <API key> = 55, <API key> = 56, <API key> = 57, <API key> = 58, <API key> = 59, <API key> = 60, <API key> = 61, <API key> = 62, SPELL_AURA_63 = 63, // old <API key> <API key> = 64, <API key> = 65, <API key> = 66, <API key> = 67, <API key> = 68, <API key> = 69, <API key> = 70, <API key> = 71, <API key> = 72, <API key> = 73, <API key> = 74, <API key> = 75, <API key> = 76, <API key> = 77, SPELL_AURA_MOUNTED = 78, <API key> = 79, <API key> = 80, <API key> = 81, <API key> = 82, <API key> = 83, <API key> = 84, <API key> = 85, <API key> = 86, <API key> = 87, <API key> = 88, <API key> = 89, SPELL_AURA_90 = 90, // old <API key> <API key> = 91, <API key> = 92, <API key> = 93, <API key> = 94, SPELL_AURA_GHOST = 95, <API key> = 96, <API key> = 97, <API key> = 98, <API key> = 99, <API key> = 100, <API key> = 101, <API key> = 102, <API key> = 103, <API key> = 104, <API key> = 105, SPELL_AURA_HOVER = 106, <API key> = 107, <API key> = 108, <API key> = 109, <API key> = 110, <API key> = 111, <API key> = 112, <API key> = 113, <API key> = 114, <API key> = 115, <API key> = 116, <API key> = 117, <API key> = 118, SPELL_AURA_119 = 119, // old <API key> <API key> = 120, SPELL_AURA_EMPATHY = 121, <API key> = 122, <API key> = 123, <API key> = 124, <API key> = 125, <API key> = 126, <API key> = 127, <API key> = 128, <API key> = 129, <API key> = 130, <API key> = 131, <API key> = 132, <API key> = 133, <API key> = 134, <API key> = 135, <API key> = 136, <API key> = 137, <API key> = 138, <API key> = 139, <API key> = 140, SPELL_AURA_141 = 141, // old <API key>, unused now <API key> = 142, <API key> = 143, <API key> = 144, <API key> = 145, <API key> = 146, <API key> = 147, <API key> = 148, <API key> = 149, // Reduce Pushback <API key> = 150, <API key> = 151, // Track Stealthed <API key> = 152, // Mod Detected Range SPELL_AURA_153 = 153, // old <API key>. unused 4.3.4 <API key> = 154, // Stealth Level Modifier <API key> = 155, // Mod Water Breathing <API key> = 156, // Mod Reputation Gain <API key> = 157, // Mod Pet Damage <API key> = 158, <API key> = 159, SPELL_AURA_160 = 160, // old <API key>. Unused 4.3.4 <API key> = 161, <API key> = 162, <API key> = 163, SPELL_AURA_164 = 164, <API key> = 165, <API key> = 166, <API key> = 167, <API key> = 168, SPELL_AURA_169 = 169, // old <API key>. unused 4.3.4 <API key> = 170, <API key> = 171, <API key> = 172, SPELL_AURA_173 = 173, // old <API key> <API key> = 174, // by defeult intelect, dependent from <API key> <API key> = 175, <API key> = 176, <API key> = 177, SPELL_AURA_178 = 178, // old <API key>, unused <API key> = 179, <API key> = 180, SPELL_AURA_181 = 181, // old <API key> - possible flat spell crit damage versus <API key> = 182, <API key> = 183, <API key> = 184, <API key> = 185, <API key> = 186, <API key> = 187, <API key> = 188, <API key> = 189, <API key> = 190, <API key> = 191, <API key> = 192, <API key> = 193, <API key> = 194, <API key> = 195, <API key> = 196, // only 24818 Noxious Breath <API key> = 197, SPELL_AURA_198 = 198, // old <API key> SPELL_AURA_199 = 199, // old <API key>. unused 4.3.4 <API key> = 200, SPELL_AURA_FLY = 201, <API key> = 202, <API key> = 203, <API key> = 204, <API key> = 205, <API key> = 206, <API key> = 207, <API key> = 208, <API key> = 209, <API key> = 210, <API key> = 211, SPELL_AURA_212 = 212, // old <API key>. unused 4.3.4 <API key> = 213, SPELL_AURA_214 = 214, <API key> = 215, <API key> = 216, <API key> = 217, <API key> = 218, <API key> = 219, <API key> = 220, <API key> = 221, SPELL_AURA_222 = 222, <API key> = 223, SPELL_AURA_224 = 224, <API key> = 225, <API key> = 226, <API key> = 227, <API key> = 228, <API key> = 229, SPELL_AURA_230 = 230, <API key> = 231, <API key> = 232, <API key> = 233, // client-side only <API key> = 234, <API key> = 235, <API key> = 236, <API key> = 237, <API key> = 238, <API key> = 239, <API key> = 240, <API key> = 241, <API key> = 242, <API key> = 243, <API key> = 244, <API key> = 245, <API key> = 246, <API key> = 247, <API key> = 248, <API key> = 249, <API key> = 250, <API key> = 251, <API key> = 252, <API key> = 253, <API key> = 254, <API key> = 255, <API key> = 256, <API key> = 257, SPELL_AURA_258 = 258, <API key> = 259, // <API key> <API key> = 260, SPELL_AURA_PHASE = 261, <API key> = 262, <API key> = 263, SPELL_AURA_264 = 264, SPELL_AURA_265 = 265, SPELL_AURA_266 = 266, <API key> = 267, SPELL_AURA_268 = 268, // old <API key>. unused 4.3.4 <API key> = 269, SPELL_AURA_270 = 270, // old <API key>, unused 4.3.4 <API key> = 271, <API key> = 272, SPELL_AURA_X_RAY = 273, SPELL_AURA_274 = 274, // old <API key>, unused 4.3.4 <API key> = 275, <API key> = 276, SPELL_AURA_277 = 277, // old <API key>. unused 4.3.4 <API key> = 278, <API key> = 279, <API key> = 280, // old <API key> unused 4.3.4 <API key> = 281, <API key> = 282, <API key> = 283, // Possibly only for some spell family class spells SPELL_AURA_LINKED = 284, <API key> = 285, <API key> = 286, <API key> = 287, <API key> = 288, SPELL_AURA_289 = 289, <API key> = 290, <API key> = 291, <API key> = 292, <API key> = 293, <API key> = 294, SPELL_AURA_295 = 295, <API key> = 296, <API key> = 297, <API key> = 298, SPELL_AURA_299 = 299, <API key> = 300, <API key> = 301, SPELL_AURA_302 = 302, <API key> = 303, <API key> = 304, <API key> = 305, SPELL_AURA_306 = 306, <API key> = 307, <API key> = 308, <API key> = 309, <API key> = 310, SPELL_AURA_311 = 311, <API key> = 312, SPELL_AURA_313 = 313, // Not used in 4.3.4 - related to mounts <API key> = 314, <API key> = 315, SPELL_AURA_316 = 316, // Not used in 4.3.4 old <API key> <API key> = 317, SPELL_AURA_MASTERY = 318, <API key> = 319, <API key> = 320, SPELL_AURA_321 = 321, <API key> = 322, // NYI SPELL_AURA_323 = 323, // Not used in 4.3.4 SPELL_AURA_324 = 324, // spell critical chance (probably by school mask) SPELL_AURA_325 = 325, // Not used in 4.3.4 SPELL_AURA_PHASE_2 = 326, // phase related SPELL_AURA_327 = 327, // Not used in 4.3.4 <API key> = 328, <API key> = 329, // NYI <API key> = 330, <API key> = 331, <API key> = 332, <API key> = 333, <API key> = 334, // NYI <API key> = 335, // NYI <API key> = 336, // NYI <API key> = 337, <API key> = 338, <API key> = 339, // NYI <API key> = 340, // Increases health gained when resurrected by a guild member by X <API key> = 341, // Modifies cooldown of all spells using affected category <API key> = 342, <API key> = 343, <API key> = 344, // NYI <API key> = 345, <API key> = 346, // NYI <API key> = 347, // NYI <API key> = 348, // NYI <API key> = 349, <API key> = 350, // NYI <API key> = 351, <API key> = 352, <API key> = 353, // Used by Camouflage <API key> = 354, // Restoration Shaman mastery - mod healing based on target's health (less = more healing) SPELL_AURA_355 = 355, <API key> = 356, // Arcane Mage mastery - mod damage based on current mana <API key> = 357, <API key> = 358, SPELL_AURA_359 = 359, <API key> = 360, // Procs the same spell that caused this proc (Dragonwrath, Tarecgosa's Rest) <API key> = 361, SPELL_AURA_362 = 362, // Not used in 4.3.4 <API key> = 363, // Used by 101601 Throw Totem - causes the client to initialize spell cast with specified spell SPELL_AURA_364 = 364, // Not used in 4.3.4 <API key> = 365, // Overrides client's View Distance setting to max("Fair", current_setting) and turns off terrain display <API key> = 366, // Sets spellpower equal to % of attack power, discarding all other bonuses (from gear and buffs) SPELL_AURA_367 = 367, SPELL_AURA_368 = 368, // Not used in 4.3.4 <API key> = 369, <API key> = 370, // Overrides client's View Distance setting to max("Fair", current_setting) SPELL_AURA_371 = 371, // 5.0.5 unk aura SPELL_AURA_372 = 372, // 5.0.5 unk aura <API key> = 373, // Not sure if increase only swim, but in Roll (Monk), blizz send only update swim speed packet <API key> = 374, // <API key> SPELL_AURA_375 = 375, // 5.0.5 unk aura SPELL_AURA_376 = 376, // 5.0.5 unk aura SPELL_AURA_377 = 377, // 5.0.5 unk aura SPELL_AURA_378 = 378, // 5.0.5 unk aura SPELL_AURA_379 = 379, // 5.0.5 unk aura SPELL_AURA_380 = 380, // 5.0.5 unk aura SPELL_AURA_381 = 381, // 5.0.5 unk aura SPELL_AURA_382 = 382, // 5.0.5 unk aura <API key> = 383, // <API key> implemented in Spell::CheckCast SPELL_AURA_384 = 384, // 5.0.5 unk aura <API key> = 385, // Give a chance to misfire attacks and hit self instead SPELL_AURA_386 = 386, // 5.0.5 unk aura SPELL_AURA_387 = 387, // 5.0.5 unk aura <API key> = 388, // <API key> <API key> = 389, // <API key> in SpellInfo::AttackerStateUpdate SPELL_AURA_390 = 390, // 5.0.5 unk aura SPELL_AURA_391 = 391, // 5.0.5 unk aura SPELL_AURA_392 = 392, // 5.0.5 unk aura <API key> = 393, // <API key> SPELL_AURA_394 = 394, // 5.0.5 unk aura SPELL_AURA_395 = 395, // 5.0.5 unk aura SPELL_AURA_396 = 396, // 5.0.5 unk aura SPELL_AURA_397 = 397, // 5.0.5 unk aura SPELL_AURA_398 = 398, // 5.0.5 unk aura SPELL_AURA_399 = 399, // 5.0.5 unk aura <API key> = 400, // <API key> SPELL_AURA_401 = 401, // 5.0.5 Cart Control Capture Point Unit (East / North / South) SPELL_AURA_402 = 402, // 5.0.5 unk aura <API key> = 403, <API key> = 404, // Sets attack power equal to % of spellpower, discarding all other bonuses (from gear and buffs) <API key> = 405, // <API key> SPELL_AURA_406 = 406, // 5.0.5 unk aura <API key> = 407, // <API key> SPELL_AURA_408 = 408, // 5.0.5 unk aura <API key> = 409, // <API key> SPELL_AURA_410 = 410, // 5.0.5 unk aura <API key> = 411, // <API key> <API key> = 412, // <API key> SPELL_AURA_413 = 413, // 5.0.5 unk aura SPELL_AURA_414 = 414, // 5.0.5 unk aura SPELL_AURA_415 = 415, // 5.0.5 unk aura <API key> = 416, // <API key> SPELL_AURA_417 = 417, // 5.0.5 unk aura SPELL_AURA_418 = 418, // 5.0.5 unk aura <API key> = 419, // <API key> <API key> = 420, // 5.4.0 +10% Battle Pet XP (134635)(NYI) <API key> = 421, // 5.4.0 unk aura (NYI) <API key> = 422, // 5.4.0 unk aura (NYI) wind Storm Iron Qon phase 2 SPELL_AURA_423 = 423, // 5.4.0 unk aura (NYI) "Balance: Spell Damage and Hit Chance increased.Mana cost of all damage spells reduced by 100 % ." SPELL_AURA_424 = 424, // 5.4.0 unk aura (NYI) Heart of the Wild talent related SPELL_AURA_425 = 425, // 5.4.0 unused SPELL_AURA_426 = 426, // 5.4.0 unk aura (NYI) Brawl queue SPELL_AURA_427 = 427, // 5.4.0 unk aura (NYI) Spell 91318 SPELL_AURA_428 = 428, // 5.4.0 unk aura (NYI) used for cart in silvershard mines ? <API key> = 429, // 5.4.0 unk aura (NYI) see 144364 SPELL_AURA_430 = 430, // 5.4.0 unk aura (NYI) SPELL_AURA_431 = 431, // 5.4.0 unk aura (NYI) Contested Territory 142869 SPELL_AURA_432 = 432, // 5.4.0 unk aura (NYI) SPELL_AURA_433 = 433, // 5.4.0 unused SPELL_AURA_434 = 434, // 5.4.0 unk aura (NYI) used by wowhead.com/spell=145175 value is wowhead.com/npc=72327 SPELL_AURA_435 = 435, // 5.4.0 Unused SPELL_AURA_436 = 436, // 5.4.0 Internal spell SPELL_AURA_437 = 437, // 5.4.0 Internal spell TOTAL_AURAS = 438 // 5.4.0 }; enum AuraObjectType { UNIT_AURA_TYPE, DYNOBJ_AURA_TYPE, }; #endif
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Mono.Cecil; using Mono.Cecil.Cil; using PKTracer.Framework.Tracer; using PKCodeWeaver.Framework.Weavers.Abstract; namespace PKCodeWeaver.Framework.Weavers.Concrete { internal class ItemTraceWeaver : MethodWeaver { public override void Weave(AssemblyDefinition assembly, MethodDefinition method) { method.Body.InitLocals = true; ILProcessor ilProcessor = method.Body.GetILProcessor(); var count = method.Body.Variables.Count; method.Body.Variables.Add(new VariableDefinition(WeaverUtil.ImportType<PKTracer.Framework.Tracer.ItemTracer>(assembly))); var lastRet = FixReturns(method); var firstInstruction = <API key>(method); var beforeReturn = Instruction.Create(OpCodes.Nop); ilProcessor.InsertBefore(lastRet, beforeReturn); Instruction i3 = InsertBeginTrace(assembly, method, count, firstInstruction); var weaver = new <API key>(count, i3); weaver.Parameters = this.Parameters; weaver.Weave(assembly, method); InsertEndTrace(assembly, method, count, beforeReturn, firstInstruction, lastRet); } private void InsertEndTrace( AssemblyDefinition assembly, MethodDefinition method, int count, Instruction beforeReturn, Instruction firstInstruction, Instruction lastRet) { ILProcessor ilProcessor = method.Body.GetILProcessor(); var instructions = new List<Instruction>(); instructions.Add(ilProcessor.Create(OpCodes.Ldloc, count)); instructions.Add(ilProcessor.Create(OpCodes.Callvirt, WeaverUtil.ImportMethod<ItemTracer>(assembly, "Dispose"))); instructions.Add(ilProcessor.Create(OpCodes.Nop)); instructions.Add(ilProcessor.Create(OpCodes.Endfinally)); instructions.ForEach(x => { ilProcessor.InsertBefore(lastRet, x); }); var handlerFinally = new ExceptionHandler(<API key>.Finally) { TryStart = firstInstruction, TryEnd = beforeReturn, HandlerStart = beforeReturn, HandlerEnd = lastRet }; method.Body.ExceptionHandlers.Add(handlerFinally); } private Instruction InsertBeginTrace( AssemblyDefinition assembly, MethodDefinition method, int count, Instruction firstInstruction) { ILProcessor ilProcessor = method.Body.GetILProcessor(); var instructions = new List<Instruction>(); /* //Begin: ItemTracer itemTracer = new ItemTracer("..Method.."); Instruction param1 = ilProcessor.Create(OpCodes.Ldstr, assembly.Name.Name); ilProcessor.InsertBefore(firstInstruction, param1); Instruction param2 = ilProcessor.Create(OpCodes.Ldstr, method.FullName); ilProcessor.InsertAfter(param1, param2); Instruction i2 = ilProcessor.Create(OpCodes.Newobj, method.Module.Import(typeof(LogTracer.ItemTracer).GetConstructors()[0])); ilProcessor.InsertAfter(param2, i2); Instruction i3 = ilProcessor.Create(OpCodes.Stloc, count); ilProcessor.InsertAfter(i2, i3); //End: ItemTracer itemTracer = new ItemTracer("..Method.."); */ instructions.Add(ilProcessor.Create(OpCodes.Ldstr, assembly.Name.Name)); instructions.Add(ilProcessor.Create(OpCodes.Ldstr, method.FullName)); instructions.Add(ilProcessor.Create(OpCodes.Newobj, method.Module.Import(typeof(PKTracer.Framework.Tracer.ItemTracer).GetConstructors()[0]))); instructions.Add(ilProcessor.Create(OpCodes.Stloc, count)); instructions.ForEach(x => { ilProcessor.InsertBefore(firstInstruction, x); }); return instructions.Last(); } } }
/* $Id: DrvStorageFilter.cpp $ */ /** @file * VBox storage filter driver sample. */ #define LOG_GROUP LOG_GROUP_MISC #include <VBox/vmm/pdmifs.h> #include <VBox/vmm/pdmdrv.h> #include <VBox/log.h> #include <iprt/uuid.h> /** * Storage Filter Driver Instance Data. */ typedef struct DRVSTORAGEFILTER { /** @name Interfaces exposed by this driver. * @{ */ PDMIMEDIA IMedia; PDMIMEDIAPORT IMediaPort; PDMIMEDIAASYNC IMediaAsync; PDMIMEDIAASYNCPORT IMediaAsyncPort; /** @name Interfaces exposed by the driver below us. * @{ */ PPDMIMEDIA pIMediaBelow; PPDMIMEDIAASYNC pIMediaAsyncBelow; /** @name Interfaces exposed by the driver/device above us. * @{ */ PPDMIMEDIAPORT pIMediaPortAbove; PPDMIMEDIAASYNCPORT <API key>; /** If clear, then suppress Async support. */ bool fAsyncIOSupported; /** @todo implement memfrob. */ } DRVSTORAGEFILTER; /** Pointer to a storage filter driver instance. */ typedef DRVSTORAGEFILTER *PDRVSTORAGEFILTER; /* * * IMediaAsyncPort Implementation. * */ /** @<API key>{PDMIMEDIAASYNCPORT,<API key>} */ static DECLCALLBACK(int) <API key>(PPDMIMEDIAASYNCPORT pInterface, void *pvUser, int rcReq) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMediaAsyncPort); int rc = pThis-><API key>-><API key>(pThis-><API key>, pvUser, rcReq); return rc; } /* * * IMediaAsync Implementation. * */ /** @<API key>{PDMIMEDIAASYNC,pfnStartRead} */ static DECLCALLBACK(int) <API key>(PPDMIMEDIAASYNC pInterface, uint64_t off, PCRTSGSEG paSegs, unsigned cSegs, size_t cbRead, void *pvUser) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMediaAsync); int rc = pThis->pIMediaAsyncBelow->pfnStartRead(pThis->pIMediaAsyncBelow, off, paSegs, cSegs, cbRead, pvUser); return rc; } /** @<API key>{PDMIMEDIAASYNC,pfnStartWrite} */ static DECLCALLBACK(int) <API key>(PPDMIMEDIAASYNC pInterface, uint64_t off, PCRTSGSEG paSegs, unsigned cSegs, size_t cbWrite, void *pvUser) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMediaAsync); int rc = pThis->pIMediaAsyncBelow->pfnStartWrite(pThis->pIMediaAsyncBelow, off, paSegs, cSegs, cbWrite, pvUser); return rc; } /** @<API key>{PDMIMEDIAASYNC,pfnStartFlush} */ static DECLCALLBACK(int) <API key>(PPDMIMEDIAASYNC pInterface, void *pvUser) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMediaAsync); int rc = pThis->pIMediaAsyncBelow->pfnStartFlush(pThis->pIMediaAsyncBelow, pvUser); return rc; } /** @<API key>{PDMIMEDIAASYNC,pfnStartDiscard} */ static DECLCALLBACK(int) <API key>(PPDMIMEDIAASYNC pInterface, PCRTRANGE paRanges, unsigned cRanges, void *pvUser) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMediaAsync); int rc = pThis->pIMediaAsyncBelow->pfnStartDiscard(pThis->pIMediaAsyncBelow, paRanges, cRanges, pvUser); return rc; } /* * * IMedia Implementation. * */ /** @<API key>{PDMIMEDIAPORT,<API key>} */ static DECLCALLBACK(int) <API key>(PPDMIMEDIAPORT pInterface, const char **ppcszController, uint32_t *piInstance, uint32_t *piLUN) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMediaPort); int rc = pThis->pIMediaPortAbove-><API key>(pThis->pIMediaPortAbove, ppcszController, piInstance, piLUN); return rc; } /* * * IMedia Implementation. * */ /** @<API key>{PDMIMEDIA,pfnRead} */ static DECLCALLBACK(int) <API key>(PPDMIMEDIA pInterface, uint64_t off, void *pvBuf, size_t cbRead) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMedia); int rc = pThis->pIMediaBelow->pfnRead(pThis->pIMediaBelow, off, pvBuf, cbRead); return rc; } /** @<API key>{PDMIMEDIA,pfnWrite} */ static DECLCALLBACK(int) <API key>(PPDMIMEDIA pInterface, uint64_t off, const void *pvBuf, size_t cbWrite) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMedia); int rc = pThis->pIMediaBelow->pfnWrite(pThis->pIMediaBelow, off, pvBuf, cbWrite); return rc; } /** @<API key>{PDMIMEDIA,pfnFlush} */ static DECLCALLBACK(int) <API key>(PPDMIMEDIA pInterface) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMedia); int rc = pThis->pIMediaBelow->pfnFlush(pThis->pIMediaBelow); return rc; } /** @<API key>{PDMIMEDIA,pfnMerge} */ static DECLCALLBACK(int) <API key>(PPDMIMEDIA pInterface, PFNSIMPLEPROGRESS pfnProgress, void *pvUser) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMedia); int rc = pThis->pIMediaBelow->pfnMerge(pThis->pIMediaBelow, pfnProgress, pvUser); return rc; } /** @<API key>{PDMIMEDIA,pfnGetSize} */ static DECLCALLBACK(uint64_t) <API key>(PPDMIMEDIA pInterface) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMedia); uint64_t cb = pThis->pIMediaBelow->pfnGetSize(pThis->pIMediaBelow); return cb; } /** @<API key>{PDMIMEDIA,pfnIsReadOnly} */ static DECLCALLBACK(bool) <API key>(PPDMIMEDIA pInterface) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMedia); bool fRc = pThis->pIMediaBelow->pfnIsReadOnly(pThis->pIMediaBelow); return fRc; } /** @<API key>{PDMIMEDIA,<API key>} */ static DECLCALLBACK(int) <API key>(PPDMIMEDIA pInterface, PPDMMEDIAGEOMETRY pPCHSGeometry) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMedia); int rc = pThis->pIMediaBelow-><API key>(pThis->pIMediaBelow, pPCHSGeometry); return rc; } /** @<API key>{PDMIMEDIA,<API key>} */ static DECLCALLBACK(int) <API key>(PPDMIMEDIA pInterface, PCPDMMEDIAGEOMETRY pPCHSGeometry) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMedia); int rc = pThis->pIMediaBelow-><API key>(pThis->pIMediaBelow, pPCHSGeometry); return rc; } /** @<API key>{PDMIMEDIA,<API key>} */ static DECLCALLBACK(int) <API key>(PPDMIMEDIA pInterface, PPDMMEDIAGEOMETRY pLCHSGeometry) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMedia); int rc = pThis->pIMediaBelow-><API key>(pThis->pIMediaBelow, pLCHSGeometry); return rc; } /** @<API key>{PDMIMEDIA,<API key>} */ static DECLCALLBACK(int) <API key>(PPDMIMEDIA pInterface, PCPDMMEDIAGEOMETRY pLCHSGeometry) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMedia); int rc = pThis->pIMediaBelow-><API key>(pThis->pIMediaBelow, pLCHSGeometry); return rc; } /** @<API key>{PDMIMEDIA,pfnGetUuid} */ static DECLCALLBACK(int) <API key>(PPDMIMEDIA pInterface, PRTUUID pUuid) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMedia); int rc = pThis->pIMediaBelow->pfnGetUuid(pThis->pIMediaBelow, pUuid); return rc; } /** @<API key>{PDMIMEDIA,pfnDiscard} */ static DECLCALLBACK(int) <API key>(PPDMIMEDIA pInterface, PCRTRANGE paRanges, unsigned cRanges) { PDRVSTORAGEFILTER pThis = RT_FROM_MEMBER(pInterface, DRVSTORAGEFILTER, IMedia); int rc = pThis->pIMediaBelow->pfnDiscard(pThis->pIMediaBelow, paRanges, cRanges); return rc; } /* * * IBase Implementation. * */ static DECLCALLBACK(void *) <API key>(PPDMIBASE pInterface, const char *pszIID) { PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface); PDRVSTORAGEFILTER pThis = PDMINS_2_DATA(pDrvIns, PDRVSTORAGEFILTER); <API key>(pszIID, PDMIBASE, &pDrvIns->IBase); if (pThis->pIMediaBelow) <API key>(pszIID, PDMIMEDIA, &pThis->IMedia); if (pThis->pIMediaPortAbove) <API key>(pszIID, PDMIMEDIAPORT, &pThis->IMediaPort); if (pThis->fAsyncIOSupported && pThis->pIMediaAsyncBelow) <API key>(pszIID, PDMIMEDIAASYNC, &pThis->IMediaAsync); if (pThis->fAsyncIOSupported && pThis-><API key>) <API key>(pszIID, PDMIMEDIAASYNCPORT, &pThis->IMediaAsyncPort); return NULL; } /* * * PDMDRVREG Methods * */ /** * Construct a storage filter driver. * * @copydoc FNPDMDRVCONSTRUCT */ static DECLCALLBACK(int) <API key>(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags) { PDRVSTORAGEFILTER pThis = PDMINS_2_DATA(pDrvIns, PDRVSTORAGEFILTER); <API key>(pDrvIns); /* * Initialize the instance data. */ pDrvIns->IBase.pfnQueryInterface = <API key>; pThis->IMedia.pfnRead = <API key>; pThis->IMedia.pfnWrite = <API key>; pThis->IMedia.pfnFlush = <API key>; pThis->IMedia.pfnMerge = <API key>; pThis->IMedia.pfnGetSize = <API key>; pThis->IMedia.pfnIsReadOnly = <API key>; pThis->IMedia.<API key> = <API key>; pThis->IMedia.<API key> = <API key>; pThis->IMedia.<API key> = <API key>; pThis->IMedia.<API key> = <API key>; pThis->IMedia.pfnGetUuid = <API key>; pThis->IMedia.pfnDiscard = <API key>; pThis->IMediaPort.<API key> = <API key>; pThis->IMediaAsync.pfnStartRead = <API key>; pThis->IMediaAsync.pfnStartWrite = <API key>; pThis->IMediaAsync.pfnStartFlush = <API key>; pThis->IMediaAsync.pfnStartDiscard = <API key>; pThis->IMediaAsyncPort.<API key> = <API key>; /* * Validate and read config. */ <API key>(pDrvIns, "AsyncIOSupported|", ""); int rc = CFGMR3QueryBoolDef(pCfg, "AsyncIOSupported", &pThis->fAsyncIOSupported, true); <API key>(rc, rc); /* * Query interfaces from the driver/device above us. */ pThis->pIMediaPortAbove = <API key>(pDrvIns->pUpBase, PDMIMEDIAPORT); pThis-><API key> = <API key>(pDrvIns->pUpBase, PDMIMEDIAASYNCPORT); /* * Attach driver below us. */ PPDMIBASE pIBaseBelow; rc = PDMDrvHlpAttach(pDrvIns, fFlags, &pIBaseBelow); <API key>(rc, rc); pThis->pIMediaBelow = <API key>(pIBaseBelow, PDMIMEDIA); pThis->pIMediaAsyncBelow = <API key>(pIBaseBelow, PDMIMEDIAASYNC); AssertLogRelReturn(pThis->pIMediaBelow, <API key>); if (!pThis->pIMediaBelow->pfnDiscard) pThis->IMedia.pfnDiscard = NULL; if (!pThis->pIMediaAsyncBelow || !pThis->pIMediaAsyncBelow->pfnStartDiscard) pThis->IMediaAsync.pfnStartDiscard = NULL; return VINF_SUCCESS; } /** * Storage filter driver registration record. */ static const PDMDRVREG g_DrvStorageFilter = { /* u32Version */ PDM_DRVREG_VERSION, /* szName */ "StorageFilter", /* szRCMod */ "", /* szR0Mod */ "", /* pszDescription */ "Storage Filter Driver Sample", /* fFlags */ <API key>, /* fClass. */ <API key>, /* cMaxInstances */ ~0U, /* cbInstance */ sizeof(DRVSTORAGEFILTER), /* pfnConstruct */ <API key>, /* pfnDestruct */ NULL, /* pfnRelocate */ NULL, /* pfnIOCtl */ NULL, /* pfnPowerOn */ NULL, /* pfnReset */ NULL, /* pfnSuspend */ NULL, /* pfnResume */ NULL, /* pfnAttach */ NULL, /* pfnDetach */ NULL, /* pfnPowerOff */ NULL, /* pfnSoftReset */ NULL, /* u32EndVersion */ PDM_DRVREG_VERSION }; /** * Register builtin devices. * * @returns VBox status code. * @param pCallbacks Pointer to the callback table. * @param u32Version VBox version number. */ extern "C" DECLEXPORT(int) VBoxDriversRegister(PPDMDRVREGCB pCallbacks, uint32_t u32Version) { LogFlow(("VBoxSampleDriver::VBoxDriversRegister: u32Version=%#x pCallbacks->u32Version=%#x\n", u32Version, pCallbacks->u32Version)); <API key>(pCallbacks->u32Version == <API key>, ("%#x, expected %#x\n", pCallbacks->u32Version, <API key>), <API key>); return pCallbacks->pfnRegister(pCallbacks, &g_DrvStorageFilter); }
#ifndef __ALPHA_MMAN_H__ #define __ALPHA_MMAN_H__ #define PROT_READ 0x1 /* page can be read */ #define PROT_WRITE 0x2 /* page can be written */ #define PROT_EXEC 0x4 /* page can be executed */ #define PROT_SEM 0x8 /* page may be used for atomic ops */ #define PROT_NONE 0x0 /* page can not be accessed */ #define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */ #define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */ #define MAP_SHARED 0x01 /* Share changes */ #define MAP_PRIVATE 0x02 /* Changes are private */ #define MAP_TYPE 0x0f /* Mask for type of mapping (OSF/1 is _wrong_) */ #define MAP_FIXED 0x100 /* Interpret addr exactly */ #define MAP_ANONYMOUS 0x10 /* don't use a file */ /* not used by linux, but here to make sure we don't clash with OSF/1 defines */ #define _MAP_HASSEMAPHORE 0x0200 #define _MAP_INHERIT 0x0400 #define _MAP_UNALIGNED 0x0800 /* These are linux-specific */ #define MAP_GROWSDOWN 0x01000 /* stack-like segment */ #define MAP_DENYWRITE 0x02000 /* ETXTBSY */ #define MAP_EXECUTABLE 0x04000 /* mark it as an executable */ #define MAP_LOCKED 0x08000 /* lock the mapping */ #define MAP_NORESERVE 0x10000 /* don't check for reservations */ #define MAP_POPULATE 0x20000 /* populate (prefault) pagetables */ #define MAP_NONBLOCK 0x40000 /* do not block on IO */ #define MAP_STACK 0x80000 /* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x100000 /* create a huge page mapping */ #define MS_ASYNC 1 /* sync memory asynchronously */ #define MS_SYNC 2 /* synchronous memory sync */ #define MS_INVALIDATE 4 /* invalidate the caches */ #define MCL_CURRENT 8192 /* lock all currently mapped pages */ #define MCL_FUTURE 16384 /* lock all additions to address space */ #define MADV_NORMAL 0 /* no further special treatment */ #define MADV_RANDOM 1 /* expect random page references */ #define MADV_SEQUENTIAL 2 /* expect sequential page references */ #define MADV_WILLNEED 3 /* will need these pages */ #define MADV_SPACEAVAIL 5 /* ensure resources are available */ #define MADV_DONTNEED 6 /* don't need these pages */ /* common/generic parameters */ #define MADV_REMOVE 9 /* remove these pages & resources */ #define MADV_DONTFORK 10 /* don't inherit across fork */ #define MADV_DOFORK 11 /* do inherit across fork */ #define MADV_MERGEABLE 12 /* KSM may merge identical pages */ #define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages */ /* compatibility flags */ #define MAP_FILE 0 #endif /* __ALPHA_MMAN_H__ */
package de.cardcontact.opencard.service.isocard; import opencard.core.service.<API key>; import opencard.core.terminal.<API key>; import opencard.core.terminal.CommandAPDU; import opencard.core.terminal.ResponseAPDU; import opencard.opt.iso.fs.CardFilePath; /** * Interface implemented by CardServices supporting direct APDUs to file system objects * * @author asc */ public interface FileSystemSendAPDU { /** * Send APDU making sure that the object referenced by path is selected * * @param path the DF which should be the active DF for this APDU * @param com the command APDU * @param usageQualifier a combination of SecureChannel.CPRO / CENC / RPRO / RENC to control the transformation of the APDU * for secure messaging. Use 0 for plain transmission. * @return Response APDU the response from the card * @throws <API key> * @throws <API key> */ public ResponseAPDU sendCommandAPDU(CardFilePath path, CommandAPDU com, int usageQualifier) throws <API key>, <API key>; }
#ifndef BATTLE_UTILS_H #define BATTLE_UTILS_H #include <array> #include <limits> #include <vector> #include "boost/container/static_vector.hpp" class UnitData; constexpr int ARMY_SIZE = 6; enum class DamageType {normal, simulated}; enum class BattleSide {attacker, defender}; struct UnitState { const UnitData *unit; int num; int hpLeft; // HP of top creature in the stack int timesAttacked; int armyIndex; // slot this unit occupies in its army bool attacker; // unit is a member of the attacking team bool retaliated; UnitState(); UnitState(const UnitData &data, int quantity, BattleSide side); int type() const; bool alive() const; int total_hp() const; int speed() const; int damage(DamageType dType = DamageType::normal) const; void take_damage(int dmg); }; using ArmyState = std::array<UnitState, ARMY_SIZE>; using BattleState = std::array<UnitState, ARMY_SIZE * 2>; struct Army { struct Unit { int type = -1; int num = 0; }; std::array<Unit, ARMY_SIZE> units; int entity = -1; void update(const ArmyState &state); }; // Compare armies by entity id. bool operator<(const Army &lhs, const Army &rhs); bool operator<(const Army &lhs, int rhs); enum class ActionType {attack, retaliate, next_round}; struct BattleEvent { ActionType action = ActionType::attack; int attackerType = -1; int attackerHp = 0; int numAttackers = 0; int defenderType = -1; int defenderHp = 0; int numDefenders = 0; int damage = 0; int losses = 0; bool attackingTeam = true; // attacker is in attacking army }; using BattleLog = std::vector<BattleEvent>; using TargetList = boost::container::static_vector<int, ARMY_SIZE>; class Battle { public: Battle(const BattleState &armies); // Keep a running log of the battle's actions so they can be animated later. // Turn it off for the AI when simulating a battle. void enable_log(BattleLog &log); void disable_log(); bool done() const; bool attackers_turn() const; const BattleState & view_units() const; const UnitState * active_unit() const; // Try to evaluate how much the attacking team is winning. int score() const; // Vector of unit indexes the active unit may attack. TargetList possible_targets() const; int optimal_target() const; // Active unit attacks the given target and then we advance to the next turn. // Simulated attacks always do average damage. void attack(int targetIndex, DamageType dType = DamageType::normal); private: void next_turn(); void next_round(); void update_hp_totals(); // Return the best target to attack and the resulting score after searching // 'depth' plies. Testing suggests depth <= 2 is suboptimal because it can't // adequately consider defender responses to the attacker's chosen move. std::pair<int, int> alpha_beta(int depth, int alpha = std::numeric_limits<int>::min(), int beta = std::numeric_limits<int>::max()) const; BattleState units_; BattleLog *log_; int activeUnit_; int attackerTotalHp_; int defenderTotalHp_; }; struct BattleResult { ArmyState attacker; ArmyState defender; BattleLog log; bool attackerWins = true; }; // Run a battle to completion. BattleResult do_battle(const ArmyState &attacker, const ArmyState &defender, DamageType dType = DamageType::normal); #endif
// Iostreams base classes -*- C++ -*- // 2006, 2007, 2008 // Free Software Foundation, Inc. // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // invalidate any other reasons why the executable file might be covered by /** @file ios_base.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ // ISO C++ 14882: 27.4 Iostreams base classes #ifndef _IOS_BASE_H #define _IOS_BASE_H 1 #pragma GCC system_header #include <ext/atomicity.h> #include <bits/localefwd.h> #include <bits/locale_classes.h> #include <cstdio> // For SEEK_CUR, SEEK_END <API key>(std) // The following definitions of bitmask types are enums, not ints, // as permitted (but not required) in the standard, in order to provide // better type safety in iostream calls. A side effect is that // expressions involving them are no longer compile-time constants. enum _Ios_Fmtflags { _S_boolalpha = 1L << 0, _S_dec = 1L << 1, _S_fixed = 1L << 2, _S_hex = 1L << 3, _S_internal = 1L << 4, _S_left = 1L << 5, _S_oct = 1L << 6, _S_right = 1L << 7, _S_scientific = 1L << 8, _S_showbase = 1L << 9, _S_showpoint = 1L << 10, _S_showpos = 1L << 11, _S_skipws = 1L << 12, _S_unitbuf = 1L << 13, _S_uppercase = 1L << 14, _S_adjustfield = _S_left | _S_right | _S_internal, _S_basefield = _S_dec | _S_oct | _S_hex, _S_floatfield = _S_scientific | _S_fixed, _S_ios_fmtflags_end = 1L << 16 }; inline _Ios_Fmtflags operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b) { return _Ios_Fmtflags(static_cast<int>(__a) & static_cast<int>(__b)); } inline _Ios_Fmtflags operator|(_Ios_Fmtflags __a, _Ios_Fmtflags __b) { return _Ios_Fmtflags(static_cast<int>(__a) | static_cast<int>(__b)); } inline _Ios_Fmtflags operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b) { return _Ios_Fmtflags(static_cast<int>(__a) ^ static_cast<int>(__b)); } inline _Ios_Fmtflags& operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) { return __a = __a | __b; } inline _Ios_Fmtflags& operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) { return __a = __a & __b; } inline _Ios_Fmtflags& operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) { return __a = __a ^ __b; } inline _Ios_Fmtflags operator~(_Ios_Fmtflags __a) { return _Ios_Fmtflags(~static_cast<int>(__a)); } enum _Ios_Openmode { _S_app = 1L << 0, _S_ate = 1L << 1, _S_bin = 1L << 2, _S_in = 1L << 3, _S_out = 1L << 4, _S_trunc = 1L << 5, _S_ios_openmode_end = 1L << 16 }; inline _Ios_Openmode operator&(_Ios_Openmode __a, _Ios_Openmode __b) { return _Ios_Openmode(static_cast<int>(__a) & static_cast<int>(__b)); } inline _Ios_Openmode operator|(_Ios_Openmode __a, _Ios_Openmode __b) { return _Ios_Openmode(static_cast<int>(__a) | static_cast<int>(__b)); } inline _Ios_Openmode operator^(_Ios_Openmode __a, _Ios_Openmode __b) { return _Ios_Openmode(static_cast<int>(__a) ^ static_cast<int>(__b)); } inline _Ios_Openmode& operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) { return __a = __a | __b; } inline _Ios_Openmode& operator&=(_Ios_Openmode& __a, _Ios_Openmode __b) { return __a = __a & __b; } inline _Ios_Openmode& operator^=(_Ios_Openmode& __a, _Ios_Openmode __b) { return __a = __a ^ __b; } inline _Ios_Openmode operator~(_Ios_Openmode __a) { return _Ios_Openmode(~static_cast<int>(__a)); } enum _Ios_Iostate { _S_goodbit = 0, _S_badbit = 1L << 0, _S_eofbit = 1L << 1, _S_failbit = 1L << 2, _S_ios_iostate_end = 1L << 16 }; inline _Ios_Iostate operator&(_Ios_Iostate __a, _Ios_Iostate __b) { return _Ios_Iostate(static_cast<int>(__a) & static_cast<int>(__b)); } inline _Ios_Iostate operator|(_Ios_Iostate __a, _Ios_Iostate __b) { return _Ios_Iostate(static_cast<int>(__a) | static_cast<int>(__b)); } inline _Ios_Iostate operator^(_Ios_Iostate __a, _Ios_Iostate __b) { return _Ios_Iostate(static_cast<int>(__a) ^ static_cast<int>(__b)); } inline _Ios_Iostate& operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) { return __a = __a | __b; } inline _Ios_Iostate& operator&=(_Ios_Iostate& __a, _Ios_Iostate __b) { return __a = __a & __b; } inline _Ios_Iostate& operator^=(_Ios_Iostate& __a, _Ios_Iostate __b) { return __a = __a ^ __b; } inline _Ios_Iostate operator~(_Ios_Iostate __a) { return _Ios_Iostate(~static_cast<int>(__a)); } enum _Ios_Seekdir { _S_beg = 0, _S_cur = SEEK_CUR, _S_end = SEEK_END, _S_ios_seekdir_end = 1L << 16 }; // 27.4.2 Class ios_base /** * @brief The base of the I/O class hierarchy. * * This class defines everything that can be defined about I/O that does * not depend on the type of characters being input or output. Most * people will only see @c ios_base when they need to specify the full * name of the various I/O flags (e.g., the openmodes). */ class ios_base { public: // 27.4.2.1.1 Class ios_base::failure These are thrown to indicate problems. Doc me. class failure : public exception { public: // <API key> // 48. Use of non-existent exception constructor explicit failure(const string& __str) throw(); // This declaration is not useless: virtual ~failure() throw(); virtual const char* what() const throw(); private: string _M_msg; }; // 27.4.2.1.2 Type ios_base::fmtflags /** * @brief This is a bitmask type. * * @c "_Ios_Fmtflags" is <API key>, but it is valid to * perform bitwise operations on these values and expect the Right * Thing to happen. Defined objects of type fmtflags are: * - boolalpha * - dec * - fixed * - hex * - internal * - left * - oct * - right * - scientific * - showbase * - showpoint * - showpos * - skipws * - unitbuf * - uppercase * - adjustfield * - basefield * - floatfield */ typedef _Ios_Fmtflags fmtflags; Insert/extract @c bool in alphabetic rather than numeric format. static const fmtflags boolalpha = _S_boolalpha; Converts integer input or generates integer output in decimal base. static const fmtflags dec = _S_dec; Generate floating-point output in fixed-point notation. static const fmtflags fixed = _S_fixed; Converts integer input or generates integer output in hexadecimal base. static const fmtflags hex = _S_hex; Adds fill characters at a designated internal point in certain generated output, or identical to @c right if no such point is designated. static const fmtflags internal = _S_internal; Adds fill characters on the right (final positions) of certain generated output. (I.e., the thing you print is flush left.) static const fmtflags left = _S_left; Converts integer input or generates integer output in octal base. static const fmtflags oct = _S_oct; Adds fill characters on the left (initial positions) of certain generated output. (I.e., the thing you print is flush right.) static const fmtflags right = _S_right; Generates floating-point output in scientific notation. static const fmtflags scientific = _S_scientific; Generates a prefix indicating the numeric base of generated integer output. static const fmtflags showbase = _S_showbase; Generates a decimal-point character unconditionally in generated floating-point output. static const fmtflags showpoint = _S_showpoint; Generates a + sign in non-negative generated numeric output. static const fmtflags showpos = _S_showpos; Skips leading white space before certain input operations. static const fmtflags skipws = _S_skipws; Flushes output after each output operation. static const fmtflags unitbuf = _S_unitbuf; Replaces certain lowercase letters with their uppercase equivalents in generated output. static const fmtflags uppercase = _S_uppercase; A mask of left|right|internal. Useful for the 2-arg form of @c setf. static const fmtflags adjustfield = _S_adjustfield; A mask of dec|oct|hex. Useful for the 2-arg form of @c setf. static const fmtflags basefield = _S_basefield; A mask of scientific|fixed. Useful for the 2-arg form of @c setf. static const fmtflags floatfield = _S_floatfield; // 27.4.2.1.3 Type ios_base::iostate /** * @brief This is a bitmask type. * * @c "_Ios_Iostate" is <API key>, but it is valid to * perform bitwise operations on these values and expect the Right * Thing to happen. Defined objects of type iostate are: * - badbit * - eofbit * - failbit * - goodbit */ typedef _Ios_Iostate iostate; Indicates a loss of integrity in an input or output sequence (such as an irrecoverable read error from a file). static const iostate badbit = _S_badbit; Indicates that an input operation reached the end of an input sequence. static const iostate eofbit = _S_eofbit; Indicates that an input operation failed to read the expected characters, or that an output operation failed to generate the desired characters. static const iostate failbit = _S_failbit; Indicates all is well. static const iostate goodbit = _S_goodbit; // 27.4.2.1.4 Type ios_base::openmode /** * @brief This is a bitmask type. * * @c "_Ios_Openmode" is <API key>, but it is valid to * perform bitwise operations on these values and expect the Right * Thing to happen. Defined objects of type openmode are: * - app * - ate * - binary * - in * - out * - trunc */ typedef _Ios_Openmode openmode; Seek to end before each write. static const openmode app = _S_app; Open and seek to end immediately after opening. static const openmode ate = _S_ate; Perform input and output in binary mode (as opposed to text mode). This is probably not what you think it is; see http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch27s02.html static const openmode binary = _S_bin; Open for input. Default for @c ifstream and fstream. static const openmode in = _S_in; Open for output. Default for @c ofstream and fstream. static const openmode out = _S_out; Open for input. Default for @c ofstream. static const openmode trunc = _S_trunc; // 27.4.2.1.5 Type ios_base::seekdir /** * @brief This is an enumerated type. * * @c "_Ios_Seekdir" is <API key>. Defined values * of type seekdir are: * - beg * - cur, equivalent to @c SEEK_CUR in the C standard library. * - end, equivalent to @c SEEK_END in the C standard library. */ typedef _Ios_Seekdir seekdir; Request a seek relative to the beginning of the stream. static const seekdir beg = _S_beg; Request a seek relative to the current position within the sequence. static const seekdir cur = _S_cur; Request a seek relative to the current end of the sequence. static const seekdir end = _S_end; // Annex D.6 typedef int io_state; typedef int open_mode; typedef int seek_dir; typedef std::streampos streampos; typedef std::streamoff streamoff; // Callbacks; /** * @brief The set of events that may be passed to an event callback. * * erase_event is used during ~ios() and copyfmt(). imbue_event is used * during imbue(). copyfmt_event is used during copyfmt(). */ enum event { erase_event, imbue_event, copyfmt_event }; /** * @brief The type of an event callback function. * @param event One of the members of the event enum. * @param ios_base Reference to the ios_base object. * @param int The integer provided when the callback was registered. * * Event callbacks are user defined functions that get called during * several ios_base and basic_ios functions, specifically imbue(), * copyfmt(), and ~ios(). */ typedef void (*event_callback) (event, ios_base&, int); /** * @brief Add the callback __fn with parameter __index. * @param __fn The function to add. * @param __index The integer to pass to the function when invoked. * * Registers a function as an event callback with an integer parameter to * be passed to the function when invoked. Multiple copies of the * function are allowed. If there are multiple callbacks, they are * invoked in the order they were registered. */ void register_callback(event_callback __fn, int __index); protected: /** * ios_base data members (doc me) */ streamsize _M_precision; streamsize _M_width; fmtflags _M_flags; iostate _M_exception; iostate _M_streambuf_state; // 27.4.2.6 Members for callbacks // 27.4.2.6 ios_base callbacks struct _Callback_list { // Data Members _Callback_list* _M_next; ios_base::event_callback _M_fn; int _M_index; _Atomic_word _M_refcount; // 0 means one reference. _Callback_list(ios_base::event_callback __fn, int __index, _Callback_list* __cb) : _M_next(__cb), _M_fn(__fn), _M_index(__index), _M_refcount(0) { } void _M_add_reference() { __gnu_cxx::<API key>(&_M_refcount, 1); } // 0 => OK to delete. int _M_remove_reference() { return __gnu_cxx::<API key>(&_M_refcount, -1); } }; _Callback_list* _M_callbacks; void _M_call_callbacks(event __ev) throw(); void <API key>(void); // 27.4.2.5 Members for iword/pword storage struct _Words { void* _M_pword; long _M_iword; _Words() : _M_pword(0), _M_iword(0) { } }; // Only for failed iword/pword calls. _Words _M_word_zero; // Guaranteed storage. // The first 5 iword and pword slots are reserved for internal use. enum { _S_local_word_size = 8 }; _Words _M_local_word[_S_local_word_size]; // Allocated storage. int _M_word_size; _Words* _M_word; _Words& _M_grow_words(int __index, bool __iword); // Members for locale and locale caching. locale _M_ios_locale; void _M_init(); public: // 27.4.2.1.6 Class ios_base::Init // Used to initialize standard streams. In theory, g++ could use // -finit-priority to order this stuff correctly without going // through these machinations. class Init { friend class ios_base; public: Init(); ~Init(); private: static _Atomic_word _S_refcount; static bool <API key>; }; // [27.4.2.2] fmtflags state functions /** * @brief Access to format flags. * @return The format control flags for both input and output. */ fmtflags flags() const { return _M_flags; } /** * @brief Setting new format flags all at once. * @param fmtfl The new flags to set. * @return The previous format control flags. * * This function overwrites all the format flags with @a fmtfl. */ fmtflags flags(fmtflags __fmtfl) { fmtflags __old = _M_flags; _M_flags = __fmtfl; return __old; } /** * @brief Setting new format flags. * @param fmtfl Additional flags to set. * @return The previous format control flags. * * This function sets additional flags in format control. Flags that * were previously set remain set. */ fmtflags setf(fmtflags __fmtfl) { fmtflags __old = _M_flags; _M_flags |= __fmtfl; return __old; } /** * @brief Setting new format flags. * @param fmtfl Additional flags to set. * @param mask The flags mask for @a fmtfl. * @return The previous format control flags. * * This function clears @a mask in the format flags, then sets * @a fmtfl @c & @a mask. An example mask is @c ios_base::adjustfield. */ fmtflags setf(fmtflags __fmtfl, fmtflags __mask) { fmtflags __old = _M_flags; _M_flags &= ~__mask; _M_flags |= (__fmtfl & __mask); return __old; } /** * @brief Clearing format flags. * @param mask The flags to unset. * * This function clears @a mask in the format flags. */ void unsetf(fmtflags __mask) { _M_flags &= ~__mask; } /** * @brief Flags access. * @return The precision to generate on certain output operations. * * Be careful if you try to give a definition of "precision" here; see * DR 189. */ streamsize precision() const { return _M_precision; } /** * @brief Changing flags. * @param prec The new precision value. * @return The previous value of precision(). */ streamsize precision(streamsize __prec) { streamsize __old = _M_precision; _M_precision = __prec; return __old; } /** * @brief Flags access. * @return The minimum field width to generate on output operations. * * "Minimum field width" refers to the number of characters. */ streamsize width() const { return _M_width; } /** * @brief Changing flags. * @param wide The new width value. * @return The previous value of width(). */ streamsize width(streamsize __wide) { streamsize __old = _M_width; _M_width = __wide; return __old; } // [27.4.2.4] ios_base static members static bool sync_with_stdio(bool __sync = true); // [27.4.2.3] ios_base locale functions /** * @brief Setting a new locale. * @param loc The new locale. * @return The previous locale. * * Sets the new locale for this stream, and then invokes each callback * with imbue_event. */ locale imbue(const locale& __loc); /** * @brief Locale access * @return A copy of the current locale. * * If @c imbue(loc) has previously been called, then this function * returns @c loc. Otherwise, it returns a copy of @c std::locale(), * the global C++ locale. */ locale getloc() const { return _M_ios_locale; } /** * @brief Locale access * @return A reference to the current locale. * * Like getloc above, but returns a reference instead of * generating a copy. */ const locale& _M_getloc() const { return _M_ios_locale; } // [27.4.2.5] ios_base storage functions /** * @brief Access to unique indices. * @return An integer different from all previous calls. * * This function returns a unique integer every time it is called. It * can be used for any purpose, but is primarily intended to be a unique * index for the iword and pword functions. The expectation is that an * application calls xalloc in order to obtain an index in the iword and * pword arrays that can be used without fear of conflict. * * The implementation maintains a static variable that is incremented and * returned on each invocation. xalloc is guaranteed to return an index * that is safe to use in the iword and pword arrays. */ static int xalloc() throw(); /** * @brief Access to integer array. * @param __ix Index into the array. * @return A reference to an integer associated with the index. * * The iword function provides access to an array of integers that can be * used for any purpose. The array grows as required to hold the * supplied index. All integers in the array are initialized to 0. * * The implementation reserves several indices. You should use xalloc to * obtain an index that is safe to use. Also note that since the array * can grow dynamically, it is not safe to hold onto the reference. */ long& iword(int __ix) { _Words& __word = (__ix < _M_word_size) ? _M_word[__ix] : _M_grow_words(__ix, true); return __word._M_iword; } /** * @brief Access to void pointer array. * @param __ix Index into the array. * @return A reference to a void* associated with the index. * * The pword function provides access to an array of pointers that can be * used for any purpose. The array grows as required to hold the * supplied index. All pointers in the array are initialized to 0. * * The implementation reserves several indices. You should use xalloc to * obtain an index that is safe to use. Also note that since the array * can grow dynamically, it is not safe to hold onto the reference. */ void*& pword(int __ix) { _Words& __word = (__ix < _M_word_size) ? _M_word[__ix] : _M_grow_words(__ix, false); return __word._M_pword; } // Destructor /** * Invokes each callback with erase_event. Destroys local storage. * * Note that the ios_base object for the standard streams never gets * destroyed. As a result, any callbacks registered with the standard * streams will not get invoked with erase_event (unless copyfmt is * used). */ virtual ~ios_base(); protected: ios_base(); // <API key> // 50. Copy constructor and assignment operator of ios_base private: ios_base(const ios_base&); ios_base& operator=(const ios_base&); }; // [27.4.5.1] fmtflags manipulators Calls base.setf(ios_base::boolalpha). inline ios_base& boolalpha(ios_base& __base) { __base.setf(ios_base::boolalpha); return __base; } Calls base.unsetf(ios_base::boolalpha). inline ios_base& noboolalpha(ios_base& __base) { __base.unsetf(ios_base::boolalpha); return __base; } Calls base.setf(ios_base::showbase). inline ios_base& showbase(ios_base& __base) { __base.setf(ios_base::showbase); return __base; } Calls base.unsetf(ios_base::showbase). inline ios_base& noshowbase(ios_base& __base) { __base.unsetf(ios_base::showbase); return __base; } Calls base.setf(ios_base::showpoint). inline ios_base& showpoint(ios_base& __base) { __base.setf(ios_base::showpoint); return __base; } Calls base.unsetf(ios_base::showpoint). inline ios_base& noshowpoint(ios_base& __base) { __base.unsetf(ios_base::showpoint); return __base; } Calls base.setf(ios_base::showpos). inline ios_base& showpos(ios_base& __base) { __base.setf(ios_base::showpos); return __base; } Calls base.unsetf(ios_base::showpos). inline ios_base& noshowpos(ios_base& __base) { __base.unsetf(ios_base::showpos); return __base; } Calls base.setf(ios_base::skipws). inline ios_base& skipws(ios_base& __base) { __base.setf(ios_base::skipws); return __base; } Calls base.unsetf(ios_base::skipws). inline ios_base& noskipws(ios_base& __base) { __base.unsetf(ios_base::skipws); return __base; } Calls base.setf(ios_base::uppercase). inline ios_base& uppercase(ios_base& __base) { __base.setf(ios_base::uppercase); return __base; } Calls base.unsetf(ios_base::uppercase). inline ios_base& nouppercase(ios_base& __base) { __base.unsetf(ios_base::uppercase); return __base; } Calls base.setf(ios_base::unitbuf). inline ios_base& unitbuf(ios_base& __base) { __base.setf(ios_base::unitbuf); return __base; } Calls base.unsetf(ios_base::unitbuf). inline ios_base& nounitbuf(ios_base& __base) { __base.unsetf(ios_base::unitbuf); return __base; } // [27.4.5.2] adjustfield manipulators Calls base.setf(ios_base::internal, ios_base::adjustfield). inline ios_base& internal(ios_base& __base) { __base.setf(ios_base::internal, ios_base::adjustfield); return __base; } Calls base.setf(ios_base::left, ios_base::adjustfield). inline ios_base& left(ios_base& __base) { __base.setf(ios_base::left, ios_base::adjustfield); return __base; } Calls base.setf(ios_base::right, ios_base::adjustfield). inline ios_base& right(ios_base& __base) { __base.setf(ios_base::right, ios_base::adjustfield); return __base; } // [27.4.5.3] basefield manipulators Calls base.setf(ios_base::dec, ios_base::basefield). inline ios_base& dec(ios_base& __base) { __base.setf(ios_base::dec, ios_base::basefield); return __base; } Calls base.setf(ios_base::hex, ios_base::basefield). inline ios_base& hex(ios_base& __base) { __base.setf(ios_base::hex, ios_base::basefield); return __base; } Calls base.setf(ios_base::oct, ios_base::basefield). inline ios_base& oct(ios_base& __base) { __base.setf(ios_base::oct, ios_base::basefield); return __base; } // [27.4.5.4] floatfield manipulators Calls base.setf(ios_base::fixed, ios_base::floatfield). inline ios_base& fixed(ios_base& __base) { __base.setf(ios_base::fixed, ios_base::floatfield); return __base; } Calls base.setf(ios_base::scientific, ios_base::floatfield). inline ios_base& scientific(ios_base& __base) { __base.setf(ios_base::scientific, ios_base::floatfield); return __base; } <API key> #endif /* _IOS_BASE_H */
#include <sys/types.h> #include <ctype.h> #include <sys/time.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include "bb.h" static int soundin; static int soundout; static int freq = 22050, stereo = 1, _16bit = 1; static int freqs[14] = { 5512, 6615, 8000, 9600, 11025, 16000, 18900, 22050, 27428, 32000, 33075, 37800, 44100, 48000 }; int bbsound = 0; int soundcounter; static int isplaying=0; void stop() { if (bbsound) { write(soundout, "T", 1); isplaying=0; } } int load_song(char *name) { finish_stuff=0; if (bbsound) { stop(); isplaying=1; bbsound=1; switch(name[2]) { case '.': write(soundout, "0", 1); break; case '2': write(soundout, "1", 1); break; case '3': write(soundout, "2", 1); } } return 0; } static int start_sound(void) { pid_t pid; int mypipe[2]; int mypipe2[2]; /* Create the pipe. */ if (pipe(mypipe) || pipe(mypipe2)) { fprintf(stderr, "Pipe failed.\n"); return EXIT_FAILURE; } pid = fork(); if (pid == (pid_t) 0) { /* This is the child process. */ char str[256]; sprintf(str, "bb_snd_server %i %i %i bb.s3m bb2.s3m bb3.s3m", freq, stereo, _16bit); close(mypipe[0]); close(mypipe2[1]); close(1); dup(mypipe[1]); close(0); dup(mypipe2[0]); fflush(stdout); if(system(str)) { sprintf(str, "./bb_snd_server %i %i %i bb.s3m bb2.s3m bb3.s3m", freq, stereo, _16bit); system(str); } write(mypipe[1], "!", 1); exit(0); } else if (pid > (pid_t) 0) { /* This is the parent process. */ close(mypipe[1]); close(mypipe2[0]); soundin = mypipe[0]; soundout = mypipe2[1]; bbsound = 1; return EXIT_SUCCESS; } else { /* The fork failed. */ fprintf(stderr, "Fork failed.\n"); return EXIT_FAILURE; } } void play() { if (bbsound) { write(soundout, "S", 1); } } void wait_sound() { char ch; read(soundin, &ch, 1); if (ch == '!') { bbsound = 0; } } void update_sound() { fd_set readfds; char ch; struct timeval tv; if (!bbsound) return; tv.tv_sec = 0; tv.tv_usec = 0; FD_ZERO(&readfds); FD_SET(soundin, &readfds); while (select(soundin + 1, &readfds, NULL, NULL, &tv)) { soundcounter++; read(soundin, &ch, 1); if (ch == '!') { bbsound = 0; break; } } } int main(int argc, char *argv[]) { int retval; int p=0; char s[255]; bbinit(argc,argv); //aa_puts(context, 0, p++, AA_SPECIAL, "Music?[Y/n]"); //aa_flush(context); /* if (tolower(aa_getkey(context, 1)) != 'n') { aa_puts(context, 0, p, AA_SPECIAL, "Sample rate"); do { sprintf(s, "%i", freq); aa_edit(context, 13, p++, 5, s, 6); } while (sscanf(s, "%i", &freq) == 0 || freq < 8000 || freq > 100000); {int i,minv=freqs[0]; for(i=0;i<14;i++) if(abs(freq-minv)>abs(freq-freqs[i])) minv=freqs[i]; freq=minv; } aa_puts(context, 0, p++, AA_SPECIAL, "Stereo?[Y/n]"); aa_flush(context); if (tolower(aa_getkey(context, 1)) == 'n') stereo = 0; aa_puts(context, 0, p++, AA_SPECIAL, "16 bit?[Y/n]"); aa_flush(context); if (tolower(aa_getkey(context, 1)) == 'n') _16bit = 0; start_sound(); wait_sound(); } */ retval = bb(); if (bbsound) { write(soundout, "!", 1); close(soundout); close(soundin); } return retval; }
package org.peerfact.impl.overlay.dht.can.components; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.log4j.Logger; import org.peerfact.api.common.ConnectivityEvent; import org.peerfact.api.common.Message; import org.peerfact.api.common.OperationCallback; import org.peerfact.api.overlay.<API key>; import org.peerfact.api.overlay.dht.DHTListener; import org.peerfact.api.overlay.dht.DHTNode; import org.peerfact.api.overlay.dht.DHTObject; import org.peerfact.api.overlay.kbr.<API key>; import org.peerfact.api.overlay.kbr.KBRListener; import org.peerfact.api.overlay.kbr.KBRLookupProvider; import org.peerfact.api.transport.TransInfo; import org.peerfact.api.transport.TransLayer; import org.peerfact.api.transport.TransProtocol; import org.peerfact.impl.common.AbstractOperation; import org.peerfact.impl.overlay.AbstractOverlayNode; import org.peerfact.impl.overlay.dht.can.operations.<API key>; import org.peerfact.impl.overlay.dht.can.operations.JoinOperation; import org.peerfact.impl.overlay.dht.can.operations.LeaveOperation; import org.peerfact.impl.overlay.dht.can.operations.LookupOperation; import org.peerfact.impl.overlay.dht.can.operations.StoreOperation; import org.peerfact.impl.overlay.dht.can.operations.TakeoverOperation; import org.peerfact.impl.overlay.kbr.KBRMsgHandler; import org.peerfact.impl.overlay.kbr.messages.<API key>; import org.peerfact.impl.overlay.kbr.messages.KBRForwardMsg; import org.peerfact.impl.simengine.Simulator; import org.peerfact.impl.util.logging.SimLogger; /** * This is the base for every peer in the CAN it saves all information of the * peer. It is the central of the peers. Implements DHTNode. * * @author Bjoern Dollak <peerfact@kom.tu-darmstadt.de> * @version February 2010 * */ public class CanNode extends AbstractOverlayNode<CanOverlayID, CanOverlayContact> implements DHTNode<CanOverlayID, CanOverlayContact, CanOverlayKey> { private final static Logger log = SimLogger.getLogger(CanNode.class); private CanOverlayContact localContact = null; private final TransLayer transLayer; private CanMessageHandler msgHandler; private OperationCallback<Object> canCallback; List<CanOverlayContact> neighbours; private CanBootstrapManager bootstrap; private String joiningTime; private CanOverlayContact[] VIDNeighbours; // overload extension private List<CanOverlayContact> overloadedContacts; private CanOverlayContact mainNode; // takeover leave private TakeoverOperation takeoverOperation; private List<List<CanOverlayContact>> <API key>; private List<CanOverlayContact[]> <API key>; private List<CanOverlayContact> leavingNeighbours; private List<CanArea> leavingArea; private List<CanOverlayContact> <API key>; // also used for // takeover private List<CanOverlayContact[]> <API key>; private List<Object[]> leavingHashs; private CanOverlayContact missingNode; // node left without a message // lookup store private List<Object[]> storedHashs; private final Map<Integer, AbstractOperation<?, ?>> lookupStore = new LinkedHashMap<Integer, AbstractOperation<?, ?>>(); private KBRListener<CanOverlayID, CanOverlayContact, CanOverlayKey> kbrListener; private KBRLookupProvider<CanOverlayID, CanOverlayContact, CanOverlayKey> kbrLookupProvider; /** * Initiates the CanNode. Is called when the peer is created. * * @param transLayer * the TransLayer of the peer * @param port */ public CanNode(TransLayer transLayer, short port) { super(new CanOverlayID(transLayer.getLocalTransInfo(port)), port); overloadedContacts = new LinkedList<CanOverlayContact>(); neighbours = new LinkedList<CanOverlayContact>(); <API key> = new LinkedList<List<CanOverlayContact>>(); <API key> = new LinkedList<CanOverlayContact[]>(); this.transLayer = transLayer; localContact = new CanOverlayContact(new CanOverlayID( transLayer.getLocalTransInfo(port)), transLayer.getLocalTransInfo(port)); // create message handler msgHandler = new CanMessageHandler(this); // add message handler to the listeners list this.getTransLayer().addTransMsgListener(this.msgHandler, this.getPort()); this.VIDNeighbours = new CanOverlayContact[2]; leavingNeighbours = new LinkedList<CanOverlayContact>(); leavingArea = new LinkedList<CanArea>(); <API key> = new LinkedList<CanOverlayContact>(); <API key> = new LinkedList<CanOverlayContact[]>(); leavingHashs = new LinkedList<Object[]>(); takeoverOperation = new TakeoverOperation(this, canCallback); storedHashs = new LinkedList<Object[]>(); log.debug(Simulator.<API key>() + " New CanNode initiated."); } // start Operations @Override public int join(OperationCallback<Object> callback) { // get the first active node in bootstrap, to join in the overlay log.info(Simulator.<API key>() + " Node is joining."); this.canCallback = callback; JoinOperation join = new JoinOperation(this, callback); join.scheduleImmediately(); return join.getOperationID(); } @Override public int leave(OperationCallback<Object> callback) { LeaveOperation leave = new LeaveOperation(this, callback); leave.scheduleImmediately(); return leave.getOperationID(); } /** * Calls the <API key> which shows all the data of the peer * * @param canCallback * @return */ public int giveNodeInfo(OperationCallback<Object> callback) { <API key> giveNeighbour = new <API key>(this, callback); giveNeighbour.scheduleImmediately(); return giveNeighbour.getOperationID(); } /** * Sets the peer absent. Is used for debug. * * @param canCallback * @return */ public int setAbsent(OperationCallback<Object> callback) { log.debug("set node absent: " + this.<API key>().getOverlayID().toString() + " " + this.<API key>().getArea().toString() + " " + this.<API key>().getArea().getVid().toString()); this.setPeerStatus(PeerStatus.ABSENT); this.setAlive(false); return 0; } @Override public int store(CanOverlayKey key, DHTObject obj, OperationCallback<Set<CanOverlayContact>> callback) { StoreOperation storeOperation = new StoreOperation(this, key, obj, callback); storeOperation.scheduleImmediately(); return storeOperation.getOperationID(); } @Override public int nodeLookup(CanOverlayKey key, OperationCallback<List<CanOverlayContact>> callback, boolean returnSingleNode) { LookupOperation lookupOperation = new LookupOperation(this, key, callback); lookupOperation.scheduleImmediately(); // Inform the monitors about an initiated query Simulator.getMonitor() .dhtLookupInitiated(<API key>(), key); return lookupOperation.getOperationID(); } @Override public int valueLookup(CanOverlayKey key, OperationCallback<DHTObject> callback) { throw new <API key>("FIXME: Implement this method"); } @Override public void connectivityChanged(ConnectivityEvent ce) { if (ce.isOffline()) { if (this.getPeerStatus().equals(PeerStatus.PRESENT)) { this.setPeerStatus(PeerStatus.ABSENT); this.storedHashs = new LinkedList<Object[]>(); this.<API key>(); this.setAlive(false); } } else if (ce.isOnline()) { if (!this.getPeerStatus().equals(PeerStatus.PRESENT)) { neighbours = new LinkedList<CanOverlayContact>(); <API key> = new LinkedList<List<CanOverlayContact>>(); <API key> = new LinkedList<CanOverlayContact[]>(); localContact = new CanOverlayContact(new CanOverlayID( transLayer.getLocalTransInfo(this.getPort())), transLayer.getLocalTransInfo(this.getPort())); this.VIDNeighbours = new CanOverlayContact[2]; leavingNeighbours = new LinkedList<CanOverlayContact>(); leavingArea = new LinkedList<CanArea>(); <API key> = new LinkedList<CanOverlayContact>(); <API key> = new LinkedList<CanOverlayContact[]>(); leavingHashs = new LinkedList<Object[]>(); takeoverOperation = new TakeoverOperation(this, canCallback); storedHashs = new LinkedList<Object[]>(); this.setPeerStatus(PeerStatus.TO_JOIN); this.join(canCallback); } } } // basic methods public CanOverlayID getCanOverlayID() { return <API key>().getOverlayID(); } public void setAlive(boolean live) { localContact.setAlive(live); } public void setNeighbours(List<CanOverlayContact> neighbours) { this.neighbours = neighbours; takeoverOperation.updateNode(this); } public List<CanOverlayContact> getNeighbours() { return this.neighbours; } /** * removes a certain neighbor * * @param remove * neighbor to remove */ public void removeNeighbour(CanOverlayContact remove) { for (int i = 0; i < neighbours.size(); i++) { if ((neighbours.get(i)).getOverlayID().toString() .equals(remove.getOverlayID().toString())) { neighbours.remove(i); } } <API key>(remove); <API key>(remove); } /** * checks if the neighbor is in the list * * @param compare * CanOverlayContact to check * @return true if neighbor is in the list */ public boolean neighboursContain(CanOverlayContact compare) { for (int i = 0; i < neighbours.size(); i++) { if ((neighbours.get(i)).getOverlayID().equals( compare.getOverlayID())) { return true; } } return false; } public CanBootstrapManager getBootstrap() { return bootstrap; } public void setBootstrap(CanBootstrapManager bootstrap) { this.bootstrap = bootstrap; } @Override public TransLayer getTransLayer() { return this.transLayer; } // neighbors of neighbors methods /** * checks if the neighbor is in the list * * @param compare * CanOverlayID to check * @return true if neighbor is in the list */ public boolean neighboursContain(CanOverlayID compare) { for (int i = 0; i < neighbours.size(); i++) { if ((neighbours.get(i)).getOverlayID().equals(compare)) { return true; } } return false; } public List<CanOverlayContact[]> <API key>() { return this.<API key>; } public void <API key>( List<CanOverlayContact[]> <API key>) { this.<API key> = <API key>; } public void <API key>(CanOverlayContact neighbour, CanOverlayContact[] vidNeighbours) { CanOverlayContact[] vidToSave = { neighbour, vidNeighbours[0], vidNeighbours[1] }; this.<API key>.add(vidToSave); } /** * remove the VID neighbors of a peer * * @param neighbour */ public void <API key>(CanOverlayContact neighbour) { for (int i = 0; i < <API key>.size(); i++) { if (<API key>.get(i)[0].getArea().getVid() .toString().equals(neighbour.getArea().getVid().toString()) || <API key>.get(i)[0].getOverlayID() .toString() .equals(neighbour.getOverlayID().toString())) { <API key>.remove(i); i = -1; } } } /** * removes a list of neighbor in the VID neighbors of neighbors list. * * @param neighbourList */ public void <API key>( List<CanOverlayContact> neighbourList) { try { for (int i = 0; i < <API key>.size(); i++) { boolean contains = false; CanOverlayContact[] toTry = <API key>.get(i); for (int j = 0; j < neighbourList.size(); j++) { if (toTry[0] .getOverlayID() .toString() .equals(neighbourList.get(j).clone().getOverlayID() .toString())) { contains = true; } } if (!contains) { <API key>.remove(i); i = -1; } } } catch (Exception e) { // in case the list is null log.error("Exception in CanNode occured", e); } } /** * updates the VID neighbors of a peer. * * @param neighbour * @param <API key> */ public void <API key>(CanOverlayContact neighbour, CanOverlayContact[] <API key>) { try { <API key>(neighbour); } catch (Exception e) { // in case the list is null log.error("Exception in CanNode occured", e); } <API key>(neighbour, <API key>); } /** * Gives the VID neighbors of a certain node. * * @param neighbour * @return */ public CanOverlayContact[] <API key>( CanOverlayContact neighbour) { CanOverlayContact[] output = new CanOverlayContact[2]; for (int i = 0; i < <API key>.size(); i++) { if (<API key>.get(i)[0].getArea().getVid() .toString().equals(neighbour.getArea().getVid().toString())) { output[0] = <API key>.get(i)[1]; output[1] = <API key>.get(i)[2]; } } return output; } public List<List<CanOverlayContact>> <API key>() { return this.<API key>; } public void <API key>( List<List<CanOverlayContact>> <API key>) { this.<API key> = <API key>; } /** * adds a peer to the neighbor of neighbors list * * @param neighbour * @param <API key> */ public void <API key>(CanOverlayContact neighbour, List<CanOverlayContact> <API key>) { try { List<CanOverlayContact> listToSave = new LinkedList<CanOverlayContact>(); listToSave.add(neighbour); listToSave.addAll(<API key>); this.<API key>.add(listToSave); } catch (Exception e) { // in case the list is null log.error("Exception in CanNode occured", e); } } /** * removes a peer in the neighbour of neighbours list * * @param neighbour */ public void <API key>(CanOverlayContact neighbour) { for (int i = 0; i < <API key>.size(); i++) { if (<API key>.get(i).get(0).getOverlayID().toString() .equals(neighbour.getOverlayID().toString())) { <API key>.remove(i); i = -1; } } } /** * removes a list of peers from the neighbours of neighbour list * * @param neighbourList */ public void <API key>( List<CanOverlayContact> neighbourList) { try { for (int i = 0; i < <API key>.size(); i++) { boolean contains = false; for (int j = 0; j < neighbourList.size(); j++) { List<CanOverlayContact> toTry = <API key> .get(i); if (toTry .get(0) .getOverlayID() .toString() .equals(neighbourList.get(j).getOverlayID() .toString())) { contains = true; } } if (!contains) { <API key>.remove(i); i = -1; } } } catch (Exception e) { // in case the list is empty log.error("Exception in CanNode occured", e); } } /** * updates a peer in the neighbours of neighbour list * * @param neighbour * @param <API key> */ public void <API key>(CanOverlayContact neighbour, List<CanOverlayContact> <API key>) { try { <API key>(neighbour); } catch (Exception e) { // in case the list is empty log.error("Exception in CanNode occured", e); } <API key>(neighbour, <API key>); } /** * gets the neighbous of a certain peer. * * @param neighbour * @return */ public List<CanOverlayContact> <API key>( CanOverlayContact neighbour) { List<CanOverlayContact> outputList = new LinkedList<CanOverlayContact>(); for (int i = 0; i < <API key>.size(); i++) { if (<API key>.get(i).get(0).getOverlayID().toString() .equals(neighbour.getOverlayID().toString())) { outputList = <API key>.get(i); } } try { outputList.remove(0); } catch (Exception e) { // in case the list is empty log.error("Exception in CanNode occured", e); } return outputList; } public void <API key>() { try { for (int x = 0; x < this.neighbours.size(); x++) { log.debug("own neighbours: " + this.neighbours.get(x).getOverlayID().toString()); } } catch (Exception e) { // in case the list is empty log.error("Exception in CanNode occured", e); } for (int x = 0; x < this.<API key>().size(); x++) { List<CanOverlayContact> toShow = this.<API key>() .get(x); log.debug("neighbours of: " + toShow.get(0).getOverlayID().toString()); for (int y = 1; y < toShow.size(); y++) { log.debug(toShow.get(y).getOverlayID().toString()); } } } // for overload extension public List<CanOverlayContact> <API key>() { return overloadedContacts; } public void <API key>(List<CanOverlayContact> overloadedContacts) { this.overloadedContacts = overloadedContacts; } public CanOverlayContact getMainNode() { return mainNode; } public void setMainNode(CanOverlayContact mainNode) { this.mainNode = mainNode; } public void setVIDNeigbours(CanOverlayContact[] vIDNeighbours) { this.VIDNeighbours = new CanOverlayContact[2]; this.VIDNeighbours[0] = vIDNeighbours[0].clone(); this.VIDNeighbours[1] = vIDNeighbours[1].clone(); } /** * sets both VID neighbors to null */ public void emptyVIDNeigbours() { this.VIDNeighbours = new CanOverlayContact[2]; } public CanOverlayContact[] getVIDNeighbours() { return VIDNeighbours; } public void setArea(CanArea area) { this.localContact.setArea(area); } public void setVID(CanVID vid) { this.localContact.getArea().setVid(vid); } // is used for leave and takeover to store the data of the other nodes // with the same parents /** * adds the neighbors of a peer */ public void <API key>( List<CanOverlayContact> <API key>) { this.leavingNeighbours.addAll(<API key>); } /** * adds a contact * * @return */ public List<CanOverlayContact> <API key>() { return leavingNeighbours; } /** * sets the list to null */ public void <API key>() { this.leavingNeighbours = new LinkedList<CanOverlayContact>(); } /** * adds a area * * @param newLeavingArea */ public void addLeavingArea(CanArea newLeavingArea) { this.leavingArea.add(newLeavingArea); } public List<CanArea> getLeavingArea() { return leavingArea; } /** * sets the list to null */ public void emptyLeavingArea() { this.leavingArea = new LinkedList<CanArea>(); } public void <API key>( CanOverlayContact <API key>) { this.<API key>.add(<API key>); } public List<CanOverlayContact> <API key>() { return <API key>; } /** * sets the list to null */ public void <API key>() { this.<API key> = new LinkedList<CanOverlayContact>(); } public List<CanOverlayContact[]> <API key>() { return this.<API key>; } public void <API key>(CanOverlayContact[] vidNeighbour) { this.<API key>.add(vidNeighbour); } /** * sets the list to null */ public void <API key>() { this.<API key> = new LinkedList<CanOverlayContact[]>(); } public List<Object[]> getLeavingHash() { return this.leavingHashs; } public void addLeavingHash(List<Object[]> newLeavingHash) { if (newLeavingHash != null) { this.leavingHashs.addAll(newLeavingHash); } } /** * sets the list to null */ public void emptyLeavingHashs() { this.leavingHashs = new LinkedList<Object[]>(); } // the TakeoverOperation handles the ping messages /** * starts the TakeoverOperation */ public void <API key>() { takeoverOperation = new TakeoverOperation(this, canCallback); takeoverOperation.scheduleWithDelay(CanConfig.waitTimeBetweenPing); } public TakeoverOperation <API key>() { return takeoverOperation; } /** * stops the TakeoverOperation */ public void <API key>() { takeoverOperation.stopOperation(); } /** * resumes the TakeoverOperation with delay */ public void <API key>() { takeoverOperation.updateNode(this); takeoverOperation.resumeOperation(); } /** * resumes the TakoverOperation directly */ public void <API key>() { takeoverOperation.updateNode(this); takeoverOperation.<API key>(); } /** * saves a missing peer and deletes it from the neighbour list * * @param missingNode */ public void setMissingNode(CanOverlayContact missingNode) { this.missingNode = missingNode; if (missingNode != null) { List<CanOverlayContact> newNeighbours = getNeighbours(); for (int i = 0; i < newNeighbours.size(); i++) { if (newNeighbours.get(i).getOverlayID().toString() .equals(missingNode.getOverlayID().toString())) { newNeighbours.remove(i); } } setNeighbours(newNeighbours); } } public CanOverlayContact getMissingNode() { return missingNode; } // store and lookup /** * Gives the next peer for the routing of lookup and store messages. * * @param id * DataID the has value which should be routed to * @return */ public CanOverlayContact routingNext(CanOverlayKey id) { // Data ID CanOverlayContact next = null; if (id.includedInArea(this.localContact.getArea())) { return this.localContact; } for (int i = 0; i < neighbours.size(); i++) { if (id.includedInArea(neighbours.get(i).getArea())) { return neighbours.get(i); } } CanArea areaActualNode = this.<API key>().getArea(); if (id.sameXValue(areaActualNode)) { // equal high if (id.getYValue().intValue() > areaActualNode.getArea()[3]) { // area // bigger // than // current for (int i = 0; i < neighbours.size(); i++) { next = neighbours.get(i); if (id.getYValue().intValue() >= next.getArea().getArea()[3] && next.isAlive() && areaActualNode.getArea()[3] <= next.getArea() .getArea()[2]) { return next; } } } else if (id.getYValue().intValue() <= areaActualNode.getArea()[2]) { // area // smaller // than // current for (int i = 0; i < neighbours.size(); i++) { next = neighbours.get(i); if (id.getYValue().intValue() <= next.getArea().getArea()[3] && next.isAlive() && areaActualNode.getArea()[2] >= next.getArea() .getArea()[3]) { return next; } } } } else if (id.getXValue().intValue() >= areaActualNode.getArea()[1]) { // area // bigger // than // current for (int i = 0; i < neighbours.size(); i++) { next = neighbours.get(i); if (id.getXValue().intValue() > next.getArea().getArea()[0] && next.isAlive() && areaActualNode.getArea()[1] <= next.getArea() .getArea()[0]) { return next; } } } else if (id.getXValue().intValue() <= areaActualNode.getArea()[0]) { // area // smaller // than // current for (int i = 0; i < neighbours.size(); i++) { next = neighbours.get(i); if (id.getXValue().intValue() <= next.getArea().getArea()[1] && next.isAlive() && areaActualNode.getArea()[0] >= next.getArea() .getArea()[1]) { return next; } } } else if (id.getYValue().intValue() >= areaActualNode.getArea()[3]) { // area // bigger // than // current for (int i = 0; i < neighbours.size(); i++) { next = neighbours.get(i); if (id.getYValue().intValue() > next.getArea().getArea()[3] && next.isAlive() && areaActualNode.getArea()[3] <= next.getArea() .getArea()[2]) { return next; } } } else { return neighbours.get(Simulator.getRandom().nextInt( neighbours.size())); } return next; } /** * adds a hash and the connected CanOveralayContact * * @param id * hash value * @param contact * CanOverlayContact */ public void addStoredHashs(CanOverlayKey id, CanOverlayContact contact) { Object[] store = { id, contact }; this.storedHashs.add(store); } /** * deletes a certain hash * * @param id * hash value to delete */ public void deleteStoredHashs(CanOverlayKey id) { for (int i = 0; i < storedHashs.size(); i++) { if (((CanOverlayKey) storedHashs.get(i)[0]).toString().equals( id.toString())) { this.storedHashs.remove(i); i = -1; } } } /** * deletes all the hash values from the contact * * @param contact */ public void deleteStoredHashs(CanOverlayContact contact) { for (int i = 0; i < storedHashs.size(); i++) { if (((CanOverlayContact) storedHashs.get(i)[1]).toString().equals( contact.toString())) { this.storedHashs.remove(i); i = -1; } } } /** * gives the CanOverlayContact to a hash, if it is saved in the list. * * @param id * searched hash value * @return */ public CanOverlayContact getStoredHashToID(CanOverlayKey id) { for (int i = 0; i < storedHashs.size(); i++) { if (((CanOverlayKey) storedHashs.get(i)[0]).toString().equals( id.toString())) { return ((CanOverlayContact) storedHashs.get(i)[1]); } } return null; } public List<Object[]> getStoredHashs() { return this.storedHashs; } public void setStoredHashs(List<Object[]> newHashs) { try { this.storedHashs = newHashs; } catch (Exception e) { log.error("Exception in CanNode occured", e); this.storedHashs = new LinkedList<Object[]>(); } for (int i = 0; i < this.storedHashs.size(); i++) { if ((CanOverlayContact) this.storedHashs.get(i)[1] != null) { for (int j = 0; j < this.storedHashs.size(); j++) { if ((CanOverlayContact) this.storedHashs.get(j)[1] != null) { if (i != j && ((CanOverlayKey) this.storedHashs.get(i)[0]) .getId() .toString() .equals(((CanOverlayKey) this.storedHashs .get(j)[0]).getId().toString()) && ((CanOverlayContact) this.storedHashs.get(i)[1]) .getOverlayID() .toString() .equals(((CanOverlayContact) this.storedHashs .get(j)[1]).getOverlayID() .toString())) { this.storedHashs.remove(i); i = -1; break; } } } } } for (int x = 0; x < newHashs.size(); x++) { log.debug("hash " + ((CanOverlayKey) newHashs.get(x)[0]).toString()); } } /** * gives a map of all lookup and store Operations. * * @return */ public Map<Integer, AbstractOperation<?, ?>> getLookupStore() { return this.lookupStore; } /** * registers a new Lookup or store operation * * @param id * @param op */ public void registerLookupStore(Integer id, AbstractOperation<?, ?> op) { lookupStore.put(id, op); } /** * removes a lookup or store Operation from the map. * * @param cmdID */ public void lookupStoreFinished(Integer cmdID) { lookupStore.remove(cmdID); } /** * sets the time the peer joins * * @param time */ public void setJoiningTime(String time) { this.joiningTime = time; } public String getJoiningTime() { return this.joiningTime; } @Override public <API key><CanOverlayContact> getNeighbors() { return new <API key><CanOverlayContact>() { @Override public Collection<CanOverlayContact> getNeighbors() { List<CanOverlayContact> res = neighbours; return Collections.unmodifiableList(res); } }; } @Override public void route(CanOverlayKey key, Message msg, CanOverlayContact hint) { CanOverlayContact nextHop = null; if (hint != null) { nextHop = hint; } else if (key != null) { nextHop = local_lookup(key, 1).get(0); // Inform the monitors about an initiated query Simulator.getMonitor().kbrQueryStarted(<API key>(), msg); } else { log.error("KBR route problem: Both key and hint are null! No idea where to route the message."); return; } <API key><CanOverlayID, CanOverlayContact, CanOverlayKey> info = new <API key><CanOverlayID, CanOverlayContact, CanOverlayKey>( key, msg, nextHop); kbrListener.forward(info); if (nextHop != null) { // see <API key>, stop Message if // nextHop = null KBRForwardMsg<CanOverlayID, CanOverlayKey> fm = new KBRForwardMsg<CanOverlayID, CanOverlayKey>( getOverlayID(), nextHop.getOverlayID(), key, msg); getTransLayer().send(fm, nextHop.getTransInfo(), getPort(), TransProtocol.UDP); } } @Override public List<CanOverlayContact> local_lookup(CanOverlayKey key, int num) { List<CanOverlayContact> contacts = new ArrayList<CanOverlayContact>(); if (num > 0) { contacts.add(routingNext(key)); } return contacts; } @Override public List<CanOverlayContact> replicaSet(CanOverlayKey key, int maxRank) { throw new <API key>("FIXME: Implement this method"); } @Override public List<CanOverlayContact> neighborSet(int num) { throw new <API key>("FIXME: Implement this method"); } @Override public CanOverlayID[] range(CanOverlayContact contact, int rank) { throw new <API key>("FIXME: Implement this method"); } @Override public boolean isRootOf(CanOverlayKey key) { return key.includedInArea(<API key>().getArea()); } @Override public void setKBRListener( KBRListener<CanOverlayID, CanOverlayContact, CanOverlayKey> listener) { this.kbrListener = listener; KBRMsgHandler<CanOverlayID, CanOverlayContact, CanOverlayKey> messageHandler1 = new KBRMsgHandler<CanOverlayID, CanOverlayContact, CanOverlayKey>( this, this, kbrListener); kbrLookupProvider = messageHandler1.getLookupProvider(); } @Override public CanOverlayKey getNewOverlayKey(int rank) { return new CanOverlayKey(String.valueOf(rank)); } @Override public CanOverlayKey getRandomOverlayKey() { return new CanOverlayKey(String.valueOf(Simulator.getRandom() .nextDouble())); } @Override public CanOverlayContact <API key>() { return localContact.clone(); } @Override public CanOverlayContact getOverlayContact(CanOverlayID id, TransInfo transinfo) { return new CanOverlayContact(id, transinfo); } @Override public void hadContactTo(CanOverlayContact contact) { // nothing to do here } @Override public KBRLookupProvider<CanOverlayID, CanOverlayContact, CanOverlayKey> <API key>() { return kbrLookupProvider; } @Override public void registerDHTListener(DHTListener<CanOverlayKey> listener) { throw new <API key>("not yet implemented"); } }
<?php // dsm($rows); ?> <div class="front-page-slider" id="slideShow"> <div id="slideShowItems"> <?php // dsm($rows); ?> <?php foreach ($rows as $row_count => $row): ?> <div class="slides_container"> <a href="<?php print $row['field_link_banner']; ?>"> <?php print $row['<API key>'] ?> </a> </div> <?php endforeach; ?> </div> </div><!-- /.front-page-slider-->
<?php namespace Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer; use Magento\Framework\Locale\Bundle\DataBundle; use Magento\Framework\Stdlib\DateTime\<API key>; /** * Adminhtml grid item renderer date */ class Date extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Date { /** * @var \Magento\Framework\Locale\ResolverInterface */ private $localeResolver; /** * Constructor * * @param \Magento\Backend\Block\Context $context * @param <API key> $dateTimeFormatter * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, <API key> $dateTimeFormatter, \Magento\Framework\Locale\ResolverInterface $localeResolver, array $data = [] ) { parent::__construct($context, $dateTimeFormatter, $data); $this->localeResolver = $localeResolver; } /** * Retrieve date format * * @return string */ protected function _getFormat() { $format = $this->getColumn()->getFormat(); if (!$format) { $dataBundle = new DataBundle(); $resourceBundle = $dataBundle->get($this->localeResolver->getLocale()); $formats = $resourceBundle['calendar']['gregorian']['availableFormats']; switch ($this->getColumn()->getPeriodType()) { case 'month': $format = $formats['yM']; break; case 'year': $format = $formats['y']; break; default: $format = $this->_localeDate->getDateFormat(\IntlDateFormatter::MEDIUM); break; } } return $format; } /** * Renders grid column * * @param \Magento\Framework\DataObject $row * @return string */ public function render(\Magento\Framework\DataObject $row) { if ($data = $row->getData($this->getColumn()->getIndex())) { switch ($this->getColumn()->getPeriodType()) { case 'month': $data = $data . '-01'; break; case 'year': $data = $data . '-01-01'; break; } $format = $this->_getFormat(); if ($this->getColumn()->getGmtoffset() || $this->getColumn()->getTimezone()) { $date = $this->_localeDate->date(new \DateTime($data)); } else { $date = $this->_localeDate->date(new \DateTime($data), null, false); } return $this->dateTimeFormatter->formatObject($date, $format, $this->localeResolver->getLocale()); } return $this->getColumn()->getDefault(); } }
<?php namespace Magento\Eav\Model\Entity; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend; use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend; use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource; use Magento\Framework\App\Config\Element; use Magento\Framework\DataObject; use Magento\Framework\DB\Adapter\DuplicateException; use Magento\Framework\Exception\<API key>; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Model\AbstractModel; use Magento\Framework\Model\ResourceModel\Db\<API key>; use Magento\Framework\Model\ResourceModel\Db\<API key>; use Magento\Eav\Model\ResourceModel\Attribute\<API key>\ProviderInterface as <API key>; use Magento\Framework\Model\ResourceModel\AbstractResource; use Magento\Framework\App\ObjectManager; /** * Entity/Attribute/Model - entity abstract * * @api * @author Magento Core Team <core@magentocommerce.com> * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.<API key>) * @SuppressWarnings(PHPMD.<API key>) * @since 100.0.2 */ abstract class AbstractEntity extends AbstractResource implements EntityInterface, <API key> { /** * @var \Magento\Eav\Model\Entity\<API key> * @since 100.1.0 */ protected $attributeLoader; /** * Connection name * * @var string */ protected $connectionName; /** * Entity type configuration * * @var Type */ protected $_type; /** * Attributes array by attribute name * * @var array */ protected $_attributesByCode = []; /** * Attributes stored by scope (store id and attribute set id). * * @var array */ private $attributesByScope = []; /** * Two-dimensional array by table name and attribute name * * @var array */ protected $_attributesByTable = []; /** * Attributes that are static fields in entity table * * @var array */ protected $_staticAttributes = []; /** * Entity table * * @var string */ protected $_entityTable; /** * Describe data for tables * * @var array */ protected $_describeTable = []; /** * Entity table identification field name * * @var string */ protected $_entityIdField; /** * Entity primary key for link field name * * @var string * @since 100.1.0 */ protected $linkIdField; /** * Entity values table identification field name * * @var string */ protected $_valueEntityIdField; /** * Entity value table prefix * * @var string */ protected $_valueTablePrefix; /** * Entity table string * * @var string */ protected $_entityTablePrefix; /** * Partial load flag * * @var bool */ protected $_isPartialLoad = false; /** * Partial save flag * * @var bool */ protected $_isPartialSave = false; /** * Attribute set id which used for get sorted attributes * * @var int */ protected $_sortingSetId = null; /** * Entity attribute values per backend table to delete * * @var array */ protected $<API key> = []; /** * Entity attribute values per backend table to save * * @var array */ protected $<API key> = []; /** * Array of describe attribute backend tables * The table name as key * * @var array */ protected static $<API key> = []; /** * @var \Magento\Framework\App\ResourceConnection */ protected $_resource; /** * @var \Magento\Eav\Model\Config */ protected $_eavConfig; /** * @var \Magento\Eav\Model\Entity\Attribute\Set */ protected $_attrSetEntity; /** * @var \Magento\Framework\Locale\FormatInterface */ protected $_localeFormat; /** * @var \Magento\Eav\Model\ResourceModel\Helper */ protected $_resourceHelper; /** * @var \Magento\Framework\Validator\UniversalFactory */ protected $_universalFactory; /** * @var <API key> */ protected $transactionManager; /** * @var <API key> */ protected $<API key>; /** * @param Context $context * @param array $data */ public function __construct(Context $context, $data = []) { $this->_eavConfig = $context->getEavConfig(); $this->_resource = $context->getResource(); $this->_attrSetEntity = $context-><API key>(); $this->_localeFormat = $context->getLocaleFormat(); $this->_resourceHelper = $context->getResourceHelper(); $this->_universalFactory = $context->getUniversalFactory(); $this->transactionManager = $context-><API key>(); $this-><API key> = $context-><API key>(); parent::__construct(); $properties = get_object_vars($this); foreach ($data as $key => $value) { if (array_key_exists('_' . $key, $properties)) { $this->{'_' . $key} = $value; } } } /** * Set connections for entity operations * * @param \Magento\Framework\DB\Adapter\AdapterInterface|string $connection * @return $this * @codeCoverageIgnore */ public function setConnection($connection) { $this->connectionName = $connection; return $this; } /** * Resource initialization * * @return void */ protected function _construct() { } /** * Get connection * * @return \Magento\Framework\DB\Adapter\AdapterInterface * @codeCoverageIgnore */ public function getConnection() { return $this->_resource->getConnection(); } /** * For compatibility with AbstractModel * * @return string * @codeCoverageIgnore */ public function getIdFieldName() { return $this->getEntityIdField(); } /** * Retrieve table name * * @param string $alias * @return string * @codeCoverageIgnore */ public function getTable($alias) { return $this->_resource->getTableName($alias); } /** * Set configuration for the entity * * Accepts config node or name of entity type * * @param string|Type $type * @return $this */ public function setType($type) { $this->_type = $this->_eavConfig->getEntityType($type); return $this; } /** * Retrieve current entity config * * @return Type * @throws LocalizedException */ public function getEntityType() { if (empty($this->_type)) { throw new LocalizedException(__('Entity is not initialized')); } return $this->_type; } /** * Get entity type name * * @return string */ public function getType() { return $this->getEntityType()->getEntityTypeCode(); } /** * Get entity type id * * @return int */ public function getTypeId() { return (int) $this->getEntityType()->getEntityTypeId(); } /** * Unset attributes * * If NULL or not supplied removes configuration of all attributes * If string - removes only one, if array - all specified * * @param array|string|null $attributes * @return $this * @throws LocalizedException */ public function unsetAttributes($attributes = null) { if ($attributes === null) { $this->_attributesByCode = []; $this->_attributesByTable = []; return $this; } if (is_string($attributes)) { $attributes = [$attributes]; } if (!is_array($attributes)) { throw new LocalizedException(__('This parameter is unknown. Verify and try again.')); } foreach ($attributes as $attrCode) { if (!isset($this->_attributesByCode[$attrCode])) { continue; } $attr = $this->getAttribute($attrCode); unset($this->_attributesByTable[$attr->getBackend()->getTable()][$attrCode]); unset($this->_attributesByCode[$attrCode]); } return $this; } /** * Get EAV config model * * @return \Magento\Eav\Model\Config */ protected function _getConfig() { return $this->_eavConfig; } /** * Retrieve attribute instance by name, id or config node * * This will add the attribute configuration to entity's attributes cache * * If attribute is not found false is returned * * @param string|int|Element $attribute * @return AbstractAttribute|false * @SuppressWarnings(PHPMD.<API key>) */ public function getAttribute($attribute) { /** @var $config \Magento\Eav\Model\Config */ $config = $this->_getConfig(); if (is_numeric($attribute)) { $attributeId = $attribute; $attributeInstance = $config->getAttribute($this->getEntityType(), $attributeId); if ($attributeInstance) { $attributeCode = $attributeInstance->getAttributeCode(); } } elseif (is_string($attribute)) { $attributeCode = $attribute; $attributeInstance = $config->getAttribute($this->getEntityType(), $attributeCode); if (!$attributeInstance->getAttributeCode() && in_array($attribute, $this-><API key>())) { $attributeInstance->setAttributeCode( $attribute )->setBackendType( AbstractAttribute::TYPE_STATIC )->setIsGlobal( 1 )->setEntity( $this )->setEntityType( $this->getEntityType() )->setEntityTypeId( $this->getEntityType()->getId() ); } } elseif ($attribute instanceof AbstractAttribute) { $attributeInstance = $attribute; $attributeCode = $attributeInstance->getAttributeCode(); } if (empty($attributeInstance) || !$attributeInstance instanceof AbstractAttribute || !$attributeInstance->getId() && !in_array($attributeInstance->getAttributeCode(), $this-><API key>()) ) { return false; } $attribute = $attributeInstance; if (!$attribute->getAttributeCode()) { $attribute->setAttributeCode($attributeCode); } if (!$attribute->getAttributeModel()) { $attribute->setAttributeModel($this-><API key>()); } $this->addAttribute($attribute); return $attribute; } /** * Adding attribute to entity * * @param AbstractAttribute $attribute * @param DataObject|null $object * @return $this */ public function addAttribute(AbstractAttribute $attribute, $object = null) { $attribute->setEntity($this); $attributeCode = $attribute->getAttributeCode(); $this->_attributesByCode[$attributeCode] = $attribute; if ($object !== null) { $suffix = $this-><API key>($object); $this->attributesByScope[$suffix][$attributeCode] = $attribute; } if ($attribute->isStatic()) { $this->_staticAttributes[$attributeCode] = $attribute; } else { $this->_attributesByTable[$attribute->getBackendTable()][$attributeCode] = $attribute; } return $this; } /** * Get attributes by scope * * @return array */ private function <API key>($suffix) { return (isset($this->attributesByScope[$suffix]) && !empty($this->attributesByScope[$suffix])) ? $this->attributesByScope[$suffix] : $this->getAttributesByCode(); } /** * Get attributes cache suffix. * * @param DataObject $object * @return string */ private function <API key>(DataObject $object) { $attributeSetId = $object->getAttributeSetId() ?: 0; $storeId = $object->getStoreId() ?: 0; return $storeId . '-' . $attributeSetId; } /** * Retrieve partial load flag * * @param bool $flag * @return bool */ public function isPartialLoad($flag = null) { $result = $this->_isPartialLoad; if ($flag !== null) { $this->_isPartialLoad = (bool)$flag; } return $result; } /** * Retrieve partial save flag * * @param bool $flag * @return bool */ public function isPartialSave($flag = null) { $result = $this->_isPartialSave; if ($flag !== null) { $this->_isPartialSave = (bool) $flag; } return $result; } /** * Retrieve configuration for all attributes * * @param null|DataObject $object * @return $this */ public function loadAllAttributes($object = null) { return $this->getAttributeLoader()->loadAllAttributes($this, $object); } /** * Retrieve sorted attributes * * @param int $setId * @return array */ public function getSortedAttributes($setId = null) { $attributes = $this->getAttributesByCode(); if ($setId === null) { $setId = $this->getEntityType()-><API key>(); } // initialize set info $this->_attrSetEntity->addSetInfo($this->getEntityType(), $attributes, $setId); foreach ($attributes as $code => $attribute) { /* @var $attribute AbstractAttribute */ if (!$attribute->isInSet($setId)) { unset($attributes[$code]); } } $this->_sortingSetId = $setId; uasort($attributes, [$this, 'attributesCompare']); return $attributes; } /** * Compare attributes * * @param Attribute $firstAttribute * @param Attribute $secondAttribute * @return int */ public function attributesCompare($firstAttribute, $secondAttribute) { $firstSort = $firstAttribute->getSortWeight((int) $this->_sortingSetId); $secondSort = $secondAttribute->getSortWeight((int) $this->_sortingSetId); return $firstSort <=> $secondSort; } /** * Check whether the attribute is Applicable to the object * * @param DataObject $object * @param AbstractAttribute $attribute * @return bool * @SuppressWarnings(PHPMD.<API key>) */ protected function <API key>($object, $attribute) { return true; } /** * Walk through the attributes and run method with optional arguments * * Returns array with results for each attribute * * if $partMethod is in format "part/method" will run method on specified part * for example: $this->walkAttributes('backend/validate'); * * @param string $partMethod * @param array $args * @param null|bool $<API key> * * @throws \Exception|\Magento\Eav\Model\Entity\Attribute\Exception * @return array * @SuppressWarnings(PHPMD.<API key>) * @SuppressWarnings(PHPMD.NPathComplexity) */ public function walkAttributes($partMethod, array $args = [], $<API key> = null) { $methodArr = explode('/', $partMethod); switch (sizeof($methodArr)) { case 1: $part = 'attribute'; $method = $methodArr[0]; break; case 2: $part = $methodArr[0]; $method = $methodArr[1]; break; default: break; } $results = []; $suffix = $this-><API key>($args[0]); foreach ($this-><API key>($suffix) as $attrCode => $attribute) { if (isset($args[0]) && is_object($args[0]) && !$this-><API key>($args[0], $attribute)) { continue; } switch ($part) { case 'attribute': $instance = $attribute; break; case 'backend': $instance = $attribute->getBackend(); break; case 'frontend': $instance = $attribute->getFrontend(); break; case 'source': $instance = $attribute->getSource(); break; default: break; } if (!$this-><API key>($instance, $method, $args)) { continue; } try { $results[$attrCode] = <API key>([$instance, $method], $args); } catch (\Magento\Eav\Model\Entity\Attribute\Exception $e) { if ($<API key>) { $results[$attrCode] = $e->getMessage(); } else { throw $e; } } catch (\Exception $e) { if ($<API key>) { $results[$attrCode] = $e->getMessage(); } else { /** @var \Magento\Eav\Model\Entity\Attribute\Exception $e */ $e = $this->_universalFactory->create( \Magento\Eav\Model\Entity\Attribute\Exception::class, ['phrase' => __($e->getMessage())] ); $e->setAttributeCode($attrCode)->setPart($part); throw $e; } } } return $results; } /** * Check whether attribute instance (attribute, backend, frontend or source) has method and applicable * * @param AbstractAttribute|AbstractBackend|AbstractFrontend|AbstractSource $instance * @param string $method * @param array $args array of arguments * @return bool * @SuppressWarnings(PHPMD.<API key>) */ protected function <API key>($instance, $method, $args) { if (!is_object($instance) || !method_exists($instance, $method) || !is_callable([$instance, $method])) { return false; } return true; } /** * Get attributes by name array * * @return array */ public function getAttributesByCode() { return $this->_attributesByCode; } /** * Get attributes by table and name array * * @return array */ public function <API key>() { return $this->_attributesByTable; } /** * Get entity table name * * @return string */ public function getEntityTable() { if (!$this->_entityTable) { $table = $this->getEntityType()->getEntityTable(); if (!$table) { $table = \Magento\Eav\Model\Entity::<API key>; } $this->_entityTable = $this->_resource->getTableName($table); } return $this->_entityTable; } /** * Get link id * * @return string * @since 100.1.0 */ public function getLinkField() { if (!$this->linkIdField) { $indexList = $this->getConnection()->getIndexList($this->getEntityTable()); $pkName = $this->getConnection()->getPrimaryKeyName($this->getEntityTable()); $this->linkIdField = $indexList[$pkName]['COLUMNS_LIST'][0]; if (!$this->linkIdField) { $this->linkIdField = $this->getEntityIdField(); } } return $this->linkIdField; } /** * Get entity id field name in entity table * * @return string */ public function getEntityIdField() { if (!$this->_entityIdField) { $this->_entityIdField = $this->getEntityType()->getEntityIdField(); if (!$this->_entityIdField) { $this->_entityIdField = \Magento\Eav\Model\Entity::<API key>; } } return $this->_entityIdField; } /** * Get default entity id field name in attribute values tables * * @return string */ public function <API key>() { return $this->getLinkField(); } /** * Get prefix for value tables * * @return string */ public function getValueTablePrefix() { if (!$this->_valueTablePrefix) { $prefix = (string) $this->getEntityType()->getValueTablePrefix(); if (!empty($prefix)) { $this->_valueTablePrefix = $prefix; /** * entity type prefix include DB table name prefix */ //$this->_resource->getTableName($prefix); } else { $this->_valueTablePrefix = $this->getEntityTable(); } } return $this->_valueTablePrefix; } /** * Get entity table prefix for value * * @return string */ public function <API key>() { if (empty($this->_entityTablePrefix)) { $prefix = $this->getEntityType()-><API key>(); if (empty($prefix)) { $prefix = $this->getEntityType()->getEntityTable(); if (empty($prefix)) { $prefix = \Magento\Eav\Model\Entity::<API key>; } } $this->_entityTablePrefix = $prefix; } return $this->_entityTablePrefix; } /** * Check whether the attribute is a real field in entity table * * @see \Magento\Eav\Model\Entity\AbstractEntity::getAttribute for $attribute format * @param int|string|AbstractAttribute $attribute * @return bool */ public function isAttributeStatic($attribute) { $attrInstance = $this->getAttribute($attribute); return $attrInstance && $attrInstance->getBackend()->isStatic(); } /** * Validate all object's attributes against configuration * * @param DataObject $object * @throws \Magento\Eav\Model\Entity\Attribute\Exception * @return true|array */ public function validate($object) { $this->loadAllAttributes($object); $result = $this->walkAttributes('backend/validate', [$object], $object-><API key>()); $errors = []; foreach ($result as $attributeCode => $error) { if ($error === false) { $errors[$attributeCode] = true; } elseif (is_string($error)) { $errors[$attributeCode] = $error; } } if (!$errors) { return true; } return $errors; } /** * Set new increment id to object * * @param DataObject $object * @return $this */ public function setNewIncrementId(DataObject $object) { if ($object->getIncrementId()) { return $this; } $incrementId = $this->getEntityType()->fetchNewIncrementId($object->getStoreId()); if ($incrementId !== false) { $object->setIncrementId($incrementId); } return $this; } /** * Check attribute unique value * * @param AbstractAttribute $attribute * @param DataObject $object * @return bool */ public function <API key>(AbstractAttribute $attribute, $object) { $connection = $this->getConnection(); $select = $connection->select(); $entityIdField = $this->getEntityIdField(); $attributeBackend = $attribute->getBackend(); if ($attributeBackend->getType() === 'static') { $value = $object->getData($attribute->getAttributeCode()); $bind = ['value' => trim($value)]; $select->from( $this->getEntityTable(), $entityIdField )->where( $attribute->getAttributeCode() . ' = :value' ); } else { $value = $object->getData($attribute->getAttributeCode()); if ($attributeBackend->getType() == 'datetime') { $value = (new \DateTime($value))->format('Y-m-d H:i:s'); } $bind = [ 'attribute_id' => $attribute->getId(), 'value' => trim($value), ]; $entityIdField = $object->getResource()->getLinkField(); $select->from( $attributeBackend->getTable(), $entityIdField )->where( 'attribute_id = :attribute_id' )->where( 'value = :value' ); } if ($this->getEntityTable() == \Magento\Eav\Model\Entity::<API key>) { $bind['entity_type_id'] = $this->getTypeId(); $select->where('entity_type_id = :entity_type_id'); } $data = $connection->fetchCol($select, $bind); $objectId = $object->getData($entityIdField); if ($objectId) { if (isset($data[0])) { return $data[0] == $objectId; } return true; } return !count($data); } /** * Retrieve default source model * * @return string */ public function <API key>() { return \Magento\Eav\Model\Entity::<API key>; } /** * Load entity's attributes into the object * * @param AbstractModel $object * @param int $entityId * @param array|null $attributes * @return $this */ public function load($object, $entityId, $attributes = []) { \Magento\Framework\Profiler::start('EAV:load_entity'); /** * Load object base row data */ $object->beforeLoad($entityId); $select = $this->_getLoadRowSelect($object, $entityId); $row = $this->getConnection()->fetchRow($select); if (is_array($row)) { $object->addData($row); $this-><API key>($attributes, $object); $this-><API key>($object); $this->_afterLoad($object); $object->afterLoad(); $object->setOrigData(); $object->setHasDataChanges(false); } else { $object->isObjectNew(true); } \Magento\Framework\Profiler::stop('EAV:load_entity'); return $this; } /** * Loads attributes metadata. * * @deprecated 100.2.0 Use self::<API key> instead * @param array|null $attributes * @return $this * @since 100.1.0 */ protected function <API key>($attributes) { $this-><API key>($attributes); } /** * Load model attributes data * * @param \Magento\Framework\Model\AbstractModel $object * @return $this */ protected function <API key>($object) { if (!$object->getId()) { return $this; } \Magento\Framework\Profiler::start('<API key>'); $selects = []; foreach (array_keys($this-><API key>()) as $table) { $attribute = current($this->_attributesByTable[$table]); $eavType = $attribute->getBackendType(); $select = $this-><API key>($object, $table); $selects[$eavType][] = $select->columns('*'); } $selectGroups = $this->_resourceHelper-><API key>($selects); foreach ($selectGroups as $selects) { if (!empty($selects)) { if (is_array($selects)) { $select = $this->_prepareLoadSelect($selects); } else { $select = $selects; } $values = $this->getConnection()->fetchAll($select); foreach ($values as $valueRow) { $this->_setAttributeValue($object, $valueRow); } } } \Magento\Framework\Profiler::stop('<API key>'); return $this; } /** * Prepare select object for loading entity attributes values * * @param array $selects * @return \Magento\Framework\DB\Select */ protected function _prepareLoadSelect(array $selects) { return $this->getConnection()->select()->union($selects, \Magento\Framework\DB\Select::SQL_UNION_ALL); } /** * Retrieve select object for loading base entity row * * @param DataObject $object * @param string|int $rowId * @return \Magento\Framework\DB\Select * @SuppressWarnings(PHPMD.<API key>) */ protected function _getLoadRowSelect($object, $rowId) { $select = $this->getConnection()->select()->from( $this->getEntityTable() )->where( $this->getEntityIdField() . ' =?', $rowId ); return $select; } /** * Retrieve select object for loading entity attributes values * * @param DataObject $object * @param string $table * @return \Magento\Framework\DB\Select */ protected function <API key>($object, $table) { $select = $this->getConnection()->select()->from( $table, [] )->where( $this->getEntityIdField() . ' =?', $object->getId() ); return $select; } /** * Initialize attribute value for object * * @param DataObject $object * @param array $valueRow * @return $this */ protected function _setAttributeValue($object, $valueRow) { $attribute = $this->getAttribute($valueRow['attribute_id']); if ($attribute) { $attributeCode = $attribute->getAttributeCode(); $object->setData($attributeCode, $valueRow['value']); $attribute->getBackend()->setEntityValueId($object, $valueRow['value_id']); } return $this; } /** * Save entity's attributes into the object's resource * * @param \Magento\Framework\Model\AbstractModel $object * @return $this * @throws \Exception * @throws <API key> */ public function save(\Magento\Framework\Model\AbstractModel $object) { /** * Direct deleted items to delete method */ if ($object->isDeleted()) { return $this->delete($object); } if (!$object->hasDataChanges()) { return $this; } $this->beginTransaction(); try { $object->validateBeforeSave(); $object->beforeSave(); if ($object->isSaveAllowed()) { if (!$this->isPartialSave()) { $this->loadAllAttributes($object); } if ($this->getEntityTable() == \Magento\Eav\Model\Entity::<API key> && !$object->getEntityTypeId() ) { $object->setEntityTypeId($this->getTypeId()); } $object->setParentId((int)$object->getParentId()); $this-><API key>-><API key>($this->getEntityTable(), $object->getData()); $this->_beforeSave($object); $this->processSave($object); $this->_afterSave($object); $object->afterSave(); } $this->addCommitCallback([$object, 'afterCommitCallback'])->commit(); $object->setHasDataChanges(false); } catch (DuplicateException $e) { $this->rollBack(); $object->setHasDataChanges(true); throw new <API key>(__('Unique constraint violation found'), $e); } catch (\Exception $e) { $this->rollBack(); $object->setHasDataChanges(true); throw $e; } return $this; } /** * Save entity process * * @param \Magento\Framework\Model\AbstractModel $object * @return void * @since 100.1.0 */ protected function processSave($object) { $this->_processSaveData($this->_collectSaveData($object)); } /** * Retrieve Object instance with original data * * @param DataObject $object * @return DataObject */ protected function _getOrigObject($object) { $className = get_class($object); $origObject = $this->_universalFactory->create($className); $origObject->setData([]); $this->load($origObject, $object->getData($this->getEntityIdField())); return $origObject; } /** * Aggregate Data for attributes that will be deleted * * @param array &$delete * @param AbstractAttribute $attribute * @param AbstractEntity $object * @return void */ private function <API key>(&$delete, $attribute, $object) { foreach ($attribute->getBackend()->getAffectedFields($object) as $tableName => $valuesData) { if (!isset($delete[$tableName])) { $delete[$tableName] = []; } $delete[$tableName] = array_merge((array)$delete[$tableName], $valuesData); } } /** * Prepare entity object data for save * * Result array structure: * array ( * 'newObject', 'entityRow', 'insert', 'update', 'delete' * ) * * @param \Magento\Framework\Model\AbstractModel $newObject * @return array * @SuppressWarnings(PHPMD.<API key>) * @SuppressWarnings(PHPMD.NPathComplexity) */ protected function _collectSaveData($newObject) { $newData = $newObject->getData(); $entityId = $newObject->getData($this->getEntityIdField()); // define result data $entityRow = []; $insert = []; $update = []; $delete = []; if (!empty($entityId)) { $origData = $newObject->getOrigData(); /** * get current data in db for this entity if original data is empty */ if (empty($origData)) { $origData = $this->_getOrigObject($newObject)->getOrigData(); } if ($origData === null) { $origData = []; } /** * drop attributes that are unknown in new data * not needed after introduction of partial entity loading */ foreach ($origData as $k => $v) { if (!array_key_exists($k, $newData)) { unset($origData[$k]); } } } else { $origData = []; } $staticFields = $this->getConnection()->describeTable($this->getEntityTable()); $staticFields = array_keys($staticFields); $attributeCodes = array_keys($this->_attributesByCode); foreach ($newData as $k => $v) { /** * Check if data key is presented in static fields or attribute codes */ if (!in_array($k, $staticFields) && !in_array($k, $attributeCodes)) { continue; } $attribute = $this->getAttribute($k); if (empty($attribute)) { continue; } if (!$attribute->isInSet($newObject->getAttributeSetId()) && !in_array($k, $staticFields)) { $this-><API key>($delete, $attribute, $newObject); continue; } $attrId = $attribute->getAttributeId(); /** * Only scalar values can be stored in generic tables */ if (!$attribute->getBackend()->isScalar()) { continue; } /** * if attribute is static add to entity row and continue */ if ($this->isAttributeStatic($k)) { $entityRow[$k] = $this->_prepareStaticValue($k, $v); continue; } /** * Check comparability for attribute value */ if ($this->_canUpdateAttribute($attribute, $v, $origData)) { if ($this-><API key>($attribute, $v)) { $this-><API key>($delete, $attribute, $newObject); } elseif (!is_numeric($v) && $v !== $origData[$k] || is_numeric($v) && $v != $origData[$k]) { $update[$attrId] = [ 'value_id' => $attribute->getBackend()->getEntityValueId($newObject), 'value' => is_array($v) ? array_shift($v) : $v,//@TODO: MAGETWO-44182, ]; } } elseif (!$this-><API key>($attribute, $v)) { $insert[$attrId] = is_array($v) ? array_shift($v) : $v;//@TODO: MAGETWO-44182 } } $result = compact('newObject', 'entityRow', 'insert', 'update', 'delete'); return $result; } /** * Return if attribute exists in original data array. * * @param AbstractAttribute $attribute * @param mixed $v New value of the attribute. Can be used in subclasses. * @param array $origData * @return bool * @SuppressWarnings(PHPMD.<API key>) */ protected function _canUpdateAttribute(AbstractAttribute $attribute, $v, array &$origData) { return array_key_exists($attribute->getAttributeCode(), $origData); } /** * Retrieve static field properties * * @param string $field * @return array */ protected function <API key>($field) { if (empty($this->_describeTable[$this->getEntityTable()])) { $this->_describeTable[$this->getEntityTable()] = $this->getConnection()->describeTable( $this->getEntityTable() ); } if (isset($this->_describeTable[$this->getEntityTable()][$field])) { return $this->_describeTable[$this->getEntityTable()][$field]; } return false; } /** * Prepare static value for save * * @param string $key * @param mixed $value * @return mixed */ protected function _prepareStaticValue($key, $value) { $fieldProp = $this-><API key>($key); if (!$fieldProp) { return $value; } if ($fieldProp['DATA_TYPE'] == 'decimal') { $value = $this->_localeFormat->getNumber($value); } return $value; } /** * Save object collected data * * @param array $saveData array('newObject', 'entityRow', 'insert', 'update', 'delete') * @return $this * @SuppressWarnings(PHPMD.<API key>) * @SuppressWarnings(PHPMD.NPathComplexity) */ protected function _processSaveData($saveData) { extract($saveData, EXTR_SKIP); /** * Import variables into the current symbol table from save data array * * @see \Magento\Eav\Model\Entity\AbstractEntity::_collectSaveData() * * @var array $entityRow * @var \Magento\Framework\Model\AbstractModel $newObject * @var array $insert * @var array $update * @var array $delete */ $connection = $this->getConnection(); $insertEntity = true; $entityTable = $this->getEntityTable(); $entityIdField = $this->getEntityIdField(); $entityId = $newObject->getId(); unset($entityRow[$entityIdField]); if (!empty($entityId) && is_numeric($entityId)) { $bind = ['entity_id' => $entityId]; $select = $connection->select()->from($entityTable, $entityIdField)->where("{$entityIdField} = :entity_id"); $result = $connection->fetchOne($select, $bind); if ($result) { $insertEntity = false; } } else { $entityId = null; } /** * Process base row */ $entityObject = new DataObject($entityRow); $entityRow = $this-><API key>($entityObject, $entityTable); if ($insertEntity) { if (!empty($entityId)) { $entityRow[$entityIdField] = $entityId; $connection->insertForce($entityTable, $entityRow); } else { $connection->insert($entityTable, $entityRow); $entityId = $connection->lastInsertId($entityTable); } $newObject->setId($entityId); } else { $where = sprintf('%s=%d', $connection->quoteIdentifier($entityIdField), $entityId); $connection->update($entityTable, $entityRow, $where); } /** * insert attribute values */ if (!empty($insert)) { foreach ($insert as $attributeId => $value) { $attribute = $this->getAttribute($attributeId); $this->_insertAttribute($newObject, $attribute, $value); } } /** * update attribute values */ if (!empty($update)) { foreach ($update as $attributeId => $v) { $attribute = $this->getAttribute($attributeId); $this->_updateAttribute($newObject, $attribute, $v['value_id'], $v['value']); } } /** * delete empty attribute values */ if (!empty($delete)) { foreach ($delete as $table => $values) { $this->_deleteAttributes($newObject, $table, $values); } } $this-><API key>(); $newObject->isObjectNew(false); return $this; } /** * Insert entity attribute value * * @param DataObject $object * @param AbstractAttribute $attribute * @param mixed $value * @return $this */ protected function _insertAttribute($object, $attribute, $value) { return $this->_saveAttribute($object, $attribute, $value); } /** * Update entity attribute value * * @param DataObject $object * @param AbstractAttribute $attribute * @param mixed $valueId * @param mixed $value * @return $this * @SuppressWarnings(PHPMD.<API key>) */ protected function _updateAttribute($object, $attribute, $valueId, $value) { return $this->_saveAttribute($object, $attribute, $value); } /** * Save entity attribute value * * Collect for mass save * * @param \Magento\Framework\Model\AbstractModel $object * @param AbstractAttribute $attribute * @param mixed $value * @return $this */ protected function _saveAttribute($object, $attribute, $value) { $table = $attribute->getBackend()->getTable(); if (!isset($this-><API key>[$table])) { $this-><API key>[$table] = []; } $entityIdField = $attribute->getBackend()->getEntityIdField(); $data = [ $entityIdField => $object->getId(), 'attribute_id' => $attribute->getId(), 'value' => $this-><API key>($value, $attribute), ]; if (!$this->getEntityTable() || $this->getEntityTable() == \Magento\Eav\Model\Entity::<API key>) { $data['entity_type_id'] = $object->getEntityTypeId(); } $this-><API key>[$table][] = $data; return $this; } /** * Save and delete collected attribute values * * @return $this */ protected function <API key>() { $connection = $this->getConnection(); foreach ($this-><API key> as $table => $data) { $connection->insertOnDuplicate($table, $data, ['value']); } foreach ($this-><API key> as $table => $valueIds) { $connection->delete($table, ['value_id IN (?)' => $valueIds]); } // reset data arrays $this-><API key> = []; $this-><API key> = []; return $this; } /** * Prepare value for save * * @param mixed $value * @param AbstractAttribute $attribute * @return mixed */ protected function <API key>($value, AbstractAttribute $attribute) { $type = $attribute->getBackendType(); if (($type == 'int' || $type == 'decimal' || $type == 'datetime') && $value === '') { $value = null; } elseif ($type == 'decimal') { $value = $this->_localeFormat->getNumber($value); } $backendTable = $attribute->getBackendTable(); if (!isset(self::$<API key>[$backendTable])) { self::$<API key>[$backendTable] = $this->getConnection()->describeTable($backendTable); } $describe = self::$<API key>[$backendTable]; return $this->getConnection()->prepareColumnValue($describe['value'], $value); } /** * Delete entity attribute values * * @param DataObject $object * @param string $table * @param array $info * @return DataObject * @SuppressWarnings(PHPMD.<API key>) */ protected function _deleteAttributes($object, $table, $info) { $valueIds = []; foreach ($info as $itemData) { $valueIds[] = $itemData['value_id']; } if (empty($valueIds)) { return $this; } if (isset($this-><API key>[$table])) { $this-><API key>[$table] = array_merge($this-><API key>[$table], $valueIds); } else { $this-><API key>[$table] = $valueIds; } return $this; } /** * Save attribute * * @param DataObject $object * @param string $attributeCode * @return $this * @throws \Exception * @SuppressWarnings(PHPMD.<API key>) */ public function saveAttribute(DataObject $object, $attributeCode) { $attribute = $this->getAttribute($attributeCode); $backend = $attribute->getBackend(); $table = $backend->getTable(); $entity = $attribute->getEntity(); $connection = $this->getConnection(); $row = $this->getAttributeRow($entity, $object, $attribute); $newValue = $object->getData($attributeCode); if ($attribute->isValueEmpty($newValue)) { $newValue = null; } $whereArr = []; foreach ($row as $field => $value) { $whereArr[] = $connection->quoteInto($field . '=?', $value); } $where = implode(' AND ', $whereArr); $connection->beginTransaction(); try { $select = $connection->select()->from($table, 'value_id')->where($where); $origValueId = $connection->fetchOne($select); if ($origValueId === false && $newValue !== null) { $this->_insertAttribute($object, $attribute, $newValue); } elseif ($origValueId !== false && $newValue !== null) { $this->_updateAttribute($object, $attribute, $origValueId, $newValue); } elseif ($origValueId !== false && $newValue === null) { $connection->delete($table, $where); } $this-><API key>(); $connection->commit(); } catch (\Exception $e) { $connection->rollBack(); throw $e; } return $this; } /** * Return attribute row to prepare where statement * * @param DataObject $entity * @param DataObject $object * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute * @return array */ protected function getAttributeRow($entity, $object, $attribute) { $data = [ 'attribute_id' => $attribute->getId(), $this->getLinkField() => $object->getData($this->getLinkField()), ]; if (!$this->getEntityTable()) { $data['entity_type_id'] = $entity->getTypeId(); } return $data; } /** * Delete entity using current object's data * * @param DataObject|int|string $object * @return $this * @throws \Exception * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public function delete($object) { try { $connection = $this->transactionManager->start($this->getConnection()); if (is_numeric($object)) { $id = (int) $object; } elseif ($object instanceof \Magento\Framework\Model\AbstractModel) { $object->beforeDelete(); $id = (int) $object->getData($this->getLinkField()); } $this->_beforeDelete($object); $this->evaluateDelete( $object, $id, $connection ); $this->_afterDelete($object); if ($object instanceof \Magento\Framework\Model\AbstractModel) { $object->isDeleted(true); $object->afterDelete(); } $this->transactionManager->commit(); if ($object instanceof \Magento\Framework\Model\AbstractModel) { $object->afterDeleteCommit(); } } catch (\Exception $e) { $this->transactionManager->rollBack(); throw $e; } return $this; } /** * Evaluate Delete operations * * @param DataObject|int|string $object * @param string|int $id * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection * @return void * @throws \Exception * @SuppressWarnings(PHPMD.UnusedLocalVariable) * @since 100.1.0 */ protected function evaluateDelete($object, $id, $connection) { $where = [$this->getEntityIdField() . '=?' => $id]; $this-><API key>->delete( $this->transactionManager, $connection, $this->getEntityTable(), $this->getConnection()->quoteInto( $this->getEntityIdField() . '=?', $id ), [$this->getEntityIdField() => $id] ); $this->loadAllAttributes($object); foreach ($this-><API key>() as $table => $attributes) { $this->getConnection()->delete( $table, $where ); } } /** * After Load Entity process * * @param DataObject $object * @return $this */ protected function _afterLoad(DataObject $object) { \Magento\Framework\Profiler::start('after_load'); $this->walkAttributes('backend/afterLoad', [$object]); \Magento\Framework\Profiler::stop('after_load'); return $this; } /** * Before delete Entity process * * @param DataObject $object * @return $this */ protected function _beforeSave(DataObject $object) { $this->walkAttributes('backend/beforeSave', [$object]); return $this; } /** * After Save Entity process * * @param DataObject $object * @return $this */ protected function _afterSave(DataObject $object) { $this->walkAttributes('backend/afterSave', [$object]); return $this; } /** * Before Delete Entity process * * @param DataObject $object * @return $this */ protected function _beforeDelete(DataObject $object) { $this->walkAttributes('backend/beforeDelete', [$object]); return $this; } /** * After delete entity process * * @param DataObject $object * @return $this */ protected function _afterDelete(DataObject $object) { $this->walkAttributes('backend/afterDelete', [$object]); return $this; } /** * Retrieve Default attribute model * * @return string */ protected function <API key>() { return \Magento\Eav\Model\Entity::<API key>; } /** * Retrieve default entity attributes * * @return string[] */ protected function <API key>() { return ['entity_type_id', 'attribute_set_id', 'created_at', 'updated_at', 'parent_id', 'increment_id']; } /** * Retrieve default entity static attributes * * @return string[] */ public function <API key>() { return array_unique(array_merge( $this-><API key>(), [$this->getEntityIdField(), $this->getLinkField()] )); } /** * Check is attribute value empty * * @param AbstractAttribute $attribute * @param mixed $value * @return bool */ protected function <API key>(AbstractAttribute $attribute, $value) { return $attribute->isValueEmpty($value); } /** * The getter function to get the <API key> * * @return <API key> * * @deprecated 100.1.0 * @since 100.1.0 */ protected function getAttributeLoader() { if ($this->attributeLoader === null) { $this->attributeLoader= ObjectManager::getInstance()->get(<API key>::class); } return $this->attributeLoader; } /** * Perform actions after entity load * * @param DataObject $object * @since 100.1.0 */ public function afterLoad(DataObject $object) { $this->_afterLoad($object); } /** * Perform actions before entity save * * @param DataObject $object * @since 100.1.0 */ public function beforeSave(DataObject $object) { $this->_beforeSave($object); } /** * Perform actions after entity save * * @param DataObject $object * @since 100.1.0 */ public function afterSave(DataObject $object) { $this->_afterSave($object); } /** * Perform actions before entity delete * * @param DataObject $object * @since 100.1.0 */ public function beforeDelete(DataObject $object) { $this->_beforeDelete($object); } /** * Perform actions after entity delete * * @param DataObject $object * @since 100.1.0 */ public function afterDelete(DataObject $object) { $this->_afterDelete($object); } /** * Load attributes for object * if the object will not pass all attributes for this entity type will be loaded * * @param array $attributes * @param AbstractEntity|null $object * @return void * @since 100.2.0 */ protected function <API key>($attributes, $object = null) { if (empty($attributes)) { $this->loadAllAttributes($object); } else { if (!is_array($attributes)) { $attributes = [$attributes]; } foreach ($attributes as $attrCode) { $this->getAttribute($attrCode); } } } }
package com.thedarkera.handler; import com.thedarkera.api.systems.scoring.ScoreStat; import com.thedarkera.init.TDEAchievements; import com.thedarkera.init.TDEBiomes; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.<API key>; public class EnterBiomeHandler { @SubscribeEvent public void enterBiome(<API key> event) { // Item item = event.player.getHeldItem().getItem(); World world = event.player.worldObj; EntityPlayer player = event.player; int x = (int) player.posX; int z = (int) player.posZ; String x1 = ""+x; String z1 = ""+z; player.addChatMessage(new ChatComponentText(x1 + " _ " + z1)); BiomeGenBase biome = world.<API key>().getBiomeGenAt(x, z); if (biome == TDEBiomes.dark_forest) { player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_GRAY + "You entered the Dark Forrest biome")); AchievementHandler.setAchieved(TDEAchievements.biome); ScoreStat.addScore(1); } if (biome == TDEBiomes.dark_jungle) { player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_GRAY + "You entered the Dark Jungle biome")); AchievementHandler.setAchieved(TDEAchievements.biome1); ScoreStat.addScore(1); } /*if (biome == TDEBiomes.dark_plains) { player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_GRAY + "You entered the Dark Plains biome")); AchievementHandler.setAchieved(TDEAchievements.biome2); ScoreStat.addScore(1); }*/ if (biome == TDEBiomes.dark_hills) { player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_GRAY + "You entered the Dark Hills biome")); AchievementHandler.setAchieved(TDEAchievements.biome3); ScoreStat.addScore(1); } if (biome == TDEBiomes.dead_land) { player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_GRAY + "You entered the Dead Land biome")); AchievementHandler.setAchieved(TDEAchievements.biome4); ScoreStat.addScore(1); } if (biome == TDEBiomes.dark_ocean) { player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_GRAY + "You entered the Dark Ocean biome")); AchievementHandler.setAchieved(TDEAchievements.biome5); ScoreStat.addScore(1); } if (biome == TDEBiomes.dark_land) { player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_GRAY + "You entered the Dark Land biome")); AchievementHandler.setAchieved(TDEAchievements.biome6); ScoreStat.addScore(1); } if (biome == TDEBiomes.ancient_land) { player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_GRAY + "You entered the Ancient Land biome")); AchievementHandler.setAchieved(TDEAchievements.biome7); ScoreStat.addScore(1); } if (biome == TDEBiomes.misty_mountains) { player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_GRAY + "You entered the Misty Mountains biome")); AchievementHandler.setAchieved(TDEAchievements.biome8); ScoreStat.addScore(1); } /*if (biome == TDEBiomes.magical_forrest) { player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_GRAY + "You entered the Magical Forrest biome")); AchievementHandler.setAchieved(TDEAchievements.biome9); ScoreStat.addScore(1); }*/ /*if (biome == TDEBiomes.dark_roofed_forrest) { player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_GRAY + "You entered the Dark Roofed Forrest biome")); AchievementHandler.setAchieved(TDEAchievements.biome10); ScoreStat.addScore(1); }*/ } }
using System; using System.Collections.Generic; using HL7Lib.Base; namespace HL7Lib.Segments { <summary> AUT Class: Constructs an HL7 AUT Segment Object </summary> public class AUT { public string Name { get; set; } public string Description { get; set; } public List<Field> Fields { get; set; } public AUT() { Name = "AUT"; Description = "Authorization Information"; List<Field> fs = new List<Field>(); fs.Add(Field.SegName()); fs.Add(AUT1()); fs.Add(AUT2()); fs.Add(AUT3()); fs.Add(AUT4()); fs.Add(AUT5()); fs.Add(AUT6()); fs.Add(AUT7()); fs.Add(AUT8()); fs.Add(AUT9()); fs.Add(AUT10()); Fields = fs; } private Field AUT1() { Field f = new Field("Authorizing Payor, Plan ID"); List<Component> c = new List<Component>(); c.Add(new Component("Identifier", "AUT-1.1")); c.Add(new Component("", "AUT-1.2")); c.Add(new Component("Name of Coding System", "AUT-1.3")); c.Add(new Component("Alternate Identifier", "AUT-1.4")); c.Add(new Component("Alternate Text", "AUT-1.5")); c.Add(new Component("Name of Alternate Coding System", "AUT-1.6")); f.Components = c; return f; } private Field AUT2() { Field f = new Field("Authorizing Payor, Company ID"); List<Component> c = new List<Component>(); c.Add(new Component("Identifier", "AUT-2.1")); c.Add(new Component("", "AUT-2.2")); c.Add(new Component("Name of Coding System", "AUT-2.3")); c.Add(new Component("Alternate Identifier", "AUT-2.4")); c.Add(new Component("Alternate Text", "AUT-2.5")); c.Add(new Component("Name of Alternate Coding System", "AUT-2.6")); f.Components = c; return f; } private Field AUT3() { Field f = new Field("Authorizing Payor, Company Name"); List<Component> c = new List<Component>(); c.Add(new Component("", "AUT-3.1")); f.Components = c; return f; } private Field AUT4() { Field f = new Field("Authorization Effective Date"); List<Component> c = new List<Component>(); c.Add(new Component("Time", "AUT-4.1")); c.Add(new Component("Degree of Precision", "AUT-4.2")); f.Components = c; return f; } private Field AUT5() { Field f = new Field("Authorization Expiration Date"); List<Component> c = new List<Component>(); c.Add(new Component("Time", "AUT-5.1")); c.Add(new Component("Degree of Precision", "AUT-5.2")); f.Components = c; return f; } private Field AUT6() { Field f = new Field("Authorization Identifier"); List<Component> c = new List<Component>(); c.Add(new Component("Entity Identifier", "AUT-6.1")); c.Add(new Component("Namespace ID", "AUT-6.2")); c.Add(new Component("Universal ID", "AUT-6.3")); c.Add(new Component("Universal ID Type", "AUT-6.4")); f.Components = c; return f; } private Field AUT7() { Field f = new Field("Reimbursement Limit"); List<Component> c = new List<Component>(); c.Add(new Component("Price", "AUT-7.1")); c.Add(new Component("Price Type", "AUT-7.2")); c.Add(new Component("From Value", "AUT-7.3")); c.Add(new Component("To Value", "AUT-7.4")); c.Add(new Component("Range Units", "AUT-7.5")); c.Add(new Component("Range Type", "AUT-7.6")); f.Components = c; return f; } private Field AUT8() { Field f = new Field("Requested Number of Treatments"); List<Component> c = new List<Component>(); c.Add(new Component("", "AUT-8.1")); f.Components = c; return f; } private Field AUT9() { Field f = new Field("Authorized Number of Treatments"); List<Component> c = new List<Component>(); c.Add(new Component("", "AUT-9.1")); f.Components = c; return f; } private Field AUT10() { Field f = new Field("Process Date"); List<Component> c = new List<Component>(); c.Add(new Component("Time", "AUT-10.1")); c.Add(new Component("Degree of Precision", "AUT-10.2")); f.Components = c; return f; } } }
package com.oracle.graal.nodes.extended; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; /** * The {@code SwitchNode} class is the base of both lookup and table switches. */ public abstract class SwitchNode extends ControlSplitNode { @Successor private final NodeSuccessorList<BeginNode> successors; @Input private ValueNode value; // do not change the contents of these arrays: private final double[] keyProbabilities; private final int[] keySuccessors; /** * Constructs a new Switch. * * @param value the instruction that provides the value to be switched over * @param successors the list of successors of this switch */ public SwitchNode(ValueNode value, BeginNode[] successors, int[] keySuccessors, double[] keyProbabilities) { super(StampFactory.forVoid()); assert value.getKind() == Kind.Int || value.getKind() == Kind.Long || value.getKind() == Kind.Object : value.getKind() + " key not supported by SwitchNode"; assert keySuccessors.length == keyProbabilities.length; this.successors = new NodeSuccessorList<>(this, successors); this.value = value; this.keySuccessors = keySuccessors; this.keyProbabilities = keyProbabilities; assert assertProbabilities(); } private boolean assertProbabilities() { double total = 0; for (double d : keyProbabilities) { total += d; assert d >= 0.0 : "Cannot have negative probabilities in switch node: " + d; } assert total > 0.999 && total < 1.001 : "Total " + total; return true; } protected boolean assertValues() { Kind kind = value.getKind(); for (int i = 0; i < keyCount(); i++) { Constant key = keyAt(i); assert key.getKind() == kind; } return true; } @Override public double probability(BeginNode successor) { double sum = 0; for (int i = 0; i < keySuccessors.length; i++) { if (successors.get(keySuccessors[i]) == successor) { sum += keyProbabilities[i]; } } return sum; } public ValueNode value() { return value; } public abstract boolean isSorted(); /** * The number of distinct keys in this switch. */ public abstract int keyCount(); /** * The key at the specified position, encoded in a Constant. */ public abstract Constant keyAt(int i); /** * Returns true if the switch has the same keys in the same order as this switch. */ public abstract boolean equalKeys(SwitchNode switchNode); /** * Returns the index of the successor belonging to the key at the specified index. */ public int keySuccessorIndex(int i) { return keySuccessors[i]; } /** * Returns the successor for the key at the given index. */ public BeginNode keySuccessor(int i) { return successors.get(keySuccessors[i]); } /** * Returns the probability of the key at the given index. */ public double keyProbability(int i) { return keyProbabilities[i]; } /** * Returns the index of the default (fall through) successor of this switch. */ public int <API key>() { return keySuccessors[keySuccessors.length - 1]; } public BeginNode blockSuccessor(int i) { return successors.get(i); } public void setBlockSuccessor(int i, BeginNode s) { successors.set(i, s); } public int blockSuccessorCount() { return successors.count(); } /** * Gets the successor corresponding to the default (fall through) case. * * @return the default successor */ public BeginNode defaultSuccessor() { if (<API key>() == -1) { throw new GraalInternalError("unexpected"); } return <API key>() == -1 ? null : successors.get(<API key>()); } }
import commands import sys import postproc_yt as pp import os import shutil targetdir = sys.argv[1] timestep = float(sys.argv[2]) face = float(sys.argv[3]) level = float(sys.argv[4]) ppdir = os.getenv('PPDIR') outdir = os.getenv('PPOUTDIR') D = pp.FileSetup(targetdir, face=face, level=level, timestep=timestep, ppdir=ppdir) #pp.ProblemSetup(D['FileName'], face = face, dust_temp = D['GasTemp']) os.chdir(D['TempDir']) command = ppdir + 'radmc3d image npix ' + \ str(int(D['GridSize'])) + \ ' iline 1 widthkms 10 linenlam 500 loadlambda fluxcons inclline linelist nostar writepop doppcatch sizepc 10 norefine' print(command) result = commands.getoutput(command) print(result) save_name = os.path.join(outdir, D['FileName'][17:-5] + '_radmc.fits') pp.MakeFits(fitsfile=save_name, dpc=260.0, toK=True) shutil.move(save_name, outdir) shutil.rmtree(D['TempDir'])
! ! Copyright (C) 2001-2009 Quantum ESPRESSO group ! This file is distributed under the terms of the ! GNU General Public License. See the file `License' ! in the root directory of the present distribution, ! or http: ! ! program <API key> !! use mp, ONLY : mp_get, mp_barrier use mp_global, ONLY : mp_startup, mp_global_end use mp_world, ONLY : world_comm, nproc, mpime use kinds, ONLY : dp use io_global, ONLY : ionode, ionode_id use constants, ONLY : pi !! implicit none !! These are the user set-able parameters. integer, parameter :: Nr_points = 1024 !! The number of radial points (also the number of k points) used real(dp), parameter :: r_max =100.0D0 !! The value of the maximum radius to use for the real-space kernel functions !! CHARACTER(LEN=30) :: double_format = "(1p4e23.14)" !! integer, parameter :: Nqs = 20 !! !! real(dp), dimension(Nqs):: q_mesh = (/ 1.0D-4, 1.0D-3, 2.180901130847297D-3, 3.730376109554437D-3, & !! 5.763461392415386D-3, 8.431097736459265D-3, 1.193133637576012D-2, 1.652404278396654D-2, & !! 2.255018966296721D-2, 3.045717151192698D-2, 4.083202018639992D-2, 5.444498744423845D-2, & !! 7.230673014309263D-2, 9.574334364529304D-2, 0.126494814076381D0, 0.166844198751147D0, & !! 0.219787125408285D0, 0.289254194252484D0, 0.380402794424442D0, 0.5D0 /) !! integer, parameter :: Nqs = 20 real(dp), dimension(Nqs):: q_mesh = (/ 1.0D-4, 3.0D-4, 5.893850845618885D-4, 1.008103720396345D-3, & 1.613958359589310D-3, 2.490584839564653D-3, 3.758997979748929D-3, 5.594297198907115D-3, & 8.249838297569416D-3, 1.209220822453922D-2, 1.765183095571029D-2, 2.569619042667097D-2, & 3.733577865542191D-2, 5.417739477463518D-2, 7.854595729872216D-2, 0.113805449932145D0, & 0.164823306218807D0, 0.238642339497217D0, 0.345452975434964D0, 0.5D0 /) !! integer, parameter :: Nqs = 20 !! !! real(dp), dimension(Nqs):: q_mesh = (/ 1.0D-4, 5.0D-3, 1.069893648719707D-2, 1.732707466783098D-2, & !! 2.503591926370824D-2, 3.400167757831576D-2, 4.442928720984789D-2, 5.655710047584504D-2, & !! 7.066233262513155D-2, 8.706739837124464D-2, 0.106147281586631D0, 0.128338106612676D0, & !! 0.154147107106948D0, 0.184164220293662D0, 0.219075571636537D0, 0.259679158164142D0, & !! 0.306903088934189D0, 0.361826799573841D0, 0.425705725813956D0, 0.5D0 /) !! !! !! !! integer, parameter :: Nqs = 20 !! !! real(dp), dimension(Nqs):: q_mesh = (/ 1.0D-4, 1.0D-3, 2.236206697581317D-3, 3.934214474408992D-3, & !! 6.266535125808476D-3, 9.470124470438768D-3, 1.387045625280778D-2, 1.991458916496835D-2, & !! 2.821658648395121D-2, 3.961990280509427D-2, 5.528307615046694D-2, 7.679743147816347D-2, & !! 0.106348753867322D0, 0.146939356822725D0, 0.202693107080873D0, 0.279274395396871D0, & !! 0.384463619314253D0, 0.528947645003195D0, 0.727405556392285D0, 1.0D0 /) !! !! !! integer, parameter :: Nqs = 20 !! !! real(dp), dimension(Nqs):: q_mesh = (/ 1.0D-4, 5.0D-4, 1.078773837542156D-3, 1.916221725100339D-3, & !! 3.127954044159392D-3, 4.881251455098552D-3, 7.418158132303510D-3, 1.108889616493409D-2, & !! 1.640021400932794D-2, 2.408534353734285D-2, 3.520522330968714D-2, 5.129496203180489D-2, & !! 7.457576159493165D-2, 0.108261555855433D0, 0.157002696892448D0, 0.227527940002890D0, & !! 0.329573353999449D0, 0.477226393655365D0, 0.690870684621412D0, 1.0D0 /) !! !! DO NOT CHANGE ANYTHING BELOW THIS LINE !! integer :: q1_i, q2_i, r_i, count !! Indexing variables real(dp) :: dr, d1, d2 !! Intermediate values real(dp) :: gamma = 4.0D0*pi/9.0D0 !! Multiplicative factor for exponent in the functions called ! !! "h" in DION real(dp), parameter :: small = 1.0D-15 !! Number at which to employ special algorithms to avoid numerical ! !! problems. This is probably not needed but I like to be careful. !! The following sets up a parallel run. !! integer :: my_start_q, my_end_q, Ntotal !! starting and ending q value for each processor, also the total number of ! !! calculations to do ( (Nqs^2 + Nqs)/2 ) real(dp), allocatable :: phi(:,:), d2phi_dk2(:,:) !! Arrays to store the kernel functions and their second derivatives. They are ! !! stored as phi(radial_point, index) integer, allocatable :: indices(:,:), proc_indices(:,:) !! indices holds the values of q1 and q2 as partitioned out to the processors. It is an ! !! Ntotal x 2 array stored as indices(index of point number, q1:q2). ! !! Proc_indices holds the section of the indices array that is assigned to each processor. ! !! This is a Nprocs x 2 array, stored as proc_indices(processor number, starting_index:ending_index) integer :: Nper, Nextra, start_q, end_q !! Baseline number of jobs per processor, number of processors that get an extra job in case the ! !! number of jobs doesn't split evenly over the number of processors, starting index into the ! !! indices array, ending index into the indices array. integer :: index, proc_i, kernel_file, my_Nqs integer :: Nprocs, my_rank, group_id !! Variables holding information about the parallel run. The total number of processors, the rank of ! !! this particular processor, and a group id. These are given to the mp_global module and its internal ! !! variables are used in most of this code. ! Set up the parallel run using PWSCF methods. ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ !! Start a parallel run call mp_startup () !call mp_start(Nprocs, my_rank, group_id) !! This calls mpoi_init, figures out the total number of processors, !! the index of this particular processor, and a group id for mpi_comm_world !call io_global_start(my_rank, 0) !! This sets processor 0 to be the input/output node. This is assumed below during the output stage !call mp_global_start(0, my_rank, group_id, Nprocs) !! Pass parameters to the mp_global module. Its internal parameters are used hereafter. ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ! The total number of phi_alpha_beta functions that have to be calculated Ntotal = (Nqs**2 + Nqs)/2 allocate( indices(Ntotal, 2) ) count = 1 ! This part fills in the indices array. It just loops through the q1 and q2 values and stores them. Sections ! of this array will be assigned to each of the processors later. ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ do q1_i = 1, Nqs do q2_i = 1, q1_i indices(count, 1) = q1_i indices(count, 2) = q2_i count = count + 1 end do end do ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ! Figure out the baseline number of functions to be calculated by each processor and how many processors get 1 extra job. Nper = Ntotal/nproc Nextra = mod(Ntotal, nproc) allocate(proc_indices(nproc,2) ) start_q = 0 end_q = 0 ! Loop over all the processors and figure out which section of the indices array each processor should do. All processors ! figure this out for every processor so there is no need to communicate results. ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ do proc_i = 1, nproc start_q = end_q + 1 end_q = start_q + (Nper - 1) if (proc_i <= Nextra) end_q = end_q + 1 if (proc_i == (mpime+1)) then my_start_q = start_q my_end_q = end_q end if proc_indices(proc_i, 1) = start_q proc_indices(proc_i, 2) = end_q end do ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ! Store how many jobs are assigned to me my_Nqs = my_end_q - my_start_q + 1 !! allocate( phi(0:Nr_points, my_Nqs), d2phi_dk2(0:Nr_points, my_Nqs) ) phi = 0.0D0 d2phi_dk2 = 0.0D0 dr = (r_max)/(Nr_points) !! Now, we loop over all the pairs q1,q2 that are assigned to us and perform our calculations !! do index = 1, my_Nqs ! First, get the value of phi(q1*r, q2*r) for each r and the particular values of q1 and q2 we are using ! +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ do r_i = 1, Nr_points d1 = q_mesh(indices(index+my_start_q-1, 1)) * (dr * r_i)**2 !! Different definition of d1 and d2 for vv10 !!!! d2 = q_mesh(indices(index+my_start_q-1, 2)) * (dr * r_i)**2 !! Different definition of d1 and d2 for vv10 !!!! phi(r_i, index) = phi_value(d1, d2) end do ! +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ! Now, perform a radial FFT to turn our phi_alpha_beta(r) into phi_alpha_beta(k) needed for SOLER ! equation 11 call radial_fft( phi(:,index) ) ! Determine the spline interpolation coefficients for the Fourier transformed kernel function call set_up_splines( phi(:, index), d2phi_dk2(:, index) ) end do !! !! Finally, we write out the results, after letting everybody catch up !! call mp_barrier(world_comm) call <API key>(phi, d2phi_dk2) !! !! Finalize the mpi run using the PWSCF method call mp_global_end( ) deallocate( phi, d2phi_dk2, indices, proc_indices ) CONTAINS !! !! | | !! | SET UP SPLINES | !! |__________________| !! This subroutine accepts a function (phi) and finds at each point the second derivative (D2) for use with !! spline interpolation. This function assumes we are using the expansion described in SOLER 3 and 4. That !! is, the derivatives are those needed to interpolate Kronecker delta functions at each of the q values !! Other than some special modification to speed up the algorithm in our particular case, this algorithm is !! taken directly from NUMERICAL_RECIPES pages 96-97. subroutine set_up_splines(phi, D2) real(dp), intent(in) :: phi(0:Nr_points) !! The k-space kernel function for a particular q1 and q2 real(dp), intent(inout) :: D2(0:Nr_points) !! The second derivatives to be used in the interpolation ! !! expansion (SOLER equation 3) real(dp), save :: dk = 2.0D0*pi/r_max !! Spacing of k points real(dp), allocatable :: temp_array(:) !! Temporary storage real(dp) :: temp_1, temp_2 !! allocate( temp_array(0:Nr_points) ) D2 = 0 temp_array = 0 do r_i = 1, Nr_points - 1 temp_1 = dble(r_i - (r_i - 1))/dble( (r_i + 1) - (r_i - 1) ) temp_2 = temp_1 * D2(r_i-1) + 2.0D0 D2(r_i) = (temp_1 - 1.0D0)/temp_2 temp_array(r_i) = ( phi(r_i+1) - phi(r_i))/dble( dk*((r_i+1) - r_i) ) - & ( phi(r_i) - phi(r_i-1))/dble( dk*(r_i - (r_i-1)) ) temp_array(r_i) = (6.0D0*temp_array(r_i)/dble( dk*((r_i+1) - (r_i-1)) )-temp_1*temp_array(r_i-1))/temp_2 end do D2(Nr_points) = 0.0D0 do r_i = Nr_points-1, 0, -1 D2(r_i) = D2(r_i)*D2(r_i+1) + temp_array(r_i) end do deallocate( temp_array ) end subroutine set_up_splines !! !! !! | | !! | PHI_VALUE | !! |_____________| !! vv10 kernel phi real(dp) function phi_value(d1, d2) real(dp), intent(in) :: d1, d2 !! The point at which to evaluate the kernel. Note that ! !! d1 = q1*r^2 and d2 = q2*r^2 phi_value = - 24.0D0 / ( ( d1 + 1.0 ) * ( d2 + 1.0 ) * ( d1 + d2 + 2.0 ) ) return end function phi_value !! !! | | !! | <API key> | !! |<API key>| !! Subroutine to write out the vdW_kernel_table file. All processors pass their data to processor 0 which !! is the one that actually does the writing. This is the only communication in the entire program. subroutine <API key>(phi, d2phi_dk2) real(dp), target :: phi(:,:), d2phi_dk2(:,:) !! Each processor passes in its array of kernel values and second ! !! derivative values for the q-pairs it calculated. They are stored ! !! as phi(index of function, function_values) integer :: proc_Nqs !! Number of calculated functions for a particular processor real(dp), pointer :: data(:,:) !! Pointer to point to the needed section of the phi and d2phi_dk2 ! !! arrays. This is needed because some processors may have calculated ! !! 1 extra function if the number of processors is not an even divisor ! !! of (Nqs^2+Nqs)/2. Processor 0 is guaranteed to be one of the ones ! !! with an extra calculation (if there are any), so it can collect the ! !! arrays from other processors and put it in its array. Data then ! !! points to either the entire array (if the other processor also had ! !! an extra calculation), or just the first proc_Nqs entries (which is ! !! guaranteed to be at most 1 less than the proc_Nqs for processor 0. if (ionode) then !! Open the file for writing. The file is written in binary to save space. !open(UNIT=21, FILE='vdW_kernel_table', status='replace', form='unformatted', action='write') open(UNIT=21, FILE='rVV10_kernel_table', status='replace', form='formatted', action='write') !! Write the relevant header information that will be read in by the kernel_table module !! !write(*) "Writing headers..." write(21, '(2i5,f13.8)') Nqs, Nr_points write(21, double_format) r_max write(21, double_format) q_mesh !! !! Processor 0 writes its kernel functions first. The subroutine "write_data" is defined !! below. !! !write(*) "Writing phi proc ", 0 data => phi(:,:) call write_data(21, data) !! end if !! Now, loop over all other processors (if any) and collect their kernel functions in the phi !! array of processor 0, which is big enough to hold any of them. Figure out how many functions !! should have been passed and make data point to just the right amount of the phi array. Then !! write the data. !! do proc_i = 1, nproc-1 call mp_get(phi, phi, mpime, 0, proc_i, 0, world_comm) if (ionode) then proc_Nqs = proc_indices(proc_i+1, 2) - proc_indices(proc_i+1,1) + 1 !write(*) "Writing phi proc ", proc_i data => phi(:,1:proc_Nqs) call write_data(21, data) end if end do !! !! Here, we basically repeat the process exactly but for the second derivatives d2phi_dk2 !! instead of the kernel itself !! if (ionode) then !write(*) "Writing d2phi_dk2 proc ", 0 data => d2phi_dk2(:,:) call write_data(21, data) end if do proc_i = 1, nproc-1 call mp_get(d2phi_dk2, d2phi_dk2, mpime, 0, proc_i, 0, world_comm) if (mpime == 0) then proc_Nqs = proc_indices(proc_i+1,2) - proc_indices(proc_i+1,1) + 1 !write(*) "Writing d2phi_dk2 proc ", proc_i data => d2phi_dk2(:, 1:proc_Nqs) call write_data(21, data) end if end do !! if (ionode) then close(21) end if end subroutine <API key> !! !! | | !! | WRITE_DATA | !! !______________| !! Write matrix data held in the point "array" to the file with unit number "file". Data is written !! in binary format. subroutine write_data(file, array) real(dp), pointer:: array(:,:) !! Input pointer to the matrix data to be written integer, intent(in) :: file !! Unit number of file to write to integer :: index, ios !! Indexing variable do index = 1, size(array,2) ! write(file) array(:,index) write (file, double_format, err=100, iostat=ios) array(:,index) end do 100 call errore ('<API key>', 'Writing table file', abs (ios) ) end subroutine write_data !! !! | | !! | RADIAL_FFT | !! |______________| !! This subroutine performs a radial Fourier transform on the real-space kernel functions. Basically, this is !! just int( 4*pi*r^2*phi*sin(k*r)/(k*r))dr integrated from 0 to r_max. That is, it is the kernel function phi !! integrated with the 0^th spherical Bessel function radially, with a 4*pi assumed from angular integration !! since we have spherical symmetry. The spherical symmetry comes in because the kernel function depends only !! on the magnitude of the vector between two points. The integration is done using the trapezoid rule. subroutine radial_fft(phi) real(dp), intent(inout) :: phi(0:Nr_points) !! On input holds the real-space function phi_q1_q2(r) ! !! On output hold the reciprocal-space function phi_q1_q2(k) real(dp) :: phi_k(0:Nr_points) !! Temporary storage for phi_q1_q2(k) real(dp) :: dr = r_max/Nr_points !! Spacing between real-space sample points real(dp) :: dk = 2.0D0*pi/r_max !! Spacing between reciprocal space sample points integer :: k_i, r_i !! Indexing variables real(dp) :: r, k !! The real and reciprocal space points phi_k = 0.0D0 !! Handle the k=0 point separately !! do r_i = 1, Nr_points r = r_i * dr phi_k(0) = phi_k(0) + phi(r_i)*r**2 end do !! Subtract half of the last value of because of the trapezoid rule phi_k(0) = phi_k(0) - 0.5D0 * (Nr_points*dr)**2 * phi(Nr_points) !! !! Integration for the rest of the k-points !! do k_i = 1, Nr_points k = k_i * dk do r_i = 1, Nr_points r = r_i * dr phi_k(k_i) = phi_k(k_i) + phi(r_i) * r * sin(k*r) / k end do phi_k(k_i) = phi_k(k_i) - 0.5D0 * phi(Nr_points) * r *sin(k*r) / k end do !! Add in the 4*pi and the dr factor for the integration phi = 4.0D0 * pi * phi_k * dr !! end subroutine radial_fft !! end program <API key>
#include "mlan.h" #include "mlan_join.h" #include "mlan_util.h" #include "mlan_fw.h" #include "mlan_main.h" #include "mlan_wmm.h" #include "mlan_11n.h" #include "mlan_11h.h" #include "mlan_sdio.h" #include "mlan_meas.h" /** * @brief This function handles the command response error * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to command buffer * * @return N/A */ static void <API key>(mlan_private * pmpriv, HostCmd_DS_COMMAND * resp, mlan_ioctl_req * pioctl_buf) { mlan_adapter *pmadapter = pmpriv->adapter; ENTER(); PRINTM(MERROR, "CMD_RESP: cmd %#x error, result=%#x\n", resp->command, resp->result); if (pioctl_buf) pioctl_buf->status_code = <API key>; switch (resp->command) { case <API key>: { <API key> *pm = &resp->params.psmode_enh; PRINTM(MERROR, "PS_MODE_ENH command failed: result=0x%x action=0x%X\n", resp->result, wlan_le16_to_cpu(pm->action)); /* * We do not re-try enter-ps command in ad-hoc mode. */ if (wlan_le16_to_cpu(pm->action) == EN_AUTO_PS && (wlan_le16_to_cpu(pm->params.auto_ps.ps_bitmap) & BITMAP_STA_PS) && pmpriv->bss_mode == MLAN_BSS_MODE_IBSS) pmadapter->ps_mode = <API key>; } break; case <API key>: case <API key>: /* Cancel all pending scan command */ <API key>(pmadapter); wlan_recv_event(pmpriv, <API key>, MNULL); break; case <API key>: break; default: break; } /* * Handling errors here */ <API key>(pmadapter, pmadapter->curr_cmd); <API key>(pmadapter); pmadapter->curr_cmd = MNULL; <API key>(pmadapter); LEAVE(); return; } /** * @brief This function handles the command response of RSSI info * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { <API key> *prssi_info_rsp = &resp->params.rssi_info_rsp; mlan_ds_get_info *pget_info = MNULL; ENTER(); pmpriv->data_rssi_last = wlan_le16_to_cpu(prssi_info_rsp->data_rssi_last); pmpriv->data_nf_last = wlan_le16_to_cpu(prssi_info_rsp->data_nf_last); pmpriv->data_rssi_avg = wlan_le16_to_cpu(prssi_info_rsp->data_rssi_avg); pmpriv->data_nf_avg = wlan_le16_to_cpu(prssi_info_rsp->data_nf_avg); pmpriv->bcn_rssi_last = wlan_le16_to_cpu(prssi_info_rsp->bcn_rssi_last); pmpriv->bcn_nf_last = wlan_le16_to_cpu(prssi_info_rsp->bcn_nf_last); pmpriv->bcn_rssi_avg = wlan_le16_to_cpu(prssi_info_rsp->bcn_rssi_avg); pmpriv->bcn_nf_avg = wlan_le16_to_cpu(prssi_info_rsp->bcn_nf_avg); /* Need to indicate IOCTL complete */ if (pioctl_buf != MNULL) { pget_info = (mlan_ds_get_info *) pioctl_buf->pbuf; memset(pmpriv->adapter, &pget_info->param.signal, 0, sizeof(mlan_ds_get_signal)); pget_info->param.signal.selector = ALL_RSSI_INFO_MASK; /* RSSI */ pget_info->param.signal.bcn_rssi_last = pmpriv->bcn_rssi_last; pget_info->param.signal.bcn_rssi_avg = pmpriv->bcn_rssi_avg; pget_info->param.signal.data_rssi_last = pmpriv->data_rssi_last; pget_info->param.signal.data_rssi_avg = pmpriv->data_rssi_avg; /* SNR */ pget_info->param.signal.bcn_snr_last = CAL_SNR(pmpriv->bcn_rssi_last, pmpriv->bcn_nf_last); pget_info->param.signal.bcn_snr_avg = CAL_SNR(pmpriv->bcn_rssi_avg, pmpriv->bcn_nf_avg); pget_info->param.signal.data_snr_last = CAL_SNR(pmpriv->data_rssi_last, pmpriv->data_nf_last); pget_info->param.signal.data_snr_avg = CAL_SNR(pmpriv->data_rssi_avg, pmpriv->data_nf_avg); pget_info->param.signal.bcn_nf_last = pmpriv->bcn_nf_last; pget_info->param.signal.bcn_nf_avg = pmpriv->bcn_nf_avg; pget_info->param.signal.data_nf_last = pmpriv->data_nf_last; pget_info->param.signal.data_nf_avg = pmpriv->data_nf_avg; pioctl_buf->data_read_written = sizeof(mlan_ds_get_info); } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of mac_control * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { ENTER(); LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of snmp_mib * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { <API key> *psmib = &resp->params.smib; t_u16 oid = wlan_le16_to_cpu(psmib->oid); t_u16 query_type = wlan_le16_to_cpu(psmib->query_type); t_u32 ul_temp; mlan_ds_snmp_mib *mib = MNULL; ENTER(); if (pioctl_buf) mib = (mlan_ds_snmp_mib *) pioctl_buf->pbuf; PRINTM(MINFO, "SNMP_RESP: value of the oid = 0x%x, query_type=0x%x\n", oid, query_type); PRINTM(MINFO, "SNMP_RESP: Buf size = 0x%x\n", wlan_le16_to_cpu(psmib->buf_size)); if (query_type == HostCmd_ACT_GEN_GET) { switch (oid) { case DtimPeriod_i: ul_temp = psmib->value[0]; PRINTM(MINFO, "SNMP_RESP: DTIM Period =%u\n", ul_temp); if (mib) mib->param.dtim_period = ul_temp; break; case FragThresh_i: ul_temp = wlan_le16_to_cpu(*((t_u16 *) (psmib->value))); PRINTM(MINFO, "SNMP_RESP: FragThsd =%u\n", ul_temp); if (mib) mib->param.frag_threshold = ul_temp; break; case RtsThresh_i: ul_temp = wlan_le16_to_cpu(*((t_u16 *) (psmib->value))); PRINTM(MINFO, "SNMP_RESP: RTSThsd =%u\n", ul_temp); if (mib) mib->param.rts_threshold = ul_temp; break; case ShortRetryLim_i: ul_temp = wlan_le16_to_cpu(*((t_u16 *) (psmib->value))); PRINTM(MINFO, "SNMP_RESP: TxRetryCount=%u\n", ul_temp); if (mib) mib->param.retry_count = ul_temp; break; case WwsMode_i: ul_temp = wlan_le16_to_cpu(*((t_u16 *) (psmib->value))); PRINTM(MINFO, "SNMP_RESP: WWSCfg =%u\n", ul_temp); if (pioctl_buf) ((mlan_ds_misc_cfg *) pioctl_buf->pbuf)->param.wws_cfg = ul_temp; break; case Thermal_i: ul_temp = wlan_le32_to_cpu(*((t_u32 *) (psmib->value))); PRINTM(MINFO, "SNMP_RESP: Thermal =%u\n", ul_temp); if (pioctl_buf) ((mlan_ds_misc_cfg *) pioctl_buf->pbuf)->param.thermal = ul_temp; break; default: break; } } else { /* (query_type == HostCmd_ACT_GEN_SET) */ /* Update state for 11d */ if (oid == Dot11D_i) { ul_temp = wlan_le16_to_cpu(*((t_u16 *) (psmib->value))); /* Set 11d state to private */ pmpriv->state_11d.enable_11d = ul_temp; /* Set user enable flag if called from ioctl */ if (pioctl_buf) pmpriv->state_11d.user_enable_11d = ul_temp; } /* Update state for 11h */ if (oid == Dot11H_i) { ul_temp = wlan_le16_to_cpu(*((t_u16 *) (psmib->value))); /* Set 11h state to priv */ pmpriv->intf_state_11h.is_11h_active = (ul_temp & ENABLE_11H_MASK); /* Set radar_det state to adapter */ pmpriv->adapter->state_11h.<API key> = (ul_temp & <API key>) ? MTRUE : MFALSE; pmpriv->adapter->state_11h.<API key> = (ul_temp & <API key>) ? MTRUE : MFALSE; } } if (pioctl_buf) { /* Indicate ioctl complete */ pioctl_buf->data_read_written = sizeof(mlan_ds_snmp_mib); } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of get_log * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * * @return MLAN_STATUS_SUCCESS */ static mlan_status wlan_ret_get_log(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { <API key> *pget_log = (<API key> *) & resp->params.get_log; mlan_ds_get_info *pget_info = MNULL; ENTER(); if (pioctl_buf) { pget_info = (mlan_ds_get_info *) pioctl_buf->pbuf; pget_info->param.stats.mcast_tx_frame = wlan_le32_to_cpu(pget_log->mcast_tx_frame); pget_info->param.stats.failed = wlan_le32_to_cpu(pget_log->failed); pget_info->param.stats.retry = wlan_le32_to_cpu(pget_log->retry); pget_info->param.stats.multi_retry = wlan_le32_to_cpu(pget_log->multiretry); pget_info->param.stats.frame_dup = wlan_le32_to_cpu(pget_log->frame_dup); pget_info->param.stats.rts_success = wlan_le32_to_cpu(pget_log->rts_success); pget_info->param.stats.rts_failure = wlan_le32_to_cpu(pget_log->rts_failure); pget_info->param.stats.ack_failure = wlan_le32_to_cpu(pget_log->ack_failure); pget_info->param.stats.rx_frag = wlan_le32_to_cpu(pget_log->rx_frag); pget_info->param.stats.mcast_rx_frame = wlan_le32_to_cpu(pget_log->mcast_rx_frame); pget_info->param.stats.fcs_error = wlan_le32_to_cpu(pget_log->fcs_error); pget_info->param.stats.tx_frame = wlan_le32_to_cpu(pget_log->tx_frame); pget_info->param.stats.wep_icv_error[0] = wlan_le32_to_cpu(pget_log->wep_icv_err_cnt[0]); pget_info->param.stats.wep_icv_error[1] = wlan_le32_to_cpu(pget_log->wep_icv_err_cnt[1]); pget_info->param.stats.wep_icv_error[2] = wlan_le32_to_cpu(pget_log->wep_icv_err_cnt[2]); pget_info->param.stats.wep_icv_error[3] = wlan_le32_to_cpu(pget_log->wep_icv_err_cnt[3]); /* Indicate ioctl complete */ pioctl_buf->data_read_written = sizeof(mlan_ds_get_info); } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief Get power level and rate index * * @param pmpriv A pointer to mlan_private structure * @param pdata_buf Pointer to the data buffer * * @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE */ static mlan_status <API key>(pmlan_private pmpriv, void *pdata_buf) { int length = -1, max_power = -1, min_power = -1; <API key> *ppg_tlv = MNULL; Power_Group_t *pg = MNULL; ENTER(); if (pdata_buf) { ppg_tlv = (<API key> *) ((t_u8 *) pdata_buf + sizeof(<API key>)); pg = (Power_Group_t *) ((t_u8 *) ppg_tlv + sizeof(<API key>)); length = ppg_tlv->length; if (length > 0) { max_power = pg->power_max; min_power = pg->power_min; length -= sizeof(Power_Group_t); } while (length) { pg++; if (max_power < pg->power_max) { max_power = pg->power_max; } if (min_power > pg->power_min) { min_power = pg->power_min; } length -= sizeof(Power_Group_t); } if (ppg_tlv->length > 0) { pmpriv->min_tx_power_level = (t_u8) min_power; pmpriv->max_tx_power_level = (t_u8) max_power; } } else { LEAVE(); return MLAN_STATUS_FAILURE; } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of tx_power_cfg * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { <API key> *ptxp_cfg = &resp->params.txp_cfg; <API key> *ppg_tlv = MNULL; Power_Group_t *pg = MNULL; t_u16 action = wlan_le16_to_cpu(ptxp_cfg->action); mlan_ds_power_cfg *power = MNULL; t_u32 data[5]; ENTER(); ppg_tlv = (<API key> *) ((t_u8 *) ptxp_cfg + sizeof(<API key>)); pg = (Power_Group_t *) ((t_u8 *) ppg_tlv + sizeof(<API key>)); switch (action) { case HostCmd_ACT_GEN_GET: ppg_tlv->length = wlan_le16_to_cpu(ppg_tlv->length); if (pmpriv->adapter->hw_status == <API key>) <API key>(pmpriv, ptxp_cfg); pmpriv->tx_power_level = (t_u16) pg->power_min; break; case HostCmd_ACT_GEN_SET: if (wlan_le32_to_cpu(ptxp_cfg->mode)) { if (pg->power_max == pg->power_min) pmpriv->tx_power_level = (t_u16) pg->power_min; } break; default: PRINTM(MERROR, "CMD_RESP: unknown command action %d\n", action); LEAVE(); return MLAN_STATUS_SUCCESS; } PRINTM(MINFO, "Current TxPower Level = %d,Max Power=%d, Min Power=%d\n", pmpriv->tx_power_level, pmpriv->max_tx_power_level, pmpriv->min_tx_power_level); if (pioctl_buf) { power = (mlan_ds_power_cfg *) pioctl_buf->pbuf; if (action == HostCmd_ACT_GEN_GET) { if (power->sub_command == MLAN_OID_POWER_CFG) { pioctl_buf->data_read_written = sizeof(mlan_power_cfg_t) + <API key>; power->param.power_cfg.power_level = pmpriv->tx_power_level; if (wlan_le32_to_cpu(ptxp_cfg->mode)) power->param.power_cfg.is_power_auto = 0; else power->param.power_cfg.is_power_auto = 1; } else { power->param.power_ext.len = 0; while (ppg_tlv->length) { data[0] = pg->first_rate_code; data[1] = pg->last_rate_code; if (pg->modulation_class == MOD_CLASS_OFDM) { data[0] += <API key>; data[1] += <API key>; } else if (pg->modulation_class == MOD_CLASS_HT) { data[0] += <API key>; data[1] += <API key>; if (pg->ht_bandwidth == HT_BW_40) { data[0] |= TX_RATE_HT_BW40_BIT; data[1] |= TX_RATE_HT_BW40_BIT; } } data[2] = pg->power_min; data[3] = pg->power_max; data[4] = pg->power_step; memcpy(pmpriv->adapter, (t_u8 *) (&power->param.power_ext. power_data[power->param.power_ext.len]), (t_u8 *) data, sizeof(data)); power->param.power_ext.len += 5; pg++; ppg_tlv->length -= sizeof(Power_Group_t); } pioctl_buf->data_read_written = sizeof(mlan_power_cfg_ext) + <API key>; } } } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of rf_tx_power * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { <API key> *rtp = &resp->params.txp; t_u16 action = wlan_le16_to_cpu(rtp->action); mlan_ds_power_cfg *power = MNULL; ENTER(); pmpriv->tx_power_level = wlan_le16_to_cpu(rtp->current_level); if (action == HostCmd_ACT_GEN_GET) { pmpriv->max_tx_power_level = rtp->max_power; pmpriv->min_tx_power_level = rtp->min_power; if (pioctl_buf) { power = (mlan_ds_power_cfg *) pioctl_buf->pbuf; if (power->sub_command == MLAN_OID_POWER_CFG) { pioctl_buf->data_read_written = sizeof(mlan_power_cfg_t) + <API key>; power->param.power_cfg.power_level = pmpriv->tx_power_level; } } } PRINTM(MINFO, "Current TxPower Level = %d,Max Power=%d, Min Power=%d\n", pmpriv->tx_power_level, pmpriv->max_tx_power_level, pmpriv->min_tx_power_level); LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of sleep_period * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { <API key> *pcmd_sleep_pd = &resp->params.sleep_pd; mlan_ds_pm_cfg *pm_cfg = MNULL; t_u16 sleep_pd = 0; ENTER(); sleep_pd = wlan_le16_to_cpu(pcmd_sleep_pd->sleep_pd); if (pioctl_buf) { pm_cfg = (mlan_ds_pm_cfg *) pioctl_buf->pbuf; pm_cfg->param.sleep_period = (t_u32) sleep_pd; pioctl_buf->data_read_written = sizeof(pm_cfg->param.sleep_period) + <API key>; } pmpriv->adapter->sleep_period.period = sleep_pd; pmpriv->adapter->pps_uapsd_mode = MFALSE; if ((pmpriv->adapter->sleep_period.period != 0) && (pmpriv->adapter->sleep_period.period != <API key>)) { pmpriv->adapter->gen_null_pkt = MTRUE; } else { pmpriv->adapter->delay_null_pkt = MFALSE; pmpriv->adapter->gen_null_pkt = MFALSE; } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of sleep_params * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { <API key> *presp_sp = &resp->params.sleep_param; mlan_ds_pm_cfg *pm_cfg = MNULL; <API key> *psp = MNULL; sleep_params_t *psleep_params = &pmpriv->adapter->sleep_params; ENTER(); psleep_params->sp_reserved = wlan_le16_to_cpu(presp_sp->reserved); psleep_params->sp_error = wlan_le16_to_cpu(presp_sp->error); psleep_params->sp_offset = wlan_le16_to_cpu(presp_sp->offset); psleep_params->sp_stable_time = wlan_le16_to_cpu(presp_sp->stable_time); psleep_params->sp_cal_control = presp_sp->cal_control; psleep_params->sp_ext_sleep_clk = presp_sp->external_sleep_clk; if (pioctl_buf) { pm_cfg = (mlan_ds_pm_cfg *) pioctl_buf->pbuf; psp = (<API key> *) & pm_cfg->param.sleep_params; psp->error = (t_u32) psleep_params->sp_error; psp->offset = (t_u32) psleep_params->sp_offset; psp->stable_time = (t_u32) psleep_params->sp_stable_time; psp->cal_control = (t_u32) psleep_params->sp_cal_control; psp->ext_sleep_clk = (t_u32) psleep_params->sp_ext_sleep_clk; psp->reserved = (t_u32) psleep_params->sp_reserved; pioctl_buf->data_read_written = sizeof(pm_cfg->param.sleep_params) + <API key>; } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of mac_address * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { <API key> *pmac_addr = &resp->params.mac_addr; mlan_ds_bss *bss = MNULL; ENTER(); memcpy(pmpriv->adapter, pmpriv->curr_addr, pmac_addr->mac_addr, <API key>); PRINTM(MINFO, "MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n", pmpriv->curr_addr[0], pmpriv->curr_addr[1], pmpriv->curr_addr[2], pmpriv->curr_addr[3], pmpriv->curr_addr[4], pmpriv->curr_addr[5]); if (pioctl_buf) { bss = (mlan_ds_bss *) pioctl_buf->pbuf; memcpy(pmpriv->adapter, &bss->param.mac_addr, pmpriv->curr_addr, <API key>); pioctl_buf->data_read_written = <API key> + <API key>; } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of multicast_address * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { ENTER(); if (pioctl_buf) { pioctl_buf->data_read_written = sizeof(mlan_multicast_list) + <API key>; } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of deauthenticate * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { mlan_adapter *pmadapter = pmpriv->adapter; ENTER(); pmadapter->dbg.num_cmd_deauth++; if (!memcmp(pmadapter, resp->params.deauth.mac_addr, &pmpriv->curr_bss_params.bss_descriptor.mac_address, sizeof(resp->params.deauth.mac_addr))) { <API key>(pmpriv, MTRUE); } if (pmpriv->adapter->state_rdh.stage == RDH_STOP_INTFS) <API key>((t_void *) pmpriv); LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of ad_hoc_stop * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { ENTER(); <API key>(pmpriv, MTRUE); if (pmpriv->adapter->state_rdh.stage == RDH_STOP_INTFS) <API key>((t_void *) pmpriv); LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of key_material * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { <API key> *pkey = &resp->params.key_material; mlan_ds_sec_cfg *sec = MNULL; ENTER(); if (wlan_le16_to_cpu(pkey->action) == HostCmd_ACT_GEN_SET) { if ((wlan_le16_to_cpu(pkey->key_param_set.key_info) & KEY_INFO_TKIP_MCAST)) { PRINTM(MINFO, "key: GTK is set\n"); pmpriv->wpa_is_gtk_set = MTRUE; if (pmpriv->port_ctrl_mode == MTRUE) { /* GTK is set, open the port */ PRINTM(MINFO, "GTK_SET: Open port for WPA/WPA2 h-supp mode\n"); pmpriv->port_open = MTRUE; } pmpriv->scan_block = MFALSE; } } else { if (pioctl_buf && (wlan_le16_to_cpu(pkey->key_param_set.type) == <API key>)) { PRINTM(MIOCTL, "key_type_id=%d, key_len=%d, key_info=0x%x\n", wlan_le16_to_cpu(pkey->key_param_set.key_type_id), wlan_le16_to_cpu(pkey->key_param_set.key_len), wlan_le16_to_cpu(pkey->key_param_set.key_info)); sec = (mlan_ds_sec_cfg *) pioctl_buf->pbuf; #define WAPI_KEY_SIZE 32 switch (wlan_le16_to_cpu(pkey->key_param_set.key_type_id)) { case KEY_TYPE_ID_WEP: sec->param.encrypt_key.key_index = pkey->key_param_set.key[0]; sec->param.encrypt_key.key_len = wlan_le16_to_cpu(pkey->key_param_set.key_len); memcpy(pmpriv->adapter, sec->param.encrypt_key.key_material, &pkey->key_param_set.key[2], sec->param.encrypt_key.key_len); break; case KEY_TYPE_ID_TKIP: sec->param.encrypt_key.key_len = wlan_le16_to_cpu(pkey->key_param_set.key_len); memcpy(pmpriv->adapter, sec->param.encrypt_key.key_material, pkey->key_param_set.key, sec->param.encrypt_key.key_len); break; case KEY_TYPE_ID_AES: case <API key>: sec->param.encrypt_key.key_len = wlan_le16_to_cpu(pkey->key_param_set.key_len); memcpy(pmpriv->adapter, sec->param.encrypt_key.key_material, pkey->key_param_set.key, sec->param.encrypt_key.key_len); break; case KEY_TYPE_ID_WAPI: sec->param.encrypt_key.is_wapi_key = MTRUE; sec->param.encrypt_key.key_index = pkey->key_param_set.key[0]; sec->param.encrypt_key.key_len = WAPI_KEY_SIZE; memcpy(pmpriv->adapter, sec->param.encrypt_key.key_material, &pkey->key_param_set.key[2], sec->param.encrypt_key.key_len); memcpy(pmpriv->adapter, sec->param.encrypt_key.pn, &pkey->key_param_set.key[2 + WAPI_KEY_SIZE], PN_SIZE); break; } } } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief Handle the supplicant pmk response * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * * @return MLAN_STATUS_SUCCESS MLAN_STATUS_FAILURE */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { <API key> *supplicant_pmk_resp = &resp->params.esupplicant_psk; mlan_ds_sec_cfg sec_buf; mlan_ds_sec_cfg *sec = MNULL; MrvlIEtypes_PMK_t *ppmk_tlv = MNULL; <API key> *passphrase_tlv = MNULL; <API key> *pssid_tlv = MNULL; MrvlIEtypes_Bssid_t *pbssid_tlv = MNULL; t_u8 *tlv_buf = (t_u8 *) supplicant_pmk_resp->tlv_buffer; t_u16 action = wlan_le16_to_cpu(supplicant_pmk_resp->action); int tlv_buf_len = 0; t_u16 tlv; mlan_status ret = MLAN_STATUS_SUCCESS; ENTER(); tlv_buf_len = resp->size - (sizeof(<API key>) + S_DS_GEN - 1); if (pioctl_buf) { if (((mlan_ds_bss *) pioctl_buf->pbuf)->sub_command == <API key>) sec = &sec_buf; else sec = (mlan_ds_sec_cfg *) pioctl_buf->pbuf; if (action == HostCmd_ACT_GEN_GET) { while (tlv_buf_len > 0) { tlv = (*tlv_buf) | (*(tlv_buf + 1) << 8); if ((tlv != TLV_TYPE_SSID) && (tlv != TLV_TYPE_BSSID) && (tlv != TLV_TYPE_PASSPHRASE) && (tlv != TLV_TYPE_PMK)) break; switch (tlv) { case TLV_TYPE_SSID: pssid_tlv = (<API key> *) tlv_buf; pssid_tlv->header.len = wlan_le16_to_cpu(pssid_tlv->header.len); memcpy(pmpriv->adapter, sec->param.passphrase.ssid.ssid, pssid_tlv->ssid, MIN(<API key>, pssid_tlv->header.len)); sec->param.passphrase.ssid.ssid_len = MIN(<API key>, pssid_tlv->header.len); tlv_buf += pssid_tlv->header.len + sizeof(MrvlIEtypesHeader_t); tlv_buf_len -= (pssid_tlv->header.len + sizeof(MrvlIEtypesHeader_t)); break; case TLV_TYPE_BSSID: pbssid_tlv = (MrvlIEtypes_Bssid_t *) tlv_buf; pbssid_tlv->header.len = wlan_le16_to_cpu(pbssid_tlv->header.len); memcpy(pmpriv->adapter, &sec->param.passphrase.bssid, pbssid_tlv->bssid, <API key>); tlv_buf += pbssid_tlv->header.len + sizeof(MrvlIEtypesHeader_t); tlv_buf_len -= (pbssid_tlv->header.len + sizeof(MrvlIEtypesHeader_t)); break; case TLV_TYPE_PASSPHRASE: passphrase_tlv = (<API key> *) tlv_buf; passphrase_tlv->header.len = wlan_le16_to_cpu(passphrase_tlv->header.len); sec->param.passphrase.psk_type = MLAN_PSK_PASSPHRASE; sec->param.passphrase.psk.passphrase.passphrase_len = passphrase_tlv->header.len; memcpy(pmpriv->adapter, sec->param.passphrase.psk.passphrase.passphrase, passphrase_tlv->passphrase, MIN(<API key>, passphrase_tlv->header.len)); tlv_buf += passphrase_tlv->header.len + sizeof(MrvlIEtypesHeader_t); tlv_buf_len -= (passphrase_tlv->header.len + sizeof(MrvlIEtypesHeader_t)); break; case TLV_TYPE_PMK: ppmk_tlv = (MrvlIEtypes_PMK_t *) tlv_buf; ppmk_tlv->header.len = wlan_le16_to_cpu(ppmk_tlv->header.len); sec->param.passphrase.psk_type = MLAN_PSK_PMK; memcpy(pmpriv->adapter, sec->param.passphrase.psk.pmk.pmk, ppmk_tlv->pmk, MIN(MLAN_MAX_KEY_LENGTH, ppmk_tlv->header.len)); tlv_buf += ppmk_tlv->header.len + sizeof(MrvlIEtypesHeader_t); tlv_buf_len -= (ppmk_tlv->header.len + sizeof(MrvlIEtypesHeader_t)); break; } } if (((mlan_ds_bss *) pioctl_buf->pbuf)->sub_command == <API key>) { wlan_set_ewpa_mode(pmpriv, &sec->param.passphrase); ret = wlan_find_bss(pmpriv, pioctl_buf); } } else if (action == HostCmd_ACT_GEN_SET) { PRINTM(MINFO, "Esupp PMK set: enable ewpa query\n"); pmpriv->ewpa_query = MTRUE; } } LEAVE(); return ret; } /** * @brief Handle the supplicant profile response * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { <API key> *psup_profile = &resp->params.esupplicant_profile; MrvlIEtypesHeader_t *head; <API key> *encr_proto_tlv = MNULL; <API key> *pcipher_tlv = MNULL; mlan_ds_sec_cfg *sec = MNULL; t_u8 *tlv; int len; ENTER(); len = resp->size - S_DS_GEN - sizeof(t_u16); tlv = psup_profile->tlv_buf; if (pioctl_buf) { sec = (mlan_ds_sec_cfg *) pioctl_buf->pbuf; while (len > 0) { head = (MrvlIEtypesHeader_t *) tlv; head->type = wlan_le16_to_cpu(head->type); head->len = wlan_le16_to_cpu(head->len); switch (head->type) { case <API key>: encr_proto_tlv = (<API key> *) head; sec->param.esupp_mode.rsn_mode = wlan_le16_to_cpu(encr_proto_tlv->rsn_mode); PRINTM(MINFO, "rsn_mode=0x%x\n", sec->param.esupp_mode.rsn_mode); break; case TLV_TYPE_CIPHER: pcipher_tlv = (<API key> *) head; sec->param.esupp_mode.act_paircipher = pcipher_tlv->pair_cipher; sec->param.esupp_mode.act_groupcipher = pcipher_tlv->group_cipher; PRINTM(MINFO, "paircipher=0x%x, groupcipher=0x%x\n", sec->param.esupp_mode.act_paircipher, sec->param.esupp_mode.act_groupcipher); break; } len -= (head->len - sizeof(MrvlIEtypesHeader_t)); tlv = tlv + (head->len + sizeof(MrvlIEtypesHeader_t)); } } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of rf_channel * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { <API key> *prf_channel = &resp->params.rf_channel; t_u16 new_channel = wlan_le16_to_cpu(prf_channel->current_channel); mlan_ds_bss *bss = MNULL; ENTER(); if (pmpriv->curr_bss_params.bss_descriptor.channel != new_channel) { PRINTM(MINFO, "Channel Switch: %d to %d\n", pmpriv->curr_bss_params.bss_descriptor.channel, new_channel); /* Update the channel again */ pmpriv->curr_bss_params.bss_descriptor.channel = new_channel; } if (pioctl_buf) { bss = (mlan_ds_bss *) pioctl_buf->pbuf; bss->param.bss_chan.channel = new_channel; } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief Handle the <API key> resp * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp) { <API key> *pibss_coal_resp = &(resp->params.ibss_coalescing); t_u8 zero_mac[<API key>] = { 0, 0, 0, 0, 0, 0 }; ENTER(); if (wlan_le16_to_cpu(pibss_coal_resp->action) == HostCmd_ACT_GEN_SET) { LEAVE(); return MLAN_STATUS_SUCCESS; } PRINTM(MINFO, "New BSSID %02x:%02x:%02x:%02x:%02x:%02x\n", pibss_coal_resp->bssid[0], pibss_coal_resp->bssid[1], pibss_coal_resp->bssid[2], pibss_coal_resp->bssid[3], pibss_coal_resp->bssid[4], pibss_coal_resp->bssid[5]); /* If rsp has MNULL BSSID, Just return..... No Action */ if (!memcmp (pmpriv->adapter, pibss_coal_resp->bssid, zero_mac, <API key>)) { PRINTM(MMSG, "New BSSID is MNULL\n"); LEAVE(); return MLAN_STATUS_SUCCESS; } /* If BSSID is diff, modify current BSS parameters */ if (memcmp (pmpriv->adapter, pmpriv->curr_bss_params.bss_descriptor.mac_address, pibss_coal_resp->bssid, <API key>)) { /* BSSID */ memcpy(pmpriv->adapter, pmpriv->curr_bss_params.bss_descriptor.mac_address, pibss_coal_resp->bssid, <API key>); /* Beacon Interval and ATIM window */ pmpriv->curr_bss_params.bss_descriptor.beacon_period = wlan_le16_to_cpu(pibss_coal_resp->beacon_interval); pmpriv->curr_bss_params.bss_descriptor.atim_window = wlan_le16_to_cpu(pibss_coal_resp->atim_window); /* ERP Information */ pmpriv->curr_bss_params.bss_descriptor.erp_flags = (t_u8) wlan_le16_to_cpu(pibss_coal_resp->use_g_rate_protect); pmpriv->adhoc_state = ADHOC_COALESCED; } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of MGMT_IE_LIST * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, OUT mlan_ioctl_req * pioctl_buf) { t_u16 resp_len = 0, travel_len = 0; int i = 0; mlan_ds_misc_cfg *misc = MNULL; <API key> *cust_ie = MNULL; custom_ie *cptr; tlvbuf_max_mgmt_ie *max_mgmt_ie = MNULL; <API key> *pmgmt_ie_list = &(resp->params.mgmt_ie_list); ENTER(); if (wlan_le16_to_cpu(pmgmt_ie_list->action) == HostCmd_ACT_GEN_SET) { if ((pmpriv->adapter->state_rdh.stage == RDH_SET_CUSTOM_IE) || (pmpriv->adapter->state_rdh.stage == RDH_REM_CUSTOM_IE)) <API key>((t_void *) pmpriv); LEAVE(); return MLAN_STATUS_SUCCESS; } misc = (mlan_ds_misc_cfg *) pioctl_buf->pbuf; cust_ie = (<API key> *) & pmgmt_ie_list->ds_mgmt_ie; max_mgmt_ie = (tlvbuf_max_mgmt_ie *) ((t_u8 *) cust_ie + cust_ie->len + sizeof(MrvlIEtypesHeader_t)); if (cust_ie) { cust_ie->type = wlan_le16_to_cpu(cust_ie->type); resp_len = cust_ie->len = wlan_le16_to_cpu(cust_ie->len); travel_len = 0; /* conversion for index, mask, len */ if (resp_len == sizeof(t_u16)) cust_ie->ie_data_list[0].ie_index = wlan_cpu_to_le16(cust_ie->ie_data_list[0].ie_index); while (resp_len > sizeof(t_u16)) { cptr = (custom_ie *) (((t_u8 *) cust_ie->ie_data_list) + travel_len); cptr->ie_index = wlan_le16_to_cpu(cptr->ie_index); cptr->mgmt_subtype_mask = wlan_le16_to_cpu(cptr->mgmt_subtype_mask); cptr->ie_length = wlan_le16_to_cpu(cptr->ie_length); travel_len += cptr->ie_length + sizeof(custom_ie) - MAX_IE_SIZE; resp_len -= cptr->ie_length + sizeof(custom_ie) - MAX_IE_SIZE; } memcpy(pmpriv->adapter, &misc->param.cust_ie, cust_ie, (cust_ie->len + sizeof(MrvlIEtypesHeader_t))); if (max_mgmt_ie) { max_mgmt_ie->type = wlan_le16_to_cpu(max_mgmt_ie->type); if (max_mgmt_ie->type == <API key>) { max_mgmt_ie->len = wlan_le16_to_cpu(max_mgmt_ie->len); max_mgmt_ie->count = wlan_le16_to_cpu(max_mgmt_ie->count); for (i = 0; i < max_mgmt_ie->count; i++) { max_mgmt_ie->info[i].buf_size = wlan_le16_to_cpu(max_mgmt_ie->info[i].buf_size); max_mgmt_ie->info[i].buf_count = wlan_le16_to_cpu(max_mgmt_ie->info[i].buf_count); } /* Append max_mgmt_ie TLV after custom_ie */ memcpy(pmpriv->adapter, (t_u8 *) & misc->param.cust_ie + (cust_ie->len + sizeof (MrvlIEtypesHeader_t)), max_mgmt_ie, max_mgmt_ie->len + sizeof(MrvlIEtypesHeader_t)); } } } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of sysclock * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to mlan_ioctl_req structure * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { mlan_ds_misc_cfg *mis_ccfg = MNULL; <API key> *clk_cfg = &resp->params.sys_clock_cfg; int i = 0; ENTER(); if (pioctl_buf) { mis_ccfg = (mlan_ds_misc_cfg *) pioctl_buf->pbuf; mis_ccfg->param.sys_clock.cur_sys_clk = wlan_le16_to_cpu(clk_cfg->cur_sys_clk); mis_ccfg->param.sys_clock.sys_clk_type = wlan_le16_to_cpu(clk_cfg->sys_clk_type); mis_ccfg->param.sys_clock.sys_clk_num = wlan_le16_to_cpu(clk_cfg->sys_clk_len) / sizeof(t_u16); for (i = 0; i < mis_ccfg->param.sys_clock.sys_clk_num; i++) mis_ccfg->param.sys_clock.sys_clk[i] = wlan_le16_to_cpu(clk_cfg->sys_clk[i]); } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of reg_access * * @param type The type of reg access (MAC, BBP or RF) * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to command buffer * * @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE */ static mlan_status wlan_ret_reg_access(mlan_adapter * pmadapter, t_u16 type, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { mlan_ds_reg_mem *reg_mem = MNULL; mlan_ds_reg_rw *reg_rw = MNULL; ENTER(); if (pioctl_buf) { reg_mem = (mlan_ds_reg_mem *) pioctl_buf->pbuf; reg_rw = &reg_mem->param.reg_rw; switch (type) { case <API key>: { <API key> *reg; reg = (<API key> *) & resp->params.mac_reg; reg_rw->offset = (t_u32) wlan_le16_to_cpu(reg->offset); reg_rw->value = wlan_le32_to_cpu(reg->value); break; } case <API key>: { <API key> *reg; reg = (<API key> *) & resp->params.bbp_reg; reg_rw->offset = (t_u32) wlan_le16_to_cpu(reg->offset); reg_rw->value = (t_u32) reg->value; break; } case <API key>: { <API key> *reg; reg = (<API key> *) & resp->params.rf_reg; reg_rw->offset = (t_u32) wlan_le16_to_cpu(reg->offset); reg_rw->value = (t_u32) reg->value; break; } case <API key>: { <API key> *reg; reg = (<API key> *) & resp->params.rf_reg; reg_rw->offset = (t_u32) wlan_le16_to_cpu(reg->offset); reg_rw->value = (t_u32) reg->value; break; } case <API key>: { mlan_ds_read_eeprom *eeprom = &reg_mem->param.rd_eeprom; <API key> *cmd_eeprom = (<API key> *) & resp->params.eeprom; cmd_eeprom->byte_count = wlan_le16_to_cpu(cmd_eeprom->byte_count); PRINTM(MINFO, "EEPROM read len=%x\n", cmd_eeprom->byte_count); if (eeprom->byte_count < cmd_eeprom->byte_count) { eeprom->byte_count = 0; PRINTM(MINFO, "EEPROM read return length is too big\n"); pioctl_buf->status_code = <API key>; LEAVE(); return MLAN_STATUS_FAILURE; } eeprom->offset = wlan_le16_to_cpu(cmd_eeprom->offset); eeprom->byte_count = cmd_eeprom->byte_count; if (eeprom->byte_count > 0) { memcpy(pmadapter, &eeprom->value, &cmd_eeprom->value, MIN(MAX_EEPROM_DATA, eeprom->byte_count)); HEXDUMP("EEPROM", (char *) &eeprom->value, MIN(MAX_EEPROM_DATA, eeprom->byte_count)); } break; } default: pioctl_buf->status_code = <API key>; LEAVE(); return MLAN_STATUS_FAILURE; } } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of mem_access * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to command buffer * * @return MLAN_STATUS_SUCCESS */ static mlan_status wlan_ret_mem_access(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { mlan_ds_reg_mem *reg_mem = MNULL; mlan_ds_mem_rw *mem_rw = MNULL; <API key> *mem = (<API key> *) & resp->params.mem; ENTER(); if (pioctl_buf) { reg_mem = (mlan_ds_reg_mem *) pioctl_buf->pbuf; mem_rw = &reg_mem->param.mem_rw; mem_rw->addr = wlan_le32_to_cpu(mem->addr); mem_rw->value = wlan_le32_to_cpu(mem->value); } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of inactivity timeout * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to command buffer * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { mlan_ds_pm_cfg *pmcfg = MNULL; <API key> *inac_to = MNULL; <API key> *cmd_inac_to = (<API key> *) & resp->params.inactivity_to; ENTER(); if (pioctl_buf) { pmcfg = (mlan_ds_pm_cfg *) pioctl_buf->pbuf; inac_to = &pmcfg->param.inactivity_to; inac_to->timeout_unit = wlan_le16_to_cpu(cmd_inac_to->timeout_unit); inac_to->unicast_timeout = wlan_le16_to_cpu(cmd_inac_to->unicast_timeout); inac_to->mcast_timeout = wlan_le16_to_cpu(cmd_inac_to->mcast_timeout); inac_to->ps_entry_timeout = wlan_le16_to_cpu(cmd_inac_to->ps_entry_timeout); } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of * subscribe event * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to command buffer * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { <API key> *evt = (<API key> *) & resp->params.subscribe_event; <API key> *sub_evt = MNULL; mlan_ds_misc_cfg *misc = MNULL; ENTER(); if (pioctl_buf && (pioctl_buf->action == MLAN_ACT_GET)) { misc = (mlan_ds_misc_cfg *) pioctl_buf->pbuf; sub_evt = &misc->param.subscribe_event; sub_evt->evt_bitmap = wlan_le16_to_cpu(evt->event_bitmap); pioctl_buf->data_read_written = sizeof(mlan_ds_misc_cfg); } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the command response of * OTP user data * * @param pmpriv A pointer to mlan_private structure * @param resp A pointer to HostCmd_DS_COMMAND * @param pioctl_buf A pointer to command buffer * * @return MLAN_STATUS_SUCCESS */ static mlan_status <API key>(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND * resp, IN mlan_ioctl_req * pioctl_buf) { <API key> *cmd_user_data = (<API key> *) & resp->params.otp_user_data; <API key> *user_data = MNULL; ENTER(); if (pioctl_buf && (pioctl_buf->action == MLAN_ACT_GET)) { user_data = (<API key> *) pioctl_buf->pbuf; user_data->user_data_length = MIN(<API key>, wlan_le16_to_cpu(cmd_user_data-> user_data_length)); memcpy(pmpriv->adapter, user_data->user_data, cmd_user_data->user_data, user_data->user_data_length); pioctl_buf->data_read_written = sizeof(<API key>) + user_data->user_data_length; } LEAVE(); return MLAN_STATUS_SUCCESS; } /** * @brief This function handles the station command response * * @param priv A pointer to mlan_private structure * @param cmdresp_no cmd no * @param pcmd_buf cmdresp buf * @param pioctl A pointer to ioctl buf * * @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE */ mlan_status <API key>(IN t_void * priv, IN t_u16 cmdresp_no, IN t_void * pcmd_buf, IN t_void * pioctl) { mlan_status ret = MLAN_STATUS_SUCCESS; mlan_private *pmpriv = (mlan_private *) priv; HostCmd_DS_COMMAND *resp = (HostCmd_DS_COMMAND *) pcmd_buf; mlan_ioctl_req *pioctl_buf = (mlan_ioctl_req *) pioctl; mlan_adapter *pmadapter = pmpriv->adapter; int ctr; ENTER(); /* If the command is not successful, cleanup and return failure */ if ((resp->result != HostCmd_RESULT_OK) ) { <API key>(pmpriv, resp, pioctl_buf); LEAVE(); return MLAN_STATUS_FAILURE; } /* Command successful, handle response */ switch (cmdresp_no) { case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = wlan_ret_cfg_data(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); pioctl_buf = MNULL; pmadapter->curr_cmd->pioctl_buf = MNULL; break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); pioctl_buf = MNULL; pmadapter->curr_cmd->pioctl_buf = MNULL; break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); PRINTM(MINFO, "CMD_RESP: BG_SCAN result is ready!\n"); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = wlan_ret_get_log(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = wlan_ret_ver_ext(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: case <API key>: break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp); break; case <API key>: case <API key>: case <API key>: case <API key>: ret = <API key>(pmpriv, resp); break; case <API key>: ret = <API key>(pmpriv, resp); break; case <API key>: ret = wlan_ret_11n_delba(pmpriv, resp); break; case <API key>: ret = <API key>(pmpriv, resp); break; case <API key>: pmadapter->tx_buf_size = (t_u16) wlan_le16_to_cpu(resp->params.tx_buf.buff_size); pmadapter->tx_buf_size = (pmadapter->tx_buf_size / <API key>) * <API key>; pmadapter->curr_tx_buf_size = pmadapter->tx_buf_size; pmadapter->mp_end_port = wlan_le16_to_cpu(resp->params.tx_buf.mp_end_port); pmadapter->mp_data_port_mask = DATA_PORT_MASK; for (ctr = 1; ctr <= MAX_PORT - pmadapter->mp_end_port; ctr++) { pmadapter->mp_data_port_mask &= ~(1 << (MAX_PORT - ctr)); } pmadapter->curr_wr_port = 1; PRINTM(MCMND, "end port %d, data port mask %x\n", wlan_le16_to_cpu(resp->params.tx_buf.mp_end_port), pmadapter->mp_data_port_mask); PRINTM(MCMND, "max_tx_buf_size=%d, tx_buf_size=%d\n", pmadapter->max_tx_buf_size, pmadapter->tx_buf_size); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp->params.get_wmm_status. queue_status_tlv, resp->size - S_DS_GEN); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case HostCmd_CMD_11N_CFG: ret = wlan_ret_11n_cfg(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: ret = wlan_ret_reg_access(pmpriv->adapter, cmdresp_no, resp, pioctl_buf); break; case <API key>: ret = wlan_ret_mem_access(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: break; case <API key>: break; case <API key>: case <API key>: ret = <API key>(pmpriv, resp); break; #ifdef WIFI_DIRECT_SUPPORT case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; #endif case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; case <API key>: ret = <API key>(pmpriv, resp, pioctl_buf); break; default: PRINTM(MERROR, "CMD_RESP: Unknown command response % resp->command); break; } LEAVE(); return ret; }
using System; using System.Linq; using Vexe.Runtime.Extensions; using Vexe.Runtime.Helpers; using Vexe.Runtime.Types; using Vexe.Editor.Types; namespace Vexe.Editor.Drawers { public class ShowTypeDrawer : AttributeDrawer<Type, ShowTypeAttribute> { private Type[] availableTypes; private string[] typesNames; private int index; protected override void Initialize() { if (attribute.FromThisGo) { availableTypes = gameObject.GetAllComponents() .Select(x => x.GetType()) .Where(x => x.IsA(attribute.baseType)) .ToArray(); } else { availableTypes = ReflectionHelper.GetAllTypesOf(attribute.baseType) .Where(t => !t.IsAbstract) .ToArray(); } typesNames = availableTypes.Select(t => t.Name) .ToArray(); } public override void OnGUI() { index = member.IsNull() ? -1 : availableTypes.IndexOf(memberValue); var selection = gui.Popup(displayText, index, typesNames); { if (index != selection) { memberValue = availableTypes[selection]; index = selection; } } } } }
{% extends "webclient/base/base_container.html" %} {% load i18n %} {% load markup %} {% load custom_tags %} {% load wikitags %} {% block link %} {% endblock %} {% comment %} <! Copyright (C) 2011 University of Dundee & Open Microscopy Environment. All rights reserved. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http: {% endcomment %} {% comment %} <! This page is the 'home page' of the 3-column data layout for webclient. It loads the tree in the left panel. This is then used to load data into the middle and right panels (via AJAX) using functions in the actions.js file. E.g. On selection change: loadOtherPanels() calls loadMetadataPanel() {% endcomment %} {% block jscript %} <script type="text/javascript" src="{% url webstatic "javascript/jquery.cookie.js" %}"></script> <script type="text/javascript" src="{% url webstatic "javascript/jquery.hotkeys.js" %}"></script> <script type="text/javascript" src="{% url webstatic "javascript/jquery.jstree.js" %}"></script> {% endblock %} {% block script %} <script type="text/javascript" src="{% url webstatic "javascript/actions.js" %}"></script> <script type="text/javascript"> $(function() { var h = $(window).height()-200; $("div#tree_details").css('height', h); $("div#metadata_details").css('height', h+31); $("div#metadata_details iframe").attr('height', h+7); $("div#content_details").css('height', h+31); var buttonsShowHide = function(selected, inst) { var toolbar_config = {"addproject":false, 'adddataset':false, 'addscreen':false, 'copy':false, 'cut':false, 'unlink':false, 'delete':false, 'annotation':false, 'basket':false}; if(selected.length > 0) { if(selected.attr("rel").indexOf("locked") < 0) { toolbar_config['delete'] = true; if(selected.attr("id").indexOf("experimenter")>=0) { toolbar_config['delete'] = false; toolbar_config["addproject"] = true; toolbar_config['adddataset'] = true; toolbar_config['addscreen'] = true; if ($.inArray(selected.attr('rel').replace("-locked", ""), ["dataset", "plate"]) > -1) { toolbar_config['copy'] = true; } } else if(selected.attr("id").indexOf("project")>=0) { toolbar_config['adddataset'] = true; } else if(selected.attr("id").indexOf("dataset")>=0) { toolbar_config['copy'] = true; if (selected.parent().parent().length > 0 && selected.parent().parent().attr('rel').replace("-locked", "").indexOf("experimenter") < 0) { toolbar_config["cut"] = true; toolbar_config["unlink"] = true; } } else if(selected.attr("id").indexOf("image")>=0) { toolbar_config['basket'] = true; toolbar_config['copy'] = true; if (selected.parent().parent().length > 0 && selected.parent().parent().attr('rel').replace("-locked", "").indexOf("orphaned") < 0) { toolbar_config["cut"] = true; toolbar_config["unlink"] = true; } } else if(selected.attr("id").indexOf("plate")>=0) { toolbar_config['copy'] = true; if (selected.parent().parent().length > 0 && selected.parent().parent().attr('rel').replace("-locked", "").indexOf("experimenter") < 0) { toolbar_config["cut"] = true; toolbar_config["unlink"] = true; } } } if ((inst.data.crrm.cp_nodes || inst.data.crrm.ct_nodes) && ($.inArray(selected.attr('rel').replace("-locked", ""), ["project", "dataset", "screen"]) > -1)) { toolbar_config['paste'] = true; } } else { toolbar_config = {"addproject":false, 'adddataset':false, 'addscreen':false, 'copy':false, 'cut':false, 'unlink':false, 'delete':{% if eContext.isLeader %}true{% else %}false{% endif %}, 'annotation':false, 'basket':false}; } for (var sIndex in toolbar_config) { if (toolbar_config[sIndex]){ $('input#'+sIndex+'Button').removeClass('button-disabled').removeAttr('disabled'); } else { $('input#'+sIndex+'Button').addClass('button-disabled').attr('disabled', true); } } } var jstree = $("#dataTree").jstree({ // the list of plugins to include "plugins" : [ "themes", "html_data", "ui", "crrm", "dnd", "types", "hotkeys", "contextmenu" ], // Plugin configuration // I usually configure the plugin that handles the data first - in this case JSON as it is most common "html_data" : { // I chose an ajax enabled tree - again - as this is most common, and maybe a bit more complex // All the options are the same as jQuery's except for `data` which CAN (not should) be a function "ajax" : { // the URL to fetch the data "url" : function(n) { if (n.attr) { var parent = this._get_parent(n); if ($.inArray($(parent).attr("rel").replace("-locked", ""), ["project", "screen"]) > -1) { url = "{% url load_data %}"+$(parent).attr("rel").replace("-locked", "")+"/"+$(parent).attr("id").split("-")[1]+"/"+n.attr("rel").replace("-locked", "")+"/"+n.attr("id").split("-")[1]+"/"; } else { url = "{% url load_data %}"+n.attr("rel").replace("-locked", "")+"/"+n.attr("id").split("-")[1]+"/"; } } else { url = "{% url load_data %}"; } return url; }, // this function is executed in the instance's scope (this refers to the tree instance) // the parameter is the node being loaded (may be -1, 0, or undefined when loading the root nodes) "data" : function (n) { var r = { "view" : "tree" }; if (n.attr && $.inArray(n.attr("rel").replace("-locked", ""), ["dataset", "orphaned"]) > -1) { if($("div r["page"] = parseInt($("div#content_details").find("#page").attr("rel")); } } return r; } } }, // Using types - most of the time this is an overkill // Still meny people use them - here is how "types" : { // I want only `drive` nodes to be root nodes // This will prevent moving or creating any other type as a root node "max_depth" : -1, "max_children" : -1, "valid_children" : [ "experimenter" ], "types" : { "experimenter" : { "valid_children" : [ "project", "project-locked", "dataset", "dataset-locked", "screen", "screen-locked", "plate", "plate-locked" ], "icon" : { "image" : '{% url webstatic "images/personal16.png" %}' }, "create_node" : true, "start_drag" : false, "move_node" : false, "delete_node" : false, "remove" : false }, "project" : { "valid_children" : [ "dataset" ], "icon" : { "image" : '{% url webstatic "images/folder16.png" %}' }, "create_node" : true, "start_drag" : false, "move_node" : true, "delete_node" : true, "remove" : true }, "project-locked" : { "valid_children" : [ "dataset", "dataset-locked" ], "icon" : { "image" : '{% url webstatic "images/folder_locked16.png" %}' }, "create_node" : true, "start_drag" : false, "move_node" : false, "delete_node" : {% if eContext.isLeader %}true{% else %}false{% endif %}, "remove" : {% if eContext.isLeader %}true{% else %}false{% endif %} }, "dataset" : { "valid_children" : [ "image", "image-locked" ], "icon" : { "image" : '{% url webstatic "images/folder_image16.png" %}' }, "create_node" : false, "start_drag" : true, "move_node" : true, "delete_node" : true, "remove" : true }, "dataset-locked" : { "valid_children" : [ "image", "image-locked" ], "icon" : { "image" : '{% url webstatic "images/<API key>.png" %}' }, "create_node" : false, "start_drag" : false, "move_node" : false, "delete_node" : {% if eContext.isLeader %}true{% else %}false{% endif %}, "remove" : {% if eContext.isLeader %}true{% else %}false{% endif %} }, "image" : { "valid_children" : "none", "icon" : { "image" : '{% url webstatic "images/image16.png" %}' }, "create_node" : false, "start_drag" : true, "move_node" : true, "delete_node" : true, "remove" : true }, "image-locked" : { "valid_children" : "none", "icon" : { "image" : '{% url webstatic "images/image_locked16.png" %}' }, "create_node" : false, "start_drag" : false, "move_node" : false, "delete_node" : {% if eContext.isLeader %}true{% else %}false{% endif %}, "remove" : {% if eContext.isLeader %}true{% else %}false{% endif %} }, "screen" : { "valid_children" : [ "plate", "plate-locked" ], "icon" : { "image" : '{% url webstatic "images/folder_screen16.png" %}' }, "create_node" : true, "start_drag" : false, "move_node" : true, "delete_node" : true, "remove" : true }, "screen-locked" : { "valid_children" : [ "plate", "plate-locked" ], "icon" : { "image" : '{% url webstatic "images/<API key>.png" %}' }, "create_node" : true, "start_drag" : false, "move_node" : false, "delete_node" : {% if eContext.isLeader %}true{% else %}false{% endif %}, "remove" : {% if eContext.isLeader %}true{% else %}false{% endif %} }, "plate" : { "valid_children" : "acquisition", "icon" : { "image" : '{% url webstatic "images/folder_plate16.png" %}' }, "create_node" : false, "start_drag" : true, "move_node" : true, "delete_node" : true, "remove" : true }, "plate-locked" : { "valid_children" : "acquisition", "icon" : { "image" : '{% url webstatic "images/<API key>.png" %}' }, "create_node" : false, "start_drag" : false, "move_node" : false, "delete_node" : {% if eContext.isLeader %}true{% else %}false{% endif %}, "remove" : {% if eContext.isLeader %}true{% else %}false{% endif %} }, "acquisition" : { "valid_children" : "none", "icon" : { "image" : '{% url webstatic "images/image16.png" %}' }, "create_node" : false, "start_drag" : false, "move_node" : false, "delete_node" : false, "remove" : false }, "acquisition-locked" : { "valid_children" : "none", "icon" : { "image" : '{% url webstatic "images/image16.png" %}' }, "create_node" : false, "start_drag" : false, "move_node" : false, "delete_node" : false, "remove" : false }, "orphaned" : { "valid_children" : [ "image", "image_locked" ], "icon" : { "image" : '{% url webstatic "images/folder_yellow16.png" %}' }, "create_node" : false, "start_drag" : false, "move_node" : false, "delete_node" : false, "remove" : false } } }, // For UI & core - the nodes to initially select and open will be overwritten by the cookie plugin // the UI plugin - it handles selecting/deselecting/hovering nodes "ui" : { "select_limit" : -1, "<API key>": multi_key(), "<API key>": "select_parent", "<API key>": false, "initially_select" : [ {% if init.initially_select %}"{{ init.initially_select }}"{% else %}"experimenter-0"{% endif %} ], }, // the core plugin - not many options here "core" : { // just open those two nodes up // as this is an AJAX enabled tree, both will be downloaded from the server "initially_open" : [ {% for p in init.initially_open %}"{{ p }}",{% endfor %} "experimenter-0" ] }, "contextmenu" : { "select_node":true, "items" : function(obj){ var config = {}; config["create"] = { "label" : "Create new", "icon" : '{% url webstatic "images/window_new16.png" %}', "submenu": { "project": { "label" : "Project", "icon" : '{% url webstatic "images/folder16.png" %}', "action": function (obj) { this.create(obj, null, {"attr": {"rel": "project"}, "data":"New project"}, false, true); } }, "dataset": { "label" : "Dataset", "icon" : '{% url webstatic "images/folder_image16.png" %}', "action": function (obj) { this.create(obj, null, {"attr":{"rel": "dataset"}, "data":"New dataset"}, false, true); } }, "screen": { "label" : "Screen", "icon" : '{% url webstatic "images/folder_screen16.png" %}', "action": function (obj) { this.create(obj, null, {"attr":{"rel": "screen"}, "data":"New screen"}, false, true); } } } }; config["ccp"] = { "label" : "Edit", "action" : false, "submenu" : { "copy" : { "label" : "Copy", "icon" : '{% url webstatic "images/eclipse_copy_edit16.png" %}', "action": function() { this.copy(this.get_selected()); } }, "cut" :{ "label" : "Cut", "icon" : '{% url webstatic "images/cut16.png" %}', "action": function() { this.cut(this.get_selected()); } }, "paste": { "label" : "Paste", "icon" : '{% url webstatic "images/<API key>.png" %}', "action": function() { this.paste(this.get_selected()); } }, "unlink" : { "label" : "Remove", "icon" : '{% url webstatic "images/minus_15.png" %}', "action": function(){ var tree = this; //empty clipboard tree.data.crrm.ct_nodes = false; tree.data.crrm.cp_nodes = false; var selected = tree.get_selected(); if (selected.length>0) { var images = selected.filter('li[id|=image]'); var datasets = selected.filter('li[id|=dataset]') if (confirm("Remove the "+selected.length+" object(-s) from its current context.")) { if (images.length > 0) tree.move_node(images,$("li#orphaned-0")) if (datasets.length > 0) tree.move_node(datasets, $("li#experimenter-0")); } } } } } }; config["delete"] = { "label" : "Delete", "icon" : '{% url webstatic "images/cancel16.png" %}', "action": function(){ if (confirm("Delete permanently selected object(-s)? You will NOT be able to access this object any more.")) { this.remove(this.get_selected()); } } }; config["basket"] = { "label" : "Add to Basket", "icon" : '{% url webstatic "images/basket16.png" %}', "action": function(){ addToBasket(this.get_selected()); } }; if(obj.attr("rel").indexOf("locked")>=0) { {% if not eContext.isLeader %}config["delete"]["_disabled"] = true;{% endif %} config["ccp"]["_disabled"] = true; config["create"]["_disabled"] = true; config["basket"]["_disabled"] = true; } else { if(obj.attr("id").indexOf("orphaned")>=0) { config["delete"]["_disabled"] = true; config["ccp"]["_disabled"] = true; config["create"]["_disabled"] = true; config["basket"]["_disabled"] = true; } else if(obj.attr("id").indexOf("experimenter")>=0) { config["delete"]["_disabled"] = true; config["ccp"]["_disabled"] = true; config["basket"]["_disabled"] = true; } else if(obj.attr("id").indexOf("project")>=0) { config["ccp"]["submenu"]["cut"]["_disabled"] = true; config["ccp"]["submenu"]["copy"]["_disabled"] = true; config["ccp"]["submenu"]["unlink"]["_disabled"] = true; config["create"]["submenu"]["project"]["_disabled"] = true; config["create"]["submenu"]["screen"]["_disabled"] = true; config["basket"]["_disabled"] = true; if (!this.data.crrm.cp_nodes && !this.data.crrm.ct_nodes) { config["ccp"]["submenu"]["paste"]["_disabled"] = true; } } else if(obj.attr("id").indexOf("dataset")>=0) { if (obj.parent().parent().attr('rel').indexOf('experimenter')>=0) { config["ccp"]["submenu"]["cut"]["_disabled"] = true; config["ccp"]["submenu"]["unlink"]["_disabled"] = true; } if (!this.data.crrm.cp_nodes && !this.data.crrm.ct_nodes) { config["ccp"]["submenu"]["paste"]["_disabled"] = true; } config["create"]["_disabled"] = true; config["basket"]["_disabled"] = true; } else if(obj.attr("id").indexOf("image")>=0) { if (obj.parent().parent().attr('rel').indexOf('orphaned')>=0) { config["ccp"]["submenu"]["cut"]["_disabled"] = true; config["ccp"]["submenu"]["unlink"]["_disabled"] = true; } config["ccp"]["submenu"]["paste"]["_disabled"] = true; config["create"]["_disabled"] = true; } else if(obj.attr("id").indexOf("screen")>=0) { config["ccp"]["submenu"]["cut"]["_disabled"] = true; config["ccp"]["submenu"]["copy"]["_disabled"] = true; config["ccp"]["submenu"]["unlink"]["_disabled"] = true; config["create"]["_disabled"] = true; config["basket"]["_disabled"] = true; if (!this.data.crrm.cp_nodes && !this.data.crrm.ct_nodes) { config["ccp"]["submenu"]["paste"]["_disabled"] = true; } } else if(obj.attr("id").indexOf("plate")>=0) { if (obj.parent().parent().attr('rel').indexOf('experimenter')>=0) { config["ccp"]["submenu"]["cut"]["_disabled"] = true; config["ccp"]["submenu"]["unlink"]["_disabled"] = true; } config["create"]["_disabled"] = true; config["ccp"]["submenu"]["paste"]["_disabled"] = true; config["basket"]["_disabled"] = true; } else { config["ccp"]["_disabled"] = true; config["create"]["_disabled"] = true; config["basket"]["_disabled"] = true; config["delete"]["_disabled"] = true; } } return config; } } }) .delegate("a", "click.jstree", function (e) { var data = $.jstree._focused(); if(!data.is_open() && data.get_selected().length < 2) { data.open_node(data.get_selected()); } }) .delegate("a", "dblclick", function(e) { if ($(this).parent().attr('rel')=='image') { openPopup("{% url web_image_viewer 0 %}".replace('0', $(this).parent().attr('id').split("-")[1])); } }) .bind("select_node.jstree", function (e, data) { buttonsShowHide(data.inst.data.ui.last_selected, data.inst); var selected = data.inst.get_selected(); if (selected.length > 1) { loadMetadataPanel(null,'<p>Multiple objects selected: <br /><a href="#" id="batchAnnotate"><img src="{% url webstatic "images/knotes16.png" %}"/> Batch Annotate</a></p>'); $("#batchAnnotate").click(function() { multipleAnnotation(selected); return false; }); if (selected.filter('li:not([id|=image])').length > 0) { $("div#content_details").empty(); $("div#content_details").removeAttr('rel'); } } else { loadOtherPanels(data.inst, '{% url load_data %}'); } syncPanels(selected); }) .bind("deselect_node.jstree", function (e, data) { var selected = data.inst.get_selected(); buttonsShowHide(data.inst.data.ui.last_selected, data.inst); if (selected.length === 1 && data.args[0].length > 0) { data.rslt.obj = selected; loadOtherPanels(data.inst, '{% url load_data %}'); } syncPanels(selected); }) .bind("open_node.jstree", function (e, data) { }) .bind("create.jstree", function (e, data) { if(data.rslt.parent.attr("rel") == "project") { url = '{% url <API key> "addnewcontainer" %}project/'+data.rslt.parent.attr("id").split("-")[1]+'/'; } else { url = '{% url <API key> "addnewcontainer" %}'; } $.ajax({ url: url, data: { "name" : data.rslt.name, "folder_type" : data.rslt.obj.attr("rel") }, dataType: "json", type: "POST", success: function(r){ if(eval(r.bad)) { $.jstree.rollback(data.rlbk); alert(r.errs); } else { $(data.rslt.obj).attr("id", data.rslt.obj.attr("rel")+"-"+r.id); } }, error: function(response) { $.jstree.rollback(data.rlbk); alert("Internal server error. Cannot create object."); } }); }) .bind("move_node.jstree", function (e, data) { var refresh = false; data.rslt.o.each(function (i) { var remove = false; if (data.inst.data.crrm.cp_nodes) { url = '{% url <API key> "paste" %}'+$(this).attr("rel")+'/'+$(this).attr("id").split("-")[1]+'/' d = { "destination" : data.rslt.np.attr("rel")+'-'+data.rslt.np.attr("id").split("-")[1] } } else { if (data.rslt.cr.attr('rel')!="orphaned") { url = '{% url <API key> "move" %}'+$(this).attr("rel")+'/'+$(this).attr("id").split("-")[1]+'/'; d = { "parent" : data.rslt.op.attr("rel")+'-'+data.rslt.op.attr("id").split("-")[1], "destination" : data.rslt.np.attr("rel")+'-'+data.rslt.np.attr("id").split("-")[1] }; if (data.inst.get_container().find('#'+this.id).length > 1 ) data.inst.delete_node(this); } else { url = '{% url <API key> "remove" %}'+$(this).attr("rel")+'/'+$(this).attr("id").split("-")[1]+'/' d = { "parent" : data.rslt.op.attr("rel")+'-'+data.rslt.op.attr("id").split("-")[1] }; } } $.ajax({ async : false, url: url, data : d, dataType: "json", type: "POST", success: function(r){ if(eval(r.bad)) { $.jstree.rollback(data.rlbk); alert(r.errs); } else { refresh = true; if(data.rslt.cy && $(data.rslt.oc).children("UL").length) { data.inst.refresh(data.inst._get_node(data.rslt.oc)); } } }, error: function(response) { $.jstree.rollback(data.rlbk); alert("Internal server error. "+response); } }); }); if (refresh) { //data.inst.refresh(); if (refresh) { data.inst.deselect_all(); if (!data.inst.is_leaf(data.rslt.op) && $.inArray(data.rslt.op.attr("rel").replace("-locked", ""), ["dataset", "orphaned"]) > -1) data.inst.refresh(data.inst._get_node('#'+data.rslt.op.attr('id'))); data.inst.select_node(data.rslt.op); if (!data.inst.is_leaf(data.rslt.cr) && $.inArray(data.rslt.cr.attr("rel").replace("-locked", ""), ["dataset", "orphaned"]) > -1) data.inst.refresh(data.inst._get_node('#'+data.rslt.cr.attr('id'))); if(!data.inst.data.crrm.cp_nodes && !data.inst.data.crrm.ct_nodes) refreshCenterPanel(); } } }) .bind("remove.jstree", function (e, data) { data.inst.deselect_all(); var ajax_data = new Array(); var q = false; data.args[0].each(function (i) { ajax_data[i] = $(this).attr('id').replace("-","="); if (!q && $(this).attr('rel').indexOf('image')<0) q = true; }); if (q){ if (confirm('Also delete content of selected object(-s)?')) { ajax_data[ajax_data.length] = 'child=on'; } } if (confirm('Also delete linked annotations?')) { ajax_data[ajax_data.length] = 'anns=on'; } url = '{% url <API key> "deletemany" %}' $.ajax({ async : false, url: url, data : ajax_data.join("&"), dataType: "json", type: "POST", success: function(r){ if(eval(r.bad)) { $.jstree.rollback(data.rlbk); alert(r.errs); } else { data.args[0].each(function (i) { data.inst.get_container().find('#'+this.id).each(function() { data.inst.delete_node(this); }); }); refreshProgressBar(); data.inst.load_node($("li#orphaned-0")); } }, error: function(response) { $.jstree.rollback(data.rlbk); alert("Internal server error. Cannot remove object."); } }); }) }); </script> <script type="text/javascript"> $(function () { $("#buttons input").click(function () { switch(this.id) { case "addprojectButton": $("#dataTree").jstree("create", null, "first", { "attr" : { "rel" : 'project' }, "data":"New project" }, false, true); break; case "adddatasetButton": $("#dataTree").jstree("create", null, "first", { "attr" : { "rel" : 'dataset' }, "data":"New dataset" }, false, true); break; case "addscreenButton": $("#dataTree").jstree("create", null, "first", { "attr" : { "rel" : 'screen' }, "data":"New screen" }, false, true); break; case "copyButton": $("#dataTree").jstree('copy', $.jstree._focused().get_selected()); break; case "cutButton": $("#dataTree").jstree('cut', $.jstree._focused().get_selected()); break; case "pasteButton": $("#dataTree").jstree('paste', $.jstree._focused().get_selected()); break; case "unlinkButton": var jstree = $.jstree._focused(); jstree.data.crrm.ct_nodes = false; jstree.data.crrm.cp_nodes = false; var selected = jstree.get_selected(); if (selected.length>0) { var images = selected.filter('li[id|=image]'); var datasets = selected.filter('li[id|=dataset]') if (confirm("Remove the "+selected.length+" object(-s) from its current context.")) { if (images.length > 0) jstree.move_node(images,$("li#orphaned-0")) if (datasets.length > 0) jstree.move_node(datasets,$("li#experimenter-0")); } } break; case "deleteButton": if (confirm("Delete permanently selected object(-s)? You will NOT be able to access this object any more.")) { $("#dataTree").jstree('remove', $.jstree._focused().get_selected()); } break; case "basketButton": addToBasket($.jstree._focused().get_selected()); break; case "refreshButton": $("#dataTree").jstree("refresh"); refreshCenterPanel(); break; default: break; } }); }); </script> {% endblock %} {% block left %} <div class="toolbar"> <div id="buttons" class="align_left"> <input id="refreshButton" class="button" type="image" src="{% url webstatic "images/reload16.png" %}" alt="Refresh" title="Refresh" {% comment %}onclick="document.location.href='{% url load_template nav.menu %}'"{% endcomment %}> <input class="button" type="image" src="{% url webstatic "images/view_tag16.png" %}" alt="Tags" title="Tags" onclick="document.location.href='{% url load_template "usertags" %}'"> | <input id="addprojectButton" class="button button-disabled" type="image" src="{% url webstatic "images/folder16.png" %}" alt="Create new project" title="Create new Project" /> <input id="adddatasetButton" class="button button-disabled" type="image" src="{% url webstatic "images/folder_image16.png" %}" alt="Create new dataset" title="Create new Dataset" /> <input id="addscreenButton" class="button button-disabled" type="image" src="{% url webstatic "images/folder_screen16.png" %}" alt="Create new screen" title="Create new Screen" /> | <input id="copyButton" class="button button-disabled" type="image" src="{% url webstatic "images/eclipse_copy_edit16.png" %}" alt="Copy" title="Copy" /> <input id="cutButton" class="button button-disabled" type="image" src="{% url webstatic "images/cut16.png" %}" alt="Cut" title="Cut" /> <input id="pasteButton" class="button button-disabled" type="image" src="{% url webstatic "images/<API key>.png" %}" alt="Paste" title="Paste" /> <input id="unlinkButton" class="button button-disabled" type="image" src="{% url webstatic "images/minus_15.png" %}" alt="Remove" title="Remove" /> <input id="deleteButton" class="button button-disabled" type="image" src="{% url webstatic "images/cancel16.png" %}" alt="Delete" title="Delete" /> <input id="basketButton" class="button button-disabled" type="image" src="{% url webstatic "images/basket16.png" %}" alt="Add to basket" title="Add to basket"> </div> </div> <div class="clear"> </div> <div id="tree_details"> <div class="dataTree" id="dataTree"></div> </div> {% endblock %} {% block center %} <div id="content_details"> </div> {% endblock %} {% block right %} <script type="text/javascript"> function openScriptWindow(event) { // open script url, providing Data_Type and IDs params in request var script_url = $(this).attr('href'); if (script_url == "#") return false; var datatree = $.jstree._focused(); var ids = new Array(); var Data_Type = null; var selected = datatree.data.ui.selected; if (selected.size() == 1) { var klass = selected.attr('rel'); if (klass == 'plate' || klass == 'acquisition') { var plateSelected = $('#spw .ui-selected img'); if (plateSelected.size() > 0) { selected = plateSelected; } } } selected.each(function() { var dtype = this.id.split("-")[0]; if (Data_Type == undefined) { Data_Type = dtype; ids.push(this.id.split("-")[1]); } else if (Data_Type == dtype) { // need to be sure our IDs are all of the same dtype ids.push(this.id.split("-")[1]); } }); Data_Type = Data_Type.charAt(0).toUpperCase() + Data_Type.slice(1); // capitalise script_url += "?Data_Type="+ Data_Type +"&IDs="+ ids.join(); openCenteredWindow(script_url); return false; } $(document).ready(function(){ // Loading Scripts with AJAX for drop-down menu, (only the first time we click) $("#scriptButton").click(function(e){ if ($("#scriptList li").length == 0){ // if none loaded yet... var $scriptLink = $(this).hide(); var $scriptSpinner = $("#scriptSpinner").show(); var script_list_url = $(this).attr('href'); $("#scriptList").load(script_list_url, function(){ // Now show the menu and add ">>" to any <li> with child <ul> $('ul.sub_menu').css('visibility', 'visible'); $("ul.sub_menu li:has(ul)").find("a:first").append(" &raquo; "); // bind links to openPopup $("ul.sub_menu a").click(openScriptWindow); $scriptLink.show(); $scriptSpinner.hide(); }); } else { $('ul.sub_menu').css('visibility', 'visible'); } e.preventDefault(); return false; }); // on hover-out, hide drop-down menus $("#scriptList").hover(function(){}, function(){ $(this).css('visibility', 'hidden'); }); }); </script> <style type="text/css"> .dropdown { font-weight: bold; float: left; zoom: 1; position: relative; } .dropdown li a { display: block; padding: 4px 8px; border-right: 1px solid #333; color: #222; } .dropdown li:last-child a { border-right: none; } /* Doesn't work in IE */ .dropdown li.hover, .dropdown li:hover { background: #ddf; color: black; position: relative; } .dropdown li.hover a { color: black; } .dropdown ul { width: 170px; visibility: hidden; position: absolute; top: 100%; left: 0; z-index:50; margin: 0; padding: 0; list-style:none; border:solid black 1px;} .dropdown ul li { font-weight: normal; background: #fff; color: #000; border-bottom: 1px solid #eee; float: none; } .dropdown ul li a { border-right: none; width: 100%; display: inline-block; } /* IE 6 & 7 Needs Inline Block */ ul.sub_menu li ul { left: 100%; top: 0;} ul.sub_menu li:hover > ul { visibility: visible;} </style> <div id="metadata_details"> <div id="toolbar-right" class="dropdown" style="padding-top: 7px"> <!-- Script launcher --> <a id="scriptButton" href="{% url list_scripts %}"> <img src="{% url webstatic 'images/nuvola_script-run16.png' %}" /> </a> <img id="scriptSpinner" style="display:none" src="{% url webstatic 'images/spinner.gif' %}" /> <ul id="scriptList" class="sub_menu"> <!-- script list-items loaded here by AJAX --> </ul> </div> <div style="clear:both"></div> <div id="<API key>"></div> <iframe width="370" name="metadata_details" frameborder="0"></iframe> </div> {% endblock %}
<! UCSF Chimera Copyright Copyright (c) 2009-2011 Regents of the University of California. All rights reserved. This software provided pursuant to a license agreement containing restrictions on its disclosure, duplication and use. This notice must be embedded in or attached to all copies, including partial copies, of the software or any revisions or derivations thereof. UCSF Chimera Copyright <html><head> <title>pause</title> </head><body> <font size="-1"> <a href="../framecommand.html" target="_top">Chimera Commands Index</a> </font> <h3><a href="usageconventions.html">Usage</a>: <br><b>pause</b> [ end ]</h3> <p> The <b>pause</b> command without arguments suspends <a href="../indexcommand.html#cmdfile">command script</a> execution. During the resulting pause, pressing the <b>End</b> or <b>Esc</b> key will abort script execution, whereas pressing any other key will resume execution. The <b>end</b> keyword indicates aborting immediately, as if the <b>End</b> key had been pressed. </p><p> Alternatively (without use of the <b>pause</b> command), command script execution can be paused/resumed by pressing <b>Shift</b>-<b>Esc</b> or aborted by pressing <b>Esc</b>. </p><p> The pause will not be included in any <a href="../movies.html">movie</a> that is being recorded, because no new frames are drawn during that time; to generate pauses in a movie, <b><A href="wait.html">wait</A></b> should be used instead. <p> See also: <b><A href="sleep.html">sleep</A></b> </p> </body></html>
package com.cubes.cubesandroidsdk.config; /** * Represents type of banner * @author makarenko.s * */ public class AdsType { /** * Banner with top or bottom bar */ public static final int MULTIPART = 100; /** * Full screen banner */ public static final int INTERSTITIAL = 101; /** * Ads with small bar and full-screen banner (expandable ads) */ public static final int MULTIPART_LOGO = 102; public static final int LOGO_AD = 103; }
// associated documentation files (the "Software"), to deal in the Software without restriction, // including without limitation the rights to use, copy, modify, merge, publish, distribute, // furnished to do so, subject to the following conditions: // substantial portions of the Software. // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef <API key> #define <API key> // Boost: #include <boost/date_time/posix_time/posix_time_types.hpp> // STL: #include <vector> namespace malmo { //! An array of unsigned chars with an attached timestamp saying when it was collected. struct <API key> { //! The timestamp. boost::posix_time::ptime timestamp; //! The array of unsigned char values. std::vector<unsigned char> data; <API key>(boost::posix_time::ptime timestamp, std::vector<unsigned char> data) : timestamp(timestamp) , data(data) { } <API key>() { } }; } #endif
/* $Id: <API key>.cpp 56290 2015-06-09 14:01:31Z vboxsync $ */ /** @file * IPRT - RTSystemShutdown, Windows. */ #include <iprt/system.h> #include "internal/iprt.h" #include <iprt/assert.h> #include <iprt/err.h> #include <iprt/string.h> #include <Windows.h> RTDECL(int) RTSystemShutdown(RTMSINTERVAL cMsDelay, uint32_t fFlags, const char *pszLogMsg) { AssertPtrReturn(pszLogMsg, <API key>); AssertReturn(!(fFlags & ~<API key>), <API key>); PRTUTF16 pwszLogMsg; int rc = RTStrToUtf16(pszLogMsg, &pwszLogMsg); if (RT_FAILURE(rc)) return rc; DWORD cSecsTimeout = (cMsDelay + 499) / 1000; BOOL <API key> = (fFlags & <API key>) == <API key> ? TRUE : FALSE; BOOL fForceAppsClosed = fFlags & <API key> ? TRUE : FALSE; /* * Do the */ if (<API key>(NULL /*pwszMachineName = NULL = localhost*/, pwszLogMsg, cSecsTimeout, fForceAppsClosed, <API key>)) rc = (fFlags & <API key>) == <API key> ? <API key> : VINF_SUCCESS; else { /* If we failed because of missing privileges, try get the right to shut down the system and call the api again. */ DWORD dwErr = GetLastError(); rc = <API key>(dwErr); if (dwErr == ERROR_ACCESS_DENIED) { HANDLE hToken = NULL; if (OpenThreadToken(GetCurrentThread(), <API key>, TRUE /*OpenAsSelf*/, &hToken)) dwErr = NO_ERROR; else { dwErr = GetLastError(); if (dwErr == ERROR_NO_TOKEN) { if (OpenProcessToken(GetCurrentProcess(), <API key>, &hToken)) dwErr = NO_ERROR; else dwErr = GetLastError(); } } if (dwErr == NO_ERROR) { union { TOKEN_PRIVILEGES TokenPriv; char ab[sizeof(TOKEN_PRIVILEGES) + sizeof(LUID_AND_ATTRIBUTES)]; } u; u.TokenPriv.PrivilegeCount = 1; u.TokenPriv.Privileges[0].Attributes = <API key>; if (<API key>(NULL /*localhost*/, SE_SHUTDOWN_NAME, &u.TokenPriv.Privileges[0].Luid)) { if (<API key>(hToken, FALSE /*<API key>*/, &u.TokenPriv, RT_OFFSETOF(TOKEN_PRIVILEGES, Privileges[1]), NULL, NULL) ) { if (<API key>(NULL /*pwszMachineName = NULL = localhost*/, pwszLogMsg, cSecsTimeout, fForceAppsClosed, <API key>)) rc = (fFlags & <API key>) == <API key> ? <API key> : VINF_SUCCESS; else { dwErr = GetLastError(); rc = <API key>(dwErr); } } CloseHandle(hToken); } } } } RTUtf16Free(pwszLogMsg); return rc; } RT_EXPORT_SYMBOL(RTSystemShutdown);
/* $Id: avlou32.cpp $ */ /** @file * IPRT - AVL tree, uint_32, unique keys, offset pointers. */ #ifndef NOFILEID static const char szFileId[] = "Id: kAVLULInt.c,v 1.4 2003/02/13 02:02:38 bird Exp $"; #endif /* * AVL configuration. */ #define KAVL_FN(a) RTAvloU32 #define KAVL_MAX_STACK 27 /* Up to 2^24 nodes. */ #define <API key> 1 /* No duplicate keys! */ #define KAVLNODECORE AVLOU32NODECORE #define PKAVLNODECORE PAVLOU32NODECORE #define PPKAVLNODECORE PPAVLOU32NODECORE #define KAVLKEY AVLOU32KEY #define PKAVLKEY AVLOU32KEY * #define KAVLENUMDATA AVLOU32ENUMDATA #define PKAVLENUMDATA PAVLOU32ENUMDATA #define PKAVLCALLBACK PAVLOU32CALLBACK #define KAVL_OFFSET 1 /* * AVL Compare macros */ #define KAVL_G( key1, key2) ( (key1) > (key2) ) #define KAVL_E( key1, key2) ( (key1) == (key2) ) #define KAVL_NE(key1, key2) ( (key1) != (key2) ) #include <iprt/avl.h> #include <iprt/assert.h> #include <iprt/err.h> /* * Include the code. */ #define SSToDS(ptr) ptr #define KMAX RT_MAX #define kASSERT Assert #include "avl_Base.cpp.h" #include "avl_Get.cpp.h" #include "avl_DoWithAll.cpp.h" #include "avl_GetBestFit.cpp.h" #include "avl_RemoveBestFit.cpp.h" #include "avl_Destroy.cpp.h"
// jQuery File Tree Plugin // Version 1.02 // Cory S.N. LaViska // 24 March 2008 // Usage: $('.fileTreeDemo').fileTree( options, callback ) // Options: root - root folder to display; default = / // script - location of the serverside AJAX file to use; default = jqueryFileTree.php // folderEvent - event to trigger expand/collapse; default = click // expandSpeed - default = 500 (ms); use -1 for no animation // collapseSpeed - default = 500 (ms); use -1 for no animation // expandEasing - easing function to use on expand (optional) // collapseEasing - easing function to use on collapse (optional) // multiFolder - whether or not to limit the browser to one subfolder at a time // loadMessage - Message to display while initial tree loads (can be HTML) // History: // 1.02 - updated to allow pre-selection of nodes (Josh Heidenreich, 25 August 2009) // 1.01 - updated to work with foreign characters in directory/file names (12 April 2008) // 1.00 - released (24 March 2008) // TERMS OF USE if(jQuery) (function($){ $.extend($.fn, { fileTree: function(o, h) { // Defaults if( !o ) var o = {}; if( o.root == undefined ) o.root = '/'; if( o.script == undefined ) o.script = 'jqueryFileTree.php'; if( o.closeScript == undefined ) o.closeScript = null; if( o.folderEvent == undefined ) o.folderEvent = 'click'; if( o.expandSpeed == undefined ) o.expandSpeed= 500; if( o.collapseSpeed == undefined ) o.collapseSpeed= 500; if( o.expandEasing == undefined ) o.expandEasing = null; if( o.collapseEasing == undefined ) o.collapseEasing = null; if( o.multiFolder == undefined ) o.multiFolder = true; if( o.loadMessage == undefined ) o.loadMessage = 'Loading...'; if( o.showNodes == undefined ) o.showNodes = []; $(this).each( function() { function showTree(c, t) { $(c).addClass('wait'); $(".jqueryFileTree.start").remove(); $.post(o.script, { dir: t }, function(data) { $(c).find('.start').html(''); $(c).removeClass('wait').append(data); if( o.root == t ) $(c).find('UL:hidden').show(); else $(c).find('UL:hidden').slideDown({ duration: o.expandSpeed, easing: o.expandEasing }); bindTree(c); for( key in o.showNodes ) { $('.collapsed > a[rel=' + o.showNodes[key] +']', c).trigger(o.folderEvent); o.showNodes.splice(key, 0); } }); } function bindTree(t, dirname) { $(t).find('LI A').bind(o.folderEvent, function() { if( $(this).parent().hasClass('directory') ) { if( $(this).parent().hasClass('collapsed') ) { // Expand if( !o.multiFolder ) { $(this).parent().parent().find('UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing }); $(this).parent().parent().find('LI.directory').removeClass('expanded').addClass('collapsed'); } $(this).parent().find('UL').remove(); // cleanup showTree( $(this).parent(), escape($(this).attr('rel').match( /.*\ $(this).parent().removeClass('collapsed').addClass('expanded'); } else { // Collapse if (o.closeScript) $.post(o.closeScript, { dir: escape($(this).attr('rel').match( /.*\ $(this).parent().find('UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing }); $(this).parent().find('P').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing }); $(this).parent().removeClass('expanded').addClass('collapsed'); } } else { h('main', $(this).attr('rel')); } return false; }); $(t).find('LI A').mouseup(function(event) { if (event.button == 2) { nav_actions(this); } event.stopPropagation(); return false; }); $(t).find('LI A').each(function(i) { this.oncontextmenu = function() {return false;}; }); // Prevent A from triggering the # on non-click events if( o.folderEvent.toLowerCase != 'click' ) $(t).find('LI A').bind('click', function() { return false; }); } // Loading message $(this).html('<ul class="jqueryFileTree start"><li class="wait">' + o.loadMessage + '<li></ul>'); // Get the initial file list showTree( $(this), escape(o.root) ); }); } }); })(jQuery);
// Z1013 Sprungverteiler extern unsigned char z1013_spvt_inkey(); extern unsigned char z1013_spvt_poll(); extern unsigned char z1013_spvt_stat(); extern void z1013_spvt_saruf(); extern void z1013_spvt_loruf(); /* FFEEH - JMP ZMINI Initialisierung der Z-Monitorrufe auf B0H */ extern void z1013_spvt_zmini(); extern void z1013_spvt_drdel(); extern void z1013_spvt_drakk(unsigned char c); extern void z1013_spvt_bsdr(); extern void z1013_spvt_hardc(unsigned char c); extern void z1013_spvt_drzel(); /* FFDCH - JMP BEEP erzeugen eines kurzen Signals */ extern void z1013_spvt_beep(); /* FFD9H - JMP ASTA Ausgabe Akkuinhalt als ASCII-Zeichen an PUNCH */ extern void z1013_spvt_asta(unsigned char); /* FFD6H - JMP BSTA Ausgabe Akkuinhalt als Hexadezimalwert an PUNCH */ extern void z1013_spvt_bsta(); extern unsigned char z1013_spvt_ain(); extern unsigned char z1013_spvt_bin(); /* FFCDH - JMP DRINI Initialisierung des logischen Druckertreibers */ extern void z1013_spvt_drini(); extern void z1013_spvt_zeidr(unsigned char c); extern void z1013_spvt_blmk(); extern unsigned int z1013_spvt_bsmk(unsigned int HL, unsigned int IX, unsigned int DE); extern void z1013_spvt_suchk(); extern void z1013_spvt_akp(); #define JOYSTICK_LEFT 1 #define JOYSTICK_RIGHT 2 #define JOYSTICK_DOWN 4 #define JOYSTICK_UP 8 #define JOYSTICK_FIRE 16 extern unsigned int z1013_spvt_getst(); extern void z1013_spvt_sound(unsigned char periode); extern void z1013_spvt_bsave(); extern void z1013_spvt_bload(); #ifdef __SDCC #define PRST7(X) \ __asm__("rst 0x20"); \ __asm__(".db 2 ;PRST7"); \ __asm__(".ascis " #endif extern void OUTCH(unsigned char); //UP:00 extern unsigned char INCH(); //UP:01 extern unsigned char INKEY(); //UP:04 extern void OUTHL(unsigned int); //UP:06 extern void OUTHX(unsigned char); //UP:07 __at (0x04) unsigned char Z1013_KEYCODE; __at (0x1f) unsigned char Z1013_CODE; __at (0x2b) unsigned char * Z1013_CURSR; __at (0xec00) unsigned char Z1013_BWS[32*32]; #define GOTOXY(X,Y) Z1013_CURSR=(char*)0xec00+(Y)*32+(X) /* BYTES PER LINE Anzahl der Zeichen pro Zeile */ #define BPL 32
# BaseThought.py # This file is part of Labyrinth # Labyrinth is free software; you can redistribute it and/or modify # (at your option) any later version. # Labyrinth is distributed in the hope that it will be useful, # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # along with Labyrinth; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA from gi.repository import GObject from gi.repository import Gtk import utils from gi.repository import Pango import TextBufferMarkup import UndoManager UNDO_RESIZE = 0 UNDO_DRAW = 1 UNDO_ERASE = 2 MIN_SIZE = 20 DEFAULT_WIDTH = 100 DEFAULT_HEIGHT = 70 class BaseThought (GObject.GObject): ''' The basic class to derive other thoughts from. \ Instructions for creating derivative thought types are \ given as comments''' # These are general signals. They are available to all thoughts to # emit. If you emit other signals, the chances are they'll be ignored # by the MMapArea. It's you're responsiblity to catch and handle them. # All these signals are handled correctly by the MMapArea. __gsignals__ = dict (select_thought = (GObject.SignalFlags.RUN_FIRST, None, (GObject.TYPE_PYOBJECT,)), update_view = (GObject.SignalFlags.RUN_LAST, None, ()), create_link = (GObject.SignalFlags.RUN_FIRST, None, (GObject.TYPE_PYOBJECT,)), title_changed = (GObject.SignalFlags.RUN_LAST, None, (GObject.TYPE_STRING,)), <API key> = (GObject.SignalFlags.RUN_LAST, None, (GObject.TYPE_INT, GObject.TYPE_INT, GObject.TYPE_STRING)), change_mouse_cursor = (GObject.SignalFlags.RUN_FIRST, None, (GObject.TYPE_INT,)), update_links = (GObject.SignalFlags.RUN_LAST, None, ()), grab_focus = (GObject.SignalFlags.RUN_FIRST, None, (GObject.TYPE_BOOLEAN,)), update_attrs = (GObject.SignalFlags.RUN_FIRST, None, (GObject.TYPE_BOOLEAN, GObject.TYPE_BOOLEAN, GObject.TYPE_BOOLEAN, Pango.FontDescription))) # The first thing that should be called is this constructor # It sets some basic properties of all thoughts and should be called # before you start doing you're own thing with thoughts # save: the save document passed into the derived constructor # elem_type: a string representing the thought type (e.g. "image_thought") def __init__ (self, save, elem_type, undo, background_color, foreground_color): # Note: Once the thought has been successfully initialised (i.e. at the end # of the constructor) you MUST set all_okay to True # Otherwise, bad things will happen. self.all_okay = False super (BaseThought, self).__init__() self.ul = self.lr = None self.am_primary = False self.am_selected = False self.sensitive = 5 self.editing = False self.identity = -1 self.index = 0 self.end_index = 0 self.text = "" self.undo = undo self.background_color = background_color self.foreground_color = foreground_color self.model_iter = None extended_elem = save.createElement ("Extended") self.extended_buffer = TextBufferMarkup.ExtendedBuffer (self.undo, extended_elem, save) self.extended_buffer.set_text("") self.extended_buffer.connect ("set_focus", self.focus_buffer) self.extended_buffer.connect ("set_attrs", self.set_extended_attrs) self.element = save.createElement (elem_type) self.element.appendChild (extended_elem) self.creating = True # These are self-explanitory. You probably don't want to # overwrite these methods, unless you have a very good reason def get_save_element (self): return self.element def make_primary (self): self.am_primary = True def select (self): self.am_selected = True def unselect (self): self.am_selected = False def get_max_area (self): if not self.ul or not self.lr: return 999,999,-999,-999 return self.ul[0], self.ul[1], self.lr[0], self.lr[1] def okay (self): return self.all_okay def move_content_by (self, x, y): pass def move_by (self, x, y): pass def focus_buffer (self, buf): self.emit ("select_thought", None) self.emit ("grab_focus", True) def set_extended_attrs(self, buf, bold, underline, italics, pango_font): self.emit("update_attrs", bold, underline, italics, pango_font) def can_be_parent (self): return True # This, you may want to change. Though, doing so will only affect # thoughts that are "parents" def find_connection (self, other): if not self.ul or not self.lr or not other.ul \ or not other.lr: return None, None if utils.use_bezier_curves: if other.ul[0] > self.lr[0]: xfrom = self.lr[0] xto = other.ul[0] else: xfrom = self.ul[0] xto = other.lr[0] else: xfrom = self.ul[0]-((self.ul[0]-self.lr[0]) / 2.) xto = other.ul[0]-((other.ul[0]-other.lr[0]) / 2.) yfrom = self.ul[1]-((self.ul[1]-self.lr[1]) / 2.) yto = other.ul[1]-((other.ul[1]-other.lr[1]) / 2.) return (xfrom, yfrom), (xto, yto) # All the rest of these should be handled within you're thought # type, supposing you actually want to handle them. # You almost certianly do want to ;) def process_button_down (self, event, transformed): return False def <API key> (self, event, transformed): return False def process_key_press (self, event, mode): return False def handle_motion (self, event, transformed): return False def includes (self, coords): pass def draw (self, context): pass def load (self, node, tar): pass def update_save (self): pass def save (self, tar): pass def copy_text (self, clip): pass def cut_text (self, clip): pass def paste_text (self, clip): pass def export (self, context, move_x, move_y): pass def commit_text (self, im_context, string, mode): pass def recalc_edges (self): pass def delete_surroundings(self, imcontext, offset, n_chars, mode): pass def preedit_changed (self, imcontext, mode): pass def preedit_end (self, imcontext, mode): pass def preedit_start (self, imcontext, mode): pass def <API key> (self, imcontext, mode): pass def set_bold (self, active): pass def inside (self, inside): pass def enter (self): pass def leave (self): pass RESIZE_NONE = 0 RESIZE_LEFT = 1 RESIZE_RIGHT = 2 RESIZE_TOP = 4 RESIZE_BOTTOM = 8 CURSOR = {} CURSOR[RESIZE_LEFT] = Gdk.LEFT_SIDE; CURSOR[RESIZE_RIGHT] = Gdk.RIGHT_SIDE; CURSOR[RESIZE_TOP] = Gdk.TOP_SIDE; CURSOR[RESIZE_BOTTOM] = Gdk.BOTTOM_SIDE; CURSOR[RESIZE_LEFT|RESIZE_TOP] = Gdk.TOP_LEFT_CORNER; CURSOR[RESIZE_LEFT|RESIZE_BOTTOM] = Gdk.BOTTOM_LEFT_CORNER; CURSOR[RESIZE_RIGHT|RESIZE_TOP] = Gdk.TOP_RIGHT_CORNER; CURSOR[RESIZE_RIGHT|RESIZE_BOTTOM] = Gdk.BOTTOM_RIGHT_CORNER; class ResizableThought (BaseThought): ''' A resizable thought base class. This allows the sides and corners \ of the thought to be dragged around. It only provides the very basic \ functionality. Other stuff must be done within the derived classes''' # Possible types of resizing - where the user selected to resize def __init__ (self, coords, save, elem_type, undo, background_color, foreground_color): super (ResizableThought, self).__init__(save, elem_type, undo, background_color, foreground_color) self.resizing = RESIZE_NONE self.button_down = False self.orig_size = None if coords: margin = utils.margin_required (utils.STYLE_NORMAL) self.ul = (coords[0]-margin[0], coords[1]-margin[1]) self.lr = (coords[0]+margin[2], coords[1]+margin[3]) self.width = 1 self.height = 1 self.min_x = self.max_x = None self.min_y = self.max_y = None def move_content_by (self, x, y): if self.min_x != None: self.min_x += x if self.min_y != None: self.min_y += y if self.max_x != None: self.max_x += x if self.max_y != None: self.max_y += y def move_by (self, x, y): self.move_content_by(x, y) self.ul = (self.ul[0]+x, self.ul[1]+y) self.recalc_edges () self.emit ("update_links") self.emit ("update_view") def inside (self, inside): self.emit ("change_mouse_cursor", Gdk.CursorType.LEFT_PTR) def includes (self, coords): if not self.ul or not self.lr or not coords: return False if self.button_down: resizing = self.resizing inside = True else: inside = (coords[0] < self.lr[0] + self.sensitive) and \ (coords[0] > self.ul[0] - self.sensitive) and \ (coords[1] < self.lr[1] + self.sensitive) and \ (coords[1] > self.ul[1] - self.sensitive) resizing = RESIZE_NONE if inside: # 2 cases: 1. The click was within the main area # 2. The click was near the border # In the first case, we handle as normal # In the second case, we want to intercept all the fun thats # going to happen so we can resize the thought if abs (coords[0] - self.ul[0]) <= self.sensitive: if coords[1] <= self.lr[1] and coords[1] >= self.ul[1]: resizing = resizing | RESIZE_LEFT elif abs (coords[0] - self.lr[0]) <= self.sensitive: if coords[1] <= self.lr[1] and coords[1] >= self.ul[1]: resizing = resizing | RESIZE_RIGHT if abs (coords[1] - self.ul[1]) <= self.sensitive and \ (coords[0] <= self.lr[0] and coords[0] >= self.ul[0]): resizing = resizing | RESIZE_TOP elif abs (coords[1] - self.lr[1]) <= self.sensitive and \ (coords[0] <= self.lr[0] and coords[0] >= self.ul[0]): resizing = resizing | RESIZE_BOTTOM if resizing == RESIZE_NONE: self.inside(inside) else: self.emit ("change_mouse_cursor", CURSOR[resizing]) self.resizing = resizing return inside def process_button_down(self, event, coords): self.orig_size = None if self.resizing: self.button_down = True self.orig_size = (self.ul, self.width, self.height) return True return False def <API key>(self, event, coords): self.resizing = RESIZE_NONE self.button_down = False if self.width < MIN_SIZE or self.height < MIN_SIZE: self.width = max(MIN_SIZE, self.width) self.height = max(MIN_SIZE, self.height) self.recalc_edges() return True def handle_motion (self, event, coords): if not self.resizing or not self.button_down: return False resizing = False if self.resizing & RESIZE_LEFT: if self.min_x is None or coords[0] < self.lr[0]-(self.max_x-self.min_x): if self.min_x and coords[0] > self.min_x: self.move_content_by(coords[0] - self.min_x, 0) self.ul = (coords[0], self.ul[1]) resizing = True; elif self.resizing & RESIZE_RIGHT: if self.max_x is None or coords[0] > self.ul[0]+(self.max_x-self.min_x): if self.max_x and coords[0] < self.max_x: self.move_content_by(coords[0] - self.max_x, 0) self.lr = (coords[0], self.lr[1]) resizing = True; if self.resizing & RESIZE_TOP: if self.min_y is None or coords[1] < self.lr[1]-(self.max_y-self.min_y): if self.min_y and coords[1] > self.min_y: self.move_content_by(0, coords[1] - self.min_y) self.ul = (self.ul[0], coords[1]) resizing = True; elif self.resizing & RESIZE_BOTTOM: if self.max_y is None or coords[1] > self.ul[1]+(self.max_y-self.min_y): if self.max_y and coords[1] < self.max_y: self.move_content_by(0, coords[1] - self.max_y) self.lr = (self.lr[0], coords[1]) resizing = True; if not resizing: return False if self.ul[0] > self.lr[0]: # horizontal mirroring tmp = self.ul[0] self.ul = (self.lr[0], self.ul[1]) self.lr = (tmp, self.lr[1]) self.resizing = (~self.resizing & 0x3) | (self.resizing & (0x3<<2)) if self.ul[1] > self.lr[1]: # vertical mirroring tmp = self.ul[1] self.ul = (self.ul[0], self.lr[1]) self.lr = (self.lr[0], tmp) self.resizing = (~self.resizing & (0x3<<2)) | (self.resizing & 0x3) self.width = self.lr[0] - self.ul[0] self.height = self.lr[1] - self.ul[1] return True def leave (self): self.editing = False self.emit('change_mouse_cursor', Gdk.CursorType.LEFT_PTR) def undo_resize (self, action, mode): self.undo.block () if mode == UndoManager.UNDO: choose = 0 else: choose = 1 self.ul = action.args[choose][0] self.width = action.args[choose][1] self.height = action.args[choose][2] self.pic = self.orig_pic.scale_simple (int(self.width), int(self.height), GdkPixbuf.InterpType.HYPER) self.recalc_edges () self.emit ("update_links") self.emit ("update_view") self.undo.unblock () def draw (self, context): if len (self.extended_buffer.get_text()) == 0: utils.<API key> (context, self.ul, self.lr, self.background_color, self.am_selected, self.am_primary, utils.STYLE_NORMAL) else: utils.<API key> (context, self.ul, self.lr, self.background_color, self.am_selected, self.am_primary, utils.<API key>)
#ifndef <API key> #define <API key> #include "content/public/browser/<API key>.h" #include "content/public/browser/<API key>.h" namespace ash { class <API key>; } namespace chromeos { ash::<API key>* <API key>(); } #endif
package org.owasp.benchmark.testcode; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet("/BenchmarkTest15028") public class BenchmarkTest15028 extends HttpServlet { private static final long serialVersionUID = 1L; @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String param = request.getHeader("foo"); String bar = doSomething(param); response.getWriter().println(bar); } // end doPost private static String doSomething(String param) throws ServletException, IOException { // Chain a bunch of propagators in sequence String a26874 = param; //assign StringBuilder b26874 = new StringBuilder(a26874); // stick in stringbuilder b26874.append(" SafeStuff"); // append some safe content b26874.replace(b26874.length()-"Chars".length(),b26874.length(),"Chars"); //replace some of the end content java.util.HashMap<String,Object> map26874 = new java.util.HashMap<String,Object>(); map26874.put("key26874", b26874.toString()); // put in a collection String c26874 = (String)map26874.get("key26874"); // get it back out String d26874 = c26874.substring(0,c26874.length()-1); // extract most of it String e26874 = new String( new sun.misc.BASE64Decoder().decodeBuffer( new sun.misc.BASE64Encoder().encode( d26874.getBytes() ) )); // B64 encode and decode it String f26874 = e26874.split(" ")[0]; // split it on a space org.owasp.benchmark.helpers.ThingInterface thing = org.owasp.benchmark.helpers.ThingFactory.createThing(); String g26874 = "<API key>"; // This is static so this whole flow is 'safe' String bar = thing.doSomething(g26874); // reflection return bar; } }
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ #include "logging/nm-logging.h" #include "nm-netlink-utils.h" #include "nm-netlink-monitor.h" #include "nm-netlink-compat.h" #include <arpa/inet.h> #include <netinet/in.h> #include <netlink/netlink.h> #include <netlink/addr.h> #include <netlink/route/addr.h> #include <errno.h> typedef struct { int ifindex; int family; void *addr; int addrlen; int prefix; gboolean found; } FindAddrInfo; static void find_one_address (struct nl_object *object, void *user_data) { FindAddrInfo *info = user_data; struct rtnl_addr *addr = (struct rtnl_addr *) object; struct nl_addr *local; void *binaddr; if (info->found) return; if (<API key> (addr) != info->ifindex) return; if (<API key> (addr) != info->family) return; if (<API key> (addr) != info->prefix) return; local = rtnl_addr_get_local (addr); if (nl_addr_get_family (local) != info->family) return; if (nl_addr_get_len (local) != info->addrlen) return; binaddr = <API key> (local); if (binaddr) { if (memcmp (binaddr, info->addr, info->addrlen) == 0) info->found = TRUE; /* Yay, found it */ } } /** * <API key>: * @ifindex: interface index * @family: address family, either AF_INET or AF_INET6 * @addr: binary address, either struct in_addr* or struct in6_addr* * @prefix: prefix length * * Searches for a matching address on the given interface. * * Returns: %TRUE if the given address was found on the interface, %FALSE if it * was not found or an error occurred. **/ gboolean <API key> (int ifindex, int family, void *addr, /* struct in_addr or struct in6_addr */ int prefix) { struct nl_sock *nlh = NULL; struct nl_cache *cache = NULL; FindAddrInfo info; <API key> (ifindex > 0, FALSE); <API key> (family == AF_INET || family == AF_INET6, FALSE); <API key> (addr != NULL, FALSE); <API key> (prefix >= 0, FALSE); memset (&info, 0, sizeof (info)); info.ifindex = ifindex; info.family = family; info.prefix = prefix; info.addr = addr; if (family == AF_INET) info.addrlen = sizeof (struct in_addr); else if (family == AF_INET6) info.addrlen = sizeof (struct in6_addr); else <API key> (); nlh = <API key> (); if (nlh) { <API key>(nlh, &cache); if (cache) { <API key> (cache); nl_cache_foreach (cache, find_one_address, &info); nl_cache_free (cache); } } return info.found; } struct rtnl_route * <API key> (int ifindex, int family, int mss, ) { va_list var_args; struct rtnl_route *route; NmNlProp prop = NMNL_PROP_INVALID; int value; route = rtnl_route_alloc (); <API key> (route != NULL, NULL); if (ifindex >= 0) rtnl_route_set_oif (route, ifindex); if (family != AF_UNSPEC) <API key> (route, family); if (mss > 0) <API key> (route, RTAX_ADVMSS, mss); va_start (var_args, mss); prop = va_arg (var_args, NmNlProp); while (prop != NMNL_PROP_INVALID) { value = va_arg (var_args, int); if (prop == NMNL_PROP_PROT && value != RTPROT_UNSPEC) <API key> (route, value); else if (prop == NMNL_PROP_TABLE && value != RT_TABLE_UNSPEC) <API key> (route, value); else if (prop == NMNL_PROP_SCOPE && value != RT_SCOPE_NOWHERE) <API key> (route, value); else if (prop == NMNL_PROP_PRIO && value > 0) <API key> (route, value); prop = va_arg (var_args, NmNlProp); } va_end (var_args); return route; } /** * <API key>: * @route: the route to add * * Returns: zero if succeeded or the netlink error otherwise. **/ int <API key>(struct rtnl_route * route, int family, const void * dest, /* in_addr or in6_addr */ int dest_prefix, const void * gateway, /* in_addr or in6_addr */ int flags) { struct nl_sock * sk; struct nl_addr * dest_addr, * gw_addr; void * tmp_addr; int addrlen, err, log; if(family == AF_INET) { addrlen = sizeof(struct in_addr); log = LOGD_IP4; } else if (family == AF_INET6) { addrlen = sizeof(struct in6_addr); log = LOGD_IP6; } else { <API key> (); } sk = <API key>(); /* Build up the destination address */ if (dest) { /* Copy to preserve const */ tmp_addr = g_malloc0(addrlen); memcpy(tmp_addr, dest, addrlen); dest_addr = nl_addr_build (family, tmp_addr, addrlen); g_free(tmp_addr); <API key> (dest_addr != NULL, -NLE_INVAL); <API key> (dest_addr, dest_prefix); rtnl_route_set_dst (route, dest_addr); nl_addr_put (dest_addr); } /* Build up the gateway address */ if (gateway) { tmp_addr = g_malloc0(addrlen); memcpy(tmp_addr, gateway, addrlen); gw_addr = nl_addr_build (family, tmp_addr, addrlen); g_free(tmp_addr); if (gw_addr) { <API key> (gw_addr, 0); <API key> (route, gw_addr); <API key> (route, RT_SCOPE_UNIVERSE); nl_addr_put(gw_addr); } else { nm_log_err (LOGD_DEVICE | log, "Invalid gateway"); } } err = rtnl_route_add (sk, route, flags); /* LIBNL Bug: Aliased ESRCH */ if (err == -NLE_FAILURE) err = -NLE_OBJ_NOTFOUND; if (err) nm_log_warn (LOGD_DEVICE | log, "Failed to add route %s", nl_geterror(err)); return err; } /** * <API key>: * @route: the route to delete * * Returns: %TRUE if the request was successful, %FALSE if it failed **/ gboolean <API key> (struct rtnl_route *route) { struct nl_sock *nlh; int err = 0; <API key> (route != NULL, FALSE); nlh = <API key> (); err = rtnl_route_delete (nlh, route, 0); if (err) nm_log_dbg (LOGD_IP4 | LOGD_IP6, "%s (%d)", nl_geterror(err), err); if (err == -NLE_FAILURE) err = -NLE_OBJ_NOTFOUND; return (err && (err != -NLE_OBJ_NOTFOUND) && (err != -NLE_RANGE) ) ? FALSE : TRUE; } static void dump_route (struct rtnl_route *route) { char buf6[INET6_ADDRSTRLEN]; char buf4[INET_ADDRSTRLEN]; struct nl_addr *nl; struct in6_addr *addr6 = NULL; struct in_addr *addr4 = NULL; int prefixlen = 0; const char *sf = "UNSPEC"; int family = <API key> (route); guint32 log_level = LOGD_IP4 | LOGD_IP6; memset (buf6, 0, sizeof (buf6)); memset (buf4, 0, sizeof (buf4)); nl = rtnl_route_get_dst (route); if (nl) { if (nl_addr_get_family (nl) == AF_INET) { addr4 = <API key> (nl); if (addr4) inet_ntop (AF_INET, addr4, &buf4[0], sizeof (buf4)); } else if (nl_addr_get_family (nl) == AF_INET6) { addr6 = <API key> (nl); if (addr6) inet_ntop (AF_INET6, addr6, &buf6[0], sizeof (buf6)); } prefixlen = <API key> (nl); } if (family == AF_INET) { sf = "INET"; log_level = LOGD_IP4; } else if (family == AF_INET6) { sf = "INET6"; log_level = LOGD_IP6; } nm_log_dbg (log_level, " route idx %d family %s (%d) addr %s/%d", rtnl_route_get_oif (route), sf, family, strlen (buf4) ? buf4 : (strlen (buf6) ? buf6 : "<unknown>"), prefixlen); } typedef struct { int ifindex; int family; int scope; gboolean ignore_inet6_ll_mc; char *iface; NlRouteForeachFunc callback; gpointer user_data; struct rtnl_route *out_route; } ForeachRouteInfo; static void foreach_route_cb (struct nl_object *object, void *user_data) { ForeachRouteInfo *info = user_data; struct rtnl_route *route = (struct rtnl_route *) object; struct nl_addr *dst; if (info->out_route) return; if (<API key> (LOGL_DEBUG)) dump_route (route); if ( info->ifindex >= 0 && rtnl_route_get_oif (route) != info->ifindex) return; if ( info->scope != RT_SCOPE_UNIVERSE && <API key> (route) != info->scope) return; if ( info->family != AF_UNSPEC && <API key> (route) != info->family) return; dst = rtnl_route_get_dst (route); /* Check for IPv6 LL and MC routes that might need to be ignored */ if ( (info->family == AF_INET6 || info->family == AF_UNSPEC) && (<API key> (route) == AF_INET6)) { struct in6_addr *addr = NULL; if (dst) addr = <API key> (dst); if (addr) { if ( <API key> (addr) || <API key> (addr) || (<API key> (addr) && (<API key> (dst) == 8))) return; } } info->out_route = info->callback (route, dst, info->iface, info->user_data); if (info->out_route) { /* Ref the route so it sticks around after the cache is cleared */ rtnl_route_get (info->out_route); } } /** * <API key>: * @ifindex: the interface index to filter routes for * @family: the address family to filter routes for * @scope: route scope, eg RT_SCOPE_LINK * @ignore_inet6_ll_mc: if %TRUE ignore IPv6 link-local and multi-cast routes * @callback: function called when a route matches the filter * @user_data: data passed to @callback * * Filters each route in the routing table against the given @ifindex and * @family (if given) and calls @callback for each matching route. * * Returns: a route if @callback returned one; the caller must dispose of the * route using rtnl_route_put() when it is no longer required. **/ struct rtnl_route * <API key> (int ifindex, int family, int scope, gboolean ignore_inet6_ll_mc, NlRouteForeachFunc callback, gpointer user_data) { struct nl_cache *cache; ForeachRouteInfo info; memset (&info, 0, sizeof (info)); info.ifindex = ifindex; info.family = family; info.scope = scope; info.ignore_inet6_ll_mc = ignore_inet6_ll_mc; info.callback = callback; info.user_data = user_data; info.iface = <API key> (ifindex); <API key> (<API key> (), family, NL_AUTO_PROVIDE, &cache); g_warn_if_fail (cache != NULL); if (cache) { nl_cache_foreach (cache, foreach_route_cb, &info); nl_cache_free (cache); } g_free (info.iface); return info.out_route; }
#include "parser/forcefieldatom.h" #include "parser/stepnode.h" #include "base/forcefieldatom.h" #include "base/prefs.h" #include "math/constants.h" #include "main/aten.h" <API key> /* // Variable */ // Constructor <API key>::<API key>(ForcefieldAtom* ptr, bool constant) { // Private variables returnType_ = VTypes::ForcefieldAtomData; readOnly_ = constant; pointerData_ = ptr; } // Destructor <API key>::~<API key>() { } /* // Accessors */ // Accessor data Accessor <API key>::accessorData[<API key>::nAccessors] = { { "charge", VTypes::DoubleData, 0, FALSE }, { "data", VTypes::DoubleData, MAXFFPARAMDATA, FALSE }, { "dataKeyword", VTypes::StringData, MAXFFPARAMDATA, TRUE }, { "dataName", VTypes::StringData, MAXFFPARAMDATA, TRUE }, { "description", VTypes::StringData, 0, FALSE }, { "equivalent", VTypes::StringData, 0, FALSE }, { "ff", VTypes::ForcefieldData, 0, TRUE }, { "form", VTypes::StringData, 0, FALSE }, { "id", VTypes::IntegerData, 0, TRUE }, { "mass", VTypes::DoubleData, 0, TRUE }, { "name", VTypes::StringData, 0, FALSE }, { "neta", VTypes::StringData, 0, FALSE }, { "nParams", VTypes::IntegerData, 0, TRUE }, { "z", VTypes::IntegerData, 0, FALSE } }; // Function data FunctionAccessor <API key>::functionData[<API key>::nFunctions] = { { "combine", VTypes::DoubleData, "ON", "FFAtom j, int param" }, { "dataD", VTypes::DoubleData, "C", "string name" }, { "dataI", VTypes::IntegerData, "C", "string name" }, { "dataS", VTypes::StringData, "C", "string name" }, { "parameter", VTypes::DoubleData, "C", "string name" } }; // Search variable access list for provided accessor (call private static function) StepNode* <API key>::findAccessor(const char* s, TreeNode* arrayIndex, TreeNode* argList) { return <API key>::accessorSearch(s, arrayIndex, argList); } // Private static function to search accessors StepNode* <API key>::accessorSearch(const char* s, TreeNode* arrayIndex, TreeNode* argList) { Messenger::enter("<API key>::accessorSearch"); StepNode* result = NULL; int i = 0; i = Variable::searchAccessor(s, nAccessors, accessorData); if (i == -1) { // No accessor found - is it a function definition? // for (i = 0; i < nFunctions; i++) if (strcmp(functionData[i].name,s) == 0) break; i = Variable::searchAccessor(s, nFunctions, functionData); if (i == -1) { Messenger::print("Error: Type 'FFAtom&' has no member or function named '%s'.", s); printAccessors(); Messenger::exit("<API key>::accessorSearch"); return NULL; } Messenger::print(Messenger::Parse, "FunctionAccessor match = %i (%s)", i, functionData[i].name); if (arrayIndex != NULL) { Messenger::print("Error: Array index given to 'FFAtom&' function '%s'.", s); Messenger::exit("<API key>::accessorSearch"); return NULL; } // Add and check supplied arguments... result = new StepNode(i, VTypes::ForcefieldAtomData, functionData[i].returnType); result->addJoinedArguments(argList); if (!result->checkArguments(functionData[i].arguments, functionData[i].name)) { Messenger::print("Error: Syntax for 'FFAtom&' function '%s' is '%s(%s)'.", functionData[i].name, functionData[i].name, functionData[i].argText ); delete result; result = NULL; } } else { Messenger::print(Messenger::Parse, "Accessor match = %i (%s)", i, accessorData[i].name); // Were we given an array index when we didn't want one? if ((accessorData[i].arraySize == 0) && (arrayIndex != NULL)) { Messenger::print("Error: Irrelevant array index provided for member '%s'.", accessorData[i].name); result = NULL; } // Were we given an argument list when we didn't want one? if (argList != NULL) { Messenger::print("Error: Argument list given to 'FFAtom&' array member '%s'.", s); Messenger::exit("<API key>::accessorSearch"); return NULL; } result = new StepNode(i, VTypes::ForcefieldAtomData, arrayIndex, accessorData[i].returnType, accessorData[i].isReadOnly, accessorData[i].arraySize); } Messenger::exit("<API key>::accessorSearch"); return result; } // Retrieve desired value bool <API key>::retrieveAccessor(int i, ReturnValue& rv, bool hasArrayIndex, int arrayIndex) { Messenger::enter("<API key>::retrieveAccessor"); // Cast 'i' into Accessors enum value if ((i < 0) || (i >= nAccessors)) { printf("Internal Error: Accessor id %i is out of range for ForcefieldAtom type.\n", i); Messenger::exit("<API key>::retrieveAccessor"); return FALSE; } Accessors acc = (Accessors) i; // Check for correct lack/presence of array index given if ((accessorData[i].arraySize == 0) && hasArrayIndex) { Messenger::print("Error: Unnecessary array index provided for member '%s'.", accessorData[i].name); Messenger::exit("<API key>::retrieveAccessor"); return FALSE; } else if ((accessorData[i].arraySize > 0) && (hasArrayIndex)) { if ((arrayIndex < 1) || (arrayIndex > accessorData[i].arraySize)) { Messenger::print("Error: Array index out of bounds for member '%s' (%i, range is 1-%i).", accessorData[i].name, arrayIndex, accessorData[i].arraySize); Messenger::exit("<API key>::retrieveAccessor"); return FALSE; } } // Get current data from ReturnValue bool result = TRUE; int n; ForcefieldAtom* ptr = (ForcefieldAtom*) rv.asPointer(VTypes::ForcefieldAtomData, result); if ((!result) || (ptr == NULL)) { Messenger::print("Invalid (NULL) %s reference encountered.", VTypes::dataType(VTypes::ForcefieldAtomData)); result = FALSE; } if (result) switch (acc) { case (<API key>::Charge): rv.set(ptr->charge()); break; case (<API key>::Data): if (hasArrayIndex) { rv.set(ptr->parameter(arrayIndex-1)); // Autoconversion of energy parameters? if ((prefs.autoConversionUnit() != Prefs::nEnergyUnits) && VdwFunctions::VdwFunctions[ptr->vdwForm()].isEnergyParameter[arrayIndex-1]) rv.set( prefs.convertEnergy(rv.asDouble(), prefs.energyUnit(), prefs.autoConversionUnit()) ); } else { rv.setArray(VTypes::DoubleData, ptr->parameters(), MAXFFPARAMDATA); // Autoconversion of energy parameters? if (prefs.autoConversionUnit() != Prefs::nEnergyUnits) { for (n = 0; n<MAXFFPARAMDATA; ++n) if (VdwFunctions::VdwFunctions[ptr->vdwForm()].isEnergyParameter[n]) rv.setElement(n, prefs.convertEnergy(ptr->parameter(n), prefs.energyUnit(), prefs.autoConversionUnit()) ); } } break; case (<API key>::Description): rv.set(ptr->description()); break; case (<API key>::DataKeyword): // Must have an array index here... if (!hasArrayIndex) { Messenger::print("Accessor 'datakeyword' must have an array index."); result = FALSE; } else rv.set(VdwFunctions::VdwFunctions[ptr->vdwForm()].parameterKeywords[arrayIndex-1]); break; case (<API key>::DataName): // Must have an array index here... if (!hasArrayIndex) { Messenger::print("Accessor 'dataname' must have an array index."); result = FALSE; } else rv.set(VdwFunctions::VdwFunctions[ptr->vdwForm()].parameters[arrayIndex-1]); break; case (<API key>::Equivalent): if (aten_->typeExportMapping()) rv.set(aten_->typeExportConvert(ptr->equivalent())); else rv.set(ptr->equivalent()); break; case (<API key>::FField): rv.set(VTypes::ForcefieldData, ptr->parent()); break; case (<API key>::Form): rv.set(VdwFunctions::VdwFunctions[ptr->vdwForm()].keyword); break; case (<API key>::Id): rv.set(ptr->typeId()); break; case (<API key>::Mass): rv.set(ptr->elementMass()); break; case (<API key>::Name): if (aten_->typeExportMapping()) rv.set(aten_->typeExportConvert(ptr->name())); else rv.set(ptr->name()); break; case (<API key>::Neta): rv.set(ptr->netaString()); break; case (<API key>::NParams): rv.set(VdwFunctions::VdwFunctions[ptr->vdwForm()].nParameters); break; case (<API key>::Z): rv.set(ptr->neta()->characterElement()); break; default: printf("Internal Error: Access to member '%s' has not been defined in <API key>.\n", accessorData[i].name); result = FALSE; break; } Messenger::exit("<API key>::retrieveAccessor"); return result; } // Set desired value bool <API key>::setAccessor(int i, ReturnValue& sourcerv, ReturnValue& newValue, bool hasArrayIndex, int arrayIndex) { Messenger::enter("<API key>::setAccessor"); // Cast 'i' into Accessors enum value if ((i < 0) || (i >= nAccessors)) { printf("Internal Error: Accessor id %i is out of range for ForcefieldAtom type.\n", i); Messenger::exit("<API key>::retrieveAccessor"); return FALSE; } Accessors acc = (Accessors) i; // Check for correct lack/presence of array index given to original accessor, and nature of new value bool result = TRUE; if (accessorData[i].arraySize != 0) { if (hasArrayIndex) { if ((accessorData[i].arraySize > 0) && ( (arrayIndex < 1) || (arrayIndex > accessorData[i].arraySize) )) { Messenger::print("Error: Array index provided for member '%s' is out of range (%i, range is 1-%i).", accessorData[i].name, arrayIndex, accessorData[i].arraySize); result = FALSE; } if (newValue.arraySize() > 0) { Messenger::print("Error: An array can't be assigned to the single valued member '%s'.", accessorData[i].name); result = FALSE; } } else { if (newValue.arraySize() > accessorData[i].arraySize) { Messenger::print("Error: The array being assigned to member '%s' is larger than the size of the desination array (%i cf. %i).", accessorData[i].name, newValue.arraySize(), accessorData[i].arraySize); result = FALSE; } } } else { // This is not an array member, so cannot be assigned an array unless its a Vector if (newValue.arraySize() != -1) { if (accessorData[i].returnType != VTypes::VectorData) { Messenger::print("Error: An array can't be assigned to the single valued member '%s'.", accessorData[i].name); result = FALSE; } else if ((newValue.type() != VTypes::VectorData) && (newValue.arraySize() != 3)) { Messenger::print("Error: Only an array of size 3 can be assigned to a vector (member '%s').", accessorData[i].name); result = FALSE; } } } if (!result) { Messenger::exit("<API key>::setAccessor"); return FALSE; } // Get current data from ReturnValue VdwFunctions::VdwFunction vf; int n; ForcefieldAtom* ptr = (ForcefieldAtom*) sourcerv.asPointer(VTypes::ForcefieldAtomData, result); if ((!result) || (ptr == NULL)) { Messenger::print("Invalid (NULL) %s reference encountered.", VTypes::dataType(VTypes::ForcefieldAtomData)); result = FALSE; } if (result) switch (acc) { case (<API key>::Charge): ptr->setCharge(newValue.asDouble()); break; case (<API key>::Data): if ((newValue.arraySize() != -1) && (newValue.arraySize() <= MAXFFPARAMDATA)) for (n=0; n<newValue.arraySize(); ++n) ptr->setParameter(n, newValue.asDouble(n, result)); else if (hasArrayIndex) ptr->setParameter(arrayIndex-1, newValue.asDouble()); else for (n=0; n<MAXFFPARAMDATA; ++n) ptr->setParameter(n, newValue.asDouble()); break; case (<API key>::Description): ptr->setDescription(newValue.asString()); break; case (<API key>::Equivalent): ptr->setEquivalent(newValue.asString()); break; case (<API key>::Form): vf = VdwFunctions::vdwFunction(newValue.asString()); if (vf == VdwFunctions::None) result = FALSE; else ptr->setVdwForm(vf); break; case (<API key>::Name): ptr->setName(newValue.asString()); break; case (<API key>::Neta): ptr->setNeta(newValue.asString(), NULL); break; case (<API key>::Z): ptr->neta()->setCharacterElement(newValue.asInteger()); break; default: printf("<API key>::setAccessor doesn't know how to use member '%s'.\n", accessorData[acc].name); result = FALSE; break; } Messenger::exit("<API key>::setAccessor"); return result; } // Perform desired function bool <API key>::performFunction(int i, ReturnValue& rv, TreeNode* node) { Messenger::enter("<API key>::performFunction"); // Cast 'i' into Accessors enum value if ((i < 0) || (i >= nFunctions)) { printf("Internal Error: FunctionAccessor id %i is out of range for ForcefieldAtom type.\n", i); Messenger::exit("<API key>::performFunction"); return FALSE; } // Get current data from ReturnValue bool result = TRUE; int param; ForcefieldAtom* at2; ForcefieldAtom* ptr = (ForcefieldAtom*) rv.asPointer(VTypes::ForcefieldAtomData, result); Variable* v; int id; ReturnValue resultrv; if (result) switch (i) { case (<API key>::Combine): // Grab the two FFAtom variables at2 = (ForcefieldAtom*) node->argp(0, VTypes::ForcefieldAtomData); // Check for NULL pointers if ((ptr == NULL) || (at2 == NULL)) { result = FALSE; Messenger::print("Error: NULL ForcefieldAtom (or target) passed to 'combine' function."); break; } // Check functional forms if (ptr->vdwForm() != at2->vdwForm()) { result = FALSE; Messenger::print("Error: ForcefieldAtom passed to 'combine' function has differing functional form ('%s' cf. '%s').", VdwFunctions::VdwFunctions[ptr->vdwForm()].name, VdwFunctions::VdwFunctions[at2->vdwForm()].name); break; } // Check parameter ID param = node->argi(1)-1; if ((param < 0) || (param >= VdwFunctions::VdwFunctions[ptr->vdwForm()].nParameters)) { result = FALSE; Messenger::print("Error: Parameter ID is out of range for VDW functional form - asked for %i, valid parameter range is 1 - %i.", param, VdwFunctions::VdwFunctions[ptr->vdwForm()].nParameters); break; } // Combine parameters rv.set(aten_->combinationRules().combine(VdwFunctions::VdwFunctions[ptr->vdwForm()].combinationRules[param], ptr->parameter(param), at2->parameter(param))); break; case (<API key>::DataD): case (<API key>::DataI): case (<API key>::DataS): // Find data item in local variable list v = ptr->data(node->argc(0)); if (v == NULL) { result = FALSE; Messenger::print("Error: Data '%s' has not been defined in this ForcefieldAtom.", node->argc(0)); break; } v->execute(resultrv); if (i == <API key>::DataD) rv.set(resultrv.asDouble()); else if (i == <API key>::DataI) rv.set(resultrv.asInteger()); else if (i == <API key>::DataS) rv.set(resultrv.asString()); else result = FALSE; break; case (<API key>::Parameter): id = VdwFunctions::vdwParameter(ptr->vdwForm(), node->argc(0), TRUE); if (id == VdwFunctions::VdwFunctions[ptr->vdwForm()].nParameters) result = FALSE; else { // Autoconversion of energy parameters? if ((prefs.autoConversionUnit() != Prefs::nEnergyUnits) && VdwFunctions::VdwFunctions[ptr->vdwForm()].isEnergyParameter[id]) rv.set( prefs.convertEnergy(ptr->parameter(id), prefs.energyUnit(), prefs.autoConversionUnit()) ); else rv.set(ptr->parameter(id)); } break; default: printf("Internal Error: Access to function '%s' has not been defined in <API key>.\n", functionData[i].name); result = FALSE; break; } Messenger::exit("<API key>::performFunction"); return result; } // Print valid accessors/functions void <API key>::printAccessors() { if (<API key>::nAccessors > 0) { Messenger::print("Valid accessors are:"); for (int n=0; n<<API key>::nAccessors; ++n) Messenger::print("%s%s%s", n == 0 ? " " : ", ", accessorData[n].name, accessorData[n].arraySize > 0 ? "[]" : ""); Messenger::print(""); } if ((<API key>::nFunctions > 0) && (strcmp(functionData[0].name,".dummy") != 0)) { Messenger::print("Valid functions are:"); for (int n=0; n<<API key>::nFunctions; ++n) Messenger::print("%s%s(%s)", n == 0 ? " " : ", ", functionData[n].name, functionData[n].argText); Messenger::print(""); } } /* // Variable Array */ // Constructor <API key>::<API key>(TreeNode* sizeexpr, bool constant) { // Private variables returnType_ = VTypes::ForcefieldAtomData; pointerArrayData_ = NULL; arraySize_ = 0; nodeType_ = TreeNode::ArrayVarNode; readOnly_ = constant; <API key> = sizeexpr; } // Search variable access list for provided accessor StepNode* <API key>::findAccessor(const char* s, TreeNode* arrayIndex, TreeNode* argList) { return <API key>::accessorSearch(s, arrayIndex, argList); }
select NET_DEP_ID,trim(regexp_substr (COUNTRY, '[^|]+', 1, level)) COUNTRY from SEM_LIST_INFO connect by level <= length (regexp_replace (COUNTRY, '[^|]+')) + 1
<!-- INCLUDE overall_header.html --> <div class="time"><!-- IF S_USER_LOGGED_IN --><span>{LAST_VISIT_DATE}.</span><!-- ENDIF --><span>{CURRENT_TIME}.</span><span>{S_TIMEZONE}.</span></div> <!-- EVENT <API key> --> <!-- IF U_MARK_FORUMS --> <div class="action-bar compact"> <a href="{U_MARK_FORUMS}" class="mark-read rightside" accesskey="m" data-ajax="mark_forums_read">{L_MARK_FORUMS_READ}</a> </div> <!-- ENDIF --> <!-- EVENT <API key> --> <!-- INCLUDE forumlist_body.html --> <!-- EVENT <API key> --> <!-- IF not S_USER_LOGGED_IN and not S_IS_BOT --> <form method="post" action="{S_LOGIN_ACTION}" class="headerspace"> <h3><a href="{U_LOGIN_LOGOUT}">{L_LOGIN_LOGOUT}</a><!-- IF S_REGISTER_ENABLED -->&nbsp; &bull; &nbsp;<a href="{U_REGISTER}">{L_REGISTER}</a><!-- ENDIF --></h3> <fieldset class="quick-login"> <label for="username"><span>{L_USERNAME}{L_COLON}</span> <input type="text" tabindex="1" name="username" id="username" size="10" class="inputbox" title="{L_USERNAME}" /></label> <label for="password"><span>{L_PASSWORD}{L_COLON}</span> <input type="password" tabindex="2" name="password" id="password" size="10" class="inputbox" title="{L_PASSWORD}" autocomplete="off" /></label> <!-- IF U_SEND_PASSWORD --> <a href="{U_SEND_PASSWORD}">{L_FORGOT_PASS}</a> <!-- ENDIF --> <!-- IF S_AUTOLOGIN_ENABLED --> <span class="responsive-hide">|</span> <label for="autologin">{L_LOG_ME_IN} <input type="checkbox" tabindex="4" name="autologin" id="autologin" /></label> <!-- ENDIF --> <input type="submit" tabindex="5" name="login" value="{L_LOGIN}" class="button2" /> {S_LOGIN_REDIRECT} </fieldset> </form> <!-- ENDIF --> <!-- EVENT <API key> --> <!-- IF <API key> --> <div class="stat-block online-list"> <!-- IF U_VIEWONLINE --><h3><a href="{U_VIEWONLINE}">{L_WHO_IS_ONLINE}</a></h3><!-- ELSE --><h3>{L_WHO_IS_ONLINE}</h3><!-- ENDIF --> <p> <!-- EVENT <API key> --> {TOTAL_USERS_ONLINE} ({L_ONLINE_EXPLAIN})<br />{RECORD_USERS}<br /> <br />{LOGGED_IN_USER_LIST} <!-- IF LEGEND --><br /><em>{L_LEGEND}{L_COLON} {LEGEND}</em><!-- ENDIF --> <!-- EVENT <API key> --> </p> </div> <!-- ENDIF --> <!-- IF <API key> --> <div class="stat-block birthday-list"> <h3>{L_BIRTHDAYS}</h3> <p> <!-- EVENT <API key> --> <!-- IF .birthdays -->{L_CONGRATULATIONS}{L_COLON} <strong><!-- BEGIN birthdays -->{birthdays.USERNAME}<!-- IF birthdays.AGE !== '' --> ({birthdays.AGE})<!-- ENDIF --><!-- IF not birthdays.S_LAST_ROW -->, <!-- ENDIF --><!-- END birthdays --></strong><!-- ELSE -->{L_NO_BIRTHDAYS}<!-- ENDIF --> <!-- EVENT <API key> --> </p> </div> <!-- ENDIF --> <!-- IF NEWEST_USER --> <div class="stat-block statistics"> <h3>{L_STATISTICS}</h3> <p> <!-- EVENT <API key> --> {TOTAL_POSTS} &bull; {TOTAL_TOPICS} &bull; {TOTAL_USERS} &bull; {NEWEST_USER} <!-- EVENT <API key> --> </p> </div> <!-- ENDIF --> <!-- EVENT <API key> --> <!-- INCLUDE overall_footer.html -->
<?php define('DB_NAME', 'beast'); define('DB_USER', 'root'); define('DB_PASSWORD', 'Root5045'); define('DB_HOST', 'localhost'); define('DB_CHARSET', 'utf8mb4'); define('DB_COLLATE', ''); define('AUTH_KEY', 'Ag:i8Lc8VR^6Ltre-8Q$*b2(V^M2n9+Kv@>[ElK>Yr|EbC~Q$`)VAw|?tno;*^i^'); define('SECURE_AUTH_KEY', 'W6h%8*b&~mp@+R_4>p/oN+qn%( 0b2VF&QWOa}G-y=NUYcFh_DG--A|tk*SduWY6'); define('LOGGED_IN_KEY', 'RH?ew:N|=2Vza8)PEfNLl.W[A^d;YEbAP$^LR]sr|K8~Qw,^7t=pqGj->n3oe,Cc'); define('NONCE_KEY', '[WYJ[ fV+%%i;ej1jREQim|-VYvm@ZT$[#z#Q}DD|#hP|6F+qg4LxDDuZVj(8vVm'); define('AUTH_SALT', 'hq6+=IYYBO>=g{{-#DT+W2;ec9ee(V$z{;Dq3mHHZQ@p;y7iQb6fBHp-o5zNk()3'); define('SECURE_AUTH_SALT', ')gjQmd`n-dVo)T%:2/R(+LAmAIwKh[QfQ;Mn]1]<lFaFc21=d?cAp*Jfr}8<R4XM'); define('LOGGED_IN_SALT', '^|w9ubccU}qyq${g<72*!+xnbr+RHi7h;FEh? ;]7it_J6?)o|U]m(DM6pbr!m!'); define('NONCE_SALT', '%dvD1j!~U]Lsj<}(3qo[q)|)!hN=$/5E7aGtaZAV8Eu<4wF,e7&7sG(pzif6t3+7'); $table_prefix = 'wp_'; define('WP_DEBUG', false); define('WPLANG', 'ru_RU'); if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); require_once(ABSPATH . 'wp-settings.php');
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace cms.Components { class imageAttribute : Attribute {} }
#include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/errno.h> #include <linux/clk.h> #include <linux/err.h> #include <linux/mutex.h> #include <linux/platform_device.h> #include <linux/io.h> #include <mach/hardware.h> #include <mach/psc.h> #include <mach/cputype.h> #include "clock.h" static LIST_HEAD(clocks); static DEFINE_MUTEX(clocks_mutex); static DEFINE_SPINLOCK(clockfw_lock); static unsigned psc_domain(struct clk *clk) { return (clk->flags & PSC_DSP) ? <API key> : <API key>; } static void __clk_enable(struct clk *clk) { if (clk->parent) __clk_enable(clk->parent); if (clk->usecount++ == 0 && (clk->flags & CLK_PSC)) davinci_psc_config(psc_domain(clk), clk->psc_ctlr, clk->lpsc, 1); } static void __clk_disable(struct clk *clk) { if (WARN_ON(clk->usecount == 0)) return; if (--clk->usecount == 0 && !(clk->flags & CLK_PLL)) davinci_psc_config(psc_domain(clk), clk->psc_ctlr, clk->lpsc, 0); if (clk->parent) __clk_disable(clk->parent); } int clk_enable(struct clk *clk) { unsigned long flags; if (clk == NULL || IS_ERR(clk)) return -EINVAL; spin_lock_irqsave(&clockfw_lock, flags); __clk_enable(clk); <API key>(&clockfw_lock, flags); return 0; } EXPORT_SYMBOL(clk_enable); void clk_disable(struct clk *clk) { unsigned long flags; if (clk == NULL || IS_ERR(clk)) return; spin_lock_irqsave(&clockfw_lock, flags); __clk_disable(clk); <API key>(&clockfw_lock, flags); } EXPORT_SYMBOL(clk_disable); unsigned long clk_get_rate(struct clk *clk) { if (clk == NULL || IS_ERR(clk)) return -EINVAL; return clk->rate; } EXPORT_SYMBOL(clk_get_rate); long clk_round_rate(struct clk *clk, unsigned long rate) { if (clk == NULL || IS_ERR(clk)) return -EINVAL; return clk->rate; } EXPORT_SYMBOL(clk_round_rate); int clk_set_rate(struct clk *clk, unsigned long rate) { if (clk == NULL || IS_ERR(clk)) return -EINVAL; return -EINVAL; } EXPORT_SYMBOL(clk_set_rate); int clk_register(struct clk *clk) { if (clk == NULL || IS_ERR(clk)) return -EINVAL; if (WARN(clk->parent && !clk->parent->rate, "CLK: %s parent %s has no rate!\n", clk->name, clk->parent->name)) return -EINVAL; mutex_lock(&clocks_mutex); list_add_tail(&clk->node, &clocks); mutex_unlock(&clocks_mutex); if (clk->rate) return 0; if (clk->parent) clk->rate = clk->parent->rate; return 0; } EXPORT_SYMBOL(clk_register); void clk_unregister(struct clk *clk) { if (clk == NULL || IS_ERR(clk)) return; mutex_lock(&clocks_mutex); list_del(&clk->node); mutex_unlock(&clocks_mutex); } EXPORT_SYMBOL(clk_unregister); #ifdef <API key> static int __init clk_disable_unused(void) { struct clk *ck; spin_lock_irq(&clockfw_lock); list_for_each_entry(ck, &clocks, node) { if (ck->usecount > 0) continue; if (!(ck->flags & CLK_PSC)) continue; if (!<API key>(ck->psc_ctlr, ck->lpsc)) continue; pr_info("Clocks: disable unused %s\n", ck->name); davinci_psc_config(psc_domain(ck), ck->psc_ctlr, ck->lpsc, 0); } spin_unlock_irq(&clockfw_lock); return 0; } late_initcall(clk_disable_unused); #endif static void clk_sysclk_recalc(struct clk *clk) { u32 v, plldiv; struct pll_data *pll; if (clk->pll_data) return; if (WARN_ON(!clk->parent)) return; clk->rate = clk->parent->rate; if (WARN_ON(!clk->parent->pll_data)) return; pll = clk->parent->pll_data; if (clk->flags & PRE_PLL) clk->rate = pll->input_rate; if (!clk->div_reg) return; v = __raw_readl(pll->base + clk->div_reg); if (v & PLLDIV_EN) { plldiv = (v & PLLDIV_RATIO_MASK) + 1; if (plldiv) clk->rate /= plldiv; } } static void __init clk_pll_init(struct clk *clk) { u32 ctrl, mult = 1, prediv = 1, postdiv = 1; u8 bypass; struct pll_data *pll = clk->pll_data; pll->base = IO_ADDRESS(pll->phys_base); ctrl = __raw_readl(pll->base + PLLCTL); clk->rate = pll->input_rate = clk->parent->rate; if (ctrl & PLLCTL_PLLEN) { bypass = 0; mult = __raw_readl(pll->base + PLLM); if (<API key>()) mult = 2 * (mult & PLLM_PLLM_MASK); else mult = (mult & PLLM_PLLM_MASK) + 1; } else bypass = 1; if (pll->flags & PLL_HAS_PREDIV) { prediv = __raw_readl(pll->base + PREDIV); if (prediv & PLLDIV_EN) prediv = (prediv & PLLDIV_RATIO_MASK) + 1; else prediv = 1; } if (<API key>() && pll->num == 1) prediv = 8; if (pll->flags & PLL_HAS_POSTDIV) { postdiv = __raw_readl(pll->base + POSTDIV); if (postdiv & PLLDIV_EN) postdiv = (postdiv & PLLDIV_RATIO_MASK) + 1; else postdiv = 1; } if (!bypass) { clk->rate /= prediv; clk->rate *= mult; clk->rate /= postdiv; } pr_debug("PLL%d: input = %lu MHz [ ", pll->num, clk->parent->rate / 1000000); if (bypass) pr_debug("bypass "); if (prediv > 1) pr_debug("/ %d ", prediv); if (mult > 1) pr_debug("* %d ", mult); if (postdiv > 1) pr_debug("/ %d ", postdiv); pr_debug("] --> %lu MHz output.\n", clk->rate / 1000000); } int __init davinci_clk_init(struct davinci_clk *clocks) { struct davinci_clk *c; struct clk *clk; for (c = clocks; c->lk.clk; c++) { clk = c->lk.clk; if (clk->pll_data) clk_pll_init(clk); else if (clk->flags & CLK_PLL) clk_sysclk_recalc(clk); if (clk->lpsc) clk->flags |= CLK_PSC; clkdev_add(&c->lk); clk_register(clk); if (clk->flags & ALWAYS_ENABLED) clk_enable(clk); } return 0; } #ifdef CONFIG_PROC_FS #include <linux/proc_fs.h> #include <linux/seq_file.h> static void *davinci_ck_start(struct seq_file *m, loff_t *pos) { return *pos < 1 ? (void *)1 : NULL; } static void *davinci_ck_next(struct seq_file *m, void *v, loff_t *pos) { ++*pos; return NULL; } static void davinci_ck_stop(struct seq_file *m, void *v) { } #define CLKNAME_MAX 10 #define NEST_DELTA 2 #define NEST_MAX 4 static void dump_clock(struct seq_file *s, unsigned nest, struct clk *parent) { char *state; char buf[CLKNAME_MAX + NEST_DELTA * NEST_MAX]; struct clk *clk; unsigned i; if (parent->flags & CLK_PLL) state = "pll"; else if (parent->flags & CLK_PSC) state = "psc"; else state = ""; memset(buf, ' ', sizeof(buf) - 1); buf[sizeof(buf) - 1] = 0; i = strlen(parent->name); memcpy(buf + nest, parent->name, min(i, (unsigned)(sizeof(buf) - 1 - nest))); seq_printf(s, "%s users=%2d %-3s %9ld Hz\n", buf, parent->usecount, state, clk_get_rate(parent)); list_for_each_entry(clk, &clocks, node) { if (clk->parent == parent) dump_clock(s, nest + NEST_DELTA, clk); } } static int davinci_ck_show(struct seq_file *m, void *v) { mutex_lock(&clocks_mutex); if (!list_empty(&clocks)) dump_clock(m, 0, list_first_entry(&clocks, struct clk, node)); mutex_unlock(&clocks_mutex); return 0; } static const struct seq_operations davinci_ck_op = { .start = davinci_ck_start, .next = davinci_ck_next, .stop = davinci_ck_stop, .show = davinci_ck_show }; static int davinci_ck_open(struct inode *inode, struct file *file) { return seq_open(file, &davinci_ck_op); } static const struct file_operations <API key> = { .open = davinci_ck_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, }; static int __init <API key>(void) { proc_create("davinci_clocks", 0, NULL, &<API key>); return 0; } __initcall(<API key>); #endif
/**** MOVE THIS FILE BEFORE EDITING ***/ /* General Style */ .edit-link-footer { text-align: right; font-size:.9em; } .ee-featured-image{ float: left; } /* Payment Page Styles */ .payment_container, .payment-option-dv { position: relative; margin:0 .25em .25em 0; } .<API key> { display: inline-block !important; } .payment-option-dv .payment-option-lnk { display: inline-block; position: relative; max-width:140px; padding:20px; margin:0 0 1em; border:1px solid black; border-radius:3px; text-align: center; line-height:1em; vertical-align: middle; cursor:pointer; } .payment-option-dv .payment-option-lnk:hover { top:-1px; border-color:#d5d5d5; text-decoration:none; -webkit-box-shadow: 4px 10px 15px -3px rgba(0,0,0,.05), 1px 2px 4px -1px rgba(0,0,0,.1), -2px -1px 5px rgba(0,0,0,.025); -moz-box-shadow:4px 10px 15px -3px rgba(0,0,0,.05), 1px 2px 4px -1px rgba(0,0,0,.1), -2px -1px 5px rgba(0,0,0,.025); box-shadow:4px 10px 15px -3px rgba(0,0,0,.05), 1px 2px 4px -1px rgba(0,0,0,.1), -2px -1px 5px rgba(0,0,0,.025); } .payment-option-dv .payment-option-lnk img { max-width:140px !important; padding:0; margin:0; border:none; box-shadow: none; } .payment-option-dv .payment-option-lnk.algn-vrt { display: table !important; height:30px; } .payment-option-dv .payment-option-lnk.algn-vrt .vrt-cell { display: table-cell !important; vertical-align: middle; } #<API key> { margin: 5px 0; padding: 5px; } .<API key> { margin:0 0 6em; font-size:.8em; } .payment-option-dv .<API key> { position: absolute; top:-4px; right:-5px; border:none; box-shadow: none; } #<API key> { margin:0 0 4em; color:black; font-size:.7em; text-align: center;; } #<API key> img { position: relative; top:2px; border:none; box-shadow: none; } /* Multi registration form style */ .event_total_price{ font-size: 25px; float: right; text-align: right; padding:5px; } .<API key>{ padding:5px; margin:5px; } #<API key> { display: block; margin: 2em 10px; padding: 1em; border: 2px solid #EEEEEE; border-radius: 3px 3px 3px 3px; } #<API key> { padding:5px; margin:5px 10px 5px 5px; text-align: right;; } #<API key> { padding:5px; margin:5px; } #<API key> { clear:both; padding:5px; margin:5px 5px 1em 5px; font-size:.9em; } #<API key> { clear:both; padding:5px; margin:5px 5px 1em 5px; text-align:right;font-size:.9em; } #<API key> { clear:both; padding:5px; margin:5px 4px 1em 5px; text-align:right;font-size:.9em; } #<API key> { clear:both; padding:5px; margin:5px; text-align:right; } #<API key> table{ text-align: left; } #<API key> { margin: 2px 1px; } /* Errors and notices */ .<API key> { padding: 1em 2em 1.25em; margin: 0 0 1em 0; background-color:#FFEEEE; border: #FF0000 1px solid; border-radius:3px; color: #000; text-shadow:1px 1px #fff; } .<API key> p { margin: 0; color: #333; text-shadow:1px 1px #fff; } .<API key> p em { color: #cc0000; font-style: normal; font-weight: bold; display: block;} .<API key> { padding:1em 2em 1.25em; margin: 0 0 1em 0; background-color: #FFC; border: #FC6 1px solid; border-radius:3px; color: #000; text-shadow:1px 1px #fff; } .<API key> p { margin: 0; text-shadow:1px 1px #fff; } .<API key> p em { color: #C00; font-style: normal; font-weight: bold;display: block; } .<API key> label.error, .<API key> span.error { color: #C00; width: auto;} .<API key> label em, .<API key> span.label em, .<API key> legend em { font-style: normal; color: #C00; padding-left: 3px;} .<API key> input.error { border-color: #C00; background-color: #FEF; } /* Form styles */ .event_form_field input.<API key>, .event_form_field textarea.<API key> { width: 90%; } .<API key> { font-size: 1em; padding: 0 .5em; } #<API key>, #<API key> { margin: 2em 0 0; } .<API key> h3, .<API key> h4, .<API key> h5, .<API key> h6 { margin: 1em 0 .25em; font-weight: bold; } .<API key> p { margin:.5em 0 1.5em; } .<API key> fieldset { margin: .5em 0; background-color: #c5c5c5; } .<API key> fieldset legend.event_form_field { float: left; width:150px; padding:.5em 10px 1em 0; border:none; font-size:12px; text-align: right; line-height:1.25em; } .<API key> fieldset div { margin:1em 0 2em; clear: both; } .<API key>, .<API key>, .event_price_label{ display: inline-block; width:150px; padding:0 10px 0 0; text-align: left; font-size:.9em; line-height:1em; vertical-align: middle; font-weight: bold; } .<API key> label, .<API key> span.label { display: inline-block; float: left; padding:.5em .5em 1em 0; text-align: right; line-height:1em; vertical-align: middle; } .event_form_field .<API key> label.<API key>{ vertical-align: top; } .<API key>, .<API key> { display: inline-block; padding:0; margin:0; text-align: left; } .<API key> input[type=text], .<API key> select { width:65%; padding: 3px; margin:0 0 .25em; vertical-align: middle; text-align: left; } .<API key> .coupon_code { margin:2em 0; } /* FEM Styles */ .ee_fem_form_field label.date_time{ width:80px; float:none; } .ee_fem_form_field label.time{ width:50px; margin-left:30px; } .ee_fem_form_field input.ee_fem_time_value, .ee_fem_form_field input.ee_fem_date_value { width: 80px; } input.price-name-input{ width:45% !important; } ul.<API key> { list-style:none !important; } ul.<API key>, ul.<API key> li { margin:0 !important; } #event_title_field { width:100%; } label.<API key> { width:100px; } .ee_fem_form_field input.price-input { width: 80px; float:none; } .<API key> select.surcharge_type { width:25%; } #ee_fem_form div.title { float:left !important; width:40%; clear:none; } #ee_fem_form div.reg_limit { float:right !important; width:30%; text-align:left !important; clear:none; } #ee_fem_form div.reg_limit label, #ee_fem_form div.title label, #ee_fem_form p.title label{ text-align:left !important; } select.small { width:25px; } select.med { width: 100px; } select.wide { width: 175px; } .<API key> ul.event_form_field { display: inline-block; width:65%; list-style: none; padding:0; margin:.25em 0 0; } /*160px*/ .<API key> ul.event_form_field li, .<API key> .checkbox-lbl, .<API key> .radio-btn-lbl { display: inline-block; margin:0 2em 0 0; padding:0; text-align: left; vertical-align: middle; cursor: pointer; } /*.<API key> li label { width:auto; }*/ .<API key> .checkbox-lbl span, .<API key> .radio-btn-lbl span { position: relative; top:0px; margin:0; vertical-align: top; font-size:1em; line-height:1em; text-align: left; } .<API key> .checkbox-lbl input, .<API key> .radio-btn-lbl input { float: left; position: relative; top:0px; vertical-align: middle; margin:0 .5em 1em .25em; } .<API key> .checkbox-lbl + .checkbox-lbl, .<API key> .radio-btn-lbl + .radio-btn-lbl { margin-left:1em; } #additional_header { margin:2em 0 1em; } .<API key> .<API key> { margin:3em 0 .25em; } .<API key> { padding:0 0 0 0; } .<API key> { padding:0 0 1em 0; } .event_form_submit { padding: .7em 0 1em 0; font-weight: bold; } .<API key> { font-size: large; text-transform: uppercase; } .<API key> { display: inline-block; margin:0 0 .5em; cursor: pointer; } .<API key> img { margin:1px .5em -2px 0; } .smaller-text { font-size:.7em; } .small-text { font-size:.85em; } .big-text { font-size:1.2em; } .bigger-text { font-size:1.5em; } .highlight-bg { padding:1em 20px; background:#ffffdd; border-radius:3px; } .highlight-bg label { width:130px; } .long-label { position: relative; top:-2px; } .laquo { line-height:.9em; vertical-align: top; } .recaptchatable #<API key> {left:0 !important;} /* Confirmation page display */ table#<API key> th, table#<API key> th { padding: .75em; text-align: right; width:160px; line-height:1.25em; vertical-align: middle; } table#<API key> td, table#<API key> td { padding: .75em; text-align: left; line-height:1.25em; vertical-align: top; } table#<API key> tr, table#<API key> tr { text-align: left; line-height:1.25em; vertical-align: middle; } table.price_list{ margin: 10px auto; border: 1px; } table.price_list td{ padding: 5px; } .<API key> { } /* Event List Pagination */ .page_navigation .no_more{ background-color: white; color: gray; cursor: default; } .ellipse{ float: left; } .page_navigation , .alt_page_navigation{ padding-bottom: 10px; } .page_navigation a, .alt_page_navigation a{ padding:3px 5px; margin:2px; text-decoration:none; float: left; font-family: Tahoma; font-size: 12px; } .active_page{ color:black !important; } .ajx_loading { width:400px; height:400px; background:url('../images/ajax-loader-large.gif') center no-repeat; } /* Search Form */ #<API key> { padding:1em 1.5em; margin:0em 0 3em; background:#f8f8f8; border:1px solid #f0f0f0; border-top:1px solid #f4f4f4; border-bottom:1px solid #e8e8e8; border-radius:3px; text-align: center; } /* Autocomplete */ #ee_autocomplete, #ee_fem_autocomplete{ width:400px; } #ee_autocomplete{ } .ui-autocomplete { list-style:none; width:400px; background:#fff; border:1px solid #ccc; border-radius:3px; -webkit-box-shadow: 4px 10px 15px -3px rgba(0,0,0,.05), 1px 2px 4px -1px rgba(0,0,0,.1), -2px -1px 5px rgba(0,0,0,.025); -moz-box-shadow:4px 10px 15px -3px rgba(0,0,0,.05), 1px 2px 4px -1px rgba(0,0,0,.1), -2px -1px 5px rgba(0,0,0,.025); box-shadow:4px 10px 15px -3px rgba(0,0,0,.05), 1px 2px 4px -1px rgba(0,0,0,.1), -2px -1px 5px rgba(0,0,0,.025); } .ui-autocomplete li { } .ui-autocomplete li a { display: block; padding: .5em 1em; border-radius:3px; cursor: pointer; text-decoration: none; line-height:1em; } .ui-autocomplete li a:hover { background:#f8f8f8; text-decoration: none; } /* Media Queries */ @media (max-width: 990px) { .ajx_loading { width:300px; height:300px; } #ee_autocomplete, #ee_fem_autocomplete{ width:300px; } .ui-autocomplete { width:300px; } .<API key> p { margin: 20px 0 1em; } } /*@media (max-width: 880px) { .<API key> legend, .<API key> label, .<API key> span.label { display: block; width:auto; padding:0; text-align: left; } .<API key> ul { margin:0 0 0 1em; } }*/ @media (max-width: 850px) { .ajx_loading { width:250px; height:250px; } #ee_autocomplete, #ee_fem_autocomplete{ width:250px; } .ui-autocomplete { width:250px; } .<API key> p { margin: 20px 0 1em; } } @media (max-width: 800px) { .ajx_loading { width:400px; height:400px; } #ee_autocomplete, #ee_fem_autocomplete{ width:400px; } .ui-autocomplete { width:400px; } .<API key> p { margin: 20px 0 1em; } .event_form_field input.<API key>, .event_form_field textarea.<API key> { width:60%; margin-top:5px; } } @media (max-width: 700px) { .ajx_loading { width:300px; height:300px; } #ee_autocomplete, #ee_fem_autocomplete{ width:300px; } .ui-autocomplete { width:300px; } .<API key> p { margin: 20px 0 1em; } .event_form_field input.<API key>, .event_form_field textarea.<API key> { width:60%; margin-top:5px; } .ee_fem_form_field label.time{ width:50px; margin:0; } } @media (max-width: 600px) { .<API key> ul.event_form_field li, .<API key> .checkbox-lbl, .<API key> .radio-btn-lbl { display: block; clear: both; width:100%; margin:0; } .<API key> label, .<API key> span.label { display: block; float: none; padding:.5em 0 0; text-align: left; } .event_form_submit, .<API key> { padding-left:0; } .ajx_loading { width:250px; height:250px; } #ee_autocomplete, #ee_fem_autocomplete{ width:250px; } .ui-autocomplete { width:250px; } .event_form_field input.<API key>, .event_form_field textarea.<API key> { width:80%; margin-top:5px; } .ee_fem_form_field label.time{ width:50px; margin:0; } } @media (max-width: 505px) { .<API key> ul.event_form_field li, .<API key> .checkbox-lbl, .<API key> .radio-btn-lbl { display: block; clear: both; width:100%; margin:0; } .<API key> label, .<API key> span.label { display: block; float: none; width:90%; padding:.5em 0 0; text-align: left; } .event_form_submit, .<API key> { padding-left:0; } .ajx_loading { width:210px; height:210px; } #ee_autocomplete, #ee_fem_autocomplete{ width:210px; margin:0 0 .5em; } .ui-autocomplete { width:210px; } .event_form_field input.<API key>, .event_form_field textarea.<API key> { width:90%; margin-top:5px; } .ee_fem_form_field label.time{ width:50px; margin:0; } } @media (max-width: 450px) { .<API key> ul.event_form_field li, .<API key> .checkbox-lbl, .<API key> .radio-btn-lbl { display: block; clear: both; width:100%; margin:0; } .<API key> label, .<API key> span.label { display: block; float: none; width:90%; padding:.5em 0 0; text-align: left; } .event_form_submit, .<API key> { padding-left:0; } #<API key> { padding:1em; } .ajx_loading { width:170px; height:170px; } #ee_autocomplete, #ee_fem_autocomplete{ width:170px; } .ui-autocomplete { width:170px; } .event_form_field input.<API key>, .event_form_field textarea.<API key> { width:90%; margin-top:5px; } .ee_fem_form_field label.time{ width:50px; margin:0; } } @media (max-width: 410px) { .<API key> ul.event_form_field li, .<API key> .checkbox-lbl, .<API key> .radio-btn-lbl { display: block; clear: both; width:100%; margin:0; } .<API key> label, .<API key> span.label { display: block; float: none; width:90%; padding:.5em 0 0; text-align: left; } .event_form_submit, .<API key> { padding-left:0; } #<API key> { padding:1em; } .ajx_loading { width:130px; height:130px; } #ee_autocomplete, #ee_fem_autocomplete{ width:130px; } .ui-autocomplete { width:130px; } .event_form_field input.<API key>, .event_form_field textarea.<API key> { width:90%; margin-top:5px; } .ee_fem_form_field label.time{ width:50px; margin:0; } } @media (max-width: 360px) { .<API key> ul.event_form_field li, .<API key> .checkbox-lbl, .<API key> .radio-btn-lbl { display: block; clear: both; width:100%; margin:0; } .<API key> label, .<API key> span.label { display: block; float: none; width:90%; padding:.5em 0 0; text-align: left; } .event_form_submit, .<API key> { padding-left:0; } #<API key> { padding:1em; text-align: right; } .ajx_loading { width:150px; height:150px; } #ee_autocomplete, #ee_fem_autocomplete{ width:150px; margin:0 0 .5em; } .ui-autocomplete { width:150px; } .event_form_field input.<API key>, .event_form_field textarea.<API key> { width:90%; margin-top:5px; } .ee_fem_form_field label.time{ width:50px; margin:0; } } /* 38solutions Customizations */ .ui-widget-header { } .event_title { color: #770715; border: solid; border-top: none; border-left: none; border-right: none; border-bottom-style: groove; padding: .3em; } .<API key> .section-title { border: none; font-weight: bold; } #<API key> { background: #F5F5F5; padding: .2em; } .event_questions label { text-align: left !important; float: left !important; margin-right: 5px !important; font-weight: bold !important; font-size: 100%; } .<API key> fieldset div { margin-top: .5em; margin-bottom: .5em; } .event_questions label em { color: red; font-weight: bold; } .coupon_code label { font-weight: bold !important; } input[type="text"] { margin-right: 2em; display: inline; } .error { color: red; font-weight: normal !important; font-style: italic; } #<API key> { border: none; } #payment-options-dv { border: #01448b 1px; border-style: ridge; padding: .5em; background: #C5C5C5; } event_form_field .<API key> { width: 8em; } .event_form_field .<API key> .<API key> { width: 80%; } .<API key> { background-color: #F5F5F5; border: #01448b 1px; border-style: ridge; padding: .5em; margin-bottom: .5em; } .<API key> h3 { text-transform: uppercase; } .event-messages .instruct { font-weight: bold; } .event-data-display .<API key> { color: #770715; font-weight: bold; } .event_prices .event_price_value { color: #770715; font-weight: bold; } .available_spaces { font-weight: bold; } .<API key> .fc-event-skin { background-color: #770715 !important; } .<API key> .fc-event-skin { background-color: #01448b !important; } .<API key> a.fc-event-skin div { background: url('http://kennett-design.com/wp-content/plugins/espresso-calendar/css/images/tick-circle-frame.png') no-repeat 6px -24px; !important } a.reg_now { background-color: #0d89b1; } /**** MOVE THIS FILE BEFORE EDITING ***/
<?php namespace Wucdbm\Bundle\MenuBuilderBundle\Repository; use Wucdbm\Bundle\MenuBuilderBundle\Entity\Route; use Wucdbm\Bundle\MenuBuilderBundle\Entity\RouteParameter; use Wucdbm\Bundle\MenuBuilderBundle\Entity\RouteParameterType; use Wucdbm\Bundle\MenuBuilderBundle\Filter\Route\<API key>; use Wucdbm\Bundle\WucdbmBundle\Repository\AbstractRepository; class <API key> extends AbstractRepository { public function filter(<API key> $filter) { $builder = $this->getQueryBuilder(); if ($filter->getName()) { $builder->andWhere('p.name LIKE :name') ->setParameter('name', '%' . $filter->getName() . '%'); } if ($filter->getParameter()) { $builder->andWhere('p.parameter LIKE :parameter') ->setParameter('parameter', '%' . $filter->getParameter() . '%'); } if ($filter->getIsNamed()) { switch ($filter->getIsNamed()) { case <API key>::IS_NAMED_TRUE: $builder->andWhere('p.name IS NOT NULL'); break; case <API key>::IS_NAMED_FALSE: $builder->andWhere('p.name IS NULL'); break; } } $route = $filter->getRoute(); if ($route instanceof Route) { $builder->andWhere('r.id = :routeId') ->setParameter('routeId', $route->getId()); } $type = $filter->getType(); if ($type instanceof RouteParameterType) { $builder->andWhere('t.id = :typeId') ->setParameter('typeId', $type->getId()); } return $this-><API key>($builder, $filter, 'p.id'); } /** * @param $id * @return RouteParameter * @throws \Doctrine\ORM\<API key> */ public function findOneById($id) { $builder = $this->getQueryBuilder() ->andWhere('p.id = :id') ->setParameter('id', $id); $query = $builder->getQuery(); return $query->getOneOrNullResult(); } public function getQueryBuilder() { return $this->createQueryBuilder('p') ->addSelect('t, r, v') ->leftJoin('p.type', 't') ->leftJoin('p.route', 'r') ->leftJoin('p.values', 'v'); } public function saveIfNotExists(Route $route, $parameter, RouteParameterType $type) { $parameterEntity = $this-><API key>($route, $parameter); if ($parameterEntity) { $parameterEntity->setType($type); $this->save($parameterEntity); return $parameterEntity; } $parameterEntity = new RouteParameter(); $parameterEntity->setRoute($route); $route->addParameter($parameterEntity); $parameterEntity->setParameter($parameter); $parameterEntity->setType($type); $this->save($parameterEntity); return $parameterEntity; } public function <API key>(Route $route) { return $this->getQueryBuilder() ->andWhere('r.id = :routeId') ->setParameter('routeId', $route->getId()); } /** * @param Route $route * @param $parameter * @return RouteParameter * @throws \Doctrine\ORM\<API key> */ public function <API key>(Route $route, $parameter) { $builder = $this->getQueryBuilder() ->andWhere('r.id = :routeId') ->setParameter('routeId', $route->getId()) ->andWhere('p.parameter = :parameter') ->setParameter('parameter', $parameter); $query = $builder->getQuery(); return $query->getOneOrNullResult(); } public function save(RouteParameter $parameter) { $em = $this->getEntityManager(); $em->persist($parameter); $em->flush($parameter); } public function remove(RouteParameter $parameter) { $em = $this->getEntityManager(); $em->remove($parameter); $em->flush($parameter); } }
#ifndef _PROFILING_H_ #define _PROFILING_H_ #include "config.h" /* forward decls (C++ only) */ #if __cplusplus class CacheManager; #endif #ifdef USE_XPROF_STATS #if !defined(_SQUID_SOLARIS_) typedef int64_t hrtime_t; #else #include <sys/time.h> #endif #if defined(__i386) || defined(__i386__) static inline hrtime_t get_tick(void) { hrtime_t regs; asm volatile ("rdtsc":"=A" (regs)); return regs; /* We need return value, we rely on CC to optimise out needless subf calls */ /* Note that "rdtsc" is relatively slow OP and stalls the CPU pipes, so use it wisely */ } #elif defined(__alpha) static inline hrtime_t get_tick(void) { hrtime_t regs; asm volatile ("rpcc %0" : "=r" (regs)); return regs; } #elif defined(_M_IX86) && defined(_MSC_VER) /* x86 platform on Microsoft C Compiler ONLY */ static __inline hrtime_t get_tick(void) { hrtime_t regs; __asm { cpuid rdtsc mov eax,DWORD PTR regs[0] mov edx,DWORD PTR regs[4] } return regs; } #else #warning Unsupported CPU. Define function get_tick(). Disabling USE_XPROF_STATS... #undef USE_XPROF_STATS #endif #endif /* USE_XPROF_STATS - maybe disabled above */ #ifdef USE_XPROF_STATS typedef enum { <API key>, XPROF_PROF_OVERHEAD, XPROF_hash_lookup, XPROF_splay_splay, XPROF_xmalloc, XPROF_malloc, XPROF_xfree, XPROF_xxfree, XPROF_xrealloc, XPROF_xcalloc, XPROF_calloc, XPROF_xstrdup, XPROF_xstrndup, XPROF_xstrncpy, XPROF_xcountws, XPROF_socket, XPROF_read, XPROF_write, XPROF_send, XPROF_recv, XPROF_sendto, XPROF_recvfrom, XPROF_accept, XPROF_connect, <API key>, XPROF_memPoolAlloc, XPROF_memPoolFree, XPROF_memPoolClean, <API key>, XPROF_aclCheckFast, XPROF_comm_open, <API key>, XPROF_comm_accept, XPROF_comm_close, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, XPROF_storeGet, <API key>, XPROF_storeRelease, <API key>, <API key>, XPROF_file_open, XPROF_file_read, XPROF_file_write, XPROF_file_close, #if USE_SQUID_ESI <API key>, XPROF_esiProcessing, XPROF_esiParsing, #endif <API key>, XPROF_eventRun, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, XPROF_mem_hdr_write, XPROF_headersEnd, <API key>, <API key>, <API key>, XPROF_MemBuf_append, XPROF_MemBuf_grow, <API key>, <API key>, <API key>, <API key>, XPROF_Temp1, XPROF_Temp2, XPROF_Temp3, <API key>, XPROF_httpStart, <API key>, <API key>, <API key>, <API key>, XPROF_StringInitBuf, XPROF_StringInit, <API key>, XPROF_StringClean, XPROF_StringReset, XPROF_StringAppend, <API key>, <API key>, <API key>, XPROF_checkTimeouts, XPROF_CommSelect, XPROF_LAST } xprof_type; #define XP_NOBEST (hrtime_t)-1 typedef struct _xprof_stats_node xprof_stats_node; typedef struct _xprof_stats_data xprof_stats_data; struct _xprof_stats_data { hrtime_t start; hrtime_t stop; hrtime_t delta; hrtime_t best; hrtime_t worst; hrtime_t count; hrtime_t accum; int64_t summ; }; struct _xprof_stats_node { const char *name; xprof_stats_data accu; xprof_stats_data hist; }; typedef xprof_stats_node TimersArray[1]; /* public Data */ SQUIDCEXTERN TimersArray *xprof_Timers; /* Exported functions */ SQUIDCEXTERN void xprof_start(xprof_type type, const char *timer); SQUIDCEXTERN void xprof_stop(xprof_type type, const char *timer); SQUIDCEXTERN void xprof_event(void *data); #if __cplusplus extern void <API key>(CacheManager & manager); #endif #define PROF_start(type) xprof_start(XPROF_##type, #type) #define PROF_stop(type) xprof_stop(XPROF_##type, #type) #else /* USE_XPROF_STATS */ #define PROF_start(ARGS) ((void)0) #define PROF_stop(ARGS) ((void)0) #endif /* USE_XPROF_STATS */ #endif /* _PROFILING_H_ */
<!doctype html public "- <html> <head> <title>PHPXRef 0.7.1 : Unnamed Project : Function Reference: getstring()</title> <link rel="stylesheet" href="../sample.css" type="text/css"> <link rel="stylesheet" href="../sample-print.css" type="text/css" media="print"> <style id="hilight" type="text/css"></style> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> </head> <body bgcolor="#ffffff" text="#000000" link="#801800" vlink="#300540" alink="#ffffff"> <table class="pagetitle" width="100%"> <tr> <td valign="top" class="pagetitle"> [ <a href="../index.html">Index</a> ] </td> <td align="right" class="pagetitle"> <h2 style="margin-bottom: 0px">PHP Cross Reference of Unnamed Project</h2> </td> </tr> </table> <!-- Generated by PHPXref 0.7.1 at Sat Nov 21 22:13:19 2015 --> <script src="../phpxref.js" type="text/javascript"></script> <script language="JavaScript" type="text/javascript"> <! ext='.html'; relbase='../'; subdir='_functions'; filename='index.html'; cookiekey='phpxref'; handleNavFrame(relbase, subdir, filename); logFunction('getstring'); </script> <script language="JavaScript" type="text/javascript"> if (gwGetCookie('xrefnav')=='off') document.write('<p class="navlinks">[ <a href="javascript:navOn()">Show Explorer<\/a> ]<\/p>'); else document.write('<p class="navlinks">[ <a href="javascript:navOff()">Hide Explorer<\/a> ]<\/p>'); </script> <noscript> <p class="navlinks"> [ <a href="../nav.html" target="_top">Show Explorer</a> ] [ <a href="index.html" target="_top">Hide Navbar</a> ] </p> </noscript> [<a href="../index.html">Top level directory</a>]<br> <script language="JavaScript" type="text/javascript"> <! document.writeln('<table align="right" class="searchbox-link"><tr><td><a class="searchbox-link" href="javascript:void(0)" onMouseOver="showSearchBox()">Search</a><br>'); document.writeln('<table border="0" cellspacing="0" cellpadding="0" class="searchbox" id="searchbox">'); document.writeln('<tr><td class="searchbox-title">'); document.writeln('<a class="searchbox-title" href="javascript:showSearchPopup()">Search History +</a>'); document.writeln('<\/td><\/tr>'); document.writeln('<tr><td class="searchbox-body" id="searchbox-body">'); document.writeln('<form name="search" style="margin:0px; padding:0px" onSubmit=\'return jump()\'>'); document.writeln('<a class="searchbox-body" href="../_classes/index.html">Class<\/a>: '); document.writeln('<input type="text" size=10 value="" name="classname"><br>'); document.writeln('<a id="funcsearchlink" class="searchbox-body" href="../_functions/index.html">Function<\/a>: '); document.writeln('<input type="text" size=10 value="" name="funcname"><br>'); document.writeln('<a class="searchbox-body" href="../_variables/index.html">Variable<\/a>: '); document.writeln('<input type="text" size=10 value="" name="varname"><br>'); document.writeln('<a class="searchbox-body" href="../_constants/index.html">Constant<\/a>: '); document.writeln('<input type="text" size=10 value="" name="constname"><br>'); document.writeln('<a class="searchbox-body" href="../_tables/index.html">Table<\/a>: '); document.writeln('<input type="text" size=10 value="" name="tablename"><br>'); document.writeln('<input type="submit" class="searchbox-button" value="Search">'); document.writeln('<\/form>'); document.writeln('<\/td><\/tr><\/table>'); document.writeln('<\/td><\/tr><\/table>'); </script> <div id="search-popup" class="searchpopup"><p id="searchpopup-title" class="searchpopup-title">title</p><div id="searchpopup-body" class="searchpopup-body">Body</div><p class="searchpopup-close"><a href="javascript:gwCloseActive()">[close]</a></p></div> <h3>Function and Method Cross Reference</h3> <h2><a href="index.html#getstring">getstring()</a></h2> <b>Defined at:</b><ul> <li><a href="../inc/_ext/swift/classes/Swift/KeyCache/DiskKeyCache.php.html#getstring">/inc/_ext/swift/classes/Swift/KeyCache/DiskKeyCache.php</a> -> <a onClick="logFunction('getstring', '/inc/_ext/swift/classes/Swift/KeyCache/DiskKeyCache.php.source.html#l166')" href="../inc/_ext/swift/classes/Swift/KeyCache/DiskKeyCache.php.source.html#l166"> line 166</a></li> <li><a href="../inc/_ext/swift/classes/Swift/KeyCache.php.html#getstring">/inc/_ext/swift/classes/Swift/KeyCache.php</a> -> <a onClick="logFunction('getstring', '/inc/_ext/swift/classes/Swift/KeyCache.php.source.html#l64')" href="../inc/_ext/swift/classes/Swift/KeyCache.php.source.html#l64"> line 64</a></li> <li><a href="../inc/_ext/swift/classes/Swift/KeyCache/NullKeyCache.php.html#getstring">/inc/_ext/swift/classes/Swift/KeyCache/NullKeyCache.php</a> -> <a onClick="logFunction('getstring', '/inc/_ext/swift/classes/Swift/KeyCache/NullKeyCache.php.source.html#l63')" href="../inc/_ext/swift/classes/Swift/KeyCache/NullKeyCache.php.source.html#l63"> line 63</a></li> <li><a href="../inc/_ext/swift/classes/Swift/KeyCache/ArrayKeyCache.php.html#getstring">/inc/_ext/swift/classes/Swift/KeyCache/ArrayKeyCache.php</a> -> <a onClick="logFunction('getstring', '/inc/_ext/swift/classes/Swift/KeyCache/ArrayKeyCache.php.source.html#l132')" href="../inc/_ext/swift/classes/Swift/KeyCache/ArrayKeyCache.php.source.html#l132"> line 132</a></li> </ul> <b>Referenced 2 times:</b><ul> <li><a href="../inc/_ext/swift/classes/Swift/Mime/SimpleMimeEntity.php.html">/inc/_ext/swift/classes/Swift/Mime/SimpleMimeEntity.php</a> -> <a href="../inc/_ext/swift/classes/Swift/Mime/SimpleMimeEntity.php.source.html#l487"> line 487</a></li> <li><a href="../inc/_ext/swift/classes/Swift/KeyCache/ArrayKeyCache.php.html">/inc/_ext/swift/classes/Swift/KeyCache/ArrayKeyCache.php</a> -> <a href="../inc/_ext/swift/classes/Swift/KeyCache/ArrayKeyCache.php.source.html#l158"> line 158</a></li> </ul> <!-- A link to the phpxref site in your customized footer file is appreciated ;-) --> <br><hr> <table width="100%"> <tr><td>Generated: Sat Nov 21 22:13:19 2015</td> <td align="right"><i>Cross-referenced by <a href="http://phpxref.sourceforge.net/">PHPXref 0.7.1</a></i></td> </tr> </table> </body></html>
// TangramSettings.h : CTangramSettingsDlg implementation file #pragma once #include "resource.h" // CTangramSettingsDlg class CTangramSettingsDlg : public CAxDialogImpl<CTangramSettingsDlg> { public: CTangramSettingsDlg() { } ~CTangramSettingsDlg() { } enum { IDD = IDD_TANGRAMSETTINGS }; BEGIN_MSG_MAP(CTangramSettingsDlg) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) COMMAND_HANDLER(IDOK, BN_CLICKED, OnClickedOK) COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnClickedCancel) CHAIN_MSG_MAP(CAxDialogImpl<CTangramSettingsDlg>) END_MSG_MAP() // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnClickedOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnClickedCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); };
<?php /** * @author Ning * * @file * @ingroup WikiObjectModels */ class WOMTableCellParser extends <API key> { public function __construct() { parent::__construct(); $this->m_parserId = <API key>; } public function getValidModelTypes() { return array( WOM_TYPE_TBL_CELL ); } private function getFirstLineChar( $text, $offset ) { for ( $i = $offset; $i >= 0; if ( $text { $i } == "\n" ) { $s = substr( $text, $i ); if ( preg_match( '/^\s*([!|])/', $s, $m ) ) { return $m[1]; } break; } } return ''; } // FIXME: what if table cell style uses parser function which contains 'return' or '|' public function parseNext( $text, <API key> $parentObj, $offset = 0 ) { if ( !( $parentObj instanceof WOMTableModel ) ) return null; $lastLF = ( $text { $offset } == "\n" || ( $offset == 0 || $text { $offset - 1 } == "\n" ) ); // get the first char of current line $fch = $this->getFirstLineChar( $text, $offset ); if ( $fch == '' ) return null; $text = substr( $text, $offset ); $r = preg_match( '/^(' . ( ( $fch == '!' ) ? '!!|' : '' ) . '\|\||(\s*(\|\+|\|-|[!|])))/', $text, $m ); if ( !$r ) return null; if ( isset( $m[2] ) && !$lastLF ) return null; $len = strlen( $m[0] ); $text = substr( $text, $len ); $r = preg_match( '/^([^<\n|]*\|)[^|]/', $text, $m1 ); if ( !$r || preg_match( '/\{\{/', $m1[1] ) ) { // FIXME: what if matched style contains '{{', just think it is table body return array( 'len' => $len, 'obj' => new WOMTableCellModel( $m[0] ) ); } if ( $fch == '!' ) { $pos = strpos( $text, '!!', $len ); if ( $pos !== false && $pos < strlen( $m1[1] ) ) { return array( 'len' => $len, 'obj' => new WOMTableCellModel( $m[0] ) ); } } return array( 'len' => $len + strlen( $m1[1] ), 'obj' => new WOMTableCellModel( $m[0] . $m1[1] ) ); } public function isObjectClosed( $obj, $text, $offset ) { if ( !( $obj instanceof WOMTableCellModel ) ) return false; $fch = $this->getFirstLineChar( $text, $offset ); $lastLF = ( $text { $offset } == "\n" || ( $offset == 0 || $text { $offset - 1 } == "\n" ) ); $text = substr( $text, $offset ); if ( strlen( $text ) == 0 ) return 0; if ( $lastLF && preg_match( '/^(\s*[!|])/', $text ) ) return 0; if ( $fch == '' ) return false; if ( preg_match( '/^(' . ( ( $fch == '!' ) ? '!!|':'' ) . '\|\|)/', $text ) ) return 0; return false; } }
/* * Corrects block display not defined in IE6/7/8/9 & FF3 */ article, aside, details, figcaption, figure, footer, header, hgroup, nav, section { display: block; } /* * Corrects inline-block display not defined in IE6/7/8/9 & FF3 */ audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; } /* * Prevents modern browsers from displaying 'audio' without controls */ audio:not([controls]) { display: none; } /* * Addresses styling for 'hidden' attribute not present in IE7/8/9, FF3, S4 * Known issue: no IE6 support */ [hidden] { display: none; } html { font-size: 100%; overflow-y: scroll; -<API key>: 100%; -ms-text-size-adjust: 100%; } /* * Addresses margins handled incorrectly in IE6/7 */ body { margin: 0; } /* * Addresses font-family inconsistency between 'textarea' and other form elements. */ body, button, input, select, textarea { font-family: sans-serif; } /* * Addresses outline displayed oddly in Chrome */ a:focus { outline: thin dotted; } /* * Improves readability when focused and also mouse hovered in all browsers * people.opera.com/patrickl/experiments/keyboard/test */ a:hover, a:active { outline: 0; } /* * Neutralise smaller font-size in 'section' and 'article' in FF4+, Chrome, S5 */ h1 { font-size: 2em; } /* * Addresses styling not present in IE7/8/9, S5, Chrome */ abbr[title] { border-bottom: 1px dotted; } /* * Addresses style set to 'bolder' in FF3+, S4/5, Chrome */ b, strong { font-weight: 600; } blockquote { margin: 1em 40px; } /* * Addresses styling not present in S5, Chrome */ dfn { font-style: italic; } /* * Addresses styling not present in IE6/7/8/9 */ mark { background: #ff0; color: #000; } /* * Corrects font family set oddly in IE6, S4/5, Chrome * en.wikipedia.org/wiki/User:Davidgothberg/Test59 */ pre, code, kbd, samp { font-family: monospace, serif; _font-family: 'courier new', monospace; font-size: 1em; } /* * Improves readability of pre-formatted text in all browsers */ pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; } /* * 1. Addresses CSS quotes not supported in IE6/7 * 2. Addresses quote property not supported in S4 */ q { quotes: none; } q:before, q:after { content: ''; content: none; } small { font-size: 75%; } /* * Prevents sub and sup affecting line-height in all browsers * gist.github.com/413930 */ sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } sup { top: -0.5em; } sub { bottom: -0.25em; } ul, ol { margin-left: 0; padding: 0 0 0 40px; } dd { margin: 0 0 0 40px; } nav ul, nav ol { list-style: none; list-style-image: none; } /* * 1. Removes border when inside 'a' element in IE6/7/8/9, FF3 * 2. Improves image quality when scaled in IE7 * code.flickr.com/blog/2008/11/12/<API key>/ */ img { border: 0; -<API key>: bicubic; } /* * Corrects overflow displayed oddly in IE9 */ svg:not(:root) { overflow: hidden; } /* * Addresses margin not present in IE6/7/8/9, S5, O11 */ figure { margin: 0; } /* * Corrects margin displayed oddly in IE6/7 */ form { margin: 0; } /* * Define consistent border, margin, and padding */ fieldset { border: 1px solid #c0c0c0; margin: 0 2px; padding: 0.35em 0.625em 0.75em; } /* * 1. Corrects color not being inherited in IE6/7/8/9 * 2. Corrects text not wrapping in FF3 * 3. Corrects alignment displayed oddly in IE6/7 */ legend { border: 0; padding: 0; white-space: normal; *margin-left: -7px; } /* * 1. Corrects font size not being inherited in all browsers * 2. Addresses margins set differently in IE6/7, FF3+, S5, Chrome * 3. Improves appearance and consistency in all browsers */ button, input, select, textarea { font-size: 100%; margin: 0; vertical-align: baseline; *vertical-align: middle; } /* * Addresses FF3/4 setting line-height on 'input' using !important in the UA stylesheet */ button, input { line-height: normal; } /* * 1. Improves usability and consistency of cursor style between image-type 'input' and others * 2. Corrects inability to style clickable 'input' types in iOS * 3. Removes inner spacing in IE7 without affecting normal text inputs * Known issue: inner spacing remains in IE6 */ button, input[type="button"], input[type="reset"], input[type="submit"] { cursor: pointer; -webkit-appearance: button; *overflow: visible; } /* * 1. Addresses box sizing set to content-box in IE8/9 * 2. Removes excess padding in IE8/9 * 3. Removes excess padding in IE7 Known issue: excess padding remains in IE6 */ input[type="checkbox"], input[type="radio"] { box-sizing: border-box; padding: 0; *height: 13px; *width: 13px; } /* * 1. Addresses appearance set to searchfield in S5, Chrome * 2. Addresses box-sizing set to border-box in S5, Chrome (include -moz to future-proof) */ input[type="search"] { -webkit-appearance: textfield; -moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; } /* * Removes inner padding that is displayed in S5, Chrome on OS X */ input[type="search"]::-<API key> { -webkit-appearance: none; } /* * Removes search cancel button in S5, Chrome on OS X */ input[type="search"]::-<API key> { -webkit-appearance: none; } button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; } /* * 1. Removes default vertical scrollbar in IE6/7/8/9 * 2. Improves readability and alignment in all browsers */ textarea { overflow: auto; vertical-align: top; } /* * Remove most spacing between table cells */ table { border-collapse: collapse; border-spacing: 0; }
<?php if (!defined('IS_ADMIN_FLAG')) { die('Illegal Access'); } $csrfBlackListLocal = array(); $csrfBlackList = (isset($csrfBlackListCustom)) ? array_merge($csrfBlackListLocal, $csrfBlackListCustom) : $csrfBlackListLocal; if (! isset ( $_SESSION ['securityToken'] )) { $_SESSION ['securityToken'] = md5 ( uniqid ( rand (), true ) ); } if ((isset ( $_GET ['action'] ) || isset($_POST['action']) ) && $_SERVER['REQUEST_METHOD'] == 'POST') { $mainPage = isset($_GET['main_page']) ? $_GET['main_page'] : FILENAME_DEFAULT; if (!in_array($mainPage, $csrfBlackList)) { if ((! isset ( $_SESSION ['securityToken'] ) || ! isset ( $_POST ['securityToken'] )) || ($_SESSION ['securityToken'] !== $_POST ['securityToken'])) { zen_redirect ( zen_href_link ( FILENAME_TIME_OUT, '', $request_type ) ); } } } if (isset($_GET['typefilter'])) $_GET['typefilter'] = preg_replace('/[^0-9a-zA-Z_-]/', '', $_GET['typefilter']); if (isset($_GET['products_id'])) $_GET['products_id'] = preg_replace('/[^0-9a-f:]/', '', $_GET['products_id']); if (isset($_GET['manufacturers_id'])) $_GET['manufacturers_id'] = preg_replace('/[^0-9]/', '', $_GET['manufacturers_id']); if (isset($_GET['categories_id'])) $_GET['categories_id'] = preg_replace('/[^0-9]/', '', $_GET['categories_id']); if (isset($_GET['cPath'])) $_GET['cPath'] = preg_replace('/[^0-9_]/', '', $_GET['cPath']); if (isset($_GET['main_page'])) $_GET['main_page'] = preg_replace('/[^0-9a-zA-Z_]/', '', $_GET['main_page']); if (isset($_GET['sort'])) $_GET['sort'] = preg_replace('/[^0-9a-zA-Z]/', '', $_GET['sort']); $saniGroup1 = array('action', 'addr', 'alpha_filter_id', 'alpha_filter', 'authcapt', 'chapter', 'cID', 'currency', 'debug', 'delete', 'dfrom', 'disp_order', 'dto', 'edit', 'faq_item', 'filter_id', 'goback', 'goto', 'gv_no', 'id', 'inc_subcat', 'language', 'markflow', 'music_genre_id', 'nocache', 'notify', 'number_of_uploads', 'order_id', 'order', 'override', 'page', 'pfrom', 'pid', 'pID', 'pos', 'product_id', '<API key>', '<API key>', 'pto', 'record_company_id', 'referer', 'reviews_id', '<API key>', 'set_session_login', 'token', 'tx', 'type', 'zenid'); foreach ($saniGroup1 as $key) { if (isset($_GET[$key])) { $_GET[$key] = preg_replace('/[^\/0-9a-zA-Z_:@.-]/', '', $_GET[$key]); if (isset($_REQUEST[$key])) $_REQUEST[$key] = preg_replace('/[^\/0-9a-zA-Z_:@.-]/', '', $_REQUEST[$key]); } } /** * process all $_GET terms */ $strictReplace = '[<>\']'; $unStrictReplace = '[<>]'; if (isset($_GET) && count($_GET) > 0) { foreach($_GET as $key=>$value){ if(is_array($value)){ foreach($value as $key2 => $val2){ if ($key2 == 'keyword') { $_GET[$key][$key2] = preg_replace('/'.$unStrictReplace.'/', '', $val2); if (isset($_REQUEST[$key][$key2])) $_REQUEST[$key][$key2] = preg_replace('/'.$unStrictReplace.'/', '', $val2); } elseif(is_array($val2)){ foreach($val2 as $key3 => $val3){ $_GET[$key][$key2][$key3] = preg_replace('/'.$strictReplace.'/', '', $val3); if (isset($_REQUEST[$key][$key2][$key3])) $_REQUEST[$key][$key2][$key3] = preg_replace('/'.$strictReplace.'/', '', $val3); } } else { $_GET[$key][$key2] = preg_replace('/'.$strictReplace.'/', '', $val2); if (isset($_REQUEST[$key][$key2])) $_REQUEST[$key][$key2] = preg_replace('/'.$strictReplace.'/', '', $val2); } } } else { if ($key == 'keyword') { $_GET[$key] = preg_replace('/'.$unStrictReplace.'/', '', $value); if (isset($_REQUEST[$key])) $_REQUEST[$key] = preg_replace('/'.$unStrictReplace.'/', '', $value); } else { $_GET[$key] = preg_replace('/'.$strictReplace.'/', '', $value); if (isset($_REQUEST[$key])) $_REQUEST[$key] = preg_replace('/'.$strictReplace.'/', '', $value); } } unset($GLOBALS[$key]); } } /** * process all $_POST terms * @todo move the array process to security class */ if (isset($_POST) && count($_POST) > 0) { foreach($_POST as $key=>$value){ if(is_array($value)){ foreach($value as $key2 => $val2){ unset($GLOBALS[$key]); } } else { unset($GLOBALS[$key]); } } } /** * process all $_COOKIE terms */ if (isset($_COOKIE) && count($_COOKIE) > 0) { foreach($_COOKIE as $key=>$value){ if(is_array($value)){ foreach($value as $key2 => $val2){ unset($GLOBALS[$key]); } } else { unset($GLOBALS[$key]); } } } /** * process all $_SESSION terms */ if (isset($_SESSION) && count($_SESSION) > 0) { foreach($_SESSION as $key=>$value){ if(is_array($value)){ foreach($value as $key2 => $val2){ unset($GLOBALS[$key]); } } else { unset($GLOBALS[$key]); } } } /** * validate products_id for search engines and bookmarks, etc. */ if (isset($_GET['products_id']) && isset($_SESSION['check_valid']) && $_SESSION['check_valid'] != 'false') { $check_valid = <API key>($_GET['products_id']); if (!$check_valid) { $_GET['main_page'] = zen_get_info_page($_GET['products_id']); /** * do not recheck redirect */ $_SESSION['check_valid'] = 'false'; zen_redirect(zen_href_link($_GET['main_page'], 'products_id=' . $_GET['products_id'])); } } else { $_SESSION['check_valid'] = 'true'; } /** * We do some checks here to ensure $_GET['main_page'] has a sane value */ if (!isset($_GET['main_page']) || !zen_not_null($_GET['main_page'])) $_GET['main_page'] = 'index'; if (!is_dir(DIR_WS_MODULES . 'pages/' . $_GET['main_page'])) { if (MISSING_PAGE_CHECK == 'On' || MISSING_PAGE_CHECK == 'true') { $_GET['main_page'] = 'index'; } elseif (MISSING_PAGE_CHECK == 'Page Not Found') { header('HTTP/1.1 404 Not Found'); $_GET['main_page'] = <API key>; } } $current_page = $_GET['main_page']; $current_page_base = $current_page; $code_page_directory = DIR_WS_MODULES . 'pages/' . $current_page_base; $page_directory = $code_page_directory;
import os from urllib.error import URLError import pytest from distlib.index import PackageIndex from autopilot import pypi def test_restore_cwd(fake_project_dir): cwd = os.getcwd() with pypi.generate_dist(fake_project_dir.as_posix()) as (metadata, dist_files): pass assert cwd == os.getcwd() def test_generate_dist(fake_project_dir): with pypi.generate_dist(fake_project_dir.as_posix()) as (metadata, dist_files): assert metadata.name == 'fake_project' assert len(dist_files) == 2 for dist_file in dist_files: assert dist_file.exists() assert dist_file.is_file() def test_https_default(pypi_server, fake_project_dir): url, local_dir = pypi_server with pytest.raises(URLError) as excinfo: pypi.pypi_upload({'url': url, 'user': 'user', 'passeval': 'echo pass' }, dist_dir=fake_project_dir.as_posix()) assert 'Unexpected HTTP request on what should be a secure connection' in str(excinfo.value) def test_upload(pypi_server, fake_project_dir): url, local_dir = pypi_server assert local_dir.is_dir() assert local_dir.exists() assert len(list(local_dir.iterdir())) == 0 pypi.pypi_upload({'url': url, 'user': 'user', 'passeval': 'echo pass' }, use_https=False, dist_dir=fake_project_dir.as_posix()) files = [f.name for f in local_dir.iterdir()] assert len(files) == 2 assert 'fake_project-1.0.0-py2.py3-none-any.whl' in files assert 'fake_project-1.0.0.tar.gz' in files
var resource = { messages: {}, <API key>: 100, resourceIdMaxLength: 100, <API key>: 250, PROPAGATE_EVENT: 'propagateEvent', STEP_DISPLAY_ID: "stepDisplay", FLOW_CONTROLS_ID: "flowControls", initSwipeScroll: function() { var display = $(resource.STEP_DISPLAY_ID); // var hasControls = $(resource.FLOW_CONTROLS_ID).childElements().length > 0; // var scrollElement = hasControls ? display.up() : display; display && new TouchController(display.up(), display.up(1), { // debug: true }); }, submitForm: function(formId, params, fillForm) { if (!params) { return; } // prepare action url var url = buildActionUrl(params); fillForm && fillForm(); // write form attributes and submit it $(formId).writeAttribute('method', 'post').writeAttribute('action', url); $(formId).submit(); }, // Setup main event handler for click events on Add Resource pages. <API key>: function(handlers, <API key>, addAtBeginning) { if (resource.<API key>) { //If we want some handlers to fire before others we should pass addAtBeginning = true (addAtBeginning ? Array.prototype.unshift : Array.prototype.push). apply(resource.<API key>, handlers); return; } resource.<API key> = handlers; var selector = <API key> || 'body'; $$(selector)[0].observe('click', function(event) { resource.<API key> && resource.<API key>.each(function(clickEventHandler) { var result = clickEventHandler(event); //if handler returns some result //this means that we have found necessary handler so //do not need to process other if (result) { if (result !== resource.PROPAGATE_EVENT) { Event.stop(event); } throw $break; } }); }); }, TreeWrapper : function(options) { var that = this; this._treeId = options.treeId; this._resourceUriInput = $(options.resourceUriInput || 'resourceUri'); this._uri = this._resourceUriInput && this._resourceUriInput.getValue() || options.uri || '/'; if (!options.providerId) throw "There is no tree provider set for tree interpolate({id: this._treeId}); // Setup folders tree var treeOptions = ['providerId', 'rootUri', 'organizationId', 'publicFolderUri', 'urlGetNode', 'urlGetChildren']. inject({}, function(treeOptions, key) { options[key] !== null && (treeOptions[key] = options[key]); return treeOptions; }); this._tree = new dynamicTree.<API key>(this._treeId, treeOptions); this._tree.observe('tree:loaded', function() { that._tree.openAndSelectNode($(that._resourceUriInput).getValue()); }); this._tree.observe('leaf:selected', function(event) { that._uri = event.memo.node.param.uri; that._resourceUriInput.setValue(that._uri); }); this._tree.observe('node:selected', function() { that._resourceUriInput.setValue(that._uri = ''); }); return { getTreeId: function() { return that._treeId; }, getTree: function() { return that._tree; }, selectFolder: function(folderUri) { that._tree.openAndSelectNode(folderUri); }, <API key>: function() { return that._uri; } }; }, // Utility Methods switchButtonState : function(button, state) { buttonManager[state ? 'enable' : 'disable'].call(buttonManager, button); }, switchDisableState : function(element, disable) { (element = $(element)) && element[disable ? 'disable' : 'enable'].call(element); }, generateResourceId: function(name) { if (localContext && localContext.initOptions && localContext.initOptions.<API key>) { return name.replace(new RegExp(localContext.initOptions.<API key>, "g"), '_'); } else { throw "There is no <API key> property in init options."; } }, testResourceId: function(resourceId) { if (localContext && localContext.initOptions && localContext.initOptions.<API key>) { return new RegExp(localContext.initOptions.<API key>, "g").test(resourceId); } else { throw "There is no <API key> property in init options."; } }, labelValidator: function(value) { var isValid = true; var errorMessage = ""; if (value.blank()) { errorMessage = resource.messages['labelIsEmpty']; isValid = false; } else if (value.length > resource.<API key>) { errorMessage = resource.messages['labelToLong']; isValid = false; } return { isValid: isValid, errorMessage: errorMessage }; }, <API key>: function(element) { return { element: element, validators: [ {method: "mandatory", messages: {mandatory: resource.messages['labelIsEmpty']}}, {method: "minMaxLength", messages: {tooLong: resource.messages['labelToLong']}, options: {maxLength: resource.<API key>}}] }; }, <API key>: function(element) { return { element: element, validators: [ {method: "resourceIdChars", messages: resource.messages}, {method: "mandatory", messages: {mandatory: resource.messages['resourceIdIsEmpty']}}, {method: "minMaxLength", messages: {tooLong: resource.messages['resourceIdToLong']}, options: {maxLength: resource.resourceIdMaxLength}}] }; }, /** * The context of this method should contain _isEditMode property. Id it is true then validator will not validate * the value but will return isValid=true. */ resourceIdValidator: function(value) { var isValid = true; var errorMessage = ""; if (!this._isEditMode) { if (value.blank()) { errorMessage = resource.messages['resourceIdIsEmpty']; isValid = false; } else if (value.length > resource.resourceIdMaxLength) { errorMessage = resource.messages['resourceIdToLong']; isValid = false; } else if (resource.testResourceId(value)) { errorMessage = resource.messages['<API key>']; isValid = false; } } return { isValid: isValid, errorMessage: errorMessage }; }, <API key>: function(element) { return { element: element, validators: [ {method: "minMaxLength", messages: {tooLong: resource.messages['descriptionToLong']}, options: {maxLength: resource.<API key>}}] }; }, <API key>: function(value) { var isValid = true; var errorMessage = ""; if (value.length > resource.<API key>) { errorMessage = resource.messages['descriptionToLong']; isValid = false; } return { isValid: isValid, errorMessage: errorMessage }; }, dataSourceValidator: function(value) { var isValid = true; var errorMessage = ""; if (value.trim() === '') { errorMessage = resource.messages['dataSourceInvalid']; isValid = false; } return { isValid: isValid, errorMessage: errorMessage }; }, queryValidator: function(value) { var isValid = true; var errorMessage = ""; if (value.trim() === '') { errorMessage = resource.messages['queryInvalid']; isValid = false; } return { isValid: isValid, errorMessage: errorMessage }; }, <API key>: function(elementsToValidate) { // To use this method all elements should have validator or validationEntry property set. return elementsToValidate.collect(function(element) { if(element.validationEntry) { return element.validationEntry } else { return {validator: element.validator, element: element}; } }); } }; if (typeof require === "undefined") { // prevent conflict with domReady plugin in RequireJS environment isIPad() && document.observe("dom:loaded", resource.initSwipeScroll.bind(resource)); }
#include <linux/vmalloc.h> #include <linux/highmem.h> #include "netxen_nic_hw.h" #include "netxen_nic.h" #include "netxen_nic_phan_reg.h" #include <linux/dma-mapping.h> #include <linux/vmalloc.h> MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver"); MODULE_LICENSE("GPL"); MODULE_VERSION(<API key>); char <API key>[] = "netxen_nic"; static char <API key>[] = "NetXen Network Driver version " <API key>; static int port_mode = <API key>; /* Default to restricted 1G auto-neg mode */ static int wol_port_mode = 5; static int use_msi = 1; #ifdef CONFIG_PCI_MSIX static int use_msi_x = 1; #else /* CONFIG_PCI_MSIX */ static int use_msi_x = 0; #endif /* CONFIG_PCI_MSIX */ u8 nx_p2_id = NX_P2_C0; #define DMA_32BIT_MASK <API key> #define DMA_35BIT_MASK <API key> #define DMA_39BIT_MASK <API key> /* Local functions to NetXen NIC driver */ static int __devinit netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent); static void __devexit netxen_nic_remove(struct pci_dev *pdev); static int netxen_nic_open(struct net_device *netdev); static int netxen_nic_close(struct net_device *netdev); static int <API key>(struct sk_buff *, struct net_device *); static void netxen_tx_timeout(struct net_device *netdev); static void <API key>(unsigned long adapid); static void netxen_watchdog(unsigned long); static void <API key>(unsigned long adaptid); static int netxen_nic_poll(struct net_device *dev, int *budget); #ifdef <API key> static void <API key>(struct net_device *netdev); #endif static irqreturn_t netxen_intr(int irq, void *data, struct pt_regs *regs); static irqreturn_t netxen_msi_intr(int irq, void *data, struct pt_regs *regs); /* PCI Device ID Table */ #define ENTRY(device) \ {PCI_DEVICE(0x4040, (device)), \ .class = <API key> << 8, .class_mask = ~0} static struct pci_device_id netxen_pci_tbl[] __devinitdata = { ENTRY(0x0001), ENTRY(0x0002), ENTRY(0x0003), ENTRY(0x0004), ENTRY(0x0005), ENTRY(0x0024), ENTRY(0x0025), ENTRY(0x0100), {0,} }; MODULE_DEVICE_TABLE(pci, netxen_pci_tbl); /* * In netxen_nic_down(), we must wait for any pending callback requests into * <API key>() to complete; eg otherwise the watchdog_timer could be * reenabled right after it is deleted in netxen_nic_down(). * <API key>() does this synchronization. * * Normally, schedule_work()/<API key>() could have worked, but * netxen_nic_close() is invoked with kernel rtnl lock held. netif_carrier_off() * call in netxen_nic_close() triggers a schedule_work(&linkwatch_work), and a * subsequent call to <API key>() in netxen_nic_down() would cause * linkwatch_event() to be executed which also attempts to acquire the rtnl * lock thus causing a deadlock. */ static struct workqueue_struct *netxen_workq; #define SCHEDULE_WORK(tp) queue_work(netxen_workq, tp) #define <API key>() flush_workqueue(netxen_workq) static void netxen_watchdog(unsigned long); static uint32_t crb_cmd_producer[4] = { <API key>, <API key>, <API key>, <API key> }; void <API key>(struct netxen_adapter *adapter, uint32_t crb_producer) { adapter->pci_write_normalize(adapter, adapter-><API key>, crb_producer); } static uint32_t crb_cmd_consumer[4] = { <API key>, <API key>, <API key>, <API key> }; static inline void <API key>(struct netxen_adapter *adapter, u32 crb_consumer) { adapter->pci_write_normalize(adapter, adapter-><API key>, crb_consumer); } static uint32_t msi_tgt_status[8] = { <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key> }; static struct <API key> legacy_intr[] = <API key>; static inline void <API key>(struct netxen_adapter *adapter) { adapter->pci_write_normalize(adapter, adapter->crb_intr_mask, 0); } static inline void <API key>(struct netxen_adapter *adapter) { adapter->pci_write_normalize(adapter, adapter->crb_intr_mask, 0x1); if (!<API key>(adapter)) adapter->pci_write_immediate(adapter, adapter->legacy_intr.tgt_mask_reg, 0xfbff); } static int nx_set_dma_mask(struct netxen_adapter *adapter, uint8_t revision_id) { struct pci_dev *pdev = adapter->pdev; int err; uint64_t mask; #ifdef CONFIG_IA64 adapter->dma_mask = DMA_32BIT_MASK; #else if (revision_id >= NX_P3_B0) { /* should go to DMA_64BIT_MASK */ adapter->dma_mask = DMA_39BIT_MASK; mask = DMA_39BIT_MASK; } else if (revision_id == NX_P3_A2) { adapter->dma_mask = DMA_39BIT_MASK; mask = DMA_39BIT_MASK; } else if (revision_id == NX_P2_C1) { adapter->dma_mask = DMA_35BIT_MASK; mask = DMA_35BIT_MASK; } else { adapter->dma_mask = DMA_32BIT_MASK; mask = DMA_32BIT_MASK; goto set_32_bit_mask; } /* * Consistent DMA mask is set to 32 bit because it cannot be set to * 35 bits. For P3 also leave it at 32 bits for now. Only the rings * come off this pool. */ if (pci_set_dma_mask(pdev, mask) == 0 && <API key>(pdev, DMA_32BIT_MASK) == 0) { adapter->pci_using_dac = 1; return 0; } #endif /* CONFIG_IA64 */ set_32_bit_mask: err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); if (!err) err = <API key>(pdev, DMA_32BIT_MASK); if (err) { DPRINTK(ERR, "No usable DMA configuration, aborting:%d\n", err); return err; } adapter->pci_using_dac = 0; return 0; } static void <API key>(struct netxen_adapter *adapter) { switch (adapter->ahw.boardcfg.board_type) { case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: adapter->msix_supported = !!use_msi_x; adapter->max_rx_desc_count = <API key>; break; case <API key>: case <API key>: case <API key>: case <API key>: adapter->msix_supported = 0; adapter->max_rx_desc_count = <API key>; break; case <API key>: case <API key>: case <API key>: adapter->msix_supported = !!use_msi_x; adapter->max_rx_desc_count = <API key>; break; case <API key>: case <API key>: adapter->msix_supported = 0; adapter->max_rx_desc_count = <API key>; break; case <API key>: adapter->msix_supported = !!use_msi_x; if (adapter->ahw.board_type == NETXEN_NIC_XGBE) adapter->max_rx_desc_count = <API key>; else adapter->max_rx_desc_count = <API key>; break; default: adapter->msix_supported = 0; adapter->max_rx_desc_count = <API key>; printk(KERN_WARNING "Unknown board type(0x%x)\n", adapter->ahw.boardcfg.board_type); break; } adapter->max_tx_desc_count = <API key>; adapter-><API key> = <API key>; adapter-><API key> = <API key>; adapter-><API key> = 1; return; } static int <API key>(struct netxen_adapter *adapter, int first_boot) { u32 val, timeout; if (first_boot == 0x55555555) { /* This is the first boot after power up */ adapter->pci_write_normalize(adapter, NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC); if (!NX_IS_REVISION_P2(adapter->ahw.revision_id)) return 0; /* PCI bus master workaround */ adapter->hw_read_wx(adapter, NETXEN_PCIE_REG(0x4), &first_boot, 4); if (!(first_boot & 0x4)) { first_boot |= 0x4; adapter->hw_write_wx(adapter, NETXEN_PCIE_REG(0x4), &first_boot, 4); adapter->hw_read_wx(adapter, NETXEN_PCIE_REG(0x4), &first_boot, 4); } /* This is the first boot after power up */ adapter->hw_read_wx(adapter, <API key>, &first_boot, 4); if (first_boot != 0x80000f) { /* clear the register for future unloads/loads */ adapter->pci_write_normalize(adapter, NETXEN_CAM_RAM(0x1fc), 0); return -EIO; } /* Start P2 boot loader */ val = adapter->pci_read_normalize(adapter, <API key>); adapter->pci_write_normalize(adapter, <API key>, val | 0x1); timeout = 0; do { msleep(1); val = adapter->pci_read_normalize(adapter, NETXEN_CAM_RAM(0x1fc)); if (++timeout > 5000) return -EIO; } while (val == NETXEN_BDINFO_MAGIC); } return 0; } static void <API key>(struct netxen_adapter *adapter) { u32 val, data; val = adapter->ahw.boardcfg.board_type; if ((val == <API key>) || (val == <API key>)) { if (port_mode == <API key>) { data = <API key>; adapter->hw_write_wx(adapter, <API key>, &data, 4); } else if (port_mode == NETXEN_PORT_MODE_XG) { data = NETXEN_PORT_MODE_XG; adapter->hw_write_wx(adapter, <API key>, &data, 4); } else if (port_mode == <API key>) { data = <API key>; adapter->hw_write_wx(adapter, <API key>, &data, 4); } else if (port_mode == <API key>) { data = <API key>; adapter->hw_write_wx(adapter, <API key>, &data, 4); } else { data = <API key>; adapter->hw_write_wx(adapter, <API key>, &data, 4); } if ((wol_port_mode != <API key>) && (wol_port_mode != NETXEN_PORT_MODE_XG) && (wol_port_mode != <API key>) && (wol_port_mode != <API key>)) { wol_port_mode = <API key>; } adapter->hw_write_wx(adapter, <API key>, &wol_port_mode, 4); } } #define PCI_CAP_ID_GEN 0x10 static void <API key>(struct netxen_adapter *adapter) { u32 pdevfuncsave; u32 c8c9value = 0; u32 chicken = 0; u32 control = 0; int i, pos; struct pci_dev *pdev; pdev = adapter->pdev; adapter->hw_read_wx(adapter, NETXEN_PCIE_REG(PCIE_CHICKEN3), &chicken, 4); /* clear chicken3.25:24 */ chicken &= 0xFCFFFFFF; /* * if gen1 and B0, set F1020 - if gen 2, do nothing * if gen2 set to F1000 */ pos = pci_find_capability(pdev, PCI_CAP_ID_GEN); if (pos == 0xC0) { <API key>(pdev, pos + 0x10, &control); if ((control & 0x000F0000) != 0x00020000) { /* set chicken3.24 if gen1 */ chicken |= 0x01000000; } printk(KERN_INFO "%s Gen2 strapping detected\n", <API key>); c8c9value = 0xF1000; } else { /* set chicken3.24 if gen1 */ chicken |= 0x01000000; printk(KERN_INFO "%s Gen1 strapping detected\n", <API key>); if (adapter->ahw.revision_id == NX_P3_B0) c8c9value = 0xF1020; else c8c9value = 0; } adapter->hw_write_wx(adapter, NETXEN_PCIE_REG(PCIE_CHICKEN3), &chicken, 4); if (!c8c9value) return; pdevfuncsave = pdev->devfn; if (pdevfuncsave & 0x07) return; for (i = 0; i < 8; i++) { <API key>(pdev, pos + 8, &control); <API key>(pdev, pos + 8, &control); <API key>(pdev, pos + 8, c8c9value); pdev->devfn++; } pdev->devfn = pdevfuncsave; } static void netxen_set_msix_bit(struct pci_dev *pdev, int enable) { #ifdef CONFIG_PCI_MSIX u32 control; int pos; pos = pci_find_capability(pdev, PCI_CAP_ID_MSIX); if (pos) { <API key>(pdev, pos, &control); if (enable) control |= <API key>; else control = 0; <API key>(pdev, pos, control); } #endif /* CONFIG_PCI_MSIX */ } static void <API key>(struct netxen_adapter *adapter) { int i; for (i = 0; i < <API key>; i++) adapter->msix_entries[i].entry = i; } static int <API key>(struct netxen_adapter *adapter) { int i; unsigned char *p; __le64 mac_addr; struct net_device *netdev = adapter->netdev; if (<API key>(adapter) != 0) return -EIO; if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { if (<API key>(adapter, &mac_addr) != 0) return -EIO; } else { if (<API key>(adapter, &mac_addr) != 0) return -EIO; } p = (unsigned char *)&mac_addr; for (i = 0; i < 6; i++) netdev->dev_addr[i] = *(p + 5 - i); if (!is_valid_ether_addr(netdev->dev_addr)) { dev_warn(&adapter->pdev->dev, "%s: Bad MAC address " "%02x:%02x:%02x:%02x:%02x:%02x.\n", <API key>, netdev->dev_addr[0], netdev->dev_addr[1], netdev->dev_addr[2], netdev->dev_addr[3], netdev->dev_addr[4], netdev->dev_addr[5]); } else adapter->macaddr_set(adapter, netdev->dev_addr); return 0; } /* * netxen_nic_probe() * * The Linux system will invoke this after identifying the vendor ID and * device Id in the pci_tbl supported by this module. * * A quad port card has one operational PCI config space, (function 0), * which is used to access all four ports. * * This routine will initialize the adapter, and setup the global parameters * along with the port's specific structure. */ static int __devinit netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct net_device *netdev = NULL; struct netxen_adapter *adapter = NULL; void __iomem *mem_ptr0 = NULL; void __iomem *mem_ptr1 = NULL; void __iomem *mem_ptr2 = NULL; unsigned long <API key>; unsigned long <API key>; u8 __iomem *db_ptr = NULL; unsigned long mem_base, mem_len, db_base, db_len, pci_len0 = 0; int i, err; int first_driver, first_boot; u32 val; int pci_func_id = PCI_FUNC(pdev->devfn); struct <API key> *legacy_intrp; uint8_t revision_id; if (pci_func_id == 0) printk(KERN_INFO "%s\n", <API key>); if (pdev->class != 0x020000) { printk(KERN_DEBUG "NetXen function %d, class %x will not " "be enabled.\n",pci_func_id, pdev->class); return -ENODEV; } <API key>(pdev, PCI_REVISION_ID, &nx_p2_id); revision_id = nx_p2_id; if ((revision_id >= NX_P3_A0) && (revision_id < NX_P3_B1)) { printk(KERN_WARNING "NetXen chip revisions between 0x%x-0x%x" "will not be enabled.\n", NX_P3_A0, NX_P3_B1); return -ENODEV; } if ((err = pci_enable_device(pdev))) return err; if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { err = -ENODEV; goto <API key>; } if ((err = pci_request_regions(pdev, <API key>))) goto <API key>; pci_set_master(pdev); netdev = alloc_etherdev(sizeof(struct netxen_adapter)); if(!netdev) { printk(KERN_ERR"%s: Failed to allocate memory for the " "device block.Check system memory resource" " usage.\n", <API key>); goto err_out_free_res; } SET_MODULE_OWNER(netdev); SET_NETDEV_DEV(netdev, &pdev->dev); adapter = netdev->priv; memset(adapter, 0 , sizeof(struct netxen_adapter)); adapter->netdev = netdev; adapter->pdev = pdev; adapter->ahw.pci_func = pci_func_id; adapter->ahw.revision_id = revision_id; err = nx_set_dma_mask(adapter, revision_id); if (err) goto err_out_free_netdev; rwlock_init(&adapter->adapter_lock); adapter->ahw.qdr_sn_window = -1; adapter->ahw.ddr_mn_window = -1; /* remap phys address */ mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */ mem_len = pci_resource_len(pdev, 0); pci_len0 = 0; adapter->hw_write_wx = <API key>; adapter->hw_read_wx = <API key>; adapter->pci_read_immediate = <API key>; adapter->pci_write_immediate = <API key>; adapter->pci_read_normalize = <API key>; adapter->pci_write_normalize = <API key>; adapter->pci_set_window = <API key>; adapter->pci_mem_read = <API key>; adapter->pci_mem_write = <API key>; /* 128 Meg of memory */ if (mem_len == <API key>) { mem_ptr0 = ioremap(mem_base, <API key>); mem_ptr1 = ioremap(mem_base + <API key>, <API key>); mem_ptr2 = ioremap(mem_base + <API key>, <API key>); <API key> = <API key>; <API key> = <API key>; } else if (mem_len == <API key>) { mem_ptr1 = ioremap(mem_base, <API key>); mem_ptr2 = ioremap(mem_base + <API key> - <API key>, <API key>); <API key> = 0; <API key> = 0; } else if (mem_len == NETXEN_PCI_2MB_SIZE) { adapter->hw_write_wx = <API key>; adapter->hw_read_wx = <API key>; adapter->pci_read_immediate = <API key>; adapter->pci_write_immediate = <API key>; adapter->pci_read_normalize = <API key>; adapter->pci_write_normalize = <API key>; adapter->pci_set_window = <API key>; adapter->pci_mem_read = <API key>; adapter->pci_mem_write = <API key>; mem_ptr0 = ioremap(mem_base, mem_len); pci_len0 = mem_len; <API key> = 0; <API key> = 0; adapter->ahw.ddr_mn_window = 0; adapter->ahw.qdr_sn_window = 0; adapter->ahw.mn_win_crb = 0x100000 + PCIX_MN_WINDOW + (pci_func_id * 0x20); adapter->ahw.ms_win_crb = 0x100000 + PCIX_SN_WINDOW; if (pci_func_id < 4) adapter->ahw.ms_win_crb += (pci_func_id * 0x20); else adapter->ahw.ms_win_crb += 0xA0 + ((pci_func_id - 4) * 0x10); } else { err = -EIO; goto err_out_free_netdev; } dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20)); db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */ db_len = pci_resource_len(pdev, 4); if (db_len == 0) { printk(KERN_ERR "%s: doorbell is disabled\n", <API key>); err = -EIO; goto err_out_iounmap; } DPRINTK(INFO, "doorbell ioremap from %lx a size of %lx\n", db_base, db_len); db_ptr = ioremap(db_base, <API key>); if (!db_ptr) { printk(KERN_ERR "%s: Failed to allocate doorbell map.", <API key>); err = -EIO; goto err_out_iounmap; } DPRINTK(INFO, "doorbell ioremaped at %p\n", db_ptr); adapter->ahw.pci_base0 = mem_ptr0; adapter->ahw.pci_len0 = pci_len0; adapter->ahw.<API key> = <API key>; adapter->ahw.<API key> = <API key>; adapter->ahw.pci_base1 = mem_ptr1; adapter->ahw.pci_base2 = mem_ptr2; adapter->ahw.db_base = db_ptr; adapter->ahw.db_len = db_len; if (revision_id >= NX_P3_B0) legacy_intrp = &legacy_intr[pci_func_id]; else legacy_intrp = &legacy_intr[0]; adapter->legacy_intr.int_vec_bit = legacy_intrp->int_vec_bit; adapter->legacy_intr.tgt_status_reg = legacy_intrp->tgt_status_reg; adapter->legacy_intr.tgt_mask_reg = legacy_intrp->tgt_mask_reg; adapter->legacy_intr.pci_int_reg = legacy_intrp->pci_int_reg; /* this will be read from FW later */ adapter->intr_scheme = -1; adapter->msi_mode = -1; /* This will be reset for mezz cards */ adapter->portnum = pci_func_id; adapter->status &= ~<API key>; adapter->rx_csum = 1; adapter->mc_enabled = 0; if (NX_IS_REVISION_P3(revision_id)) adapter->max_mc_count = 38; else adapter->max_mc_count = 16; netdev->open = netxen_nic_open; netdev->stop = netxen_nic_close; netdev->hard_start_xmit = <API key>; netdev->get_stats = <API key>; if (NX_IS_REVISION_P3(revision_id)) netdev->set_multicast_list = <API key>; else netdev->set_multicast_list = <API key>; netdev->set_mac_address = netxen_nic_set_mac; netdev->change_mtu = <API key>; netdev->tx_timeout = netxen_tx_timeout; netdev->watchdog_timeo = 2*HZ; <API key>(netdev, netdev->mtu); SET_ETHTOOL_OPS(netdev, &<API key>); netdev->poll = netxen_nic_poll; netdev->weight = <API key>; #ifdef <API key> netdev->poll_controller = <API key>; #endif /* ScatterGather support */ netdev->features = NETIF_F_SG; netdev->features |= NETIF_F_IP_CSUM; netdev->features |= NETIF_F_TSO; if (adapter->pci_using_dac) netdev->features |= NETIF_F_HIGHDMA; /* * Set the CRB window to invalid. If any register in window 0 is * accessed it should set the window to 0 and then reset it to 1. */ adapter->curr_window = 255; if (<API key>(adapter) != 0) { printk("%s: Error getting board config info.\n", <API key>); err = -EIO; goto err_out_iounmap; } <API key>(adapter); /* Mezz cards have PCI function 0,2,3 enabled */ switch (adapter->ahw.boardcfg.board_type) { case <API key>: case <API key>: if (pci_func_id >= 2) adapter->portnum = pci_func_id - 2; break; default: break; } /* * This call will setup various max rx/tx counts. * It must be done before any buffer/ring allocations. */ <API key>(adapter); first_driver = 0; if (NX_IS_REVISION_P3(revision_id)) { if (adapter->ahw.pci_func == 0) first_driver = 1; } else { if (adapter->portnum == 0) first_driver = 1; } if (first_driver) { first_boot = adapter->pci_read_normalize(adapter, NETXEN_CAM_RAM(0x1fc)); err = <API key>(adapter, first_boot); if (err) { printk(KERN_ERR "%s: error in init HW init sequence\n", <API key>); goto err_out_iounmap; } if (NX_IS_REVISION_P3(revision_id)) <API key>(adapter); if (first_boot != 0x55555555) { adapter->pci_write_normalize(adapter, CRB_CMDPEG_STATE, 0); <API key>(adapter, 0); msleep(1); } <API key>(adapter); if (NX_IS_REVISION_P3(revision_id)) <API key>(adapter); if (NX_IS_REVISION_P2(revision_id)) { /* Initialize multicast addr pool owners */ val = 0x7654; if (adapter->ahw.board_type == NETXEN_NIC_XGBE) val |= 0x0f000000; <API key>(adapter, <API key>, val); } err = <API key>(adapter); if (err) goto err_out_iounmap; /* * Tell the hardware our version number. */ i = (<API key> << 16) | ((<API key> << 8)) | (<API key>); adapter->pci_write_normalize(adapter, CRB_DRIVER_VERSION, i); /* Handshake with the card before we register the devices. */ err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); if (err) goto <API key>; } /* first_driver */ <API key>(adapter); if (NX_IS_REVISION_P3(revision_id)) { adapter->hw_read_wx(adapter, <API key>, &val, 4); adapter->ahw.cut_through = (val & 0x4) ? 1 : 0; dev_info(&pdev->dev, "firmware running in %s mode\n", adapter->ahw.cut_through ? "cut through" : "legacy"); } /* * See if the firmware gave us a virtual-physical port mapping. */ adapter->physical_port = adapter->portnum; i = adapter->pci_read_normalize(adapter, CRB_V2P(adapter->portnum)); if (i != 0x55555555) adapter->physical_port = i; adapter->flags &= ~(<API key> | <API key>); netxen_set_msix_bit(pdev, 0); if (NX_IS_REVISION_P3(revision_id)) { if ((mem_len != <API key>) && mem_len != NETXEN_PCI_2MB_SIZE) adapter->msix_supported = 0; } if (adapter->msix_supported) { <API key>(adapter); if (pci_enable_msix(pdev, adapter->msix_entries, <API key>)) goto request_msi; adapter->flags |= <API key>; netxen_set_msix_bit(pdev, 1); dev_info(&pdev->dev, "using msi-x interrupts\n"); } else { request_msi: if (use_msi && !pci_enable_msi(pdev)) { adapter->flags |= <API key>; dev_info(&pdev->dev, "using msi interrupts\n"); } else dev_info(&pdev->dev, "using legacy interrupts\n"); } if (adapter->flags & <API key>) netdev->irq = adapter->msix_entries[0].vector; else netdev->irq = pdev->irq; err = <API key>(adapter); if (err) goto err_out_disable_msi; init_timer(&adapter->watchdog_timer); adapter->watchdog_timer.function = &netxen_watchdog; adapter->watchdog_timer.data = (unsigned long)adapter; INIT_WORK(&adapter->watchdog_task, (void (*)(void *))<API key>, adapter); INIT_WORK(&adapter->tx_timeout_task, (void (*)(void *))<API key>, netdev); err = <API key>(adapter); if (err) dev_warn(&pdev->dev, "failed to read mac addr\n"); netif_carrier_off(netdev); netif_stop_queue(netdev); if ((err = register_netdev(netdev))) { printk(KERN_ERR "%s: register_netdev failed port " aborting\n", <API key>, adapter->portnum); err = -EIO; goto err_out_disable_msi; } pci_set_drvdata(pdev, adapter); switch (adapter->ahw.board_type) { case NETXEN_NIC_GBE: dev_info(&adapter->pdev->dev, "%s: GbE port initialized\n", adapter->netdev->name); break; case NETXEN_NIC_XGBE: dev_info(&adapter->pdev->dev, "%s: XGbE port initialized\n", adapter->netdev->name); break; } return 0; err_out_disable_msi: if (adapter->flags & <API key>) pci_disable_msix(pdev); if (adapter->flags & <API key>) pci_disable_msi(pdev); <API key>: if (first_driver) <API key>(adapter); err_out_iounmap: if (db_ptr) iounmap(db_ptr); if (mem_ptr0) iounmap(mem_ptr0); if (mem_ptr1) iounmap(mem_ptr1); if (mem_ptr2) iounmap(mem_ptr2); err_out_free_netdev: free_netdev(netdev); err_out_free_res: pci_release_regions(pdev); <API key>: pci_set_drvdata(pdev, NULL); pci_disable_device(pdev); return err; } static void __devexit netxen_nic_remove(struct pci_dev *pdev) { struct netxen_adapter *adapter; struct net_device *netdev; adapter = pci_get_drvdata(pdev); if (adapter == NULL) return; netdev = adapter->netdev; unregister_netdev(netdev); if (adapter->is_up == <API key>) { <API key>(adapter); <API key>(adapter); <API key>(adapter); if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) <API key>(adapter); } if (adapter->portnum == 0) <API key>(adapter); if (adapter->irq) free_irq(adapter->irq, adapter); if (adapter->flags & <API key>) pci_disable_msix(pdev); if (adapter->flags & <API key>) pci_disable_msi(pdev); iounmap(adapter->ahw.db_base); iounmap(adapter->ahw.pci_base0); if (adapter->ahw.pci_base1 != NULL) iounmap(adapter->ahw.pci_base1); if (adapter->ahw.pci_base2 != NULL) iounmap(adapter->ahw.pci_base2); pci_release_regions(pdev); pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); free_netdev(netdev); } /* * Called when a network interface is made active * @returns 0 on success, negative value on failure */ static int netxen_nic_open(struct net_device *netdev) { struct netxen_adapter *adapter = (struct netxen_adapter *)netdev->priv; int err = 0; int ctx, ring; irq_handler_t handler; unsigned long flags = SA_SAMPLE_RANDOM; if (adapter->driver_mismatch) return -EIO; if (adapter->is_up != <API key>) { err = <API key>(adapter); if (err != 0) { printk(KERN_ERR "Failed to init firmware\n"); return -EIO; } if (adapter->fw_major < 4) adapter->max_rds_rings = 3; else adapter->max_rds_rings = 2; err = <API key>(adapter); if (err) { printk(KERN_ERR "%s: Error in setting sw resources\n", netdev->name); return err; } <API key>(adapter); err = <API key>(adapter); if (err) { printk(KERN_ERR "%s: Error in setting hw resources\n", netdev->name); goto err_out_free_sw; } if ((adapter->msi_mode != MSI_MODE_MULTIFUNC) || (adapter->intr_scheme != INTR_SCHEME_PERPORT)) { printk(KERN_ERR "%s: Firmware interrupt scheme is " "incompatible with driver\n", netdev->name); adapter->driver_mismatch = 1; goto err_out_free_hw; } if (adapter->fw_major < 4) { adapter-><API key> = crb_cmd_producer[adapter->portnum]; adapter-><API key> = crb_cmd_consumer[adapter->portnum]; <API key>(adapter, 0); <API key>(adapter, 0); } for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { for (ring = 0; ring < adapter->max_rds_rings; ring++) <API key>(adapter, ctx, ring); } if (<API key>(adapter)) handler = netxen_msi_intr; else { flags |= SA_SHIRQ; handler = netxen_intr; } adapter->irq = netdev->irq; err = request_irq(adapter->irq, handler, flags, netdev->name, adapter); if (err) { printk(KERN_ERR "request_irq failed with: %d\n", err); goto err_out_free_rxbuf; } adapter->is_up = <API key>; } /* Done here again so that even if phantom sw overwrote it, * we set it */ err = adapter->init_port(adapter, adapter->physical_port); if (err) { printk(KERN_ERR "%s: Failed to initialize port %d\n", <API key>, adapter->portnum); goto err_out_free_irq; } adapter->macaddr_set(adapter, netdev->dev_addr); <API key>(adapter); netdev->set_multicast_list(netdev); if (adapter->set_mtu) adapter->set_mtu(adapter, netdev->mtu); adapter->ahw.linkup = 0; mod_timer(&adapter->watchdog_timer, jiffies); <API key>(adapter); netif_start_queue(netdev); return 0; err_out_free_irq: free_irq(adapter->irq, adapter); err_out_free_rxbuf: <API key>(adapter); err_out_free_hw: <API key>(adapter); err_out_free_sw: <API key>(adapter); return err; } /* * netxen_nic_close - Disables a network interface entry point */ static int netxen_nic_close(struct net_device *netdev) { struct netxen_adapter *adapter = netdev_priv(netdev); netif_carrier_off(netdev); netif_stop_queue(netdev); if (adapter->stop_port) adapter->stop_port(adapter); <API key>(adapter); <API key>(adapter); <API key>(); del_timer_sync(&adapter->watchdog_timer); return 0; } void netxen_tso_check(struct netxen_adapter *adapter, struct cmd_desc_type0 *desc, struct sk_buff *skb) { if (desc->mss) { desc->total_hdr_length = sizeof(struct ethhdr) + ((skb->nh.iph)->ihl * sizeof(u32)) + ((skb->h.th)->doff * sizeof(u32)); if ((NX_IS_REVISION_P3(adapter->ahw.revision_id)) && (skb->protocol == htons(ETH_P_IPV6))) <API key>(desc, TX_TCP_LSO6); else <API key>(desc, TX_TCP_LSO); } else if (skb->ip_summed == CHECKSUM_HW) { if (skb->nh.iph->protocol == IPPROTO_TCP) <API key>(desc, TX_TCP_PKT); else if (skb->nh.iph->protocol == IPPROTO_UDP) <API key>(desc, TX_UDP_PKT); else return; } desc->tcp_hdr_offset = skb->h.raw - skb->data; desc->ip_hdr_offset = skb->nh.raw - skb->data; } static int <API key>(struct sk_buff *skb, struct net_device *netdev) { struct netxen_adapter *adapter = netdev_priv(netdev); struct <API key> *hw = &adapter->ahw; unsigned int first_seg_len = skb->len - skb->data_len; struct netxen_skb_frag *buffrag; unsigned int i; u32 producer, consumer; u32 saved_producer = 0; struct cmd_desc_type0 *hwdesc; int k; struct netxen_cmd_buffer *pbuf = NULL; int frag_count; int no_of_desc; u32 num_txd = adapter->max_tx_desc_count; frag_count = skb_shinfo(skb)->nr_frags + 1; /* There 4 fragments per descriptor */ no_of_desc = (frag_count + 3) >> 2; if (netdev->features & NETIF_F_TSO) { if (skb_shinfo(skb)->tso_size > 0) { no_of_desc++; if (((skb->nh.iph)->ihl * sizeof(u32)) + ((skb->h.th)->doff * sizeof(u32)) + sizeof(struct ethhdr) > (sizeof(struct cmd_desc_type0) - 2)) { no_of_desc++; } } } producer = adapter->cmd_producer; smp_mb(); consumer = adapter->last_cmd_consumer; if ((no_of_desc+2) > find_diff_among(producer, consumer, num_txd)) { netif_stop_queue(netdev); smp_mb(); return NETDEV_TX_BUSY; } /* Copy the descriptors into the hardware */ saved_producer = producer; hwdesc = &hw->cmd_desc_head[producer]; memset(hwdesc, 0, sizeof(struct cmd_desc_type0)); /* Take skb->data itself */ pbuf = &adapter->cmd_buf_arr[producer]; if ((netdev->features & NETIF_F_TSO) && skb_shinfo(skb)->tso_size > 0) { pbuf->mss = skb_shinfo(skb)->tso_size; hwdesc->mss = cpu_to_le16(skb_shinfo(skb)->tso_size); } else { pbuf->mss = 0; hwdesc->mss = 0; } pbuf->total_length = skb->len; pbuf->skb = skb; pbuf->cmd = TX_ETHER_PKT; pbuf->frag_count = frag_count; pbuf->port = adapter->portnum; buffrag = &pbuf->frag_array[0]; buffrag->dma = pci_map_single(adapter->pdev, skb->data, first_seg_len, PCI_DMA_TODEVICE); buffrag->length = first_seg_len; <API key>(hwdesc, skb->len); <API key>(hwdesc, frag_count); <API key>(hwdesc, TX_ETHER_PKT); <API key>(hwdesc, adapter->portnum); <API key>(hwdesc, adapter->portnum); hwdesc->buffer1_length = cpu_to_le16(first_seg_len); hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma); for (i = 1, k = 1; i < frag_count; i++, k++) { struct skb_frag_struct *frag; int len, temp_len; unsigned long offset; dma_addr_t temp_dma; /* move to next desc. if there is a need */ if ((i & 0x3) == 0) { k = 0; producer = get_next_index(producer, num_txd); hwdesc = &hw->cmd_desc_head[producer]; memset(hwdesc, 0, sizeof(struct cmd_desc_type0)); pbuf = &adapter->cmd_buf_arr[producer]; pbuf->skb = NULL; } frag = &skb_shinfo(skb)->frags[i - 1]; len = frag->size; offset = frag->page_offset; temp_len = len; temp_dma = pci_map_page(adapter->pdev, frag->page, offset, len, PCI_DMA_TODEVICE); buffrag++; buffrag->dma = temp_dma; buffrag->length = temp_len; switch (k) { case 0: hwdesc->buffer1_length = cpu_to_le16(temp_len); hwdesc->addr_buffer1 = cpu_to_le64(temp_dma); break; case 1: hwdesc->buffer2_length = cpu_to_le16(temp_len); hwdesc->addr_buffer2 = cpu_to_le64(temp_dma); break; case 2: hwdesc->buffer3_length = cpu_to_le16(temp_len); hwdesc->addr_buffer3 = cpu_to_le64(temp_dma); break; case 3: hwdesc->buffer4_length = cpu_to_le16(temp_len); hwdesc->addr_buffer4 = cpu_to_le64(temp_dma); break; } frag++; } producer = get_next_index(producer, num_txd); /* might change opcode to TX_TCP_LSO */ netxen_tso_check(adapter, &hw->cmd_desc_head[saved_producer], skb); /* For LSO, we need to copy the MAC/IP/TCP headers into * the descriptor ring */ if (<API key>(&hw->cmd_desc_head[saved_producer]) == TX_TCP_LSO) { int hdr_len, first_hdr_len, more_hdr; hdr_len = hw->cmd_desc_head[saved_producer].total_hdr_length; if (hdr_len > (sizeof(struct cmd_desc_type0) - 2)) { first_hdr_len = sizeof(struct cmd_desc_type0) - 2; more_hdr = 1; } else { first_hdr_len = hdr_len; more_hdr = 0; } /* copy the MAC/IP/TCP headers to the cmd descriptor list */ hwdesc = &hw->cmd_desc_head[producer]; pbuf = &adapter->cmd_buf_arr[producer]; pbuf->skb = NULL; /* copy the first 64 bytes */ memcpy(((void *)hwdesc) + 2, (void *)(skb->data), first_hdr_len); producer = get_next_index(producer, num_txd); if (more_hdr) { hwdesc = &hw->cmd_desc_head[producer]; pbuf = &adapter->cmd_buf_arr[producer]; pbuf->skb = NULL; /* copy the next 64 bytes - should be enough except * for pathological case */ memcpy((void *)hwdesc, (void *)(skb->data) + first_hdr_len, hdr_len - first_hdr_len); producer = get_next_index(producer, num_txd); } } adapter->cmd_producer = producer; adapter->stats.txbytes += skb->len; <API key>(adapter, adapter->cmd_producer); adapter->stats.xmitcalled++; netdev->trans_start = jiffies; return NETDEV_TX_OK; } static int <API key>(struct netxen_adapter *adapter) { struct net_device *netdev = adapter->netdev; uint32_t temp, temp_state, temp_val; int rv = 0; temp = adapter->pci_read_normalize(adapter, CRB_TEMP_STATE); temp_state = nx_get_temp_state(temp); temp_val = nx_get_temp_val(temp); if (temp_state == NX_TEMP_PANIC) { printk(KERN_ALERT "%s: Device temperature %d degrees C exceeds" " maximum allowed. Hardware has been shut down.\n", <API key>, temp_val); netif_carrier_off(netdev); netif_stop_queue(netdev); rv = 1; } else if (temp_state == NX_TEMP_WARN) { if (adapter->temp == NX_TEMP_NORMAL) { printk(KERN_ALERT "%s: Device temperature %d degrees C " "exceeds operating range." " Immediate action needed.\n", <API key>, temp_val); } } else { if (adapter->temp == NX_TEMP_WARN) { printk(KERN_INFO "%s: Device temperature is now %d degrees C" " in normal range.\n", <API key>, temp_val); } } adapter->temp = temp_state; return rv; } static void <API key>(struct netxen_adapter *adapter) { struct net_device *netdev = adapter->netdev; u32 val, port, linkup; port = adapter->physical_port; if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { val = adapter->pci_read_normalize(adapter, CRB_XG_STATE_P3); val = XG_LINK_STATE_P3(adapter->ahw.pci_func, val); linkup = (val == XG_LINK_UP_P3); } else { val = adapter->pci_read_normalize(adapter, CRB_XG_STATE); if (adapter->ahw.board_type == NETXEN_NIC_GBE) linkup = (val >> port) & 1; else { val = (val >> port*8) & 0xff; linkup = (val == XG_LINK_UP); } } if (adapter->ahw.linkup && !linkup) { printk(KERN_INFO "%s: %s NIC Link is down\n", <API key>, netdev->name); adapter->ahw.linkup = 0; if (netif_running(netdev)) { netif_carrier_off(netdev); netif_stop_queue(netdev); } <API key>(adapter); } else if (!adapter->ahw.linkup && linkup) { printk(KERN_INFO "%s: %s NIC Link is up\n", <API key>, netdev->name); adapter->ahw.linkup = 1; if (netif_running(netdev)) { netif_carrier_on(netdev); netif_wake_queue(netdev); } <API key>(adapter); } } static void netxen_watchdog(unsigned long v) { struct netxen_adapter *adapter = (struct netxen_adapter *)v; SCHEDULE_WORK(&adapter->watchdog_task); } static void <API key>(unsigned long adaptid) { struct netxen_adapter *adapter = (struct netxen_adapter *)adaptid; if ((adapter->portnum == 0) && <API key>(adapter)) return; <API key>(adapter); if (netif_running(adapter->netdev)) mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); } static void netxen_tx_timeout(struct net_device *netdev) { struct netxen_adapter *adapter = (struct netxen_adapter *) netdev_priv(netdev); SCHEDULE_WORK(&adapter->tx_timeout_task); } static void <API key>(unsigned long adapid) { struct net_device *netdev = (struct net_device *)adapid; struct netxen_adapter *adapter = (struct netxen_adapter *) netdev_priv(netdev); printk(KERN_ERR "%s %s: transmit timeout, resetting.\n", <API key>, adapter->netdev->name); netxen_nic_close(adapter->netdev); netxen_nic_open(adapter->netdev); adapter->netdev->trans_start = jiffies; netif_wake_queue(adapter->netdev); } /* * <API key> - Get System Network Statistics * @netdev: network interface device structure */ struct net_device_stats *<API key>(struct net_device *netdev) { struct netxen_adapter *adapter = netdev_priv(netdev); struct net_device_stats *stats = &adapter->net_stats; memset(stats, 0, sizeof(*stats)); /* total packets received */ stats->rx_packets = adapter->stats.no_rcv; /* total packets transmitted */ stats->tx_packets = adapter->stats.xmitedframes + adapter->stats.xmitfinished; /* total bytes received */ stats->rx_bytes = adapter->stats.rxbytes; /* total bytes transmitted */ stats->tx_bytes = adapter->stats.txbytes; /* bad packets received */ stats->rx_errors = adapter->stats.rcvdbadskb; /* packet transmit problems */ stats->tx_errors = adapter->stats.nocmddescriptor; /* no space in linux buffers */ stats->rx_dropped = adapter->stats.rxdropped; /* no space available in linux */ stats->tx_dropped = adapter->stats.txdropped; return stats; } /* * netxen_intr - Interrupt Handler * @irq: interrupt number * data points to adapter stucture (which may be handling more than 1 port */ static irqreturn_t netxen_intr(int irq, void *data, struct pt_regs *regs) { struct netxen_adapter *adapter = data; u32 status; status = adapter->pci_read_immediate(adapter, ISR_INT_VECTOR); if (!(status & adapter->legacy_intr.int_vec_bit)) return IRQ_NONE; if (adapter->ahw.revision_id >= NX_P3_B1) { /* check interrupt state machine, to be sure */ status = adapter->pci_read_immediate(adapter, ISR_INT_STATE_REG); if (!<API key>(status)) return IRQ_NONE; } else if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { unsigned long our_int; our_int = adapter->pci_read_normalize(adapter, CRB_INT_VECTOR); /* not our interrupt */ if (!test_and_clear_bit((7 + adapter->portnum), &our_int)) return IRQ_NONE; /* claim interrupt */ adapter->pci_write_normalize(adapter, CRB_INT_VECTOR, (our_int & 0xffffffff)); } /* clear interrupt */ if (adapter->fw_major < 4) <API key>(adapter); adapter->pci_write_immediate(adapter, adapter->legacy_intr.tgt_status_reg, 0xffffffff); /* read twice to ensure write is flushed */ adapter->pci_read_immediate(adapter, ISR_INT_VECTOR); adapter->pci_read_immediate(adapter, ISR_INT_VECTOR); netif_rx_schedule(adapter->netdev); return IRQ_HANDLED; } static irqreturn_t netxen_msi_intr(int irq, void *data, struct pt_regs *regs) { struct netxen_adapter *adapter = data; /* clear interrupt */ adapter->pci_write_immediate(adapter, msi_tgt_status[adapter->ahw.pci_func], 0xffffffff); netif_rx_schedule(adapter->netdev); return IRQ_HANDLED; } static int netxen_nic_poll(struct net_device *netdev, int *budget) { struct netxen_adapter *adapter = netdev_priv(netdev); int work_to_do = min(*budget, netdev->quota); int tx_complete; int ctx; int this_work_done; int work_done; adapter->stats.polled++; tx_complete = <API key>(adapter); work_done = 0; for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { /* * Fairness issue. This will give undue weight to the * receive context 0. */ /* * To avoid starvation, we give each of our receivers, * a fraction of the quota. Sometimes, it might happen that we * have enough quota to process every packet, but since all the * packets are on one context, it gets only half of the quota, * and ends up not processing it. */ this_work_done = <API key>(adapter, ctx, work_to_do / MAX_RCV_CTX); work_done += this_work_done; } netdev->quota -= work_done; *budget -= work_done; if ((work_done < work_to_do) && tx_complete) { netif_rx_complete(adapter->netdev); <API key>(adapter); return 0; } return 1; } #ifdef <API key> static void <API key>(struct net_device *netdev) { struct netxen_adapter *adapter = netdev_priv(netdev); disable_irq(adapter->irq); netxen_intr(adapter->irq, adapter, NULL); enable_irq(adapter->irq); } #endif static struct pci_driver netxen_driver = { .name = <API key>, .id_table = netxen_pci_tbl, .probe = netxen_nic_probe, .remove = __devexit_p(netxen_nic_remove) }; /* Driver Registration on NetXen card */ static int __init netxen_init_module(void) { if ((netxen_workq = <API key>("netxen")) == 0) return -ENOMEM; return pci_register_driver(&netxen_driver); } module_init(netxen_init_module); static void __exit netxen_exit_module(void) { <API key>(&netxen_driver); destroy_workqueue(netxen_workq); } module_exit(netxen_exit_module);
#include <linux/module.h> #include <linux/delay.h> #include <linux/earlysuspend.h> #include <linux/hrtimer.h> #include <linux/i2c.h> #include <linux/input.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/slab.h> #include <linux/irq.h> #include <linux/platform_device.h> #include <linux/melfas_ts.h> #include <mach/gpio.h> #include <mach/gpio-sec.h> #define TS_READ_START_ADDR 0x10 #define TS_READ_REGS_LEN 5 #define TS_WRITE_REGS_LEN 16 #define P5_MAX_TOUCH 10 #define P5_MAX_I2C_FAIL 50 #define P5_THRESHOLD 0x70 #ifndef I2C_M_WR #define I2C_M_WR 0 #endif #define DEBUG_MODE #define <API key> #define COOD_ROTATE_270 #define TSP_FACTORY_TEST #define <API key> #if !defined(CONFIG_ICS) #define REPORT_MT(touch_number, x, y, amplitude) \ do { \ input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, touch_number);\ input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x); \ input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y); \ input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, amplitude); \ input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, amplitude); \ input_mt_sync(ts->input_dev); \ } while (0) #else #define REPORT_MT(touch_number, x, y, amplitude, key) \ do { \ input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, touch_number);\ input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x); \ input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y); \ input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, amplitude); \ input_report_abs(ts->input_dev, ABS_MT_PRESSURE, amplitude); \ input_report_key(ts->input_dev, BTN_TOUCH, key); \ input_mt_sync(ts->input_dev); \ } while (0) #endif #ifdef <API key> #include "mcs8000_download.h" #endif struct melfas_ts_data { uint16_t addr; struct i2c_client *client; struct input_dev *input_dev; struct <API key> *pdata; struct early_suspend early_suspend; struct tsp_callbacks callbacks; uint32_t flags; bool charging_status; #ifdef <API key> int gpio_scl; int gpio_sda; #endif int touch_id; int (*power)(int on); void (*power_enable)(int en); }; #ifdef <API key> extern struct class *sec_class; #endif #ifdef <API key> static void <API key>(struct early_suspend *h); static void <API key>(struct early_suspend *h); #endif static struct muti_touch_info g_Mtouch_info[P5_MAX_TOUCH]; static bool debug_print = false; #ifdef DEBUG_MODE static bool debug_on = false; static tCommandInfo_t tCommandInfo[] = { { '?', "Help" }, { 'T', "Go to LOGGING mode" }, { 'M', "Go to MTSI_1_2_0 mode" }, { 'R', "Toggle LOG ([R]awdata)" }, { 'F', "Toggle LOG (Re[f]erence)" }, { 'I', "Toggle LOG ([I]ntensity)" }, { 'G', "Toggle LOG ([G]roup Image)" }, { 'D', "Toggle LOG ([D]elay Image)" }, { 'P', "Toggle LOG ([P]osition)" }, { 'B', "Toggle LOG (De[b]ug)" }, { 'V', "Toggle LOG (Debug2)" }, { 'L', "Toggle LOG (Profi[l]ing)" }, { 'O', "[O]ptimize Delay" }, { 'N', "[N]ormalize Intensity" } }; static bool vbLogType[LT_LIMIT] = {0, }; static const char mcLogTypeName[LT_LIMIT][20] = { "LT_DIAGNOSIS_IMG", "LT_RAW_IMG", "LT_REF_IMG", "LT_INTENSITY_IMG", "LT_GROUP_IMG", "LT_DELAY_IMG", "LT_POS", "LT_DEBUG", "LT_DEBUG2", "LT_PROFILING", }; static void toggle_log(struct melfas_ts_data *ts, eLogType_t _eLogType); static void print_command_list(void); static int melfas_i2c_read(struct i2c_client *client, u16 addr, u16 length, u8 *value); static void debug_i2c_read(struct i2c_client *client, u16 addr, u8 *value, u16 length) { melfas_i2c_read(client, addr, length, value); } static int debug_i2c_write(struct i2c_client *client, u8 *value, u16 length) { return i2c_master_send(client, value, length); } static void key_handler(struct melfas_ts_data *ts, char key_val) { u8 write_buf[2]; // u8 read_buf[2]; // int try_cnt = 0; pr_info("[TSP] %s - %c\n", __func__, key_val); switch (key_val) { case '?': case '/': print_command_list(); break; case 'T': case 't': write_buf[0] = ADDR_ENTER_LOGGING; write_buf[1] = 1; debug_i2c_write(ts->client, write_buf, 2); debug_on = true; #if 0 for ( try_cnt = 1; try_cnt - 1 < 10; try_cnt++) { msleep(100); /* verify the register was written */ i2c_master_recv(ts->client, read_buf, 1); if (read_buf[0] == 72) { pr_info("[TSP] success - %c \n", key_val); break; } else { pr_info("[TSP] try again : val : %d , cnt : %d\n", read_buf[0], try_cnt); debug_i2c_write(ts->client, write_buf, 2); } } #endif break; case 'M': case 'm': write_buf[0] = <API key>; write_buf[1] = PTC_STSI_1_0_0; debug_i2c_write(ts->client, write_buf, 2); debug_on = false; break; case 'R': case 'r': toggle_log(ts, LT_RAW_IMG); break; case 'F': case 'f': toggle_log(ts, LT_REF_IMG); break; case 'I': case 'i': toggle_log(ts, LT_INTENSITY_IMG); break; case 'G': case 'g': toggle_log(ts, LT_GROUP_IMG); break; case 'D': case 'd': toggle_log(ts, LT_DELAY_IMG); break; case 'P': case 'p': toggle_log(ts, LT_POS); break; case 'B': case 'b': toggle_log(ts, LT_DEBUG); break; case 'V': case 'v': toggle_log(ts, LT_DEBUG2); break; case 'L': case 'l': toggle_log(ts, LT_PROFILING); break; case 'O': case 'o': pr_info("Enter 'Optimize Delay' mode!!!\n"); write_buf[0] = ADDR_CHANGE_OPMODE; write_buf[1] = OM_OPTIMIZE_DELAY; if (!debug_i2c_write(ts->client, write_buf, 2)) goto ERROR_HANDLE; break; case 'N': case 'n': pr_info("Enter 'Normalize Intensity' mode!!!\n"); write_buf[0] = ADDR_CHANGE_OPMODE; write_buf[1] = <API key>; if (!debug_i2c_write(ts->client, write_buf, 2)) goto ERROR_HANDLE; break; default: ; } return; ERROR_HANDLE: pr_info("ERROR!!! \n"); } static void print_command_list(void) { int i; pr_info(" for (i = 0; i < sizeof(tCommandInfo) / sizeof(tCommandInfo_t); i++) { pr_info("[%c]: %s\n", tCommandInfo[i].cCommand, tCommandInfo[i].sDescription); } pr_info(" } static void toggle_log(struct melfas_ts_data *ts, eLogType_t _eLogType) { u8 write_buf[2]; vbLogType[_eLogType] ^= 1; if (vbLogType[_eLogType]) { write_buf[0] = ADDR_LOGTYPE_ON; pr_info("%s ON\n", mcLogTypeName[_eLogType]); } else { write_buf[0] = ADDR_LOGTYPE_OFF; pr_info("%s OFF\n", mcLogTypeName[_eLogType]); } write_buf[1] = _eLogType; debug_i2c_write(ts->client, write_buf, 2); } static void logging_function(struct melfas_ts_data *ts) { u8 read_buf[100]; u8 read_mode, read_num; int FingerX, FingerY, FingerID; int i; static int past_read_mode = HEADER_NONE; static char *ps; static char s[500]; debug_i2c_read(ts->client, LOG_READ_ADDR, read_buf, 2); read_mode = read_buf[0]; read_num = read_buf[1]; //pr_info("[TSP] read_mode : %d, read_num : %d\n", read_mode, read_num); switch (read_mode) { case HEADER_U08://Unsigned character { unsigned char* p = (unsigned char*) &read_buf[2]; i2c_master_recv(ts->client, read_buf, read_num + 2); ps = s; s[0] = '\0'; for (i = 0; i < read_num - 1; i++) { sprintf(ps, "%4d,", p[i]); ps = s + strlen(s); } sprintf(ps, "%4d\n", p[i]); ps = s + strlen(s); printk(KERN_DEBUG "%s", s); break; } case HEADER_S08://Unsigned character { signed char* p = (signed char*) &read_buf[2]; i2c_master_recv(ts->client, read_buf, read_num + 2); ps = s; s[0] = '\0'; for (i = 0; i < read_num - 1; i++) { sprintf(ps, "%4d,", p[i]); ps = s + strlen(s); } sprintf(ps, "%4d\n", p[i]); ps = s + strlen(s); printk(KERN_DEBUG "%s", s); break; } case HEADER_U16://Unsigned short { unsigned short* p = (unsigned short*) &read_buf[2]; i2c_master_recv(ts->client, read_buf, read_num * 2 + 2); if (past_read_mode != HEADER_U16_NOCR) { ps = s; s[0] = '\0'; } for (i = 0; i < read_num - 1; i++) { sprintf(ps, "%5d,", p[i]); ps = s + strlen(s); } sprintf(ps, "%5d\n", p[i]); ps = s + strlen(s); printk(KERN_DEBUG "%s", s); break; } case HEADER_U16_NOCR: { unsigned short* p = (unsigned short*) &read_buf[2]; i2c_master_recv(ts->client, read_buf, read_num * 2 + 2); if (past_read_mode != HEADER_U16_NOCR) { ps = s; s[0] = '\0'; } for (i = 0; i < read_num; i++) { sprintf(ps, "%5d,", p[i]); ps = s + strlen(s); } break; } case HEADER_S16://Unsigned short { signed short* p = (signed short*) &read_buf[2]; i2c_master_recv(ts->client, read_buf, read_num * 2 + 2); if (past_read_mode != HEADER_S16_NOCR) { ps = s; s[0] = '\0'; } for (i = 0; i < read_num - 1; i++) { sprintf(ps, "%5d,", p[i]); ps = s + strlen(s); } sprintf(ps, "%5d\n", p[i]); ps = s + strlen(s); printk(KERN_DEBUG "%s", s); break; } case HEADER_S16_NOCR: { signed short* p = (signed short*) &read_buf[2]; i2c_master_recv(ts->client, read_buf, read_num * 2 + 2); if (past_read_mode != HEADER_S16_NOCR) { ps = s; s[0] = '\0'; } for (i = 0; i < read_num; i++) { sprintf(ps, "%5d,", p[i]); ps = s + strlen(s); } break; } case HEADER_U32://Unsigned short { unsigned long* p = (unsigned long*) &read_buf[2]; i2c_master_recv(ts->client, read_buf, read_num * 4 + 4); if (past_read_mode != HEADER_U32_NOCR) { ps = s; s[0] = '\0'; } for (i = 0; i < read_num - 1; i++) { sprintf(ps, "%10ld,", p[i]); ps = s + strlen(s); } sprintf(ps, "%10ld\n", p[i]); ps = s + strlen(s); printk(KERN_DEBUG "%s", s); break; } case HEADER_U32_NOCR://Unsigned short { unsigned long* p = (unsigned long*) &read_buf[2]; i2c_master_recv(ts->client, read_buf, read_num * 4 + 4); if (past_read_mode != HEADER_U32_NOCR) { ps = s; s[0] = '\0'; } for (i = 0; i < read_num; i++) { sprintf(ps, "%10ld,", p[i]); ps = s + strlen(s); } break; } case HEADER_S32://Unsigned short { signed long* p = (signed long*) &read_buf[2]; i2c_master_recv(ts->client, read_buf, read_num * 4 + 4); if (past_read_mode != HEADER_S32_NOCR) { ps = s; s[0] = '\0'; } for (i = 0; i < read_num - 1; i++) { sprintf(ps, "%10ld,", p[i]); ps = s + strlen(s); } sprintf(ps, "%10ld\n", p[i]); ps = s + strlen(s); printk(KERN_DEBUG "%s", s); break; } case HEADER_S32_NOCR://Unsigned short { signed long* p = (signed long*) &read_buf[2]; i2c_master_recv(ts->client, read_buf, read_num * 4 + 4); if (past_read_mode != HEADER_S32_NOCR) { ps = s; s[0] = '\0'; } for (i = 0; i < read_num; i++) { sprintf(ps, "%10ld,", p[i]); ps = s + strlen(s); } break; } case HEADER_TEXT://Text { i2c_master_recv(ts->client, read_buf, read_num + 2); ps = s; s[0] = '\0'; for (i = 2; i < read_num + 2; i++) { sprintf(ps, "%c", read_buf[i]); ps = s + strlen(s); } printk(KERN_DEBUG "%s\n", s); break; } case HEADER_FINGER: { i2c_master_recv(ts->client, read_buf, read_num * 4 + 2); ps = s; s[0] = '\0'; for (i = 2; i < read_num * 4 + 2; i = i + 4) { //log_printf( device_idx, " %5ld", read_buf[i] , 0,0); FingerX = (read_buf[i + 1] & 0x07) << 8 | read_buf[i]; FingerY = (read_buf[i + 3] & 0x07) << 8 | read_buf[i + 2]; FingerID = (read_buf[i + 1] & 0xF8) >> 3; sprintf(ps, "%2d (%4d,%4d) | ", FingerID, FingerX, FingerY); ps = s + strlen(s); } printk(KERN_DEBUG "%s\n", s); break; } case HEADER_S12://Unsigned short { signed short* p = (signed short*) &read_buf[2]; i2c_master_recv(ts->client, read_buf, read_num * 2 + 2); if (past_read_mode != HEADER_S12_NOCR) { ps = s; s[0] = '\0'; } for (i = 0; i < read_num; i++) { if (p[i] > 4096 / 2) p[i] -= 4096; } for (i = 0; i < read_num - 1; i++) { sprintf(ps, "%5d,", p[i]); ps = s + strlen(s); } sprintf(ps, "%5d\n", p[i]); ps = s + strlen(s); printk(KERN_DEBUG "%s", s); break; } case HEADER_S12_NOCR: { signed short* p = (signed short*) &read_buf[2]; i2c_master_recv(ts->client, read_buf, read_num * 2 + 2); if (past_read_mode != HEADER_S12_NOCR) { ps = s; s[0] = '\0'; } for (i = 0; i < read_num; i++) { if (p[i] > 4096 / 2) p[i] -= 4096; } for (i = 0; i < read_num; i++) { sprintf(ps, "%5d,", p[i]); ps = s + strlen(s); } break; } case HEADER_PRIVATE://Unsigned character { unsigned char* p = (unsigned char*) &read_buf[2]; i2c_master_recv(ts->client, read_buf, read_num + 2 + read_num % 2); ps = s; s[0] = '\0'; sprintf(ps, " ps = s + strlen(s); for (i = 0; i < read_num - 1; i++) { sprintf(ps, "%5d,", p[i]); ps = s + strlen(s); } sprintf(ps, "%5d\n", p[i]); ps = s + strlen(s); printk(KERN_DEBUG "%s", s); break; } default: break; } past_read_mode = read_mode; } #endif /* DEBUG_MODE */ static int melfas_i2c_read(struct i2c_client *client, u16 addr, u16 length, u8 *value) { struct i2c_adapter *adapter = client->adapter; struct i2c_msg msg[2]; msg[0].addr = client->addr; msg[0].flags = 0x00; msg[0].len = 2; msg[0].buf = (u8 *) &addr; msg[1].addr = client->addr; msg[1].flags = I2C_M_RD; msg[1].len = length; msg[1].buf = (u8 *) value; if (i2c_transfer(adapter, msg, 2) == 2) return 0; else return -EIO; } static int melfas_i2c_write(struct i2c_client *client, char *buf, int length) { int i; char data[TS_WRITE_REGS_LEN]; if (length > TS_WRITE_REGS_LEN) { pr_err("[TSP] size error - %s\n", __func__); return -EINVAL; } for (i = 0; i < length; i++) data[i] = *buf++; i = i2c_master_send(client, (char *)data, length); if (i == length) return length; else return -EIO; } static void release_all_fingers(struct melfas_ts_data *ts) { int i; for(i=0; i<P5_MAX_TOUCH; i++) { if(-1 == g_Mtouch_info[i].strength) { g_Mtouch_info[i].posX = 0; g_Mtouch_info[i].posY = 0; continue; } g_Mtouch_info[i].strength = 0; REPORT_MT(i, g_Mtouch_info[i].posX, g_Mtouch_info[i].posY, #if !defined(CONFIG_ICS) g_Mtouch_info[i].strength); #else g_Mtouch_info[i].strength, g_Mtouch_info[i].strength ? 1 : 0); #endif g_Mtouch_info[i].posX = 0; g_Mtouch_info[i].posY = 0; if(0 == g_Mtouch_info[i].strength) g_Mtouch_info[i].strength = -1; } } static int read_input_info(struct melfas_ts_data *ts, u8 *val) { return melfas_i2c_read(ts->client, TS_READ_START_ADDR, TS_READ_REGS_LEN, val); } static int <API key>(struct melfas_ts_data *ts, u8 *val) { return melfas_i2c_read(ts->client, <API key>, 1, val); } static int <API key>(struct melfas_ts_data *ts, u8 *val) { return melfas_i2c_read(ts->client, <API key>, 1, val); } static int check_firmware_core(struct melfas_ts_data *ts, u8 *val) { return melfas_i2c_read(ts->client, <API key>, 1, val); } static int <API key>(struct melfas_ts_data *ts, u8 *val) { return melfas_i2c_read(ts->client, <API key>, 1, val); } static int <API key>(struct melfas_ts_data *ts, u8 *val) { return melfas_i2c_read(ts->client, <API key>, 1, val); } static int check_slave_boot(struct melfas_ts_data *ts, u8 *val) { return melfas_i2c_read(ts->client, 0xb1, 1, val); } static int firmware_update(struct melfas_ts_data *ts) { int i=0; u8 val = 0; u8 val_slv = 0; u8 fw_ver = 0; int ret = 0; int ret_slv = 0; bool empty_chip = false; #if !MELFAS_ISP_DOWNLOAD ret = <API key>(ts, &val); ret_slv = <API key>(ts, &val_slv); msleep(100); if (ret || ret_slv) { empty_chip = true; pr_err("[TSP] ISC mode : Failed to check firmware version(ISP) : %d , %d : %0x0 , %0x0 \n",ret, ret_slv,val,val_slv); } #endif #ifdef <API key> disable_irq(ts->client->irq); /* enable gpio */ #ifdef CONFIG_ARCH_TEGRA tegra_gpio_enable(ts->gpio_sda); tegra_gpio_enable(ts->gpio_scl); #endif gpio_request(ts->gpio_sda, "TSP_SDA"); gpio_request(ts->gpio_scl, "TSP_SCL"); #ifndef FW_FROM_FILE #if MELFAS_ISP_DOWNLOAD ret = <API key>(ts->touch_id); if (ret) pr_err("[TSP] SET Download ISP Fail - error code [%d]\n", ret); #else /* (current version < binary verion) */ if (empty_chip || (ts->touch_id == 1 && val < ILJIN_BASE_FW_VER ) || (ts->touch_id == 0 && (val < MELFAS_BASE_FW_VER || val > 0x50))){ pr_info("[TSP] ISC mode enter and Under Base F/W Version : 0x%X\n",val); <API key>(ts->touch_id); //ISP mode download ( CORE + PRIVATE ) } ret = <API key>(ts->touch_id); if (ret) { pr_err("[TSP] SET Download ISC Fail - error code [%d]\n", ret); for(i=0; i<3 ; i++) { if(ret) ret = <API key>(ts->touch_id); //ISP mode download ( CORE + PRIVATE ) if(!ret && <API key>) ret = <API key>(ts->touch_id); if (ret) pr_err("[TSP] SET Download ISC & ISP Fail - error code [%d]\n", ret); else break; } } #endif #else ret = <API key>(ts->touch_id); if (ret) pr_err("[TSP] SET Download From File is Fail - error code [%d]\n", ret); #endif gpio_free(ts->gpio_sda); gpio_free(ts->gpio_scl); /* disable gpio */ #ifdef CONFIG_ARCH_TEGRA tegra_gpio_disable(ts->gpio_sda); tegra_gpio_disable(ts->gpio_scl); #endif #endif /* <API key> */ msleep(100); /* reset chip */ ts->power_enable(0); msleep(200); ts->power_enable(1); msleep(100); enable_irq(ts->client->irq); return 0; } static void <API key>(struct tsp_callbacks *cb, int mode) { struct melfas_ts_data *ts = container_of(cb, struct melfas_ts_data, callbacks); char buf[2]; buf[0] = 0x60; buf[1] = !!mode; ts->charging_status = !!mode; pr_info("[TSP] TA/USB is %sconnected\n", !!mode ? "" : "dis"); melfas_i2c_write(ts->client, (char *)buf, 2); } static void <API key>(struct melfas_ts_data *ts) { int ret = 0, i; u8 buf[TS_READ_REGS_LEN]; int touchType=0, touchState =0, touchID=0, posX=0, posY=0, strength=0, keyID = 0, reportID = 0; #ifdef DEBUG_MODE if (debug_on) { logging_function(ts); return ; } #endif ret = read_input_info(ts, buf); if (ret < 0) { pr_err("[TSP] Failed to read the touch info\n"); for(i=0; i<P5_MAX_I2C_FAIL; i++ ) read_input_info(ts, buf); if(i == P5_MAX_I2C_FAIL){ // ESD Detection - I2c Fail pr_err("[TSP] Melfas_ESD I2C FAIL \n"); release_all_fingers(ts); ts->power_enable(0); msleep(700); ts->power_enable(1); } return ; } else{ touchType = (buf[0]>>6)&0x03; touchState = (buf[0]>>4)&0x01; reportID = (buf[0]&0x0f); #if defined(COOD_ROTATE_90) posY = ((buf[1]& 0x0F) << 8) | buf[2]; posX = ((buf[1]& 0xF0) << 4) | buf[3]; posX = ts->pdata->max_y - posX; #elif defined(COOD_ROTATE_270) posY = ((buf[1]& 0x0F) << 8) | buf[2]; posX = ((buf[1]& 0xF0) << 4) | buf[3]; posY = ts->pdata->max_x - posY; #else posX = ((buf[1]& 0x0F) << 8) | buf[2]; posY = ((buf[1]& 0xF0) << 4) | buf[3]; #endif keyID = strength = buf[4]; if(reportID == 0x0f ) { // ESD Detection pr_info("[TSP] MELFAS_ESD Detection"); release_all_fingers(ts); ts->power_enable(0); msleep(700); ts->power_enable(1); return ; } /* else if(reportID == 0x0E)// Plam { pr_info("[TSP] MELFAS_Plam"); release_all_fingers(ts); return ; } */ touchID = reportID-1; if (debug_print) pr_info("[TSP] reportID: %d\n", reportID); if(reportID > P5_MAX_TOUCH || reportID < 1) { pr_err("[TSP] Invalid touch id.\n"); release_all_fingers(ts); return ; } if(touchType == TOUCH_SCREEN) { g_Mtouch_info[touchID].posX= posX; g_Mtouch_info[touchID].posY= posY; if(touchState) { #ifdef <API key> if (0 >= g_Mtouch_info[touchID].strength) pr_info("[TSP] Press - ID : %d [%d,%d] WIDTH : %d", touchID, g_Mtouch_info[touchID].posX, g_Mtouch_info[touchID].posY, strength); #endif g_Mtouch_info[touchID].strength= strength/2; } else { #ifdef <API key> if (g_Mtouch_info[touchID].strength) pr_info("[TSP] Release - ID : %d [%d,%d]", touchID, g_Mtouch_info[touchID].posX, g_Mtouch_info[touchID].posY); #endif g_Mtouch_info[touchID].strength = 0; } for(i=0; i<P5_MAX_TOUCH; i++) { if(g_Mtouch_info[i].strength== -1) continue; REPORT_MT(i, g_Mtouch_info[i].posX, g_Mtouch_info[i].posY, #if !defined(CONFIG_ICS) g_Mtouch_info[i].strength); #else g_Mtouch_info[i].strength, g_Mtouch_info[i].strength ? 1 : 0); #endif if (debug_print) pr_info("[TSP] Touch ID: %d, State : %d, x: %d, y: %d, z: %d\n", i, touchState, g_Mtouch_info[i].posX, g_Mtouch_info[i].posY, g_Mtouch_info[i].strength); if(g_Mtouch_info[i].strength == 0) g_Mtouch_info[i].strength = -1; } } input_sync(ts->input_dev); } } static irqreturn_t <API key>(int irq, void *handle) { struct melfas_ts_data *ts = (struct melfas_ts_data *)handle; if (debug_print) pr_info("[TSP] %s\n", __func__); <API key>(ts); return IRQ_HANDLED; } static ssize_t show_firmware_dev(struct device *dev, struct device_attribute *attr, char *buf) { struct melfas_ts_data *ts = dev_get_drvdata(dev); u8 ver = 0; <API key>(ts, &ver); if (!ts->touch_id) return snprintf(buf, PAGE_SIZE, "MEL_%Xx%d\n", ver, 0x0); else return snprintf(buf, PAGE_SIZE, "ILJ_%Xx%d\n", ver, 0x0); } static ssize_t store_firmware(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct melfas_ts_data *ts = dev_get_drvdata(dev); int i ; if (sscanf(buf, "%d", &i) != 1) return -EINVAL; firmware_update(ts); return count; } static ssize_t show_firmware_bin(struct device *dev, struct device_attribute *attr, char *buf) { struct melfas_ts_data *ts = dev_get_drvdata(dev); if (!ts->touch_id) return snprintf(buf, PAGE_SIZE, "MEL_%Xx%d\n", MELFAS_FW_VER, 0x0); else return snprintf(buf, PAGE_SIZE, "ILJ_%Xx%d\n", ILJIN_FW_VER, 0x0); } static ssize_t store_debug_mode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct melfas_ts_data *ts = dev_get_drvdata(dev); char ch; if (sscanf(buf, "%c", &ch) != 1) return -EINVAL; key_handler(ts, ch); return count; } static ssize_t show_debug_mode(struct device *dev, struct device_attribute *attr, char *buf) { return sprintf(buf, debug_on ? "ON\n" : "OFF\n"); } static ssize_t store_debug_log(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int i; if (sscanf(buf, "%d", &i) != 1) return -EINVAL; if (i) debug_print = true; else debug_print = false; return count; } static ssize_t show_threshold(struct device *dev, struct device_attribute *attr, char *buf) { struct melfas_ts_data *ts = dev_get_drvdata(dev); u8 threshold; melfas_i2c_read(ts->client, P5_THRESHOLD, 1, &threshold); return sprintf(buf, "%d\n", threshold); } static DEVICE_ATTR(fw_dev, S_IWUSR|S_IRUGO, show_firmware_dev, store_firmware); static DEVICE_ATTR(fw_bin, S_IRUGO, show_firmware_bin, NULL); static DEVICE_ATTR(debug_mode, S_IWUSR|S_IRUGO, show_debug_mode, store_debug_mode); static DEVICE_ATTR(debug_log, S_IWUSR|S_IRUGO, NULL, store_debug_log); #ifdef <API key> static DEVICE_ATTR(set_threshould, S_IRUGO, show_threshold, NULL); #else static DEVICE_ATTR(threshold, S_IRUGO, show_threshold, NULL); #endif #if defined(TSP_FACTORY_TEST) static u16 inspection_data[1134] = { 0, }; #ifdef DEBUG_LOW_DATA static u16 low_data[1134] = { 0, }; #endif static u16 lntensity_data[1134] = { 0, }; static void check_debug_data(struct melfas_ts_data *ts) { u8 write_buffer[6]; u8 read_buffer[2]; int sensing_line, exciting_line; int gpio = irq_to_gpio(ts->client->irq); disable_irq(ts->client->irq); /* enter the debug mode */ write_buffer[0] = 0xA0; write_buffer[1] = 0x1A; write_buffer[2] = 0x0; write_buffer[3] = 0x0; write_buffer[4] = 0x0; write_buffer[5] = 0x01; melfas_i2c_write(ts->client, (char *)write_buffer, 6); /* wating for the interrupt*/ while (gpio_get_value(gpio)) { printk("."); udelay(100); } if (debug_print) pr_info("[TSP] read dummy\n"); /* read the dummy data */ melfas_i2c_read(ts->client, 0xA8, 2, read_buffer); if (debug_print) pr_info("[TSP] read inspenction data\n"); write_buffer[5] = 0x02; for (sensing_line = 0; sensing_line < 27; sensing_line++) { for (exciting_line =0; exciting_line < 42; exciting_line++) { write_buffer[2] = exciting_line; write_buffer[3] = sensing_line; melfas_i2c_write(ts->client, (char *)write_buffer, 6); melfas_i2c_read(ts->client, 0xA8, 2, read_buffer); inspection_data[exciting_line + sensing_line * 42] = (read_buffer[1] & 0xf) << 8 | read_buffer[0]; } } #ifdef DEBUG_LOW_DATA if (debug_print) pr_info("[TSP] read low data\n"); write_buffer[5] = 0x03; for (sensing_line = 0; sensing_line < 27; sensing_line++) { for (exciting_line =0; exciting_line < 42; exciting_line++) { write_buffer[2] = exciting_line; write_buffer[3] = sensing_line; melfas_i2c_write(ts->client, (char *)write_buffer, 6); melfas_i2c_read(ts->client, 0xA8, 2, read_buffer); low_data[exciting_line + sensing_line * 42] = (read_buffer[1] & 0xf) << 8 | read_buffer[0]; } } #endif release_all_fingers(ts); ts->power_enable(0); msleep(200); ts->power_enable(1); enable_irq(ts->client->irq); } static ssize_t all_refer_show(struct device *dev, struct device_attribute *attr, char *buf) { int status = 0; int i; struct melfas_ts_data *ts = dev_get_drvdata(dev); check_debug_data(ts); if (debug_print) pr_info("[TSP] inspection data\n"); for (i = 0; i < 1134; i++) { /* out of range */ if (inspection_data[i] < 30) { status = 1; break; } if (debug_print) { if (0 == i % 27) printk("\n"); printk("%5u ", inspection_data[i]); } } #if DEBUG_LOW_DATA pr_info("[TSP] low data\n"); for (i = 0; i < 1134; i++) { if (0 == i % 27) printk("\n"); printk("%5u ", low_data[i]); } #endif return sprintf(buf, "%u\n", status); } static void check_intesity_data(struct melfas_ts_data *ts) { u8 write_buffer[6]; u8 read_buffer[2]; int sensing_line, exciting_line; int gpio = irq_to_gpio(ts->client->irq); if (0 == inspection_data[0]) { /* enter the debug mode */ write_buffer[0] = 0xA0; write_buffer[1] = 0x1A; write_buffer[2] = 0x0; write_buffer[3] = 0x0; write_buffer[4] = 0x0; write_buffer[5] = 0x01; melfas_i2c_write(ts->client, (char *)write_buffer, 6); /* wating for the interrupt*/ while (gpio_get_value(gpio)) { printk("."); udelay(100); } /* read the dummy data */ melfas_i2c_read(ts->client, 0xA8, 2, read_buffer); write_buffer[5] = 0x02; for (sensing_line = 0; sensing_line < 27; sensing_line++) { for (exciting_line =0; exciting_line < 42; exciting_line++) { write_buffer[2] = exciting_line; write_buffer[3] = sensing_line; melfas_i2c_write(ts->client, (char *)write_buffer, 6); melfas_i2c_read(ts->client, 0xA8, 2, read_buffer); inspection_data[exciting_line + sensing_line * 42] = (read_buffer[1] & 0xf) << 8 | read_buffer[0]; } } release_all_fingers(ts); ts->power_enable(0); msleep(700); ts->power_enable(1); } write_buffer[0] = 0xA0; write_buffer[1] = 0x1A; write_buffer[4] = 0x0; write_buffer[5] = 0x04; for (sensing_line = 0; sensing_line < 27; sensing_line++) { for (exciting_line =0; exciting_line < 42; exciting_line++) { write_buffer[2] = exciting_line; write_buffer[3] = sensing_line; melfas_i2c_write(ts->client, (char *)write_buffer, 6); melfas_i2c_read(ts->client, 0xA8, 2, read_buffer); lntensity_data[exciting_line + sensing_line * 42] = (read_buffer[1] & 0xf) << 8 | read_buffer[0]; } } #if 1 pr_info("[TSP] lntensity data"); int i; for (i = 0; i < 1134; i++) { if (0 == i % 27) printk("\n"); printk("%5u ", lntensity_data[i]); } #endif } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { u16 refrence = 0; struct melfas_ts_data *ts = dev_get_drvdata(dev); check_intesity_data(ts); refrence = inspection_data[927]; return sprintf(buf, "%u\n", refrence); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { u16 refrence = 0; refrence = inspection_data[172]; return sprintf(buf, "%u\n", refrence); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { u16 refrence = 0; refrence = inspection_data[608]; return sprintf(buf, "%u\n", refrence); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { u16 refrence = 0; refrence = inspection_data[1003]; return sprintf(buf, "%u\n", refrence); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { u16 refrence = 0; refrence = inspection_data[205]; return sprintf(buf, "%u\n", refrence); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { u16 intensity = 0; intensity = lntensity_data[927]; return sprintf(buf, "%u\n", intensity); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { u16 intensity = 0; intensity = lntensity_data[172]; return sprintf(buf, "%u\n", intensity); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { u16 intensity = 0; intensity = lntensity_data[608]; return sprintf(buf, "%u\n", intensity); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { u16 intensity = 0; intensity = lntensity_data[1003]; return sprintf(buf, "%u\n", intensity); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { u16 intensity = 0; intensity = lntensity_data[205]; return sprintf(buf, "%u\n", intensity); } /* noise test */ static DEVICE_ATTR(set_all_refer, S_IRUGO, all_refer_show, NULL); static DEVICE_ATTR(set_refer0, S_IRUGO, <API key>, NULL); static DEVICE_ATTR(set_delta0, S_IRUGO, <API key>, NULL); static DEVICE_ATTR(set_refer1, S_IRUGO, <API key>, NULL); static DEVICE_ATTR(set_delta1, S_IRUGO, <API key>, NULL); static DEVICE_ATTR(set_refer2, S_IRUGO, <API key>, NULL); static DEVICE_ATTR(set_delta2, S_IRUGO, <API key>, NULL); static DEVICE_ATTR(set_refer3, S_IRUGO, <API key>, NULL); static DEVICE_ATTR(set_delta3, S_IRUGO, <API key>, NULL); static DEVICE_ATTR(set_refer4, S_IRUGO, <API key>, NULL); static DEVICE_ATTR(set_delta4, S_IRUGO, <API key>, NULL); #endif static struct attribute *<API key>[] = { &dev_attr_fw_dev.attr, &dev_attr_fw_bin.attr, &dev_attr_debug_mode.attr, &dev_attr_debug_log.attr, #ifndef <API key> &dev_attr_threshold.attr, &<API key>.attr, &dev_attr_set_refer0.attr, &dev_attr_set_delta0.attr, &dev_attr_set_refer1.attr, &dev_attr_set_delta1.attr, &dev_attr_set_refer2.attr, &dev_attr_set_delta2.attr, &dev_attr_set_refer3.attr, &dev_attr_set_delta3.attr, &dev_attr_set_refer4.attr, &dev_attr_set_delta4.attr, #endif NULL, }; static struct attribute_group <API key> = { .attrs = <API key>, }; #ifdef <API key> static struct attribute *<API key>[] = { &<API key>.attr, &dev_attr_set_refer0.attr, &dev_attr_set_delta0.attr, &dev_attr_set_refer1.attr, &dev_attr_set_delta1.attr, &dev_attr_set_refer2.attr, &dev_attr_set_delta2.attr, &dev_attr_set_refer3.attr, &dev_attr_set_delta3.attr, &dev_attr_set_refer4.attr, &dev_attr_set_delta4.attr, &<API key>.attr, NULL, }; static struct attribute_group <API key> = { .attrs = <API key>, }; #endif static int melfas_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct melfas_ts_data *ts; struct device *tsp_dev; #ifdef <API key> struct device *test_dev; #endif struct input_dev *input; bool empty_chip = false; u8 val_mst = 0; u8 val_slv = 0; u8 fw_ver = 0; int ret = 0; int ret_slv = 0; u8 val_core = 0; u8 val_private = 0; u8 val_public = 0; int ret_core = 0; int ret_private = 0; int ret_public = 0; int i = 0; int irq = 0; int val_firm = -1; if (!<API key>(client->adapter, I2C_FUNC_I2C)) { pr_err("[TSP] melfas_ts_probe: need I2C_FUNC_I2C\n"); ret = -ENODEV; goto <API key>; } ts = kmalloc(sizeof(struct melfas_ts_data), GFP_KERNEL); if (ts == NULL) { pr_err("[TSP] %s: failed to create a state of melfas-ts\n", __func__); ret = -ENOMEM; goto err_alloc_failed; } ts->pdata = client->dev.platform_data; if (ts->pdata->power_enable) ts->power_enable = ts->pdata->power_enable; ts->callbacks.inform_charger = <API key>; if (ts->pdata->register_cb) ts->pdata->register_cb(&ts->callbacks); #ifdef <API key> ts->gpio_scl = ts->pdata->gpio_scl; ts->gpio_sda = ts->pdata->gpio_sda; #endif ts->touch_id = ts->pdata->gpio_touch_id; ts->client = client; i2c_set_clientdata(client, ts); #ifndef FW_FROM_FILE ret = <API key>(ts, &val_mst); ret_slv = <API key>(ts, &val_slv); #if MELFAS_ISP_DOWNLOAD // ISP mode start if (ret || ret_slv) { empty_chip = true; pr_err("[TSP] Failed to check firmware version : %d , %d",ret, ret_slv); } fw_ver = ts->touch_id ? ILJIN_FW_VER : MELFAS_FW_VER; if(val_mst > 0x0 && val_mst < 0x50 ) val_firm = 0; else if (val_mst > 0x50 ) val_firm = 1; else val_firm = -1; /* (current version < binary verion) */ if (val_mst != val_slv || val_firm != ts->touch_id || val_mst < fw_ver || empty_chip ) firmware_update(ts); ret = <API key>(ts, &val_mst); ret_slv = <API key>(ts, &val_slv); pr_info("[TSP] %s panel - current firmware version : 0x%x , 0x%x\n", ts->touch_id ? "Iljin" : "Melfas", val_mst, val_slv); ret = check_slave_boot(ts, &val_mst); if (ret) pr_err("[TSP] Failed to check slave boot : %d", ret); #else // ISC mode start pr_info("[TSP] ISC mode Before update %s panel - current firmware version : 0x%x , 0x%x\n", ts->touch_id ? "Iljin" : "Melfas", val_mst, val_slv); firmware_update(ts); ret_core = check_firmware_core(ts, &val_core); ret_private = <API key>(ts, &val_private); ret_public = <API key>(ts, &val_public); if (ret_core || ret_private || ret_public) { pr_err("[TSP] Failed to check firmware version : %d , %d, %d\n", ret_core, ret_private , ret_public); } pr_info("[TSP] %s panel - current firmware version(ISC mode) : 0x%x , 0x%x, 0x%x\n", ts->touch_id ? "Iljin" : "Melfas", val_core, val_private , val_public); #endif #endif input = <API key>(); if (!input) { pr_err("[TSP] %s: failed to allocate input device\n", __func__); ret = -ENOMEM; goto err_alloc_failed; } ts->input_dev = input; #ifdef <API key> input->name = "sec_touchscreen"; #else input->name = client->name; #endif set_bit(EV_ABS, input->evbit); set_bit(EV_SYN, input->evbit); set_bit(EV_KEY, input->evbit); set_bit(BTN_TOUCH, input->keybit); #if defined(COOD_ROTATE_90) || defined(COOD_ROTATE_270) <API key>(input, ABS_MT_POSITION_X, 0, ts->pdata->max_y, 0, 0); <API key>(input, ABS_MT_POSITION_Y, 0, ts->pdata->max_x, 0, 0); #else <API key>(input, ABS_MT_POSITION_X, 0, ts->pdata->max_x, 0, 0); <API key>(input, ABS_MT_POSITION_Y, 0, ts->pdata->max_y, 0, 0); #endif <API key>(input, ABS_MT_TOUCH_MAJOR, 0, ts->pdata->max_pressure, 0, 0); #if defined(CONFIG_ICS) <API key>(input, ABS_MT_WIDTH_MAJOR, 0, ts->pdata->max_width, 0, 0); #endif <API key>(input, ABS_MT_TRACKING_ID, 0, P5_MAX_TOUCH-1, 0, 0); #if !defined(CONFIG_ICS) <API key>(input, ABS_MT_WIDTH_MAJOR, 0, ts->pdata->max_width, 0, 0); #else <API key>(input, ABS_MT_PRESSURE, 0, ts->pdata->max_pressure, 0, 0); #endif ret = <API key>(input); if (ret) { pr_err("[TSP] %s: failed to register input device\n", __func__); ret = -ENOMEM; goto <API key>; } if (client->irq) { irq = client->irq; ret = <API key>(irq, NULL, <API key>, IRQF_ONESHOT | IRQF_TRIGGER_LOW, ts->client->name, ts); if (ret) { pr_err("[TSP] %s: Can't allocate irq %d, ret %d\n", __func__, irq, ret); ret = -EBUSY; goto err_request_irq; } } for (i = 0; i < P5_MAX_TOUCH ; i++) /* <API key> */ g_Mtouch_info[i].strength = -1; #ifdef <API key> tsp_dev = device_create(sec_class, NULL, 0, ts, "sec_touch"); if (IS_ERR(tsp_dev)) pr_err("[TSP] Failed to create device for the sysfs\n"); ret = sysfs_create_group(&tsp_dev->kobj, &<API key>); if (ret) pr_err("[TSP] Failed to create sysfs group\n"); #endif #ifdef <API key> test_dev = device_create(sec_class, NULL, 0, ts, "qt602240_noise_test"); if (IS_ERR(test_dev)) { pr_err("Failed to create device for the factory test\n"); ret = -ENODEV; } ret = sysfs_create_group(&test_dev->kobj, &<API key>); if (ret) { pr_err("Failed to create sysfs group for the factory test\n"); } #endif #ifdef <API key> ts->early_suspend.level = <API key> + 1; ts->early_suspend.suspend = <API key>; ts->early_suspend.resume = <API key>; <API key>(&ts->early_suspend); #endif return 0; err_request_irq: free_irq(client->irq, ts); <API key>: input_free_device(input); err_alloc_failed: kfree(ts); <API key>: return ret; } static int melfas_ts_remove(struct i2c_client *client) { struct melfas_ts_data *ts = i2c_get_clientdata(client); pr_warning("[TSP] %s\n", __func__); <API key>(&ts->early_suspend); free_irq(client->irq, ts); <API key>(ts->input_dev); kfree(ts); return 0; } #ifdef <API key> static void <API key>(struct early_suspend *h) { struct melfas_ts_data *ts = container_of(h, struct melfas_ts_data, early_suspend); #else static int melfas_ts_suspend(struct i2c_client *client, pm_message_t mesg) { int ret; struct melfas_ts_data *ts = i2c_get_clientdata(client); #endif pr_info("[TSP] %s\n", __func__); release_all_fingers(ts); disable_irq(ts->client->irq); if (ts->power_enable) ts->power_enable(0); } #ifdef <API key> static void <API key>(struct early_suspend *h) { struct melfas_ts_data *ts = container_of(h, struct melfas_ts_data, early_suspend); #else static int melfas_ts_resume(struct i2c_client *client) { struct melfas_ts_data *ts = i2c_get_clientdata(client); #endif char buf[2]; int ret = 0; pr_info("[TSP] %s : TA/USB %sconnect\n", __func__,ts->charging_status?"":"dis"); if (ts->power_enable) ts->power_enable(1); buf[0] = 0x60; buf[1] = ts->charging_status; msleep(500); ret = melfas_i2c_write(ts->client, (char *)buf, 2); if(ret < 0){ pr_err("[TSP] TA condtion i2c write fail :%d \n",ret); } enable_irq(ts->client->irq); } static void melfas_ts_shutdown(struct i2c_client *client) { struct melfas_ts_data *ts = i2c_get_clientdata(client); free_irq(client->irq, ts); ts->power_enable(0); #ifdef CONFIG_ARCH_TEGRA <API key>(GPIO_TOUCH_INT, 0); #endif } static const struct i2c_device_id melfas_ts_id[] = { { MELFAS_TS_NAME, 0 }, { } }; static struct i2c_driver melfas_ts_driver = { .driver = { .name = MELFAS_TS_NAME, }, .id_table = melfas_ts_id, .probe = melfas_ts_probe, .remove = __devexit_p (melfas_ts_remove), .shutdown = melfas_ts_shutdown, #ifndef <API key> .suspend = melfas_ts_suspend, .resume = melfas_ts_resume, #endif }; static int __devinit melfas_ts_init(void) { return i2c_add_driver(&melfas_ts_driver); } static void __exit melfas_ts_exit(void) { i2c_del_driver(&melfas_ts_driver); } MODULE_DESCRIPTION("Driver for Melfas MTSI Touchscreen Controller"); MODULE_AUTHOR("MinSang, Kim <kimms@melfas.com>"); MODULE_VERSION("0.1"); MODULE_LICENSE("GPL"); module_init(melfas_ts_init); module_exit(melfas_ts_exit);
#include <linux/fs.h> #include <linux/namei.h> #include <linux/ctype.h> #include <linux/quotaops.h> #include <linux/exportfs.h> #include "jfs_incore.h" #include "jfs_superblock.h" #include "jfs_inode.h" #include "jfs_dinode.h" #include "jfs_dmap.h" #include "jfs_unicode.h" #include "jfs_metapage.h" #include "jfs_xattr.h" #include "jfs_acl.h" #include "jfs_debug.h" /* * forward references */ const struct dentry_operations <API key>; static s64 commitZeroLink(tid_t, struct inode *); /* * NAME: free_ea_wmap(inode) * * FUNCTION: free uncommitted extended attributes from working map * */ static inline void free_ea_wmap(struct inode *inode) { dxd_t *ea = &JFS_IP(inode)->ea; if (ea->flag & DXD_EXTENT) { /* free EA pages from cache */ <API key>(inode, *ea); dbFree(inode, addressDXD(ea), lengthDXD(ea)); } ea->flag = 0; } /* * NAME: jfs_create(dip, dentry, mode) * * FUNCTION: create a regular file in the parent directory <dip> * with name = <from dentry> and mode = <mode> * * PARAMETER: dip - parent directory vnode * dentry - dentry of new file * mode - create mode (rwxrwxrwx). * nd- nd struct * * RETURN: Errors from subroutines * */ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, struct nameidata *nd) { int rc = 0; tid_t tid; /* transaction id */ struct inode *ip = NULL; /* child directory inode */ ino_t ino; struct component_name dname; /* child directory name */ struct btstack btstack; struct inode *iplist[2]; struct tblock *tblk; jfs_info("jfs_create: dip:0x%p name:%s", dip, dentry->d_name.name); dquot_initialize(dip); /* * search parent directory for entry/freespace * (dtSearch() returns parent directory page pinned) */ if ((rc = get_UCSname(&dname, dentry))) goto out1; /* * Either iAlloc() or txBegin() may block. Deadlock can occur if we * block there while holding dtree page, so we allocate the inode & * begin the transaction before we search the directory. */ ip = ialloc(dip, mode); if (IS_ERR(ip)) { rc = PTR_ERR(ip); goto out2; } tid = txBegin(dip->i_sb, 0); mutex_lock_nested(&JFS_IP(dip)->commit_mutex, COMMIT_MUTEX_PARENT); mutex_lock_nested(&JFS_IP(ip)->commit_mutex, COMMIT_MUTEX_CHILD); rc = jfs_init_acl(tid, ip, dip); if (rc) goto out3; rc = jfs_init_security(tid, ip, dip, &dentry->d_name); if (rc) { txAbort(tid, 0); goto out3; } if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) { jfs_err("jfs_create: dtSearch returned %d", rc); txAbort(tid, 0); goto out3; } tblk = tid_to_tblock(tid); tblk->xflag |= COMMIT_CREATE; tblk->ino = ip->i_ino; tblk->u.ixpxd = JFS_IP(ip)->ixpxd; iplist[0] = dip; iplist[1] = ip; /* * initialize the child XAD tree root in-line in inode */ xtInitRoot(tid, ip); /* * create entry in parent directory for child directory * (dtInsert() releases parent directory page) */ ino = ip->i_ino; if ((rc = dtInsert(tid, dip, &dname, &ino, &btstack))) { if (rc == -EIO) { jfs_err("jfs_create: dtInsert returned -EIO"); txAbort(tid, 1); /* Marks Filesystem dirty */ } else txAbort(tid, 0); /* Filesystem full */ goto out3; } ip->i_op = &<API key>; ip->i_fop = &jfs_file_operations; ip->i_mapping->a_ops = &jfs_aops; mark_inode_dirty(ip); dip->i_ctime = dip->i_mtime = CURRENT_TIME; mark_inode_dirty(dip); rc = txCommit(tid, 2, &iplist[0], 0); out3: txEnd(tid); mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(dip)->commit_mutex); if (rc) { free_ea_wmap(ip); ip->i_nlink = 0; unlock_new_inode(ip); iput(ip); } else { d_instantiate(dentry, ip); unlock_new_inode(ip); } out2: free_UCSname(&dname); out1: jfs_info("jfs_create: rc:%d", rc); return rc; } static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) { int rc = 0; tid_t tid; /* transaction id */ struct inode *ip = NULL; /* child directory inode */ ino_t ino; struct component_name dname; /* child directory name */ struct btstack btstack; struct inode *iplist[2]; struct tblock *tblk; jfs_info("jfs_mkdir: dip:0x%p name:%s", dip, dentry->d_name.name); dquot_initialize(dip); /* link count overflow on parent directory ? */ if (dip->i_nlink == JFS_LINK_MAX) { rc = -EMLINK; goto out1; } /* * search parent directory for entry/freespace * (dtSearch() returns parent directory page pinned) */ if ((rc = get_UCSname(&dname, dentry))) goto out1; /* * Either iAlloc() or txBegin() may block. Deadlock can occur if we * block there while holding dtree page, so we allocate the inode & * begin the transaction before we search the directory. */ ip = ialloc(dip, S_IFDIR | mode); if (IS_ERR(ip)) { rc = PTR_ERR(ip); goto out2; } tid = txBegin(dip->i_sb, 0); mutex_lock_nested(&JFS_IP(dip)->commit_mutex, COMMIT_MUTEX_PARENT); mutex_lock_nested(&JFS_IP(ip)->commit_mutex, COMMIT_MUTEX_CHILD); rc = jfs_init_acl(tid, ip, dip); if (rc) goto out3; rc = jfs_init_security(tid, ip, dip, &dentry->d_name); if (rc) { txAbort(tid, 0); goto out3; } if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) { jfs_err("jfs_mkdir: dtSearch returned %d", rc); txAbort(tid, 0); goto out3; } tblk = tid_to_tblock(tid); tblk->xflag |= COMMIT_CREATE; tblk->ino = ip->i_ino; tblk->u.ixpxd = JFS_IP(ip)->ixpxd; iplist[0] = dip; iplist[1] = ip; /* * initialize the child directory in-line in inode */ dtInitRoot(tid, ip, dip->i_ino); /* * create entry in parent directory for child directory * (dtInsert() releases parent directory page) */ ino = ip->i_ino; if ((rc = dtInsert(tid, dip, &dname, &ino, &btstack))) { if (rc == -EIO) { jfs_err("jfs_mkdir: dtInsert returned -EIO"); txAbort(tid, 1); /* Marks Filesystem dirty */ } else txAbort(tid, 0); /* Filesystem full */ goto out3; } ip->i_nlink = 2; /* for '.' */ ip->i_op = &<API key>; ip->i_fop = &jfs_dir_operations; mark_inode_dirty(ip); /* update parent directory inode */ inc_nlink(dip); /* for '..' from child directory */ dip->i_ctime = dip->i_mtime = CURRENT_TIME; mark_inode_dirty(dip); rc = txCommit(tid, 2, &iplist[0], 0); out3: txEnd(tid); mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(dip)->commit_mutex); if (rc) { free_ea_wmap(ip); ip->i_nlink = 0; unlock_new_inode(ip); iput(ip); } else { d_instantiate(dentry, ip); unlock_new_inode(ip); } out2: free_UCSname(&dname); out1: jfs_info("jfs_mkdir: rc:%d", rc); return rc; } /* * NAME: jfs_rmdir(dip, dentry) * * FUNCTION: remove a link to child directory * * PARAMETER: dip - parent inode * dentry - child directory dentry * * RETURN: -EINVAL - if name is . or .. * -EINVAL - if . or .. exist but are invalid. * errors from subroutines * * note: * if other threads have the directory open when the last link * is removed, the "." and ".." entries, if present, are removed before * rmdir() returns and no new entries may be created in the directory, * but the directory is not removed until the last reference to * the directory is released (cf.unlink() of regular file). */ static int jfs_rmdir(struct inode *dip, struct dentry *dentry) { int rc; tid_t tid; /* transaction id */ struct inode *ip = dentry->d_inode; ino_t ino; struct component_name dname; struct inode *iplist[2]; struct tblock *tblk; jfs_info("jfs_rmdir: dip:0x%p name:%s", dip, dentry->d_name.name); /* Init inode for quota operations. */ dquot_initialize(dip); dquot_initialize(ip); /* directory must be empty to be removed */ if (!dtEmpty(ip)) { rc = -ENOTEMPTY; goto out; } if ((rc = get_UCSname(&dname, dentry))) { goto out; } tid = txBegin(dip->i_sb, 0); mutex_lock_nested(&JFS_IP(dip)->commit_mutex, COMMIT_MUTEX_PARENT); mutex_lock_nested(&JFS_IP(ip)->commit_mutex, COMMIT_MUTEX_CHILD); iplist[0] = dip; iplist[1] = ip; tblk = tid_to_tblock(tid); tblk->xflag |= COMMIT_DELETE; tblk->u.ip = ip; /* * delete the entry of target directory from parent directory */ ino = ip->i_ino; if ((rc = dtDelete(tid, dip, &dname, &ino, JFS_REMOVE))) { jfs_err("jfs_rmdir: dtDelete returned %d", rc); if (rc == -EIO) txAbort(tid, 1); txEnd(tid); mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(dip)->commit_mutex); goto out2; } /* update parent directory's link count corresponding * to ".." entry of the target directory deleted */ dip->i_ctime = dip->i_mtime = CURRENT_TIME; <API key>(dip); /* * OS/2 could have created EA and/or ACL */ /* free EA from both persistent and working map */ if (JFS_IP(ip)->ea.flag & DXD_EXTENT) { /* free EA pages */ txEA(tid, ip, &JFS_IP(ip)->ea, NULL); } JFS_IP(ip)->ea.flag = 0; /* free ACL from both persistent and working map */ if (JFS_IP(ip)->acl.flag & DXD_EXTENT) { /* free ACL pages */ txEA(tid, ip, &JFS_IP(ip)->acl, NULL); } JFS_IP(ip)->acl.flag = 0; /* mark the target directory as deleted */ clear_nlink(ip); mark_inode_dirty(ip); rc = txCommit(tid, 2, &iplist[0], 0); txEnd(tid); mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(dip)->commit_mutex); /* * Truncating the directory index table is not guaranteed. It * may need to be done iteratively */ if (test_cflag(COMMIT_Stale, dip)) { if (dip->i_size > 1) jfs_truncate_nolock(dip, 0); clear_cflag(COMMIT_Stale, dip); } out2: free_UCSname(&dname); out: jfs_info("jfs_rmdir: rc:%d", rc); return rc; } /* * NAME: jfs_unlink(dip, dentry) * * FUNCTION: remove a link to object <vp> named by <name> * from parent directory <dvp> * * PARAMETER: dip - inode of parent directory * dentry - dentry of object to be removed * * RETURN: errors from subroutines * * note: * temporary file: if one or more processes have the file open * when the last link is removed, the link will be removed before * unlink() returns, but the removal of the file contents will be * postponed until all references to the files are closed. * * JFS does NOT support unlink() on directories. * */ static int jfs_unlink(struct inode *dip, struct dentry *dentry) { int rc; tid_t tid; /* transaction id */ struct inode *ip = dentry->d_inode; ino_t ino; struct component_name dname; /* object name */ struct inode *iplist[2]; struct tblock *tblk; s64 new_size = 0; int commit_flag; jfs_info("jfs_unlink: dip:0x%p name:%s", dip, dentry->d_name.name); /* Init inode for quota operations. */ dquot_initialize(dip); dquot_initialize(ip); if ((rc = get_UCSname(&dname, dentry))) goto out; IWRITE_LOCK(ip, RDWRLOCK_NORMAL); tid = txBegin(dip->i_sb, 0); mutex_lock_nested(&JFS_IP(dip)->commit_mutex, COMMIT_MUTEX_PARENT); mutex_lock_nested(&JFS_IP(ip)->commit_mutex, COMMIT_MUTEX_CHILD); iplist[0] = dip; iplist[1] = ip; /* * delete the entry of target file from parent directory */ ino = ip->i_ino; if ((rc = dtDelete(tid, dip, &dname, &ino, JFS_REMOVE))) { jfs_err("jfs_unlink: dtDelete returned %d", rc); if (rc == -EIO) txAbort(tid, 1); /* Marks FS Dirty */ txEnd(tid); mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(dip)->commit_mutex); IWRITE_UNLOCK(ip); goto out1; } ASSERT(ip->i_nlink); ip->i_ctime = dip->i_ctime = dip->i_mtime = CURRENT_TIME; mark_inode_dirty(dip); /* update target's inode */ <API key>(ip); /* * commit zero link count object */ if (ip->i_nlink == 0) { assert(!test_cflag(COMMIT_Nolink, ip)); /* free block resources */ if ((new_size = commitZeroLink(tid, ip)) < 0) { txAbort(tid, 1); /* Marks FS Dirty */ txEnd(tid); mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(dip)->commit_mutex); IWRITE_UNLOCK(ip); rc = new_size; goto out1; } tblk = tid_to_tblock(tid); tblk->xflag |= COMMIT_DELETE; tblk->u.ip = ip; } /* * Incomplete truncate of file data can * result in timing problems unless we synchronously commit the * transaction. */ if (new_size) commit_flag = COMMIT_SYNC; else commit_flag = 0; /* * If xtTruncate was incomplete, commit synchronously to avoid * timing complications */ rc = txCommit(tid, 2, &iplist[0], commit_flag); txEnd(tid); mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(dip)->commit_mutex); while (new_size && (rc == 0)) { tid = txBegin(dip->i_sb, 0); mutex_lock(&JFS_IP(ip)->commit_mutex); new_size = xtTruncate_pmap(tid, ip, new_size); if (new_size < 0) { txAbort(tid, 1); /* Marks FS Dirty */ rc = new_size; } else rc = txCommit(tid, 2, &iplist[0], COMMIT_SYNC); txEnd(tid); mutex_unlock(&JFS_IP(ip)->commit_mutex); } if (ip->i_nlink == 0) set_cflag(COMMIT_Nolink, ip); IWRITE_UNLOCK(ip); /* * Truncating the directory index table is not guaranteed. It * may need to be done iteratively */ if (test_cflag(COMMIT_Stale, dip)) { if (dip->i_size > 1) jfs_truncate_nolock(dip, 0); clear_cflag(COMMIT_Stale, dip); } out1: free_UCSname(&dname); out: jfs_info("jfs_unlink: rc:%d", rc); return rc; } /* * NAME: commitZeroLink() * * FUNCTION: for non-directory, called by jfs_remove(), * truncate a regular file, directory or symbolic * link to zero length. return 0 if type is not * one of these. * * if the file is currently associated with a VM segment * only permanent disk and inode map resources are freed, * and neither the inode nor indirect blocks are modified * so that the resources can be later freed in the work * map by ctrunc1. * if there is no VM segment on entry, the resources are * freed in both work and permanent map. * (? for temporary file - memory object is cached even * after no reference: * reference count > 0 - ) * * PARAMETERS: cd - pointer to commit data structure. * current inode is the one to truncate. * * RETURN: Errors from subroutines */ static s64 commitZeroLink(tid_t tid, struct inode *ip) { int filetype; struct tblock *tblk; jfs_info("commitZeroLink: tid = %d, ip = 0x%p", tid, ip); filetype = ip->i_mode & S_IFMT; switch (filetype) { case S_IFREG: break; case S_IFLNK: /* fast symbolic link */ if (ip->i_size < IDATASIZE) { ip->i_size = 0; return 0; } break; default: assert(filetype != S_IFDIR); return 0; } set_cflag(COMMIT_Freewmap, ip); /* mark transaction of block map update type */ tblk = tid_to_tblock(tid); tblk->xflag |= COMMIT_PMAP; /* * free EA */ if (JFS_IP(ip)->ea.flag & DXD_EXTENT) /* acquire maplock on EA to be freed from block map */ txEA(tid, ip, &JFS_IP(ip)->ea, NULL); /* * free ACL */ if (JFS_IP(ip)->acl.flag & DXD_EXTENT) /* acquire maplock on EA to be freed from block map */ txEA(tid, ip, &JFS_IP(ip)->acl, NULL); /* * free xtree/data (truncate to zero length): * free xtree/data pages from cache if COMMIT_PWMAP, * free xtree/data blocks from persistent block map, and * free xtree/data blocks from working block map if COMMIT_PWMAP; */ if (ip->i_size) return xtTruncate_pmap(tid, ip, 0); return 0; } /* * NAME: jfs_free_zero_link() * * FUNCTION: for non-directory, called by iClose(), * free resources of a file from cache and WORKING map * for a file previously committed with zero link count * while associated with a pager object, * * PARAMETER: ip - pointer to inode of file. */ void jfs_free_zero_link(struct inode *ip) { int type; jfs_info("jfs_free_zero_link: ip = 0x%p", ip); /* return if not reg or symbolic link or if size is * already ok. */ type = ip->i_mode & S_IFMT; switch (type) { case S_IFREG: break; case S_IFLNK: /* if its contained in inode nothing to do */ if (ip->i_size < IDATASIZE) return; break; default: return; } /* * free EA */ if (JFS_IP(ip)->ea.flag & DXD_EXTENT) { s64 xaddr = addressDXD(&JFS_IP(ip)->ea); int xlen = lengthDXD(&JFS_IP(ip)->ea); struct maplock maplock; /* maplock for COMMIT_WMAP */ struct pxd_lock *pxdlock; /* maplock for COMMIT_WMAP */ /* free EA pages from cache */ <API key>(ip, JFS_IP(ip)->ea); /* free EA extent from working block map */ maplock.index = 1; pxdlock = (struct pxd_lock *) & maplock; pxdlock->flag = mlckFREEPXD; PXDaddress(&pxdlock->pxd, xaddr); PXDlength(&pxdlock->pxd, xlen); txFreeMap(ip, pxdlock, NULL, COMMIT_WMAP); } /* * free ACL */ if (JFS_IP(ip)->acl.flag & DXD_EXTENT) { s64 xaddr = addressDXD(&JFS_IP(ip)->acl); int xlen = lengthDXD(&JFS_IP(ip)->acl); struct maplock maplock; /* maplock for COMMIT_WMAP */ struct pxd_lock *pxdlock; /* maplock for COMMIT_WMAP */ <API key>(ip, JFS_IP(ip)->acl); /* free ACL extent from working block map */ maplock.index = 1; pxdlock = (struct pxd_lock *) & maplock; pxdlock->flag = mlckFREEPXD; PXDaddress(&pxdlock->pxd, xaddr); PXDlength(&pxdlock->pxd, xlen); txFreeMap(ip, pxdlock, NULL, COMMIT_WMAP); } /* * free xtree/data (truncate to zero length): * free xtree/data pages from cache, and * free xtree/data blocks from working block map; */ if (ip->i_size) xtTruncate(0, ip, 0, COMMIT_WMAP); } /* * NAME: jfs_link(vp, dvp, name, crp) * * FUNCTION: create a link to <vp> by the name = <name> * in the parent directory <dvp> * * PARAMETER: vp - target object * dvp - parent directory of new link * name - name of new link to target object * crp - credential * * RETURN: Errors from subroutines * * note: * JFS does NOT support link() on directories (to prevent circular * path in the directory hierarchy); * EPERM: the target object is a directory, and either the caller * does not have appropriate privileges or the implementation prohibits * using link() on directories [XPG4.2]. * * JFS does NOT support links between file systems: * EXDEV: target object and new link are on different file systems and * implementation does not support links between file systems [XPG4.2]. */ static int jfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) { int rc; tid_t tid; struct inode *ip = old_dentry->d_inode; ino_t ino; struct component_name dname; struct btstack btstack; struct inode *iplist[2]; jfs_info("jfs_link: %s %s", old_dentry->d_name.name, dentry->d_name.name); if (ip->i_nlink == JFS_LINK_MAX) return -EMLINK; dquot_initialize(dir); tid = txBegin(ip->i_sb, 0); mutex_lock_nested(&JFS_IP(dir)->commit_mutex, COMMIT_MUTEX_PARENT); mutex_lock_nested(&JFS_IP(ip)->commit_mutex, COMMIT_MUTEX_CHILD); /* * scan parent directory for entry/freespace */ if ((rc = get_UCSname(&dname, dentry))) goto out; if ((rc = dtSearch(dir, &dname, &ino, &btstack, JFS_CREATE))) goto free_dname; /* * create entry for new link in parent directory */ ino = ip->i_ino; if ((rc = dtInsert(tid, dir, &dname, &ino, &btstack))) goto free_dname; /* update object inode */ inc_nlink(ip); /* for new link */ ip->i_ctime = CURRENT_TIME; dir->i_ctime = dir->i_mtime = CURRENT_TIME; mark_inode_dirty(dir); ihold(ip); iplist[0] = ip; iplist[1] = dir; rc = txCommit(tid, 2, &iplist[0], 0); if (rc) { ip->i_nlink--; /* never instantiated */ iput(ip); } else d_instantiate(dentry, ip); free_dname: free_UCSname(&dname); out: txEnd(tid); mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(dir)->commit_mutex); jfs_info("jfs_link: rc:%d", rc); return rc; } /* * NAME: jfs_symlink(dip, dentry, name) * * FUNCTION: creates a symbolic link to <symlink> by name <name> * in directory <dip> * * PARAMETER: dip - parent directory vnode * dentry - dentry of symbolic link * name - the path name of the existing object * that will be the source of the link * * RETURN: errors from subroutines * * note: * ENAMETOOLONG: pathname resolution of a symbolic link produced * an intermediate result whose length exceeds PATH_MAX [XPG4.2] */ static int jfs_symlink(struct inode *dip, struct dentry *dentry, const char *name) { int rc; tid_t tid; ino_t ino = 0; struct component_name dname; int ssize; /* source pathname size */ struct btstack btstack; struct inode *ip = dentry->d_inode; unchar *i_fastsymlink; s64 xlen = 0; int bmask = 0, xsize; s64 extent = 0, xaddr; struct metapage *mp; struct super_block *sb; struct tblock *tblk; struct inode *iplist[2]; jfs_info("jfs_symlink: dip:0x%p name:%s", dip, name); dquot_initialize(dip); ssize = strlen(name) + 1; /* * search parent directory for entry/freespace * (dtSearch() returns parent directory page pinned) */ if ((rc = get_UCSname(&dname, dentry))) goto out1; /* * allocate on-disk/in-memory inode for symbolic link: * (iAlloc() returns new, locked inode) */ ip = ialloc(dip, S_IFLNK | 0777); if (IS_ERR(ip)) { rc = PTR_ERR(ip); goto out2; } tid = txBegin(dip->i_sb, 0); mutex_lock_nested(&JFS_IP(dip)->commit_mutex, COMMIT_MUTEX_PARENT); mutex_lock_nested(&JFS_IP(ip)->commit_mutex, COMMIT_MUTEX_CHILD); rc = jfs_init_security(tid, ip, dip, &dentry->d_name); if (rc) goto out3; tblk = tid_to_tblock(tid); tblk->xflag |= COMMIT_CREATE; tblk->ino = ip->i_ino; tblk->u.ixpxd = JFS_IP(ip)->ixpxd; ip->i_mode |= 0777; /* * write symbolic link target path name */ xtInitRoot(tid, ip); /* * write source path name inline in on-disk inode (fast symbolic link) */ if (ssize <= IDATASIZE) { ip->i_op = &<API key>; i_fastsymlink = JFS_IP(ip)->i_inline; memcpy(i_fastsymlink, name, ssize); ip->i_size = ssize - 1; /* * if symlink is > 128 bytes, we don't have the space to * store inline extended attributes */ if (ssize > sizeof (JFS_IP(ip)->i_inline)) JFS_IP(ip)->mode2 &= ~INLINEEA; jfs_info("jfs_symlink: fast symlink added ssize:%d name:%s ", ssize, name); } /* * write source path name in a single extent */ else { jfs_info("jfs_symlink: allocate extent ip:0x%p", ip); ip->i_op = &<API key>; ip->i_mapping->a_ops = &jfs_aops; /* * even though the data of symlink object (source * path name) is treated as non-journaled user data, * it is read/written thru buffer cache for performance. */ sb = ip->i_sb; bmask = JFS_SBI(sb)->bsize - 1; xsize = (ssize + bmask) & ~bmask; xaddr = 0; xlen = xsize >> JFS_SBI(sb)->l2bsize; if ((rc = xtInsert(tid, ip, 0, 0, xlen, &xaddr, 0))) { txAbort(tid, 0); goto out3; } extent = xaddr; ip->i_size = ssize - 1; while (ssize) { /* This is kind of silly since PATH_MAX == 4K */ int copy_size = min(ssize, PSIZE); mp = get_metapage(ip, xaddr, PSIZE, 1); if (mp == NULL) { xtTruncate(tid, ip, 0, COMMIT_PWMAP); rc = -EIO; txAbort(tid, 0); goto out3; } memcpy(mp->data, name, copy_size); flush_metapage(mp); ssize -= copy_size; name += copy_size; xaddr += JFS_SBI(sb)->nbperpage; } } /* * create entry for symbolic link in parent directory */ rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE); if (rc == 0) { ino = ip->i_ino; rc = dtInsert(tid, dip, &dname, &ino, &btstack); } if (rc) { if (xlen) xtTruncate(tid, ip, 0, COMMIT_PWMAP); txAbort(tid, 0); /* discard new inode */ goto out3; } mark_inode_dirty(ip); dip->i_ctime = dip->i_mtime = CURRENT_TIME; mark_inode_dirty(dip); /* * commit update of parent directory and link object */ iplist[0] = dip; iplist[1] = ip; rc = txCommit(tid, 2, &iplist[0], 0); out3: txEnd(tid); mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(dip)->commit_mutex); if (rc) { free_ea_wmap(ip); ip->i_nlink = 0; unlock_new_inode(ip); iput(ip); } else { d_instantiate(dentry, ip); unlock_new_inode(ip); } out2: free_UCSname(&dname); out1: jfs_info("jfs_symlink: rc:%d", rc); return rc; } /* * NAME: jfs_rename * * FUNCTION: rename a file or directory */ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry) { struct btstack btstack; ino_t ino; struct component_name new_dname; struct inode *new_ip; struct component_name old_dname; struct inode *old_ip; int rc; tid_t tid; struct tlock *tlck; struct dt_lock *dtlck; struct lv *lv; int ipcount; struct inode *iplist[4]; struct tblock *tblk; s64 new_size = 0; int commit_flag; jfs_info("jfs_rename: %s %s", old_dentry->d_name.name, new_dentry->d_name.name); dquot_initialize(old_dir); dquot_initialize(new_dir); old_ip = old_dentry->d_inode; new_ip = new_dentry->d_inode; if ((rc = get_UCSname(&old_dname, old_dentry))) goto out1; if ((rc = get_UCSname(&new_dname, new_dentry))) goto out2; /* * Make sure source inode number is what we think it is */ rc = dtSearch(old_dir, &old_dname, &ino, &btstack, JFS_LOOKUP); if (rc || (ino != old_ip->i_ino)) { rc = -ENOENT; goto out3; } /* * Make sure dest inode number (if any) is what we think it is */ rc = dtSearch(new_dir, &new_dname, &ino, &btstack, JFS_LOOKUP); if (!rc) { if ((!new_ip) || (ino != new_ip->i_ino)) { rc = -ESTALE; goto out3; } } else if (rc != -ENOENT) goto out3; else if (new_ip) { /* no entry exists, but one was expected */ rc = -ESTALE; goto out3; } if (S_ISDIR(old_ip->i_mode)) { if (new_ip) { if (!dtEmpty(new_ip)) { rc = -ENOTEMPTY; goto out3; } } else if ((new_dir != old_dir) && (new_dir->i_nlink == JFS_LINK_MAX)) { rc = -EMLINK; goto out3; } } else if (new_ip) { IWRITE_LOCK(new_ip, RDWRLOCK_NORMAL); /* Init inode for quota operations. */ dquot_initialize(new_ip); } /* * The real work starts here */ tid = txBegin(new_dir->i_sb, 0); /* * How do we know the locking is safe from deadlocks? * The vfs does the hard part for us. Any time we are taking nested * commit_mutexes, the vfs already has i_mutex held on the parent. * Here, the vfs has already taken i_mutex on both old_dir and new_dir. */ mutex_lock_nested(&JFS_IP(new_dir)->commit_mutex, COMMIT_MUTEX_PARENT); mutex_lock_nested(&JFS_IP(old_ip)->commit_mutex, COMMIT_MUTEX_CHILD); if (old_dir != new_dir) mutex_lock_nested(&JFS_IP(old_dir)->commit_mutex, <API key>); if (new_ip) { mutex_lock_nested(&JFS_IP(new_ip)->commit_mutex, COMMIT_MUTEX_VICTIM); /* * Change existing directory entry to new inode number */ ino = new_ip->i_ino; rc = dtModify(tid, new_dir, &new_dname, &ino, old_ip->i_ino, JFS_RENAME); if (rc) goto out4; drop_nlink(new_ip); if (S_ISDIR(new_ip->i_mode)) { drop_nlink(new_ip); if (new_ip->i_nlink) { mutex_unlock(&JFS_IP(new_ip)->commit_mutex); if (old_dir != new_dir) mutex_unlock(&JFS_IP(old_dir)->commit_mutex); mutex_unlock(&JFS_IP(old_ip)->commit_mutex); mutex_unlock(&JFS_IP(new_dir)->commit_mutex); if (!S_ISDIR(old_ip->i_mode) && new_ip) IWRITE_UNLOCK(new_ip); jfs_error(new_ip->i_sb, "jfs_rename: new_ip->i_nlink != 0"); return -EIO; } tblk = tid_to_tblock(tid); tblk->xflag |= COMMIT_DELETE; tblk->u.ip = new_ip; } else if (new_ip->i_nlink == 0) { assert(!test_cflag(COMMIT_Nolink, new_ip)); /* free block resources */ if ((new_size = commitZeroLink(tid, new_ip)) < 0) { txAbort(tid, 1); /* Marks FS Dirty */ rc = new_size; goto out4; } tblk = tid_to_tblock(tid); tblk->xflag |= COMMIT_DELETE; tblk->u.ip = new_ip; } else { new_ip->i_ctime = CURRENT_TIME; mark_inode_dirty(new_ip); } } else { /* * Add new directory entry */ rc = dtSearch(new_dir, &new_dname, &ino, &btstack, JFS_CREATE); if (rc) { jfs_err("jfs_rename didn't expect dtSearch to fail " "w/rc = %d", rc); goto out4; } ino = old_ip->i_ino; rc = dtInsert(tid, new_dir, &new_dname, &ino, &btstack); if (rc) { if (rc == -EIO) jfs_err("jfs_rename: dtInsert returned -EIO"); goto out4; } if (S_ISDIR(old_ip->i_mode)) inc_nlink(new_dir); } /* * Remove old directory entry */ ino = old_ip->i_ino; rc = dtDelete(tid, old_dir, &old_dname, &ino, JFS_REMOVE); if (rc) { jfs_err("jfs_rename did not expect dtDelete to return rc = %d", rc); txAbort(tid, 1); /* Marks Filesystem dirty */ goto out4; } if (S_ISDIR(old_ip->i_mode)) { drop_nlink(old_dir); if (old_dir != new_dir) { /* * Change inode number of parent for moved directory */ JFS_IP(old_ip)->i_dtroot.header.idotdot = cpu_to_le32(new_dir->i_ino); /* Linelock header of dtree */ tlck = txLock(tid, old_ip, (struct metapage *) &JFS_IP(old_ip)->bxflag, tlckDTREE | tlckBTROOT | tlckRELINK); dtlck = (struct dt_lock *) & tlck->lock; ASSERT(dtlck->index == 0); lv = & dtlck->lv[0]; lv->offset = 0; lv->length = 1; dtlck->index++; } } /* * Update ctime on changed/moved inodes & mark dirty */ old_ip->i_ctime = CURRENT_TIME; mark_inode_dirty(old_ip); new_dir->i_ctime = new_dir->i_mtime = current_fs_time(new_dir->i_sb); mark_inode_dirty(new_dir); ipcount = 0; iplist[ipcount++] = old_ip; if (new_ip) iplist[ipcount++] = new_ip; iplist[ipcount++] = old_dir; if (old_dir != new_dir) { iplist[ipcount++] = new_dir; old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME; mark_inode_dirty(old_dir); } /* * Incomplete truncate of file data can * result in timing problems unless we synchronously commit the * transaction. */ if (new_size) commit_flag = COMMIT_SYNC; else commit_flag = 0; rc = txCommit(tid, ipcount, iplist, commit_flag); out4: txEnd(tid); if (new_ip) mutex_unlock(&JFS_IP(new_ip)->commit_mutex); if (old_dir != new_dir) mutex_unlock(&JFS_IP(old_dir)->commit_mutex); mutex_unlock(&JFS_IP(old_ip)->commit_mutex); mutex_unlock(&JFS_IP(new_dir)->commit_mutex); while (new_size && (rc == 0)) { tid = txBegin(new_ip->i_sb, 0); mutex_lock(&JFS_IP(new_ip)->commit_mutex); new_size = xtTruncate_pmap(tid, new_ip, new_size); if (new_size < 0) { txAbort(tid, 1); rc = new_size; } else rc = txCommit(tid, 1, &new_ip, COMMIT_SYNC); txEnd(tid); mutex_unlock(&JFS_IP(new_ip)->commit_mutex); } if (new_ip && (new_ip->i_nlink == 0)) set_cflag(COMMIT_Nolink, new_ip); out3: free_UCSname(&new_dname); out2: free_UCSname(&old_dname); out1: if (new_ip && !S_ISDIR(new_ip->i_mode)) IWRITE_UNLOCK(new_ip); /* * Truncating the directory index table is not guaranteed. It * may need to be done iteratively */ if (test_cflag(COMMIT_Stale, old_dir)) { if (old_dir->i_size > 1) jfs_truncate_nolock(old_dir, 0); clear_cflag(COMMIT_Stale, old_dir); } jfs_info("jfs_rename: returning %d", rc); return rc; } /* * NAME: jfs_mknod * * FUNCTION: Create a special file (device) */ static int jfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) { struct jfs_inode_info *jfs_ip; struct btstack btstack; struct component_name dname; ino_t ino; struct inode *ip; struct inode *iplist[2]; int rc; tid_t tid; struct tblock *tblk; if (!new_valid_dev(rdev)) return -EINVAL; jfs_info("jfs_mknod: %s", dentry->d_name.name); dquot_initialize(dir); if ((rc = get_UCSname(&dname, dentry))) goto out; ip = ialloc(dir, mode); if (IS_ERR(ip)) { rc = PTR_ERR(ip); goto out1; } jfs_ip = JFS_IP(ip); tid = txBegin(dir->i_sb, 0); mutex_lock_nested(&JFS_IP(dir)->commit_mutex, COMMIT_MUTEX_PARENT); mutex_lock_nested(&JFS_IP(ip)->commit_mutex, COMMIT_MUTEX_CHILD); rc = jfs_init_acl(tid, ip, dir); if (rc) goto out3; rc = jfs_init_security(tid, ip, dir, &dentry->d_name); if (rc) { txAbort(tid, 0); goto out3; } if ((rc = dtSearch(dir, &dname, &ino, &btstack, JFS_CREATE))) { txAbort(tid, 0); goto out3; } tblk = tid_to_tblock(tid); tblk->xflag |= COMMIT_CREATE; tblk->ino = ip->i_ino; tblk->u.ixpxd = JFS_IP(ip)->ixpxd; ino = ip->i_ino; if ((rc = dtInsert(tid, dir, &dname, &ino, &btstack))) { txAbort(tid, 0); goto out3; } ip->i_op = &<API key>; jfs_ip->dev = new_encode_dev(rdev); init_special_inode(ip, ip->i_mode, rdev); mark_inode_dirty(ip); dir->i_ctime = dir->i_mtime = CURRENT_TIME; mark_inode_dirty(dir); iplist[0] = dir; iplist[1] = ip; rc = txCommit(tid, 2, iplist, 0); out3: txEnd(tid); mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(dir)->commit_mutex); if (rc) { free_ea_wmap(ip); ip->i_nlink = 0; unlock_new_inode(ip); iput(ip); } else { d_instantiate(dentry, ip); unlock_new_inode(ip); } out1: free_UCSname(&dname); out: jfs_info("jfs_mknod: returning %d", rc); return rc; } static struct dentry *jfs_lookup(struct inode *dip, struct dentry *dentry, struct nameidata *nd) { struct btstack btstack; ino_t inum; struct inode *ip; struct component_name key; const char *name = dentry->d_name.name; int len = dentry->d_name.len; int rc; jfs_info("jfs_lookup: name = %s", name); if ((name[0] == '.') && (len == 1)) inum = dip->i_ino; else if (strcmp(name, "..") == 0) inum = PARENT(dip); else { if ((rc = get_UCSname(&key, dentry))) return ERR_PTR(rc); rc = dtSearch(dip, &key, &inum, &btstack, JFS_LOOKUP); free_UCSname(&key); if (rc == -ENOENT) { d_add(dentry, NULL); return NULL; } else if (rc) { jfs_err("jfs_lookup: dtSearch returned %d", rc); return ERR_PTR(rc); } } ip = jfs_iget(dip->i_sb, inum); if (IS_ERR(ip)) { jfs_err("jfs_lookup: iget failed on inum %d", (uint) inum); return ERR_CAST(ip); } return d_splice_alias(ip, dentry); } static struct inode *jfs_nfs_get_inode(struct super_block *sb, u64 ino, u32 generation) { struct inode *inode; if (ino == 0) return ERR_PTR(-ESTALE); inode = jfs_iget(sb, ino); if (IS_ERR(inode)) return ERR_CAST(inode); if (generation && inode->i_generation != generation) { iput(inode); return ERR_PTR(-ESTALE); } return inode; } struct dentry *jfs_fh_to_dentry(struct super_block *sb, struct fid *fid, int fh_len, int fh_type) { return <API key>(sb, fid, fh_len, fh_type, jfs_nfs_get_inode); } struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid, int fh_len, int fh_type) { return <API key>(sb, fid, fh_len, fh_type, jfs_nfs_get_inode); } struct dentry *jfs_get_parent(struct dentry *dentry) { unsigned long parent_ino; parent_ino = le32_to_cpu(JFS_IP(dentry->d_inode)->i_dtroot.header.idotdot); return d_obtain_alias(jfs_iget(dentry->d_inode->i_sb, parent_ino)); } const struct inode_operations <API key> = { .create = jfs_create, .lookup = jfs_lookup, .link = jfs_link, .unlink = jfs_unlink, .symlink = jfs_symlink, .mkdir = jfs_mkdir, .rmdir = jfs_rmdir, .mknod = jfs_mknod, .rename = jfs_rename, .setxattr = jfs_setxattr, .getxattr = jfs_getxattr, .listxattr = jfs_listxattr, .removexattr = jfs_removexattr, .setattr = jfs_setattr, #ifdef <API key> .check_acl = jfs_check_acl, #endif }; const struct file_operations jfs_dir_operations = { .read = generic_read_dir, .readdir = jfs_readdir, .fsync = jfs_fsync, .unlocked_ioctl = jfs_ioctl, #ifdef CONFIG_COMPAT .compat_ioctl = jfs_compat_ioctl, #endif .llseek = generic_file_llseek, }; static int jfs_ci_hash(const struct dentry *dir, const struct inode *inode, struct qstr *this) { unsigned long hash; int i; hash = init_name_hash(); for (i=0; i < this->len; i++) hash = partial_name_hash(tolower(this->name[i]), hash); this->hash = end_name_hash(hash); return 0; } static int jfs_ci_compare(const struct dentry *parent, const struct inode *pinode, const struct dentry *dentry, const struct inode *inode, unsigned int len, const char *str, const struct qstr *name) { int i, result = 1; if (len != name->len) goto out; for (i=0; i < len; i++) { if (tolower(str[i]) != tolower(name->name[i])) goto out; } result = 0; out: return result; } static int jfs_ci_revalidate(struct dentry *dentry, struct nameidata *nd) { if (nd && nd->flags & LOOKUP_RCU) return -ECHILD; /* * This is not negative dentry. Always valid. * * Note, rename() to existing directory entry will have ->d_inode, * and will use existing name which isn't specified name by user. * * We may be able to drop this positive dentry here. But dropping * positive dentry isn't good idea. So it's unsupported like * rename("filename", "FILENAME") for now. */ if (dentry->d_inode) return 1; /* * This may be nfsd (or something), anyway, we can't see the * intent of this. So, since this can be for creation, drop it. */ if (!nd) return 0; /* * Drop the negative dentry, in order to make sure to use the * case sensitive name which is specified by user if this is * for creation. */ if (!(nd->flags & (LOOKUP_CONTINUE | LOOKUP_PARENT))) { if (nd->flags & (LOOKUP_CREATE | <API key>)) return 0; } return 1; } const struct dentry_operations <API key> = { .d_hash = jfs_ci_hash, .d_compare = jfs_ci_compare, .d_revalidate = jfs_ci_revalidate, };
require "rjava" # This code is free software; you can redistribute it and/or modify it # published by the Free Software Foundation. Sun designates this # particular file as subject to the "Classpath" exception as provided # This code is distributed in the hope that it will be useful, but WITHOUT # accompanied this code). # 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, # have any questions. module Sun::Security::Krb5::Internal module LastReqEntryImports #:nodoc: class_module.module_eval { include ::Java::Lang include ::Sun::Security::Krb5::Internal include ::Sun::Security::Util include_const ::Sun::Security::Krb5, :Asn1Exception include_const ::Java::Io, :IOException } end class LastReqEntry <API key> LastReqEntryImports attr_accessor :lr_type alias_method :attr_lr_type, :lr_type undef_method :lr_type alias_method :attr_lr_type=, :lr_type= undef_method :lr_type= attr_accessor :lr_value alias_method :attr_lr_value, :lr_value undef_method :lr_value alias_method :attr_lr_value=, :lr_value= undef_method :lr_value= typesig { [] } def initialize @lr_type = 0 @lr_value = nil end typesig { [::Java::Int, KerberosTime] } def initialize(type, time) @lr_type = 0 @lr_value = nil @lr_type = type @lr_value = time # XXX check the type and time. end typesig { [DerValue] } # Constructs a LastReqEntry object. # @param encoding a Der-encoded data. # @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. # @exception IOException if an I/O error occurs while reading encoded data. def initialize(encoding) @lr_type = 0 @lr_value = nil if (!(encoding.get_tag).equal?(DerValue.attr_tag_sequence)) raise Asn1Exception.new(Krb5::ASN1_BAD_ID) end der = nil der = encoding.get_data.get_der_value if (((der.get_tag & 0x1f)).equal?(0x0)) @lr_type = der.get_data.get_big_integer.int_value else raise Asn1Exception.new(Krb5::ASN1_BAD_ID) end @lr_value = KerberosTime.parse(encoding.get_data, 0x1, false) if (encoding.get_data.available > 0) raise Asn1Exception.new(Krb5::ASN1_BAD_ID) end end typesig { [] } # Encodes an LastReqEntry object. # @return the byte array of encoded LastReqEntry object. # @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. # @exception IOException if an I/O error occurs while reading encoded data. def asn1_encode bytes = DerOutputStream.new temp = DerOutputStream.new temp.put_integer(@lr_type) bytes.write(DerValue.create_tag(DerValue::TAG_CONTEXT, true, 0x0), temp) bytes.write(DerValue.create_tag(DerValue::TAG_CONTEXT, true, 0x1), @lr_value.asn1_encode) temp = DerOutputStream.new temp.write(DerValue.attr_tag_sequence, bytes) return temp.to_byte_array end typesig { [] } def clone new_entry = LastReqEntry.new new_entry.attr_lr_type = @lr_type new_entry.attr_lr_value = @lr_value.clone return new_entry end private alias_method :<API key>, :initialize end end
require "rjava" # This code is free software; you can redistribute it and/or modify it # published by the Free Software Foundation. Sun designates this # particular file as subject to the "Classpath" exception as provided # This code is distributed in the hope that it will be useful, but WITHOUT # accompanied this code). # 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, # have any questions. module Java::Lang module BooleanImports #:nodoc: class_module.module_eval { include ::Java::Lang } end # The Boolean class wraps a value of the primitive type # {@code boolean} in an object. An object of type # {@code Boolean} contains a single field whose type is # {@code boolean}. # In addition, this class provides many methods for # converting a {@code boolean} to a {@code String} and a # {@code String} to a {@code boolean}, as well as other # constants and methods useful when dealing with a # {@code boolean}. # @author Arthur van Hoff # @since JDK1.0 class Boolean <API key> BooleanImports include Java::Io::Serializable include JavaComparable class_module.module_eval { # The {@code Boolean} object corresponding to the primitive # value {@code true}. const_set_lazy(:TRUE) { Boolean.new(true) } const_attr_reader :TRUE # The {@code Boolean} object corresponding to the primitive # value {@code false}. const_set_lazy(:FALSE) { Boolean.new(false) } const_attr_reader :FALSE # The Class object representing the primitive type boolean. # @since JDK1.1 const_set_lazy(:TYPE) { Class.get_primitive_class("boolean") } const_attr_reader :TYPE } # The value of the Boolean. # @serial attr_accessor :value alias_method :attr_value, :value undef_method :value alias_method :attr_value=, :value= undef_method :value= class_module.module_eval { # use serialVersionUID from JDK 1.0.2 for interoperability const_set_lazy(:SerialVersionUID) { -3665804199014368530 } const_attr_reader :SerialVersionUID } typesig { [::Java::Boolean] } # Allocates a {@code Boolean} object representing the # {@code value} argument. # <p><b>Note: It is rarely appropriate to use this constructor. # Unless a <i>new</i> instance is required, the static factory # {@link #valueOf(boolean)} is generally a better choice. It is # likely to yield significantly better space and time performance.</b> # @param value the value of the {@code Boolean}. def initialize(value) @value = false @value = value end typesig { [String] } # Allocates a {@code Boolean} object representing the value # {@code true} if the string argument is not {@code null} # and is equal, ignoring case, to the string {@code "true"}. # Otherwise, allocate a {@code Boolean} object representing the # value {@code false}. Examples:<p> # {@code new Boolean("True")} produces a {@code Boolean} object # that represents {@code true}.<br> # {@code new Boolean("yes")} produces a {@code Boolean} object # that represents {@code false}. # @param s the string to be converted to a {@code Boolean}. def initialize(s) initialize__boolean(to_boolean(s)) end class_module.module_eval { typesig { [String] } # Parses the string argument as a boolean. The {@code boolean} # returned represents the value {@code true} if the string argument # is not {@code null} and is equal, ignoring case, to the string # {@code "true"}. <p> # Example: {@code Boolean.parseBoolean("True")} returns {@code true}.<br> # Example: {@code Boolean.parseBoolean("yes")} returns {@code false}. # @param s the {@code String} containing the boolean # representation to be parsed # @return the boolean represented by the string argument # @since 1.5 def parse_boolean(s) return to_boolean(s) end } typesig { [] } # Returns the value of this {@code Boolean} object as a boolean # primitive. # @return the primitive {@code boolean} value of this object. def boolean_value return @value end class_module.module_eval { typesig { [::Java::Boolean] } # Returns a {@code Boolean} instance representing the specified # {@code boolean} value. If the specified {@code boolean} value # is {@code true}, this method returns {@code Boolean.TRUE}; # if it is {@code false}, this method returns {@code Boolean.FALSE}. # If a new {@code Boolean} instance is not required, this method # should generally be used in preference to the constructor # {@link #Boolean(boolean)}, as this method is likely to yield # significantly better space and time performance. # @param b a boolean value. # @return a {@code Boolean} instance representing {@code b}. # @since 1.4 def value_of(b) return (b ? TRUE : FALSE) end typesig { [String] } # Returns a {@code Boolean} with a value represented by the # specified string. The {@code Boolean} returned represents a # true value if the string argument is not {@code null} # and is equal, ignoring case, to the string {@code "true"}. # @param s a string. # @return the {@code Boolean} value represented by the string. def value_of(s) return to_boolean(s) ? TRUE : FALSE end typesig { [::Java::Boolean] } # Returns a {@code String} object representing the specified # boolean. If the specified boolean is {@code true}, then # the string {@code "true"} will be returned, otherwise the # string {@code "false"} will be returned. # @param b the boolean to be converted # @return the string representation of the specified {@code boolean} # @since 1.4 def to_s(b) return b ? "true" : "false" end } typesig { [] } # Returns a {@code String} object representing this Boolean's # value. If this object represents the value {@code true}, # a string equal to {@code "true"} is returned. Otherwise, a # string equal to {@code "false"} is returned. # @return a string representation of this object. def to_s return @value ? "true" : "false" end typesig { [] } # Returns a hash code for this {@code Boolean} object. # @return the integer {@code 1231} if this object represents # {@code true}; returns the integer {@code 1237} if this # object represents {@code false}. def hash_code return @value ? 1231 : 1237 end typesig { [Object] } # Returns {@code true} if and only if the argument is not # {@code null} and is a {@code Boolean} object that # represents the same {@code boolean} value as this object. # @param obj the object to compare with. # @return {@code true} if the Boolean objects represent the # same value; {@code false} otherwise. def ==(obj) if (obj.is_a?(Boolean)) return (@value).equal?((obj).boolean_value) end return false end class_module.module_eval { typesig { [String] } # Returns {@code true} if and only if the system property # named by the argument exists and is equal to the string # {@code "true"}. (Beginning with version 1.0.2 of the # Java<small><sup>TM</sup></small> platform, the test of # this string is case insensitive.) A system property is accessible # through {@code getProperty}, a method defined by the # {@code System} class. # If there is no property with the specified name, or if the specified # name is empty or null, then {@code false} is returned. # @param name the system property name. # @return the {@code boolean} value of the system property. # @see java.lang.System#getProperty(java.lang.String) # @see java.lang.System#getProperty(java.lang.String, java.lang.String) def get_boolean(name) result = false begin result = to_boolean(System.get_property(name)) rescue <API key> => e rescue <API key> => e end return result end } typesig { [Boolean] } # Compares this {@code Boolean} instance with another. # @param b the {@code Boolean} instance to be compared # @return zero if this object represents the same boolean value as the # argument; a positive value if this object represents true # and the argument represents false; and a negative value if # this object represents false and the argument represents true # @throws <API key> if the argument is {@code null} # @see Comparable # @since 1.5 def compare_to(b) return ((b.attr_value).equal?(@value) ? 0 : (@value ? 1 : -1)) end class_module.module_eval { typesig { [String] } def to_boolean(name) return ((!(name).nil?) && name.equals_ignore_case("true")) end } private alias_method :initialize__boolean, :initialize end end
<?php // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); if(!class_exists('tsmTableData'))require(VMPATH_ADMIN.DS.'helpers'.DS.'tsmtabledata.php'); /** * Currency table class * The class is is used to manage the currencies in the shop. * * @package tsmart * @author RickG, Max Milbers */ class <API key> extends tsmTableData { /** @var int Primary key */ var $<API key> = 0; var $tsmart_hotel_id = 0; var $<API key> = 0; /** * @author Max Milbers * @param JDataBase $db */ function __construct(&$db) { $keys=(object)array( '<API key>','tsmart_hotel_id','<API key>' ); parent::__construct('#<API key>', 'id', $db); } function check(){ //$this->checkCurrencySymbol(); return parent::check(); } /** * ATM Unused ! * Checks a departure symbol wether it is a HTML entity. * When not and $convertToEntity is true, it converts the symbol * Seems not be used ATTENTION seems BROKEN, working only for euro, ... * */ } // pure php no closing tag
<?php \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('adminhtml'); /** @var $category \Magento\Catalog\Model\Category */ $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Category::class); $category->isObjectNew(true); $category->setId(3) ->setName('Category 1') ->setParentId(2) ->setPath('1/2/3') ->setLevel(2) ->setAvailableSortBy('name') ->setDefaultSortBy('name') ->setIsActive(true) ->setPosition(1) ->save(); $urlKeys = ['url-key', 'url-key-1', 'url-key-2', 'url-key-5', 'url-key-1000', 'url-key-999', 'url-key-asdf']; foreach ($urlKeys as $i => $urlKey) { $id = $i + 1; $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( \Magento\Catalog\Model\Product::class ); $product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) ->setStoreId(1) ->setAttributeSetId(4) ->setWebsiteIds([1]) ->setName('Simple Product ' . $id) ->setSku('simple-' . $id) ->setPrice(10) ->setCategoryIds([3]) ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) ->setUrlKey($urlKey)->setUrlPath($urlKey) ->save(); }
#ifndef <API key> #define <API key> #include <TestTeam.hpp> namespace Test { TEST(TEST_CATEGORY, team_for) { TestTeamPolicy<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >::test_for( 0); TestTeamPolicy<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >::test_for( 0); TestTeamPolicy<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >::test_for( 2); TestTeamPolicy<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >::test_for( 2); TestTeamPolicy<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >::test_for( 1000); TestTeamPolicy<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >::test_for( 1000); } TEST(TEST_CATEGORY, team_reduce) { TestTeamPolicy<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >::test_reduce(0); TestTeamPolicy<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >::test_reduce(0); TestTeamPolicy<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >::test_reduce(2); TestTeamPolicy<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >::test_reduce(2); TestTeamPolicy<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >::test_reduce(1000); TestTeamPolicy<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >::test_reduce(1000); } TEST(TEST_CATEGORY, team_broadcast_long) { // FIXME_OPENMPTARGET #ifdef <API key> if constexpr (!std::is_same<TEST_EXECSPACE, Kokkos::Experimental::OpenMPTarget>::value) #endif { TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static>, long>::test_teambroadcast(0, 1); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic>, long>::test_teambroadcast(0, 1); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static>, long>::test_teambroadcast(2, 1); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic>, long>::test_teambroadcast(2, 1); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static>, long>::test_teambroadcast(16, 1); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic>, long>::test_teambroadcast(16, 1); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static>, long>::test_teambroadcast(1000, 1); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic>, long>::test_teambroadcast(1000, 1); } } TEST(TEST_CATEGORY, team_broadcast_char) { // FIXME_OPENMPTARGET #ifdef <API key> if constexpr (!std::is_same<TEST_EXECSPACE, Kokkos::Experimental::OpenMPTarget>::value) #endif { TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static>, unsigned char>::test_teambroadcast(0, 1); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic>, unsigned char>::test_teambroadcast(0, 1); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static>, unsigned char>::test_teambroadcast(2, 1); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic>, unsigned char>::test_teambroadcast(2, 1); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static>, unsigned char>::test_teambroadcast(16, 1); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic>, unsigned char>::test_teambroadcast(16, 1); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static>, long>::test_teambroadcast(1000, 1); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic>, long>::test_teambroadcast(1000, 1); } } TEST(TEST_CATEGORY, <API key>) { // FIXME_OPENMPTARGET #ifdef <API key> if constexpr (!std::is_same<TEST_EXECSPACE, Kokkos::Experimental::OpenMPTarget>::value) #endif { TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static>, float>::test_teambroadcast(0, 1.3); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic>, float>::test_teambroadcast(0, 1.3); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static>, float>::test_teambroadcast(2, 1.3); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic>, float>::test_teambroadcast(2, 1.3); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static>, float>::test_teambroadcast(16, 1.3); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic>, float>::test_teambroadcast(16, 1.3); // FIXME_CUDA #ifdef KOKKOS_ENABLE_CUDA if (!std::is_same<TEST_EXECSPACE, Kokkos::Cuda>::value) #endif // FIXME_HIP #ifdef KOKKOS_ENABLE_HIP if (!std::is_same<TEST_EXECSPACE, Kokkos::Experimental::HIP>::value) #endif { TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static>, float>::test_teambroadcast(1000, 1.3); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic>, float>::test_teambroadcast(1000, 1.3); } } } TEST(TEST_CATEGORY, <API key>) { // FIXME_OPENMPTARGET #ifdef <API key> if constexpr (!std::is_same<TEST_EXECSPACE, Kokkos::Experimental::OpenMPTarget>::value) #endif { TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static>, double>::test_teambroadcast(0, 1.3); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic>, double>::test_teambroadcast(0, 1.3); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static>, double>::test_teambroadcast(2, 1.3); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic>, double>::test_teambroadcast(2, 1.3); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static>, double>::test_teambroadcast(16, 1.3); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic>, double>::test_teambroadcast(16, 1.3); // FIXME_CUDA #ifdef KOKKOS_ENABLE_CUDA if (!std::is_same<TEST_EXECSPACE, Kokkos::Cuda>::value) #endif // FIXME_HIP #ifdef KOKKOS_ENABLE_HIP if (!std::is_same<TEST_EXECSPACE, Kokkos::Experimental::HIP>::value) #endif { TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static>, double>::test_teambroadcast(1000, 1.3); TestTeamBroadcast<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic>, double>::test_teambroadcast(1000, 1.3); } } } } // namespace Test #ifndef <API key> #include <TestTeamVector.hpp> #endif #endif
require([ 'mage/backend/editablemultiselect' ]);