text:
"""
Module of AccessibleDisplayImplementation class.
"""

import re
from hatemile import helper
from hatemile.accessibledisplay import AccessibleDisplay
from hatemile.util.commonfunctions import CommonFunctions
from hatemile.util.configure import Configure
from hatemile.util.idgenerator import IDGenerator
from hatemile.util.html.htmldomparser import HTMLDOMParser

class AccessibleDisplayImplementation(AccessibleDisplay):
    """
    The AccessibleDisplayImplementation class is official implementation of
    :py:class:`hatemile.accessibledisplay.AccessibleDisplay` for screen
    readers.
    """

    #: The id of list element that contains the description of shortcuts,
    #: before the whole content of page.
    ID_CONTAINER_SHORTCUTS_BEFORE = 'container-shortcuts-before'

    #: The id of list element that contains the description of shortcuts, after
    #: the whole content of page.
    ID_CONTAINER_SHORTCUTS_AFTER = 'container-shortcuts-after'

    #: The HTML class of text of description of container of shortcuts
    #: descriptions.
    CLASS_TEXT_SHORTCUTS = 'text-shortcuts'

    #: The HTML class of content to force the screen reader show the current
    #: state of element, before it.
    CLASS_FORCE_READ_BEFORE = 'force-read-before'

    #: The HTML class of content to force the screen reader show the current
    #: state of element, after it.
    CLASS_FORCE_READ_AFTER = 'force-read-after'

    #: The name of attribute that links the description of shortcut of element.
    DATA_ATTRIBUTE_ACCESSKEY_OF = 'data-attributeaccesskeyof'

    #: The name of attribute that links the content of download link.
    DATA_ATTRIBUTE_DOWNLOAD_OF = 'data-attributedownloadof'

    #: The name of attribute that links the content of header cell with the
    #: data cell.
    DATA_ATTRIBUTE_HEADERS_OF = 'data-headersof'

    #: The name of attribute that links the description of language with the
    #: element.
    DATA_ATTRIBUTE_LANGUAGE_OF = 'data-languageof'

    #: The name of attribute that links the content of link that open a new
    #: instance.
    DATA_ATTRIBUTE_TARGET_OF = 'data-attributetargetof'

    #: The name of attribute that links the content of title of element.
    DATA_ATTRIBUTE_TITLE_OF = 'data-attributetitleof'

    #: The name of attribute that links the content of autocomplete state of
    #: field.
    DATA_ARIA_AUTOCOMPLETE_OF = 'data-ariaautocompleteof'

    #: The name of attribute that links the content of busy state of element.
    DATA_ARIA_BUSY_OF = 'data-ariabusyof'

    #: The name of attribute that links the content of checked state field.
    DATA_ARIA_CHECKED_OF = 'data-ariacheckedof'

    #: The name of attribute that links the content of drop effect state of
    #: element.
    DATA_ARIA_DROPEFFECT_OF = 'data-ariadropeffectof'

    #: The name of attribute that links the content of expanded state of
    #: element.
    DATA_ARIA_EXPANDED_OF = 'data-ariaexpandedof'

    #: The name of attribute that links the content of grabbed state of
    #: element.
    DATA_ARIA_GRABBED_OF = 'data-ariagrabbedof'

    #: The name of attribute that links the content that show if the field has
    #: popup.
    DATA_ARIA_HASPOPUP_OF = 'data-ariahaspopupof'

    #: The name of attribute that links the content of level state of element.
    DATA_ARIA_LEVEL_OF = 'data-arialevelof'

    #: The name of attribute that links the content of orientation state of
    #: element.
    DATA_ARIA_ORIENTATION_OF = 'data-ariaorientationof'

    #: The name of attribute that links the content of pressed state of field.
    DATA_ARIA_PRESSED_OF = 'data-ariapressedof'

    #: The name of attribute that links the content of minimum range state of
    #: field.
    DATA_ARIA_RANGE_MIN_OF = 'data-attributevalueminof'

    #: The name of attribute that links the content of maximum range state of
    #: field.
    DATA_ARIA_RANGE_MAX_OF = 'data-attributevaluemaxof'

    #: The name of attribute that links the content of required state of field.
    DATA_ARIA_REQUIRED_OF = 'data-attributerequiredof'

    #: The name of attribute that links the content of selected state of field.
    DATA_ARIA_SELECTED_OF = 'data-ariaselectedof'

    #: The name of attribute that links the content of sort state of element.
    DATA_ARIA_SORT_OF = 'data-ariasortof'

    #: The name of attribute that links the content of role of element with the
    #: element.
    DATA_ROLE_OF = 'data-roleof'

    def __init__(self, parser, configure, user_agent=None):
        """
        Initializes a new object that manipulate the display for screen readers
        of parser.

        :param parser: The HTML parser.
        :type parser: hatemile.util.html.htmldomparser.HTMLDOMParser
        :param configure: The configuration of HaTeMiLe.
        :type configure: hatemile.util.configure.Configure
        :param user_agent: The user agent of the user.
        :type user_agent: str
        """

        helper.require_not_none(parser, configure)
        helper.require_valid_type(parser, HTMLDOMParser)
        helper.require_valid_type(configure, Configure)
        helper.require_valid_type(user_agent, str)

        self.parser = parser
        self.configure = configure
        self.id_generator = IDGenerator('display')
        self.shortcut_prefix = self._get_shortcut_prefix(
            user_agent,
            configure.get_parameter('attribute-accesskey-default')
        )
        self.attribute_accesskey_before = configure.get_parameter(
            'attribute-accesskey-before'
        )
        self.attribute_accesskey_after = configure.get_parameter(
            'attribute-accesskey-after'
        )
        self.attribute_accesskey_prefix_before = configure.get_parameter(
            'attribute-accesskey-prefix-before'
        )
        self.attribute_accesskey_suffix_before = configure.get_parameter(
            'attribute-accesskey-suffix-before'
        )
        self.attribute_accesskey_prefix_after = configure.get_parameter(
            'attribute-accesskey-prefix-after'
        )
        self.attribute_accesskey_suffix_after = configure.get_parameter(
            'attribute-accesskey-suffix-after'
        )
        self.attribute_download_before = configure.get_parameter(
            'attribute-download-before'
        )
        self.attribute_download_after = configure.get_parameter(
            'attribute-download-after'
        )
        self.attribute_headers_prefix_before = configure.get_parameter(
            'attribute-headers-prefix-before'
        )
        self.attribute_headers_suffix_before = configure.get_parameter(
            'attribute-headers-suffix-before'
        )
        self.attribute_headers_prefix_after = configure.get_parameter(
            'attribute-headers-prefix-after'
        )
        self.attribute_headers_suffix_after = configure.get_parameter(
            'attribute-headers-suffix-after'
        )
        self.attribute_language_prefix_before = configure.get_parameter(
            'attribute-language-prefix-before'
        )
        self.attribute_language_suffix_before = configure.get_parameter(
            'attribute-language-suffix-before'
        )
        self.attribute_language_prefix_after = configure.get_parameter(
            'attribute-language-prefix-after'
        )
        self.attribute_language_suffix_after = configure.get_parameter(
            'attribute-language-suffix-after'
        )
        self.attribute_role_prefix_before = configure.get_parameter(
            'attribute-role-prefix-before'
        )
        self.attribute_role_suffix_before = configure.get_parameter(
            'attribute-role-suffix-before'
        )
        self.attribute_role_prefix_after = configure.get_parameter(
            'attribute-role-prefix-after'
        )
        self.attribute_role_suffix_after = configure.get_parameter(
            'attribute-role-suffix-after'
        )
        self.attribute_target_blank_before = configure.get_parameter(
            'attribute-target-blank-before'
        )
        self.attribute_target_blank_after = configure.get_parameter(
            'attribute-target-blank-after'
        )
        self.attribute_title_prefix_before = configure.get_parameter(
            'attribute-title-prefix-before'
        )
        self.attribute_title_suffix_before = configure.get_parameter(
            'attribute-title-suffix-before'
        )
        self.attribute_title_prefix_after = configure.get_parameter(
            'attribute-title-prefix-after'
        )
        self.attribute_title_suffix_after = configure.get_parameter(
            'attribute-title-suffix-after'
        )
        self.aria_autocomplete_both_before = configure.get_parameter(
            'aria-autocomplete-both-before'
        )
        self.aria_autocomplete_both_after = configure.get_parameter(
            'aria-autocomplete-both-after'
        )
        self.aria_autocomplete_inline_before = configure.get_parameter(
            'aria-autocomplete-inline-before'
        )
        self.aria_autocomplete_inline_after = configure.get_parameter(
            'aria-autocomplete-inline-after'
        )
        self.aria_autocomplete_list_before = configure.get_parameter(
            'aria-autocomplete-list-before'
        )
        self.aria_autocomplete_list_after = configure.get_parameter(
            'aria-autocomplete-list-after'
        )
        self.aria_busy_true_before = configure.get_parameter(
            'aria-busy-true-before'
        )
        self.aria_busy_true_after = configure.get_parameter(
            'aria-busy-true-after'
        )
        self.aria_checked_false_before = configure.get_parameter(
            'aria-checked-false-before'
        )
        self.aria_checked_false_after = configure.get_parameter(
            'aria-checked-false-after'
        )
        self.aria_checked_mixed_before = configure.get_parameter(
            'aria-checked-mixed-before'
        )
        self.aria_checked_mixed_after = configure.get_parameter(
            'aria-checked-mixed-after'
        )
        self.aria_checked_true_before = configure.get_parameter(
            'aria-checked-true-before'
        )
        self.aria_checked_true_after = configure.get_parameter(
            'aria-checked-true-after'
        )
        self.aria_dropeffect_copy_before = configure.get_parameter(
            'aria-dropeffect-copy-before'
        )
        self.aria_dropeffect_copy_after = configure.get_parameter(
            'aria-dropeffect-copy-after'
        )
        self.aria_dropeffect_execute_before = configure.get_parameter(
            'aria-dropeffect-execute-before'
        )
        self.aria_dropeffect_execute_after = configure.get_parameter(
            'aria-dropeffect-execute-after'
        )
        self.aria_dropeffect_link_before = configure.get_parameter(
            'aria-dropeffect-link-before'
        )
        self.aria_dropeffect_link_after = configure.get_parameter(
            'aria-dropeffect-link-after'
        )
        self.aria_dropeffect_move_before = configure.get_parameter(
            'aria-dropeffect-move-before'
        )
        self.aria_dropeffect_move_after = configure.get_parameter(
            'aria-dropeffect-move-after'
        )
        self.aria_dropeffect_popup_before = configure.get_parameter(
            'aria-dropeffect-popup-before'
        )
        self.aria_dropeffect_popup_after = configure.get_parameter(
            'aria-dropeffect-popup-after'
        )
        self.aria_expanded_false_before = configure.get_parameter(
            'aria-expanded-false-before'
        )
        self.aria_expanded_false_after = configure.get_parameter(
            'aria-expanded-false-after'
        )
        self.aria_expanded_true_before = configure.get_parameter(
            'aria-expanded-true-before'
        )
        self.aria_expanded_true_after = configure.get_parameter(
            'aria-expanded-true-after'
        )
        self.aria_grabbed_false_before = configure.get_parameter(
            'aria-grabbed-false-before'
        )
        self.aria_grabbed_false_after = configure.get_parameter(
            'aria-grabbed-false-after'
        )
        self.aria_grabbed_true_before = configure.get_parameter(
            'aria-grabbed-true-before'
        )
        self.aria_grabbed_true_after = configure.get_parameter(
            'aria-grabbed-true-after'
        )
        self.aria_haspopup_true_before = configure.get_parameter(
            'aria-haspopup-true-before'
        )
        self.aria_haspopup_true_after = configure.get_parameter(
            'aria-haspopup-true-after'
        )
        self.aria_level_prefix_before = configure.get_parameter(
            'aria-level-prefix-before'
        )
        self.aria_level_suffix_before = configure.get_parameter(
            'aria-level-suffix-before'
        )
        self.aria_level_prefix_after = configure.get_parameter(
            'aria-level-prefix-after'
        )
        self.aria_level_suffix_after = configure.get_parameter(
            'aria-level-suffix-after'
        )
        self.aria_value_maximum_prefix_before = configure.get_parameter(
            'aria-value-maximum-prefix-before'
        )
        self.aria_value_maximum_suffix_before = configure.get_parameter(
            'aria-value-maximum-suffix-before'
        )
        self.aria_value_maximum_prefix_after = configure.get_parameter(
            'aria-value-maximum-prefix-after'
        )
        self.aria_value_maximum_suffix_after = configure.get_parameter(
            'aria-value-maximum-suffix-after'
        )
        self.aria_value_minimum_prefix_before = configure.get_parameter(
            'aria-value-minimum-prefix-before'
        )
        self.aria_value_minimum_suffix_before = configure.get_parameter(
            'aria-value-minimum-suffix-before'
        )
        self.aria_value_minimum_prefix_after = configure.get_parameter(
            'aria-value-minimum-prefix-after'
        )
        self.aria_value_minimum_suffix_after = configure.get_parameter(
            'aria-value-minimum-suffix-after'
        )
        self.aria_orientation_horizontal_before = configure.get_parameter(
            'aria-orientation-horizontal-before'
        )
        self.aria_orientation_horizontal_after = configure.get_parameter(
            'aria-orientation-horizontal-after'
        )
        self.aria_orientation_vertical_before = configure.get_parameter(
            'aria-orientation-vertical-before'
        )
        self.aria_orientation_vertical_after = configure.get_parameter(
            'aria-orientation-vertical-after'
        )
        self.aria_pressed_false_before = configure.get_parameter(
            'aria-pressed-false-before'
        )
        self.aria_pressed_false_after = configure.get_parameter(
            'aria-pressed-false-after'
        )
        self.aria_pressed_mixed_before = configure.get_parameter(
            'aria-pressed-mixed-before'
        )
        self.aria_pressed_mixed_after = configure.get_parameter(
            'aria-pressed-mixed-after'
        )
        self.aria_pressed_true_before = configure.get_parameter(
            'aria-pressed-true-before'
        )
        self.aria_pressed_true_after = configure.get_parameter(
            'aria-pressed-true-after'
        )
        self.aria_required_true_before = configure.get_parameter(
            'aria-required-true-before'
        )
        self.aria_required_true_after = configure.get_parameter(
            'aria-required-true-after'
        )
        self.aria_selected_false_before = configure.get_parameter(
            'aria-selected-false-before'
        )
        self.aria_selected_false_after = configure.get_parameter(
            'aria-selected-false-after'
        )
        self.aria_selected_true_before = configure.get_parameter(
            'aria-selected-true-before'
        )
        self.aria_selected_true_after = configure.get_parameter(
            'aria-selected-true-after'
        )
        self.aria_sort_ascending_before = configure.get_parameter(
            'aria-sort-ascending-before'
        )
        self.aria_sort_ascending_after = configure.get_parameter(
            'aria-sort-ascending-after'
        )
        self.aria_sort_descending_before = configure.get_parameter(
            'aria-sort-descending-before'
        )
        self.aria_sort_descending_after = configure.get_parameter(
            'aria-sort-descending-after'
        )
        self.aria_sort_other_before = configure.get_parameter(
            'aria-sort-other-before'
        )
        self.aria_sort_other_after = configure.get_parameter(
            'aria-sort-other-after'
        )
        self.list_shortcuts_added = False
        self.list_shortcuts_before = None
        self.list_shortcuts_after = None

    def _get_shortcut_prefix(self, user_agent, standart_prefix):
        """
        Returns the shortcut prefix of browser.

        :param user_agent: The user agent of browser.
        :type user_agent: str
        :param standart_prefix: The default prefix.
        :type standart_prefix: str
        :return: The shortcut prefix of browser.
        :rtype: str
        """
        # pylint: disable=no-self-use

        if user_agent is not None:
            user_agent = user_agent.lower()
            opera = 'opera' in user_agent
            mac = 'mac' in user_agent
            konqueror = 'konqueror' in user_agent
            spoofer = 'spoofer' in user_agent
            safari = 'applewebkit' in user_agent
            windows = 'windows' in user_agent
            chrome = 'chrome' in user_agent
            firefox = (
                ('firefox' in user_agent)
                or ('minefield' in user_agent)
            )
            internet_explorer = (
                ('msie' in user_agent)
                or ('trident' in user_agent)
            )

            if opera:
                return 'SHIFT + ESC'
            elif chrome and mac and (not spoofer):
                return 'CTRL + OPTION'
            elif safari and (not windows) and (not spoofer):
                return 'CTRL + ALT'
            elif (not windows) and (safari or mac or konqueror):
                return 'CTRL'
            elif firefox:
                return 'ALT + SHIFT'
            elif chrome or internet_explorer:
                return 'ALT'
            return standart_prefix
        return standart_prefix

    def _get_role_description(self, role):
        """
        Returns the description of role.

        :param role: The role.
        :type role: str
        :return: The description of role.
        :rtype: str
        """

        parameter = 'role-' + role.lower()
        if self.configure.has_parameter(parameter):
            return self.configure.get_parameter(parameter)
        return None

    def _get_language_description(self, language_code):
        """
        Returns the description of language.

        :param language_code: The BCP 47 code language.
        :type language_code: str
        :return: The description of language.
        :rtype: str
        """

        language = language_code.lower()
        parameter = 'language-' + language
        if self.configure.has_parameter(parameter):
            return self.configure.get_parameter(parameter)
        elif '-' in language:
            codes = re.split(r'\-', language)
            parameter = 'language-' + codes[0]
            if self.configure.has_parameter(parameter):
                return self.configure.get_parameter(parameter)
        return None

    def _get_description(self, element):
        """
        Returns the description of element.

        :param element: The element.
        :type element: hatemile.util.html.htmldomelement.HTMLDOMElement
        :return: The description of element.
        :rtype: str
        """

        description = None
        if element.has_attribute('title'):
            description = element.get_attribute('title')
        elif element.has_attribute('aria-label'):
            description = element.get_attribute('aria-label')
        elif element.has_attribute('alt'):
            description = element.get_attribute('alt')
        elif element.has_attribute('label'):
            description = element.get_attribute('label')
        elif (
            (element.has_attribute('aria-labelledby'))
            or (element.has_attribute('aria-describedby'))
        ):
            if element.has_attribute('aria-labelledby'):
                description_ids = re.split(
                    '[ \n\r\t]+',
                    element.get_attribute('aria-labelledby').strip()
                )
            else:
                description_ids = re.split(
                    '[ \n\r\t]+',
                    element.get_attribute('aria-describedby').strip()
                )
            for description_id in description_ids:
                element_description = self.parser.find(
                    '#' + description_id
                ).first_result()
                if element_description is not None:
                    description = element_description.get_text_content()
                    break
        elif (
            (element.get_tag_name() == 'INPUT')
            and (element.has_attribute('type'))
        ):
            type_attribute = element.get_attribute('type').lower()
            if (
                (
                    (type_attribute == 'button')
                    or (type_attribute == 'submit')
                    or (type_attribute == 'reset')
                )
                and (element.has_attribute('value'))
            ):
                description = element.get_attribute('value')
        if not bool(description):
            description = element.get_text_content()
        return re.sub('[ \n\r\t]+', ' ', description.strip())

    def _generate_list_shortcuts(self):
        """
        Generate the list of shortcuts of page.
        """

        id_container_shortcuts_before = (
            AccessibleDisplayImplementation.ID_CONTAINER_SHORTCUTS_BEFORE
        )
        id_container_shortcuts_after = (
            AccessibleDisplayImplementation.ID_CONTAINER_SHORTCUTS_AFTER
        )
        local = self.parser.find('body').first_result()
        if local is not None:
            container_before = self.parser.find(
                '#'
                + id_container_shortcuts_before
            ).first_result()
            if (
                (container_before is None)
                and (self.attribute_accesskey_before)
            ):
                container_before = self.parser.create_element('div')
                container_before.set_attribute(
                    'id',
                    id_container_shortcuts_before
                )

                text_container_before = self.parser.create_element('span')
                text_container_before.set_attribute(
                    'class',
                    AccessibleDisplayImplementation.CLASS_TEXT_SHORTCUTS
                )
                text_container_before.append_text(
                    self.attribute_accesskey_before
                )

                container_before.append_element(text_container_before)
                local.prepend_element(container_before)
            if container_before is not None:
                self.list_shortcuts_before = self.parser.find(
                    container_before
                ).find_children('ul').first_result()
                if self.list_shortcuts_before is None:
                    self.list_shortcuts_before = self.parser.create_element(
                        'ul'
                    )
                    container_before.append_element(self.list_shortcuts_before)

            container_after = self.parser.find(
                '#'
                + id_container_shortcuts_after
            ).first_result()
            if (
                (container_after is None)
                and (self.attribute_accesskey_after)
            ):
                container_after = self.parser.create_element('div')
                container_after.set_attribute(
                    'id',
                    id_container_shortcuts_after
                )

                text_container_after = self.parser.create_element('span')
                text_container_after.set_attribute(
                    'class',
                    AccessibleDisplayImplementation.CLASS_TEXT_SHORTCUTS
                )
                text_container_after.append_text(
                    self.attribute_accesskey_after
                )

                container_after.append_element(text_container_after)
                local.append_element(container_after)
            if container_after is not None:
                self.list_shortcuts_after = self.parser.find(
                    container_after
                ).find_children('ul').first_result()
                if self.list_shortcuts_after is None:
                    self.list_shortcuts_after = self.parser.create_element(
                        'ul'
                    )
                    container_after.append_element(self.list_shortcuts_after)
        self.list_shortcuts_added = True

    def _insert(self, element, new_element, before):
        """
        Insert a element before or after other element.

        :param element: The reference element.
        :type element: hatemile.util.html.htmldomelement.HTMLDOMElement
        :param new_element: The element that be inserted.
        :type new_element: hatemile.util.html.htmldomelement.HTMLDOMElement
        :param before: To insert the element before the other element.
        :type before: bool
        """

        tag_name = element.get_tag_name()
        append_tags = [
            'BODY',
            'A',
            'FIGCAPTION',
            'LI',
            'DT',
            'DD',
            'LABEL',
            'OPTION',
            'TD',
            'TH'
        ]
        controls = ['INPUT', 'SELECT', 'TEXTAREA']
        if tag_name == 'HTML':
            body = self.parser.find('body').first_result()
            if body is not None:
                self._insert(body, new_element, before)
        elif tag_name in append_tags:
            if before:
                element.prepend_element(new_element)
            else:
                element.append_element(new_element)
        elif tag_name in controls:
            labels = []
            if element.has_attribute('id'):
                labels = self.parser.find(
                    'label[for="'
                    + element.get_attribute('id')
                    + '"]'
                ).list_results()
            if not labels:
                labels = self.parser.find(element).find_ancestors(
                    'label'
                ).list_results()
            for label in labels:
                self._insert(label, new_element, before)
        elif before:
            element.insert_before(new_element)
        else:
            element.insert_after(new_element)

    def _force_read_simple(self, element, text_before, text_after, data_of):
        """
        Force the screen reader display an information of element.

        :param element: The reference element.
        :type element: hatemile.util.html.htmldomelement.HTMLDOMElement
        :param text_before: The text content to show before the element.
        :type text_before: str
        :param text_after: The text content to show after the element.
        :type text_after: str
        :param data_of: The name of attribute that links the content with
                        element.
        :type data_of: str
        """

        self.id_generator.generate_id(element)
        identifier = element.get_attribute('id')
        selector = '[' + data_of + '="' + identifier + '"]'

        reference_before = self.parser.find(
            '.'
            + AccessibleDisplayImplementation.CLASS_FORCE_READ_BEFORE
            + selector
        ).first_result()
        reference_after = self.parser.find(
            '.'
            + AccessibleDisplayImplementation.CLASS_FORCE_READ_AFTER
            + selector
        ).first_result()
        references = self.parser.find(selector).list_results()
        if reference_before in references:
            references.remove(reference_before)
        if reference_after in references:
            references.remove(reference_after)

        if not references:
            if text_before:
                if reference_before is not None:
                    reference_before.remove_node()

                span = self.parser.create_element('span')
                span.set_attribute(
                    'class',
                    AccessibleDisplayImplementation.CLASS_FORCE_READ_BEFORE
                )
                span.set_attribute(data_of, identifier)
                span.append_text(text_before)
                self._insert(element, span, True)
            if text_after:
                if reference_after is not None:
                    reference_after.remove_node()

                span = self.parser.create_element('span')
                span.set_attribute(
                    'class',
                    AccessibleDisplayImplementation.CLASS_FORCE_READ_AFTER
                )
                span.set_attribute(data_of, identifier)
                span.append_text(text_after)
                self._insert(element, span, False)

    def _force_read(
        self,
        element,
        value,
        text_prefix_before,
        text_suffix_before,
        text_prefix_after,
        text_suffix_after,
        data_of
    ):
        """
        Force the screen reader display an information of element with prefixes
        or suffixes.

        :param element: The reference element.
        :type element: hatemile.util.html.htmldomelement.HTMLDOMElement
        :param value: The value to be show.
        :type value: str
        :param text_prefix_before: The prefix of value to show before the
                                   element.
        :type text_prefix_before: str
        :param text_suffix_before: The suffix of value to show before the
                                   element.
        :type text_suffix_before: str
        :param text_prefix_after: The prefix of value to show after the
                                  element.
        :type text_prefix_after: str
        :param text_suffix_after: The suffix of value to show after the
                                  element.
        :type text_suffix_after: str
        :param data_of: The name of attribute that links the content with
                        element.
        :type data_of: str
        """

        if (text_prefix_before) or (text_suffix_before):
            text_before = text_prefix_before + value + text_suffix_before
        else:
            text_before = ''
        if (text_prefix_after) or (text_suffix_after):
            text_after = text_prefix_after + value + text_suffix_after
        else:
            text_after = ''
        self._force_read_simple(element, text_before, text_after, data_of)

    def display_shortcut(self, element):
        data_attribute_accesskey_of = (
            AccessibleDisplayImplementation.DATA_ATTRIBUTE_ACCESSKEY_OF
        )
        if element.has_attribute('accesskey'):
            description = self._get_description(element)
            if not element.has_attribute('title'):
                element.set_attribute('title', description)
                self.id_generator.generate_id(element)
                element.set_attribute(
                    AccessibleDisplayImplementation.DATA_ATTRIBUTE_TITLE_OF,
                    element.get_attribute('id')
                )

            if not self.list_shortcuts_added:
                self._generate_list_shortcuts()

            keys = re.split(
                '[ \n\t\r]+',
                element.get_attribute('accesskey').upper()
            )
            for key in keys:
                shortcut = self.shortcut_prefix + ' + ' + key
                self._force_read(
                    element,
                    shortcut,
                    self.attribute_accesskey_prefix_before,
                    self.attribute_accesskey_suffix_before,
                    self.attribute_accesskey_prefix_after,
                    self.attribute_accesskey_suffix_after,
                    data_attribute_accesskey_of
                )

                item = self.parser.create_element('li')
                item.set_attribute(data_attribute_accesskey_of, key)
                item.append_text(shortcut + ': ' + description)

                selector = (
                    '['
                    + data_attribute_accesskey_of
                    + '="'
                    + key
                    + '"]'
                )
                if (
                    (self.list_shortcuts_before is not None)
                    and (
                        self.parser.find(
                            self.list_shortcuts_before
                        ).find_children(selector).first_result() is None
                    )
                ):
                    self.list_shortcuts_before.append_element(
                        item.clone_element()
                    )
                if (
                    (self.list_shortcuts_after)
                    and (
                        self.parser.find(
                            self.list_shortcuts_after
                        ).find_children(selector).first_result() is None
                    )
                ):
                    self.list_shortcuts_after.append_element(
                        item.clone_element()
                    )

    def display_all_shortcuts(self):
        elements = self.parser.find('[accesskey]').list_results()
        for element in elements:
            if CommonFunctions.is_valid_element(element):
                self.display_shortcut(element)

    def display_role(self, element):
        if element.has_attribute('role'):
            role_description = self._get_role_description(
                element.get_attribute('role')
            )
            if role_description is not None:
                self._force_read(
                    element,
                    role_description,
                    self.attribute_role_prefix_before,
                    self.attribute_role_suffix_before,
                    self.attribute_role_prefix_after,
                    self.attribute_role_suffix_after,
                    AccessibleDisplayImplementation.DATA_ROLE_OF
                )

    def display_all_roles(self):
        elements = self.parser.find('[role]').list_results()
        for element in elements:
            if CommonFunctions.is_valid_element(element):
                self.display_role(element)

    def display_cell_header(self, table_cell):
        if table_cell.has_attribute('headers'):
            text_header = ''
            ids_headers = re.split(
                '[ \n\t\r]+',
                table_cell.get_attribute('headers')
            )
            for id_header in ids_headers:
                header = self.parser.find('#' + id_header).first_result()
                if header is not None:
                    if text_header == '':
                        text_header = header.get_text_content().strip()
                    else:
                        text_header = (
                            text_header
                            + ' '
                            + header.get_text_content().strip()
                        )
            if text_header.strip() != '':
                self._force_read(
                    table_cell,
                    text_header,
                    self.attribute_headers_prefix_before,
                    self.attribute_headers_suffix_before,
                    self.attribute_headers_prefix_after,
                    self.attribute_headers_suffix_after,
                    AccessibleDisplayImplementation.DATA_ATTRIBUTE_HEADERS_OF
                )

    def display_all_cell_headers(self):
        elements = self.parser.find('td[headers],th[headers]').list_results()
        for element in elements:
            if CommonFunctions.is_valid_element(element):
                self.display_cell_header(element)

    def display_waiaria_states(self, element):
        if (
            (element.has_attribute('aria-busy'))
            and (element.get_attribute('aria-busy') == 'true')
        ):
            self._force_read_simple(
                element,
                self.aria_busy_true_before,
                self.aria_busy_true_after,
                AccessibleDisplayImplementation.DATA_ARIA_BUSY_OF
            )
        if element.has_attribute('aria-checked'):
            attribute_value = element.get_attribute('aria-checked')
            if attribute_value == 'true':
                self._force_read_simple(
                    element,
                    self.aria_checked_true_before,
                    self.aria_checked_true_after,
                    AccessibleDisplayImplementation.DATA_ARIA_CHECKED_OF
                )
            elif attribute_value == 'false':
                self._force_read_simple(
                    element,
                    self.aria_checked_false_before,
                    self.aria_checked_false_after,
                    AccessibleDisplayImplementation.DATA_ARIA_CHECKED_OF
                )
            elif attribute_value == 'mixed':
                self._force_read_simple(
                    element,
                    self.aria_checked_mixed_before,
                    self.aria_checked_mixed_after,
                    AccessibleDisplayImplementation.DATA_ARIA_CHECKED_OF
                )
        if element.has_attribute('aria-expanded'):
            attribute_value = element.get_attribute('aria-expanded')
            if attribute_value == 'true':
                self._force_read_simple(
                    element,
                    self.aria_expanded_true_before,
                    self.aria_expanded_true_after,
                    AccessibleDisplayImplementation.DATA_ARIA_EXPANDED_OF
                )
            elif attribute_value == 'false':
                self._force_read_simple(
                    element,
                    self.aria_expanded_false_before,
                    self.aria_expanded_false_after,
                    AccessibleDisplayImplementation.DATA_ARIA_EXPANDED_OF
                )
        if (
            (element.has_attribute('aria-haspopup'))
            and (element.get_attribute('aria-haspopup') == 'true')
        ):
            self._force_read_simple(
                element,
                self.aria_haspopup_true_before,
                self.aria_haspopup_true_after,
                AccessibleDisplayImplementation.DATA_ARIA_HASPOPUP_OF
            )
        if element.has_attribute('aria-level'):
            self._force_read(
                element,
                element.get_attribute('aria-level'),
                self.aria_level_prefix_before,
                self.aria_level_suffix_before,
                self.aria_level_prefix_after,
                self.aria_level_suffix_after,
                AccessibleDisplayImplementation.DATA_ARIA_LEVEL_OF
            )
        if element.has_attribute('aria-orientation'):
            attribute_value = element.get_attribute('aria-orientation')
            if attribute_value == 'vertical':
                self._force_read_simple(
                    element,
                    self.aria_orientation_vertical_before,
                    self.aria_orientation_vertical_after,
                    AccessibleDisplayImplementation.DATA_ARIA_ORIENTATION_OF
                )
            elif attribute_value == 'horizontal':
                self._force_read_simple(
                    element,
                    self.aria_orientation_horizontal_before,
                    self.aria_orientation_horizontal_after,
                    AccessibleDisplayImplementation.DATA_ARIA_ORIENTATION_OF
                )
        if element.has_attribute('aria-pressed'):
            attribute_value = element.get_attribute('aria-pressed')
            if attribute_value == 'true':
                self._force_read_simple(
                    element,
                    self.aria_pressed_true_before,
                    self.aria_pressed_true_after,
                    AccessibleDisplayImplementation.DATA_ARIA_PRESSED_OF
                )
            elif attribute_value == 'false':
                self._force_read_simple(
                    element,
                    self.aria_pressed_false_before,
                    self.aria_pressed_false_after,
                    AccessibleDisplayImplementation.DATA_ARIA_PRESSED_OF
                )
            elif attribute_value == 'mixed':
                self._force_read_simple(
                    element,
                    self.aria_pressed_mixed_before,
                    self.aria_pressed_mixed_after,
                    AccessibleDisplayImplementation.DATA_ARIA_PRESSED_OF
                )
        if element.has_attribute('aria-selected'):
            attribute_value = element.get_attribute('aria-selected')
            if attribute_value == 'true':
                self._force_read_simple(
                    element,
                    self.aria_selected_true_before,
                    self.aria_selected_true_after,
                    AccessibleDisplayImplementation.DATA_ARIA_SELECTED_OF
                )
            elif attribute_value == 'false':
                self._force_read_simple(
                    element,
                    self.aria_selected_false_before,
                    self.aria_selected_false_after,
                    AccessibleDisplayImplementation.DATA_ARIA_SELECTED_OF
                )
        if element.has_attribute('aria-sort'):
            attribute_value = element.get_attribute('aria-sort')
            if attribute_value == 'ascending':
                self._force_read_simple(
                    element,
                    self.aria_sort_ascending_before,
                    self.aria_sort_ascending_after,
                    AccessibleDisplayImplementation.DATA_ARIA_SORT_OF
                )
            elif attribute_value == 'descending':
                self._force_read_simple(
                    element,
                    self.aria_sort_descending_before,
                    self.aria_sort_descending_after,
                    AccessibleDisplayImplementation.DATA_ARIA_SORT_OF
                )
            elif attribute_value == 'other':
                self._force_read_simple(
                    element,
                    self.aria_sort_other_before,
                    self.aria_sort_other_after,
                    AccessibleDisplayImplementation.DATA_ARIA_SORT_OF
                )
        if (
            (element.has_attribute('aria-required'))
            and (element.get_attribute('aria-required') == 'true')
        ):
            self._force_read_simple(
                element,
                self.aria_required_true_before,
                self.aria_required_true_after,
                AccessibleDisplayImplementation.DATA_ARIA_REQUIRED_OF
            )
        if element.has_attribute('aria-valuemin'):
            self._force_read(
                element,
                element.get_attribute('aria-valuemin'),
                self.aria_value_minimum_prefix_before,
                self.aria_value_minimum_suffix_before,
                self.aria_value_minimum_prefix_after,
                self.aria_value_minimum_suffix_after,
                AccessibleDisplayImplementation.DATA_ARIA_RANGE_MIN_OF
            )
        if element.has_attribute('aria-valuemax'):
            self._force_read(
                element,
                element.get_attribute('aria-valuemax'),
                self.aria_value_maximum_prefix_before,
                self.aria_value_maximum_suffix_before,
                self.aria_value_maximum_prefix_after,
                self.aria_value_maximum_suffix_after,
                AccessibleDisplayImplementation.DATA_ARIA_RANGE_MAX_OF
            )
        if element.has_attribute('aria-autocomplete'):
            attribute_value = element.get_attribute('aria-autocomplete')
            if attribute_value == 'both':
                self._force_read_simple(
                    element,
                    self.aria_autocomplete_both_before,
                    self.aria_autocomplete_both_after,
                    AccessibleDisplayImplementation.DATA_ARIA_AUTOCOMPLETE_OF
                )
            elif attribute_value == 'inline':
                self._force_read_simple(
                    element,
                    self.aria_autocomplete_list_before,
                    self.aria_autocomplete_list_after,
                    AccessibleDisplayImplementation.DATA_ARIA_AUTOCOMPLETE_OF
                )
            elif attribute_value == 'list':
                self._force_read_simple(
                    element,
                    self.aria_autocomplete_inline_before,
                    self.aria_autocomplete_inline_after,
                    AccessibleDisplayImplementation.DATA_ARIA_AUTOCOMPLETE_OF
                )
        if element.has_attribute('aria-dropeffect'):
            attribute_value = element.get_attribute('aria-dropeffect')
            if attribute_value == 'copy':
                self._force_read_simple(
                    element,
                    self.aria_dropeffect_copy_before,
                    self.aria_dropeffect_copy_after,
                    AccessibleDisplayImplementation.DATA_ARIA_DROPEFFECT_OF
                )
            elif attribute_value == 'move':
                self._force_read_simple(
                    element,
                    self.aria_dropeffect_move_before,
                    self.aria_dropeffect_move_after,
                    AccessibleDisplayImplementation.DATA_ARIA_DROPEFFECT_OF
                )
            elif attribute_value == 'link':
                self._force_read_simple(
                    element,
                    self.aria_dropeffect_link_before,
                    self.aria_dropeffect_link_after,
                    AccessibleDisplayImplementation.DATA_ARIA_DROPEFFECT_OF
                )
            elif attribute_value == 'execute':
                self._force_read_simple(
                    element,
                    self.aria_dropeffect_execute_before,
                    self.aria_dropeffect_execute_after,
                    AccessibleDisplayImplementation.DATA_ARIA_DROPEFFECT_OF
                )
            elif attribute_value == 'popup':
                self._force_read_simple(
                    element,
                    self.aria_dropeffect_popup_before,
                    self.aria_dropeffect_popup_after,
                    AccessibleDisplayImplementation.DATA_ARIA_DROPEFFECT_OF
                )
        if element.has_attribute('aria-grabbed'):
            attribute_value = element.get_attribute('aria-grabbed')
            if attribute_value == 'true':
                self._force_read_simple(
                    element,
                    self.aria_grabbed_true_before,
                    self.aria_grabbed_true_after,
                    AccessibleDisplayImplementation.DATA_ARIA_GRABBED_OF
                )
            elif attribute_value == 'false':
                self._force_read_simple(
                    element,
                    self.aria_grabbed_false_before,
                    self.aria_grabbed_false_after,
                    AccessibleDisplayImplementation.DATA_ARIA_GRABBED_OF
                )

    def display_all_waiaria_states(self):
        elements = self.parser.find(
            '[aria-busy=true],[aria-checked],[aria-dropeffect],'
            + '[aria-expanded],[aria-grabbed],[aria-haspopup],[aria-level],'
            + '[aria-orientation],[aria-pressed],[aria-selected],[aria-sort],'
            + '[aria-required=true],[aria-valuemin],[aria-valuemax],'
            + '[aria-autocomplete]'
        ).list_results()
        for element in elements:
            if CommonFunctions.is_valid_element(element):
                self.display_waiaria_states(element)

    def display_link_attributes(self, link):
        if link.has_attribute('download'):
            self._force_read_simple(
                link,
                self.attribute_download_before,
                self.attribute_download_after,
                AccessibleDisplayImplementation.DATA_ATTRIBUTE_DOWNLOAD_OF
            )
        if (
            (link.has_attribute('target'))
            and (link.get_attribute('target') == '_blank')
        ):
            self._force_read_simple(
                link,
                self.attribute_target_blank_before,
                self.attribute_target_blank_after,
                AccessibleDisplayImplementation.DATA_ATTRIBUTE_TARGET_OF
            )

    def display_all_links_attributes(self):
        elements = self.parser.find(
            'a[download],a[target="_blank"]'
        ).list_results()
        for element in elements:
            if CommonFunctions.is_valid_element(element):
                self.display_link_attributes(element)

    def display_title(self, element):
        if element.get_tag_name() == 'IMG':
            self.display_alternative_text_image(element)
        elif (
            (element.has_attribute('title'))
            and (element.get_attribute('title'))
        ):
            self._force_read(
                element,
                element.get_attribute('title'),
                self.attribute_title_prefix_before,
                self.attribute_title_suffix_before,
                self.attribute_title_prefix_after,
                self.attribute_title_suffix_after,
                AccessibleDisplayImplementation.DATA_ATTRIBUTE_TITLE_OF
            )

    def display_all_titles(self):
        elements = self.parser.find('body [title]').list_results()
        for element in elements:
            if CommonFunctions.is_valid_element(element):
                self.display_title(element)

    def display_language(self, element):
        language_code = None
        if element.has_attribute('lang'):
            language_code = element.get_attribute('lang')
        elif element.has_attribute('hreflang'):
            language_code = element.get_attribute('hreflang')
        language = self._get_language_description(language_code)
        if language is not None:
            self._force_read(
                element,
                language,
                self.attribute_language_prefix_before,
                self.attribute_language_suffix_before,
                self.attribute_language_prefix_after,
                self.attribute_language_suffix_after,
                AccessibleDisplayImplementation.DATA_ATTRIBUTE_LANGUAGE_OF
            )

    def display_all_languages(self):
        elements = self.parser.find(
            'html[lang],body[lang],body [lang],body [hreflang]'
        ).list_results()
        for element in elements:
            if CommonFunctions.is_valid_element(element):
                self.display_language(element)

    def display_alternative_text_image(self, image):
        if (image.has_attribute('alt')) or (image.has_attribute('title')):
            if (
                (image.has_attribute('alt'))
                and (not image.has_attribute('title'))
            ):
                image.set_attribute('title', image.get_attribute('alt'))
            elif (
                (image.has_attribute('title'))
                and (not image.has_attribute('alt'))
            ):
                image.set_attribute('alt', image.get_attribute('title'))
            self.id_generator.generate_id(image)
            image.set_attribute(
                AccessibleDisplayImplementation.DATA_ATTRIBUTE_TITLE_OF,
                image.get_attribute('id')
            )
        else:
            image.set_attribute('alt', '')
            image.set_attribute('role', 'presentation')
            image.set_attribute('aria-hidden', 'true')

    def display_all_alternative_text_images(self):
        images = self.parser.find('img').list_results()
        for image in images:
            if CommonFunctions.is_valid_element(image):
                self.display_alternative_text_image(image)


text:
package cct.modelling;

import java.util.HashMap;
import java.util.Map;

import cct.interfaces.AtomInterface;
import cct.interfaces.BondInterface;

/**
 *
Title:

 *
 *
Description:

 *
 *
Copyright: Copyright (c) 2004

 *
 *
Company:

 *
 * @author not attributable
 * @version 1.0
 */
public class Bond
    implements BondInterface {

   protected AtomInterface a1, a2;
   Map<String, Object> properties = new HashMap<String, Object> ();

   public Bond() {
      a1 = a2 = null;
   }

   @Override
  public BondInterface getNewBondInstance() {
      return new Bond();
   }

   public Bond(AtomInterface a1, AtomInterface a2) {
      this.a1 = a1;
      this.a2 = a2;

      a1.setBondedTo(a2, true);
      a2.setBondedTo(a1, true);

      a1.setBondIndex(this);
      a2.setBondIndex(this);
   }

   @Override
  public BondInterface getNewBondInstance(AtomInterface a_i, AtomInterface a_j) {
      return new Bond(a_i, a_j);
   }

   @Override
  public BondInterface getNewBondInstance(BondInterface bond) {
      return new Bond(bond);
   }

   public Bond(Bond b) {
      a1 = b.a1;
      a2 = b.a2;
   }

   public Bond(BondInterface b) {
      a1 = b.getIAtomInterface();
      a2 = b.getJAtomInterface();
   }

   @Override
  public float bondLength() {
      return (float) Math.sqrt( (
          (a1.getX() - a2.getX()) * (a1.getX() - a2.getX()) +
          (a1.getY() - a2.getY()) * (a1.getY() - a2.getY()) +
          (a1.getZ() - a2.getZ()) * (a1.getZ() - a2.getZ())));
   }

   public Bond getBond() {
      return this;
   }

   public AtomInterface getI() {
      return a1;
   }

   public AtomInterface getJ() {
      return a2;
   }

   @Override
  public AtomInterface getIAtomInterface() {
      return a1;
   }

   @Override
  public AtomInterface getJAtomInterface() {
      return a2;
   }

   @Override
  public Map<String, Object> getProperties() {
      return properties;
   }

   @Override
  public Object getProperty(String key) {
      return properties.get(key);
   }

   @Override
  public void setProperty(String prop, Object value) {
      properties.put(prop, value);
   }
}

redpajama_set_name: RedPajamaGithub


text:
<?php

namespace swestcott\MonologExtension;

use Symfony\Component\Config\FileLocator,
    Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition,
    Symfony\Component\DependencyInjection\Definition,
    Symfony\Component\DependencyInjection\ContainerBuilder,
    Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

use Behat\Behat\Extension\ExtensionInterface;

class Extension implements ExtensionInterface
{
    public function load(array $config, ContainerBuilder $container)
    {
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.DIRECTORY_SEPARATOR.'services'));
        $loader->load('core.xml');

        if (isset($config['logger_name'])) {
            $container->setParameter('behat.monolog.logger_name', $config['logger_name']);
        }

        $handlers = array();

        foreach ($config['handlers'] as $name => $config) {

            $handlers[] = $name;

            switch ($config['type']) {
                case 'stream':
                    $def = new Definition(
                        'Monolog\Handler\StreamHandler',
                        array(
                            $config['path'],
                            $config['level']
                        )
                    );
                    $def->addTag('behat.monolog.handler.tag');
                    $container->setDefinition($name, $def);
                    break;

                default:
                    throw new \InvalidArgumentException('Invalid or supported handler supplied: "'.$config['type'].'"');
            }
        }

        $container->setParameter('behat.monolog.handlers', $handlers);
    }

    public function getConfig(ArrayNodeDefinition $builder) {
        $builder->
            children()->
                scalarNode('logger_name')->
                    defaultValue('logger')->
                end()->
                arrayNode('handlers')->
                    isRequired()->
                    requiresAtLeastOneElement()->
                    useAttributeAsKey('name')->
                    prototype('array')->
                        children()->
                            scalarNode('type')->
                                isRequired()->
                                cannotBeEmpty()->
                            end()->
                            scalarNode('level')->end()->
                            scalarNode('path')->end()-> // stream
                            // add
                        end()->
                    end()->
                end()->
            end()->
        end();
    }

    public function getCompilerPasses() {
        return array();
    }
}


text:
layout: content
title:  "tcpbridge man page"
categories: tcpreplay wiki
description: "tcpbridge manual"
---

<meta name="generator" content="groff -Thtml, see www.gnu.org">
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta name="Content-Style" content="text/css">

<title>tcpbridge</title>

tcpbridge

名前/NAME

書式/SYNOPSIS

概要/DESCRIPTION

オプション/OPTIONS

OPTION PRESETS

ファイル/FILES

exit コード/EXIT STATUS

AUTHORS/AUTHORS

COPYRIGHT/COPYRIGHT

バグ/BUGS

注意/NOTES

NAME

tcpbridge
− Bridge network traffic across two interfaces

SYNOPSIS

tcpbridge
[−flag [value]]...
[−−opt−name [[=|
]value]]...

All arguments
must be options.

tcpbridge is a
tool for selectively briding network traffic across two
interfaces and optionally modifying the packets in
betweeen

DESCRIPTION

The basic
operation of tcpbridge is to be a network bridge between two
subnets. All packets received on one interface are sent via
the other. Optionally, packets can be edited in a variety of
ways according to your needs. For more details, please see
the Tcpreplay Manual at: http://tcpreplay.appneta.com

OPTIONS

−r
string,
−−portmap=string

Rewrite TCP/UDP ports. This
option may appear up to -1 times.

Specify a list
of comma delimited port mappingings consisting of colon
delimited port number pairs. Each colon delimited port pair
consists of the port to match followed by the port number to
rewrite. Examples:

−-portmap=80:8000 −-portmap=8080:80 #
80->8000 and 8080->80

−-portmap=8000,8080,88888:80 # 3 different ports
become 80

−-portmap=8000-8999:80 # ports 8000 to 8999 become
80

−s number,
−−seed=number

Randomize src/dst IPv4/v6
addresses w/ given seed. This option may appear up to 1
times. This option takes an integer number as its
argument.

Causes the
source and destination IPv4/v6 addresses to be pseudo
randomized but still maintain client/server relationships.
Since the randomization is deterministic based on the seed,
you can reuse the same seed value to recreate the
traffic.

−N string,
−−pnat=string

Rewrite IPv4/v6 addresses using
pseudo-NAT. This option may appear up to 2 times. This
option must not appear in combination with any of the
following options: srcipmap.

Takes a comma
delimited series of colon delimited CIDR netblock pairs.
Each netblock pair is evaluated in order against the IP
addresses. If the IP address in the packet matches the first
netblock, it is rewriten using the second netblock as a mask
against the high order bits. IPv4 Example:

−-pnat=192.168.0.0/16:10.77.0.0/16,172.16.0.0/12:10.1.0.0/24

IPv6 Example:

−-pnat=[2001:db8::/32]:[dead::/16],[2001:db8::/32]:[::ffff:0:0/96]

−S string,
−−srcipmap=string

Rewrite source IPv4/v6
addresses using pseudo-NAT. This option may appear up to 1
times. This option must not appear in combination with any
of the following options: pnat.

Works just like
the −-pnat option, but only affects the source IP
addresses in the IPv4/v6 header.

−D string,
−−dstipmap=string

Rewrite destination IPv4/v6
addresses using pseudo-NAT. This option may appear up to 1
times. This option must not appear in combination with any
of the following options: pnat.

Works just like
the −-pnat option, but only affects the destination IP
addresses in the IPv4/v6 header.

−e string,
−−endpoints=string

Rewrite IP addresses to be
between two endpoints. This option may appear up to 1 times.
This option must appear in combination with the following
options: cachefile.

Takes a pair of
colon delimited IPv4/v6 addresses which will be used to
rewrite all traffic to appear to be between the two IP
addresses. IPv4 Example:

−-endpoints=172.16.0.1:172.16.0.2

IPv6 Example:

−-endpoints=[2001:db8::dead:beef]:[::ffff:0:0:ac:f:0:2]

−b,
-−skipbroadcast

Skip rewriting
broadcast/multicast IPv4/v6 addresses.

By default
−-seed, −-pnat and −-endpoints will
rewrite broadcast and multicast IPv4/v6 and MAC addresses.
Setting this flag will keep broadcast/multicast IPv4/v6 and
MAC addresses from being rewritten.

−C,
-−fixcsum

Force recalculation of
IPv4/TCP/UDP header checksums.

Causes each
IPv4/v6 packet to have their checksums recalcualted and
fixed. Automatically enabled for packets modified with
--seed, --pnat, --endpoints or
--fixlen.

−m number,
−−mtu=number

Override default MTU length
(1500 bytes). This option may appear up to 1 times. This
option takes an integer number as its argument. The value of
number is constrained to being:

in the range 1 through
MAXPACKET

Override the
default 1500 byte MTU size for determining the maximum
padding length (--fixlen=pad) or when truncating
(--mtu-trunc).

−−mtu−trunc

Truncate packets larger then
specified MTU. This option may appear up to 1 times.

Similar to
−-fixlen, this option will truncate data in packets
from Layer 3 and above to be no larger then the MTU.

−E,
-−efcs

Remove Ethernet checksums (FCS)
from end of frames.

Note, this
option is pretty dangerous! We do not actually check to see
if a FCS actually exists in the frame, we just blindly
delete the last 4 bytes. Hence, you should only use this if
you know know that your OS provides the FCS when reading raw
packets.

−−ttl=string

Modify the IPv4/v6 TTL/Hop
Limit.

Allows you to
modify the TTL/Hop Limit of all the IPv4/v6 packets. Specify
a number to hard-code the value or +/-value to increase or
decrease by the value provided (limited to 1-255). Examples:

−-ttl=10

−-ttl=+7

−-ttl=-64

−−tos=number

Set the IPv4 TOS/DiffServ/ECN
byte. This option may appear up to 1 times. This option
takes an integer number as its argument. The value of
number is constrained to being:

in the range 0 through 255

Allows you to
override the TOS (also known as DiffServ/ECN) value in
IPv4.

−−tclass=number

Set the IPv6 Traffic Class
byte. This option may appear up to 1 times. This option
takes an integer number as its argument. The value of
number is constrained to being:

in the range 0 through 255

Allows you to
override the IPv6 Traffic Class field.

−−flowlabel=number

Set the IPv6 Flow Label. This
option may appear up to 1 times. This option takes an
integer number as its argument. The value of number
is constrained to being:

in the range 0 through
1048575

Allows you to
override the 20bit IPv6 Flow Label field. Has no effect on
IPv4 packets.

−F string,
−−fixlen=string

Pad or truncate packet data to
match header length. This option may appear up to 1
times.

Packets may be
truncated during capture if the snaplen is smaller then the
packet. This option allows you to modify the packet to pad
the packet back out to the size stored in the IPv4/v6 header
or rewrite the IP header total length to reflect the stored
packet length.

pad
Truncated packets will be padded out so that the packet
length matches the IPv4 total length

trunc
Truncated packets will have their IPv4 total length field
rewritten to match the actual packet length

del
Delete the packet

−−skipl2broadcast

Skip rewriting
broadcast/multicast Layer 2 addresses.

By default,
editing Layer 2 addresses will rewrite broadcast and
multicast MAC addresses. Setting this flag will keep
broadcast/multicast MAC addresses from being rewritten.

−−dlt=string

Override output DLT
encapsulation. This option may appear up to 1 times.

By default, no
DLT (data link type) conversion will be made. To change the
DLT type of the output pcap, select one of the following
values:

enet
Ethernet aka DLT_EN10MB

hdlc
Cisco HDLC aka DLT_C_HDLC

jnpr_ether
Juniper Ethernet DLT_C_JNPR_ETHER

pppserial
PPP Serial aka DLT_PPP_SERIAL

user
User specified Layer 2 header and DLT type

−−enet−dmac=string

Override destination ethernet
MAC addresses. This option may appear up to 1 times.

Takes a pair of
comma deliminated ethernet MAC addresses which will replace
the destination MAC address of outbound packets. The first
MAC address will be used for the server to client traffic
and the optional second MAC address will be used for the
client to server traffic. Example:

−-enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66

−−enet−smac=string

Override source ethernet MAC
addresses. This option may appear up to 1 times.

Takes a pair of
comma deliminated ethernet MAC addresses which will replace
the source MAC address of outbound packets. The first MAC
address will be used for the server to client traffic and
the optional second MAC address will be used for the client
to server traffic. Example:

−-enet-smac=00:12:13:14:15:16,00:22:33:44:55:66

−−enet−vlan=string

Specify ethernet 802.1q VLAN
tag mode. This option may appear up to 1 times.

Allows you to
rewrite ethernet frames to add a 802.1q header to standard
802.3 ethernet headers or remove the 802.1q VLAN tag
information.

add
Rewrites the existing 802.3 ethernet header as an 802.1q
VLAN header

del
Rewrites the existing 802.1q VLAN header as an 802.3
ethernet header

−−enet−vlan−tag=number

Specify the new ethernet 802.1q
VLAN tag value. This option may appear up to 1 times. This
option must appear in combination with the following
options: enet-vlan. This option takes an integer number as
its argument. The value of number is constrained to
being:

in the range 0 through 4095

−−enet−vlan−cfi=number

Specify the ethernet 802.1q
VLAN CFI value. This option may appear up to 1 times. This
option must appear in combination with the following
options: enet-vlan. This option takes an integer number as
its argument. The value of number is constrained to
being:

in the range 0 through 1

−−enet−vlan−pri=number

Specify the ethernet 802.1q
VLAN priority. This option may appear up to 1 times. This
option must appear in combination with the following
options: enet-vlan. This option takes an integer number as
its argument. The value of number is constrained to
being:

in the range 0 through 7

−−hdlc−control=number

Specify HDLC control value.
This option may appear up to 1 times. This option takes an
integer number as its argument.

The Cisco HDLC
header has a 1 byte "control" field. Apparently
this should always be 0, but if you can use any 1 byte
value.

−−hdlc−address=number

Specify HDLC address. This
option may appear up to 1 times. This option takes an
integer number as its argument.

The Cisco HDLC
header has a 1 byte "address" field which has two
valid values:

0x0F
Unicast

0xBF
Broadcast

You can however specify any single byte value.

−−user−dlt=number

Set output file DLT type. This
option may appear up to 1 times. This option takes an
integer number as its argument.

Set the DLT
value of the output pcap file.

−−user−dlink=string

Rewrite Data-Link layer with
user specified data. This option may appear up to 2
times.

Provide a
series of comma deliminated hex values which will be used to
rewrite or create the Layer 2 header of the packets. The
first instance of this argument will rewrite both server and
client traffic, but if this argument is specified a second
time, it will be used for the client traffic. Example:

−-user-dlink=01,02,03,04,05,06,00,1A,2B,3C,4D,5E,6F,08,00

−d number,
−−dbug=number

Enable debugging output. This
option may appear up to 1 times. This option takes an
integer number as its argument. The value of number
is constrained to being:

in the range 0 through 5

The default number for
this option is:

0

If configured
with −-enable-debug, then you can specify a verbosity
level for debugging output. Higher numbers increase
verbosity.

−i string,
−−intf1=string

Primary interface (listen in
uni-directional mode). This option may appear up to 1
times.

−I string,
−−intf2=string

Secondary interface (send in
uni-directional mode). This option may appear up to 1
times.

−u,
-−unidir

Send and receive in only one
direction. This option may appear up to 1 times.

Normally,
tcpbridge will send and receive traffic in both directions
(bi-directionally). However, if you choose this option,
traffic will be sent uni-directionally.

−−listnics

List available network
interfaces and exit.

−L number,
−−limit=number

Limit the number of packets to
send. This option may appear up to 1 times. This option
takes an integer number as its argument. The value of
number is constrained to being:

greater than or equal to 1

The default number for
this option is:

-1

By default,
tcpbridge will send packets forever or until Ctrl-C.
Alternatively, you can specify a maximum number of packets
to send.

−M string,
−−mac=string

MAC addresses of local
NIC’s. This option may appear up to 2 times.

tcpbridge does
not support detecting the MAC addresses of the local network
interfaces under Windows. Please specify both MAC addresses
of the interfaces used in the bridge: −M <intf1
mac> −M <intf2 mac>

−x string,
−−include=string

Include only packets matching
rule. This option may appear up to 1 times. This option must
not appear in combination with any of the following options:
exclude.

Override
default of sending all packets stored in the capture file
and only send packets which match the provided rule. Rules
can be one of:

S:<CIDR1>,...
- Source IP must match specified CIDR(s)

D:<CIDR1>,...
- Destination IP must match specified CIDR(s)

B:<CIDR1>,...
- Both source and destination IP must match specified
CIDR(s)

E:<CIDR1>,...
- Either IP must match specified CIDR(s)

P:<LIST>
- Must be one of the listed packets where the list
corresponds to the packet number in the capture file.

−-include=P:1-5,9,15,72-

would send packets 1 thru 5, the 9th and 15th packet, and
packets 72 until the end of the file

F:’<bpf>’
- BPF filter. See the tcpdump(8) man page for
syntax.

−X string,
−−exclude=string

Exclude any packet matching
this rule. This option may appear up to 1 times. This option
must not appear in combination with any of the following
options: include.

Override
default of sending all packets stored in the capture file
and only send packets which do not match the provided rule.
Rules can be one of:

S:<CIDR1>,...
- Source IP must not match specified CIDR(s)

D:<CIDR1>,...
- Destination IP must not match specified CIDR(s)

B:<CIDR1>,...
- Both source and destination IP must not match specified
CIDR(s)

E:<CIDR1>,...
- Either IP must not match specified CIDR(s)

P:<LIST>
- Must not be one of the listed packets where the list
corresponds to the packet number in the capture file.

−-exclude=P:1-5,9,15,72-

would drop packets 1 thru 5, the 9th and 15th packet, and
packets 72 until the end of the file

−P,
-−pid

Print the PID of tcpbridge at
startup.

−v,
-−verbose

Print decoded packets via
tcpdump to STDOUT. This option may appear up to 1 times.

−A string,
−−decode=string

Arguments passed to tcpdump
decoder. This option may appear up to 1 times. This option
must appear in combination with the following options:
verbose.

When enabling
verbose mode (-v) you may also specify one or more
additional arguments to pass to tcpdump to modify the
way packets are decoded. By default, −n and −l
are used. Be sure to quote the arguments like:
−-verbose="-axxx" so that they are not
interpreted by tcpbridge. The following arguments are vaild:

[ −aAeNqRStuvxX ]

[ −E spi@ipaddr algo:secret,... ]

[ −s snaplen ]

−V,
-−version

Print version information.

−h,
-−less−help

Display less usage information
and exit.

−H,
−−help

Display usage information and
exit.

−!,
−−more-help

Pass the extended usage
information through a pager.

− [rcfile],
−−save-opts[=rcfile]

Save the option state to
rcfile. The default is the last configuration
file listed in the OPTION PRESETS section, below.

− rcfile,
−−load-opts=rcfile,
−−no-load-opts

Load options from
rcfile. The no-load-opts form will disable the
loading of earlier RC/INI files.
−−no-load-opts is handled early, out of
order.

OPTION PRESETS

Any option that
is not marked as not presettable may be preset by
loading values from configuration ("RC" or
".INI") file(s). The homerc file is
"$$/", unless that is a directory. In that
case, the file ".tcpbridgerc" is searched
for within that directory.

FILES

See OPTION
PRESETS for configuration files.

EXIT STATUS

One of the
following exit values will be returned:

0 (EXIT_SUCCESS)

Successful program
execution.

1 (EXIT_FAILURE)

The operation failed or the
command syntax was not valid.

66 (EX_NOINPUT)

A specified configuration file
could not be loaded.

70 (EX_SOFTWARE)

libopts had an internal
operational error. Please report it to
autogen-users@lists.sourceforge.net. Thank you.

AUTHORS

Copyright
2013-2014 Fred Klassen - AppNeta Inc. Copyright 2000-2012
Aaron Turner For support please use the
tcpreplay-users@lists.sourceforge.net mailing list. The
latest version of this software is always available from:
http://tcpreplay.appneta.com/

COPYRIGHT

Copyright (C)
2000-2014 Aaron Turner and Fred Klassen all rights reserved.
This program is released under the terms of the GNU General
Public License, version 3 or later.

BUGS

Please send bug
reports to: tcpreplay-users@lists.sourceforge.net

NOTES

This manual
page was AutoGen-erated from the tcpbridge
option definitions.


text:
package org.drools.compiler.lang.dsl;

import java.io.IOException;
import java.io.Reader;
import java.util.HashMap;
import java.util.Map;

import org.drools.compiler.lang.Expander;
import org.drools.compiler.lang.ExpanderResolver;

/**
 * The default expander resolver will provide instances of the DefaultExpander.
 * The DefaultExpander uses templates to provide DSL and pseudo
 * natural language support.
 */
public class DefaultExpanderResolver
    implements
    ExpanderResolver {

    private final Map expanders = new HashMap();

    /**
     * Create an empty resolver, which you will then
     * call addExpander multiple times, to map a specific expander
     * with a name that will be found in the drl after the expander keyword.
     */
    public DefaultExpanderResolver() {
    }

    /**
     * This will load up a DSL from the reader specified.
     * This will make the expander available to any parser
     * regardless of name.
     *
     * The DSL expander will be the default expander.
     *
     * This is the constructor most people should use.
     */
    public DefaultExpanderResolver(final Reader reader) throws IOException {
        final DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
        if ( file.parseAndLoad( reader ) ) {
            final Expander expander = new DefaultExpander();
            expander.addDSLMapping( file.getMapping() );
            this.expanders.put( "*",
                                expander );
        } else {
            throw new RuntimeException( "Error parsing and loading DSL file." + file.getErrors() );
        }
    }

    /**
     * Add an expander with the given name, which will be used
     * by looking for the "expander" keyword in the DRL.
     *
     * If a default expander is installed, it will always be returned
     * if none matching the given name can be found.
     *
     * You don't need to use this unless you have multiple expanders/DSLs
     * involved when compiling multiple rule packages at the same time.
     * If you don't know what that sentence means, you probably don't need to use this method.
     */
    public void addExpander(final String name,
                            final Expander expander) {
        this.expanders.put( name,
                            expander );
    }

    public Expander get(final String name,
                        final String config) {
        if ( this.expanders.containsKey( name ) ) {
            return (Expander) this.expanders.get( name );
        } else {
            final Expander exp = (Expander) this.expanders.get( "*" );
            if ( exp == null ) {
                throw new IllegalArgumentException( "Unable to provide an expander for " + name + " or a default expander." );
            }
            return exp;
        }
    }

}


text:
process.on('error', function(err) {
    logger.error("Error fatal");
    //mongoose.disconnect();
});

var logger    = require("./log"),
    mongoose  = require('mongoose'),
    Netmask   = require('netmask').Netmask,
    Enlace    = require("./models/enlace"),
    util      = require("util"),
    sshConn   = require("ssh2"),
    readline  = require("readline"),
    Supernodo = require("./models/supernodo");

var working = new Array();

var conn = 'mongodb://localhost/troncales';
var db = mongoose.connect(conn);
var INTERVAL = process.env.COLLECTD_INTERVAL;

if (!INTERVAL) {
	INTERVAL = 7200;
}

function get_testing_ip(enlace, supernodo) {
    if (enlace.supernodos[0].id == supernodo.id.toString()) {
    	var iface_name = enlace.supernodos[0].iface;
    } else if (enlace.supernodos[1].id == supernodo.id.toString()) {
    	var iface_name = enlace.supernodos[1].iface;
    } else {
        logger.error(util.format("Error finding the neighbout IP from %s to %s.", enlace._id, supernodo.name));
        return;
    }

    var network = new Netmask(enlace.network);
    var interfaces = supernodo.interfaces;
    for (var i=0; i<interfaces.length; i++) {
        var interface = interfaces[i];
        var ip = interface.address.split("/")[0];
        if (interface.name === iface_name && network.contains(ip)) {
            return ip;
        }
    }
}

function bandwidth_test(enlace, s1, s2, cb) {
    if (s1.system == "mikrotik" && s2.system == "mikrotik") {
        bandwidth_test_mikrotik(enlace, s1, s2, cb);
    } else if (s1.system == "openwrt") {
        bandwidth_test_openwrt(enlace, s1, s2, cb);
    } else if (s2.system == "openwrt") {
        bandwidth_test_openwrt(enlace, s2, s1, cb);
    }
}

function bandwidth_test_openwrt(enlace, s1, s2, cb) {
    var c = new sshConn();
    var ip = s1.mainip;
    var username = s1.username;
    var password = s1.password;
    var duration = 20;
    var testip = get_testing_ip(enlace, s2);
    if (testip) {
        c.on("ready", function() {
            c.exec(util.format("/usr/sbin/mikrotik_btest -d both -t %s %s", duration, testip), function(err, stream) {
                logger.debug(util.format("ssh %s /usr/sbin/mikrotik_btest -d both -t %s %s", ip, duration, testip));
                var tx = 0, rx = 0;
                stream.on("data", function(data) {
                    var data = data.toString().trim();
                    var data = data.split("\n");
                    for (l in data) {
                        var line = data[l];
                        if (line.search("Rx:") == 0) {
                            tx = line.split("\t")[1];
                            rx = line.split("\t")[0];
                            tx = tx.replace(/Tx: +/, "");
                            tx = tx.split(" ")[0];
                            rx = rx.replace(/Rx: +/, "");
                            rx = rx.split(" ")[0];
                        }
                    }
                });
                stream.on("exit", function() {
                    tx = parseInt(tx) * 1024 * 1024;
                    rx = parseInt(rx) * 1024 * 1024;
                    console.log(util.format("PUTVAL \"%s/links/bandwidth-%s\" interval=%s N:%s:%s", s1.name, s2.name, INTERVAL, tx, rx));
                    logger.debug(util.format("PUTVAL \"%s/links/bandwidth-%s\" interval=%s N:%s:%s", s1.name, s2.name, INTERVAL, tx, rx));
                    cb(enlace.id);
                    c.end();
                });
            });
        });

        c.on("error", function(err) {
            logger.error(util.format("Error connecting %s %s", ip, err));
            cb(enlace.id);
        });

        c.connect({
            host: ip,
            port: 22,
            username: username,
            password: password || "-"
        });
    } else {
        logger.error(util.format("Link not found: %s %s", ip, enlace.id));
        cb(enlace.id);
    }
}

function bandwidth_test_mikrotik(enlace, s1, s2, cb) {
    var c = new sshConn();
    var ip = s1.mainip;
    var username = s1.username;
    var password = s1.password;
    var username2 = s2.username;
    var password2 = s2.password;
    var interval = 5;
    var duration = 19;
    var testip = get_testing_ip(enlace, s2);

    if (testip) {
        c.on("ready", function() {
            c.exec(util.format(":global ip; :global username; :global password; :global interval; :global duration; :set ip %s; :set username %s; :set password %s; :set interval %s; :set duration %s; /system script run bandwidth", testip, username2, password2, interval, duration), function(err, stream) {
                logger.debug(util.format(":global ip; :global username; :global password; :global interval; :global duration; :set ip %s; :set username %s; :set password %s; :set interval %s; :set duration %s; /system script run bandwidth", testip, username2, password2, interval, duration));
                if (err) {
                        logger.debug(util.format("Error on bandwidth from %s to %s.", ip, testip));
		        cb(enlace.id);
	        } else {
                    stream.on("data", function(data) {
                        var data = data.toString().trim();
                        if (data.search("tx:") != -1) {
                            var tx = 0, rx = 0;
                            tx = data.split(" ")[0].replace("tx:", "");
                            rx = data.split(" ")[1].replace("rx:", "");
                            console.log(util.format("PUTVAL \"%s/links/bandwidth-%s\" interval=%s N:%s:%s", s1.name, s2.name, INTERVAL, tx, rx));
                            logger.debug(util.format("PUTVAL \"%s/links/bandwidth-%s\" interval=%s N:%s:%s", s1.name, s2.name, INTERVAL, tx, rx));
                        }
                    });
                    stream.on("exit", function() {
                        cb(enlace.id);
                        c.end();
                    });
                }
            });
        });

        c.on("error", function(err) {
            logger.error(util.format("Error connecting %s %s", ip, err));
            cb(enlace.id);
        });

        c.connect({
            host: ip,
            port: 22,
            username: username,
            password: password || "-"
        });
    } else {
        logger.error(util.format("Link not found: %s %s", ip, enlace.id));
        cb(enlace.id);
    }
}

function monitor_link(enlace, countdown_and_exit) {
    var s1 = enlace.supernodos[0].id;
    var s2 = enlace.supernodos[1].id;

    Supernodo.count({ _id: { $in: [ s1, s2 ] } }, function(err, count) {
        if (count != 2) {
            logger.error(util.format("Invalid link: %s %s %s", enlace.id, s1, s2));
            countdown_and_exit(enlace.id);
        } else {
            Supernodo.find({ _id: { $in: [ s1, s2 ] } }, function(err, supernodos) {
                var s1 = supernodos[0];
                var s2 = supernodos[1];

                var time = 45000;
                if (working.length == 0) {
                    working[0] = new Array();
                }
                var found = false;
                for (var index in working) {
                    if (working[index].indexOf(s1.name) == -1 && working[index].indexOf(s2.name) == -1) {
                        working[index].push(s1.name);
                        working[index].push(s2.name);
                        found = true;
                        setTimeout(function() {
                            bandwidth_test(enlace, s1, s2, countdown_and_exit);
                        }, time*index);
                        break;
                    }
                }
                if (!found) {
                    var next = working.length;
                    working[next] = new Array(s1.name, s2.nam3);
                    setTimeout(function() {
                        bandwidth_test(enlace, s1, s2, countdown_and_exit);
                    }, time*(next+1));
                }
            });
        }
    });
}

var query = { active: true };
Enlace.find(query).exec(function(err, enlaces) {
    if (err) { throw err };

    var counter = enlaces.length;

    var waitfor = new Array();
    for (var i=0; i<enlaces.length; i++) {
        waitfor.push(enlaces[i].id);
    }

    setTimeout(function() {
       logger.error(util.format("Bad exit: %s", waitfor));
       process.exit(-1);
    }, 380000);

    function countdown_and_exit(enlaceid) {
        waitfor.splice(waitfor.indexOf(enlaceid), 1);
        if (waitfor.length == 0) {
            mongoose.disconnect();
            process.exit(0);
        }
    }

    enlaces.forEach(function(enlace) {
        monitor_link(enlace, countdown_and_exit);
    });
});


text:
package stack

type StackLinkedList struct {
	head *Node
	size int
}

type Node struct {
	next  *Node
	value interface{}
}

func NewStackLinkedList() *StackLinkedList {
	return new(StackLinkedList)
}

func (sll *StackLinkedList) Push(v interface{}) {
	headTmp := sll.head
	sll.head = &Node{
		next:  headTmp,
		value: v,
	}
	sll.size++
}

func (sll *StackLinkedList) Pop() interface{} {
	if sll.Empty() {
		return nil
	}
	headTmp := sll.head
	sll.head = sll.head.next
	sll.size--
	return headTmp.value
}

func (sll *StackLinkedList) Peek() interface{} {
	if sll.Empty() {
		return nil
	}
	return sll.head.value
}

func (sll *StackLinkedList) Size() int {
	return sll.size
}

func (sll *StackLinkedList) Empty() bool {
	return sll.size == 0
}


text:
package com.thaiopensource.datatype.xsd;

interface OrderRelation
{
  boolean isLessThan (Object obj1, Object obj2);
}


text:
set(CMAKE_DEPENDS_GENERATOR "Unix Makefiles")

# The top level Makefile was generated from the following files:
set(CMAKE_MAKEFILE_DEPENDS
  "CMakeCache.txt"
  "CMakeFiles/3.14.0/CMakeCCompiler.cmake"
  "CMakeFiles/3.14.0/CMakeCXXCompiler.cmake"
  "CMakeFiles/3.14.0/CMakeSystem.cmake"
  "CMakeLists.txt"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/CMakeCInformation.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/CMakeCXXInformation.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/CMakeCommonLanguageInclude.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/CMakeGenericSystem.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/CMakeInitializeConfigs.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/CMakeLanguageInformation.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/CMakeSystemSpecificInformation.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/CMakeSystemSpecificInitialize.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/CheckCCompilerFlag.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/CheckCSourceCompiles.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/Compiler/AppleClang-C.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/Compiler/AppleClang-CXX.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/Compiler/CMakeCommonCompilerMacros.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/Compiler/Clang.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/Compiler/GNU.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/Internal/CMakeCheckCompilerFlag.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/Platform/Apple-AppleClang-C.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/Platform/Apple-AppleClang-CXX.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/Platform/Apple-Clang-C.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/Platform/Apple-Clang-CXX.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/Platform/Apple-Clang.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/Platform/Darwin-Initialize.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/Platform/Darwin.cmake"
  "/usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/Platform/UnixPaths.cmake"
  )

# The corresponding makefile is:
set(CMAKE_MAKEFILE_OUTPUTS
  "Makefile"
  "CMakeFiles/cmake.check_cache"
  )

# Byproducts of CMake generate step:
set(CMAKE_MAKEFILE_PRODUCTS
  "CMakeFiles/CMakeDirectoryInformation.cmake"
  )

# Dependency information for all targets:
set(CMAKE_DEPEND_INFO_FILES
  "CMakeFiles/LibUvTutorial.dir/DependInfo.cmake"
  )


text:
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\User;
use App\Models\Setting;
use Auth;
use Flash;

class AppController extends Controller
{

    /**
     *  In the constructor we attach the
     *  auth middleweare to the settings function
     */
    public function __construct() {
        $this->middleware('auth' ,['only' => ['settings', 'save_settings', 'delete_account'] ]);
        $this->middleware('resendConfirmationCode', ['only' => 'resend_code']);
    }

    /*
	*
	* Returns the about view
	*/
    public function about(){
    	return view('pages.about')->withPage('about');
    }

    /*
	*
	* Returns the contact view
	*/
    public function contact(){
    	return view('pages.contact')->withPage('contact');
    }

 	/*
	*
	* Returns the pin view
	*/
    public function pin($id){
    	return view('auth.pin')->with('id', $id)->withPage('pin');
    }

    /*
    *
    * Returns the terms view
    */
    public function terms(){

        return view('pages.terms')->withPage('terms');
    }

    /*
    *
    * Returns the settings view
    */
    public function settings(){
        $user = Auth::user();
        $settings = Setting::findOrFail($user->setting_id);

        $data = [
        'name' => $user->name,
        'email' => $user->email,
        'confirmed' => $user->confirmed
        ];

        return view('pages.settings')->withPage('settings')->withData($data)->withSettings($settings);
    }

    /*
    *
    * Saves the settings into the database
    */
    public function save_settings(Request $request){

        $user = Auth::user();
        $settings = Setting::findOrFail($user->setting_id);

        $user->name = $request->name;
        $user->save();

        $settings->certified = $request->certified ? 1 : 0;
        $settings->tags = $request->tags ? 1 : 0;
        $settings->show_first = $request->show_first;
        $settings->pagination_count = $request->pagination_count;
        $settings->pagination_type = $request->pagination_type;
        $settings->date_format = $request->date_format;

        $settings->save();

        Flash::success('Settings saved successfully!');
        return redirect('/settings');
    }

    /*
    *
    * Deletes the user
    */
    public function delete_account(){
        $user = Auth::user();

        $user->delete();

        Flash::warning('Your account has been deleted! From now on you can write non-certified posts.');
        return redirect(route('posts.index'));
    }

    /*
    *
    * Resends the confirmation code
    */
    public function resend_code(){

        $user = Auth::user();

        $data = [
            'email' => $user->email,
            'name' => $user->name,
            'confirmation_code' => $user->confirmation_code
        ];

        $logo = [
                'path' => asset('img/logo.png'),
                'width' => '320',
                'height' => '70',
            ];

        $beautymail = app()->make(\Snowfire\Beautymail\Beautymail::class);
        $beautymail->send('emails.welcome', ['confirmation_code' => $data['confirmation_code'], 'logo' => $logo], function ($message) use ($data) {
            $message
                ->from('no-reply@mrklog.com')
                ->to($data['email'], $data['name'])
                ->subject('Welcome!');
        });

        Flash::success('Please checkout your email inbox messages!');
        return redirect(route('posts.index'));
    }

}


text:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace GoogleClosure
{
    public class JavaExecutableDiscovery
    {
        ///
        /// Simple, stupid, heuristic to try and find a suitable java.exe
        ///
        /// <returns></returns>
        public static string DisoverJavaExecutablePath()
        {
            return GetPotentialJavaExecutables().First(File.Exists);
        }

        public static IEnumerable<string> GetPotentialJavaExecutables()
        {
            return from javaHome in GetPotentialJavaHomeDirectories()
                   select Path.Combine(javaHome, "bin", "java.exe");
        }

        public static IEnumerable<string> GetPotentialJavaHomeDirectories()
        {
            return GetJavaHomeFromEnvironmentVariable()
                .Concat(GetJavaHomeFromProgramFilesDirectory());
        }

        public static IEnumerable<string> GetJavaHomeFromEnvironmentVariable()
        {
            var javaHome = Environment.GetEnvironmentVariable("JAVA_HOME", EnvironmentVariableTarget.Process);

            if (javaHome != null)
            {
                yield return javaHome;
            }
        }

        public static IEnumerable<string> GetJavaHomeFromProgramFilesDirectory()
        {
            var jreVersions = new[] { "jre7", "jre6" };

            return from directory in GetProgramFilesDirectories()
                   from jre in jreVersions
                   select Path.Combine(directory, "Java", jre);
        }

        public static IEnumerable<string> GetProgramFilesDirectories()
        {
            yield return Environment.GetEnvironmentVariable("ProgramW6432");
            yield return Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
            yield return Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
        }
    }
}


text:
use rustc_serialize::base64::{ToBase64, STANDARD};
use rustc_serialize::json;
use super::schema::{VName, Fact, EdgeKind};

// EntryWriter implementations define behavior for outputting kythe info.
pub trait EntryWriter {
    fn edge(&self, src: &VName, edge_kind: EdgeKind, target: &VName);
    // TODO(djrenren): Make fact_value &[u8] instead of &str
    fn node(&self, src: &VName, fact_name: Fact, fact_value: &str);
}

// Struct used for writing kythe info to STDOUT in json form
pub struct JsonEntryWriter;

#[derive(RustcEncodable)]
struct Node<'a> {
    source: &'a VName,
    fact_name: &'a str,
    fact_value: String,
}

#[derive(RustcEncodable)]
struct Edge<'a> {
    source: &'a VName,
    edge_kind: &'a str,
    target: &'a VName,
    fact_name: &'a str,
}

impl EntryWriter for JsonEntryWriter {
    fn edge(&self, src: &VName, edge_kind: EdgeKind, target: &VName) {
        let edge = Edge {
            source: src,
            edge_kind: &edge_kind,
            target: target,
            fact_name: "/",
        };

        let json_str = json::encode(&edge).unwrap();
        println!("{}", json_str);
    }

    fn node(&self, src: &VName, fact_name: Fact, fact_value: &str) {
        let node = Node {
            source: src,
            fact_name: &fact_name,
            fact_value: fact_value.as_bytes().to_base64(STANDARD),
        };

        let json_str = json::encode(&node).unwrap();
        println!("{}", json_str);
    }
}


text:
package org.magicnexus.classes.game.turn.step;

import java.util.List;

import org.magicnexus.classes.game.event.turn.BeginningInitiativeCombatDamageStepEvent;
import org.magicnexus.classes.game.turn.action.InitiativeCombatDamageAction;
import org.magicnexus.interfaces.game.turn.IStep;
import org.magicnexus.interfaces.game.turn.ITurnBasedAction;

public class InitiativeCombatDamageStep extends AbstractStep
{

	@Override
	public IStep getNextStep()
	{
		RegularCombatDamageStep step = new RegularCombatDamageStep();
		step.setPhase(getPhase());
		return step;
	}

	@Override
	public List<ITurnBasedAction> getActions()
	{
		List<ITurnBasedAction> actions = super.getActions();
		actions.add(new InitiativeCombatDamageAction(this));
		return actions;
	}

	@Override
	public void run()
	{
		getGame().handle(new BeginningInitiativeCombatDamageStepEvent(this));
	}

}


text:
/* http://keith-wood.name/datepick.html
   Lithuanian localisation for jQuery Datepicker.
   Written by Arturas Paleicikas <arturas@avalon.lt> */
(function($) {
	$.datepick.regionalOptions['lt'] = {
		monthNames: ['Sausis','Vasaris','Kovas','Balandis','Gegužė','Birželis',
		'Liepa','Rugpjūtis','Rugsėjis','Spalis','Lapkritis','Gruodis'],
		monthNamesShort: ['Sau','Vas','Kov','Bal','Geg','Bir',
		'Lie','Rugp','Rugs','Spa','Lap','Gru'],
		dayNames: ['sekmadienis','pirmadienis','antradienis','trečiadienis','ketvirtadienis','penktadienis','šeštadienis'],
		dayNamesShort: ['sek','pir','ant','tre','ket','pen','šeš'],
		dayNamesMin: ['Se','Pr','An','Tr','Ke','Pe','Še'],
		dateFormat: 'yyyy-mm-dd', firstDay: 1,
		renderer: $.datepick.defaultRenderer,
		prevText: '<Atgal',  prevStatus: '',
		prevJumpText: '<<', prevJumpStatus: '',
		nextText: 'Pirmyn>', nextStatus: '',
		nextJumpText: '>>', nextJumpStatus: '',
		currentText: 'Šiandien', currentStatus: '',
		todayText: 'Šiandien', todayStatus: '',
		clearText: 'Išvalyti', clearStatus: '',
		closeText: 'Uždaryti', closeStatus: '',
		yearStatus: '', monthStatus: '',
		weekText: 'Wk', weekStatus: '',
		dayStatus: 'D, M d', defaultStatus: '',
		isRTL: false
	};
	$.datepick.setDefaults($.datepick.regionalOptions['lt']);
})(jQuery);