diff --git a/extras/android-event-viewer/.gitignore b/extras/android-event-viewer/.gitignore new file mode 100644 index 0000000000..28a312e757 --- /dev/null +++ b/extras/android-event-viewer/.gitignore @@ -0,0 +1,56 @@ +# Built application files +*.apk +*.ap_ + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# Intellij +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/dictionaries +.idea/libraries + +# Keystore files +*.jks + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + diff --git a/extras/android-event-viewer/.idea/compiler.xml b/extras/android-event-viewer/.idea/compiler.xml new file mode 100644 index 0000000000..96cc43efa6 --- /dev/null +++ b/extras/android-event-viewer/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/extras/android-event-viewer/.idea/copyright/profiles_settings.xml b/extras/android-event-viewer/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000000..e7bedf3377 --- /dev/null +++ b/extras/android-event-viewer/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/extras/android-event-viewer/.idea/misc.xml b/extras/android-event-viewer/.idea/misc.xml new file mode 100644 index 0000000000..38041c7cc6 --- /dev/null +++ b/extras/android-event-viewer/.idea/misc.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/extras/android-event-viewer/.idea/modules.xml b/extras/android-event-viewer/.idea/modules.xml new file mode 100644 index 0000000000..135b400226 --- /dev/null +++ b/extras/android-event-viewer/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/extras/android-event-viewer/.idea/runConfigurations.xml b/extras/android-event-viewer/.idea/runConfigurations.xml new file mode 100644 index 0000000000..7f68460d8b --- /dev/null +++ b/extras/android-event-viewer/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/extras/android-event-viewer/app/build.gradle b/extras/android-event-viewer/app/build.gradle new file mode 100644 index 0000000000..92924f93b3 --- /dev/null +++ b/extras/android-event-viewer/app/build.gradle @@ -0,0 +1,19 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 8 + buildToolsVersion "25.0.2" + + defaultConfig { + applicationId "pandroid_event_viewer.pandorafms" + minSdkVersion 8 + targetSdkVersion 8 + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + } +} diff --git a/extras/pandroid_event_viewer/lint.xml b/extras/android-event-viewer/app/lint.xml similarity index 61% rename from extras/pandroid_event_viewer/lint.xml rename to extras/android-event-viewer/app/lint.xml index f4be1f0ca4..b148b1a931 100644 --- a/extras/pandroid_event_viewer/lint.xml +++ b/extras/android-event-viewer/app/lint.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/extras/pandroid_event_viewer/AndroidManifest.xml b/extras/android-event-viewer/app/src/main/AndroidManifest.xml similarity index 98% rename from extras/pandroid_event_viewer/AndroidManifest.xml rename to extras/android-event-viewer/app/src/main/AndroidManifest.xml index 443f3c8bd0..bdd70a163e 100644 --- a/extras/pandroid_event_viewer/AndroidManifest.xml +++ b/extras/android-event-viewer/app/src/main/AndroidManifest.xml @@ -16,8 +16,8 @@ --> + android:versionCode="6" + android:versionName="1.5" > parameters = new ArrayList(); parameters.add(new BasicNameValuePair("op", "get")); parameters.add(new BasicNameValuePair("op2", "events")); parameters.add(new BasicNameValuePair("other_mode", "url_encode_separator_|")); - parameters.add(new BasicNameValuePair("return_type", "csv")); + parameters.add(new BasicNameValuePair("return_type", returnType)); parameters.add(new BasicNameValuePair("other", serializeEventsParamsToAPI(filterAgentName, idGroup, filterSeverity, filterStatus, filterEventSearch, @@ -159,6 +162,88 @@ public class API { more_criticity))); return Core.httpGet(context, parameters); } + + /** + * Performs a get_events API call. + * + * @param context + * Application context. + * @param filterAgentName + * Agent name. + * @param idGroup + * Group id. + * @param filterSeverity + * Severity. + * @param filterStatus + * Status. + * @param filterEventSearch + * Text in event title. + * @param filterTag + * Tag. + * @param filterTimestamp + * Events after this time. + * @param itemsPerPage + * Number of items retrieved per list in each call. + * @param offset + * List offset. + * @param total + * Retrieve number of events instead of events info. + * @param more_criticity + * Retrieve maximum criticity instead of events info. + * + * @return API call result. + * @throws IOException + * if there was any problem. + */ + public static String getEvents (Context context, String filterAgentName, + int idGroup, int filterSeverity, int filterStatus, + String filterEventSearch, String filterTag, + long filterTimestamp, long itemsPerPage, long offset, + boolean total, boolean more_criticity) throws IOException { + return API.getEvents(context, + filterAgentName, idGroup, filterSeverity, filterStatus, filterEventSearch, + filterTag, filterTimestamp, itemsPerPage, offset, total, more_criticity, "csv"); + } + + /** + * Performs a get_events API call. + * + * @param context + * Application context. + * @param filterAgentName + * Agent name. + * @param idGroup + * Group id. + * @param filterSeverity + * Severity. + * @param filterStatus + * Status. + * @param filterEventSearch + * Text in event title. + * @param filterTag + * Tag. + * @param filterTimestamp + * Events after this time. + * @param itemsPerPage + * Number of items retrieved per list in each call. + * @param offset + * List offset. + * @param returnType + * To chose the type of the returned data (csv, json...). + * + * @return API call result. + * @throws IOException + * if there was any problem. + */ + public static String getEvents (Context context, String filterAgentName, + int idGroup, int filterSeverity, int filterStatus, + String filterEventSearch, String filterTag, + long filterTimestamp, long itemsPerPage, long offset, + String returnType) throws IOException { + return API.getEvents(context, + filterAgentName, idGroup, filterSeverity, filterStatus, filterEventSearch, + filterTag, filterTimestamp, itemsPerPage, offset, false, false, returnType); + } /** * Get tags through an api call. diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/About.java b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/About.java similarity index 100% rename from extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/About.java rename to extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/About.java diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Core.java b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/Core.java similarity index 95% rename from extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Core.java rename to extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/Core.java index 462a0af2d5..4363e7d57a 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Core.java +++ b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/Core.java @@ -34,6 +34,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; @@ -755,4 +757,32 @@ public class Core { return null; } } + + /** + * Returns the major version by extracting it from the api_version token from the preferences. + * + * @param context Application context. + * @return int Major API version + * + * @throws Exception If the major version cannot be extracted. + * @throws NumberFormatException If the major version cannot be casted to integer. + */ + public static int getMajorVersion (Context context) throws Exception { + SharedPreferences preferences = context.getSharedPreferences( + context.getString(R.string.const_string_preferences), + Activity.MODE_PRIVATE); + // It is something like v5.0SP1 + String api_version = preferences.getString("api_version", ""); + + // Try to get the version number + Matcher apiVerMatcher = Pattern.compile("^v(\\d)+\\.\\d+.*$").matcher(api_version); + + if (apiVerMatcher.find()) { + String apiVerString = apiVerMatcher.group(1); + int apiVerNumber = Integer.parseInt(apiVerString); + + return apiVerNumber; + } + throw new Exception("The version number cannot be extracted from the version string"); + } } diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/EventList.java b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/EventList.java similarity index 100% rename from extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/EventList.java rename to extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/EventList.java diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/EventListItem.java b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/EventListItem.java similarity index 100% rename from extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/EventListItem.java rename to extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/EventListItem.java diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Info.java b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/Info.java similarity index 100% rename from extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Info.java rename to extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/Info.java diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/Main.java similarity index 100% rename from extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java rename to extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/Main.java diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/NaiveTrustManager.java b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/NaiveTrustManager.java similarity index 100% rename from extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/NaiveTrustManager.java rename to extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/NaiveTrustManager.java diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/OnBootLoader.java b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/OnBootLoader.java similarity index 100% rename from extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/OnBootLoader.java rename to extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/OnBootLoader.java diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Options.java b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/Options.java similarity index 100% rename from extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Options.java rename to extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/Options.java diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java similarity index 60% rename from extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java rename to extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java index 510fe0303c..df270c8fc7 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java +++ b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java @@ -22,6 +22,8 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import android.app.Activity; import android.app.Notification; @@ -39,9 +41,12 @@ import android.widget.BaseAdapter; import android.widget.TabHost; import android.widget.Toast; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; -public class PandroidEventviewerActivity extends TabActivity implements - Serializable { + +public class PandroidEventviewerActivity extends TabActivity implements Serializable { private static String TAG = "PandroidEventviewerActivity"; private static final int PROBLEM_NOTIFICATION_ID = 1; private static final long serialVersionUID = 1L; @@ -259,250 +264,220 @@ public class PandroidEventviewerActivity extends TabActivity implements "Configuration changes commited (timestamp)"); } } - + /** - * Get events from pandora console. For only Pandora 5.0 version - * - * @throws IOException - * If there is any connection problem. - * + * Parses a JSON object and returns a valid event list item. + * For >= v7. + * + * @param item Object with the event columns. + * + * @return EventListItem + * @throws JSONException, NumberFormatException */ - private void getEvents_v50(String[] lines) { - for (int i = 0; i < lines.length; i++) { - String[] items = lines[i].split(";"); + private EventListItem parseEvent (JSONObject item) throws JSONException, NumberFormatException { + EventListItem event = new EventListItem(); - EventListItem event = new EventListItem(); - boolean extract = true; + // Event id + event.id_event = item.optInt("id_evento"); + // Agent id + event.id_agent = item.optInt("id_agente"); + // User id + event.id_user = item.getString("id_usuario"); + // Group id + event.id_group = item.optInt("id_grupo"); + // Status + event.status = item.optInt("estado"); + // Timestamp (Y-M-d H:m:s) + event.timestamp = item.getString("timestamp"); + // Event text + event.event = item.getString("evento"); + // Unix timestamp + event.utimestamp = item.optInt("utimestamp"); + // Event type + event.event_type = item.getString("event_type"); + // Module id + event.id_agentmodule = item.optInt("id_agentmodule"); + // Alert id + event.id_alert_am = item.optInt("id_alert_am"); + // Event priority + event.criticity = item.optInt("criticity"); + // User comments + event.user_comment = item.getString("user_comment"); + // Tags + event.tags = item.getString("tags"); + // Agent name (try to use the alias) + event.agent_name = item.optString("agent_alias", item.optString("agent_name")); + // Group name + event.group_name = item.optString("group_name"); + // Group icon + event.group_icon = item.optString("group_icon"); + // Event description + event.description_event = item.optString("description_event"); + // Event description image + event.description_image = item.optString("img_description"); + // Event priority name + event.criticity_name = item.optString("criticity_name"); + // Event priority image + event.criticity_image = item.optString("img_criticy"); + + event.opened = false; + + return event; + } + + /** + * Parses a string array and returns a valid event list item. + * + * THIS IS AN HORRIBLE WAY TO DO THIS. + * Any change on the columns order on the tevento's table from the database + * or any change to the public API can break this in multiple ways. + * CSV is bad for a maintainable and scalable APIs, but someone could almost map the + * head (nonexistent) with the line columns indexes... /rage + * + * For <= v6. + * + * @param columns String array with the event columns. + * @param old Whether to use the csv parsing for the <=v4 or the >=v5 && <= v6. + * + * @return EventListItem + * @throws NumberFormatException + */ + private EventListItem parseEvent (String[] columns, boolean old) throws NumberFormatException { + EventListItem event = new EventListItem(); + + // Event id + event.id_event = (columns[0].length() > 0) ? Integer.parseInt(columns[0]) : 0; + // Agent id + event.id_agent = (columns[1].length() > 0) ? Integer.parseInt(columns[1]) : 0; + // User id + event.id_user = columns[2]; + //Get id group + event.id_group = (columns[3].length() > 0) ? Integer.parseInt(columns[3]) : 0; + // Status + event.status = (columns[4].length() > 0) ? Integer.parseInt(columns[4]) : 0; + // Timestamp (format Y-M-d H:m:s) + event.timestamp = columns[5]; + //Get event as text + event.event = columns[6]; + // Unix timestamp + event.utimestamp = (columns[7].length() > 0) ? Integer.parseInt(columns[7]) : 0; + // Event type + event.event_type = columns[8]; + // Module id + event.id_agentmodule = (columns[9].length() > 0) ? Integer.parseInt(columns[9]) : 0; + // Alert id + event.id_alert_am = (columns[10].length() > 0) ? Integer.parseInt(columns[10]) : 0; + // Priority + event.criticity = (columns[11].length() > 0) ? Integer.parseInt(columns[11]) : 0; + // User comment + event.user_comment = columns[12]; + // Tags + event.tags = columns[13]; + + // For <= v4 + if (old) { + // Agent name + event.agent_name = (columns.length >= 15) ? columns[14] : ""; + // Group name + event.group_name = (columns.length >= 16) ? columns[15] : ""; + // Group icon + event.group_icon = (columns.length >= 17) ? columns[16] : ""; + // Event description + event.description_event = (columns.length >= 18) ? columns[17] : ""; + // Event description image + event.description_image = (columns.length >= 19) ? columns[18] : ""; + // Priority image + event.criticity_image = (columns.length >= 20) ? columns[19] : ""; + // Priority name + event.criticity_name = (columns.length >= 21) ? columns[20] : ""; + } + // For v5 and v6 + else { + // Agent name + event.agent_name = (columns.length >= 23) ? columns[22] : ""; + // Group name + event.group_name = (columns.length >= 24) ? columns[23] : ""; + // Group icon + event.group_icon = (columns.length >= 25) ? columns[24] : ""; + // Event description + event.description_event = (columns.length >= 26) ? columns[25] : ""; + // Event description image + event.description_image = (columns.length >= 27) ? columns[26] : ""; + // Priority image + event.criticity_image = (columns.length >= 28) ? columns[27] : ""; + // Priority name + event.criticity_name = (columns.length >= 29) ? columns[28] : ""; + } + + event.opened = false; + + return event; + } + + /** + * Process a JSON response from the api and save the new events. + * For >= v7. + * + * @param items JSONObject array with the event rows. + */ + private void saveEvents (JSONArray items) { + if (items.length() == 0) { + Log.d("WORKS?", "NEWEVENTS = FALSE"); + this.newEvents = false; + return; + } + this.newEvents = true; + + // Iterate the JSON Objects + for (int i = 0; i < items.length(); i++) { try { - if (items.length < 14) { - extract = false; - continue; - } - //Get id event - if (items[0].length() == 0) { - event.id_event = 0; - } - else { - event.id_event = Integer.parseInt(items[0]); - } - - //Get id agent - if (items[1].length() == 0) { - event.id_agent = 0; - } - else { - event.id_agent = Integer.parseInt(items[1]); - } - - //Get id user - event.id_user = items[2]; - - //Get id group - if (items[3].length() == 0) { - event.id_group = 0; - } - else { - event.id_group = Integer.parseInt(items[3]); - } - - //Get status - if (items[4].length() == 0) { - event.status = 0; - } - else { - event.status = Integer.parseInt(items[4]); - } - - //Get timestamp (format Y-M-d H:m:s) - event.timestamp = items[5]; - - //Get event as text - event.event = items[6]; - - //Get unix timestamp - if (items[7].length() == 0) { - event.utimestamp = 0; - } - else { - event.utimestamp = Integer.parseInt(items[7]); - } - - //Get event type - event.event_type = items[8]; - - //Get id module - if (items[9].length() == 0) { - event.id_agentmodule = 0; - } - else { - event.id_agentmodule = Integer.parseInt(items[9]); - } - - //Get id alert - if (items[10].length() == 0) { - event.id_alert_am = 0; - } - else { - event.id_alert_am = Integer.parseInt(items[10]); - } - - //Get criticity - if (items[11].length() == 0) { - event.criticity = 0; - } - else { - event.criticity = Integer.parseInt(items[11]); - } - - //Get user comment - event.user_comment = items[12]; - - //Get tags - event.tags = items[13]; - - /* This fields are not used in the Pandroid event - - event.source = item[14]; - event.id_extra = item[15]; - event.critical_instructions = item[16]; - event.warning_instructions = item[17]; - event.unknown_instructions = item[18]; - event.owner_user = item[19]; - event.ack_utimestamp = item[20]; - event.custom_data = item[21] - - */ - - event.agent_name = ""; - event.group_name = ""; - event.group_icon = ""; - event.description_event = ""; - event.description_image = ""; - event.criticity_name = ""; - event.criticity_image = ""; - - if (items.length >= 23) - event.agent_name = items[22]; - if (items.length >= 24) - event.group_name = items[23]; - if (items.length >= 25) - event.group_icon = items[24]; - if (items.length >= 26) - event.description_event = items[25]; - if (items.length >= 27) - event.description_image = items[26]; - if (items.length >= 28) - event.criticity_name = items[28]; - if (items.length >= 27) - event.criticity_image = items[27]; - - event.opened = false; - } - catch (NumberFormatException nfe) { - event.event = getApplication().getString( - R.string.unknown_event_str); - launchProblemParsingNotification(); - } - if (extract) + JSONObject item = items.getJSONObject(i); + EventListItem event = this.parseEvent(item); this.eventList.add(event); - } - } - - /** - * Get events from pandora console. For old versions of Pandora (v4 <) - * - * @throws IOException - * If there is any connection problem. - * - */ - private void getEvents_old(String[] lines) { - for (int i = 0; i < lines.length; i++) { - String[] items = lines[i].split(";"); - - EventListItem event = new EventListItem(); - try { - - if (items[0].length() == 0) { - event.id_event = 0; - } - else { - event.id_event = Integer.parseInt(items[0]); - } - if (items[1].length() == 0) { - event.id_agent = 0; - } - else { - event.id_agent = Integer.parseInt(items[1]); - } - event.id_user = items[2]; - if (items[3].length() == 0) { - event.id_group = 0; - } - else { - event.id_group = Integer.parseInt(items[3]); - } - if (items[4].length() == 0) { - event.status = 0; - } - else { - event.status = Integer.parseInt(items[4]); - } - event.timestamp = items[5]; - event.event = items[6]; - if (items[7].length() == 0) { - event.utimestamp = 0; - } - else { - event.utimestamp = Integer.parseInt(items[7]); - } - event.event_type = items[8]; - if (items[9].length() == 0) { - event.id_agentmodule = 0; - } - else { - event.id_agentmodule = Integer.parseInt(items[9]); - } - if (items[10].length() == 0) { - event.id_alert_am = 0; - } - else { - event.id_alert_am = Integer.parseInt(items[10]); - } - if (items[11].length() == 0) { - event.criticity = 0; - } - else { - event.criticity = Integer.parseInt(items[11]); - } - event.user_comment = items[12]; - event.tags = items[13]; - event.agent_name = items[14]; - event.group_name = items[15]; - event.group_icon = items[16]; - event.description_event = items[17]; - event.description_image = items[18]; - event.criticity_name = items[19]; - event.criticity_image = items[20]; - - event.opened = false; } catch (NumberFormatException nfe) { - event.event = getApplication().getString( - R.string.unknown_event_str); launchProblemParsingNotification(); } - this.eventList.add(event); + catch (JSONException e) { + launchProblemParsingNotification(); + } } } - + + /** + * Process a CSV response from the api and save the new events. + * For <= v6. + * + * @param lines String array with the event lines in CSV format. + * @param old Whether to use the csv parsing for the <=v4 or the >=v5 && <= v6. + */ + private void saveEvents (String[] lines, boolean old) { + if (lines.length == 0) { + Log.d("WORKS?", "NEWEVENTS = FALSE"); + this.newEvents = false; + return; + } + this.newEvents = true; + + // Iterate the CSV lines + for (int i = 0; i < lines.length; i++) { + try { + String[] columns = lines[i].split(";"); + EventListItem event = this.parseEvent(columns, old); + this.eventList.add(event); + } + catch (NumberFormatException nfe) { + launchProblemParsingNotification(); + } + } + } + /** * Get events from pandora console. * - * @throws IOException - * If there is any connection problem. - * + * @throws IOException If there is any connection problem. */ - private void getEvents() throws IOException { + private void getEvents () throws IOException { // Get total count. String return_api = API.getEvents(getApplicationContext(), agentNameStr, id_group, severity, status, eventSearch, @@ -521,35 +496,42 @@ public class PandroidEventviewerActivity extends TabActivity implements return; } + // Try to get the API version number + int apiVerNumber = 0; + try { + apiVerNumber = Core.getMajorVersion(getApplicationContext()); + } + catch (Exception e) {} + // Get the list of events. - return_api = API.getEvents(getApplicationContext(), agentNameStr, - id_group, severity, status, eventSearch, eventTag, timestamp, - pagination, offset, false, false); + String returnType = (apiVerNumber < 7) ? "csv" : "json"; + return_api = API.getEvents(getApplicationContext(), + agentNameStr, id_group, severity, status, eventSearch, + eventTag, timestamp, pagination, offset, returnType); + Log.d(TAG, "List of events: " + return_api); - Log.i(TAG + " getEvents - return_api", return_api); - String[] lines = return_api.split("\n"); - newEvents = true; - if (return_api.length() == 0) { - Log.d("WORKS?", "NEWEVENTS = FALSE"); - newEvents = false; - return; + try { + if (apiVerNumber >= 7) { + JSONObject response = new JSONObject(return_api); + if (!response.optString("type").equals("array")) { + throw new Exception("Invalid API return type"); + } + + JSONArray rows = response.getJSONArray("data"); + this.saveEvents(rows); + } + else { + String[] lines = return_api.split("\n"); + + // The Console API changed in the v5 + boolean old = apiVerNumber < 5; + this.saveEvents(lines, old); + } } - - SharedPreferences preferences = getSharedPreferences( - getString(R.string.const_string_preferences), - Activity.MODE_PRIVATE); - String api_version = preferences.getString("api_version", ""); - - // Get the short form of the version. I.E. "v5" for "v5.0SP1" - String[] api_version_short = api_version.split("\\."); - - if (api_version_short[0].equals("v5")) { - this.getEvents_v50(lines); - } - else { - this.getEvents_old(lines); + catch (Exception e) { + this.newEvents = false; } } diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/PandroidEventviewerService.java b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/PandroidEventviewerService.java similarity index 100% rename from extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/PandroidEventviewerService.java rename to extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/PandroidEventviewerService.java diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/PopupValidationEvent.java b/extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/PopupValidationEvent.java similarity index 100% rename from extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/PopupValidationEvent.java rename to extras/android-event-viewer/app/src/main/java/pandroid_event_viewer/pandorafms/PopupValidationEvent.java diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/about.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/about.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/about.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/about.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/b_green.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/b_green.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/b_green.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/b_green.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/b_red.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/b_red.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/b_red.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/b_red.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/b_yellow.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/b_yellow.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/b_yellow.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/b_yellow.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/bell.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/bell.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/bell.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/bell.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/cog.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/cog.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/cog.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/cog.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/config.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/config.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/config.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/config.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/criticity_0.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/criticity_0.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/criticity_0.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/criticity_0.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/criticity_1.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/criticity_1.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/criticity_1.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/criticity_1.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/criticity_2.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/criticity_2.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/criticity_2.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/criticity_2.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/criticity_3.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/criticity_3.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/criticity_3.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/criticity_3.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/criticity_4.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/criticity_4.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/criticity_4.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/criticity_4.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/criticity_default.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/criticity_default.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/criticity_default.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/criticity_default.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/cross.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/cross.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/cross.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/cross.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/delete.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/delete.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/delete.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/delete.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/delete_pressed.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/delete_pressed.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/delete_pressed.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/delete_pressed.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/err.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/err.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/err.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/err.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/error.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/error.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/error.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/error.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/eye.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/eye.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/eye.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/eye.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/help.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/help.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/help.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/help.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/icon_filter.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/icon_filter.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/icon_filter.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/icon_filter.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/icon_filter_pressed.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/icon_filter_pressed.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/icon_filter_pressed.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/icon_filter_pressed.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/icon_refresh.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/icon_refresh.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/icon_refresh.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/icon_refresh.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/icon_refresh_pressed.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/icon_refresh_pressed.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/icon_refresh_pressed.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/icon_refresh_pressed.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/network.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/network.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/network.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/network.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/ok.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/ok.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/ok.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/ok.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/pandorafms_logo.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/pandorafms_logo.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/pandorafms_logo.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/pandorafms_logo.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/refresh.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/refresh.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/refresh.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/refresh.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/save.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/save.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/save.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/save.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/save_pressed.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/save_pressed.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/save_pressed.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/save_pressed.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/severity_critical.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/severity_critical.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/severity_critical.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/severity_critical.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/severity_informational.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/severity_informational.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/severity_informational.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/severity_informational.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/severity_maintenance.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/severity_maintenance.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/severity_maintenance.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/severity_maintenance.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/severity_normal.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/severity_normal.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/severity_normal.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/severity_normal.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/severity_warning.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/severity_warning.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/severity_warning.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/severity_warning.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/tick.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/tick.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/tick.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/tick.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/tick_off.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/tick_off.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/tick_off.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/tick_off.png diff --git a/extras/pandroid_event_viewer/res/drawable-ldpi/wand.png b/extras/android-event-viewer/app/src/main/res/drawable-ldpi/wand.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable-ldpi/wand.png rename to extras/android-event-viewer/app/src/main/res/drawable-ldpi/wand.png diff --git a/extras/pandroid_event_viewer/res/drawable/btn_dropdown.xml b/extras/android-event-viewer/app/src/main/res/drawable/btn_dropdown.xml similarity index 93% rename from extras/pandroid_event_viewer/res/drawable/btn_dropdown.xml rename to extras/android-event-viewer/app/src/main/res/drawable/btn_dropdown.xml index 6632f1172e..d02baf24eb 100644 --- a/extras/pandroid_event_viewer/res/drawable/btn_dropdown.xml +++ b/extras/android-event-viewer/app/src/main/res/drawable/btn_dropdown.xml @@ -1,4 +1,4 @@ - + diff --git a/extras/pandroid_event_viewer/res/drawable/button_normal.9.png b/extras/android-event-viewer/app/src/main/res/drawable/button_normal.9.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable/button_normal.9.png rename to extras/android-event-viewer/app/src/main/res/drawable/button_normal.9.png diff --git a/extras/pandroid_event_viewer/res/drawable/button_pressed.9.png b/extras/android-event-viewer/app/src/main/res/drawable/button_pressed.9.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable/button_pressed.9.png rename to extras/android-event-viewer/app/src/main/res/drawable/button_pressed.9.png diff --git a/extras/pandroid_event_viewer/res/drawable/combobox_normal.9.png b/extras/android-event-viewer/app/src/main/res/drawable/combobox_normal.9.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable/combobox_normal.9.png rename to extras/android-event-viewer/app/src/main/res/drawable/combobox_normal.9.png diff --git a/extras/pandroid_event_viewer/res/drawable/combobox_pressed.9.png b/extras/android-event-viewer/app/src/main/res/drawable/combobox_pressed.9.png similarity index 100% rename from extras/pandroid_event_viewer/res/drawable/combobox_pressed.9.png rename to extras/android-event-viewer/app/src/main/res/drawable/combobox_pressed.9.png diff --git a/extras/pandroid_event_viewer/res/drawable/delete_icon_button.xml b/extras/android-event-viewer/app/src/main/res/drawable/delete_icon_button.xml similarity index 92% rename from extras/pandroid_event_viewer/res/drawable/delete_icon_button.xml rename to extras/android-event-viewer/app/src/main/res/drawable/delete_icon_button.xml index 12fb68eebd..e84bc69184 100644 --- a/extras/pandroid_event_viewer/res/drawable/delete_icon_button.xml +++ b/extras/android-event-viewer/app/src/main/res/drawable/delete_icon_button.xml @@ -1,4 +1,4 @@ - + + + + + diff --git a/extras/pandroid_event_viewer/res/drawable/round_event_item_blue.xml b/extras/android-event-viewer/app/src/main/res/drawable/round_event_item_blue.xml similarity index 84% rename from extras/pandroid_event_viewer/res/drawable/round_event_item_blue.xml rename to extras/android-event-viewer/app/src/main/res/drawable/round_event_item_blue.xml index c92f785f94..80eda4b5a7 100644 --- a/extras/pandroid_event_viewer/res/drawable/round_event_item_blue.xml +++ b/extras/android-event-viewer/app/src/main/res/drawable/round_event_item_blue.xml @@ -1,4 +1,4 @@ - + diff --git a/extras/pandroid_event_viewer/res/drawable/round_event_item_green.xml b/extras/android-event-viewer/app/src/main/res/drawable/round_event_item_green.xml similarity index 84% rename from extras/pandroid_event_viewer/res/drawable/round_event_item_green.xml rename to extras/android-event-viewer/app/src/main/res/drawable/round_event_item_green.xml index 34214ad096..bca8d276f9 100644 --- a/extras/pandroid_event_viewer/res/drawable/round_event_item_green.xml +++ b/extras/android-event-viewer/app/src/main/res/drawable/round_event_item_green.xml @@ -1,4 +1,4 @@ - + diff --git a/extras/pandroid_event_viewer/res/drawable/round_event_item_grey.xml b/extras/android-event-viewer/app/src/main/res/drawable/round_event_item_grey.xml similarity index 84% rename from extras/pandroid_event_viewer/res/drawable/round_event_item_grey.xml rename to extras/android-event-viewer/app/src/main/res/drawable/round_event_item_grey.xml index 184aa46014..fb034f0191 100644 --- a/extras/pandroid_event_viewer/res/drawable/round_event_item_grey.xml +++ b/extras/android-event-viewer/app/src/main/res/drawable/round_event_item_grey.xml @@ -1,4 +1,4 @@ - + diff --git a/extras/pandroid_event_viewer/res/drawable/round_event_item_red.xml b/extras/android-event-viewer/app/src/main/res/drawable/round_event_item_red.xml similarity index 84% rename from extras/pandroid_event_viewer/res/drawable/round_event_item_red.xml rename to extras/android-event-viewer/app/src/main/res/drawable/round_event_item_red.xml index 15c4cc96e9..2102af9a64 100644 --- a/extras/pandroid_event_viewer/res/drawable/round_event_item_red.xml +++ b/extras/android-event-viewer/app/src/main/res/drawable/round_event_item_red.xml @@ -1,4 +1,4 @@ - + diff --git a/extras/pandroid_event_viewer/res/drawable/round_event_item_yellow.xml b/extras/android-event-viewer/app/src/main/res/drawable/round_event_item_yellow.xml similarity index 84% rename from extras/pandroid_event_viewer/res/drawable/round_event_item_yellow.xml rename to extras/android-event-viewer/app/src/main/res/drawable/round_event_item_yellow.xml index 07e2edaf5e..0b2f00baf3 100644 --- a/extras/pandroid_event_viewer/res/drawable/round_event_item_yellow.xml +++ b/extras/android-event-viewer/app/src/main/res/drawable/round_event_item_yellow.xml @@ -1,4 +1,4 @@ - + diff --git a/extras/pandroid_event_viewer/res/drawable/save_icon_button.xml b/extras/android-event-viewer/app/src/main/res/drawable/save_icon_button.xml similarity index 92% rename from extras/pandroid_event_viewer/res/drawable/save_icon_button.xml rename to extras/android-event-viewer/app/src/main/res/drawable/save_icon_button.xml index 4412e49258..8f4f24ecc1 100644 --- a/extras/pandroid_event_viewer/res/drawable/save_icon_button.xml +++ b/extras/android-event-viewer/app/src/main/res/drawable/save_icon_button.xml @@ -1,4 +1,4 @@ - + + %d<---\n",n+1); - } - if (r==0) { - fprintf(outf,"fscanf() didn't get a number\n"); - } - if (r==EOF) { - fprintf(outf,"fscanf() returned EOF\n"); - } - if (feof(inf)) { - fprintf(outf,"EOF on input\n"); - } - if (ferror(inf)) { - fprintf(outf,"Error on input(!)\n"); - } - if (ferror(outf)) { - fprintf(outf,"Error on output(!)\n"); - } - fflush(outf); - } -}; - - - -int main(int argc, char* argv[]) -{ - IncDaemon d; - if (argc==1) { - // Guess whether to run in interactive or daemon mode based on isatty(0) - d.run_default(); - } else if (argc==2) { - string a(argv[1]); - if (a=="-i") { - // Run interactively, i.e. not a daemon at all - d.run_interactively(); - } else if (a=="-d") { - // Run as a daemon - cout << "Daemon about to start. Telnet to port 1705." << endl; - d.run_as_daemon(); - } else { - cerr << "Unrecognised option '" << a << "'" << endl; - exit(1); - } - } else { - cerr << "Too many options" << endl; - exit(1); - } -} diff --git a/extras/anytermd/libpbe/examples/mailform.cc b/extras/anytermd/libpbe/examples/mailform.cc deleted file mode 100644 index b44fc2492c..0000000000 --- a/extras/anytermd/libpbe/examples/mailform.cc +++ /dev/null @@ -1,190 +0,0 @@ -// examples/mailform.cc -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -// MAILFORM -// -------- - -// This is a demonstration of the libpbe CgiParams and SmtpClient -// classes. It is a CGI program that implements the backend of a -// feedback form, or similar. The user completes a form on a web page -// and submits it to this script, which forwards its content as an -// email message. - -// The important bits of the form look like this: -//
-// -// -// -// -//
-// -// feedback_received.html is the page that will be shown when the -// message has been sucessfully sent. -// -// You can also note from which page the user clicked on the "feedback -// form" page using a tad of javascript (which will not mess up -// non-javascript browsers): -// -// (Put this inside the
element, obviously.) - - - -// libpbe includes: - -#include "CgiParams.hh" -#include "SmtpClient.hh" - - -// Standard includes: - -#include - -#include -#include -using namespace std; - - -// The values can be redefined using -D when compiling. You at least -// need to supply sensible values for SENDER and RECIPIENT. - -// From address if the user doesn't specify one: -#ifndef ANON_ADDR - #define ANON_ADDR "anonymous" -#endif - -// From address if the user doesn't specify one: -#ifndef SENDER - #define SENDER "webpage@this_machine" -#endif - -// Define the recipient of the emails here: -#ifndef RECIPIENT - #define RECIPIENT "feedback@some_domain" -#endif - -// SMTP server to connect to: -#ifndef SMTP_SERVER - #define SMTP_SERVER "localhost" -#endif - -// Our own domain name, as announced to the SMTP server when the -// connection is established: -#ifndef OWN_DOMAIN - #define OWN_DOMAIN "localhost" -#endif - - -int main (int argc, char* argv[]) -{ - // This must be called from a web server as a CGI program. Give up - // immediately if that doesn't seem to be the case. (CGI sets - // various environment variables, of which QUERY_STRING is one.) - if (!getenv("QUERY_STRING")) { - cerr << "This program must be invoked using CGI." << endl; - exit(1); - } - - // This is my standard idiom for top-level exception handling, see - // below. - try { try { - - // Create a CgiParams object and load it from the environment. We - // don't need to know the details of what this is doing, just that - // it can cope with all of the variants of CGI encoding. - CgiParams params; - params.load(); - - // Get the form values. get_default() substitutes the supplied - // default if no parameter with that name was supplied. get() - // throws an exception in this case. operator[] can be used if - // you are certain that the parameter is present (like a - // std::map). - string name = params.get_default("name","(none)"); - string email = params.get_default("email","(none)"); - string page = params.get_default("page","(none)"); - string message = params.get("message"); - string nextpage = params.get_default("nextpage","index.html"); - - // Now construct the message. This needs to be a complete message - // in RFC822 (aka RFC2822 which is easier to read) format. - - // Do PLEASE ensure that your DATE is in the correct RFC822 - // format! And, if you ever write code to parse an email, be - // prepared for dates in just about any misformat you can imagine. - // I speak from experience. - char datetime[36]; - time_t t; - time(&t); - struct tm tm; - localtime_r(&t,&tm); - strftime(datetime,sizeof(datetime),"%a, %d %b %Y %H:%M:%S %z",&tm); - - // If the user gave an email address, we can give it here as the - // from address. That makes it easy to reply to the right place. - // On the other hand it might break if you have a spam-filtering - // system like SPF in place (anyone know the magic to avoid this?) - string from_addr = (email=="" || email=="(none)") ? ANON_ADDR : email; - - string rfc822_message = - "Sender: " + string(SENDER) + "\r\n" - "From: " + from_addr + "\r\n" - "To: " + RECIPIENT + "\r\n" - "Subject: " + "Feedback form" + "\r\n" - "Date: " + datetime + "\r\n" - "\r\n" - "Name: " + name + "\r\n" - "Email: " + email + "\r\n" - "Page: " + page + "\r\n\r\n" - "Message:\r\n" + message + "\r\n"; - - // Now create the SMTP client. - // If you want to see what is going on on the SMTP connection, you - // can enable logging to syslog by defining SYSLOG in - // SmtpClient.cc. - SmtpClient smtpc; - // Make an SMTP connection to the server - smtpc.connect(SMTP_SERVER,OWN_DOMAIN); - // Send the message - smtpc.send_msg(SENDER,RECIPIENT,rfc822_message); - // Done, disconnect. - smtpc.disconnect(); - - // Final thing to do is to redirect to the "message sent" HTML page. - cout << "Location: " << nextpage << "\r\n\r\n"; - - // All done. - exit(0); - - - // My standard exception handling magic. This converts any odd - // exception types, like char* from 'throw "something bad";', into - // an Exception. - } RETHROW_MISC_EXCEPTIONS } - catch (Exception& E) { - cout << "content-type: text/plain\r\n\r\n" - << "An error has occured:\r\n"; - E.report(cout); - exit(0); - } -} - diff --git a/extras/anytermd/libpbe/examples/recode.cc b/extras/anytermd/libpbe/examples/recode.cc deleted file mode 100644 index de53c12387..0000000000 --- a/extras/anytermd/libpbe/examples/recode.cc +++ /dev/null @@ -1,64 +0,0 @@ -// examples/recode.cc -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Demo program for libpbe Recoder class -// C++ interface to the recode library -// Convert between character sets e.g. ISO-8859-n to/from unicode -// Also CR to CRLF, do base64 coding and the like - -#include "Recoder.hh" - -// Create a converter as a global object of class Recoder. -// (There is startup overhead; doesn't have to be global, but is probably -// best in most cases. Don't create and destroy them all over the place) - -// In this case, convert LF line endings (the default) to Microsfot-style -// CR-LF line endings. - -Recoder lf_to_crlf ( "", "/CR-LF" ); - -// Parameters to constructor are "from" and "to" character sets. -// See recode documentation for details (info recode) -// Just a few examples: -// ASCII 7-bit ASCII -// ISO-8859-1 8-bit ISO-8859-1 (Latin 1; Western European languages) -// ISO-8859-15 8-bit ISO-8859-15 (ditto plus Euro symbol) -// UTF-8 8-bit Unicode -// UCS-2 16-bit Unicode -// /CR CR for end-of-line (Apple) -// /CR-LF CR-LF for end-of-line (Microsoft) -// [LF is default, use empty string] -// /Base64 Base 64 encoding (used for email attachments) -// /Decimal-1 Output decimal values for each character (for debugging) - -// Having created to Recoder object, use it as a function (on strings) to -// actually do the conversion: - -#include -#include -using namespace std; - -int main(int argc, char* argv[]) -{ - string s = "Hello\nWorld\n"; - string t = lf_to_crlf(s); - cout << s << ' ' << t; -} - -// Need to link with -lrecode - -// Pipe this program into "od -a" to see what is going on. diff --git a/extras/anytermd/libpbe/examples/safe_int.cc b/extras/anytermd/libpbe/examples/safe_int.cc deleted file mode 100644 index 38389ae0c6..0000000000 --- a/extras/anytermd/libpbe/examples/safe_int.cc +++ /dev/null @@ -1,31 +0,0 @@ -#include - -#include "safe_int.hh" - -#include "Exception.hh" - - -using namespace std; -using namespace pbe; - -typedef safe_int<7> safe_byte; - -int main(int argc, char* argv[]) -{ - try { try { - - safe_byte a = 1; - - for (int i=0; i<1024; ++i) { - cout << "a = " << a << "\n"; - a = a * static_cast(3); - } - - return 0; - - } RETHROW_MISC_EXCEPTIONS } - catch (Exception& E) { - E.report(cerr); - } -} - diff --git a/extras/anytermd/libpbe/examples/sort_by.cc b/extras/anytermd/libpbe/examples/sort_by.cc deleted file mode 100644 index f1122156de..0000000000 --- a/extras/anytermd/libpbe/examples/sort_by.cc +++ /dev/null @@ -1,26 +0,0 @@ -#include "sort_by.hh" - -#include - -using namespace std; -using namespace pbe; - - -struct A { - int x; - int y; - bool z; - A(int x_, int y_, bool z_): x(x_), y(y_), z(z_) {} -}; - - -int main() -{ - std::vector v; - v.push_back(A(1,2,true)); - v.push_back(A(3,4,false)); - v.push_back(A(9,0,true)); - - sort_by(v.begin(),v.end(),&A::y); -} - diff --git a/extras/anytermd/libpbe/examples/sort_by_pointee.cc b/extras/anytermd/libpbe/examples/sort_by_pointee.cc deleted file mode 100644 index 1efda788b0..0000000000 --- a/extras/anytermd/libpbe/examples/sort_by_pointee.cc +++ /dev/null @@ -1,26 +0,0 @@ -#include "sort_by_pointee.hh" - -#include - -using namespace std; -using namespace pbe; - - -struct A { - int x; - int y; - bool z; - A(int x_, int y_, bool z_): x(x_), y(y_), z(z_) {} -}; - - -int main() -{ - std::vector v; - v.push_back(new A(1,2,true)); - v.push_back(new A(3,4,false)); - v.push_back(new A(9,0,true)); - - sort_by_pointee(v.begin(),v.end(),&A::y); -} - diff --git a/extras/anytermd/libpbe/examples/sorted_ptr_vector.cc b/extras/anytermd/libpbe/examples/sorted_ptr_vector.cc deleted file mode 100644 index 0a345c5f7f..0000000000 --- a/extras/anytermd/libpbe/examples/sorted_ptr_vector.cc +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include -#include "sorted_ptr_vector.hh" - -using namespace std; -using namespace pbe; - - -struct A { - int x; - int y; - int z; - A(int x_, int y_, int z_): x(x_), y(y_), z(z_) {}; -}; - - -int main() -{ - list l; - l.push_back(new A(1,2,3)); - l.push_back(new A(5,4,3)); - l.push_back(new A(2,3,2)); - - typedef sorted_ptr_vector v_t; - v_t v(l.begin(),l.end()); - - for (v_t::const_iterator i = v.begin(); i != v.end(); ++i) { - cout << (*i)->x << "," << (*i)->y << "," << (*i)->z << "\n"; - } -} - diff --git a/extras/anytermd/libpbe/examples/string_qsort.cc b/extras/anytermd/libpbe/examples/string_qsort.cc deleted file mode 100644 index 269e7e0239..0000000000 --- a/extras/anytermd/libpbe/examples/string_qsort.cc +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include - -#include "string_qsort.hh" - -using namespace std; -using namespace pbe; - - -int main() -{ - typedef vector data_t; - data_t data; - - while (cin.good()) { - string s; - getline(cin,s); - data.push_back(s); - } - - string_qsort(data.begin(), data.end()); - -// Or try this for comparison: -// std::sort(data.begin(), data.end()); -// The result should be the same. - - for (data_t::const_iterator i = data.begin(); - i != data.end(); ++i) { - cout << *i << "\n"; - } -} - diff --git a/extras/anytermd/libpbe/examples/transform_strings.cc b/extras/anytermd/libpbe/examples/transform_strings.cc deleted file mode 100644 index 5b6ad31759..0000000000 --- a/extras/anytermd/libpbe/examples/transform_strings.cc +++ /dev/null @@ -1,59 +0,0 @@ -// examples/transform_strings.cc -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Example for use of StringTransformer class - -// Create a string transformer object to transform strings. -// Create the object once (a bit expensive) and use it many time (cheapish) -// For example: transform a string to escape quotes, make upper case etc. - - -#include "StringTransformer.hh" - -#include -#include -using namespace std; - - -bool is_ctrl(char c) { - return c<32; -} - -string to_escseq(char c) { - ostringstream s; - s << '\\' << static_cast(c); - return s.str(); -} - - -int main(int argc, char* argv[]) -{ - StringTransformer escape_quotes; - escape_quotes.add_cs_rule('\"', "\\\""); // replace " with \" - - StringTransformer escape_ctrl; - escape_ctrl.add_pf_rule(is_ctrl, to_escseq); - - while (1) { - char buf[128]; - cin.getline(buf,sizeof(buf)); - string s(buf); - - cout << "Escape quotes: " << escape_quotes(s) << endl; - cout << "Escape ctrls: " << escape_ctrl(s) << endl; - } -} diff --git a/extras/anytermd/libpbe/include/Array2d.hh b/extras/anytermd/libpbe/include/Array2d.hh deleted file mode 100644 index ef4bb729ef..0000000000 --- a/extras/anytermd/libpbe/include/Array2d.hh +++ /dev/null @@ -1,59 +0,0 @@ -// Array2d.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_Array2d_hh -#define libpbe_Array2d_hh - -#include - - -namespace pbe { - -template > -class Array2d { - -public: - Array2d(unsigned int w, unsigned int h): - data(w*h), width_(w), height_(h) - {} - - Array2d(unsigned int w, unsigned int h, T value): - data(w*h,value), width_(w), height_(h) - {} - - const T& operator()(unsigned int x, unsigned int y) const { - return data[y*width_ + x]; - } - - T& operator()(unsigned int x, unsigned int y) { - return data[y*width_ + x]; - } - - unsigned int width() const { return width_; } - unsigned int height() const { return height_; } - -private: - Impl data; - const unsigned int width_; - const unsigned int height_; -}; - -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/AtomicCounter.hh b/extras/anytermd/libpbe/include/AtomicCounter.hh deleted file mode 100644 index 7b12179276..0000000000 --- a/extras/anytermd/libpbe/include/AtomicCounter.hh +++ /dev/null @@ -1,132 +0,0 @@ -// AtomicCounter.hh -// This file is part of libpbe; see http://decimail.org/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_AtomicCounter_hh -#define libpbe_AtomicCounter_hh - - -// Atomic (i.e. thread-safe) counter. Uses the gcc atomic builtins, except on ARM -// where they are not available. On ARM it uses a swap instruction, using -1 as a sentinel -// value (and has one fewer useful bits as a consequence; code should allow for the counter -// wrapping after 31 or 32 bits). It normally spins if it can't get the lock, but you can define -// YIELD_WHEN_LOCKED to make it yield in that case. Contention should be extremely rare. - -// FIXME this should use atomic.hh. It should also test whether the gcc builtins are -// available. - - -#include - - -#if defined(__arm__) && defined(YIELD_WHEN_LOCKED) -#include -#endif - - -namespace pbe { - - -#ifdef __arm__ - -static inline int32_t arm_atomic_read_and_lock(int32_t& mem) -{ - int32_t val; - do { - // Equivalent to: - // val = mem; - // mem = -1; - asm volatile ("swp\t%0, %1, [%2]" - :"=&r"(val) - :"r" (-1), - "r" (&mem) - :"memory"); - if (val != -1) { - break; - } -#ifdef YIELD_WHEN_LOCKED - sched_yield(); -#endif - } while (1); - return val; -} - -static inline int32_t arm_atomic_inc(int32_t& mem, int32_t inc) -{ - return mem = (arm_atomic_read_and_lock(mem)+inc) & 0x7fffffff; -} - -static inline int32_t arm_atomic_inc_pre(int32_t& mem, int32_t inc) -{ - int32_t r = arm_atomic_read_and_lock(mem); - mem = (r+inc) & 0x7fffffff; - return r; -} - -#endif - - - -class AtomicCounter { - - int c; - -public: - AtomicCounter(): - c(0) - {} - - AtomicCounter(int n): - c(n) - {} - - int operator++() { // ++n -#ifdef __arm__ - return arm_atomic_inc(c, 1); -#else - return __sync_add_and_fetch(&c, 1); -#endif - } - - int operator++(int) { // n++ -#ifdef __arm__ - return arm_atomic_inc_pre(c, 1); -#else - return __sync_fetch_and_add(&c, 1); -#endif - } - - int operator--() { // --n -#ifdef __arm__ - return arm_atomic_inc(c, -1); -#else - return __sync_add_and_fetch(&c, -1); -#endif - } - - int operator--(int) { // n-- -#ifdef __arm__ - return arm_atomic_inc_pre(c, -1); -#else - return __sync_fetch_and_add(&c, -1); -#endif - } -}; - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/Box.hh b/extras/anytermd/libpbe/include/Box.hh deleted file mode 100644 index 30bb702e5a..0000000000 --- a/extras/anytermd/libpbe/include/Box.hh +++ /dev/null @@ -1,134 +0,0 @@ -// include/Box.hh -// This file is part of libpbe -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef pbe_Box_hh -#define pbe_Box_hh - -#include "Point.hh" - -#include - - -namespace pbe { - -template -struct Box { - typedef COORD_T coord_t; - typedef AREA_T area_t; - typedef typename pbe::Point point_t; - - coord_t x0; - coord_t y0; - coord_t x1; - coord_t y1; - - Box() {} - - Box(const Box& other): - x0(other.x0), y0(other.y0), x1(other.x1), y1(other.y1) - {} - - Box(coord_t x0_, coord_t y0_, coord_t x1_, coord_t y1_): - x0(x0_), y0(y0_), x1(x1_), y1(y1_) - {} - - Box(point_t x0y0, point_t x1y1): - x0(x0y0.x), y0(x0y0.y), x1(x1y1.x), y1(x1y1.y) - {} - - Box(point_t x0y0, coord_t w, coord_t h): - x0(x0y0.x), y0(x0y0.y), x1(x0y0.x+w), y1(x0y0.y+h) - {} - - coord_t width() const { return x1-x0; } - coord_t height() const { return y1-y0; } - - point_t x0y0() const { - return point_t(x0,y0); - } - - point_t x0y1() const { - return point_t(x0,y1); - } - - point_t x1y0() const { - return point_t(x1,y0); - } - - point_t x1y1() const { - return point_t(x1,y1); - } - - bool contains(point_t p) const { - return p.x>=x0 && p.x=y0 && p.y -inline bool overlap(const Box& lhs, const Box& rhs) { - return lhs.x0<=rhs.x1 && lhs.x1>=rhs.x0 - && lhs.y0<=rhs.y1 && lhs.y1>=rhs.y0; -} - - -template -inline typename BOX_T::area_t area(BOX_T box) { - return box.width() * box.height(); -} - - -template -inline void expand_box(BOX_T& box, typename BOX_T::point_t point){ - box.x0 = min(box.x0,point.x); - box.y0 = min(box.y0,point.y); - box.x1 = max(box.x1,point.x); - box.y1 = max(box.y1,point.y); -} - - -template -inline BOX_T intersect(const BOX_T& b1, const BOX_T& b2) { - return BOX_T( std::max(b1.x0, b2.x0), - std::max(b1.y0, b2.y0), - std::min(b1.x1, b2.x1), - std::min(b1.y1, b2.y1) ); -} - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/Bunzipper.hh b/extras/anytermd/libpbe/include/Bunzipper.hh deleted file mode 100644 index 6d32b8f1c0..0000000000 --- a/extras/anytermd/libpbe/include/Bunzipper.hh +++ /dev/null @@ -1,89 +0,0 @@ -// include/Bunzipper.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef pbe_Bunzipper_hh -#define pbe_Bunzipper_hh - -#ifdef HAVE_BZIP - -#include - -#include - - -namespace pbe { - - -class Bunzipper { - - bz_stream bz; - -public: - - Bunzipper(bool small_mem = false) { - bz.bzalloc = NULL; - bz.bzfree = NULL; - bz.opaque = NULL; - int r = BZ2_bzDecompressInit(&bz, 0, small_mem?1:0); - switch (r) { - case BZ_CONFIG_ERROR: throw "BZ_CONFIG_ERROR"; - case BZ_PARAM_ERROR: throw "BZ_PARAM_ERROR"; - case BZ_MEM_ERROR: throw std::bad_alloc(); - } - } - - ~Bunzipper() { - BZ2_bzDecompressEnd(&bz); - } - - struct InvalidData {}; - - std::string operator()(const char* in, size_t in_bytes) { - bz.next_in = const_cast(in); - bz.avail_in = in_bytes; - std::string out; - while (bz.avail_in>0) { - char buffer[4096]; - bz.next_out = buffer; - bz.avail_out = sizeof(buffer); - int r = BZ2_bzDecompress(&bz); - switch (r) { - case BZ_PARAM_ERROR: throw "BZ_PARAM_ERROR"; - case BZ_DATA_ERROR: throw InvalidData(); - case BZ_DATA_ERROR_MAGIC: throw InvalidData(); - case BZ_MEM_ERROR: throw std::bad_alloc(); - } - out.append(buffer,sizeof(buffer)-bz.avail_out); - } - return out; - } - - std::string operator()(std::string in) { - return operator()(in.data(),in.length()); - } -}; - - - -}; - - -#endif - -#endif - diff --git a/extras/anytermd/libpbe/include/CgiParams.hh b/extras/anytermd/libpbe/include/CgiParams.hh deleted file mode 100644 index f22b781ef5..0000000000 --- a/extras/anytermd/libpbe/include/CgiParams.hh +++ /dev/null @@ -1,77 +0,0 @@ -// include/CgiParams.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifndef libpbe_CgiParams_hh -#define libpbe_CgiParams_hh - -#include -#include -using namespace std; - - -// CGI parameters - -// Provides a mechanism to access form parameters passed from the -// browser. - -// The CgiParams class makes the parameters available as a key-value -// map (it inherits from map. - -// CGI parameters can be passed from the browser, via the server, in -// three formats. - -// For forms with METHOD="GET" (indicated in the CGI program by the -// REQUEST_METHOD environment variable having the value GET), the -// parameters are passed over HTTP as part of the URI, and arrive at -// the CGI program in the QUERY_STRING environment variable. -// E.g. http://www.foo.com/cgi-bin/blobby.cgi?name=phil&blah=33 Note -// that & or ; can be used to separate paramters; if & is used, it -// must be escaped in HTML. Keys and values are separated by =. Keys -// and values are URI-encoded ( + is space, %nn hex for other odd -// characters). - -// For forms with METHOD="POST", the parameters are passed over HTTP -// in the "body" of the request, and arrive at the CGI program on -// stdin. They can be encoded in one of two ways, indicated by the -// CONTENT_TYPE environment variable. - -// If the content-type is "application/x-www-form-urlencoded", the data -// is in the same format as for the GET method: name=phil&blah=33. - -// If the content-type is multipart/form-data, the data is encoded in -// a MIME style. - - -// The load() method for class CgiParams will determine which -// mechanism is in use, and do whatever decoding is necessary. - - -class CgiParams: public map { -public: - CgiParams(void) {} - void load(void); - - string get(string name) const; - string get_default(string name, string def) const; - -private: - void init_from_urlencoded(string query_string); - void init_from_multipart(string input, string boundary); -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/CgiVars.hh b/extras/anytermd/libpbe/include/CgiVars.hh deleted file mode 100644 index a430c8e391..0000000000 --- a/extras/anytermd/libpbe/include/CgiVars.hh +++ /dev/null @@ -1,72 +0,0 @@ -// src/CgiVars.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_CgiVars_hh -#define libpbe_CgiVars_hh - -#include -#include - -class CgiVars: public std::map { -private: - void setvar(const char* varname); - std::string get(std::string varname) const { - CgiVars::const_iterator i = find(varname); - if (i==end()) { - return ""; - } else { - return i->second; - } - } - -public: - void load(void); - - // Basic variables defined by CGI spec: - std::string get_server_software(void) const { return get("SERVER_SOFTWARE"); } - std::string get_server_name(void) const { return get("SERVER_NAME"); } - std::string get_gateway_interface(void) const { return get("GATEWAY_INTERFACE"); } - std::string get_server_protocol(void) const { return get("SERVER_PROTOCOL"); } - std::string get_server_port(void) const { return get("SERVER_PORT"); } - std::string get_request_method(void) const { return get("REQUEST_METHOD"); } - std::string get_path_info(void) const { return get("PATH_INFO"); } - std::string get_path_translated(void) const { return get("PATH_TRANSLATED"); } - std::string get_script_name(void) const { return get("SCRIPT_NAME"); } - std::string get_query_string(void) const { return get("QUERY_STRING"); } - std::string get_remote_host(void) const { return get("REMOTE_HOST"); } - std::string get_auth_type(void) const { return get("AUTH_TYPE"); } - std::string get_remote_user(void) const { return get("REMOTE_USER"); } - std::string get_remote_ident(void) const { return get("REMOTE_IDENT"); } - std::string get_content_type(void) const { return get("CONTENT_TYPE"); } - std::string get_content_length(void) const { return get("CONTENT_LENGTH"); } - - // Generic HTTP variables: - std::string get_http_user_agent(void) const { return get("HTTP_USER_AGENT"); } - std::string get_http_cookie(void) const { return get("HTTP_COOKIE"); } - std::string get_http_if_modified_since(void) - const { return get("HTTP_IF_MODIFIED_SINCE"); } - std::string get_http_if_none_match(void) const { return get("HTTP_IF_NONE_MATCH"); } - - // Apache specials: - bool get_https(void) const { return get("HTTPS")!=""; } - - static const CgiVars& singleton(void); -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/Condition.hh b/extras/anytermd/libpbe/include/Condition.hh deleted file mode 100644 index 198d66029c..0000000000 --- a/extras/anytermd/libpbe/include/Condition.hh +++ /dev/null @@ -1,267 +0,0 @@ -// include/Condition.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_Condition_hh -#define libpbe_Condition_hh - -// This file provides a class Condition, which implements a condition variable -// compatible with N2447's condition_variable[_any?]. - -// If we have Futex - i.e. if this is Linux - then we implement Condition directly -// on top of Futex. Otherwise we implement it using pthread_condition. - -#include "Futex.hh" -#include "atomic.hh" -#include "HPtime.hh" - -#include - -#include - -#include - - -#if defined(PBE_HAVE_FUTEX) && defined(PBE_HAVE_ATOMICS) - -#include "Unlock.hh" - - -namespace pbe { - - -class Condition: boost::noncopyable { - - uint32_t waiters; - uint32_t eventcount; - Futex fut; - -public: - Condition(): - waiters(0), // Keep track of the number of waiting threads so that - // the notify operations can be no-ops in the case where - // there are no waiters. - eventcount(0), // Incremented on each notify_all. This is needed to - // detect any notify_all that occurs between unlocking - // the mutex and waiting on the futex. - fut(eventcount) {} - - ~Condition() {} - // Note that ~Condition does not wait for any waiters to stop waiting; - // undefined behaviour results if a Condition is destructed while a thread - // is still waiting on it. - - void notify_one() { - if (atomic_read(waiters)==0) { - return; - } - unsigned int n_woken = fut.wake(1); - if (n_woken==0) { - notify_all(); // WHY??? - return; - } - atomic_dec(waiters,n_woken); - } - - void notify_all() { - if (atomic_read(waiters)==0) { - return; - } - atomic_inc(eventcount); - unsigned int n_woken = fut.wake(INT_MAX); - atomic_dec(waiters,n_woken); - } - - template - void wait(LOCK_T& lock) { - atomic_inc(waiters); - uint32_t initial_eventcount = atomic_read(eventcount); - Unlock ul(*lock.mutex()); // Must not throw. - // If this could throw, we would need to --waiters. - do { - // fut.wait can return spuriously e.g. if a signal is handled. - // We retry in this case, so Condition.wait does not return spuriously. - fut.wait(initial_eventcount); - } while (atomic_read(eventcount)==initial_eventcount); // NO broken for notify_one - } - - template - void wait(LOCK_T& lock, Predicate pred) { - // Note that the following "trivial" implementation is specified by N2447; - // if notify_one() is called, the thread that is woken may test its condition - // and sleep again. There's no guarantee that the notification is delivered - // to a thread whose condition will evaluate true. So notify_one() is not - // useful in combination with predicated wait, unless perhaps all waiters - // have the same predicate. - while (!pred()) { - wait(lock); - } - } - - - template - bool timed_wait(LOCK_T& lock, HPtime abs_time) { - atomic_inc(waiters); - uint32_t initial_eventcount = atomic_read(eventcount); - Unlock ul(*lock.mutex()); // Must not throw. - // If this could throw, we would need to --waiters. - do { - // fut.wait can return spuriously e.g. if a signal is handled. - // We retry in this case, so Condition.wait does not return spuriously. - HPtime now = HPtime::now(); - if (now>abs_time || !fut.timed_wait(initial_eventcount, abs_time-now)) { - return false; - } - } while (atomic_read(eventcount)==initial_eventcount); // NO broken for notify_one - return true; - } - - template - bool timed_wait(LOCK_T& lock, float rel_time) { - HPtime abs_time = HPtime::now() + rel_time; - return timed_wait(lock,abs_time); - } - - template - bool timed_wait(Lock& lock, ::time_t abs_time, Predicate pred) { - // See above. If the predicate becomes true and the timeout expires at - // the same time, we're supposed to return true indicating that the predicate - // was true. - while (!pred()) { - if (!timed_wait(lock,abs_time)) { - return pred(); - } - } - return true; - } - - // native_handle not provided -}; - -}; - -#else - - -#include - -#include "Exception.hh" - - -namespace pbe { - - -class Condition: boost::noncopyable { - - pthread_cond_t cond; - -public: - Condition() { - int r = pthread_cond_init(&cond, NULL); - if (r!=0) { - pbe::throw_ErrnoException("pthread_cond_init()",r); - } - } - - ~Condition() { - pthread_cond_destroy(&cond); - } - - void notify_one() { - int r = pthread_cond_signal(&cond); - if (r!=0) { - pbe::throw_ErrnoException("pthread_cond_signal()",r); - } - } - - void notify_all() { - int r = pthread_cond_broadcast(&cond); - if (r!=0) { - pbe::throw_ErrnoException("pthread_cond_broadcast()",r); - } - } - - template - void wait(LOCK_T& lock) { - int r = pthread_cond_wait(&cond, lock.mutex()->native_handle()); - if (r!=0) { - pbe::throw_ErrnoException("pthread_cond_wait()",r); - } - } - - template - void wait(LOCK_T& lock, Predicate pred) { - // Note that the following "trivial" implementation is specified by N2447; - // if notify_one() is called, the thread that is woken may test its condition - // and sleep again. There's no guarantee that the notification is delivered - // to a thread whose condition will evaluate true. So notify_one() is not - // useful in combination with predicated wait, unless perhaps all waiters - // have the same predicate. - while (!pred()) { - wait(lock); - } - } - - template - bool timed_wait(LOCK_T& lock, ::time_t abs_time) { - timespec ts; - ts.tv_sec = abs_time; - ts.tv_nsec = 0; - int r = pthread_cond_timedwait(&cond, lock.mutex()->native_handle(), &ts); - switch (r) { - case 0: return true; - case ETIMEDOUT: return false; - default: pbe::throw_ErrnoException("pthread_cond_timedwait()",r); - } - // NOT REACHED - return true; - } - - template - bool timed_wait(LOCK_T& lock, float rel_time) { - // This limits resolution to whole seconds. - return timed_wait(lock, static_cast(time(NULL)+rel_time)); - } - - template - bool timed_wait(Lock& lock, ::time_t abs_time, Predicate pred) { - // See above. If the predicate becomes true and the timeout expires at - // the same time, we're supposed to return true indicating that the predicate - // was true. - while (!pred()) { - if (!timed_wait(lock,abs_time)) { - return pred(); - } - } - return true; - } - - pthread_cond_t* native_handle() { - return &cond; - } - -}; - - -}; - - -#endif - -#endif - - diff --git a/extras/anytermd/libpbe/include/ConditionAll.hh b/extras/anytermd/libpbe/include/ConditionAll.hh deleted file mode 100644 index db23e2f383..0000000000 --- a/extras/anytermd/libpbe/include/ConditionAll.hh +++ /dev/null @@ -1,138 +0,0 @@ -// include/ConditionAll.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_ConditionAll_hh -#define libpbe_ConditionAll_hh - -// This file provides a class ConditionAll, which implements a condition variable -// compatible with N2447's condition_variable_any, except that it provides -// only notify_all() and not notify_one(). - -// FIXME this should be updated to match Condition. - - -#include - -#include "atomic.hh" -#include "Futex.hh" -#include "Unlock.hh" - -#include - - -namespace pbe { - -class ConditionAll: boost::noncopyable { - - uint32_t waiters; - uint32_t eventcount; - Futex fut; - -public: - ConditionAll(): - waiters(0), // Keep track of the number of waiting threads so that - // the notify operations can be no-ops in the case where - // there are no waiters. - // In an application where there are always waiters, this - // is an unnecessary overhead. - eventcount(0), // Incremented on each notify_all. This is needed to - // detect any notify_all that occurs between unlocking - // the mutex and waiting on the futex. - fut(eventcount) {} - - ~ConditionAll() {} - // Note that ~ConditionAll does not wait for any waiters to stop waiting; - // undefined behaviour results if a ConditionAll is destructed while a thread - // is still waiting on it. - - void notify_all() { - if (atomic_read(waiters)==0) { - return; - } - atomic_inc(eventcount); - uint32_t n_woken = fut.wake(std::numeric_limits::max()); - atomic_dec(waiters,n_woken); - } - - template - void wait(LOCK_T& lock) { - atomic_inc(waiters); - uint32_t initial_eventcount = atomic_read(eventcount); - Unlock ul(*(lock.mutex())); - // Must not throw. FIXME is this a valid assumption? - // If this could throw, we would need to --waiters. - do { - // fut.wait can return spuriously e.g. if a signal is handled. - // We retry in this case, so ConditionAll.wait does not return spuriously. - fut.wait(initial_eventcount); - } while (atomic_read(eventcount)==initial_eventcount); - } - - template - void wait(LOCK_T& lock, Predicate pred) { - while (!pred()) { - wait(lock); - } - } - - // What type to use for the timeout? N2447 species that it's 'system_time', - // which doesn't mean anything to me. Note that it's an absolute time, - // in contrast to the relative timeout in Mutex::timed_lock - I'm not sure why. - // I'll use time_t, though perhaps struct timeval would be more appropriate - // as it includes a microseconds field. - template - bool timed_wait(LOCK_T& lock, ::time_t abs_time) { - ::time_t start_time = time(NULL); - atomic_inc(waiters); - uint32_t initial_eventcount = atomic_read(eventcount); - Unlock ul(*(lock.mutex())); - // Must not throw. FIXME is this a valid assumption? - // If this could throw, we would need to --waiters. - do { - // fut.timed_wait can return spuriously e.g. if a signal is handled. - // We retry in this case, so ConditionAll.wait does not return spuriously. - if (!fut.timed_wait(initial_eventcount, static_cast(abs_time-start_time))) { - // Timed out. - atomic_dec(waiters); - return false; - } - } while (atomic_read(eventcount)==initial_eventcount); - return true; - } - - template - bool timed_wait(Lock& lock, ::time_t abs_time, Predicate pred) { - // If the predicate becomes true and the timeout expires at - // the same time, we're supposed to return true indicating that the predicate - // was true. - while (!pred()) { - if (!timed_wait(lock,abs_time)) { - return pred(); - } - } - return true; - } - - // native_handle not provided -}; - -}; - -#endif - - diff --git a/extras/anytermd/libpbe/include/Daemon.hh b/extras/anytermd/libpbe/include/Daemon.hh deleted file mode 100644 index 2e7596fc85..0000000000 --- a/extras/anytermd/libpbe/include/Daemon.hh +++ /dev/null @@ -1,75 +0,0 @@ -// include/Daemon.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2004-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_Daemon_hh -#define libpbe_Daemon_hh - -#include -#include - -#include "FileDescriptor.hh" -#include "Mutex.hh" -#include "Condition.hh" - -// TODO: -// Sending EOF doesn't do anything (sigpipe?) -// Worry about other signals -// Spurious thread on first connection (is it syslog???) - - -class Daemon { -public: - static const int default_max_sessions = 25; - - Daemon(short p, - std::string pn, - int sf = LOG_LOCAL0, - std::string u="", - std::string d="", - int max_sessions_=0, - bool accept_local_only_=false); - virtual ~Daemon(); - - void run_interactively(void); - void run_as_daemon(bool background = true); - void run_default(void); - - virtual void startup(void) {}; - virtual void session(pbe::FileDescriptor& in_fd, pbe::FileDescriptor& out_fd) = 0; - -private: - const short port; - const std::string progname; - const int syslog_facility; - const std::string username; - const std::string dir; - const int max_sessions; - const bool accept_local_only; - - typedef pbe::Mutex<> n_sessions_mutex_t; - n_sessions_mutex_t n_sessions_mutex; - typedef pbe::Condition n_sessions_condition_t; - n_sessions_condition_t n_sessions_condition; - int n_sessions; - -public: // really private - void decrement_session_count(void); -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/Database.hh b/extras/anytermd/libpbe/include/Database.hh deleted file mode 100644 index bee16d70a8..0000000000 --- a/extras/anytermd/libpbe/include/Database.hh +++ /dev/null @@ -1,678 +0,0 @@ -// src/Database.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2004 - 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_Database_hh -#define libpbe_Database_hh - -#include "Exception.hh" -#include "FileDescriptor.hh" -#include "endian.hh" - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - - -namespace pbe { - -// The maximum number of query parameters is set by this macro, which user code can -// define before #including this file. -#ifndef PBE_DB_MAX_QUERY_PARAMS -#define PBE_DB_MAX_QUERY_PARAMS 7 -#endif - -// Making it too large has the disadvantage that error messages become even more -// incomprehensible, and may also increase compile times. - - -// private: - -// We support queries with variable numbers of parameters by means of -// sentinel default paramter values. The sentinel is of a special empty type -// null_t. -// ? Could we just use void for this ? - -struct null_t {}; -static const null_t nullval = null_t(); - - -// We need to map between C++ types and PostgreSQL types in query parameters. -// This enum lists all of the PostgreSQL types that we map to, plus two -// sentinels: unknown_type indicates that no PostgreSQL type corresponds to the -// supplied C++ type, and should result in a compile-time error; null_type is used -// in unused arguments slots in the varargs-like query syntax. - -enum typecode_t { /*unknown_type=0,*/ null_type, - text_type, numeric_type, timestamptz_type, bytea_type, - float_type, double_type, - typecode_t_max }; - -// Now we use template specialisation to get the typecode_t corresponding to a C++ -// type at compile time. get_typecode() is the typecode_t for type T. - -// The generic template is not implemented anywhere, so it will fail at link -// time for these unsupported types. -template inline typecode_t get_typecode(void); - -template <> inline typecode_t get_typecode(void) { return null_type; } -template <> inline typecode_t get_typecode(void) { return text_type; } -template <> inline typecode_t get_typecode(void) { return numeric_type; } -template <> inline typecode_t get_typecode(void) { return timestamptz_type; } -template <> inline typecode_t get_typecode(void) { return float_type; } -template <> inline typecode_t get_typecode(void) { return double_type; } - -// public: - -// class Database represents a connection to the database server. -// It's marked non-copyable because it's not clear what should be done with -// the underlying libpq connection object in that case. -class Database: public boost::noncopyable { -public: - - // Connect to the database server using the supplied connection info. - Database(std::string conninfo); - - // Disconnect on destruction. - ~Database(); - - // Get the file descriptor for the connction to the server. - // This is useful if you want to use select() to wait for asynchronous - // notifications from the server. You obviously mustn't read or write to - // it. - const pbe::FileDescriptor& get_fd(void) const; - - // Return any asynchronous notifications received from the server. - std::string get_any_notification(void); - -private: - // libpq data structure representing the connection. - PGconn* pgconn; - - // Connection file descriptor. - pbe::FileDescriptor conn_fd; - - // This is needed so that we can support nested transactions. - // (PostgreSQL now has built-in support for this, so it should be reviewed.) - bool transaction_in_progress; - - // Run arbitary queries - void exec_sql(std::string cmd); - - friend class QueryCore; - friend class Transaction; -}; - - -// Exceptions thrown by the Database functions: - -class DatabaseException: public Exception { -public: - DatabaseException(PGconn* pgconn, std::string doing_what_): - postgres_error(PQerrorMessage(pgconn)), - doing_what(doing_what_) {} - void report(std::ostream& s) const; -private: - std::string postgres_error; - std::string doing_what; -}; - -class QueryFailed: public DatabaseException { -public: - QueryFailed(PGconn* pgconn, std::string query): - DatabaseException(pgconn,"Executing query " + query) {} -}; - -class TypeError: public DatabaseException { -public: - TypeError(PGconn* pgconn): - DatabaseException(pgconn,"Type error") {} -}; - - -// Transactions. Typical usage: -// { -// Transaction t(db); -// ... run queries ... -// t.commit(); -// } -// If the transaction goes out of scope without commit() having been called, e.g. -// because an exception was thrown and not caught, the transaction will be rolled -// back. -// TODO: PostgreSQL now has some sort of built-in support for nested -// transactions. -class Transaction: public boost::noncopyable { -public: - Transaction(Database& database_); - ~Transaction(); - void commit(void); -private: - Database& database; - bool nested; - bool committed; -}; - - -// Convert from the representation returned by libpq to a normal C++ type. - -template -T decode_pq_res(const char* data, int length __attribute__((unused))); - -template <> -inline int decode_pq_res(const char* data, int length __attribute__((unused))) { - const int* valp = reinterpret_cast(data); - return ntohl(*valp); -} - -template <> -inline uint64_t decode_pq_res(const char* data, int length __attribute__((unused))) { - const uint64_t* valp = reinterpret_cast(data); - return ntoh64(*valp); -} - -template <> -inline int64_t decode_pq_res(const char* data, int length __attribute__((unused))) { - const int64_t* valp = reinterpret_cast(data); - return ntoh64(*valp); -} - -template <> -inline time_t decode_pq_res(const char* data, int length __attribute__((unused))) { - // Timestamp values are returned by PostgreSQL as 64-bit microsecond - // values. 946684800000000 is a magic number to convert to the Unix - // 1970 epoch. - int64_t t = decode_pq_res(data, length); - return t/1000000 + 946684800; -} - -template <> -inline std::string decode_pq_res(const char* data, int length __attribute__((unused))) { - return std::string(data,length); -} - -union float_or_int { - float f; - int i; -}; - -template <> -inline float decode_pq_res(const char* data, int length __attribute__((unused))) { - const float_or_int* uptr = reinterpret_cast(data); - float_or_int ucopy; - ucopy.i = ntohl(uptr->i); - return ucopy.f; -} - -union double_or_two_ints { - double d; - int i[2]; -}; - -template <> -inline double decode_pq_res(const char* data, int length __attribute__((unused))) { - const double_or_two_ints* uptr = reinterpret_cast(data); - double_or_two_ints ucopy; - ucopy.i[0] = ntohl(uptr->i[0]); - ucopy.i[1] = ntohl(uptr->i[1]); - return ucopy.d; -} - - -// Result of a SELECT query: -class Result { -public: - // Construct from the result object from libpq - Result(boost::shared_ptr); - - // For insert, update and delete statements the result tells us how many - // rows were inserted, updated or deleted, using the following: - int get_rows_changed(void) const; - - // Everything below here is for getting at the table returned for a select - // statement: - - // The size of the table - const int rows; - const int cols; - - // Map between column names and numbers - int column(std::string name) const ; - std::string column_name(int pos) const; - - // Get data - // The pointer returned by rawget is valid for as long as the Result object exists. - char* rawget(int row, int col) const; - - int getlength(int row, int col) const; - - template - T get_nocheck(int row, int col) const { - return decode_pq_res(rawget(row,col),getlength(row,col)); - } - - template - T get(int row, int col) const { - check_column_type(col); - return get_nocheck(row,col); - } - - template - T get(int row, std::string colname) const { - return get(row, column(colname)); - } - -#if 0 - // ... does this work? - template - T operator()(int row, int col) const { - } - - template - T operator()(int row, std::string colname) const { - return operator()(row, column(colname)); - } -#endif - - bool is_null(int row, int col) const; - - bool is_null(int row, std::string colname) const { - return is_null(row, column(colname)); - } - - // Column types - typecode_t column_typecode(int col) const; - - template - void check_column_type(int col) const { - if (column_typecode(col)!=get_typecode()) { - throw StrException("type error for column " -+boost::lexical_cast(col)+", expecting typecode " -+boost::lexical_cast(get_typecode())+" but got typecode " -+boost::lexical_cast(column_typecode(col))); - } - } - -private: - boost::shared_ptr res; -}; - - -// Alternative result for a query that generates a single column. -// Values can be accessed using (), e.g. r(i). -template -class ColumnResult: public Result { -public: - ColumnResult(Result r): Result(r) { - if (cols!=1) { - throw "Single column expected"; - } - if (rows>0) { - check_column_type(0); - } - } - T operator ()(int row) const { return get(row,0); } - bool is_null (int row) const { return Result::is_null(row,0); } - class const_iterator: - public boost::iterator_facade { - public: - const_iterator(): - res(NULL), row(0) {} - const_iterator(const const_iterator& other): - res(other.res), row(other.row) {} - private: - const ColumnResult& res; - int row; - friend class ColumnResult; - const_iterator(const ColumnResult& res_, int row_): - res(res_), row(row_) {} - friend class boost::iterator_core_access; - void increment() { ++row; } - void decrement() { --row; } - void advance(int n) { row+=n; } - int distance_to(const_iterator other) { return other.row-row; } - bool equal(const const_iterator& other) const { - return row==other.row && &res==&(other.res); - } - const T dereference() const { - return res(row); - } - }; - const_iterator begin() const { - return const_iterator(*this,0); - } - const_iterator end() const { - return const_iterator(*this,rows); - } -}; - - -// Alternative result for a query that generates a single value -// (e.g. a "count(*)" query). -// This is convertable to the type of that value. -template -class SingletonResult: public Result { -public: - SingletonResult(Result r): Result(r) { - if (rows!=1 || cols!=1) { - throw "Singleton expected"; - } - check_column_type(0); - } - operator T () const { return get(0,0); } - bool is_null () const { return Result::is_null(0,0); } -}; - - -// Alternative result for a query that generates a zero or one values. -// This is convertable to the type of that value. -template -class OptResult: public Result { -public: - OptResult(Result r): Result(r) { - if (rows>1 || cols!=1) { - throw "Zero or one values expected"; - } - if (rows==1) { - check_column_type(0); - } - } - operator T () { return get(0,0); } - bool is_null () { return Result::is_null(0,0); } - bool empty() { return rows==0; } -}; - - -// private: - -// Generate names for prepared statements -class statement_name_t: public std::string { -public: - statement_name_t(void): - std::string("stmt_"+boost::lexical_cast(counter++)) - {} -private: - static int counter; -}; - - -// Most of the work of Query is delagated to QueryCore which is not a template -// class and so need not be coded inline. -// This is "semi-private": code can use it if it needs to pass more than -// PBE_DB_MAX_QUERY_PARAMS paramters to a query, but if that's not necessary then it -// should not be used. - -class QueryCore { -public: - QueryCore(Database& database_, std::string querystr_, int nparams, - typecode_t* argtypecodes, int* lengths, int* formats); - ~QueryCore(); - Result operator()(const char* enc_args[]); - Result runonce(const char* enc_args[]); -private: - Database& database; - const std::string querystr; - const bool params_ok; - const statement_name_t statement_name; - int nparams; - int* param_lengths; - int* param_formats; - Oid* argoids; - bool prepared; - void prepare(void); -}; - - -// Convert from C++ types to the representation passed to libpq. -// Types are either binary or character. Binary is used for numeric types and -// character is used for text types. Binary types must be in network byte -// order. -// This uses template specialisation. -// It's OK for these function to modify their paramters in place. - -template -inline const char* encode_pq_arg(T& t); - -template <> -inline const char* encode_pq_arg(null_t& i __attribute__((unused)) ) { - return NULL; -} - -template <> -inline const char* encode_pq_arg(int& i) { - i = htonl(i); - return reinterpret_cast(&i); -} - -template <> -inline const char* encode_pq_arg(uint64_t& i) { - i = hton64(i); - return reinterpret_cast(&i); -} - -template <> -inline const char* encode_pq_arg(int64_t& i) { - i = hton64(i); - return reinterpret_cast(&i); -} - -template <> -inline const char* encode_pq_arg(time_t& t) { -// No! This leaks! - int64_t* iptr = new int64_t; - *iptr = static_cast(t-946684800)*1000000; - return encode_pq_arg(*iptr); -} - -template <> -inline const char* encode_pq_arg(std::string& s) { - return s.c_str(); -} - -static inline float htonfloat(float f) { - uint32_t i; - memcpy(&i,&f,4); - i = htonl(i); - float r; - memcpy(&r,&i,4); - return r; -} - -template <> -inline const char* encode_pq_arg(float& f) { - f = htonfloat(f); - return reinterpret_cast(&f); -} - -template <> -inline const char* encode_pq_arg(double& d) { - uint32_t* ptr = reinterpret_cast(&d); - ptr[0] = htonl(ptr[0]); - ptr[1] = htonl(ptr[1]); - return reinterpret_cast(&d); -} - - -// We need to know the size of the encoded data. -// In most cases this is sizeof(T), but there are exceptions when the -// encoding process changes the size. - -template -inline size_t get_enc_type_size(void) { return sizeof(T); } - -template <> -inline size_t get_enc_type_size(void) { return 8; } - - - -// The Boost preprocessor library is used to build query parameter lists (etc.) with -// multiple argumnets. - -#define PBE_DB_Q_TEMPLATE_PARAM(z,n,data) typename T##n=null_t -#define PBE_DB_Q_TEMPLATE_PARAMS BOOST_PP_ENUM(PBE_DB_MAX_QUERY_PARAMS,PBE_DB_Q_TEMPLATE_PARAM,) -// Expands to e.g. typename T0=null_t,typename T1=null_t - -#define PBE_DB_Q_OP_APPLY_PARAM(z,n,data) T##n arg##n=nullval -#define PBE_DB_Q_OP_APPLY_PARAMS BOOST_PP_ENUM(PBE_DB_MAX_QUERY_PARAMS,PBE_DB_Q_OP_APPLY_PARAM,) -// Expands to e.g. T0 arg0=nullval,T1 arg1=nullval - -#define PBE_DB_Q_BASE_TEMPL_PARAM(z,n,data) T##n -#define PBE_DB_Q_BASE_TEMPL_PARAMS BOOST_PP_ENUM(PBE_DB_MAX_QUERY_PARAMS,PBE_DB_Q_BASE_TEMPL_PARAM,) -// Expands to e.g. T0,T1 - -#define PBE_DB_Q_BASE_OP_APPLY_PARAM(z,n,data) arg##n -#define PBE_DB_Q_BASE_OP_APPLY_PARAMS BOOST_PP_ENUM(PBE_DB_MAX_QUERY_PARAMS,PBE_DB_Q_BASE_OP_APPLY_PARAM,) -// Expands to e.g. arg0,arg1 - - -// This base class is used to form the parameters passed to Query, below, into arrays -// that can be passed to QueryCore. - -template struct QueryBase { - typecode_t typecodes[PBE_DB_MAX_QUERY_PARAMS]; - int lengths[PBE_DB_MAX_QUERY_PARAMS]; - int formats[PBE_DB_MAX_QUERY_PARAMS]; - - QueryBase() { -#define PBE_DB_QB_INIT_ONE(z,n,data) \ - typecodes[n]=get_typecode(); \ - lengths[n]=get_enc_type_size();\ - formats[n]=!boost::is_same::value; -BOOST_PP_REPEAT(PBE_DB_MAX_QUERY_PARAMS,PBE_DB_QB_INIT_ONE,) - } -}; - - -// Prepare and run a query. Typical usage: -// Query insert_item(db,"insert into items(name,qty) values ($1,$2)"); -// insert_item("nut",100); -// insert_item("bolt",102); -// The query can have up to PBE_DB_MAX_QUERY_PARAMS parameters. This limit can be -// increased at the top of this file. - -template class Query: - private QueryBase { -public: - - // Create a query. SQL is supplied in querystr with parameters indicated by - // $1, $2 etc. C++ types of these parameters are the template paramters. - Query(Database& database, std::string querystr): - core(database, querystr, PBE_DB_MAX_QUERY_PARAMS, - QueryBase::typecodes, - QueryBase::lengths, - QueryBase::formats) - {} - - // Run a query. It is prepared the first time that it is run. - Result operator()(PBE_DB_Q_OP_APPLY_PARAMS) { - const char* arg_cs[PBE_DB_MAX_QUERY_PARAMS]; -#define PBE_DB_Q_OP_APPLY_ONE(z,n,data) \ - T##n arg##n##_c = arg##n; \ - arg_cs[n] = encode_pq_arg(arg##n##_c); -BOOST_PP_REPEAT(PBE_DB_MAX_QUERY_PARAMS,PBE_DB_Q_OP_APPLY_ONE,) - return core(arg_cs); - } - - // Run a query immediately, without preparation. Use this for queries that will only be - // run once. - Result runonce(PBE_DB_Q_OP_APPLY_PARAMS) { - const char* arg_cs[PBE_DB_MAX_QUERY_PARAMS]; -#define PBE_DB_Q_RUNONCE_ONE(z,n,data) \ - T##n arg##n##_c = arg##n; \ - arg_cs[n] = encode_pq_arg(arg##n##_c); -BOOST_PP_REPEAT(PBE_DB_MAX_QUERY_PARAMS,PBE_DB_Q_RUNONCE_ONE,) - return core.runonce(arg_cs); - } - - -private: - QueryCore core; -}; - - -// A query that returns a ColumnResult. -template -class ColumnQuery: public Query< PBE_DB_Q_BASE_TEMPL_PARAMS> { -public: - typedef ColumnResult result_t; - - ColumnQuery(Database& database, std::string querystr): - Query(database,querystr) - {} - - result_t operator()(PBE_DB_Q_OP_APPLY_PARAMS) { - return Query::operator()(PBE_DB_Q_BASE_OP_APPLY_PARAMS); - } - - result_t runonce(PBE_DB_Q_OP_APPLY_PARAMS) { - return Query::runonce(PBE_DB_Q_BASE_OP_APPLY_PARAMS); - } -}; - - -// A query that returns a SingeltonResult. In this case there's no need to -// delcare the result object, thanks to implicit type conversion. For -// example: int a = query(param); -template -class SingletonQuery: public Query< PBE_DB_Q_BASE_TEMPL_PARAMS> { -public: - typedef SingletonResult result_t; - - SingletonQuery(Database& database, std::string querystr): - Query(database,querystr) - {} - - result_t operator()(PBE_DB_Q_OP_APPLY_PARAMS) { - return Query::operator()(PBE_DB_Q_BASE_OP_APPLY_PARAMS); - } - - result_t runonce(PBE_DB_Q_OP_APPLY_PARAMS) { - return Query::runonce(PBE_DB_Q_BASE_OP_APPLY_PARAMS); - } -}; - - -// A query that returns a OptResult. -template -class OptQuery: public Query< PBE_DB_Q_BASE_TEMPL_PARAMS> { -public: - typedef OptResult result_t; - - OptQuery(Database& database, std::string querystr): - Query(database,querystr) - {} - - result_t operator()(PBE_DB_Q_OP_APPLY_PARAMS) { - return Query::operator()(PBE_DB_Q_BASE_OP_APPLY_PARAMS); - } - - result_t runonce(PBE_DB_Q_OP_APPLY_PARAMS) { - return Query::runonce(PBE_DB_Q_BASE_OP_APPLY_PARAMS); - } -}; - - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/Date.hh b/extras/anytermd/libpbe/include/Date.hh deleted file mode 100644 index 8ba20b8669..0000000000 --- a/extras/anytermd/libpbe/include/Date.hh +++ /dev/null @@ -1,126 +0,0 @@ -// src/Date.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_Date_hh -#define libpbe_Date_hh - -#include - -#include - -#include - - -namespace pbe { - - - static int days_in_month_[] = { 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - - struct Date { - - uint16_t year; - uint8_t month; - uint8_t day; - - Date() {} - - Date(int year_, int month_, int day_): - year(year_), month(month_), day(day_) {} - - Date(time_t t) { - struct tm b; - localtime_r(&t, &b); - year = b.tm_year + 1900; - month = b.tm_mon + 1; - day = b.tm_mday; - } - - bool operator<(const Date& rhs) const { - return (year1) { - --day; - } else { - if (month>1) { - --month; - } else { - month=12; - --year; - } - day = days_in_month(); - } - return *this; - } - - }; - - - inline std::ostream& operator<<(std::ostream& strm, Date d) { - strm << d.year << "-" << static_cast(d.month) << "-" << static_cast(d.day); - return strm; - } - -} - - -#endif diff --git a/extras/anytermd/libpbe/include/DateTime.hh b/extras/anytermd/libpbe/include/DateTime.hh deleted file mode 100644 index ded47c09b3..0000000000 --- a/extras/anytermd/libpbe/include/DateTime.hh +++ /dev/null @@ -1,118 +0,0 @@ -// src/DateTime.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_DateTime_hh -#define libpbe_DateTime_hh - -#include - -#include - -#include "Date.hh" -#include "Time.hh" -#include "Exception.hh" - - -namespace pbe { - - struct DateTime { - - Date date; - Time time; - - DateTime() {} - - DateTime(int year, int month, int day, - int hour=0, int minute=0, int second=0): - date(year,month,day), - time(hour,minute,second) {} - - DateTime(time_t t) { - struct tm b; - localtime_r(&t, &b); // Or gmtime_r() ??? - date.year = b.tm_year + 1900; - date.month = b.tm_mon + 1; - date.day = b.tm_mday; - time.hour = b.tm_hour; - time.minute = b.tm_min; - time.second = b.tm_sec; - } - - DateTime(Date date_): - date(date_), time(0,0,0) {} - - DateTime(Date date_, Time time_): - date(date_), time(time_) {} - - bool operator<(const DateTime& rhs) const { - return (date -#include - -#include - -namespace pbe { - -class Directory { - -public: - Directory(std::string dirname_); - ~Directory(); - - struct Entry { - std::string leafname; - std::string pathname; - }; - - class const_iterator { - public: - ~const_iterator(); - void operator++(void); - Entry operator*(void) const {return this_entry;} - const Entry* operator->(void) const {return &this_entry;} - bool operator==(const const_iterator& r) const; - bool operator!=(const const_iterator& r) const { return !((*this)==r); } - friend class Directory; - private: - std::string dirname; - DIR* dir; - bool at_end; - Entry this_entry; - const_iterator(void); - const_iterator(std::string dirname_); - void read_next(void); - }; - - const_iterator begin(void) const; - const_iterator end(void) const; - -private: - std::string dirname; - -}; - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/Exception.hh b/extras/anytermd/libpbe/include/Exception.hh deleted file mode 100644 index fa9ac9d5b7..0000000000 --- a/extras/anytermd/libpbe/include/Exception.hh +++ /dev/null @@ -1,189 +0,0 @@ -// src/Exception.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2004-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_Exception_hh -#define libpbe_Exception_hh - -#include - -#include -#include - - -namespace pbe { - -class Exception -{ -public: - Exception(void): exit_status(1) {} - virtual ~Exception() {} - virtual void report(std::ostream& s) const = 0; - const int exit_status; -}; - - -class StrException: public Exception -{ -private: - const std::string msg; -public: - StrException(std::string s): msg(s) {} - void report(std::ostream& s) const { s << msg << std::endl; } -}; - - -class StdException: public Exception -{ -private: - std::string msg; -public: - StdException(std::exception& e): msg(e.what()) {} - void report(std::ostream& s) const { s << msg << std::endl; } -}; - - -class UnknownException: public Exception -{ -public: - void report(std::ostream& s) const; -}; - - -class ErrnoException: public Exception -{ -private: - int error_number; - std::string doing_what; - -public: - ErrnoException(std::string dw, int errno_=errno): error_number(errno_), doing_what(dw) {} - int get_errno(void) { return error_number; } - void report(std::ostream& s) const; -}; - - -struct NoSuchFileOrDirectory: public ErrnoException { - NoSuchFileOrDirectory(std::string dw): - ErrnoException(dw) {} -}; - -struct ConnectionRefused: public ErrnoException { - ConnectionRefused(std::string dw): - ErrnoException(dw) {} -}; - -struct NoSuchDevice: public ErrnoException { - NoSuchDevice(std::string dw): - ErrnoException(dw) {} -}; - -struct HostUnreachable: public ErrnoException { - HostUnreachable(std::string dw): - ErrnoException(dw) {} -}; - -struct NoDataAvailable: public ErrnoException { - NoDataAvailable(std::string dw): - ErrnoException(dw) {} -}; - -struct BrokenPipe: public ErrnoException { - BrokenPipe(std::string dw): - ErrnoException(dw) {} -}; - -struct Overflow: public ErrnoException { - Overflow(std::string dw): - ErrnoException(dw) {} -}; - -struct InvalidArgument: public ErrnoException { - InvalidArgument(std::string dw): - ErrnoException(dw) {} -}; - -struct WouldBlock: public ErrnoException { - WouldBlock(std::string dw): - ErrnoException(dw) {} -}; - -struct TimedOut: public ErrnoException { - TimedOut(std::string dw): - ErrnoException(dw) {} -}; - -struct IOError: public ErrnoException { - IOError(std::string dw): - ErrnoException(dw) {} -}; - -struct InterruptedSysCall: public ErrnoException { - InterruptedSysCall(std::string dw): - ErrnoException(dw) {} -}; - -struct NoSpace: public ErrnoException { - NoSpace(std::string dw): - ErrnoException(dw) {} -}; - -inline void throw_ErrnoException(std::string dw, int errno_=errno) { - switch (errno_) { - case ENOENT: throw NoSuchFileOrDirectory(dw); - case ECONNREFUSED: throw ConnectionRefused(dw); - case ENODEV: throw NoSuchDevice(dw); - case EHOSTUNREACH: throw HostUnreachable(dw); -#ifdef ENODATA -// FreeBSD doesn't have ENODATA - case ENODATA: throw NoDataAvailable(dw); -#endif - case EPIPE: throw BrokenPipe(dw); - case EOVERFLOW: throw Overflow(dw); - case EINVAL: throw InvalidArgument(dw); - case EWOULDBLOCK: throw WouldBlock(dw); - case ETIMEDOUT: throw TimedOut(dw); - case EIO: throw IOError(dw); - case EINTR: throw InterruptedSysCall(dw); - case ENOSPC: throw NoSpace(dw); - default: throw ErrnoException(dw,errno_); - } -} - - -#define RETHROW_MISC_EXCEPTIONS \ -catch(pbe::Exception& E) { \ - throw; \ -} \ -catch(std::exception& e) { \ - throw pbe::StdException(e); \ -} \ -catch(const char* s) { \ - throw pbe::StrException(s); \ -} \ -catch(std::string s) { \ - throw pbe::StrException(s); \ -} \ -catch(...) { \ - throw pbe::UnknownException();\ -} - - -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/FileDescriptor.hh b/extras/anytermd/libpbe/include/FileDescriptor.hh deleted file mode 100644 index 07babe7a19..0000000000 --- a/extras/anytermd/libpbe/include/FileDescriptor.hh +++ /dev/null @@ -1,864 +0,0 @@ -// FileDescriptor.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2006-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_FileDescriptor_hh -#define libpbe_FileDescriptor_hh - -#include "Exception.hh" -#include "missing_syscalls.hh" -#include "compiler_magic.hh" - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - - -namespace pbe { - -class FileDescriptor: public boost::noncopyable { -// C++ wrapper around the traditional POSIX file descriptor. -// Some methods are simple wrappers around a standard POSIX library -// function. In addition there is a rich set of read/write methods and -// an easy to use wrapper for select(). -// In all cases, exceptions are used to report error conditions. - -protected: - const int fd; - const std::string fn; - const bool close_on_destr; - -public: - enum open_mode_t { read_only=O_RDONLY, read_write=O_RDWR, write_only=O_WRONLY, - create=O_WRONLY|O_CREAT }; - - FileDescriptor(std::string fn_, open_mode_t open_mode): - // Constructor that opens a file given a file name and an access mode. - // The file will be closed when the FileDescriptor is destructed. - // I set close-on-exec for all FileDescriptors, since this seems like the - // sensible default for me. - fd(open(fn_.c_str(),open_mode,0666)), - fn('"'+fn_+'"'), - close_on_destr(true) - { - if (fd==-1) { - throw_ErrnoException("open("+fn+")"); - } - // Set close-on-exec. - // There is a race condition here: if another thread has forked - // between the calls to open and fcntl, it will get the fd, which is - // bad. It may be fixable in the future if we get O_CLOEXEC. - // See http://lwn.net/Articles/236486/. - int rc = fcntl(fd,F_SETFD,FD_CLOEXEC); - if (rc==-1) { - throw_ErrnoException("fcntl("+fn+",F_SETFD,FD_CLOEXEC)"); - } - } - - FileDescriptor(int fd_, bool close_on_destr_=true): - // Constructor that takes an existing file descriptor. - // The file will be closed when the FileDescriptor is destructed - // unless the optional close_on_destr_ parameter is false. - fd(fd_), - fn("fd"+boost::lexical_cast(fd)), - close_on_destr(close_on_destr_) - { - } - - FileDescriptor(int fd_, std::string fn_, bool close_on_destr_=true): - // Constructor that takes an existing file descriptor. - // A name, for use in error messages, is supplied. - // The file will be closed when the FileDescriptor is destructed - // unless the optional close_on_destr_ parameter is false. - fd(fd_), - fn(fn_), - close_on_destr(close_on_destr_) - { - } - - ~FileDescriptor() { - if (close_on_destr) { - int rc = ::close(fd); - if (rc==-1) { - //throw_ErrnoException("close("+fn+")"); - // Don't throw exceptions from destructors, in case the destructor is being - // called during exception processing. - // TODO need a better fix for this. - } - } - } - - - void close() { - // Call close. This is only necessary if the user wants to close the fd before - // it goes out of scope for some reason; further operations on it are obviously - // not allowed. It also has the benefit of checking the return value, which - // the destructor does not do. - int rc = ::close(fd); - if (rc==-1) { - throw_ErrnoException("close("+fn+")"); - } - } - - - // - // Various implementation of READ: - // - - size_t read(char* buf, size_t max_bytes) { - // Directly provides almost the functionality of the read system call. - // At most max_bytes are read into the buffer. Fewer bytes may be - // read at EOF, when a socket has less data waiting, etc. The number - // of bytes actually read is returned. - // If EINTR is returned, the call is retried. - while (1) { - ssize_t n = ::read(fd,buf,max_bytes); - if (n==-1) { - if (errno==EINTR) { - continue; - } - throw_ErrnoException("read("+fn+")"); - } - return n; - } - } - - std::string read(size_t max_bytes) { - // Provides the functionality of the read sytem call, but returns - // the data in a std::string. At most max_bytes are read and returned. - // Fewer bytes may be read at EOF, when a socket has less data waiting, - // etc. - boost::scoped_array buf(new char[max_bytes]); - size_t bytes = read(buf.get(),max_bytes); - return std::string(buf.get(),bytes); - } - - class EndOfFile: public StrException { - public: - EndOfFile(): StrException("EOF") {}; - }; - - void readall(char* buf, size_t bytes) { - // Reads exactly bytes bytes into the buffer, making more than one - // call to read as necessary. Throws EOF if end-of-file is reached - // before the required number of bytes has been read. - while (bytes>0) { - size_t n = read(buf,bytes); - if (n==0) { - throw EndOfFile(); - } - buf += n; - bytes -= n; - } - } - - std::string readall(size_t bytes) { - // Reads exactly bytes bytes from the file descriptor and returns them - // as a std::string, making more than one call to read as necessary. - // Throws EOF if end-of-file is reached before the required number of - // bytes has been read. - boost::scoped_array buf(new char[bytes]); - readall(buf.get(),bytes); - return std::string(buf.get(),bytes); - } - - size_t readmax(char* buf, size_t bytes) { - // Reads exactly bytes bytes into the buffer, making more than one - // call to read as necessary, unless end-of-file is reached before - // the required number of bytes has been read, in which case all the - // available bytes are read. The number of bytes read is returned. - size_t bytes_read = 0; - while (bytes>0) { - size_t n = read(buf,bytes); - if (n==0) { - return bytes_read; - } - bytes_read += n; - buf += n; - bytes -= n; - } - return bytes_read; - } - - std::string readmax(size_t bytes) { - // Reads exactly bytes bytes from the file descriptor and returns them - // as a std::string, making more than one call to read as necessary, - // unless end-of-file is reached before the required number of bytes - // has been read, in which case all the available bytes are read. - boost::scoped_array buf(new char[bytes]); - size_t bytes_read = readmax(buf.get(),bytes); - return std::string(buf.get(),bytes_read); - } - - std::string readsome(void) { - // Reads an unspecified number of bytes from the file descriptor and - // returns them as a std::string. Use this call if you want to - // process the contents of the file in chunks and don't care about - // the chunk size. - // Currently returns an empty string at EOF; should it throw EndOfFile? - // (No - readall() below relies on it returning an empty string.) - char buf[BUFSIZ]; - int bytes = read(buf,BUFSIZ); - return std::string(buf,bytes); - } - - std::string readall() { - // Reads everything from the file descriptor until no more data is available - // (i.e. end of file) - std::string s; - std::string some; - while ((some=readsome()) != "") { - s += some; - } - return s; - } - - template - void binread(T& t) { - // Read and return a thing of type T in binary format. - char* ptr = reinterpret_cast(&t); - readall(ptr,sizeof(t)); - } - - template - T binread(void) { - // Read and return a thing of type T in binary format. - T t; - binread(t); - return t; - } - - template - void binread_at(off_t pos, T& t) { - // Read and return a thing of type T in binary format at position pos in the file. - seek(pos); - binread(t); - } - - std::string read_until_idle(float timeout) { - // Read something, and then keep reading until nothing more has been - // read for at least timeout. - std::string s = readsome(); - while (wait_until(readable(),timeout)) { - s += readsome(); - } - return s; - } - - void set_nonblocking() { - // Calls fcntl to make an open fd non-blocking on subsequent reads and writes. - int flags = fcntl(fd,F_GETFL); - flags |= O_NONBLOCK; - int rc = fcntl(fd,F_SETFL,flags); - if (rc==-1) { - throw_ErrnoException("fcntl("+fn+",F_SETFL,|O_NONBLOCK)"); - } - } - - void set_blocking() { - // Calls fcntl to make an open fd blocking on subsequent reads and writes. - int flags = fcntl(fd,F_GETFL); - flags &=~ O_NONBLOCK; - int rc = fcntl(fd,F_SETFL,flags); - if (rc==-1) { - throw_ErrnoException("fcntl("+fn+",F_SETFL,&~O_NONBLOCK)"); - } - } - - class scoped_nonblocking { - FileDescriptor& fd; - public: - scoped_nonblocking(FileDescriptor& fd_): fd(fd_) { - fd.set_nonblocking(); - } - ~scoped_nonblocking() { - fd.set_blocking(); // FIXME maybe it was already nonblocking! - } - }; - - size_t try_read(char* buf, size_t max_bytes, bool& readable) { - // Directly provides the functionality of the read system call. - // At most max_bytes are read into the buffer. Fewer bytes may be - // read at EOF, when a socket has less data waiting, etc. Zero bytes - // will be read if no data is waiting and the operation would block. - // The number of bytes actually read is returned, and readable is - // set to indicate whether the file was readable. (If the return - // value is zero and readable is true, we're at EOF.) - scoped_nonblocking nb(*this); - ssize_t n = ::read(fd,buf,max_bytes); - // FIXME what about EINTR? - if (n==-1) { - if (errno==EAGAIN) { - readable = false; - return 0; - } - throw_ErrnoException("read("+fn+")"); - } - readable = true; - return n; - } - - bool try_readall(char* buf, size_t bytes) { - // Try to read exactly bytes bytes into the buffer, making more than one - // call to read as necessary. Throws EOF if end-of-file is reached - // before the required number of bytes has been read. Returns false if - // the operation would block. (Hmm, data will be discarded if a partial - // read completes but a subsequent full read would block.) - while (bytes>0) { - bool readable; - size_t n = try_read(buf,bytes,readable); - if (!readable) { - return false; - } - if (n==0) { - throw EndOfFile(); - } - buf += n; - bytes -= n; - } - return true; - } - - template - bool try_binread(T& t) { - // Try to read a thing of type T in binary format. If the operation would block - // (e.g. a serial port or socket with insifficient data currently available) - // return false immediately. - char* ptr = reinterpret_cast(&t); - return try_readall(ptr,sizeof(t)); - } - - std::string try_readsome(void) { - // Tries to reads an unspecified number of bytes from the file descriptor and - // returns them as a std::string. If nothing can be read at present, returns an - // empty string. - char buf[BUFSIZ]; - bool readable; - int bytes = try_read(buf,BUFSIZ,readable); - return std::string(buf,bytes); - } - - // - // Various implementations of WRITE: - // - - size_t write(const char* buf, size_t max_bytes) PBE_WARN_RESULT_IGNORED { - // Directly provides the functionality of the write system call. - // At most max_bytes are written from the buffer. Fewer bytes may be - // written under various circumstances. The number of bytes actually - // written is returned. - ssize_t n = ::write(fd,buf,max_bytes); - if (n==-1) { - throw_ErrnoException("write("+fn+")"); - } - return n; - } - - size_t write(std::string s) PBE_WARN_RESULT_IGNORED { - // Provides the functionality of the write system call, but with the data - // coming from a std::string. Not all of the data may be written under - // various circumstances. The number of bytes actually written is - // returned. - return write(s.data(),s.length()); - } - - void writeall(const char* buf, size_t bytes) { - // Write all bytes bytes from buf, making repeated calls to write - // as necessary. - while (bytes>0) { - ssize_t n = write(buf,bytes); - if (n==-1) { - throw_ErrnoException("write("+fn+")"); - } - // What happens if 0 bytes are written? - buf += n; - bytes -= n; - } - } - - void writeall(std::string s) { - // Write all of string s, making repeated calls to write as necessary. - writeall(s.data(),s.length()); - } - - template - void binwrite(const T& t) { - // Write a thing of type T in binary format. - const char* ptr = reinterpret_cast(&t); - writeall(ptr,sizeof(T)); - } - - template - void binwrite_at(off_t pos, const T& t) { - // Write a thing of type T in binary format at position pos in the file. - seek(pos); - binwrite(t); - } - - void writeallv2(const char* buf1, size_t bytes1, const char* buf2, size_t bytes2) { - // Writes all bytes from buf1 and all bytes from buf2 using the writev system call. - iovec v[2]; - v[0].iov_base = const_cast(buf1); - v[0].iov_len = bytes1; - v[1].iov_base = const_cast(buf2); - v[1].iov_len = bytes2; - size_t bytes_written = 0; - while (1) { - int rc = writev(fd,v,2); - if (rc==-1) { - throw_ErrnoException("writev("+fn+")"); - } - bytes_written += rc; - if (bytes_written == bytes1+bytes2) { - return; - } - if (bytes_written >= bytes1) { - break; - } - v[0].iov_base = static_cast(v[0].iov_base)+rc; - v[0].iov_len -= rc; - } - writeall(buf2+bytes_written-bytes1, bytes1+bytes2-bytes_written); - } - - - int dup() { - // Directly provides the functionality of the dup() system call. - // The duplicate file descriptor is returned as an int, not as a FileDesriptor - // object. A FileDescriptor object can of course be constructed from the int. - int d = ::dup(fd); - if (d==-1) { - throw_ErrnoException("dup("+fn+")"); - } - return d; - } - -// The following code allows a C++ stream to be created from a -// file descriptor. This relies on a non-standard extension in -// GNU libstdc++. Not only is this non-standard, but it has -// changed slightly in different versions of the library. -// The following is known to work with g++ 3.4.4, and hopefully -// newer versions. If you have an earlier version that works -// with this please let me know. -#if __GLIBCXX__ >= 20050421 -#define LIBPBE_HAS_FILEDESCRIPTOR_STREAMS - - class istream: public std::istream { - private: - __gnu_cxx::stdio_filebuf fbuf; - public: - istream(FileDescriptor& fd, int bufsize=BUFSIZ): - fbuf(fd.dup(), std::ios::in, bufsize) - { - rdbuf(&fbuf); - } - }; - - class ostream: public std::ostream { - private: - __gnu_cxx::stdio_filebuf fbuf; - public: - ostream(FileDescriptor& fd, int bufsize=BUFSIZ): - fbuf(fd.dup(), std::ios::out, bufsize) - { - rdbuf(&fbuf); - } - }; - -// The following should work with gcc 3.3. -// Note that the libstdc++ version symbol has changed from __GLIBCPP__ -// to __GLIBCXX__ at some point. -// If you have an earlier or later version that works with this -// please let me know. -#elif (__GLIBCPP__ >= 20040214) && (__GLIBCPP__ <= 20050503) -#define LIBPBE_HAS_FILEDESCRIPTOR_STREAMS - - class istream: public std::istream { - private: - __gnu_cxx::stdio_filebuf fbuf; - public: - istream(FileDescriptor& fd, int bufsize=BUFSIZ): - std::istream(&fbuf), - fbuf(fd.dup(), std::ios::in, true, bufsize) - // (I'm concerned about the order of construction here) - {} - }; - - class ostream: public std::ostream { - private: - __gnu_cxx::stdio_filebuf fbuf; - public: - ostream(FileDescriptor& fd, int bufsize=BUFSIZ): - std::ostream(&fbuf), - fbuf(fd.dup(), std::ios::out, true, bufsize) - // ditto - {} - }; - -#endif -// Information about and/or patches for other versions of g++ are welcome. - - - void set_nodelay() { - // Calls setscokopt to disable Nagle's algorithm for this socket. - int flag = 1; - int rc = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int)); - if (rc==-1) { - throw_ErrnoException("setsockopt("+fn+",TCP_NODELAY)"); - } - } - - - struct in_addr get_peer_ip_addr() { - // For an fd that is a socket, finds the IP address of the other end of the - // connection. - // For a non-socket, returns the loopback address. - struct sockaddr_in client_addr; - socklen_t client_addr_len = sizeof(client_addr); - int rc = getpeername(fd, (struct sockaddr*)&client_addr, - &client_addr_len); - if (rc==-1) { - if (errno==ENOTSOCK) { - struct in_addr a; - a.s_addr = htonl(INADDR_LOOPBACK); - return a; - } else { - throw_ErrnoException("getpeername("+fn+")"); - } - } - if (client_addr.sin_family!=AF_INET) { - throw "socket is not an AF_INET socket"; - } - return client_addr.sin_addr; - } - - - template - int ioctl(int request, T* argp) { - // Directly provides the functionality of the ioctl system call. - int rc = ::ioctl(fd, request, reinterpret_cast(argp)); - if (rc==-1) { - throw_ErrnoException("ioctl("+boost::lexical_cast(request)+","+fn+")"); - } - return rc; - } - - template - int ioctl(int request, T& arg) { - return ioctl(request,&arg); - } - - int ioctl(int request) { - // ioctl with no data. - return ioctl(request,NULL); - } - - - template - int try_ioctl(int request, T* argp, bool& done) { - // Directly provides the functionality of the ioctl system call, non-blocking; - // done is false if the ioctl would block. - int rc = ::ioctl(fd, request, reinterpret_cast(argp)); - if (rc==-1) { - if (errno==EAGAIN) { - done = false; - return 0; - } - throw_ErrnoException("ioctl("+boost::lexical_cast(request)+","+fn+")"); - } - done = true; - return rc; - } - - template - int try_ioctl(int request, T& arg, bool& done) { - return try_ioctl(request,&arg,done); - } - - int try_ioctl(int request, bool& done) { - // try_ioctl with no data. - return try_ioctl(request,NULL,done); - } - - - void get_sigio(void) - // Ask the kernel to send this process or thread SIGIO when this fd becomes - // readable or writable. - { - int r = fcntl(fd,F_SETOWN,getpid()); // should be gettid - if (r==-1) { - throw_ErrnoException("fcntl("+fn+",F_SETOWN)"); - } - r = fcntl(fd,F_SETFL,O_ASYNC); - if (r==-1) { - throw_ErrnoException("fnctl("+fn+",F_SETFL,O_ASYNC)"); - } - } - - - enum whence_t {seek_set=SEEK_SET, seek_cur=SEEK_CUR, seek_end=SEEK_END}; - - off_t seek(off_t offset, whence_t whence = seek_set) { - // Directly provides the functionality of the lseek() system call. - // By default the offset is interpretted relative to the start of the file. - off_t r = lseek(fd,offset,whence); - if (r==(off_t)-1) { - throw_ErrnoException("lseek("+fn+")"); - } - return r; - } - - - off_t getpos() { - return seek(0,seek_cur); - } - - off_t file_length() { - // Returns the length of the file. This is done by seeking to the end. - off_t pos = getpos(); - off_t len = seek(0,seek_end); - seek(pos); - return len; - } - - - void* mmap(size_t length, open_mode_t open_mode, off_t offset = 0, bool copy_on_write=false) { - int prot = 0; - if (open_mode == read_only || open_mode == read_write) { - prot |= PROT_READ; - } - if (open_mode == write_only || open_mode == read_write) { - prot |= PROT_WRITE; - } - void* ptr = ::mmap(0, length, prot, copy_on_write ? MAP_PRIVATE : MAP_SHARED, fd, offset); - if (ptr==MAP_FAILED) { - throw_ErrnoException("mmap("+fn+")"); - } - return ptr; - } - - - void truncate(off_t length) { - int rc = ftruncate(fd,length); - if (rc==-1) { - throw_ErrnoException("truncate("+fn+")"); - } - } - - - void sync() { - int rc = ::fsync(fd); - if (rc==-1) { - throw_ErrnoException("fsync("+fn+")"); - } - } - -#if ! (defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__) -// These systems don't have fdatasync - void datasync() { - int rc = ::fdatasync(fd); - if (rc==-1) { - throw_ErrnoException("fdatasync("+fn+")"); - } - } -#endif - - -private: - - struct select_item_readable { - const int fd; - select_item_readable(int fd_): fd(fd_) {} - }; - - struct select_item_writeable { - const int fd; - select_item_writeable(int fd_): fd(fd_) {} - }; - - struct select_item_exception { - const int fd; - select_item_exception(int fd_): fd(fd_) {} - }; - - class select_info { - private: - fd_set readfds; - fd_set writefds; - fd_set exceptfds; - int max_fd; - - public: - void clear() { - FD_ZERO(&readfds); - FD_ZERO(&writefds); - FD_ZERO(&exceptfds); - max_fd=0; - } - - void set_readable(int fd) { - FD_SET(fd,&readfds); - max_fd=std::max(max_fd,fd); - } - - void set_writeable(int fd) { - FD_SET(fd,&writefds); - max_fd=std::max(max_fd,fd); - } - - void set_exception(int fd) { - FD_SET(fd,&exceptfds); - max_fd=std::max(max_fd,fd); - } - - select_info(select_item_readable i) { - clear(); - set_readable(i.fd); - } - - select_info(select_item_writeable i) { - clear(); - set_writeable(i.fd); - } - - select_info(select_item_exception i) { - clear(); - set_exception(i.fd); - } - - friend int wait_until_(FileDescriptor::select_info, struct timeval*); - }; - - -public: - - select_item_readable readable() const { - return select_item_readable(fd); - } - select_item_writeable writeable() const { - return select_item_writeable(fd); - } - select_item_exception exception() const { - return select_item_exception(fd); - } - - friend select_info operator||(select_info, select_item_readable); - friend select_info operator||(select_info, select_item_writeable); - friend select_info operator||(select_info, select_item_exception); - friend int wait_until_(FileDescriptor::select_info, struct timeval*); - friend int wait_until(FileDescriptor::select_info); - friend int wait_until(FileDescriptor::select_info, float); - - - bool operator==(int rhs) const { - return fd==rhs; - } - - bool operator==(const FileDescriptor& rhs) const { - return fd==rhs.fd; - } - - -}; - - -inline FileDescriptor::select_info -operator||(FileDescriptor::select_info lhs, - FileDescriptor::select_item_readable rhs) { - FileDescriptor::select_info i = lhs; - i.set_readable(rhs.fd); - return i; -} - -inline FileDescriptor::select_info -operator||(FileDescriptor::select_info lhs, - FileDescriptor::select_item_writeable rhs) { - FileDescriptor::select_info i = lhs; - i.set_writeable(rhs.fd); - return i; -} - -inline FileDescriptor::select_info -operator||(FileDescriptor::select_info lhs, - FileDescriptor::select_item_exception rhs) { - FileDescriptor::select_info i = lhs; - i.set_exception(rhs.fd); - return i; -} - - -inline int wait_until_(FileDescriptor::select_info i, struct timeval* tv) { - int rc; - do { - rc = select(i.max_fd+1, &i.readfds, &i.writefds, &i.exceptfds, tv); - if (rc==-1) { - if (errno==EINTR) { - continue; - } - throw_ErrnoException("select()"); - } - } while (0); - - if (rc==0) { - return -1; - } - for (int n=0; n<=i.max_fd; n++) { - if (FD_ISSET(n,&i.readfds) || FD_ISSET(n,&i.writefds) - || FD_ISSET(n,&i.exceptfds)) { - return n; - } - } - throw "not reached"; -} - -inline int wait_until(FileDescriptor::select_info i) { - // Returns a file descriptor number that changed. - return wait_until_(i,NULL); -} - -inline int wait_until(FileDescriptor::select_info i, - float timeout) { - // Returns -1 if timed out, else a file descriptor number that changed. - struct timeval tv; - float timeout_whole; - float timeout_frac; - timeout_frac = modff(timeout, &timeout_whole); - tv.tv_sec = static_cast(timeout_whole); - tv.tv_usec = static_cast(1000000.0*timeout_frac); - return wait_until_(i,&tv); -} - -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/FileMonitor.hh b/extras/anytermd/libpbe/include/FileMonitor.hh deleted file mode 100644 index a7bc788993..0000000000 --- a/extras/anytermd/libpbe/include/FileMonitor.hh +++ /dev/null @@ -1,81 +0,0 @@ -// include/FileMonitor.cc -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef pbe_FileMonitor_hh -#define pbe_FileMonitor_hh - -#include "FileDescriptor.hh" -#include "Exception.hh" -#include "missing_syscalls.hh" - -#include - - -namespace pbe { - -#if defined(PBE_HAVE_INOTIFY_INIT) && defined(PBE_HAVE_INOTIFY_ADD_WATCH) - -static inline int check_inotify_init() { - int rc = ::inotify_init(); - if (rc==-1) { - pbe::throw_ErrnoException("inotify_init()"); - } - return rc; -} - -class FileMonitor { - - int fdnum; - pbe::FileDescriptor fd; - -public: - FileMonitor(std::string fn): - fdnum(check_inotify_init()), - fd(fdnum,"inotify handle") - { - int rc = ::inotify_add_watch(fdnum,fn.c_str(),IN_MODIFY); - if (rc==-1) { - pbe::throw_ErrnoException("inotify_add_watch()"); - } - } - - void wait_until_modified() { - struct inotify_event ev; - fd.binread(ev); - } - - bool wait_until_modified_or_timeout(float timeout) { - bool readable = fd.wait_until_readable_or_timeout(timeout); - if (!readable) { - return false; - } - struct inotify_event ev; - fd.binread(ev); - return true; - } - - -}; - -#endif - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/FileType.hh b/extras/anytermd/libpbe/include/FileType.hh deleted file mode 100644 index 3711c06c69..0000000000 --- a/extras/anytermd/libpbe/include/FileType.hh +++ /dev/null @@ -1,104 +0,0 @@ -// src/FileType.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -// Determine the type of a pathname: regular file, directory, symlink, etc. - - -#ifndef libpbe_FileType_hh -#define libpbe_FileType_hh - -#include -#include -#include - -#include - -#include "Exception.hh" - - -namespace pbe { - - enum FileType { file, directory, symlink, does_not_exist, other }; - - static inline FileType filetype_from_stat(struct stat& stat_buf) - { - if (S_ISDIR(stat_buf.st_mode)) { - return directory; - } else if (S_ISREG(stat_buf.st_mode)) { - return file; - } else if (S_ISLNK(stat_buf.st_mode)) { - return symlink; - } else { - return other; - } - } - - inline FileType get_filetype(std::string pathname, bool report_noexist=false) - { - struct stat stat_buf; - int ret = stat(pathname.c_str(),&stat_buf); - if (ret==-1) { - if (report_noexist && errno==ENOENT) { - return does_not_exist; - } - throw_ErrnoException("stat("+pathname+")"); - } - return filetype_from_stat(stat_buf); - } - - inline FileType get_link_filetype(std::string pathname, bool report_noexist=false) - { - struct stat stat_buf; - int ret = lstat(pathname.c_str(),&stat_buf); - if (ret==-1) { - if (report_noexist && errno==ENOENT) { - return does_not_exist; - } - throw_ErrnoException("lstat("+pathname+")"); - } - return filetype_from_stat(stat_buf); - } - - inline FileType get_fd_filetype(int fd) - { - struct stat stat_buf; - int ret = fstat(fd,&stat_buf); - if (ret==-1) { - throw_ErrnoException("fstat()"); - } - return filetype_from_stat(stat_buf); - } - - inline bool file_exists(std::string pathname) - { - struct stat stat_buf; - int ret = stat(pathname.c_str(),&stat_buf); - if (ret==-1) { - if (errno==ENOENT) { - return false; - } - throw_ErrnoException("stat("+pathname+")"); - } - return true; - } - -}; - -#endif - diff --git a/extras/anytermd/libpbe/include/Futex.hh b/extras/anytermd/libpbe/include/Futex.hh deleted file mode 100644 index a907c2b8eb..0000000000 --- a/extras/anytermd/libpbe/include/Futex.hh +++ /dev/null @@ -1,117 +0,0 @@ -// include/Futex.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_Futex_hh -#define libpbe_Futex_hh - -// The file implements a Futex class, which is a simple wrapper around -// the futex syscall. -// Futex is supported on Linux 2.6 but not older kernels. If you want to -// run on a 2.4 kernel you need to compile with SUPPORT_LINUX_2_4 defined. -// This will supress the content of this file and the things that use it -// will fall back to something else (as they do on non-Linux platforms). - -#if defined(__linux__) && !defined(SUPPORT_LINUX_2_4) - -#define PBE_HAVE_FUTEX - -#include -#include -#include - -#include - -#include "missing_syscalls.hh" -#include "Exception.hh" - -namespace pbe { - - -template -struct Futex { - - BOOST_STATIC_ASSERT(sizeof(INT_T)==sizeof(int)); - - int* const valptr; - - Futex(INT_T& val): valptr(reinterpret_cast(&val)) {} - - ~Futex() {} - - void wait(INT_T expected) { - int r = futex(valptr, FUTEX_WAIT, - static_cast(expected), NULL, NULL, 0); - if (r==-1) { - // There are various legitimate errors that we'll throw an exception for. - // But there are also these, which are expected in normal operations: - // EWOULDBLOCK - valptr != expected - // EINTR - signal or spurious wakeup - // We might want to return something indicating that one of these conditions - // had occurred, but it seems that the mutex algorithm doesn't need this. - switch (errno) { - case EWOULDBLOCK: return; - case EINTR: return; - default: throw_ErrnoException("futex(FUTEX_WAIT)"); - } - } - } - - bool timed_wait(INT_T expected, const timespec& timeout) { - // Returns false if timeout reached. - int r = futex(valptr, FUTEX_WAIT, - static_cast(expected), &timeout, NULL, 0); - if (r==-1) { - // As above. - switch (errno) { - case EWOULDBLOCK: return true; - case EINTR: return true; - case ETIMEDOUT: return false; - default: throw_ErrnoException("futex(FUTEX_WAIT)"); - } - } - return true; - } - - bool timed_wait(INT_T expected, float timeout) { - // Returns false if timeout reached. - struct timespec ts; - float timeout_whole; - float timeout_frac; - timeout_frac = modff(timeout, &timeout_whole); - ts.tv_sec = static_cast(timeout_whole); - ts.tv_nsec = static_cast(1e9*timeout_frac); - return timed_wait(expected,ts); - } - - // Wake up to n waiters; returns the number woken. - unsigned int wake(int n=1) { - int r = futex(valptr, FUTEX_WAKE, n, NULL, NULL, 0); - if (r==-1) { - throw_ErrnoException("futex(FUTEX_WAIT)"); - } - return r; - } -}; - - -}; - - -#endif -#endif - diff --git a/extras/anytermd/libpbe/include/Gunzipper.hh b/extras/anytermd/libpbe/include/Gunzipper.hh deleted file mode 100644 index 3658031813..0000000000 --- a/extras/anytermd/libpbe/include/Gunzipper.hh +++ /dev/null @@ -1,92 +0,0 @@ -// include/Gunzipper.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef pbe_Gunzipper_hh -#define pbe_Gunzipper_hh - -#include - -#include - - -namespace pbe { - - -class Gunzipper { - - z_stream_s gz; - -public: - - Gunzipper() { - gz.zalloc = Z_NULL; - gz.zfree = Z_NULL; - gz.opaque = Z_NULL; - gz.next_in = Z_NULL; - gz.avail_in = 0; - int r = inflateInit2(&gz, 15+32); // 15 = windowbits; this is the default; - // adding 32 (ARGH!) magically makes it - // recognise both zlib and gzip formats - // (you didn't even know they differed, right?) - switch (r) { - case Z_MEM_ERROR: throw std::bad_alloc(); - case Z_VERSION_ERROR: throw "Z_VERSION_ERROR"; - } - } - - ~Gunzipper() { - inflateEnd(&gz); - } - - struct InvalidData {}; - - std::string operator()(const char* in, size_t in_bytes) { - gz.next_in = reinterpret_cast(const_cast(in)); - gz.avail_in = in_bytes; - std::string out; - while (gz.avail_in>0 || gz.avail_out==0) { - char buffer[4096]; - gz.next_out = reinterpret_cast(buffer); - gz.avail_out = sizeof(buffer); - int r = inflate(&gz,Z_SYNC_FLUSH); - switch (r) { - case Z_NEED_DICT: throw "Z_NEED_DICT"; - case Z_DATA_ERROR: throw InvalidData(); - case Z_STREAM_ERROR: throw InvalidData(); - case Z_MEM_ERROR: throw std::bad_alloc(); - } - out.append(buffer,sizeof(buffer)-gz.avail_out); - if (r==Z_STREAM_END) { - break; - } - } - return out; - } - - std::string operator()(std::string in) { - return operator()(in.data(),in.length()); - } -}; - - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/HPtime.hh b/extras/anytermd/libpbe/include/HPtime.hh deleted file mode 100644 index c25f15971c..0000000000 --- a/extras/anytermd/libpbe/include/HPtime.hh +++ /dev/null @@ -1,61 +0,0 @@ -// include/HPtime.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2007-2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -// High-precision time. -// Convertible to/from a double, representing the time in seconds since the epoch. -// Resolution is whatever gettimeofday provides, which is at best microseconds. - - -#ifndef pbe_HPtime_hh -#define pbe_HPtime_hh - -#include -#include - - -namespace pbe { - -class HPtime { - -private: - double dt; - -public: - HPtime(): dt(0) {} - - HPtime(const HPtime& t): dt(t.dt) {} - - HPtime(double t): dt(t) {} - - operator double() const { return dt; } - - static HPtime now() { - struct timeval tv; - gettimeofday(&tv,NULL); - return HPtime(tv.tv_sec + tv.tv_usec/1e6); - } - -}; - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/HttpAuthenticator.hh b/extras/anytermd/libpbe/include/HttpAuthenticator.hh deleted file mode 100644 index 713e73cba7..0000000000 --- a/extras/anytermd/libpbe/include/HttpAuthenticator.hh +++ /dev/null @@ -1,39 +0,0 @@ -// HttpAuthenticator.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2005 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef HttpAuthenticator_hh -#define HttpAuthenticator_hh - -#include - - -class HttpAuthenticator { - -public: - class NotAuthenticated {}; - - virtual ~HttpAuthenticator() {} - - virtual std::string operator()(std::string credentials) const; - virtual void basic_auth(std::string username, std::string password) const = 0; - -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/HttpClient.hh b/extras/anytermd/libpbe/include/HttpClient.hh deleted file mode 100644 index bc4bd9d1ca..0000000000 --- a/extras/anytermd/libpbe/include/HttpClient.hh +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef libpbe_HttpClient_hh -#define libpbe_HttpClient_hh - -// include/HttpClient.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include "URI.hh" -#include "HttpResponse.hh" - -#include - - -namespace pbe { - - -class HttpClient { - - std::string user_agent; - - template - void get_process_save(const URI& uri, std::string fn, int redirect_hops); - -public: - HttpClient(std::string user_agent_="libpbe::HttpClient"): - user_agent(user_agent_) - {} - - HttpResponse get(const URI& uri, int redirect_hops=10); - - void get_save(const URI& uri, std::string fn, int redirect_hops=10); - void get_save_with_etag(const URI& uri, std::string fn, int redirect_hops=10); - - void get_gunzip_save(const URI& uri, std::string fn, int redirect_hops=10); - void get_gunzip_save_with_etag(const URI& uri, std::string fn, int redirect_hops=10); - -#ifdef HAVE_BZIP - void get_bunzip_save(const URI& uri, std::string fn, int redirect_hops=10); - void get_bunzip_save_with_etag(const URI& uri, std::string fn, int redirect_hops=10); -#endif -}; - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/HttpDaemon.hh b/extras/anytermd/libpbe/include/HttpDaemon.hh deleted file mode 100644 index da302ecacd..0000000000 --- a/extras/anytermd/libpbe/include/HttpDaemon.hh +++ /dev/null @@ -1,65 +0,0 @@ -// HttpDaemon.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2005-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef HttpDaemon_hh -#define HttpDaemon_hh - -#include "Daemon.hh" -#include "HttpRequest.hh" -#include "HttpResponse.hh" -#include "HttpAuthenticator.hh" -#include "FileDescriptor.hh" - -#include - - -namespace pbe { - - -class HttpDaemon: public Daemon { - -private: - HttpAuthenticator* const authenticator; - const bool keepalive; - -public: - HttpDaemon(short port=80, std::string progname="httpd", std::string user="", - bool keepalive_=true, int max_connections=0, bool accept_local_only=false): - Daemon(port, progname, LOG_LOCAL0, user, "", max_connections, accept_local_only), - authenticator(NULL), - keepalive(keepalive_) {} - - HttpDaemon(HttpAuthenticator& a, short port=80, std::string progname="httpd", - std::string user="", bool keepalive_=true, int max_connections=0, - bool accept_local_only=false): - Daemon(port, progname, LOG_LOCAL0, user, "", max_connections, accept_local_only), - authenticator(&a), keepalive(keepalive_) {} - - void session(pbe::FileDescriptor& in_fd, pbe::FileDescriptor& out_fd); - - virtual void session_start() {} - virtual void handle(const HttpRequest& req, HttpResponse& resp) = 0; - - void authenticate(HttpRequest& req); -}; - - -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/HttpRequest.hh b/extras/anytermd/libpbe/include/HttpRequest.hh deleted file mode 100644 index 9376dbd769..0000000000 --- a/extras/anytermd/libpbe/include/HttpRequest.hh +++ /dev/null @@ -1,79 +0,0 @@ -// include/HttpRequest.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2006-2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef libpbe_HttpRequest_hh -#define libpbe_HttpRequest_hh - -#include "URI.hh" - -#include -#include - - -namespace pbe { - - -struct HttpRequest { - std::string method; - std::string host; - std::string abs_path; - std::string query; - std::string http_version; - std::string userinfo; - typedef std::map headers_t; - headers_t headers; - std::string body; - - HttpRequest() {} - - HttpRequest(const URI& uri, std::string method_="GET", std::string http_version_="HTTP/1.1"): - method(method_), - host(uri.host), - abs_path(uri.abs_path), - query(uri.query), - http_version(http_version_), - userinfo(uri.userinfo) - { - headers["Host"]=host; - } - - std::string request_line() const { - return method - +" " - +abs_path + (query.empty() ? std::string() : "?"+query) - +" " - +http_version+"\r\n"; - } - - std::string headers_str() const { - std::string s; - for (headers_t::const_iterator i = headers.begin(); - i != headers.end(); ++i) { - s += i->first + ": " + i->second + "\r\n"; - } - return s; - } - -}; - - -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/HttpResponse.hh b/extras/anytermd/libpbe/include/HttpResponse.hh deleted file mode 100644 index c0a652e90e..0000000000 --- a/extras/anytermd/libpbe/include/HttpResponse.hh +++ /dev/null @@ -1,53 +0,0 @@ -// HttpResponse.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2005-2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef libpbe_HttpResponse_hh -#define libpbe_HttpResponse_hh - -#include -#include - -#include "FileDescriptor.hh" - - -namespace pbe { - - -class HttpResponse { - -public: - HttpResponse(): - http_version("HTTP/1.1"), status_code(200), reason_phrase("OK") {} - - HttpResponse(std::string s); - - void send(pbe::FileDescriptor& fd); - - std::string http_version; - int status_code; - std::string reason_phrase; - std::map headers; - std::string body; -}; - - -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/Iconver.hh b/extras/anytermd/libpbe/include/Iconver.hh deleted file mode 100644 index 5dd3c1e8fa..0000000000 --- a/extras/anytermd/libpbe/include/Iconver.hh +++ /dev/null @@ -1,192 +0,0 @@ -// src/Iconvert.hh -// This file is part of libpbe; see http://decimail.org and http://anyterm.org -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -// C++ wrapper around iconv. - -// This is not thread-safe in the sense that an Iconver object cannot -// be used safely from multiple threads; each thread must have its own -// object. - -#ifndef libpbe_Iconver_hh -#define libpbe_Iconver_hh - -#include - -#include - -#include - -#include - -#include "Exception.hh" - - -#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun__) -// Previously __APPLE__ was included in this list; presumably they have -// changed their headers. If you have an older system you may need to put -// it back. -#define ICONV_ARG2_IS_CONST -#endif - - -namespace pbe { - - -enum iconv_errmode { reversible, // Throw if an input character cannot be reversibly converted. - complete, // Throw if the input is not complete. - valid, // Throw if the input is not valid. - permissive // Don't throw. - }; // TODO there are combinations of these.... - -// The template parameter char types don't need to be the actual types of the character sets, -// since iconv just deals with lumps of bytes; they just need to correspond to the types of the -// input and output to operator(). -template -class Iconver { - -public: - Iconver(std::string from_charset, std::string to_charset) { - iconverter = iconv_open(to_charset.c_str(), from_charset.c_str()); - if (iconverter==reinterpret_cast(-1)) { - throw InvalidCharset(); - } - } - - ~Iconver() { - int rc = iconv_close(iconverter); - if (rc==-1) { - // pbe::throw_ErrnoException("iconv_close()"); - // Don't throw an exception from a destructor, in case it has been invoked - // during exception processing. - // (TODO is there a better solution to this?) - } - } - - std::basic_string operator()(std::basic_string i) { - return operator()(i.data(),i.size()); - } - - std::basic_string operator()(const from_char* i, size_t l) { - if (carry.size()) { - std::basic_string s = carry; - s.append(i,l); - carry.clear(); - i = s.data(); - l = s.size(); - } - const size_t bytes_in = sizeof(from_char) * l; - const size_t obuf_sz = l * 2; // do multiple chunks if necessary - const size_t buf_bytes = obuf_sz * sizeof(to_char); - boost::scoped_array obuf (new to_char[obuf_sz]); - std::basic_string o; - -#ifdef ICONV_ARG2_IS_CONST - const char* ip = reinterpret_cast(i); -#else - char* ip = reinterpret_cast(const_cast(i)); -#endif - - size_t in = bytes_in; - - do { - char* op = reinterpret_cast(obuf.get()); - size_t on = buf_bytes; - - int rc = iconv(iconverter, &ip, &in, &op, &on); - if (rc==-1) { - if (errno==E2BIG) { - // Output buffer is full. We'll go around the loop again. - } else if (errno==EILSEQ) { - // An invalid multibyte sequence has been found. - if (errmode==permissive) { - // Skip the offending character and continue. - // (iconv stores any valid converted data from before the error and updates - // the pointers correctly in this case.) - ip += sizeof(from_char); - in -= sizeof(from_char); - } else { - throw InvalidInput(); - } - } else if (errno==EINVAL) { - // An incomplete multibyte sequence has been found at the end of the input. - if (errmode==complete) { - throw IncompleteInput(); - } else { - carry = std::basic_string(reinterpret_cast(ip),in/sizeof(from_char)); - in = 0; - } - } else { - pbe::throw_ErrnoException("iconv()"); - } - } else if (rc>0) { - if (errmode==reversible) { - throw NotReversible(); - } - } - o += std::basic_string(obuf.get(), (buf_bytes - on)/sizeof(to_char)); - } while (in>0); - - return o; - } - - - void flush() { - // Caller believes that the input is complete; throws if a multi-byte character is outstanding. - if (errmode==permissive) { - reset(); - } else if (carry.size()) { - throw IncompleteInput(); - } - } - - - void reset() { - // Clear any outstanding partial multi-byte character. - carry.clear(); - } - - - class InvalidCharset: public pbe::StrException { - public: - InvalidCharset(): pbe::StrException("Invalid character set or unsupported conversion") {} - }; - - class InvalidInput: public pbe::StrException { - public: - InvalidInput(): pbe::StrException("Invalid input to Iconv") {} - }; - - class IncompleteInput: public pbe::StrException { - public: - IncompleteInput(): pbe::StrException("Incomplete multi-byte input to Iconv") {} - }; - - class NotReversible: public pbe::StrException { - public: - NotReversible(): pbe::StrException("Non-reversible input to Iconv") {} - }; - -private: - iconv_t iconverter; - std::basic_string carry; -}; - - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/Line.hh b/extras/anytermd/libpbe/include/Line.hh deleted file mode 100644 index 8467970deb..0000000000 --- a/extras/anytermd/libpbe/include/Line.hh +++ /dev/null @@ -1,192 +0,0 @@ -// include/Line.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_Line_hh -#define libpbe_Line_hh - -#include "Point.hh" -#include "Vector.hh" -#include "Box.hh" - - -namespace pbe { - -template -struct Line { - typedef COORD_T coord_t; - typedef Point point_t; - - point_t a; - point_t b; - - Line() {} - - Line(const Line& other): - a(other.a), b(other.b) - {} - - Line(point_t a_, point_t b_): - a(a_), b(b_) - {} - - bool operator==(const Line& other) const { - return (a==other.a && b==other.b); - } - - bool operator!=(const Line& other) const { - return ! operator==(other); - } -}; - - - -template -bool line_crosses_line(Line u, Line v, Point& cross) -{ - // Do lines u and v cross? If so, find the point where they cross. - // Precondition: the lines must not be points. - // - // Method: - // U = u.a + alpha(u.b-u.a) - // V = v.a + beta(v.b-v.a) - // Solve for U=V - // If 0<=alpha<=1 und 0<=beta<=1 then the lines cross. - // - // u.x = u.a.x + alpha(u.b.x-u.a.x) - // u.y = u.a.y + alpha(u.b.y-u.a.y) - // v.x = v.a.x + beta(v.b.x-v.a.x) - // v.y = v.a.y + beta(v.b.y-v.a.y) - // - // u.a.x + alpha(u.b.x-u.a.x) = v.a.x + beta(v.b.x-v.a.x) - // u.a.y + alpha(u.b.y-u.a.y) = v.a.y + beta(v.b.y-v.a.y) - // - // alpha = ( v.a.x + beta(v.b.x-v.a.x) - u.a.x ) / (u.b.x-u.a.x) provided u.b.x!=u.a.x - // alpha = ( v.a.y + beta(v.b.y-v.a.y) - u.a.y ) / (u.b.y-u.a.y) provided u.b.y!=u.a.y - // ( v.a.x + beta(v.b.x-v.a.x) - u.a.x ) / (u.b.x-u.a.x) = ( v.a.y + beta(v.b.y-v.a.y) - u.a.y ) / (u.b.y-u.a.y) - // ( v.a.x + beta(v.b.x-v.a.x) - u.a.x ) (u.b.y-u.a.y) = ( v.a.y + beta(v.b.y-v.a.y) - u.a.y ) (u.b.x-u.a.x) - // beta.(v.b.x-v.a.x).(u.b.y-u.a.y) + (v.a.x-u.a.x).(u.b.y-u.a.y) = beta.(v.b.y-v.a.y).(u.b.x-u.a.x) + (v.a.y-u.a.y).(u.b.x-u.a.x) - // beta.(v.b.x-v.a.x).(u.b.y-u.a.y) - beta.(v.b.y-v.a.y).(u.b.x-u.a.x) = (v.a.y-u.a.y).(u.b.x-u.a.x) - (v.a.x-u.a.x).(u.b.y-u.a.y) - // beta = ( (v.a.y-u.a.y).(u.b.x-u.a.x) - (v.a.x-u.a.x).(u.b.y-u.a.y) ) / ( (v.b.x-v.a.x).(u.b.y-u.a.y) - (v.b.y-v.a.y).(u.b.x-u.a.x) ) - // - // beta = ( u.a.x + alpha(u.b.x-u.a.x) - v.a.x ) / (v.b.x-v.a.x) - // beta = ( u.a.y + alpha(u.b.y-u.a.y) - v.a.y ) / (v.b.y-v.a.y) - // ( u.a.x + alpha(u.b.x-u.a.x) - v.a.x ) / (v.b.x-v.a.x) = ( u.a.y + alpha(u.b.y-u.a.y) - v.a.y ) / (v.b.y-v.a.y) - // ( u.a.x + alpha(u.b.x-u.a.x) - v.a.x ) (v.b.y-v.a.y) = ( u.a.y + alpha(u.b.y-u.a.y) - v.a.y ) (v.b.x-v.a.x) - // alpha.(u.b.x-u.a.x).(v.b.y-v.a.y) + (u.a.x-v.a.x).(v.b.y-v.a.y) = alpha.(u.b.y-u.a.y).(v.b.x-v.a.x) + (u.a.y-v.a.y).(v.b.x-v.a.x) - // alpha.(u.b.x-u.a.x).(v.b.y-v.a.y) - alpha.(u.b.y-u.a.y).(v.b.x-v.a.x) = (u.a.y-v.a.y).(v.b.x-v.a.x) - (u.a.x-v.a.x).(v.b.y-v.a.y) - // alpha = ( (u.a.y-v.a.y).(v.b.x-v.a.x) - (u.a.x-v.a.x).(v.b.y-v.a.y) ) / ( (u.b.x-u.a.x).(v.b.y-v.a.y) - (u.b.y-u.a.y).(v.b.x-v.a.x) ) - // - // Note that the denominators of the expressions for alpha and beta are almost the - // same, differing only in sign. - // If this expression is zero it indicates that that lines do not cross because they - // are parallel, or that they are co-linear. - - double alpha_denom = (u.b.x-u.a.x)*(v.b.y-v.a.y) - (u.b.y-u.a.y)*(v.b.x-v.a.x); - if (alpha_denom==0) { - // In the case of co-linear lines, do we consider them to cross if they overlap? - // It's simplest to say "no", and always return false here. - return false; - - } else { - double alpha_num = (u.a.y-v.a.y)*(v.b.x-v.a.x) - (u.a.x-v.a.x)*(v.b.y-v.a.y); - double alpha = alpha_num / alpha_denom; - if (alpha<0 || alpha>1) { - return false; - } - double beta_denom = -alpha_denom; - double beta_num = (v.a.y-u.a.y)*(u.b.x-u.a.x) - (v.a.x-u.a.x)*(u.b.y-u.a.y); - double beta = beta_num / beta_denom; - if (beta<0 || beta>1) { - return false; - } - Vector uvec = u.b-u.a; - cross = u.a + uvec * alpha; - return true; - } -} - - -template -bool line_crosses_box(Box b, Line& l) -{ - // Does box b contain any part of line l? - // If line l crosses the boundary of the box, it is modified in place to - // clip at the boundary. - - if (b.contains(l.a) && b.contains(l.b)) { - // Both ends inside the box - easy. - return true; - } - - if ( (l.a.x < b.x0 && l.b.x < b.x0) - || (l.a.x > b.x1 && l.b.x > b.x1) - || (l.a.y < b.y0 && l.b.y < b.y0) - || (l.a.y > b.y1 && l.b.y > b.y1) ) { - // Line can't cross the box - easy. - return false; - } - - // There's a chance that the line crosses the box, but at least one - // end is outside it and will need to be clipped. - Point cross; - - bool crosses_left = line_crosses_line(l,Line(b.x0y0(),b.x0y1()),cross); - if (crosses_left) { - if (l.a.x<=b.x0) { - l.a = cross; - } else { - l.b = cross; - } - } - - bool crosses_top = line_crosses_line(l,Line(b.x0y1(),b.x1y1()),cross); - if (crosses_top) { - if (l.a.y>=b.y1) { - l.a = cross; - } else { - l.b = cross; - } - } - - bool crosses_right = line_crosses_line(l,Line(b.x1y1(),b.x1y0()),cross); - if (crosses_right) { - if (l.a.x>=b.x1) { - l.a = cross; - } else { - l.b = cross; - } - } - - bool crosses_bottom = line_crosses_line(l,Line(b.x1y0(),b.x0y0()),cross); - if (crosses_bottom) { - if (l.a.y<=b.y0) { - l.a = cross; - } else { - l.b = cross; - } - } - - return crosses_left || crosses_top || crosses_right || crosses_bottom; -} - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/Lock.hh b/extras/anytermd/libpbe/include/Lock.hh deleted file mode 100644 index 807ba6297a..0000000000 --- a/extras/anytermd/libpbe/include/Lock.hh +++ /dev/null @@ -1,55 +0,0 @@ -// include/Lock.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_Lock_hh -#define libpbe_Lock_hh - -// The file implements a Lock class, which is based on the unique_lock from N2447 -// without many of that lock's features. - -#include - - -namespace pbe { - - -template -struct Lock: boost::noncopyable { - - typedef MUTEX_T mutex_t; - - mutex_t& m; - - explicit Lock(mutex_t& m_): m(m_) { - m.lock(); - } - - ~Lock() { - m.unlock(); - } - - mutex_t* mutex(void) { - return &m; - } -}; - - -}; - -#endif - diff --git a/extras/anytermd/libpbe/include/Lockable.hh b/extras/anytermd/libpbe/include/Lockable.hh deleted file mode 100644 index e8ee51cef2..0000000000 --- a/extras/anytermd/libpbe/include/Lockable.hh +++ /dev/null @@ -1,42 +0,0 @@ -// src/Lockable.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_Lockable_hh -#define libpbe_Lockable_hh - -#include "Mutex.hh" -#include "Lock.hh" - - -namespace pbe { - - template - struct Lockable: public T { - Lockable() {} - Lockable(const T& t): T(t) {} - Lockable& operator=(const Lockable& rhs) { return T::operator=(rhs); } - Lockable& operator=(const T& rhs) { T::operator=(rhs); return *this; } - typedef pbe::Mutex mutex_t; - typedef pbe::Lock scoped_lock_t; - }; - - -} - -#endif - diff --git a/extras/anytermd/libpbe/include/Locked.hh b/extras/anytermd/libpbe/include/Locked.hh deleted file mode 100644 index a5d91d7ec8..0000000000 --- a/extras/anytermd/libpbe/include/Locked.hh +++ /dev/null @@ -1,97 +0,0 @@ -// Locked.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -// This provides a class template that augments a variable with a mutex, and -// allows access only when the mutex is locked. Example: -// -// typedef Locked< vector > x_t; -// x_t x; -// -// // We can only modify x via an x_t::writer: -// x_t::writer xw; -// // Creating xw locks the mutex. -// // xw behaves like a pointer to the underlying vector: -// xw->push_back(123); -// xw->push_back(321); -// // The lock is released when xw goes out of scope. -// -// To read, use an x_t::reader. It behaves like a const pointer to the -// underlying data. -// -// The mutex and lock types can be specified with template parameters, but -// they default to the boost versions. -// -// I had hoped to allow conversion-to-reference for the writer and reader, so -// that you could write xw.push_back(123) rather than xw->push_back(123). -// But this didn't work, presumably because I don't really understand how -// implict type conversion is supposed to work. My attempt is still present, -// commented out. - - -#ifndef libpbe_Locked_hh -#define libpbe_Locked_hh - -#include "Mutex.hh" - - -namespace pbe { - -template , - typename LOCK_T = pbe::Lock > -class Locked { - -private: - T data; - MUTEX_T mutex; - -public: - class writer { - Locked& locked; - LOCK_T l; - public: - writer(Locked& locked_): - locked(locked_), - l(locked.mutex) - {} -// operator T&() { return locked.data; } - T& operator*() { return locked.data; } - T* operator->() { return &locked.data; } - }; - - class reader { - Locked& locked; - LOCK_T l; - public: - reader(Locked& locked_): - locked(locked_), - l(locked.mutex) - {} -// operator const T&() const { return locked.data; } - const T& operator*() const { return locked.data; } - const T* operator->() const { return &locked.data; } - }; - -}; - - -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/MappedFile.hh b/extras/anytermd/libpbe/include/MappedFile.hh deleted file mode 100644 index c2d11f7e5e..0000000000 --- a/extras/anytermd/libpbe/include/MappedFile.hh +++ /dev/null @@ -1,73 +0,0 @@ -// include/MappedFile.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_MappedFile_hh -#define libpbe_MappedFile_hh - -#include "FileDescriptor.hh" -#include "Exception.hh" - -#include - - -namespace pbe { - -class MappedFile { - -public: - const size_t length; - const off_t offset; - char* const addr; - - MappedFile(pbe::FileDescriptor& fd, size_t length_, pbe::FileDescriptor::open_mode_t open_mode, - off_t offset_ = 0, bool copy_on_write = false): - length(length_), offset(offset_), - addr(reinterpret_cast(fd.mmap(length,open_mode,offset,copy_on_write))) - {} - - ~MappedFile() { - int rc = munmap(addr,length); - if (rc==-1) { - pbe::throw_ErrnoException("munmap()"); - } - } - - operator char* () const { return addr; } - - template - T* ptr(int offset) const { - return reinterpret_cast(reinterpret_cast(addr)+offset); - } - - template - T& ref(int offset) const { - return *ptr(offset); - } - - void sync() { - int rc = ::msync(addr,length,MS_SYNC|MS_INVALIDATE); - if (rc==-1) { - throw_ErrnoException("msync()"); - } - } - -}; - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/Mutex.hh b/extras/anytermd/libpbe/include/Mutex.hh deleted file mode 100644 index c4d8ebd2cd..0000000000 --- a/extras/anytermd/libpbe/include/Mutex.hh +++ /dev/null @@ -1,214 +0,0 @@ -// include/Mutex.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_Mutex_hh -#define libpbe_Mutex_hh - - -// This file provides class Mutex, which is a model of a non-recursive -// timed Mutex as defined in N2447. -// It's implemented on top of a user-supplied Futex-like class, defaulting -// to Futex. -// If we don't have Futex (i.e. this isn't Linux), or if we don't have atomic -// operations (i.e. is this an old gcc), the default is a specialisation -// that uses pthread_mutex_t. - -#include "atomic.hh" -#include "Lock.hh" -#include "Exception.hh" - -#include -#include - -#include -#include - - -#include "Futex.hh" -#if defined(PBE_HAVE_FUTEX) && defined(PBE_HAVE_ATOMICS) -#define FUTEX_T Futex<> -#else -#include -#define FUTEX_T pthread_mutex_t -#endif - - -namespace pbe { - -template -class Mutex: boost::noncopyable { - -#ifdef PBE_HAVE_ATOMICS - - int state; - FUT_T fut; - -public: - Mutex(): state(0), fut(state) {} - - ~Mutex() {} - - // Lock, waiting if necessary. - void lock() { - if (!try_lock()) { - lock_body(); - } - } - - // Try to lock, but don't wait if it's not possible. - // Return indicating whether lock is now held. - bool try_lock() { - return atomic_compare_and_swap(state,0,1); - } - - // Spend up to rel_time trying to lock. - // Return indicating whether lock is now held. - // N2447 templates this on the TimeDuration type, but we can't do specialisation - // of member functions; is that a new C++0x feature? So we'll use overloading. - - // C++0x will have various time types that can be used here. - typedef uint32_t microseconds_t; - - bool timed_lock(microseconds_t rel_time) { - return try_lock() || timed_lock_body(rel_time); - } - - bool timed_lock(float rel_time) { - // Careful! This will fail for durations that overflow microseconds_t, i.e. - // about an hour. - // We could postpone the float conversion until after the try_lock(). - return timed_lock(static_cast(rel_time*1e6)); - } - - void unlock() { - if (atomic_post_dec(state) != 1) { - unlock_body(); - } - } - - - // native_handle not provided. - - // This is not in N2447: - typedef Lock lock_t; - -private: - void lock_body() { - while (atomic_swap(state,2) != 0) { - fut.wait(2); - } - } - - bool timed_lock_body(microseconds_t rel_time) { - ::timeval start; - // Can gettimeofday() return an error? The only errors that the joint man - // page lists apply only to settimeofday(), or to gettimeofday() with the - // obsolete timezone parameter. - gettimeofday(&start,NULL); - while (atomic_swap(state,2) != 0) { - ::timeval now; - gettimeofday(&now,NULL); - microseconds_t elapsed = now.tv_usec - start.tv_usec - + 1000000 * (now.tv_sec - start.tv_sec); - // Hmm, this would be faster if we pre-computed the end time - // and just did a comparison in here. But it's not trivial - // to add rel_time to start without overlow concerns. - if (elapsed>rel_time) { - return false; - } - fut.wait(2); - } - } - - void unlock_body() { - atomic_write(state,0); - fut.wake(1); - } - -#endif - -}; - - - -#if !(defined(PBE_HAVE_FUTEX) && defined(PBE_HAVE_ATOMICS)) - -template <> -class Mutex: boost::noncopyable { - - pthread_mutex_t mut; - -public: - Mutex() { - int r = pthread_mutex_init(&mut, NULL); - if (r!=0) { - pbe::throw_ErrnoException("pthread_mutex_init()",r); - } - } - - ~Mutex() { - pthread_mutex_destroy(&mut); - } - - // Lock, waiting if necessary. - void lock() { - int r = pthread_mutex_lock(&mut); - if (r!=0) { - pbe::throw_ErrnoException("pthread_mutex_lock()",r); - } - } - - // Try to lock, but don't wait if it's not possible. - // Return indicating whether lock is now held. - bool try_lock() { - int r = pthread_mutex_trylock(&mut); - switch (r) { - case 0: return true; - case EBUSY: return false; - default: pbe::throw_ErrnoException("pthread_mutex_trylock()",r); - } - } - - // FIXME I'm too lazy to implement timed_lock. - - void unlock() { - int r = pthread_mutex_unlock(&mut); - if (r!=0) { - pbe::throw_ErrnoException("pthread_mutex_unlock()",r); - } - } - - - pthread_mutex_t* native_handle() { - return &mut; - } - - // This is not in N2447: - typedef Lock lock_t; - -}; - -#endif - - -}; - -#undef FUTEX_T - -#endif - diff --git a/extras/anytermd/libpbe/include/Point.hh b/extras/anytermd/libpbe/include/Point.hh deleted file mode 100644 index a7614d7729..0000000000 --- a/extras/anytermd/libpbe/include/Point.hh +++ /dev/null @@ -1,67 +0,0 @@ -// include/Point.hh -// This file is part of libpbe -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef pbe_Point_hh -#define pbe_Point_hh - -namespace pbe { - - -template -struct Point { - typedef COORD_T coord_t; - - coord_t x; - coord_t y; - - Point() {} - - Point(const Point& other): - x(other.x), y(other.y) - {} - - Point(coord_t x_, coord_t y_): - x(x_), y(y_) - {} - - bool operator<(const Point& other) const { - if (x - -#include - -#include - - -// ReadTiffFile is a wrapper around libtiff's facilities for reading -// a TIFF file. The ctor takes a filename; you can then access properties -// such as the dimensions of the image. -// -// libtiff provides various methods to access the pixel data, some of -// which work with all files and others work with files with particular -// organisations [tiff allows data to be in raster order or tiled, with -// the colour channels packed or separate, etc]. This wrapper currently -// only supports reading in "ARGB strips", i.e. the colours are decoded -// to 32-bits-per-pixel and the data is in strips the full width of the -// image and some some number of pixels (possibly 1) high. -// -// Boost.GIL also has a libtiff wrapper, but I believe that it only -// supports reading whole images. - - -namespace pbe { - - -struct ReadTiffFile: boost::noncopyable { - TIFF* const tiff; - ReadTiffFile(const char* fn): - tiff(TIFFOpen(fn,"r")) - { - if (!tiff) { - throw "TIFFOpen() failed"; - } - } - ~ReadTiffFile() { - TIFFClose(tiff); - } - - uint32_t width() const { - uint32_t w; - int r = TIFFGetField(tiff,TIFFTAG_IMAGEWIDTH,&w); - if (r==0) { - throw "TIFFGetField(TIFFTAG_IMAGEWIDTH); failed"; - } - return w; - } - uint32_t height() const { - uint32_t h; - int r = TIFFGetField(tiff,TIFFTAG_IMAGELENGTH,&h); - if (r==0) { - throw "TIFFGetField(TIFFTAG_IMAGLENGTH); failed"; - } - return h; - } - uint32_t rows_per_strip() const { - uint32_t n; - int r = TIFFGetField(tiff,TIFFTAG_ROWSPERSTRIP,&n); - if (r==0) { - throw "TIFFGetField(TIFFTAG_ROWSPERSTRIP); failed"; - } - return n; - } - size_t number_of_strips() const { - return TIFFNumberOfStrips(tiff); - } - - void read_rgba_strip(uint32_t row, uint32_t* data) const { - int r = TIFFReadRGBAStrip(tiff,row,data); - if (r==0) { - throw "TIFFReadRGBAStrip failed"; - } - } -}; - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/Recoder.hh b/extras/anytermd/libpbe/include/Recoder.hh deleted file mode 100644 index 63d5f81365..0000000000 --- a/extras/anytermd/libpbe/include/Recoder.hh +++ /dev/null @@ -1,55 +0,0 @@ -// src/Recoder.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifndef libpbe_Recoder_hh -#define libpbe_Recoder_hh - -#include -#include -#include - -#include - -using namespace std; - - -class Recoder { - -public: - - enum ErrorLevel { not_canonical=RECODE_NOT_CANONICAL, - ambiguous_output=RECODE_AMBIGUOUS_OUTPUT, - untranslatable=RECODE_UNTRANSLATABLE, - invalid_input=RECODE_INVALID_INPUT, - system_error=RECODE_SYSTEM_ERROR }; - - Recoder(string from_charset, string to_charset, - ErrorLevel e=ambiguous_output); - ~Recoder(); - string operator()(string i); - string operator()(const char* i, int l); - -private: - - ErrorLevel error_level; - static RECODE_OUTER outer; - RECODE_REQUEST request; - -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/SerialPort.hh b/extras/anytermd/libpbe/include/SerialPort.hh deleted file mode 100644 index 7fd707808e..0000000000 --- a/extras/anytermd/libpbe/include/SerialPort.hh +++ /dev/null @@ -1,133 +0,0 @@ -// SerialPort.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2006-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef libpbe_SerialPort_hh -#define libpbe_SerialPort_hh - -#include "FileDescriptor.hh" -#include "Exception.hh" - -#include -#include - -#include -#include - - -namespace pbe { - -class SerialPort: public FileDescriptor { - -public: - SerialPort(std::string fn, open_mode_t open_mode, int baudrate, bool raw=true): - FileDescriptor(fn,open_mode) - { - set_serial_mode(baudrate,raw); - } - - SerialPort(std::string fn, open_mode_t open_mode): - FileDescriptor(fn,open_mode) - {} - - SerialPort(int fd): - FileDescriptor(fd) - {} - - void set_serial_mode(int baudrate, bool raw=true) { - struct termios settings; - int rc = tcgetattr(fd, &settings); - if (rc<0) { - throw_ErrnoException("tcgetattr("+fn+")"); - } - if (raw) { - cfmakeraw(&settings); - } - rc = cfsetspeed(&settings,baudrate); - if (rc!=0) { - throw_ErrnoException("cfsetspeed("+fn+"," - +boost::lexical_cast(baudrate)+")"); - } - rc = tcsetattr(fd, TCSANOW, &settings); - if (rc<0) { - throw_ErrnoException("tcsetattr("+fn+")"); - } - } - - void discard_pending_input(void) { - int rc = tcflush(fd, TCIFLUSH); - if (rc!=0) { - throw_ErrnoException("tcflush(TCIFLUSH)"); - } - } - - - typedef int modem_bits_t; - - modem_bits_t get_modem_bits(void) { - modem_bits_t bits; - ioctl(TIOCMGET,&bits); - return bits; - } - - bool is_cd(void) { - return get_modem_bits()&TIOCM_CD; - } - - bool is_ri(void) { - return get_modem_bits()&TIOCM_RI; - } - - bool is_dsr(void) { - return get_modem_bits()&TIOCM_DSR; - } - - bool is_cts(void) { - return get_modem_bits()&TIOCM_CTS; - } - - - void set_these_modem_bits(modem_bits_t bits) { - ioctl(TIOCMBIS,&bits); - } - - void clear_these_modem_bits(modem_bits_t bits) { - ioctl(TIOCMBIC,&bits); - } - - void define_modem_bits(modem_bits_t bits, bool v) { - if (v) { - set_these_modem_bits(bits); - } else { - clear_these_modem_bits(bits); - } - } - - void define_rts(bool v) { - define_modem_bits(TIOCM_RTS,v); - } - - void define_dtr(bool v) { - define_modem_bits(TIOCM_DTR,v); - } - -}; - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/SmtpClient.hh b/extras/anytermd/libpbe/include/SmtpClient.hh deleted file mode 100644 index 16446d6c2e..0000000000 --- a/extras/anytermd/libpbe/include/SmtpClient.hh +++ /dev/null @@ -1,55 +0,0 @@ -// src/SmtpClient.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifndef libpbe_SmtpClient_hh -#define libpbe_SmtpClient_hh - -#include "Exception.hh" - -#include -#include -using namespace std; - - - class SmtpError: public pbe::Exception { - private: - string msg; - public: - SmtpError(string m): msg(m) {} - void report(ostream& s) const; - }; - - - class SmtpClient { - public: - SmtpClient(bool log=false); - void connect(string server_name, string domain, int port=25); - bool is_connected(void) { return connected; } - void send_msg(string sender, string recipient, string msg); - void send_msg(string sender, const list& recipients, string msg); - void disconnect(void); - - private: - const bool enable_log; - bool connected; - int fd; - - void wait_for_reply(int expected_code, int timeout); - void send(string d); - }; - -#endif diff --git a/extras/anytermd/libpbe/include/Spin.hh b/extras/anytermd/libpbe/include/Spin.hh deleted file mode 100644 index eec93ac45e..0000000000 --- a/extras/anytermd/libpbe/include/Spin.hh +++ /dev/null @@ -1,62 +0,0 @@ -// include/Spin.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_Spin_hh -#define libpbe_Spin_hh - -// The file implements a Futex-like class which simply spins. - -#include "compiler_magic.hh" - -#include - - -namespace pbe { - - -struct Spin { - - Spin(PBE_UNUSED_ARG(int& val)) {} - ~Spin() {} - - void wait(PBE_UNUSED_ARG(int expected)) { - } - - bool timed_wait(PBE_UNUSED_ARG(int expected), const timespec& timeout) { - // TODO detect timeout - return true; - } - - bool timed_wait(PBE_UNUSED_ARG(int expected), float timeout) { - // TODO detect timeout - return true; - } - - // Wake up to n waiters; returns the number woken. - int wake(int n=1) { - // Hmm, how much does the return value matter? - return n; - } -}; - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/StringSplitter.hh b/extras/anytermd/libpbe/include/StringSplitter.hh deleted file mode 100644 index f48fcc3471..0000000000 --- a/extras/anytermd/libpbe/include/StringSplitter.hh +++ /dev/null @@ -1,122 +0,0 @@ -// src/StringSplitter.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifndef libpbe_StringSplitter_hh -#define libpbe_StringSplitter_hh - -#include -using namespace std; - - -class StringSplitter { -protected: - const string& str; - - std::string::size_type start; - std::string::size_type end; - bool init; - bool last; - bool past_end; - -public: - StringSplitter ( const string& s ): - str(s), start(0), init(false), last(false), past_end(false) {} - - virtual ~StringSplitter() {} - - bool exhausted(void) const { - return past_end; - } - - string operator*(void) /*const*/ { - if (!init) { - find_end(); - init=true; - } - return str.substr(start,end-start); - } - - void operator++(void) { - if (last) { - past_end=true; - } else { - if (!init) { - find_end(); - init=true; - } - find_next_start(); - find_end(); - } - } - -private: - virtual void find_next_start(void) = 0; - virtual void find_end(void) = 0; - -}; - - - -class StringSplitterSeq: public StringSplitter { -private: - const string split_seq; - -public: - StringSplitterSeq ( const string& s, const string ss ): - StringSplitter(s), split_seq(ss) {} - -private: - void find_next_start(void) { - start = end+split_seq.size(); - } - - void find_end(void) { - end = str.find(split_seq,start); - if (end==str.npos) { - end=str.size(); - last=true; - } - } -}; - - - -class StringSplitterAny: public StringSplitter { -private: - const string split_chars; - -public: - StringSplitterAny ( const string& s, const string sc ): - StringSplitter(s), split_chars(sc) {} - -private: - void find_next_start(void) { - start = end+1; - } - -private: - void find_end(void) { - end = str.find_first_of(split_chars,start); - if (end==str.npos) { - end=str.size(); - last=true; - } - } -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/StringTransformer.hh b/extras/anytermd/libpbe/include/StringTransformer.hh deleted file mode 100644 index 76e2da1c2d..0000000000 --- a/extras/anytermd/libpbe/include/StringTransformer.hh +++ /dev/null @@ -1,116 +0,0 @@ -// src/StringTransformer.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifndef libpbe_StringTransformer_hh -#define libpbe_StringTransformer_hh - -#include -#include -using namespace std; - -class StringTransformer { -private: - int char_idx(char c) const { return (unsigned char)(c); } - -public: - StringTransformer(void): - transformation(256) - { - for(int c=0; c<256; ++c) { - transformation[c] = c; - } - } - - void add_cc_rule(char from, char to) - { - transformation[char_idx(from)]=to; - } - - void add_cs_rule(char from, string to) - { - transformation[char_idx(from)]=to; - } - - template - void add_cf_rule(char from, const CharToStringFunc xform) - { - transformation[char_idx(from)]=xform(from); - } - - template - void add_pc_rule(const CharPredicate from, char to) - { - for(int c=0; c<256; ++c) { - if (from(c)) { - transformation[c] = to; - } - } - } - - template - void add_ps_rule(const CharPredicate from, string to) - { - for(int c=0; c<256; ++c) { - if (from(c)) { - transformation[c] = to; - } - } - } - - template - void add_pf_rule(const CharPredicate from, const CharToStringFunc xform) - { - for(int c=0; c<256; ++c) { - if (from(c)) { - transformation[c] = xform(c); - } - } - } - - string operator()(const string& s) const - { - string r; - for(string::const_iterator i=s.begin(); - i!=s.end(); ++i) { - r.append(transformation[char_idx(*i)]); - } - return r; - } - -private: - vector transformation; -}; - - - -class EscapeInserter: public StringTransformer { -public: - EscapeInserter(string chars_to_escape, char escape_char = '\\') - { - string escaped(" "); - escaped[0]=escape_char; - for (string::const_iterator i=chars_to_escape.begin(); - i!=chars_to_escape.end(); ++i) { - escaped[1]=*i; - add_cs_rule(*i,escaped); - } - } -}; - - - -#endif diff --git a/extras/anytermd/libpbe/include/TcpClientSocket.hh b/extras/anytermd/libpbe/include/TcpClientSocket.hh deleted file mode 100644 index 0eb15c7d3a..0000000000 --- a/extras/anytermd/libpbe/include/TcpClientSocket.hh +++ /dev/null @@ -1,45 +0,0 @@ -// TcpClientSocket.hh -// This file is part of libpbe; see http://decimail.org/ -// (C) 2006-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_TcpClientSocket_hh -#define libpbe_TcpClientSocket_hh - -#include - -#include "FileDescriptor.hh" -#include "ip.hh" - - -namespace pbe { - -class TcpClientSocket: public FileDescriptor { - -private: - const std::string host; - const short port; - -public: - TcpClientSocket(std::string host_, short port_): - FileDescriptor(tcp_client_connect(host_,port_)), - host(host_), port(port_) - {} -}; - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/TcpListenSocket.hh b/extras/anytermd/libpbe/include/TcpListenSocket.hh deleted file mode 100644 index f0e2e25b42..0000000000 --- a/extras/anytermd/libpbe/include/TcpListenSocket.hh +++ /dev/null @@ -1,102 +0,0 @@ -// TcpListenSocket.hh -// This file is part of libpbe; see http://decimail.org/ -// (C) 2006-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_TcpListenSocket_hh -#define libpbe_TcpListenSocket_hh - -#include - -#include "FileDescriptor.hh" - -#include -#include -#include -#include - - -namespace pbe { - -class TcpListenSocket: public FileDescriptor { - - static int create_tcp_listen_socket(short port) { - int listenfd = socket(PF_INET,SOCK_STREAM,0); - if (listenfd==-1) { - throw_ErrnoException("socket()"); - } - try { - // race condition here - int rc = fcntl(listenfd,F_SETFD,FD_CLOEXEC); - if (rc==-1) { - throw_ErrnoException("fcntl(listenfd,F_SETFD,FD_CLOEXEC)"); - } - - // Not sure what this does - const int t=1; - setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &t, sizeof(t)); - - struct sockaddr_in server_addr; - memset(&server_addr,0,sizeof(server_addr)); - server_addr.sin_family=AF_INET; - server_addr.sin_addr.s_addr=htonl(INADDR_ANY); - server_addr.sin_port=htons(port); - int r = bind(listenfd,reinterpret_cast(&server_addr),sizeof(server_addr)); - if (r==-1) { - throw_ErrnoException("bind()"); - } - - // 128 is the "backlog" parameter. - r = listen(listenfd,128); - if (r==-1) { - throw_ErrnoException("listen()"); - } - } catch(...) { - ::close(listenfd); - throw; - } - return listenfd; - } - -public: - TcpListenSocket(short port): - FileDescriptor(create_tcp_listen_socket(port)) - {} - - int accept() { - struct sockaddr_in client_addr; - socklen_t client_size=sizeof(client_addr); - int connfd = ::accept(fd,reinterpret_cast(&client_addr),&client_size); - if (connfd==-1) { - throw_ErrnoException("accept()"); - } - try { - // race condition here - int rc = fcntl(connfd,F_SETFD,FD_CLOEXEC); - if (rc==-1) { - throw_ErrnoException("fcntl(connfd,F_SETFD,FD_CLOEXEC)"); - } - } catch(...) { - ::close(connfd); - throw; - } - return connfd; - } -}; - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/TcpServerSocket.hh b/extras/anytermd/libpbe/include/TcpServerSocket.hh deleted file mode 100644 index 37862d34cc..0000000000 --- a/extras/anytermd/libpbe/include/TcpServerSocket.hh +++ /dev/null @@ -1,42 +0,0 @@ -// TcpServerSocket.hh -// This file is part of libpbe; see http://decimail.org/ -// (C) 2006-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_TcpServerSocket_hh -#define libpbe_TcpServerSocket_hh - -#include "FileDescriptor.hh" -#include "TcpListenSocket.hh" - - -namespace pbe { - -class TcpServerSocket: public FileDescriptor { - -public: - TcpServerSocket(TcpListenSocket& listen_socket): - FileDescriptor(listen_socket.accept()) - {} - - TcpServerSocket(int fd): - FileDescriptor(fd) - {} -}; - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/Thread.hh b/extras/anytermd/libpbe/include/Thread.hh deleted file mode 100644 index d9a2a9d4b2..0000000000 --- a/extras/anytermd/libpbe/include/Thread.hh +++ /dev/null @@ -1,314 +0,0 @@ -// include/Thread.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_thread_hh -#define libpbe_thread_hh - - -// This file defines a class Thread, which has a similar interface to -// Boost.Thread and the proposed std::thread described in N2447, but -// with various extensions including cancellation and priorities. -// It's implemented on top of the POSIX thread primitives, as implemented -// in linux by NPTL; that's included in glibc and sufficiently-new -// versions of uClibc. - -#include -#include - -#include -#include -#include - -#include "Exception.hh" - - -namespace pbe { - -class Thread; - -namespace this_thread { - // Operations on the current thread: -// Thread::id get_id(); - void yield(); - template void sleep(const TimeDuration& rel_t); -}; - - -// This is a helper used in thread creation, see below: -typedef boost::function thread_fn_t; -// Hmm, maybe this has to be in a .cc file??? -static void* start_thread(void* voidstar_fn_ptr) { - thread_fn_t* fn_ptr = static_cast(voidstar_fn_ptr); - thread_fn_t fn = *fn_ptr; - delete fn_ptr; - fn(); - return NULL; -} - - -class Thread: boost::noncopyable { - - // Note that the lifetime of the thread is not coupled to the lifetime of - // the Thread object; i.e. destroying the Thread object does not terminate - // the thread. It's more of a "thread handle" really. - - - class pthread_attr_wrapper: boost::noncopyable { - // The POSIX pthread_attr_t type needs be initialised and destroyed - // before and after use. This wrapper makes that automatic. - ::pthread_attr_t attrs; - public: - pthread_attr_wrapper() { - int r = ::pthread_attr_init(&attrs); - if (r!=0) { - // Apparently error code is in r, not errno. This is the case for many - // of the pthread_* functions. - throw_ErrnoException("pthread_attr_init()",r); - } - } - ~pthread_attr_wrapper() { - ::pthread_attr_destroy(&attrs); - } - // Make it possible to use a pthread_attr_wrapper anywhere that a - // pthread_attr_t* is called for: - operator ::pthread_attr_t* () { - return &attrs; - } - }; - - -public: - //typedef pid_t id; // TODO this should probably be the thread's tid, but pthread_create - // doesn't give a way to get this easily. - typedef ::pthread_t native_handle_type; - - // POSIX defines the scheduling parameters for a thread as a (priority, policy) pair. - // Higher-priority threads are always run in preference to lower-priority threads, - // irrespective of scheduling policy. Scheduling policy determines how equal-priority - // threads are scheduled, with the two choices SCHED_FIFO and SCHED_RR. RR, "Round - // Robin", is somewhat fair in the sense that threads are preempted after a timeslice - // has elapsed and don't run again until all other threads (at that priority) have - // had a chance to run. FIFO, in contrast, runs the same thread until it blocks - // (e.g. a system call). - // I'm not totally convinced that Linux necessarily implements all of this: you - // can find documentation saying that it definitely doesn't, but that may be out of - // date by now. - - // Neither std::thread not Boost.Threads provides a way to set these parameters, - // but we do, when the thread is created, using this struct to store the parameters: - - struct scheduling_parameters { - int priority; - int policy; - bool inherit; // This causes the parameters to be inheritted from the calling thread. - - scheduling_parameters(): inherit(true) {} - scheduling_parameters(int priority_, int policy_=SCHED_RR): - priority(priority_), policy(policy_), inherit(false) {} - - // Legitimate values for priority are rather inconveniently defined dynamically - // and depend on the policy. There's a guarantee that at least 32 levels exist, - // but there's no guarantee about any overlap between the ranges for the different - // policies. We ignore this: users should assume that the priorities range 0 to 31 - // and that there's an undefined relationship between the policies. - - void set_attrs(::pthread_attr_t* attrs_p) const { // Store these parameters in this - // pthread_attrs_t - int r = ::pthread_attr_setinheritsched(attrs_p, inherit ? PTHREAD_INHERIT_SCHED - : PTHREAD_EXPLICIT_SCHED); - if (r!=0) { - throw_ErrnoException("pthread_attr_setinheritsched()",r); - } - if (!inherit) { - r = ::pthread_attr_setschedpolicy(attrs_p, policy); - if (r!=0) { - throw_ErrnoException("pthread_attr_setschedpolicy()",r); - } - struct ::sched_param p; - p.sched_priority = priority + ::sched_get_priority_min(policy); - r = ::pthread_attr_setschedparam(attrs_p, &p); - if (r!=0) { - throw_ErrnoException("pthread_attr_setschedparam()",r); - } - } - } - }; - - - // The default constructor is supposed to return an object not attached to any - // thread with an id that compares equal to all detached or joined threads. - Thread(): - //id(), - joinable_(false) - {} - - - // This is the main constructor that actually starts a thread. - // std::thread has this constructor: - // template explicit Thread(F f, Args&&... args); - // The Args&&... stuff is magic C++0x varargs voodoo that we can't use. We'll - // use Boost.Function. Note that there's a thread-safety bug in Boost.Function - // in 1.34.*; it's fixed in 1.35, but I think that we're OK as gcc provides - // thread-safe statics by default. - // We also supply initial scheduling parameters, with a default of inheritting the - // caller's. std::thread only allows this via the native_handle hack. - // We also take a stack size, with a default provided by pthreads (maybe 2 MBytes, - // or 10 MBytes, or something like that). There's no way to specify this - // in std::thread or Boost.Threads. The kernel will reserve all of this memory, - // which doesn't matter on a system with lots of swap (though it can make some - // memory-usage numbers look odd). On a system with no swap, it's still OK as - // long as the kernel is happy to over-commit; see /proc/sys/vm/overcommit*. - - explicit Thread(thread_fn_t fn, - scheduling_parameters sp = scheduling_parameters(), - size_t stacksize=0) { - pthread_attr_wrapper attrs; - sp.set_attrs(attrs); - if (stacksize!=0) { - int r = ::pthread_attr_setstacksize(attrs,stacksize); - if (r!=0) { - throw_ErrnoException("pthread_attr_setstacksize()",r); - } - } - // pthread_create takes a C function pointer, so we can't pass the - // boost::function to it directly (though we could perhaps specialise - // this constructor for the simple case where the thread-function is - // a C function pointer). Instead we'll use a helper function and pass - // the boost::function as the arg. But the pthread_create arg is a - // void*, and the boost::function is larger than a pointer, and we - // can't pass a pointer to fn since this function may have terminated - // and fn gone out of scope before the new thread starts. Solution: - // dynamically allocate a copy of fn, and have the new thread delete - // it. - - thread_fn_t* fn_ptr = new thread_fn_t(fn); - - int r = pthread_create(&pt, attrs, &start_thread, static_cast(fn_ptr)); - if (r!=0) { - delete fn_ptr; // The thread has not been created in any case reporting - // an error, right? - throw_ErrnoException("pthread_create()",r); - } - joinable_ = true; - } - - - // Destroying this Thread object does not terminate the thread. - // It does, however, detach it (see below) if it is still running. - ~Thread() { - // We can't unconditionally call detach() as pthread_detach is undefined - // if called more than once, or if called when join() has been called (I think). - if (joinable()) { - detach(); - } - } - - // std::thread defines C++0x "move" copy constructor and assignment operators. - // We don't because we don't have the necessary C++0x magic yet. - // Thread(Thread&&); - // Thread& operator=(Thread&&); - // void swap(Thread&&); - - // A thread that has not yet been joined or detached is "joinable". - // Note that "joinable" doesn't mean that join will return immediately. - bool joinable() const { - return joinable_; - } - - // "joining" with a thread means waiting for it to terminate if it has not - // yet done so, and then releasing its resources. It's "wait() for threads". - void join() { - int r = ::pthread_join(pt,NULL); - if (r!=0) { - throw_ErrnoException("pthread_join()",r); - } - joinable_ = false; - } - - // Note that there is no version of join that takes a timeout. There's no - // such functionality provided by POSIX. If needed, it could be emulated - // using a condition variable that's signalled to indicate termination. - - // "detaching" a thread indicates that it will not be "joined"; when it - // terminates its resources will be released automatically. - void detach() { - int r = ::pthread_detach(pt); - if (r!=0) { - throw_ErrnoException("pthread_detach()",r); - } - joinable_ = false; - } - - - // std::threads doesn't provide any way to cancel a thread. Boost.Threads - // does provide a way, but it only provides cancellation points in - // synchronisation primitives (i.e. lock mutex, wait for condition), not - // in blocking IO operations. POSIX does provide cancellation that works - // for blocking IO, but the POSIX spec doesn't provide for interoperation - // with C++: destructors and catch-blocks are not executed. However, the - // glibc implementation of pthread_cancel() _does_ invoke destructors. - // But it might not do the right thing with catch blocks; this needs to - // be understood. I'm not yet sure if the uClibc NPTL implementation has - // this C++ integration. - // Anyway, we provide thread cancellation based on the POSIX primitives. - // Calling cancel() will ask the thread to cancel and return immediately; - // it does not wait for the thread to actually terminate. The thread will - // start to terminate either immediately, at the next cancellation point, - // or not at all depending on its current cancellation mode (see - // cancellation.hh). It will then run its destructors and terminate. - // For a list of functions that must or may be cancellation points, see - // http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_09.html#tag_02_09_05 - - void cancel() { - int r = ::pthread_cancel(pt); - if (r!=0) { - throw_ErrnoException("pthread_cancel()",r); - } - } - - - //id get_id() const; // TODO - - native_handle_type native_handle() { - return pt; - } - - // This static function indicates the number of processors that the system - // has. - // There are actually two measures, for the total number of processors and - // the total number of "online" processors, e.g. if the OS can power them - // up and down dynamically. This returns the former. - static unsigned hardware_concurrency() { - int n = sysconf(_SC_NPROCESSORS_ONLN); - if (n==-1) { - throw_ErrnoException("sysconf(_SC_NPROCESSORS_ONLN)"); - } - return n; - } - -private: - //id tid; - pthread_t pt; - bool joinable_; -}; - - -}; - -#endif - diff --git a/extras/anytermd/libpbe/include/Time.hh b/extras/anytermd/libpbe/include/Time.hh deleted file mode 100644 index 110ab7dabf..0000000000 --- a/extras/anytermd/libpbe/include/Time.hh +++ /dev/null @@ -1,62 +0,0 @@ -// src/Time.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_Time_hh -#define libpbe_Time_hh - -#include - -#include - - -namespace pbe { - - struct Time { - - uint8_t hour; - uint8_t minute; - uint8_t second; - - Time() {} - - Time(int hour_, int minute_, int second_): - hour(hour_), minute(minute_), second(second_) {} - - bool operator<(const Time& rhs) const { - return (hour(t.hour) << ":" << static_cast(t.minute) - << ":" << static_cast(t.second); - return strm; - } - -} - - -#endif diff --git a/extras/anytermd/libpbe/include/Timer.hh b/extras/anytermd/libpbe/include/Timer.hh deleted file mode 100644 index 9eb9700afb..0000000000 --- a/extras/anytermd/libpbe/include/Timer.hh +++ /dev/null @@ -1,53 +0,0 @@ -// include/Timer.cc -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -// A Timer. -// Constructor takes a period (a double, in seconds), and the expired() method indicates -// whether that much time has elapsed since construction. - - -#ifndef pbe_Timer_hh -#define pbe_Timer_hh - -#include "HPtime.hh" - - -namespace pbe { - -class Timer { - -private: - HPtime end_time; - -public: - Timer(double dt): - end_time(HPtime::now() + dt) - {} - - bool expired() { - return end_time - -#include -#include - -// URIs per RFC2396. -// All URIs have a scheme - well, except for relative URIs outside their -// context - but the form of the rest is scheme-dependent. However, -// schemes that are hierarchical have a common syntax for hierarchy, and -// schemes that involve the network have a common syntax for indicating -// the remote host. This URI class is intended primarily for these schemes -// i.e. HTTP, HTTPS, and FTP. - - -namespace pbe { - - -class URI { - -public: - URI(): port(0) {} - URI(std::string absolute_uri); - URI(std::string scheme_, std::string host_, std::string abs_path_, - std::string query_="", uint16_t port_=0, std::string userinfo_=""): - scheme(scheme_), userinfo(userinfo_), host(host_), port(port_), - abs_path(abs_path_), query(query_) - {} - - // The names of the following fields match the rules in the RFC2396 EBNF. - std::string scheme; - std::string userinfo; - std::string host; - uint16_t port; // port is set to zero if it's not specified; this class doesn't - // know about protocol-specific default port numbers. - std::string abs_path; - std::string query; - // Example: http://joe@example.com:8080/path/to/foo.cgi?a=1 - // scheme=http, userinfo=joe, host=example.com, port=8080, - // abs_path=/path/to/foo.cgi, quary=a=1 - - struct SyntaxError {}; - - std::string str() const { - std::string s = scheme + "://"; - if (!userinfo.empty()) { - s += userinfo + "@"; - } - s += host; - if (port!=0) { - s += ":" + boost::lexical_cast(port); - } - s += abs_path; - if (!query.empty()) { - s += "?" + query; - } - return s; - } - -}; - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/Unlock.hh b/extras/anytermd/libpbe/include/Unlock.hh deleted file mode 100644 index be02892e56..0000000000 --- a/extras/anytermd/libpbe/include/Unlock.hh +++ /dev/null @@ -1,55 +0,0 @@ -// include/Unlock.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_Unlock_hh -#define libpbe_Unlock_hh - -// The file implements a Unlock class, which unlocks a mutex while it is -// in scope. - -#include - - -namespace pbe { - - -template -struct Unlock: boost::noncopyable { - - typedef MUTEX_T mutex_t; - - mutex_t& m; - - explicit Unlock(mutex_t& m_): m(m_) { - m.unlock(); - } - - ~Unlock() { - m.lock(); - } - - mutex_t* mutex(void) { - return &m; - } -}; - - -}; - -#endif - diff --git a/extras/anytermd/libpbe/include/Vector.hh b/extras/anytermd/libpbe/include/Vector.hh deleted file mode 100644 index ebe4d99e5f..0000000000 --- a/extras/anytermd/libpbe/include/Vector.hh +++ /dev/null @@ -1,105 +0,0 @@ -// include/Vector.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef pbe_Vector_hh -#define pbe_Vector_hh - -#include - -#include "Point.hh" - - -namespace pbe { - - -template -struct Vector { - typedef COORD_T coord_t; - - coord_t x; - coord_t y; - - Vector() {} - - Vector(const Vector& other): - x(other.x), y(other.y) - {} - - Vector(coord_t x_, coord_t y_): - x(x_), y(y_) - {} - - bool operator<(const Vector& other) const { - if (x - Vector operator/=(DIV_T divisor) { x /= divisor; y /= divisor; return *this; } - - template - Vector operator/(DIV_T divisor) const { Vector v = *this; v /= divisor; return v; } - - template - Vector operator*=(MUL_T multiplier) { x *= multiplier; y *= multiplier; return *this; } - - template - Vector operator*(MUL_T multiplier) const { Vector v = *this; v *= multiplier; return v; } - -}; - - -template -Vector operator-(const Point& a, const Point& b) { - return Vector(a.x-b.x, a.y-b.y); -} - -template -Point operator+(const Point& a, const Vector& b) { - return Point(a.x+b.x, a.y+b.y); -} - -template -Point operator-(const Point& a, const Vector& b) { - return Point(a.x-b.x, a.y-b.y); -} - - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/WritePngFile.hh b/extras/anytermd/libpbe/include/WritePngFile.hh deleted file mode 100644 index feeb3422fc..0000000000 --- a/extras/anytermd/libpbe/include/WritePngFile.hh +++ /dev/null @@ -1,103 +0,0 @@ -// include/WritePngFile.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2009 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_WritePngFile_hh -#define libpbe_WritePngFile_hh - -#include - -#include - - -// WritePngFile is a wrapper around libpng's facilities for writing -// a PNG file. The ctor takes a filename, image dimensions and so on; -// you then supply pixel data row-at-a-time. This is a small subsit -// of libpng's facilities. -// -// Boost.GIL also has a libpng wrapper, but I believe that it only -// supports writing whole images. - - -namespace pbe { - - -struct WritePngFile { - - FILE* f; - png_structp png_p; - png_infop info_p; - - static FILE* check_fopen(const char* fn, const char* mode) { - FILE* f = fopen(fn,mode); - if (!f) { - throw "fopen() failed"; - } - return f; - } - - static png_structp check_png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn) { - png_structp p = png_create_write_struct(user_png_ver, error_ptr, error_fn, warn_fn); - if (!p) { - throw "png_create_write_struct() failed"; - } - return p; - } - - static png_infop check_png_create_info_struct(png_structp png_ptr) { - png_infop i = png_create_info_struct(png_ptr); - if (!i) { - throw "png_create_info_struct() failed"; - } - return i; - } - - static void error_fn(png_structp, png_const_charp error_msg) { - throw error_msg; - } - - WritePngFile(const char* fn, uint32_t width, uint32_t height, - int bit_depth=8, int colour_type=PNG_COLOR_TYPE_RGB_ALPHA): - f(check_fopen(fn,"wb")), - png_p(check_png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, &error_fn, 0)), - info_p(check_png_create_info_struct(png_p)) - { - png_init_io(png_p,f); - png_set_IHDR(png_p, info_p, width, height, bit_depth, colour_type, - PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - png_write_info(png_p, info_p); - } - - ~WritePngFile() { - png_write_end(png_p, info_p); - png_destroy_write_struct(&png_p,&info_p); // frees both - fclose(f); - } - - void write_row(const uint32_t* data) { - png_write_row(png_p, const_cast(reinterpret_cast(data))); - } - -}; - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/Yield.hh b/extras/anytermd/libpbe/include/Yield.hh deleted file mode 100644 index e04aa53ea1..0000000000 --- a/extras/anytermd/libpbe/include/Yield.hh +++ /dev/null @@ -1,68 +0,0 @@ -// include/Yield.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_Yield_hh -#define libpbe_Yield_hh - -// The file implements a Futex-like class which simply calls sched_yield(). - -#include - -#include "Exception.hh" -#include "compiler_magic.hh" - -namespace pbe { - - -struct Yield { - - Yield(PBE_UNUSED_ARG(int& val)) {} - ~Yield() {} - - void wait(PBE_UNUSED_ARG(int expected)) { - int r = ::sched_yield(); - if (r==-1) { - throw_ErrnoException("futex(FUTEX_WAIT)"); - } - } - - bool timed_wait(PBE_UNUSED_ARG(int expected), const timespec& timeout) { - // TODO detect timeout - wait(expected); - return true; - } - - bool timed_wait(PBE_UNUSED_ARG(int expected), float timeout) { - // TODO detect timeout - wait(expected); - return true; - } - - // Wake up to n waiters; returns the number woken. - int wake(int n=1) { - // Hmm, how much does the return value matter? - return n; - } -}; - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/atomic.hh b/extras/anytermd/libpbe/include/atomic.hh deleted file mode 100644 index 58c80ed2f7..0000000000 --- a/extras/anytermd/libpbe/include/atomic.hh +++ /dev/null @@ -1,124 +0,0 @@ -// include/atomic.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_atomic_hh -#define libpbe_atomic_hh - - -// This file provides some basic atomic operations using the gcc builtins. -// It doesn't attempt to provide an N2427-compatiable interface. -// Memory ordering sematics are those provided by the gcc builtins, -// which basically means that they all provide full memory barriers (I think). - -// We have a special version for ARM: - -#ifdef __arm__ -#include "atomic_arm.hh" -#else - -// gcc provides __sync atomic primatives from version 4.1. However, -// they didn't bother to add the feature-test-macros until version 4.2 or 4.3. -// Ideally we would ignore the gcc versions that have the primitives -// but don't tell us about them, but unfortunately that covers a few systems -// that we might be interested in. So for the time being we'll fake it: - -#if __GNUC__ == 4 && __GNUC_MINOR__ == 1 -// Maybe need to check for 4.2 too. -// This assumes that all types <= 32 bits are atomic, which is a good -// bet but not 100% certain. -#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 -#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 -#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 -#endif - - -#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1) || defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) \ - || defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) - -#define PBE_HAVE_ATOMICS - -namespace pbe { - -// The N2427 proposed CAS is: -// if ( *object == *expected ) -// *object = desired; -// else -// *expected = *object; -// The boolean result of the comparison is returned. -// Note that *expected is updated if the comparison fails. This seems -// odd to me; it isn't what the gcc builtin does. I'm going to provide -// something closer to gcc. - -template -// T must of course be a type that's atomic on the hardware in use. -// I hope that some sort of error will occur if it isn't. -bool atomic_compare_and_swap(volatile T& var, T expected, T newval) { - // The return value indicates the result of the compare. - return __sync_bool_compare_and_swap(&var, expected, newval); -} - - -template -T atomic_post_dec(volatile T& var, T amt = 1) { - return __sync_fetch_and_sub(&var, amt); -} - - -template -T atomic_pre_inc(volatile T& var, T amt = 1) { - return __sync_add_and_fetch(&var, amt); -} - - -template -void atomic_inc(volatile T& var, T amt = 1) { - __sync_fetch_and_add(&var, amt); -} - - -template -void atomic_dec(volatile T& var, T amt = 1) { - __sync_fetch_and_sub(&var, amt); -} - - -template -T atomic_swap(volatile T& var, T newval) { - return __sync_lock_test_and_set(&var,newval); // misnamed -} - - -template -T atomic_read(volatile T& var) { - return var; -}; - - -template -void atomic_write(volatile T& var, T newval) { - var = newval; -}; - - -}; - -#endif - -#endif -#endif - diff --git a/extras/anytermd/libpbe/include/atomic_arm.hh b/extras/anytermd/libpbe/include/atomic_arm.hh deleted file mode 100644 index e82fe0c0d8..0000000000 --- a/extras/anytermd/libpbe/include/atomic_arm.hh +++ /dev/null @@ -1,141 +0,0 @@ -// include/atomic_arm.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_atomic_arm_hh -#define libpbe_atomic_arm_hh - - -// This file provides some basic atomic operations for ARM processors -// where the only primitive is swap. - - -#define PBE_HAVE_ATOMICS - - -namespace pbe { - - -// First some asm to do a swap: - -template -static inline T simple_atomic_swap(volatile T& mem, T newval) -{ - T oldval; - asm volatile ("swp\t%0, %1, [%2]" - :"=&r"(oldval) - :"r" (newval), - "r" (&mem) - :"memory"); - return oldval; -} - -// The other atomic operations are emulated by means of a sentinel value, -1: -// the variable is first swapped with the sentinel, the operation is performed and -// the modified value is written back. Any thread that wants to read the -// variable must re-try if it reads the sentinel. - -template -static inline T atomic_read_and_lock(T& var) -{ - do { - int val = simple_atomic_swap(var,static_cast(-1)); - if (static_cast(val) != -1) { - return val; - } - } while (1); -} - - -template -// T must of course be a type that's atomic on the hardware in use. -// I hope that some sort of error will occur if it isn't. -static inline bool atomic_compare_and_swap(volatile T& var, T expected, T newval) { - // The return value indicates the result of the compare. - T oldval = atomic_read_and_lock(var); - if (oldval==expected) { - var = newval; - return true; - } else { - var = oldval; - return false; - } -} - - -template -static inline T atomic_post_dec(volatile T& var, T amt = 1) { - T val = atomic_read_and_lock(var); - var = val - amt; - return val; -} - - -template -static inline T atomic_pre_inc(volatile T& var, T amt = 1) { - T val = atomic_read_and_lock(var); - T newval = val + amt; - var = newval; - return newval; -} - - -template -static inline void atomic_inc(volatile T& var, T amt = 1) { - T val = atomic_read_and_lock(var); - T newval = val + amt; - var = newval; -} - - -template -static inline void atomic_dec(volatile T& var, T amt = 1) { - T val = atomic_read_and_lock(var); - T newval = val - amt; - var = newval; -} - - -template -static inline T atomic_swap(volatile T& var, T newval) { - T oldval = atomic_read_and_lock(var); - var = newval; - return oldval; -} - - -template -static inline T atomic_read(volatile T& var) { - do { - T val = var; - if (static_cast(val) != -1) { - return val; - } - } while (1); -}; - - -template -static inline void atomic_write(volatile T& var, T newval) { - atomic_read_and_lock(var); - var = newval; -}; - - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/atomic_ofstream.hh b/extras/anytermd/libpbe/include/atomic_ofstream.hh deleted file mode 100644 index f287e44436..0000000000 --- a/extras/anytermd/libpbe/include/atomic_ofstream.hh +++ /dev/null @@ -1,92 +0,0 @@ -// include/atomic_ofstream.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_atomic_ofstream_hh -#define libpbe_atomic_ofstream_hh - -#include "Exception.hh" - -#include -#include - -#include -#include - - -namespace pbe { - - -// atomic_ofstream is like std::ofstream except that the stream writes to -// a temporary file. When the file has been completely written the client -// code should call commit() which removes any existing file and moves the -// new one into its place; this should happen somewhat atomically. If -// commit() has not been called by the time the destructor is reached -// the temporary file is removed and the original file is left unchanged. - - -struct atomic_ofstream_base { - const std::string orig_fn; - const std::string tmp_fn; - atomic_ofstream_base(std::string orig_fn_): - orig_fn(orig_fn_), - tmp_fn(orig_fn+".tmp") - {} -}; - - -class atomic_ofstream: - private atomic_ofstream_base, - public std::ofstream { - - bool committed; - -public: - atomic_ofstream(std::string orig_fn_): - atomic_ofstream_base(orig_fn_), - std::ofstream(tmp_fn.c_str()), - committed(false) - {} - - void commit() { - if (!committed) { - std::ofstream::close(); - // We don't need to remove the old file; rename() does this. - int r = ::rename(tmp_fn.c_str(),orig_fn.c_str()); - if (r==-1) { - throw_ErrnoException("rename()"); - } - committed = true; - } - } - - ~atomic_ofstream() { - if (!committed) { - std::ofstream::close(); - ::unlink(tmp_fn.c_str()); - } - } - -}; - - -}; - - -#endif - - diff --git a/extras/anytermd/libpbe/include/base64.hh b/extras/anytermd/libpbe/include/base64.hh deleted file mode 100644 index 8d1ef9b97a..0000000000 --- a/extras/anytermd/libpbe/include/base64.hh +++ /dev/null @@ -1,202 +0,0 @@ -// include/base64.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_base64_hh -#define libpbe_base64_hh - -#include -#include -#include -#include - -#include - -#include "init_array.hh" -#include "compiler_magic.hh" - - -// Base64 decoding -// =============== -// -// As specified by RFC2045 section 6.8. - - -namespace pbe { - - -// Thrown if invalid base64 data is encountered while decoding: -struct InvalidBase64 {}; - - -// An iterator adaptor that does base64 decoding. -// It wraps an underlying iterator that iterates over the bytes of the -// base64-coded data, providing an iterator over the bytes of the -// decoded data. Both iterators are input iterators. - - -template -class base64_iter -{ - -// The implementation stores 3 decoded bytes internally and iterates -// through them until they're all used; it then reads and decodes -// another 4 raw bytes from the input. - -// Note that this iterator expects you to alternately dereference and -// increment it. If you increment without dereferencing, bad things -// will happen. (Multiple dereferencing without incrementing is OK.) - -public: - typedef std::input_iterator_tag iterator_category; - typedef boost::uint8_t value_type; - typedef std::ptrdiff_t difference_type; - typedef boost::uint8_t& reference; - typedef boost::uint8_t* pointer; - - base64_iter() {} - - // Construct using the underlying iterator. - // This takes a second iterator pointing to the end of the data; - // this could be made optional for cases where it's not feasible to - // provide it (e.g. an istream_iterator), but in this case it's not - // clear how to detect and report end-of-data. - base64_iter(Iter i_, Iter i_end_): - i(i_), - i_end(i_end_), - pos(3), - bytes(0) - {} - - boost::uint8_t operator*() { - maybe_get_more_bytes(); - return bytes[pos]; - } - - base64_iter& operator++() { - ++pos; - return *this; - } - - void operator++(int) { - ++pos; - } - - bool operator==(const base64_iter& other) const { - return i==other.i && pos==other.pos; - } - - bool operator!=(const base64_iter& other) const { - return !operator==(other); - } - -private: - Iter i; - Iter i_end; - int pos; - init_array bytes; - - void maybe_get_more_bytes() { - if (pos > 2) { - get_3bytes(); - } - } - - void get_3bytes() { - int h0 = get_sixbits(); - int h1 = get_sixbits(); - int h2 = get_sixbits(); - int h3 = get_sixbits(); - // The format of each 4-character group can be: - // XXXX : 3 bytes - // XXX= : 2 bytes - // XX== : 1 byte - // There will always be 4 characters in the group. - // get_sixbits returns -1 if it sees an =. - IF_LIKELY(h0>=0 && h1>=0 && h2>=0 && h3>=0) { - bytes[0] = (h0<<2) | (h1>>4); - bytes[1] = ((h1&15)<<4) | (h2>>2); - bytes[2] = ((h2&3)<<6) | (h3); - pos -= 3; - return; - } - // In the "short" cases we put the bytes that we have received at - // the end of the bytes array. This means that once they've been - // read, end-of-data will be readed with i==i_end && pos==3. This - // should equal the base64_iter constructed from the underlying end(). - if (h0>=0 && h1>=0 && h2>=0 && h3==-1) { - bytes[1] = (h0<<2) | (h1>>4); - bytes[2] = ((h1&15)<<4) | (h2>>2); - pos -= 2; - return; - } - if (h0>=0 && h1>=0 && h2==-1 && h3==-1) { - bytes[2] = (h0<<2) | (h1>>4); - pos -= 1; - return; - } - throw InvalidBase64(); - } - - int get_sixbits() { - char c; - do { - if (i==i_end) { - return 0; - } - c = *i; - ++i; - } while (std::isspace(c)); - if (c>='a' && c<='z') return c-'a'+26; - if (c>='A' && c<='Z') return c-'A'; - if (c>='0' && c<='9') return c-'0'+52; - if (c=='+') return 62; - if (c=='/') return 63; - if (c=='=') return -1; - throw InvalidBase64(); - // The RFC says that we "must ignore" other characters, but a - // couple of lines later says that they "probably indicate a - // transmission error" ... "rejection might be appropriate". - } -}; - - - - -// Decode a std::string - -inline std::string decode_base64(const std::string& data) -{ - std::string result; - result.reserve(data.length()*3/4); - typedef base64_iter in_iter_t; - in_iter_t data_begin(data.begin(), data.end()); - in_iter_t data_end(data.end(), data.end()); - typedef std::back_insert_iterator out_iter_t; - out_iter_t result_inserter(result); - std::copy(data_begin, data_end, result_inserter); -//for (; data_begin != data_end; ++data_begin) { *(result_inserter++) = *data_begin; } - return result; -} - - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/bistrector.hh b/extras/anytermd/libpbe/include/bistrector.hh deleted file mode 100644 index 6d3242b9a9..0000000000 --- a/extras/anytermd/libpbe/include/bistrector.hh +++ /dev/null @@ -1,274 +0,0 @@ -// include/bistrector.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_bistrector_hh -#define libpbe_bistrector_hh - -// bistrector: bidirectionally-stretchy-vector -// ------------------------------------------- -// -// Provides a vector which stretches when new elements are accessed -// using operator[]. It stretches in both directions, i.e. only enough -// space for elements between the minimum and maximem indices is -// allocated. In contrast, a strector allocates space between 0 and -// the maximum index. -// -// This is actually implemented using a pair of strectors, one for elements -// above the first one added and a reversed one for those below it. A -// consequence is that if elements are erased the bistrector cannot shrink -// beyond the first element added. In fact, erasing elements in general -// is problematic because of this and is not implemented, except for clear(). -// -// The rules for invalidation etc. are the same as for strector. -// -// An additional optional constructor parameter allows you to specify a value -// used for new elements when the vector is resized during operator[] and -// when a beyond-the-end element is read as above. - - -#include "strector.hh" - -#include - - -namespace pbe { - - -template < typename T, typename ALLOC=std::allocator > -class bistrector: public std::vector { - typedef strector strector_t; - strector_t bottom; - strector_t top; - size_t mid_index; - -public: - typedef T value_type; - typedef T* pointer; - typedef T& reference; - typedef const T& const_reference; - typedef size_t size_type; - typedef ssize_t difference_type; - - - // Most of the vector ctors don't make much sense and aren't implemented. - - bistrector(): mid_index(0) {} - explicit bistrector(const T& default_t): bottom(default_t), top(default_t), mid_index(0) {} - bistrector(const bistrector& other): bottom(other.bottom), top(other.top), mid_index(other.mid_index) {} - - template - void advance_iterator(iter_t& i, bool& top_half, size_t n) { - if (n>0) { - if (top_half) { - i += n; - } else if (i-bottom.begin() >= n) { - i -= n; - } else { - i = top.begin() + (i-bottom.begin()) + (n-1); - top_half = true; - } - } else { - if (!top_half) { - i -= n; - } else if (i-top.begin() >= -n) { - i += n; - } else { - i = bottom.begin() + (i-top.begin()) + (-n-1); - top_half = false; - } - } - } - - - class iterator: - public boost::iterator_facade< iterator, T, std::random_access_iterator_tag > { - - friend class boost::iterator_core_access; - friend class bistrector; - - const bistrector& b; - bool top_half; - typename strector_t::iterator i; - - iterator(const bistrector& b_, bool top_half_, typename strector_t::iterator i_): - b(b_), top_half(top_half_), i(i_) - {} - - T& dereference() { - return *i; - } - - bool equal(const iterator& other) { - return i == other.i; - } - - void advance(size_t n) { - b.advance_iterator(i,top_half,n); - } - - void increment() { - advance(1); - } - - void decrement() { - advance(-1); - } - - }; - - - class const_iterator: - public boost::iterator_facade< const_iterator, T, std::random_access_iterator_tag, const T& > { - - friend class boost::iterator_core_access; - friend class bistrector; - - const bistrector& b; - bool top_half; - typename strector_t::const_iterator i; - - const_iterator(const bistrector& b_, bool top_half_, typename strector_t::const_iterator i_): - b(b_), top_half(top_half_), i(i_) - {} - - const T& dereference() { - return *i; - } - - bool equal(const const_iterator& other) { - return i == other.i; - } - - void advance(size_t n) { - bistrector::advance_iterator(i,top_half,n); - } - - void increment() { - advance(1); - } - - void decrement() { - advance(-1); - } - - }; - - - iterator begin() { - if (bottom.empty()) { - return iterator(*this,true,top.begin()); - } else { - return iterator(*this,false,bottom.end()-1); - } - } - - iterator end() { - return iterator(*this,true,top.end()); - } - - const_iterator begin() const { - if (bottom.empty()) { - return const_iterator(*this,true,top.begin()); - } else { - return const_iterator(*this,false,bottom.end()-1); - } - } - - const_iterator end() const { - return const_iterator(*this,true,top.end()); - } - - size_type size() const { - return top.size() + bottom.size(); - } - - size_type max_size() const { - return top.max_size() + bottom.max_size(); - } - - bool empty() const { - return top.empty() && bottom.empty(); - } - - reference operator[](size_type n) { - if (top.empty() && bottom.empty()) { - mid_index = n; - } - if (n>=mid_index) { - return top[n-mid_index]; - } else { - return bottom[mid_index-n-1]; - } - } - - const_reference operator[](size_type n) const { - if (n>=mid_index) { - return top[n-mid_index]; - } else { - return bottom[mid_index-n-1]; - } - } - - reference front() { - if (bottom.empty()) { - return top.front(); - } else { - return bottom.back(); - } - } - - const_reference front() const { - if (bottom.empty()) { - return top.front(); - } else { - return bottom.back(); - } - } - - reference back() { - if (top.empty()) { - return bottom.front(); - } else { - return top.back(); - } - } - - const_reference back() const { - if (top.empty()) { - return bottom.front(); - } else { - return top.back(); - } - } - - void push_back(const T& t) { - top.push_back(t); - } - - void clear() { - top.clear(); - bottom.clear(); - } -}; - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/bloom_filter.hh b/extras/anytermd/libpbe/include/bloom_filter.hh deleted file mode 100644 index 6c70203440..0000000000 --- a/extras/anytermd/libpbe/include/bloom_filter.hh +++ /dev/null @@ -1,129 +0,0 @@ -// include/bloom_filter.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef bloom_filter_hh -#define bloom_filter_hh - -#include - -// This class implements an approximation to set using a Bloom Filter. -// It's approximate in the senses that: -// - It sometimes returns false positives. (It never returns false negatives.) -// - It provides only a subset of the features of a real set, in particular it does -// not support iteration or erasure of elements. Only insertion and testing are -// provided. -// -// Insertion and testing are both O(1) in the number of keys stored. -// -// See e.g. the Wikipedia Bloom Filter page for the theory. -// -// There are a few template parameters that you need to set: -// Choose n_bits based on the acceptable probability of false positives (f) and the -// number of stored keys (n_keys) to satisfy: -// f = 0.618 ^ (n_bits/n_keys) -// => n_bits = n_keys ln(f)/-0.48 -// It's best to round n_bits to a power of 2; if you don't, mod is needed -// at run-time. In any case it must be a multiple of 32. -// Space is O(n_bits). -// -// Choose n_hashes using -// n_hashes = 0.7 n_bits / n_keys -// Insertion and testing are O(n_hashes). Using fewer hashes will make these operations -// faster at the expense of more false positives; this can be offset by increasing -// n_bits i.e. trading off time vs. space. Using more hashes will NOT reduce the rate of -// false positivies. -// -// (Hmm, I now wonder if the better approach is to choose n_hashes based on f, and then -// to choose n_bits.) -// -// So for example, to store the 56840 words in /usr/share/dict/words with a probability -// of a false positive of 1% (i.e. 1% of your mis-spellings are identified as correct), -// we get n_bits = 545329 which rounds down to 512*1024 or up to 1024*1024. n_hashes -// is 9 or 18 respectively. -// -// These values are theoretical optimums; in practice you may need to experiment a bit -// to find good values if you're fussy about the space required and the false positive rate. -// -// You need to supply a hash function. It takes the key as an argument and returns a tr1::array -// of n_hashes hash values, which much each have at least log2(n_bits) bits. -// Possible sources of hash functions are: -// - The standard library includes them, returning size_t, for integer types and std::string. -// - Boost.CRC. -// -// In cases where you want to do the same insert or lookup on multiple filters, it makes -// sense to do the hash calculation only once. To allow this the insert and check methods -// are overloaded with versions that take hash results. - - -template < typename KEY_TYPE, - int n_bits, - int n_hashes, - typename HASH - > -class bloom_filter { -public: - typedef KEY_TYPE key_type; - typedef std::tr1::array< unsigned int, n_hashes > hash_return_type; - - bloom_filter() { - bits_t b_ = {{0}}; - bits = b_; - } - - void insert(const hash_return_type& h) { - for (int k=0; k bits_t; - bits_t bits; - - void set_bit(int n) { - bits[n>>5] |= 1<<(n&31); - } - - bool test_bit(int n) const { - return bits[n>>5] & (1<<(n&31)); - } -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/charset/char_conv.hh b/extras/anytermd/libpbe/include/charset/char_conv.hh deleted file mode 100644 index e4ed7a670e..0000000000 --- a/extras/anytermd/libpbe/include/charset/char_conv.hh +++ /dev/null @@ -1,116 +0,0 @@ -// char_conv.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_char_conv_hh -#define libpbe_charset_char_conv_hh - -#include "charset_t.hh" -#include "charset_traits.hh" -#include "error_policy.hh" - -#include - -#include "compiler_magic.hh" - - -namespace pbe { - -// Conversion of characters between character sets -// ----------------------------------------------- -// -// This file provides facilities to convert a single character from -// one character set to another. It's implemented using specialisations -// for character set pairs in other files. -// A template parameter specifies a policy for error handling. -// Because function templates can't be partially specialised, and -// the character-set-pair specialisation will not want to be specialised -// on the error handling polocy, we need to wrap the conversion in a -// class. -// The default implementation here converts to a UCS4 character as an -// intermediate step, which will work as long as the necessary supporting -// conversions are implemented somehow. -// There's also a specialisation here for the null conversion where source -// and destination are the same. - - -// Base template, with default implementation via ucs4: - -template -struct char_conv { - // We shouldn't be here if from_cs or to_cs is ucs4; that indicates recursion. - // A specialisation should have been invoked. Maybe the appropriate - // specialisation hasn't been #included, or hasn't been written? - BOOST_STATIC_ASSERT(from_cs!=cs::ucs4 && to_cs!=cs::ucs4); - - // FIXME shouldn't this be a static member function? - typename charset_traits::char_t - operator() ( typename charset_traits::char_t c, - typename charset_traits::state_t& from_state - = charset_traits::state_t(), - typename charset_traits::state_t& to_state - = charset_traits::state_t() ) - { - charset_traits::state_t ucs4_state; - char32_t tmp = char_conv() (c,from_state,ucs4_state); - return char_conv() (tmp,ucs4_state,to_state); - } -}; - - -// Specialisation for trivial conversion to the same character set: -template -struct char_conv { - typename charset_traits::char_t - operator() ( typename charset_traits::char_t c, - PBE_UNUSED_ARG(typename charset_traits::state_t& from_state) - = charset_traits::state_t(), - PBE_UNUSED_ARG(typename charset_traits::state_t& to_state) - = charset_traits::state_t() ) - { - return c; - } -}; - - -// This macro is used elsewhere to define trivial conversions. - -#define IDENTITY_CHAR_CONV(FROM_CS,TO_CS) \ -template \ -struct char_conv { \ - charset_traits::char_t \ - operator() ( charset_traits::char_t c, \ - charset_traits::state_t&, \ - charset_traits::state_t& ) { \ - return static_cast::char_t>(c); \ - } \ -}; - - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/charset/char_converter.hh b/extras/anytermd/libpbe/include/charset/char_converter.hh deleted file mode 100644 index 98b992c118..0000000000 --- a/extras/anytermd/libpbe/include/charset/char_converter.hh +++ /dev/null @@ -1,67 +0,0 @@ -// char_converter.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_char_converter_hh -#define libpbe_charset_char_converter_hh - -#include "charset_t.hh" -#include "charset_traits.hh" -#include "char_conv.hh" -#include "error_policy.hh" - - -namespace pbe { - -// Stateful functor for character conversion -// ----------------------------------------- -// -// The function template char_conv takes state variables for the input and output, -// in case they are stateful. -// A simplified interface is provided by this functor, which keeps the state -// internally from one call to the next. - -template -class char_converter { - typedef charset_traits from_traits; - typedef charset_traits to_traits; - - typename from_traits::state_t from_state; - typename to_traits::state_t to_state; - -public: - char_conv cc; - typename to_traits::char_t operator()(typename from_traits::char_t c) { - return cc ( c, from_state, to_state ); - } - - // TODO flush, perhaps reset. -}; - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/charset/char_t.hh b/extras/anytermd/libpbe/include/charset/char_t.hh deleted file mode 100644 index 4f5d50dd90..0000000000 --- a/extras/anytermd/libpbe/include/charset/char_t.hh +++ /dev/null @@ -1,72 +0,0 @@ -// char_t.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2007-2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_char_t_hh -#define libpbe_charset_char_t_hh - -#include - -namespace pbe { - -// Defined-size character types -// ---------------------------- -// -// The built-in types char and wchar_t have different numbers of bits on -// different platforms. C++0x will probably have new char types of determined -// sizes; this file provides three typedefs, char8_t, char16_t and char32_t -// that do the same sort of thing. These map to char and wchar_t when -// appropriate, and to an unsigned integer of the appropriate size (using -// Boost.Integer) otherwise. -// -// The specialised template class char_t provides a typedef 'type' for an -// N-bit character. - - -template -struct char_t { - typedef typename boost::uint_t::least type; -}; - -template <> -struct char_t<8*sizeof(char)> { - typedef char type; -}; - -template <> -struct char_t<8*sizeof(wchar_t)> { - typedef wchar_t type; -}; - -typedef char_t<8>::type char8_t; -typedef char_t<16>::type char16_t; -typedef char_t<32>::type char32_t; - - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/charset/character_output_iterator.hh b/extras/anytermd/libpbe/include/charset/character_output_iterator.hh deleted file mode 100644 index 2948f3db1d..0000000000 --- a/extras/anytermd/libpbe/include/charset/character_output_iterator.hh +++ /dev/null @@ -1,84 +0,0 @@ -// character_output_iterator.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2007-2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_character_output_iterator_hh -#define libpbe_charset_character_output_iterator_hh - -#include "charset_t.hh" -#include "charset_traits.hh" - -namespace pbe { - -// Character Output Iterator Adapter -// --------------------------------- -// -// This iterator adapter takes an output iterator over a string's units -// and supplies an output iterator that stores characters. This is of -// course trivial for fixed-length character sets; for variable-length -// character sets the encoding is performed by a function supplied by the -// character set's traits class. -// The supplied iterator is only an output iterator: the only permitted -// pattern of use is to alternately store characters and increment the -// iterator. Typically it will be used with an appending ("back insert") -// iterator: -// -// typedef std::container ctr_t; -// ctr_t ctr; -// typedef std::back_insert_iterator unit_iter_t; -// unit_iter_t ui(ctr); // ui inserts units -// typedef character_output_iterator char_iter_t; -// char_iter_t ci(ui); // ci inserts characters -// *(ci++) = 0x1234; // some random non-ASCII character - - -template -class character_output_iterator { - unit_iterator_t i; - - struct assignment_proxy { - unit_iterator_t& i; - assignment_proxy(unit_iterator_t& i_): i(i_) {} - void operator=(typename charset_traits::char_t c) { - charset_traits::encode(i,c); - } - }; - -public: - character_output_iterator() {} - character_output_iterator(const unit_iterator_t& i_): i(i_) {} - assignment_proxy operator*() { return assignment_proxy(i); } - character_output_iterator& operator++() { return *this; } - character_output_iterator& operator++(int) { return *this; } - unit_iterator_t& base() { return i; } -}; - - - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/charset/charset_char_traits.hh b/extras/anytermd/libpbe/include/charset/charset_char_traits.hh deleted file mode 100644 index 01ffd3e56c..0000000000 --- a/extras/anytermd/libpbe/include/charset/charset_char_traits.hh +++ /dev/null @@ -1,80 +0,0 @@ -// charset_char_traits.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2007-2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_charset_char_traits_hh -#define libpbe_charset_charset_char_traits_hh - -#include "charset_t.hh" -#include "charset_traits.hh" - -#include - - -namespace pbe { - -// Character Set Character Traits -// ------------------------------ -// -// It would be great if we could write -// std::char_traits -// but unfortunately we can't as iso8859_1_char is only a typedef, and -// std::char_traits can't be specialised differently for it than for char, -// iso8859_2_char, and all the others. -// -// So instead we can write -// charset_char_traits -// which is a traits class compatible with std::char_traits, for iso-8859-1 -// characters. We also have -// charset_unit_traits -// which gives the character traits for the character set's unit type, rather -// than its character type, which will be different in the case of variable -// length character sets like utf8. -// They are all defined in terms of charset_traits and std::char_traits. - -template -struct charset_char_traits { - typedef charset_traits::char_t char_type; - typedef std::char_traits::int_t int_type; - typedef std::char_traits::pos_t pos_type; - typedef std::char_traits::off_t off_type; - typedef charset_traits::state_t state_type; -}; - -template -struct charset_unit_traits { - typedef charset_traits::unit_t char_type; - typedef std::char_traits::int_t int_type; - typedef std::char_traits::pos_t pos_type; - typedef std::char_traits::off_t off_type; - typedef charset_traits::state_t state_type; -}; - -// FIXME the state_types in the two versions should be DIFFERENT, right??? - - -#endif diff --git a/extras/anytermd/libpbe/include/charset/charset_names.hh b/extras/anytermd/libpbe/include/charset/charset_names.hh deleted file mode 100644 index 1d743ba59f..0000000000 --- a/extras/anytermd/libpbe/include/charset/charset_names.hh +++ /dev/null @@ -1,74 +0,0 @@ -// charset_names.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_charset_names_hh -#define libpbe_charset_charset_names_hh - -#include - -#include "charset_t.hh" - -namespace pbe { - -// Character Set Names -// ------------------- -// -// This file provides functions for converting between character set names -// in ASCII strings and charset_t values. -// -// Several names may be recorded for each character set. The primary -// IANA-registered name is returned by charset_name(). charset_mime_name() -// returns the same as charset_name(), unless a different name is preferred -// for MIME purposes. (Typically the preferred MIME name is more concise, -// while the primary name is less ambiguous.) lookup_charset() recognises -// both of these names plus a large number of IANA-defined aliases and -// many variations in case and punctuation. - - -extern const char* const charset_iana_names[]; - -inline const char* charset_name(charset_t cs) { - return charset_iana_names[cs]; -} - - -extern const char* const charset_mime_names[]; - -inline const char* charset_mime_name(charset_t cs) { - return charset_mime_names[cs]; -} - - -struct NoSuchCharacterSet {}; // FIXME maybe we need a no-throw version too? - -charset_t lookup_charset(const char* name); -charset_t lookup_charset(std::string name); - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/charset/charset_t.hh b/extras/anytermd/libpbe/include/charset/charset_t.hh deleted file mode 100644 index cceb6ac715..0000000000 --- a/extras/anytermd/libpbe/include/charset/charset_t.hh +++ /dev/null @@ -1,55 +0,0 @@ -// charset_t.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_charset_t_hh -#define libpbe_charset_charset_t_hh - -namespace pbe { - -// Definition of charset_t -// ----------------------- -// -// This file defines an enum, charset_t, which names character sets. -// The body of the enum is populated by an automatically-generated file -// generated from the IANA list of character sets. - -// The character set names include some rather terse ones, e.g. "l1" and "no", -// so to avoid collisions they're kept in their own sub-namespace, pbe::cs. -// The type charset_t itself is brought up to the main pbe:: namesapce. - -namespace cs { -#include "generated/charset_t_enum_body.hh" -}; - -using cs::charset_t; - - -}; - -#endif - diff --git a/extras/anytermd/libpbe/include/charset/charset_traits.hh b/extras/anytermd/libpbe/include/charset/charset_traits.hh deleted file mode 100644 index 27342e7f88..0000000000 --- a/extras/anytermd/libpbe/include/charset/charset_traits.hh +++ /dev/null @@ -1,416 +0,0 @@ -// charset_traits.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2007-2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_charset_traits_hh -#define libpbe_charset_charset_traits_hh - -#include "charset_t.hh" -#include "char_t.hh" - - -namespace pbe { - -// Character Set Traits -// -------------------- -// -// charset_traits provides information about a character set cs, identified -// by a member of the charset_t enumeration. This information comprises: -// - The character type, char_t. -// - The unit type, unit_t. -// - The state type (for character sets like Shift-JIS), state_t. -// The character and unit types differ for variable-length encodings. -// Since the majority of the character sets in charset_t are fixed-length -// byte character sets with no shift-state, this is defined as a default. -// Note that different character sets' state types are distinct, even if they -// are all stateless character sets. -// - The boolean constants is_ascii_superset and is_iso8859_common_superset, -// which indicate whether the character set shares codes 0-127 with ASCII -// and whether it shares code 0-160 (inclusive) with the iso-8859 character -// sets, respectively. (The iso-8859 character sets are all ASCII supersets, -// and they also have in common with each other characters 128 to 160 -// inclusive; 128 to 159 are control characters and 160 is non-breaking space. -// - The following functions, for conversion between the character type and -// a sequence of units: -// template char_t decode(const_unit_ptr_t& p); -// Decodes and returns one character pointed to by p, and advances p -// to point to the next character. -// template void encode(unit_ptr_t& p, char_t c); -// Encodes the character c and stores it starting at *p, and advances -// p to point after the character that it has written. -// - The following functions, for per-character iteration though units: -// template void skip_forward_char(const_unit_ptr_t& p); -// Advance p to point to the next character. -// template void skip_backward_char(const_unit_ptr_t& p); -// Move p back to point to the previous character. -// template int char_length(const_unit_ptr_t& p); -// Returns the length in units of the character pointed to by p. -// - The following to help client code allocate buffer space: -// size_t max_characters(size_t n_units) -// size_t typ_characters(size_t n_units) -// size_t max_units(size_t n_characters) -// size_t typ_units(size_t n_characters) - -// Maybe add: check whether units pointed to are valid. - -// For fixed-length character sets, most of these things are trivial; the -// only variable is whether they have the common ASCII or ISO-8859 subset. -// Specialisations for such cases can inherit from one of these: - -// cset must be a template parameter so that the state_t for each character -// set is distinct. -template -struct fixed_charset_traits { - typedef C char_t; - typedef C unit_t; - struct state_t {}; - static const bool is_ascii_superset = false; - static const bool is_ascii_plus_c1_superset = false; - template static char_t decode(const_unit_ptr_t& p) { return *(p++); } - template static void encode(unit_ptr_t& p, char_t c) { *(p++) = c; } - template static void skip_forward_char(const_unit_ptr_t& p) { ++p; } - template static void skip_backward_char(const_unit_ptr_t& p) { --p; } - template static int char_length(const_unit_ptr_t& p) { return 1; } - static size_t max_characters(size_t n_units) { return n_units; } - static size_t typ_characters(size_t n_units) { return n_units; } - static size_t max_units(size_t n_characters) { return n_characters; } - static size_t typ_units(size_t n_characters) { return n_characters; } -}; - -template -struct fixed_byte_charset_traits: fixed_charset_traits {}; - -template -struct fixed_byte_ascii_superset_charset_traits: fixed_byte_charset_traits { - static const bool is_ascii_superset = true; - static const bool is_ascii_plus_c1_superset = false; -}; - -template -struct fixed_byte_iso8859_common_superset_charset_traits: fixed_byte_charset_traits { - static const bool is_ascii_superset = true; - static const bool is_ascii_plus_c1_superset = true; -}; - - -// Here is the base charset traits class, for which specialisations are made: - -template -struct charset_traits {}; - - -// For many of the fixed-length character sets, we define specialisations here: - -template <> struct charset_traits: fixed_byte_ascii_superset_charset_traits {}; - -// The ISO-8859 character sets: -template <> struct charset_traits: fixed_byte_iso8859_common_superset_charset_traits {}; -template <> struct charset_traits: fixed_byte_iso8859_common_superset_charset_traits {}; -template <> struct charset_traits: fixed_byte_iso8859_common_superset_charset_traits {}; -template <> struct charset_traits: fixed_byte_iso8859_common_superset_charset_traits {}; -template <> struct charset_traits: fixed_byte_iso8859_common_superset_charset_traits {}; -template <> struct charset_traits: fixed_byte_iso8859_common_superset_charset_traits {}; -template <> struct charset_traits: fixed_byte_iso8859_common_superset_charset_traits {}; -template <> struct charset_traits: fixed_byte_iso8859_common_superset_charset_traits {}; -template <> struct charset_traits: fixed_byte_iso8859_common_superset_charset_traits {}; -template <> struct charset_traits: fixed_byte_iso8859_common_superset_charset_traits {}; -template <> struct charset_traits: fixed_byte_iso8859_common_superset_charset_traits {}; -template <> struct charset_traits: fixed_byte_iso8859_common_superset_charset_traits {}; -template <> struct charset_traits: fixed_byte_iso8859_common_superset_charset_traits {}; -template <> struct charset_traits: fixed_byte_iso8859_common_superset_charset_traits {}; -// These sound related, but I don't know what they are: -// iso8859_6_e -// iso8859_6_i -// iso8859_supp - -// The ISO-646 character sets. These are 7-bit character sets with most characters shared -// with ASCII, but with some punctuation characters replaced by national accented characters -// and symbols. -// It might be useful to have a trait indicating that they're "approximately" ASCII. -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -// This sounds related, but I don't know what it is: -// ISO_646.basic:1983 - -// These "code pages" are all 8-bit fixed-length encodings. -// Some/many of them will be ASCII supersets but this isn't identified here. -// (In some/most cases a definition is provided in the Unicode mapping tables.) -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; -template <> struct charset_traits: fixed_byte_charset_traits {}; - -// The cyrillic KOI8 character sets are ASCII supersets. -template <> struct charset_traits: fixed_byte_ascii_superset_charset_traits {}; -template <> struct charset_traits: fixed_byte_ascii_superset_charset_traits {}; -template <> struct charset_traits: fixed_byte_ascii_superset_charset_traits {}; - - -// The fixed Unicode formats: -template <> struct charset_traits: fixed_charset_traits {}; -template <> struct charset_traits: fixed_charset_traits {}; - - -// For the variable-length, specialisations are -// provided in separate files. These are: -// utf8 -// utf16 -// iso_10646_utf_1 -// unicode_1_1_utf_7 -// UTF-7 -// UTF16-BE -// UTF16-LE -// UTF32 -// UTF32-BE -// UTF32-LE -// iso_2022_kr -// iso_2022_jp -// iso_2022_jp_2 -// iso_2022_cn -// iso_2022_cn_ext -// shift_jis - - -// I don't yet know enough about the following character sets to supply traits -// for them. I do not aim to do so for every single character set. - -// iso_ir_142 -// jis_x0201 -// jis_encoding -// euc_jp -// Extended_UNIX_Code_Fixed_Width_for_Japanese -// INVARIANT -// iso_ir_2 -// iso_ir_8_1 -// iso_ir_8_2 -// iso_ir_9_1 -// iso_ir_9_2 -// iso_ir_149 -// euc_kr -// iso_ir_13 -// iso_ir_14 -// iso_ir_18 -// iso_ir_19 -// iso_ir_27 -// iso_ir_37 -// iso_ir_42 -// iso_ir_47 -// iso_ir_49 -// iso_ir_50 -// iso_ir_51 -// iso_ir_52 -// iso_ir_53 -// iso_ir_54 -// iso_ir_55 -// iso_ir_57 -// iso_ir_58 -// iso_ir_70 -// iso_ir_87 -// iso_ir_88 -// iso_ir_89 -// iso_ir_90 -// iso_ir_91 -// iso_ir_93 -// iso_ir_94 -// iso_ir_95 -// iso_ir_96 -// iso_ir_98 -// iso_ir_99 -// iso_ir_102 -// iso_ir_103 -// iso_ir_103 -// iso_ir_123 -// iso_ir_139 -// iso_ir_143 -// iso_ir_146 -// iso_ir_147 -// iso_ir_150 -// iso_ir_152 -// iso_ir_153 -// iso_ir_155 -// iso_ir_158 -// iso_ir_159 -// us-dk -// dk-us -// gb18030 -// OSD_EBCDIC_DF04_15 -// OSD_EBCDIC_DF03_IRV -// OSD_EBCDIC_DF04_1 -// ISO-11548-1 -// KZ-1048 -// ISO-10646-UCS-Basic -// ISO-10646-Unicode-Latin1 -// ISO-10646-J-1 -// ISO-Unicode-IBM-1261 -// ISO-Unicode-IBM-1268 -// ISO-Unicode-IBM-1276 -// ISO-Unicode-IBM-1264 -// ISO-Unicode-IBM-1265 -// UNICODE-1-1 -// SCSU -// CESU-8 -// BOCU-1 -// ISO-8859-1-Windows-3.0-Latin-1 -// ISO-8859-1-Windows-3.1-Latin-1 -// ISO-8859-2-Windows-Latin-2 -// ISO-8859-9-Windows-Latin-5 -// hp_roman8 -// Adobe-Standard-Encoding -// Ventura-US -// Ventura-International -// DEC-MCS -// PC8-Danish-Norwegian -// PC8-Turkish -// IBM-Symbols -// IBM-Thai -// HP-Legal -// HP-Pi-font -// HP-Math8 -// Adobe-Symbol-Encoding -// HP-DeskTop -// Ventura-Math -// Microsoft-Publishing -// Windows-31J -// GB2312 -// Big5 -// macintosh -// EBCDIC-AT-DE -// EBCDIC-AT-DE-A -// EBCDIC-CA-FR -// EBCDIC-DK-NO -// EBCDIC-DK-NO-A -// EBCDIC-FI-SE -// EBCDIC-FI-SE-A -// EBCDIC-FR -// EBCDIC-IT -// EBCDIC-PT -// EBCDIC-ES -// EBCDIC-ES-A -// EBCDIC-ES-S -// EBCDIC-UK -// EBCDIC-US -// UNKNOWN-8BIT -// MNEMONIC -// MNEM -// VISCII -// VIQR -// HZ-GB-2312 -// Big5-HKSCS -// Amiga1251 -// KOI7-switched -// BRF -// TSCII -// TIS-620 - - - -}; - - - -#endif diff --git a/extras/anytermd/libpbe/include/charset/const_character_iterator.hh b/extras/anytermd/libpbe/include/charset/const_character_iterator.hh deleted file mode 100644 index 6fd7117c68..0000000000 --- a/extras/anytermd/libpbe/include/charset/const_character_iterator.hh +++ /dev/null @@ -1,102 +0,0 @@ -// const_character_iterator.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2007-2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - - -#ifndef libpbe_charset_const_character_iterator_hh -#define libpbe_charset_const_character_iterator_hh - -#include "charset_t.hh" -#include "charset_traits.hh" - -#include - - -namespace pbe { - - -// const_character_iterator -// ------------------------ -// -// This iterator adaptor converts an iterator over the units of a string -// to an iterator over the characters. -// This is of course a trivial operation for fixed-length character sets, -// and non-trivial for variable-length ones. The character-set-specific -// details are provided by various functions in the character set's traits -// class. -// The iterator is implemented using Boost's iterator_adaptor class. -// -// Typical use is as follows: -// std::container ctr; // some sort of container containing bytes, -// // in UTF-8. -// std::container::const_iterator i = ctr.begin(); -// // i iterates over the bytes. -// const_character_iterator j = i; -// // j iterates over the decoded characters. -// -// The const_character_iterator is, as the name suggests, a const iterator: -// it's not possible to change the string using it since that could require -// that the string grows or shrinks. It's also not a random-access iterator, -// even if the underlying iterator is random-access, since random access -// is O(n) rather than O(1). - - -template -class const_character_iterator: - public boost::iterator_adaptor, - unit_iterator_t, - typename charset_traits::char_t const, - boost::bidirectional_traversal_tag, - // FIXME should be min(unit_iterator_t,bidirectional) - typename charset_traits::char_t const> -{ - typedef charset_traits traits; - typename traits::char_t dereference() const { - unit_iterator_t i = const_character_iterator::iterator_adaptor_::base(); - return traits::decode(i); - } - void increment(void) { - traits::skip_forward_char(const_character_iterator::iterator_adaptor_::base_reference()); - } - void decrement(void) { - traits::skip_backward_char(const_character_iterator::iterator_adaptor_::base_reference()); - } - - friend class boost::iterator_core_access; - -public: - const_character_iterator() {} - const_character_iterator(const unit_iterator_t& iter): - const_character_iterator::iterator_adaptor_(iter) - {} -}; - - -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/charset/contig_sequence_conv.hh b/extras/anytermd/libpbe/include/charset/contig_sequence_conv.hh deleted file mode 100644 index 5871f02e09..0000000000 --- a/extras/anytermd/libpbe/include/charset/contig_sequence_conv.hh +++ /dev/null @@ -1,148 +0,0 @@ -// contig_sequence_conv.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_contig_sequence_conv_hh -#define libpbe_charset_contig_sequence_conv_hh - -#include "charset_t.hh" -#include "sequence_conv.hh" -#include "const_character_iterator.hh" -#include "charset_traits.hh" - -#include - - -namespace pbe { - -// Conversion of strings in contiguous memory -// ------------------------------------------ -// -// This file provides a specialisation of sequence_conv for data in -// contiguous memory, for which an optimised algorithm is possible. - -// Some background can be found at -// http://gcc.gnu.org/ml/libstdc++/2005-11/msg00275.html - -// There are at least these cases where the elements are contiguous: -// - raw memory, i.e. the iterator is a pointer (guaranteed) -// - std::vector (guaranteed) -// - std::valarray (guaranteed, I think) -// - tr1::array / boost::array (guaranteed, I think) -// - std::basic_string (not formally guaranteed, but true in practice) -// It would be good to be able to automatically detect other cases, -// e.g. user-defined array-like classes, but I don't know how that can be -// done. -// This file includes the optimisations for raw memory (pointers), vectors -// and strings. Adding the others would be straightforward; the only -// issue is that it would bring in their headers. - - -template -static uint8_t byte_n(unsigned int i) { - return (i>>(8*n))&0xff; -} - - -// First we specialise for a character_iterator over a unit_t*: - -template< charset_t from_cs, charset_t to_cs, typename error_policy, typename OutputIterator > -struct sequence_conv< from_cs, to_cs, error_policy, - const_character_iterator::unit_t*>, - OutputIterator, - typename boost::enable_if_c< charset_traits::is_ascii_superset - && charset_traits::is_ascii_superset >::type - > -{ - typedef const_character_iterator::unit_t*> InputIterator; - void - operator() ( InputIterator first, const InputIterator& last, - OutputIterator result, // ?? modify in place, return new version, or what? - typename charset_traits::state_t& from_state, - typename charset_traits::state_t& to_state) - { -std::cout << "specialisation!\n"; - uintptr_t last_addr = reinterpret_cast(last.base()); - while (first != last) { - uintptr_t first_addr = reinterpret_cast(first.base()); - if (((first_addr & (sizeof(int)-1))==0) - && ((last_addr-first_addr) >= sizeof(int))) { - const unsigned* uptr = static_cast(static_cast(first.base())); - unsigned u = *uptr; - if (!(u&0x80808080)) { // FIXME 64 bits - *(result++) = byte_n<0>(u); // FIXME enable_if both cs ASCII supersets // FIXME result is ptr too - *(result++) = byte_n<1>(u); - *(result++) = byte_n<2>(u); - *(result++) = byte_n<3>(u); - first = InputIterator(first.base() + 4); - continue; - } - } - *(result++) = char_conv()(*first,from_state,to_state); - ++first; - } - } -}; - - -// Now specialise for std::basic_string and std::vector by calling the above -// pointer specialisation: - -template -struct sequence_conv< from_cs, to_cs, error_policy, - const_character_iterator::unit_t> - ::const_iterator>, - OutputIterator, - typename boost::enable_if_c< charset_traits::is_ascii_superset - && charset_traits::is_ascii_superset >::type - > -{ - typedef const_character_iterator::unit_t> - ::const_iterator> InputIterator; - typedef const_character_iterator::unit_t*> InputPointer; - void - operator() ( InputIterator first, const InputIterator& last, - OutputIterator result, // ?? modify in place, return new version, or what? - typename charset_traits::state_t& from_state, - typename charset_traits::state_t& to_state) - { - sequence_conv< from_cs,to_cs,error_policy, - InputPointer, OutputIterator > sc; - InputPointer first_p(&(*(first.base()))); - InputPointer last_p(&(*(last.base()))); - sc(first_p,last_p,result,from_state,to_state); - } -}; - - - - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/charset/conv/ascii.hh b/extras/anytermd/libpbe/include/charset/conv/ascii.hh deleted file mode 100644 index 74d2e4c2e6..0000000000 --- a/extras/anytermd/libpbe/include/charset/conv/ascii.hh +++ /dev/null @@ -1,77 +0,0 @@ -// ascii.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_conv_ascii_hh -#define libpbe_charset_conv_ascii_hh - -#include "charset/charset_t.hh" -#include "charset/char_conv.hh" - - -namespace pbe { - -// ASCII-to-Unicode character conversion -// -------------------------------------- -// -// This file provides specialisations of char_conv to convert between ASCII -// and ucs2 and ucs4. - - -IDENTITY_CHAR_CONV(cs::ascii,cs::ucs4) -IDENTITY_CHAR_CONV(cs::ascii,cs::ucs2) - -template -struct char_conv { - char8_t - operator() ( char16_t c, - charset_traits::state_t&, - charset_traits::state_t& ) { - if (c>0x7f) { - return error_policy::no_equivalent(); - } - return c; - } -}; - -template -struct char_conv { - char8_t - operator() ( char32_t c, - charset_traits::state_t&, - charset_traits::state_t& ) { - if (c>0x7f) { - return error_policy::no_equivalent(); - } - return c; - } -}; - - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/charset/conv/iso8859.hh b/extras/anytermd/libpbe/include/charset/conv/iso8859.hh deleted file mode 100644 index 6443d0132c..0000000000 --- a/extras/anytermd/libpbe/include/charset/conv/iso8859.hh +++ /dev/null @@ -1,255 +0,0 @@ -// iso8859.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_conv_iso8859_hh -#define libpbe_charset_conv_iso8859_hh - -#include "charset/charset_t.hh" -#include "charset/char_t.hh" -#include "charset/charset_traits.hh" -#include "charset/char_conv.hh" - -#include - -#include - - -namespace pbe { - -// Conversion of iso8859 characters -// -------------------------------- -// -// This file implements character conversions to and from the iso8859 character -// sets. - - -// Conversions to Unicode characters -// --------------------------------- - -// All iso8859 characters correspond to "basic multilingual plane" unicode -// characters, i.e. they fit in a 16-bit ucs2 character. - -// iso8859-1 is a special case: the first 256 Unicode characters are -// the iso8859-1 characters. - -IDENTITY_CHAR_CONV(cs::iso8859_1,cs::ucs2) -IDENTITY_CHAR_CONV(cs::iso8859_1,cs::ucs4) - - -// For the other character sets, characters 0 to 160 inclusivve map directly to -// Unicode. Tables are used to map characters 161 to 255: - -typedef char16_t iso8859_table_t[95]; // character n in [n-161]. -extern iso8859_table_t iso8859_tables[15]; // iso8859-n in [n-2]. - -// These tables are automatically generated from data from unicode.org. - -// Some character sets don't use some codes. The sentinel value -1 is stored -// in the tables for these cases. (0xffff is not a valid ucs2 character.) - -// In the following, template parameter n is the character set number 2-16. - -template -static inline int iso8859_to_ucs ( char8_t c ) -{ - int i = static_cast(static_cast(c)); - return (i<161) ? i : iso8859_tables[n-2][i-161]; -} - -#define CONV_ISO8859_TO_UCS(N) \ -template \ -struct char_conv { \ - char16_t operator() ( char8_t c, \ - charset_traits::state_t&, \ - charset_traits::state_t& ) \ - { \ - return iso8859_to_ucs(c); \ - } \ -}; \ -template \ -struct char_conv { \ - char32_t operator() ( char8_t c, \ - charset_traits::state_t&, \ - charset_traits::state_t& ) \ - { \ - return iso8859_to_ucs(c); \ - } \ -}; - -CONV_ISO8859_TO_UCS(2) -CONV_ISO8859_TO_UCS(3) -CONV_ISO8859_TO_UCS(4) -CONV_ISO8859_TO_UCS(5) -CONV_ISO8859_TO_UCS(6) -CONV_ISO8859_TO_UCS(7) -CONV_ISO8859_TO_UCS(8) -CONV_ISO8859_TO_UCS(9) -CONV_ISO8859_TO_UCS(10) -//CONV_ISO8859_TO_UCS(11) // This is missing from the IANA file - // -11 should be Thai. - // -12 is supposed to be missing; it's the abandoned Devanagari -CONV_ISO8859_TO_UCS(13) -CONV_ISO8859_TO_UCS(14) -CONV_ISO8859_TO_UCS(15) -CONV_ISO8859_TO_UCS(16) - -#undef CONV_ISO8859_TO_UCS - - -// Conversion from Unicode characters -// ---------------------------------- - -// iso8859-1 is a special case again: - -template -struct char_conv { - char8_t operator() ( char16_t c, - charset_traits::state_t&, - charset_traits::state_t& ) - { - if (c>0xff) { - error_policy::no_equivalent(); - } - return c; - } -}; - -template -struct char_conv { - char8_t operator() ( char32_t c, - charset_traits::state_t&, - charset_traits::state_t& ) - { - if (c>0xff) { - error_policy::no_equivalent(); - } - return c; - } -}; - - -// For the other cases we use tables. -// A single-level table-driven conversion would require large, sparse -// tables; instead we break the unicode space into pages and have one table -// for each combination of ucs page and iso8859 character set. -// These tables are generated dynamically only as needed by invoking -// the reverse functions above. - - -template -static inline const char8_t* mk_ucs_to_iso8859_page_table() { - char8_t* table = new char8_t[256]; // never deleted - std::fill(table,table+256,0); // 0 = no equivalent - for (int c=161; c<256; ++c) { - int unichar = iso8859_to_ucs(c); - if ((unichar>>8) == page) { - table[unichar&0xff] = c; - } - } - return table; -} - -template -static inline char8_t char_conv_ucs_to_iso8859_lookup ( uint8_t point ) -{ - /*FIXME THREAD SAFE*/ static const char8_t* table_p = mk_ucs_to_iso8859_page_table(); - char8_t c = table_p[point]; - if (c==0) { - return error_policy::no_equivalent(); - } - return c; -} - -template -static inline char8_t ucs_to_iso8859 ( int c ) -{ - if (c<=160) { - return c; - } else { - int page = c>>8; - uint8_t point = c&0xff; - switch (page) { - // These are the only pages that have any characters in any iso8859 character sets. - // FIXME we could use specialisation to consider only those pages that apply to - // a partiuclar character set. - case 0x00: return char_conv_ucs_to_iso8859_lookup(point); - case 0x01: return char_conv_ucs_to_iso8859_lookup(point); - case 0x02: return char_conv_ucs_to_iso8859_lookup(point); - case 0x03: return char_conv_ucs_to_iso8859_lookup(point); - case 0x04: return char_conv_ucs_to_iso8859_lookup(point); - case 0x05: return char_conv_ucs_to_iso8859_lookup(point); - case 0x06: return char_conv_ucs_to_iso8859_lookup(point); - case 0x0e: return char_conv_ucs_to_iso8859_lookup(point); - case 0x1e: return char_conv_ucs_to_iso8859_lookup(point); - case 0x20: return char_conv_ucs_to_iso8859_lookup(point); - case 0x21: return char_conv_ucs_to_iso8859_lookup(point); - default: return error_policy::no_equivalent(); - } - } -} - - -#define CONV_UCS_TO_ISO8859(N) \ -template \ -struct char_conv { \ - char8_t operator() ( char16_t c, \ - charset_traits::state_t&, \ - charset_traits::state_t& ) \ - { \ - return ucs_to_iso8859(c); \ - } \ -}; \ -template \ -struct char_conv { \ - char8_t operator() ( char32_t c, \ - charset_traits::state_t&, \ - charset_traits::state_t& ) \ - { \ - return ucs_to_iso8859(c); \ - } \ -}; - -CONV_UCS_TO_ISO8859(2) -CONV_UCS_TO_ISO8859(3) -CONV_UCS_TO_ISO8859(4) -CONV_UCS_TO_ISO8859(5) -CONV_UCS_TO_ISO8859(6) -CONV_UCS_TO_ISO8859(7) -CONV_UCS_TO_ISO8859(8) -CONV_UCS_TO_ISO8859(9) -CONV_UCS_TO_ISO8859(10) -CONV_UCS_TO_ISO8859(13) -CONV_UCS_TO_ISO8859(14) -CONV_UCS_TO_ISO8859(15) -CONV_UCS_TO_ISO8859(16) - -#undef CONV_UCS_TO_ISO8859 - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/charset/conv/unicode.hh b/extras/anytermd/libpbe/include/charset/conv/unicode.hh deleted file mode 100644 index f5c0fbd37c..0000000000 --- a/extras/anytermd/libpbe/include/charset/conv/unicode.hh +++ /dev/null @@ -1,88 +0,0 @@ -// unicode.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_conv_unicode_hh -#define libpbe_charset_conv_unicode_hh - -#include "charset/charset_t.hh" -#include "charset/char_conv.hh" -#include "charset/char_t.hh" - - -namespace pbe { - -// Unicode character conversion -// ---------------------------- -// -// This file provides specialisation of char_conv for the Unicode -// character types. -// Note that UTF-8 and UTF-16 characters are 32-bit characters here, -// not groups of units. -// Everything is trivial except conversion to ucs2. - -// UTF16 has not been implemented yet. - - -IDENTITY_CHAR_CONV(cs::ucs2,cs::ucs4) -IDENTITY_CHAR_CONV(cs::ucs2,cs::utf8) -//IDENTITY_CHAR_CONV(cs::ucs2,cs::utf16) - -IDENTITY_CHAR_CONV(cs::ucs4,cs::utf8) -//IDENTITY_CHAR_CONV(cs::ucs4,cs::utf16) - -IDENTITY_CHAR_CONV(cs::utf8,cs::ucs4) -//IDENTITY_CHAR_CONV(cs::utf8,cs::utf16) - -//IDENTITY_CHAR_CONV(cs::utf16,cs::ucs4) -//IDENTITY_CHAR_CONV(cs::utf16,cs::utf8) - - -#define CONV_TO_UCS2(FROM_CS) \ -template \ -struct char_conv { \ - char16_t \ - operator() ( charset_traits::char_t c, \ - charset_traits::state_t&, \ - charset_traits::state_t& ) { \ - if (c>0xffff) { \ - return error_policy::no_equivalent(); \ - } \ - return c; \ - } \ -}; - -CONV_TO_UCS2(cs::ucs4) -CONV_TO_UCS2(cs::utf8) -//CONV_TO_UCS2(cs::utf16) - -#undef CONV_TO_UCS2 - - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/charset/cs_string.hh b/extras/anytermd/libpbe/include/charset/cs_string.hh deleted file mode 100644 index 483b70f984..0000000000 --- a/extras/anytermd/libpbe/include/charset/cs_string.hh +++ /dev/null @@ -1,114 +0,0 @@ -// cs_string.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2007-2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_cs_string_hh -#define libpbe_charset_cs_string_hh - -#include "charset/charset_t.hh" -#include "charset/string_adaptor.hh" - -#include -#include - - -namespace pbe { - -// String tagged with character set -// -------------------------------- -// -// This class provides a string tagged with its character set. It is -// implemented using a std::basic_string of the character set's unit_t -// and a string_adaptor. - - -// This base class is used so that ustr is constructed before it is -// passed by reference to string_adaptor. -template -struct cs_string_base { - unit_string_t ustr_; - cs_string_base() {} - cs_string_base(unit_string_t u): ustr_(u) {} - cs_string_base(const typename unit_string_t::pointer u): ustr_(u) {} -}; - - -template< charset_t cset, - typename Alloc = std::allocator< typename charset_traits::unit_t > - > -class cs_string: - private cs_string_base< typename string_adaptor::unit_string_t >, - public string_adaptor -{ - typedef string_adaptor adaptor; - typedef cs_string_base< typename adaptor::unit_string_t > base; - typedef typename charset_traits::unit_t unit_t; - -public: - cs_string(): adaptor(base::ustr_) {} - cs_string(const unit_t* s): base(s), adaptor(base::ustr_) {} // ??? - cs_string(const cs_string& other): base(other.unit_str()), adaptor(base::ustr_) {} - cs_string(typename adaptor::size_type n, typename adaptor::value_type c): - adaptor(base::ustr_) { - append(n,c); - } - template - cs_string(InputIterator first, InputIterator last): - adaptor(base::ustr_) { - append(first,last); - } -}; - - -template -cs_string operator+(const cs_string& s1, - const cs_string& s2) { - cs_string s = s1; - s.append(s2); - return s; -} - -template -cs_string operator+(typename charset_traits::char_t c, - const cs_string& s2) { - cs_string s = c; - s.append(s2); - return s; -} - -template -cs_string operator+(const cs_string& s1, - typename charset_traits::char_t c) { - cs_string s = s1; - s.append(c); - return s; -} - - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/charset/error_policy.hh b/extras/anytermd/libpbe/include/charset/error_policy.hh deleted file mode 100644 index 562b519567..0000000000 --- a/extras/anytermd/libpbe/include/charset/error_policy.hh +++ /dev/null @@ -1,93 +0,0 @@ -// error_policy.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_error_policy_hh -#define libpbe_charset_error_policy_hh - - -namespace pbe { - -// Error Policies -// -------------- -// -// The function template char_conv takes a template parameter that specifies -// its behaviour on error. This file supplies implementations of the -// error_policy concept, though the user is free to supply -// their own. -// -// An error_policy class should provide the following static -// member functions, corresponding to the different errors that char_conv -// may detect: -// -// static int no_equivalent() -// Called when the output character set does not have an equivalent -// character. -// -// static int invalid_input() -// Called when the input is not valid for the input character set. -// -// TODO - perhaps something for approximate equivalents? -// -// If the function returns, the value that it returns is used as the return -// value of char_conv. - -// In cases where these error policies throw an exception, by default it -// is the following: -struct conversion_error {}; - -// Throw an exception on error: -template -struct error_policy_throw { - static int no_equivalent() { - throw exception(); - } - static int invalid_input() { - throw exception(); - } -}; - -// Return a sentinel value on error: -template -struct error_policy_return_sentinel { - static int no_equivalent() { - return sentinel; - } - static int invalid_input() { - return sentinel; - } -}; - - -// The default error policy is error_policy_throw: - -typedef error_policy_throw<> default_error_policy; - - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/charset/generated/charset_t_enum_body.hh b/extras/anytermd/libpbe/include/charset/generated/charset_t_enum_body.hh deleted file mode 100644 index 8191f02462..0000000000 --- a/extras/anytermd/libpbe/include/charset/generated/charset_t_enum_body.hh +++ /dev/null @@ -1,1949 +0,0 @@ -enum charset_t { - ansi_x3_4_1968, - iso646_us = ansi_x3_4_1968, - iso_646irv_1991 = ansi_x3_4_1968, - iso_ir_6 = ansi_x3_4_1968, - cp367 = ansi_x3_4_1968, - ansi_x3_4_1986 = ansi_x3_4_1968, - usascii = ansi_x3_4_1968, - iso646irv1991 = ansi_x3_4_1968, - iso_646_irv_1991 = ansi_x3_4_1968, - isoir6 = ansi_x3_4_1968, - csascii = ansi_x3_4_1968, - iso646irv_1991 = ansi_x3_4_1968, - ansix3_4_1986 = ansi_x3_4_1968, - ansix3_4_1968 = ansi_x3_4_1968, - us_ascii = ansi_x3_4_1968, - iso_ir6 = ansi_x3_4_1968, - ibm367 = ansi_x3_4_1968, - iso646us = ansi_x3_4_1968, - iso646_irv1991 = ansi_x3_4_1968, - iso646_irv_1991 = ansi_x3_4_1968, - isoir_6 = ansi_x3_4_1968, - us = ansi_x3_4_1968, - ascii = ansi_x3_4_1968, - iso_646irv1991 = ansi_x3_4_1968, - iso_646_irv1991 = ansi_x3_4_1968, - iso_8859_1_1987, - iso_ir_100 = iso_8859_1_1987, - l1 = iso_8859_1_1987, - isoir100 = iso_8859_1_1987, - iso8859_1_1987 = iso_8859_1_1987, - iso8859_1 = iso_8859_1_1987, - csisolatin1 = iso_8859_1_1987, - ibm819 = iso_8859_1_1987, - isoir_100 = iso_8859_1_1987, - cp819 = iso_8859_1_1987, - iso_8859_1 = iso_8859_1_1987, - latin1 = iso_8859_1_1987, - iso_ir100 = iso_8859_1_1987, - iso_8859_2_1987, - iso_ir_101 = iso_8859_2_1987, - iso8859_2_1987 = iso_8859_2_1987, - l2 = iso_8859_2_1987, - isoir101 = iso_8859_2_1987, - iso8859_2 = iso_8859_2_1987, - csisolatin2 = iso_8859_2_1987, - isoir_101 = iso_8859_2_1987, - iso_8859_2 = iso_8859_2_1987, - latin2 = iso_8859_2_1987, - iso_ir101 = iso_8859_2_1987, - iso_8859_3_1988, - latin3 = iso_8859_3_1988, - iso8859_3_1988 = iso_8859_3_1988, - l3 = iso_8859_3_1988, - isoir_109 = iso_8859_3_1988, - iso8859_3 = iso_8859_3_1988, - csisolatin3 = iso_8859_3_1988, - iso_ir109 = iso_8859_3_1988, - iso_ir_109 = iso_8859_3_1988, - isoir109 = iso_8859_3_1988, - iso_8859_3 = iso_8859_3_1988, - iso_8859_4_1988, - iso_8859_4 = iso_8859_4_1988, - latin4 = iso_8859_4_1988, - iso_ir_110 = iso_8859_4_1988, - isoir110 = iso_8859_4_1988, - l4 = iso_8859_4_1988, - iso8859_4 = iso_8859_4_1988, - csisolatin4 = iso_8859_4_1988, - isoir_110 = iso_8859_4_1988, - iso8859_4_1988 = iso_8859_4_1988, - iso_ir110 = iso_8859_4_1988, - iso_8859_5_1988, - csisolatincyrillic = iso_8859_5_1988, - iso8859_5_1988 = iso_8859_5_1988, - iso_8859_5 = iso_8859_5_1988, - isoir_144 = iso_8859_5_1988, - iso_ir144 = iso_8859_5_1988, - iso8859_5 = iso_8859_5_1988, - iso_ir_144 = iso_8859_5_1988, - cyrillic = iso_8859_5_1988, - isoir144 = iso_8859_5_1988, - iso_8859_6_1987, - asmo708 = iso_8859_6_1987, - ecma_114 = iso_8859_6_1987, - iso_8859_6 = iso_8859_6_1987, - arabic = iso_8859_6_1987, - isoir_127 = iso_8859_6_1987, - asmo_708 = iso_8859_6_1987, - iso_ir127 = iso_8859_6_1987, - iso8859_6 = iso_8859_6_1987, - iso_ir_127 = iso_8859_6_1987, - iso8859_6_1987 = iso_8859_6_1987, - csisolatinarabic = iso_8859_6_1987, - ecma114 = iso_8859_6_1987, - isoir127 = iso_8859_6_1987, - iso_8859_7_1987, - ecma118 = iso_8859_7_1987, - isoir_126 = iso_8859_7_1987, - greek8 = iso_8859_7_1987, - iso_8859_7 = iso_8859_7_1987, - elot928 = iso_8859_7_1987, - ecma_118 = iso_8859_7_1987, - iso_ir126 = iso_8859_7_1987, - csisolatingreek = iso_8859_7_1987, - iso_ir_126 = iso_8859_7_1987, - iso8859_7_1987 = iso_8859_7_1987, - greek = iso_8859_7_1987, - elot_928 = iso_8859_7_1987, - iso8859_7 = iso_8859_7_1987, - isoir126 = iso_8859_7_1987, - iso_8859_8_1988, - isoir138 = iso_8859_8_1988, - iso_8859_8 = iso_8859_8_1988, - csisolatinhebrew = iso_8859_8_1988, - isoir_138 = iso_8859_8_1988, - iso8859_8_1988 = iso_8859_8_1988, - iso_ir138 = iso_8859_8_1988, - hebrew = iso_8859_8_1988, - iso8859_8 = iso_8859_8_1988, - iso_ir_138 = iso_8859_8_1988, - iso_8859_9_1989, - isoir148 = iso_8859_9_1989, - latin5 = iso_8859_9_1989, - l5 = iso_8859_9_1989, - iso_8859_9 = iso_8859_9_1989, - isoir_148 = iso_8859_9_1989, - iso8859_9_1989 = iso_8859_9_1989, - csisolatin5 = iso_8859_9_1989, - iso_ir148 = iso_8859_9_1989, - iso8859_9 = iso_8859_9_1989, - iso_ir_148 = iso_8859_9_1989, - iso_8859_10, - isoir157 = iso_8859_10, - latin6 = iso_8859_10, - l6 = iso_8859_10, - isoir_157 = iso_8859_10, - iso_8859_10_1992 = iso_8859_10, - csisolatin6 = iso_8859_10, - iso_ir157 = iso_8859_10, - iso8859_10 = iso_8859_10, - iso8859_10_1992 = iso_8859_10, - iso_ir_157 = iso_8859_10, - iso_6937_2_add, - csisotextcomm = iso_6937_2_add, - isoir_142 = iso_6937_2_add, - iso_6937_2add = iso_6937_2_add, - iso_ir142 = iso_6937_2_add, - iso_ir_142 = iso_6937_2_add, - isoir142 = iso_6937_2_add, - iso6937_2add = iso_6937_2_add, - iso6937_2_add = iso_6937_2_add, - jis_x0201, - cshalfwidthkatakana = jis_x0201, - jisx0201 = jis_x0201, - x0201 = jis_x0201, - jis_encoding, - csjisencoding = jis_encoding, - jisencoding = jis_encoding, - shift_jis, - csshiftjis = shift_jis, - mskanji = shift_jis, - ms_kanji = shift_jis, - shiftjis = shift_jis, - extended_unix_code_packed_format_for_japanese, - extended_unixcode_packed_format_for_japanese= extended_unix_code_packed_format_for_japanese, - extendedunix_code_packed_formatfor_japanese= extended_unix_code_packed_format_for_japanese, - extended_unixcodepackedformat_for_japanese= extended_unix_code_packed_format_for_japanese, - extendedunixcode_packed_formatforjapanese= extended_unix_code_packed_format_for_japanese, - extendedunix_code_packedformatforjapanese= extended_unix_code_packed_format_for_japanese, - extended_unixcodepackedformat_forjapanese= extended_unix_code_packed_format_for_japanese, - extendedunix_codepacked_format_forjapanese= extended_unix_code_packed_format_for_japanese, - extendedunixcodepacked_formatforjapanese= extended_unix_code_packed_format_for_japanese, - extendedunix_code_packed_formatforjapanese= extended_unix_code_packed_format_for_japanese, - extendedunixcode_packed_format_forjapanese= extended_unix_code_packed_format_for_japanese, - extended_unixcodepacked_format_forjapanese= extended_unix_code_packed_format_for_japanese, - extended_unix_codepacked_formatforjapanese= extended_unix_code_packed_format_for_japanese, - extended_unixcode_packed_formatforjapanese= extended_unix_code_packed_format_for_japanese, - euc_jp = extended_unix_code_packed_format_for_japanese, - extended_unix_codepacked_format_forjapanese= extended_unix_code_packed_format_for_japanese, - extended_unix_code_packed_formatforjapanese= extended_unix_code_packed_format_for_japanese, - extended_unixcode_packed_format_forjapanese= extended_unix_code_packed_format_for_japanese, - extendedunix_codepacked_format_for_japanese= extended_unix_code_packed_format_for_japanese, - extendedunixcode_packedformat_forjapanese= extended_unix_code_packed_format_for_japanese, - extendedunix_codepackedformat_forjapanese= extended_unix_code_packed_format_for_japanese, - extendedunixcode_packedformatforjapanese= extended_unix_code_packed_format_for_japanese, - extendedunix_code_packed_format_for_japanese= extended_unix_code_packed_format_for_japanese, - extended_unix_code_packedformat_for_japanese= extended_unix_code_packed_format_for_japanese, - extendedunix_codepackedformatforjapanese= extended_unix_code_packed_format_for_japanese, - extended_unix_code_packedformatforjapanese= extended_unix_code_packed_format_for_japanese, - extendedunixcodepacked_formatfor_japanese= extended_unix_code_packed_format_for_japanese, - extended_unix_code_packedformat_forjapanese= extended_unix_code_packed_format_for_japanese, - extendedunixcode_packed_format_for_japanese= extended_unix_code_packed_format_for_japanese, - cseucpkdfmtjapanese = extended_unix_code_packed_format_for_japanese, - extended_unixcodepackedformatfor_japanese= extended_unix_code_packed_format_for_japanese, - extended_unix_code_packed_format_forjapanese= extended_unix_code_packed_format_for_japanese, - extendedunixcodepackedformatforjapanese= extended_unix_code_packed_format_for_japanese, - extendedunixcodepackedformat_forjapanese= extended_unix_code_packed_format_for_japanese, - extendedunix_code_packedformat_forjapanese= extended_unix_code_packed_format_for_japanese, - extended_unix_codepacked_formatfor_japanese= extended_unix_code_packed_format_for_japanese, - extended_unix_codepackedformat_forjapanese= extended_unix_code_packed_format_for_japanese, - extended_unixcode_packedformat_forjapanese= extended_unix_code_packed_format_for_japanese, - eucjp = extended_unix_code_packed_format_for_japanese, - extendedunix_codepacked_formatfor_japanese= extended_unix_code_packed_format_for_japanese, - extendedunix_code_packedformat_for_japanese= extended_unix_code_packed_format_for_japanese, - extendedunixcode_packed_formatfor_japanese= extended_unix_code_packed_format_for_japanese, - extended_unixcodepacked_formatfor_japanese= extended_unix_code_packed_format_for_japanese, - extended_unixcode_packed_formatfor_japanese= extended_unix_code_packed_format_for_japanese, - extendedunixcode_packedformatfor_japanese= extended_unix_code_packed_format_for_japanese, - extendedunix_codepackedformatfor_japanese= extended_unix_code_packed_format_for_japanese, - extendedunixcodepacked_format_for_japanese= extended_unix_code_packed_format_for_japanese, - extendedunixcodepackedformatfor_japanese= extended_unix_code_packed_format_for_japanese, - extendedunix_code_packedformatfor_japanese= extended_unix_code_packed_format_for_japanese, - extended_unixcodepacked_format_for_japanese= extended_unix_code_packed_format_for_japanese, - extended_unix_codepackedformatfor_japanese= extended_unix_code_packed_format_for_japanese, - extendedunix_code_packed_format_forjapanese= extended_unix_code_packed_format_for_japanese, - extended_unix_code_packedformatfor_japanese= extended_unix_code_packed_format_for_japanese, - extended_unixcodepacked_formatforjapanese= extended_unix_code_packed_format_for_japanese, - extended_unix_code_packed_formatfor_japanese= extended_unix_code_packed_format_for_japanese, - extended_unixcode_packedformatforjapanese= extended_unix_code_packed_format_for_japanese, - extendedunixcodepackedformat_for_japanese= extended_unix_code_packed_format_for_japanese, - extended_unixcode_packedformatfor_japanese= extended_unix_code_packed_format_for_japanese, - extendedunix_codepackedformat_for_japanese= extended_unix_code_packed_format_for_japanese, - extendedunixcode_packedformat_for_japanese= extended_unix_code_packed_format_for_japanese, - extendedunixcodepacked_format_forjapanese= extended_unix_code_packed_format_for_japanese, - extendedunix_codepacked_formatforjapanese= extended_unix_code_packed_format_for_japanese, - extended_unix_codepackedformat_for_japanese= extended_unix_code_packed_format_for_japanese, - extended_unix_codepacked_format_for_japanese= extended_unix_code_packed_format_for_japanese, - extended_unixcode_packedformat_for_japanese= extended_unix_code_packed_format_for_japanese, - extended_unix_codepackedformatforjapanese= extended_unix_code_packed_format_for_japanese, - extended_unixcodepackedformatforjapanese= extended_unix_code_packed_format_for_japanese, - extended_unix_code_fixed_width_for_japanese, - extended_unixcode_fixedwidth_for_japanese= extended_unix_code_fixed_width_for_japanese, - extendedunixcodefixed_widthfor_japanese= extended_unix_code_fixed_width_for_japanese, - extendedunixcode_fixedwidthfor_japanese= extended_unix_code_fixed_width_for_japanese, - extendedunix_codefixed_widthfor_japanese= extended_unix_code_fixed_width_for_japanese, - extended_unixcodefixed_widthforjapanese= extended_unix_code_fixed_width_for_japanese, - extendedunix_codefixed_widthforjapanese= extended_unix_code_fixed_width_for_japanese, - extended_unixcodefixedwidth_forjapanese= extended_unix_code_fixed_width_for_japanese, - extended_unix_code_fixed_widthforjapanese= extended_unix_code_fixed_width_for_japanese, - extended_unix_codefixedwidth_for_japanese= extended_unix_code_fixed_width_for_japanese, - extended_unixcode_fixed_width_forjapanese= extended_unix_code_fixed_width_for_japanese, - extended_unixcode_fixed_widthforjapanese= extended_unix_code_fixed_width_for_japanese, - extended_unixcodefixedwidth_for_japanese= extended_unix_code_fixed_width_for_japanese, - extended_unixcodefixed_width_for_japanese= extended_unix_code_fixed_width_for_japanese, - extended_unix_code_fixedwidth_forjapanese= extended_unix_code_fixed_width_for_japanese, - extended_unixcode_fixedwidth_forjapanese= extended_unix_code_fixed_width_for_japanese, - extendedunix_codefixedwidthforjapanese= extended_unix_code_fixed_width_for_japanese, - extendedunixcodefixed_widthforjapanese= extended_unix_code_fixed_width_for_japanese, - extendedunix_code_fixedwidth_for_japanese= extended_unix_code_fixed_width_for_japanese, - extended_unix_codefixedwidthfor_japanese= extended_unix_code_fixed_width_for_japanese, - extendedunix_codefixedwidth_forjapanese= extended_unix_code_fixed_width_for_japanese, - extended_unix_codefixed_width_forjapanese= extended_unix_code_fixed_width_for_japanese, - extendedunixcode_fixedwidth_for_japanese= extended_unix_code_fixed_width_for_japanese, - extended_unixcodefixed_width_forjapanese= extended_unix_code_fixed_width_for_japanese, - extended_unix_code_fixedwidthforjapanese= extended_unix_code_fixed_width_for_japanese, - extended_unix_code_fixedwidth_for_japanese= extended_unix_code_fixed_width_for_japanese, - extendedunix_code_fixed_width_forjapanese= extended_unix_code_fixed_width_for_japanese, - extendedunixcodefixedwidth_forjapanese= extended_unix_code_fixed_width_for_japanese, - extendedunixcode_fixed_widthforjapanese= extended_unix_code_fixed_width_for_japanese, - extendedunixcode_fixed_width_for_japanese= extended_unix_code_fixed_width_for_japanese, - extendedunix_codefixed_width_for_japanese= extended_unix_code_fixed_width_for_japanese, - extendedunixcodefixedwidth_for_japanese= extended_unix_code_fixed_width_for_japanese, - extendedunix_code_fixed_widthforjapanese= extended_unix_code_fixed_width_for_japanese, - extendedunix_codefixedwidth_for_japanese= extended_unix_code_fixed_width_for_japanese, - extendedunix_code_fixed_width_for_japanese= extended_unix_code_fixed_width_for_japanese, - extended_unixcodefixedwidthfor_japanese= extended_unix_code_fixed_width_for_japanese, - extended_unixcode_fixed_widthfor_japanese= extended_unix_code_fixed_width_for_japanese, - extended_unixcode_fixedwidthforjapanese= extended_unix_code_fixed_width_for_japanese, - extendedunix_codefixedwidthfor_japanese= extended_unix_code_fixed_width_for_japanese, - extended_unix_code_fixedwidthfor_japanese= extended_unix_code_fixed_width_for_japanese, - extendedunixcode_fixed_width_forjapanese= extended_unix_code_fixed_width_for_japanese, - extended_unixcodefixedwidthforjapanese= extended_unix_code_fixed_width_for_japanese, - extended_unixcode_fixedwidthfor_japanese= extended_unix_code_fixed_width_for_japanese, - cseucfixwidjapanese = extended_unix_code_fixed_width_for_japanese, - extendedunixcode_fixedwidth_forjapanese= extended_unix_code_fixed_width_for_japanese, - extendedunixcodefixed_width_for_japanese= extended_unix_code_fixed_width_for_japanese, - extendedunix_codefixed_width_forjapanese= extended_unix_code_fixed_width_for_japanese, - extended_unix_code_fixed_width_forjapanese= extended_unix_code_fixed_width_for_japanese, - extendedunix_code_fixedwidth_forjapanese= extended_unix_code_fixed_width_for_japanese, - extended_unix_codefixed_width_for_japanese= extended_unix_code_fixed_width_for_japanese, - extended_unixcode_fixed_width_for_japanese= extended_unix_code_fixed_width_for_japanese, - extended_unix_codefixed_widthforjapanese= extended_unix_code_fixed_width_for_japanese, - extendedunixcodefixedwidthforjapanese= extended_unix_code_fixed_width_for_japanese, - extended_unix_codefixed_widthfor_japanese= extended_unix_code_fixed_width_for_japanese, - extended_unixcodefixed_widthfor_japanese= extended_unix_code_fixed_width_for_japanese, - extendedunixcodefixed_width_forjapanese= extended_unix_code_fixed_width_for_japanese, - extendedunix_code_fixedwidthforjapanese= extended_unix_code_fixed_width_for_japanese, - extendedunix_code_fixed_widthfor_japanese= extended_unix_code_fixed_width_for_japanese, - extendedunixcodefixedwidthfor_japanese= extended_unix_code_fixed_width_for_japanese, - extended_unix_codefixedwidth_forjapanese= extended_unix_code_fixed_width_for_japanese, - extendedunixcode_fixed_widthfor_japanese= extended_unix_code_fixed_width_for_japanese, - extendedunixcode_fixedwidthforjapanese= extended_unix_code_fixed_width_for_japanese, - extended_unix_codefixedwidthforjapanese= extended_unix_code_fixed_width_for_japanese, - extended_unix_code_fixed_widthfor_japanese= extended_unix_code_fixed_width_for_japanese, - extendedunix_code_fixedwidthfor_japanese= extended_unix_code_fixed_width_for_japanese, - bs_4730, - uk = bs_4730, - isoir4 = bs_4730, - iso646gb = bs_4730, - gb = bs_4730, - iso_ir4 = bs_4730, - bs4730 = bs_4730, - iso646_gb = bs_4730, - isoir_4 = bs_4730, - iso_ir_4 = bs_4730, - csiso4unitedkingdom = bs_4730, - sen_850200_c, - isoir_11 = sen_850200_c, - iso_ir11 = sen_850200_c, - sen850200c = sen_850200_c, - iso646se2 = sen_850200_c, - iso646_se2 = sen_850200_c, - sen_850200c = sen_850200_c, - csiso11swedishfornames = sen_850200_c, - iso_ir_11 = sen_850200_c, - sen850200_c = sen_850200_c, - se2 = sen_850200_c, - isoir11 = sen_850200_c, - it, - iso_ir_15 = it, - iso646_it = it, - isoir15 = it, - csiso15italian = it, - isoir_15 = it, - iso_ir15 = it, - iso646it = it, - es, - iso_ir_17 = es, - isoir17 = es, - isoir_17 = es, - iso646es = es, - iso_ir17 = es, - csiso17spanish = es, - iso646_es = es, - din_66003, - isoir_21 = din_66003, - iso_ir21 = din_66003, - csiso21german = din_66003, - iso646de = din_66003, - din66003 = din_66003, - de = din_66003, - iso646_de = din_66003, - iso_ir_21 = din_66003, - isoir21 = din_66003, - ns_4551_1, - no = ns_4551_1, - iso_ir_60 = ns_4551_1, - csiso60norwegian1 = ns_4551_1, - iso646_no = ns_4551_1, - isoir60 = ns_4551_1, - csiso60danishnorwegian = ns_4551_1, - isoir_60 = ns_4551_1, - iso_ir60 = ns_4551_1, - ns4551_1 = ns_4551_1, - iso646no = ns_4551_1, - nf_z_62_010, - isoir_69 = nf_z_62_010, - nfz62_010 = nf_z_62_010, - iso_ir69 = nf_z_62_010, - csiso69french = nf_z_62_010, - iso646fr = nf_z_62_010, - fr = nf_z_62_010, - iso_ir_69 = nf_z_62_010, - iso646_fr = nf_z_62_010, - isoir69 = nf_z_62_010, - nf_z62_010 = nf_z_62_010, - nfz_62_010 = nf_z_62_010, - iso_10646_utf_1, - iso10646_utf1 = iso_10646_utf_1, - iso_10646utf_1 = iso_10646_utf_1, - iso_10646_utf1 = iso_10646_utf_1, - iso10646utf1 = iso_10646_utf_1, - iso10646_utf_1 = iso_10646_utf_1, - iso10646utf_1 = iso_10646_utf_1, - csiso10646utf1 = iso_10646_utf_1, - iso_10646utf1 = iso_10646_utf_1, - iso_646_basic_1983, - iso646_basic_1983 = iso_646_basic_1983, - iso_646basic1983 = iso_646_basic_1983, - iso646basic1983 = iso_646_basic_1983, - iso646_basic1983 = iso_646_basic_1983, - ref = iso_646_basic_1983, - iso646basic_1983 = iso_646_basic_1983, - csiso646basic1983 = iso_646_basic_1983, - iso_646basic_1983 = iso_646_basic_1983, - iso_646_basic1983 = iso_646_basic_1983, - invariant, - csinvariant = invariant, - iso_646_irv_1983, - iso_646_irv1983 = iso_646_irv_1983, - iso_646irv_1983 = iso_646_irv_1983, - isoir2 = iso_646_irv_1983, - irv = iso_646_irv_1983, - iso_ir2 = iso_646_irv_1983, - isoir_2 = iso_646_irv_1983, - iso646irv1983 = iso_646_irv_1983, - csiso2intlrefversion = iso_646_irv_1983, - iso646irv_1983 = iso_646_irv_1983, - iso_ir_2 = iso_646_irv_1983, - iso646_irv1983 = iso_646_irv_1983, - iso646_irv_1983 = iso_646_irv_1983, - iso_646irv1983 = iso_646_irv_1983, - nats_sefi, - natssefi = nats_sefi, - iso_ir8_1 = nats_sefi, - csnatssefi = nats_sefi, - iso_ir_8_1 = nats_sefi, - isoir8_1 = nats_sefi, - isoir_8_1 = nats_sefi, - nats_sefi_add, - isoir_8_2 = nats_sefi_add, - iso_ir8_2 = nats_sefi_add, - iso_ir_8_2 = nats_sefi_add, - natssefi_add = nats_sefi_add, - csnatssefiadd = nats_sefi_add, - isoir8_2 = nats_sefi_add, - natssefiadd = nats_sefi_add, - nats_sefiadd = nats_sefi_add, - nats_dano, - isoir_9_1 = nats_dano, - csnatsdano = nats_dano, - iso_ir9_1 = nats_dano, - iso_ir_9_1 = nats_dano, - natsdano = nats_dano, - isoir9_1 = nats_dano, - nats_dano_add, - isoir9_2 = nats_dano_add, - csnatsdanoadd = nats_dano_add, - natsdanoadd = nats_dano_add, - nats_danoadd = nats_dano_add, - isoir_9_2 = nats_dano_add, - iso_ir9_2 = nats_dano_add, - iso_ir_9_2 = nats_dano_add, - natsdano_add = nats_dano_add, - sen_850200_b, - iso_ir10 = sen_850200_b, - sen850200b = sen_850200_b, - iso646_fi = sen_850200_b, - sen_850200b = sen_850200_b, - iso646se = sen_850200_b, - se = sen_850200_b, - iso_ir_10 = sen_850200_b, - sen850200_b = sen_850200_b, - iso646_se = sen_850200_b, - isoir10 = sen_850200_b, - csiso10swedish = sen_850200_b, - iso646fi = sen_850200_b, - fi = sen_850200_b, - isoir_10 = sen_850200_b, - ks_c_5601_1987, - ksc_5601_1989 = ks_c_5601_1987, - iso_ir_149 = ks_c_5601_1987, - ksc_5601 = ks_c_5601_1987, - isoir149 = ks_c_5601_1987, - korean = ks_c_5601_1987, - ksc5601_1987 = ks_c_5601_1987, - ks_c_5601_1989 = ks_c_5601_1987, - ksc5601_1989 = ks_c_5601_1987, - ksc5601 = ks_c_5601_1987, - isoir_149 = ks_c_5601_1987, - ks_c5601_1987 = ks_c_5601_1987, - csksc56011987 = ks_c_5601_1987, - ks_c5601_1989 = ks_c_5601_1987, - iso_ir149 = ks_c_5601_1987, - ksc_5601_1987 = ks_c_5601_1987, - iso_2022_kr, - iso2022kr = iso_2022_kr, - iso2022_kr = iso_2022_kr, - iso_2022kr = iso_2022_kr, - csiso2022kr = iso_2022_kr, - euc_kr, - cseuckr = euc_kr, - euckr = euc_kr, - iso_2022_jp, - iso2022_jp = iso_2022_jp, - iso_2022jp = iso_2022_jp, - csiso2022jp = iso_2022_jp, - iso2022jp = iso_2022_jp, - iso_2022_jp_2, - iso_2022_jp2 = iso_2022_jp_2, - iso2022jp_2 = iso_2022_jp_2, - iso_2022jp_2 = iso_2022_jp_2, - iso2022_jp_2 = iso_2022_jp_2, - iso2022jp2 = iso_2022_jp_2, - csiso2022jp2 = iso_2022_jp_2, - iso_2022jp2 = iso_2022_jp_2, - iso2022_jp2 = iso_2022_jp_2, - jis_c6220_1969_jp, - isoir13 = jis_c6220_1969_jp, - isoir_13 = jis_c6220_1969_jp, - iso_ir13 = jis_c6220_1969_jp, - csiso13jisc6220jp = jis_c6220_1969_jp, - katakana = jis_c6220_1969_jp, - jisc6220_1969 = jis_c6220_1969_jp, - jis_c6220_1969jp = jis_c6220_1969_jp, - jis_c6220_1969 = jis_c6220_1969_jp, - x0201_7 = jis_c6220_1969_jp, - iso_ir_13 = jis_c6220_1969_jp, - jisc6220_1969_jp = jis_c6220_1969_jp, - jisc6220_1969jp = jis_c6220_1969_jp, - jis_c6220_1969_ro, - csiso14jisc6220ro = jis_c6220_1969_ro, - isoir14 = jis_c6220_1969_ro, - jis_c6220_1969ro = jis_c6220_1969_ro, - isoir_14 = jis_c6220_1969_ro, - iso_ir14 = jis_c6220_1969_ro, - jisc6220_1969_ro = jis_c6220_1969_ro, - jisc6220_1969ro = jis_c6220_1969_ro, - iso646jp = jis_c6220_1969_ro, - jp = jis_c6220_1969_ro, - iso646_jp = jis_c6220_1969_ro, - iso_ir_14 = jis_c6220_1969_ro, - pt, - iso_ir_16 = pt, - isoir16 = pt, - csiso16portuguese = pt, - isoir_16 = pt, - iso646pt = pt, - iso_ir16 = pt, - iso646_pt = pt, - greek7_old, - csiso18greek7old = greek7_old, - iso_ir_18 = greek7_old, - isoir18 = greek7_old, - isoir_18 = greek7_old, - iso_ir18 = greek7_old, - greek7old = greek7_old, - latin_greek, - iso_ir_19 = latin_greek, - latingreek = latin_greek, - isoir19 = latin_greek, - isoir_19 = latin_greek, - iso_ir19 = latin_greek, - csiso19latingreek = latin_greek, - nf_z_62_010__1973_, - nfz62_010__1973_ = nf_z_62_010__1973_, - iso_ir_25 = nf_z_62_010__1973_, - isoir25 = nf_z_62_010__1973_, - nf_z62_010__1973_ = nf_z_62_010__1973_, - iso646fr1 = nf_z_62_010__1973_, - iso646_fr1 = nf_z_62_010__1973_, - isoir_25 = nf_z_62_010__1973_, - nf_z_62_010_1973 = nf_z_62_010__1973_, - nf_z62_010_1973 = nf_z_62_010__1973_, - csiso25french = nf_z_62_010__1973_, - iso_ir25 = nf_z_62_010__1973_, - nf_z62_010_1973_ = nf_z_62_010__1973_, - nf_z_62_010__1973 = nf_z_62_010__1973_, - nf_z62_010__1973 = nf_z_62_010__1973_, - nfz_62_010_1973_ = nf_z_62_010__1973_, - nfz_62_010__1973 = nf_z_62_010__1973_, - nfz62_010__1973 = nf_z_62_010__1973_, - nfz62_010_1973 = nf_z_62_010__1973_, - nfz_62_010__1973_ = nf_z_62_010__1973_, - nf_z_62_010_1973_ = nf_z_62_010__1973_, - nfz_62_010_1973 = nf_z_62_010__1973_, - nfz62_010_1973_ = nf_z_62_010__1973_, - latin_greek_1, - iso_ir_27 = latin_greek_1, - isoir27 = latin_greek_1, - isoir_27 = latin_greek_1, - iso_ir27 = latin_greek_1, - latingreek_1 = latin_greek_1, - csiso27latingreek1 = latin_greek_1, - latin_greek1 = latin_greek_1, - latingreek1 = latin_greek_1, - iso_5427, - iso_ir_37 = iso_5427, - isoir37 = iso_5427, - iso5427 = iso_5427, - isoir_37 = iso_5427, - iso_ir37 = iso_5427, - csiso5427cyrillic = iso_5427, - jis_c6226_1978, - iso_ir_42 = jis_c6226_1978, - isoir42 = jis_c6226_1978, - isoir_42 = jis_c6226_1978, - iso_ir42 = jis_c6226_1978, - jisc6226_1978 = jis_c6226_1978, - csiso42jisc62261978 = jis_c6226_1978, - bs_viewdata, - bsviewdata = bs_viewdata, - iso_ir_47 = bs_viewdata, - isoir47 = bs_viewdata, - isoir_47 = bs_viewdata, - iso_ir47 = bs_viewdata, - csiso47bsviewdata = bs_viewdata, - inis, - iso_ir_49 = inis, - isoir49 = inis, - isoir_49 = inis, - csiso49inis = inis, - iso_ir49 = inis, - inis_8, - isoir50 = inis_8, - isoir_50 = inis_8, - iso_ir50 = inis_8, - csiso50inis8 = inis_8, - inis8 = inis_8, - iso_ir_50 = inis_8, - inis_cyrillic, - csiso51iniscyrillic = inis_cyrillic, - iso_ir_51 = inis_cyrillic, - isoir51 = inis_cyrillic, - isoir_51 = inis_cyrillic, - iso_ir51 = inis_cyrillic, - iniscyrillic = inis_cyrillic, - iso_5427_1981, - iso_ir_54 = iso_5427_1981, - isoir54 = iso_5427_1981, - isoir_54 = iso_5427_1981, - iso_ir54 = iso_5427_1981, - iso5427_1981 = iso_5427_1981, - iso5427cyrillic1981 = iso_5427_1981, - iso_5428_1980, - iso_ir_55 = iso_5428_1980, - iso5428_1980 = iso_5428_1980, - isoir55 = iso_5428_1980, - isoir_55 = iso_5428_1980, - iso_ir55 = iso_5428_1980, - csiso5428greek = iso_5428_1980, - gb_1988_80, - iso646cn = gb_1988_80, - gb1988_80 = gb_1988_80, - cn = gb_1988_80, - iso646_cn = gb_1988_80, - iso_ir_57 = gb_1988_80, - isoir57 = gb_1988_80, - isoir_57 = gb_1988_80, - iso_ir57 = gb_1988_80, - csiso57gb1988 = gb_1988_80, - gb_2312_80, - csiso58gb231280 = gb_2312_80, - chinese = gb_2312_80, - iso_ir_58 = gb_2312_80, - isoir58 = gb_2312_80, - gb2312_80 = gb_2312_80, - isoir_58 = gb_2312_80, - iso_ir58 = gb_2312_80, - ns_4551_2, - iso_ir_61 = ns_4551_2, - isoir61 = ns_4551_2, - csiso61norwegian2 = ns_4551_2, - iso646no2 = ns_4551_2, - iso646_no2 = ns_4551_2, - isoir_61 = ns_4551_2, - iso_ir61 = ns_4551_2, - no2 = ns_4551_2, - ns4551_2 = ns_4551_2, - videotex_suppl, - iso_ir_70 = videotex_suppl, - isoir70 = videotex_suppl, - csiso70videotexsupp1 = videotex_suppl, - isoir_70 = videotex_suppl, - iso_ir70 = videotex_suppl, - videotexsuppl = videotex_suppl, - pt2, - csiso84portuguese2 = pt2, - iso646pt2 = pt2, - iso646_pt2 = pt2, - iso_ir_84 = pt2, - isoir84 = pt2, - isoir_84 = pt2, - iso_ir84 = pt2, - es2, - iso646es2 = es2, - iso646_es2 = es2, - iso_ir_85 = es2, - isoir85 = es2, - isoir_85 = es2, - csiso85spanish2 = es2, - iso_ir85 = es2, - msz_7795_3, - hu = msz_7795_3, - iso_ir86 = msz_7795_3, - msz7795_3 = msz_7795_3, - iso646_hu = msz_7795_3, - csiso86hungarian = msz_7795_3, - iso_ir_86 = msz_7795_3, - isoir86 = msz_7795_3, - iso646hu = msz_7795_3, - isoir_86 = msz_7795_3, - jis_c6226_1983, - jisx0208_1983 = jis_c6226_1983, - isoir_87 = jis_c6226_1983, - iso_ir87 = jis_c6226_1983, - csiso87jisx0208 = jis_c6226_1983, - x0208 = jis_c6226_1983, - jisc6226_1983 = jis_c6226_1983, - jis_x0208_1983 = jis_c6226_1983, - iso_ir_87 = jis_c6226_1983, - isoir87 = jis_c6226_1983, - greek7, - isoir_88 = greek7, - iso_ir88 = greek7, - csiso88greek7 = greek7, - iso_ir_88 = greek7, - isoir88 = greek7, - asmo_449, - isoir89 = asmo_449, - iso_9036 = asmo_449, - isoir_89 = asmo_449, - iso_ir89 = asmo_449, - asmo449 = asmo_449, - csiso89asmo449 = asmo_449, - iso_ir_89 = asmo_449, - arabic7 = asmo_449, - iso9036 = asmo_449, - iso_ir_90, - csiso90 = iso_ir_90, - isoir90 = iso_ir_90, - isoir_90 = iso_ir_90, - iso_ir90 = iso_ir_90, - jis_c6229_1984_a, - csiso91jisc62291984a = jis_c6229_1984_a, - iso_ir_91 = jis_c6229_1984_a, - jp_ocr_a = jis_c6229_1984_a, - jisc6229_1984a = jis_c6229_1984_a, - jisc6229_1984_a = jis_c6229_1984_a, - jpocr_a = jis_c6229_1984_a, - isoir91 = jis_c6229_1984_a, - isoir_91 = jis_c6229_1984_a, - jp_ocra = jis_c6229_1984_a, - iso_ir91 = jis_c6229_1984_a, - jis_c6229_1984a = jis_c6229_1984_a, - jpocra = jis_c6229_1984_a, - jis_c6229_1984_b, - jpocrb = jis_c6229_1984_b, - iso646_jp_ocrb = jis_c6229_1984_b, - iso646_jp_ocr_b = jis_c6229_1984_b, - iso646jpocr_b = jis_c6229_1984_b, - csiso92jisc62991984b = jis_c6229_1984_b, - iso_ir_92 = jis_c6229_1984_b, - jp_ocr_b = jis_c6229_1984_b, - iso646_jpocr_b = jis_c6229_1984_b, - jisc6229_1984b = jis_c6229_1984_b, - jisc6229_1984_b = jis_c6229_1984_b, - jpocr_b = jis_c6229_1984_b, - iso646_jpocrb = jis_c6229_1984_b, - isoir92 = jis_c6229_1984_b, - iso646jp_ocrb = jis_c6229_1984_b, - isoir_92 = jis_c6229_1984_b, - jp_ocrb = jis_c6229_1984_b, - iso_ir92 = jis_c6229_1984_b, - iso646jp_ocr_b = jis_c6229_1984_b, - jis_c6229_1984b = jis_c6229_1984_b, - iso646jpocrb = jis_c6229_1984_b, - jis_c6229_1984_b_add, - csiso93jis62291984badd = jis_c6229_1984_b_add, - jp_ocr_b_add = jis_c6229_1984_b_add, - jp_ocrb_add = jis_c6229_1984_b_add, - jp_ocr_badd = jis_c6229_1984_b_add, - jpocr_b_add = jis_c6229_1984_b_add, - jpocrb_add = jis_c6229_1984_b_add, - jpocr_badd = jis_c6229_1984_b_add, - jisc6229_1984b_add = jis_c6229_1984_b_add, - jp_ocrbadd = jis_c6229_1984_b_add, - jisc6229_1984_badd = jis_c6229_1984_b_add, - jisc6229_1984_b_add = jis_c6229_1984_b_add, - iso_ir_93 = jis_c6229_1984_b_add, - jpocrbadd = jis_c6229_1984_b_add, - isoir93 = jis_c6229_1984_b_add, - jis_c6229_1984badd = jis_c6229_1984_b_add, - jis_c6229_1984b_add = jis_c6229_1984_b_add, - jis_c6229_1984_badd = jis_c6229_1984_b_add, - jisc6229_1984badd = jis_c6229_1984_b_add, - isoir_93 = jis_c6229_1984_b_add, - iso_ir93 = jis_c6229_1984_b_add, - jis_c6229_1984_hand, - csiso94jis62291984hand = jis_c6229_1984_hand, - jp_ocr_hand = jis_c6229_1984_hand, - jpocr_hand = jis_c6229_1984_hand, - jisc6229_1984_hand = jis_c6229_1984_hand, - iso_ir_94 = jis_c6229_1984_hand, - jpocrhand = jis_c6229_1984_hand, - jis_c6229_1984hand = jis_c6229_1984_hand, - jp_ocrhand = jis_c6229_1984_hand, - isoir94 = jis_c6229_1984_hand, - jisc6229_1984hand = jis_c6229_1984_hand, - isoir_94 = jis_c6229_1984_hand, - iso_ir94 = jis_c6229_1984_hand, - jis_c6229_1984_hand_add, - iso_ir95 = jis_c6229_1984_hand_add, - jp_ocrhandadd = jis_c6229_1984_hand_add, - jpocr_hand_add = jis_c6229_1984_hand_add, - jpocr_handadd = jis_c6229_1984_hand_add, - jisc6229_1984_hand_add = jis_c6229_1984_hand_add, - jis_c6229_1984_handadd = jis_c6229_1984_hand_add, - jis_c6229_1984handadd = jis_c6229_1984_hand_add, - jp_ocr_handadd = jis_c6229_1984_hand_add, - jp_ocrhand_add = jis_c6229_1984_hand_add, - iso_ir_95 = jis_c6229_1984_hand_add, - csiso95jis62291984handadd = jis_c6229_1984_hand_add, - jpocrhandadd = jis_c6229_1984_hand_add, - jp_ocr_hand_add = jis_c6229_1984_hand_add, - jpocrhand_add = jis_c6229_1984_hand_add, - isoir95 = jis_c6229_1984_hand_add, - jisc6229_1984_handadd = jis_c6229_1984_hand_add, - jisc6229_1984hand_add = jis_c6229_1984_hand_add, - jis_c6229_1984hand_add = jis_c6229_1984_hand_add, - isoir_95 = jis_c6229_1984_hand_add, - jisc6229_1984handadd = jis_c6229_1984_hand_add, - jis_c6229_1984_kana, - csiso96jisc62291984kana = jis_c6229_1984_kana, - isoir_96 = jis_c6229_1984_kana, - iso_ir96 = jis_c6229_1984_kana, - jisc6229_1984kana = jis_c6229_1984_kana, - iso_ir_96 = jis_c6229_1984_kana, - isoir96 = jis_c6229_1984_kana, - jis_c6229_1984kana = jis_c6229_1984_kana, - jisc6229_1984_kana = jis_c6229_1984_kana, - iso_2033_1983, - isoir98 = iso_2033_1983, - iso2033_1983 = iso_2033_1983, - isoir_98 = iso_2033_1983, - iso_ir98 = iso_2033_1983, - e13b = iso_2033_1983, - csiso2033 = iso_2033_1983, - iso_ir_98 = iso_2033_1983, - ansi_x3_110_1983, - naplps = ansi_x3_110_1983, - isoir99 = ansi_x3_110_1983, - ansix3_110_1983 = ansi_x3_110_1983, - csiso99naplps = ansi_x3_110_1983, - isoir_99 = ansi_x3_110_1983, - csat500_1983 = ansi_x3_110_1983, - iso_ir99 = ansi_x3_110_1983, - csa_t500_1983 = ansi_x3_110_1983, - iso_ir_99 = ansi_x3_110_1983, - t_61_7bit, - iso_ir102 = t_61_7bit, - t61_7bit = t_61_7bit, - iso_ir_102 = t_61_7bit, - isoir102 = t_61_7bit, - isoir_102 = t_61_7bit, - csiso102t617bit = t_61_7bit, - t_61_8bit, - csiso103t618bit = t_61_8bit, - iso_ir103 = t_61_8bit, - iso_ir_103 = t_61_8bit, - t61_8bit = t_61_8bit, - isoir103 = t_61_8bit, - t61 = t_61_8bit, - isoir_103 = t_61_8bit, - t_61 = t_61_8bit, - ecma_cyrillic, - iso_ir111 = ecma_cyrillic, - koi8_e = ecma_cyrillic, - iso_ir_111 = ecma_cyrillic, - isoir111 = ecma_cyrillic, - ecmacyrillic = ecma_cyrillic, - csiso111ecmacyrillic = ecma_cyrillic, - koi8e = ecma_cyrillic, - isoir_111 = ecma_cyrillic, - csa_z243_4_1985_1, - iso646ca = csa_z243_4_1985_1, - ca = csa_z243_4_1985_1, - iso_ir121 = csa_z243_4_1985_1, - csa7_1 = csa_z243_4_1985_1, - iso646_ca = csa_z243_4_1985_1, - iso_ir_121 = csa_z243_4_1985_1, - isoir121 = csa_z243_4_1985_1, - csaz243_4_1985_1 = csa_z243_4_1985_1, - csiso121canadian1 = csa_z243_4_1985_1, - isoir_121 = csa_z243_4_1985_1, - csa_z243_4_1985_2, - iso646ca2 = csa_z243_4_1985_2, - iso646_ca2 = csa_z243_4_1985_2, - iso_ir122 = csa_z243_4_1985_2, - csa7_2 = csa_z243_4_1985_2, - iso_ir_122 = csa_z243_4_1985_2, - isoir122 = csa_z243_4_1985_2, - csaz243_4_1985_2 = csa_z243_4_1985_2, - csiso122canadian2 = csa_z243_4_1985_2, - isoir_122 = csa_z243_4_1985_2, - csa_z243_4_1985_gr, - csaz243_4_1985_gr = csa_z243_4_1985_gr, - iso_ir123 = csa_z243_4_1985_gr, - csaz243_4_1985gr = csa_z243_4_1985_gr, - iso_ir_123 = csa_z243_4_1985_gr, - isoir123 = csa_z243_4_1985_gr, - csa_z243_4_1985gr = csa_z243_4_1985_gr, - csiso123csaz24341985gr = csa_z243_4_1985_gr, - isoir_123 = csa_z243_4_1985_gr, - iso_8859_6_e, - iso8859_6e = iso_8859_6_e, - csiso88596e = iso_8859_6_e, - iso_8859_6e = iso_8859_6_e, - iso8859_6_e = iso_8859_6_e, - iso_8859_6_i, - csiso88596i = iso_8859_6_i, - iso_8859_6i = iso_8859_6_i, - iso8859_6_i = iso_8859_6_i, - iso8859_6i = iso_8859_6_i, - t_101_g2, - csiso128t101g2 = t_101_g2, - t_101g2 = t_101_g2, - isoir_128 = t_101_g2, - t101g2 = t_101_g2, - t101_g2 = t_101_g2, - iso_ir128 = t_101_g2, - iso_ir_128 = t_101_g2, - isoir128 = t_101_g2, - iso_8859_8_e, - iso8859_8e = iso_8859_8_e, - iso8859_8_e = iso_8859_8_e, - csiso88598e = iso_8859_8_e, - iso_8859_8e = iso_8859_8_e, - iso_8859_8_i, - csiso88598i = iso_8859_8_i, - iso_8859_8i = iso_8859_8_i, - iso8859_8i = iso_8859_8_i, - iso8859_8_i = iso_8859_8_i, - csn_369103, - isoir139 = csn_369103, - csiso139csn369103 = csn_369103, - isoir_139 = csn_369103, - iso_ir139 = csn_369103, - csn369103 = csn_369103, - iso_ir_139 = csn_369103, - jus_i_b1_002, - js = jus_i_b1_002, - iso646yu = jus_i_b1_002, - iso_ir141 = jus_i_b1_002, - yu = jus_i_b1_002, - iso_ir_141 = jus_i_b1_002, - jusib1_002 = jus_i_b1_002, - iso646_yu = jus_i_b1_002, - isoir141 = jus_i_b1_002, - jusi_b1_002 = jus_i_b1_002, - csiso141jusib1002 = jus_i_b1_002, - jus_ib1_002 = jus_i_b1_002, - isoir_141 = jus_i_b1_002, - iec_p27_1, - isoir_143 = iec_p27_1, - iso_ir143 = iec_p27_1, - iecp27_1 = iec_p27_1, - iso_ir_143 = iec_p27_1, - csiso143iecp271 = iec_p27_1, - isoir143 = iec_p27_1, - jus_i_b1_003_serb, - jus_ib1_003_serb = jus_i_b1_003_serb, - jus_i_b1_003serb = jus_i_b1_003_serb, - isoir_146 = jus_i_b1_003_serb, - jusi_b1_003_serb = jus_i_b1_003_serb, - jus_ib1_003serb = jus_i_b1_003_serb, - jusib1_003serb = jus_i_b1_003_serb, - iso_ir146 = jus_i_b1_003_serb, - jusi_b1_003serb = jus_i_b1_003_serb, - jusib1_003_serb = jus_i_b1_003_serb, - csiso146serbian = jus_i_b1_003_serb, - iso_ir_146 = jus_i_b1_003_serb, - serbian = jus_i_b1_003_serb, - isoir146 = jus_i_b1_003_serb, - jus_i_b1_003_mac, - isoir147 = jus_i_b1_003_mac, - jus_ib1_003_mac = jus_i_b1_003_mac, - jusib1_003_mac = jus_i_b1_003_mac, - csiso147macedonian = jus_i_b1_003_mac, - jusib1_003mac = jus_i_b1_003_mac, - isoir_147 = jus_i_b1_003_mac, - jus_i_b1_003mac = jus_i_b1_003_mac, - jusi_b1_003mac = jus_i_b1_003_mac, - jusi_b1_003_mac = jus_i_b1_003_mac, - iso_ir147 = jus_i_b1_003_mac, - iso_ir_147 = jus_i_b1_003_mac, - jus_ib1_003mac = jus_i_b1_003_mac, - macedonian = jus_i_b1_003_mac, - greek_ccitt, - iso_ir150 = greek_ccitt, - iso_ir_150 = greek_ccitt, - isoir150 = greek_ccitt, - greekccitt = greek_ccitt, - csiso150greekccitt = greek_ccitt, - csiso150 = greek_ccitt, - isoir_150 = greek_ccitt, - nc_nc00_10_81, - isoir_151 = nc_nc00_10_81, - ncnc00_10_81 = nc_nc00_10_81, - iso_ir151 = nc_nc00_10_81, - csiso151cuba = nc_nc00_10_81, - iso_ir_151 = nc_nc00_10_81, - iso646cu = nc_nc00_10_81, - isoir151 = nc_nc00_10_81, - iso646_cu = nc_nc00_10_81, - cuba = nc_nc00_10_81, - iso_6937_2_25, - csiso6937add = iso_6937_2_25, - isoir_152 = iso_6937_2_25, - iso_ir152 = iso_6937_2_25, - iso_ir_152 = iso_6937_2_25, - isoir152 = iso_6937_2_25, - iso6937_2_25 = iso_6937_2_25, - gost_19768_74, - gost19768_74 = gost_19768_74, - stsev_358_88 = gost_19768_74, - isoir_153 = gost_19768_74, - st_sev_358_88 = gost_19768_74, - csiso153gost1976874 = gost_19768_74, - iso_ir153 = gost_19768_74, - iso_ir_153 = gost_19768_74, - isoir153 = gost_19768_74, - stsev358_88 = gost_19768_74, - st_sev358_88 = gost_19768_74, - iso_8859_supp, - iso_8859supp = iso_8859_supp, - isoir_154 = iso_8859_supp, - csiso8859supp = iso_8859_supp, - iso8859supp = iso_8859_supp, - iso_ir154 = iso_8859_supp, - iso_ir_154 = iso_8859_supp, - iso8859_supp = iso_8859_supp, - latin1_2_5 = iso_8859_supp, - isoir154 = iso_8859_supp, - iso_10367_box, - iso10367_box = iso_10367_box, - isoir_155 = iso_10367_box, - iso_ir155 = iso_10367_box, - csiso10367box = iso_10367_box, - iso10367box = iso_10367_box, - iso_ir_155 = iso_10367_box, - isoir155 = iso_10367_box, - iso_10367box = iso_10367_box, - latin_lap, - iso_ir_158 = latin_lap, - latinlap = latin_lap, - isoir158 = latin_lap, - csiso158lap = latin_lap, - isoir_158 = latin_lap, - lap = latin_lap, - iso_ir158 = latin_lap, - jis_x0212_1990, - csiso159jisx02121990 = jis_x0212_1990, - iso_ir_159 = jis_x0212_1990, - isoir159 = jis_x0212_1990, - isoir_159 = jis_x0212_1990, - iso_ir159 = jis_x0212_1990, - x0212 = jis_x0212_1990, - jisx0212_1990 = jis_x0212_1990, - ds_2089, - iso646_dk = ds_2089, - ds2089 = ds_2089, - csiso646danish = ds_2089, - iso646dk = ds_2089, - dk = ds_2089, - us_dk, - csusdk = us_dk, - usdk = us_dk, - dk_us, - csdkus = dk_us, - dkus = dk_us, - ksc5636, - iso646_kr = ksc5636, - csksc5636 = ksc5636, - iso646kr = ksc5636, - unicode_1_1_utf_7, - unicode1_1_utf_7 = unicode_1_1_utf_7, - unicode_1_1_utf7 = unicode_1_1_utf_7, - unicode_1_1utf7 = unicode_1_1_utf_7, - csunicode11utf7 = unicode_1_1_utf_7, - unicode1_1utf7 = unicode_1_1_utf_7, - unicode1_1utf_7 = unicode_1_1_utf_7, - unicode_1_1utf_7 = unicode_1_1_utf_7, - unicode1_1_utf7 = unicode_1_1_utf_7, - iso_2022_cn, - iso2022cn = iso_2022_cn, - iso2022_cn = iso_2022_cn, - iso_2022cn = iso_2022_cn, - iso_2022_cn_ext, - iso2022_cnext = iso_2022_cn_ext, - iso_2022cnext = iso_2022_cn_ext, - iso2022_cn_ext = iso_2022_cn_ext, - iso_2022_cnext = iso_2022_cn_ext, - iso2022cn_ext = iso_2022_cn_ext, - iso_2022cn_ext = iso_2022_cn_ext, - iso2022cnext = iso_2022_cn_ext, - utf_8, - utf8 = utf_8, - iso_8859_13, - iso8859_13 = iso_8859_13, - iso_8859_14, - iso8859_14 = iso_8859_14, - iso_ir199 = iso_8859_14, - iso_celtic = iso_8859_14, - latin8 = iso_8859_14, - iso_ir_199 = iso_8859_14, - isoir199 = iso_8859_14, - l8 = iso_8859_14, - iso_8859_14_1998 = iso_8859_14, - iso8859_14_1998 = iso_8859_14, - isoceltic = iso_8859_14, - isoir_199 = iso_8859_14, - iso_8859_15, - iso8859_15 = iso_8859_15, - latin9 = iso_8859_15, - latin_9 = iso_8859_15, - iso_8859_16, - l10 = iso_8859_16, - iso_ir_226 = iso_8859_16, - isoir226 = iso_8859_16, - iso8859_16 = iso_8859_16, - latin10 = iso_8859_16, - isoir_226 = iso_8859_16, - iso_ir226 = iso_8859_16, - iso_8859_16_2001 = iso_8859_16, - iso8859_16_2001 = iso_8859_16, - gbk, - ms936 = gbk, - cp936 = gbk, - windows_936 = gbk, - windows936 = gbk, - gb18030, - osd_ebcdic_df04_15, - osdebcdic_df04_15 = osd_ebcdic_df04_15, - osd_ebcdicdf04_15 = osd_ebcdic_df04_15, - osdebcdicdf04_15 = osd_ebcdic_df04_15, - osd_ebcdic_df03_irv, - osd_ebcdic_df03irv = osd_ebcdic_df03_irv, - osdebcdic_df03irv = osd_ebcdic_df03_irv, - osd_ebcdicdf03_irv = osd_ebcdic_df03_irv, - osdebcdic_df03_irv = osd_ebcdic_df03_irv, - osd_ebcdicdf03irv = osd_ebcdic_df03_irv, - osdebcdicdf03irv = osd_ebcdic_df03_irv, - osdebcdicdf03_irv = osd_ebcdic_df03_irv, - osd_ebcdic_df04_1, - osdebcdicdf04_1 = osd_ebcdic_df04_1, - osdebcdic_df04_1 = osd_ebcdic_df04_1, - osd_ebcdicdf04_1 = osd_ebcdic_df04_1, - iso_11548_1, - csiso115481 = iso_11548_1, - isotr_11548_1 = iso_11548_1, - isotr11548_1 = iso_11548_1, - iso11548_1 = iso_11548_1, - iso_tr_11548_1 = iso_11548_1, - iso_tr11548_1 = iso_11548_1, - kz_1048, - cskz1048 = kz_1048, - strk1048_2002 = kz_1048, - kz1048 = kz_1048, - rk1048 = kz_1048, - iso_10646_ucs_2, - iso10646_ucs_2 = iso_10646_ucs_2, - csunicode = iso_10646_ucs_2, - ucs2 = iso_10646_ucs_2, - iso10646ucs_2 = iso_10646_ucs_2, - iso_10646ucs2 = iso_10646_ucs_2, - iso_10646ucs_2 = iso_10646_ucs_2, - ucs_2 = iso_10646_ucs_2, - iso10646_ucs2 = iso_10646_ucs_2, - iso_10646_ucs2 = iso_10646_ucs_2, - iso10646ucs2 = iso_10646_ucs_2, - iso_10646_ucs_4, - iso_10646_ucs4 = iso_10646_ucs_4, - iso10646ucs4 = iso_10646_ucs_4, - csucs4 = iso_10646_ucs_4, - iso10646_ucs_4 = iso_10646_ucs_4, - ucs4 = iso_10646_ucs_4, - iso10646ucs_4 = iso_10646_ucs_4, - iso_10646ucs4 = iso_10646_ucs_4, - iso_10646ucs_4 = iso_10646_ucs_4, - ucs_4 = iso_10646_ucs_4, - iso10646_ucs4 = iso_10646_ucs_4, - iso_10646_ucs_basic, - iso10646ucsbasic = iso_10646_ucs_basic, - iso10646ucs_basic = iso_10646_ucs_basic, - iso_10646ucs_basic = iso_10646_ucs_basic, - iso10646_ucs_basic = iso_10646_ucs_basic, - iso_10646ucsbasic = iso_10646_ucs_basic, - iso10646_ucsbasic = iso_10646_ucs_basic, - csunicodeascii = iso_10646_ucs_basic, - iso_10646_ucsbasic = iso_10646_ucs_basic, - iso_10646_unicode_latin1, - csunicodelatin1 = iso_10646_unicode_latin1, - iso10646_unicode_latin1 = iso_10646_unicode_latin1, - iso_10646 = iso_10646_unicode_latin1, - iso_10646unicode_latin1 = iso_10646_unicode_latin1, - iso10646unicodelatin1 = iso_10646_unicode_latin1, - iso10646 = iso_10646_unicode_latin1, - iso10646_unicodelatin1 = iso_10646_unicode_latin1, - iso_10646_unicodelatin1 = iso_10646_unicode_latin1, - iso_10646unicodelatin1 = iso_10646_unicode_latin1, - iso10646unicode_latin1 = iso_10646_unicode_latin1, - iso_10646_j_1, - iso10646_j1 = iso_10646_j_1, - iso_10646_j1 = iso_10646_j_1, - iso10646_j_1 = iso_10646_j_1, - iso10646j1 = iso_10646_j_1, - iso_10646j1 = iso_10646_j_1, - iso10646j_1 = iso_10646_j_1, - iso_10646j_1 = iso_10646_j_1, - iso_unicode_ibm_1261, - csunicodeibm1261 = iso_unicode_ibm_1261, - iso_unicode_ibm1261 = iso_unicode_ibm_1261, - iso_unicodeibm_1261 = iso_unicode_ibm_1261, - isounicode_ibm_1261 = iso_unicode_ibm_1261, - isounicode_ibm1261 = iso_unicode_ibm_1261, - isounicodeibm1261 = iso_unicode_ibm_1261, - iso_unicodeibm1261 = iso_unicode_ibm_1261, - isounicodeibm_1261 = iso_unicode_ibm_1261, - iso_unicode_ibm_1268, - isounicode_ibm1268 = iso_unicode_ibm_1268, - isounicodeibm1268 = iso_unicode_ibm_1268, - iso_unicodeibm1268 = iso_unicode_ibm_1268, - isounicodeibm_1268 = iso_unicode_ibm_1268, - csunicodeibm1268 = iso_unicode_ibm_1268, - iso_unicode_ibm1268 = iso_unicode_ibm_1268, - iso_unicodeibm_1268 = iso_unicode_ibm_1268, - isounicode_ibm_1268 = iso_unicode_ibm_1268, - iso_unicode_ibm_1276, - isounicode_ibm1276 = iso_unicode_ibm_1276, - isounicodeibm1276 = iso_unicode_ibm_1276, - iso_unicodeibm1276 = iso_unicode_ibm_1276, - isounicodeibm_1276 = iso_unicode_ibm_1276, - csunicodeibm1276 = iso_unicode_ibm_1276, - iso_unicode_ibm1276 = iso_unicode_ibm_1276, - iso_unicodeibm_1276 = iso_unicode_ibm_1276, - isounicode_ibm_1276 = iso_unicode_ibm_1276, - iso_unicode_ibm_1264, - iso_unicodeibm1264 = iso_unicode_ibm_1264, - isounicodeibm_1264 = iso_unicode_ibm_1264, - csunicodeibm1264 = iso_unicode_ibm_1264, - iso_unicode_ibm1264 = iso_unicode_ibm_1264, - iso_unicodeibm_1264 = iso_unicode_ibm_1264, - isounicode_ibm_1264 = iso_unicode_ibm_1264, - isounicode_ibm1264 = iso_unicode_ibm_1264, - isounicodeibm1264 = iso_unicode_ibm_1264, - iso_unicode_ibm_1265, - isounicode_ibm1265 = iso_unicode_ibm_1265, - isounicodeibm1265 = iso_unicode_ibm_1265, - iso_unicodeibm1265 = iso_unicode_ibm_1265, - isounicodeibm_1265 = iso_unicode_ibm_1265, - csunicodeibm1265 = iso_unicode_ibm_1265, - iso_unicode_ibm1265 = iso_unicode_ibm_1265, - iso_unicodeibm_1265 = iso_unicode_ibm_1265, - isounicode_ibm_1265 = iso_unicode_ibm_1265, - unicode_1_1, - csunicode11 = unicode_1_1, - unicode1_1 = unicode_1_1, - scsu, - utf_7, - utf7 = utf_7, - utf_16be, - utf16be = utf_16be, - utf_16le, - utf16le = utf_16le, - utf_16, - utf16 = utf_16, - cesu_8, - cscesu8 = cesu_8, - cesu8 = cesu_8, - cscesu_8 = cesu_8, - utf_32, - utf32 = utf_32, - utf_32be, - utf32be = utf_32be, - utf_32le, - utf32le = utf_32le, - bocu_1, - csbocu1 = bocu_1, - bocu1 = bocu_1, - csbocu_1 = bocu_1, - iso_8859_1_windows_3_0_latin_1, - iso_8859_1_windows3_0_latin_1= iso_8859_1_windows_3_0_latin_1, - iso_8859_1windows3_0_latin1= iso_8859_1_windows_3_0_latin_1, - iso8859_1_windows3_0_latin_1= iso_8859_1_windows_3_0_latin_1, - iso8859_1windows3_0latin_1= iso_8859_1_windows_3_0_latin_1, - iso_8859_1_windows3_0_latin1= iso_8859_1_windows_3_0_latin_1, - iso_8859_1windows_3_0latin1= iso_8859_1_windows_3_0_latin_1, - iso8859_1_windows3_0latin1= iso_8859_1_windows_3_0_latin_1, - iso8859_1windows3_0latin1 = iso_8859_1_windows_3_0_latin_1, - iso_8859_1windows_3_0latin_1= iso_8859_1_windows_3_0_latin_1, - iso_8859_1_windows_3_0latin1= iso_8859_1_windows_3_0_latin_1, - iso_8859_1windows3_0_latin_1= iso_8859_1_windows_3_0_latin_1, - iso8859_1_windows3_0_latin1= iso_8859_1_windows_3_0_latin_1, - iso_8859_1_windows_3_0_latin1= iso_8859_1_windows_3_0_latin_1, - iso8859_1_windows_3_0_latin1= iso_8859_1_windows_3_0_latin_1, - iso8859_1windows_3_0latin_1= iso_8859_1_windows_3_0_latin_1, - iso_8859_1windows3_0latin1= iso_8859_1_windows_3_0_latin_1, - iso8859_1_windows_3_0latin1= iso_8859_1_windows_3_0_latin_1, - iso8859_1windows3_0_latin_1= iso_8859_1_windows_3_0_latin_1, - iso_8859_1windows_3_0_latin_1= iso_8859_1_windows_3_0_latin_1, - iso_8859_1windows3_0latin_1= iso_8859_1_windows_3_0_latin_1, - iso8859_1windows_3_0_latin_1= iso_8859_1_windows_3_0_latin_1, - iso8859_1windows3_0_latin1= iso_8859_1_windows_3_0_latin_1, - iso_8859_1_windows3_0latin1= iso_8859_1_windows_3_0_latin_1, - iso_8859_1_windows3_0latin_1= iso_8859_1_windows_3_0_latin_1, - iso_8859_1windows_3_0_latin1= iso_8859_1_windows_3_0_latin_1, - iso8859_1windows_3_0latin1= iso_8859_1_windows_3_0_latin_1, - cswindows30latin1 = iso_8859_1_windows_3_0_latin_1, - iso8859_1_windows_3_0_latin_1= iso_8859_1_windows_3_0_latin_1, - iso8859_1_windows3_0latin_1= iso_8859_1_windows_3_0_latin_1, - iso8859_1windows_3_0_latin1= iso_8859_1_windows_3_0_latin_1, - iso_8859_1_windows_3_0latin_1= iso_8859_1_windows_3_0_latin_1, - iso8859_1_windows_3_0latin_1= iso_8859_1_windows_3_0_latin_1, - iso_8859_1_windows_3_1_latin_1, - iso_8859_1windows3_1_latin1= iso_8859_1_windows_3_1_latin_1, - iso_8859_1_windows_3_1_latin1= iso_8859_1_windows_3_1_latin_1, - iso_8859_1_windows3_1_latin1= iso_8859_1_windows_3_1_latin_1, - iso_8859_1windows_3_1_latin_1= iso_8859_1_windows_3_1_latin_1, - iso_8859_1windows_3_1latin_1= iso_8859_1_windows_3_1_latin_1, - iso_8859_1windows3_1_latin_1= iso_8859_1_windows_3_1_latin_1, - iso8859_1windows3_1_latin1= iso_8859_1_windows_3_1_latin_1, - iso_8859_1windows_3_1latin1= iso_8859_1_windows_3_1_latin_1, - iso8859_1_windows3_1_latin1= iso_8859_1_windows_3_1_latin_1, - iso8859_1_windows3_1latin1= iso_8859_1_windows_3_1_latin_1, - iso8859_1windows3_1latin1 = iso_8859_1_windows_3_1_latin_1, - iso8859_1_windows_3_1_latin1= iso_8859_1_windows_3_1_latin_1, - iso8859_1windows_3_1latin_1= iso_8859_1_windows_3_1_latin_1, - iso8859_1windows3_1_latin_1= iso_8859_1_windows_3_1_latin_1, - iso_8859_1_windows_3_1latin1= iso_8859_1_windows_3_1_latin_1, - iso8859_1windows_3_1_latin_1= iso_8859_1_windows_3_1_latin_1, - iso_8859_1windows3_1latin_1= iso_8859_1_windows_3_1_latin_1, - iso_8859_1_windows_3_1latin_1= iso_8859_1_windows_3_1_latin_1, - iso_8859_1_windows3_1_latin_1= iso_8859_1_windows_3_1_latin_1, - iso_8859_1windows3_1latin1= iso_8859_1_windows_3_1_latin_1, - iso8859_1_windows_3_1latin1= iso_8859_1_windows_3_1_latin_1, - iso_8859_1_windows3_1latin_1= iso_8859_1_windows_3_1_latin_1, - iso_8859_1windows_3_1_latin1= iso_8859_1_windows_3_1_latin_1, - iso8859_1_windows_3_1_latin_1= iso_8859_1_windows_3_1_latin_1, - iso_8859_1_windows3_1latin1= iso_8859_1_windows_3_1_latin_1, - iso8859_1windows3_1latin_1= iso_8859_1_windows_3_1_latin_1, - iso8859_1_windows3_1latin_1= iso_8859_1_windows_3_1_latin_1, - iso8859_1windows_3_1_latin1= iso_8859_1_windows_3_1_latin_1, - iso8859_1windows_3_1latin1= iso_8859_1_windows_3_1_latin_1, - cswindows31latin1 = iso_8859_1_windows_3_1_latin_1, - iso8859_1_windows_3_1latin_1= iso_8859_1_windows_3_1_latin_1, - iso8859_1_windows3_1_latin_1= iso_8859_1_windows_3_1_latin_1, - iso_8859_2_windows_latin_2, - cswindows31latin2 = iso_8859_2_windows_latin_2, - iso8859_2_windowslatin_2 = iso_8859_2_windows_latin_2, - iso_8859_2_windowslatin_2 = iso_8859_2_windows_latin_2, - iso_8859_2windows_latin2 = iso_8859_2_windows_latin_2, - iso8859_2_windowslatin2 = iso_8859_2_windows_latin_2, - iso8859_2windows_latin_2 = iso_8859_2_windows_latin_2, - iso_8859_2windows_latin_2 = iso_8859_2_windows_latin_2, - iso8859_2_windows_latin2 = iso_8859_2_windows_latin_2, - iso8859_2_windows_latin_2 = iso_8859_2_windows_latin_2, - iso8859_2windowslatin_2 = iso_8859_2_windows_latin_2, - iso_8859_2_windows_latin2 = iso_8859_2_windows_latin_2, - iso8859_2windowslatin2 = iso_8859_2_windows_latin_2, - iso_8859_2_windowslatin2 = iso_8859_2_windows_latin_2, - iso_8859_2windowslatin2 = iso_8859_2_windows_latin_2, - iso_8859_2windowslatin_2 = iso_8859_2_windows_latin_2, - iso8859_2windows_latin2 = iso_8859_2_windows_latin_2, - iso_8859_9_windows_latin_5, - iso_8859_9_windows_latin5 = iso_8859_9_windows_latin_5, - iso_8859_9windowslatin5 = iso_8859_9_windows_latin_5, - iso_8859_9_windowslatin5 = iso_8859_9_windows_latin_5, - iso8859_9_windows_latin_5 = iso_8859_9_windows_latin_5, - cswindows31latin5 = iso_8859_9_windows_latin_5, - iso_8859_9windowslatin_5 = iso_8859_9_windows_latin_5, - iso8859_9windows_latin5 = iso_8859_9_windows_latin_5, - iso8859_9_windowslatin_5 = iso_8859_9_windows_latin_5, - iso_8859_9_windowslatin_5 = iso_8859_9_windows_latin_5, - iso8859_9windowslatin5 = iso_8859_9_windows_latin_5, - iso_8859_9windows_latin_5 = iso_8859_9_windows_latin_5, - iso_8859_9windows_latin5 = iso_8859_9_windows_latin_5, - iso8859_9_windowslatin5 = iso_8859_9_windows_latin_5, - iso8859_9windows_latin_5 = iso_8859_9_windows_latin_5, - iso8859_9windowslatin_5 = iso_8859_9_windows_latin_5, - iso8859_9_windows_latin5 = iso_8859_9_windows_latin_5, - hp_roman8, - r8 = hp_roman8, - cshproman8 = hp_roman8, - roman8 = hp_roman8, - hproman8 = hp_roman8, - adobe_standard_encoding, - adobestandardencoding = adobe_standard_encoding, - adobe_standardencoding = adobe_standard_encoding, - adobestandard_encoding = adobe_standard_encoding, - csadobestandardencoding = adobe_standard_encoding, - ventura_us, - csventuraus = ventura_us, - venturaus = ventura_us, - ventura_international, - csventurainternational = ventura_international, - venturainternational = ventura_international, - dec_mcs, - decmcs = dec_mcs, - dec = dec_mcs, - csdecmcs = dec_mcs, - ibm850, - cp850 = ibm850, - cspc850multilingual = ibm850, - pc8_danish_norwegian, - cspc8danishnorwegian = pc8_danish_norwegian, - pc8danishnorwegian = pc8_danish_norwegian, - pc8danish_norwegian = pc8_danish_norwegian, - pc8_danishnorwegian = pc8_danish_norwegian, - ibm862, - cspc862latinhebrew = ibm862, - cp862 = ibm862, - pc8_turkish, - pc8turkish = pc8_turkish, - cspc8turkish = pc8_turkish, - ibm_symbols, - ibmsymbols = ibm_symbols, - csibmsymbols = ibm_symbols, - ibm_thai, - ibmthai = ibm_thai, - csibmthai = ibm_thai, - hp_legal, - hplegal = hp_legal, - cshplegal = hp_legal, - hp_pi_font, - hppi_font = hp_pi_font, - cshppifont = hp_pi_font, - hppifont = hp_pi_font, - hp_pifont = hp_pi_font, - hp_math8, - cshpmath8 = hp_math8, - hpmath8 = hp_math8, - adobe_symbol_encoding, - cshppsmath = adobe_symbol_encoding, - adobe_symbolencoding = adobe_symbol_encoding, - adobesymbolencoding = adobe_symbol_encoding, - adobesymbol_encoding = adobe_symbol_encoding, - hp_desktop, - cshpdesktop = hp_desktop, - hpdesktop = hp_desktop, - ventura_math, - csventuramath = ventura_math, - venturamath = ventura_math, - microsoft_publishing, - microsoftpublishing = microsoft_publishing, - csmicrosoftpublishing = microsoft_publishing, - windows_31j, - cswindows31j = windows_31j, - windows31j = windows_31j, - gb2312, - csgb2312 = gb2312, - big5, - csbig5 = big5, - macintosh, - csmacintosh = macintosh, - mac = macintosh, - ibm037, - ebcdic_cp_nl = ibm037, - ebcdic_cp_us = ibm037, - csibm037 = ibm037, - ebcdiccp_wt = ibm037, - ebcdiccp_ca = ibm037, - ebcdiccpnl = ibm037, - ebcdic_cp_wt = ibm037, - ebcdic_cp_ca = ibm037, - ebcdiccpus = ibm037, - ebcdiccpwt = ibm037, - ebcdiccpca = ibm037, - ebcdic_cpnl = ibm037, - ebcdic_cpus = ibm037, - cp037 = ibm037, - ebcdiccp_nl = ibm037, - ebcdic_cpwt = ibm037, - ebcdic_cpca = ibm037, - ebcdiccp_us = ibm037, - ibm038, - csibm038 = ibm038, - ebcdic_int = ibm038, - cp038 = ibm038, - ebcdicint = ibm038, - ibm273, - cp273 = ibm273, - csibm273 = ibm273, - ibm274, - csibm274 = ibm274, - ebcdic_be = ibm274, - cp274 = ibm274, - ebcdicbe = ibm274, - ibm275, - ebcdic_br = ibm275, - csibm275 = ibm275, - cp275 = ibm275, - ebcdicbr = ibm275, - ibm277, - ebcdiccp_dk = ibm277, - ebcdiccp_no = ibm277, - ebcdic_cp_dk = ibm277, - csibm277 = ibm277, - ebcdic_cp_no = ibm277, - ebcdiccpdk = ibm277, - ebcdiccpno = ibm277, - ebcdic_cpdk = ibm277, - ebcdic_cpno = ibm277, - ibm278, - ebcdiccp_fi = ibm278, - ebcdiccpse = ibm278, - ebcdic_cp_fi = ibm278, - csibm278 = ibm278, - ebcdiccpfi = ibm278, - ebcdic_cpse = ibm278, - ebcdiccp_se = ibm278, - ebcdic_cpfi = ibm278, - ebcdic_cp_se = ibm278, - cp278 = ibm278, - ibm280, - ebcdiccp_it = ibm280, - ebcdic_cp_it = ibm280, - cp280 = ibm280, - ebcdiccpit = ibm280, - csibm280 = ibm280, - ebcdic_cpit = ibm280, - ibm281, - ebcdic_jp_e = ibm281, - ebcdicjpe = ibm281, - cp281 = ibm281, - ebcdic_jpe = ibm281, - csibm281 = ibm281, - ebcdicjp_e = ibm281, - ibm284, - csibm284 = ibm284, - ebcdiccpes = ibm284, - ebcdic_cpes = ibm284, - cp284 = ibm284, - ebcdiccp_es = ibm284, - ebcdic_cp_es = ibm284, - ibm285, - csibm285 = ibm285, - ebcdic_cpgb = ibm285, - ebcdiccp_gb = ibm285, - ebcdic_cp_gb = ibm285, - cp285 = ibm285, - ebcdiccpgb = ibm285, - ibm290, - ebcdicjp_kana = ibm290, - ebcdicjpkana = ibm290, - cp290 = ibm290, - ebcdic_jp_kana = ibm290, - csibm290 = ibm290, - ebcdic_jpkana = ibm290, - ibm297, - ebcdiccpfr = ibm297, - csibm297 = ibm297, - ebcdic_cpfr = ibm297, - ebcdiccp_fr = ibm297, - ebcdic_cp_fr = ibm297, - cp297 = ibm297, - ibm420, - csibm420 = ibm420, - ebcdiccp_ar1 = ibm420, - ebcdiccpar1 = ibm420, - ebcdic_cpar1 = ibm420, - cp420 = ibm420, - ebcdic_cp_ar1 = ibm420, - ibm423, - ebcdiccpgr = ibm423, - csibm423 = ibm423, - ebcdic_cpgr = ibm423, - ebcdiccp_gr = ibm423, - cp423 = ibm423, - ebcdic_cp_gr = ibm423, - ibm424, - ebcdic_cp_he = ibm424, - ebcdiccphe = ibm424, - csibm424 = ibm424, - ebcdic_cphe = ibm424, - ebcdiccp_he = ibm424, - cp424 = ibm424, - ibm437, - cp437 = ibm437, - cspc8codepage437 = ibm437, - ibm500, - ebcdiccpch = ibm500, - ebcdic_cpbe = ibm500, - csibm500 = ibm500, - ebcdiccp_be = ibm500, - ebcdic_cpch = ibm500, - ebcdic_cp_be = ibm500, - ebcdiccp_ch = ibm500, - ebcdiccpbe = ibm500, - ebcdic_cp_ch = ibm500, - cp500 = ibm500, - ibm851, - cp851 = ibm851, - csibm851 = ibm851, - ibm852, - cspcp852 = ibm852, - cp852 = ibm852, - ibm855, - csibm855 = ibm855, - cp855 = ibm855, - ibm857, - csibm857 = ibm857, - cp857 = ibm857, - ibm860, - cp860 = ibm860, - csibm860 = ibm860, - ibm861, - csibm861 = ibm861, - cp_is = ibm861, - cp861 = ibm861, - cpis = ibm861, - ibm863, - csibm863 = ibm863, - cp863 = ibm863, - ibm864, - csibm864 = ibm864, - cp864 = ibm864, - ibm865, - csibm865 = ibm865, - cp865 = ibm865, - ibm868, - cpar = ibm868, - cp868 = ibm868, - csibm868 = ibm868, - cp_ar = ibm868, - ibm869, - cp869 = ibm869, - cp_gr = ibm869, - cpgr = ibm869, - csibm869 = ibm869, - ibm870, - csibm870 = ibm870, - ebcdic_cproece = ibm870, - ebcdiccp_roece = ibm870, - ebcdic_cpyu = ibm870, - ebcdiccp_yu = ibm870, - ebcdiccproece = ibm870, - ebcdic_cp_yu = ibm870, - cp870 = ibm870, - ebcdic_cp_roece = ibm870, - ebcdiccpyu = ibm870, - ibm871, - ebcdiccp_is = ibm871, - csibm871 = ibm871, - ebcdic_cp_is = ibm871, - ebcdiccpis = ibm871, - cp871 = ibm871, - ebcdic_cpis = ibm871, - ibm880, - ebcdiccyrillic = ibm880, - csibm880 = ibm880, - ebcdic_cyrillic = ibm880, - cp880 = ibm880, - ibm891, - csibm891 = ibm891, - cp891 = ibm891, - ibm903, - csibm903 = ibm903, - cp903 = ibm903, - ibm904, - csibbm904 = ibm904, - cp904 = ibm904, - ibm905, - ebcdiccptr = ibm905, - csibm905 = ibm905, - ebcdic_cptr = ibm905, - ebcdiccp_tr = ibm905, - cp905 = ibm905, - ebcdic_cp_tr = ibm905, - ibm918, - cp918 = ibm918, - ebcdiccp_ar2 = ibm918, - ebcdiccpar2 = ibm918, - csibm918 = ibm918, - ebcdic_cpar2 = ibm918, - ebcdic_cp_ar2 = ibm918, - ibm1026, - csibm1026 = ibm1026, - cp1026 = ibm1026, - ebcdic_at_de, - ebcdic_atde = ebcdic_at_de, - ebcdicat_de = ebcdic_at_de, - ebcdicatde = ebcdic_at_de, - csibmebcdicatde = ebcdic_at_de, - ebcdic_at_de_a, - ebcdic_atdea = ebcdic_at_de_a, - ebcdic_at_dea = ebcdic_at_de_a, - ebcdic_atde_a = ebcdic_at_de_a, - csebcdicatdea = ebcdic_at_de_a, - ebcdicatdea = ebcdic_at_de_a, - ebcdicat_dea = ebcdic_at_de_a, - ebcdicat_de_a = ebcdic_at_de_a, - ebcdicatde_a = ebcdic_at_de_a, - ebcdic_ca_fr, - ebcdiccafr = ebcdic_ca_fr, - csebcdiccafr = ebcdic_ca_fr, - ebcdic_cafr = ebcdic_ca_fr, - ebcdicca_fr = ebcdic_ca_fr, - ebcdic_dk_no, - ebcdic_dkno = ebcdic_dk_no, - ebcdicdkno = ebcdic_dk_no, - ebcdicdk_no = ebcdic_dk_no, - csebcdicdkno = ebcdic_dk_no, - ebcdic_dk_no_a, - ebcdicdk_noa = ebcdic_dk_no_a, - ebcdic_dknoa = ebcdic_dk_no_a, - ebcdicdkno_a = ebcdic_dk_no_a, - csebcdicdknoa = ebcdic_dk_no_a, - ebcdic_dk_noa = ebcdic_dk_no_a, - ebcdicdknoa = ebcdic_dk_no_a, - ebcdicdk_no_a = ebcdic_dk_no_a, - ebcdic_dkno_a = ebcdic_dk_no_a, - ebcdic_fi_se, - csebcdicfise = ebcdic_fi_se, - ebcdicfi_se = ebcdic_fi_se, - ebcdic_fise = ebcdic_fi_se, - ebcdicfise = ebcdic_fi_se, - ebcdic_fi_se_a, - ebcdicfise_a = ebcdic_fi_se_a, - ebcdic_fi_sea = ebcdic_fi_se_a, - ebcdic_fisea = ebcdic_fi_se_a, - csebcdicfisea = ebcdic_fi_se_a, - ebcdicfisea = ebcdic_fi_se_a, - ebcdic_fise_a = ebcdic_fi_se_a, - ebcdicfi_se_a = ebcdic_fi_se_a, - ebcdicfi_sea = ebcdic_fi_se_a, - ebcdic_fr, - ebcdicfr = ebcdic_fr, - csebcdicfr = ebcdic_fr, - ebcdic_it, - ebcdicit = ebcdic_it, - csebcdicit = ebcdic_it, - ebcdic_pt, - ebcdicpt = ebcdic_pt, - csebcdicpt = ebcdic_pt, - ebcdic_es, - ebcdices = ebcdic_es, - csebcdices = ebcdic_es, - ebcdic_es_a, - ebcdicesa = ebcdic_es_a, - ebcdic_esa = ebcdic_es_a, - ebcdices_a = ebcdic_es_a, - csebcdicesa = ebcdic_es_a, - ebcdic_es_s, - ebcdic_ess = ebcdic_es_s, - ebcdices_s = ebcdic_es_s, - csebcdicess = ebcdic_es_s, - ebcdicess = ebcdic_es_s, - ebcdic_uk, - ebcdicuk = ebcdic_uk, - csebcdicuk = ebcdic_uk, - ebcdic_us, - ebcdicus = ebcdic_us, - csebcdicus = ebcdic_us, - unknown_8bit, - csunknown8bit = unknown_8bit, - unknown8bit = unknown_8bit, - mnemonic, - csmnemonic = mnemonic, - mnem, - csmnem = mnem, - viscii, - csviscii = viscii, - viqr, - csviqr = viqr, - koi8_r, - cskoi8r = koi8_r, - koi8r = koi8_r, - hz_gb_2312, - hzgb_2312 = hz_gb_2312, - hz_gb2312 = hz_gb_2312, - hzgb2312 = hz_gb_2312, - ibm866, - csibm866 = ibm866, - cp866 = ibm866, - ibm775, - cspc775baltic = ibm775, - cp775 = ibm775, - koi8_u, - koi8u = koi8_u, - ibm00858, - cp00858 = ibm00858, - pc_multilingual_850euro = ibm00858, - pc_multilingual850_euro = ibm00858, - ccsid00858 = ibm00858, - pcmultilingual_850euro = ibm00858, - pcmultilingual_850_euro = ibm00858, - pcmultilingual850euro = ibm00858, - pc_multilingual850euro = ibm00858, - pc_multilingual_850_euro = ibm00858, - pcmultilingual850_euro = ibm00858, - ibm00924, - ccsid00924 = ibm00924, - ebcdic_latin9euro = ibm00924, - ebcdiclatin9__euro = ibm00924, - ebcdiclatin9_euro = ibm00924, - ebcdiclatin9euro = ibm00924, - ebcdic_latin9_euro = ibm00924, - ebcdic_latin9__euro = ibm00924, - cp00924 = ibm00924, - ibm01140, - ebcdicus37euro = ibm01140, - ccsid01140 = ibm01140, - ebcdicus_37_euro = ibm01140, - ebcdic_us37_euro = ibm01140, - ebcdicus37_euro = ibm01140, - ebcdic_us37euro = ibm01140, - ebcdic_us_37euro = ibm01140, - ebcdic_us_37_euro = ibm01140, - ebcdicus_37euro = ibm01140, - cp01140 = ibm01140, - ibm01141, - ccsid01141 = ibm01141, - ebcdic_de273euro = ibm01141, - ebcdicde_273_euro = ibm01141, - ebcdicde273euro = ibm01141, - ebcdic_de_273euro = ibm01141, - ebcdic_de273_euro = ibm01141, - ebcdic_de_273_euro = ibm01141, - ebcdicde_273euro = ibm01141, - ebcdicde273_euro = ibm01141, - cp01141 = ibm01141, - ibm01142, - cp01142 = ibm01142, - ebcdic_dk277_euro = ibm01142, - ebcdic_no277euro = ibm01142, - ebcdicno_277euro = ibm01142, - ebcdicno_277_euro = ibm01142, - ebcdicdk_277euro = ibm01142, - ccsid01142 = ibm01142, - ebcdic_dk_277_euro = ibm01142, - ebcdicno277_euro = ibm01142, - ebcdicdk277_euro = ibm01142, - ebcdic_no_277euro = ibm01142, - ebcdicdk277euro = ibm01142, - ebcdic_no_277_euro = ibm01142, - ebcdic_no277_euro = ibm01142, - ebcdicno277euro = ibm01142, - ebcdic_dk_277euro = ibm01142, - ebcdic_dk277euro = ibm01142, - ebcdicdk_277_euro = ibm01142, - ibm01143, - ebcdic_se278_euro = ibm01143, - ebcdicse_278euro = ibm01143, - cp01143 = ibm01143, - ebcdic_se278euro = ibm01143, - ebcdic_fi_278_euro = ibm01143, - ebcdic_fi278euro = ibm01143, - ebcdicfi278euro = ibm01143, - ebcdicse_278_euro = ibm01143, - ebcdic_fi_278euro = ibm01143, - ebcdicfi278_euro = ibm01143, - ccsid01143 = ibm01143, - ebcdic_se_278euro = ibm01143, - ebcdic_se_278_euro = ibm01143, - ebcdicse278_euro = ibm01143, - ebcdicfi_278euro = ibm01143, - ebcdicfi_278_euro = ibm01143, - ebcdicse278euro = ibm01143, - ebcdic_fi278_euro = ibm01143, - ibm01144, - ebcdic_it280_euro = ibm01144, - ebcdic_it_280_euro = ibm01144, - cp01144 = ibm01144, - ebcdic_it280euro = ibm01144, - ebcdicit_280euro = ibm01144, - ebcdicit280euro = ibm01144, - ccsid01144 = ibm01144, - ebcdicit_280_euro = ibm01144, - ebcdicit280_euro = ibm01144, - ebcdic_it_280euro = ibm01144, - ibm01145, - ebcdic_es284euro = ibm01145, - ebcdices284euro = ibm01145, - ebcdic_es_284_euro = ibm01145, - cp01145 = ibm01145, - ebcdic_es284_euro = ibm01145, - ebcdices_284euro = ibm01145, - ccsid01145 = ibm01145, - ebcdic_es_284euro = ibm01145, - ebcdices_284_euro = ibm01145, - ebcdices284_euro = ibm01145, - ibm01146, - ebcdic_gb_285_euro = ibm01146, - ebcdic_gb285_euro = ibm01146, - ebcdic_gb285euro = ibm01146, - ebcdicgb285euro = ibm01146, - ebcdic_gb_285euro = ibm01146, - ebcdicgb_285_euro = ibm01146, - cp01146 = ibm01146, - ccsid01146 = ibm01146, - ebcdicgb285_euro = ibm01146, - ebcdicgb_285euro = ibm01146, - ibm01147, - ebcdic_fr_297_euro = ibm01147, - ebcdic_fr297_euro = ibm01147, - ebcdic_fr_297euro = ibm01147, - cp01147 = ibm01147, - ebcdic_fr297euro = ibm01147, - ebcdicfr297euro = ibm01147, - ebcdicfr297_euro = ibm01147, - ebcdicfr_297_euro = ibm01147, - ccsid01147 = ibm01147, - ebcdicfr_297euro = ibm01147, - ibm01148, - ebcdic_international500euro= ibm01148, - ebcdicinternational500_euro= ibm01148, - ebcdic_international500_euro= ibm01148, - ebcdic_international_500euro= ibm01148, - ebcdic_international_500_euro= ibm01148, - cp01148 = ibm01148, - ebcdicinternational_500euro= ibm01148, - ccsid01148 = ibm01148, - ebcdicinternational_500_euro= ibm01148, - ebcdicinternational500euro= ibm01148, - ibm01149, - ebcdic_is_871euro = ibm01149, - ebcdic_is871_euro = ibm01149, - ebcdicis_871_euro = ibm01149, - ebcdic_is871euro = ibm01149, - ebcdicis871euro = ibm01149, - ebcdic_is_871_euro = ibm01149, - cp01149 = ibm01149, - ccsid01149 = ibm01149, - ebcdicis_871euro = ibm01149, - ebcdicis871_euro = ibm01149, - big5_hkscs, - big5hkscs = big5_hkscs, - ibm1047, - ibm_1047 = ibm1047, - ptcp154, - cp154 = ptcp154, - csptcp154 = ptcp154, - cyrillic_asian = ptcp154, - cyrillicasian = ptcp154, - pt154 = ptcp154, - amiga_1251, - ami_1251 = amiga_1251, - ami1251 = amiga_1251, - amiga1251 = amiga_1251, - koi7_switched, - koi7switched = koi7_switched, - brf, - csbrf = brf, - tscii, - cstscii = tscii, - windows_1250, - windows1250 = windows_1250, - windows_1251, - windows1251 = windows_1251, - windows_1252, - windows1252 = windows_1252, - windows_1253, - windows1253 = windows_1253, - windows_1254, - windows1254 = windows_1254, - windows_1255, - windows1255 = windows_1255, - windows_1256, - windows1256 = windows_1256, - windows_1257, - windows1257 = windows_1257, - windows_1258, - windows1258 = windows_1258, - tis_620, - tis620 = tis_620, - max_charset -}; diff --git a/extras/anytermd/libpbe/include/charset/sequence_conv.hh b/extras/anytermd/libpbe/include/charset/sequence_conv.hh deleted file mode 100644 index 51780a456a..0000000000 --- a/extras/anytermd/libpbe/include/charset/sequence_conv.hh +++ /dev/null @@ -1,74 +0,0 @@ -// sequence_conv.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_sequence_conv_hh -#define libpbe_charset_sequence_conv_hh - -#include "charset_t.hh" -#include "charset_traits.hh" -#include "char_conv.hh" -#include "error_policy.hh" - - -namespace pbe { - -// Conversion of strings between character sets -// ----------------------------------------------- -// -// This file provides facilites to convert sequences of characters, including -// strings and other sequences, from one character set to another. Essentially -// this just involves repeated application of the character-at-a-time -// char_conv template, and that is the default strategy implemented below. -// However for some iterators and some character set pairs, optimised -// implementations are possible and these can be provided by specialisation -// of sequence_conv. - -// Base template, with default implementation using char_conv: - -template< charset_t from_cs, charset_t to_cs, typename error_policy, - typename InputIterator, typename OutputIterator, typename Enable = void > -struct sequence_conv { - OutputIterator - operator() ( InputIterator first, const InputIterator& last, - OutputIterator result, - typename charset_traits::state_t& from_state, - typename charset_traits::state_t& to_state) - { - for (; first != last; ++first) { - *(result++) = char_conv()(*first,from_state,to_state); - } - return result; - } -}; - - - - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/charset/sequence_converter.hh b/extras/anytermd/libpbe/include/charset/sequence_converter.hh deleted file mode 100644 index 9b3b057ae1..0000000000 --- a/extras/anytermd/libpbe/include/charset/sequence_converter.hh +++ /dev/null @@ -1,69 +0,0 @@ -// sequence_converter.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_sequence_converter_hh -#define libpbe_charset_sequence_converter_hh - -#include "charset_t.hh" -#include "charset_traits.hh" -#include "sequence_conv.hh" -#include "error_policy.hh" - - -namespace pbe { - -// Stateful functor for sequence conversion -// ----------------------------------------- -// -// The function template sequence_conv takes state variables for the input and output, -// in case they are stateful. -// A simplified interface is provided by this functor, which keeps the state -// internally from one call to the next. - -template< charset_t from_cs, charset_t to_cs, typename error_policy /*= default_error_policy*/, - typename InputIterator, typename OutputIterator > -class sequence_converter { - typedef charset_traits from_traits; - typedef charset_traits to_traits; - - typename from_traits::state_t from_state; - typename to_traits::state_t to_state; - -public: - sequence_conv sc; - OutputIterator operator()(const InputIterator& first, const InputIterator& last, - OutputIterator result) { - return sc ( first, last, result, from_state, to_state ); - } - - // TODO flush, perhaps reset. -}; - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/charset/string_adaptor.hh b/extras/anytermd/libpbe/include/charset/string_adaptor.hh deleted file mode 100644 index 338e6dc1c6..0000000000 --- a/extras/anytermd/libpbe/include/charset/string_adaptor.hh +++ /dev/null @@ -1,196 +0,0 @@ -// string_adaptor.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2007-2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_string_adaptor_hh -#define libpbe_charset_string_adaptor_hh - -#include "charset/charset_t.hh" -#include "charset/charset_traits.hh" -#include "charset/const_character_iterator.hh" - -#include - -#include -#include - - -namespace pbe { - -// String adaptor -// -------------- -// -// This class adapts a std::string containing a sequence of units into a -// std::string-like object containing a sequence of characters. It stores -// a reference to the underlying unit-string. - - -template -class string_adaptor { - - typedef charset_traits traits_t; - typedef typename traits_t::char_t char_t; - typedef typename traits_t::unit_t unit_t; - -public: - typedef std::basic_string, Alloc> unit_string_t; - -private: - unit_string_t& ustr; - -public: - string_adaptor(unit_string_t& ustr_): - ustr(ustr_) - {} - - unit_string_t& unit_str() { return ustr; } - const unit_string_t& unit_str() const { return ustr; } - - typedef char_t value_type; - typedef char_t* pointer; - typedef char_t& reference; - typedef const char_t& const_reference; - typedef size_t size_type; - typedef ptrdiff_t difference_type; // ?? - static const size_type npos = -1; - // iterator ?? - typedef const_character_iterator const_iterator; - // reverse_iterator ?? - typedef boost::reverse_iterator const_reverse_iterator; - - // begin - // end - const_iterator begin() const { return const_iterator(ustr.begin()); } - const_iterator end() const { return const_iterator(ustr.end()); } - // rbegin - // rend - const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } - const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } - - // size // ?? could do this in O(n) - // length - size_type max_size() const { return ustr.max_size(); } // ??? - size_type capacity() const { return ustr.capacity(); } // ??? - bool empty() const { return ustr.empty(); } - // operator[] - // operator[] const - // c_str() ??? - // data() ??? - - string_adaptor& operator=(const string_adaptor& other) { ustr=other.ustr; return *this; } - string_adaptor& operator=(char_t c) { clear(); push_back(c); } - void reserve(size_t sz) { ustr.reserve(sz); } // *typ_units_per_char - void swap(string_adaptor& other) { ustr.swap(other.ustr); } - - // insert - - string_adaptor& append(const string_adaptor& s) { ustr.append(s.unit_str()); return *this; } - string_adaptor& append(size_type n, char_t c) { - for (size_type i=0; i - string_adaptor& append(InputIterator first, InputIterator last) { - for (; first!=last; ++first) { - push_back(*first); - } - } - - void push_back(char_t c) { - std::back_insert_iterator i(ustr); - traits_t::encode(i,c); - } - - string_adaptor& operator+=(const string_adaptor& s) { append(s); } - string_adaptor& operator+=(char_t c) { push_back(c); } - -#if 0 - iterator erase(iterator p) { - ustr.erase(p.base(), p.base()+traits_t::char_length(p.base())-1); - } - iterator erase(iterator first, iterator last) { - ustr.erase(first.base(), last.base()+traits_t::char_length(last.base())-1); - } -#endif - - void clear() { ustr.clear(); } - - // resize - - string_adaptor& assign(const string_adaptor& other) { operator=(other); } - string_adaptor& assign(size_type n, char_t c) { clear(); append(n,c); } - template - string_adaptor& assign(InputIterator first, InputIterator last) { clear(); append(first,last); } - - // replace - - // copy - - // find - // find variants - - // substr - - int compare(const string_adaptor& s) const { - // FIXME apparently this is an SGI thing that's not in the standard - // return std::lexicographical_compare_3way(s.begin(), s.end(), begin(), end()); - } - // Note that for UTF8 we can do the comparison directly on the units, which - // should be faster. - -}; - - -template -bool operator==(const string_adaptor& s1, - const string_adaptor& s2) { - return s1.ustr == s2.ustr; -} - -template -bool operator!=(const string_adaptor& s1, - const string_adaptor& s2) { - return s1.ustr != s2.ustr; -} - -template -bool operator<(const string_adaptor& s1, - const string_adaptor& s2) { - return s1.compare(s2)<0; -} - -template -void swap(string_adaptor& s1, - string_adaptor& s2) { - s1.swap(s2); -} - - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/charset/to_ascii_letters.hh b/extras/anytermd/libpbe/include/charset/to_ascii_letters.hh deleted file mode 100644 index 5f2c4b6d4a..0000000000 --- a/extras/anytermd/libpbe/include/charset/to_ascii_letters.hh +++ /dev/null @@ -1,210 +0,0 @@ -// include/charset/to_ascii_letters.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef pbe_charset_to_ascii_letters_hh -#define pbe_charset_to_ascii_letters_hh - -#include "charset/char_t.hh" - -#include - - -namespace pbe { - - -typedef char char_expansion_page_00_t [3]; -typedef char char_expansion_page_01_t [3]; -typedef char char_expansion_page_02_t [3]; -typedef char char_expansion_page_1D_t [2]; -typedef char char_expansion_page_1E_t [2]; -typedef char char_expansion_page_20_t [3]; -typedef char char_expansion_page_21_t [5]; -typedef char char_expansion_page_24_t [2]; -typedef char char_expansion_page_2C_t [2]; -typedef char char_expansion_page_32_t [4]; -typedef char char_expansion_page_33_t [5]; -typedef char char_expansion_page_FB_t [4]; -typedef char char_expansion_page_FF_t [2]; -typedef char char_expansion_page_1D4_t [2]; -typedef char char_expansion_page_1D5_t [2]; -typedef char char_expansion_page_1D6_t [2]; - -extern char_expansion_page_00_t to_ascii_letters_page_00 [256]; -extern char_expansion_page_01_t to_ascii_letters_page_01 [256]; -extern char_expansion_page_02_t to_ascii_letters_page_02 [256]; -extern char_expansion_page_1D_t to_ascii_letters_page_1D [256]; -extern char_expansion_page_1E_t to_ascii_letters_page_1E [256]; -extern char_expansion_page_20_t to_ascii_letters_page_20 [256]; -extern char_expansion_page_21_t to_ascii_letters_page_21 [256]; -extern char_expansion_page_24_t to_ascii_letters_page_24 [256]; -extern char_expansion_page_2C_t to_ascii_letters_page_2C [256]; -extern char_expansion_page_32_t to_ascii_letters_page_32 [256]; -extern char_expansion_page_33_t to_ascii_letters_page_33 [256]; -extern char_expansion_page_FB_t to_ascii_letters_page_FB [256]; -extern char_expansion_page_FF_t to_ascii_letters_page_FF [256]; -extern char_expansion_page_1D4_t to_ascii_letters_page_1D4 [256]; -extern char_expansion_page_1D5_t to_ascii_letters_page_1D5 [256]; -extern char_expansion_page_1D6_t to_ascii_letters_page_1D6 [256]; - - -inline const char* to_ascii_letters(char32_t c) { - // Given a Unicode (UCS4) character c, return a pointer to a sequence of ASCII - // lower-case letters (a-z) that are equivalent in the following sense: - // - Upper case is mapped to lower case. - // - Accents (etc) are stripped. - // - "Compound" letters are decomposed into multiple individial letters (e.g. ae). - // (This includes various mathemtical symbols and oddities like VIII, for which there - // is a single unicode character.) - // If the character has no corresponding letters, an empty sequence is returned - // (e.g. punctuation symbols and letters in other scripts. Letters from e.g. cyrillic - // and greek that are homoglyphs to latin letters are not considered equivalent.) - // The aim of this conversion is to convert a string to something that can be used - // as a search key for user-supplied search terms. - // This is based on data extracted from the unicode character database, using the - // "NFKD" rules. One oddity is that the German ezsett is not expanded to ss; I don't - // know why not, or what other oddities there are. All of the useful conversions are - // in the various "Latin" pages (see below). - // The returned pointer points to static data. - - // FIXME it would probably be better to distinguish between NULL, space and other - // word-breaking punctuation, non-word-breaking punctuation, and non-latin-convertible - // characters in some way. - - int page = c>>8; - int point = c&0xff; - switch (page) { - case 0x000: return to_ascii_letters_page_00[point]; // Basic Latin & Latin-1 Supplement - case 0x001: return to_ascii_letters_page_01[point]; // Latin Extended-A & Latin Extended-B - case 0x002: return to_ascii_letters_page_02[point]; // Latin Extended-B etc. - case 0x01D: return to_ascii_letters_page_1D[point]; // Phonetic Extensions etc. - case 0x01E: return to_ascii_letters_page_1E[point]; // Latin Extended Additional. - case 0x020: return to_ascii_letters_page_20[point]; // General Punctuation etc. - case 0x021: return to_ascii_letters_page_21[point]; // Letterlike symbols etc. - case 0x024: return to_ascii_letters_page_24[point]; // Enclosed alphanumerics etc. - case 0x02C: return to_ascii_letters_page_2C[point]; // Latin Extended-C etc. - case 0x032: return to_ascii_letters_page_32[point]; // Enclosed CJK Letters and Months. - case 0x033: return to_ascii_letters_page_33[point]; // CJK Compatibility. - case 0x0FB: return to_ascii_letters_page_FB[point]; // Alphabetic Presentation Forms etc. - case 0x0FF: return to_ascii_letters_page_FF[point]; // Halfwidth and Fullwidth Forms etc. - case 0x1D4: return to_ascii_letters_page_1D4[point]; // Mathematical Alphanumeric Symbols. - case 0x1D5: return to_ascii_letters_page_1D5[point]; // (cont.) - case 0x1D6: return to_ascii_letters_page_1D6[point]; // (cont.) - default: return ""; - } -} - - -template -inline OutputIter to_ascii_letters(InputIter first, InputIter last, OutputIter result) { - // Copy Unicode (UCS4) characters in the range first to last to result, converting to ASCII - // letters as abive, and return an iterator for the end of the result. Input characters that - // don't correspond to any ASCII letters are replaced with spaces, except that 0 remains 0. - - for (InputIter i = first; i!=last; ++i) { - char32_t c = *i; - if (!c) { - *(result++) = 0; - } else { - const char* l = to_ascii_letters(c); - if (!*l) { - *(result++) = ' '; - } else { - do { - *(result++) = *(l++); - } while (*l); - } - } - } - return result; -} - - -template -class ascii_letter_iterator: public boost::iterator_facade< ascii_letter_iterator, - char, - boost::forward_traversal_tag, - char > -{ - // This is an immutable forward iterator that steps through the ascii letters (as above) - // that come from the contained iterator. Punctuation is replaced with spaces; multiple - // punctuation yeilds multiple spaces. A null in the input results in a null in the - // output (but don't try to increment past it - FIXME this is a bit broken). - // The end-of-input iterator must be supplied to the constructor. You can get away with - // passing a fake end-of-input iterator (e.g. NULL) if you can be certain that - // dereferencing end() is harmless. - - Iter i; - const char* decomp_ptr; - Iter end; - - friend class boost::iterator_core_access; - - void increment() { - if (*decomp_ptr) { - ++decomp_ptr; - } - if (!*decomp_ptr) { - ++i; - if (i==end || !*i) { - decomp_ptr = NULL; - } else { - decomp_ptr = to_ascii_letters(*i); - } - } - } - - bool equal(const ascii_letter_iterator& other) const { - return (i == other.i) && (decomp_ptr == other.decomp_ptr); - } - - char dereference() const { - if (!decomp_ptr) { - return 0; - } - char c = *decomp_ptr; - if (!c) { - return ' '; - } else { - return c; - } - } - -public: - ascii_letter_iterator(Iter i_, Iter end_): - i(i_), - decomp_ptr(NULL), - end(end_) - { - if (i!=end && *i) { - decomp_ptr = to_ascii_letters(*i); - } - } - - - Iter base() const { - return i; - } - -}; - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/charset/utf8.hh b/extras/anytermd/libpbe/include/charset/utf8.hh deleted file mode 100644 index 1d33a3db21..0000000000 --- a/extras/anytermd/libpbe/include/charset/utf8.hh +++ /dev/null @@ -1,210 +0,0 @@ -// utf8.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2007-2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef libpbe_charset_utf8_hh -#define libpbe_charset_utf8_hh - -#include "char_t.hh" -#include "charset_t.hh" -#include "charset_traits.hh" - -#include "compiler_magic.hh" - - -// UTF-8 Encoding and Decoding -// --------------------------- -// -// This file provides functions that do the bit-shuffling needed for UTF-8 -// encoding and decoding in the form of a charset_traits specialisation. -// -// TODO there should be an error_policy template parameter to the decoding -// function so that the behaviour when invalid input is encountered can be -// defined. -// -// These functions perform significantly better than the alternaitves that -// I benchmarked: Ken Thompson's originals, glibc's mbsrtowcs etc. and -// glibc's iconv. Performance is somewhat sensitive to optimisation, however; -// the branch prediction hints that I've included make this less of a problem. - - -namespace pbe { - -template <> struct charset_traits { - - typedef char32_t char_t; - typedef char8_t unit_t; - struct state_t {}; - static const bool is_ascii_superset = true; - static const bool is_ascii_plus_c1_superset = true; - - struct InvalidUTF8 {}; // FIXME see above error_policy needed - -private: - static void check(bool condition) { - IF_UNLIKELY(!condition) throw InvalidUTF8(); - } - -public: - template - static char32_t decode(const_char8_ptr_t& p) { - char8_t b0 = *(p++); - IF_LIKELY((b0&0x80)==0) { - return b0; - } - char8_t b1 = *(p++); - check((b1&0xc0)==0x80); - IF_LIKELY((b0&0xe0)==0xc0) { - char32_t r = (b1&0x3f) | ((b0&0x1f)<<6); - check(r>=0x80); - return r; - } - char8_t b2 = *(p++); - check((b2&0xc0)==0x80); - IF_LIKELY((b0&0xf0)==0xe0) { - char32_t r = (b2&0x3f) | ((b1&0x3f)<<6) | ((b0&0x0f)<<12); - check(r>=0x800); - return r; - } - char8_t b3 = *(p++); - check((b3&0xc0)==0x80); - IF_LIKELY((b0&0xf8)==0xf0) { - char32_t r = (b3&0x3f) | ((b2&0x3f)<<6) | ((b1&0x3f)<<12) | ((b0&0x07)<<18); - check(r>=0x10000); - return r; - } - // The original definition of UTF-8 includes 5- and 6-byte encodings. - // But these correspond to values that are not valid Unicode characters, - // and they are not included in the more recent spec. Included here - // for interest: - // char8_t b4 = *(p++); - // check((b4&0xc0)==0x80); - // IF_LIKELY((b0&0xfc)==0xf8) { - // char32_t r = (b4&0x3f) | ((b3&0x3f)<<6) | ((b2&0x3f)<<12) | ((b1&0x3f)<<18) | ((b0&0x03)<<24); - // check(r>=0x200000); - // return r; - // } - // char8_t b5 = *(p++); - // check((b5&0xc0)==0x80); - // IF_LIKELY((b0&0xfe)==0xfc) { - // char32_t r = (b5&0x3f) | ((b4&0x3f)<<6) | ((b3&0x3f)<<12) | ((b2&0x3f)<<18) | ((b1&0x3f)<<24) | ((b0&0x01)<<30); - // check(r>=0x4000000); - // return r; - // } - check(false); - return 0; // not reached - } - - - template - static void encode(char8_ptr_t& p, char32_t c) { - IF_LIKELY(c<=0x7f) { - *(p++) = c; - } else { - IF_LIKELY(c<=0x7ff) { - *(p++) = 0xc0 | (c>>6); - } else { - IF_LIKELY(c<=0xffff) { - *(p++) = 0xe0 | (c>>12); - } else { - IF_LIKELY(c<=0x1fffff) { - *(p++) = 0xf0 | (c>>18); - } else { - // As above, disable 5- and 6-byte forms: - // IF_LIKELY(c<=0x3ffffff) { - // *(p++) = 0xf8 | (c>>24); - // } else { - // if (c&0x80000000) { - throw "can't represent this value in UTF8"; // needs error_policy - // } - // *(p++) = 0xfc | (c>>30); - // *(p++) = 0x80 | ((c>>24)&0x3f); - // } - // *(p++) = 0x80 | ((c>>18)&0x3f); - } - *(p++) = 0x80 | ((c>>12)&0x3f); - } - *(p++) = 0x80 | ((c>>6)&0x3f); - } - *(p++) = 0x80 | (c&0x3f); - } - } - - - // Skip forward and backward to the start of the next character. - // We know the length of a character from its first byte, so in principle we - // need only look at that to skip forward. But I guess that it's actually - // quicker to look at all bytes until a character-starting-byte is found, - // because the bit manipulation is simpler and less code is needed. - -private: - static bool char_start_byte(char8_t b) { - // All non-first bytes of a UTF8 character are 10xxxxxx. - return (b&0xc0) != 0x80; - } - -public: - template - static void skip_forward_char(char8_ptr_t& i) { - do { - ++i; - } while (!char_start_byte(*i)); // Maybe hint this? - } - - template - static void skip_backward_char(char8_ptr_t& i) { - do { - --i; - } while (!char_start_byte(*i)); // Maybe hint this? - } - - template - static int char_length(const_char8_ptr_t& p) { - char8_t b = *p; - if ((b&0x80)==0) return 1; - if ((b&0xe0)==0xc0) return 2; - if ((b&0xf0)==0xe0) return 3; - if ((b&0xf8)==0xf0) return 4; - // As above, disable 5- and 6-byte forms: - // if ((b&0xfc)==0xf8) return 5; - // if ((b&0xfe)==0xfc) return 6; - return 0; // not reached for valid input - } - - - static size_t max_characters(size_t n_units) { return n_units; } - static size_t typ_characters(size_t n_units) { return n_units; } - static size_t max_units(size_t n_characters) { return 4*n_characters; } - static size_t typ_units(size_t n_characters) { return 2*n_characters; } - - -}; - - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/ci_string.hh b/extras/anytermd/libpbe/include/ci_string.hh deleted file mode 100644 index c8dc82e653..0000000000 --- a/extras/anytermd/libpbe/include/ci_string.hh +++ /dev/null @@ -1,68 +0,0 @@ -// src/ci_string.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifndef libpbe_ci_string_hh -#define libpbe_ci_string_hh - -#include -#include -#include - -using namespace std; - - -// This code is from http://www.gotw.ca/gotw/029.htm -// It seems to be in the public domain (usenet posting) - -struct ci_char_traits : public char_traits { - static bool eq( char c1, char c2 ) { - return toupper(c1) == toupper(c2); - } - - static bool ne( char c1, char c2 ) { - return toupper(c1) != toupper(c2); - } - - static bool lt( char c1, char c2 ) { - return toupper(c1) < toupper(c2); - } - - static int compare( const char* s1, const char* s2, size_t n ) { - return strncasecmp( s1, s2, n ); - } - - static const char* find( const char* s, int n, char a ) { - while( n-- > 0 && toupper(*s) != toupper(a) ) { - ++s; - } - return s; - } -}; - - -typedef basic_string ci_string; - -// End of code from gowt.ca - - -string to_string(const ci_string& s); - -ci_string to_ci_string(const string& s); - - - -#endif diff --git a/extras/anytermd/libpbe/include/compiler_magic.hh b/extras/anytermd/libpbe/include/compiler_magic.hh deleted file mode 100644 index dbf7261ac6..0000000000 --- a/extras/anytermd/libpbe/include/compiler_magic.hh +++ /dev/null @@ -1,47 +0,0 @@ -// libpbe/include/compiler_magic.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2007-2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -// Wrappers around various gcc thingies. - - -#ifndef compiler_magic_hh -#define compiler_magic_hh - -#ifdef __GNUC__ - -// Supress unused-argument warning: -#define PBE_UNUSED_ARG(a) a __attribute__((unused)) - -// Give status branch prediction hints: -#define IF_LIKELY(c) if(__builtin_expect(c,1)) -#define IF_UNLIKELY(c) if(__builtin_expect(c,0)) - -// Warn if function result is ignored: -#define PBE_WARN_RESULT_IGNORED __attribute__ ((warn_unused_result)) - -#else - -#define PBE_UNUSED_ARG(a) a -#define IF_LIKELY(c) if(c) -#define IF_UNLIKELY(c) if(c) -#define PBE_WARN_RESULT_IGNORED - -#endif - -#endif diff --git a/extras/anytermd/libpbe/include/const_string_facade.hh b/extras/anytermd/libpbe/include/const_string_facade.hh deleted file mode 100644 index c57a845f97..0000000000 --- a/extras/anytermd/libpbe/include/const_string_facade.hh +++ /dev/null @@ -1,355 +0,0 @@ -// include/const_string_facade.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef pbe_const_string_facade_hh -#define pbe_const_string_facade_hh - -#include -#include -#include -#include - -#include - -// const_string_facade makes it simpler to implement a class with -// an interface similar to a const std::string. The implementation -// simply needs to provide access to pointers to the beginning and -// end of the raw data. -// If the raw data is null-terminated then c_str() will work. -// See ../examples/const_string_facade.cc for example usage. - - -namespace pbe { - - -template -inline size_t strlen(const CHAR* s) { return std::find(s,s-1,0) - s; } - -template<> -inline size_t strlen(const char* s) { return ::strlen(s); } - -template<> -inline size_t strlen(const unsigned char* s) { return ::strlen(reinterpret_cast(s)); } - -template<> -inline size_t strlen(const signed char* s) { return ::strlen(reinterpret_cast(s)); } - -template -inline bool contains(ITER b, ITER e, CHAR c) { return std::find(b,e,c)!=e; } - -template -inline bool not_contains(ITER b, ITER e, CHAR c) { return std::find(b,e,c)==e; } - -template -inline int strcmp(CHAR* abeg, CHAR* aend, CHAR* bbeg, CHAR* bend) { - CHAR* a = abeg; - CHAR* b = bbeg; - while (a *b) { - return 1; - } - ++a; - ++b; - } - if (a -class const_string_facade {}; - - -template -class const_string_facade { - - DERIVED& derived() { return *static_cast(this); } - const DERIVED& derived() const { return *static_cast(this); } - -public: - - typedef CHAR value_type; - typedef CHAR* pointer; - typedef CHAR& reference; - typedef const CHAR& const_reference; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - - static const size_type npos = -1; - - typedef CHAR* iterator; - typedef const CHAR* const_iterator; - - typedef boost::reverse_iterator reverse_iterator; - typedef boost::reverse_iterator const_reverse_iterator; - - iterator begin() { return derived().get_begin(); } - iterator end() { return derived().get_end(); } - const_iterator begin() const { return derived().get_begin(); } - const_iterator end() const { return derived().get_end(); } - - reverse_iterator rbegin() { return reverse_iterator(derived().get_end()); } - reverse_iterator rend() { return reverse_iterator(derived().get_begin()); } - const_reverse_iterator rbegin() const { return const_reverse_iterator(derived().get_end()); } - const_reverse_iterator rend() const { return const_reverse_iterator(derived().get_begin()); } - - size_type size() const { return end() - begin(); } - size_type length() const { return end() - begin(); } - size_type max_size() const { return end() - begin(); } // ??? - size_type capacity() const { return end() - begin(); } // ??? - bool empty() const { return end() == begin(); } - - reference operator[](size_type n) { return *(begin()+n); } - const_reference operator[](size_type n) const { return *(begin()+n); } - - const CHAR* data() const { return begin(); } - - size_type copy(CHAR* buf, size_type n, size_type pos=0) const { - // Is n allowed to be larger than size() ? - return std::copy(begin()+pos, std::min(end(),begin()+pos+n), buf) - buf; - } - - template - size_type find(const STR& s, size_type pos=0) const { - const_iterator i = std::search(begin()+pos, end(), s.begin(), s.end()); - return (i==end()) ? npos : (i-begin()); - } - size_type find(const CHAR* s, size_type pos, size_type n) const { - const_iterator i = std::search(begin()+pos, end(), s, s+n); - return (i==end()) ? npos : (i-begin()); - } - size_type find(const CHAR* s, size_type pos=0) const { - size_t len = strlen(s); - return find(s,pos,len); - } - size_type find(CHAR c, size_type pos=0) const { - const_iterator i = std::find(begin()+pos, end(), c); - return (i==end()) ? npos : (i-begin()); - } - - template - size_type rfind(const STR& s, size_type pos=npos) const { - const_reverse_iterator start = rend() - std::min(pos,size()); - const_reverse_iterator i = std::search(start, rend(), s.rbegin(), s.rend()); - return (i==rend()) ? npos : (rend()-i-s.size()); - } - size_type rfind(const CHAR* s, size_type pos, size_type n) const { - const_reverse_iterator start = rend() - std::min(pos,size()); - const_reverse_iterator i = std::search(start, rend(), const_reverse_iterator(s+n), const_reverse_iterator(s)); - return (i==rend()) ? npos : (rend()-i-n); - } - size_type rfind(const CHAR* s, size_type pos=npos) const { - size_t len = strlen(s); - return rfind(s,pos,len); - } - size_type rfind(CHAR c, size_type pos=npos) const { - const_reverse_iterator start = rend() - std::min(pos,size()); - const_reverse_iterator i = std::find(start, rend(), c); - return (i==rend()) ? npos : (rend()-i-1); - } - - template - size_type find_first_of(const STR& s, size_type pos=0) const { - const_iterator i = std::find_if(begin()+pos, end(), boost::bind(&contains,s.begin(),s.end(),_1)); - return (i==end()) ? npos : (i-begin()); - } - size_type find_first_of(const CHAR* s, size_type pos, size_type n) const { - const_iterator i = std::find_if(begin()+pos, end(), boost::bind(&contains,s,s+n,_1)); - return (i==end()) ? npos : (i-begin()); - } - size_type find_first_of(const CHAR* s, size_type pos=0) const { - size_t len = strlen(s); - return find_first_of(s,pos,len); - } - size_type find_first_of(CHAR c, size_type pos=0) const { - return find(c,pos); - } - - template - size_type find_first_not_of(const STR& s, size_type pos=0) const { - const_iterator i = std::find_if(begin()+pos, end(), boost::bind(¬_contains,s.begin(),s.end(),_1)); - return (i==end()) ? npos : (i-begin()); - } - size_type find_first_not_of(const CHAR* s, size_type pos, size_type n) const { - const_iterator i = std::find_if(begin()+pos, end(), boost::bind(¬_contains,s,s+n,_1)); - return (i==end()) ? npos : (i-begin()); - } - size_type find_first_not_of(const CHAR* s, size_type pos=0) const { - size_t len = strlen(s); - return find_first_not_of(s,pos,len); - } - size_type find_first_not_of(CHAR c, size_type pos=0) const { - return find_first_not_of(&c, pos, 1); // FIXME should use find_if - } - - template - size_type find_last_of(const STR& s, size_type pos=npos) const { - const_reverse_iterator start = rend() - std::min(pos,size()); - const_reverse_iterator i = std::find_if(start, rend(), boost::bind(&contains,s.begin(),s.end(),_1)); - return (i==rend()) ? npos : (rend()-i-1); - } - size_type find_last_of(const CHAR* s, size_type pos, size_type n) const { - const_reverse_iterator start = rend() - std::min(pos,size()); - const_reverse_iterator i = std::find_if(start, rend(), boost::bind(&contains,s,s+n,_1)); - return (i==rend()) ? npos : (rend()-i-1); - } - size_type find_last_of(const CHAR* s, size_type pos=npos) const { - size_t len = strlen(s); - return find_last_of(s,pos,len); - } - size_type find_last_of(CHAR c, size_type pos=npos) const { - return rfind(c,pos); - } - - template - size_type find_last_not_of(const STR& s, size_type pos=npos) const { - const_reverse_iterator start = rend() - std::min(pos,size()); - const_reverse_iterator i = std::find_if(start, rend(), boost::bind(¬_contains,s.begin(),s.end(),_1)); - return (i==rend()) ? npos : (rend()-i-1); - } - size_type find_last_not_of(const CHAR* s, size_type pos, size_type n) const { - const_reverse_iterator start = rend() - std::min(pos,size()); - const_reverse_iterator i = std::find_if(start, rend(), boost::bind(¬_contains,s,s+n,_1)); - return (i==rend()) ? npos : (rend()-i-1); - } - size_type find_last_not_of(const CHAR* s, size_type pos=npos) const { - size_t len = strlen(s); - return find_last_not_of(s,pos,len); - } - size_type find_last_not_of(CHAR c, size_type pos=npos) const { - return find_last_not_of(&c, pos, 1); // FIXME should use find_if - } - - std::basic_string substr(size_type pos=0, size_type n=npos) const { - return std::basic_string(begin()+pos,begin()+std::min(n,size())); - } - - template - int compare(const STR& s) const { - return strcmp(begin(), end(), s.begin(), s.end()); - } - template - int compare(size_type pos, size_type n, const STR& s) const { - return strcmp(begin()+pos, begin()+pos+n, s.begin(), s.end()); - } - template - int compare(size_type pos, size_type n, const STR& s, size_type pos1, size_type n1) const { - return strcmp(begin()+pos, begin()+pos+n, s.begin()+pos1, s.begin()+pos1+n1); - } - int compare(const CHAR* s) const { - return strcmp(begin(), end, s, s+strlen(s)); - } - int compare(size_type pos, size_type n, const CHAR* s, size_type len=npos) const { - return strcmp(begin()+pos, begin()+pos+n, s, s+std::min(len,strlen(s))); // traits::length??? - } - -}; - - -#if 0 -template -class const_string_facade: public const_string_facade { -public: - const CHAR* c_str() const { return begin(); } -}; -#endif - - - -template -inline bool operator==(const const_string_facade& s1, - const const_string_facade& s2) { - return s1.compare(s2) == 0; -} - -template -inline bool operator==(const CHAR* s1, - const const_string_facade& s2) { - return s2.compare(s1) == 0; -} - -template -inline bool operator==(const const_string_facade& s1, - const CHAR* s2) { - return s1.compare(s2) == 0; -} - - -template -inline bool operator!=(const const_string_facade& s1, - const const_string_facade& s2) { - return s1.compare(s2) != 0; -} - -template -inline bool operator!=(const CHAR* s1, - const const_string_facade& s2) { - return s2.compare(s1) != 0; -} - -template -inline bool operator!=(const const_string_facade& s1, - const CHAR* s2) { - return s1.compare(s2) != 0; -} - - -template -inline bool operator<(const const_string_facade& s1, - const const_string_facade& s2) { - return s1.compare(s2) < 0; -} - -template -inline bool operator<(const CHAR* s1, - const const_string_facade& s2) { - return s2.compare(s1) < 0; -} - -template -inline bool operator<(const const_string_facade& s1, - const CHAR* s2) { - return s1.compare(s2) < 0; -} - - -template -inline std::basic_ostream& operator<<(std::basic_ostream& os, - const const_string_facade& s) { - std::ostream_iterator osi(os); - copy(s.begin(),s.end(),osi); // something about os.width() ??? - return os; -} - - -}; - -#endif - diff --git a/extras/anytermd/libpbe/include/create_dir.hh b/extras/anytermd/libpbe/include/create_dir.hh deleted file mode 100644 index 735b9cddfa..0000000000 --- a/extras/anytermd/libpbe/include/create_dir.hh +++ /dev/null @@ -1,56 +0,0 @@ -// include/create_dir.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe -// (C) 2009 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -// Create directories. - - -#ifndef libpbe_create_dir_hh -#define libpbe_create_dir_hh - -#include "Exception.hh" - -#include -#include - -#include - -namespace pbe { - - -// Simple wrapper for mkdir(). Doesn't create parent directories; fails -// if the directory already exists or is a file. - -inline void create_dir(std::string path, mode_t mode = 0777) { - int r = ::mkdir(path.c_str(),mode); - if (r==-1) { - pbe::throw_ErrnoException("mkdir()"); - } -} - - -// Check for and create necessary parent directories. Succeeds if the -// directory already exists; fails if it is a file. - -extern void create_dir_with_parents(const std::string path, mode_t mode = 0777); - - -}; - -#endif - diff --git a/extras/anytermd/libpbe/include/csv.hh b/extras/anytermd/libpbe/include/csv.hh deleted file mode 100644 index bd4c7542bf..0000000000 --- a/extras/anytermd/libpbe/include/csv.hh +++ /dev/null @@ -1,29 +0,0 @@ -// csv.hh -// (C) 2008 Philip Endecott -// This file is part of libpbe. See http://svn.chezphil.org/libpbe/ -// This file is distributed under the terms of the Boost Software License v1.0. -// Please see http://www.boost.org/LICENSE_1_0.txt or the accompanying file BOOST_LICENSE. - -#ifndef pbe_csv_hh -#define pbe_csv_hh - -#include -#include - -namespace pbe { - -// Parse a line from a comma-separated-variables (CSV) file. -// The fields are used to populate a vector. -// -// Each field may be quoted with "" or not quoted. If it's quoted it may -// contain unescaped commas; if it's not quoted it can't. In either case -// it may contain escaped characters using \. -// -// The code makes some attempt to handle invalid input sanely, but -// it is not designed to be secure against malicious input. - -extern void parse_csv_line(std::string l, std::vector& v); - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/endian.hh b/extras/anytermd/libpbe/include/endian.hh deleted file mode 100644 index 5883842ae7..0000000000 --- a/extras/anytermd/libpbe/include/endian.hh +++ /dev/null @@ -1,78 +0,0 @@ -// src/endian.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_endian_hh -#define libpbe_endian_hh - -#include - -#ifdef __GLIBC__ -#include -#define PBE_BYTE_ORDER __BYTE_ORDER -#define PBE_BIG_ENDIAN __BIG_ENDIAN -#define PBE_LITTLE_ENDIAN __LITTLE_ENDIAN - -#elif defined(__FreeBSD__) -#include -#define PBE_BYTE_ORDER _BYTE_ORDER -#define PBE_BIG_ENDIAN _BIG_ENDIAN -#define PBE_LITTLE_ENDIAN _LITTLE_ENDIAN - -#endif - - -namespace pbe { - -inline uint32_t swap_end_32(uint32_t data) -{ - uint32_t r = data>>24; - r |= (data>>8)&0x0000ff00; - r |= (data<<8)&0x00ff0000; - r |= data<<24; - return r; -} - -inline uint64_t swap_end_64(uint64_t data) -{ - uint64_t a = swap_end_32(data>>32); - uint64_t b = swap_end_32(data&0xffffffff); - return a | b<<32; -} - - -inline uint64_t hton64(uint64_t i) { -#if PBE_BYTE_ORDER == PBE_BIG_ENDIAN - return i; -#else - return swap_end_64(i); -#endif -} - - -inline uint64_t ntoh64(uint64_t i) { -#if PBE_BYTE_ORDER == PBE_BIG_ENDIAN - return i; -#else - return swap_end_64(i); -#endif -} - - -}; - -#endif diff --git a/extras/anytermd/libpbe/include/ffs.hh b/extras/anytermd/libpbe/include/ffs.hh deleted file mode 100644 index 1e57e16425..0000000000 --- a/extras/anytermd/libpbe/include/ffs.hh +++ /dev/null @@ -1,61 +0,0 @@ -// include/ffs.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef pbe_ffs_hh -#define pbe_ffs_hh - -// ffs - Find First Set -// This is overloading of the libc ffs* functions for different int types. -// Find the least significant bit set in a value and return its index. -// Bits are numbered starting from 1. -// If no bits are set, return 0. - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#include -#undef _GNU_SOURCE -#else -#include -#endif - -#include - - -namespace pbe { - -inline int ffs(::uint32_t i) { - return ::ffsl(i); -} - -inline int ffs(::int32_t i) { - return ::ffsl(i); -} - -inline int ffs(::uint64_t i) { - return ::ffsll(i); -} - -inline int ffs(::int64_t i) { - return ::ffsll(i); -} - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/file_length.hh b/extras/anytermd/libpbe/include/file_length.hh deleted file mode 100644 index 65d60f33fd..0000000000 --- a/extras/anytermd/libpbe/include/file_length.hh +++ /dev/null @@ -1,52 +0,0 @@ -// include/file_length.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef pbe_file_length_hh -#define pbe_file_length_hh - -#include "Exception.hh" - -#include - -#include -#include -#include - - -// Find the length of a file, given its pathname - - -namespace pbe { - - ::off_t file_length(const char* pathname) { - struct ::stat s; - int rc = ::stat(pathname,&s); - if (rc==-1) { - throw_ErrnoException("stat()"); - } - return s.st_size; - } - - ::off_t file_length(std::string pathname) { - return file_length(pathname.c_str()); - } - -}; - -#endif - diff --git a/extras/anytermd/libpbe/include/fixed.hh b/extras/anytermd/libpbe/include/fixed.hh deleted file mode 100644 index 3c0f574798..0000000000 --- a/extras/anytermd/libpbe/include/fixed.hh +++ /dev/null @@ -1,397 +0,0 @@ -// include/fixed.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// It is also offered as a candidate for inclusion in Boost, http://boost.org/ -// (C) 2007 Philip Endecott -// This file is distributed under the terms of the Boost Software License v. 1.0, -// see http://www.boost.org/LICENSE_1_0.txt. - -// Introduction -// ------------ - -// This file provides class templates 'fixed' and 'ufixed' which implement signed and -// unsigned fixed-point arithmetic. For background information about fixed-point -// arithmetic, see for example this Wikipedia article: -// http://en.wikipedia.org/wiki/Fixed-point_arithmetic. Note in particular that this -// is binary arithmetic, not binary coded decimal. -// -// The author's requirement for fixed-point arithmetic is based on these -// characteristics: -// -// - Comparing a 32-bit fixed-point value and a 32-bit single-precision -// floating-point value, the fixed-point value has about 8 bits more precision -// because it does not "waste" bits representing the exponent. In the case of -// latitude and longitude values this makes the difference between a precision of -// hundreds of metres and ones of metres. -// -// - Certain operations that directly operate on the bit patterns of values are much -// simpler to carry out on fixed-point values than on floating-point values. (For -// example, the bit interleaving required for Z-curves.) -// -// Other characteristics that are often beneficial include: -// -// - Computation is faster on systems that have no floating-point hardware, e.g. -// embedded systems. -// -// - The precision of the values is well-defined and predictable. -// -// -// Quick Start -// ----------- -// -// Here's a very quick illustration of how the class can be used: -// -// #include -// -// void test() { -// fixed<15,16> f1, f2; // Signed fixed-point values with 15 bits of integer part -// // and 16 bits of fractional part. -// f1 = 1.2345; // Conversion from floating point. -// f2 = f1 - 2; // Mixed arithmetic with integers. -// f2 = f1 / f2; // Arithmetic on fixed-point values. -// } -// -// -// Primary Objective -// ----------------- -// -// The primary objective of this implementation is zero performance overhead compared -// to using integer arithmetic with manually-inserted scaling. This is because -// performance is important in many applications of fixed-point arithmetic and it -// really isn't very hard to do ad-hoc fixed-point arithmetic using integers and -// shifts. Users will therefore not be attracted to this library unless it can offer -// this feature. -// -// -// Secondary Objectives -// -------------------- -// -// Secondary objectives are: -// -// - To behave in as many respects as possible in the same was as the built-in -// numeric types (integer and floating-point). The motivation for this is to give -// the user the behaviour that they are already familiar with from those types. -// -// -// Hardware Support -// ---------------- -// -// The objective of this implementation is to work efficiently with conventional -// processors' integer arithmetic instructions. It is worth noting, however, that -// some processors have hardware support for fixed-point operations. These include: -// -// [Hmm, no MMX doesn't seem to have any explicit fixed-point support] -// -// - DSP processors. -// - Intel's MMX instruction set (also implemented in other x86-compatible -// processors). -// - The PowerPC's AltiVec instruction set. -// - The ARM Piccolo instruction set. -// -// Support for any of these instruction sets would require either use of -// architecture-specific assembly language or a very smart compiler. These are -// considered outside the scope of the current work; however, it is worthwhile to see -// what these instruction sets offer in order to avoid unintentionally implementing -// something that is incompatible. -// -// For example, it seems that these instruction sets could more easily support -// fixed<16,15> than fixed<15,16>. It may be that the user would be happy with -// either of these formats. So we should consider offering a way to get the "best" -// format with at least a certain number of bits of integer and fractional parts for -// a particular instruction set. -// -// -// Related Work -// ------------ -// -// "Embedded C" (see ISO/IEC [draft] technical report 18037:2004) proposes fixed -// point types for C. It defines -// new keywords _Fract and _Accum which modify the built-in short, int and long -// types; _Fract makes the value entirely fractional while _Accum gives it 4 -// integer bits. -// -// It requires saturating arithmetic (controlled by an _Sat keyword or a #pragma), -// and does not require wrap-around behaviour. -// -// Fixed-point constants can be written using letter suffixes, e.g. 3.1415uhk. -// -// It looks very much as if this proposal is motivated by one particular category of -// applications (i.e. digital signal processing). The requirement for saturating -// arithmetic imposes a significant overhead on processors that do not have support -// for it, and the lack of support for values with more than 4 integer bits makes it -// useless for the author's latitude/longitude application. -// -// -// Getting the High part of a multiply result -// ------------------------------------------ -// -// MMX has "packed multiply high" instruction. -// -// -// Meaning of ++ and -- -// -------------------- -// -// It could be argued that the meaning of ++ and -- is unclear: do they add/subtract -// 1, or do they add/subtract the type's delta? (...there is an example of something -// where they do delta...). I note, however, that the built-in floating point types -// add and subtract 1, as does the proposed "Embedded C" fixed-point type. -// Therefore, ++ and -- are defined to do that for fixed and ufixed. -// -// -// Fixed Point Constants -// --------------------- -// -// It would be ideal if code such as -// -// const ufixed<2,14> pi = 3.1415926; -// -// could have no run-time overhead. To be investigated... -// -// -// Result Types -// ------------ -// -// -// Free Functions -// -------------- -// -// embedded C has... -// ...names are crytic due to absence of template/overloading in C. -// -// -// Overflow and Saturation -// ----------------------- -// -// Users of fixed-point arithmetic sometimes want to detect overflow, or for -// operations to saturate when overflow would occur. However, users of -// floating-point and integer arithmetic also sometimes want these features, but they -// are not provided by the built-in C/C++ types. The approach taken in this -// implementation is to follow the behaviour of the built-in types, i.e. to not -// handle overflow; values will wrap-around. -// -// Hardware overhead of saturation; MMX has saturating instructions. -// -// -// Division By Zero -// ---------------- -// -// compare with int and float... -// -// embedded C fixed is undefined -// -// -// Formatted input/output -// ---------------------- -// -// ... implemented by conversion to floating point? ... -// -// -// 'Math library' functions -// ------------------------ -// -// A set of functions similar to those provided by the standard library for integer -// and floating-point types is provided. The skeleton for these functions was -// provided by ...... -// -// In the case of ....., tables of constants are required. Different tables are -// required for each fixed point type. By default, the approach taken is to compute -// these tables when the functions are first used [note that the use of static -// variables may not be thread safe]. This could impose an unacceptable delay in -// some applications; in this case, the preprocessor symbol ... should be defined, -// and the included program ... should be run once for each type to generate static -// tables. Simply include the output of this program in your build. -// -// -// bigint -// ------ -// -// -// Benchmarks -// ---------- -// -// The following results are based on the benchmark programs in the ... directory. -// There are: -// -// - sort: generates a std::vector of xxxx pseudo-random values and sorts them -// using std::sort. This measures comparison performance, which should be of the -// same order as addition and subtraction. -// -// - filt: generates a vector of pseudo-random values and filters them using an FIR -// (finite impulse response) filter. The filter coefficients are also generated -// pseudo-randomly. This measures primarily multiply performance. -// -// In each case the performance is measured for fixed-point, floating-point and -// integer types with manually-inserted shifts. -// -// The following platforms have been tested: -// -// - NSLU2. (See http://nslu2-linux.org/). This system has a 266 MHz Intel IXP420 -// XScale ARM processor, which has no floating point hardware. The compiler used was -// g++ verson 4.1.2. -// -// - The author's desktop computer, which as a 1 GHz VIA C3 (x86-compatible) -// processor. The compiler used was also g++ version 4.1.2. -// - - - -// Note to Boost people: I will change all the 'libpbe' identifiers to 'boost' -// when this is formally proposed for review. - -#ifndef libpbe_fixed_hh -#define libpbe_fixed_hh - -#include // for ldexp* -#include "./integer.hpp" // Copy of boost::integer to which I've added 64-bit support. - // I expect this functionality to be added to the official - // version before this code is reviewed. -#include -#include - - -namespace pbe { - - -// This helper function exists mainly to avoid warnings about negative shifts. - -template -T shift(T val) { - if (amt>0) { - unsigned int u_amt = amt; - return val>>u_amt; - } else { - unsigned int u_amt = -amt; - return val<::least> -// WB = Whole Bits -// FB = Fraction Bits -// VAL_T = type to use for implementation -class fixed: - - boost::totally_ordered >, - boost::additive >, - boost::bitwise >, - boost::unit_steppable > -{ - -// Question: do we want to expose the implementation type and value? -// In my application I have found it useful to do so. -//private: -public: - typedef VAL_T val_t; - val_t val; - -public: - fixed() {} - fixed(const fixed& x): val(x.val) {} - - template - fixed(const fixed& x): - val(shift(x.val)) - //(X_FB>(X_FB-FB))) - {} - - fixed(int x): val(x<(ldexpf(x,FB))) {} - fixed(double x): val(static_cast(ldexp (x,FB))) {} - - operator float() const { return ldexpf(static_cast(val),-FB); } - operator double() const { return ldexp (static_cast(val),-FB); } - - - bool operator<(const fixed& x) const { return val - fixed& operator*=(const fixed& x) { (*this) = (*this) * x; return *this; } - - template - fixed& operator/=(const fixed& x) { (*this) = (*this) / x; return *this; } - - fixed& operator*=(float x) { (*this) = static_cast(*this) * x; return *this; } - - fixed& operator/=(float x) { (*this) = static_cast(*this) / x; return *this; } -}; - - -// I don't know how to choose the VAL_T for the results of these operations. -// I.e. if the operands use safe_int then the result should also use safe_int. - -template -pbe::fixed::value, boost::static_unsigned_max::value> -operator+(pbe::fixed x, pbe::fixed y) { - typedef pbe::fixed::value, boost::static_unsigned_max::value> result_t; - result_t x_(x); - result_t y_(y); - return x_ + y_; -} - - -template -pbe::fixed::value, boost::static_unsigned_max::value> -operator-(pbe::fixed x, pbe::fixed y) { - typedef pbe::fixed::value, boost::static_unsigned_max::value> result_t; - result_t x_(x); - result_t y_(y); - return x_ - y_; -} - - -template -pbe::fixed -operator*(pbe::fixed x, pbe::fixed y) { - typedef pbe::fixed result_t; - result_t r; - r.val = static_cast(x.val) * y.val; - return r; -} - - -template -pbe::fixed -operator/(pbe::fixed x, pbe::fixed y) { - pbe::fixed r; - r.val = x.val; - r.val <<= (YWB+YFB); - r.val /= y.val; - return r; -} - - -template -float operator*(pbe::fixed x, float y) { - // fixed * float is done using floating-point. Right choice? - return static_cast(x) * y; -} - -template -float operator/(pbe::fixed x, float y) { - // Ditto. - return static_cast(x) / y; -} - - - -// Also planned: an unsigned version. - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/format.hh b/extras/anytermd/libpbe/include/format.hh deleted file mode 100644 index cfa5c027df..0000000000 --- a/extras/anytermd/libpbe/include/format.hh +++ /dev/null @@ -1,38 +0,0 @@ -// include/format.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2009 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_format_hh -#define libpbe_format_hh - -#include - - -// pbe::format is an sprintf-like function that returns a std::string. - - -namespace pbe { - - -extern std::string format(const char* fmt,...) __attribute__ ((format (printf, 1, 2))); - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/geometry.hh b/extras/anytermd/libpbe/include/geometry.hh deleted file mode 100644 index 99b1ab1a42..0000000000 --- a/extras/anytermd/libpbe/include/geometry.hh +++ /dev/null @@ -1,100 +0,0 @@ -// include/geometry.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_geometry_hh -#define libpbe_geometry_hh - -#include - - -namespace pbe { - -const float PI = 3.1415927F; -const double PId = 3.1415927; -const float earth_radius = 6372795.0F; - -template -inline T sqr(T x) { return x*x; } - -inline float deg2rad(float a) { return PI/180.0F * a; } -inline float rad2deg(float a) { return 180.0F/PI * a; } - -inline float degsin(float a) { return sin(deg2rad(a)); } -inline float degcos(float a) { return cos(deg2rad(a)); } -inline float degtan(float a) { return tan(deg2rad(a)); } - -inline float degasin(float x) { return rad2deg(asin(x)); } -inline float degacos(float x) { return rad2deg(acos(x)); } -inline float degatan(float x) { return rad2deg(atan(x)); } -inline float degatan2(float y, float x) { return rad2deg(atan2(y,x)); } - -inline double deg2rad(double a) { return PId/180.0 * a; } -inline double rad2deg(double a) { return 180.0/PId * a; } - -inline double degsin(double a) { return sin(deg2rad(a)); } -inline double degcos(double a) { return cos(deg2rad(a)); } -inline double degtan(double a) { return tan(deg2rad(a)); } - -inline double degasin(double x) { return rad2deg(asin(x)); } -inline double degacos(double x) { return rad2deg(acos(x)); } -inline double degatan(double x) { return rad2deg(atan(x)); } -inline double degatan2(double y, double x) { return rad2deg(atan2(y,x)); } - -inline float normalise_unsigned_angle(float a) { return a>0 ? fmod(a,360.0F) : 360.0F+fmod(a,360.0F); } -inline float normalise_signed_angle(float a) { return normalise_unsigned_angle(a+180.0F)-180.0F; } - - -struct position { - float lng; - float lat; - float alt; - - position() {} - position(float lng_, float lat_, float alt_): - lng(lng_), lat(lat_), alt(alt_) - {} -}; - -float distance(const position& a, const position& b); // Proper great circle calculation -float bearing(const position& a, const position& b); -float elevation(const position& a, const position& b); - -inline float cheap_distance(const position& a, const position& b) { - return earth_radius / 360.0F * 2*PI - * sqrt( sqr(a.lat-b.lat) + sqr((a.lng-b.lng)*degcos(a.lat)) ); -} - -inline float cheap_bearing(const position& a, const position& b) { - float d = degatan2( (b.lng-a.lng) * degcos(a.lat), - b.lat-a.lat ); - return normalise_unsigned_angle(d); -} - -inline float elevation(const position& a, const position& b) { - return degatan2(b.alt-a.alt,cheap_distance(a,b)); -} - -inline float rectilinear_elevation(const position& a, const position& b) { - return rad2deg((b.alt-a.alt) / cheap_distance(a,b)); -} - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/inc_init_array.hh b/extras/anytermd/libpbe/include/inc_init_array.hh deleted file mode 100644 index ae404fc725..0000000000 --- a/extras/anytermd/libpbe/include/inc_init_array.hh +++ /dev/null @@ -1,240 +0,0 @@ -// include/inc_init_array.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -// This work is based on Boost.Array, which is: -// (C) Copyright Nicolai M. Josuttis 2001. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -#ifndef libpbe_inc_init_array_hh -#define libpbe_inc_init_array_hh - -// pbe::inc_init_array is like boost::array, except that T must have -// a constructor that takes an integer, and when inc_init_array is -// constructed it will make N instances of T passing values 0 to N-1 to T's -// constructor. When given an extra template parameter M it will make N -// instances passing values M to M+N-1 - -// You can also pass an additional, constant, arbitrary-typed value to the elements' -// constructors by passing it as a final parameter to the array's constructor, i.e. -// if T has a constructor T(int,X) then pbe::inc_init_array has a -// constructor inc_init_array(X). - -#include - -#include -#include -#include - - -namespace pbe { - -template -class inc_init_array { - - char mem[sizeof(T)*N]; // worry about alignment - -public: - - // Unlike Boost.Array, elems is a function: - T* elems() { return reinterpret_cast(&mem); } - const T* elems() const { return reinterpret_cast(&mem); } - - inc_init_array() { - int i; - try { - for (i=0; i0; --i) { - (elems()+i) -> ~T(); - } - throw; - } - } - - inc_init_array(X x) { - int i; - try { - for (i=0; i0; --i) { - (elems()+i) -> ~T(); - } - throw; - } - } - - ~inc_init_array() { - for (int i=N-1; i>=0; --i) { - (elems()+i) -> ~T(); - } - } - - // type definitions - typedef T value_type; - typedef T* iterator; - typedef const T* const_iterator; - typedef T& reference; - typedef const T& const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - // iterator support - iterator begin() { return elems(); } - const_iterator begin() const { return elems(); } - iterator end() { return elems()+N; } - const_iterator end() const { return elems()+N; } - - // reverse iterator support - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - - reverse_iterator rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const { - return const_reverse_iterator(end()); - } - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const { - return const_reverse_iterator(begin()); - } - - // operator[] - reference operator[](size_type i) - { - BOOST_ASSERT( i < N && "out of range" ); - return elems()[i]; - } - - const_reference operator[](size_type i) const - { - BOOST_ASSERT( i < N && "out of range" ); - return elems()[i]; - } - - // at() with range check - reference at(size_type i) { rangecheck(i); return elems()[i]; } - const_reference at(size_type i) const { rangecheck(i); return elems()[i]; } - - // front() and back() - reference front() - { - return elems()[0]; - } - - const_reference front() const - { - return elems()[0]; - } - - reference back() - { - return elems()[N-1]; - } - - const_reference back() const - { - return elems()[N-1]; - } - - // size is constant - static size_type size() { return N; } - static bool empty() { return false; } - static size_type max_size() { return N; } - enum { static_size = N }; - - // swap (note: linear complexity) - void swap (inc_init_array& y) { - std::swap_ranges(begin(),end(),y.begin()); - } - - // direct access to data (read-only) - const T* data() const { return elems(); } - - // use array as C array (direct read/write access to data) - T* c_array() { return elems(); } - - // assignment with type conversion - template - inc_init_array& operator= (const inc_init_array& rhs) { - std::copy(rhs.begin(),rhs.end(), begin()); - return *this; - } - - // assign one value to all elements - void assign (const T& value) - { - std::fill_n(begin(),size(),value); - } - - // check range (may be private because it is static) - static void rangecheck (size_type i) { - if (i >= size()) { - throw std::range_error("inc_init_array<>: index out of range"); - } - } - -}; - - -// comparisons -template -bool operator== (const inc_init_array& x, const inc_init_array& y) { - return std::equal(x.begin(), x.end(), y.begin()); -} -template -bool operator< (const inc_init_array& x, const inc_init_array& y) { - return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); -} -template -bool operator!= (const inc_init_array& x, const inc_init_array& y) { - return !(x==y); -} -template -bool operator> (const inc_init_array& x, const inc_init_array& y) { - return y -bool operator<= (const inc_init_array& x, const inc_init_array& y) { - return !(y -bool operator>= (const inc_init_array& x, const inc_init_array& y) { - return !(x -inline void swap (inc_init_array& x, inc_init_array& y) { - x.swap(y); -} - - -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/inc_init_vector.hh b/extras/anytermd/libpbe/include/inc_init_vector.hh deleted file mode 100644 index 95f404dfb5..0000000000 --- a/extras/anytermd/libpbe/include/inc_init_vector.hh +++ /dev/null @@ -1,51 +0,0 @@ -// include/inc_init_vector.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_inc_init_vector_hh -#define libpbe_inc_init_vector_hh - - -// pbe::inc_init_vector is like std::vector, except that T must have -// a constructor that takes an integer, and when inc_init_vector is -// constructed with a parameter n it will make n instances of T, passing -// values 0 to n-1 to T's constructor, or when constructed with parameters -// n and m it will make n instances passing values m to m+n-1 - -#include - - -namespace pbe { - -template -class inc_init_vector: public std::vector { - -public: - inc_init_vector() {} - inc_init_vector(const inc_init_vector& other): std::vector(other) {} - inc_init_vector(int n, int m=0) { - for (int i=m; i is like boost::array, except that it provides -// a constructor that takes a T and copy-constructs each of its elements -// using it. - -#include - -#include - - -namespace pbe { - -template -class init_array { - - char mem[sizeof(T)*N]; // worry about alignment - -public: - - // Unlike Boost.Array, elems is a function: - T* elems() { return reinterpret_cast(&mem); } - const T* elems() const { return reinterpret_cast(&mem); } - - init_array() { - int i; - try { - for (i=0; i0; --i) { - (elems()+i) -> ~T(); - } - throw; - } - } - - init_array(T t) { - int i; - try { - for (i=0; i0; --i) { - (elems()+i) -> ~T(); - } - throw; - } - } - - ~init_array() { - for (int i=N-1; i>=0; --i) { - (elems()+i) -> ~T(); - } - } - - // type definitions - typedef T value_type; - typedef T* iterator; - typedef const T* const_iterator; - typedef T& reference; - typedef const T& const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - // iterator support - iterator begin() { return elems(); } - const_iterator begin() const { return elems(); } - iterator end() { return elems()+N; } - const_iterator end() const { return elems()+N; } - - // reverse iterator support - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - - reverse_iterator rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const { - return const_reverse_iterator(end()); - } - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const { - return const_reverse_iterator(begin()); - } - - // operator[] - reference operator[](size_type i) - { - BOOST_ASSERT( i < N && "out of range" ); - return elems()[i]; - } - - const_reference operator[](size_type i) const - { - BOOST_ASSERT( i < N && "out of range" ); - return elems()[i]; - } - - // at() with range check - reference at(size_type i) { rangecheck(i); return elems()[i]; } - const_reference at(size_type i) const { rangecheck(i); return elems()[i]; } - - // front() and back() - reference front() - { - return elems()[0]; - } - - const_reference front() const - { - return elems()[0]; - } - - reference back() - { - return elems()[N-1]; - } - - const_reference back() const - { - return elems()[N-1]; - } - - // size is constant - static size_type size() { return N; } - static bool empty() { return false; } - static size_type max_size() { return N; } - enum { static_size = N }; - - // swap (note: linear complexity) - void swap (init_array& y) { - std::swap_ranges(begin(),end(),y.begin()); - } - - // direct access to data (read-only) - const T* data() const { return elems(); } - - // use array as C array (direct read/write access to data) - T* c_array() { return elems(); } - - // assignment with type conversion - template - init_array& operator= (const init_array& rhs) { - std::copy(rhs.begin(),rhs.end(), begin()); - return *this; - } - - // assign one value to all elements - void assign (const T& value) - { - std::fill_n(begin(),size(),value); - } - - // check range (may be private because it is static) - static void rangecheck (size_type i) { - if (i >= size()) { - throw std::range_error("init_array<>: index out of range"); - } - } - -}; - - -// comparisons -template -bool operator== (const init_array& x, const init_array& y) { - return std::equal(x.begin(), x.end(), y.begin()); -} -template -bool operator< (const init_array& x, const init_array& y) { - return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); -} -template -bool operator!= (const init_array& x, const init_array& y) { - return !(x==y); -} -template -bool operator> (const init_array& x, const init_array& y) { - return y -bool operator<= (const init_array& x, const init_array& y) { - return !(y -bool operator>= (const init_array& x, const init_array& y) { - return !(x -inline void swap (init_array& x, init_array& y) { - x.swap(y); -} - - -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/integer.hpp b/extras/anytermd/libpbe/include/integer.hpp deleted file mode 100644 index dae64f2c94..0000000000 --- a/extras/anytermd/libpbe/include/integer.hpp +++ /dev/null @@ -1,136 +0,0 @@ -// boost integer.hpp header file -------------------------------------------// - -// Copyright Beman Dawes and Daryle Walker 1999. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/integer for documentation. - -// Hacked by Phil Endecott to add 64 bits - -// Revision History -// 22 Sep 01 Added value-based integer templates. (Daryle Walker) -// 01 Apr 01 Modified to use new header. (John Maddock) -// 30 Jul 00 Add typename syntax fix (Jens Maurer) -// 28 Aug 99 Initial version - -#ifndef BOOST_INTEGER_HPP -#define BOOST_INTEGER_HPP - -#include "./integer_fwd.hpp" // self include - -#include // for boost::integer_traits -#include // for std::numeric_limits -#include - -namespace boost -{ - - // Helper templates ------------------------------------------------------// - - // fast integers from least integers - // int_fast_t<> works correctly for unsigned too, in spite of the name. - template< typename LeastInt > - struct int_fast_t { typedef LeastInt fast; }; // imps may specialize - - // convert category to type - template< int Category > struct int_least_helper {}; // default is empty - - // specializatons: 1=int64_t 2=long, 3=int, 4=short, 5=signed char, - // 7=uint64_t 8=unsigned long, 9=unsigned int, 10=unsigned short, 11=unsigned char - // no specializations for 0 and 6: requests for a type > 64 bits are in error - template<> struct int_least_helper<1> { typedef int64_t least; }; - template<> struct int_least_helper<2> { typedef long least; }; - template<> struct int_least_helper<3> { typedef int least; }; - template<> struct int_least_helper<4> { typedef short least; }; - template<> struct int_least_helper<5> { typedef signed char least; }; - template<> struct int_least_helper<7> { typedef uint64_t least; }; - template<> struct int_least_helper<8> { typedef unsigned long least; }; - template<> struct int_least_helper<9> { typedef unsigned int least; }; - template<> struct int_least_helper<10>{ typedef unsigned short least; }; - template<> struct int_least_helper<11>{ typedef unsigned char least; }; - - // integer templates specifying number of bits ---------------------------// - - // signed - template< int Bits > // bits (including sign) required - struct int_t - { - typedef typename int_least_helper - < - (Bits-1 <= std::numeric_limits::digits) + - (Bits-1 <= std::numeric_limits::digits) + - (Bits-1 <= std::numeric_limits::digits) + - (Bits-1 <= std::numeric_limits::digits) + - (Bits-1 <= std::numeric_limits::digits) - >::least least; - typedef typename int_fast_t::fast fast; - }; - - // unsigned - template< int Bits > // bits required - struct uint_t - { - typedef typename int_least_helper - < - 6 + - (Bits <= std::numeric_limits::digits) + - (Bits <= std::numeric_limits::digits) + - (Bits <= std::numeric_limits::digits) + - (Bits <= std::numeric_limits::digits) - >::least least; - typedef typename int_fast_t::fast fast; - // int_fast_t<> works correctly for unsigned too, in spite of the name. - }; - - // integer templates specifying extreme value ----------------------------// - - // signed - template< int64_t MaxValue > // maximum value to require support - struct int_max_value_t - { - typedef typename int_least_helper - < - (MaxValue <= integer_traits::const_max) + - (MaxValue <= integer_traits::const_max) + - (MaxValue <= integer_traits::const_max) + - (MaxValue <= integer_traits::const_max) + - (MaxValue <= integer_traits::const_max) - >::least least; - typedef typename int_fast_t::fast fast; - }; - - template< int64_t MinValue > // minimum value to require support - struct int_min_value_t - { - typedef typename int_least_helper - < - (MinValue >= integer_traits::const_min) + - (MinValue >= integer_traits::const_min) + - (MinValue >= integer_traits::const_min) + - (MinValue >= integer_traits::const_min) + - (MinValue >= integer_traits::const_min) - >::least least; - typedef typename int_fast_t::fast fast; - }; - - // unsigned - template< uint64_t Value > // maximum value to require support - struct uint_value_t - { - typedef typename int_least_helper - < - 6 + - (Value <= integer_traits::const_max) + - (Value <= integer_traits::const_max) + - (Value <= integer_traits::const_max) + - (Value <= integer_traits::const_max) + - (Value <= integer_traits::const_max) - >::least least; - typedef typename int_fast_t::fast fast; - }; - - -} // namespace boost - -#endif // BOOST_INTEGER_HPP diff --git a/extras/anytermd/libpbe/include/integer_fwd.hpp b/extras/anytermd/libpbe/include/integer_fwd.hpp deleted file mode 100644 index c37d141bc7..0000000000 --- a/extras/anytermd/libpbe/include/integer_fwd.hpp +++ /dev/null @@ -1,153 +0,0 @@ -// Boost integer_fwd.hpp header file ---------------------------------------// - -// (C) Copyright Dave Abrahams and Daryle Walker 2001. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/integer for documentation. - -#ifndef BOOST_INTEGER_FWD_HPP -#define BOOST_INTEGER_FWD_HPP - -#include // for UCHAR_MAX, etc. -#include // for std::size_t -#include - -#include // for BOOST_NO_INTRINSIC_WCHAR_T -#include // for std::numeric_limits - - -namespace boost -{ - - -// From ------------------------------------------------// - -// Only has typedefs or using statements, with #conditionals - - -// From -----------------------------------------// - -template < class T > - class integer_traits; - -template < > - class integer_traits< bool >; - -template < > - class integer_traits< char >; - -template < > - class integer_traits< signed char >; - -template < > - class integer_traits< unsigned char >; - -#ifndef BOOST_NO_INTRINSIC_WCHAR_T -template < > - class integer_traits< wchar_t >; -#endif - -template < > - class integer_traits< short >; - -template < > - class integer_traits< unsigned short >; - -template < > - class integer_traits< int >; - -template < > - class integer_traits< unsigned int >; - -template < > - class integer_traits< long >; - -template < > - class integer_traits< unsigned long >; - -#ifdef ULLONG_MAX -template < > - class integer_traits< ::boost::long_long_type>; - -template < > - class integer_traits< ::boost::ulong_long_type >; -#endif - - -// From ------------------------------------------------// - -template < typename LeastInt > - struct int_fast_t; - -template< int Bits > - struct int_t; - -template< int Bits > - struct uint_t; - -template< int64_t MaxValue > - struct int_max_value_t; - -template< int64_t MinValue > - struct int_min_value_t; - -template< uint64_t Value > - struct uint_value_t; - - -// From -----------------------------------// - -template < std::size_t Bit > - struct high_bit_mask_t; - -template < std::size_t Bits > - struct low_bits_mask_t; - -template < > - struct low_bits_mask_t< ::std::numeric_limits::digits >; - -#if USHRT_MAX > UCHAR_MAX -template < > - struct low_bits_mask_t< ::std::numeric_limits::digits >; -#endif - -#if UINT_MAX > USHRT_MAX -template < > - struct low_bits_mask_t< ::std::numeric_limits::digits >; -#endif - -#if ULONG_MAX > UINT_MAX -template < > - struct low_bits_mask_t< ::std::numeric_limits::digits >; -#endif - - -// From ------------------------------------// - -template < unsigned long Value > - struct static_log2; - -template < > - struct static_log2< 0ul >; - - -// From ---------------------------------// - -template < long Value1, long Value2 > - struct static_signed_min; - -template < long Value1, long Value2 > - struct static_signed_max; - -template < unsigned long Value1, unsigned long Value2 > - struct static_unsigned_min; - -template < unsigned long Value1, unsigned long Value2 > - struct static_unsigned_max; - - -} // namespace boost - - -#endif // BOOST_INTEGER_FWD_HPP diff --git a/extras/anytermd/libpbe/include/ip.hh b/extras/anytermd/libpbe/include/ip.hh deleted file mode 100644 index 48587edfb5..0000000000 --- a/extras/anytermd/libpbe/include/ip.hh +++ /dev/null @@ -1,60 +0,0 @@ -// src/ip.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2004-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_ip_hh -#define libpbe_ip_hh - -#include "Exception.hh" - -#include -#include - -#include -#include - - -namespace pbe { - - -std::ostream& operator<<(std::ostream& s, struct in_addr ip); - - -class HostLookupError: public Exception -{ -private: - std::string hostname; - int error_code; -public: - HostLookupError(std::string h, int e): hostname(h), error_code(e) {} - void report(std::ostream& s) const; -}; - - -struct in_addr get_ip_address(std::string hostname); - -std::string get_own_hostname(void); - -int tcp_client_connect(std::string server_name, int port); - -int local_client_connect(std::string address); - - -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/map_iterators.hh b/extras/anytermd/libpbe/include/map_iterators.hh deleted file mode 100644 index 118fe9747c..0000000000 --- a/extras/anytermd/libpbe/include/map_iterators.hh +++ /dev/null @@ -1,69 +0,0 @@ -// include/map_iterators.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_map_iterators_hh -#define libpbe_map_iterators_hh - -// Provides map_key_iterator and map_value_iterator, which adapt a -// std::map::iterator to iterate over only the keys or values respectively. - -#include -#include - - -namespace pbe { - -template -struct map_key_iterator: - public boost::transform_iterator< __gnu_cxx::select1st, - iter_t > -{ - map_key_iterator() {} - map_key_iterator(iter_t i): - boost::transform_iterator< __gnu_cxx::select1st, iter_t >(i) - {} -}; - -template -static map_key_iterator make_map_key_iterator(const iter_t& i) { - return map_key_iterator(i); -} - - - -template -struct map_value_iterator: - public boost::transform_iterator< __gnu_cxx::select2nd, - iter_t > -{ - map_value_iterator() {} - map_value_iterator(iter_t i): - boost::transform_iterator< __gnu_cxx::select2nd, iter_t >(i) - {} -}; - -template -static map_value_iterator make_map_value_iterator(const iter_t& i) { - return map_value_iterator(i); -} - - -}; - -#endif - diff --git a/extras/anytermd/libpbe/include/markup.hh b/extras/anytermd/libpbe/include/markup.hh deleted file mode 100644 index adfc37042e..0000000000 --- a/extras/anytermd/libpbe/include/markup.hh +++ /dev/null @@ -1,28 +0,0 @@ -// src/markup.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifndef libpbe_markup_hh -#define libpbe_markup_hh - -#include -using namespace std; - - -void markup_uris_emails(string& s); - - -#endif diff --git a/extras/anytermd/libpbe/include/missing_syscalls.hh b/extras/anytermd/libpbe/include/missing_syscalls.hh deleted file mode 100644 index 3e3507db8c..0000000000 --- a/extras/anytermd/libpbe/include/missing_syscalls.hh +++ /dev/null @@ -1,78 +0,0 @@ -// include/missing_syscalls.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef pbe_missing_syscalls_hh -#define pbe_missing_syscalls_hh - -#include -#include -#include -#include - - -#ifdef __NR_futex -inline int futex(int *uaddr, int op, int val, const struct timespec *timeout, int *uaddr2, int val3) -{ - return syscall(__NR_futex,uaddr,op,val,timeout,uaddr2,val3); -} -#endif - -#ifdef __NR_gettid -inline int gettid() -{ - return syscall(__NR_gettid); -} -#endif - -#ifdef __NR_tkill -inline int tkill(int tid, int sig) -{ - return syscall(__NR_tkill,tid,sig); -} -#endif - -#ifdef __NR_delete_module -inline int delete_module(const char* name) -{ - return syscall(__NR_delete_module,name); -} -#endif - - -// These are missing from my glibc, but they may be present in newer versions: - -#ifdef __NR_inotify_init -#define PBE_HAVE_INOTIFY_INIT 1 -inline int inotify_init(void) -{ - return syscall(__NR_inotify_init); -} -#endif - -#ifdef __NR_inotify_add_watch -#define PBE_HAVE_INOTIFY_ADD_WATCH -inline int inotify_add_watch(int fd, const char* pathname, uint32_t mask) -{ - return syscall(__NR_inotify_add_watch,fd,pathname,mask); -} -#endif - - - -#endif - diff --git a/extras/anytermd/libpbe/include/mustfind.hh b/extras/anytermd/libpbe/include/mustfind.hh deleted file mode 100644 index b42979651d..0000000000 --- a/extras/anytermd/libpbe/include/mustfind.hh +++ /dev/null @@ -1,86 +0,0 @@ -// include/mustfind.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_mustfind_hh -#define libpbe_mustfind_hh - - -// pbe::mustfind is an an algorithm like std::find except that it -// throws an exception, pbe::notfound, if it fails to find a match. -// So calling code can rely on the returned iterator pointing to a -// valid element. - -// pbe::mustfind_if does the same thing for std::find_if and pbe::mustsearch -// does the same thing for std::search. - - -#include - - -namespace pbe { - - -struct notfound {}; - - -template -Iter mustfind(Iter first, Iter last, const Comp& val) { - Iter i = std::find(first,last,val); - if (i==last) { - throw notfound(); - } - return i; -} - - -template -Iter mustfind_if(Iter first, Iter last, Pred pred) { - Iter i = std::find_if(first,last,pred); - if (i==last) { - throw notfound(); - } - return i; -} - - -template -Iter1 mustsearch(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2) { - Iter1 i = std::search(first1,last1,first2,last2); - if (i==last1) { - throw notfound(); - } - return i; -} - - -template -Iter1 mustsearch(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Pred pred) { - Iter1 i = std::search(first1,last1,first2,last2,pred); - if (i==last1) { - throw notfound(); - } - return i; -} - - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/parse_http_request.hh b/extras/anytermd/libpbe/include/parse_http_request.hh deleted file mode 100644 index 34b4b2c053..0000000000 --- a/extras/anytermd/libpbe/include/parse_http_request.hh +++ /dev/null @@ -1,44 +0,0 @@ -// include/parse_http_request.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2005-2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_parse_http_request_hh -#define libpbe_parse_http_request_hh - -#include - -#include "HttpRequest.hh" -#include "Exception.hh" - - -namespace pbe { - - -HttpRequest parse_http_request(std::istream& strm); - - -struct HttpRequestSyntaxError: StrException { - HttpRequestSyntaxError(void): - StrException("Syntax error in http request") - {} -}; - - -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/rfcdate.hh b/extras/anytermd/libpbe/include/rfcdate.hh deleted file mode 100644 index 7970e6fa00..0000000000 --- a/extras/anytermd/libpbe/include/rfcdate.hh +++ /dev/null @@ -1,36 +0,0 @@ -// rfcdate.hh -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_rfcdate_hh -#define libpbe_rfcdate_hh - - -#include - - -namespace pbe { - -std::string rfc_date(void); -// Return a date in the format required by RFC2616, RFC1123, -// RFC822 and RFC2822 - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/run_cmd.hh b/extras/anytermd/libpbe/include/run_cmd.hh deleted file mode 100644 index 15c2080ea0..0000000000 --- a/extras/anytermd/libpbe/include/run_cmd.hh +++ /dev/null @@ -1,34 +0,0 @@ -// src/run_cmd.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2005, 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_run_cmd_hh -#define libpbe_run_cmd_hh - -#include - - -namespace pbe { - -std::string run_cmd(std::string cmd, bool& exit_ok); - -std::string run_cmd(std::string cmd); - -}; - - -#endif diff --git a/extras/anytermd/libpbe/include/safe_int.hh b/extras/anytermd/libpbe/include/safe_int.hh deleted file mode 100644 index 18ca41613e..0000000000 --- a/extras/anytermd/libpbe/include/safe_int.hh +++ /dev/null @@ -1,151 +0,0 @@ -// src/safe_int.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -// safe_int: provide an N-bit signed integer (N excludes the sign bit) with overflow -// checking. An exception is thrown if the value overflows. - -// The implementation uses Boost.Integer to supply an integer with at least one more bit -// than we need. This extra guard bit is tested to detect overflow. -// This approach is reasonably efficient, except in the case where the need for the extra -// bit means that we have to use a larger underlying value; for example, safe_int<31> needs -// an int64_t. There is another approach that could work in that case, which is to compare -// the operands before performing the operation; that could be added as a specialisation of -// this template for safe_int<31>, safe_int<15> and safe_int<7>. - -// One of the better resources describing this subject is: -// http://msdn2.microsoft.com/en-us/library/ms972705.aspx - - -#ifndef libpbe_safe_int_hh -#define libpbe_safe_int_hh - -#include "./integer.hpp" -#include - -namespace pbe { - -template // NBITS excludes the sign bit -class safe_int: - boost::operators > -{ -public: - struct overflow: public std::exception { - const char* what() const throw() { return "safe_int overflow"; } - }; - -private: - typedef typename boost::int_t::least val_t; - val_t val; - - void check() { - // If guard bits != sign bit, value has overflowed. - val_t x = val>>NBITS; - if (x==0 || x==-1) { - return; - } - throw overflow(); - } - -public: - safe_int() {} - safe_int(const safe_int& x): val(x.val) {} - - // This can convert from integer or other safe_int types. - // It would be good if we could do a non-checking version when X_T is guaranteed to be - // smaller than NBITS. Is there any template-magic that can do that? (enable_if?) - template - safe_int(X_T x): val(static_cast(x)) { check(); } - - // Implicitly convert to val_t. (Is this a safe thing to do?) - operator val_t() { return val; } - - // These don't need any checking: - bool operator<(const safe_int& x) const { return val>=(const safe_int& x) { val>>=x.val; return *this; } - - // These can be checked using the guard bit: - safe_int& operator+=(const safe_int& x) { val+=x.val; check(); return *this; } - safe_int& operator-=(const safe_int& x) { val-=x.val; check(); return *this; } - - // These need more complex checking: - - // This only works when val_t is <= int32_t. - safe_int& operator*=(const safe_int& x) { - // Do a multiplication that is certain to have enough bits for the result: - typedef typename boost::int_t<2*NBITS+1>::least twice_val_t; - twice_val_t tw = static_cast(val) * static_cast(x.val); - // Overflow if any too-significant bits are set: - twice_val_t r = tw >> NBITS; - if (r!=0 && r!=-1) { - throw overflow(); - } - val = static_cast(tw); - return *this; - } - - // The only case where division can overflow is -MAX/-1. - // We could also detect division by zero here if we wanted to. - safe_int& operator/=(const safe_int& x) { - if (x.val==-1 && val==(1<>(NBITS-x.val); - if (r!=0 && r!=-1) { - throw overflow(); - } - val <<= x.val; - return *this; - } - - // These are implemented in terms of other operators, which do checking: - safe_int& operator++() { return (*this) += 1; } - safe_int& operator--() { return (*this) -= 1; } - - // (Does Boost.Operators provide unary operator- ?) - // safe_int operator-() { ... } - - - // It would probably be reasonable to allow a different type for the RHS of most of these - // operators. Boost.Integer has some code to do this, but I have not investigated it. - -}; - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/scoped_true.hh b/extras/anytermd/libpbe/include/scoped_true.hh deleted file mode 100644 index b6e1716ecd..0000000000 --- a/extras/anytermd/libpbe/include/scoped_true.hh +++ /dev/null @@ -1,44 +0,0 @@ -// include/scoped_true.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef pbe_scoped_true_hh -#define pbe_scoped_true_hh - -// This file provides a simple class that sets a boolean to true when it -// is constructed and to false when it is destructed. - - -namespace pbe { - -class scoped_true { - bool& var; -public: - scoped_true(bool& var_): - var(var_) - { - var = true; - } - ~scoped_true() { - var = false; - } -}; - -}; - -#endif - diff --git a/extras/anytermd/libpbe/include/segv_backtrace.hh b/extras/anytermd/libpbe/include/segv_backtrace.hh deleted file mode 100644 index e49a167d9f..0000000000 --- a/extras/anytermd/libpbe/include/segv_backtrace.hh +++ /dev/null @@ -1,30 +0,0 @@ -// include/segv_backtrace.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/trunk -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_segv_backtrace_hh -#define libpbe_segv_backtrace_hh - - -// Call this to install a signal handler that will report a -// backtrace to stderr on segfault, bus error, illegal instruction -// and FP exception. - -void get_backtrace_on_segv(); - - -#endif diff --git a/extras/anytermd/libpbe/include/select.hh b/extras/anytermd/libpbe/include/select.hh deleted file mode 100644 index d0964281ea..0000000000 --- a/extras/anytermd/libpbe/include/select.hh +++ /dev/null @@ -1,34 +0,0 @@ -// src/select.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifndef libpbe_select_hh -#define libpbe_select_hh - -// User-friendly wrappers around select(). -// Take various numbers of file descriptors and an optional timeout. -// Naming scheme is "r" for "readable", "t" for "timeout". -// i.e. select_rr waits for either of two fds to be readable. -// The return value is the file descriptor that has become useable, -// i.e. select_rr(4,9) can return 4 or 9. If the timeout expires, -// -1 is returned. -2 can also be returned but I can't recall when. - -int select_r (int fd1); -int select_rr(int fd1, int fd2); -int select_rt(int fd1, float timeout); - - -#endif diff --git a/extras/anytermd/libpbe/include/sleep.hh b/extras/anytermd/libpbe/include/sleep.hh deleted file mode 100644 index 8bae55de25..0000000000 --- a/extras/anytermd/libpbe/include/sleep.hh +++ /dev/null @@ -1,58 +0,0 @@ -// include/sleep.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_sleep_hh -#define libpbe_sleep_hh - -#include - -#include - -#include "Exception.hh" - - -namespace pbe { - -inline void sleep(double t) -{ - double whole_secs; - double frac_secs = modf(t, &whole_secs); - struct timespec ts; - ts.tv_sec = static_cast(whole_secs); - ts.tv_nsec = static_cast(frac_secs*1e9); - struct timespec rem; - while (1) { - int rc = nanosleep(&ts,&rem); - if (rc==0) { - return; - } else { - if (errno==EINTR) { - ts = rem; - continue; - } - throw_ErrnoException("nanosleep"); - } - } -} - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/sort_by.hh b/extras/anytermd/libpbe/include/sort_by.hh deleted file mode 100644 index e9856379f5..0000000000 --- a/extras/anytermd/libpbe/include/sort_by.hh +++ /dev/null @@ -1,60 +0,0 @@ -// include/sort_by.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_sort_by_hh -#define libpbe_sort_by_hh - -// Provides a function sort_by, which is like std::sort except that it -// takes a pointer to member to indicate which field of a struct it should -// use for sorting. -// Typical usage: -// struct T { int a; ..... }; -// std::container c; -// sort_by(c.begin(),c.end(),&T::a); - - -#include - - -namespace pbe { - -template -struct compare_data_member { - data_member_ptr_t data_member_ptr; - compare_data_member(data_member_ptr_t data_member_ptr_): - data_member_ptr(data_member_ptr_) - {} - bool operator()(const obj_t& a, const obj_t& b) - { - return a.*data_member_ptr < b.*data_member_ptr; - } -}; - -template -void sort_by(iter_t begin, iter_t end, data_member_ptr_t data_member_ptr) { - std::sort(begin,end, - compare_data_member (data_member_ptr)); -} - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/sort_by_pointee.hh b/extras/anytermd/libpbe/include/sort_by_pointee.hh deleted file mode 100644 index 97f3202f9f..0000000000 --- a/extras/anytermd/libpbe/include/sort_by_pointee.hh +++ /dev/null @@ -1,60 +0,0 @@ -// include/sort_by_pointee.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_sort_by_pointee_hh -#define libpbe_sort_by_pointee_hh - -// Provides a function sort_by_pointee, which is like std::sort except that it -// takes a pointer to member to indicate which field of a struct it should -// use for sorting. -// Typical usage: -// struct T { int a; ..... }; -// std::container c; -// sort_by_pointee(c.begin(),c.end(),&T::a); - - -#include - - -namespace pbe { - -template -struct compare_ptr_data_member { - data_member_ptr_t data_member_ptr; - compare_ptr_data_member(data_member_ptr_t data_member_ptr_): - data_member_ptr(data_member_ptr_) - {} - bool operator()(ptr_t a, ptr_t b) - { - return a->*data_member_ptr < b->*data_member_ptr; - } -}; - -template -void sort_by_pointee(iter_t begin, iter_t end, data_member_ptr_t data_member_ptr) { - std::sort(begin,end, - compare_ptr_data_member (data_member_ptr)); -} - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/sorted_ptr_vector.hh b/extras/anytermd/libpbe/include/sorted_ptr_vector.hh deleted file mode 100644 index 16f8090aec..0000000000 --- a/extras/anytermd/libpbe/include/sorted_ptr_vector.hh +++ /dev/null @@ -1,65 +0,0 @@ -// include/sorted_ptr_vector.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_sorted_ptr_vector_hh -#define libpbe_sorted_ptr_vector_hh - -// Provides a vector of pointers, which is ordered according to one of -// the fields in the pointed-to struct. It is sorted after construction. - -#include -#include - -#include "sort_by_pointee.hh" - - -namespace pbe { - - -template -class sorted_ptr_vector { - - typedef std::vector vec_t; - vec_t vec; - -public: - // default ctor is not very useful: - sorted_ptr_vector() {} - // default copy ctor is OK - - // This is the useful one: - template - sorted_ptr_vector(iter_t begin, iter_t end): - vec(begin,end) - { - sort_by_pointee(vec.begin(),vec.end(),data_member_ptr); - } - - typedef typename vec_t::const_iterator const_iterator; - - const_iterator begin() const { return vec.begin(); } - const_iterator end() const { return vec.end(); } - -}; - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/sorted_vector.hh b/extras/anytermd/libpbe/include/sorted_vector.hh deleted file mode 100644 index 2f3b150a99..0000000000 --- a/extras/anytermd/libpbe/include/sorted_vector.hh +++ /dev/null @@ -1,63 +0,0 @@ -// include/sorted_vector.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_sorted_vector_hh -#define libpbe_sorted_vector_hh - -// Provides a vector, which is sorted immediately after construction -// according to a supplied less-than predicate, and is then const. - -#include -#include - - -namespace pbe { - - -template -class sorted_vector { - - typedef std::vector vec_t; - vec_t vec; - -public: - // default ctor is not very useful: - sorted_vector() {} - // default copy ctor is OK - - // This is the useful one: - template - sorted_vector(iter_t begin, iter_t end, COMP comp = COMP()): - vec(begin,end) - { - std::sort(vec.begin(),vec.end(),comp); - } - - typedef typename vec_t::const_iterator const_iterator; - - const_iterator begin() const { return vec.begin(); } - const_iterator end() const { return vec.end(); } - -}; - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/strector.hh b/extras/anytermd/libpbe/include/strector.hh deleted file mode 100644 index cfebf78897..0000000000 --- a/extras/anytermd/libpbe/include/strector.hh +++ /dev/null @@ -1,93 +0,0 @@ -// include/strector.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_strector_hh -#define libpbe_strector_hh - -// strector: stretchy-vector -// ------------------------- -// -// Provides a vector which stretches when new elements are accessed -// using operator[]. -// -// Since the stretch may cause the vector to re-allocate, operator[] -// on a mutable strector invalidates iterators, references and pointers -// to its elements unless the index is less than capacity(). -// -// What should operator[] do for a const strector when you access a -// beyond-the-end element? It can't stretch the vector. It could be -// undefined (like vector). It could throw. It could return a default -// T by value - but then it would have to return by value in all cases. -// The option that I've chosen is to return a const reference to a static -// T. This is broken if you try to compare addresses of elements. It -// is also broken if you expected the reference to change when you wrote -// to that element via a mutable reference to the strector, but that would -// be broken anyway unless size() < index < capacity() due to the -// iterator-invalidation rules. The use of a static may also have -// thread-safety problems. -// -// An additional optional constructor parameter allows you to specify a value -// used for new elements when the vector is resized during operator[] and -// when a beyond-the-end element is read as above. - - -#include - - -namespace pbe { - - -template < typename T, typename ALLOC=std::allocator > -class strector: public std::vector { - typedef std::vector base_t; - const T default_t; - -public: - // Same ctors as std::vector: - strector() {} - strector(typename base_t::size_type n): base_t(n) {} - strector(typename base_t::size_type n, const T& t): base_t(n,t), default_t(t) {} - // The copy-ctor takes a base_t, so we can copy from another strector or - // from a compatible std::vector: - strector(const base_t& other): base_t(other) {} - template - strector(iter first, iter last): base_t(first,last) {} - - // Additional ctor to specify default_t: - explicit strector(const T& default_t_): default_t(default_t_) {} - - typename base_t::reference operator[](typename base_t::size_type n) { - if (n>=base_t::size()) { - base_t::resize(n+1,default_t); - } - return base_t::operator[](n); - } - typename base_t::const_reference operator[](typename base_t::size_type n) const { - if (n>=base_t::size()) { - return default_t; - } - return base_t::operator[](n); - } -}; - - -}; - - -#endif - diff --git a/extras/anytermd/libpbe/include/string_qsort.hh b/extras/anytermd/libpbe/include/string_qsort.hh deleted file mode 100644 index c797c017a8..0000000000 --- a/extras/anytermd/libpbe/include/string_qsort.hh +++ /dev/null @@ -1,213 +0,0 @@ -// include/string_qsort.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott -// This file is distributed under the terms of the Boost Software License v1.0. -// Please see http://www.boost.org/LICENSE_1_0.txt or the accompanying file BOOST_LICENSE. - -// string_qsort is a function template that sorts a range of strings using the -// quicksort algorithm, and avoids unnecessary comparisons of string prefixes that -// are already known to be equal while doing so. The range iterators must be -// random-access and the "strings" they refer to can be any random-access containers. -// -// When the input consists of strings with frequent long common prefixes this can -// give a performance advantage. However in other cases there is no advantage and -// this implementation's defects then make it slower than std::sort. Those -// defects are dumb pivot selection, dumb character comparison, no introsort-style -// fallback mode, and general lack of optimisation. - - -#ifndef libpbe_string_qsort_hh -#define libpbe_string_qsort_hh - -#include -#include -#include -#include - - -namespace pbe { - - -template -ITER choose_pivot(ITER begin, ITER end, std::size_t /*equal_prefix_length*/) -{ - // We just choose the middle of the range which gives good results for an - // already-sorted range. - // A smart version would do something clever especially when end-begin is large, - // e.g. choose a set of candidate pivots and use the middle one. - // (It's a shame we can't just use std::sort's version.) - // The desire to maximise the prefix length could also be taken into account. - return begin + (end-begin)/2; -} - - -template -bool chars_equal_at_offset(ITER begin, ITER end, std::size_t offset) -{ - // Is the character at [offset] equal for all strings in the range begin to end? - - if (begin->size() <= offset) { - return false; - } - - typedef typename ITER::value_type STRING; - typedef typename STRING::value_type CHAR; - CHAR c = (*begin)[offset]; - for (ITER i = begin; i != end; ++i) { - if (i->size() <= offset) { - return false; - } - if ((*i)[offset] != c) { - return false; - } - } - return true; -} - - -template -bool less_with_prefix(const STRING& a, const STRING& b, std::size_t equal_prefix_length) -{ - // Is a < b ? We know that the fist equal_prefix_length characters of a and b are equal. - - typename STRING::const_iterator ai = a.begin()+equal_prefix_length; - typename STRING::const_iterator bi = b.begin()+equal_prefix_length; - - // We can make this code a bit faster by avoiding the need to check for end-of-input - // on both strings on every iteration; instead we determine which is shorter up front - // and check only that one. - - if (a.size() >= b.size()) { - - while (1) { - if (bi==b.end()) { - return false; - } - if (*ai != *bi) { - return *ai < *bi; - } - ++ai; - ++bi; - } - - } else { - - while (1) { - if (ai==a.end()) { - return true; - } - if (*ai != *bi) { - return *ai < *bi; - } - ++ai; - ++bi; - } - - } -} - - -bool less_with_prefix(const std::string& a, const std::string& b, std::size_t equal_prefix_length) -{ - // We know that the characters are in contiguous memory for std::string so we can use memcmp(). - if (a.size() >= b.size()) { - return memcmp(&(a[equal_prefix_length]), &(b[equal_prefix_length]), b.size()-equal_prefix_length) == -1; - } else { - return memcmp(&(a[equal_prefix_length]), &(b[equal_prefix_length]), a.size()-equal_prefix_length) != 1; - } -} - -bool less_with_prefix(const std::vector& a, const std::vector& b, std::size_t equal_prefix_length) -{ - // We know that the characters are in contiguous memory for std::vector so we can use memcmp(). - if (a.size() >= b.size()) { - return memcmp(&(a[equal_prefix_length]), &(b[equal_prefix_length]), b.size()-equal_prefix_length) == -1; - } else { - return memcmp(&(a[equal_prefix_length]), &(b[equal_prefix_length]), a.size()-equal_prefix_length) != 1; - } -} - - -template -inline void string_qsort(ITER begin, ITER end, std::size_t equal_prefix_length=0) -{ - if (end-begin < 2) { - // Nothing to do if there are 0 or 1 elements. - return; - } - - if (end-begin == 2) { - // We can save some effort in this case. - if (less_with_prefix(*(begin+1), *begin, equal_prefix_length)) { - std::swap(*(begin+1), *begin); - } - return; - } - - if (end-begin == 3) { - /// The benefit from this is barely measureable. - if (less_with_prefix(*(begin+1), *begin, equal_prefix_length)) { - // BAC CAB CBA - if (less_with_prefix(*(begin+2), *(begin+1), equal_prefix_length)) { - // CBA - std::swap(*begin, *(begin+2)); - } else { - // BAC CAB - if (less_with_prefix(*(begin+2), *begin, equal_prefix_length)) { - // CAB - std::swap(*begin, *(begin+1)); - std::swap(*(begin+1), *(begin+2)); - } else { - // BAC - std::swap(*begin, *(begin+1)); - } - } - } else { - // ABC ACB BCA - if (less_with_prefix(*(begin+2), *(begin+1), equal_prefix_length)) { - // ACB BCA - if (less_with_prefix(*(begin+2), *begin, equal_prefix_length)) { - // BCA - std::swap(*begin, *(begin+1)); - std::swap(*begin, *(begin+2)); - } else { - // ACB - std::swap(*(begin+1), *(begin+2)); - } - } else { - // ABC - } - } - return; - } - - // Increase the equal prefix length if possible. - // This is a breadth-first method. Depth-first is an alternative that - // would have better locality but could waste effort for some inputs. - // (Is there a way to do this while partitioning in the previous pass?) - while (chars_equal_at_offset(begin,end,equal_prefix_length)) { - ++equal_prefix_length; - } - - // This is standard quicksort. - ITER pivot_i = choose_pivot(begin,end,equal_prefix_length); - std::swap(*pivot_i, *(end-1)); - pivot_i = end-1; - ITER s = begin; - for (ITER i = begin; i != pivot_i; ++i) { - if (less_with_prefix(*i,*pivot_i,equal_prefix_length)) { - std::swap(*i, *s); - ++s; - } - } - swap(*s, *pivot_i); - - string_qsort(begin, s, equal_prefix_length); - string_qsort(s+1, end, equal_prefix_length); -} - - -}; - -#endif - diff --git a/extras/anytermd/libpbe/include/utils.hh b/extras/anytermd/libpbe/include/utils.hh deleted file mode 100644 index 3fd15e8dfd..0000000000 --- a/extras/anytermd/libpbe/include/utils.hh +++ /dev/null @@ -1,81 +0,0 @@ -// src/utils.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2004-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef libpbe_utils_hh -#define libpbe_utils_hh - -#include "StringTransformer.hh" - -#include -//#include - - -namespace pbe { - -//string int_to_string(int i); -//string float_to_string(float f); -//string double_to_string(double f); - -//int string_to_int(string s); -//float string_to_float(string s); -//double string_to_double(string s); - -int hex_string_to_int(string s); - -int maybe_hex_string_to_int(string s); - -extern std::string escape_for_dquoted_string(std::string s); -extern std::string escape_for_squoted_string(std::string s); -extern std::string escape_for_regexp(std::string s); - -//string escape_for_xpath_string(string s); - -//extern const StringTransformer& to_upper; - -//extern const StringTransformer& to_lower; - -//extern const StringTransformer& lf_to_crlf; - -template // contaier -std::string join(const T& strs, std::string joiner) { - if (strs.empty()) { - return ""; - } - typename T::const_iterator i = strs.begin(); - std::string s = *i; - ++i; - while (i != strs.end()) { - s += joiner; - s += *i; - ++i; - } - return s; -} - -//string trim_whitespace (string s); - -//string normalise_whitespace (string s); - -//bool starts_with ( string s, string prefix ); - -//void check_alphanumeric ( string s ); -//void check_numeric ( string s ); - -}; - -#endif diff --git a/extras/anytermd/libpbe/scripts/iana/Makefile b/extras/anytermd/libpbe/scripts/iana/Makefile deleted file mode 100644 index ecb180769d..0000000000 --- a/extras/anytermd/libpbe/scripts/iana/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -default_target: all - -iana_character_sets: - wget -O $@ http://www.iana.org/assignments/character-sets - -charsets.dat: iana_character_sets mk_charsets_dat.awk - awk -f mk_charsets_dat.awk iana_character_sets > charsets.dat - -charset_t_enum_body.hh: charsets.dat mk_charset_t_enum_body.awk - awk -f mk_charset_t_enum_body.awk charsets.dat > charset_t_enum_body.hh - -charset_iana_names_body.cc: charsets.dat mk_charset_iana_names_body.awk - awk -f mk_charset_iana_names_body.awk charsets.dat > charset_iana_names_body.cc - -charset_mime_names_body.cc: charsets.dat mk_charset_mime_names_body.awk - awk -f mk_charset_mime_names_body.awk charsets.dat > charset_mime_names_body.cc - -charset_lookup_body.cc: charsets.dat mk_charset_lookup_body.sh - ./mk_charset_lookup_body.sh < charsets.dat > charset_lookup_body.cc - -all: iana_character_sets charsets.dat charset_t_enum_body.hh \ - charset_iana_names_body.cc charset_mime_names_body.cc charset_lookup_body.cc - -FORCE: - -.PHONY: FORCE default_target all - diff --git a/extras/anytermd/libpbe/scripts/iana/iana-diffs.patch b/extras/anytermd/libpbe/scripts/iana/iana-diffs.patch deleted file mode 100644 index 02f8cec3f6..0000000000 --- a/extras/anytermd/libpbe/scripts/iana/iana-diffs.patch +++ /dev/null @@ -1,19 +0,0 @@ -*** iana_character_sets.orig 2008-02-14 22:42:58.000000000 +0000 ---- iana_character_sets 2008-02-14 22:43:36.000000000 +0000 -*************** -*** 899,910 **** ---- 899,912 ---- - Source: the 2-octet Basic Multilingual Plane, aka Unicode - this needs to specify network byte order: the standard - does not specify (it is a 16-bit integer space) -+ Alias: UCS-2 - Alias: csUnicode - - Name: ISO-10646-UCS-4 - MIBenum: 1001 - Source: the full code space. (same comment about byte order, - these are 31-bit numbers. -+ Alias: UCS-4 - Alias: csUCS4 - - Name: ISO-10646-UCS-Basic diff --git a/extras/anytermd/libpbe/scripts/iana/mk_charset_iana_names_body.awk b/extras/anytermd/libpbe/scripts/iana/mk_charset_iana_names_body.awk deleted file mode 100644 index c7a051c9e1..0000000000 --- a/extras/anytermd/libpbe/scripts/iana/mk_charset_iana_names_body.awk +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN { print "const char * const charset_iana_names[] = {"; } -NF>0 { printf(" \"%s\",\n",$1); } -END { print " NULL"; - print "};"; } - diff --git a/extras/anytermd/libpbe/scripts/iana/mk_charset_lookup_body.sh b/extras/anytermd/libpbe/scripts/iana/mk_charset_lookup_body.sh deleted file mode 100755 index 6e914014d5..0000000000 --- a/extras/anytermd/libpbe/scripts/iana/mk_charset_lookup_body.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -awk ' -function to_ident(n) { - n = tolower(n); - gsub("[-:.()+_]","_",n); - return n; -} -function to_key(n) { - n = tolower(n); - n = gensub("([[:digit:]])[-:.()+_]+([[:digit:]])","\\1@\\2","g",n); - n = gensub("([[:digit:]])[-:.()+_]+([[:digit:]])","\\1@\\2","g",n); - gsub("[-:.()+_]","",n); - gsub("@","_",n); - return n; -} -NF>0 { ident = to_ident($1); - for (i=1; i<=NF; i++) { - if ($i != "*") { - aliases[to_key($i)] = 1; - } - } - for (A in aliases) { - printf(" {\"%s\", cs::%s},\n", A, ident); - } - delete aliases; - } -' | -LC_ALL=C sort -t '"' - - diff --git a/extras/anytermd/libpbe/scripts/iana/mk_charset_mime_names_body.awk b/extras/anytermd/libpbe/scripts/iana/mk_charset_mime_names_body.awk deleted file mode 100644 index 017dacff46..0000000000 --- a/extras/anytermd/libpbe/scripts/iana/mk_charset_mime_names_body.awk +++ /dev/null @@ -1,14 +0,0 @@ -BEGIN { print "const char * const charset_mime_names[] = {"; } -NF>0 { N=$1; - for (i=2; i<=NF; i++) { - if ($i=="*") { - i++; - N=$i; - break; - } - } - printf(" \"%s\",\n",N); - } -END { print " NULL"; - print "};"; } - diff --git a/extras/anytermd/libpbe/scripts/iana/mk_charset_t_enum_body.awk b/extras/anytermd/libpbe/scripts/iana/mk_charset_t_enum_body.awk deleted file mode 100644 index e3f768c875..0000000000 --- a/extras/anytermd/libpbe/scripts/iana/mk_charset_t_enum_body.awk +++ /dev/null @@ -1,46 +0,0 @@ -function to_ident(n) { - n = tolower(n); - gsub("[-:.()+]","_",n); - return n; -} -function add_aliases_rec(pref,suff, pos,chunk,newsuff) { - pos = index(suff,"_"); - if (pos>0) { - chunk = substr(suff,0,pos-1); - newsuff = substr(suff,pos+1); - if (pref !~ "[[:digit:]]$" || suff !~ "^[[:digit:]]") { - add_aliases_rec(pref chunk, newsuff); - } - if (pref!="") { - add_aliases_rec(pref "_" chunk, newsuff); - } - } else if (pref=="") { - aliases[suff]=1; - } else { - aliases[pref "_" suff]=1; - if (pref !~ "[[:digit:]]$" || suff !~ "^[[:digit:]]") { - aliases[pref suff]=1; - } - } -} -function add_aliases(A) { - add_aliases_rec("",A); -} -BEGIN { print "enum charset_t {"; } -NF>0 { CS=to_ident($1); - printf(" %s,\n",CS); - add_aliases(CS); - for (i=2; i<=NF; i++) { - if ($i != "*") { - A=to_ident($i); - add_aliases(A); - } - } - for (A in aliases) { - if (A!=CS && A !~ /^[[:digit:]]/) { - printf(" %-26s= %s,\n",A,CS); - } - } - delete aliases; - } -END { print " max_charset"; print "};"; } diff --git a/extras/anytermd/libpbe/scripts/iana/mk_charsets_dat.awk b/extras/anytermd/libpbe/scripts/iana/mk_charsets_dat.awk deleted file mode 100644 index 34734a20eb..0000000000 --- a/extras/anytermd/libpbe/scripts/iana/mk_charsets_dat.awk +++ /dev/null @@ -1,4 +0,0 @@ -/^Name:/ { printf("\n%s",$2); } -/^Alias:/ && $2!="None" && /preferred MIME name/ { printf("\t* %s",$2); } -/^Alias:/ && $2!="None" && !/preferred MIME name/ { printf("\t%s",$2); } - diff --git a/extras/anytermd/libpbe/scripts/unicode/Makefile b/extras/anytermd/libpbe/scripts/unicode/Makefile deleted file mode 100644 index 28cd6dddbf..0000000000 --- a/extras/anytermd/libpbe/scripts/unicode/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -iso8859_tables_body.cc: FORCE - ./mk_c_tables.sh > $@ - - -FORCE: - -.PHONY: FORCE diff --git a/extras/anytermd/libpbe/scripts/unicode/download_tables.sh b/extras/anytermd/libpbe/scripts/unicode/download_tables.sh deleted file mode 100755 index f6832d265e..0000000000 --- a/extras/anytermd/libpbe/scripts/unicode/download_tables.sh +++ /dev/null @@ -1,20 +0,0 @@ -for i in \ -ISO8859/8859-2.TXT \ -ISO8859/8859-3.TXT \ -ISO8859/8859-4.TXT \ -ISO8859/8859-5.TXT \ -ISO8859/8859-6.TXT \ -ISO8859/8859-7.TXT \ -ISO8859/8859-8.TXT \ -ISO8859/8859-9.TXT \ -ISO8859/8859-10.TXT \ -ISO8859/8859-11.TXT \ -ISO8859/8859-13.TXT \ -ISO8859/8859-14.TXT \ -ISO8859/8859-15.TXT \ -ISO8859/8859-16.TXT -do - f="tables/$i" - mkdir -p `dirname $f` - wget "http://unicode.org/Public/MAPPINGS/$i" -O $f -done diff --git a/extras/anytermd/libpbe/scripts/unicode/make_to_ascii_letters_tables.sh b/extras/anytermd/libpbe/scripts/unicode/make_to_ascii_letters_tables.sh deleted file mode 100755 index 7480d047fd..0000000000 --- a/extras/anytermd/libpbe/scripts/unicode/make_to_ascii_letters_tables.sh +++ /dev/null @@ -1,280 +0,0 @@ -# scripts/unicode/make_to_ascii_letters_tables.sh -# This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -# (C) 2008 Philip Endecott - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -# Download the Unicode character database: -# wget http://www.unicode.org/Public/5.1.0/ucd/UnicodeData.txt - -# Extract the decompositions: -cat UnicodeData.txt | -awk -F ';' '$6!="" {print $1,$6}' | -awk '/ decompositions - -# Each line in decompositions starts with the source character and is followed by the -# sequence of characters that it may be replaced by. This replacement needs to be -# applied recursively: -while true -do - -awk '{if (ARGIND==1) {d=""; for(i=2;i<=NF;i++) {d = d $i " "}; dec[$1]=d;} - else {printf("%s ",$1); - for(i=2;i<=NF;i++) { - if ($i in dec) {printf("%s",dec[$i]);} else {printf("%s ",$i);} - } - printf("\n");} - }' decompositions decompositions > new_decompositions - -if cmp decompositions new_decompositions -then - break -fi - -mv new_decompositions decompositions - -done - -mv new_decompositions full_decompositions - - -# For the puposes of converting strings to text searchable ASCII equivalents, we're only -# interested in determining the ASCII letter base characters. Strip all the other characters -# in the expansion, and if none are left remove the line. - -awk '{printf("%s ",$1); - for(i=2;i<=NF;i++) { - n=strtonum("0x" $i); - if (n>=65 && n<=90 || n>=97 && n<=122) - printf("%s ",$i) - } - printf("\n"); - }' full_decompositions | -awk '{if (NF>1) print}' | - - -# Now convert the letter codes to actual letters, and convert to lower case. - -awk '{printf("%s \"",$1); - for(i=2;i<=NF;i++) { - v=strtonum("0x" $i); - c=sprintf("%c",v); - printf("%c",tolower(c)); - } - printf("\"\n"); - }' | - -# Add 'identity' conversions for a-z and 'tolower' conversions for A-Z. - -awk 'BEGIN {for(i=65;i<=90;i++) printf("%04X \"%c\"\n",i,i+32); - for(i=97;i<=122;i++) printf("%04X \"%c\"\n",i,i);} - {print}' > all_decompositions - - -# Add some more local decompositions. - -cat >>all_decompositions <(page ".d0")}' all_decompositions - - -# Reformat them as struct initialisers: - -for i in *.d0 -do - -n=`basename $i .d0` - -echo -n "char_expansion_page_${n}_t to_ascii_letters_page_${n} [] = {"; - -awk '{n=strtonum("0x" $1); a[n%256]=$2;} - END {for(i=0;i<256;i++) { - if (i in a) printf("%s, ",a[i]); else printf("\"\", "); - } - printf("};\n") - }' $i - -done > to_ascii_letters_tables.cc - - diff --git a/extras/anytermd/libpbe/scripts/unicode/mk_c_tables.sh b/extras/anytermd/libpbe/scripts/unicode/mk_c_tables.sh deleted file mode 100755 index 475d0b4289..0000000000 --- a/extras/anytermd/libpbe/scripts/unicode/mk_c_tables.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -echo "iso8859_table_t iso8859_tables[] = {" - -for n in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 -do - if [ $n == 12 ] - then - echo " // ISO-8859-12 does not exist" - echo " {}," - else - echo " // ISO-8859-${n}" - echo -n " {" - awk 'BEGIN { L = -1; } - !/^#/ && !/^ *$/ { - N = strtonum($1); U = $2; - if (N < L) { print "Table is out of order"; exit(1); } - while (L - -#include -#include - -#ifdef __OpenBSD__ -// Why is this needed? -#include -#endif - -using namespace std; -using namespace pbe; - - -class CgiError: public Exception { -private: - string msg; -public: - CgiError(string m): msg(m) {} - void report(ostream& s) const { - s << "Error while decoding CGI input: " << msg << endl; - } -}; - - -static string uri_unescape(string esc) -{ - string unesc; - string::size_type start=0; - while(start(hex_string_to_int(esc.substr(end+1,2))); - start=end+3; - } - } - return unesc; -} - - -class MimeHeader { -private: - ci_string name; - string value; - typedef map params_t; - params_t params; -public: - - MimeHeader(string s) - { - const string::size_type colon_pos = s.find(':'); - if (colon_pos==s.npos) { - throw CgiError("Malformed MIME header; no colon"); - } - name = s.substr(0,colon_pos).c_str(); - const string value_and_params = s.substr(colon_pos+1); - StringSplitterSeq splitter ( value_and_params, ";" ); - value = boost::algorithm::trim_copy(*splitter); - ++splitter; - while (!splitter.exhausted()) { - const string param = *splitter; - const unsigned int equals_pos = param.find('='); - const ci_string pname = boost::algorithm::trim_copy(param.substr(0,equals_pos)).c_str(); - string pvalue = boost::algorithm::trim_copy(param.substr(equals_pos+1)); - if (pvalue[0]=='\"' && pvalue[pvalue.size()-1]=='\"') { - pvalue=pvalue.substr(1,pvalue.size()-2); - } - params.insert(make_pair(pname,pvalue)); - ++splitter; - } - } - - ci_string get_name(void) const { return name; } - string get_value(void) const { return value; } - string get_param(ci_string name) const - { - params_t::const_iterator i = params.find(name); - if (i==params.end()) { - throw CgiError("No such header \""+string(name.c_str())+"\""); - } else { - return i->second; - } - } -}; - - - -void CgiParams::load(void) -{ - const char* method_c = getenv("REQUEST_METHOD"); - if (!method_c) { - throw CgiError("REQUEST_METHOD not set"); - } - const string method = method_c; - - // Normally you can assume that GET is accompanied with parameters - // in the QUERY_STRING, while POST is accompanied with parameters in - // the request body. But I now sometimes use POST requests with - // GET-style parameters and no body, so this code looks at the - // QUERY_STRING in all cases, and does not reject an empty body. If - // it finds more than set of parameters they will be merged. - - const char* query_c = getenv("QUERY_STRING"); - if (query_c) { - const string query = query_c; - init_from_urlencoded(query); - } else { - if (method=="GET") { - throw CgiError("QUERY_STRING not set in GET request"); - } - } - - if (method=="POST") { - - // N.B. The CGI spec says that the server is not required to send EOF - // after the POST data. We should really look at the CONTENT_LENGTH - // environment variable to find how much we should read. - // (This does seem to work with Apache however.) - string input; - char buf[1024]; - int nr; - do { - nr = read(0,buf,sizeof(buf)); - input.append(buf,nr); - } while (nr>0); - - const char* enctype_c = getenv("CONTENT_TYPE"); - if (!enctype_c) { - return; - } - const string enctype = enctype_c; - - const MimeHeader enctype_hdr("content-type: "+enctype); - - if (enctype_hdr.get_value()=="application/x-www-form-urlencoded") { - init_from_urlencoded(input); - } else if (enctype_hdr.get_value()=="multipart/form-data") { - const string boundary = enctype_hdr.get_param("boundary"); - init_from_multipart("\r\n"+input,boundary); - } else { - throw CgiError("Unknown content-type \""+enctype_hdr.get_value()+"\""); - } - - } -} - - -void CgiParams::init_from_urlencoded(string query_string) -{ - if (query_string=="") { - return; - } - for ( StringSplitterAny splitter ( query_string, "&;" ); - !splitter.exhausted(); ++splitter ) { - string key_value = *splitter; - string::size_type equals_pos = key_value.find('='); - if (equals_pos==key_value.npos) { - throw CgiError("Query string \""+query_string+"\" malformed"); - } - string key_esc = key_value.substr(0,equals_pos); - string key = uri_unescape(key_esc); - string value_esc = key_value.substr(equals_pos+1); - string value = uri_unescape(value_esc); - insert(make_pair(key,value)); - } -} - - -void CgiParams::init_from_multipart(string input, string boundary) -{ - StringSplitterSeq splitter(input,"\r\n--"+boundary); - ++splitter; - - while(!splitter.exhausted()) { - const string pre_section = *splitter; - if (pre_section.substr(0,2)=="--") { - break; - } - - unsigned int nl_pos = pre_section.find_first_not_of(" \t"); - if (pre_section.substr(nl_pos,2)!="\r\n") { - throw CgiError("MIME boundary not followed by newline"); - } - const string section = pre_section.substr(nl_pos+2); - const string::size_type blank_line_pos = section.find("\r\n\r\n"); - if (blank_line_pos==section.npos) { - throw CgiError("MIME section has no blank line"); - } - const string header = section.substr(0,blank_line_pos); - const string body = section.substr(blank_line_pos+4); - - string name=""; - - for (StringSplitterSeq headersplit(header,"\r\n"); - !headersplit.exhausted(); ++headersplit) { - const string headerline = *headersplit; - MimeHeader hdr(headerline); - if (hdr.get_name()=="content-disposition") { - if (hdr.get_value()=="form-data") { - name = hdr.get_param("name"); - } - } - if (hdr.get_name()=="content-transfer-encoding") { - throw CgiError("Content transfer encodings are not supported"); - } - } - - if (name=="") { - throw CgiError("No name found"); - } - - insert(make_pair(name,body)); - ++splitter; - } -} - - -string CgiParams::get(string name) const -{ - const_iterator i = find(name); - if (i!=end()) { - return i->second; - } else { - throw CgiError("Parameter "+name+" not found"); - } -} - - -string CgiParams::get_default(string name, string def) const -{ - const_iterator i = find(name); - if (i!=end()) { - return i->second; - } else { - return def; - } -} - diff --git a/extras/anytermd/libpbe/src/CgiVars.cc b/extras/anytermd/libpbe/src/CgiVars.cc deleted file mode 100644 index f89c417808..0000000000 --- a/extras/anytermd/libpbe/src/CgiVars.cc +++ /dev/null @@ -1,76 +0,0 @@ -// src/CgiVars.hh -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include "CgiVars.hh" - -#include - -using namespace std; - - -void CgiVars::setvar(const char* varname) -{ - const char* envvar = getenv(varname); - if (envvar) { - (*this)[varname]=envvar; - } else { - (*this)[varname]=""; - } -} - - -void CgiVars::load(void) -{ - setvar("SERVER_SOFTWARE"); - setvar("SERVER_NAME"); - setvar("GATEWAY_INTERFACE"); - setvar("SERVER_PROTOCOL"); - setvar("SERVER_PORT"); - setvar("REQUEST_METHOD"); - setvar("PATH_INFO"); - setvar("PATH_TRANSLATED"); - setvar("SCRIPT_NAME"); - setvar("QUERY_STRING"); - setvar("REMOTE_HOST"); - setvar("AUTH_TYPE"); - setvar("REMOTE_USER"); - setvar("REMOTE_IDENT"); - setvar("CONTENT_TYPE"); - setvar("CONTENT_LENGTH"); - - setvar("HTTP_USER_AGENT"); - setvar("HTTP_COOKIE"); - setvar("HTTP_IF_MODIFIED_SINCE"); - setvar("HTTP_IF_NONE_MATCH"); - - setvar("HTTPS"); -} - - -/*static*/ const CgiVars& CgiVars::singleton(void) -{ - static CgiVars cgivars; - static bool loaded=false; - - if (!loaded) { - cgivars.load(); - loaded=true; - } - return cgivars; -} diff --git a/extras/anytermd/libpbe/src/Daemon.cc b/extras/anytermd/libpbe/src/Daemon.cc deleted file mode 100644 index e94103bbee..0000000000 --- a/extras/anytermd/libpbe/src/Daemon.cc +++ /dev/null @@ -1,329 +0,0 @@ -// src/Daemon.cc -// This file is part of libpbe; see http://decimail.org -// (C) 2004-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "Daemon.hh" - -#include "Exception.hh" -#include "Lock.hh" -#include "Thread.hh" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; -using namespace pbe; - - -static void handle_foreground_exception(Exception& E) -{ - E.report(cerr); - exit(E.exit_status); -} - - -static void handle_background_exception(Exception& E) -{ - ostringstream s; - E.report(s); - syslog(LOG_ERR,"Unhandled exception: %s",s.str().c_str()); -} - - -Daemon::Daemon(short p, string n, int sf, string u, string d, int max_sessions_, - bool accept_local_only_): - port(p), progname(n), syslog_facility(sf), username(u), dir(d), - max_sessions(max_sessions_ ? max_sessions_ : default_max_sessions), - accept_local_only(accept_local_only_), - n_sessions(0) -{} - - -Daemon::~Daemon() -{} - - -void Daemon::run_interactively(void) -{ - FileDescriptor fdin(0); - FileDescriptor fdout(1); - try { - try { - startup(); - session(fdin,fdout); - } - RETHROW_MISC_EXCEPTIONS; - } - catch(Exception& E) { - handle_foreground_exception(E); - } -} - - -void Daemon::decrement_session_count() -{ - { - Lock l(n_sessions_mutex); - --n_sessions; - } - n_sessions_condition.notify_all(); -} - -static void run_session(Daemon* daemon, int connfd_n) -{ - try { - try { - //syslog(LOG_INFO,"new session starting"); - FileDescriptor connfd(connfd_n); - daemon->session(connfd,connfd); - //syslog(LOG_INFO,"session finished"); - daemon->decrement_session_count(); - return; - } - RETHROW_MISC_EXCEPTIONS; - } - catch(Exception& E) { - handle_background_exception(E); - // what do we want to do after an exception in a session? - // presumably continue? alternative is to quit the entire process. - // exit(E.exit_status); - daemon->decrement_session_count(); - } -} - - -void handle_signal(int signo) -{ - syslog(LOG_CRIT,"got signal %s",strsignal(signo)); - - switch(signo) { - - case SIGHUP: - // Hangup - often means "restart" for daemons, but we ignore it. - signal (SIGHUP, handle_signal); - return; - - case SIGPIPE: - // Wrote to a closed pipe. - // This signal is now ignored, so this case is never reached. - // We must detect closed sockets by checking the return values - // of system calls. - // The difficulty with SIGPIPE is that it is unclear which thread - // receives it - it may not be the one doing the write(), according - // to some web references - and even then, I don't know how the - // signal handler could then cause an exception (or whatever) in - // the corresponding session code. Horrible. - return; - - default: - // Other signals e.g. INT, SEGV etc. - // Terminate entire process. - // Could consider terminating a single thread. - syslog(LOG_CRIT,"terminating"); - exit(1); - } - - // remember signal need to be re-enabled if the handler is going to - // return -} - - -void Daemon::run_as_daemon(bool background) -{ - signal (SIGHUP, handle_signal); - signal (SIGINT, handle_signal); - //signal (SIGQUIT, SIG_DFL); // This means we can kill -QUIT and dump core - signal (SIGILL, handle_signal); - signal (SIGBUS, handle_signal); - signal (SIGFPE, handle_signal); - signal (SIGSEGV, handle_signal); - signal (SIGTERM, handle_signal); - signal (SIGPIPE, SIG_IGN); - signal (SIGABRT, handle_signal); - - openlog(progname.c_str(),LOG_PID,syslog_facility); - - try { - try { - - // set umask? - - int listenfd = socket(PF_INET,SOCK_STREAM,0); - // Add SO_KEEPALIVE so we get SIGPIPE if connection fails? - if(listenfd==-1) { - throw_ErrnoException("socket()"); - } - // race condition here - int rc = fcntl(listenfd,F_SETFD,FD_CLOEXEC); - if (rc==-1) { - throw_ErrnoException("fcntl(listenfd,F_SETFD,FD_CLOEXEC)"); - } - - // Not sure what this does - const int t=1; - setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &t, sizeof(t)); - - struct sockaddr_in server_addr; - memset(&server_addr,0,sizeof(server_addr)); - server_addr.sin_family=AF_INET; - server_addr.sin_addr.s_addr=htonl( accept_local_only ? INADDR_LOOPBACK : INADDR_ANY ); - server_addr.sin_port=htons(port); - int r = bind(listenfd,(struct sockaddr*)&server_addr,sizeof(server_addr)); - if (r==-1) { - throw_ErrnoException("bind()"); - } - - // The parameter to listen is the "backlog" parameter, the number un-accepted - // connections allowed before the connection is refused. - r = listen(listenfd,8); - if (r==-1) { - throw_ErrnoException("listen()"); - } - - if (background) { - // cd to / - // disconnect std[in|out|err]; - // fork; parent process exits. - r = daemon(0,0); - if(r) { - throw_ErrnoException("daemon()"); - } - } - - // Errors now go to syslog - try { - try { - - // Create PID file - // Need to do this after daemon() else we get the wrong pid - if (getuid()==0) { - string pidfilename = "/var/run/"+progname+".pid"; - ofstream pidfile(pidfilename.c_str()); - pidfile << getpid() << endl; - pidfile.close(); - } - // Can't delete this file at termination as we don't have - // the neccessary permissions then - does this matter? - - syslog(LOG_INFO,"%s starting",progname.c_str()); - - // Start as root in order to bind to a reserved port - // Having bound, give up root and run as the specified daemon user - if (getuid()==0 && username!="") { - struct passwd* pw = getpwnam(username.c_str()); - if (!pw) { - throw_ErrnoException("getpwnam(\""+username+"\")"); - } - int rc = setuid(pw->pw_uid); - if (rc==-1) { - throw_ErrnoException("seteuid()"); - } - } - - // Change working directory, if requested. - // This was added so that core files can go somewhere sensible. - if (dir!="") { - int rc = chdir(dir.c_str()); - if (rc==-1) { - throw_ErrnoException("chdir("+dir+")"); - } - } - - // If we dump core, it may be a large core file if we have many threads - // running, and some systems set an rlimit that breaks this. If this is - // a soft rlimit we can increase it here. If for some reason we can't - // increase it we won't treat it as an error. Note that we're doing this - // having changed user to the run-as user. - struct rlimit unlimited_cores; - unlimited_cores.rlim_cur = RLIM_INFINITY; - unlimited_cores.rlim_max = RLIM_INFINITY; - setrlimit(RLIMIT_CORE,&unlimited_cores); - - startup(); - - while(1) { - - { - Lock l(n_sessions_mutex); - while (n_sessions >= max_sessions) { - n_sessions_condition.wait(l); - } - } - - struct sockaddr_in client_addr; - socklen_t client_size=sizeof(client_addr); - int connfd_n; - do { - connfd_n = accept(listenfd,(struct sockaddr*)&client_addr, - &client_size); - } while (connfd_n==-1 && errno==EINTR); - if (connfd_n==-1) { - throw_ErrnoException("accept()"); - } - // race condition here - int rc = fcntl(connfd_n,F_SETFD,FD_CLOEXEC); - if (rc==-1) { - throw_ErrnoException("fcntl(connfd_n,F_SETFD,FD_CLOEXEC)"); - } - - { - Lock l(n_sessions_mutex); - ++n_sessions; - } - - Thread t(boost::bind(&run_session,this,connfd_n)); - } - } - RETHROW_MISC_EXCEPTIONS; - } - catch(Exception& E) { - if (background) { - handle_background_exception(E); - } else { - handle_foreground_exception(E); - } - exit(E.exit_status); - } - - } - RETHROW_MISC_EXCEPTIONS; - } - catch(Exception& E) { - handle_foreground_exception(E); - } -} - - -void Daemon::run_default(void) -{ - if (isatty(0)) { - run_interactively(); - } else { - run_as_daemon(); - } -} - diff --git a/extras/anytermd/libpbe/src/Database.cc b/extras/anytermd/libpbe/src/Database.cc deleted file mode 100644 index 67026df722..0000000000 --- a/extras/anytermd/libpbe/src/Database.cc +++ /dev/null @@ -1,422 +0,0 @@ -// src/Database.cc -// This file is part of libpbe; see http://decimail.org -// (C) 2004 - 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "Database.hh" - -#include "Exception.hh" -#include "utils.hh" -#include "StringTransformer.hh" - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -using namespace std; - - -namespace pbe { - - -static typecode_t oid_to_typecode(Oid oid) -{ - switch(oid) { - case TEXTOID: return text_type; - case BYTEAOID: return text_type; - case INT4OID: return numeric_type; - case INT8OID: return numeric_type; - case TIMESTAMPTZOID: return timestamptz_type; - case TIMESTAMPOID: return timestamptz_type; // Hmm, should distinguish it is local time - case FLOAT4OID: return float_type; - case FLOAT8OID: return double_type; - default: throw StrException("type error, unrecognised oid "+boost::lexical_cast(oid)); - } -} - - -static Oid typecode_to_oid(typecode_t typecode) -{ - switch(typecode) { - case null_type: return 0; - case text_type: return TEXTOID; - case numeric_type: return INT4OID; - case timestamptz_type: return TIMESTAMPTZOID; - case bytea_type: return BYTEAOID; - case float_type: return FLOAT4OID; - case double_type: return FLOAT8OID; - default: throw "type error, unrecognised typecode"; - } -} - - -class DatabaseConnectionFailed: public DatabaseException { -public: - DatabaseConnectionFailed(PGconn* pgconn): - DatabaseException(pgconn,"Connecting to database") {} -}; - - -Database::Database(string conninfo): - pgconn(PQconnectdb(conninfo.c_str())), - conn_fd(PQsocket(pgconn),false), - transaction_in_progress(false) -{ - if (PQstatus(pgconn)!=CONNECTION_OK) { - throw DatabaseConnectionFailed(pgconn); - } -} - - -Database::~Database() -{ - PQfinish(pgconn); -} - - -const FileDescriptor& Database::get_fd(void) const -{ - return conn_fd; -} - - -string Database::get_any_notification(void) -{ - int rc = PQconsumeInput(pgconn); - if (rc==0) { - throw QueryFailed(pgconn,"checking for notifications"); - } - boost::shared_ptr p(PQnotifies(pgconn), PQfreemem); - if (!p) { - return ""; - } - return p.get()->relname; -} - - -void Database::exec_sql(string cmd) -{ - boost::shared_ptr res(PQexec(pgconn, cmd.c_str()), PQclear); - if (!res || PQresultStatus(res.get()) !=PGRES_COMMAND_OK) { - throw QueryFailed(pgconn, cmd.c_str()); - } -} - - -void DatabaseException::report(ostream& s) const -{ - s << "Database exception: " << postgres_error; - if (doing_what!="") { - s << " while " << doing_what; - } - s << "\n"; -} - - -Transaction::Transaction(Database& database_): - database(database_), - committed(false) -{ - if (database.transaction_in_progress) { - nested=true; - } else { - nested=false; - database.transaction_in_progress=true; - database.exec_sql("begin"); - } -} - - -Transaction::~Transaction() -{ - if (!nested) { - if (!committed) { - database.transaction_in_progress=false; - try { - database.exec_sql("rollback;"); - } - catch(...) { - // Mustn't throw an exception from inside a destructor, in case it is being - // invoked during exception processing. - // (TODO is there a better fix for this?) - } - } - } -} - - -void Transaction::commit(void) -{ - if (!nested) { - database.transaction_in_progress=false; - database.exec_sql("commit"); - committed=true; - } -} - - -Result::Result(boost::shared_ptr res_): - rows(PQntuples(res_.get())), - cols(PQnfields(res_.get())), - res(res_) -{} - - -int Result::get_rows_changed(void) const -{ - return boost::lexical_cast(PQcmdTuples(res.get())); -} - - -class ColumnNotFound: public StrException { -public: - ColumnNotFound(string colname): - StrException("Table has no column named " + colname) - {} -}; - - -int Result::column(std::string name) const -{ - int n = PQfnumber(res.get(),name.c_str()); - if (n==-1) { - throw ColumnNotFound(name); - } - return n; -} - - -std::string Result::column_name(int col) const -{ - return PQfname(res.get(),col); -} - -char* Result::rawget(int row, int col) const -{ - return PQgetvalue(res.get(),row,col); -} - -int Result::getlength(int row, int col) const -{ - return PQgetlength(res.get(),row,col); -} - - -bool Result::is_null(int row, int col) const -{ - return PQgetisnull(res.get(),row,col); -} - - -typecode_t Result::column_typecode(int col) const -{ - Oid oid = PQftype(res.get(),col); - return oid_to_typecode(oid); -} - - -int statement_name_t::counter = 0; - - -static bool can_use_pqexecparams(string querystr) -{ - boost::algorithm::trim_left_if(querystr,boost::algorithm::is_any_of(" (")); - return boost::algorithm::istarts_with(querystr,"select") - || boost::algorithm::istarts_with(querystr,"update") - || boost::algorithm::istarts_with(querystr,"insert") - || boost::algorithm::istarts_with(querystr,"delete"); -} - - -QueryCore::QueryCore(Database& database_, std::string querystr_, int nparams_, - typecode_t* argtypecodes, int* lengths, int* formats): - database(database_), - querystr(querystr_), - params_ok(can_use_pqexecparams(querystr_)), - nparams(nparams_), - param_lengths(lengths), - param_formats(formats), - prepared(false) -{ - while (nparams>0 && argtypecodes[nparams-1]==null_type) { - nparams--; - } - argoids = new Oid[nparams]; // hmm, use something smart - for (int i=0; i - result(PQexecPrepared(database.pgconn, statement_name.c_str(), nparams, - enc_args, param_lengths, param_formats, 1), - PQclear); - if (result) { - ExecStatusType status = PQresultStatus(result.get()); - if (status==PGRES_TUPLES_OK || status==PGRES_COMMAND_OK) { - return Result(result); - } - } - throw QueryFailed(database.pgconn, querystr); -} - - -static PGresult* wrap_PQexecParams(PGconn* conn, string command, int nparams, - const Oid* paramTypes, const char* const * paramValues, - const int* paramLengths, const int* paramFormats) -{ - string new_command; - string::size_type p=0; - while (p(command.substr(q+1,(r-q-1))); - if (n==0) { - throw "$0 not allowed"; - } - if (n>nparams) { - throw "Not enough parameters"; - } - --n; - Oid o = paramTypes[n]; - switch (o) { - case TEXTOID: { boost::scoped_array buf(new char[paramLengths[n]*2+1]); - PQescapeStringConn(conn,buf.get(),paramValues[n], - paramLengths[n],NULL); - new_command += string("\'") + buf.get() + "\'"; - break; } - case BYTEAOID: { boost::shared_ptr buf ( - PQescapeByteaConn(conn, - reinterpret_cast(paramValues[n]), - paramLengths[n],NULL), - PQfreemem); - new_command += string("\'") - + reinterpret_cast(buf.get()) + "\'"; - break; } - case INT4OID: { int32_t i = ntohl(*reinterpret_cast(paramValues[n])); - new_command += boost::lexical_cast(i); - break; } - case INT8OID: { int64_t i = ntoh64(*reinterpret_cast(paramValues[n])); - new_command += boost::lexical_cast(i); - break; } - case TIMESTAMPTZOID: throw "timestamptz not implemented"; - break; - default: throw "unrecognised oid"; - } - p = r; - } - //cout << "converted '" << command << "' to '" << new_command << "'\n"; - return PQexec(conn, new_command.c_str()); -} - - -Result QueryCore::runonce(const char* enc_args[]) -{ - if (params_ok) { - boost::shared_ptr - result(PQexecParams(database.pgconn, querystr.c_str(), nparams, - argoids, enc_args, param_lengths, param_formats, 1), - PQclear); - if (result) { - ExecStatusType status = PQresultStatus(result.get()); - if (status==PGRES_TUPLES_OK || status==PGRES_COMMAND_OK) { - return Result(result); - } - } - } else { - boost::shared_ptr - result(wrap_PQexecParams(database.pgconn, querystr, nparams, - argoids, enc_args, param_lengths, param_formats), - PQclear); - if (result) { - ExecStatusType status = PQresultStatus(result.get()); - if (status==PGRES_TUPLES_OK) { - throw StrException("Not expecting tuples in result from " - "non-pqexecparams query '"+querystr+"'"); - } - if (status==PGRES_COMMAND_OK) { - return Result(result); - } - } - } - throw QueryFailed(database.pgconn, querystr); -} - - -void QueryCore::prepare(void) -{ -//cout << "Preparing query with nparams=" << nparams << "\n"; - boost::shared_ptr - result(PQprepare(database.pgconn, statement_name.c_str(), - querystr.c_str(), nparams, argoids), - PQclear); - if (result) { - ExecStatusType status = PQresultStatus(result.get()); - if (status==PGRES_COMMAND_OK) { - prepared=true; - return; - } - } - throw QueryFailed(database.pgconn, querystr); -} - - - -}; - diff --git a/extras/anytermd/libpbe/src/Date.cc b/extras/anytermd/libpbe/src/Date.cc deleted file mode 100644 index fd1f4d1eec..0000000000 --- a/extras/anytermd/libpbe/src/Date.cc +++ /dev/null @@ -1,34 +0,0 @@ -// src/Date.cc -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "Date.hh" - -#include "DateTime.hh" - - -namespace pbe { - -int Date::day_of_week(void) const -{ - DateTime dt(*this); - return dt.day_of_week(); -} - - -}; - diff --git a/extras/anytermd/libpbe/src/Directory.cc b/extras/anytermd/libpbe/src/Directory.cc deleted file mode 100644 index b3f5e1e593..0000000000 --- a/extras/anytermd/libpbe/src/Directory.cc +++ /dev/null @@ -1,112 +0,0 @@ -// src/Directory.cc -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "Directory.hh" - -#include "Exception.hh" - -#include - -using namespace std; - -namespace pbe { - - -Directory::Directory(string dirname_): - dirname(dirname_) -{} - - -Directory::~Directory() -{} - - -void Directory::const_iterator::operator++(void) -{ - read_next(); -} - - -bool Directory::const_iterator::operator==(const const_iterator& rhs) const -{ - if (!at_end && !rhs.at_end) { - throw "Cannot compare these Directory::const_iterators"; - } - return at_end==rhs.at_end; -} - - -Directory::const_iterator::const_iterator(void): - dir(NULL), at_end(true) -{} - - -Directory::const_iterator::const_iterator(string dirname_): - dirname(dirname_), at_end(false) -{ - dir = opendir(dirname.c_str()); - if (!dir) { - throw_ErrnoException("opendir("+dirname+")"); - } - read_next(); -} - - -Directory::const_iterator::~const_iterator() -{ - if (dir) { - int ret = closedir(dir); - if (ret==-1) { - // throw_ErrnoException("closing a directory"); - // Don't throw an exception from a destructor, in case it is being invoked - // during exception processing. - // (TODO is there a better fix for this?) - } - } -} - - -void Directory::const_iterator::read_next(void) -{ - struct dirent* ent_p = readdir(dir); - if (!ent_p) { - at_end=true; - } else { - this_entry.leafname = ent_p->d_name; - if (this_entry.leafname=="." || this_entry.leafname=="..") { - read_next(); - return; - } - this_entry.pathname = dirname + '/' + this_entry.leafname; - } -} - - -Directory::const_iterator Directory::begin(void) const -{ - return const_iterator(dirname); -} - - -Directory::const_iterator Directory::end(void) const -{ - return const_iterator(); -} - -}; - diff --git a/extras/anytermd/libpbe/src/Exception.cc b/extras/anytermd/libpbe/src/Exception.cc deleted file mode 100644 index 9495ab8bdb..0000000000 --- a/extras/anytermd/libpbe/src/Exception.cc +++ /dev/null @@ -1,43 +0,0 @@ -// src/Exception.cc -// This file is part of libpbe; see http://decimail.org -// (C) 2004-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "Exception.hh" - -#include - -using namespace std; -//using namespace pbe; - - -namespace pbe { - - -void UnknownException::report(ostream& s) const -{ - s << "Unknown Exception." << endl; -} - - -void ErrnoException::report(ostream& s) const -{ - s << strerror(error_number) << " while " << doing_what << endl; -} - - -}; - diff --git a/extras/anytermd/libpbe/src/HttpAuthenticator.cc b/extras/anytermd/libpbe/src/HttpAuthenticator.cc deleted file mode 100644 index 191990afe1..0000000000 --- a/extras/anytermd/libpbe/src/HttpAuthenticator.cc +++ /dev/null @@ -1,44 +0,0 @@ -// HttpAuthenticator.cc -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2005 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include "HttpAuthenticator.hh" - -#include "base64.hh" - -using namespace std; -using namespace pbe; - - -string HttpAuthenticator::operator()(string credentials) const -{ - if (credentials.substr(0,6)!="Basic ") { - // should be case-insensitive - throw NotAuthenticated(); - } - string user_pass_b64 = credentials.substr(6); - - string user_pass = decode_base64(user_pass_b64); - unsigned int colon_pos = user_pass.find(':'); - string username = user_pass.substr(0,colon_pos); - string password = user_pass.substr(colon_pos+1); - - basic_auth(username,password); - - return username; -} diff --git a/extras/anytermd/libpbe/src/HttpClient.cc b/extras/anytermd/libpbe/src/HttpClient.cc deleted file mode 100644 index a4b9e5a38e..0000000000 --- a/extras/anytermd/libpbe/src/HttpClient.cc +++ /dev/null @@ -1,202 +0,0 @@ -// src/HttpClient.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "HttpClient.hh" - -#include "HttpRequest.hh" -#include "TcpClientSocket.hh" -#include "Gunzipper.hh" -#include "Bunzipper.hh" -#include "FileDescriptor.hh" -#include "rfcdate.hh" -#include "FileType.hh" -#include "atomic_ofstream.hh" - -#include -#include - -using namespace std; - - -namespace pbe { - - -HttpResponse HttpClient::get(const URI& uri, int redirect_hops) -{ - if (uri.scheme != "http") { - throw "Not an HTTP URI"; - } - HttpRequest req(uri); - req.headers["Date"] = rfc_date(); - req.headers["Connection"] = "close"; - req.headers["User-Agent"] = user_agent; - TcpClientSocket sock(uri.host, uri.port ? uri.port : 80); - sock.writeall(req.request_line() + req.headers_str() + "\r\n"); - HttpResponse response(sock.readall()); - if (response.status_code==301 || response.status_code==302 - || response.status_code==303 || response.status_code==307) { - if (redirect_hops<=0) { - throw "Redirection limit reached"; - } - return get(response.headers["Location"], redirect_hops-1); - } - return response; -} - - -template -void HttpClient::get_process_save(const URI& uri, std::string fn, int redirect_hops) -{ - if (uri.scheme != "http") { - throw "Not an HTTP URI"; - } - const string etag_fn = fn+".etag"; - HttpRequest req(uri); - req.headers["Date"] = rfc_date(); - req.headers["Connection"] = "close"; - req.headers["User-Agent"] = user_agent; - if (use_etag && file_exists(etag_fn) && file_exists(fn)) { - ifstream etagf(etag_fn.c_str()); - string etag; - getline(etagf,etag); - req.headers["If-None-Match"] = etag; - } - TcpClientSocket sock(uri.host, uri.port ? uri.port : 80); - sock.writeall(req.request_line() + req.headers_str() + "\r\n"); - - string resp_start; - string::iterator crlf2pos; - do { - bool timed_out = wait_until(sock.readable(), 30)==-1; - if (timed_out) { - throw TimedOut("read()"); - } - resp_start.append(sock.readsome()); - string crlf2 = "\r\n\r\n"; - crlf2pos = search(resp_start.begin(),resp_start.end(), crlf2.begin(),crlf2.end()); - } while (crlf2pos==resp_start.end()); - HttpResponse response(string(resp_start.begin(),crlf2pos+4)); - - if (use_etag && response.status_code==304) { - return; - } - - if (response.status_code==301 || response.status_code==302 - || response.status_code==303 || response.status_code==307) { - if (redirect_hops<=0) { - throw "Redirection limit reached"; - } - get_process_save(response.headers["Location"], fn, redirect_hops-1); - return; - } - - if (response.status_code != 200) { - throw response; - } - - string tmp_fn = fn+".part"; - - { - FileDescriptor fd(tmp_fn,FileDescriptor::create); - try { - Processor proc; - fd.writeall(proc(string(crlf2pos+4,resp_start.end()))); - - while (1) { - bool timed_out = wait_until(sock.readable(), 30)==-1; - if (timed_out) { - throw TimedOut("read()"); - } - string s = sock.readsome(); - if (s.empty()) { - break; - } - fd.writeall(proc(s)); - } - } - catch (...) { - unlink(tmp_fn.c_str()); - throw; - } - } - - // Ideally we should rename both the data file and the etag file atomically, but - // we can't do that. A safe alternative is to delete the old etag file first; in this - // case the worst that can happen is that we end up with a valid data file and a - // missing etag file. - - if (use_etag) { - unlink(etag_fn.c_str()); - } - - int rc = rename(tmp_fn.c_str(),fn.c_str()); - if (rc==-1) { - throw_ErrnoException("rename("+tmp_fn+","+fn+")"); - } - - if (use_etag && response.headers.find("ETag")!=response.headers.end()) { - atomic_ofstream etagf(etag_fn); - etagf << response.headers["ETag"]; - etagf.commit(); - } -} - - -struct identity_processor { - std::string operator()(string s) const { return s; } -}; - - -void HttpClient::get_save(const URI& uri, std::string fn, int redirect_hops) -{ - return get_process_save(uri,fn,redirect_hops); -} - -void HttpClient::get_save_with_etag(const URI& uri, std::string fn, int redirect_hops) -{ - return get_process_save(uri,fn,redirect_hops); -} - - -void HttpClient::get_gunzip_save(const URI& uri, std::string fn, int redirect_hops) -{ - return get_process_save(uri,fn,redirect_hops); -} - -void HttpClient::get_gunzip_save_with_etag(const URI& uri, std::string fn, int redirect_hops) -{ - return get_process_save(uri,fn,redirect_hops); -} - - -#ifdef HAVE_BZIP - -void HttpClient::get_bunzip_save(const URI& uri, std::string fn, int redirect_hops) -{ - return get_process_save(uri,fn,redirect_hops); -} - -void HttpClient::get_bunzip_save_with_etag(const URI& uri, std::string fn, int redirect_hops) -{ - return get_process_save(uri,fn,redirect_hops); -} - - -#endif - -}; diff --git a/extras/anytermd/libpbe/src/HttpDaemon.cc b/extras/anytermd/libpbe/src/HttpDaemon.cc deleted file mode 100644 index 05c91fa256..0000000000 --- a/extras/anytermd/libpbe/src/HttpDaemon.cc +++ /dev/null @@ -1,124 +0,0 @@ -// HttpDaemon.cc -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2005 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include "HttpDaemon.hh" - -#include "HttpRequest.hh" -#include "parse_http_request.hh" -#include "HttpResponse.hh" -#include "rfcdate.hh" - -#include -#include - -using namespace std; - - -namespace pbe { - - -void HttpDaemon::session(FileDescriptor& in_fd, FileDescriptor& out_fd) -{ - session_start(); - -#ifndef LIBPBE_HAS_FILEDESCRIPTOR_STREAMS -#error "Sorry, there is a problem with your compiler / C++ library. Please ask for assistance" -#endif - FileDescriptor::istream in_strm(in_fd); - - bool close_connection=!keepalive; - do { - HttpRequest req; - HttpResponse resp; - try { - try { - req = parse_http_request(in_strm); - // Should look at Host: header and consider complete URIs in - // request line - if (req.http_version!="HTTP/1.1") { - // We should send a 1.0 response if the request was for 1.0; i.e. - // we should send a content-length header and not use chunked encoding. - close_connection=true; - } - if (req.headers["Connection"]=="close") { - // could be other tokens in the line. Should be case-insensitive. - close_connection=true; - } - if (req.headers.find("Host")==req.headers.end()) { - resp.status_code=400; - resp.reason_phrase="Bad Request (missing Host: header)"; - - } else if (req.method!="GET" && req.method!="POST") { - resp.status_code=405; - resp.reason_phrase="Method not allowed"; - resp.headers["Allow"]="GET POST"; - // should check for Expect: header and reject with 417 response. - - } else { - handle(req,resp); - } - } - catch (HttpRequestSyntaxError& E) { - resp.status_code=400; - resp.reason_phrase="Malformed request"; - close_connection=true; - } - catch (HttpAuthenticator::NotAuthenticated& NA) { - resp.status_code=401; - resp.reason_phrase="Unauthorised"; - resp.headers["WWW-Authenticate"]="Basic realm=\"Anyterm\""; - } - RETHROW_MISC_EXCEPTIONS; - } - catch (Exception& E) { - resp.status_code=500; - ostringstream s; - s << "Server error: "; - E.report(s); - resp.reason_phrase=s.str(); - } - if (resp.status_code!=200) { - close_connection=true; - // Actually we don't need to do this, but maybe it is safer - } - if (close_connection) { - resp.headers["Connection"]="close"; - } - resp.headers["Date"]=rfc_date(); - resp.send(out_fd); - } while (!close_connection); -} - - - -void HttpDaemon::authenticate(HttpRequest& req) -{ - if (authenticator) { - HttpRequest::headers_t::const_iterator i = req.headers.find("Authorization"); - if (i==req.headers.end()) { - throw HttpAuthenticator::NotAuthenticated(); - } - string credentials = i->second; - req.userinfo = (*authenticator)(credentials); - } -} - - -}; - diff --git a/extras/anytermd/libpbe/src/HttpResponse.cc b/extras/anytermd/libpbe/src/HttpResponse.cc deleted file mode 100644 index 7398383192..0000000000 --- a/extras/anytermd/libpbe/src/HttpResponse.cc +++ /dev/null @@ -1,103 +0,0 @@ -// src/HttpResponse.cc -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2005-2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include "HttpResponse.hh" - -#include "FileDescriptor.hh" -#include "mustfind.hh" - -#include - -#include -#include - -using namespace std; - - -namespace pbe { - - -static void send_chunked(ostream& strm, string data) -{ - strm << hex << data.length() << "\r\n" - << data << "\r\n" - << "0\r\n" - << "\r\n"; -} - - -void HttpResponse::send(FileDescriptor& fd) -{ - ostringstream s; - s << http_version << ' ' << status_code << ' ' << reason_phrase << "\r\n"; - for (map::const_iterator i = headers.begin(); - i != headers.end(); ++i) { - s << i->first << ": " << i->second << "\r\n"; - } - s << "Transfer-Encoding: chunked\r\n" - << "\r\n"; - if (body.length()==0) { - s << "0\r\n\r\n"; - } else { - send_chunked(s,body); - } - - fd.writeall(s.str()); -} - - -static string get_line(string& s) -{ - string crlf = "\r\n"; - string::iterator i = mustsearch(s.begin(),s.end(),crlf.begin(),crlf.end()); - string l(s.begin(),i); - s = string(i+2,s.end()); - return l; -} - - -HttpResponse::HttpResponse(string s) -{ - const string response_line = get_line(s); - string::const_iterator sp1 = mustfind(response_line.begin(),response_line.end(),' '); - http_version = string(response_line.begin(),sp1); - string::const_iterator sp2 = mustfind(sp1+1,response_line.end(),' '); - status_code = boost::lexical_cast(string(sp1+1,sp2)); - reason_phrase = string(sp2+2,response_line.end()); - - while (1) { - const string hdr = get_line(s); - if (hdr.empty()) { - break; - } - string::const_iterator colon_pos = mustfind(hdr.begin(),hdr.end(),':'); - const string hdr_name(hdr.begin(),colon_pos); - const string hdr_val(colon_pos+1,hdr.end()); - const string trimmed_hdr_val(mustfind_if(hdr_val.begin(),hdr_val.end(), - bind2nd(not_equal_to(),' ')), - hdr_val.end()); - headers[hdr_name] = trimmed_hdr_val; - } - - body = s; -} - - -}; - diff --git a/extras/anytermd/libpbe/src/Recoder.cc b/extras/anytermd/libpbe/src/Recoder.cc deleted file mode 100644 index ce166e6466..0000000000 --- a/extras/anytermd/libpbe/src/Recoder.cc +++ /dev/null @@ -1,80 +0,0 @@ -// src/Recoder.cc -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#include "Recoder.hh" - -#include -#include - -#include - - -RECODE_OUTER Recoder::outer = NULL; - -Recoder::Recoder(string from_charset, string to_charset, ErrorLevel e): - error_level(e) -{ - if (!outer) { - outer = recode_new_outer(false); - assert(outer); - } - request = recode_new_request(outer); - assert(request); - assert(recode_scan_request(request, - string(from_charset+".."+to_charset).c_str())); -}; - - -Recoder::~Recoder() -{ - recode_delete_request(request); -} - - -string Recoder::operator()(string i) -{ - return operator()(i.data(),i.size()); -} - - -string Recoder::operator()(const char* i, int l) -{ - RECODE_TASK task = recode_new_task(request); - - task->input.name = NULL; - task->input.file = NULL; - task->input.buffer = i; - task->input.cursor = i; - task->input.limit = i+l; - - task->output.name = NULL; - task->output.file = NULL; - task->output.buffer = NULL; - task->output.cursor = NULL; - task->output.limit = NULL; - - task->fail_level = static_cast(error_level); - - assert(recode_perform_task(task)); - - string o(task->output.buffer,task->output.cursor - task->output.buffer); - free(task->output.buffer); - - recode_delete_task(task); - - return o; -} diff --git a/extras/anytermd/libpbe/src/SmtpClient.cc b/extras/anytermd/libpbe/src/SmtpClient.cc deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/extras/anytermd/libpbe/src/SmtpClient.cc.caca b/extras/anytermd/libpbe/src/SmtpClient.cc.caca deleted file mode 100644 index 0a4933d0d1..0000000000 --- a/extras/anytermd/libpbe/src/SmtpClient.cc.caca +++ /dev/null @@ -1,147 +0,0 @@ -// src/SmtpClient.cc -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#include "SmtpClient.hh" - -#include "ip.hh" -#include "select.hh" - -#include -#include - -#ifdef __OpenBSD__ -// Is this really needed? -#include -#endif - -using namespace std; -using namespace pbe; - - - void SmtpError::report(ostream& s) const - { - s << msg; - } - - - SmtpClient::SmtpClient(bool log): enable_log(log), connected(false) - {} - - - void SmtpClient::connect(string server_name, string domain, int port) - { - fd = tcp_client_connect(server_name, port); - - wait_for_reply(220,300); - send("EHLO "+domain); - wait_for_reply(250,300); - - connected=true; - } - - - void SmtpClient::wait_for_reply(int expected_code, int timeout) - { - if (select_rt(fd,timeout)==-1) { - throw SmtpError("Timeout"); - } - char buf[513]; - int n=0; - while (1) { - int c = read(fd,buf+n,sizeof(buf)-n); - buf[n+c+1]='\0'; - if (enable_log) { - syslog(LOG_MAIL|LOG_DEBUG,"SmtpClient:S: %s",buf); - } - if (c==-1) { - throw_ErrnoException("read()"); - } - n += c; - if (buf[n-1]=='\n') { - break; - } - if (n==sizeof(buf)) { - throw SmtpError("Command line did not terminate"); - } - } - int code; - int rc = sscanf(buf,"%d",&code); - if (rc!=1) { - throw SmtpError("No reply code at start of line"); - } - if (code != expected_code) { - throw SmtpError("Unexpected reply: \'"+string(buf)+"\'"); - } - } - - - void SmtpClient::send(string d) - { - if (enable_log) { - syslog(LOG_MAIL|LOG_DEBUG,"SmtpClient:C: %s",d.c_str()); - } - d.append("\r\n"); - // ought to impose a timeout on these writes - const char* p = d.data(); - int n = d.length(); - int c = 0; - while(c recipients; - recipients.push_back(recipient); - send_msg(sender, recipients, msg); - } - - - void SmtpClient::send_msg(string sender, const list& recipients, - string msg) - { - send("MAIL FROM:<"+sender+">"); - wait_for_reply(250,300); - for (list::const_iterator i = recipients.begin(); - i != recipients.end(); ++i) { - send("RCPT TO:<"+*i+">"); - wait_for_reply(250,300); // could get 251 as well - } - send("DATA"); - wait_for_reply(354,120); - send(msg); - send("."); - wait_for_reply(250,600); - } - - - void SmtpClient::disconnect(void) - { - send("QUIT"); - wait_for_reply(221,300); - int rc = close(fd); - if (rc==-1) { - throw_ErrnoException("close()"); - } - connected=false; - } diff --git a/extras/anytermd/libpbe/src/URI.cc b/extras/anytermd/libpbe/src/URI.cc deleted file mode 100644 index f2cfd77d30..0000000000 --- a/extras/anytermd/libpbe/src/URI.cc +++ /dev/null @@ -1,120 +0,0 @@ -// src/URI.cc -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2005-2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "URI.hh" - -#include -#include -#include -#include -#include - -#include -#include - -#include - -using namespace std; -using namespace boost::spirit; - - -namespace pbe { - - -URI::URI(string absolute_uri): - port(0) -{ - typedef rule<> rule_t; - - // URI parsing EBNF based on - // RFC2616 - // RFC2396 - // HTTP/1.1 Errata (http://skrb.org/ietf/http_errata.html) - - rule_t mark = ch_p('-') | '_' | '.' | '!' | '~' | '*' | '\'' | '(' | ')'; - - rule_t unreserved = alnum_p | mark; - - rule_t escaped = ch_p('%') >> xdigit_p >> xdigit_p; - - rule_t reserved = ch_p(';') | '/' | '?' | ':' | '@' | '&' | '=' | '+' | '$' | ','; - - rule_t pchar = unreserved | escaped | ':' | '@' | '&' | '=' | '+' | '$' | ','; - - rule_t param = *pchar; - - rule_t segment = *pchar >> *(';' >> param); - - rule_t path_segments = segment >> *('/' >> segment); - - rule_t abs_path = ( ch_p('/') >> path_segments )[assign_a(URI::abs_path)]; - - rule_t scheme = alpha_p >> *(alpha_p | digit_p | '+' | '-' | '.' ); - - rule_t userinfo = *(unreserved | escaped | ';' | ':' | '&' | '=' | '+' | '$' | ',' ); - - //rule_t domainlabel = alnum_p | alnum_p >> *(alnum_p | '-') >> alnum_p; - rule_t domainlabel = *(alnum_p | '-'); - - //rule_t toplabel = alpha_p | alpha_p >> *(alnum_p | '-') >> alnum_p; - - //rule_t hostname = *(domainlabel >> '.') >> toplabel >> !ch_p('.'); - rule_t hostname = domainlabel % ch_p('.'); - - uint_parser decimal_byte; - - rule_t ipv4address = decimal_byte >> '.' >> decimal_byte >> '.' >> - decimal_byte >> '.' >> decimal_byte; - - rule_t host = hostname | ipv4address; - - rule_t port = uint_p[assign_a(URI::port)]; - - rule_t hostport = host[assign_a(URI::host)] - >> !(':' >> port); - - rule_t server = !( !(userinfo[assign_a(URI::userinfo)] >> '@') >> hostport ); - - rule_t reg_name = +(unreserved | escaped | '$' | ',' | ';' | ':' | '@' | - '&' | '=' | '+'); - - rule_t authority = server | reg_name; - - rule_t net_path = str_p("//") >> authority >> !abs_path; - - rule_t uric = reserved | unreserved | escaped; - - rule_t query = (*uric) [assign_a(URI::query)]; - - rule_t hier_part = (net_path | abs_path) >> !('?' >> query); - - rule_t uric_no_slash = unreserved | escaped | ';' | '?' | ':' | '@' | - '&' | '=' | '+' | '$' | ','; - - rule_t opaque_part = uric_no_slash >> *uric; - - rule_t absoluteURI = scheme[assign_a(URI::scheme)] >> ':' >> (hier_part | opaque_part); - - if (!parse(absolute_uri.c_str(), absoluteURI).full) { - throw SyntaxError(); - } -} - - -}; - diff --git a/extras/anytermd/libpbe/src/charset_names.cc b/extras/anytermd/libpbe/src/charset_names.cc deleted file mode 100644 index 06651b1561..0000000000 --- a/extras/anytermd/libpbe/src/charset_names.cc +++ /dev/null @@ -1,97 +0,0 @@ -// charset_names.cc -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#include "charset/charset_names.hh" - -#include -#include -#include -#include - -#include - -using namespace std; - - -namespace pbe { - -#include "generated/charset_iana_names_body.cc" -#include "generated/charset_mime_names_body.cc" - - -struct charset_lookup { - const char* name; - charset_t cs; -}; - -static const charset_lookup lookup_table[] = { -#include "generated/charset_lookup_body.cc" -// {NULL, 0} -}; - - -static bool charset_name_less_than(const charset_lookup& a, string b) -{ - return ::strcmp(a.name,b.c_str())<0; -} - -charset_t lookup_charset(const char* name) -{ - string stripped_lc_name; - bool was_digit=false; - bool uscore_pending=false; - for (const char* p = name; *p; ++p) { - if (isalnum(*p)) { - if (uscore_pending && isdigit(*p)) { - stripped_lc_name += '_'; - } - stripped_lc_name += tolower(*p); - was_digit = isdigit(*p); - uscore_pending = false; - } else if (was_digit) { - uscore_pending=true; - } - } - - const charset_lookup* lookup_table_end = - lookup_table+sizeof(lookup_table)/sizeof(charset_lookup); - const charset_lookup* l = - lower_bound(&lookup_table[0], lookup_table_end, stripped_lc_name, charset_name_less_than); - if (l==lookup_table_end || string(l->name)!=stripped_lc_name) { - throw NoSuchCharacterSet(); - } - return l->cs; -} - - -charset_t lookup_charset(string name) { - return lookup_charset(name.c_str()); -} - -}; - diff --git a/extras/anytermd/libpbe/src/ci_string.cc b/extras/anytermd/libpbe/src/ci_string.cc deleted file mode 100644 index 4b89dc5998..0000000000 --- a/extras/anytermd/libpbe/src/ci_string.cc +++ /dev/null @@ -1,26 +0,0 @@ -// src/ci_string.cc -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#include "ci_string.hh" - -string to_string(const ci_string& s) { - return string(s.data(),s.size()); -} - -ci_string to_ci_string(const string& s) { - return ci_string(s.data(),s.size()); -} diff --git a/extras/anytermd/libpbe/src/create_dir.cc b/extras/anytermd/libpbe/src/create_dir.cc deleted file mode 100644 index 1d6f24a2bf..0000000000 --- a/extras/anytermd/libpbe/src/create_dir.cc +++ /dev/null @@ -1,68 +0,0 @@ -// src/create_dir.hh -// This file is part of libpbe; see http://svn.chezphil.org/libpbe -// (C) 2009 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -// Create directories. - - -#include "create_dir.hh" - -#include "FileType.hh" - -#include - -using namespace std; - -namespace pbe { - -// Check for and create necessary parent directories. Succeeds if the -// directory already exists; fails if it is a file. - -void create_dir_with_parents(const string path, mode_t mode) -{ - string::const_iterator i = path.begin(); - while (1) { - string::const_iterator j = find(i,path.end(),'/'); - string elem(i,j); - string to_here(path.begin(),j); - if (elem=="" || elem==".") { - } else { - switch (get_link_filetype(to_here,true)) { - case does_not_exist: - create_dir(to_here,mode); - break; - case directory: - break; - default: - throw_ErrnoException("create_dir_with_parents()",EEXIST); - break; - } - } - - if (j==path.end()) { - break; - } - - i = j; - ++i; - } -} - - -}; - diff --git a/extras/anytermd/libpbe/src/csv.cc b/extras/anytermd/libpbe/src/csv.cc deleted file mode 100644 index 7ad49176c8..0000000000 --- a/extras/anytermd/libpbe/src/csv.cc +++ /dev/null @@ -1,75 +0,0 @@ -// csv.cc -// (C) 2008 Philip Endecott -// This file is part of libpbe. See http://svn.chezphil.org/libpbe/ -// This file is distributed under the terms of the Boost Software License v1.0. -// Please see http://www.boost.org/LICENSE_1_0.txt or the accompanying file BOOST_LICENSE. - -#include "csv.hh" - -#include -#include -#include - -using namespace std; - - -namespace pbe { - -template -static string parse_csv_field(iter& i, iter j) -{ - if (i==j) { - return ""; - } - string s; - if (*i == '"') { - // Quoted: - ++i; // initial quote - while (i != j && *i != '"') { - if (*i == '\\') { - ++i; - if (i==j) { - break; - } - } - s += *i; - ++i; - } - if (i != j) { - ++i; // final quote - } - } else { - // Unquoted: - while (i != j && *i != ',') { - if (*i == '\\') { - ++i; - if (i==j) { - break; - } - } - s += *i; - ++i; - } - } - return s; -} - - -void parse_csv_line(const string l, vector& v) -{ - v.clear(); - string::const_iterator i = l.begin(); - while (1) { - v.push_back(parse_csv_field(i, l.end())); - if (i==l.end()) { - break; - } - if (*i != ',') { - throw "expecting a comma"; - } - ++i; - } -} - - -}; diff --git a/extras/anytermd/libpbe/src/format.cc b/extras/anytermd/libpbe/src/format.cc deleted file mode 100644 index 769a435201..0000000000 --- a/extras/anytermd/libpbe/src/format.cc +++ /dev/null @@ -1,54 +0,0 @@ -// src/format.cc -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2009 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "format.hh" - -#include -#include -#include -#include - - -namespace pbe { - - -// vasprintf is a GNUism. We could achieve the same thing using vsnprintf -// in a loop for other C libraries. - -#ifdef __GLIBC__ - -std::string format(const char* fmt,...) -{ - va_list args; - va_start(args,fmt); - char* p; - int r = vasprintf(&p,fmt,args); - if (r<0) { - throw "vasprintf failed"; - } - va_end(args); - std::string s(p); - free(p); - return s; -} - -#endif - - -}; - diff --git a/extras/anytermd/libpbe/src/generated/charset_iana_names_body.cc b/extras/anytermd/libpbe/src/generated/charset_iana_names_body.cc deleted file mode 100644 index 4130db46de..0000000000 --- a/extras/anytermd/libpbe/src/generated/charset_iana_names_body.cc +++ /dev/null @@ -1,257 +0,0 @@ -const char * const charset_iana_names[] = { - "ANSI_X3.4-1968", - "ISO_8859-1:1987", - "ISO_8859-2:1987", - "ISO_8859-3:1988", - "ISO_8859-4:1988", - "ISO_8859-5:1988", - "ISO_8859-6:1987", - "ISO_8859-7:1987", - "ISO_8859-8:1988", - "ISO_8859-9:1989", - "ISO-8859-10", - "ISO_6937-2-add", - "JIS_X0201", - "JIS_Encoding", - "Shift_JIS", - "Extended_UNIX_Code_Packed_Format_for_Japanese", - "Extended_UNIX_Code_Fixed_Width_for_Japanese", - "BS_4730", - "SEN_850200_C", - "IT", - "ES", - "DIN_66003", - "NS_4551-1", - "NF_Z_62-010", - "ISO-10646-UTF-1", - "ISO_646.basic:1983", - "INVARIANT", - "ISO_646.irv:1983", - "NATS-SEFI", - "NATS-SEFI-ADD", - "NATS-DANO", - "NATS-DANO-ADD", - "SEN_850200_B", - "KS_C_5601-1987", - "ISO-2022-KR", - "EUC-KR", - "ISO-2022-JP", - "ISO-2022-JP-2", - "JIS_C6220-1969-jp", - "JIS_C6220-1969-ro", - "PT", - "greek7-old", - "latin-greek", - "NF_Z_62-010_(1973)", - "Latin-greek-1", - "ISO_5427", - "JIS_C6226-1978", - "BS_viewdata", - "INIS", - "INIS-8", - "INIS-cyrillic", - "ISO_5427:1981", - "ISO_5428:1980", - "GB_1988-80", - "GB_2312-80", - "NS_4551-2", - "videotex-suppl", - "PT2", - "ES2", - "MSZ_7795.3", - "JIS_C6226-1983", - "greek7", - "ASMO_449", - "iso-ir-90", - "JIS_C6229-1984-a", - "JIS_C6229-1984-b", - "JIS_C6229-1984-b-add", - "JIS_C6229-1984-hand", - "JIS_C6229-1984-hand-add", - "JIS_C6229-1984-kana", - "ISO_2033-1983", - "ANSI_X3.110-1983", - "T.61-7bit", - "T.61-8bit", - "ECMA-cyrillic", - "CSA_Z243.4-1985-1", - "CSA_Z243.4-1985-2", - "CSA_Z243.4-1985-gr", - "ISO_8859-6-E", - "ISO_8859-6-I", - "T.101-G2", - "ISO_8859-8-E", - "ISO_8859-8-I", - "CSN_369103", - "JUS_I.B1.002", - "IEC_P27-1", - "JUS_I.B1.003-serb", - "JUS_I.B1.003-mac", - "greek-ccitt", - "NC_NC00-10:81", - "ISO_6937-2-25", - "GOST_19768-74", - "ISO_8859-supp", - "ISO_10367-box", - "latin-lap", - "JIS_X0212-1990", - "DS_2089", - "us-dk", - "dk-us", - "KSC5636", - "UNICODE-1-1-UTF-7", - "ISO-2022-CN", - "ISO-2022-CN-EXT", - "UTF-8", - "ISO-8859-13", - "ISO-8859-14", - "ISO-8859-15", - "ISO-8859-16", - "GBK", - "GB18030", - "OSD_EBCDIC_DF04_15", - "OSD_EBCDIC_DF03_IRV", - "OSD_EBCDIC_DF04_1", - "ISO-11548-1", - "KZ-1048", - "ISO-10646-UCS-2", - "ISO-10646-UCS-4", - "ISO-10646-UCS-Basic", - "ISO-10646-Unicode-Latin1", - "ISO-10646-J-1", - "ISO-Unicode-IBM-1261", - "ISO-Unicode-IBM-1268", - "ISO-Unicode-IBM-1276", - "ISO-Unicode-IBM-1264", - "ISO-Unicode-IBM-1265", - "UNICODE-1-1", - "SCSU", - "UTF-7", - "UTF-16BE", - "UTF-16LE", - "UTF-16", - "CESU-8", - "UTF-32", - "UTF-32BE", - "UTF-32LE", - "BOCU-1", - "ISO-8859-1-Windows-3.0-Latin-1", - "ISO-8859-1-Windows-3.1-Latin-1", - "ISO-8859-2-Windows-Latin-2", - "ISO-8859-9-Windows-Latin-5", - "hp-roman8", - "Adobe-Standard-Encoding", - "Ventura-US", - "Ventura-International", - "DEC-MCS", - "IBM850", - "PC8-Danish-Norwegian", - "IBM862", - "PC8-Turkish", - "IBM-Symbols", - "IBM-Thai", - "HP-Legal", - "HP-Pi-font", - "HP-Math8", - "Adobe-Symbol-Encoding", - "HP-DeskTop", - "Ventura-Math", - "Microsoft-Publishing", - "Windows-31J", - "GB2312", - "Big5", - "macintosh", - "IBM037", - "IBM038", - "IBM273", - "IBM274", - "IBM275", - "IBM277", - "IBM278", - "IBM280", - "IBM281", - "IBM284", - "IBM285", - "IBM290", - "IBM297", - "IBM420", - "IBM423", - "IBM424", - "IBM437", - "IBM500", - "IBM851", - "IBM852", - "IBM855", - "IBM857", - "IBM860", - "IBM861", - "IBM863", - "IBM864", - "IBM865", - "IBM868", - "IBM869", - "IBM870", - "IBM871", - "IBM880", - "IBM891", - "IBM903", - "IBM904", - "IBM905", - "IBM918", - "IBM1026", - "EBCDIC-AT-DE", - "EBCDIC-AT-DE-A", - "EBCDIC-CA-FR", - "EBCDIC-DK-NO", - "EBCDIC-DK-NO-A", - "EBCDIC-FI-SE", - "EBCDIC-FI-SE-A", - "EBCDIC-FR", - "EBCDIC-IT", - "EBCDIC-PT", - "EBCDIC-ES", - "EBCDIC-ES-A", - "EBCDIC-ES-S", - "EBCDIC-UK", - "EBCDIC-US", - "UNKNOWN-8BIT", - "MNEMONIC", - "MNEM", - "VISCII", - "VIQR", - "KOI8-R", - "HZ-GB-2312", - "IBM866", - "IBM775", - "KOI8-U", - "IBM00858", - "IBM00924", - "IBM01140", - "IBM01141", - "IBM01142", - "IBM01143", - "IBM01144", - "IBM01145", - "IBM01146", - "IBM01147", - "IBM01148", - "IBM01149", - "Big5-HKSCS", - "IBM1047", - "PTCP154", - "Amiga-1251", - "KOI7-switched", - "BRF", - "TSCII", - "windows-1250", - "windows-1251", - "windows-1252", - "windows-1253", - "windows-1254", - "windows-1255", - "windows-1256", - "windows-1257", - "windows-1258", - "TIS-620", - NULL -}; diff --git a/extras/anytermd/libpbe/src/generated/charset_lookup_body.cc b/extras/anytermd/libpbe/src/generated/charset_lookup_body.cc deleted file mode 100644 index 70e61f2957..0000000000 --- a/extras/anytermd/libpbe/src/generated/charset_lookup_body.cc +++ /dev/null @@ -1,807 +0,0 @@ - {"437", cs::ibm437}, - {"850", cs::ibm850}, - {"851", cs::ibm851}, - {"852", cs::ibm852}, - {"855", cs::ibm855}, - {"857", cs::ibm857}, - {"860", cs::ibm860}, - {"861", cs::ibm861}, - {"862", cs::ibm862}, - {"863", cs::ibm863}, - {"865", cs::ibm865}, - {"866", cs::ibm866}, - {"869", cs::ibm869}, - {"904", cs::ibm904}, - {"adobestandardencoding", cs::adobe_standard_encoding}, - {"adobesymbolencoding", cs::adobe_symbol_encoding}, - {"ami1251", cs::amiga_1251}, - {"amiga1251", cs::amiga_1251}, - {"ansix3_110_1983", cs::ansi_x3_110_1983}, - {"ansix3_4_1968", cs::ansi_x3_4_1968}, - {"ansix3_4_1986", cs::ansi_x3_4_1968}, - {"arabic", cs::iso_8859_6_1987}, - {"arabic7", cs::asmo_449}, - {"ascii", cs::ansi_x3_4_1968}, - {"asmo449", cs::asmo_449}, - {"asmo708", cs::iso_8859_6_1987}, - {"big5", cs::big5}, - {"big5hkscs", cs::big5_hkscs}, - {"bocu1", cs::bocu_1}, - {"brf", cs::brf}, - {"bs4730", cs::bs_4730}, - {"bsviewdata", cs::bs_viewdata}, - {"ca", cs::csa_z243_4_1985_1}, - {"ccsid00858", cs::ibm00858}, - {"ccsid00924", cs::ibm00924}, - {"ccsid01140", cs::ibm01140}, - {"ccsid01141", cs::ibm01141}, - {"ccsid01142", cs::ibm01142}, - {"ccsid01143", cs::ibm01143}, - {"ccsid01144", cs::ibm01144}, - {"ccsid01145", cs::ibm01145}, - {"ccsid01146", cs::ibm01146}, - {"ccsid01147", cs::ibm01147}, - {"ccsid01148", cs::ibm01148}, - {"ccsid01149", cs::ibm01149}, - {"cesu8", cs::cesu_8}, - {"chinese", cs::gb_2312_80}, - {"cn", cs::gb_1988_80}, - {"cp00858", cs::ibm00858}, - {"cp00924", cs::ibm00924}, - {"cp01140", cs::ibm01140}, - {"cp01141", cs::ibm01141}, - {"cp01142", cs::ibm01142}, - {"cp01143", cs::ibm01143}, - {"cp01144", cs::ibm01144}, - {"cp01145", cs::ibm01145}, - {"cp01146", cs::ibm01146}, - {"cp01147", cs::ibm01147}, - {"cp01148", cs::ibm01148}, - {"cp01149", cs::ibm01149}, - {"cp037", cs::ibm037}, - {"cp038", cs::ibm038}, - {"cp1026", cs::ibm1026}, - {"cp154", cs::ptcp154}, - {"cp273", cs::ibm273}, - {"cp274", cs::ibm274}, - {"cp275", cs::ibm275}, - {"cp278", cs::ibm278}, - {"cp280", cs::ibm280}, - {"cp281", cs::ibm281}, - {"cp284", cs::ibm284}, - {"cp285", cs::ibm285}, - {"cp290", cs::ibm290}, - {"cp297", cs::ibm297}, - {"cp367", cs::ansi_x3_4_1968}, - {"cp420", cs::ibm420}, - {"cp423", cs::ibm423}, - {"cp424", cs::ibm424}, - {"cp437", cs::ibm437}, - {"cp500", cs::ibm500}, - {"cp775", cs::ibm775}, - {"cp819", cs::iso_8859_1_1987}, - {"cp850", cs::ibm850}, - {"cp851", cs::ibm851}, - {"cp852", cs::ibm852}, - {"cp855", cs::ibm855}, - {"cp857", cs::ibm857}, - {"cp860", cs::ibm860}, - {"cp861", cs::ibm861}, - {"cp862", cs::ibm862}, - {"cp863", cs::ibm863}, - {"cp864", cs::ibm864}, - {"cp865", cs::ibm865}, - {"cp866", cs::ibm866}, - {"cp868", cs::ibm868}, - {"cp869", cs::ibm869}, - {"cp870", cs::ibm870}, - {"cp871", cs::ibm871}, - {"cp880", cs::ibm880}, - {"cp891", cs::ibm891}, - {"cp903", cs::ibm903}, - {"cp904", cs::ibm904}, - {"cp905", cs::ibm905}, - {"cp918", cs::ibm918}, - {"cp936", cs::gbk}, - {"cpar", cs::ibm868}, - {"cpgr", cs::ibm869}, - {"cpis", cs::ibm861}, - {"csa7_1", cs::csa_z243_4_1985_1}, - {"csa7_2", cs::csa_z243_4_1985_2}, - {"csadobestandardencoding", cs::adobe_standard_encoding}, - {"csascii", cs::ansi_x3_4_1968}, - {"csat500_1983", cs::ansi_x3_110_1983}, - {"csaz243_4_1985_1", cs::csa_z243_4_1985_1}, - {"csaz243_4_1985_2", cs::csa_z243_4_1985_2}, - {"csaz243_4_1985gr", cs::csa_z243_4_1985_gr}, - {"csbig5", cs::big5}, - {"csbocu1", cs::bocu_1}, - {"csbrf", cs::brf}, - {"cscesu8", cs::cesu_8}, - {"csdecmcs", cs::dec_mcs}, - {"csdkus", cs::dk_us}, - {"csebcdicatdea", cs::ebcdic_at_de_a}, - {"csebcdiccafr", cs::ebcdic_ca_fr}, - {"csebcdicdkno", cs::ebcdic_dk_no}, - {"csebcdicdknoa", cs::ebcdic_dk_no_a}, - {"csebcdices", cs::ebcdic_es}, - {"csebcdicesa", cs::ebcdic_es_a}, - {"csebcdicess", cs::ebcdic_es_s}, - {"csebcdicfise", cs::ebcdic_fi_se}, - {"csebcdicfisea", cs::ebcdic_fi_se_a}, - {"csebcdicfr", cs::ebcdic_fr}, - {"csebcdicit", cs::ebcdic_it}, - {"csebcdicpt", cs::ebcdic_pt}, - {"csebcdicuk", cs::ebcdic_uk}, - {"csebcdicus", cs::ebcdic_us}, - {"cseucfixwidjapanese", cs::extended_unix_code_fixed_width_for_japanese}, - {"cseuckr", cs::euc_kr}, - {"cseucpkdfmtjapanese", cs::extended_unix_code_packed_format_for_japanese}, - {"csgb2312", cs::gb2312}, - {"cshalfwidthkatakana", cs::jis_x0201}, - {"cshpdesktop", cs::hp_desktop}, - {"cshplegal", cs::hp_legal}, - {"cshpmath8", cs::hp_math8}, - {"cshppifont", cs::hp_pi_font}, - {"cshppsmath", cs::adobe_symbol_encoding}, - {"cshproman8", cs::hp_roman8}, - {"csibbm904", cs::ibm904}, - {"csibm037", cs::ibm037}, - {"csibm038", cs::ibm038}, - {"csibm1026", cs::ibm1026}, - {"csibm273", cs::ibm273}, - {"csibm274", cs::ibm274}, - {"csibm275", cs::ibm275}, - {"csibm277", cs::ibm277}, - {"csibm278", cs::ibm278}, - {"csibm280", cs::ibm280}, - {"csibm281", cs::ibm281}, - {"csibm284", cs::ibm284}, - {"csibm285", cs::ibm285}, - {"csibm290", cs::ibm290}, - {"csibm297", cs::ibm297}, - {"csibm420", cs::ibm420}, - {"csibm423", cs::ibm423}, - {"csibm424", cs::ibm424}, - {"csibm500", cs::ibm500}, - {"csibm851", cs::ibm851}, - {"csibm855", cs::ibm855}, - {"csibm857", cs::ibm857}, - {"csibm860", cs::ibm860}, - {"csibm861", cs::ibm861}, - {"csibm863", cs::ibm863}, - {"csibm864", cs::ibm864}, - {"csibm865", cs::ibm865}, - {"csibm866", cs::ibm866}, - {"csibm868", cs::ibm868}, - {"csibm869", cs::ibm869}, - {"csibm870", cs::ibm870}, - {"csibm871", cs::ibm871}, - {"csibm880", cs::ibm880}, - {"csibm891", cs::ibm891}, - {"csibm903", cs::ibm903}, - {"csibm905", cs::ibm905}, - {"csibm918", cs::ibm918}, - {"csibmebcdicatde", cs::ebcdic_at_de}, - {"csibmsymbols", cs::ibm_symbols}, - {"csibmthai", cs::ibm_thai}, - {"csinvariant", cs::invariant}, - {"csiso102t617bit", cs::t_61_7bit}, - {"csiso10367box", cs::iso_10367_box}, - {"csiso103t618bit", cs::t_61_8bit}, - {"csiso10646utf1", cs::iso_10646_utf_1}, - {"csiso10swedish", cs::sen_850200_b}, - {"csiso111ecmacyrillic", cs::ecma_cyrillic}, - {"csiso115481", cs::iso_11548_1}, - {"csiso11swedishfornames", cs::sen_850200_c}, - {"csiso121canadian1", cs::csa_z243_4_1985_1}, - {"csiso122canadian2", cs::csa_z243_4_1985_2}, - {"csiso123csaz24341985gr", cs::csa_z243_4_1985_gr}, - {"csiso128t101g2", cs::t_101_g2}, - {"csiso139csn369103", cs::csn_369103}, - {"csiso13jisc6220jp", cs::jis_c6220_1969_jp}, - {"csiso141jusib1002", cs::jus_i_b1_002}, - {"csiso143iecp271", cs::iec_p27_1}, - {"csiso146serbian", cs::jus_i_b1_003_serb}, - {"csiso147macedonian", cs::jus_i_b1_003_mac}, - {"csiso14jisc6220ro", cs::jis_c6220_1969_ro}, - {"csiso150", cs::greek_ccitt}, - {"csiso150greekccitt", cs::greek_ccitt}, - {"csiso151cuba", cs::nc_nc00_10_81}, - {"csiso153gost1976874", cs::gost_19768_74}, - {"csiso158lap", cs::latin_lap}, - {"csiso159jisx02121990", cs::jis_x0212_1990}, - {"csiso15italian", cs::it}, - {"csiso16portuguese", cs::pt}, - {"csiso17spanish", cs::es}, - {"csiso18greek7old", cs::greek7_old}, - {"csiso19latingreek", cs::latin_greek}, - {"csiso2022jp", cs::iso_2022_jp}, - {"csiso2022jp2", cs::iso_2022_jp_2}, - {"csiso2022kr", cs::iso_2022_kr}, - {"csiso2033", cs::iso_2033_1983}, - {"csiso21german", cs::din_66003}, - {"csiso25french", cs::nf_z_62_010__1973_}, - {"csiso27latingreek1", cs::latin_greek_1}, - {"csiso2intlrefversion", cs::iso_646_irv_1983}, - {"csiso42jisc62261978", cs::jis_c6226_1978}, - {"csiso47bsviewdata", cs::bs_viewdata}, - {"csiso49inis", cs::inis}, - {"csiso4unitedkingdom", cs::bs_4730}, - {"csiso50inis8", cs::inis_8}, - {"csiso51iniscyrillic", cs::inis_cyrillic}, - {"csiso5427cyrillic", cs::iso_5427}, - {"csiso5428greek", cs::iso_5428_1980}, - {"csiso57gb1988", cs::gb_1988_80}, - {"csiso58gb231280", cs::gb_2312_80}, - {"csiso60danishnorwegian", cs::ns_4551_1}, - {"csiso60norwegian1", cs::ns_4551_1}, - {"csiso61norwegian2", cs::ns_4551_2}, - {"csiso646basic1983", cs::iso_646_basic_1983}, - {"csiso646danish", cs::ds_2089}, - {"csiso6937add", cs::iso_6937_2_25}, - {"csiso69french", cs::nf_z_62_010}, - {"csiso70videotexsupp1", cs::videotex_suppl}, - {"csiso84portuguese2", cs::pt2}, - {"csiso85spanish2", cs::es2}, - {"csiso86hungarian", cs::msz_7795_3}, - {"csiso87jisx0208", cs::jis_c6226_1983}, - {"csiso88596e", cs::iso_8859_6_e}, - {"csiso88596i", cs::iso_8859_6_i}, - {"csiso88598e", cs::iso_8859_8_e}, - {"csiso88598i", cs::iso_8859_8_i}, - {"csiso8859supp", cs::iso_8859_supp}, - {"csiso88greek7", cs::greek7}, - {"csiso89asmo449", cs::asmo_449}, - {"csiso90", cs::iso_ir_90}, - {"csiso91jisc62291984a", cs::jis_c6229_1984_a}, - {"csiso92jisc62991984b", cs::jis_c6229_1984_b}, - {"csiso93jis62291984badd", cs::jis_c6229_1984_b_add}, - {"csiso94jis62291984hand", cs::jis_c6229_1984_hand}, - {"csiso95jis62291984handadd", cs::jis_c6229_1984_hand_add}, - {"csiso96jisc62291984kana", cs::jis_c6229_1984_kana}, - {"csiso99naplps", cs::ansi_x3_110_1983}, - {"csisolatin1", cs::iso_8859_1_1987}, - {"csisolatin2", cs::iso_8859_2_1987}, - {"csisolatin3", cs::iso_8859_3_1988}, - {"csisolatin4", cs::iso_8859_4_1988}, - {"csisolatin5", cs::iso_8859_9_1989}, - {"csisolatin6", cs::iso_8859_10}, - {"csisolatinarabic", cs::iso_8859_6_1987}, - {"csisolatincyrillic", cs::iso_8859_5_1988}, - {"csisolatingreek", cs::iso_8859_7_1987}, - {"csisolatinhebrew", cs::iso_8859_8_1988}, - {"csisotextcomm", cs::iso_6937_2_add}, - {"csjisencoding", cs::jis_encoding}, - {"cskoi8r", cs::koi8_r}, - {"csksc56011987", cs::ks_c_5601_1987}, - {"csksc5636", cs::ksc5636}, - {"cskz1048", cs::kz_1048}, - {"csmacintosh", cs::macintosh}, - {"csmicrosoftpublishing", cs::microsoft_publishing}, - {"csmnem", cs::mnem}, - {"csmnemonic", cs::mnemonic}, - {"csn369103", cs::csn_369103}, - {"csnatsdano", cs::nats_dano}, - {"csnatsdanoadd", cs::nats_dano_add}, - {"csnatssefi", cs::nats_sefi}, - {"csnatssefiadd", cs::nats_sefi_add}, - {"cspc775baltic", cs::ibm775}, - {"cspc850multilingual", cs::ibm850}, - {"cspc862latinhebrew", cs::ibm862}, - {"cspc8codepage437", cs::ibm437}, - {"cspc8danishnorwegian", cs::pc8_danish_norwegian}, - {"cspc8turkish", cs::pc8_turkish}, - {"cspcp852", cs::ibm852}, - {"csptcp154", cs::ptcp154}, - {"csshiftjis", cs::shift_jis}, - {"cstscii", cs::tscii}, - {"csucs4", cs::iso_10646_ucs_4}, - {"csunicode", cs::iso_10646_ucs_2}, - {"csunicode11", cs::unicode_1_1}, - {"csunicode11utf7", cs::unicode_1_1_utf_7}, - {"csunicodeascii", cs::iso_10646_ucs_basic}, - {"csunicodeibm1261", cs::iso_unicode_ibm_1261}, - {"csunicodeibm1264", cs::iso_unicode_ibm_1264}, - {"csunicodeibm1265", cs::iso_unicode_ibm_1265}, - {"csunicodeibm1268", cs::iso_unicode_ibm_1268}, - {"csunicodeibm1276", cs::iso_unicode_ibm_1276}, - {"csunicodelatin1", cs::iso_10646_unicode_latin1}, - {"csunknown8bit", cs::unknown_8bit}, - {"csusdk", cs::us_dk}, - {"csventurainternational", cs::ventura_international}, - {"csventuramath", cs::ventura_math}, - {"csventuraus", cs::ventura_us}, - {"csviqr", cs::viqr}, - {"csviscii", cs::viscii}, - {"cswindows30latin1", cs::iso_8859_1_windows_3_0_latin_1}, - {"cswindows31j", cs::windows_31j}, - {"cswindows31latin1", cs::iso_8859_1_windows_3_1_latin_1}, - {"cswindows31latin2", cs::iso_8859_2_windows_latin_2}, - {"cswindows31latin5", cs::iso_8859_9_windows_latin_5}, - {"cuba", cs::nc_nc00_10_81}, - {"cyrillic", cs::iso_8859_5_1988}, - {"cyrillicasian", cs::ptcp154}, - {"de", cs::din_66003}, - {"dec", cs::dec_mcs}, - {"decmcs", cs::dec_mcs}, - {"din66003", cs::din_66003}, - {"dk", cs::ds_2089}, - {"dkus", cs::dk_us}, - {"ds2089", cs::ds_2089}, - {"e13b", cs::iso_2033_1983}, - {"ebcdicatde", cs::ebcdic_at_de}, - {"ebcdicatdea", cs::ebcdic_at_de_a}, - {"ebcdicbe", cs::ibm274}, - {"ebcdicbr", cs::ibm275}, - {"ebcdiccafr", cs::ebcdic_ca_fr}, - {"ebcdiccpar1", cs::ibm420}, - {"ebcdiccpar2", cs::ibm918}, - {"ebcdiccpbe", cs::ibm500}, - {"ebcdiccpca", cs::ibm037}, - {"ebcdiccpch", cs::ibm500}, - {"ebcdiccpdk", cs::ibm277}, - {"ebcdiccpes", cs::ibm284}, - {"ebcdiccpfi", cs::ibm278}, - {"ebcdiccpfr", cs::ibm297}, - {"ebcdiccpgb", cs::ibm285}, - {"ebcdiccpgr", cs::ibm423}, - {"ebcdiccphe", cs::ibm424}, - {"ebcdiccpis", cs::ibm871}, - {"ebcdiccpit", cs::ibm280}, - {"ebcdiccpnl", cs::ibm037}, - {"ebcdiccpno", cs::ibm277}, - {"ebcdiccproece", cs::ibm870}, - {"ebcdiccpse", cs::ibm278}, - {"ebcdiccptr", cs::ibm905}, - {"ebcdiccpus", cs::ibm037}, - {"ebcdiccpwt", cs::ibm037}, - {"ebcdiccpyu", cs::ibm870}, - {"ebcdiccyrillic", cs::ibm880}, - {"ebcdicde273euro", cs::ibm01141}, - {"ebcdicdk277euro", cs::ibm01142}, - {"ebcdicdkno", cs::ebcdic_dk_no}, - {"ebcdicdknoa", cs::ebcdic_dk_no_a}, - {"ebcdices", cs::ebcdic_es}, - {"ebcdices284euro", cs::ibm01145}, - {"ebcdicesa", cs::ebcdic_es_a}, - {"ebcdicess", cs::ebcdic_es_s}, - {"ebcdicfi278euro", cs::ibm01143}, - {"ebcdicfise", cs::ebcdic_fi_se}, - {"ebcdicfisea", cs::ebcdic_fi_se_a}, - {"ebcdicfr", cs::ebcdic_fr}, - {"ebcdicfr297euro", cs::ibm01147}, - {"ebcdicgb285euro", cs::ibm01146}, - {"ebcdicint", cs::ibm038}, - {"ebcdicinternational500euro", cs::ibm01148}, - {"ebcdicis871euro", cs::ibm01149}, - {"ebcdicit", cs::ebcdic_it}, - {"ebcdicit280euro", cs::ibm01144}, - {"ebcdicjpe", cs::ibm281}, - {"ebcdicjpkana", cs::ibm290}, - {"ebcdiclatin9euro", cs::ibm00924}, - {"ebcdicno277euro", cs::ibm01142}, - {"ebcdicpt", cs::ebcdic_pt}, - {"ebcdicse278euro", cs::ibm01143}, - {"ebcdicuk", cs::ebcdic_uk}, - {"ebcdicus", cs::ebcdic_us}, - {"ebcdicus37euro", cs::ibm01140}, - {"ecma114", cs::iso_8859_6_1987}, - {"ecma118", cs::iso_8859_7_1987}, - {"ecmacyrillic", cs::ecma_cyrillic}, - {"elot928", cs::iso_8859_7_1987}, - {"es", cs::es}, - {"es2", cs::es2}, - {"eucjp", cs::extended_unix_code_packed_format_for_japanese}, - {"euckr", cs::euc_kr}, - {"extendedunixcodefixedwidthforjapanese", cs::extended_unix_code_fixed_width_for_japanese}, - {"extendedunixcodepackedformatforjapanese", cs::extended_unix_code_packed_format_for_japanese}, - {"fi", cs::sen_850200_b}, - {"fr", cs::nf_z_62_010}, - {"gb", cs::bs_4730}, - {"gb18030", cs::gb18030}, - {"gb1988_80", cs::gb_1988_80}, - {"gb2312", cs::gb2312}, - {"gb2312_80", cs::gb_2312_80}, - {"gbk", cs::gbk}, - {"gost19768_74", cs::gost_19768_74}, - {"greek", cs::iso_8859_7_1987}, - {"greek7", cs::greek7}, - {"greek7old", cs::greek7_old}, - {"greek8", cs::iso_8859_7_1987}, - {"greekccitt", cs::greek_ccitt}, - {"hebrew", cs::iso_8859_8_1988}, - {"hpdesktop", cs::hp_desktop}, - {"hplegal", cs::hp_legal}, - {"hpmath8", cs::hp_math8}, - {"hppifont", cs::hp_pi_font}, - {"hproman8", cs::hp_roman8}, - {"hu", cs::msz_7795_3}, - {"hzgb2312", cs::hz_gb_2312}, - {"ibm00858", cs::ibm00858}, - {"ibm00924", cs::ibm00924}, - {"ibm01140", cs::ibm01140}, - {"ibm01141", cs::ibm01141}, - {"ibm01142", cs::ibm01142}, - {"ibm01143", cs::ibm01143}, - {"ibm01144", cs::ibm01144}, - {"ibm01145", cs::ibm01145}, - {"ibm01146", cs::ibm01146}, - {"ibm01147", cs::ibm01147}, - {"ibm01148", cs::ibm01148}, - {"ibm01149", cs::ibm01149}, - {"ibm037", cs::ibm037}, - {"ibm038", cs::ibm038}, - {"ibm1026", cs::ibm1026}, - {"ibm1047", cs::ibm1047}, - {"ibm273", cs::ibm273}, - {"ibm274", cs::ibm274}, - {"ibm275", cs::ibm275}, - {"ibm277", cs::ibm277}, - {"ibm278", cs::ibm278}, - {"ibm280", cs::ibm280}, - {"ibm281", cs::ibm281}, - {"ibm284", cs::ibm284}, - {"ibm285", cs::ibm285}, - {"ibm290", cs::ibm290}, - {"ibm297", cs::ibm297}, - {"ibm367", cs::ansi_x3_4_1968}, - {"ibm420", cs::ibm420}, - {"ibm423", cs::ibm423}, - {"ibm424", cs::ibm424}, - {"ibm437", cs::ibm437}, - {"ibm500", cs::ibm500}, - {"ibm775", cs::ibm775}, - {"ibm819", cs::iso_8859_1_1987}, - {"ibm850", cs::ibm850}, - {"ibm851", cs::ibm851}, - {"ibm852", cs::ibm852}, - {"ibm855", cs::ibm855}, - {"ibm857", cs::ibm857}, - {"ibm860", cs::ibm860}, - {"ibm861", cs::ibm861}, - {"ibm862", cs::ibm862}, - {"ibm863", cs::ibm863}, - {"ibm864", cs::ibm864}, - {"ibm865", cs::ibm865}, - {"ibm866", cs::ibm866}, - {"ibm868", cs::ibm868}, - {"ibm869", cs::ibm869}, - {"ibm870", cs::ibm870}, - {"ibm871", cs::ibm871}, - {"ibm880", cs::ibm880}, - {"ibm891", cs::ibm891}, - {"ibm903", cs::ibm903}, - {"ibm904", cs::ibm904}, - {"ibm905", cs::ibm905}, - {"ibm918", cs::ibm918}, - {"ibmsymbols", cs::ibm_symbols}, - {"ibmthai", cs::ibm_thai}, - {"iecp27_1", cs::iec_p27_1}, - {"inis", cs::inis}, - {"inis8", cs::inis_8}, - {"iniscyrillic", cs::inis_cyrillic}, - {"invariant", cs::invariant}, - {"irv", cs::iso_646_irv_1983}, - {"iso10367box", cs::iso_10367_box}, - {"iso10646", cs::iso_10646_unicode_latin1}, - {"iso10646j1", cs::iso_10646_j_1}, - {"iso10646ucs2", cs::iso_10646_ucs_2}, - {"iso10646ucs4", cs::iso_10646_ucs_4}, - {"iso10646ucsbasic", cs::iso_10646_ucs_basic}, - {"iso10646unicodelatin1", cs::iso_10646_unicode_latin1}, - {"iso10646utf1", cs::iso_10646_utf_1}, - {"iso11548_1", cs::iso_11548_1}, - {"iso2022cn", cs::iso_2022_cn}, - {"iso2022cnext", cs::iso_2022_cn_ext}, - {"iso2022jp", cs::iso_2022_jp}, - {"iso2022jp2", cs::iso_2022_jp_2}, - {"iso2022kr", cs::iso_2022_kr}, - {"iso2033_1983", cs::iso_2033_1983}, - {"iso5427", cs::iso_5427}, - {"iso5427_1981", cs::iso_5427_1981}, - {"iso5427cyrillic1981", cs::iso_5427_1981}, - {"iso5428_1980", cs::iso_5428_1980}, - {"iso646basic1983", cs::iso_646_basic_1983}, - {"iso646ca", cs::csa_z243_4_1985_1}, - {"iso646ca2", cs::csa_z243_4_1985_2}, - {"iso646cn", cs::gb_1988_80}, - {"iso646cu", cs::nc_nc00_10_81}, - {"iso646de", cs::din_66003}, - {"iso646dk", cs::ds_2089}, - {"iso646es", cs::es}, - {"iso646es2", cs::es2}, - {"iso646fi", cs::sen_850200_b}, - {"iso646fr", cs::nf_z_62_010}, - {"iso646fr1", cs::nf_z_62_010__1973_}, - {"iso646gb", cs::bs_4730}, - {"iso646hu", cs::msz_7795_3}, - {"iso646irv1983", cs::iso_646_irv_1983}, - {"iso646irv1991", cs::ansi_x3_4_1968}, - {"iso646it", cs::it}, - {"iso646jp", cs::jis_c6220_1969_ro}, - {"iso646jpocrb", cs::jis_c6229_1984_b}, - {"iso646kr", cs::ksc5636}, - {"iso646no", cs::ns_4551_1}, - {"iso646no2", cs::ns_4551_2}, - {"iso646pt", cs::pt}, - {"iso646pt2", cs::pt2}, - {"iso646se", cs::sen_850200_b}, - {"iso646se2", cs::sen_850200_c}, - {"iso646us", cs::ansi_x3_4_1968}, - {"iso646yu", cs::jus_i_b1_002}, - {"iso6937_2_25", cs::iso_6937_2_25}, - {"iso6937_2add", cs::iso_6937_2_add}, - {"iso8859_1", cs::iso_8859_1_1987}, - {"iso8859_10", cs::iso_8859_10}, - {"iso8859_10_1992", cs::iso_8859_10}, - {"iso8859_13", cs::iso_8859_13}, - {"iso8859_14", cs::iso_8859_14}, - {"iso8859_14_1998", cs::iso_8859_14}, - {"iso8859_15", cs::iso_8859_15}, - {"iso8859_16", cs::iso_8859_16}, - {"iso8859_16_2001", cs::iso_8859_16}, - {"iso8859_1_1987", cs::iso_8859_1_1987}, - {"iso8859_1windows3_0latin1", cs::iso_8859_1_windows_3_0_latin_1}, - {"iso8859_1windows3_1latin1", cs::iso_8859_1_windows_3_1_latin_1}, - {"iso8859_2", cs::iso_8859_2_1987}, - {"iso8859_2_1987", cs::iso_8859_2_1987}, - {"iso8859_2windowslatin2", cs::iso_8859_2_windows_latin_2}, - {"iso8859_3", cs::iso_8859_3_1988}, - {"iso8859_3_1988", cs::iso_8859_3_1988}, - {"iso8859_4", cs::iso_8859_4_1988}, - {"iso8859_4_1988", cs::iso_8859_4_1988}, - {"iso8859_5", cs::iso_8859_5_1988}, - {"iso8859_5_1988", cs::iso_8859_5_1988}, - {"iso8859_6", cs::iso_8859_6_1987}, - {"iso8859_6_1987", cs::iso_8859_6_1987}, - {"iso8859_6e", cs::iso_8859_6_e}, - {"iso8859_6i", cs::iso_8859_6_i}, - {"iso8859_7", cs::iso_8859_7_1987}, - {"iso8859_7_1987", cs::iso_8859_7_1987}, - {"iso8859_8", cs::iso_8859_8_1988}, - {"iso8859_8_1988", cs::iso_8859_8_1988}, - {"iso8859_8e", cs::iso_8859_8_e}, - {"iso8859_8i", cs::iso_8859_8_i}, - {"iso8859_9", cs::iso_8859_9_1989}, - {"iso8859_9_1989", cs::iso_8859_9_1989}, - {"iso8859_9windowslatin5", cs::iso_8859_9_windows_latin_5}, - {"iso8859supp", cs::iso_8859_supp}, - {"iso9036", cs::asmo_449}, - {"isoceltic", cs::iso_8859_14}, - {"isoir10", cs::sen_850200_b}, - {"isoir100", cs::iso_8859_1_1987}, - {"isoir101", cs::iso_8859_2_1987}, - {"isoir102", cs::t_61_7bit}, - {"isoir103", cs::t_61_8bit}, - {"isoir109", cs::iso_8859_3_1988}, - {"isoir11", cs::sen_850200_c}, - {"isoir110", cs::iso_8859_4_1988}, - {"isoir111", cs::ecma_cyrillic}, - {"isoir121", cs::csa_z243_4_1985_1}, - {"isoir122", cs::csa_z243_4_1985_2}, - {"isoir123", cs::csa_z243_4_1985_gr}, - {"isoir126", cs::iso_8859_7_1987}, - {"isoir127", cs::iso_8859_6_1987}, - {"isoir128", cs::t_101_g2}, - {"isoir13", cs::jis_c6220_1969_jp}, - {"isoir138", cs::iso_8859_8_1988}, - {"isoir139", cs::csn_369103}, - {"isoir14", cs::jis_c6220_1969_ro}, - {"isoir141", cs::jus_i_b1_002}, - {"isoir142", cs::iso_6937_2_add}, - {"isoir143", cs::iec_p27_1}, - {"isoir144", cs::iso_8859_5_1988}, - {"isoir146", cs::jus_i_b1_003_serb}, - {"isoir147", cs::jus_i_b1_003_mac}, - {"isoir148", cs::iso_8859_9_1989}, - {"isoir149", cs::ks_c_5601_1987}, - {"isoir15", cs::it}, - {"isoir150", cs::greek_ccitt}, - {"isoir151", cs::nc_nc00_10_81}, - {"isoir152", cs::iso_6937_2_25}, - {"isoir153", cs::gost_19768_74}, - {"isoir154", cs::iso_8859_supp}, - {"isoir155", cs::iso_10367_box}, - {"isoir157", cs::iso_8859_10}, - {"isoir158", cs::latin_lap}, - {"isoir159", cs::jis_x0212_1990}, - {"isoir16", cs::pt}, - {"isoir17", cs::es}, - {"isoir18", cs::greek7_old}, - {"isoir19", cs::latin_greek}, - {"isoir199", cs::iso_8859_14}, - {"isoir2", cs::iso_646_irv_1983}, - {"isoir21", cs::din_66003}, - {"isoir226", cs::iso_8859_16}, - {"isoir25", cs::nf_z_62_010__1973_}, - {"isoir27", cs::latin_greek_1}, - {"isoir37", cs::iso_5427}, - {"isoir4", cs::bs_4730}, - {"isoir42", cs::jis_c6226_1978}, - {"isoir47", cs::bs_viewdata}, - {"isoir49", cs::inis}, - {"isoir50", cs::inis_8}, - {"isoir51", cs::inis_cyrillic}, - {"isoir54", cs::iso_5427_1981}, - {"isoir55", cs::iso_5428_1980}, - {"isoir57", cs::gb_1988_80}, - {"isoir58", cs::gb_2312_80}, - {"isoir6", cs::ansi_x3_4_1968}, - {"isoir60", cs::ns_4551_1}, - {"isoir61", cs::ns_4551_2}, - {"isoir69", cs::nf_z_62_010}, - {"isoir70", cs::videotex_suppl}, - {"isoir84", cs::pt2}, - {"isoir85", cs::es2}, - {"isoir86", cs::msz_7795_3}, - {"isoir87", cs::jis_c6226_1983}, - {"isoir88", cs::greek7}, - {"isoir89", cs::asmo_449}, - {"isoir8_1", cs::nats_sefi}, - {"isoir8_2", cs::nats_sefi_add}, - {"isoir90", cs::iso_ir_90}, - {"isoir91", cs::jis_c6229_1984_a}, - {"isoir92", cs::jis_c6229_1984_b}, - {"isoir93", cs::jis_c6229_1984_b_add}, - {"isoir94", cs::jis_c6229_1984_hand}, - {"isoir95", cs::jis_c6229_1984_hand_add}, - {"isoir96", cs::jis_c6229_1984_kana}, - {"isoir98", cs::iso_2033_1983}, - {"isoir99", cs::ansi_x3_110_1983}, - {"isoir9_1", cs::nats_dano}, - {"isoir9_2", cs::nats_dano_add}, - {"isotr11548_1", cs::iso_11548_1}, - {"isounicodeibm1261", cs::iso_unicode_ibm_1261}, - {"isounicodeibm1264", cs::iso_unicode_ibm_1264}, - {"isounicodeibm1265", cs::iso_unicode_ibm_1265}, - {"isounicodeibm1268", cs::iso_unicode_ibm_1268}, - {"isounicodeibm1276", cs::iso_unicode_ibm_1276}, - {"it", cs::it}, - {"jisc6220_1969", cs::jis_c6220_1969_jp}, - {"jisc6220_1969jp", cs::jis_c6220_1969_jp}, - {"jisc6220_1969ro", cs::jis_c6220_1969_ro}, - {"jisc6226_1978", cs::jis_c6226_1978}, - {"jisc6226_1983", cs::jis_c6226_1983}, - {"jisc6229_1984a", cs::jis_c6229_1984_a}, - {"jisc6229_1984b", cs::jis_c6229_1984_b}, - {"jisc6229_1984badd", cs::jis_c6229_1984_b_add}, - {"jisc6229_1984hand", cs::jis_c6229_1984_hand}, - {"jisc6229_1984handadd", cs::jis_c6229_1984_hand_add}, - {"jisc6229_1984kana", cs::jis_c6229_1984_kana}, - {"jisencoding", cs::jis_encoding}, - {"jisx0201", cs::jis_x0201}, - {"jisx0208_1983", cs::jis_c6226_1983}, - {"jisx0212_1990", cs::jis_x0212_1990}, - {"jp", cs::jis_c6220_1969_ro}, - {"jpocra", cs::jis_c6229_1984_a}, - {"jpocrb", cs::jis_c6229_1984_b}, - {"jpocrbadd", cs::jis_c6229_1984_b_add}, - {"jpocrhand", cs::jis_c6229_1984_hand}, - {"jpocrhandadd", cs::jis_c6229_1984_hand_add}, - {"js", cs::jus_i_b1_002}, - {"jusib1_002", cs::jus_i_b1_002}, - {"jusib1_003mac", cs::jus_i_b1_003_mac}, - {"jusib1_003serb", cs::jus_i_b1_003_serb}, - {"katakana", cs::jis_c6220_1969_jp}, - {"koi7switched", cs::koi7_switched}, - {"koi8e", cs::ecma_cyrillic}, - {"koi8r", cs::koi8_r}, - {"koi8u", cs::koi8_u}, - {"korean", cs::ks_c_5601_1987}, - {"ksc5601", cs::ks_c_5601_1987}, - {"ksc5601_1987", cs::ks_c_5601_1987}, - {"ksc5601_1989", cs::ks_c_5601_1987}, - {"ksc5636", cs::ksc5636}, - {"kz1048", cs::kz_1048}, - {"l1", cs::iso_8859_1_1987}, - {"l10", cs::iso_8859_16}, - {"l2", cs::iso_8859_2_1987}, - {"l3", cs::iso_8859_3_1988}, - {"l4", cs::iso_8859_4_1988}, - {"l5", cs::iso_8859_9_1989}, - {"l6", cs::iso_8859_10}, - {"l8", cs::iso_8859_14}, - {"lap", cs::latin_lap}, - {"latin1", cs::iso_8859_1_1987}, - {"latin10", cs::iso_8859_16}, - {"latin1_2_5", cs::iso_8859_supp}, - {"latin2", cs::iso_8859_2_1987}, - {"latin3", cs::iso_8859_3_1988}, - {"latin4", cs::iso_8859_4_1988}, - {"latin5", cs::iso_8859_9_1989}, - {"latin6", cs::iso_8859_10}, - {"latin8", cs::iso_8859_14}, - {"latin9", cs::iso_8859_15}, - {"latingreek", cs::latin_greek}, - {"latingreek1", cs::latin_greek_1}, - {"latinlap", cs::latin_lap}, - {"mac", cs::macintosh}, - {"macedonian", cs::jus_i_b1_003_mac}, - {"macintosh", cs::macintosh}, - {"microsoftpublishing", cs::microsoft_publishing}, - {"mnem", cs::mnem}, - {"mnemonic", cs::mnemonic}, - {"ms936", cs::gbk}, - {"mskanji", cs::shift_jis}, - {"msz7795_3", cs::msz_7795_3}, - {"naplps", cs::ansi_x3_110_1983}, - {"natsdano", cs::nats_dano}, - {"natsdanoadd", cs::nats_dano_add}, - {"natssefi", cs::nats_sefi}, - {"natssefiadd", cs::nats_sefi_add}, - {"ncnc00_10_81", cs::nc_nc00_10_81}, - {"nfz62_010", cs::nf_z_62_010}, - {"nfz62_010_1973", cs::nf_z_62_010__1973_}, - {"no", cs::ns_4551_1}, - {"no2", cs::ns_4551_2}, - {"ns4551_1", cs::ns_4551_1}, - {"ns4551_2", cs::ns_4551_2}, - {"osdebcdicdf03irv", cs::osd_ebcdic_df03_irv}, - {"osdebcdicdf04_1", cs::osd_ebcdic_df04_1}, - {"osdebcdicdf04_15", cs::osd_ebcdic_df04_15}, - {"pc8danishnorwegian", cs::pc8_danish_norwegian}, - {"pc8turkish", cs::pc8_turkish}, - {"pcmultilingual850euro", cs::ibm00858}, - {"pt", cs::pt}, - {"pt154", cs::ptcp154}, - {"pt2", cs::pt2}, - {"ptcp154", cs::ptcp154}, - {"r8", cs::hp_roman8}, - {"ref", cs::iso_646_basic_1983}, - {"rk1048", cs::kz_1048}, - {"roman8", cs::hp_roman8}, - {"scsu", cs::scsu}, - {"se", cs::sen_850200_b}, - {"se2", cs::sen_850200_c}, - {"sen850200b", cs::sen_850200_b}, - {"sen850200c", cs::sen_850200_c}, - {"serbian", cs::jus_i_b1_003_serb}, - {"shiftjis", cs::shift_jis}, - {"strk1048_2002", cs::kz_1048}, - {"stsev358_88", cs::gost_19768_74}, - {"t101g2", cs::t_101_g2}, - {"t61", cs::t_61_8bit}, - {"t61_7bit", cs::t_61_7bit}, - {"t61_8bit", cs::t_61_8bit}, - {"tis620", cs::tis_620}, - {"tscii", cs::tscii}, - {"ucs2", cs::iso_10646_ucs_2}, - {"ucs4", cs::iso_10646_ucs_4}, - {"uk", cs::bs_4730}, - {"unicode1_1", cs::unicode_1_1}, - {"unicode1_1utf7", cs::unicode_1_1_utf_7}, - {"unknown8bit", cs::unknown_8bit}, - {"us", cs::ansi_x3_4_1968}, - {"usascii", cs::ansi_x3_4_1968}, - {"usdk", cs::us_dk}, - {"utf16", cs::utf_16}, - {"utf16be", cs::utf_16be}, - {"utf16le", cs::utf_16le}, - {"utf32", cs::utf_32}, - {"utf32be", cs::utf_32be}, - {"utf32le", cs::utf_32le}, - {"utf7", cs::utf_7}, - {"utf8", cs::utf_8}, - {"venturainternational", cs::ventura_international}, - {"venturamath", cs::ventura_math}, - {"venturaus", cs::ventura_us}, - {"videotexsuppl", cs::videotex_suppl}, - {"viqr", cs::viqr}, - {"viscii", cs::viscii}, - {"windows1250", cs::windows_1250}, - {"windows1251", cs::windows_1251}, - {"windows1252", cs::windows_1252}, - {"windows1253", cs::windows_1253}, - {"windows1254", cs::windows_1254}, - {"windows1255", cs::windows_1255}, - {"windows1256", cs::windows_1256}, - {"windows1257", cs::windows_1257}, - {"windows1258", cs::windows_1258}, - {"windows31j", cs::windows_31j}, - {"windows936", cs::gbk}, - {"x0201", cs::jis_x0201}, - {"x0201_7", cs::jis_c6220_1969_jp}, - {"x0208", cs::jis_c6226_1983}, - {"x0212", cs::jis_x0212_1990}, - {"yu", cs::jus_i_b1_002}, diff --git a/extras/anytermd/libpbe/src/generated/charset_mime_names_body.cc b/extras/anytermd/libpbe/src/generated/charset_mime_names_body.cc deleted file mode 100644 index d12b79d806..0000000000 --- a/extras/anytermd/libpbe/src/generated/charset_mime_names_body.cc +++ /dev/null @@ -1,257 +0,0 @@ -const char * const charset_mime_names[] = { - "US-ASCII", - "ISO-8859-1", - "ISO-8859-2", - "ISO-8859-3", - "ISO-8859-4", - "ISO-8859-5", - "ISO-8859-6", - "ISO-8859-7", - "ISO-8859-8", - "ISO-8859-9", - "ISO-8859-10", - "ISO_6937-2-add", - "JIS_X0201", - "JIS_Encoding", - "Shift_JIS", - "EUC-JP", - "Extended_UNIX_Code_Fixed_Width_for_Japanese", - "BS_4730", - "SEN_850200_C", - "IT", - "ES", - "DIN_66003", - "NS_4551-1", - "NF_Z_62-010", - "ISO-10646-UTF-1", - "ISO_646.basic:1983", - "INVARIANT", - "ISO_646.irv:1983", - "NATS-SEFI", - "NATS-SEFI-ADD", - "NATS-DANO", - "NATS-DANO-ADD", - "SEN_850200_B", - "KS_C_5601-1987", - "ISO-2022-KR", - "EUC-KR", - "ISO-2022-JP", - "ISO-2022-JP-2", - "JIS_C6220-1969-jp", - "JIS_C6220-1969-ro", - "PT", - "greek7-old", - "latin-greek", - "NF_Z_62-010_(1973)", - "Latin-greek-1", - "ISO_5427", - "JIS_C6226-1978", - "BS_viewdata", - "INIS", - "INIS-8", - "INIS-cyrillic", - "ISO_5427:1981", - "ISO_5428:1980", - "GB_1988-80", - "GB_2312-80", - "NS_4551-2", - "videotex-suppl", - "PT2", - "ES2", - "MSZ_7795.3", - "JIS_C6226-1983", - "greek7", - "ASMO_449", - "iso-ir-90", - "JIS_C6229-1984-a", - "JIS_C6229-1984-b", - "JIS_C6229-1984-b-add", - "JIS_C6229-1984-hand", - "JIS_C6229-1984-hand-add", - "JIS_C6229-1984-kana", - "ISO_2033-1983", - "ANSI_X3.110-1983", - "T.61-7bit", - "T.61-8bit", - "ECMA-cyrillic", - "CSA_Z243.4-1985-1", - "CSA_Z243.4-1985-2", - "CSA_Z243.4-1985-gr", - "ISO-8859-6-E", - "ISO-8859-6-I", - "T.101-G2", - "ISO-8859-8-E", - "ISO-8859-8-I", - "CSN_369103", - "JUS_I.B1.002", - "IEC_P27-1", - "JUS_I.B1.003-serb", - "JUS_I.B1.003-mac", - "greek-ccitt", - "NC_NC00-10:81", - "ISO_6937-2-25", - "GOST_19768-74", - "ISO_8859-supp", - "ISO_10367-box", - "latin-lap", - "JIS_X0212-1990", - "DS_2089", - "us-dk", - "dk-us", - "KSC5636", - "UNICODE-1-1-UTF-7", - "ISO-2022-CN", - "ISO-2022-CN-EXT", - "UTF-8", - "ISO-8859-13", - "ISO-8859-14", - "ISO-8859-15", - "ISO-8859-16", - "GBK", - "GB18030", - "OSD_EBCDIC_DF04_15", - "OSD_EBCDIC_DF03_IRV", - "OSD_EBCDIC_DF04_1", - "ISO-11548-1", - "KZ-1048", - "ISO-10646-UCS-2", - "ISO-10646-UCS-4", - "ISO-10646-UCS-Basic", - "ISO-10646-Unicode-Latin1", - "ISO-10646-J-1", - "ISO-Unicode-IBM-1261", - "ISO-Unicode-IBM-1268", - "ISO-Unicode-IBM-1276", - "ISO-Unicode-IBM-1264", - "ISO-Unicode-IBM-1265", - "UNICODE-1-1", - "SCSU", - "UTF-7", - "UTF-16BE", - "UTF-16LE", - "UTF-16", - "CESU-8", - "UTF-32", - "UTF-32BE", - "UTF-32LE", - "BOCU-1", - "ISO-8859-1-Windows-3.0-Latin-1", - "ISO-8859-1-Windows-3.1-Latin-1", - "ISO-8859-2-Windows-Latin-2", - "ISO-8859-9-Windows-Latin-5", - "hp-roman8", - "Adobe-Standard-Encoding", - "Ventura-US", - "Ventura-International", - "DEC-MCS", - "IBM850", - "PC8-Danish-Norwegian", - "IBM862", - "PC8-Turkish", - "IBM-Symbols", - "IBM-Thai", - "HP-Legal", - "HP-Pi-font", - "HP-Math8", - "Adobe-Symbol-Encoding", - "HP-DeskTop", - "Ventura-Math", - "Microsoft-Publishing", - "Windows-31J", - "GB2312", - "Big5", - "macintosh", - "IBM037", - "IBM038", - "IBM273", - "IBM274", - "IBM275", - "IBM277", - "IBM278", - "IBM280", - "IBM281", - "IBM284", - "IBM285", - "IBM290", - "IBM297", - "IBM420", - "IBM423", - "IBM424", - "IBM437", - "IBM500", - "IBM851", - "IBM852", - "IBM855", - "IBM857", - "IBM860", - "IBM861", - "IBM863", - "IBM864", - "IBM865", - "IBM868", - "IBM869", - "IBM870", - "IBM871", - "IBM880", - "IBM891", - "IBM903", - "IBM904", - "IBM905", - "IBM918", - "IBM1026", - "EBCDIC-AT-DE", - "EBCDIC-AT-DE-A", - "EBCDIC-CA-FR", - "EBCDIC-DK-NO", - "EBCDIC-DK-NO-A", - "EBCDIC-FI-SE", - "EBCDIC-FI-SE-A", - "EBCDIC-FR", - "EBCDIC-IT", - "EBCDIC-PT", - "EBCDIC-ES", - "EBCDIC-ES-A", - "EBCDIC-ES-S", - "EBCDIC-UK", - "EBCDIC-US", - "UNKNOWN-8BIT", - "MNEMONIC", - "MNEM", - "VISCII", - "VIQR", - "KOI8-R", - "HZ-GB-2312", - "IBM866", - "IBM775", - "KOI8-U", - "IBM00858", - "IBM00924", - "IBM01140", - "IBM01141", - "IBM01142", - "IBM01143", - "IBM01144", - "IBM01145", - "IBM01146", - "IBM01147", - "IBM01148", - "IBM01149", - "Big5-HKSCS", - "IBM1047", - "PTCP154", - "Amiga-1251", - "KOI7-switched", - "BRF", - "TSCII", - "windows-1250", - "windows-1251", - "windows-1252", - "windows-1253", - "windows-1254", - "windows-1255", - "windows-1256", - "windows-1257", - "windows-1258", - "TIS-620", - NULL -}; diff --git a/extras/anytermd/libpbe/src/generated/iso8859_tables_body.cc b/extras/anytermd/libpbe/src/generated/iso8859_tables_body.cc deleted file mode 100644 index bb141a0f06..0000000000 --- a/extras/anytermd/libpbe/src/generated/iso8859_tables_body.cc +++ /dev/null @@ -1,32 +0,0 @@ -iso8859_table_t iso8859_tables[] = { - // ISO-8859-2 - { 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7, 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B, 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7, 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C, 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7, 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF, 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9,}, - // ISO-8859-3 - { 0x0126, 0x02D8, 0x00A3, 0x00A4, -1, 0x0124, 0x00A7, 0x00A8, 0x0130, 0x015E, 0x011E, 0x0134, 0x00AD, -1, 0x017B, 0x00B0, 0x0127, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x0125, 0x00B7, 0x00B8, 0x0131, 0x015F, 0x011F, 0x0135, 0x00BD, -1, 0x017C, 0x00C0, 0x00C1, 0x00C2, -1, 0x00C4, 0x010A, 0x0108, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, -1, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x0120, 0x00D6, 0x00D7, 0x011C, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x016C, 0x015C, 0x00DF, 0x00E0, 0x00E1, 0x00E2, -1, 0x00E4, 0x010B, 0x0109, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, -1, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x0121, 0x00F6, 0x00F7, 0x011D, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x016D, 0x015D, 0x02D9,}, - // ISO-8859-4 - { 0x0104, 0x0138, 0x0156, 0x00A4, 0x0128, 0x013B, 0x00A7, 0x00A8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00AD, 0x017D, 0x00AF, 0x00B0, 0x0105, 0x02DB, 0x0157, 0x00B4, 0x0129, 0x013C, 0x02C7, 0x00B8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014A, 0x017E, 0x014B, 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E, 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x012A, 0x0110, 0x0145, 0x014C, 0x0136, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x0168, 0x016A, 0x00DF, 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F, 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x012B, 0x0111, 0x0146, 0x014D, 0x0137, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x0169, 0x016B, 0x02D9,}, - // ISO-8859-5 - { 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407, 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x00AD, 0x040E, 0x040F, 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, 0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457, 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00A7, 0x045E, 0x045F,}, - // ISO-8859-6 - { -1, -1, -1, 0x00A4, -1, -1, -1, -1, -1, -1, -1, 0x060C, 0x00AD, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0x061B, -1, -1, -1, 0x061F, -1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, -1, -1, -1, -1, -1, 0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x0651, 0x0652,}, - // ISO-8859-7 - { 0x2018, 0x2019, 0x00A3, 0x20AC, 0x20AF, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x037A, 0x00AB, 0x00AC, 0x00AD, -1, 0x2015, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x0385, 0x0386, 0x00B7, 0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F, 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, 0x03A1, -1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF, 0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE,}, - // ISO-8859-8 - { -1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0x2017, 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, -1, -1, 0x200E, 0x200F,}, - // ISO-8859-9 - { 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x011E, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x0130, 0x015E, 0x00DF, 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF,}, - // ISO-8859-10 - { 0x0104, 0x0112, 0x0122, 0x012A, 0x0128, 0x0136, 0x00A7, 0x013B, 0x0110, 0x0160, 0x0166, 0x017D, 0x00AD, 0x016A, 0x014A, 0x00B0, 0x0105, 0x0113, 0x0123, 0x012B, 0x0129, 0x0137, 0x00B7, 0x013C, 0x0111, 0x0161, 0x0167, 0x017E, 0x2015, 0x016B, 0x014B, 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E, 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x00CF, 0x00D0, 0x0145, 0x014C, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x0168, 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F, 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x00EF, 0x00F0, 0x0146, 0x014D, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x0169, 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x0138,}, - // ISO-8859-11 - { 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07, 0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F, 0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17, 0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F, 0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27, 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F, 0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37, 0x0E38, 0x0E39, 0x0E3A, -1, -1, -1, -1, 0x0E3F, 0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47, 0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F, 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57, 0x0E58, 0x0E59, 0x0E5A, 0x0E5B,}, - // ISO-8859-12 does not exist - {}, - // ISO-8859-13 - { 0x201D, 0x00A2, 0x00A3, 0x00A4, 0x201E, 0x00A6, 0x00A7, 0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00C6, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x201C, 0x00B5, 0x00B6, 0x00B7, 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6, 0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112, 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B, 0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, 0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF, 0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C, 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7, 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x2019,}, - // ISO-8859-14 - { 0x1E02, 0x1E03, 0x00A3, 0x010A, 0x010B, 0x1E0A, 0x00A7, 0x1E80, 0x00A9, 0x1E82, 0x1E0B, 0x1EF2, 0x00AD, 0x00AE, 0x0178, 0x1E1E, 0x1E1F, 0x0120, 0x0121, 0x1E40, 0x1E41, 0x00B6, 0x1E56, 0x1E81, 0x1E57, 0x1E83, 0x1E60, 0x1EF3, 0x1E84, 0x1E85, 0x1E61, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x0174, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x1E6A, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x0176, 0x00DF, 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x0175, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x1E6B, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x0177, 0x00FF,}, - // ISO-8859-15 - { 0x00A1, 0x00A2, 0x00A3, 0x20AC, 0x00A5, 0x0160, 0x00A7, 0x0161, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x017D, 0x00B5, 0x00B6, 0x00B7, 0x017E, 0x00B9, 0x00BA, 0x00BB, 0x0152, 0x0153, 0x0178, 0x00BF, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF,}, - // ISO-8859-16 - { 0x0104, 0x0105, 0x0141, 0x20AC, 0x201E, 0x0160, 0x00A7, 0x0161, 0x00A9, 0x0218, 0x00AB, 0x0179, 0x00AD, 0x017A, 0x017B, 0x00B0, 0x00B1, 0x010C, 0x0142, 0x017D, 0x201D, 0x00B6, 0x00B7, 0x017E, 0x010D, 0x0219, 0x00BB, 0x0152, 0x0153, 0x0178, 0x017C, 0x00C0, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0106, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x0110, 0x0143, 0x00D2, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x015A, 0x0170, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x0118, 0x021A, 0x00DF, 0x00E0, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x0107, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x0111, 0x0144, 0x00F2, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x015B, 0x0171, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0119, 0x021B, 0x00FF,}, -}; diff --git a/extras/anytermd/libpbe/src/generated/to_ascii_letters_tables.cc b/extras/anytermd/libpbe/src/generated/to_ascii_letters_tables.cc deleted file mode 100644 index 76077f91a5..0000000000 --- a/extras/anytermd/libpbe/src/generated/to_ascii_letters_tables.cc +++ /dev/null @@ -1,16 +0,0 @@ -char_expansion_page_00_t to_ascii_letters_page_00 [] = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "", "", "", "", "", "", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "a", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "o", "", "", "", "", "", "a", "a", "a", "a", "a", "a", "ae", "c", "e", "e", "e", "e", "i", "i", "i", "i", "d", "n", "o", "o", "o", "o", "o", "", "o", "u", "u", "u", "u", "y", "th", "ss", "a", "a", "a", "a", "a", "a", "ae", "c", "e", "e", "e", "e", "i", "i", "i", "i", "d", "n", "o", "o", "o", "o", "o", "", "o", "u", "u", "u", "u", "y", "th", "y", }; -char_expansion_page_01_t to_ascii_letters_page_01 [] = {"a", "a", "a", "a", "a", "a", "c", "c", "c", "c", "c", "c", "c", "c", "d", "d", "d", "d", "e", "e", "e", "e", "e", "e", "e", "e", "e", "e", "g", "g", "g", "g", "g", "g", "g", "g", "h", "h", "h", "h", "i", "i", "i", "i", "i", "i", "i", "i", "i", "i", "ij", "ij", "j", "j", "k", "k", "", "l", "l", "l", "l", "l", "l", "l", "l", "l", "l", "n", "n", "n", "n", "n", "n", "n", "", "", "o", "o", "o", "o", "o", "o", "oe", "oe", "r", "r", "r", "r", "r", "r", "s", "s", "s", "s", "s", "s", "s", "s", "t", "t", "t", "t", "t", "t", "u", "u", "u", "u", "u", "u", "u", "u", "u", "u", "u", "u", "w", "w", "y", "y", "y", "z", "z", "z", "z", "z", "z", "s", "b", "b", "b", "b", "", "", "o", "c", "c", "d", "d", "d", "d", "", "e", "", "e", "f", "f", "g", "", "hv", "", "i", "k", "k", "l", "", "m", "n", "n", "o", "o", "o", "oi", "oi", "p", "p", "yr", "", "", "", "", "t", "t", "t", "t", "u", "u", "", "v", "y", "y", "z", "z", "", "", "", "", "", "", "", "", "", "", "", "", "", "dz", "dz", "dz", "lj", "lj", "lj", "nj", "nj", "nj", "a", "a", "i", "i", "o", "o", "u", "u", "u", "u", "u", "u", "u", "u", "u", "u", "e", "a", "a", "a", "a", "", "", "g", "g", "g", "g", "k", "k", "o", "o", "o", "o", "", "", "j", "dz", "dz", "dz", "g", "g", "", "", "n", "n", "a", "a", "", "", "", "", }; -char_expansion_page_02_t to_ascii_letters_page_02 [] = {"a", "a", "a", "a", "e", "e", "e", "e", "i", "i", "i", "i", "o", "o", "o", "o", "r", "r", "r", "r", "u", "u", "u", "u", "s", "s", "t", "t", "", "", "h", "h", "n", "d", "", "ou", "z", "z", "a", "a", "e", "e", "o", "o", "o", "o", "o", "o", "o", "o", "y", "y", "l", "n", "t", "j", "db", "qp", "a", "", "c", "l", "t", "s", "z", "", "", "b", "u", "v", "e", "e", "j", "j", "q", "q", "r", "r", "y", "y", "a", "", "", "b", "o", "c", "d", "d", "e", "", "", "e", "e", "e", "e", "j", "g", "g", "g", "", "", "h", "h", "", "i", "", "i", "l", "l", "l", "", "m", "m", "m", "m", "n", "n", "o", "oe", "", "", "r", "r", "r", "r", "r", "r", "r", "r", "r", "s", "", "j", "", "", "t", "t", "u", "", "v", "v", "w", "y", "y", "z", "z", "", "", "", "", "", "c", "", "b", "e", "g", "h", "j", "k", "l", "q", "", "", "dz", "", "dz", "ts", "", "tc", "", "ls", "lz", "", "", "h", "h", "h", "", "j", "r", "", "", "", "w", "y", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "l", "s", "x", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; -char_expansion_page_1D4_t to_ascii_letters_page_1D4 [] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "", "c", "d", "", "", "g", "", "", "j", "k", "", "", "n", "o", "p", "q", "", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "", "f", "", "h", "i", "j", "k", "l", "m", "n", "", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", }; -char_expansion_page_1D5_t to_ascii_letters_page_1D5 [] = {"w", "x", "y", "z", "a", "b", "", "d", "e", "f", "g", "", "", "j", "k", "l", "m", "n", "o", "p", "q", "", "s", "t", "u", "v", "w", "x", "y", "", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "", "d", "e", "f", "g", "", "i", "j", "k", "l", "m", "", "o", "", "", "", "s", "t", "u", "v", "w", "x", "y", "", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", }; -char_expansion_page_1D6_t to_ascii_letters_page_1D6 [] = {"s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; -char_expansion_page_1D_t to_ascii_letters_page_1D [] = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "a", "", "b", "", "d", "e", "", "g", "h", "i", "j", "k", "l", "m", "n", "", "o", "", "p", "r", "t", "u", "w", "a", "", "", "", "b", "d", "e", "", "", "", "g", "", "k", "m", "", "o", "", "", "", "p", "t", "u", "", "", "v", "", "", "", "", "", "", "i", "r", "u", "v", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "c", "", "", "", "f", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "z", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; -char_expansion_page_1E_t to_ascii_letters_page_1E [] = {"a", "a", "b", "b", "b", "b", "b", "b", "c", "c", "d", "d", "d", "d", "d", "d", "d", "d", "d", "d", "e", "e", "e", "e", "e", "e", "e", "e", "e", "e", "f", "f", "g", "g", "h", "h", "h", "h", "h", "h", "h", "h", "h", "h", "i", "i", "i", "i", "k", "k", "k", "k", "k", "k", "l", "l", "l", "l", "l", "l", "l", "l", "m", "m", "m", "m", "m", "m", "n", "n", "n", "n", "n", "n", "n", "n", "o", "o", "o", "o", "o", "o", "o", "o", "p", "p", "p", "p", "r", "r", "r", "r", "r", "r", "r", "r", "s", "s", "s", "s", "s", "s", "s", "s", "s", "s", "t", "t", "t", "t", "t", "t", "t", "t", "u", "u", "u", "u", "u", "u", "u", "u", "u", "u", "v", "v", "v", "v", "w", "w", "w", "w", "w", "w", "w", "w", "w", "w", "x", "x", "x", "x", "y", "y", "z", "z", "z", "z", "z", "z", "h", "t", "w", "y", "a", "s", "", "", "", "", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "e", "e", "e", "e", "e", "e", "e", "e", "e", "e", "e", "e", "e", "e", "e", "e", "i", "i", "i", "i", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "u", "u", "u", "u", "u", "u", "u", "u", "u", "u", "u", "u", "u", "u", "y", "y", "y", "y", "y", "y", "y", "y", "", "", "", "", "", "", }; -char_expansion_page_20_t to_ascii_letters_page_20 [] = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "i", "", "", "", "", "", "", "", "", "", "", "", "", "", "n", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "a", "e", "o", "x", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "rs", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; -char_expansion_page_21_t to_ascii_letters_page_21 [] = {"ac", "as", "c", "c", "", "co", "cu", "", "", "f", "g", "h", "h", "h", "h", "", "i", "i", "l", "l", "", "n", "no", "", "", "p", "q", "r", "r", "r", "", "", "sm", "tel", "tm", "", "z", "", "", "", "z", "", "k", "a", "b", "c", "", "e", "e", "f", "", "m", "o", "", "", "", "", "i", "", "fax", "", "", "", "", "", "", "", "", "", "d", "d", "e", "i", "j", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x", "xi", "xii", "l", "c", "d", "m", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x", "xi", "xii", "l", "c", "d", "m", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; -char_expansion_page_24_t to_ascii_letters_page_24 [] = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; -char_expansion_page_2C_t to_ascii_letters_page_2C [] = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "j", "v", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; -char_expansion_page_32_t to_ascii_letters_page_32 [] = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "pte", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "hg", "erg", "ev", "ltd", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; -char_expansion_page_33_t to_ascii_letters_page_33 [] = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "hpa", "da", "au", "bar", "ov", "pc", "dm", "dm", "dm", "iu", "", "", "", "", "", "pa", "na", "a", "ma", "ka", "kb", "mb", "gb", "cal", "kcal", "pf", "nf", "f", "g", "mg", "kg", "hz", "khz", "mhz", "ghz", "thz", "l", "ml", "dl", "kl", "fm", "nm", "m", "mm", "cm", "km", "mm", "cm", "m", "km", "mm", "cm", "m", "km", "ms", "ms", "pa", "kpa", "mpa", "gpa", "rad", "rads", "rads", "ps", "ns", "s", "ms", "pv", "nv", "v", "mv", "kv", "mv", "pw", "nw", "w", "mw", "kw", "mw", "k", "m", "am", "bq", "cc", "cd", "ckg", "co", "db", "gy", "ha", "hp", "in", "kk", "km", "kt", "lm", "ln", "log", "lx", "mb", "mil", "mol", "ph", "pm", "ppm", "pr", "sr", "sv", "wb", "vm", "am", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "gal", }; -char_expansion_page_FB_t to_ascii_letters_page_FB [] = {"ff", "fi", "fl", "ffi", "ffl", "st", "st", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; -char_expansion_page_FF_t to_ascii_letters_page_FF [] = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "", "", "", "", "", "", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; diff --git a/extras/anytermd/libpbe/src/geometry.cc b/extras/anytermd/libpbe/src/geometry.cc deleted file mode 100644 index 96d22c5f5a..0000000000 --- a/extras/anytermd/libpbe/src/geometry.cc +++ /dev/null @@ -1,49 +0,0 @@ -// src/geometry.cc -// (C) 2008 Philip Endecott -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "geometry.hh" - -#include - -using namespace std; - - -namespace pbe { - - -float distance(const position& a, const position& b) -{ - return earth_radius * 2.0F * asin( - sqrt( - sqr(degsin((a.lat-b.lat)/2.0F)) - + degcos(a.lat)*degcos(b.lat)*sqr(degsin((a.lng-b.lng)/2.0F)) - ) - ); -} - - -float bearing(const position& a, const position& b) -{ - float d = degatan2( degsin(b.lng-a.lng) * degcos(b.lat), - degcos(a.lat) * degsin(b.lat) - - degsin(a.lat) * degcos(b.lat) * degcos(b.lng-a.lng) - ); - return normalise_unsigned_angle(d); -} - - -}; diff --git a/extras/anytermd/libpbe/src/ip.cc b/extras/anytermd/libpbe/src/ip.cc deleted file mode 100644 index 3e4ddf1074..0000000000 --- a/extras/anytermd/libpbe/src/ip.cc +++ /dev/null @@ -1,141 +0,0 @@ -// src/ip.cc -// This file is part of libpbe; see http://decimail.org -// (C) 2004-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "ip.hh" - -#include -#include -#include -#include -#include - -using namespace std; - - -namespace pbe { - - -ostream& operator<<(ostream& s, struct in_addr ip) -{ - uint32_t i = ntohl(ip.s_addr); - s << ((i&0xff000000)>>24) - << '.' << ((i&0x00ff0000)>>16) - << '.' << ((i&0x0000ff00)>>8) - << '.' << (i&0x000000ff); - return s; -} - - -void HostLookupError::report(ostream& s) const { - s << "host name lookup failed for " << hostname << ": " - << gai_strerror(error_code) << endl; -} - - -struct in_addr get_ip_address(string hostname) -{ - struct addrinfo ai; - memset(&ai, 0, sizeof(ai)); - ai.ai_family = AF_INET; - - struct addrinfo* res; - int rc = getaddrinfo(hostname.c_str(), "", &ai, &res); - if (rc) { - throw HostLookupError(hostname,rc); - } - - struct in_addr result = ((sockaddr_in *)(res->ai_addr))->sin_addr; - freeaddrinfo(res); - - return result; -} - - -string get_own_hostname(void) -{ - char name[256]; - int rc = gethostname(name,sizeof(name)); - if (rc!=0) { - throw_ErrnoException("gethostname()"); - } - - struct addrinfo ai; - memset(&ai, 0, sizeof(ai)); - ai. ai_flags = AI_CANONNAME; - ai.ai_family = AF_INET; - - struct addrinfo* res; - // FIXME Is there any way to specify a timeout? - rc = getaddrinfo(name, "", &ai, &res); - if (rc) { - throw HostLookupError(name,rc); - } - - string result(res->ai_canonname); - freeaddrinfo(res); - - return result; -} - - - -int tcp_client_connect(string server_name, int port) -{ - struct sockaddr_in addr; - addr.sin_family = AF_INET; - addr.sin_addr = get_ip_address(server_name); - addr.sin_port = htons(port); - - int fd = socket(PF_INET,SOCK_STREAM,0); - if (fd==-1) { - throw_ErrnoException("socket()"); - } - // FIXME if we wanted to detect a timeout here we should make fd nonblocking; - // this will cause connect() to return with errno==EINPROGRESS; we then select() - // until fd is writeable (or times out), at which point we call getsockopt(SO_ERROR) - // to get any connect error. - int rc = connect(fd, (struct sockaddr*)&addr, sizeof(addr)); - if (rc==-1) { - throw_ErrnoException("connect()"); - } - - return fd; -} - - -int local_client_connect(string address) -{ - struct sockaddr_un addr; - addr.sun_family = AF_LOCAL; - strcpy(addr.sun_path,address.c_str()); - - int fd = socket(PF_LOCAL,SOCK_STREAM,0); - if (fd==-1) { - throw_ErrnoException("socket()"); - } - int rc = connect(fd, (struct sockaddr*)&addr, SUN_LEN(&addr)); - if (rc==-1) { - throw_ErrnoException("connect()"); - } - - return fd; -} - - -}; - diff --git a/extras/anytermd/libpbe/src/iso8859_tables.cc b/extras/anytermd/libpbe/src/iso8859_tables.cc deleted file mode 100644 index e487057ec7..0000000000 --- a/extras/anytermd/libpbe/src/iso8859_tables.cc +++ /dev/null @@ -1,37 +0,0 @@ -// iso8859_tables.cc -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2008 Philip Endecott - -// Distributed under the Boost Software License, Version 1.0: -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - - -#include "charset/conv/iso8859.hh" - -namespace pbe { - -#include "generated/iso8859_tables_body.cc" - -}; - diff --git a/extras/anytermd/libpbe/src/markup.cc b/extras/anytermd/libpbe/src/markup.cc deleted file mode 100644 index 53effae99c..0000000000 --- a/extras/anytermd/libpbe/src/markup.cc +++ /dev/null @@ -1,138 +0,0 @@ -// src/markup.cc -// This file is part of libpbe; see http://decimail.org -// (C) 2004 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#include "markup.hh" - -#include "StringTransformer.hh" - -#include -#include - - -class AtDotToWords: public StringTransformer { -public: - AtDotToWords() { - add_cs_rule('@'," AT "); - add_cs_rule('.'," DOT "); - } -}; - -static AtDotToWords at_dot_to_words; - - -static string render_email(string e) -{ - string h = ""+at_dot_to_words(e)+""; - return h; -} - - -static string render_uri(string u) -{ - string uri; - if (u.substr(0,4)!="http") { - uri = "http://" + u; - } else { - uri=u; - } - string h = ""; - h += u; - h += ""; - return h; -} - - -// See RFC2396 for URI syntax. - -// We make the protocol prefix optional, so www.foo.com works. - -// We require that the last component of the domain name is purely -// alphabetic and has at least two characters. This is true in -// practice (.com, .uk) and helps to avoid false positives ("e.g."). - -// We require that the last character of a path segment is not a -// common punctuation character: .!):;, This is because -// these rarely fall at the end of a true URI but are often placed -// after a URI when it is written in text. - -// We apply this after escaping & to &. This is only an issue in -// the path where ; normally has a special meaning which we have to -// ignore. - -// We reuse the URI domain rules for emails. - -// For email local parts we use the list of characters allowed by -// RFC2822, but allow adjacent .s. - -// We disallow @ in URIs so that we can use it to distinguish emails -// from URIs. They should be allowed in paths, queries and -// fragment-ids. - - -const char* uri_regexp = -"(https?://)?" // optional protocol -"[-a-zA-Z0-9]+(\\.[-a-zA-Z0-9]+)*\\.[a-zA-Z][a-zA-Z]+" // hostname -"(:[0-9]+)?" // optional port number -"(/[-a-zA-Z0-9_.!~*'()%:&;=+$,]*[-a-zA-Z0-9_~*'(%&=+$])*" // path, may be empty -"/?" // path to directory may be terminated with a / -"(\\?[-;/?:&=+$,a-zA-Z0-9_.!~*'()]*)?" // optional queery -"(#[-;/?:&=+$,a-zA-Z0-9_.!~*'()]*)?" // optional fragment-id -; - -const char* email_regexp = -"[a-zA-Z0-9!#$%&'*+-/=?^_`{|}~.]+" // local-part -"@" -"[-a-zA-Z0-9]+(\\.[-a-zA-Z0-9]+)*\\.[a-zA-Z][a-zA-Z]+" // hostname -; - - -void markup_uris_emails ( string& text ) -{ - static bool re_compiled = false; - static regex_t re; - if (!re_compiled) { - string regexp = string("(") + uri_regexp + ")|(" + email_regexp +")"; - int rc = regcomp(&re, regexp.c_str(), REG_EXTENDED); - assert(rc==0); - re_compiled=true; - } - - string r; - regmatch_t match; - - int pos=0; - while (1) { - int rc = regexec(&re, text.c_str()+pos, 1, &match, 0); - assert((rc==0) || (rc==REG_NOMATCH)); - if (rc==REG_NOMATCH) { - r.append(text.substr(pos)); - break; - } - r += text.substr(pos,match.rm_so); - string p = text.substr(pos+match.rm_so,match.rm_eo-match.rm_so); - if (p.find('@')!=p.npos) { - r += render_email(p); - } else { - r += render_uri(p); - } - pos += match.rm_eo; - } - - text = r; -} diff --git a/extras/anytermd/libpbe/src/parse_http_request.cc b/extras/anytermd/libpbe/src/parse_http_request.cc deleted file mode 100644 index 873232320b..0000000000 --- a/extras/anytermd/libpbe/src/parse_http_request.cc +++ /dev/null @@ -1,173 +0,0 @@ -// src/parse_http_request.cc -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2005-2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "parse_http_request.hh" - -#include -#include -#include -#include -#include - -#include -#include - -#include - - -using namespace std; -using namespace boost::spirit; - - -namespace pbe { - - -HttpRequest parse_http_request(istream& strm) -{ - HttpRequest request; - - typedef multi_pass > iterator_t; - typedef scanner scanner_t; - typedef rule rule_t; - - string tmp_hn; - string tmp_hv; - - // HTTP/1.1 request parsing, based on: - // RFC2616 - // RFC2396 - // HTTP/1.1 Errata (http://skrb.org/ietf/http_errata.html) - - rule_t CRLF = str_p("\r\n"); - - rule_t extension_method = nothing_p; - - rule_t method = str_p("OPTIONS") | "GET" | "HEAD" | "POST" | "PUT" - | "DELETE" | "TRACE" | "CONNECT" | extension_method; - - rule_t mark = ch_p('-') | '_' | '.' | '!' | '~' | '*' | '\'' | '(' | ')'; - - rule_t unreserved = alnum_p | mark; - - rule_t escaped = ch_p('%') >> xdigit_p >> xdigit_p; - - rule_t reserved = ch_p(';') | '/' | '?' | ':' | '@' | '&' | '=' | '+' | '$' | ','; - - rule_t pchar = unreserved | escaped | ':' | '@' | '&' | '=' | '+' | '$' | ','; - - rule_t param = *pchar; - - rule_t segment = *pchar >> *(';' >> param); - - rule_t path_segments = segment >> *('/' >> segment); - - rule_t abs_path = ( ch_p('/') >> path_segments )[assign_a(request.abs_path)]; - - rule_t scheme = alpha_p >> *(alpha_p | digit_p | '+' | '-' | '.' ); - - rule_t userinfo = *(unreserved | escaped | ';' | ':' | '&' | '=' | '+' | '$' | ',' ); - - rule_t domainlabel = alnum_p | alnum_p >> *(alnum_p | '-') >> alnum_p; - - rule_t toplabel = alpha_p | alpha_p >> *(alnum_p | '-') >> alnum_p; - - rule_t hostname = *(domainlabel >> '.') >> toplabel >> !ch_p('.'); - - uint_parser decimal_byte; - - rule_t ipv4address = decimal_byte >> '.' >> decimal_byte >> '.' >> - decimal_byte >> '.' >> decimal_byte; - - rule_t host = hostname | ipv4address; - - rule_t port = uint_p; - - rule_t hostport = host >> !(':' >> port); - - rule_t server = !( !(userinfo >> '@') >> hostport ); - - rule_t reg_name = +(unreserved | escaped | '$' | ',' | ';' | ':' | '@' | - '&' | '=' | '+'); - - rule_t authority = server | reg_name; - - rule_t net_path = str_p("//") >> authority >> !abs_path; - - rule_t uric = reserved | unreserved | escaped; - - rule_t query = (*uric) [assign_a(request.query)]; - - rule_t hier_part = (net_path | abs_path) >> !('?' >> query); - - rule_t uric_no_slash = unreserved | escaped | ';' | '?' | ':' | '@' | - '&' | '=' | '+' | '$' | ','; - - rule_t opaque_part = uric_no_slash >> *uric; - - rule_t absolute_uri = scheme >> ':' >> (hier_part | opaque_part); - - rule_t request_uri = ch_p('*') - | absolute_uri - | (abs_path >> !(ch_p('?') >> query)) - | authority; - - rule_t http_version = str_p("HTTP/") >> uint_p >> '.' >> uint_p; - - rule_t request_line = - method [assign_a(request.method)] - >> ' ' >> request_uri - >> ' ' >> http_version [assign_a(request.http_version)] - >> CRLF ; - - rule_t header_name = +(alnum_p|'-'); - - rule_t header_value = *(print_p|' '|'\t'); - - rule_t header = ( header_name [assign_a(tmp_hn)] >> - ':' >> *(ch_p(' ')) >> header_value [assign_a(tmp_hv)] ) - [insert_at_a(request.headers,tmp_hn,tmp_hv)]; - - rule_t request_r = - request_line - >> *(header >> CRLF) - >> CRLF; - - iterator_t first(make_multi_pass(std::istreambuf_iterator(strm))); - iterator_t last(make_multi_pass(std::istreambuf_iterator())); - - scanner_t scanner(first,last); - - if (!request_r.parse(scanner)) { - throw HttpRequestSyntaxError(); - } - - HttpRequest::headers_t::const_iterator i = request.headers.find("Content-Length"); - if (i==request.headers.end()) { - return request; - } - size_t content_length = boost::lexical_cast(i->second); - boost::scoped_array buf(new char[content_length]); - strm.read(buf.get(),content_length); - request.body = string(buf.get(),content_length); - - return request; -} - - -}; - diff --git a/extras/anytermd/libpbe/src/rfcdate.cc b/extras/anytermd/libpbe/src/rfcdate.cc deleted file mode 100644 index 80097a94fc..0000000000 --- a/extras/anytermd/libpbe/src/rfcdate.cc +++ /dev/null @@ -1,44 +0,0 @@ -// rfcdate.cc -// This file is part of libpbe; see http://anyterm.org/ -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include - -#include - -using namespace std; - - -namespace pbe { - - -string rfc_date(void) -// RFC2616 cites RFC1123 for date/time format, which cites RFC822 with -// clarifications. -{ - char s[36]; - time_t t; - time(&t); - struct tm tm; - localtime_r(&t,&tm); - strftime(s,sizeof(s),"%a, %d %b %Y %H:%M:%S %z",&tm); - return s; -} - - -}; diff --git a/extras/anytermd/libpbe/src/run_cmd.cc b/extras/anytermd/libpbe/src/run_cmd.cc deleted file mode 100644 index b6efe0968a..0000000000 --- a/extras/anytermd/libpbe/src/run_cmd.cc +++ /dev/null @@ -1,72 +0,0 @@ -// src/run_cmd.cc -// This file is part of libpbe; see http://decimail.org -// (C) 2005, 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "run_cmd.hh" - -#include "Exception.hh" - -#include -#include - -using namespace std; -using namespace pbe; - -namespace pbe { - -string run_cmd( string cmd, bool& exit_ok ) -{ - cmd+=" 2>&1"; - FILE* p = popen(cmd.c_str(),"r"); - if (!p) { - throw_ErrnoException("popen("+cmd+")"); - } - - string result; - while (1) { - const int bfsz=1024; - char buf[bfsz]; - int n = fread(buf,sizeof(char),bfsz,p); - result.append(buf,n); - if (n -#include -#include -#include -#include - -#include "compiler_magic.hh" - -#define max_backtrace_size 200 - -static void print_backtrace(int signum) -{ - signal(SIGSEGV,SIG_DFL); - signal(SIGBUS,SIG_DFL); - signal(SIGILL,SIG_DFL); - signal(SIGFPE,SIG_DFL); - const char* signame; - switch(signum) { - case SIGSEGV: signame="Segmentation fault"; break; - case SIGBUS: signame="Bus error"; break; - case SIGILL: signame="Illegal instruction"; break; - case SIGFPE: signame="FP exception"; break; - default: signame="unexpected signal"; break; - } - ::write(2,signame,::strlen(signame)); - const char* msg=" detected; Backtrace:\n"; - ::write(2,msg,::strlen(msg)); - void* return_addrs[max_backtrace_size]; - size_t n_return_addrs = ::backtrace(return_addrs,max_backtrace_size); - ::backtrace_symbols_fd(return_addrs,n_return_addrs,2); - raise(signum); -} - - -void get_backtrace_on_segv() -{ - struct sigaction s; - s.sa_handler = &print_backtrace; - sigfillset(&s.sa_mask); - s.sa_flags=0; - sigaction(SIGSEGV,&s,NULL); - sigaction(SIGBUS,&s,NULL); - sigaction(SIGILL,&s,NULL); - sigaction(SIGFPE,&s,NULL); -} - -#else -// Platform doesn't have these functions, so no-op. - -void get_backtrace_on_segv() -{ -} - -#endif - diff --git a/extras/anytermd/libpbe/src/select.cc b/extras/anytermd/libpbe/src/select.cc deleted file mode 100644 index 4f5e2bfa14..0000000000 --- a/extras/anytermd/libpbe/src/select.cc +++ /dev/null @@ -1,132 +0,0 @@ -// src/select.cc -// This file is part of libpbe; see http://decimail.org -// (C) 2004-2005 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "select.hh" - -#include "Exception.hh" - -#include - -#include -#include - -using namespace std; -using namespace pbe; - - -int select_r(int fd1) -{ - fd_set rd_fds; - FD_ZERO(&rd_fds); - fd_set wr_fds; - FD_ZERO(&wr_fds); - fd_set ex_fds; - FD_ZERO(&ex_fds); - - FD_SET(fd1,&rd_fds); - - int rc; - do { - rc = select(fd1+1,&rd_fds,&wr_fds,&ex_fds,NULL); - if (rc==-1) { - if (errno==EINTR) { - continue; - } - throw_ErrnoException("select()"); - } - break; - } while (1); - - if (FD_ISSET(fd1,&rd_fds)) { - return fd1; - } - - return -2; -} - - -int select_rr(int fd1, int fd2) -{ - fd_set rd_fds; - FD_ZERO(&rd_fds); - fd_set wr_fds; - FD_ZERO(&wr_fds); - fd_set ex_fds; - FD_ZERO(&ex_fds); - - FD_SET(fd1,&rd_fds); - FD_SET(fd2,&rd_fds); - - int rc; - do { - rc = select(max(fd1,fd2)+1,&rd_fds,&wr_fds,&ex_fds,NULL); - if (rc==-1) { - if (errno==EINTR) { - continue; - } - throw_ErrnoException("select()"); - } - } while (0); - - if (FD_ISSET(fd1,&rd_fds)) { - return fd1; - } else if (FD_ISSET(fd2,&rd_fds)) { - return fd2; - } - - return -2; -} - - -int select_rt(int fd1, float timeout) -{ - fd_set rd_fds; - FD_ZERO(&rd_fds); - fd_set wr_fds; - FD_ZERO(&wr_fds); - fd_set ex_fds; - FD_ZERO(&ex_fds); - - FD_SET(fd1,&rd_fds); - - struct timeval tv; - float timeout_whole; - float timeout_frac; - timeout_frac = modff(timeout, &timeout_whole); - tv.tv_sec = (int)timeout_whole; - tv.tv_usec = (int)(1000000.0*timeout_frac); - - int rc; - do { - rc = select(fd1+1,&rd_fds,&wr_fds,&ex_fds,&tv); - if (rc==-1) { - if (errno==EINTR) { - continue; - } - throw_ErrnoException("select()"); - } - } while (0); - - if (rc==0) { - return -1; - } else if (FD_ISSET(fd1,&rd_fds)) { - return fd1; - } - - return -2; -} diff --git a/extras/anytermd/libpbe/src/to_ascii_letters.cc b/extras/anytermd/libpbe/src/to_ascii_letters.cc deleted file mode 100644 index 6a8e3d3540..0000000000 --- a/extras/anytermd/libpbe/src/to_ascii_letters.cc +++ /dev/null @@ -1,27 +0,0 @@ -// src/to_ascii_letters.cc -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "charset/to_ascii_letters.hh" - - -namespace pbe { - -#include "generated/to_ascii_letters_tables.cc" - -}; - diff --git a/extras/anytermd/libpbe/src/utils.cc b/extras/anytermd/libpbe/src/utils.cc deleted file mode 100644 index 6014ef4158..0000000000 --- a/extras/anytermd/libpbe/src/utils.cc +++ /dev/null @@ -1,339 +0,0 @@ -// src/utils.cc -// This file is part of libpbe; see http://decimail.org -// (C) 2004-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "utils.hh" - -#include "Exception.hh" - -#if 0 -#include -#include -#endif - -#include -#include -#include - -using namespace std; - - -namespace pbe { - -#if 0 -string int_to_string(int i) -{ - ostringstream s; - s << i; - return s.str(); -} - -string float_to_string(float f) -{ - char buf[20]; - unsigned int nchars = snprintf(buf,sizeof(buf),"%g",f); - if (nchars>=sizeof(buf)) { - throw "float doesn't fit in buffer"; - } - return buf; -} - -string double_to_string(double f) -{ - char buf[20]; - unsigned int nchars = snprintf(buf,sizeof(buf),"%g",f); - if (nchars>=sizeof(buf)) { - throw "float doesn't fit in buffer"; - } - return buf; -} -#endif - -class NotANumber: public Exception { -private: - string numstr; - string base; -public: - NotANumber(string ns, string b): numstr(ns), base(b) {} - void report(ostream& s) const { - s << '"' << numstr << "\" is not a " << base << " number" << endl; - } -}; - - -#if 0 -int string_to_int(string s) -{ - if (s.size()==0) { - throw NotANumber(s,"decimal"); - } - char* endptr; - int i=strtol(s.c_str(),&endptr,10); - if (*endptr) { - throw NotANumber(s,"decimal"); - } - return i; -} - - -float string_to_float(string s) -{ - if (s.size()==0) { - throw NotANumber(s,"floating point"); - } - char* endptr; - float f=strtof(s.c_str(),&endptr); - if (*endptr) { - throw NotANumber(s,"floating point"); - } - return f; -} - - -double string_to_double(string s) -{ - if (s.size()==0) { - throw NotANumber(s,"floating point"); - } - char* endptr; - double d=strtod(s.c_str(),&endptr); - if (*endptr) { - throw NotANumber(s,"floating point"); - } - return d; -} -#endif - -int hex_string_to_int(string s) -{ - if (s.size()==0) { - throw NotANumber(s,"hex"); - } - char* endptr; - int i=strtol(s.c_str(),&endptr,16); - if (*endptr) { - throw NotANumber(s,"hex"); - } - return i; -} - - -int maybe_hex_string_to_int(string s) -{ - if (s.substr(0,2)=="0x") { - return hex_string_to_int(s.substr(2)); - } else { - return boost::lexical_cast(s); - } -} - - -static string -prefix_backslash(const boost::iterator_range& Match ) -{ - return "\\"+string(Match.begin(),Match.end()); -} - - -string escape_for_dquoted_string(string s) -{ - return boost::find_format_all_copy(s, - boost::token_finder(boost::is_any_of("\\\"")), - prefix_backslash); -} - -string escape_for_squoted_string(string s) -{ - return boost::find_format_all_copy(s, - boost::token_finder(boost::is_any_of("\\\'")), - prefix_backslash); -} - -string escape_for_regexp(string s) -{ - return boost::find_format_all_copy(s, - boost::token_finder(boost::is_any_of("/*+?{().^$\\[")), - prefix_backslash); -} - - -#if 0 -class EscapeForQuotedString: public EscapeInserter { -public: - EscapeForQuotedString(void): EscapeInserter("\\\"") {} -}; - - - -class EscapeForSQuotedString: public EscapeInserter { -public: - EscapeForSQuotedString(void): EscapeInserter("\\\'") {} -}; - - - -class EscapeForRegexp: public EscapeInserter { -public: - EscapeForRegexp(void): EscapeInserter("/*+?{().^$\\[") {} -}; - -const StringTransformer& escape_for_regexp = EscapeForRegexp(); - - -class ReplaceSquoteWithHack: public StringTransformer { -public: - ReplaceSquoteWithHack(void) { - add_cs_rule('\'',"',\"'\",'"); - } -}; - -string escape_for_xpath_string(string s) -{ - if (s.find('\'')==s.npos) { - return "\'"+s+"\'"; - } - if (s.find('\"')==s.npos) { - return "\""+s+"\""; - } - { - static ReplaceSquoteWithHack replace_squote_with_hack; - return "concat('" + replace_squote_with_hack(s) + "')"; - } -} - - - -class ToUpper: public StringTransformer { -public: - ToUpper(void) { - for(int c=0; c<256; ++c) { - add_cc_rule(c,toupper(c)); - } - } -}; - -const StringTransformer& to_upper = ToUpper(); - - -class ToLower: public StringTransformer { -public: - ToLower(void) { - for(int c=0; c<256; ++c) { - add_cc_rule(c,tolower(c)); - } - } -}; - -const StringTransformer& to_lower = ToLower(); - - -class LfToCrlf: public StringTransformer { -public: - LfToCrlf(void) { - add_cs_rule('\n',"\r\n"); - } -}; - -const StringTransformer& lf_to_crlf = LfToCrlf(); - - -string join(const list& strs, string joiner) -{ - if (strs.size()==0) { - return ""; - } - string j; - list::const_iterator i=strs.begin(); - while(1) { - j+=(*i); - ++i; - if (i==strs.end()) { - break; - } else { - j+=joiner; - } - } - return j; -} - - -string trim_whitespace (string s) -{ - string::size_type start = s.find_first_not_of("\r\n \t"); - if (start==s.npos) { - return ""; - } - unsigned int end = s.find_last_not_of("\r\n \t"); - return s.substr(start,(end-start)+1); -} - - -string normalise_whitespace (string s) -{ - string r; - bool skip_spaces=true; - bool add_space=false; - - for(unsigned int i = 0; i /dev/stderr - exit 1 - fi - if [ -f ${mime_types} ] - then - break - fi -done - - -awk '!/^#/ '"{for (i=2; i<=NF; i++) {if (\$i==\"$EXT\") {print \$1; exit;}}}" ${mime_types} - - diff --git a/extras/anytermd/scripts/mk_static_content.sh b/extras/anytermd/scripts/mk_static_content.sh deleted file mode 100755 index bd23274598..0000000000 --- a/extras/anytermd/scripts/mk_static_content.sh +++ /dev/null @@ -1,53 +0,0 @@ -# daemon/mk_static_content.sh -# This file is part of Anyterm; see http://anyterm.org/ -# (C) 2005-2007 Philip Endecott - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#!/bin/sh - -FILES="$@" - -echo "#include \"static_content.hh\"" -echo "#include " -echo "using namespace std;" - -echo 'extern "C" {' -for i in $FILES -do - sym=`echo $i | sed 's/\./_/g'` - echo "extern char _binary_${sym}_start[];" - echo "extern char _binary_${sym}_end[];" -done -echo "};" - -echo "bool get_static_content(string fn, string& mime_type, string& body) {" - -for i in $FILES -do - sym=`echo $i | sed 's/\./_/g'` - FILE="../browser/$i" - TYPE=`mimetype.sh $FILE` - echo " if (fn==\"/$i\") {" - echo " mime_type=\"$TYPE\";" - echo " body=string(_binary_${sym}_start, _binary_${sym}_end);" - echo " return true;" - echo " };" - -done - -echo " return false;" -echo "}" diff --git a/extras/anytermd/src/Activity.cc b/extras/anytermd/src/Activity.cc deleted file mode 100644 index 12823364b0..0000000000 --- a/extras/anytermd/src/Activity.cc +++ /dev/null @@ -1,77 +0,0 @@ -// common/Activity.cc -// This file is part of SlugTerm; see http://chezphil.org/slugterm -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "Activity.hh" - -#include -#include -#include -#include - -#include - -#include "select.hh" -#include "Exception.hh" - -#include - -using namespace std; -using namespace pbe; - - -Activity::Activity(onOutput_t onOutput_, onError_t onError_, pbe::FileDescriptor& fd_): - fd(fd_), - terminating(false), - onOutput(onOutput_), - onError(onError_), - output_processor(new Thread(boost::bind(&Activity::process_output,this))) -{} - - -Activity::~Activity() -{ - output_processor->join(); -} - - -void Activity::send(string s) -{ - fd.writeall(s); -} - - -void Activity::process_output(void) -{ - try { try { - while(!terminating) { - string s = fd.readsome(); - onOutput(s); - } - } RETHROW_MISC_EXCEPTIONS } - catch (IOError) { - onError("Subprocess terminated"); - return; - } - catch (Exception& e) { - ostringstream s; - s << "Exception: "; - e.report(s); - onError(s.str()); - return; - } -} diff --git a/extras/anytermd/src/Activity.hh b/extras/anytermd/src/Activity.hh deleted file mode 100644 index c23e02eb51..0000000000 --- a/extras/anytermd/src/Activity.hh +++ /dev/null @@ -1,56 +0,0 @@ -// common/Activity.hh -// This file is part of AnyTerm; see http://anyterm.org/ -// (C) 2006-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef Activity_hh -#define Activity_hh - -#include - -#include -#include - -#include "FileDescriptor.hh" -#include "Thread.hh" - - -class Activity { - -public: - typedef boost::function onOutput_t; - typedef boost::function onError_t; - -protected: - pbe::FileDescriptor& fd; - volatile bool terminating; - -private: - const onOutput_t onOutput; - const onError_t onError; - boost::scoped_ptr output_processor; - void process_output(void); - -public: - Activity(onOutput_t onOutput_, onError_t onError_, pbe::FileDescriptor& fd_); - - virtual ~Activity(); - - void send(std::string s); -}; - - -#endif diff --git a/extras/anytermd/src/Anyterm.cc b/extras/anytermd/src/Anyterm.cc deleted file mode 100644 index b958b7ac52..0000000000 --- a/extras/anytermd/src/Anyterm.cc +++ /dev/null @@ -1,259 +0,0 @@ -// daemon/Anyterm.cc -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include "Anyterm.hh" - -#include -#include - -#include -#if defined(__OpenBSD__) || defined(__APPLE__) -// sigemptyset is provided as macros, but actual function is available -// if their names are undefined (with #undef name) -#undef sigemptyset -#endif - -#include -#include - -#include "Error.hh" - -#include "auto_CgiParams.hh" - -#include "SubProcess.hh" -#include "SerialPortActivity.hh" -#include "expand_command.hh" -#include "unicode.hh" - -#include "compiler_magic.hh" - -#include - - -using namespace std; -using namespace pbe; - - -struct SubProcessFactory { - string command; - SubProcessFactory(string command_): command(command_) {} - Activity* operator()(Activity::onOutput_t onOutput, - Activity::onError_t onError, - string host, string user, - string param, int rows=25, int cols=80) { - string exp_cmd = expand_command(command,host,user,param); - return new SubProcess(onOutput,onError,exp_cmd,rows,cols); - } -}; - -struct SerialPortFactory { - string device; - int baudrate; - SerialPortFactory(string device_, int baudrate_): - device(device_), baudrate(baudrate_) {} - Activity* operator()(Activity::onOutput_t onOutput, - Activity::onError_t onError, - PBE_UNUSED_ARG(string host), PBE_UNUSED_ARG(string user), - PBE_UNUSED_ARG(string param), PBE_UNUSED_ARG(int rows), PBE_UNUSED_ARG(int cols)) { - return new SerialPortActivity(onOutput,onError,device,baudrate); - } -}; - - -static void install_sigchld_handler(void); - -static void reap_child(PBE_UNUSED_ARG(int sig)) -{ - // Handler function for SIGCHLD. - // Note that apparently you might get only one SIGCHLD for multiple - // subprocesses if they terminate at about the same time. So you - // can't just have - // wait(NULL); - - ::pid_t rc; - do { - rc = ::waitpid(-1, NULL, WNOHANG); - } while (rc>0); - - install_sigchld_handler(); -} - -static void install_sigchld_handler(void) -{ - struct sigaction sa; - sa.sa_handler=&reap_child; - ::sigemptyset(&sa.sa_mask); - sa.sa_flags=SA_NOCLDSTOP; - ::sigaction(SIGCHLD,&sa,NULL); // should check return value -} - - -Anyterm::Anyterm(std::string command, std::string device, std::string charset, bool diff_, - int max_sessions_): - def_charset(charset), - diff(diff_), - max_sessions(max_sessions_), - reaper_running(false) -{ - if (command!="") { - activityfactory=SubProcessFactory(command); - } else if (device!="") { - activityfactory=SerialPortFactory(device,9600); - } else { - throw "Neither command nor device specified"; - } - - try { - Iconver utf8_to_charset("UTF-8",def_charset); - Iconver charset_to_ucs4(def_charset,UCS4_NATIVE); - } - catch(...) { - throw "Character set not supported by Iconv. Try running iconv -l to find supported " - "character sets. It must be possible to convert from UTF-8 to CHARSET and from " - "CHARSET to UCS-4."; - } - - // We don't want child processes to become zombies when they terminate. - // (It's not OK to signal(SIGCHLD,SIG_IGN) here because [posix exec] - // "If the SIGCHLD signal is set to be ignored by the calling process image, - // it is unspecified whether the SIGCHLD signal is set to be ignored or to - // the default action in the new process image." Installing a handler - // that calls wait is safe because "Signals set to be caught by the calling - // process image shall be set to the default action in the new process image." - install_sigchld_handler(); -} - - -static Anyterm::response_t text_resp(string s) -{ - return Anyterm::response_t("text/plain; charset=\"UTF-8\"", s); -} - -Anyterm::response_t Anyterm::process_request(const HttpRequest& request) -{ - if (!reaper_running) { - // We can't start the reaper thread from the constructor, because this Anyterm - // object is constructed before the daemon forks itself into the background; child - // threads don't survive the fork. So we do it on the first call to process_request. - // There's a race condition here if the first two request processing threads start - // simultaneously. - reaper_running = true; - Thread timed_out_session_reaper - (boost::bind(&Anyterm::run_reaper_thread,this)); - } - - // Parse the arguments and call the appropriate function - - CgiParams params = auto_CgiParams(request); - - try { - - string action = params.get("a"); - - if (action=="open") { - reap_timed_out_sessions(); - - { - locked_sessions_t::reader sessions_rd(sessions); - int n_sessions = distance(sessions_rd->begin(),sessions_rd->end()); - if (n_sessions>=max_sessions) { - throw Error("The maximum number of concurrent sessions has been reached"); - } - } - - session_ptr_t ses(new Session(params.get_as("rows",25), - params.get_as("cols",80), - params.get_as("sb",0), - "[host unknown]", - request.userinfo, - params.get("p"), - ANYTERM_TIMEOUT, - activityfactory, - params.get("ch",def_charset), - diff)); - { - locked_sessions_t::writer sessions_wr(sessions); - (*sessions_wr)[ses->id]=ses; - } - return text_resp(ses->id.str()); - } - - string idstr = params.get("s"); - SessionId id(idstr); - session_ptr_t ses; - { - locked_sessions_t::reader sessions_rd(sessions); - sessions_t::const_iterator s = sessions_rd->find(id); - if (s==sessions_rd->end()) { - throw Error("no such session '"+idstr+"'"); - } - ses = s->second; - } - - if (action=="rcv") { - return text_resp(ses->rcv()); - - } else if (action=="send") { - string k = params.get("k"); - ses->send(k); - return text_resp(""); - - } else if (action=="close") { - { - locked_sessions_t::writer sessions_wr(sessions); - sessions_wr->erase(id); - } - return text_resp(""); - - } else { - throw Error("invalid query string '"+request.query+"'"); - } - } - - catch (Error& E) { - return text_resp("E"+E.get_msg()); - } -} - - -void Anyterm::reap_timed_out_sessions(void) -{ - list timed_out_sessions; // The timed out sessions are transfered to this list - // which is destroyed after the lock on session has been released. - locked_sessions_t::writer sessions_wr(sessions); - for (sessions_t::iterator i = sessions_wr->begin(); - i != sessions_wr->end();) { - sessions_t::iterator next = i; ++next; - if (i->second->timed_out()) { - timed_out_sessions.push_back(i->second); - sessions_wr->erase(i); - } - i = next; - } -} - - -void Anyterm::run_reaper_thread(void) -{ - while (1) { - sleep(30); - reap_timed_out_sessions(); - } -} - diff --git a/extras/anytermd/src/Anyterm.hh b/extras/anytermd/src/Anyterm.hh deleted file mode 100644 index 9da27c330b..0000000000 --- a/extras/anytermd/src/Anyterm.hh +++ /dev/null @@ -1,71 +0,0 @@ -// daemon/Anyterm.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - - - -#ifndef Anyterm_hh -#define Anyterm_hh - -#include -#include - -#include - -#include "Locked.hh" - -#include "Session.hh" -#include "config.hh" -#include "HttpRequest.hh" - - -class Anyterm { - -private: - const std::string def_charset; - const bool diff; - const int max_sessions; - typedef boost::shared_ptr session_ptr_t; - typedef std::map sessions_t; - typedef pbe::Locked locked_sessions_t; - locked_sessions_t sessions; - Session::activityfactory_t activityfactory; - bool reaper_running; - -public: - - Anyterm(std::string command, std::string device, std::string charset, bool diff, - int max_sessions_); - - struct response_t { - std::string type; - std::string body; - response_t(std::string t, std::string b): type(t), body(b) {}; - }; - - response_t process_request(const pbe::HttpRequest& request); - - void reap_timed_out_sessions(void); - void run_reaper_thread(void); - -}; - - - - -#endif diff --git a/extras/anytermd/src/AnytermDaemon.cc b/extras/anytermd/src/AnytermDaemon.cc deleted file mode 100644 index bde3efcf3b..0000000000 --- a/extras/anytermd/src/AnytermDaemon.cc +++ /dev/null @@ -1,74 +0,0 @@ -// daemon/AnytermDaemon.cc -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include "AnytermDaemon.hh" - -#include "Anyterm.hh" -#include "static_content.hh" - -#include -#include - -#include "segv_backtrace.hh" - - -using namespace std; -using namespace pbe; - - -/*virtual*/ void AnytermDaemon::session_start() -{ - get_backtrace_on_segv(); -} - -void AnytermDaemon::handle(const HttpRequest& req0, HttpResponse& resp) -{ - HttpRequest req = req0; - - //syslog(LOG_NOTICE,"anytermd handling %s",req.uri.c_str()); - - resp.headers["Server"]="anytermd"; - - authenticate(req); - - // Redirect a request for '/' to '/anyterm.html'. - if (req.abs_path=="/") { - string host = req.headers.find("Host")->second; - // This is tricky if we're being proxied to because "host" is the post-proxy - // hostname (e.g. locahost) while the browser needs to see the pre-proxy hostname. - // Apache can fix this up for us if we use something like this: - // ProxyPassReverse http://localhost:8080 - resp.headers["Location"]="http://"+host+"/anyterm.html"; - resp.status_code=301; - return; - } - - if (get_static_content(req.abs_path, resp.headers["Content-Type"], resp.body)) { - return; - } - - Anyterm::response_t r = anyterm.process_request(req); - resp.headers["Content-Type"] = r.type; - resp.headers["Cache-Control"] = "no-cache, no-store"; - resp.headers["Pragma"] = "no-cache"; - resp.body = r.body; -} - - - diff --git a/extras/anytermd/src/AnytermDaemon.hh b/extras/anytermd/src/AnytermDaemon.hh deleted file mode 100644 index 1cf7cc21ca..0000000000 --- a/extras/anytermd/src/AnytermDaemon.hh +++ /dev/null @@ -1,82 +0,0 @@ -// daemon/AnytermDaemon.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef AnytermDaemon_hh -#define AnytermDaemon_hh - -#include "HttpDaemon.hh" -#include "HttpRequest.hh" -#include "HttpResponse.hh" -#include "Anyterm.hh" -#include "NullAuthenticator.hh" -#include "TrivialAuthenticator.hh" - - -static inline HttpAuthenticator* choose_authenticator(std::string authname) { - if (authname=="none") { - return NULL; - } else if (authname=="null") { - return new NullAuthenticator; - } else if (authname=="trivial") { - return new TrivialAuthenticator; - } else { - throw "Unrecognised auth type"; - } -} - - -class AnytermDaemon_base { -protected: - boost::scoped_ptr auth_p; - -public: - AnytermDaemon_base(std::string authname): - auth_p(choose_authenticator(authname)) - {} -}; - - -class AnytermDaemon: public AnytermDaemon_base, public pbe::HttpDaemon { -private: - Anyterm anyterm; - -public: - AnytermDaemon(short port=80, std::string user="", - std::string command="", - std::string device="", - std::string name="", - std::string authname="none", - std::string charset="ascii", - bool diff=true, - int max_sessions=20, - int max_http_connections=60, - bool accept_local_only=false): - AnytermDaemon_base(authname), - HttpDaemon(*auth_p.get(), port, (name=="") ? "anyterm" : name, - user, true, max_http_connections, accept_local_only), - anyterm(command, device, charset, diff, max_sessions) - {} - - void session_start(); - void handle(const pbe::HttpRequest& req, pbe::HttpResponse& resp); - -}; - - -#endif diff --git a/extras/anytermd/src/Attributes.hh b/extras/anytermd/src/Attributes.hh deleted file mode 100644 index e6100a2364..0000000000 --- a/extras/anytermd/src/Attributes.hh +++ /dev/null @@ -1,49 +0,0 @@ -// common/Attributes.hh -// This file is part of AnyTerm; see http://anyterm.org/ -// (C) 2006-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef Attributes_hh -#define Attributes_hh - - -struct Attributes { - unsigned fg : 3; - unsigned bg : 3; - unsigned halfbright : 1; - unsigned bold : 1; - unsigned underline : 1; - unsigned blink : 1; - unsigned inverse : 1; - - Attributes(): - fg(7), bg(0), - halfbright(false), bold(false), underline(false), blink(false), inverse(false) - {} - - bool operator==(const Attributes& other) const { - return fg==other.fg && bg==other.bg - && halfbright==other.halfbright && bold==other.bold - && underline==other.underline && blink==other.blink - && inverse==other.inverse; - } - bool operator!=(const Attributes& other) const { - return ! operator==(other); - } -}; - - -#endif diff --git a/extras/anytermd/src/Cell.hh b/extras/anytermd/src/Cell.hh deleted file mode 100644 index f82390163f..0000000000 --- a/extras/anytermd/src/Cell.hh +++ /dev/null @@ -1,36 +0,0 @@ -// common/Cell.hh -// This file is part of AnyTerm; see http://anyterm.org/ -// (C) 2006-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef Cell_hh -#define Cell_hh - -#include "Attributes.hh" - -#include "unicode.hh" - - -struct Cell { - ucs4_char c; - Attributes attrs; - - Cell(ucs4_char c_=' '): c(c_) {} - Cell(ucs4_char c_, Attributes attrs_): c(c_), attrs(attrs_) {} -}; - - -#endif diff --git a/extras/anytermd/src/CgiParams.hh b/extras/anytermd/src/CgiParams.hh deleted file mode 100644 index 9e58f5a72d..0000000000 --- a/extras/anytermd/src/CgiParams.hh +++ /dev/null @@ -1,56 +0,0 @@ -// common/CgiParams.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef CgiParams_hh -#define CgiParams_hh - -#include -#include -#include - - -class CgiParams: public std::map { - -protected: - typedef std::map basetype; - -public: - std::string get(std::string name, std::string def="") const { - basetype::const_iterator i = find(name); - if (i==end()) { - return def; - } else { - return i->second; - } - } - - template - T get_as(std::string name, T def = T()) const { - basetype::const_iterator i = find(name); - if (i==end()) { - return def; - } else { - return boost::lexical_cast(i->second); - } - } - -}; - - -#endif diff --git a/extras/anytermd/src/Error.hh b/extras/anytermd/src/Error.hh deleted file mode 100644 index f183951b97..0000000000 --- a/extras/anytermd/src/Error.hh +++ /dev/null @@ -1,49 +0,0 @@ -// common/Error.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -// Exception classes to indicate errors - -#ifndef Error_hh -#define Error_hh - -#include - -#include - - -class Error { - private: - std::string msg; - - public: - Error(std::string m): msg(m) {}; - std::string get_msg(void) const {return msg;} -}; - - -class SysError: public Error { - public: - SysError(std::string m): Error(m+": "+strerror(errno)) {}; -}; - - - - - -#endif diff --git a/extras/anytermd/src/NullAuthenticator.hh b/extras/anytermd/src/NullAuthenticator.hh deleted file mode 100644 index dc4fb5720d..0000000000 --- a/extras/anytermd/src/NullAuthenticator.hh +++ /dev/null @@ -1,40 +0,0 @@ -// daemon/NullAuthenticator.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef NullAuthenticator_hh -#define NullAuthenticator_hh - -#include "HttpAuthenticator.hh" - -#include "compiler_magic.hh" - - -class NullAuthenticator: public HttpAuthenticator { - -public: - - void basic_auth(PBE_UNUSED_ARG(std::string username), - PBE_UNUSED_ARG(std::string password)) const { - return; - } - -}; - - -#endif diff --git a/extras/anytermd/src/Screen.hh b/extras/anytermd/src/Screen.hh deleted file mode 100644 index 764c96653a..0000000000 --- a/extras/anytermd/src/Screen.hh +++ /dev/null @@ -1,140 +0,0 @@ -// daemon/Screen.hh -// This file is part of AnyTerm; see http://anyterm.org/ -// (C) 2006-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef Screen_hh -#define Screen_hh - -#include -#include - -#include "Cell.hh" - - -class Screen { - int rows_; - int cols_; - int scrollback_; - typedef std::vector row_t; - typedef std::vector cells_t; - cells_t cells; - unsigned int wrap; - -public: - Screen(int rows, int cols, int scrollback=0): - rows_(rows), cols_(cols), scrollback_(scrollback), - wrap(0), - cursor_row(0), cursor_col(0), cursor_visible(true) - { - for (int r=0; r -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "select.hh" -#include "Exception.hh" - - -using namespace std; -using namespace pbe; - - -SerialPortActivity::SerialPortActivity(Activity::onOutput_t onOutput, - Activity::onError_t onError, - string fn, int baudrate): - SerialPortActivity_base(fn,FileDescriptor::read_write,baudrate), - Activity(onOutput, onError, sp) -{} - - - - diff --git a/extras/anytermd/src/SerialPortActivity.hh b/extras/anytermd/src/SerialPortActivity.hh deleted file mode 100644 index ee04f3837a..0000000000 --- a/extras/anytermd/src/SerialPortActivity.hh +++ /dev/null @@ -1,49 +0,0 @@ -// common/SerialPort.hh -// This file is part of AnyTerm; see http://anyterm.org/ -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef SerialPort_hh -#define SerialPort_hh - -#include "Activity.hh" - -#include - -#include "SerialPort.hh" - - -// This base class is just so that sp can be initialised before being Activity. -struct SerialPortActivity_base { - pbe::SerialPort sp; - SerialPortActivity_base(std::string fn, pbe::FileDescriptor::open_mode_t open_mode, - int baudrate, bool raw=true): - sp(fn,open_mode,baudrate,raw) - {} -}; - - -class SerialPortActivity: private SerialPortActivity_base, public Activity { -public: - SerialPortActivity(Activity::onOutput_t onOutput, - Activity::onError_t onError, - std::string fn, int baudrate); - - ~SerialPortActivity() {}; -}; - - -#endif diff --git a/extras/anytermd/src/Session.cc b/extras/anytermd/src/Session.cc deleted file mode 100644 index 3af9b1026c..0000000000 --- a/extras/anytermd/src/Session.cc +++ /dev/null @@ -1,196 +0,0 @@ -// daemon/Session.cc -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005-2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include "Session.hh" - -#include -#include - -#include -#include - -#include - -#include "Lock.hh" - -#include "config.hh" -#include "html.hh" -#include "editscript.hh" -#include "Error.hh" -#include "Iconver.hh" -#include "unicode.hh" - - -using namespace std; -using namespace pbe; - - -Session::Session(int r, int c, int sb, - string host, string user, string param, - int t, - activityfactory_t af, - string charset_, - bool diff_): - rows(r), - cols(c), - scrollback(sb), - time_out(t), - charset(charset_), - diff(diff_), - utf8_to_charset("UTF-8",charset), - charset_to_ucs4(charset,UCS4_NATIVE), - ucs4_to_utf8(UCS4_NATIVE,"UTF-8"), - screen(rows,cols,scrollback), - error(false), - term(rows,cols,screen), - activity(af(boost::bind(&Session::process_output,this,_1), - boost::bind(&Session::process_error,this,_1), - host, user, param, r, c)) -{ - dirty=true; - touch(); -} - - -Session::~Session() -{} - - -// Timeout unused sessions: - -void Session::touch(void) -{ - last_access = time(NULL); -} - - -// Check if session has a backend error to report - -void Session::report_any_backend_error(void) -{ - if (error) { - error=false; - throw Error(error_msg); - } -} - - -// Handle Apache requests: - -string int_to_string(int i) -{ - char b[32]; - snprintf(b,sizeof(b),"%d",i); - return b; -} - - -void Session::send(string k) -{ - if (!k.empty()) { - string dk = utf8_to_charset(k); - activity->send(dk); - } - - touch(); -} - - - -string escape_html(string s) -{ - string t; - for(string::size_type i=0; i': t+=">"; break; - case '&': t+="&"; break; - default: t+=c; break; - } - } - return t; -} - - -string Session::rcv(void) -{ - { - Lock l(screen_lock); - if (!dirty && !error) { - dirty_condition.timed_wait(l,10.0F); - } - } - touch(); - - report_any_backend_error(); - - bool was_dirty; - ucs4_string html_screen; - { - Lock l(screen_lock); - was_dirty = dirty; - dirty=false; - if (!was_dirty) { - return "n"; - } - html_screen = htmlify_screen(screen); - } - - string utf8_editscript; - if (diff) { - ucs4_string editscript = make_editscript(old_html_screen,html_screen); - old_html_screen=html_screen; - utf8_editscript = ucs4_to_utf8(editscript); - } else { - utf8_editscript = "R"; - utf8_editscript.append(ucs4_to_utf8(html_screen)); - } - - return utf8_editscript; -} - - -void Session::process_output(string s) -{ - ucs4_string ucs4_s = charset_to_ucs4(s); - { - Lock l(screen_lock); - term.write(ucs4_s); - dirty = true; - } - dirty_condition.notify_all(); -} - - -void Session::process_error(string s) -{ - // We could have a lock here, but maybe we can trust that the assignment - // to error is atomic. - error_msg = s; - error = true; - dirty_condition.notify_all(); -} - - -bool Session::timed_out(void) -{ - return time(NULL) - last_access > time_out; -} - diff --git a/extras/anytermd/src/Session.hh b/extras/anytermd/src/Session.hh deleted file mode 100644 index 030e918b85..0000000000 --- a/extras/anytermd/src/Session.hh +++ /dev/null @@ -1,99 +0,0 @@ -// daemon/Session.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005-2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef Session_hh -#define Session_hh - -//#define __STDC_LIMIT_MACROS -//#include - -#include "SessionId.hh" - -#include "Mutex.hh" -#include "Condition.hh" - -#include -#include -#include -#include - - -#include "Screen.hh" -#include "Terminal.hh" -#include "Activity.hh" -#include "Iconver.hh" - - -class Session: boost::noncopyable { -public: - - const SessionId id; - const int rows; - const int cols; - const int scrollback; - const int time_out; - const std::string charset; - const bool diff; - -private: - pbe::Iconver utf8_to_charset; - pbe::Iconver charset_to_ucs4; - pbe::Iconver ucs4_to_utf8; - -public: - Screen screen; - typedef pbe::Mutex<> screen_lock_t; - screen_lock_t screen_lock; - volatile bool dirty; - typedef pbe::Condition dirty_condition_t; - dirty_condition_t dirty_condition; - /*volatile*/ std::string error_msg; - volatile bool error; - ucs4_string old_html_screen; - volatile time_t last_access; - - Terminal term; - boost::scoped_ptr activity; - - typedef boost::function activityfactory_t; - Session(int r, int c, int sb, - std::string host, std::string user, std::string param, - int t, - activityfactory_t activityfactory, - std::string charset_, - bool diff_); - ~Session(); - - void touch(void); - void report_any_backend_error(void); - void send(std::string k); - std::string rcv(void); - - bool timed_out(void); - -private: - void process_output(std::string s); - void process_error(std::string s); -}; - - -#endif diff --git a/extras/anytermd/src/SessionId.cc b/extras/anytermd/src/SessionId.cc deleted file mode 100644 index 17300b5224..0000000000 --- a/extras/anytermd/src/SessionId.cc +++ /dev/null @@ -1,53 +0,0 @@ -// apachemod/SessionId.cc -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005 Philip Endecott - - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "SessionId.hh" - -#include -#include -#include -#include - -using namespace std; - - -SessionId::SessionId() -{ - ifstream devurandom("/dev/urandom"); - devurandom.read(reinterpret_cast(&n),sizeof(n)); -} - -uint64_t SessionId::hexstr_to_uint64(string s) const -{ - stringstream ss; - ss << s; - uint64_t i; - ss >> setbase(16) >> i; - return i; -} - - -string SessionId::uint64_to_hexstr(uint64_t i) const -{ - stringstream ss; - ss << setbase(16) << i; - return ss.str(); -} - - diff --git a/extras/anytermd/src/SessionId.hh b/extras/anytermd/src/SessionId.hh deleted file mode 100644 index 28fb00efb9..0000000000 --- a/extras/anytermd/src/SessionId.hh +++ /dev/null @@ -1,54 +0,0 @@ -// apachemod/SessionId.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005 Philip Endecott - - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -// This file defines the 64-bit random ID used to identify sessions - -#ifndef SessionId_hh -#define SessionId_hh - -#include - -#include -#include - - -class SessionId { -public: - SessionId(void); - SessionId(uint64_t i): n(i) {} - SessionId(std::string s): n(hexstr_to_uint64(s)) {} - std::string str(void) const { return uint64_to_hexstr(n); } - bool operator==(SessionId rhs) const { return n==rhs.n; } - bool operator<(SessionId rhs) const { return n -#include -#elif defined(__OpenBSD__) -#include -#include -#elif defined(__APPLE__) -#include -#else -#include -#endif - -#include -#include -#include -#include -#include - -#include - -#include "select.hh" -#include "Exception.hh" - - -using namespace std; -using namespace pbe; - - -static std::pair open_subprocess(string command, int pty_rows, int pty_cols) -{ - struct winsize ws; - ws.ws_row=pty_rows; - ws.ws_col=pty_cols; - ws.ws_xpixel=0; - ws.ws_ypixel=0; - - int fd; - int pid = forkpty(&fd, NULL, NULL, &ws); - if (pid==-1) { - throw_ErrnoException("forkpty()"); - } - if (pid==0) { - setenv("TERM","linux",1); - struct termios t; - tcgetattr(0,&t); // Could fail, but where would we send the error? - t.c_cc[VERASE]=8; // Make ctrl-H (backspace) the erase character. - tcsetattr(0,TCSANOW,&t); // ditto. - execl("/bin/sh","/bin/sh","-c",command.c_str(),NULL); - throw_ErrnoException("execl(/bin/sh -c "+command+")"); // pointless. - } - return make_pair(fd,pid); -} - - -SubProcess::SubProcess(Activity::onOutput_t onOutput, - Activity::onError_t onError, - string command, - int pty_rows, int pty_cols): - SubProcess_base(open_subprocess(command, pty_rows, pty_cols)), - Activity(onOutput, onError, SubProcess_base::fd) -{} - - -SubProcess::~SubProcess() -{ - // We do two things to try to kill the subprocess: we close the fd, - // which really ought to kill it, and we SIGHUP it. The SIGHUP - // by itself may not be sufficient if the process is nohup or - // setuid or something. The close by itself really should be - // sufficient, but I'm keeping the SIGHUP because I'm paranoid. - // The three results that we want are (a) the process dies, - // (b) it does not become a zombie, and (c) the output processor - // thread terminates so that ~Activity can join it. For (c), - // we hope that it will get an error when reading from the fd - // and/or that it sees terminating set. There's a danger that - // we could close the fd and something else could open another - // fd with the same number, which the output processor could read. - // I hope that's not a high probability. - - terminating = true; - - fd_open = false; - try { - SubProcess_base::fd.close(); - // fd.close() can throw. - } catch (...) {} - kill(pid,SIGHUP); -} - - diff --git a/extras/anytermd/src/SubProcess.hh b/extras/anytermd/src/SubProcess.hh deleted file mode 100644 index 405c429001..0000000000 --- a/extras/anytermd/src/SubProcess.hh +++ /dev/null @@ -1,59 +0,0 @@ -// common/SubProcess.hh -// This file is part of AnyTerm; see http://anyterm.org/ -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef SubProcess_hh -#define SubProcess_hh - -#include "Activity.hh" - -#include - -#include "FileDescriptor.hh" - - -// This base class is just so that fd can be initialised before Activity. -struct SubProcess_base { - pbe::FileDescriptor fd; - bool fd_open; - ::pid_t pid; - SubProcess_base(std::pair fd_pid): - fd(fd_pid.first, false), fd_open(true), pid(fd_pid.second) - {} - ~SubProcess_base() { - if (fd_open) { - // Normally fd is closed by ~SubProcess; this is here in case - // e.g. Activity's ctor throws and ~SubProcess is not executed. - fd.close(); - } - } -}; - - -class SubProcess: private SubProcess_base, public Activity { - -public: - SubProcess(Activity::onOutput_t onOutput_, - Activity::onError_t onError_, - std::string command, - int pty_rows=25, int pty_cols=80); - - ~SubProcess(); -}; - - -#endif diff --git a/extras/anytermd/src/Terminal.cc b/extras/anytermd/src/Terminal.cc deleted file mode 100644 index 53cc1e8914..0000000000 --- a/extras/anytermd/src/Terminal.cc +++ /dev/null @@ -1,789 +0,0 @@ -// common/Terminal.cc -// This file is part of libpbe; see http://svn.chezphil.org/libpbe/ -// (C) 2006-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "Terminal.hh" - -#include - -#include "Exception.hh" - -using namespace std; - - -static const bool debug_emulation = false; - - -// This terminal emulation code attempts to emulate the Linux console, as described in -// "man 4 console_codes". This has quite a lot in common with other common terminals -// (e.g. vt102, xterm etc) but there are always small differences. -// The starting point for this code is ROTE, and it's because ROTE chose to emulate the -// Linux console that this does the same. ROTE's emulation is not, however, very -// comprehensive. - -// [*] = This code is not implemented, but has been observed in use. - -// We really ought to implement an additional level of character set mode selection. SI -// and SO switch between G0 and G1 character sets, and we implement that assuming that G0 -// and G1 have their default meanings. However, ESC ( and ESC ) can be used to change -// the meaning of G0 and G1; we don't implement that (but could). This would make pstree -// -G work. - - -Terminal::Terminal(int rows, int cols, Screen& screen_): - screen(screen_), - rows_(rows), - cols_(cols), - saved_cursor_row(0), - saved_cursor_col(0), - scrolltop(0), - scrollbottom(rows-1), - charset_mode(0), - crlf_mode(false), - dirty(true), - esc_state(normal), - pc850_to_ucs4("850",UCS4_NATIVE) -{ - charset_modes[0] = cs_normal; - charset_modes[1] = cs_vt100gr; -} - - -Terminal::~Terminal() -{} - - -int Terminal::rows() const -{ - return rows_; -} - -int Terminal::cols() const -{ - return cols_; -} - - -bool Terminal::was_dirty(void) -{ - bool d = dirty; - dirty = false; - return d; -} - - -void Terminal::clip_cursor() -{ - screen.cursor_row = max(screen.cursor_row,0); - screen.cursor_row = min(screen.cursor_row,rows()-1); - screen.cursor_col = max(screen.cursor_col,0); - screen.cursor_col = min(screen.cursor_col,cols()-1); -} - - -void Terminal::cursor_line_down() -{ - screen.cursor_row++; - if (screen.cursor_row<=scrollbottom) { - return; - } - screen.scroll_down(scrolltop,scrollbottom); - screen.cursor_row = scrollbottom; -} - -void Terminal::cursor_line_up() -{ - screen.cursor_row--; - if (screen.cursor_row>=scrolltop) { - return; - } - screen.scroll_up(scrolltop,scrollbottom); - screen.cursor_row = scrolltop; -} - - -void Terminal::write_normal_char(ucs4_char c) -{ - switch (charset_modes[charset_mode]) { - case cs_vt100gr: - switch (c) { - case 'j': c=L'\u255b'; break; // lower right corner - case 'k': c=L'\u2510'; break; // upper right corner - case 'l': c=L'\u250c'; break; // upper left corner - case 'm': c=L'\u2514'; break; // lower left corner - case 'n': c=L'\u253c'; break; // crossing lines - case 'o': c=L'\u2500'; break; // horizontal line - scan 1 - case 'p': c=L'\u2500'; break; // horizontal line - scan 3 - case 'q': c=L'\u2500'; break; // horizontal line - scan 5 - case 'r': c=L'\u2500'; break; // horizontal line - scan 7 - case 's': c=L'\u2500'; break; // horizontal line - scan 9 - case 't': c=L'\u251c'; break; // left T - case 'u': c=L'\u2524'; break; // right T - case 'v': c=L'\u2534'; break; // bottom T - case 'w': c=L'\u252c'; break; // top T - case 'x': c=L'\u2502'; break; // vertical bar - } - break; - case cs_pc: { - string ch(1,c); - pc850_to_ucs4.reset(); - ucs4_string s = pc850_to_ucs4(ch); - c = s[0]; - break; - } - case cs_normal: - break; - } - - if (screen.cursor_col>=cols()) { - screen.cursor_col = 0; - cursor_line_down(); - } - screen(screen.cursor_row,screen.cursor_col) = Cell(c,current_attrs); - screen.cursor_col++; -} - - -void Terminal::carriage_return() -{ - screen.cursor_col = 0; -} - - -void Terminal::line_feed() -{ - cursor_line_down(); - if (crlf_mode) { - carriage_return(); - } -} - - -void Terminal::backspace() -{ - if (screen.cursor_col>0) { - screen.cursor_col--; - } -} - - -void Terminal::tab() -{ - do { - write_normal_char(' '); - } while (screen.cursor_col%8); -} - - -void Terminal::reset() -{ - for (int r=0; r=30 && params[i]<=37) { - current_attrs.fg = params[i]-30; - } else if (params[i]>=40 && params[i]<=47) { - current_attrs.bg = params[i]-40; - } else { - if (debug_emulation) { - cout << "Ignoring attribute " << params[i] << "\n"; - } - } - break; - } - } -} - - -void Terminal::csi_SM() -{ - // Set modes. - // Not implemented. - if (nparams!=1) { - return; - } - - switch (params[0]) { - //case 3: DECCRM mode - display control characters break; - //case 4: DECIM mode - insert mode break; - case 20: crlf_mode = true; - default: if (debug_emulation) { - cout << "Ignoring SM mode " << params[0] << "\n"; - } - } -} - - -void Terminal::csi_RM() -{ - // Reset modes. - // These modes are not implemented, so resetting them does nothing. - if (nparams!=1) { - return; - } - - switch (params[0]) { - case 3: break; // DECCRM mode - display control characters - case 4: break; // DECIM mode - insert mode - case 20: crlf_mode = false; break; - default: if (debug_emulation) { - cout << "Ignoring RM mode " << params[0] << "\n"; - } - } -} - - -void Terminal::csi_DSR() -{ - // Report status. - // Not implemented. - if (nparams!=1) { - return; - } - - switch (params[0]) { - //case 5: DSR - device status - reply ESC [ 0 n break; - //case 6: CPR - cursor position - reply ESC [ y ; x R break; - default: if (debug_emulation) { - cout << "Ignoring status report request " << params[0] << "\n"; - } - } -} - - -void Terminal::csi_ED() -{ - // Erase display. - int start_row; - int start_col; - int end_row; - int end_col; - - if (nparams>0 && params[0]==1) { - start_row = 0; - start_col = 0; - end_row = screen.cursor_row; - end_col = screen.cursor_col; - - } else if (nparams>0 && params[0]==2) { - start_row = 0; - start_col = 0; - end_row = rows()-1; - end_col = cols()-1; - - } else { - start_row = screen.cursor_row; - start_col = screen.cursor_col; - end_row = rows()-1; - end_col = cols()-1; - } - - for (int r=start_row; r<=end_row; ++r) { - for (int c=(r==start_row?start_col:0); c<=(r==end_row?end_col:cols()-1); ++c) { - screen(r,c) = Cell(' ',current_attrs); - } - } -} - - -void Terminal::csi_CUP() -{ - // Move cursor to absolute position. - // With no parameters, move to origin. - if (nparams==0) { - screen.cursor_row = 0; - screen.cursor_col = 0; - } else { - screen.cursor_row = params[0]-1; - screen.cursor_col = params[1]-1; - clip_cursor(); - } -} - -void Terminal::csi_HVP() -{ - csi_CUP(); -} - - -void Terminal::csi_CUU() -{ - // Cursor Up. - int n = params[0]; - screen.cursor_row -= n; - clip_cursor(); -} - - -void Terminal::csi_CUD() -{ - // Cursor Down. - int n = params[0]; - screen.cursor_row += n; - clip_cursor(); -} - -void Terminal::csi_VPR() -{ - csi_CUD(); -} - - -void Terminal::csi_CUF() -{ - // Cursor Forward (right). - int n = params[0]; - screen.cursor_col += n; - clip_cursor(); -} - -void Terminal::csi_HPR() -{ - csi_CUF(); -} - -void Terminal::csi_CUB() -{ - // Cursor Back (left). - int n = params[0]; - screen.cursor_col -= n; - clip_cursor(); -} - - -void Terminal::csi_CNL() -{ - // Cursor next line. - csi_CUD(); - screen.cursor_col = 0; - clip_cursor(); -} - - -void Terminal::csi_CPL() -{ - // Cursor previous line. - csi_CUU(); - screen.cursor_col = 0; - clip_cursor(); -} - - -void Terminal::csi_CHA() -{ - screen.cursor_col = params[0]-1; - clip_cursor(); -} - -void Terminal::csi_HPA() -{ - csi_HPA(); -} - - -void Terminal::csi_VPA() -{ - screen.cursor_row = params[0]-1; - clip_cursor(); -} - - -void Terminal::csi_EL() -{ - // Erase line. - int start; - int end; - - if (nparams>0 && params[0]==1) { - start = 0; - end = screen.cursor_col; - - } else if (nparams>0 && params[0]==2) { - start = 0; - end = cols()-1; - - } else { - start = screen.cursor_col; - end = cols()-1; - } - - for (int i=start; i<=end; ++i) { - screen(screen.cursor_row,i) = Cell(' ',current_attrs); - } -} - - -void Terminal::csi_ICH() -{ - // Insert blanks. - int n = params[0]; - for (int i=cols()-1; i>=screen.cursor_col+n; --i) { - screen(screen.cursor_row,i) = screen(screen.cursor_row,i-n); - } - for (int i=screen.cursor_col; inewbottom) { - return; - } - - scrolltop = newtop; - scrollbottom = newbottom; -} - - -void Terminal::csi_SAVECUR() -{ - // Save cursor position. - saved_cursor_row = screen.cursor_row; - saved_cursor_col = screen.cursor_col; -} - - -void Terminal::csi_RESTORECUR() -{ - // Restore cursor position. - screen.cursor_row = saved_cursor_row; - screen.cursor_col = saved_cursor_col; -} - - -void Terminal::csi_DECSET() -{ - if (nparams!=1) { - return; - } - - switch (params[0]) { - //case 1: Change cursor key prefix break; - //case 3: 80/132-column mode break; - //case 5: Reverse video mode break; - //case 6: Scroll-region-relative cursor addressing mode break; - //case 7: Autowrap mode break; [*] - //case 8: Autorepeat break; - //case 9: X10 mouse reporting break; - case 25: screen.cursor_visible=true; break; - //case 1000: X11 mouse reporting break; - default: if (debug_emulation) { - cout << "Ignoring DECSET " << params[0] << "\n"; - } - } -} - - -void Terminal::csi_DECRST() -{ - if (nparams!=1) { - return; - } - - switch (params[0]) { - //case 1: Change cursor key prefix break; - //case 3: 80/132-column mode break; - //case 5: Reverse video mode break; - //case 6: Scroll-region-relative cursor addressing mode break; - //case 7: Autowrap mode break; - //case 8: Autorepeat break; - //case 9: X10 mouse reporting break; - case 25: screen.cursor_visible=false; break; - //case 1000: X11 mouse reporting break; - default: if (debug_emulation) { - cout << "Ignoring DECSET " << params[0] << "\n"; - } - } -} - - -void Terminal::write_char(ucs4_char c) -{ - if (c<=31) { - switch (c) { - case '\a': /* bell */ break; - case '\b': backspace(); break; - case '\t': tab(); break; - case '\n': /* fall through */ - case '\v': /* fall through */ - case '\f': line_feed(); break; - case '\r': carriage_return(); break; - case '\x0E': charset_mode=1; break; - case '\x0F': charset_mode=0; break; - case '\x18': /* fall through */ - case '\x1A': esc_state = normal; break; - case '\x1B': esc_state = seen_esc; break; - default: if (debug_emulation) { - cout << "Ignoring ctrl character " << static_cast(c) << "\n"; break; - } - } - dirty = true; - - } else if (c==0x9b) { - // Is there a conflict between 9b==CSI and a UTF8 or ISO-8859 interpretation? - esc_state = seen_csi; nparams=0; params[0]=1; - - } else { - switch (esc_state) { - case normal: - write_normal_char(c); - dirty = true; - break; - - case seen_esc: - switch (c) { - case 'c': reset(); dirty=true; esc_state=normal; break; - case 'D': line_feed(); dirty=true; esc_state=normal; break; - case 'E': carriage_return(); dirty=true; esc_state=normal; break; - //case 'H': set_tab_stop(); esc_state=normal; break; [*] - case 'M': cursor_line_up(); dirty=true; esc_state=normal; break; - //case 'Z': dec_priv_ident(); esc_state=normal; break; // kernel returns ESC [ ? 6 c - //case '7': save_state(); esc_state=normal; break; // save cursor pos, attributes, charsets - //case '8': restore_state(); dirty=true; esc_state=normal; break; - case '[': esc_state=seen_csi; nparams=0; params[0]=1; break; - //case '%': esc_state=seen_escpercent; break; // select character set based on next char - // @=8859-1, G=8=UTF-8 - //case '#': esc_state=seen_eschash; break; // ESC # 8 = fill screen with Es - case '(': esc_state=seen_esclparen; break; // select G0 charset based on next char - case ')': esc_state=seen_escrparen; break; // select G1 charset based on next char - //case '>': numeric_keypad_mode(); esc_state=normal; break; - //case '=': application_keypad_mode(); esc_state=normal; break; - //case ']': esc_state=seen_escrbraket; break; - // ESC ] P nrrggbb = set palette; colour n (hex) - // ESC ] R = reset palette [*] - default: if (debug_emulation) { - cout << "Ignoring esc character " << c << "\n"; - } - esc_state = normal; - } - break; - - case seen_csi: /* fall through */ - case seen_csi_private: - if (c>='0' && c<='9') { - if (nparams==0) { - nparams=1; - params[0]=0; - } - params[nparams-1] = params[nparams-1] * 10 + (c-'0'); - - } else if (c==';') { - if (nparams>=nparams_max) { - return; - } - nparams++; - params[nparams-1] = 0; - - } else if (c=='?') { - esc_state = seen_csi_private; - - } else { - if (esc_state==seen_csi_private) { - switch (c) { - //case 'c': Unknown; code seen but not described in 'man console_codes' [*] - case 'h': csi_DECSET(); break; - case 'l': csi_DECRST(); break; - default: if (debug_emulation) { - cout << "Ignoring private csi character " << c << "\n"; - } - } - } else { - switch (c) { - case '@': csi_ICH(); break; - case 'A': csi_CUU(); break; - case 'B': csi_CUD(); break; - case 'C': csi_CUF(); break; - case 'D': csi_CUB(); break; - case 'E': csi_CNL(); break; - case 'F': csi_CPL(); break; - case 'G': csi_CHA(); break; - case 'H': csi_CUP(); break; - case 'J': csi_ED(); break; - case 'K': csi_EL(); break; - case 'L': csi_IL(); break; - case 'M': csi_DL(); break; - case 'P': csi_DCH(); break; - case 'X': csi_ECH(); break; - case 'a': csi_HPR(); break; - //case 'c': csi_DA(); break; // Reply ESC [ ? 6 c - case 'd': csi_VPA(); break; - case 'e': csi_VPR(); break; - case 'f': csi_HVP(); break; - //case 'g': csi_TBC(); break; // Clear tab stop [*] - case 'h': csi_SM(); break; - case 'l': csi_RM(); break; - case 'm': csi_SGR(); break; - case 'n': csi_DSR(); break; - //case 'q': csi_DECLL(); break; // Set keyboard LEDs - case 'r': csi_DECSTBM(); break; - case 's': csi_SAVECUR(); break; - case 'u': csi_RESTORECUR(); break; - case '`': csi_HPA(); break; - default: if (debug_emulation) { - cout << "Ignoring csi character " << c << "\n"; - } - } - } - dirty = true; - esc_state = normal; - - } - break; - - case seen_esclparen: /* fall through */ - case seen_escrparen: { - charset_mode_t m = cs_normal; - switch (c) { - case 'B': m = cs_normal; break; - case '0': m = cs_vt100gr; break; - case 'U': m = cs_pc; break; - } - if (esc_state == seen_esclparen) { - charset_modes[0] = m; - } else { - charset_modes[1] = m; - } - esc_state = normal; - break; - } - } - } -} - - -void Terminal::write(ucs4_string data) -{ - for (size_t i=0; i - -#include "Cell.hh" -#include "Attributes.hh" -#include "Screen.hh" -#include "unicode.hh" -#include "Iconver.hh" - - -class Terminal { - -public: - Terminal(int rows, int cols, Screen& screen_); - ~Terminal(); - - int rows(void) const; - int cols(void) const; - - Screen& screen; - - bool was_dirty(void); - - void write(ucs4_string data); - -private: - int rows_; - int cols_; - - int saved_cursor_row; - int saved_cursor_col; - - int scrolltop; - int scrollbottom; - - Attributes current_attrs; - - enum charset_mode_t { cs_normal, cs_pc, cs_vt100gr }; - charset_mode_t charset_modes[2]; - int charset_mode; - - bool crlf_mode; - - bool dirty; - - int nparams; - static const int nparams_max = 16; - int params[nparams_max]; - - enum esc_state_t { normal, seen_esc, seen_csi, seen_csi_private, seen_esclparen, seen_escrparen }; - esc_state_t esc_state; - - pbe::Iconver pc850_to_ucs4; - - void clip_cursor(); - void cursor_line_down(); - void cursor_line_up(); - void write_normal_char(ucs4_char c); - void carriage_return(); - void line_feed(); - void backspace(); - void tab(); - void reset(); - void csi_SGR(); - void csi_SM(); - void csi_RM(); - void csi_DSR(); - void csi_ED(); - void csi_CUP(); - void csi_HVP(); - void csi_CUU(); - void csi_CUD(); - void csi_VPR(); - void csi_CUF(); - void csi_HPR(); - void csi_CUB(); - void csi_CNL(); - void csi_CPL(); - void csi_CHA(); - void csi_HPA(); - void csi_VPA(); - void csi_EL(); - void csi_ICH(); - void csi_DCH(); - void csi_IL(); - void csi_DL(); - void csi_ECH(); - void csi_DECSTBM(); - void csi_SAVECUR(); - void csi_RESTORECUR(); - void csi_DECSET(); - void csi_DECRST(); - void write_char(ucs4_char c); -}; - - -#endif diff --git a/extras/anytermd/src/TrivialAuthenticator.hh b/extras/anytermd/src/TrivialAuthenticator.hh deleted file mode 100644 index 68d135db26..0000000000 --- a/extras/anytermd/src/TrivialAuthenticator.hh +++ /dev/null @@ -1,39 +0,0 @@ -// daemon/TrivialAuthenticator.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef TrivialAuthenticator_hh -#define TrivialAuthenticator_hh - -#include "HttpAuthenticator.hh" - -class TrivialAuthenticator: public HttpAuthenticator { - -public: - - void basic_auth(std::string username, std::string password) const { - if (username=="foo" && password=="blah") { - return; - } - throw NotAuthenticated(); - } - -}; - - -#endif diff --git a/extras/anytermd/src/UrlEncodedCgiParams.cc b/extras/anytermd/src/UrlEncodedCgiParams.cc deleted file mode 100644 index b56d76eca4..0000000000 --- a/extras/anytermd/src/UrlEncodedCgiParams.cc +++ /dev/null @@ -1,105 +0,0 @@ -// common/UrlEncodedCgiParams.cc -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include "UrlEncodedCgiParams.hh" - -#include "Exception.hh" - - -#include -#include -#include -#include - -using namespace std; -using namespace pbe; -using namespace boost::lambda; - - -// Parse x-www-form-urlencoded parameters as defined in HTML 4.01 -// section 17.13.4: -// -// 1. Control names and values are escaped. Space characters are -// replaced by `+', and then reserved characters are escaped as -// described in [RFC1738], section 2.2: Non-alphanumeric characters -// are replaced by `%HH', a percent sign and two hexadecimal digits -// representing the ASCII code of the character. Line breaks are -// represented as "CR LF" pairs (i.e., `%0D%0A'). -// -// 2. The control names/values are listed in the order they appear -// in the document. The name is separated from the value by `=' and -// name/value pairs are separated from each other by `&'. - - - - -static int hexchar(char c) -{ - if (c>='0' && c<='9') { - return c-'0'; - } else if (c>='a' && c<='f') { - return c-'a'+10; - } else if (c>='A' && c<='F') { - return c-'A'+10; - } else { - throw StrException(string("Invalid hex character '")+c+"'"); - } -} - -static char decode_percent_escape(string s) -{ - return hexchar(s[1])*16 + hexchar(s[2]); -} - - -static string decode_uri_escapes(string s) -{ - string t; - for (string::size_type i=0; i name_value_pairs_t; - name_value_pairs_t name_value_pairs; - boost::split(name_value_pairs, query, _1=='&'); - - for(name_value_pairs_t::const_iterator i = name_value_pairs.begin(); - i != name_value_pairs.end(); ++i) { - - string name_value_pair = *i; - string::size_type equals_pos = name_value_pair.find('='); - if (equals_pos==name_value_pair.npos) { - throw StrException("Misformatted URL-encoded query string component '" - +name_value_pair+"' does not contain an '='"); - } - string name = name_value_pair.substr(0,equals_pos); - string value = name_value_pair.substr(equals_pos+1); - - insert(make_pair(decode_uri_escapes(name),decode_uri_escapes(value))); - } -} diff --git a/extras/anytermd/src/UrlEncodedCgiParams.hh b/extras/anytermd/src/UrlEncodedCgiParams.hh deleted file mode 100644 index 14efa52882..0000000000 --- a/extras/anytermd/src/UrlEncodedCgiParams.hh +++ /dev/null @@ -1,36 +0,0 @@ -// common/UrlEncodedCgiParams.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef UrlEncodedCgiParams_hh -#define UrlEncodedCgiParams_hh - -#include "CgiParams.hh" - -#include - - -class UrlEncodedCgiParams: public CgiParams { - -public: - UrlEncodedCgiParams(std::string query); - -}; - - -#endif diff --git a/extras/anytermd/src/auto_CgiParams.cc b/extras/anytermd/src/auto_CgiParams.cc deleted file mode 100644 index 720a8199ca..0000000000 --- a/extras/anytermd/src/auto_CgiParams.cc +++ /dev/null @@ -1,42 +0,0 @@ -// common/auto_CgiParams.cc -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include "auto_CgiParams.hh" - -#include "UrlEncodedCgiParams.hh" - -#include - -using namespace std; -using namespace pbe; - - -CgiParams auto_CgiParams(HttpRequest request) -{ - if (request.method=="GET") { - return UrlEncodedCgiParams(request.query); - } else if (request.method=="POST") { - if (boost::algorithm::starts_with(request.headers["Content-Type"], - "application/x-www-form-urlencoded")) { - return UrlEncodedCgiParams(request.body); - } - } - - return CgiParams(); -} diff --git a/extras/anytermd/src/auto_CgiParams.hh b/extras/anytermd/src/auto_CgiParams.hh deleted file mode 100644 index f5033deb5d..0000000000 --- a/extras/anytermd/src/auto_CgiParams.hh +++ /dev/null @@ -1,30 +0,0 @@ -// common/auto_CgiParams.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef auto_CgiParams_hh -#define auto_CgiParams_hh - -#include "CgiParams.hh" -#include "HttpRequest.hh" - - -CgiParams auto_CgiParams(pbe::HttpRequest request); - - -#endif diff --git a/extras/anytermd/src/config.hh b/extras/anytermd/src/config.hh deleted file mode 100644 index 47c21a828f..0000000000 --- a/extras/anytermd/src/config.hh +++ /dev/null @@ -1,26 +0,0 @@ -// daemon/config.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005-2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef config_hh -#define config_hh - -#define ANYTERM_TIMEOUT 30 - - -#endif diff --git a/extras/anytermd/src/diff.cc b/extras/anytermd/src/diff.cc deleted file mode 100644 index 582b526855..0000000000 --- a/extras/anytermd/src/diff.cc +++ /dev/null @@ -1,544 +0,0 @@ -// common/diff.cc -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include "diff.hh" - -#include -#include -using namespace std; - - -namespace DiffAlgo { - - // The algorithm used is the one described in - // "An O(ND) Difference Algorithm and Its Variations" - // by Eugene W Myers. - // (Postscript can be found on Myers' web page.) - - // O(ND) refers to N = the size of the input (the sum of the two) - // and D = the length of the resulting "edit script", i.e. the - // number of differences. The paper notes that the expected - // performance is O(N+D^2), with O(ND) being a pathological case. - // This is the complexity for the first phase of the computation in - // which the "edit script size" is found. There is a second phase - // during which the actual "edit script" is determined. This runs - // in O(N) time, but has space complexity O(D^2) (or worse O(ND) if - // the implementation is naive). The paper presents an alternative - // implementation for the second phase in section 4b which has O(N) - // space requirements. This is NOT implemented here. It is likely - // that for non-trivial applications, space complexity is likely to - // be a concern. Comparing sequences of only a few thousand items - // with signficant differences, i.e. an "edit script length" of a - // few thousand will consume megabytes, yet execution time is only - // seconds. (On the other hand, when the inputs are similar, space - // performance is good.) - - // Myers and others have proposed improvements to this algorithm, - // including one in the following paper: - // "An O(NP) Sequence Comparison Algorithm" - // Sun Wu, Udi Manber, Gene Myers - // (Postscript ditto). - - // In this case, P is the number of deletions in the "edit script", - // which is less than the size of the script D. This has NOT been - // implemented here. - - // Here is a quick overview of the algorithm: - - // The two input strings are A and B. Imagine a grid with A - // labelling the columns and B labelling the rows. There are - // additional "zeroth" rows and columns. Say A = abc and B = baba: - - // a b c - // . . . . - // b . . * . - // a . * . . - // b . . * . - // a . * . . - - // The points where the labels on the rows and columns match are - // marked specially. - - // The aim is to find a path from the top-left to the bottom-right - // of this grid in the following way: - // - Rightward horizontal moves indicate taking an element from - // sequence A. - // - Downward vertical moves indicate taking an element from - // sequence B. - // - Down-Right diagonal moves indicate taking an element common to - // A and B. - // Horizontal and vertical moves are always allowed. Diagonal moves - // are only allowed in order to reach the (specially marked) match - // points. The aim is to find a path obeying these constraints that - // has the fewest horizontal and vertical moves, and hence the most - // diagonal moves. - // In the example above, a possible solution is as follows: - - // a b c - // + . . . - // b | . * . - // a .\* . . - // b . .\*-. - // a . * . | - - // (i.e.: vertically to take b, diagonally twice to take a and b, - // horizontally to take c, and vertically to take a.) - - // The algorithm searches in a greedy fashion, that is, it is - // breadth-first when it is doing badly, but then depth-first once - // it is "on to a good thing" (i.e. a diagonal). It expands a - // "frontier" across the grid from the top-left towards the bottom - // right. Once the frontier hits the bottom-right, the problem is - // solved. - - // Giving each horizontal and vertical move a cost of one and each - // diagonal move a cost of zero, all points on the frontier during a - // particular iteration have the same cost. The variable d is used - // to refer to the costs (d is the number of differences). - - // Points on the grid can be referred to using (x,y) coordinates. - // Row/column 0 are necessarily "empty" and do not correspond to - // elements of A or B. Care is needed with off-by-one errors, since - // the sequences A and B are indexed from 0. - - // Points can also be referred to using one or other of x and y (x - // by convention) and the "diagonal index", k, defined by k=x-y. - - // The point about the diagonal index is that the frontier will - // always expand in such a way that it cuts each diagonal exactly - // once: - - // k - // 2 - // 1 / . - // 0 \ . - // -1 \ . - // -2 /\/\/ . - // / . - - // So we can record the position of the frontier by giving the - // x-coordinate for each value of k. In the code, the vector V - // records these values. - - // Thinking of "snakes and ladders", diagonals are named "snakes" - // (though surely, since they lead toward the goal, they should be - // ladders?). A "snake" is a (possibly empty or singleton) sequence - // of diagonals. - - // Once the frontier has reached the target, a second phase of the - // algorithm identifies the optimal path by studying saved copies of - // the V vector from each step of the expansion. This is the - // space-hungry step mentioned above. - - // To reduce the space-hungryness from O(ND) to O(D^2), something of - // a hack is used. The first phase is run twice. In the first run, - // nothing is stored (so memory use is moderate). At the end of - // this run, the "edit script length" is known. In the second run, - // the V vectors are stored but this knowledge is used to limit - // their size. - - - - // The Differ class is template-parameterised by the sequence type - // that it operates on. This is normally string, but if you want to - // use a different type, you should just be able to create a Differ - // object specifying a different type. vector should - // work, as long as operator= is defined on 'something'. See the - // end of the file for how Differ is used. - - template - class Differ { - - private: - const SEQ& A; // Input sequences - const SEQ& B; - const int N; // length of A - const int M; // length of B - const int max_D; - bool store; - - // Output - typename fragment_seq::Type& result; - - // Ideally V would be an array indexed from -(M+N) to (M+N) - // inclusive, but we only have zero-indexed arrays. So we use a - // zero-indexed array and apply an offset. - - const int V_size; - const int V_offset; - - typedef vector V_impl_t; - V_impl_t V_impl; - int& V ( int k ) { return V_impl[V_offset+k]; } - - - typedef vector stored_V_impls_t; - stored_V_impls_t stored_V_impls; - int stored_V ( int d, int k ) const { return (stored_V_impls[d])[V_offset+k]; } - - // This is filled in when solve() finishes. If all that is wanted - // is to know the distance between the two inputs, there is no - // need to call find_trace() at all; just read this using - // get_edit_distance(). - int edit_distance; - - - // Append an item to the result, with a tag. - // If the tag matches the tag of the current end of the result, it - // is merged with it. - void append_result ( fragment_tag tag, typename SEQ::value_type datum ) - { - if (!result.empty() && (result.back().first == tag)) { - result.back().second.push_back(datum); - } else { - result.push_back(make_pair(tag,SEQ(1,datum))); - } - } - - // Follow any snake from (k,x) to its end, and return the x - // coordinate at the end. - int follow_snake ( int k, int x ) - { - int y = x - k; - while ( (x>=0) && (x=0) && (y=0) && (x=0) && (y::Type& r, - bool s = true, int md = -1): - A(a), - B(b), - N(A.size()), - M(B.size()), - max_D((md==-1)?(M+N):(min(md,M+N))), - store(s), - result(r), - V_size(max(2*(max_D)+1,2)), // 2 allows for d=0 V(1) special case - V_offset(max_D), - V_impl(V_size) - {} - - class max_D_exceeded {}; // Exception thrown if solution has not - // been found after max_D - // frontier-expansion iterations. - - // Perform the first phase of the algorithm, expanding the - // frontier. - // This function is essentially what is described in Figure 2 of - // Myers' paper. - void solve ( void ) - { - // The normal operation is (H or V) then any diagonal then repeat. - // But this is broken if the first diagonal starts from the origin (e.g. for equal strings). - // The following is a hack that works around that: - V(1) = 0; - // But this requires that V is large enough for this extra element. - - // Loop for increasing values of D until target reached - int D = -1; - bool done=false; - while (!done) { - ++D; - if (D>max_D) { - throw max_D_exceeded(); - } - - // Scan across the width of the frontier - for ( int k = -D; k <= D; k += 2 ) { - - // Find a new x value for this point on the frontier. - // Special cases for either end. - // Otherwise, move horizontally or vertically from a neighbour. - int x; - if ( (k==-D) || ((k!=D) && (V(k-1)=N) && (y>=M) ) { - done = true; - // We could probably leave the inner loop at this point, - // but I'm not certain it's safe, and it certainly makes - // debugging harder when only some of the points have been - // updated, so don't bother. - //break; - } - } - - // Save a copy of V for use during the second phase. - if (store) { - stored_V_impls.push_back(V_impl); - } - } - - edit_distance = D; - } - - - void find_trace ( void ) - { - find_trace_r ( edit_distance, N-M ); - } - - - int get_edit_distance(void) { return edit_distance; } - }; - - - - void make_trivial_solution ( const string& A, const string& B, string_fragment_seq& result ) - { - result.push_back(make_pair(from_a,A)); - result.push_back(make_pair(from_b,B)); - } - - - void string_diff ( const string& A, const string& B, string_fragment_seq& result ) - { - // Consider time efficiency. Aim not to take more than this much - // time (arbitary units). Return a sub-optimal solution if this - // time is exceeded. - const int max_time = 1000; - - // Consider space efficiency. Aim not to use more than this much - // memory (arbitary units). Take more time or return a - // sub-optimal solution if this much memory is exceeded. - const int max_mem = 10000000; - - // Consider changing the above settings if "top" shows that the - // apache frontend request-handling processes are using more - // memory or CPU time than you would like. - - // Reducing them means that Anyterm will give up looking for an - // edit script and just send the complete new screen sooner. So - // making them too low will use more network bandwidth. On the - // other hand, for a fast local network, you might get a faster - // response with a lower max_time setting. - - - try { - - int sz = A.size() + B.size(); - // If input is small, i.e. N^2 is acceptable, we don't worry about - // space complexity. (This will take O(ND) space, but D could - // equal N.) - if ((sz*sz) d1(A,B,result,true,max_time); - d1.solve(); - d1.find_trace(); - return; - } - - // If input is larger, do a first pass to find the edit distance: - Differ d2(A,B,result,false,max_time); - d2.solve(); - - // We could now solve this with space complexity O(ND), if that - // were acceptable: - if (sz*d2.get_edit_distance() d3(A,B,result,true,d2.get_edit_distance()); - d3.solve(); - d3.find_trace(); - return; - } - - // If even O(ND) is not acceptable, we give up and return a result - // indicating no common subset: - - make_trivial_solution(A,B,result); - } - - catch (Differ::max_D_exceeded) { - make_trivial_solution(A,B,result); - } - } - - - - void make_trivial_solution ( const ucs4_string& A, const ucs4_string& B, ucs4_string_fragment_seq& result ) - { - result.push_back(make_pair(from_a,A)); - result.push_back(make_pair(from_b,B)); - } - - - void ucs4_string_diff ( const ucs4_string& A, const ucs4_string& B, ucs4_string_fragment_seq& result ) - { - // Consider time efficiency. Aim not to take more than this much - // time (arbitary units). Return a sub-optimal solution if this - // time is exceeded. - const int max_time = 300; - - // Consider space efficiency. Aim not to use more than this much - // memory (arbitary units). Take more time or return a - // sub-optimal solution if this much memory is exceeded. - const int max_mem = 10000000; - - // Consider changing the above settings if "top" shows that the - // apache frontend request-handling processes are using more - // memory or CPU time than you would like. - - // Reducing them means that Anyterm will give up looking for an - // edit script and just send the complete new screen sooner. So - // making them too low will use more network bandwidth. On the - // other hand, for a fast local network, you might get a faster - // response with a lower max_time setting. - - - try { - - int sz = A.size() + B.size(); - // If input is small, i.e. N^2 is acceptable, we don't worry about - // space complexity. (This will take O(ND) space, but D could - // equal N.) - if ((sz*sz) d1(A,B,result,true,max_time); - d1.solve(); - d1.find_trace(); - return; - } - - // If input is larger, do a first pass to find the edit distance: - Differ d2(A,B,result,false,max_time); - d2.solve(); - - // We could now solve this with space complexity O(ND), if that - // were acceptable: - if (sz*d2.get_edit_distance() d3(A,B,result,true,d2.get_edit_distance()); - d3.solve(); - d3.find_trace(); - return; - } - - // If even O(ND) is not acceptable, we give up and return a result - // indicating no common subset: - - make_trivial_solution(A,B,result); - } - - catch (Differ::max_D_exceeded) { - make_trivial_solution(A,B,result); - } - } - -}; - - diff --git a/extras/anytermd/src/diff.hh b/extras/anytermd/src/diff.hh deleted file mode 100644 index 7ef6c1f891..0000000000 --- a/extras/anytermd/src/diff.hh +++ /dev/null @@ -1,89 +0,0 @@ -// common/diff.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef diff_hh -#define diff_hh - -#include -#include - -#include "unicode.hh" - - -namespace DiffAlgo { - - // "Diff Algorithm" i.e. the algorithm used by the diff program. - - // Unlike the diff program, this algorithm can do comparisons on - // sequences of any types, not just lines. But the template - // specialisation is hidden inside the .cc file, so if you want to - // do anything other character-by-character (string) comparisons - // you'll need to make some changes there. Don't be put off, it's - // not hard. (If you want to do line-by-line comparisons, you'll - // want to implement a line type with an efficient equality - // comparison operator, e.g. a precomputed hash. The same applies - // for other complex types.) - - // It's also possible to find a measure of similarity of two - // sequences - the "distance" between them - using this code. - // Again, you'll need to delve into the .cc file for the details. - - // Implementation details are also in the .cc file. - - // Given two input string, say "hello world" and "goodbye world", - // the algorithm finds and returns a sequence of fragments, - // indicating for each whether it was from the first string, or from - // the second string, or was common to both strings: - - // From A: "hell" - // From B: "g" "odbye" - // Common: "o" " world" - - // Here are the types that define this return format: - - - enum fragment_tag { from_a, from_b, common }; - - template - struct fragment_seq { - typedef std::list > Type; - }; - - - // String diffs: - - typedef fragment_seq::Type string_fragment_seq; - - typedef fragment_seq::Type ucs4_string_fragment_seq; - - // Here is the prototype for the diff function. It returns its - // result via an "out" parameter: - - void string_diff ( const std::string& A, const std::string& B, - string_fragment_seq& result ); - - void ucs4_string_diff ( const ucs4_string& A, const ucs4_string& B, - ucs4_string_fragment_seq& result ); - - -}; - - - -#endif diff --git a/extras/anytermd/src/editscript.cc b/extras/anytermd/src/editscript.cc deleted file mode 100644 index e6bcade9e0..0000000000 --- a/extras/anytermd/src/editscript.cc +++ /dev/null @@ -1,136 +0,0 @@ -// common/editscript.cc -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include "editscript.hh" - -#include "diff.hh" - -#include -#include - -#include - - -using namespace std; - - -static ucs4_string ucs4_int(int i) -{ - ucs4_string s; - do { - s = ucs4_string(1,(i%10)+L'0') + s; - i = i/10; - } while (i); - return s; -} - - -void simplify_editscript(const DiffAlgo::ucs4_string_fragment_seq& in, - DiffAlgo::ucs4_string_fragment_seq& out) -{ - ucs4_string a_cf; // A data to carry forward - ucs4_string b_cf; // B data to carry forward - - for ( DiffAlgo::ucs4_string_fragment_seq::const_iterator i = in.begin(); - i != in.end(); ++i ) { - switch (i->first) { - case DiffAlgo::from_a: - a_cf.append(i->second); - break; - - case DiffAlgo::from_b: - b_cf.append(i->second); - break; - - case DiffAlgo::common: - if (i->second.size() > 4) { - if (!a_cf.empty()) { - out.push_back(make_pair(DiffAlgo::from_a,a_cf)); - a_cf.clear(); - } - if (!b_cf.empty()) { - out.push_back(make_pair(DiffAlgo::from_b,b_cf)); - b_cf.clear(); - } - out.push_back(*i); - } else { - a_cf.append(i->second); - b_cf.append(i->second); - } - break; - } - } - if (!a_cf.empty()) { - out.push_back(make_pair(DiffAlgo::from_a,a_cf)); - } - if (!b_cf.empty()) { - out.push_back(make_pair(DiffAlgo::from_b,b_cf)); - } -} - - -ucs4_string make_editscript(ucs4_string o, ucs4_string n) -{ - DiffAlgo::ucs4_string_fragment_seq e; - - DiffAlgo::ucs4_string_diff(o,n,e); - - DiffAlgo::ucs4_string_fragment_seq simp_e; - simplify_editscript(e,simp_e); - - ucs4_string editscript; - ucs4_string editscript_r = L"R"; - bool any_common = false; - bool any_change = false; - - for ( DiffAlgo::ucs4_string_fragment_seq::const_iterator i = simp_e.begin(); - i != simp_e.end(); ++i ) { - unsigned int len = i->second.length(); - switch (i->first) { - case DiffAlgo::from_a: - editscript += L'd'; - editscript += ucs4_int(len); - editscript += ':'; - any_change = true; - break; - case DiffAlgo::from_b: - editscript += L'i'; - editscript += ucs4_int(len); - editscript += ':'; - editscript += i->second; - editscript_r += i->second; - any_change = true; - break; - case DiffAlgo::common: - editscript += L'k'; - editscript += ucs4_int(len); - editscript += ':'; - any_common = true; - break; - } - } - - if (!any_change) { - return L"n"; - } else if (any_common) { - return editscript; - } else { - return editscript_r; - } -} diff --git a/extras/anytermd/src/editscript.hh b/extras/anytermd/src/editscript.hh deleted file mode 100644 index 4c7b4c4a9d..0000000000 --- a/extras/anytermd/src/editscript.hh +++ /dev/null @@ -1,38 +0,0 @@ -// common/editscript.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef editscript_hh -#define editscript_hh - -#include -#include "unicode.hh" - - -// Create an edit script describing the difference between oc and -// nc. Storage for the result is allocated by this function using -// malloc() and should be freed by the caller. Syntax of edit -// script is a sequence of commands describing how to transform oc -// to nc: -// k(num): keep num characters -// d(num): delete num characters -// i(num):text insert num characters, supplied - -ucs4_string make_editscript(ucs4_string o, ucs4_string n); - -#endif diff --git a/extras/anytermd/src/expand_command.cc b/extras/anytermd/src/expand_command.cc deleted file mode 100644 index fb8d76047f..0000000000 --- a/extras/anytermd/src/expand_command.cc +++ /dev/null @@ -1,70 +0,0 @@ -// common/expand_command.cc -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include - -using namespace std; - -// Clean the given parameter to avoid command injections. - -string safe_param (string param) -{ - string safe_string = ""; - - // Remove problematic characters - for (unsigned int i = 0; i < param.size(); i++){ - if (param[i] == '<' || - param[i] == '>' || - param[i] == '|' || - param[i] == '`' || - param[i] == '$' || - param[i] == ';' || - param[i] == '&') { - continue; - } - - safe_string += param[i]; - } - - return safe_string; -} - -// Expand command string: -// %h -> remote hostname -// %u -> HTTP AUTH username -// %p -> parameter supplied from the Javascript -// %% -> % - -string expand_command(string templ, string host, string user, string param) -{ - string::size_type p = templ.find('%'); - if (p==templ.npos || p==templ.length()-1) { - return templ; - } - string v; - switch(templ[p+1]) { - case '%': v="%"; break; - case 'h': v=host; break; - case 'u': v=user; break; - case 'p': v=safe_param(param); break; - default: v="?"; break; - } - - return templ.substr(0,p) + v + expand_command(templ.substr(p+2),host,user,param); -} - diff --git a/extras/anytermd/src/expand_command.hh b/extras/anytermd/src/expand_command.hh deleted file mode 100644 index ec33871219..0000000000 --- a/extras/anytermd/src/expand_command.hh +++ /dev/null @@ -1,28 +0,0 @@ -// common/expand_command.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include - -// Expand command string: -// %h -> remote hostname -// %u -> HTTP AUTH username -// %p -> parameter supplied from the Javascript -// %% -> % - -std::string safe_param(std::string param); -std::string expand_command(std::string templ, std::string host, std::string user, std::string param); diff --git a/extras/anytermd/src/html.cc b/extras/anytermd/src/html.cc deleted file mode 100644 index 8ac014f7f2..0000000000 --- a/extras/anytermd/src/html.cc +++ /dev/null @@ -1,120 +0,0 @@ -// common/html.cc -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include "html.hh" - -#include - -using namespace std; - - -// Screen to HTML conversion: - -static bool gen_style(ucs4_string& h, Attributes attrs) -{ - if (attrs!=Attributes()) { - unsigned int fg = attrs.fg; - unsigned int bg = attrs.bg; - if (attrs.inverse) { - swap(fg,bg); - } - ucs4_string classes; - if (attrs.bold) { - classes += L'z'; - } - if (bg!=Attributes().bg) { - if (!classes.empty()) { - classes += L' '; - } - classes += L'a'+bg; - } - if (fg!=Attributes().fg) { - if (!classes.empty()) { - classes += L' '; - } - classes += L'i'+fg; - } - h += L""; - return true; - } - return false; -} - -static const ucs4_char* attr_end = L""; - -static const ucs4_char* cursor_start = L""; -static const ucs4_char* cursor_end = L""; - - -ucs4_string htmlify_screen(const Screen& screen) -{ - // Convert screen into HTML. - // Slightly optimised to reduce spaces at right end of lines. - - ucs4_string h; - - for (int r=-screen.scrollback(); r0 && r>0 && !cursor) { - sp++; - } else { - while (sp>0) { - h+=L'\u00A0'; - sp--; - } - if (styled && attrs!=prev_attrs) { - h+=attr_end; - } - if (c==0 || attrs!=prev_attrs) { - styled = gen_style(h,attrs); - prev_attrs=attrs; - } - if (cursor) { - h+=cursor_start; - } - switch (ch) { - case '<': h+=L"<"; break; - case '>': h+=L">"; break; - case '&': h+=L"&"; break; - case ' ': h+=L'\u00A0'; break; - default: h+=ch; break; - } - if (cursor) { - h+=cursor_end; - } - } - } - if (styled) { - h+=attr_end; - } - h+=L"
"; - } - - return h; -} - - diff --git a/extras/anytermd/src/html.hh b/extras/anytermd/src/html.hh deleted file mode 100644 index 930caf2078..0000000000 --- a/extras/anytermd/src/html.hh +++ /dev/null @@ -1,38 +0,0 @@ -// common/html.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -// This file declares a conversion function to transform a terminal -// screen represented as an array of character cells with associated -// attributes into a string of HTML, or WML. - - -#ifndef html_hh -#define html_hh - -#include - -#include "Screen.hh" - -#include "unicode.hh" - - -ucs4_string htmlify_screen(const Screen& screen); - - -#endif diff --git a/extras/anytermd/src/main.cc b/extras/anytermd/src/main.cc deleted file mode 100644 index 56855b273c..0000000000 --- a/extras/anytermd/src/main.cc +++ /dev/null @@ -1,175 +0,0 @@ -// daemon/main.cc -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005-2006 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "AnytermDaemon.hh" - -#include -#include - -#include -#include -#include - -#include "Exception.hh" -#include "segv_backtrace.hh" - -using namespace pbe; -using namespace std; - - -static void usage() -{ - cerr << "Usage: anytermd [options]\n" - << "Available options:\n" - << " --help Show this help message\n" - << " -c|--command Command to run in terminal (default /bin/bash)\n" - << " -d|--device Device to connect to (e.g. serial port)\n" - << " -p|--port Port number to listen on (default 8080)\n" - << " -u|--user User to run as\n" - << " -a|--auth none|null|trivial Authorisation scheme to use (default none)\n" - << " -s|--charset Character set to use (default ASCII)\n" - << " -f|--foreground Run in foreground (by default, backgrounds itself)\n" - << " --diff Send only differences to browser (default)\n" - << " -n|--nodiff Send whole screen to browser each time\n" - << " -m|--max-sessions Maximum number of simultaneous sessions (default 20)\n" - << " --max-http-connections Maximum number of simultaneous HTTP connections (default unlimited)\n" - << " --local-only Accept connections only from localhost\n" - << " --name Name used for logging and pid file (default anytermd)\n"; -} - - -struct Options { - bool background; - short port; - string user; - string command; - string device; - string authname; - string charset; - bool diff; - int max_sessions; - int max_http_connections; - bool local_only; - string name; - - Options(): - background(true), - port(8080), - user(""), - command("/bin/bash"), - device(""), - authname("none"), - charset("ascii"), - diff(true), - max_sessions(20), - max_http_connections(0), - local_only(false), - name("anytermd") - {} -}; - - -static Options parse_command_line(int argc, char* argv[]) -{ - Options options; - - for (int i=1; i(argv[++i]); - - } else if (arg=="--user" || arg=="-u") { - options.user = argv[++i]; - - } else if (arg=="--auth" || arg=="-a") { - options.authname = argv[++i]; - - } else if (arg=="--charset" || arg=="-s") { - options.charset = argv[++i]; - - } else if (arg=="--max-sessions" || arg=="-m") { - options.max_sessions = boost::lexical_cast(argv[++i]); - - } else if (arg=="--max-http-connections") { - options.max_http_connections = boost::lexical_cast(argv[++i]); - - } else if (arg=="--name") { - options.name = argv[++i]; - - } else { - cerr << "Unrecognised option '" << arg << "'\n"; - exit(1); - } - } - - return options; -} - - -int main(int argc, char* argv[]) -{ - get_backtrace_on_segv(); - - Options options = parse_command_line(argc,argv); - - if (getuid()==0 && options.user=="") { - cerr << "Please specify a user to run as using --user.\n"; - exit(1); - } - - try { try { - - AnytermDaemon d(options.port, options.user, options.command, options.device, options.name, - options.authname, options.charset, options.diff, options.max_sessions, - options.max_http_connections, options.local_only); - d.run_as_daemon(options.background); - - } RETHROW_MISC_EXCEPTIONS } - catch (Exception& E) { - E.report(cerr); - exit(E.exit_status); - } -} diff --git a/extras/anytermd/src/mk_blob.c b/extras/anytermd/src/mk_blob.c deleted file mode 100644 index 91649e7b07..0000000000 --- a/extras/anytermd/src/mk_blob.c +++ /dev/null @@ -1,49 +0,0 @@ -// daemon/mk_blob.c -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2008 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include -#include - - -int main(int argc, char* argv[]) -{ - if (argc!=2) { - fprintf(stderr,"usage: mk_blob fn\n"); - exit(1); - } - const char* fn = argv[1]; - - printf("const char _binary_%s_start[] = {\n",fn); - int l=0; - while (1) { - int c = getchar(); - if (c==EOF) { - break; - } - printf("0x%02x, ",c); - ++l; - if (l%32==0) { - printf("\n"); - } - } - printf("\n};\n"); - printf("const char _binary_%s_end[] = {};\n",fn); - exit(0); -} - diff --git a/extras/anytermd/src/slugmake.sh b/extras/anytermd/src/slugmake.sh deleted file mode 100755 index 418b4742ab..0000000000 --- a/extras/anytermd/src/slugmake.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -make CXX=arm-linux-gnu-g++ CC=arm-linux-gnu-gcc AR=arm-linux-gnu-ar \ -ROTE_CONFIG=/usr/arm-linux-gnu/local/bin/rote-config - diff --git a/extras/anytermd/src/static_content.hh b/extras/anytermd/src/static_content.hh deleted file mode 100644 index 9ea4fbbec0..0000000000 --- a/extras/anytermd/src/static_content.hh +++ /dev/null @@ -1,27 +0,0 @@ -// daemon/static_content.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2005 Philip Endecott - -// This is version $Name$ -// (if there is no version (e.g. V0-1) mentioned in the previous line, -// this is probably a snapshot from between "official" releases.) - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include - -bool get_static_content(std::string fn, - std::string& mime_type, std::string& content); diff --git a/extras/anytermd/src/unicode.hh b/extras/anytermd/src/unicode.hh deleted file mode 100644 index ed471e5e5b..0000000000 --- a/extras/anytermd/src/unicode.hh +++ /dev/null @@ -1,41 +0,0 @@ -// daemon/unicode.hh -// This file is part of Anyterm; see http://anyterm.org/ -// (C) 2007 Philip Endecott - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef unicode_hh -#define unicode_hh - -#include - -#include "endian.hh" - -#if PBE_BYTE_ORDER == PBE_LITTLE_ENDIAN -#define UCS4_NATIVE "UCS-4LE" -#elif PBE_BYTE_ORDER == PBE_BIG_ENDIAN -#define UCS4_NATIVE "UCS-4BE" -#endif - -typedef wchar_t char32_t; -typedef char32_t ucs4_char; -typedef std::basic_string ucs4_string; - -typedef char utf8_char; -typedef std::basic_string utf8_string; - - -#endif diff --git a/extras/pandroid_event_viewer/.classpath b/extras/pandroid_event_viewer/.classpath deleted file mode 100644 index d57ec02513..0000000000 --- a/extras/pandroid_event_viewer/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/extras/pandroid_event_viewer/.project b/extras/pandroid_event_viewer/.project deleted file mode 100644 index 644e0fb57f..0000000000 --- a/extras/pandroid_event_viewer/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - pandroid_event_viewer - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/extras/pandroid_event_viewer/COPYING b/extras/pandroid_event_viewer/COPYING deleted file mode 100644 index bcfae5693f..0000000000 --- a/extras/pandroid_event_viewer/COPYING +++ /dev/null @@ -1,89 +0,0 @@ -GNU GENERAL PUBLIC LICENSE -Version 2, June 1991 - -Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - -Preamble - -The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. - -When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. - -To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. - -For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. - -We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. - -Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. - -Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. - -The precise terms and conditions for copying, distribution and modification follow. -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. - -1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. - -You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. - - c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. - -3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. - -If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. - -4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. - -5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. - -6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. - -7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. - -This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - -8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. - -9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. - -10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - -NO WARRANTY - -11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -END OF TERMS AND CONDITIONS diff --git a/extras/pandroid_event_viewer/default.properties b/extras/pandroid_event_viewer/default.properties deleted file mode 100644 index e2e8061f26..0000000000 --- a/extras/pandroid_event_viewer/default.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-8 diff --git a/extras/pandroid_event_viewer/proguard.cfg b/extras/pandroid_event_viewer/proguard.cfg deleted file mode 100644 index b1cdf17b5b..0000000000 --- a/extras/pandroid_event_viewer/proguard.cfg +++ /dev/null @@ -1,40 +0,0 @@ --optimizationpasses 5 --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --dontpreverify --verbose --optimizations !code/simplification/arithmetic,!field/*,!class/merging/* - --keep public class * extends android.app.Activity --keep public class * extends android.app.Application --keep public class * extends android.app.Service --keep public class * extends android.content.BroadcastReceiver --keep public class * extends android.content.ContentProvider --keep public class * extends android.app.backup.BackupAgentHelper --keep public class * extends android.preference.Preference --keep public class com.android.vending.licensing.ILicensingService - --keepclasseswithmembernames class * { - native ; -} - --keepclasseswithmembers class * { - public (android.content.Context, android.util.AttributeSet); -} - --keepclasseswithmembers class * { - public (android.content.Context, android.util.AttributeSet, int); -} - --keepclassmembers class * extends android.app.Activity { - public void *(android.view.View); -} - --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} diff --git a/extras/pandroid_event_viewer/project.properties b/extras/pandroid_event_viewer/project.properties deleted file mode 100644 index 85aac54016..0000000000 --- a/extras/pandroid_event_viewer/project.properties +++ /dev/null @@ -1,14 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-8 diff --git a/index.pot b/index.pot index f4a20c7dda..8f8ca875e0 100644 --- a/index.pot +++ b/index.pot @@ -127094,7 +127094,7 @@ msgstr "" #: ../../Documentos/Pandoras/pandorafms_develop/pandora_console/godmode/setup/setup_ehorus.php:87 #: ../../Documentos/COPIA SEG/godmode/setup/setup_ehorus.php:87 #: ../../code/pandorafms/pandora_console/godmode/setup/setup_ehorus.php:87 -msgid "e.g., switch.ehorus.com" +msgid "e.g., portal.ehorus.com" msgstr "" #: ../../Documentos/Pandoras/pandorafms_develop/pandora_console/godmode/setup/setup_ehorus.php:92 diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index 13ee4982a8..3045e6d120 100644 --- a/pandora_agents/pc/AIX/pandora_agent.conf +++ b/pandora_agents/pc/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG, AIX version +# Version 7.0NG.712, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -15,8 +15,7 @@ logfile /var/log/pandora/pandora_agent.log # Interval in seconds, 300 by default interval 300 -# Debug mode only generate XML, and stop after first execution, -# and does not copy XML to server. +# Debug mode renames XML in the temp folder and continues running debug 0 # By default, agent takes machine name diff --git a/pandora_agents/pc/FreeBSD/pandora_agent.conf b/pandora_agents/pc/FreeBSD/pandora_agent.conf index 2c05eb66dd..95c66d2b2f 100644 --- a/pandora_agents/pc/FreeBSD/pandora_agent.conf +++ b/pandora_agents/pc/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG, FreeBSD Version +# Version 7.0NG.712, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -17,8 +17,7 @@ logfile /var/log/pandora/pandora_agent.log # Interval in seconds, 300 by default interval 300 -# Debug mode only generate XML, and stop after first execution, -# and does not copy XML to server. +# Debug mode renames XML in the temp folder and continues running debug 0 # By default, agent takes machine name diff --git a/pandora_agents/pc/HP-UX/pandora_agent.conf b/pandora_agents/pc/HP-UX/pandora_agent.conf index b17fae02a4..e45185794c 100644 --- a/pandora_agents/pc/HP-UX/pandora_agent.conf +++ b/pandora_agents/pc/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG, HP-UX Version +# Version 7.0NG.712, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -17,8 +17,7 @@ logfile /var/log/pandora/pandora_agent.log # Interval in seconds, 300 by default interval 300 -# Debug mode only generate XML, and stop after first execution, -# and does not copy XML to server. +# Debug mode renames XML in the temp folder and continues running debug 0 # By default, agent takes machine name diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index 3b3ec31b35..cf0cee7960 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG, GNU/Linux +# Version 7.0NG.712, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -17,8 +17,7 @@ logfile /var/log/pandora/pandora_agent.log # Interval in seconds, 300 by default interval 300 -# Debug mode only generate XML, and stop after first execution, -# and does not copy XML to server. +# Debug mode renames XML in the temp folder and continues running debug 0 # Optional. UDP Server to receive orders from outside diff --git a/pandora_agents/pc/NT4/pandora_agent.conf b/pandora_agents/pc/NT4/pandora_agent.conf index 4eaf6fc844..d072cce2b4 100644 --- a/pandora_agents/pc/NT4/pandora_agent.conf +++ b/pandora_agents/pc/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG, GNU/Linux +# Version 7.0NG.712, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/SunOS/pandora_agent.conf b/pandora_agents/pc/SunOS/pandora_agent.conf index cdf9221142..c11526deed 100644 --- a/pandora_agents/pc/SunOS/pandora_agent.conf +++ b/pandora_agents/pc/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG, Solaris Version +# Version 7.0NG.712, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -17,8 +17,7 @@ logfile /var/log/pandora/pandora_agent.log # Interval in seconds, 300 by default interval 300 -# Debug mode only generate XML, and stop after first execution, -# and does not copy XML to server. +# Debug mode renames XML in the temp folder and continues running debug 0 # By default, agent takes machine name diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index 7e919a716a..c70a49cdfb 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2010 Artica Soluciones Tecnologicas -# Version 7.0NG +# Version 7.0NG.712 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software @@ -11,109 +11,109 @@ # Edit this file to change your parameters or/and add your own modules # Any line with a # character at the first column will be ignored (comment) - -# General Parameters -# ================== - + +# General Parameters +# ================== + # NOTE: The variables $*$ will be substituted in the installation wizard -server_ip $ServerIP$ -server_path $ServerPath$ -temporal $AgentTemp$ -logfile $AgentLog$ - +server_ip $ServerIP$ +server_path $ServerPath$ +temporal $AgentTemp$ +logfile $AgentLog$ + #include "C:\Archivos de programa\pandora_agent\pandora_agent_alt.conf" #broker_agent name_agent - + # Agent uses your hostname automatically, if you need to change agent name # use directive agent_name (do not use blank spaces, please). # This parameter is CASE SENSITIVE. - -# agent_name My_Custom_Agent_name - -#Parent agent_name -#parent_agent_name caprica - -# address: Enforce to server a ip address to this agent -# You can also try to detect the first IP using "auto", for example -#address auto -# or setting a fixed IP address, like for example: -#address 192.168.36.73 - +# agent_name My_Custom_Agent_name + +#Parent agent_name +#parent_agent_name caprica + +# address: Enforce to server a ip address to this agent +# You can also try to detect the first IP using "auto", for example + +#address auto +# or setting a fixed IP address, like for example: +#address 192.168.36.73 + # Group assigned for this agent (descriptive, p.e: Servers) group $AgentGroup$ - + # This limits operation if temporal dir has not enough free disk. #temporal_min_size 1024 - + # Delay start execution X second before start to minonitoring nothing #startup_delay 30 - + # Interval is defined in seconds interval 300 - + # tranfer_modes: Possible values are local, tentacle (default), ftp and ssh. -transfer_mode tentacle +transfer_mode tentacle server_port 41121 - + # In case of using FTP or tentacle with password. User is always "pandora" #server_pwd pandora - -# Debug mode do not copy XML data files to server. + +# Debug mode renames XML in the temp folder and continues running # debug 1 - + # ODBC connections. Check documentation for more information. # Configuring "ExampleDSN" DSN. Notice that this DSN connection must be configured # under Control panel -> Administrative tools -> ODBC -> DSN # odbc_ExampleDSN_username UserNameForDsn # odbc_ExampleDSN_password Password1234 - + # If set to 1 allows the agent to be configured via the web console # (only works on enterprise version). # remote_config 1 - + # Set XML encoding (ISO-8859-1 by default). #encoding ISO-8859-1 - -# If set to 1 start Drone Agent's Proxy Mode -# proxy_mode 1 - -# Max number of simmultaneus connection for proxy (by default 10) -# proxy_max_connection 10 - -# Proxy timeout (by default 1s) -# proxy_timeout 1 - + +# If set to 1 start Drone Agent's Proxy Mode +# proxy_mode 1 + +# Max number of simmultaneus connection for proxy (by default 10) +# proxy_max_connection 10 + +# Proxy timeout (by default 1s) +# proxy_timeout 1 + # Enable or disable XML buffer. xml_buffer 0 # WMI by default. Set to NT if you don't want to use WMI. win32_monitoring_lib NT - -# Secondary server configuration -# ============================== - -# If secondary_mode is set to on_error, data files are copied to the secondary -# server only if the primary server fails. If set to always, data files are -# always copied to the secondary server. + +# Secondary server configuration +# ============================== + +# If secondary_mode is set to on_error, data files are copied to the secondary +# server only if the primary server fails. If set to always, data files are +# always copied to the secondary server. #secondary_mode on_error #secondary_server_ip localhost -#secondary_server_path /var/spool/pandora/data_in -#secondary_server_port 41121 -#secondary_transfer_mode tentacle -#secondary_server_pwd mypassword -#secondary_server_ssl no -#secondary_server_opts - -# Module Definition +#secondary_server_path /var/spool/pandora/data_in +#secondary_server_port 41121 +#secondary_transfer_mode tentacle +#secondary_server_pwd mypassword +#secondary_server_ssl no +#secondary_server_opts + +# Module Definition # Check online documentation and module library at http://pandorafms.org -# ================= - +# ================= + # CPU Load using WMI module_begin module_name CPU Load -module_type generic_data +module_type generic_data module_wmiquery SELECT LoadPercentage FROM Win32_Processor module_wmicolumn LoadPercentage module_description CPU Load (%) @@ -121,8 +121,8 @@ module_min_warning 80 module_max_warning 90 module_min_critical 91 module_max_critical 100 -module_end - +module_end + # Number processes module_begin module_name Number processes diff --git a/pandora_agents/shellscript/aix/pandora_agent.conf b/pandora_agents/shellscript/aix/pandora_agent.conf index efa5546087..639b2e8911 100644 --- a/pandora_agents/shellscript/aix/pandora_agent.conf +++ b/pandora_agents/shellscript/aix/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG, AIX version +# Version 7.0NG.712, AIX version # General Parameters # ================== @@ -11,7 +11,7 @@ pandora_path /usr/share/pandora_agent temporal /var/spool/pandora/data_out interval 300 checksum 0 -#agent_name adama +# Debug mode renames XML in the temp folder and continues running debug 0 # By default is 22 (for ssh) #server_port 22 diff --git a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf index 18cd12719b..98ba116947 100644 --- a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf +++ b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG +# Version 7.0NG.712 # FreeBSD/IPSO version # Licenced under GPL licence, 2003-2007 Sancho Lerena @@ -13,6 +13,7 @@ pandora_path /opt/pandora_agent temporal /var/spool/pandora/data_out interval 600 agent_name nokia +# Debug mode renames XML in the temp folder and continues running debug 0 checksum 0 harmless_mode 1 diff --git a/pandora_agents/shellscript/hp-ux/pandora_agent.conf b/pandora_agents/shellscript/hp-ux/pandora_agent.conf index 0809a9ff5b..e29d608225 100644 --- a/pandora_agents/shellscript/hp-ux/pandora_agent.conf +++ b/pandora_agents/shellscript/hp-ux/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG, HPUX Version +# Version 7.0NG.712, HPUX Version # General Parameters # ================== @@ -11,6 +11,7 @@ temporal /var/spool/pandora/data_out interval 300 #agent_name satellite_system checksum 1 +# Debug mode renames XML in the temp folder and continues running debug 0 # Module Definition diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index 04385db443..a021f7a477 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG +# Version 7.0NG.712 # Licensed under GPL license v2, # (c) 2003-2010 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net @@ -15,8 +15,7 @@ logfile /var/log/pandora/pandora_agent.log # Interval in seconds, 300 by default interval 300 -# Debug mode only generate XML, and stop after first execution, -# and does not copy XML to server. +# Debug mode renames XML in the temp folder and continues running debug 0 # By default, agent takes machine name diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index d0d2784a74..ffbc3657c2 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG +# Version 7.0NG.712 # Licensed under GPL license v2, # (c) 2003-2009 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net @@ -15,8 +15,7 @@ logfile /var/log/pandora/pandora_agent.log # Interval in seconds, 300 by default interval 300 -# Debug mode only generate XML, and stop after first execution, -# and does not copy XML to server. +# Debug mode renames XML in the temp folder and continues running debug 0 # By default, agent takes machine name diff --git a/pandora_agents/shellscript/openWRT/pandora_agent.conf b/pandora_agents/shellscript/openWRT/pandora_agent.conf index 8101369b61..f0a7023390 100644 --- a/pandora_agents/shellscript/openWRT/pandora_agent.conf +++ b/pandora_agents/shellscript/openWRT/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG +# Version 7.0NG.712 # Licensed under GPL license v2, # please visit http://pandora.sourceforge.net @@ -14,8 +14,7 @@ logfile /opt/pandora/pandora_agent.log # Interval in seconds, 300 by default interval 30 -# Debug mode only generate XML, and stop after first execution, -# and does not copy XML to server. +# Debug mode renames XML in the temp folder and continues running debug 0 # By default, agent takes machine name diff --git a/pandora_agents/shellscript/solaris/pandora_agent.conf b/pandora_agents/shellscript/solaris/pandora_agent.conf index c561bcbde1..39f27650ac 100644 --- a/pandora_agents/shellscript/solaris/pandora_agent.conf +++ b/pandora_agents/shellscript/solaris/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG, Solaris version +# Version 7.0NG.712, Solaris version # General Parameters # ================== @@ -11,6 +11,7 @@ temporal /var/spool/pandora/data_out interval 300 #agent_name satellite_system checksum 0 +# Debug mode renames XML in the temp folder and continues running debug 0 # By default is 22 (for ssh) #server_port 22 diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index 4ce83de0d2..4fc8c757ba 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG, AIX version +# Version 7.0NG.712, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -15,8 +15,7 @@ logfile /var/log/pandora/pandora_agent.log # Interval in seconds, 300 by default interval 300 -# Debug mode only generate XML, and stop after first execution, -# and does not copy XML to server. +# Debug mode renames XML in the temp folder and continues running debug 0 # By default, agent takes machine name diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index bf8bd1e3f2..2469475802 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG-170411 +Version: 7.0NG.712-170908 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/control.orig b/pandora_agents/unix/DEBIAN/control.orig new file mode 100644 index 0000000000..0d45b0b974 --- /dev/null +++ b/pandora_agents/unix/DEBIAN/control.orig @@ -0,0 +1,14 @@ +package: pandorafms-agent-unix +<<<<<<< HEAD +Version: 7.0NG-170406 +======= +Version: 7.0NG-170418 +>>>>>>> develop +Architecture: all +Priority: optional +Section: admin +Installed-Size: 260 +Maintainer: Miguel de Dios +Homepage: http://pandorafms.org/ +Depends: coreutils, perl, unzip +Description: Pandora FMS agents are based on native languages in every platform: scripts that can be written in any language. It’s possible to reproduce any agent in any programming language and can be extended without difficulty the existing ones in order to cover aspects not taken into account up to the moment. These scripts are formed by modules that each one gathers a "chunk" of information. Thus, every agent gathers several "chunks" of information; this one is organized in a data set and stored in a single file, called data file. diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 06c0a0d5a3..fa27849ada 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG-170411" +pandora_version="7.0NG.712-170908" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh.orig b/pandora_agents/unix/DEBIAN/make_deb_package.sh.orig new file mode 100644 index 0000000000..731ccfb803 --- /dev/null +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh.orig @@ -0,0 +1,132 @@ +#!/bin/bash + +#Pandora FMS- http:#pandorafms.com +# ================================================== +# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas +# Please see http:#pandorafms.org for full contribution list + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; version 2 + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +<<<<<<< HEAD +pandora_version="7.0NG-170406" +======= +pandora_version="7.0NG-170418" +>>>>>>> develop + +echo "Test if you has the tools for to make the packages." +whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null +if [ $? = 1 ] +then + echo "No found \"dpkg-deb\" aplication, please install." + exit 1 +else + echo "Found \"dpkg-debs\"." +fi + +cd .. + +echo "Make a \"temp_package\" temp dir for job." + +mkdir -p temp_package/usr +mkdir -p temp_package/usr/share/pandora_agent/ +mkdir -p temp_package/usr/bin/ +mkdir -p temp_package/usr/sbin/ +mkdir -p temp_package/etc/pandora/plugins +mkdir -p temp_package/etc/pandora/collections +mkdir -p temp_package/etc/init.d/ +mkdir -p temp_package/lib/systemd/system/ +mkdir -p temp_package/var/log/pandora/ +mkdir -p temp_package/var/spool/pandora/data_out +mkdir -p temp_package/usr/share/man/man1/ +mkdir -p temp_package/usr/share/pandora_agent/plugins +mkdir -p temp_package/tmp +mkdir -p temp_package/etc/logrotate.d/ + +echo "Make directory system tree for package." +cp DEBIAN temp_package -R +chmod 755 -R temp_package/DEBIAN + +#Next lines is same to +#cp -aRf * temp_package/usr/share/pandora_agent/ +#but don't copy recursive the temp_package into temp_package + +for item in `ls | grep -v NT4 | grep -v AIX | grep -v FreeBSD | grep -v HP-UX | grep -v SunOS | grep -v temp_package` +do + #if [ \( $item != 'temp_package' \) -a \( $item != 'NT4' \) ] + #then + cp -aRf $item temp_package/usr/share/pandora_agent/ + #fi +done +cp -aRf tentacle_client temp_package/usr/bin/ +cp -aRf pandora_agent temp_package/usr/bin/ +cp -aRf pandora_agent_exec temp_package/usr/bin/pandora_agent_exec +cp -aRf pandora_agent_daemon temp_package/etc/init.d/pandora_agent_daemon +cp -aRf pandora_agent_daemon.service temp_package/lib/systemd/system/pandora_agent_daemon.service +cp -aRf pandora_agent_logrotate temp_package/etc/logrotate.d/pandora_agent +cp Linux/pandora_agent.conf temp_package/etc/pandora/ + +cp -aRf man/man1/* temp_package/usr/share/man/man1/ + +# Relocate plugins to the final dir and delete +mv temp_package/usr/share/pandora_agent/plugins/* temp_package/etc/pandora/plugins + +echo "Official plugins are placed on /etc/pandora/plugins" > temp_package/usr/share/pandora_agent/plugins/README + +#Disabled, now the package overwrite the previous files. +##Create a temp file for to update files of plugins dir but don't crush dir. +##cp -aRf temp_package/usr/share/pandora_agent/plugins temp_package/tmp +##rm -rf temp_package/usr/share/pandora_agent/plugins/* + +echo "Remove the SVN files and other temp files." +for item in `find temp_package` +do + echo -n "." + echo $item | grep "svn" > /dev/null + #last command success + if [ $? -eq 0 ] + then + rm -rf $item + fi + + echo $item | grep "make_deb_package.sh" > /dev/null + #last command success + if [ $? -eq 0 ] + then + rm -rf $item + fi +done +echo "END" + +echo "Calcule md5sum for md5sums file control of package" +for item in `find temp_package` +do + echo -n "." + if [ ! -d $item ] + then + echo $item | grep "DEBIAN" > /dev/null + #last command success + if [ $? -eq 1 ] + then + md5=`md5sum $item | cut -d" " -f1` + + #delete "temp_package" in the path + final_path=${item#temp_package} + echo $md5" "$final_path >> temp_package/DEBIAN/md5sums + fi + fi +done +echo "END" + +echo "Make the package \"Pandorafms console\"." +dpkg-deb --build temp_package +mv temp_package.deb pandorafms.agent_unix_$pandora_version.deb + +echo "Delete the \"temp_package\" temp dir for job." +rm -rf temp_package diff --git a/pandora_agents/unix/DEBIAN/prerm b/pandora_agents/unix/DEBIAN/prerm index 847c25f593..35682fa3c5 100755 --- a/pandora_agents/unix/DEBIAN/prerm +++ b/pandora_agents/unix/DEBIAN/prerm @@ -14,3 +14,4 @@ if [ -x `command -v systemctl` ]; then else update-rc.d -f pandora_agent_daemon remove fi +exit 0 diff --git a/pandora_agents/unix/Darwin/pandora_agent.conf b/pandora_agents/unix/Darwin/pandora_agent.conf index b80614ba61..41c6747052 100644 --- a/pandora_agents/unix/Darwin/pandora_agent.conf +++ b/pandora_agents/unix/Darwin/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG, GNU/Linux +# Version 7.0NG.712, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2012 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -17,8 +17,7 @@ logfile /var/log/pandora/pandora_agent.log # Interval in seconds, 300 by default interval 300 -# Debug mode only generate XML, and stop after first execution, -# and does not copy XML to server. +# Debug mode renames XML in the temp folder and continues running debug 0 # Optional. UDP Server to receive orders from outside diff --git a/pandora_agents/unix/FreeBSD/pandora_agent.conf b/pandora_agents/unix/FreeBSD/pandora_agent.conf index 32097707ad..29d6e893b7 100644 --- a/pandora_agents/unix/FreeBSD/pandora_agent.conf +++ b/pandora_agents/unix/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG, FreeBSD Version +# Version 7.0NG.712, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2016 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -18,8 +18,7 @@ logfile /var/log/pandora/pandora_agent.log # Interval in seconds, 300 by default interval 300 -# Debug mode only generate XML, and stop after first execution, -# and does not copy XML to server. +# Debug mode renames XML in the temp folder and continues running debug 0 # Optional. UDP Server to receive orders from outside diff --git a/pandora_agents/unix/HP-UX/pandora_agent.conf b/pandora_agents/unix/HP-UX/pandora_agent.conf index 07dc423e9d..9db22b3b47 100644 --- a/pandora_agents/unix/HP-UX/pandora_agent.conf +++ b/pandora_agents/unix/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG, HP-UX Version +# Version 7.0NG.712, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -17,8 +17,7 @@ logfile /var/log/pandora/pandora_agent.log # Interval in seconds, 300 by default interval 300 -# Debug mode only generate XML, and stop after first execution, -# and does not copy XML to server. +# Debug mode renames XML in the temp folder and continues running debug 0 # By default, agent takes machine name diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index 4475226edf..fcfa94b429 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG, GNU/Linux +# Version 7.0NG.712, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2014 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -18,8 +18,7 @@ logfile /var/log/pandora/pandora_agent.log # Interval in seconds, 300 by default interval 300 -# Debug mode only generate XML, and stop after first execution, -# and does not copy XML to server. +# Debug mode renames XML in the temp folder and continues running debug 0 # Optional. UDP Server to receive orders from outside @@ -46,6 +45,12 @@ agent_name_cmd __rand__ #Parent agent_name #parent_agent_name caprica +# By default, agent takes machine alias +#agent_alias + +# To define agent alias by specific command, define 'agent_alias_cmd'. +#agent_alias_cmd + # Agent description #description This is a demo agent for Linux diff --git a/pandora_agents/unix/NT4/pandora_agent.conf b/pandora_agents/unix/NT4/pandora_agent.conf index 2110ecd693..29e9d9e9b2 100644 --- a/pandora_agents/unix/NT4/pandora_agent.conf +++ b/pandora_agents/unix/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG, GNU/Linux +# Version 7.0NG.712, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/NetBSD/pandora_agent.conf b/pandora_agents/unix/NetBSD/pandora_agent.conf index ffd6073a78..4f89baee8b 100644 --- a/pandora_agents/unix/NetBSD/pandora_agent.conf +++ b/pandora_agents/unix/NetBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG, NetBSD Version +# Version 7.0NG.712, NetBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -17,8 +17,7 @@ logfile /var/log/pandora/pandora_agent.log # Interval in seconds, 300 by default interval 300 -# Debug mode only generate XML, and stop after first execution, -# and does not copy XML to server. +# Debug mode renames XML in the temp folder and continues running debug 0 # By default, agent takes machine name diff --git a/pandora_agents/unix/SunOS/pandora_agent.conf b/pandora_agents/unix/SunOS/pandora_agent.conf index a030860d2f..94bc194a05 100644 --- a/pandora_agents/unix/SunOS/pandora_agent.conf +++ b/pandora_agents/unix/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG, Solaris Version +# Version 7.0NG.712, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -17,8 +17,7 @@ logfile /var/log/pandora/pandora_agent.log # Interval in seconds, 300 by default interval 300 -# Debug mode only generate XML, and stop after first execution, -# and does not copy XML to server. +# Debug mode renames XML in the temp folder and continues running debug 0 # By default, agent takes machine name diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 78b6a2c780..18bc995e59 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -40,8 +40,8 @@ my $Sem = undef; # Semaphore used to control the number of threads my $ThreadSem = undef; -use constant AGENT_VERSION => '7.0NG'; -use constant AGENT_BUILD => '170411'; +use constant AGENT_VERSION => '7.0NG.712'; +use constant AGENT_BUILD => '170908'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -135,9 +135,10 @@ my %DefaultConf = ( 'interval' => 300, 'debug' => 0, 'agent_name' => '', - 'agent_alias' => hostname(), + 'agent_alias' => '', 'ehorus_conf' => undef, 'agent_name_cmd' => '', + 'agent_alias_cmd' => '', 'description' => '', 'group' => '', 'group_id' => undef, @@ -802,6 +803,23 @@ sub read_config (;$) { # Module, plugin and collection definitions parse_conf_modules(\@file); + + # If agent_alias_cmd is defined, agent_alias is set by command result. + if ($Conf{'agent_alias'} eq '') { + if ($Conf{'agent_alias_cmd'} ne '') { + my $result = `$Conf{'agent_alias_cmd'}`; + # Use only the first line. + my ($temp_agent_alias, $remain2) = split(/\n/, $result); + chomp ($temp_agent_alias); + + # Remove white spaces of the first and last. + $temp_agent_alias =~ s/^ *(.*?) *$/$1/; + + $Conf{'agent_alias'} = $temp_agent_alias if ($temp_agent_alias ne ''); + } else { + $Conf{'agent_alias'} = hostname(); + } + } # If agent_name_cmd is defined, agent_name is set by command result. if ($Conf{'agent_name'} eq '') { @@ -888,14 +906,13 @@ sub fix_directory ($) { ################################################################################ # Sends a file to the server. ################################################################################ -#sub send_file ($;$) { +#sub send_file ($;$$$) { sub send_file { - my ($file, $secondary) = @_; + my ($file, $secondary, $rc_primary, $flag_always) = @_; my $output; - my $pid = fork(); return 1 unless defined $pid; - + if ($pid == 0) { # execute the transfer program by child process. eval { @@ -924,14 +941,14 @@ sub send_file { }; if ($@) { - log_message ('error', "Error sending file '$file': File transfer command is not responding."); + log_message ('error', "Error sending file '$file' to '" . $Conf{'server_ip'} . ":" . $Conf{'server_port'}. "': File transfer command is not responding."); exit 1; } # Get the errorlevel my $rc = $? >> 8; if ($rc != 0) { - log_message ('error', "Error sending file '$file': $output"); + log_message ('error', "Error sending file '$file' to '" . $Conf{'server_ip'} . ":" . $Conf{'server_port'}. "': $output"); } exit $rc; } @@ -940,39 +957,104 @@ sub send_file { waitpid ($pid, 0); my $rc = $? >> 8; - return $rc unless (defined ($secondary)); + if( ($Conf{'secondary_mode'} eq 'always') && ( !defined($flag_always) ) ){ + # Send the file to the secondary server + return $rc unless ($Conf{'secondary_mode'} eq 'always'); + + if(defined ($secondary)){ + if( ($rc != 0 && ($file =~ /\.data/)) ){ + $rc_primary = 1; + } + swap_servers (); + $rc = send_file ($file, undef, $rc_primary); + swap_servers (); - # Send the file to the secondary server - return $rc unless ($Conf{'secondary_mode'} eq 'always' || ($Conf{'secondary_mode'} eq 'on_error' && $rc != 0)); - - swap_servers (); - $rc = send_file ($file); - swap_servers (); - return $rc; + return $rc; + } + else{ + my $rc_secondary = 0; + if( ($rc != 0) && ($file =~ /\.data/)){ + $rc_secondary = 1; + } + + if ( $rc_secondary == 1 && defined($rc_primary) ){ + return 1; + } + + if ( $rc_secondary == 1 ){ + if (! -d "$Conf{'temporal'}/secondary"){ + mkdir "$Conf{'temporal'}/secondary"; + } + eval { + copy("$file", "$Conf{'temporal'}/secondary/"); + }; + if ($@) { + # We shouldn't reach this point... + die ("Cannot write on $Conf{'temporal'}/secondary/"); + } + return 0; + } + + if ( defined($rc_primary) ){ + if (! -d "$Conf{'temporal'}/primary"){ + mkdir "$Conf{'temporal'}/primary"; + } + eval { + copy("$file", "$Conf{'temporal'}/primary/"); + }; + if ($@) { + # We shouldn't reach this point... + die ("Cannot write on $Conf{'temporal'}/primary/"); + } + return 0; + } + + if ( $rc_secondary == 0 && !defined($rc_primary) ){ + return 0; + } + } + } + elsif ( ($Conf{'secondary_mode'} eq 'always') && defined($flag_always) ){ + return $rc; + } + else{ + return $rc unless (defined ($secondary)); + + # Send the file to the secondary server + return $rc unless ($Conf{'secondary_mode'} eq 'always' || ($Conf{'secondary_mode'} eq 'on_error' && $rc != 0)); + + swap_servers (); + $rc = send_file ($file); + swap_servers (); + return $rc; + } } ################################################################################ # Send buffered XML files. ################################################################################ -sub send_buffered_xml_files () { - +sub send_buffered_xml_files ($;$) { + my ($temporal_file, $flag_always) = @_; # Read XML files from the temporal directory - opendir(TEMPORAL, $Conf{'temporal'}) or return; - while (my $xml_file = readdir(TEMPORAL)) { - + opendir(TEMPORAL, $temporal_file) or return; + if (defined($flag_always) && ($flag_always == 2)){ + swap_servers (); + } + while (my $xml_file = readdir(TEMPORAL)) { # Skip non data files and symlinks - next if ($xml_file !~ m/^$Conf{'agent_name'}\.[0-9]+\.data$/ || -l "$Conf{'temporal'}/$xml_file"); - - my $rc = send_file ("$Conf{'temporal'}/$xml_file", 1); - + next if ($xml_file !~ m/^$Conf{'agent_name'}\.[0-9]+\.data$/ || -l "$temporal_file/$xml_file"); + my $rc = send_file ("$temporal_file/$xml_file", 1, undef, $flag_always); if ($rc == 0) { if ($Conf{'debug'} eq '1') { - rename "$Conf{'temporal'}/$xml_file", "$Conf{'temporal'}/$xml_file". "sent"; + rename "$temporal_file/$xml_file", "$temporal_file/$xml_file". "sent"; } else { - unlink ("$Conf{'temporal'}/$xml_file"); + unlink ("$temporal_file/$xml_file"); } } } + if (defined($flag_always) && ($flag_always == 2)){ + swap_servers (); + } } ################################################################################ @@ -2751,7 +2833,20 @@ while (1) { # Send buffered XML data files if ($Conf{'xml_buffer'} == 1) { - send_buffered_xml_files (); + if($Conf{'secondary_mode'} eq 'always'){ + $Conf{'__temporal_primary'} = "$Conf{'temporal'}/primary"; + $Conf{'__temporal_secondary'} = "$Conf{'temporal'}/secondary"; + if (-d "$Conf{'__temporal_primary'}"){ + send_buffered_xml_files ($Conf{'__temporal_primary'}, 1); + } + if (-d "$Conf{'__temporal_secondary'}"){ + send_buffered_xml_files ($Conf{'__temporal_secondary'}, 2); + } + send_buffered_xml_files ($Conf{'temporal'}); + } + else{ + send_buffered_xml_files ($Conf{'temporal'}); + } } } diff --git a/pandora_agents/unix/pandora_agent.orig b/pandora_agents/unix/pandora_agent.orig new file mode 100755 index 0000000000..2f7de8cc2a --- /dev/null +++ b/pandora_agents/unix/pandora_agent.orig @@ -0,0 +1,2824 @@ +#!/usr/bin/perl +# ********************************************************************** +# Pandora FMS Generic Unix/Perl Agent +# (c) 2009-2015 Artica Soluciones Tecnológicas +# with the help of many people. Please see http://pandorafms.org +# This code is licensed under GPL 2.0 license. +# ********************************************************************** + +=head1 NAME + +pandora_agent - Pandora FMS Agent + +=head1 VERSION + +Version 6.0 + +=head1 USAGE + +<< pandora_agent F >> + +=cut + + +use strict; +use warnings; + +use POSIX qw(strftime floor); +use Sys::Hostname; +use File::Basename; +use File::Copy; +use IO::Socket; +use Sys::Syslog; + +# Agent XML data +my $Xml; + +# Semaphore used to acces $Xml +my $Sem = undef; + +# Semaphore used to control the number of threads +my $ThreadSem = undef; + +use constant AGENT_VERSION => '7.0NG'; +<<<<<<< HEAD +use constant AGENT_BUILD => '170406'; +======= +use constant AGENT_BUILD => '170418'; +>>>>>>> develop + +# Agent log default file size maximum and instances +use constant DEFAULT_MAX_LOG_SIZE => 600000; +use constant DEFAULT_LOG_ROTATE => 3; + +# Commands to retrieve total memory information in kB +use constant TOTALMEMORY_CMDS => { + linux => 'cat /proc/meminfo | grep MemTotal: | awk \'{ print $2 }\'', + solaris => '/usr/sbin/prtconf | awk \'/Memory/ { print $3 * 1024 }\'', + hpux => 'swapinfo -t | grep memory | awk \'{print $2}\'', + freebsd => '/sbin/sysctl hw.physmem | awk \'{print $2 / 1024}\'', +}; + +# Commands to retrieve free memory information in kB +use constant FREEMEMORY_CMDS => { + linux => 'cat /proc/meminfo | grep MemFree: | awk \'{ print $2 }\'', + solaris => 'vmstat 1 2 | tail -1 | awk \'{ print $5 }\'', + hpux => 'swapinfo -t | grep memory | awk \'{print $4}\'', + freebsd => '/sbin/sysctl -n vm.stats.vm.v_page_size vm.stats.vm.v_free_count | tr "\n" " " | awk \'{ print $1 * $2 / 1024 }\'', +}; + +# Commands to retrieve cpu information +use constant CPUUSAGE_CMDS => { + linux => 'vmstat 1 2 | tail -1 | awk \'{ print $13 }\'', + solaris => 'vmstat 1 2 | tail -1 | awk \'{ print $21 }\'', + hpux => 'vmstat 1 2 | tail -1 | awk \'{ print $16 }\'', + freebsd => 'vmstat -n 0 1 2 | tail -1 | awk \'{ print $15 }\'' +}; + +# Commands to retrieve process information +use constant PROC_CMDS => { + # cpu usage, memory usage, command name + linux => 'ps aux | awk \'NR > 1 {ps = ""; for (i = 11; i <= NF; ++i) {ps = (ps " " $i) }; print $3, $6, ps}\'', + solaris => 'prstat 1 1 | awk \'NR > 1 {split ($10, ps, "/"); cpu = substr ($9, 1, length ($9) - 1); mem = substr ($3, 1, length ($3) - 1); print cpu, mem, ps[1]}\'', + hpux => 'ps -elf | awk \'NR > 1 {ps = ""; for (i = 15; i <= NF; ++i) {ps = (ps " " $i) }; print 0, $10, ps}\'', + aix => 'ps aux | awk \'NR > 1 {print $3, $6, $11}\'', + freebsd => 'ps axww -o %cpu= -o %mem= -o command= | sed -e "s/^ *//"', +}; + +# Commands to retrieve partition information in kB +use constant PART_CMDS => { + # total, available, mount point + linux => 'df -P | awk \'NR > 1 {print $2, $4, $6}\'', + solaris => 'df -k | awk \'NR > 1 {print $2, $4, $6}\'', + hpux => 'df -P | awk \'NR > 1 {print $2, $4, $6}\'', + aix => 'df -kP | awk \'NR > 1 {print $2, $4, $6}\'', + freebsd => 'df -k | awk \'NR > 1 {print $2, $4, $6}\'' +}; + +# Commands to call df with POSIX output format +use constant DF_CMDS => { + # total, available, mount point + linux => 'df -P', + solaris => 'df -k', + hpux => 'df -P', + aix => 'df -kP', + freebsd => 'df -k' +}; + +# 2 to the power of 32. +use constant POW232 => 2**32; + +# OS and OS version +my $OS = $^O; + +my $OS_VERSION; + +# Used to calculate the MD5 checksum of a string +use constant MOD232 => 2**32; + +# Directory where pandora_agent.conf is located +my $ConfDir = ''; + +# Pandora FMS agent configuration file +my $ConfFile = 'pandora_agent.conf'; + +# Set to 1 if broker agents are enabled. +my $BrokerEnabled = 0; + +# Broker agent configuration files +my @BrokerPid; + +# Configuration tokens +my %DefaultConf = ( + 'server_ip' => 'localhost', + 'server_path' => '/var/spool/pandora/data_in', + 'logfile' =>'/var/log/pandora/pandora_agent.log', + 'logsize' => DEFAULT_MAX_LOG_SIZE, + 'logrotate' => DEFAULT_LOG_ROTATE, + 'temporal' => '/var/spool/pandora', + 'interval' => 300, + 'debug' => 0, + 'agent_name' => '', + 'agent_alias' => hostname(), + 'ehorus_conf' => undef, + 'agent_name_cmd' => '', + 'description' => '', + 'group' => '', + 'group_id' => undef, + 'group_password' => undef, + 'encoding' => 'UTF-8', + 'server_port' => 41121, + 'transfer_mode' => 'tentacle', + 'transfer_timeout' => 30, + 'server_user' => 'pandora', + 'server_pwd' => '', + 'server_ssl' => '0', + 'server_opts' => '', + 'delayed_startup' => 0, + 'pandora_nice' => 10, + 'cron_mode' => 0, + 'remote_config' => 0, + 'secondary_mode' => 'never', + 'secondary_server_ip' => 'localhost', + 'secondary_server_path' => '/var/spool/pandora/data_in', + 'secondary_server_port' => 41121, + 'secondary_transfer_mode' => 'tentacle', + 'secondary_transfer_timeout' => 30, + 'secondary_server_user' => 'pandora', + 'secondary_server_pwd' => '', + 'secondary_server_ssl' => '0', + 'secondary_server_opts' => '', + 'autotime' => 0, + 'temporal_min_size' => 1, + 'timezone_offset' => 0, + 'pandora_exec' => 'pandora_agent_exec', + 'agent_threads' => 1, + 'udp_server_port' => 41122, + 'udp_server_auth_address' => '0.0.0.0', + 'udp_server' => 0, + 'proxy_mode' => 0, + 'proxy_max_connection' => 10, + 'proxy_timeout' => 1, + 'intensive_interval' => 0, + 'timestamp' => 0, + 'xml_buffer' => 0, + 'custom_id' => '', + 'url_address' => '', +); +my %Conf = %DefaultConf; + +# Modules +my @Modules; + +# Logfile file handle +my $LogFileFH; + +# Logfile index +my $LogFileIdx; + +# Agent name MD5; +my $AgentMD5; + +# Remote configuration file name +my $RemoteConfFile; + +# Remote md5 file name +my $RemoteMD5File; + +# Process data +my %Procs = ( + '__utimestamp__' => 0 +); + +# Partition data +my %Parts = ( + '__utimestamp__' => 0 +); + +# Collections +my %Collections; + +# Custom fields +my %Customfields; + +# $DevNull +my $DevNull = '/dev/null'; + +# Shell command separator +my $CmdSep = ';'; + +# Global macros +my %Macros; + +# PID of tentacle proxy, used in proxy mode +my $tentacle_pid = undef; + +# PID of udp_server +my $udp_server_pid = undef; + +################################################################################ +# Print usage information and exit. +################################################################################ +sub print_usage () { + print "\nUsage: $0 \n\n"; + print "\tPandora home is the directory where pandora_agent.conf is located,\n"; + print "\tby default /etc/pandora.\n\n"; + exit 1; +} + +################################################################################ +# Print an error message and exit. +################################################################################ +sub error ($) { + my $msg = shift; + print ("[ERROR] $msg\n\n"); + `logger -i -t pandora_agent_daemon [ERROR] $msg 2>/dev/null`; + exit 1; +} + +################################################################################ +# Check a regular expression. Returns 1 if its valid, 0 otherwise. +################################################################################ +sub valid_regexp ($) { + my $regexp = shift; + + eval { + '' =~ /$regexp/; + }; + + # Something went wrong + return 0 if ($@); + + return 1; +} + +################################################################################ +# Recursively delete files and directories. +################################################################################ +sub rmrf { + my $path = shift; + local *DIR; + + if (-d $path) { + opendir (DIR, $path) || return; + while (defined (my $file_name = readdir(DIR))) { + next if ($file_name eq '.' || $file_name eq '..'); + rmrf ("$path/$file_name"); + } + closedir (DIR); + rmdir ($path); + } else { + unlink ($path); + } +} + +################################################################################ +# Recursively set file permissions. +################################################################################ +sub chmodr { + my ($perm, $path) = @_; + local *DIR; + + if (-d $path) { + opendir (DIR, $path) || return; + while (defined (my $file_name = readdir(DIR))) { + next if ($file_name eq '.' || $file_name eq '..'); + chmodr ($perm, "$path/$file_name"); + } + closedir (DIR); + } + chmod ($perm, $path); +} + +################################################################################ +# Open the agent logfile and start logging. +################################################################################ +sub start_log (;$) { + my $quiet = shift; + + # Get the logfile + $Conf{'logfile'} = read_config ('logfile'); + $Conf{'logfile'} = '/var/log/pandora/pandora_agent.log' unless defined ($Conf{'logfile'}); + + # Open it + if ($Conf{'logfile'} eq 'syslog') { + openlog('pandora_agent', 'nowait', 'daemon'); + } else { + open ($LogFileFH, "> $Conf{'logfile'}") or error ("Could not open log file $Conf{'logfile'} for writing: $!."); + print "Logging to $Conf{'logfile'}\n" if (!defined ($quiet)); + } +} + +################################################################################ +# Rotates the agent logfile. +################################################################################ +sub rotate_log () { + if ($Conf{'logfile'} eq 'syslog') { + # No action needed + return; + } else { + if ($Conf{'logrotate'} < 0){ + $Conf{'logrotate'} = DEFAULT_LOG_ROTATE; + } + if ($Conf{'logfile'} eq 'syslog') { + return; + } + + # Rotate file + $LogFileIdx = ($LogFileIdx+1) % $Conf{'logrotate'}; + my $fsize = (stat $Conf{'logfile'})[7]; + + stop_log(); + move ($Conf{'logfile'}, $Conf{'logfile'} . "." . $LogFileIdx); + start_log('quiet'); + + } +} + +################################################################################ +# Close the agent logfile and stop logging. +################################################################################ +sub stop_log () { + if ($Conf{'logfile'} eq 'syslog') { + closelog(); + } else { + close ($LogFileFH); + } +} + +################################################################################ +# Log a message to the agent logfile. +################################################################################ +sub log_message ($$;$) { + my ($source, $msg, $dest) = @_; + + if (defined ($dest)) { + print $dest strftime ('%Y/%m/%d %H:%M:%S', localtime ()) . " - [$source] - $msg\n"; + } elsif ($Conf{'logfile'} eq 'syslog') { + syslog('info', $msg); + } else { + #Trying to write into log file to test its writable + syswrite ($LogFileFH, ""); + + #If no error, the file is writable + if (!$!) { + print $LogFileFH strftime ('%Y/%m/%d %H:%M:%S', localtime ()) . " - [$source] - $msg\n"; + } else { + #If error then log into syslog! + `logger -i -t pandora_agent_daemon [ERROR] $msg 2>/dev/null`; + } + } +} + +################################################################################ +# Parse configuration file (modules, plugins and collections) +################################################################################ +sub parse_conf_modules($) { + my ($param) = @_; + + # Mark the start of a module definition + my $module_begin = 0; + + # Skeleton for modules + my $module = {}; + + foreach my $line (@{$param}) { + + next if ($line =~ m/^\s*#/) or ($line =~ m/^\s*$/); + # Module definition + if ($line =~ /^\s*module_begin\s*$/) { + $module_begin = 1; + init_module ($module); + } elsif ($line =~ /^\s*module_name\s+(.+)$/) { + $module->{'name'} = $1; + $module->{'name'} =~ s/\s+$//g; + $module->{'name'} =~ s/^\s+//g; + } elsif ($line =~ /^\s*module_description\s+(.+)$/) { + $module->{'description'} = $1; + } elsif ($line =~ /^\s*module_type\s+(\S+)\s*$/) { + $module->{'type'} = $1; + }elsif ($line =~ /^\s*module_precondition\s+(.*)$/) { + my $action = $1; + + # Numeric comparison + if ($action =~ /^\s*([<>!=]+)\s+(\d+(?:\.\d*)?)\s+(.*)$/) { + push (@{$module->{'precondition'}}, {'operator' => $1, 'value_1' => $2, 'command' => $3}); + # Interval + } elsif ($action =~ /^\s*[(]\s*(\d+(?:\.\d*)?)\s*,\s*(\d+(?:\.\d*)?)\s*[)]\s+(.*)$/) { + push (@{$module->{'precondition'}}, {'operator' => '()', 'value_1' => $1, 'value_2' => $2, 'command' => $3}); + # Regular expression + } elsif ($action =~ /^\s*=~\s+(\S*)\s+(.*)$/) { + if (valid_regexp ($1)) { + push (@{$module->{'precondition'}}, {'operator' => '=~', 'value_1' => $1, 'command' => $2}); + } else { + log_message ('setup', "Invalid regular expression in module precondition: $line"); + } + } + } elsif ($line =~ /^\s*module_exec\s+(.+)$/) { + $module->{'func'} = \&module_exec; + $module->{'params'} = $1; + } elsif ($line =~ /^\s*module_cpuusage\s+(.*)$/) { + $module->{'func'} = \&module_cpuusage; + $module->{'params'} = $1; + } elsif ($line =~ /^\s*module_freememory\s+(.*)$/) { + $module->{'func'} = \&module_freememory; + $module->{'params'} = $1; + } elsif ($line =~ /^\s*module_freepercentmemory\s+(.*)$/) { + $module->{'func'} = \&module_freepercentmemory; + $module->{'params'} = $1; + } elsif ($line =~ /^\s*(module_proc|module_service)\s+(.+)$/) { + $module->{'func'} = \&module_proc; + $module->{'params'} = $2; + } elsif ($line =~ /^\s*module_cpuproc\s+(.+)$/) { + $module->{'func'} = \&module_cpuproc; + $module->{'params'} = $1; + } elsif ($line =~ /^\s*module_memproc\s+(.+)$/) { + $module->{'func'} = \&module_memproc; + $module->{'params'} = $1; + } elsif ($line =~ /^\s*module_freedisk\s+(.*)$/) { + $module->{'func'} = \&module_freedisk; + $module->{'params'} = $1; + } elsif ($line =~ /^\s*module_freepercentdisk\s+(.*)$/) { + $module->{'func'} = \&module_freepercentdisk; + $module->{'params'} = $1; + } elsif ($line =~ /^\s*module_occupiedpercentdisk\s+(.*)$/) { + $module->{'func'} = \&module_occupiedpercentdisk; + $module->{'params'} = $1; + } elsif ($line =~ /^\s*module_max\s+(.*)\s*$/) { + $module->{'max'} = $1; + } elsif ($line =~ /^\s*module_min\s+(.*)\s*$/) { + $module->{'min'} = $1; + } elsif ($line =~ /^\s*module_postprocess\s+(.*)\s*$/) { + $module->{'post_process'} = $1; + } elsif ($line =~ /^\s*module_interval\s+(\d+)\s*$/) { + $module->{'interval'} = $1; + } elsif ($line =~ /^\s*module_timeout\s+(\d+)\s*$/) { + $module->{'timeout'} = $1; + } elsif ($line =~ /^\s*module_save\s+(\w+)$/) { + $module->{'save'} = $1; + } elsif ($line =~ /^\s*module_alert_template\s+(.*)$/) { + $module->{'alert_template'} = $1; + } elsif ($line =~ /^\s*module_condition\s+(.*)$/) { + my $action = $1; + # Numeric comparison + if ($action =~ /^\s*([<>!=]+)\s+(\d+(?:\.\d*)?)\s+(.*)$/) { + push (@{$module->{'conditions'}}, {'operator' => $1, 'value_1' => $2, 'command' => $3}); + # Interval + } elsif ($action =~ /^\s*[(]\s*(\d+(?:\.\d*)?)\s*,\s*(\d+(?:\.\d*)?)\s*[)]\s+(.*)$/) { + push (@{$module->{'conditions'}}, {'operator' => '()', 'value_1' => $1, 'value_2' => $2, 'command' => $3}); + # Regular expression + } elsif ($action =~ /^\s*=~\s+(\S*)\s+(.*)$/) { + if (valid_regexp ($1)) { + push (@{$module->{'conditions'}}, {'operator' => '=~', 'value_1' => $1, 'command' => $2}); + } else { + log_message ('setup', "Invalid regular expression in module condition: $line"); + } + } + } elsif ($line =~ /^\s*module_intensive_condition\s+(.*)$/) { + my $action = $1; + + $module->{'is_intensive'} = 1; + + # Numeric comparison + if ($action =~ /^\s*([<>!=]+)\s+(\d+(?:\.\d*)?)\s*$/) { + push (@{$module->{'intensive_conditions'}}, {'operator' => $1, 'value_1' => $2}); + # Interval + } elsif ($action =~ /^\s*[(]\s*(\d+(?:\.\d*)?)\s*,\s*(\d+(?:\.\d*)?)\s*[)]\s*$/) { + push (@{$module->{'intensive_conditions'}}, {'operator' => '()', 'value_1' => $1, 'value_2' => $2}); + # Regular expression + } elsif ($action =~ /^\s*=~\s+(\S*)\s*$/) { + if (valid_regexp ($1)) { + push (@{$module->{'intensive_conditions'}}, {'operator' => '=~', 'value_1' => $1}); + } else { + log_message ('setup', "Invalid regular expression in intensive condition: $line"); + } + } + } elsif ($line =~ /^\s*module_crontab\s+(((\*|(\d+(-\d+){0,1}))\s*){5}).*$/) { + $module->{'cron'} = $1; + chomp ($module->{'cron'}); + } elsif ($line =~ /^\s*module_cron_interval\s+(\d+).*$/) { + $module->{'cron_interval'} = $1; + } elsif ($line =~ /^\s*module_end\s*$/) { + + $module_begin = 0; + + # Check for invalid modules + next unless (($module->{'name'} ne '' && $module->{'func'} != 0) || $module->{'func'} == \&module_plugin); + + # Set the intensive interval + if ($module->{'is_intensive'} == 1) { + $module->{'intensive_interval'} = $module->{'interval'}; + } else { + $module->{'intensive_interval'} = $module->{'interval'} * ($Conf{'interval'} / $Conf{'intensive_interval'}); + } + + # Make the module run the first time + $module->{'counter'} = $module->{'intensive_interval'}; + + # Replace macros + replace_macros ($module); + + push (@Modules, {%{$module}}); + # Plugin + } elsif ($line =~ /^\s*module_plugin\s+(.+)$/) { + + # Single line plugin definition + if ($module_begin == 0) { + + # Set default values for the module configuration + init_module ($module); + + # Configure the plugin + $module->{'func'} = \&module_plugin; + $module->{'params'} = $1; + + # Set the intensive interval + if ($module->{'is_intensive'} == 1) { + $module->{'intensive_interval'} = $module->{'interval'}; + } else { + $module->{'intensive_interval'} = $module->{'interval'} * ($Conf{'interval'} / $Conf{'intensive_interval'}); + } + + # Make the module run the first time + $module->{'counter'} = $module->{'intensive_interval'}; + + # Replace macros + replace_macros ($module); + + push (@Modules, {%{$module}}); + } else { + $module->{'func'} = \&module_plugin; + $module->{'params'} = $1; + } + # Module proc command redefinition + } elsif ($line =~ /^\s*module_proc_cmd\s+(.+)$/) { + PROC_CMDS->{$OS} = $1; + # Module freedisk command redefinition + } elsif ($line =~ /^\s*module_freedisk_cmd\s+(.+)$/) { + PART_CMDS->{$OS} = $1; + # Collection + } elsif ($line =~ /^\s*file_collection\s+(.+)$/) { + my $collection = $1; + + # Prevent path traversal attacks + if ($collection !~ m/(\.\.)|\//) { + $Collections{$collection} = 0; + } + # Min critical + } elsif ($line =~ /^\s*module_min_critical\s+(.*)\s*$/) { + $module->{'min_critical'} = $1; + # Max critical + } elsif ($line =~ /^\s*module_max_critical\s+(.*)\s*$/) { + $module->{'max_critical'} = $1; + # Min warning + } elsif ($line =~ /^\s*module_min_warning\s+(.*)\s*$/) { + $module->{'min_warning'} = $1; + # Max warning + } elsif ($line =~ /^\s*module_max_warning\s+(.*)\s*$/) { + $module->{'max_warning'} = $1; + # Disabled + } elsif ($line =~ /^\s*module_disabled\s+(.*)\s*$/) { + $module->{'disabled'} = $1; + # Min ff event + } elsif ($line =~ /^\s*module_min_ff_event\s+(.*)\s*$/) { + $module->{'min_ff_event'} = $1; + # Unit + } elsif ($line =~ /^\s*module_unit\s+(.*)\s*$/) { + $module->{'unit'} = $1; + # Module_group + } elsif ($line =~ /^\s*module_group\s+(.*?)\s*$/) { + $module->{'module_group'} = $1; + # Custom id + } elsif ($line =~ /^\s*module_custom_id\s+(.*)\s*$/) { + $module->{'custom_id'} = $1; + # Str warning + } elsif ($line =~ /^\s*module_str_warning\s+(.*)\s*$/) { + $module->{'str_warning'} = $1; + # Str critical + } elsif ($line =~ /^\s*module_str_critical\s+(.*)\s*$/) { + $module->{'str_critical'} = $1; + # Critical instructions + } elsif ($line =~ /^\s*module_critical_instructions\s+(.*)\s*$/) { + $module->{'critical_instructions'} = $1; + # Warning instructions + } elsif ($line =~ /^\s*module_warning_instructions\s+(.*)\s*$/) { + $module->{'warning_instructions'} = $1; + # Unknown instructions + } elsif ($line =~ /^\s*module_unknown_instructions\s+(.*)\s*$/) { + $module->{'unknown_instructions'} = $1; + # Tags + } elsif ($line =~ /^\s*module_tags\s+(.*)\s*$/) { + $module->{'tags'} = $1; + # Critical inverse + } elsif ($line =~ /^\s*module_critical_inverse\s+(\S+)\s*$/) { + $module->{'critical_inverse'} = $1; + # Warning inverse + } elsif ($line =~ /^\s*module_warning_inverse\s+(\S+)\s*$/) { + $module->{'warning_inverse'} = $1; + # Quiet + } elsif ($line =~ /^\s*module_quiet\s+(\S+)\s*$/) { + $module->{'quiet'} = $1; + # FF interval + } elsif ($line =~ /^\s*module_ff_interval\s+(\S+)\s*$/) { + $module->{'module_ff_interval'} = $1; + } elsif ($line =~ /^\s*module_min_ff_event_normal\s+(\S+)\s*$/) { + $module->{'min_ff_event_normal'} = $1; + } elsif ($line =~ /^\s*module_min_ff_event_warning\s+(\S+)\s*$/) { + $module->{'min_ff_event_warning'} = $1; + } elsif ($line =~ /^\s*module_min_ff_event_critical\s+(\S+)\s*$/) { + $module->{'min_ff_event_critical'} = $1; + } elsif ($line =~ /^\s*module_ff_timeout\s+(\S+)\s*$/) { + $module->{'ff_timeout'} = $1; + } elsif ($line =~ /^\s*module_each_ff\s+(\S+)\s*$/) { + $module->{'each_ff'} = $1; + # Macros + } elsif ($line =~ /^\s*module_macro(\S+)\s+(.*)\s*$/) { + $module->{'macros'}{$1} = $2; + } + } + return; +} + +################################################################################ +# Create configuration file for broker agents. +################################################################################ +sub write_broker_conf($){ + my ($broker_agent) = @_; + my $content = ''; + + # I don't think the following should be copied either: proxy_* + my %ignored_tokens = ( + 'broker_agent' => 1, 'agent_name_cmd' => 1, 'udp_server' => 1, 'cron_mode' => 1 + ); + + open (CONF_FILE, "$ConfDir/$ConfFile") or error ("Could not open file '$ConfDir/$ConfFile': $!."); + open (BROKER_FILE, ">$ConfDir/${broker_agent}.conf") or error ("Could not write configuration file: $!"); + + while (my $line = ) { + + my ( $token ) = $line =~ m/^\s*(\S+)(\s.*)?$/; + # Skip tokens which should not be copied to broker configuration + next if defined $ignored_tokens{$token}; + + # Change the agent name + if ($line =~ m/^\s*#*\s*agent_name\s+/) { + $line = "agent_name $broker_agent\n"; + } + # Change the logfile + elsif ($line =~ m/^\s*logfile\s+(.*)/) { + $line = 'logfile ' . dirname ($1) . "/$broker_agent.log\n"; + } + + print BROKER_FILE $line; + } + close (BROKER_FILE); + close (CONF_FILE); +} + +################################################################################ +# Read configuration file. Exit on error. +################################################################################ +sub read_config (;$) { + my $token = shift; + my @found_tokens; + my $module; + + error ("File '$ConfDir/$ConfFile' not found.") unless (-e "$ConfDir/$ConfFile"); + open (CONF_FILE, "$ConfDir/$ConfFile") or error ("Could not open file '$ConfDir/$ConfFile': $!."); + + my @file = ; + close(CONF_FILE); + + foreach my $line (@file){ + # Skip comments and empty lines + next if ($line =~ m/^\s*#/) or ($line =~ m/^\s*$/); + + # Replace CRLF with LF + $line =~ s/\r\n/\n/g; + + # Token search + if (defined ($token)) { + if ($line =~ /^\s*(\S+)\s+(.*)$/ && $1 eq $token) { + + # Multiple value token + if (wantarray ()) { + push (@found_tokens, $2); + } + # Single value token + else { + return $2; + } + } + next; + } + + # Store the custom fields + + if (($line =~ m/^(custom_field\d+_name)\s+(.*)/) or ($line =~ m/^(custom_field\d+_value)\s+(.*)/)) { + $Customfields{$1} = $2; + next; + } + + # Save global macros + if ($line =~ m/^macro(\S+)\s+(.*)/) { + $Macros{$1} = $2; + next; + } + + next if ($line =~ /^module\s*\w*/); + + #Configuration token + if ($line =~ /^\s*(\S+)\s+(.*)$/) { + log_message ('setup', "$1 is $2"); + $Conf{$1} = $2; + + # Look for broker agents. + if ($1 eq 'broker_agent') { + $BrokerEnabled = 1; + } + + # Remove trailing spaces + $Conf{$1} =~ s/\s*$//; + } + } + + # Token search + if (defined ($token)) { + + # Multiple value token + if (wantarray ()) { + return @found_tokens; + } + + # Single value token not found. + return undef; + } + + # Set the intensive interval + if ($Conf{'intensive_interval'} == 0) { + $Conf{'intensive_interval'} = $Conf{'interval'}; + } + + # Search for includes after all other variables have been set + foreach my $line (@file) { + + # Skip comments and empty lines + next if ($line =~ m/^\s*#/) or ($line =~ m/^\s*$/); + + # Replace CRLF with LF + $line =~ s/\r\n/\n/g; + + # Additional configuration file + if ($line =~ /^include\s+(.*)\s*/) { + $Conf{'include'} = $Conf{'include'} ? "$Conf{'include'} $1" : $1; + + foreach my $file_name (glob("$1")) { + open (FILE, "$file_name") or next; + + log_message ('setup', "reading $file_name"); + my @file_conf = ; + parse_conf_modules(\@file_conf); + close (FILE); + } + next; + } + } + + # Module, plugin and collection definitions + parse_conf_modules(\@file); + + # If agent_name_cmd is defined, agent_name is set by command result. + if ($Conf{'agent_name'} eq '') { + if ($Conf{'agent_name_cmd'} eq '__rand__') { + $Conf{'agent_name'} = generate_agent_name(); + config_update('agent_name', $Conf{'agent_name'}); + } elsif ($Conf{'agent_name_cmd'} ne '') { + my $result = `$Conf{'agent_name_cmd'}`; + + # Use only the first line. + my ($temp_agent_name, $remain) = split(/\n/, $result); + chomp ($temp_agent_name); + + # Remove white spaces of the first and last. + $temp_agent_name =~ s/^ *(.*?) *$/$1/; + + $Conf{'agent_name'} = $temp_agent_name if ($temp_agent_name ne ''); + } else { + $Conf{'agent_name'} = hostname(); + } + } + + # Update the agent MD5 since agent_name may have changed + $AgentMD5 = md5 ($Conf{'agent_name'}); + $RemoteConfFile = "$AgentMD5.conf"; + $RemoteMD5File = "$AgentMD5.md5"; + + # Load thread support if agent_threads is greater than 1. + if ($Conf{'agent_threads'} > 1) { + eval { + local $SIG{__DIE__}; + require threads; + require threads::shared; + require Thread::Semaphore; + }; + if (!$@) { + $Sem = Thread::Semaphore->new; + $ThreadSem = Thread::Semaphore->new ($Conf{'agent_threads'}); + threads::shared::share (\$Xml); + threads::shared::share (\$Sem); + log_message ('log', 'Using thread library.'); + } else { + log_message ('log', 'Thread library is not available. agent_threads is set to 1 (disabled).'); + $Conf{'agent_threads'} = 1; + $Sem = undef; + $ThreadSem = undef; + } + } else { + $Sem = undef; + $ThreadSem = undef; + log_message ('log', 'Thread is disabled.'); + } + + # Accept 'yes' for backward compatibility + $Conf{'server_ssl'} = '1' if ($Conf{'server_ssl'} eq 'yes'); + $Conf{'secondary_server_ssl'} = '1' if ($Conf{'secondary_server_ssl'} eq 'yes'); + + # Set tentacle client options + if ($Conf{'transfer_mode'} eq 'tentacle') { + $Conf{'server_opts'} = '-x \'' . $Conf{'server_pwd'} . '\' ' . $Conf{'server_opts'} if ($Conf{'server_pwd'} ne ''); + $Conf{'server_opts'} = '-c ' . $Conf{'server_opts'} if ($Conf{'server_ssl'} eq '1'); + } + + # Set tentacle client options for secondary server + if ($Conf{'secondary_transfer_mode'} eq 'tentacle') { + $Conf{'secondary_server_opts'} = '-x \'' . $Conf{'secondary_server_pwd'} . '\' ' . $Conf{'secondary_server_opts'} if ($Conf{'secondary_server_pwd'} ne ''); + $Conf{'secondary_server_opts'} = '-c ' . $Conf{'secondary_server_opts'} if ($Conf{'secondary_server_ssl'} eq '1'); + } +} + +################################################################################# +## Remove any trailing / from directory names. +################################################################################# +sub fix_directory ($) { + my $dir = shift; + + my $char = chop ($dir); + return $dir if ($char eq '/'); + return $dir . $char; +} + + + +################################################################################ +# Sends a file to the server. +################################################################################ +#sub send_file ($;$) { +sub send_file { + my ($file, $secondary) = @_; + my $output; + + my $pid = fork(); + return 1 unless defined $pid; + + if ($pid == 0) { + # execute the transfer program by child process. + eval { + local $SIG{'ALRM'} = sub {die}; + alarm ($Conf{'transfer_timeout'}); + if ($Conf{'transfer_mode'} eq 'tentacle') { + $output = `tentacle_client -v -a $Conf{'server_ip'} -p $Conf{'server_port'} $Conf{'server_opts'} "$file" 2>&1 >$DevNull`; + } elsif ($Conf{'transfer_mode'} eq 'ssh') { + $output = `scp -P $Conf{'server_port'} "$file" pandora@"$Conf{'server_ip'}:$Conf{'server_path'}" 2>&1 >$DevNull`; + } elsif ($Conf{'transfer_mode'} eq 'ftp') { + my $base = basename ($file); + my $dir = dirname ($file); + + $output = `ftp -n $Conf{'server_opts'} $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <&1 >$DevNull`; + } + alarm (0); + }; + + if ($@) { + log_message ('error', "Error sending file '$file': File transfer command is not responding."); + exit 1; + } + + # Get the errorlevel + my $rc = $? >> 8; + if ($rc != 0) { + log_message ('error', "Error sending file '$file': $output"); + } + exit $rc; + } + + # Wait the child process termination and get the errorlevel + waitpid ($pid, 0); + my $rc = $? >> 8; + + return $rc unless (defined ($secondary)); + + # Send the file to the secondary server + return $rc unless ($Conf{'secondary_mode'} eq 'always' || ($Conf{'secondary_mode'} eq 'on_error' && $rc != 0)); + + swap_servers (); + $rc = send_file ($file); + swap_servers (); + return $rc; +} + +################################################################################ +# Send buffered XML files. +################################################################################ +sub send_buffered_xml_files () { + + # Read XML files from the temporal directory + opendir(TEMPORAL, $Conf{'temporal'}) or return; + while (my $xml_file = readdir(TEMPORAL)) { + + # Skip non data files and symlinks + next if ($xml_file !~ m/^$Conf{'agent_name'}\.[0-9]+\.data$/ || -l "$Conf{'temporal'}/$xml_file"); + + my $rc = send_file ("$Conf{'temporal'}/$xml_file", 1); + + if ($rc == 0) { + if ($Conf{'debug'} eq '1') { + rename "$Conf{'temporal'}/$xml_file", "$Conf{'temporal'}/$xml_file". "sent"; + } else { + unlink ("$Conf{'temporal'}/$xml_file"); + } + } + } +} + +################################################################################ +# Swap primary and secondary servers. +################################################################################ +sub swap_servers () { + ($Conf{'server_ip'}, $Conf{'secondary_server_ip'}) = ($Conf{'secondary_server_ip'}, $Conf{'server_ip'}); + ($Conf{'server_path'}, $Conf{'secondary_server_path'}) = ($Conf{'secondary_server_path'}, $Conf{'server_path'}); + ($Conf{'server_port'}, $Conf{'secondary_server_port'}) = ($Conf{'secondary_server_port'}, $Conf{'server_port'}); + ($Conf{'transfer_mode'}, $Conf{'secondary_transfer_mode'}) = ($Conf{'secondary_transfer_mode'}, $Conf{'transfer_mode'}); + ($Conf{'transfer_timeout'}, $Conf{'secondary_transfer_timeout'}) = ($Conf{'secondary_transfer_timeout'}, $Conf{'transfer_timeout'}); + ($Conf{'server_user'}, $Conf{'secondary_server_user'}) = ($Conf{'secondary_server_user'}, $Conf{'server_user'}); + ($Conf{'server_pwd'}, $Conf{'secondary_server_pwd'}) = ($Conf{'secondary_server_pwd'}, $Conf{'server_pwd'}); + ($Conf{'server_ssl'}, $Conf{'secondary_server_ssl'}) = ($Conf{'secondary_server_ssl'}, $Conf{'server_ssl'}); + ($Conf{'server_opts'}, $Conf{'secondary_server_opts'}) = ($Conf{'secondary_server_opts'}, $Conf{'server_opts'}); +} + +################################################################################ +# Receive a file from the server. +################################################################################ +sub recv_file ($) { + my $file = shift; + my $output; + + my $pid = fork(); + return 1 unless defined $pid; + + if ($pid == 0) { + # execute the transfer program by child process. + eval { + local $SIG{'ALRM'} = sub {die}; + alarm ($Conf{'transfer_timeout'}); + if ($Conf{'transfer_mode'} eq 'tentacle') { + $output = `cd "$Conf{'temporal'}"$CmdSep tentacle_client -v -g -a $Conf{'server_ip'} -p $Conf{'server_port'} $Conf{'server_opts'} $file 2>&1 >$DevNull` + } elsif ($Conf{'transfer_mode'} eq 'ssh') { + $output = `scp -P $Conf{'server_port'} pandora@"$Conf{'server_ip'}:$Conf{'server_path'}/$file" $Conf{'temporal'} 2>&1 >$DevNull`; + } elsif ($Conf{'transfer_mode'} eq 'ftp') { + my $base = basename ($file); + my $dir = dirname ($file); + + $output = `ftp -n $Conf{'server_opts'} $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <&1 >$DevNull`; + } + alarm (0); + }; + + if ($@) { + log_message ('error', "Error retrieving file: File transfer command is not responding."); + exit 1; + } + + # Get the errorlevel + my $rc = $? >> 8; + if ($rc != 0) { + log_message ('error', "Error retrieving file: $output"); + } + exit $rc; + } + + # Wait the child process termination and get the errorlevel + waitpid ($pid, 0); + my $rc = $? >> 8; + + return $rc; +} + +################################################################################ +# Check the server for a remote configuration. +################################################################################ +sub check_remote_config () { + + return unless ($Conf{'remote_config'} eq '1'); + + # Calculate the configuration file MD5 digest + open (CONF_FILE, "$ConfDir/$ConfFile") or error ("Could not open file '$ConfDir/$ConfFile': $!."); + binmode(CONF_FILE); + my $conf_md5 = md5 (join ('', )); + close (CONF_FILE); + + # Remove temporary files if they exist as symlink to avoid symlink attack + for my $file ("$Conf{'temporal'}/$RemoteMD5File", "$Conf{'temporal'}/$RemoteConfFile") { + error ("File '$file' already exists as a symlink and could not be removed: $!") if (-l $file && ! unlink($file)); + } + + # Get the remote MD5 file + if (recv_file ($RemoteMD5File) != 0) { + open (MD5_FILE, "> $Conf{'temporal'}/$RemoteMD5File") || error ("Could not open file '$ConfDir/$RemoteMD5File' for writing: $!."); + print MD5_FILE $conf_md5; + close (MD5_FILE); + copy ("$ConfDir/$ConfFile", "$Conf{'temporal'}/$RemoteConfFile"); + send_file ("$Conf{'temporal'}/$RemoteConfFile"); + send_file ("$Conf{'temporal'}/$RemoteMD5File"); + log_message ('remote config', 'Uploading configuration for the first time.'); + unlink ("$Conf{'temporal'}/$RemoteConfFile"); + unlink ("$Conf{'temporal'}/$RemoteMD5File"); + return; + } + + open (MD5_FILE, "< $Conf{'temporal'}/$RemoteMD5File") || error ("Could not open file '$ConfDir/$RemoteMD5File' for writing: $!."); + my $remote_conf_md5 = ; + close (MD5_FILE); + + # No changes + return if ($remote_conf_md5 eq $conf_md5); + + # Get the new configuration file + return if (recv_file ($RemoteConfFile) != 0); + log_message ('remote config', 'Configuration has changed!'); + + # Save the new configuration + move ("$Conf{'temporal'}/$RemoteConfFile", "$ConfDir/$ConfFile"); + + # Empty macros, modules, plugins and collections + %Macros = (); + @Modules = (); + %Collections = (); + %Conf = %DefaultConf; + + # Reload the new configuration + read_config (); + + # Log file may have changed + stop_log (); + start_log ('quiet'); + + #Set nice of the pandora_agent + my $PID = $$; + `renice "$Conf{'pandora_nice'}" "$PID"`; +} + +################################################################################ +# SUB launch_tentacle_proxy +# Launchs tentacle server in proxy mode. +################################################################################ +sub launch_tentacle_proxy () { + # Check if proxy server ip is right. + if ($Conf{'server_ip'} ne "localhost") { + + #Create a new process and launch tentacle. + $tentacle_pid = fork(); + + if ($tentacle_pid == 0) { + + #Execute tentacle server as a daemon + my $new_process = "tentacle_server -b ".$Conf{'server_ip'}." -g ".$Conf{'server_port'}." -c ".$Conf{'proxy_max_connection'}." -t ".$Conf{'proxy_timeout'}; + + $new_process .= ' -C' if ($Conf{'server_ssl'} eq '1'); + + log_message ('setup', 'Proxy mode enabled'); + exec ($new_process); + } + } else { + log_message ('error', 'You can not proxy to localhost'); + exit 1; + } +} + +################################################################################ +# Delete old collections and download new collections. +################################################################################ +sub check_collections () { + + # Delete old collections if there are no broker agents + if ($BrokerEnabled == 0) { + opendir (DIR, "$ConfDir/collections") || return; + while (defined (my $file_name = readdir(DIR))) { + next if ($file_name eq '.' || $file_name eq '..'); + + # Do not delete md5 files associated to a collection + $file_name =~ s/\.md5$//; + + if (! defined ($Collections{$file_name})) { + rmrf ("$ConfDir/collections/$file_name"); + unlink ("$ConfDir/collections/$file_name.md5"); + } + } + closedir (DIR); + } + + # Download new collections + while (my ($collection, $in_path) = each (%Collections)) { + my $collection_file = $collection . ".zip"; + my $collection_md5_file = $collection . ".md5"; + + # Add the collection directory to the PATH + if ($in_path == 0) { + $Collections{$collection} = 1; + $ENV{'PATH'} .= ":$ConfDir/collections/$collection"; + } + + # Get remote md5 + error ("File '$Conf{'temporal'}/$collection_md5_file' already exists as a symlink and could not be removed: $!.") if (-l "$Conf{'temporal'}/$collection_md5_file" && !unlink("$Conf{'temporal'}/$collection_md5_file")); + next unless (recv_file ($collection_md5_file) == 0); + open (MD5_FILE, "< $Conf{'temporal'}/$collection_md5_file") || error ("Could not open file '$Conf{'temporal'}/$collection_md5_file' for reading: $!."); + my $remote_collection_md5 = ; + close (MD5_FILE); + unlink ("$Conf{'temporal'}/$collection_md5_file"); + + # Read local md5 + my $local_collection_md5 = ''; + if (defined (open (MD5_FILE, "< $ConfDir/collections/$collection_md5_file"))) { + $local_collection_md5 = ; + close MD5_FILE; + } + + # Check for changes + $local_collection_md5 = $remote_collection_md5 unless defined ($local_collection_md5); + next if ($local_collection_md5 eq $remote_collection_md5); + + # Download and unzip + next unless (recv_file ($collection_file) == 0); + rmrf ("$ConfDir/collections/$collection"); + `unzip -d "$ConfDir/collections/$collection" "$Conf{'temporal'}/$collection_file" 2>$DevNull`; + unlink ("$Conf{'temporal'}/$collection_file"); + + # Save the new md5 + open (MD5_FILE, "> $ConfDir/collections/$collection_md5_file") || error ("Could not open file '$ConfDir/collections/$collection_md5_file' for writing: $!."); + print MD5_FILE "$remote_collection_md5"; + close (MD5_FILE); + + # Set proper file permissions + chmodr (0750, "$ConfDir/collections/$collection"); + } +} + +############################################################################### +# Return the MD5 checksum of the given string as a hex string. +# Pseudocode from: http://en.wikipedia.org/wiki/MD5#Pseudocode +############################################################################### +my @S = ( + 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, + 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, + 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, + 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21 +); +my @K = ( + 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, + 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, + 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, + 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, + 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, + 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8, + 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, + 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, + 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, + 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, + 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, + 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, + 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, + 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, + 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, + 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 +); +sub md5 { + my $str = shift; + + # No input! + if (!defined($str)) { + return ""; + } + + # Note: All variables are unsigned 32 bits and wrap modulo 2^32 when + # calculating. + + # Initialize variables. + my $h0 = 0x67452301; + my $h1 = 0xEFCDAB89; + my $h2 = 0x98BADCFE; + my $h3 = 0x10325476; + + # Pre-processing. + my $msg = unpack ("B*", pack ("A*", $str)); + my $bit_len = length ($msg); + + # Append "1" bit to message. + $msg .= '1'; + + # Append "0" bits until message length in bits ≡ 448 (mod 512). + $msg .= '0' while ((length ($msg) % 512) != 448); + + # Append bit /* bit, not byte */ length of unpadded message as 64-bit + # little-endian integer to message. + $msg .= unpack ("B32", pack ("V", $bit_len)); + $msg .= unpack ("B32", pack ("V", $bit_len >> 32)); + + # Process the message in successive 512-bit chunks. + for (my $i = 0; $i < length ($msg); $i += 512) { + + my @w; + my $chunk = substr ($msg, $i, 512); + + # Break chunk into sixteen 32-bit little-endian words w[i], 0 <= i <= + # 15. + for (my $j = 0; $j < length ($chunk); $j += 32) { + push (@w, unpack ("V", pack ("B32", substr ($chunk, $j, 32)))); + } + + # Initialize hash value for this chunk. + my $a = $h0; + my $b = $h1; + my $c = $h2; + my $d = $h3; + my $f; + my $g; + + # Main loop. + for (my $y = 0; $y < 64; $y++) { + if ($y <= 15) { + $f = $d ^ ($b & ($c ^ $d)); + $g = $y; + } + elsif ($y <= 31) { + $f = $c ^ ($d & ($b ^ $c)); + $g = (5 * $y + 1) % 16; + } + elsif ($y <= 47) { + $f = $b ^ $c ^ $d; + $g = (3 * $y + 5) % 16; + } + else { + $f = $c ^ ($b | (0xFFFFFFFF & (~ $d))); + $g = (7 * $y) % 16; + } + + my $temp = $d; + $d = $c; + $c = $b; + $b = ($b + leftrotate (($a + $f + $K[$y] + $w[$g]) % POW232, $S[$y])) % POW232; + $a = $temp; + } + + # Add this chunk's hash to result so far. + $h0 = ($h0 + $a) % POW232; + $h1 = ($h1 + $b) % POW232; + $h2 = ($h2 + $c) % POW232; + $h3 = ($h3 + $d) % POW232; + } + + # Digest := h0 append h1 append h2 append h3 #(expressed as little-endian) + return unpack ("H*", pack ("V", $h0)) . + unpack ("H*", pack ("V", $h1)) . + unpack ("H*", pack ("V", $h2)) . + unpack ("H*", pack ("V", $h3)); +} + +############################################################################### +# MD5 leftrotate function. See: http://en.wikipedia.org/wiki/MD5#Pseudocode +############################################################################### +sub leftrotate { + my ($x, $c) = @_; + + return (0xFFFFFFFF & ($x << $c)) | ($x >> (32 - $c)); +} + +############################################################################### +# Return the SHA256 checksum of the given string as a hex string. +# Pseudocode from: http://en.wikipedia.org/wiki/SHA-2#Pseudocode +############################################################################### +my @K2 = ( + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, + 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, + 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, + 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, + 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, + 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +); +sub sha256 { + my $str = shift; + + # No input! + if (!defined($str)) { + return ""; + } + + # Note: All variables are unsigned 32 bits and wrap modulo 2^32 when + # calculating. + + # First 32 bits of the fractional parts of the square roots of the first 8 + # primes. + my $h0 = 0x6a09e667; + my $h1 = 0xbb67ae85; + my $h2 = 0x3c6ef372; + my $h3 = 0xa54ff53a; + my $h4 = 0x510e527f; + my $h5 = 0x9b05688c; + my $h6 = 0x1f83d9ab; + my $h7 = 0x5be0cd19; + + # Pre-processing. + my $msg = unpack ("B*", pack ("A*", $str)); + my $bit_len = length ($msg); + + # Append "1" bit to message. + $msg .= '1'; + + # Append "0" bits until message length in bits = 448 (mod 512). + $msg .= '0' while ((length ($msg) % 512) != 448); + + # Append bit /* bit, not byte */ length of unpadded message as 64-bit + # big-endian integer to message. + $msg .= unpack ("B32", pack ("N", $bit_len >> 32)); + $msg .= unpack ("B32", pack ("N", $bit_len)); + + # Process the message in successive 512-bit chunks. + for (my $i = 0; $i < length ($msg); $i += 512) { + + my @w; + my $chunk = substr ($msg, $i, 512); + + # Break chunk into sixteen 32-bit big-endian words. + for (my $j = 0; $j < length ($chunk); $j += 32) { + push (@w, unpack ("N", pack ("B32", substr ($chunk, $j, 32)))); + } + + # Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array: + for (my $i = 16; $i < 64; $i++) { + my $s0 = rightrotate($w[$i - 15], 7) ^ rightrotate($w[$i - 15], 18) ^ ($w[$i - 15] >> 3); + my $s1 = rightrotate($w[$i - 2], 17) ^ rightrotate($w[$i - 2], 19) ^ ($w[$i - 2] >> 10); + $w[$i] = ($w[$i - 16] + $s0 + $w[$i - 7] + $s1) % POW232; + } + + # Initialize working variables to current hash value. + my $a = $h0; + my $b = $h1; + my $c = $h2; + my $d = $h3; + my $e = $h4; + my $f = $h5; + my $g = $h6; + my $h = $h7; + + # Compression function main loop. + for (my $i = 0; $i < 64; $i++) { + my $S1 = rightrotate($e, 6) ^ rightrotate($e, 11) ^ rightrotate($e, 25); + my $ch = ($e & $f) ^ ((0xFFFFFFFF & (~ $e)) & $g); + my $temp1 = ($h + $S1 + $ch + $K2[$i] + $w[$i]) % POW232; + my $S0 = rightrotate($a, 2) ^ rightrotate($a, 13) ^ rightrotate($a, 22); + my $maj = ($a & $b) ^ ($a & $c) ^ ($b & $c); + my $temp2 = ($S0 + $maj) % POW232; + + $h = $g; + $g = $f; + $f = $e; + $e = ($d + $temp1) % POW232; + $d = $c; + $c = $b; + $b = $a; + $a = ($temp1 + $temp2) % POW232; + } + + # Add the compressed chunk to the current hash value. + $h0 = ($h0 + $a) % POW232; + $h1 = ($h1 + $b) % POW232; + $h2 = ($h2 + $c) % POW232; + $h3 = ($h3 + $d) % POW232; + $h4 = ($h4 + $e) % POW232; + $h5 = ($h5 + $f) % POW232; + $h6 = ($h6 + $g) % POW232; + $h7 = ($h7 + $h) % POW232; + } + + # Produce the final hash value (big-endian). + return unpack ("H*", pack ("N", $h0)) . + unpack ("H*", pack ("N", $h1)) . + unpack ("H*", pack ("N", $h2)) . + unpack ("H*", pack ("N", $h3)) . + unpack ("H*", pack ("N", $h4)) . + unpack ("H*", pack ("N", $h5)) . + unpack ("H*", pack ("N", $h6)) . + unpack ("H*", pack ("N", $h7)); +} + +############################################################################### +# Rotate a 32-bit number a number of bits to the right. +############################################################################### +sub rightrotate { + my ($x, $c) = @_; + + return (0xFFFFFFFF & ($x << (32 - $c))) | ($x >> $c); +} + +################################################################################ +# Try to guess the OS version. +################################################################################ +sub guess_os_version ($) { + my $os = shift; + my $os_version; + + # Linux + if ($os eq 'linux') { + $os_version = `lsb_release -sd 2>$DevNull`; + # AIX + } elsif ($os eq 'aix') { + $os_version = "$2.$1" if (`uname -rv` =~ /\s*(\d)\s+(\d)\s*/); + # Windows + } elsif ($os =~ /win/i) { + $os_version = `ver`; + $DevNull = '/Nul'; + $CmdSep = '\&'; + $OS = "windows"; + + # Solaris, HP-UX, BSD and others + } else { + $os_version = `uname -r`; + } + + # Something went wrong + return '' unless defined ($os_version); + + # Remove any trailing new lines + chomp ($os_version); + + return $os_version; +} + +################################################################################ +# Execute the given module. +################################################################################ +sub exec_module ($) { + my $module = shift; + + # Need something to execute + if ($module->{'func'} == 0) { + $ThreadSem->up () if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1); + return; + } + + # Check module interval + if (++($module->{'counter'}) < $module->{'intensive_interval'}) { + $ThreadSem->up () if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1); + return; + } + + # Check module cron + if (check_module_cron ($module) != 1) { + $ThreadSem->up () if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1); + return; + } + + # Check module preconditions + if (evaluate_module_preconditions ($module) == 0) { + return; + } + + # Reset module counter + $module->{'counter'} = 0; + + # Temporarily disable strict refs + no strict 'refs'; + + # Run + my @value = &{$module->{'func'}}($module); + if (defined ($value[0])) { + + # Evaluate intensive conditions + if ($module->{'is_intensive'} == 1) { + my $intensive_match = evaluate_module_intensive_conditions ($module, $value[0]); + if ($intensive_match == $module->{'intensive_match'} && $module->{'timestamp'} + $module->{'interval'} * $Conf{'interval'} > time ()) { + $ThreadSem->up () if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1); + return; + } + + # Update the time reference + $module->{'timestamp'} = time () if ($module->{'timestamp'} + $module->{'interval'} * $Conf{'interval'} <= time ()); + + # Update the intensive match status + $module->{'intensive_match'} = $intensive_match; + } + + # Evaluate module conditions + evaluate_module_conditions ($module, $value[0]); + + # Write the module XML + write_module_xml ($module, @value); + } + + # Save the module value if needed (only works for the first returned value) + if ($module->{'save'} ne '') { + if (defined ($value[0])) { + $ENV{$module->{'save'}} = $value[0] ; + } else { + $ENV{$module->{'save'}} = ''; + } + } + + $ThreadSem->up () if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1); +} + +################################################################################ +# Load process information. +################################################################################ +sub load_procs () { + my $utimestamp = time (); + + # Do we know hoy to get process information in this OS? + return unless defined (PROC_CMDS->{$OS}); + + # Update at most once every interval + return if ($Procs{'__utimestamp__'} > ($utimestamp - $Conf{'interval'})); + + # Get process information + my $cmd = PROC_CMDS->{$OS}; + my @procs = `$cmd`; + return undef unless ($? eq 0); + + # Clear past process infomation + %Procs = (); + + # Parse process information + foreach my $proc (@procs) { + + chomp ($proc); + my @proc_info = split (/\s+/, $proc); + next unless ($#proc_info >= 2); + + # Process command + my $proc_cmd = join (' ', @proc_info[2..$#proc_info]); + + # Process command + $Procs{$proc_cmd} = (); + + # Process CPU usage + $Procs{$proc_cmd}{'cpu'} = $proc_info[0]; + + # Process virtual size + $Procs{$proc_cmd}{'size'} = $proc_info[1]; + } + + $Procs{'__utimestamp__'} = $utimestamp; +} + +################################################################################ +# Load partition information. +################################################################################ +sub load_parts () { + my $utimestamp = time (); + + # Do we know hoy to get partition information in this OS? + return unless defined (PART_CMDS->{$OS}); + + # Update at most once every interval + return if ($Parts{'__utimestamp__'} > ($utimestamp - $Conf{'interval'})); + + # Get partition information + my $cmd = PART_CMDS->{$OS}; + my @parts = `$cmd`; + return undef unless ($? eq 0); + + # Parse partition information + foreach my $part (@parts) { + + chomp ($part); + my @part_info = split (/\s+/, $part); + next unless ($#part_info >= 2); + + my $part = join (' ', @part_info[2..$#part_info]); + + # Mount point + $Parts{$part} = (); + + # Total space in kB + $Parts{$part}{'total'} = $part_info[0]; + + # Available space in kB + $Parts{$part}{'avail'} = $part_info[1]; + } + + $Parts{'__utimestamp__'} = $utimestamp; +} + +################################################################################ +# Execute the given command. +################################################################################ +sub module_exec ($) { + my $module = shift; + my @data; + my $exe; + + # Check module parameters + return () unless ($module->{'params'} ne ''); + + my $params = $module->{'params'}; + + # Execute the command + if ($module->{'timeout'} == 0) { + @data = `$params 2> $DevNull`; + log_message ('debug', "Executing module " . $module->{'name'} . " ($params 2> $DevNull)") if ($Conf{'debug'} eq '1'); + } else { + my $cmd = quotemeta ($params); + @data = `$Conf{'pandora_exec'} $module->{'timeout'} $cmd 2> $DevNull`; + log_message ('debug', "Executing module " . $module->{'name'} . ' (' . $Conf{'pandora_exec'} . ' ' . $module->{'timeout'} . " $cmd 2> $DevNull)") if ($Conf{'debug'} eq '1'); + } + + # Something went wrong or no data + return () unless ($? eq 0 && defined ($data[0])); + + return @data; +} + +################################################################################ +# Get the status of a process. 1 running, 0 not running. +################################################################################ +sub module_proc ($) { + my $module = shift; + + # Check module parameters + return () unless ($module->{'params'} ne ''); + + # Data collection layer + load_procs (); + + return (1) if defined ($Procs{$module->{'params'}}); + return (0); +} + +################################################################################ +# Get the CPU usage of a process. +################################################################################ +sub module_cpuproc ($) { + my $module = shift; + + # Check module parameters + return () unless ($module->{'params'} ne ''); + + # Data collection layer + load_procs (); + + return () unless defined ($Procs{$module->{'params'}}) and defined ($Procs{$module->{'params'}}{'cpu'}); + return ($Procs{$module->{'params'}}{'cpu'}); +} + +################################################################################ +# Get the memory usage of a process in Mbytes. +################################################################################ +sub module_memproc ($) { + my $module = shift; + + # Check module parameters + return () unless ($module->{'params'} ne ''); + + # Data collection layer + load_procs (); + + return () unless defined ($Procs{$module->{'params'}}) and defined ($Procs{$module->{'params'}}{'size'}); + return (sprintf ("%d", $Procs{$module->{'params'}}{'size'} / 1024)); +} + +################################################################################ +# Get the free space in a partition in Mbytes. +################################################################################ +sub module_freedisk ($) { + my $module = shift; + + # Check module parameters + return () unless ($module->{'params'} ne ''); + + # Data collection layer + load_parts (); + + return () unless defined ($Parts{$module->{'params'}}) and defined ($Parts{$module->{'params'}}{'avail'}); + + my $avail = sprintf("%d", $Parts{$module->{'params'}}{'avail'} / 1024); + return ($avail); +} + +################################################################################ +# Get the free space in a partition in %. +################################################################################ +sub module_freepercentdisk ($) { + my $module = shift; + + # Check module parameters + return () unless ($module->{'params'} ne ''); + + # Data collection layer + load_parts (); + + return () unless defined ($Parts{$module->{'params'}}) and defined ($Parts{$module->{'params'}}{'avail'}); + + my $availp = sprintf("%d", $Parts{$module->{'params'}}{'avail'} * 100 / $Parts{$module->{'params'}}{'total'}); + return ($availp); +} + +################################################################################ +# Get the occupied space in a partition in %. +################################################################################ +sub module_occupiedpercentdisk ($) { + my $module = shift; + + # Check module parameters + return () unless ($module->{'params'} ne ''); + + # Data collection layer + load_parts (); + + return () unless defined ($Parts{$module->{'params'}}) and defined ($Parts{$module->{'params'}}{'avail'}); + + my $occupiedp = sprintf("%d", ($Parts{$module->{'params'}}{'total'} - $Parts{$module->{'params'}}{'avail'}) * 100 / $Parts{$module->{'params'}}{'total'}); + return ($occupiedp); +} + +################################################################################ +# Get the CPU usage %. +################################################################################ +sub module_cpuusage ($) { + my $module = shift; + + # Do we know hoy to get CPU usage in this OS? + return unless defined (CPUUSAGE_CMDS->{$OS}); + + # Get CPU usage + my $cmd = CPUUSAGE_CMDS->{$OS}; + my @data = `$cmd 2> $DevNull`; + + # Something went wrong or no data + return () unless ($? eq 0 && defined ($data[0])); + + return ($data[0]); +} + +################################################################################ +# Get the free space in a partition in Mbytes. +################################################################################ +sub module_freememory ($) { + my $module = shift; + + # Do we know hoy to get memory information in this OS? + return () unless defined (FREEMEMORY_CMDS->{$OS}); + + # Get available memory + my $cmd = FREEMEMORY_CMDS->{$OS}; + my @data = `$cmd 2> $DevNull`; + + # Something went wrong or no data + return () unless ($? eq 0 && defined ($data[0])); + + return (sprintf ("%d", $data[0] / 1024)); +} + +################################################################################ +# Get the free space in a partition in %. +################################################################################ +sub module_freepercentmemory ($) { + my $module = shift; + + # Do we know hoy to get memory information in this OS? + return unless defined (TOTALMEMORY_CMDS->{$OS}); + + # Get CPU usage + my $cmd = TOTALMEMORY_CMDS->{$OS}; + my @data = `$cmd 2> $DevNull`; + + # Something went wrong or no data + return () unless ($? eq 0 && defined ($data[0])); + + # Get total memory in MB + my $total = sprintf ("%d", $data[0] / 1024); + + # Get available memory in MB + my ($avail) = module_freememory ($module); + return () unless defined ($avail); + + return sprintf (("%d", $avail * 100 / $total)); +} + +################################################################################ +# Evaluate and execute module preconditions. +################################################################################ +sub evaluate_module_preconditions ($) { + my ($module) = @_; + + # Evaluate preconditions + foreach my $precondition (@{$module->{'precondition'}}) { + my $data = `$precondition->{'command'} 2> $DevNull`; + return 0 if (evaluate_condition ($precondition, $data) == 0); + } + + return 1; +} + +################################################################################ +# Evaluate a module condition. Returns 1 if the condition matches, 0 otherwise. +################################################################################ +sub evaluate_condition ($$) { + my ($condition, $data) = @_; + + { + no warnings; + if (($condition->{'operator'} eq '>' && $data > $condition->{'value_1'}) || + ($condition->{'operator'} eq '<' && $data < $condition->{'value_1'}) || + ($condition->{'operator'} eq '=' && $data == $condition->{'value_1'}) || + ($condition->{'operator'} eq '!=' && $data != $condition->{'value_1'}) || + ($condition->{'operator'} eq '=~' && $data =~ /$condition->{'value_1'}/) || + ($condition->{'operator'} eq '()' && $data > $condition->{'value_1'} && $data < $condition->{'value_2'})) { + return 1; + } + } + + return 0; +} + + +################################################################################ +# Evaluate and execute module conditions. +################################################################################ +sub evaluate_module_conditions ($$) { + my ($module, $data) = @_; + + # Evaluate conditions + foreach my $condition (@{$module->{'conditions'}}) { + if (evaluate_condition ($condition, $data) == 1) { + `$condition->{'command'} 2> $DevNull`; + } + } +} + +################################################################################ +# Evaluate intensive conditions. +################################################################################ +sub evaluate_module_intensive_conditions ($$) { + my ($module, $data) = @_; + + # Evaluate conditions + foreach my $condition (@{$module->{'intensive_conditions'}}) { + return 0 if (evaluate_condition ($condition, $data) == 0); + } + + return 1; +} + +################################################################################ +# Checks the module's cron string. Returns 1 if the module should be run, 0 if +# not. +################################################################################ +sub check_module_cron ($) { + my $module = shift; + + # No cron string defined + return 1 unless ($module->{'cron'} ne ''); + + # Check if the module was already executed + return 0 unless (time() >= $module->{'cron_utimestamp'}); + + # Get cron configuration + my @cron_params = split (/\s/, $module->{'cron'}); + + # Get current time + my $current_time = time(); + my @time = localtime($current_time); + + # Minutes, hours, day of the month, month and day of the week + my @time_params = @time[1, 2, 3, 4, 6]; + + # Fix month (localtime retuns 0..11 and we need 1..12) + $time_params[3] += 1; + + # Check cron parameters + for (my $i = 0; $i < 5; $i++) { + + # Wildcard + next if ($cron_params[$i] eq '*'); + + # Get interval + my ($bottom, $top) = split (/-/, $cron_params[$i]); + $top = $bottom unless defined ($top); + + # Check if next execution will overflow the cron (only minutes overflow) + # If overflow, execute the module + my $overflow_cron = 0; + if ($i == 0) { + my $start_cron_seconds = $bottom*60; + my $current_exec_seconds = $time_params[$i]*60; + my $next_exec_seconds = $time_params[$i]*60 + $module->{'interval'}*$Conf{'interval'}; + if ($current_exec_seconds > $start_cron_seconds && $current_exec_seconds > $next_exec_seconds) { + $start_cron_seconds += 3600; + } + if (($current_exec_seconds <= $start_cron_seconds) && ($start_cron_seconds <= $next_exec_seconds)) { + $overflow_cron = 1 + } + } + + # Check interval + if ($bottom <= $top) { + return 0 if (($time_params[$i] < $bottom || $time_params[$i] > $top) && !$overflow_cron); + } else { + return 0 if (($time_params[$i] < $bottom && $time_params[$i] > $top) && !$overflow_cron); + } + } + + # Do not check in the next minute, hour, day or month. + my $offset = 0; + if ($module->{'cron_interval'} >= 0) { + $offset = $module->{'cron_interval'}; + } elsif($cron_params[0] ne '*') { + # 1 minute + $offset = 60; + } elsif($cron_params[1] ne '*') { + # 1 hour + $offset = 3600; + } elsif($cron_params[2] ne '*' || $cron_params[4] ne '*') { + # 1 day + $offset = 86400; + } elsif($cron_params[3] ne '*') { + # 31 days + $offset = 2678400; + } + + $module->{'cron_utimestamp'} = $current_time + $offset; + return 1; +} + +################################################################################ +# Write module data in XML format. +################################################################################ +sub write_module_xml ($@) { + my ($module, @data) = @_; + + # No data + return unless (defined $data[0]); + + # Is it a plugin? + if ($module->{'func'} == \&module_plugin) { + $Sem->down () if (defined ($Sem)); + $Xml .= $data[0]; + $Sem->up () if (defined ($Sem)); + return; + } + + # Critical section + $Sem->down () if (defined ($Sem)); + + $Xml .= "\n" . + " {'name'} . "]]>\n" . + " {'description'} . "]]>\n" . + " " . $module->{'type'} . "\n"; + + # Interval + $Xml .= " " . $module->{'interval'} . "\n"; + + # Min + $Xml .= " " . $module->{'min'} . "\n" if (defined ($module->{'min'})); + + # Max + $Xml .= " " . $module->{'max'} . "\n" if (defined ($module->{'max'})); + + # Post process + $Xml .= " " . $module->{'post_process'} . "\n" if (defined ($module->{'post_process'})); + + # Min critical + $Xml .= " " . $module->{'min_critical'} . "\n" if (defined ($module->{'min_critical'})); + + # Max critical + $Xml .= " " . $module->{'max_critical'} . "\n" if (defined ($module->{'max_critical'})); + + # Min warning + $Xml .= " " . $module->{'min_warning'} . "\n" if (defined ($module->{'min_warning'})); + + # Max warning + $Xml .= " " . $module->{'max_warning'} . "\n" if (defined ($module->{'max_warning'})); + + # Disabled + $Xml .= " " . $module->{'disabled'} . "\n" if (defined ($module->{'disabled'})); + + # Min ff event + $Xml .= " " . $module->{'min_ff_event'} . "\n" if (defined ($module->{'min_ff_event'})); + + # Unit + $Xml .= " {'unit'} . "]]>\n" if (defined ($module->{'unit'})); + + # Module group + $Xml .= " " . $module->{'module_group'} . "\n" if (defined ($module->{'module_group'})); + + # Custom ID + $Xml .= " {'custom_id'} . "]]>\n" if (defined ($module->{'custom_id'})); + + # Str warning + $Xml .= " {'str_warning'} . "]]>\n" if (defined ($module->{'str_warning'})); + + # Str critical + $Xml .= " {'str_critical'} . "]]>\n" if (defined ($module->{'str_critical'})); + + # Critical instructions + $Xml .= " {'critical_instructions'} . "]]>\n" if (defined ($module->{'critical_instructions'})); + + # Warning instructions + $Xml .= " {'warning_instructions'} . "]]>\n" if (defined ($module->{'warning_instructions'})); + + # Unknown instructions + $Xml .= " {'unknown_instructions'} . "]]>\n" if (defined ($module->{'unknown_instructions'})); + + # Tags + $Xml .= " {'tags'} . "]]>\n" if (defined ($module->{'tags'})); + + # Critical inverse + $Xml .= " " . $module->{'critical_inverse'} . "\n" if (defined ($module->{'critical_inverse'})); + + # Warning inverse + $Xml .= " " . $module->{'warning_inverse'} . "\n" if (defined ($module->{'warning_inverse'})); + + # Quiet + $Xml .= " " . $module->{'quiet'} . "\n" if (defined ($module->{'quiet'})); + + # Module FF interval + $Xml .= " " . $module->{'module_ff_interval'} . "\n" if (defined ($module->{'module_ff_interval'})); + + # Module Alert template + $Xml .= " " . $module->{'alert_template'} . "\n" if (defined ($module->{'alert_template'})); + + # Module Alert template + $Xml .= " " . $module->{'cron'} . "\n" if (defined ($module->{'cron'}) and ($module->{'cron'} ne "")); + + # FF threshold configuration + $Xml .= " " . $module->{'min_ff_event_normal'} . "\n" if (defined ($module->{'min_ff_event_normal'})); + $Xml .= " " . $module->{'min_ff_event_warning'} . "\n" if (defined ($module->{'min_ff_event_warning'})); + $Xml .= " " . $module->{'min_ff_event_critical'} . "\n" if (defined ($module->{'min_ff_event_critical'})); + $Xml .= " " . $module->{'ff_timeout'} . "\n" if (defined ($module->{'ff_timeout'})); + $Xml .= " " . $module->{'each_ff'} . "\n" if (defined ($module->{'each_ff'})); + + # Data list + if ($#data > 0) { + $Xml .= " \n"; + # Single data + } else { + chomp ($data[0]); + $Xml .= " \n"; + } + $Xml .= "\n"; + + $Sem->up () if (defined ($Sem)); +} + +################################################################################ +# Receive a UDP server signal to restart agent +################################################################################ +sub udp_server_signal () { + log_message ('udp server', 'Received signal to restart the agent.'); +} + +################################################################################ +# Basic UDP server to restart agent on UDP signal received +################################################################################ +sub udp_server ($$) { + + my $udp_port = shift; + my $udp_auth_address = shift; + my $parent_pid = getppid(); + my @udp_auth_list = split(',', $udp_auth_address); + + my($sock, $oldmsg, $newmsg, $hisaddr, $hishost, $MAXLEN); + $MAXLEN = 1024; + + log_message ('udp server', 'Starting UDP server listening on '.$udp_auth_address.":".$udp_port); + $sock = IO::Socket::INET->new(LocalPort => $udp_port, Proto => 'udp') or die "socket: $@"; + + while ($sock->recv($newmsg, $MAXLEN)) { + my $hishost = $sock->peerhost(); + my $address_found = 0; + foreach my $single_address (@udp_auth_list) { + $address_found = $address_found || ($hishost eq $single_address); + } + if (($udp_auth_address eq "0.0.0.0") || $address_found){ + if ($newmsg =~ /REFRESH AGENT/){ + # Send signal to restart agent + log_message ('udp server', 'Received signal from '.$hishost); + kill 'SIGINT' , $parent_pid; + } + elsif ($newmsg =~ /START PROCESS (.*)/){ + my $process_name = $1; + $process_name =~ s/^\s*//g; + $process_name =~ s/\s*$//g; + if (defined($Conf{"process_${process_name}_start"})) { + log_message ('udp server', "Process $process_name started from $hishost"); + system "$Conf{\"process_${process_name}_start\"} 2>$DevNull &"; + } else { + log_message ('udp server', "Attempt to start unknown process $process_name from $hishost"); + } + } + elsif ($newmsg =~ /STOP PROCESS (.*)/){ + my $process_name = $1; + $process_name =~ s/^\s*//g; + $process_name =~ s/\s*$//g; + if (defined($Conf{"process_${process_name}_stop"})) { + log_message ('udp server', "Process $process_name stopped from $hishost"); + system "$Conf{\"process_${process_name}_stop\"} 2>$DevNull &"; + } else { + log_message ('udp server', "Attempt to stop unknown process $process_name from $hishost"); + } + } + } + } +} + +################################################################################ +# Execute the given plugin. +################################################################################ +sub module_plugin ($) { + my $plugin = shift; + + my $command = $plugin->{'params'}; + + # Empty plugin + return () if ($command eq ''); + + # Execute the plugin + + my $output = ""; + if ($plugin->{'timeout'} == 0) { + $output = `$command 2>$DevNull`; + log_message ('debug', "Executing plugin: " . $command) if ($Conf{'debug'} eq '1'); + } else { + $output = `$Conf{'pandora_exec'} $plugin->{'timeout'} $command 2> $DevNull`; + log_message ('debug', "Executing plugin: (" . $command . ") with timeout: " . $plugin->{'timeout'} . "s") if ($Conf{'debug'} eq '1'); + } + + # Do not save the output if there was an error + if ($? != 0) { + return (); + } + + return ($output); +} + +################################################################################ +# TERM Handler +################################################################################ +sub kill_signal_handler (){ + # Kill tentacle server if it was launched + + if (defined ($tentacle_pid)) { + print "kill -9 $tentacle_pid\n"; + `kill -9 $tentacle_pid`; + } + + # Kill udp_server if it was forked. + if (defined ($udp_server_pid) && $udp_server_pid) { + kill 'TERM', $udp_server_pid; + log_message ('udp server', 'terminated.'); + } + + exit (0); +} + +################################################################################ +# Get the free disk space in the temporal directory (in bytes). +################################################################################ +sub temporal_freedisk () { + + # Call df + return 0 unless defined (DF_CMDS->{$OS}); + my $cmd = DF_CMDS->{$OS} . ' ' . $Conf{'temporal'} . ' | awk \'NR > 1 {print $4}\''; + my $temporal_freedisk = `$cmd`; + + # Check for errors + return 0 unless ($? eq 0); + + # Convert to bytes + return 1024 * int ($temporal_freedisk); +} + +################################################################################ +# Replace module macros. +################################################################################ +sub replace_macros ($) { + my $module = shift; + + # Replace macros + foreach my $token (keys (%{$module})) { + + # No need to skip macros for now, since it's a hash ref and only array refs + # are searched for macros. + #if ($token eq 'macros') { + # next; + #} + + # No defined value for conf token + if (! defined ($module->{$token})) { + next; + } + + # Simple configuration token + if(ref($module->{$token}) eq ''){ + # Module macros + while (my ($macro, $subst) = each (%{$module->{'macros'}})) { + eval { + $module->{$token} =~ s/$macro/$subst/g; + }; + } + # Global macros + while (my ($macro, $subst) = each (%Macros)) { + eval { + $module->{$token} =~ s/$macro/$subst/g; + }; + } + } + # Hash array + elsif (ref($module->{$token}) eq 'ARRAY'){ + for (my $i = 0; $i <= $#{$module->{$token}}; $i++) { + + # Array of configuration tokens + foreach my $key (keys (%{$module->{$token}->[$i]})) { + + # Module macros (each configuration token is a hash) + while (my ($macro, $subst) = each (%{$module->{'macros'}})) { + eval { + $module->{$token}->[$i]->{$key} =~ s/$macro/$subst/g; + } + } + + # Global macros (each configuration token is a hash) + while (my ($macro, $subst) = each (%Macros)) { + eval { + $module->{$token}->[$i]->{$key} =~ s/$macro/$subst/g; + } + } + } + } + } + } +} + +################################################################################ +# Initialize a module with default values. +################################################################################ +sub init_module ($) { + my $module = shift; + + $module->{'name'} = ''; + $module->{'type'} = 'generic_data'; + $module->{'description'} = ''; + $module->{'func'} = 0; + $module->{'params'} = ''; + $module->{'interval'} = 1; + $module->{'timeout'} = 0; + $module->{'counter'} = 0; + $module->{'max'} = undef; + $module->{'min'} = undef; + $module->{'post_process'} = undef; + $module->{'min_critical'} = undef; + $module->{'max_critical'} = undef; + $module->{'min_warning'} = undef; + $module->{'max_warning'} = undef; + $module->{'disabled'} = undef; + $module->{'min_ff_event'} = undef; + $module->{'save'} = ''; + $module->{'conditions'} = []; + $module->{'cron'} = ''; + $module->{'cron_utimestamp'} = 0; + $module->{'cron_interval'} = -1; + $module->{'precondition'} = []; + $module->{'is_intensive'} = 0; + $module->{'intensive_conditions'} = []; + $module->{'intensive_match'} = 0; + $module->{'timestamp'} = 0; + $module->{'unit'} = undef; + $module->{'module_group'} = undef; + $module->{'custom_id'} = undef; + $module->{'str_warning'} = undef; + $module->{'str_critical'} = undef; + $module->{'critical_instructions'} = undef; + $module->{'warning_instructions'} = undef; + $module->{'unknown_instructions'} = undef; + $module->{'tags'} = undef; + $module->{'critical_inverse'} = undef; + $module->{'warning_inverse'} = undef; + $module->{'quiet'} = undef; + $module->{'module_ff_interval'} = undef; + $module->{'macros'} = {}; + $module->{'alert_template'} = undef; +} + +################################################################################ +# Generate a unique agent name. +################################################################################ +sub generate_agent_name { + return sha256(join('|', ($Conf{'agent_alias'}, $Conf{server_ip}, time(), sprintf("%04d", rand(10000))))); +} + +################################################################################ +# Set the value of a token in the configuration file. If the token does not +# exist, it is appended to the end of the file. +################################################################################ +sub config_update ($$) { + my ($token, $value) = @_; + + # Read the original configuration file. + open(my $fh, '<', "$ConfDir/$ConfFile") or die($!); + my @lines = <$fh>; + close ($fh); + + # Set the new value for the configuration token. + my $found = 0; + for(my $i = 0; $i < $#lines; $i++) { + if ($lines[$i] =~ m/[#\s]*$token/) { + $lines[$i] = "$token $value\n"; + $found = 1; + last; + } + } + + # Append the token to the end if it was not found in the file. + if ($found == 0) { + push(@lines, "$token $value\n"); + } + + # Write the changes to the configuration file. + open($fh, '>', "$ConfDir/$ConfFile") or die($!); + print $fh @lines; + close($fh); +} + +################################################################################ +# Get the eHorus key from the eHorus agent configuration file. +################################################################################ +sub get_ehkey { + my $fh; + + return '' unless defined($Conf{'ehorus_conf'}); + + # Open the eHorus configuration file. + if (!open($fh, '<', $Conf{'ehorus_conf'})) { + # Do not write to the log, since ehorus_conf points to the default eHorus configuration file by default. + return ''; + } + + # Look for the eHorus key. + while (my $line = <$fh>) { + + # Skip comments. + next if ($line =~ m/^\s*#/); + + if ($line =~ m/\s*eh_key\s+(\S+)/) { + my $eh_key = $1; + close($fh); + + return $eh_key; + } + } + + # Not found. + close($fh); + return ''; +} + +################################################################################ +# Main. +################################################################################ + +#Handler TERM signal. +$SIG{'TERM'} = \&kill_signal_handler; + +# Check command line arguments +print_usage unless ($#ARGV == 0); +$ConfDir = fix_directory ($ARGV[0]); +error ("Directory '$ConfDir' does not exist.") unless (-d "$ConfDir"); + +#Pandora home path +$ENV{'PANDORA_HOME'}=$ConfDir; + +# Get user to run as +my $pandora_user = read_config ('pandora_user'); +if (defined ($pandora_user)) { + # Change the EUID + my $pandora_user_uid = getpwnam ($pandora_user); + if (!defined ($pandora_user_uid)) { + error ("Cannot get uid for user $pandora_user. Does the user exist and can we read /etc/passwd?"); + } + $> = $pandora_user_uid; + if ($> != $pandora_user_uid) { + error ("Cannot run as $pandora_user: Insufficient permissions."); + } +} + +# Guess the OS version +$OS_VERSION = guess_os_version ($OS); + +# Start logging +start_log (); +log_message ('log', 'Running as user ' . getpwuid ($>)); + +# Read configuration file +read_config (); + +$ENV{'PANDORA_AGENT'}=$Conf{'agent_name'}; + +# Fix directory names +$Conf{'temporal'} = fix_directory ($Conf{'temporal'}); +error ("Temporal directory '" . $Conf{'temporal'} . "' does not exist.") unless (-d "$Conf{'temporal'}"); +$Conf{'server_path'} = fix_directory ($Conf{'server_path'}); +$Conf{'secondary_server_path'} = fix_directory ($Conf{'secondary_server_path'}); + +# Startup delay +log_message ('log', 'Sleeping for ' . $Conf{'delayed_startup'} . ' seconds.') if ($Conf{'delayed_startup'} > 0); +sleep ($Conf{'delayed_startup'}); + +#Set nice of the pandora_agent +my $PID = $$; +`renice "$Conf{'pandora_nice'}" "$PID"`; + +#Launch tentacle server in proxy mode if configured +if ($Conf{'proxy_mode'}) { + + #Check if user is root + if ($> != 0) { + launch_tentacle_proxy(); + } else { + log_message ('error', 'Proxy mode can not be launched as root'); + exit 1; + } +} + +# Add the plugins directory to the PATH +$ENV{'PATH'} .= ":$ConfDir/plugins"; + +# Start UDP server if configured +if ($Conf{'udp_server'} == 1){ + $udp_server_pid = fork(); + + if ($udp_server_pid == 0){ + $0 = 'udp_server (pandora_agent)'; + udp_server ($Conf{'udp_server_port'}, $Conf{'udp_server_auth_address'}); + exit; + } +} + +# Must be set to 0 if the agent is a broker agent +my $main_agent = -1; + +# base time to start eatch iteration with the same interval. +my $iter_base_time = time(); +$LogFileIdx = -1; +# Loop +while (1) { + if (-e $Conf{'logfile'} && (stat($Conf{'logfile'}))[7] > $Conf{'logsize'}) { + rotate_log(); + } + # Ignore signals from UDP and Tentacle server while processing execution + if ($Conf{'udp_server'} == 1 || $Conf{'proxy_mode'}){ + $SIG{'INT'} = 'DEFAULT'; + } + + # Check for a new configuration + check_remote_config () unless ($Conf{'debug'} eq '1'); + + # Check file collections + check_collections () unless ($Conf{'debug'} eq '1'); + + # Launch broker agents + @BrokerPid = (); + my @broker_agents = read_config ('broker_agent'); + foreach my $broker_agent (@broker_agents) { + + # Create broker conf file if it does not exist + if (! -e "$ConfDir/${broker_agent}.conf") { + write_broker_conf($broker_agent); + } + + $main_agent = fork (); + + # Broker agent + if ($main_agent == 0) { + + # Set the configuration file + $ConfFile = "${broker_agent}.conf"; + + # Log to a new file + stop_log (); + start_log ('quiet'); + + # Read configuration file + %Macros = (); + @Modules = (); + %Collections = (); + %Conf = %DefaultConf; + read_config (); + + $Conf{'agent_alias'} = $broker_agent; + # Check for a new configuration + check_remote_config () unless ($Conf{'debug'} eq '1'); + + # Check file collections + check_collections () unless ($Conf{'debug'} eq '1'); + + # Execute + last; + } else { + push (@BrokerPid, $main_agent); + } + } + + my $address; + + if(defined($Conf{'address'})) { + # Check if address is auto to get the local ip + if ($Conf{'address'} eq 'auto') { + my @address_list; + + if( -x "/bin/ip" || -x "/sbin/ip" || -x "/usr/sbin/ip" ) { + @address_list = `ip addr show 2>$DevNull | sed -e '/127.0.0/d' -e '/[0-9]*\\.[0-9]*\\.[0-9]*/!d' -e 's/^[ \\t]*\\([^ \\t]*\\)[ \\t]*\\([^ \\t]*\\)[ \\t].*/\\2/' -e 's/\\/.*//'`; + } + else { + @address_list = `ifconfig -a 2>$DevNull | sed -e '/127.0.0/d' -e '/[0-9]*\\.[0-9]*\\.[0-9]*/!d' -e 's/^[ \\t]*\\([^ \\t]*\\)[ \\t]*\\([^ \\t]*\\)[ \\t].*/\\2/' -e 's/.*://'`; + } + + for (my $i = 0; $i <= $#address_list; $i++) { + chomp($address_list[$i]); + if ($i > 0) { + $address .= ','; + } + + $address .= $address_list[$i]; + } + } + else { + $address = $Conf{'address'}; + } + } + + # Clear the XML + $Xml = ""; + + # Get the eHorus key. + my $eh_key = get_ehkey(); + + # Custom fields + my @customfieldskeys = keys(%Customfields); + if ($#customfieldskeys > -1 || $eh_key ne '') { + $Xml .= "\n"; + + foreach my $customfieldkey (@customfieldskeys) { + if($customfieldkey =~ m/^(custom_field\d+_)name/) { + if(defined($Customfields{$1."value"})) { + $Xml .= " \n"; + $Xml .= " \n"; + $Xml .= " \n"; + $Xml .= " \n"; + } + } + } + + # Add the eHorus key as a custom field. + if ($eh_key ne '') { + $Xml .= " \n"; + $Xml .= " eHorusID\n"; + $Xml .= " \n"; + $Xml .= " \n"; + } + + $Xml .= "\n"; + } + + # Execute modules + foreach my $module (@Modules) { + + # Execute the module in a separate thread + if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1) { + $ThreadSem->down (); + my $thr = threads->create (\&exec_module, $module); + if (! defined ($thr)) { + $ThreadSem->up (); + } else { + $thr->detach(); + } + # Execute the module + } else { + exec_module($module); + } + } + + # Wait for all the threads + $ThreadSem->down ($Conf{'agent_threads'}) if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1); + $ThreadSem->up ($Conf{'agent_threads'}) if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1); + + if ($Xml ne "" || $Conf{'timestamp'} + $Conf{'interval'} <= time ()) { + + # Update the time reference + $Conf{'timestamp'} = time () if ($Conf{'timestamp'} + $Conf{'interval'} <= time ()); + + # Compose the XML + my $xml_header = "\n" . + ""; + + # Save XML data file + my $temp_file = $Conf{'temporal'} . '/' . $Conf{'agent_name'} . '.' . time () . '.data'; + error ("File '$temp_file' already exists as a symlink and could not be removed: $!") if (-l $temp_file && !unlink($temp_file)); + open (TEMP_FILE, "> $temp_file") || error ("Could not write XML data file: $!"); + print TEMP_FILE $Xml; + close (TEMP_FILE); + + # Debug mode + if ($Conf{'debug'} eq '1') { + log_message ('debug', "Wrote XML data file '$temp_file'"); + log_message ('debug', "Wrote XML data file '$temp_file'", *STDOUT); + } + + # Send the XML data file + my $rc = send_file ($temp_file, 1); + if ($rc == 0 || $Conf{'xml_buffer'} == 0 || temporal_freedisk () < $Conf{'temporal_min_size'}) { + if ($Conf{'debug'} eq '1') { + rename $temp_file, $temp_file . "sent"; + } else { + unlink ($temp_file); + } + } + + # Send buffered XML data files + if ($Conf{'xml_buffer'} == 1) { + send_buffered_xml_files (); + } + } + + # Enable signal capture to break the Sleep interval on UDP signal + if ($Conf{'udp_server'} == 1) { + $SIG{'INT'} = \&udp_server_signal; + } + + # Sleep if main agent + if ($main_agent != 0) { + foreach my $broker_pid (@BrokerPid) { + waitpid ($broker_pid, 0); + } + + # Cron mode + last if ($Conf{'cron_mode'} == 1); + + $iter_base_time += $Conf{'intensive_interval'}; + my $now = time(); + + my $interval_remain = $iter_base_time - $now; + + if ($interval_remain >= 0) { + sleep ($interval_remain); + } else { + # don't sleep if iteraion took more than "intensive_interval" seconds + $iter_base_time = $now; # use current time as base time + } + } + # Finish if broker agent + else { + exit (0); + } +} + +__END__ + +=head1 EXIT STATUS + +=over + +=item 0 on Success + +=item 1 on Error + +=back + +=head1 CONFIGURATION + +By default pandora_agent uses F as B. There is the F file with all the configuration of the agent. + +=head1 DEPENDENCIES + + +=head1 LICENSE + +This is released under the GNU Lesser General Public License. + +=head1 SEE ALSO + + +=head1 COPYRIGHT + +Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L + +=cut diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 7be5c80d2e..71c275798f 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG -%define release 170411 +%define version 7.0NG.712 +%define release 170908 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.redhat.spec.orig b/pandora_agents/unix/pandora_agent.redhat.spec.orig new file mode 100644 index 0000000000..1c9bc88435 --- /dev/null +++ b/pandora_agents/unix/pandora_agent.redhat.spec.orig @@ -0,0 +1,145 @@ +# +#Pandora FMS Linux Agent +# +%define name pandorafms_agent_unix +%define version 7.0NG +<<<<<<< HEAD +%define release 170406 +======= +%define release 170418 +>>>>>>> develop + +Summary: Pandora FMS Linux agent, PERL version +Name: %{name} +Version: %{version} +Release: %{release} +License: GPL +Vendor: ArticaST +Source0: %{name}-%{version}.tar.gz +URL: http://pandorafms.org +Group: System/Monitoring +Packager: Sancho Lerena +Prefix: /usr/share +BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot +BuildArch: noarch +Requires(pre): shadow-utils +Requires(post): chkconfig /bin/ln +Requires(preun): chkconfig /bin/rm /usr/sbin/userdel +Requires: fileutils textutils unzip +Requires: util-linux procps grep +Requires: /sbin/ip /bin/awk +Requires: perl perl(Sys::Syslog) perl(IO::Socket::SSL) +# Required by plugins +#Requires: sh-utils sed passwd net-tools rpm +AutoReq: 0 +Provides: %{name}-%{version} + +%description +Pandora FMS agent for unix. Pandora FMS is an OpenSource full-featured monitoring software. + +%prep +rm -rf $RPM_BUILD_ROOT + +%setup -q -n unix + +%build + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT%{prefix}/pandora_agent/ +mkdir -p $RPM_BUILD_ROOT/usr/bin/ +mkdir -p $RPM_BUILD_ROOT/usr/sbin/ +mkdir -p $RPM_BUILD_ROOT/etc/pandora/ +mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d/ +mkdir -p $RPM_BUILD_ROOT/var/log/pandora/ +mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1/ +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/ +cp -aRf * $RPM_BUILD_ROOT%{prefix}/pandora_agent/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/tentacle_client $RPM_BUILD_ROOT/usr/bin/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent $RPM_BUILD_ROOT/usr/bin/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_exec $RPM_BUILD_ROOT/usr/bin/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_daemon $RPM_BUILD_ROOT/etc/rc.d/init.d/pandora_agent_daemon +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/pandora_agent.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/tentacle_client.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ + +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/Linux/pandora_agent.conf $RPM_BUILD_ROOT/usr/share/pandora_agent/pandora_agent.conf.rpmnew + +install -m 0644 pandora_agent_logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/pandora_agent + +if [ -f $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec ] ; then + rm $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec +fi + +%clean +rm -Rf $RPM_BUILD_ROOT + +%pre +getent passwd pandora >/dev/null || \ + /usr/sbin/useradd -d %{prefix}/pandora -s /bin/false -M -g 0 pandora +exit 0 +chown pandora:root /var/log/pandora + +%post +if [ ! -d /etc/pandora ] ; then + mkdir -p /etc/pandora +fi + +if [ ! -f /usr/share/pandora_agent/pandora_agent.conf ] ; then + cp /usr/share/pandora_agent/pandora_agent.conf.rpmnew /usr/share/pandora_agent/pandora_agent.conf +fi + +if [ ! -f /etc/pandora/pandora_agent.conf ] ; then + ln -s /usr/share/pandora_agent/pandora_agent.conf /etc/pandora/pandora_agent.conf +else + ln -s /usr/share/pandora_agent/pandora_agent.conf.rpmnew /etc/pandora/pandora_agent.conf.rpmnew +fi + +if [ ! -e /etc/pandora/plugins ]; then + ln -s /usr/share/pandora_agent/plugins /etc/pandora +fi + +if [ ! -e /etc/pandora/collections ]; then + ln -s /usr/share/pandora_agent/collections /etc/pandora +fi + +mkdir -p /var/spool/pandora/data_out +if [ ! -d /var/log/pandora ]; then + mkdir -p /var/log/pandora +fi +/sbin/chkconfig --add pandora_agent_daemon +/sbin/chkconfig pandora_agent_daemon on + +%preun + +# Upgrading +if [ "$1" = "1" ]; then + exit 0 +fi + +/sbin/chkconfig --del pandora_agent_daemon +/etc/rc.d/init.d/pandora_agent_daemon stop >/dev/null 2>&1 || : + +# Remove symbolic links +pushd /etc/pandora +for f in pandora_agent.conf plugins collections +do + [ -L $f ] && rm -f $f +done +exit 0 + +%files +%defattr(750,root,root) +/usr/bin/pandora_agent + +%defattr(755,pandora,root) +%{prefix}/pandora_agent + +%defattr(755,root,root) +/usr/bin/pandora_agent_exec +/usr/bin/tentacle_client +/etc/rc.d/init.d/pandora_agent_daemon + +%defattr(644,root,root) +/usr/share/man/man1/pandora_agent.1.gz +/usr/share/man/man1/tentacle_client.1.gz +%config(noreplace) %{_sysconfdir}/logrotate.d/pandora_agent diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index f4258ef94d..6ab308fc5c 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG -%define release 170411 +%define version 7.0NG.712 +%define release 170908 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec.orig b/pandora_agents/unix/pandora_agent.spec.orig new file mode 100644 index 0000000000..9fa4f46e9d --- /dev/null +++ b/pandora_agents/unix/pandora_agent.spec.orig @@ -0,0 +1,142 @@ +# +#Pandora FMS Linux Agent +# +%define name pandorafms_agent_unix +%define version 7.0NG +<<<<<<< HEAD +%define release 170406 +======= +%define release 170418 +>>>>>>> develop + +Summary: Pandora FMS Linux agent, PERL version +Name: %{name} +Version: %{version} +Release: %{release} +License: GPL +Vendor: ArticaST +Source0: %{name}-%{version}.tar.gz +URL: http://pandorafms.org +Group: System/Monitoring +Packager: Sancho Lerena +Prefix: /usr/share +BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot +BuildArch: noarch +PreReq: %fillup_prereq %insserv_prereq /usr/bin/sed /usr/bin/grep /usr/sbin/useradd +Requires: coreutils unzip perl +AutoReq: 0 +Provides: %{name}-%{version} + +%description +Pandora FMS agent for unix. Pandora FMS is an OpenSource full-featured monitoring software. + +%prep +rm -rf $RPM_BUILD_ROOT + +%setup -q -n unix + +%build + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT%{prefix}/pandora_agent/ +mkdir -p $RPM_BUILD_ROOT/usr/bin/ +mkdir -p $RPM_BUILD_ROOT/usr/sbin/ +mkdir -p $RPM_BUILD_ROOT/etc/pandora/ +mkdir -p $RPM_BUILD_ROOT/etc/init.d/ +mkdir -p $RPM_BUILD_ROOT/var/log/pandora/ +mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1/ +cp -aRf * $RPM_BUILD_ROOT%{prefix}/pandora_agent/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/tentacle_client $RPM_BUILD_ROOT/usr/bin/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent $RPM_BUILD_ROOT/usr/bin/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_exec $RPM_BUILD_ROOT/usr/bin/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_daemon $RPM_BUILD_ROOT/etc/init.d/pandora_agent_daemon +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_daemon $RPM_BUILD_ROOT/etc/init.d/pandora_agent_daemon +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/pandora_agent.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/tentacle_client.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ + +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/Linux/pandora_agent.conf $RPM_BUILD_ROOT/usr/share/pandora_agent/pandora_agent.conf.rpmnew + +#if [ -f $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec ] ; then +# rm $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec +#fi + +%clean +rm -Rf $RPM_BUILD_ROOT + +%pre +if [ "`id pandora | grep uid | wc -l`" = 0 ] +then + /usr/sbin/useradd -d %{prefix}/pandora -s /bin/false -M -g 0 pandora +fi + +%post +chown pandora:root /var/log/pandora +if [ ! -d /etc/pandora ] ; then + mkdir -p /etc/pandora +fi + +if [ ! -f /usr/share/pandora_agent/pandora_agent.conf ] ; then + cp /usr/share/pandora_agent/pandora_agent.conf.rpmnew /usr/share/pandora_agent/pandora_agent.conf +fi + +if [ ! -f /etc/pandora/pandora_agent.conf ] ; then + ln -s /usr/share/pandora_agent/pandora_agent.conf /etc/pandora/pandora_agent.conf +else + ln -s /usr/share/pandora_agent/pandora_agent.conf.rpmnew /etc/pandora/pandora_agent.conf.rpmnew +fi + +if [ ! -e /etc/pandora/plugins ]; then + ln -s /usr/share/pandora_agent/plugins /etc/pandora +fi + +if [ ! -e /etc/pandora/collections ]; then + ln -s /usr/share/pandora_agent/collections /etc/pandora +fi +cp -aRf /usr/share/pandora_agent/pandora_agent_logrotate /etc/logrotate.d/pandora_agent + +mkdir -p /var/spool/pandora/data_out +chkconfig pandora_agent_daemon on + +%preun + +# Upgrading +if [ "$1" = "1" ]; then + exit 0 +fi + +chkconfig --del pandora_agent_daemon +/etc/init.d/pandora_agent_daemon stop +rm /etc/init.d/pandora_agent_daemon +/usr/sbin/userdel pandora +rm -Rf /etc/pandora/pandora_agent.conf +rm -Rf /var/log/pandora/pandora_agent* 2> /dev/null +rm -Rf /usr/share/pandora_agent +rm -Rf /usr/share/man/man1/pandora_agent.1.gz +rm -Rf /usr/share/man/man1/tentacle_client.1.gz +exit 0 + +%postun + +# Upgrading +if [ "$1" = "1" ]; then + exit 0 +fi + +rm -Rf /etc/logrotate.d/pandora_agent + +%files +%defattr(750,pandora,root) +/usr/bin/pandora_agent +/usr/bin/pandora_agent_exec + +%defattr(755,pandora,root) +/usr/bin/tentacle_client +/etc/init.d/pandora_agent_daemon +%docdir %{prefix}/pandora_agents/docs +%{prefix}/pandora_agent + +%defattr(644,pandora,root) +/usr/share/man/man1/pandora_agent.1.gz +/usr/share/man/man1/tentacle_client.1.gz + diff --git a/pandora_agents/unix/pandora_agent_daemon b/pandora_agents/unix/pandora_agent_daemon index e813baad9b..ae48a57b4b 100755 --- a/pandora_agents/unix/pandora_agent_daemon +++ b/pandora_agents/unix/pandora_agent_daemon @@ -69,6 +69,9 @@ pidof_pandora () { break fi done + elif [ "$OS_NAME" = "AIX" ]; then + # AIX + PANDORA_PID=`ps -ef | grep "$DAEMON $PANDORA_PATH" | grep -v grep | awk '{ print $2 }'` else PANDORA_PID=`ps -Afw | grep "$DAEMON $PANDORA_PATH" | grep -v grep | awk '{ print $2 }'` fi diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 57635a8c54..d65123bfdd 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -9,8 +9,8 @@ # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG" -PI_BUILD="170411" +PI_VERSION="7.0NG.712" +PI_BUILD="170908" OS_NAME=`uname -s` FORCE=0 @@ -150,6 +150,13 @@ uninstall () { rm /Library/LaunchDaemons/com.pandorafms.pandorafms.plist 2> /dev/null fi + # Stops the agent on uninstall + if [ -f $PANDORA_BASE/etc/init.d/pandora_agent_daemon ]; then + $PANDORA_BASE/etc/init.d/pandora_agent_daemon stop 12> /dev/null + else + echo "$PANDORA_BASE/etc/init.d/pandora_agent_daemon not found to stop agent" + fi + echo "Removing Pandora FMS Agent..." rm -Rf $PANDORA_BASE$PANDORA_BIN 2> /dev/null rm -Rf $PANDORA_BASE$PANDORA_EXEC_BIN 2> /dev/null diff --git a/pandora_agents/unix/pandora_agent_installer.orig b/pandora_agents/unix/pandora_agent_installer.orig new file mode 100755 index 0000000000..580adf06dc --- /dev/null +++ b/pandora_agents/unix/pandora_agent_installer.orig @@ -0,0 +1,557 @@ +#!/bin/sh + +# ********************************************************************** +# Pandora FMS Agent Installer for Unix (generic installer) +# (c) 2008-2015 Artica ST +# (c) 2008-2010 Sancho Lerena +# +# This is a generic installer for all Unix-like systems.(AIX, HP-UX, SunOS, Linux, FreeBSD, NetBSD) +# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. +# ********************************************************************** + +PI_VERSION="7.0NG" +<<<<<<< HEAD +PI_BUILD="170406" +======= +PI_BUILD="170418" +>>>>>>> develop +OS_NAME=`uname -s` + +FORCE=0 +LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"` + +PREFIX=/usr +if [ "$OS_NAME" = "FreeBSD" ] || [ "$OS_NAME" = "NetBSD" ] +then + PREFIX=/usr/local +fi +PANDORA_HOME=$PREFIX/share/pandora_agent +PANDORA_BIN=$PREFIX/bin/pandora_agent +PANDORA_EXEC_BIN=$PREFIX/bin/pandora_agent_exec +PANDORA_REVENT_BIN=$PREFIX/bin/pandora_revent +PANDORA_TEMP=/var/spool/pandora +PANDORA_CFG=/etc/pandora +PANDORA_LOG_DIR=/var/log/pandora +PANDORA_LOG=pandora_agent.log +TENTACLE=$PREFIX/bin/tentacle_client +TENTACLE_SERVER=$PREFIX/bin/tentacle_server +PANDORA_MAN=$PREFIX/share/man +PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon +DAEMON_SCRIPT=pandora_agent_daemon +PANDORA_USER="root" +PANDORA_PERL_PATH="perl" +WITHOUT_TENTACLE_SERVER=0 +FAKEROOT=0 + +# defaults for each platforms +case $OS_NAME in +AIX) + PANDORA_STARTUP=/etc/rc.pandora_agent_daemon + ;; +HP-UX) + PANDORA_STARTUP=/sbin/init.d/pandora_agent_daemon + ;; +FreeBSD) + PANDORA_CFG=$PREFIX/etc/pandora + PANDORA_MAN=$PREFIX/man + PANDORA_STARTUP=$PREFIX/etc/rc.d/pandora_agent + DAEMON_SCRIPT=$OS_NAME/pandora_agent + PANDORA_PERL_PATH=/usr/local/bin/perl + ;; +NetBSD) + PANDORA_CFG=/usr/local/etc/pandora + PANDORA_STARTUP=/etc/rc.d/pandora_agent + DAEMON_SCRIPT=$OS_NAME/pandora_agent + PANDORA_PERL_PATH=/usr/pkg/bin/perl + ;; +esac + +MODE=$1 + +# options +while : +do + case "$2" in + "--no-tentacle-server") WITHOUT_TENTACLE_SERVER=1;; + "--fakeroot") FAKEROOT=1;; + *) break;; + esac + shift +done + +PANDORA_BASE=`echo $2 | sed -e 's|/$||'` +if [ "$3" != "" ] +then + PANDORA_USER=$3 + if [ -z "$PANDORA_BASE" ] + then + echo "When specifying a custom user the agent must be installed to a custom location where that user has write permissions!" + exit 1 + fi +fi + +[ "$4" ] && PANDORA_PERL_PATH=$4 + +# Check for Perl 5.6.x or higher available +PERL_VERSION=`$PANDORA_PERL_PATH -v | egrep 'v5.[6-9]|v5.[12][0-9]' | grep perl` + +if [ -z "$PERL_VERSION" ] +then + echo "Perl 5.6.x or higher is not detected. This is required for Pandora FMS" + echo "Detected: $PERL_VERSION " + echo "Aborting install..." + exit 2 +fi + +if [ -z "`echo Linux HP-UX SunOS AIX Solaris Darwin BSD bsd FreeBSD NetBSD | grep \"$OS_NAME\"`" ] +then + echo "This system: '$OS_NAME' is not supported by this script" + echo "Please make the install yourself as it's described in documentation" + exit 1 +fi + + +# check for root to do the install +if [ $FAKEROOT -ne 1 ] && [ -z "`id | grep \"uid=0(root)\"`" ] +then + echo "You need to be root to do the install. Please made a manual install" + echo "if you want to install Pandora FMS agent without root" + echo " " + echo "Aborting install" + exit 2 +fi + +help () { + echo "Syntax": + echo " " + echo " ./pandora_agent_installer < --mode > [ --option ] [ destination_path ] [ user_to_run_as ] [custom_perl_path]" + echo " " + echo "Modes:" + echo " " + echo " --force-install To force installation if already installed on system" + echo " --install To install Pandora FMS Agent on this system" + echo " --uninstall To uninstall/remove Pandora FMS Agent on this System" + echo " " + echo "Option:" + echo " " + echo " --no-tentacle-server Skip tentacle server installation (by default tentalce server installed)" + echo " --fakeroot treate \"destination_path\" as root directory" + echo " " + echo "Some exaples of how to use the installer:" + echo " " + echo " ./pandora_agent_installer --install" + echo " ./pandora_agent_installer --install /opt/pandora" + echo " ./pandora_agent_installer --install \"\" pandora" + echo " ./pandora_agent_installer --install /opt/pandora root /opt/pandora/perl5/usr/local/bin/perl" + echo " ./pandora_agent_installer --uninstall /opt/pandora" + echo " " +} + +uninstall () { + if [ "$OS_NAME" = "Darwin" ] + then + launchctl remove com.pandorafms.pandorafms + rm /Library/LaunchDaemons/com.pandorafms.pandorafms.plist 2> /dev/null + fi + + echo "Removing Pandora FMS Agent..." + rm -Rf $PANDORA_BASE$PANDORA_BIN 2> /dev/null + rm -Rf $PANDORA_BASE$PANDORA_EXEC_BIN 2> /dev/null + rm -Rf $PANDORA_BASE$PANDORA_REVENT_BIN 2> /dev/null + rm -f $DESTDIR/etc/logrotate.d/pandora_agent + + #Test if exist Pandora Server in this machine + if [ -d $PANDORA_BASE$PANDORA_TEMP/data_in ] + then + echo "You have a Pandora Server in this machine. Then don't delete "$PANDORA_TEMP + rm -Rf $PANDORA_BASE$PANDORA_TEMP/data_out 2> /dev/null + else + rm -Rf $PANDORA_BASE$PANDORA_TEMP 2> /dev/null + rm -Rf $PANDORA_BASE$TENTACLE_SERVER 2> /dev/null + fi + rm -Rf $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf 2> /dev/null + + rm -Rf $PANDORA_BASE/etc/init.d/pandora_agent_daemon 2> /dev/null + rm -Rf $PANDORA_BASE/sbin/init.d/pandora_agent_daemon 2> /dev/null + rm -Rf $PANDORA_BASE/etc/rc.pandora_agent_daemon 2> /dev/null + rm -Rf $PANDORA_BASE/etc/rc?.d/S90pandora_agent_daemon 2> /dev/null + rm -Rf $PANDORA_BASE/sbin/rc?.d/S90pandora_agent_daemon 2> /dev/null + rm -Rf $PANDORA_BASE/etc/rc?.d/S90pandora_agent 2> /dev/null + rm -Rf $PANDORA_BASE/sbin/rc?.d/S90pandora_agent 2> /dev/null + rm -Rf $PANDORA_BASE/etc/rc.d/rc?.d/S90pandora_agent_daemon 2> /dev/null + rm -Rf $PANDORA_BASE/etc/rc.d/rc?.d/S90pandora_agent 2> /dev/null + rm -Rf $PANDORA_BASE/usr/local/etc/rc.d/pandora_agent 2> /dev/null + if [ $FAKEROOT -ne 1 ] + then + rm -Rf /etc/init.d/pandora_agent_daemon 2> /dev/null + rm -Rf /sbin/init.d/pandora_agent_daemon 2> /dev/null + rm -Rf /etc/rc.pandora_agent_daemon 2> /dev/null + rm -Rf /etc/rc?.d/S90pandora_agent_daemon 2> /dev/null + rm -Rf /sbin/rc?.d/S90pandora_agent_daemon 2> /dev/null + rm -Rf /etc/rc?.d/S90pandora_agent 2> /dev/null + rm -Rf /sbin/rc?.d/S90pandora_agent 2> /dev/null + rm -Rf /etc/rc.d/rc?.d/S90pandora_agent_daemon 2> /dev/null + rm -Rf /etc/rc.d/rc?.d/S90pandora_agent 2> /dev/null + rm -Rf /usr/local/etc/rc.d/pandora_agent 2> /dev/null + fi + + rm -Rf $PANDORA_BASE$PANDORA_HOME 2> /dev/null + rm -Rf $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG 2> /dev/null + rm -Rf $PANDORA_BASE$TENTACLE 2> /dev/null + + rm -Rf $PANDORA_BASE$PANDORA_MAN/{man1,cat1}/tentacle_client.1.gz 2> /dev/null + rm -Rf $PANDORA_BASE$PANDORA_MAN/{man1,cat1}/pandora_agent.1.gz 2> /dev/null + + # Skip delete of /etc/pandora if exists configuration of a server or satellite + if [ ! -f $PANDORA_BASE/$PANDORA_CFG/pandora_server.conf -a ! -f $PANDORA_BASE/$PANDORA_CFG/satellite_server.conf ] + then + rm -Rf $PANDORA_BASE/$PANDORA_CFG 2> /dev/null + fi + + if [ ! -z "$PANDORA_BASE" ] + then + echo "Please delete manually $PANDORA_BASE for complete uninstall" + fi + + echo " " + echo "Done" +} + +# +# install_perl_script [OPTIONS] SRCFILE DESTFILE +# Install perl script. If PANDORA_PERL_DECODED_PATH is set, path of the perl +# in shebang line is replaced with PANDORA_PERL_DECODED_PATH value. +# OPTIONS: +# -o OWNER owner of the installed script +# -g GROUP group of the installed script +# -m PREM mode of the installed script +# +install_perl_script () { + OWNER=""; GROUP=""; PERM="" + while : + do + case $1 in + -o) OWNER=$2;; + -g) GROUP=$2;; + -m) PERM=$2;; + *) break;; + esac + shift;shift + done + SRC="$1" + DEST="$2" + + # do install + if echo $PANDORA_PERL_PATH | grep "/" > /dev/null && [ "$PANDORA_PERL_PATH" != "/usr/bin/perl" ] + then + sed -e "s:^#\!.*:#\!$PANDORA_PERL_PATH:g" $SRC > $DEST + else + cp $SRC $DEST + fi + + # set owner, group and permissions + [ "$OWNER" ] && chown $OWNER $DEST 2>/dev/null + [ "$GROUP" ] && chgrp $GROUP $DEST 2>/dev/null + [ "$PERM" ] && chmod $PERM $DEST +} + +install () { + OS_VERSION=`uname -r` + OLDFILENAMETMP=`date +"%Y-%m-%d"` + + echo "Detecting Unix distribution: $OS_NAME version $OS_VERSION" + if [ -f $PANDORA_BASE$PANDORA_HOME ] && [ "$FORCE" = "0" ] + then + echo "Seems that default dir already exists. Please use --force-install to" + echo "force installer to install on $PANDORA_BASE$PANDORA_HOME" + exit + else + echo "Checking default dir $PANDORA_BASE$PANDORA_HOME..." + fi + + if [ -f $PANDORA_BASE$PANDORA_BIN ] && [ "$FORCE" = "0" ] + then + echo "Seems that $PANDORA_BASE$PANDORA_BIN already exists. Please use --force-install to" + echo "force installer to reinstall overwriting it" + echo " " + exit + else + echo "Checking Pandora FMS Agent on $PANDORA_BASE$PANDORA_BIN...." + fi + + # Alter dynamically the daemon launcher and setup the new path + # if PANDORA_BASE is customized. + if [ "$PANDORA_BASE" ] && [ $FAKEROOT -ne 1 ] + then + DAEMON_TEMP=pandora_agent_daemon_temp + + # Backup the daemon script + cp -f "$DAEMON_SCRIPT" "${DAEMON_SCRIPT}.bak" + + AGENT_CFG=$OS_NAME/pandora_agent.conf + AGENT_CFG_TEMP=$OS_NAME/pandora_agent.conf.temp + + # Backup the configuration file + cp -f "$AGENT_CFG" "${AGENT_CFG}.bak" + + if [ "$OS_NAME" = "FreeBSD" ] || [ "$OS_NAME" = "NetBSD" ] + then + sed -e "\|^PATH=|s|=|=$PANDORA_BASE$PREFIX/bin:|" \ + -e "s|/usr/local/etc/pandora|$PANDORA_BASE$PANDORA_CFG|g" \ + -e "s|/usr/local/bin/pandora_agent|$PANDORA_BASE$PANDORA_BIN|g" \ + $DAEMON_SCRIPT > $DAEMON_TEMP + mv $DAEMON_TEMP $DAEMON_SCRIPT + else + sed -e "\|^PATH=|s|=|=$PANDORA_BASE/usr/bin:|" \ + -e "\|^PANDORA_PATH=|s|=|=$PANDORA_BASE|" \ + -e "\|^LOGFILE=|s|=|=$PANDORA_BASE|" \ + -e "\|^DAEMON=|s|=|=$PANDORA_BASE|" \ + -e "\|^DAEMON_TENTACLE=|s|=|=$PANDORA_BASE|" \ + -e "s/^PANDORA_USER=.*/PANDORA_USER=$PANDORA_USER/" \ + $DAEMON_SCRIPT > $DAEMON_TEMP + mv $DAEMON_TEMP $DAEMON_SCRIPT + fi + + sed -e "s|^temporal[ \t][ \t]*|temporal $PANDORA_BASE|" \ + -e "s|^logfile[ \t][ \t]*|logfile $PANDORA_BASE|" \ + $AGENT_CFG > $AGENT_CFG_TEMP + mv $AGENT_CFG_TEMP $AGENT_CFG + fi + echo "Creating Pandora FMS Agent home directory at $PANDORA_BASE$PANDORA_HOME" + if [ "$PANDORA_BASE" ] + then + mkdir -p $PANDORA_BASE 2> /dev/null + mkdir -p $PANDORA_BASE/var/log 2> /dev/null + mkdir -p $PANDORA_BASE/$PANDORA_MAN/man1 2> /dev/null + mkdir -p $PANDORA_BASE$PREFIX/bin 2> /dev/null + fi + + mkdir -p $PANDORA_BASE$PANDORA_HOME 2> /dev/null + + # Create directories based on PANDORA_BASE + + mkdir -p $PANDORA_BASE/tmp 2> /dev/null + mkdir -p $PANDORA_BASE$PANDORA_TEMP/data_out 2> /dev/null + mkdir -p $PANDORA_BASE$PANDORA_CFG 2> /dev/null + mkdir -p $PANDORA_BASE$PANDORA_LOG_DIR 2> /dev/null + + # Set the user the agent will run as + if [ "$PANDORA_USER" != "root" ] + then + sed -e "s/.*pandora_user .*/pandora_user $PANDORA_USER/" $AGENT_CFG > $AGENT_CFG_TEMP 2> /dev/null && \ + mv $AGENT_CFG_TEMP $AGENT_CFG + chmod 755 pandora_agent_daemon + chown -R $PANDORA_USER $PANDORA_BASE 2>/dev/null + fi + + # Create logfile + if [ ! -z "`touch $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG`" ] + then + echo "Seems to be a problem generating logfile ($PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG) please check it"; + else + echo "Created logfile at $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG..." + fi + echo "$LOG_TIMESTAMP Pandora FMS installer has created this file at startup" > $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG + + # Copying agent and securing it + echo "Copying Pandora FMS Agent to $PANDORA_BASE$PANDORA_BIN..." + install_perl_script -m 755 -o $PANDORA_USER -g 0 pandora_agent $PANDORA_BASE$PANDORA_BIN + install_perl_script -m 755 -o $PANDORA_USER -g 0 pandora_agent_exec $PANDORA_BASE$PANDORA_EXEC_BIN + install_perl_script -m 755 -o $PANDORA_USER -g 0 pandora_revent $PANDORA_BASE$PANDORA_REVENT_BIN + + echo "Copying Pandora FMS Agent configuration file to $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf..." + if [ -f $PANDORA_BASE/$PANDORA_CFG/pandora_agent.conf ] + then + cp $PANDORA_BASE/$PANDORA_CFG/pandora_agent.conf $PANDORA_BASE/$PANDORA_CFG/pandora_agent.conf.$OLDFILENAMETMP + echo "Backing up old configuration file to $PANDORA_BASE/$PANDORA_CFG/pandora_agent.conf.$OLDFILENAMETMP" + fi + + echo "Copying Pandora FMS Agent plugins to $PANDORA_BASE$PANDORA_HOME/plugins..." + + [ -d $PANDORA_BASE$PANDORA_HOME/plugins ] || mkdir -p $PANDORA_BASE$PANDORA_HOME/plugins >/dev/null 2>&1 + for PLUGIN in plugins/* + do + if grep '^#!.*/perl' $PLUGIN >/dev/null 2>&1 + then + install_perl_script $PLUGIN $PANDORA_BASE$PANDORA_HOME/$PLUGIN + else + cp $PLUGIN $PANDORA_BASE$PANDORA_HOME/plugins + fi + done + chmod -R 700 $PANDORA_BASE$PANDORA_HOME/plugins + + PANDORA_BASE_REAL="$PANDORA_BASE" + [ $FAKEROOT -eq 1 ] && PANDORA_BASE_REAL="" + + ln -s $PANDORA_BASE_REAL$PANDORA_HOME/plugins $PANDORA_BASE$PANDORA_CFG + + echo "Copying Pandora FMS Agent collections to $PANDORA_BASE$PANDORA_HOME/collections..." + cp -r collections $PANDORA_BASE$PANDORA_HOME + chmod -R 700 $PANDORA_BASE$PANDORA_HOME/collections + ln -s $PANDORA_BASE_REAL$PANDORA_HOME/collections $PANDORA_BASE$PANDORA_CFG + + if [ $WITHOUT_TENTACLE_SERVER -eq 0 ] + then + echo "Copying tentacle server to $PANDORA_BASE$TENTACLE_SERVER" + install_perl_script -m 755 -o $PANDORA_USER -g 0 tentacle_server $PANDORA_BASE$TENTACLE_SERVER + fi + + echo "Copying tentacle client to $PANDORA_BASE$TENTACLE" + install_perl_script -m 755 -o $PANDORA_USER -g 0 tentacle_client $PANDORA_BASE$TENTACLE + + echo "Installing the Pandora Agent and Tentacle Client manuals" + cp man/man1/tentacle_client.1.gz $PANDORA_BASE/$PANDORA_MAN/man1 + chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/tentacle_client.1.gz + cp man/man1/pandora_agent.1.gz $PANDORA_BASE/$PANDORA_MAN/man1 + chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/pandora_agent.1.gz + + echo "Setting secure permissions and ownership for all Pandora FMS Agent files..." + chown -R $PANDORA_USER $PANDORA_BASE$PANDORA_HOME 2>/dev/null + chmod -R 700 $PANDORA_BASE$PANDORA_TEMP/data_out + chmod 711 $PANDORA_BASE$PANDORA_LOG_DIR + chmod 640 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG + chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG 2>/dev/null + if [ "$OS_NAME" = "FreeBSD" ] || [ "$OS_NAME" = "NetBSD" ] + then + chown $PANDORA_USER:daemon $PANDORA_BASE$PANDORA_TEMP 2>/dev/null + chmod -R 770 $PANDORA_BASE$PANDORA_TEMP + chmod 775 $PANDORA_BASE$PANDORA_TEMP + fi + + echo "Copying default agent configuration to $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf" + + cp $OS_NAME/pandora_agent.conf $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf + chmod 600 $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf + chown $PANDORA_USER $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf 2>/dev/null + + echo "Linking start-up daemon script '$DAEMON_SCRIPT' on $OS_NAME"; + + if [ "$OS_NAME" = "Darwin" ] + then + # Specific service install on Darwin/macOSX + launchctl load -F Darwin/com.pandorafms.pandorafms.plist + echo "Start Pandora FMS service with 'launchctl start com.pandorafms.pandorafms'" + echo "This service has been scheduled to launch on each system startup" + else + DESTDIR="" + [ "$PANDORA_BASE" ] && [ $FAKEROOT -eq 1 ] && DESTDIR=$PANDORA_BASE + + cp $DAEMON_SCRIPT $DESTDIR$PANDORA_STARTUP + chmod 755 $DESTDIR$PANDORA_STARTUP + chown root:0 $DESTDIR$PANDORA_STARTUP 2>/dev/null + + RCDIRS="" + MSG="" + if [ "$OS_NAME" = "AIX" ] + then + RCDIRS=/etc/rc.d/rc2.d + MSG="Pandora FMS agent has been included in $DESTDIR/etc/rc.d/rc2.d/S90pandora_agent_daemon" + elif [ "$OS_NAME" = "HP-UX" ] + then + RCDIRS="/sbin/rc2.d /sbin/rc3.d" + MSG="Pandora FMS agent has been included in $DESTDIR/sbin/rcX.d/S90pandora_agent_daemon" + elif [ "$OS_NAME" = "SunOS" ] + then + RCDIRS=/etc/rc2.d + MSG="Pandora FMS agent has been included in $DESTDIR/etc/rc2.d/S90pandora_agent_daemon" + elif [ "$OS_NAME" = "Linux" ] + then + if [ -d /etc/rc.d/ ] + then + RCDIRS="/etc/rc.d/rc2.d /etc/rc.d/rc3.d" + else + RCDIRS="/etc/rc2.d /etc/rc3.d" + fi + fi + [ "$RCDIRS" ] && for RCDIR in $RCDIRS + do + [ $FAKEROOT -eq 1 ] && [ ! -d $DESTDIR$RCDIR ] && mkdir -p $DESTDIR$RCDIR >/dev/null 2>&1 + ln -s $PANDORA_STARTUP $DESTDIR$RCDIR/S90pandora_agent 2> /dev/null + done + [ "$MSG" ] && echo "$MSG" + fi + + if [ -d /etc/logrotate.d ] + then + [ -d $DESTDIR/etc/logrotate.d ] && mkdir -p $DESTDIR/etc/logrotate.d + echo "Creating logrotate.d entry for Pandora FMS log management" + sed -e "s|^/var/log/pandora/pandora_agent.log|$PANDORA_BASE_REAL$PANDORA_LOG_DIR/$PANDORA_LOG|" pandora_agent_logrotate \ + > $DESTDIR/etc/logrotate.d/pandora_agent + else + echo "Please add a log rotation schedule manually to your log rotation daemon (if any)" + fi + + echo "Done." + echo " " + echo "You have your startup script ready at $PANDORA_STARTUP" + echo " " + echo "Tentacle is the default transfer mode since 2.0 version." + echo " " + echo "If you want to use SSH, firstly you need to copy your public SSH keys " + echo " ($HOME/.ssh/id_dsa) under /home/pandora/.ssh/authorized_keys " + echo "on your Pandora FMS Server host" + echo " " + echo "You may need to install manually some additional required dependencies:" + echo "perl-Sys-Syslog" + echo " " + echo "You also need to setup your $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf config file" + echo " " + if [ "$OS_NAME" = "FreeBSD" ] + then + echo "Define 'pandora_agent_enable=\"YES\"' in /etc/rc.conf to enable the daemon." + elif [ "$OS_NAME" = "NetBSD" ] + then + echo "Define 'pandora_agent=\"YES\"' in /etc/rc.conf to enable the daemon." + else + echo "Check your startup configuration to be sure Pandora FMS Agent is ready " + echo "to start automatically when system restarts": + fi + + # Restore the daemon script + cp -f "$DAEMON_SCRIPT.bak" "$DAEMON_SCRIPT" >/dev/null 2>&1 + rm -f "$DAEMON_SCRIPT.bak" >/dev/null 2>&1 + + # Restore the configuration file + cp -f "$AGENT_CFG.bak" "$AGENT_CFG" >/dev/null 2>&1 + rm -f "$AGENT_CFG.bak" >/dev/null 2>&1 + +} + +if [ ! -f "pandora_agent" ] +then + echo " " + echo "Execute installer from the directory where you have your files. " + help + exit 1 +fi + +# Script banner at start +echo " " +echo "Pandora FMS Agent UNIX Installer $PI_VERSION $PI_BUILD (c) 2008-2015 ArticaST" +echo "This program is licensed under GPL2 Terms. http://pandorafms.com" +echo " " + + +case "$MODE" in + +'--force-install') + FORCE=1 + install + exit + ;; + +'--install') + install + exit + ;; + +'--uninstall') + uninstall + exit + ;; + +*) + help + ;; +esac + diff --git a/pandora_agents/unix/pandora_revent b/pandora_agents/unix/pandora_revent index 29e032d9cf..3af581decb 100755 --- a/pandora_agents/unix/pandora_revent +++ b/pandora_agents/unix/pandora_revent @@ -1,17 +1,20 @@ #!/usr/bin/perl -############################################################################### +######################################################################## # Pandora FMS - Remote Event Tool (via WEB API) -############################################################################### +######################################################################## # Copyright (c) 2013 Artica Soluciones Tecnologicas S.L # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License version 2 -############################################################################### +######################################################################## # Includes list use strict; use LWP::Simple; +use MIME::Base64; +use lib '/usr/lib/perl5'; +use PandoraFMS::Tools; # Init tool_api_init(); @@ -19,72 +22,76 @@ tool_api_init(); # Main tool_api_main(); -############################################################################## +######################################################################## # Print a help screen and exit. -############################################################################## +######################################################################## sub help_screen{ print "Options to create event: -\t$0 -p -create event +\t$0 -p -u -create_event Where options:\n - -u - -create_event - -name : Free text - -group : Group ID (use 0 for 'all') - -type : unknown, alert_fired, alert_recovered, alert_ceased - alert_manual_validation, system, error, new_agent - configuration_change, going_unknown, going_down_critical, - going_down_warning, going_up_normal + -u : API credentials separated by comma: ,, + -name : Free text + -group : Group ID (use 0 for 'all') + -agent : Agent ID Optional parameters: - [-agent ] : Agent ID - [-user ] : User comment (use in combination with -comment option) - [-status ] : 0 New, 1 Validated, 2 In process - [-am ] : ID Agent Module linked to event - [-alert ] : ID Alert Module linked to event - [-criticity ] : 0 Maintance, 1 Informative, 2 Normal, - 3 Warning, 4 Crit, 5 Minor, 6 Major + [-status ] : 0 New, 1 Validated, 2 In process + [-user ] : User comment (use in combination with -comment option) + [-type ] : unknown, alert_fired, alert_recovered, alert_ceased + alert_manual_validation, system, error, new_agent + configuration_change, going_unknown, going_down_critical, + going_down_warning, going_up_normal + [-severity ] : 0 Maintance, + 1 Informative, + 2 Normal, + 3 Warning, + 4 Crit, + 5 Minor, + 6 Major + [-am ] : ID Agent Module linked to event + [-alert ] : ID Alert Module linked to event + [-c_instructions ] + [-w_instructions ] + [-u_instructions ] + [-user_comment ] + [-owner_user ] : Use the login name, not the descriptive + [-source ] : (By default 'Pandora') + [-tag ] : Tag (must exist in the system to be imported) + [-custom_data ]: Custom data has to be in JSON format. Example: -custom_data \'{\"test1\" : \"t1\", \"test2\": \"2\"}\' + [-id_extra ] : Id extra + [-agent_name ] : Agent name, Not to be confused with the alias. + [-force_create_agent<0 o 1>]: Force the creation of agent through an event this will create when it is 1. + [-server_id ] : The pandora node server_id\n\n"; - [-comment ] : Free text for comment - [-tag ] : Tag (must exist in the system to be imported) - [-source ] : (By default 'Pandora') - [-c_instructions ] - [-w_instructions ] - [-u_instructions ] - [-owner ] : Use the login name, not the descriptive \n\n"; - - print "Credential/API syntax: \n\n\t"; - print ": API credentials separated by comma: ,,\n\n"; - print "Example of event generation:\n\n"; - - print "\t$0 -p http://192.168.70.160/pandora_console/include/api.php -u pot12,admin,pandora \ -\t-create_event -name \"Sample event executed from commandline\" -group 2 -type \"system\" -agent 2 \ -\t-user \"admin\" -status 0 -am 0 -alert 9 -criticity 3 -comment \"User comments\" -tag \"tags\" \ -\t-source \"Commandline\" -c_instructions \"Critical instructions\" \ -\t-w_instructions \"Warning instructions\" -u_instructions \"Unknown instructions\" -owner \"other\" "; - - print "\n\nOptions to validate event: \n\n\t"; - print "$0 -p -u -validate_event -id \n\n"; - print "Sample of event validation: \n\n\t"; - - print "$0 -p http://localhost/pandora/include/api.php -u pot12,admin,pandora -validate_event -id 234"; - print "\n\n\n"; - exit; + + print "\t./pandora_revent.pl -p http://localhost/pandora_console/include/api.php -u 1234,admin,pandora \ + \t-create_event -name \"SampleEvent\" -group 2 -agent 189 -status 0 -user \"admin\" -type \"system\" \ + \t-severity 3 -am 0 -alert 9 -c_instructions \"Critical instructions\" -w_instructions \"Warning instructions\" \ + \t-u_instructions \"Unknown instructions\" -id_extra \"id extra\" -agent_name \"agent name\" -source \"Commandline\" -tag \"Tags\""; + + print "\n\n\nOptions to validate event: \n\n\t"; + print "$0 -p -u -validate_event -id \n\n"; + print "Sample of event validation: \n\n\t"; + + print "$0 -p http://localhost/pandora/include/api.php -u pot12,admin,pandora -validate_event -id 234"; + print "\n\n\n"; + exit; } ############################################################################## # Init screen ############################################################################## sub tool_api_init () { - - print "\nPandora FMS Remote Event Tool Copyright (c) 2015 Artica ST\n"; + + print "\nPandora FMS Remote Event Tool Copyright (c) 2013-2015 Artica ST\n"; print "This program is Free Software, licensed under the terms of GPL License v2\n"; print "You can download latest versions and documentation at http://www.pandorafms.org\n\n"; - + if ($#ARGV < 0) { help_screen(); } @@ -92,14 +99,14 @@ sub tool_api_init () { if (($ARGV[0] eq '-h') || ($ARGV[0] eq '-help')) { help_screen(); } - + } -############################################################################### -############################################################################### +######################################################################## +######################################################################## # MAIN -############################################################################### -############################################################################### +######################################################################## +######################################################################## sub tool_api_main () { @@ -114,33 +121,37 @@ sub tool_api_main () { my $db_pass; my @db_info; my $id_agent; - my $agent_name; my $id_user = ''; my $status = ''; my $id_agent_module = ''; - my $module_name = ''; my $id_alert_am = ''; - my $criticity = ''; + my $severity = ''; my $user_comment = ''; my $tags = ''; my $source = ''; - my $id_extra = ''; my $critical_instructions = ''; my $warning_instructions = ''; my $unknown_instructions = ''; + my $id_extra = ''; + my $agent_name = ''; + my $force_create_agent = 0; my $owner_user = ''; my $id_event; my $option = $ARGV[4]; my $call_api; - + my $custom_data = ""; + my $server_id = 0; + #~ help or api path (required) if ($ARGV[0] eq '-h') { print "HELP!\n"; help_screen(); - } elsif ($ARGV[0] ne '-p') { + } + elsif ($ARGV[0] ne '-p') { print "[ERROR] Missing API path! Read help info:\n\n"; help_screen (); - } else { + } + else { $api_path = $ARGV[1]; } @@ -152,105 +163,149 @@ sub tool_api_main () { if ($#db_info < 2) { print "[ERROR] Invalid database credentials! Read help info:\n\n"; help_screen(); - } else { + } + else { $api_pass = $db_info[0]; $db_user = $db_info[1]; $db_pass = $db_info[2]; } - } else { + } + else { print "[ERROR] Missing database credentials! Read help info:\n\n"; help_screen (); } if ($ARGV[4] eq '-create_event') { - #~ event name (required) - if ($ARGV[5] ne '-name') { - print "[ERROR] Missing event name! Read help info:\n\n"; - help_screen (); - } else { - $event_name = $ARGV[6]; - } - - #~ id group (required) - if ($ARGV[7] ne '-group') { - print "[ERROR] Missing event group! Read help info:\n\n"; - help_screen (); - } else { - $id_group = $ARGV[8]; - } - - #~ id group (required) - if ($ARGV[9] ne '-type') { - print "[ERROR] Missing event type! Read help info:\n\n"; - help_screen (); - } else { - $event_type = $ARGV[10]; - } - - # -agent_name, -module_name and -extra are not supported by api. Maybe in the future my $i = 0; foreach (@ARGV) { my $line = $_; + + #-----------DEBUG---------------------------- + #print("i " . $i . " line " . $line . "\n"); + if ($line eq '-agent') { - $id_agent = $ARGV[$i+1]; + $id_agent = $ARGV[$i + 1]; } - if ($line eq '-agent_name') { - $agent_name = $ARGV[$i+1]; + if ($line eq '-group') { + $id_group = $ARGV[$i + 1]; + } + if ($line eq '-name') { + $event_name = $ARGV[$i + 1]; + } + if ($line eq '-type') { + $event_type = $ARGV[$i + 1]; } if ($line eq '-user') { - $id_user = $ARGV[$i+1]; + $id_user = $ARGV[$i + 1]; } if ($line eq '-status') { - $status = $ARGV[$i+1]; + $status = $ARGV[$i + 1]; } if ($line eq '-am') { - $id_agent_module = $ARGV[$i+1]; - } - if ($line eq '-module_name') { - $module_name = $ARGV[$i+1]; + $id_agent_module = $ARGV[$i + 1]; } if ($line eq '-alert') { - $id_alert_am = $ARGV[$i+1]; + $id_alert_am = $ARGV[$i + 1]; } - if ($line eq '-criticity') { - $criticity = $ARGV[$i+1]; - } - if ($line eq '-comment') { - $user_comment = $ARGV[$i+1]; + if ($line eq '-severity') { + $severity = $ARGV[$i + 1]; } if ($line eq '-tag') { - $tags = $ARGV[$i+1]; + $tags = $ARGV[$i + 1]; } if ($line eq '-source') { - $source = $ARGV[$i+1]; - } - if ($line eq '-extra') { - $id_extra = $ARGV[$i+1]; + $source = $ARGV[$i + 1]; } if ($line eq '-c_instructions') { - $critical_instructions = $ARGV[$i+1]; + $critical_instructions = $ARGV[$i + 1]; + $critical_instructions = uri_encode($critical_instructions); } if ($line eq '-w_instructions') { - $warning_instructions = $ARGV[$i+1]; + $warning_instructions = $ARGV[$i + 1]; + $warning_instructions = uri_encode($warning_instructions); } if ($line eq '-u_instructions') { - $unknown_instructions = $ARGV[$i+1]; + $unknown_instructions = $ARGV[$i + 1]; + $unknown_instructions = uri_encode($unknown_instructions); } - if ($line eq '-owner') { - $owner_user = $ARGV[$i+1]; + if ($line eq '-id_extra') { + $id_extra = $ARGV[$i + 1]; } + if ($line eq '-agent_name') { + $agent_name = $ARGV[$i + 1]; + } + if ($line eq '-force_create_agent') { + $force_create_agent = $ARGV[$i + 1]; + } + if ($line eq '-user_comment') { + $user_comment = $ARGV[$i + 1]; + } + if ($line eq '-owner_user') { + $owner_user = $ARGV[$i + 1]; + } + if ($line eq '-custom_data') { + $custom_data = $ARGV[$i + 1]; + $custom_data = encode_base64($custom_data, ''); + } + if ($line eq '-server_id') { + $server_id = $ARGV[$i + 1]; + } + $i++; } - $data_event .= $event_name.",".$id_group.",".$id_agent.",".$status.",".$id_user.",".$event_type.",".$criticity.",".$id_agent_module.",".$id_alert_am.",".$critical_instructions.",".$warning_instructions.",".$unknown_instructions.",".$user_comment.",".$owner_user.",".$source.",".$tags.","; - $call_api = $api_path.'?op=set&op2=create_event&id='.$event_name.'&other='.$data_event.'&other_mode=url_encode_separator_,&apipass='.$api_pass.'&user='.$db_user.'&pass='.$db_pass; + if ($event_name eq "") { + print "[ERROR] Missing id agent! Read help info:\n\n"; + help_screen (); + } + if ($id_group eq "") { + print "[ERROR] Missing event group! Read help info:\n\n"; + help_screen (); + } + if ($id_agent eq "" && $agent_name eq "") { + print "[ERROR] Missing id agent! and agent_name Read help info:\n\n"; + help_screen (); + } + + $data_event = $event_name . + "|" . $id_group . + "|" . $id_agent . + "|" . $status . + "|" . $id_user . + "|" . $event_type . + "|" . $severity . + "|" . $id_agent_module . + "|" . $id_alert_am . + "|" . $critical_instructions . + "|" . $warning_instructions . + "|" . $unknown_instructions . + "|" . $user_comment . + "|" . $owner_user . + "|" . $source . + "|" . $tags . + "|" . $custom_data . + "|" . $server_id . + "|" . $id_extra . + "|" . $agent_name . + "|" . $force_create_agent; - } elsif ($ARGV[4] eq '-validate_event') { - #~ id event(required) + $call_api = $api_path . '?' . + 'op=set&' . + 'op2=create_event&' . + 'other=' . $data_event .'&' . + 'other_mode=url_encode_separator_|&' . + 'apipass=' . $api_pass . '&' . + 'user=' . $db_user . '&' . + 'pass=' . $db_pass; + + } + elsif ($ARGV[4] eq '-validate_event') { + #~ id event(required) if ($ARGV[5] ne '-id') { print "[ERROR] Missing id event! Read help info:\n\n"; help_screen (); - } else { + } + else { $id_event = $ARGV[6]; } @@ -258,8 +313,8 @@ sub tool_api_main () { } my @args = @ARGV; - my $ltotal=$#args; - + my $ltotal=$#args; + if ($ltotal < 0) { print "[ERROR] No valid arguments. Read help info:\n\n"; help_screen (); @@ -272,15 +327,17 @@ sub tool_api_main () { if ($content eq undef) { print "[ERROR] Not respond or bad syntax. Read help info:\n\n"; help_screen(); - } else { + } + else { print "Event ID: $content"; } - } elsif ($option eq '-validate_event') { + } + elsif ($option eq '-validate_event') { print "[RESULT] $content"; } } - - print "\nExiting!\n\n"; - - exit; + + print "\nExiting!\n\n"; + + exit; } diff --git a/pandora_agents/unix/plugins/pandora_df_used b/pandora_agents/unix/plugins/pandora_df_used index 3493fb953c..dcddd7f65d 100755 --- a/pandora_agents/unix/plugins/pandora_df_used +++ b/pandora_agents/unix/plugins/pandora_df_used @@ -48,7 +48,7 @@ else my $onlyexclude = 1; # Store all "ext" fstypes in @lines array - my @lines = split /\n/, `df -khTP | tail -n +2 | awk '{print \$1":"\$2":"\$(NF-1)":"\$NF}' | grep -i "adfs\\|affs\\|autofs\\|btrfs\\|cifs\\|coda\\|coherent\\|efs\\|ext\\|hfs\\|hfsplus\\|hpfs\\|jfs\\|minix\\|msdos\\|ncpfs\\|nfs\\|nfs4\\|ntfs\\|proc\\|qnx4\\|reiserfs\\|smbfs\\|sysv\\|ubifs\\|udf\\|ufs\\|umsdos\\|usbfs\\|vfat\\|xenix\\|xfs\\|xiafs"`; + my @lines = split /\n/, `df -khTP | tail -n +2 | awk '{print \$1";"\$2";"\$(NF-1)";"\$NF}' | grep -i "adfs\\|affs\\|autofs\\|btrfs\\|cifs\\|coda\\|coherent\\|efs\\|ext\\|hfs\\|hfsplus\\|hpfs\\|jfs\\|minix\\|msdos\\|ncpfs\\|nfs\\|nfs4\\|ntfs\\|proc\\|qnx4\\|reiserfs\\|smbfs\\|sysv\\|ubifs\\|udf\\|ufs\\|umsdos\\|usbfs\\|vfat\\|xenix\\|xfs\\|xiafs"`; chomp (@lines); @@ -61,7 +61,7 @@ else } else { - my @linesmanual = split /\n/, `df -khTP | tail -n +2 | awk '{print \$1":"\$2":"\$(NF-1)":"\$NF}' | grep -i $fs`; + my @linesmanual = split /\n/, `df -khTP | tail -n +2 | awk '{print \$1";"\$2";"\$(NF-1)";"\$NF}' | grep -i $fs`; chomp (@linesmanual); @@ -76,7 +76,7 @@ else foreach (@lines) { - my ($filesystem, $fstype, $used_space, $mount_point) = split /:/,$_; + my ($filesystem, $fstype, $used_space, $mount_point) = split /;/,$_; if (defined ($filesystems{$mount_point}) || (!defined ($excluded_filesystems{$mount_point}))) { diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index 1e9feb067e..6c3e9e7eb6 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2014 Artica Soluciones Tecnologicas -# Version 7.0NG +# Version 7.0NG.712 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software @@ -36,7 +36,7 @@ temporal "%ProgramFiles%\pandora_agent\temp" # If set to __rand__ the agent will generate a random name. #agent_name_cmd cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\agentname.vbs" agent_name_cmd __rand__ - + #Parent agent_name #parent_agent_name caprica @@ -77,7 +77,7 @@ server_port 41121 # If set to 1 disables log writing into pandora_agent.log #disable_logfile 1 -# Debug mode do not copy XML data files to server. +# Debug mode renames XML in the temp folder and continues running # debug 1 # If set to 1 allows the agent to be configured via the web console diff --git a/pandora_agents/win32/bin/util/ifaces.vbs b/pandora_agents/win32/bin/util/ifaces.vbs index e4265c9bd2..2e3a14251f 100644 --- a/pandora_agents/win32/bin/util/ifaces.vbs +++ b/pandora_agents/win32/bin/util/ifaces.vbs @@ -40,14 +40,15 @@ If (NOT flag) Then set ifaces_cfg = objWMIService.ExecQuery("Select ipaddress from Win32_NetworkAdapterConfiguration Where Caption='" & iface.caption & "'") Wscript.StdOut.Write " "" ) then + On Error Resume Next + if (iface_cfg.IPAddress(0) <> "" ) then Wscript.StdOut.Write trim(iface_cfg.IPAddress(0)) end if next - wscript.stdOut.WriteLine "]]>" + Wscript.StdOut.WriteLine "]]>" Next Wscript.StdOut.WriteLine "" Wscript.StdOut.WriteLine "" Wscript.StdOut.WriteLine "" -End If \ No newline at end of file +End If diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 581e9a6b32..f2eb7a424c 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -3,7 +3,7 @@ AllowLanguageSelection {Yes} AppName -{Pandora FMS Windows Agent v7.0NG} +{Pandora FMS Windows Agent v7.0NG.712} ApplicationID {17E3D2CF-CA02-406B-8A80-9D31C17BD08F} @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{170411} +{170908} ViewReadme {Yes} diff --git a/pandora_agents/win32/installer/pandora.mpi.orig b/pandora_agents/win32/installer/pandora.mpi.orig new file mode 100644 index 0000000000..cc5c4e6b56 --- /dev/null +++ b/pandora_agents/win32/installer/pandora.mpi.orig @@ -0,0 +1,3561 @@ +array set info { +AllowLanguageSelection +{Yes} + +AppName +{Pandora FMS Windows Agent v7.0NG} + +ApplicationID +{17E3D2CF-CA02-406B-8A80-9D31C17BD08F} + +ApplicationURL +{http://pandorafms.org} + +AutoRefreshFiles +{Yes} + +BuildFailureAction +{Fail (recommended)} + +CancelledInstallAction +{Rollback and Stop} + +CleanupCancelledInstall +{Yes} + +CommandLineFailureAction +{Fail (recommended)} + +Company +{Artica ST http://www.artica.es} + +CompressionLevel +{9} + +CompressionMethod +{zlib} + +Copyright +{2004-2011} + +DefaultDirectoryLocation +{} + +DefaultLanguage +{English} + +DefaultToSystemLanguage +{Yes} + +EnableResponseFiles +{Yes} + +Ext +{.exe} + +ExtractSolidArchivesOnStartup +{No} + +Icon +{logo.png} + +IgnoreDirectories +{} + +IgnoreFiles +{} + +Image +{logo.png} + +IncludeDebugging +{0} + +InstallPassword +{} + +InstallVersion +{7.0.0.0} + +Language,ca +{No} + +Language,cs +{No} + +Language,de +{No} + +Language,en +{Yes} + +Language,es +{Yes} + +Language,fr +{No} + +Language,hu +{No} + +Language,it +{No} + +Language,lt +{No} + +Language,nl +{No} + +Language,pl +{No} + +Language,pt_br +{No} + +Language,ru +{No} + +LastIgnoreDirectories +{} + +LastIgnoreFiles +{} + +PackageDescription +{Pandora FMS Windows Agent} + +PackageLicense +{Gnu Public Licence v2 (GPL2)} + +PackageMaintainer +{Ramon Novoa } + +PackageName +{<%ShortAppName%>} + +PackagePackager +{Raul Mateos , Sancho Lerena , Ramon Novoa } + +PackageRelease +{<%PatchVersion%>} + +PackageSummary +{This is the installer for Pandora FMS agent for all Microsoft Windows platforms } + +PackageVersion +{<%MajorVersion%>.<%MinorVersion%>} + +PreserveFileAttributes +{Yes} + +PreserveFilePermissions +{No} + +ProjectID +{0EA13B96-1BB2-4238-B248-101B4F906C15} + +ProjectVersion +{1.2.15.2} + +SaveOnlyToplevelDirs +{No} + +ScriptExt +{.bat} + +ShortAppName +{Pandora FMS} + +SkipUnusedFileGroups +{No} + +SystemLanguage +{es} + +Theme +{Modern_Wizard} + +ThemeDir +{Modern_Wizard} + +ThemeVersion +{1} + +UpgradeApplicationID +{} + +Version +<<<<<<< HEAD +{170406} +======= +{170418} +>>>>>>> develop + +ViewReadme +{Yes} + +WizardHeight +{365} + +WizardWidth +{500} + +} + +array set ::InstallJammer::InstallCommandLineOptions { +mode +{InstallMode Choice No No {Silent Standard} {Set the mode to run the installer in}} + +prefix +{InstallDir String No No {} {Set the installation directory}} + +} +array set ::InstallJammer::UninstallCommandLineOptions { +debugconsole +{ShowConsole Switch Yes No {} {run uninstaller with a debug console open}} + +mode +{UninstallMode Choice No No {Silent Standard} {set the mode to run the uninstaller in}} + +test +{Testing Switch Yes No {} {run uninstaller without uninstalling any files}} + +} +FileGroup ::946FC43B-0E32-4C38-86EF-4F9252C67E16 -setup Install -active Yes -platforms {Windows MacOS-X FreeBSD-5-x86 FreeBSD-6-x86 FreeBSD-7-x86 Linux-x86_64 Solaris-x86} -name {Program Files} -parent FileGroups +File ::7003FDCA-0EDA-4431-93E2-6FEA7E8660D6 -type dir -name ../bin/key -parent 946FC43B-0E32-4C38-86EF-4F9252C67E16 +File ::B33B08D0-C80C-49CB-9431-44C6B4E7858E -name id_dsa -parent 7003FDCA-0EDA-4431-93E2-6FEA7E8660D6 +File ::7E8B4918-C894-4FCE-98F0-1DDDBF9818F8 -name id_dsa.pub -parent 7003FDCA-0EDA-4431-93E2-6FEA7E8660D6 +File ::D2362133-1FE1-4D75-8607-083C08CFDE94 -name PUT_SSH_KEYS_HERE -parent 7003FDCA-0EDA-4431-93E2-6FEA7E8660D6 +File ::A2DBFC3C-AC45-DAE1-0F04-D279DDC1EB36 -type dir -name .svn -active 0 -parent 7003FDCA-0EDA-4431-93E2-6FEA7E8660D6 +File ::9AF0652D-DF48-17E1-CAC6-C7A95749BF39 -name all-wcprops -active 0 -parent A2DBFC3C-AC45-DAE1-0F04-D279DDC1EB36 +File ::1752E819-4309-7363-EE84-9F995878B58A -name entries -active 0 -parent A2DBFC3C-AC45-DAE1-0F04-D279DDC1EB36 +File ::B2A5618C-97E8-618A-F575-AF5111A86436 -name format -active 0 -parent A2DBFC3C-AC45-DAE1-0F04-D279DDC1EB36 +File ::EC823A02-66E1-E5D0-222D-50EC848E935D -type dir -name prop-base -active 0 -parent A2DBFC3C-AC45-DAE1-0F04-D279DDC1EB36 +File ::CDE9655C-0BB8-862F-BC70-81E68E4E780B -name id_dsa.pub.svn-base -active 0 -parent EC823A02-66E1-E5D0-222D-50EC848E935D +File ::0A68C64D-C7FD-BEAD-710C-15A33BF42394 -name id_dsa.svn-base -active 0 -parent EC823A02-66E1-E5D0-222D-50EC848E935D +File ::412B52E5-5FC9-6C45-AAA8-61E792250F0C -type dir -name props -active 0 -parent A2DBFC3C-AC45-DAE1-0F04-D279DDC1EB36 +File ::AC4C1CD4-E4E5-CED0-C4F8-8F72C3BD5C99 -type dir -name text-base -active 0 -parent A2DBFC3C-AC45-DAE1-0F04-D279DDC1EB36 +File ::69B9D8E8-AA25-F6BA-D556-6601B1679C11 -name id_dsa.pub.svn-base -active 0 -parent AC4C1CD4-E4E5-CED0-C4F8-8F72C3BD5C99 +File ::73569099-F7B9-CC82-A469-52F721A70B61 -name id_dsa.svn-base -active 0 -parent AC4C1CD4-E4E5-CED0-C4F8-8F72C3BD5C99 +File ::3A083CE1-9577-2E23-60B6-B4628E3AFF7A -name PUT_SSH_KEYS_HERE.svn-base -active 0 -parent AC4C1CD4-E4E5-CED0-C4F8-8F72C3BD5C99 +File ::A3D31F9A-9C90-6019-0D36-2BF7D54FBAFC -type dir -name tmp -active 0 -parent A2DBFC3C-AC45-DAE1-0F04-D279DDC1EB36 +File ::8E51353E-6421-44F0-866E-FA3A75AF303E -type dir -name prop-base -active 0 -parent A3D31F9A-9C90-6019-0D36-2BF7D54FBAFC +File ::685ECBDE-3A87-4D92-4954-BC35E4768E42 -type dir -name props -active 0 -parent A3D31F9A-9C90-6019-0D36-2BF7D54FBAFC +File ::42CF5A97-A991-05CF-E5F7-7F78D5D52CEE -type dir -name text-base -active 0 -parent A3D31F9A-9C90-6019-0D36-2BF7D54FBAFC +File ::6E5B73B7-8B81-48D7-BF49-59D8D92FB830 -type dir -name ../bin/util -parent 946FC43B-0E32-4C38-86EF-4F9252C67E16 +File ::C410E57A-3F3E-4622-AB1B-DB6A0EBCED01 -name cut.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::9EB6D55B-F596-4486-9A5A-6A374A3E6CDA -name date.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::0F0DB1A3-D6CA-4ADF-87A3-A0ED76C60C6B -name expr.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::E9117E64-E7B3-48A3-8B57-5D9F20852EAB -name gawk.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::96EE4F8B-1EC7-46E0-869A-88D14CBD82F0 -name grep.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::CFC44D73-74F7-4D14-8FC8-62255B115551 -name head.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::44B21832-6BF6-4277-9B8C-077E49F53AD2 -name ls.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::5E41B886-FEFD-4648-B151-71195C2E04DE -name md5.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::B47EAE44-63B4-4B6F-86A0-00089DDB2437 -name puttygen.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::F792F4E1-B3E9-43AB-A17B-44E2B3013093 -name tail.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::306C9DF0-CC33-48DC-8AFC-2B99ED4E00A0 -name tr.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::1900A2B4-09F5-468A-90AD-75CBE17C727B -name wc.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::B3D9FD4E-6021-45E6-B9B8-F81CC940540E -name tentacle_client.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::AD36A2E6-370D-E5CF-3A6A-56AC4137E60C -type dir -name .svn -active 0 -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::A57FA3AE-443F-FC25-F777-70CAE8FB0892 -name all-wcprops -active 0 -parent AD36A2E6-370D-E5CF-3A6A-56AC4137E60C +File ::5CAE2970-9FA4-CDA6-6156-C0FB81206C93 -name entries -active 0 -parent AD36A2E6-370D-E5CF-3A6A-56AC4137E60C +File ::0C863D99-65DA-2CA7-9CA8-70FBB30A4F02 -name format -active 0 -parent AD36A2E6-370D-E5CF-3A6A-56AC4137E60C +File ::F4812143-55ED-3C48-3FC3-23D8C1456058 -type dir -name prop-base -active 0 -parent AD36A2E6-370D-E5CF-3A6A-56AC4137E60C +File ::5A577337-9685-8CD3-7666-54E6BD51D70C -name cut.exe.svn-base -active 0 -parent F4812143-55ED-3C48-3FC3-23D8C1456058 +File ::14D86BD8-85DE-A53C-34F9-FD6EAF3AC3E6 -name date.exe.svn-base -active 0 -parent F4812143-55ED-3C48-3FC3-23D8C1456058 +File ::B5474580-9B89-F881-AF0F-D89DFE27B74B -name expr.exe.svn-base -active 0 -parent F4812143-55ED-3C48-3FC3-23D8C1456058 +File ::2B1C2B5B-187C-8566-8EDF-0E908A20DBEE -name gawk.exe.svn-base -active 0 -parent F4812143-55ED-3C48-3FC3-23D8C1456058 +File ::346E0DB7-627C-DB73-C59E-B11DB7C3324A -name grep.exe.svn-base -active 0 -parent F4812143-55ED-3C48-3FC3-23D8C1456058 +File ::2360BC3D-5346-2B9A-0707-397F033D6385 -name head.exe.svn-base -active 0 -parent F4812143-55ED-3C48-3FC3-23D8C1456058 +File ::C1F38550-393D-79E1-6C1D-D7AEFA932F01 -name ls.exe.svn-base -active 0 -parent F4812143-55ED-3C48-3FC3-23D8C1456058 +File ::F56EAD1E-60C0-B1F2-F01D-4887B9D0FF0B -name md5.exe.svn-base -active 0 -parent F4812143-55ED-3C48-3FC3-23D8C1456058 +File ::BC5CBC91-43CB-BAB7-622D-A2F93E566458 -name puttygen.exe.svn-base -active 0 -parent F4812143-55ED-3C48-3FC3-23D8C1456058 +File ::D4510D67-0DA2-F7F1-E6A1-924452FA9E74 -name tail.exe.svn-base -active 0 -parent F4812143-55ED-3C48-3FC3-23D8C1456058 +File ::7AE3F476-020E-BA1A-626B-C631F1D6DEBC -name tr.exe.svn-base -active 0 -parent F4812143-55ED-3C48-3FC3-23D8C1456058 +File ::BB01F71B-2DA6-A63E-C112-542974B20C30 -name wc.exe.svn-base -active 0 -parent F4812143-55ED-3C48-3FC3-23D8C1456058 +File ::1867308F-F69E-2BE3-9DF6-A5ECD58AA2CE -type dir -name props -active 0 -parent AD36A2E6-370D-E5CF-3A6A-56AC4137E60C +File ::D7C4B924-B3CE-BE13-A62B-9EB256F73AB4 -name tentacle_client.exe.svn-work -active 0 -parent 1867308F-F69E-2BE3-9DF6-A5ECD58AA2CE +File ::13FFC58B-812B-624A-170C-B8954D13574D -type dir -name text-base -active 0 -parent AD36A2E6-370D-E5CF-3A6A-56AC4137E60C +File ::9BD4AAF6-4D9F-0D52-21FC-388AE4C148C4 -name cut.exe.svn-base -active 0 -parent 13FFC58B-812B-624A-170C-B8954D13574D +File ::CFC49473-239A-EDC9-EAC3-74282513DFAF -name date.exe.svn-base -active 0 -parent 13FFC58B-812B-624A-170C-B8954D13574D +File ::9F8DF1C5-531E-EDC6-E477-F49C063F927C -name expr.exe.svn-base -active 0 -parent 13FFC58B-812B-624A-170C-B8954D13574D +File ::783FD37D-8F07-6991-E37D-22A2706716CB -name gawk.exe.svn-base -active 0 -parent 13FFC58B-812B-624A-170C-B8954D13574D +File ::2305CCBD-4447-BAF4-0E7F-E38133567DB4 -name grep.exe.svn-base -active 0 -parent 13FFC58B-812B-624A-170C-B8954D13574D +File ::B1E1E90B-9A96-2526-9583-E31A370A15C9 -name head.exe.svn-base -active 0 -parent 13FFC58B-812B-624A-170C-B8954D13574D +File ::BA9586FF-BA3E-2E73-B262-CF7AF48AB4DC -name ls.exe.svn-base -active 0 -parent 13FFC58B-812B-624A-170C-B8954D13574D +File ::732C7A8A-3FC1-172E-B943-0CF1BFADA5F2 -name md5.exe.svn-base -active 0 -parent 13FFC58B-812B-624A-170C-B8954D13574D +File ::8021D8AA-4F3C-0B5D-61D1-610F3616572B -name puttygen.exe.svn-base -active 0 -parent 13FFC58B-812B-624A-170C-B8954D13574D +File ::139033A0-D9E6-870A-5BFF-2261D1D707D1 -name tail.exe.svn-base -active 0 -parent 13FFC58B-812B-624A-170C-B8954D13574D +File ::D25CAB78-44B6-9998-7B56-1E6DE957ED78 -name tr.exe.svn-base -active 0 -parent 13FFC58B-812B-624A-170C-B8954D13574D +File ::2E2CE748-D169-27FE-DC76-13933FA60A6D -name wc.exe.svn-base -active 0 -parent 13FFC58B-812B-624A-170C-B8954D13574D +File ::FC2CF695-F050-712A-EAC4-B57D19D00C77 -type dir -name tmp -active 0 -parent AD36A2E6-370D-E5CF-3A6A-56AC4137E60C +File ::17DD23ED-CFF6-4E2E-AE99-2AA03F4DC4C4 -type dir -name prop-base -active 0 -parent FC2CF695-F050-712A-EAC4-B57D19D00C77 +File ::7FFC041E-C253-BA7D-D890-3D88CDBA434C -type dir -name props -active 0 -parent FC2CF695-F050-712A-EAC4-B57D19D00C77 +File ::955A9B5D-775D-4C4B-07C6-1E457A3AEF04 -type dir -name text-base -active 0 -parent FC2CF695-F050-712A-EAC4-B57D19D00C77 +File ::57A504DC-687C-F126-8B39-6A70F43C156A -name cmp.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::B71D3B59-A60B-6C21-76D4-292FA73C1613 -name getreg.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::DB77AA43-D4B7-239C-0F48-52502E17D4DC -name sort.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::7B1652FD-0C02-13A8-BAA8-1B6F8BB257A5 -name df.vbs -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::558D0D7E-2D41-EA8A-325D-27FA08CE8B69 -name ps.vbs -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::92375EEB-039A-EAF0-C1AC-B91B00CD1DD6 -name logevent_log4x.vbs -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::0A9C1B7E-7F5C-84E0-55F9-0224A97F3CD2 -name unzip.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::8B69786B-B84F-22AC-B466-C84617B1330A -type dir -name mibs -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::10C3DFEB-75EC-B329-9CCB-F96223B326C2 -name SNMP-USER-BASED-SM-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::F7ECC5A7-160D-BA30-5C90-16128275160C -name IPV6-TCP-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::CA57A40B-EAF2-C3FF-0266-4849D92307F3 -name IPV6-UDP-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::A4AE302D-4B1F-1B96-D1AF-63647EE43060 -name UCD-IPFWACC-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::4894E284-5E13-99E3-1CAE-F90BF9006641 -name Makefile.mib -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::CDBCA051-ABF8-586B-EEA2-2738E8B839C7 -name RFC1155-SMI.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::8D3FC0D8-3E89-AA48-8AC1-0E2ABA206413 -name NET-SNMP-MONITOR-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::9E24308A-6C93-A14B-4054-B98C8855B3E7 -name DISMAN-TRACEROUTE-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::104C6B91-8D0A-1830-50F0-85B29FDFA7A4 -name SNMPv2-SMI.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::1CEF1B2C-F75C-9439-260A-940E0B6BDF34 -name RFC1213-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::1737EB19-488D-CC18-8B5B-1118C9868A2C -name HOST-RESOURCES-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::E3CCE554-B504-5F5F-7F74-FF9C7B31BF4D -name NETWORK-SERVICES-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::5C1CE0DF-685D-8D71-7E6E-A2DFAAAF3AB9 -name UCD-SNMP-MIB-OLD.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::E603538F-D5D1-6EDF-CE46-CB9C4DC718F1 -name AGENTX-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::471A4833-F9C7-0E6A-FF2D-159AB861F958 -name SNMP-VIEW-BASED-ACM-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::797C81CC-9E82-ACFC-8D45-A94DC430755D -name HOST-RESOURCES-TYPES.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::45BFFEA9-B757-1464-8F91-A07A03BA229C -name ianalist -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::88C873FE-F358-1FBC-608F-4273AD8391E4 -name RMON-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::0AC17338-9F54-9B51-00A1-9FB655FE5A8F -name HCNUM-TC.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::4B3D7FA9-0633-0969-0D48-86E9714EDDB7 -name UCD-DLMOD-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::71E96358-3EC9-3FF2-DE0F-24713B0BE65B -name EtherLike-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::0AC34548-4415-39F5-F75E-3E54611FBEA1 -name NET-SNMP-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::F3A8B2CF-374D-D5F1-AAAD-675F04ECF107 -name LM-SENSORS-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::7EE2B7C3-913B-A889-EEFB-8FD7D5B36D3D -name IANA-ADDRESS-FAMILY-NUMBERS-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::DFD52E2F-6DE4-5176-C430-683C42915D68 -name rfcmibs.diff -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::77DAD413-0D51-0043-DAB1-959155FA1584 -name SMUX-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::42EEFE3A-A534-4FDD-2D98-EDE92C9D56D5 -name IANA-RTPROTO-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::2DB878B1-5A00-3949-E1EB-6C5FFEE1BB6E -name README.mibs -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::EBC9F917-BDA1-5E9E-70A2-939E85145E96 -name UCD-IPFWACC-MIB.inc -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::8DA0A3E3-5D3A-493A-30B3-86A81D35C077 -name rfclist -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::414F8D04-D7F8-8E4B-8B9C-34C9CEEAE990 -name RFC-1215.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::3DECE776-AE57-4B11-1B00-C1E5D6E680F5 -name TUNNEL-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::316FEA16-1105-B2F9-1D64-0F94F07451DB -name makehtml.pl -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::98D3387E-6994-71AD-5E68-EC53C256BF89 -name Makefile.in -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::DD5BA10C-D728-E267-CC3C-6BFBDB0FD0F4 -name INET-ADDRESS-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::787BF3D9-F3D8-AEDC-C0A8-4539892510B3 -name DISMAN-EVENT-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::40A38693-383D-E70D-2D0B-97F14FC06A25 -name SNMPv2-TM.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::B172ABC4-5B10-6800-1C26-B5E4E7DCB3BE -name NET-SNMP-TC.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::029D3EFA-AA5D-FE7D-9B70-CB162B8731BC -name SNMP-MPD-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::C69A3E3F-602D-B85A-AD84-CD3FF7163906 -name SNMP-TARGET-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::8CDCB12A-2544-A5C7-A6F0-6C5A9D0C061D -name NET-SNMP-SYSTEM-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::A9026441-0B6F-D92B-1A07-ED3DD99BD501 -name smistrip -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::48CA671F-9217-EDAF-4196-9D9AF61A699B -name DISMAN-NSLOOKUP-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::CB1B4307-0998-D9C3-AB12-4F0367B9BC50 -name NET-SNMP-EXAMPLES-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::37418DC6-CB58-F6D6-C221-FE20835BA5B6 -name TCP-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::74E4DAD6-E267-4FBD-C7E2-FCBEF64BF132 -name DISMAN-PING-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::0A4E3D96-62B4-0244-A2C3-3E8CA564EDE0 -name NET-SNMP-AGENT-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::6620F423-865F-91B1-4C0E-93D483092228 -name NET-SNMP-EXTEND-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::8049FBBB-1C36-02C7-8690-5C24686D9CD2 -name IP-FORWARD-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::183ED813-65AD-F929-5041-715D4FD09737 -name DISMAN-SCHEDULE-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::51842E62-465C-E1B4-2DEA-871C045AF913 -name UCD-DISKIO-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::569B4E77-0B32-E95A-8540-2C97C2B2A354 -name SNMPv2-TC.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::DA1819A0-F1C0-B6BD-3C5D-FC02602ABDB2 -name SNMP-NOTIFICATION-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::C90B00DD-3DF9-5A10-80A4-F173C81E267B -name IANAifType-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::4CDDD873-7C7B-DDF1-0547-C716FA2EE6B8 -name UCD-DISKIO-MIB.inc -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::56603234-865E-B851-B55A-9A620209A198 -name SNMPv2-CONF.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::1112D09B-33C9-483A-E700-C85832FC6C69 -name IPV6-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::AF86F856-6A36-299A-5ADA-5CC9E3B14BA1 -name SNMPv2-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::605BCDB3-C411-8D49-BF90-B0D3E29288C9 -name DISMAN-EXPRESSION-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::DB106B45-CA94-21A2-F638-19EEC4BB84B6 -name IANA-LANGUAGE-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::B2FE8CE3-716F-A393-D0D3-FAAF748EFAB0 -name UCD-DEMO-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::D4295B27-BEDC-FDF3-48B1-2A58B7CF306D -name SNMP-PROXY-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::9DB499F2-F384-C5AA-E496-CA7F859FF8C8 -name IPV6-ICMP-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::B8B3D274-B94B-809E-5ABC-E2B0488B51B5 -name DISMAN-SCRIPT-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::00F9ECA3-E979-9343-7F94-9D8F349EF579 -name mibfetch -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::9430EE3D-3EF2-5CE9-BA36-02A3C0680C37 -name SNMP-FRAMEWORK-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::5A093FFD-6A05-1693-6A29-F5D68054DF46 -name UDP-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::73AD77A4-08F4-8A7D-D52B-6151D11FF33F -name UCD-DEMO-MIB.inc -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::C0B97EE6-9A3C-2EF0-22ED-082B40EE910F -name UCD-SNMP-MIB.inc -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::02DE3F78-ED9A-5A73-D283-0CD205B7BE58 -name TRANSPORT-ADDRESS-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::09203A02-1DA2-BDE3-175B-15043E2ACAE0 -name SNMP-USM-DH-OBJECTS-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::BEEFE984-6F00-376D-7BCE-812B945AEDBD -name SNMP-USM-AES-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::3D1E7967-95A3-E9B8-3579-6FFDF0D1E5AF -name UCD-DLMOD-MIB.inc -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::1A4D4BF6-FF57-559E-251B-F63BB6D9FA94 -name UCD-IPFILTER-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::31EC3141-C348-56FF-16E2-75C2FFA65413 -name MTA-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::17D117A5-B736-A21C-AAC1-C6B017A644D5 -name IPV6-TC.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::E1FDBB74-8D12-9843-B4D3-40385D91CDF5 -name SNMP-COMMUNITY-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::8CD8FE57-2B98-7814-258B-1D4FB03B144E -name IF-INVERTED-STACK-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::4A727B8A-ED01-A5C4-BFF3-F7E632E1F056 -name NOTIFICATION-LOG-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::074CBF5A-7246-A35C-EBD7-DAECBDFA8044 -name IF-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::69610A79-5EA4-6111-2946-D870A009B4FD -name UCD-SNMP-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::2285B4E9-C139-D5EC-DCF4-F0943BBB0FE1 -name nodemap -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::CC5A58CA-2719-7E75-7DC9-178C4A7AB956 -name UCD-IPFILTER-MIB.inc -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::4AF37C51-C6F6-71AB-BA2A-759CCF9EE297 -name IP-MIB.txt -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::1D9B106C-A0A0-4989-645B-0A1AFDC44138 -name .index -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::75B2C5A2-5AA7-FD10-9FF9-65820B3199E3 -type dir -name .svn -active 0 -parent 8B69786B-B84F-22AC-B466-C84617B1330A +File ::D5FFCDEA-B30C-90E1-1B2C-49DB89A2D90F -name all-wcprops -active 0 -parent 75B2C5A2-5AA7-FD10-9FF9-65820B3199E3 +File ::55BD2C4F-212D-947D-4CE5-7A1A6463AF3A -name entries -active 0 -parent 75B2C5A2-5AA7-FD10-9FF9-65820B3199E3 +File ::7BB33BC9-F34E-ACAC-5D2E-D8CE67590378 -type dir -name prop-base -active 0 -parent 75B2C5A2-5AA7-FD10-9FF9-65820B3199E3 +File ::6A15022F-5512-B5CE-287B-9FD87C8D4D61 -type dir -name props -active 0 -parent 75B2C5A2-5AA7-FD10-9FF9-65820B3199E3 +File ::CC1D7221-8233-5190-029D-9F0AF2B73225 -type dir -name text-base -active 0 -parent 75B2C5A2-5AA7-FD10-9FF9-65820B3199E3 +File ::2D8DAE81-C0D0-DEA9-0E71-DCF7CA54127F -name .index.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::DFCFD8E2-0B13-19E0-CACA-B729EB6717B3 -name AGENTX-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::1EE676C1-0749-31CE-7BA6-3B28862BA05B -name DISMAN-EVENT-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::32A01452-C5B3-A36A-9343-2473FF0EF86B -name DISMAN-EXPRESSION-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::2B2D0A95-26A6-F27D-1129-FC227D045DD3 -name DISMAN-NSLOOKUP-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::DCEFFC46-98EA-5B9D-5DBF-2A912D9998C0 -name DISMAN-PING-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::392AA770-335C-6B27-8B56-F309A8E78251 -name DISMAN-SCHEDULE-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::FFB1354A-B5E7-4A95-8755-CC5A435BE297 -name DISMAN-SCRIPT-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::C25E27F3-CE18-1B9A-D285-3D3F6A7BD2AE -name DISMAN-TRACEROUTE-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::427CB562-066F-C2E6-9264-E462AE38854E -name EtherLike-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::1B50866C-5C89-EF5A-FEE7-0EEA3C1A523D -name HCNUM-TC.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::B351A78A-038D-57FB-7CAA-FE00C2843AD6 -name HOST-RESOURCES-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::C91B3BFF-0FA4-3A20-83E9-688B9CA4A7D4 -name HOST-RESOURCES-TYPES.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::E7882D39-8A22-B573-33CF-54D2417E5AF1 -name IANA-ADDRESS-FAMILY-NUMBERS-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::6D6BC24F-6F51-E69E-EFCF-83CD3CF8F567 -name IANA-LANGUAGE-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::EF828668-6C7B-A51B-8140-D84F9AB9760C -name IANA-RTPROTO-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::7AE6382F-49F2-4D61-5124-1E4F083CB2E4 -name IANAifType-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::2291B1C0-3660-0D31-44D9-25BE27886AC2 -name ianalist.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::ED8393C4-0988-2F37-6362-82741C8BEF18 -name IF-INVERTED-STACK-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::72FBD6F5-473A-C962-6879-35015BA8D5C9 -name IF-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::AF3EA403-49CC-511E-75F2-1365816200CA -name INET-ADDRESS-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::C2B56606-E28D-EF6A-F28D-CA81B1AB67A7 -name IP-FORWARD-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::11332249-7CE3-2A37-AA1F-48925709668F -name IP-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::F9F74BD2-5DB1-52AF-E0F2-F83FBF978E48 -name IPV6-ICMP-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::1F3DED36-1DCF-21F3-7AF7-60BF0B8E490D -name IPV6-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::03762ED4-7F88-4853-2E89-2FD018A9BFF4 -name IPV6-TC.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::D0BBA9CA-701B-22C1-BB15-0D7C94C40D49 -name IPV6-TCP-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::9623E8DC-ABB6-3FE9-467C-977F1FC8D0C8 -name IPV6-UDP-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::B18EC413-4AA0-2161-0416-1B7EAF5B8587 -name LM-SENSORS-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::4FACC844-DC8A-3778-4E4F-9A4D3FE935B7 -name Makefile.in.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::5E65F151-1031-98D3-07DD-40A01F1081D9 -name Makefile.mib.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::79B81A40-00D4-397A-B228-BB4EE6006FCD -name makehtml.pl.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::729BAE35-6BD2-7C45-498A-678218DFF994 -name mibfetch.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::CD1D4E0D-3220-D888-225C-B09A2AF69D47 -name MTA-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::A1F3C16D-E3E7-8D4B-A0FA-5EA3DDC5C3E7 -name NET-SNMP-AGENT-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::6E5845C0-2470-FD92-3388-832E9EA5E41D -name NET-SNMP-EXAMPLES-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::07B57915-D30A-9B31-0F00-B4051EA17FDF -name NET-SNMP-EXTEND-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::1B9F5B34-1BCC-14B4-649E-646E703AAC42 -name NET-SNMP-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::57059FFB-1AD1-0C53-DB25-556CF56EBC55 -name NET-SNMP-MONITOR-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::9334F7D7-CAD8-756E-A495-E8A1B72C3C65 -name NET-SNMP-SYSTEM-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::979000C2-2CAA-422A-BFFA-B6E2618DF99F -name NET-SNMP-TC.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::4C34E0F6-1878-3624-E7DB-9C6B80440D24 -name NETWORK-SERVICES-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::89E5C74E-1C3F-D63C-57F8-FCB8CF2FCCC4 -name nodemap.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::B13201FB-7A83-9639-A999-9F330EA3A849 -name NOTIFICATION-LOG-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::B86561D3-9423-E3B7-4233-ADD4A4D26866 -name README.mibs.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::631AF3AA-FBAD-A007-3063-D0417A00AD25 -name RFC-1215.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::2781ED42-0D91-233F-6F51-0C14E04FCA28 -name RFC1155-SMI.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::4946D7B9-05D4-520B-C842-07CAC8C92DB2 -name RFC1213-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::A1564F0D-7F18-6256-927D-9494240F853B -name rfclist.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::D332BAD1-6058-BEF6-7CDD-3503E8DC07B6 -name rfcmibs.diff.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::41972A3C-4B83-3DC4-C18C-708B13422B13 -name RMON-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::81C1DDBE-CBDE-FE8A-83D2-13C99D113762 -name smistrip.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::BB7554E3-04DA-E5BE-D502-1001B803E565 -name SMUX-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::F27B00AA-549A-E044-EB78-369A84AF6CB8 -name SNMP-COMMUNITY-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::26E15926-97FB-CEEC-4157-B94FE7E83765 -name SNMP-FRAMEWORK-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::287047DE-53D8-D514-4E13-121FFAD31A0F -name SNMP-MPD-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::E0109AEF-812E-CF43-83C4-EB3CD4C00C8B -name SNMP-NOTIFICATION-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::B7F3BA89-6757-A82E-8DC8-CE1EA8048686 -name SNMP-PROXY-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::4D7D18CF-0E14-59C5-518F-7C0CD0B2CB4D -name SNMP-TARGET-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::FB47BE7F-2B32-CC30-2CA1-83D4CDF00215 -name SNMP-USER-BASED-SM-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::FC1443BA-24F6-9C83-630D-BB8F957BE52E -name SNMP-USM-AES-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::AC046AA3-A8D4-C3E2-C3E5-E7B68A501089 -name SNMP-USM-DH-OBJECTS-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::38691298-28A8-81F6-F1FC-00ECE21205D7 -name SNMP-VIEW-BASED-ACM-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::DFF8B0D9-907E-B263-9F23-48216BB2D058 -name SNMPv2-CONF.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::5CCFF16F-2A94-EB09-9E3E-519A3A1FE805 -name SNMPv2-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::6FFEF5BF-6508-2A40-811D-3863399E9D59 -name SNMPv2-SMI.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::97565931-8C89-F029-99A1-6DFC1979A3E8 -name SNMPv2-TC.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::3F15A49F-6BEC-F45F-DDF9-CC50CD4CC21E -name SNMPv2-TM.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::E01ACDF9-4DCE-C415-DC49-3BC213F23B10 -name TCP-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::9992E720-1A2F-2198-C236-DAA92181721A -name TRANSPORT-ADDRESS-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::479EA0FB-98E3-8710-E883-BBB9C667066A -name TUNNEL-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::7D605D50-615C-B0F9-567D-6246A313851F -name UCD-DEMO-MIB.inc.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::4FDA6897-97C5-F7E6-0AFA-52E362F9E84A -name UCD-DEMO-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::AB270B18-95CB-F42F-CA15-11359EAD35B0 -name UCD-DISKIO-MIB.inc.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::AC27DF3F-F522-2A06-BDF1-4645C9F942AE -name UCD-DISKIO-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::B3E11B2E-35C4-0B97-4408-74167C185C22 -name UCD-DLMOD-MIB.inc.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::73CFF637-FBBB-7D64-B498-2FBEAD83AADA -name UCD-DLMOD-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::569CD04F-9E6E-06E4-1B1F-4B58E0EE441A -name UCD-IPFILTER-MIB.inc.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::81EA4416-1E6D-2557-FAF6-1D4E768069C0 -name UCD-IPFILTER-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::7A6CA16A-B3E1-702B-6860-5580B12030AB -name UCD-IPFWACC-MIB.inc.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::C85A4B0A-C307-8DD6-FF88-31738AEE4BEE -name UCD-IPFWACC-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::AFDF3F9B-A060-F8C6-5B4C-208AFE2176B2 -name UCD-SNMP-MIB-OLD.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::424B0ACB-B435-1C68-47EF-88A3E9546523 -name UCD-SNMP-MIB.inc.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::855032CB-FC6E-DFA1-BC63-E5D4FD29F185 -name UCD-SNMP-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::94CA96D2-F700-B1A8-A825-6729707FF6A6 -name UDP-MIB.txt.svn-base -active 0 -parent CC1D7221-8233-5190-029D-9F0AF2B73225 +File ::8BED0534-84A0-E7A1-104A-7AB6FF964C31 -type dir -name tmp -active 0 -parent 75B2C5A2-5AA7-FD10-9FF9-65820B3199E3 +File ::FCD8F7DA-CA57-B939-BE6D-7582A8AC2EA5 -type dir -name prop-base -active 0 -parent 8BED0534-84A0-E7A1-104A-7AB6FF964C31 +File ::A549C9BC-62C4-F94D-5195-28EA21C4F48E -type dir -name props -active 0 -parent 8BED0534-84A0-E7A1-104A-7AB6FF964C31 +File ::A26BD65A-2404-4564-6D36-8FD8EBECA57C -type dir -name text-base -active 0 -parent 8BED0534-84A0-E7A1-104A-7AB6FF964C31 +File ::3A6A9726-7944-6766-FE7A-45E11E8324EC -name df_percent.vbs -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::DC4E6C4D-0CAC-9299-7F7E-715C90CA2655 -name getsnmp.bat -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::1DD45A3E-D828-38FB-3715-D9DA537EDCAA -name snmpget.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::F054DB92-ED3C-63C1-3907-9C1350C0EC25 -name pandora_update.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::F9A7539E-8E6F-05A5-18D4-3E366C257AE5 -name tentacle_server.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::45D372F1-229D-5318-5AF0-84BF65848E79 -name curl.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::6B032FAE-541E-EC63-8EB9-3407BE28B665 -name pandora_revent.exe -parent 6E5B73B7-8B81-48D7-BF49-59D8D92FB830 +File ::03A7EA5A-D6FC-4427-B35C-0288C07813B6 -filemethod {Never overwrite files} -name ../bin/pandora_agent.conf -parent 946FC43B-0E32-4C38-86EF-4F9252C67E16 +File ::71EFB181-1BAE-4749-B7E7-7837E378BA3D -name ../bin/PandoraAgent.exe -parent 946FC43B-0E32-4C38-86EF-4F9252C67E16 +File ::50980131-CDA1-4F32-86E0-FD53B1097F67 -name ../installer/pandora.ico -parent 946FC43B-0E32-4C38-86EF-4F9252C67E16 +File ::3267E440-2104-4BA2-BDEB-DFDA32441FC2 -name ../installer/LICENSE.txt -parent 946FC43B-0E32-4C38-86EF-4F9252C67E16 +File ::423325D1-5C33-41ED-965A-F7E1F2A2C32E -name ../installer/README.txt -parent 946FC43B-0E32-4C38-86EF-4F9252C67E16 +File ::9F4D1B79-C9AE-4F1F-AC50-876657B3361C -type dir -name ../installer/scripts -parent 946FC43B-0E32-4C38-86EF-4F9252C67E16 +File ::8C09E6D4-4B09-4AA5-B025-441389C76F70 -name start_pandora_agent.bat -parent 9F4D1B79-C9AE-4F1F-AC50-876657B3361C +File ::BA05415F-E246-45AE-A0B1-21C7AB400402 -name stop_pandora_agent.bat -parent 9F4D1B79-C9AE-4F1F-AC50-876657B3361C +File ::F9332D6C-1AB8-5657-0FD3-02D1B30B6EC2 -type dir -name .svn -active 0 -parent 9F4D1B79-C9AE-4F1F-AC50-876657B3361C +File ::FCD8D912-5FEE-9260-43B9-AAC4A3D97A74 -name all-wcprops -active 0 -parent F9332D6C-1AB8-5657-0FD3-02D1B30B6EC2 +File ::B52ADC0B-DDFE-19EA-217D-A9879FDB0ED0 -name entries -active 0 -parent F9332D6C-1AB8-5657-0FD3-02D1B30B6EC2 +File ::F1C08FA0-FC7D-A314-A3ED-79CABF0D6691 -name format -active 0 -parent F9332D6C-1AB8-5657-0FD3-02D1B30B6EC2 +File ::7C00D02E-E023-12F5-37DB-99EF5C139127 -type dir -name prop-base -active 0 -parent F9332D6C-1AB8-5657-0FD3-02D1B30B6EC2 +File ::9D70EC00-D797-99F7-D436-A245939366E9 -type dir -name props -active 0 -parent F9332D6C-1AB8-5657-0FD3-02D1B30B6EC2 +File ::916998A8-1F74-A5B7-EF97-4576BF4640EE -type dir -name text-base -active 0 -parent F9332D6C-1AB8-5657-0FD3-02D1B30B6EC2 +File ::022AD27A-A285-F9D4-6374-56A6DCB382DA -name start_pandora_agent.bat.svn-base -active 0 -parent 916998A8-1F74-A5B7-EF97-4576BF4640EE +File ::5F1E6560-AEB6-9C49-4A34-9D0410B1BB5D -name stop_pandora_agent.bat.svn-base -active 0 -parent 916998A8-1F74-A5B7-EF97-4576BF4640EE +File ::23F0FBAE-5849-2617-4616-D50FE1FCB137 -type dir -name tmp -active 0 -parent F9332D6C-1AB8-5657-0FD3-02D1B30B6EC2 +File ::9513C1EE-B08B-2ABE-38EF-C153696EFCD6 -type dir -name prop-base -active 0 -parent 23F0FBAE-5849-2617-4616-D50FE1FCB137 +File ::2BBBE1D9-BA80-E6CA-835E-9D958A4CF3C3 -type dir -name props -active 0 -parent 23F0FBAE-5849-2617-4616-D50FE1FCB137 +File ::486CB634-5092-8E3B-7621-5B3A044ACCCC -type dir -name text-base -active 0 -parent 23F0FBAE-5849-2617-4616-D50FE1FCB137 +File ::012BFA02-7F3D-897C-072A-877021FDC7D7 -name restart_pandora_agent.bat -parent 9F4D1B79-C9AE-4F1F-AC50-876657B3361C +File ::02213E74-8E86-E4AC-58D0-B70412A05656 -name install_service_restart.bat -parent 9F4D1B79-C9AE-4F1F-AC50-876657B3361C +File ::BAF0FDDB-F0D7-1326-D3CE-7C6676636B83 -name delete_at_job.bat -parent 9F4D1B79-C9AE-4F1F-AC50-876657B3361C +File ::94EE5172-C243-4F11-80CE-C356D9055323 -type dir -name ../bin/help -parent 946FC43B-0E32-4C38-86EF-4F9252C67E16 +File ::38108568-E397-4360-9FDD-BBD7574607E0 -name how_to_keys.html -parent 94EE5172-C243-4F11-80CE-C356D9055323 +File ::096DCAC9-2E8F-4765-9EC5-E40DAFC26B36 -name how_to_keys_es.html -parent 94EE5172-C243-4F11-80CE-C356D9055323 +File ::550F286E-2409-4221-A51A-CA980C9EA9DC -type dir -name images -parent 94EE5172-C243-4F11-80CE-C356D9055323 +File ::6FDE9DD9-ADE8-455A-B864-FA7C2B903604 -name 1.jpg -parent 550F286E-2409-4221-A51A-CA980C9EA9DC +File ::0AFE05E1-E200-4650-8F9E-ED83C9E9ADD4 -name 2.jpg -parent 550F286E-2409-4221-A51A-CA980C9EA9DC +File ::46E928DC-6919-4EC1-86EA-F161C098449D -name 3.jpg -parent 550F286E-2409-4221-A51A-CA980C9EA9DC +File ::5EA49A68-6952-43BF-9A54-1CDF8E48C3D8 -name 4.jpg -parent 550F286E-2409-4221-A51A-CA980C9EA9DC +File ::0C33AC8D-503A-4A9C-801F-2FDEF9FA98C0 -name 5.jpg -parent 550F286E-2409-4221-A51A-CA980C9EA9DC +File ::1B81E274-2375-4287-90D7-953BE3F71FA7 -name 6.jpg -parent 550F286E-2409-4221-A51A-CA980C9EA9DC +File ::C2E02994-9B4E-430C-B399-E93986DD9B0F -name logo.png -parent 550F286E-2409-4221-A51A-CA980C9EA9DC +File ::9D2B9A51-22B6-A99C-5081-FA2019F25C7C -type dir -name .svn -active 0 -parent 550F286E-2409-4221-A51A-CA980C9EA9DC +File ::EE4C4794-AF1B-9B38-C3F3-4A0F30414237 -name all-wcprops -active 0 -parent 9D2B9A51-22B6-A99C-5081-FA2019F25C7C +File ::CDEFB24E-78EC-D33D-C03B-1BF69F9D7240 -name entries -active 0 -parent 9D2B9A51-22B6-A99C-5081-FA2019F25C7C +File ::AE60977B-1615-C577-177E-5B7D25BC1B9D -name format -active 0 -parent 9D2B9A51-22B6-A99C-5081-FA2019F25C7C +File ::2FF9A303-F999-58D0-3FBA-14DBDCCDA37B -type dir -name prop-base -active 0 -parent 9D2B9A51-22B6-A99C-5081-FA2019F25C7C +File ::A315BDD0-BFAC-9951-DBA9-9C0069787C3C -name 1.jpg.svn-base -active 0 -parent 2FF9A303-F999-58D0-3FBA-14DBDCCDA37B +File ::F6039348-9850-F462-2574-1E5E891BF3E6 -name 2.jpg.svn-base -active 0 -parent 2FF9A303-F999-58D0-3FBA-14DBDCCDA37B +File ::FC2B37A3-0080-541B-9966-57C1D1C1E1D6 -name 3.jpg.svn-base -active 0 -parent 2FF9A303-F999-58D0-3FBA-14DBDCCDA37B +File ::298ED0DB-1234-5BD8-18B8-518B5FB6D496 -name 4.jpg.svn-base -active 0 -parent 2FF9A303-F999-58D0-3FBA-14DBDCCDA37B +File ::053EB4AF-E3D2-3585-97C5-74101DE38A5A -name 5.jpg.svn-base -active 0 -parent 2FF9A303-F999-58D0-3FBA-14DBDCCDA37B +File ::205526D5-AB41-59CD-4E93-921AB6B2C76D -name 6.jpg.svn-base -active 0 -parent 2FF9A303-F999-58D0-3FBA-14DBDCCDA37B +File ::14581560-7252-5709-FDFF-633B5A3E280A -name logo.png.svn-base -active 0 -parent 2FF9A303-F999-58D0-3FBA-14DBDCCDA37B +File ::6F85271E-257E-557C-FAC2-F49C1EDC2096 -type dir -name props -active 0 -parent 9D2B9A51-22B6-A99C-5081-FA2019F25C7C +File ::93B66474-8BCC-512F-7745-93C6A7363B6C -type dir -name text-base -active 0 -parent 9D2B9A51-22B6-A99C-5081-FA2019F25C7C +File ::63801B7E-91F6-27E3-6B1E-FAE252743DB2 -name 1.jpg.svn-base -active 0 -parent 93B66474-8BCC-512F-7745-93C6A7363B6C +File ::69C1BE32-1589-926A-57A7-8CF8462EE436 -name 2.jpg.svn-base -active 0 -parent 93B66474-8BCC-512F-7745-93C6A7363B6C +File ::AB5F3408-BEB6-43EB-BB36-01C2099CDA73 -name 3.jpg.svn-base -active 0 -parent 93B66474-8BCC-512F-7745-93C6A7363B6C +File ::E3C5F440-0EA5-B02E-E0CA-914C0D752579 -name 4.jpg.svn-base -active 0 -parent 93B66474-8BCC-512F-7745-93C6A7363B6C +File ::9FFDE5CB-2B86-E099-0A6D-A963C5DACFED -name 5.jpg.svn-base -active 0 -parent 93B66474-8BCC-512F-7745-93C6A7363B6C +File ::01DD93C8-FC8F-F04F-41E2-4CCE23B17446 -name 6.jpg.svn-base -active 0 -parent 93B66474-8BCC-512F-7745-93C6A7363B6C +File ::47103393-BF3D-73AA-DF55-6EC06D168B87 -name logo.png.svn-base -active 0 -parent 93B66474-8BCC-512F-7745-93C6A7363B6C +File ::AF12F531-ADF4-4FFA-AD4E-51E147AC2AB3 -type dir -name tmp -active 0 -parent 9D2B9A51-22B6-A99C-5081-FA2019F25C7C +File ::E74367AD-B33C-C7BC-29EA-1DD751790525 -type dir -name prop-base -active 0 -parent AF12F531-ADF4-4FFA-AD4E-51E147AC2AB3 +File ::03BE7202-3CE6-912B-55BD-C83BE24DE78D -type dir -name props -active 0 -parent AF12F531-ADF4-4FFA-AD4E-51E147AC2AB3 +File ::C298402E-C607-9ECB-3868-3EC497EE76E9 -type dir -name text-base -active 0 -parent AF12F531-ADF4-4FFA-AD4E-51E147AC2AB3 +File ::ECEC7A07-7C36-C3CD-BFF1-53DD1B27A949 -type dir -name .svn -active 0 -parent 94EE5172-C243-4F11-80CE-C356D9055323 +File ::1F6E3F35-3360-B6DF-DE07-FC8D97EDA429 -name all-wcprops -active 0 -parent ECEC7A07-7C36-C3CD-BFF1-53DD1B27A949 +File ::92DE54C3-70E3-54B0-6ACA-C4AB3ED414C5 -name entries -active 0 -parent ECEC7A07-7C36-C3CD-BFF1-53DD1B27A949 +File ::09CCD851-4F46-30C3-CEDF-3CF15F2F4725 -name format -active 0 -parent ECEC7A07-7C36-C3CD-BFF1-53DD1B27A949 +File ::4B269A0F-E9EF-8E24-DA33-EF312CB9366A -type dir -name prop-base -active 0 -parent ECEC7A07-7C36-C3CD-BFF1-53DD1B27A949 +File ::171423D2-828C-A2F0-6460-817D86D6AEC6 -type dir -name props -active 0 -parent ECEC7A07-7C36-C3CD-BFF1-53DD1B27A949 +File ::A95B27E3-0731-5350-09F6-A20ED47C3DBC -type dir -name text-base -active 0 -parent ECEC7A07-7C36-C3CD-BFF1-53DD1B27A949 +File ::72957FF3-D51C-5F57-9A6A-188E7DF551A3 -name how_to_keys.html.svn-base -active 0 -parent A95B27E3-0731-5350-09F6-A20ED47C3DBC +File ::2ACB40DB-9D1D-97DD-6889-E63A89437823 -name how_to_keys_es.html.svn-base -active 0 -parent A95B27E3-0731-5350-09F6-A20ED47C3DBC +File ::33B94DB4-C180-92CA-28A9-8E748747A201 -type dir -name tmp -active 0 -parent ECEC7A07-7C36-C3CD-BFF1-53DD1B27A949 +File ::9A553712-B42A-6A8F-00B1-4E8933B83D00 -type dir -name prop-base -active 0 -parent 33B94DB4-C180-92CA-28A9-8E748747A201 +File ::9376A1BB-540D-AF99-82D1-DEEDB5621B31 -type dir -name props -active 0 -parent 33B94DB4-C180-92CA-28A9-8E748747A201 +File ::FDE18B19-66AE-E8C6-38A9-FB675E103E81 -type dir -name text-base -active 0 -parent 33B94DB4-C180-92CA-28A9-8E748747A201 +File ::8DC9C5E7-7957-7E7A-5603-F78DACBDE9C2 -type dir -name ../bin/collections -parent 946FC43B-0E32-4C38-86EF-4F9252C67E16 +File ::DC2682C5-68A1-8249-6160-9B1896DAECB9 -type dir -name .svn -active 0 -parent 8DC9C5E7-7957-7E7A-5603-F78DACBDE9C2 +File ::F253AE0D-A56D-F650-C7C7-0FC69D2EA3B8 -type dir -name props -active 0 -parent DC2682C5-68A1-8249-6160-9B1896DAECB9 +File ::A90AA2E8-3EEF-A991-CE94-75B3008A53F7 -type dir -name prop-base -active 0 -parent DC2682C5-68A1-8249-6160-9B1896DAECB9 +File ::EEA6B667-6883-7666-FFFC-E7701DCDBD81 -type dir -name tmp -active 0 -parent DC2682C5-68A1-8249-6160-9B1896DAECB9 +File ::5AF5F713-EEB1-AF49-EAFD-8AB218895F2F -type dir -name prop-base -active 0 -parent EEA6B667-6883-7666-FFFC-E7701DCDBD81 +File ::D98D0A8F-FA65-BECC-B972-AF8E0713F31B -type dir -name text-base -active 0 -parent EEA6B667-6883-7666-FFFC-E7701DCDBD81 +File ::3527B202-4B84-5ECD-EDF6-E1817D90434C -type dir -name props -active 0 -parent EEA6B667-6883-7666-FFFC-E7701DCDBD81 +File ::4D77EDB1-1EE5-72EA-9495-48A48F5F926C -type dir -name text-base -active 0 -parent DC2682C5-68A1-8249-6160-9B1896DAECB9 +File ::B7F88BC0-DD0F-510C-D701-C809345CB1BF -name all-wcprops -active 0 -parent DC2682C5-68A1-8249-6160-9B1896DAECB9 +File ::626C46DF-B711-6026-CA4C-2D0C7FAB64CD -name entries -active 0 -parent DC2682C5-68A1-8249-6160-9B1896DAECB9 +Component ::FB96078B-BA3C-498C-8C20-B01C1F28ACA9 -setup Install -active Yes -platforms {Windows FreeBSD-5-x86 FreeBSD-6-x86 FreeBSD-7-x86 Linux-x86_64 Solaris-x86} -name {Default Component} -parent Components +SetupType ::A87C1A6B-ED26-4B07-8736-750725FF34E4 -setup Install -active Yes -platforms {Windows FreeBSD-5-x86 FreeBSD-6-x86 FreeBSD-7-x86 Linux-x86_64 Solaris-x86} -name Typical -parent SetupTypes + +InstallComponent 1957048E-B498-4FFF-A8BA-F2DF640463B1 -setup Install -type pane -title {Welcome Screen} -component Welcome -active Yes -parent StandardInstall +InstallComponent DE1D4DF7-A35C-4228-8A25-07106AD77C9E -setup Install -type pane -title {License Agreement} -component License -active Yes -parent StandardInstall +InstallComponent EAB473BD-3ECC-4FDE-AF62-B80B89DCAE38 -setup Install -type action -conditions {354871D2-65BD-4414-BB04-F466798FA027 0F1370DF-FF15-4CE7-ADF6-CA74BC642334} -title {Modify Widget} -component ModifyWidget -active Yes -parent DE1D4DF7-A35C-4228-8A25-07106AD77C9E +Condition 354871D2-65BD-4414-BB04-F466798FA027 -active Yes -parent EAB473BD-3ECC-4FDE-AF62-B80B89DCAE38 -title {String Is Condition} -component StringIsCondition -TreeObject::id 354871D2-65BD-4414-BB04-F466798FA027 +Condition 0F1370DF-FF15-4CE7-ADF6-CA74BC642334 -active Yes -parent EAB473BD-3ECC-4FDE-AF62-B80B89DCAE38 -title {String Is Condition} -component StringIsCondition -TreeObject::id 0F1370DF-FF15-4CE7-ADF6-CA74BC642334 +InstallComponent B2E20690-C57D-4286-9977-F2541E04D71F -setup Install -type pane -conditions {F6A6DB43-C89D-4A19-98D3-1E24284260AE E8952A0A-82A0-4AD0-8FA8-8902870AF848} -title {Select Destination} -component SelectDestination -active Yes -parent StandardInstall +Condition F6A6DB43-C89D-4A19-98D3-1E24284260AE -active Yes -parent B2E20690-C57D-4286-9977-F2541E04D71F -title {Script Condition} -component ScriptCondition -TreeObject::id F6A6DB43-C89D-4A19-98D3-1E24284260AE +Condition E8952A0A-82A0-4AD0-8FA8-8902870AF848 -active Yes -parent B2E20690-C57D-4286-9977-F2541E04D71F -title {File Permission Condition} -component FilePermissionCondition -TreeObject::id E8952A0A-82A0-4AD0-8FA8-8902870AF848 +InstallComponent C862BDC0-8F67-4546-B658-4A9A8ADCE385 -setup Install -type pane -title {Start Copying Files} -component StartCopyingFiles -active Yes -parent StandardInstall +InstallComponent 268B55D8-DE61-421A-AB68-A5D4821D981F -setup Install -type pane -title {Copying Files} -component CopyFiles -active Yes -parent StandardInstall +InstallComponent 57BABE6F-717F-4D6A-8A66-921B404862F5 -setup Install -type action -title {Disable Buttons} -component ModifyWidget -active Yes -parent 268B55D8-DE61-421A-AB68-A5D4821D981F +InstallComponent 9F763EAB-21A4-41E7-B51B-EDC4ACF4C5C8 -setup Install -type action -title {Execute Action} -component ExecuteAction -active Yes -parent 268B55D8-DE61-421A-AB68-A5D4821D981F +InstallComponent 8A1B144A-F5F6-430F-A334-C31494182599 -setup Install -type action -title {Move Forward} -component MoveForward -active Yes -parent 268B55D8-DE61-421A-AB68-A5D4821D981F +InstallComponent 22E3617C-DE0E-D452-41DC-8278EA3F9D76 -setup Install -type pane -title {Custom Blank Pane 2} -component CustomBlankPane2 -active Yes -parent StandardInstall +InstallComponent 0464C461-3BD5-93CE-C3BA-C59CA84AD70D -setup Install -type action -title {Add Widget} -component AddWidget -active Yes -parent 22E3617C-DE0E-D452-41DC-8278EA3F9D76 +InstallComponent 2D8098DC-CDEA-32BE-83A6-A5AF95CC583E -setup Install -type action -title {Replace Text In File} -component ReplaceTextInFile -active Yes -parent 22E3617C-DE0E-D452-41DC-8278EA3F9D76 +InstallComponent 68A06F1C-625E-4BF0-AE3B-8BFBD37824C1 -setup Install -type pane -title {Custom Blank Pane 2} -component CustomBlankPane2 -active Yes -parent StandardInstall +InstallComponent 75288342-4CEB-473C-B242-450642503F74 -setup Install -type action -title {Add Widget} -component AddWidget -active Yes -parent 68A06F1C-625E-4BF0-AE3B-8BFBD37824C1 +InstallComponent 0C4A17DA-7867-40CC-81B4-0D1F170581AC -setup Install -type action -title {Replace Text In File} -component ReplaceTextInFile -active Yes -parent 68A06F1C-625E-4BF0-AE3B-8BFBD37824C1 +InstallComponent 1F7BE720-7885-4150-9550-F25FB1C69423 -setup Install -type pane -title {Setup Complete} -component SetupComplete -active Yes -parent StandardInstall +InstallComponent 10D62EB5-B108-461C-91D4-1D18A9CB5B08 -setup Install -type action -conditions {8112E00E-C24D-458F-9C19-03E63937E908 29B86DFA-93EA-4584-A9CF-DE823F4787F2} -title {Start Windows Service} -component StartWindowsService -active Yes -parent 1F7BE720-7885-4150-9550-F25FB1C69423 +Condition 8112E00E-C24D-458F-9C19-03E63937E908 -active Yes -parent 10D62EB5-B108-461C-91D4-1D18A9CB5B08 -title {Ask Yes or No} -component AskYesOrNo -TreeObject::id 8112E00E-C24D-458F-9C19-03E63937E908 +Condition 29B86DFA-93EA-4584-A9CF-DE823F4787F2 -active Yes -parent 10D62EB5-B108-461C-91D4-1D18A9CB5B08 -title {String Is Condition} -component StringIsCondition -TreeObject::id 29B86DFA-93EA-4584-A9CF-DE823F4787F2 +InstallComponent 60CAEDF4-53E9-46C5-9A0F-5873E12F2328 -setup Install -type action -conditions {D8C1E7BD-813A-43ED-95A4-4F5DA45D5886 3AEDBF26-DF24-4328-B5AE-E93AA5F0617B} -title {View Readme Checkbutton} -component AddWidget -active Yes -parent 1F7BE720-7885-4150-9550-F25FB1C69423 +Condition D8C1E7BD-813A-43ED-95A4-4F5DA45D5886 -active Yes -parent 60CAEDF4-53E9-46C5-9A0F-5873E12F2328 -title {File Exists Condition} -component FileExistsCondition -TreeObject::id D8C1E7BD-813A-43ED-95A4-4F5DA45D5886 +Condition 3AEDBF26-DF24-4328-B5AE-E93AA5F0617B -active Yes -parent 60CAEDF4-53E9-46C5-9A0F-5873E12F2328 -title {String Is Condition} -component StringIsCondition -TreeObject::id 3AEDBF26-DF24-4328-B5AE-E93AA5F0617B +InstallComponent 6059F771-3AA1-491C-8B84-788812912E73 -setup Install -type pane -title {Copying Files} -component CopyFiles -active Yes -parent DefaultInstall +InstallComponent 63A986C1-609D-430F-8119-EBEDFC8315EF -setup Install -type action -title {Disable Buttons} -component ModifyWidget -active Yes -parent 6059F771-3AA1-491C-8B84-788812912E73 +InstallComponent D05D0C20-4972-455A-885D-69F24E9AF177 -setup Install -type action -title {Execute Action} -component ExecuteAction -active Yes -parent 6059F771-3AA1-491C-8B84-788812912E73 +InstallComponent 13C83B15-ECEF-9C00-F46C-6E799ABF2157 -setup Install -type action -title {Replace Text In File} -component ReplaceTextInFile -active Yes -parent 6059F771-3AA1-491C-8B84-788812912E73 +InstallComponent 66412B02-0460-4B2B-9D89-57A6BBF1328D -setup Install -type action -title {Move Forward} -component MoveForward -active Yes -parent 6059F771-3AA1-491C-8B84-788812912E73 +InstallComponent 6B06C7C2-97A8-4642-B286-3B089943F359 -setup Install -type pane -title {Setup Complete} -component SetupComplete -active Yes -parent DefaultInstall +InstallComponent D945ADEC-CFCF-87DD-B8EC-480E6A87F4AF -setup Install -type action -title {Install Everything} -component ExecuteAction -active Yes -parent ConsoleInstall +InstallComponent 4F41161A-813F-4BE4-F776-3ED4F26B0CF3 -setup Install -type action -title {Replace Text In File} -component ReplaceTextInFile -active Yes -parent ConsoleInstall +InstallComponent B5904821-3970-1701-002C-0318B8BECA06 -setup Install -type action -title {Console Message} -component ConsoleMessage -active Yes -parent ConsoleInstall +InstallComponent 613FA629-E245-7370-9591-3648E0F25E00 -setup Install -type action -title {Start Windows Service} -component StartWindowsService -active Yes -parent ConsoleInstall +InstallComponent 4D9FB66C-1A02-271A-B6C3-7C88498D1A57 -setup Install -type action -title Exit -component Exit -active Yes -parent ConsoleInstall +InstallComponent 811B66F7-9751-FF4C-8189-5AB5F50E19FC -setup Install -type action -title {Install Everything} -component ExecuteAction -active Yes -parent SilentInstall +InstallComponent A2D703B9-395E-59F4-B03C-1655F2690FB7 -setup Install -type action -title {Replace Text In File} -component ReplaceTextInFile -active Yes -parent SilentInstall +InstallComponent 6EF6AADF-D373-CE5A-2D2C-26FB5BA9154D -setup Install -type action -title {Start Windows Service} -component StartWindowsService -active Yes -parent SilentInstall +InstallComponent 466DC16E-3453-409B-999C-CCDF853AA03D -setup Install -type action -title Exit -component Exit -active Yes -parent SilentInstall +InstallComponent D567240B-2A30-47FD-97AA-3EDA09B64E9F -setup Install -type actiongroup -title {Setup Actions} -active Yes -parent ActionGroupsInstall +InstallComponent 61B40FBC-EADB-4F4C-A49F-81B35B3774BB -setup Install -type actiongroup -title {Startup Actions} -active Yes -parent ActionGroupsInstall +InstallComponent 65546717-3D31-4931-B445-220199767639 -setup Install -type action -title {Create Install Panes} -component CreateInstallPanes -active Yes -parent 61B40FBC-EADB-4F4C-A49F-81B35B3774BB +InstallComponent 9C96DF15-FD21-468D-9996-76D96466D335 -setup Install -type actiongroup -title {Install Actions} -active Yes -parent ActionGroupsInstall +InstallComponent 7FB76BFF-92E4-4210-9CFA-D6CDDB7C2288 -setup Install -type action -title {Install Selected Files} -component InstallSelectedFiles -active Yes -parent 9C96DF15-FD21-468D-9996-76D96466D335 +InstallComponent F0BC8450-668B-41B2-A442-F1BE095D1BFB -setup Install -type action -title {Install Uninstaller} -component InstallUninstaller -active Yes -parent 9C96DF15-FD21-468D-9996-76D96466D335 +InstallComponent B26D8DB4-B899-384A-DA80-782EDCBC98D6 -setup Install -type action -title {Create Folder} -component CreateFolder -active Yes -parent 9C96DF15-FD21-468D-9996-76D96466D335 +InstallComponent BC8CE18E-2121-7ECF-9CA3-FE3E7FC329A1 -setup Install -type action -title {Add Directory To Path} -component AddDirectoryToPath -active Yes -parent 9C96DF15-FD21-468D-9996-76D96466D335 +InstallComponent CAA5BD76-A403-3277-17F9-2E88C8EC540E -setup Install -type action -title {Execute External Program} -component ExecuteExternalProgram -active Yes -parent 9C96DF15-FD21-468D-9996-76D96466D335 +InstallComponent 697B7934-4664-A4A2-1467-26B285C39ABC -setup Install -type action -title {Install Program Folder Shortcut} -component InstallProgramFolderShortcut -active Yes -parent 9C96DF15-FD21-468D-9996-76D96466D335 +InstallComponent EC33B744-E0BD-BCCA-7695-F6D12FBE74E6 -setup Install -type action -title {Install Program Folder Shortcut} -component InstallProgramFolderShortcut -active Yes -parent 9C96DF15-FD21-468D-9996-76D96466D335 +InstallComponent 81001CE5-6E0D-FAC5-A8BE-D7D06ADA70B2 -setup Install -type action -title {Install Program Folder Shortcut} -component InstallProgramFolderShortcut -active Yes -parent 9C96DF15-FD21-468D-9996-76D96466D335 +InstallComponent 2C6197E2-968E-F2D8-7805-E67A43EC5BB5 -setup Install -type action -title {Install Program Folder Shortcut} -component InstallProgramFolderShortcut -active Yes -parent 9C96DF15-FD21-468D-9996-76D96466D335 +InstallComponent 06959B7F-380D-DEF6-431A-1894BF9A367C -setup Install -type action -title {Install Program Folder Shortcut} -component InstallProgramFolderShortcut -active Yes -parent 9C96DF15-FD21-468D-9996-76D96466D335 +InstallComponent EC0536AE-91F2-712A-DDBD-E6DF378335EA -setup Install -type action -title {Execute External Program} -component ExecuteExternalProgram -active Yes -parent 9C96DF15-FD21-468D-9996-76D96466D335 +InstallComponent 75B1D869-C9BA-42C4-9C07-E1D156DA80A8 -setup Install -type action -title {Windows Uninstall Registry} -component AddWindowsUninstallEntry -active Yes -parent 9C96DF15-FD21-468D-9996-76D96466D335 +InstallComponent A4155ACD-0377-4A2C-B952-2C19BF592347 -setup Install -type action -title {Uninstall Shortcut} -component InstallProgramFolderShortcut -active Yes -parent 9C96DF15-FD21-468D-9996-76D96466D335 +InstallComponent 18774B81-6D13-4BD2-B6F2-852BF95814BD -setup Install -type actiongroup -title {Finish Actions} -active Yes -parent ActionGroupsInstall +InstallComponent 5EA75DE2-F9E1-405D-800E-B28FB96CDC61 -setup Install -type action -conditions {EDB4771C-ED91-462E-84D9-66E4AE0A9D9C 5CC9615C-1568-415A-A9BA-8D48DD155F7E 9D5D32C2-9AEC-46C1-98CA-F9A535E6ED82} -title {View Readme Window} -component TextWindow -active Yes -parent 18774B81-6D13-4BD2-B6F2-852BF95814BD +Condition EDB4771C-ED91-462E-84D9-66E4AE0A9D9C -active Yes -parent 5EA75DE2-F9E1-405D-800E-B28FB96CDC61 -title {String Is Condition} -component StringIsCondition -TreeObject::id EDB4771C-ED91-462E-84D9-66E4AE0A9D9C +Condition 5CC9615C-1568-415A-A9BA-8D48DD155F7E -active Yes -parent 5EA75DE2-F9E1-405D-800E-B28FB96CDC61 -title {String Is Condition} -component StringIsCondition -TreeObject::id 5CC9615C-1568-415A-A9BA-8D48DD155F7E +Condition 9D5D32C2-9AEC-46C1-98CA-F9A535E6ED82 -active Yes -parent 5EA75DE2-F9E1-405D-800E-B28FB96CDC61 -title {File Exists Condition} -component FileExistsCondition -TreeObject::id 9D5D32C2-9AEC-46C1-98CA-F9A535E6ED82 +InstallComponent CFF365EA-C5AD-4E16-9D09-E20AADED45ED -setup Install -type actiongroup -title {Cancel Actions} -active Yes -parent ActionGroupsInstall +InstallComponent F037AAD5-E79E-4544-B8C0-AA98CDF5438E -setup Uninstall -type pane -title Uninstall -component Uninstall -active Yes -parent StandardUninstall +InstallComponent 1728FDEB-5E1A-48D4-9FF8-EE993A2C04AC -setup Uninstall -type action -title {Modify Widget} -component ModifyWidget -active Yes -parent F037AAD5-E79E-4544-B8C0-AA98CDF5438E +InstallComponent 60FEFCD5-D31D-4DEA-86D7-E0246ABF0DF5 -setup Uninstall -type action -title {Execute Action} -component ExecuteAction -active Yes -parent F037AAD5-E79E-4544-B8C0-AA98CDF5438E +InstallComponent 6B488B72-9080-4AF7-8690-8D823CCD86AE -setup Uninstall -type action -title {Move Forward} -component MoveForward -active Yes -parent F037AAD5-E79E-4544-B8C0-AA98CDF5438E +InstallComponent 2C06B466-789E-4F18-B711-E8411E2CD80F -setup Uninstall -type pane -conditions 628E6478-81A8-4DF9-A4FE-EACEFAEA2E93 -title {Uninstall Details} -component UninstallDetails -active Yes -parent StandardUninstall +Condition 628E6478-81A8-4DF9-A4FE-EACEFAEA2E93 -active Yes -parent 2C06B466-789E-4F18-B711-E8411E2CD80F -title {String Is Condition} -component StringIsCondition -TreeObject::id 628E6478-81A8-4DF9-A4FE-EACEFAEA2E93 +InstallComponent C0AAD722-CF3D-4708-A62F-4EE9C92F7B24 -setup Uninstall -type pane -title {Uninstall Complete} -component UninstallComplete -active Yes -parent StandardUninstall +InstallComponent C19EE9A4-6BBE-4631-8013-7B7DCA588367 -setup Uninstall -type action -title {Console Ask Yes Or No} -component ConsoleAskYesOrNo -active Yes -parent ConsoleUninstall +InstallComponent AA0A7460-2E6B-4DB1-A7EF-845A1C7B09CE -setup Uninstall -type action -conditions 96F7BA2D-A593-40DC-89C9-AE7895FD0984 -title Exit -component Exit -active Yes -parent ConsoleUninstall +Condition 96F7BA2D-A593-40DC-89C9-AE7895FD0984 -active Yes -parent AA0A7460-2E6B-4DB1-A7EF-845A1C7B09CE -title {String Is Condition} -component StringIsCondition -TreeObject::id 96F7BA2D-A593-40DC-89C9-AE7895FD0984 +InstallComponent 1D572EE2-DD93-4F13-850E-DE0EEB1DA110 -setup Uninstall -type action -title {Console Message} -component ConsoleMessage -active Yes -parent ConsoleUninstall +InstallComponent A518E166-9DC7-454F-8EFE-CD4461F093FB -setup Uninstall -type action -title {Execute Action} -component ExecuteAction -active Yes -parent ConsoleUninstall +InstallComponent 4E1B9A69-B88E-4DE5-A0E1-08E04C4BE6B3 -setup Uninstall -type action -title {Console Message} -component ConsoleMessage -active Yes -parent ConsoleUninstall +InstallComponent 6ADB9508-5F82-4564-B6AC-1170A76B4CB9 -setup Uninstall -type action -title Exit -component Exit -active Yes -parent ConsoleUninstall +InstallComponent F71872ED-E931-4B96-B4F8-1F65356FE848 -setup Uninstall -type action -title {Execute Action} -component ExecuteAction -active Yes -parent SilentUninstall +InstallComponent CFEEDA4E-6870-4C25-8847-2ABB087DF90D -setup Uninstall -type action -title Exit -component Exit -active Yes -parent SilentUninstall +InstallComponent ED3D7C90-4A56-40EE-A2C5-E845C3A57C12 -setup Uninstall -type actiongroup -title {Setup Actions} -active Yes -parent ActionGroupsUninstall +InstallComponent B923CC3C-CD18-4F8A-9648-51ADE1168D4A -setup Uninstall -type actiongroup -title {Startup Actions} -active Yes -parent ActionGroupsUninstall +InstallComponent 716175FD-DD14-46E4-AC3E-2E6483C6FF7D -setup Uninstall -type action -conditions {103DC6E3-97DC-46AC-81C5-DED8E4E319E7 DAE5A5A9-35B4-44B5-89C0-F25FDD2771FB} -title Exit -component Exit -active Yes -parent B923CC3C-CD18-4F8A-9648-51ADE1168D4A +Condition 103DC6E3-97DC-46AC-81C5-DED8E4E319E7 -active Yes -parent 716175FD-DD14-46E4-AC3E-2E6483C6FF7D -title {String Is Condition} -component StringIsCondition -TreeObject::id 103DC6E3-97DC-46AC-81C5-DED8E4E319E7 +Condition DAE5A5A9-35B4-44B5-89C0-F25FDD2771FB -active Yes -parent 716175FD-DD14-46E4-AC3E-2E6483C6FF7D -title {Ask Yes or No} -component AskYesOrNo -TreeObject::id DAE5A5A9-35B4-44B5-89C0-F25FDD2771FB +InstallComponent 73AB9FDF-9481-4EC3-8B31-C109BAA1086C -setup Uninstall -type actiongroup -title {Uninstall Actions} -active Yes -parent ActionGroupsUninstall +InstallComponent 19131BB8-88ED-C9E4-A5CF-8873BE8F5D09 -setup Uninstall -type action -title {Execute External Program} -component ExecuteExternalProgram -active Yes -parent 73AB9FDF-9481-4EC3-8B31-C109BAA1086C +InstallComponent 3A1294BA-6D93-95C0-D81D-3435E62A69F3 -setup Uninstall -type action -title {Execute External Program} -component ExecuteExternalProgram -active Yes -parent 73AB9FDF-9481-4EC3-8B31-C109BAA1086C +InstallComponent 73C87D6F-ACBB-026B-157C-1CC1FD4C4EEC -setup Uninstall -type action -title {Execute External Program} -component ExecuteExternalProgram -active Yes -parent 73AB9FDF-9481-4EC3-8B31-C109BAA1086C +InstallComponent 0BABDE07-5132-BB2B-CDB4-AED542367076 -setup Uninstall -type action -title {Remove Directory From Path} -component RemoveDirectoryFromPath -active Yes -parent 73AB9FDF-9481-4EC3-8B31-C109BAA1086C +InstallComponent D2829903-F232-F03E-070A-386860F74F4A -setup Uninstall -type action -title {Delete File} -component DeleteFile -active Yes -parent 73AB9FDF-9481-4EC3-8B31-C109BAA1086C +InstallComponent 100C074A-1AB7-6813-12F8-585CF0B5C2D5 -setup Uninstall -type action -title {Uninstall Leftover Files} -component UninstallLeftoverFiles -active Yes -parent 73AB9FDF-9481-4EC3-8B31-C109BAA1086C +InstallComponent ACFFE9C0-C404-4FD9-AD70-8F60E822DE65 -setup Uninstall -type action -title {Uninstall Selected Files} -component UninstallSelectedFiles -active Yes -parent 73AB9FDF-9481-4EC3-8B31-C109BAA1086C +InstallComponent AA00EDED-9979-419F-A32C-DF1480E9EFF0 -setup Uninstall -type actiongroup -title {Finish Actions} -active Yes -parent ActionGroupsUninstall +InstallComponent BC4AB013-F50F-49BF-BF98-FF7EBE16BCA4 -setup Uninstall -type actiongroup -title {Cancel Actions} -active Yes -parent ActionGroupsUninstall + +array set Properties { +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Conditions +{0 conditions} + +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Height +{20} + +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,LabelSide +{left} + +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,LabelWidth +{28} + +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Text,subst +{1} + +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Type +{entry} + +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Value +{Servers} + +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,VirtualText +{AgentGroup} + +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Width +{420} + +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,X +{20} + +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Y +{190} + +06959B7F-380D-DEF6-431A-1894BF9A367C,Conditions +{0 conditions} + +06959B7F-380D-DEF6-431A-1894BF9A367C,ShortcutName +{<%PandoraLicense%>} + +06959B7F-380D-DEF6-431A-1894BF9A367C,TargetFileName +{<%ProgramLicense%>} + +06959B7F-380D-DEF6-431A-1894BF9A367C,WorkingDirectory +{<%InstallDir%>} + +0BABDE07-5132-BB2B-CDB4-AED542367076,Conditions +{0 conditions} + +0BABDE07-5132-BB2B-CDB4-AED542367076,Directory +{<%InstallDir%>\util} + +0BABDE07-5132-BB2B-CDB4-AED542367076,Level +{system} + +0C4A17DA-7867-40CC-81B4-0D1F170581AC,Conditions +{0 conditions} + +0C4A17DA-7867-40CC-81B4-0D1F170581AC,ExecuteAction +{Before Next Pane is Displayed} + +0C4A17DA-7867-40CC-81B4-0D1F170581AC,Files +{pandora_agent.conf} + +0C4A17DA-7867-40CC-81B4-0D1F170581AC,StringMap +{$ServerIP$ <%ServerIP%> + $ServerPath$ /var/spool/pandora/data_in + $AgentTemp$ <%InstallDir%>\\temp} + +0F1370DF-FF15-4CE7-ADF6-CA74BC642334,CheckCondition +{Before Action is Executed} + +0F1370DF-FF15-4CE7-ADF6-CA74BC642334,Operator +{false} + +0F1370DF-FF15-4CE7-ADF6-CA74BC642334,String +{<%LicenseAccepted%>} + +100C074A-1AB7-6813-12F8-585CF0B5C2D5,Conditions +{0 conditions} + +103DC6E3-97DC-46AC-81C5-DED8E4E319E7,CheckCondition +{Before Action is Executed} + +103DC6E3-97DC-46AC-81C5-DED8E4E319E7,String +{<%GuiMode%>} + +10D62EB5-B108-461C-91D4-1D18A9CB5B08,Conditions +{2 conditions} + +10D62EB5-B108-461C-91D4-1D18A9CB5B08,ServiceName +{pandoraFMSagent} + +13C83B15-ECEF-9C00-F46C-6E799ABF2157,Conditions +{0 conditions} + +13C83B15-ECEF-9C00-F46C-6E799ABF2157,ExecuteAction +{Before Next Pane is Displayed} + +13C83B15-ECEF-9C00-F46C-6E799ABF2157,Files +{pandora_agent.conf} + +13C83B15-ECEF-9C00-F46C-6E799ABF2157,StringMap +{$ServerIP$ localhost + $ServerPath$ /var/spool/pandora/data_in + $AgentTemp$ <%InstallDir%>\\temp} + +1728FDEB-5E1A-48D4-9FF8-EE993A2C04AC,Conditions +{0 conditions} + +1728FDEB-5E1A-48D4-9FF8-EE993A2C04AC,State +{disabled} + +1728FDEB-5E1A-48D4-9FF8-EE993A2C04AC,Widget +{NextButton; CancelButton} + +18774B81-6D13-4BD2-B6F2-852BF95814BD,Alias +{Finish Actions} + +18774B81-6D13-4BD2-B6F2-852BF95814BD,Conditions +{0 conditions} + +19131BB8-88ED-C9E4-A5CF-8873BE8F5D09,Conditions +{0 conditions} + +19131BB8-88ED-C9E4-A5CF-8873BE8F5D09,ConsoleTitle +{<%AppName%> Deleting Pandora FMS Agent AT job} + +19131BB8-88ED-C9E4-A5CF-8873BE8F5D09,ProgramCommandLine +{delete_at_job.bat} + +19131BB8-88ED-C9E4-A5CF-8873BE8F5D09,WorkingDirectory +{<%InstallDir%>/scripts} + +1957048E-B498-4FFF-A8BA-F2DF640463B1,BackButton,subst +{1} + +1957048E-B498-4FFF-A8BA-F2DF640463B1,CancelButton,subst +{1} + +1957048E-B498-4FFF-A8BA-F2DF640463B1,Caption,subst +{1} + +1957048E-B498-4FFF-A8BA-F2DF640463B1,Conditions +{0 conditions} + +1957048E-B498-4FFF-A8BA-F2DF640463B1,Message,subst +{1} + +1957048E-B498-4FFF-A8BA-F2DF640463B1,NextButton,subst +{1} + +1D572EE2-DD93-4F13-850E-DE0EEB1DA110,Conditions +{0 conditions} + +1D572EE2-DD93-4F13-850E-DE0EEB1DA110,Message,subst +{1} + +1F7BE720-7885-4150-9550-F25FB1C69423,BackButton,subst +{0} + +1F7BE720-7885-4150-9550-F25FB1C69423,Buttons +{Next} + +1F7BE720-7885-4150-9550-F25FB1C69423,CancelButton,subst +{0} + +1F7BE720-7885-4150-9550-F25FB1C69423,Caption,subst +{1} + +1F7BE720-7885-4150-9550-F25FB1C69423,Conditions +{0 conditions} + +1F7BE720-7885-4150-9550-F25FB1C69423,Message,subst +{1} + +1F7BE720-7885-4150-9550-F25FB1C69423,NextButton,subst +{1} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Active +{Yes} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,BackButton,subst +{1} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Buttons +{Next} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,CancelButton,subst +{1} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Caption,subst +{1} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Conditions +{0 conditions} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Message,subst +{1} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,NextButton,subst +{1} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Subtitle,subst +{0} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Title,subst +{1} + +268B55D8-DE61-421A-AB68-A5D4821D981F,BackButton,subst +{1} + +268B55D8-DE61-421A-AB68-A5D4821D981F,Buttons +{Cancel} + +268B55D8-DE61-421A-AB68-A5D4821D981F,CancelButton,subst +{1} + +268B55D8-DE61-421A-AB68-A5D4821D981F,Caption,subst +{1} + +268B55D8-DE61-421A-AB68-A5D4821D981F,Conditions +{0 conditions} + +268B55D8-DE61-421A-AB68-A5D4821D981F,FileLabel,subst +{1} + +268B55D8-DE61-421A-AB68-A5D4821D981F,Message,subst +{1} + +268B55D8-DE61-421A-AB68-A5D4821D981F,NextButton,subst +{1} + +268B55D8-DE61-421A-AB68-A5D4821D981F,ProgressValue,subst +{1} + +268B55D8-DE61-421A-AB68-A5D4821D981F,Subtitle,subst +{1} + +268B55D8-DE61-421A-AB68-A5D4821D981F,Title,subst +{1} + +29B86DFA-93EA-4584-A9CF-DE823F4787F2,CheckCondition +{Before Action is Executed} + +29B86DFA-93EA-4584-A9CF-DE823F4787F2,FailureMessage +{Error starting Pandora FMS service} + +29B86DFA-93EA-4584-A9CF-DE823F4787F2,String +{<%Answer%>} + +2C06B466-789E-4F18-B711-E8411E2CD80F,BackButton,subst +{1} + +2C06B466-789E-4F18-B711-E8411E2CD80F,CancelButton,subst +{1} + +2C06B466-789E-4F18-B711-E8411E2CD80F,Caption,subst +{1} + +2C06B466-789E-4F18-B711-E8411E2CD80F,Conditions +{1 condition} + +2C06B466-789E-4F18-B711-E8411E2CD80F,Message,subst +{1} + +2C06B466-789E-4F18-B711-E8411E2CD80F,NextButton,subst +{1} + +2C06B466-789E-4F18-B711-E8411E2CD80F,Subtitle,subst +{1} + +2C06B466-789E-4F18-B711-E8411E2CD80F,Text,subst +{1} + +2C06B466-789E-4F18-B711-E8411E2CD80F,Title,subst +{1} + +2C6197E2-968E-F2D8-7805-E67A43EC5BB5,Conditions +{0 conditions} + +2C6197E2-968E-F2D8-7805-E67A43EC5BB5,ShortcutName +{<%EditConfiguration%>} + +2C6197E2-968E-F2D8-7805-E67A43EC5BB5,TargetFileName +{<%InstallDir%>\pandora_agent.conf} + +2C6197E2-968E-F2D8-7805-E67A43EC5BB5,WorkingDirectory +{<%InstallDir%>} + +2D8098DC-CDEA-32BE-83A6-A5AF95CC583E,Conditions +{0 conditions} + +2D8098DC-CDEA-32BE-83A6-A5AF95CC583E,ExecuteAction +{Before Next Pane is Displayed} + +2D8098DC-CDEA-32BE-83A6-A5AF95CC583E,Files +{pandora_agent.conf} + +2D8098DC-CDEA-32BE-83A6-A5AF95CC583E,StringMap +{$AgentGroup$ <%AgentGroup%>} + +354871D2-65BD-4414-BB04-F466798FA027,CheckCondition +{Before Action is Executed} + +354871D2-65BD-4414-BB04-F466798FA027,String +{<%Property <%CurrentPane%> UserMustAcceptLicense%>} + +3A1294BA-6D93-95C0-D81D-3435E62A69F3,Conditions +{0 conditions} + +3A1294BA-6D93-95C0-D81D-3435E62A69F3,ConsoleTitle +{<%AppName%> Stopping Pandora FMS agent} + +3A1294BA-6D93-95C0-D81D-3435E62A69F3,ProgramCommandLine +{stop_pandora_agent.bat} + +3A1294BA-6D93-95C0-D81D-3435E62A69F3,WorkingDirectory +{<%InstallDir%>/scripts} + +3AEDBF26-DF24-4328-B5AE-E93AA5F0617B,CheckCondition +{Before Action is Executed} + +3AEDBF26-DF24-4328-B5AE-E93AA5F0617B,Operator +{false} + +3AEDBF26-DF24-4328-B5AE-E93AA5F0617B,String +{<%InstallStopped%>} + +466DC16E-3453-409B-999C-CCDF853AA03D,Conditions +{0 conditions} + +466DC16E-3453-409B-999C-CCDF853AA03D,ExitType +{Finish} + +4D9FB66C-1A02-271A-B6C3-7C88498D1A57,Conditions +{0 conditions} + +4D9FB66C-1A02-271A-B6C3-7C88498D1A57,ExitType +{Finish} + +4E1B9A69-B88E-4DE5-A0E1-08E04C4BE6B3,Conditions +{0 conditions} + +4E1B9A69-B88E-4DE5-A0E1-08E04C4BE6B3,Message,subst +{1} + +4F41161A-813F-4BE4-F776-3ED4F26B0CF3,Conditions +{0 conditions} + +4F41161A-813F-4BE4-F776-3ED4F26B0CF3,ExecuteAction +{Before Next Pane is Displayed} + +4F41161A-813F-4BE4-F776-3ED4F26B0CF3,Files +{pandora_agent.conf} + +4F41161A-813F-4BE4-F776-3ED4F26B0CF3,StringMap +{$ServerIP$ localhost + $ServerPath$ /var/spool/pandora/data_in + $AgentTemp$ <%InstallDir%>\\temp} + +57BABE6F-717F-4D6A-8A66-921B404862F5,Conditions +{0 conditions} + +57BABE6F-717F-4D6A-8A66-921B404862F5,State +{disabled} + +57BABE6F-717F-4D6A-8A66-921B404862F5,Widget +{Back Button;Next Button} + +5CC9615C-1568-415A-A9BA-8D48DD155F7E,CheckCondition +{Before Action is Executed} + +5CC9615C-1568-415A-A9BA-8D48DD155F7E,String +{<%ViewReadme%>} + +5EA75DE2-F9E1-405D-800E-B28FB96CDC61,Caption,subst +{1} + +5EA75DE2-F9E1-405D-800E-B28FB96CDC61,CloseButton,subst +{1} + +5EA75DE2-F9E1-405D-800E-B28FB96CDC61,Conditions +{3 conditions} + +5EA75DE2-F9E1-405D-800E-B28FB96CDC61,Message,subst +{1} + +5EA75DE2-F9E1-405D-800E-B28FB96CDC61,TextFile +{<%ProgramReadme%>} + +5EA75DE2-F9E1-405D-800E-B28FB96CDC61,Title,subst +{1} + +6059F771-3AA1-491C-8B84-788812912E73,BackButton,subst +{1} + +6059F771-3AA1-491C-8B84-788812912E73,CancelButton,subst +{1} + +6059F771-3AA1-491C-8B84-788812912E73,Caption,subst +{1} + +6059F771-3AA1-491C-8B84-788812912E73,Conditions +{0 conditions} + +6059F771-3AA1-491C-8B84-788812912E73,FileLabel,subst +{1} + +6059F771-3AA1-491C-8B84-788812912E73,Message,subst +{1} + +6059F771-3AA1-491C-8B84-788812912E73,NextButton,subst +{1} + +6059F771-3AA1-491C-8B84-788812912E73,ProgressValue,subst +{1} + +6059F771-3AA1-491C-8B84-788812912E73,Subtitle,subst +{1} + +6059F771-3AA1-491C-8B84-788812912E73,Title,subst +{1} + +60CAEDF4-53E9-46C5-9A0F-5873E12F2328,Background +{white} + +60CAEDF4-53E9-46C5-9A0F-5873E12F2328,Checked +{Yes} + +60CAEDF4-53E9-46C5-9A0F-5873E12F2328,Conditions +{2 conditions} + +60CAEDF4-53E9-46C5-9A0F-5873E12F2328,Text,subst +{1} + +60CAEDF4-53E9-46C5-9A0F-5873E12F2328,Type +{checkbutton} + +60CAEDF4-53E9-46C5-9A0F-5873E12F2328,VirtualText +{ViewReadme} + +60CAEDF4-53E9-46C5-9A0F-5873E12F2328,X +{185} + +60CAEDF4-53E9-46C5-9A0F-5873E12F2328,Y +{250} + +60FEFCD5-D31D-4DEA-86D7-E0246ABF0DF5,Action +{Uninstall Actions} + +60FEFCD5-D31D-4DEA-86D7-E0246ABF0DF5,Conditions +{0 conditions} + +613FA629-E245-7370-9591-3648E0F25E00,Conditions +{0 conditions} + +613FA629-E245-7370-9591-3648E0F25E00,ServiceName +{pandoraFMSagent} + +61B40FBC-EADB-4F4C-A49F-81B35B3774BB,Alias +{Startup Actions} + +61B40FBC-EADB-4F4C-A49F-81B35B3774BB,Conditions +{0 conditions} + +628E6478-81A8-4DF9-A4FE-EACEFAEA2E93,String +{<%ErrorsOccurred%>} + +63A986C1-609D-430F-8119-EBEDFC8315EF,Conditions +{0 conditions} + +63A986C1-609D-430F-8119-EBEDFC8315EF,State +{disabled} + +63A986C1-609D-430F-8119-EBEDFC8315EF,Widget +{Back Button;Next Button} + +65546717-3D31-4931-B445-220199767639,Conditions +{0 conditions} + +66412B02-0460-4B2B-9D89-57A6BBF1328D,Conditions +{0 conditions} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Active +{Yes} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,BackButton,subst +{1} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Buttons +{Next} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,CancelButton,subst +{1} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Caption,subst +{1} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Conditions +{0 conditions} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Message,subst +{1} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,NextButton,subst +{1} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Subtitle,subst +{0} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Title,subst +{1} + +697B7934-4664-A4A2-1467-26B285C39ABC,Conditions +{0 conditions} + +697B7934-4664-A4A2-1467-26B285C39ABC,IconPath +{<%InstallDir%>\pandora.ico} + +697B7934-4664-A4A2-1467-26B285C39ABC,ShortcutName +{<%StopPandoraService%>} + +697B7934-4664-A4A2-1467-26B285C39ABC,TargetFileName +{<%InstallDir%>\scripts\stop_pandora_agent.bat} + +697B7934-4664-A4A2-1467-26B285C39ABC,WorkingDirectory +{<%InstallDir%>} + +6ADB9508-5F82-4564-B6AC-1170A76B4CB9,Conditions +{0 conditions} + +6ADB9508-5F82-4564-B6AC-1170A76B4CB9,ExitType +{Finish} + +6B06C7C2-97A8-4642-B286-3B089943F359,BackButton,subst +{1} + +6B06C7C2-97A8-4642-B286-3B089943F359,Buttons +{Next} + +6B06C7C2-97A8-4642-B286-3B089943F359,CancelButton,subst +{1} + +6B06C7C2-97A8-4642-B286-3B089943F359,Caption,subst +{1} + +6B06C7C2-97A8-4642-B286-3B089943F359,Conditions +{0 conditions} + +6B06C7C2-97A8-4642-B286-3B089943F359,Message,subst +{1} + +6B06C7C2-97A8-4642-B286-3B089943F359,NextButton,subst +{1} + +6B488B72-9080-4AF7-8690-8D823CCD86AE,Conditions +{0 conditions} + +6EF6AADF-D373-CE5A-2D2C-26FB5BA9154D,Conditions +{0 conditions} + +6EF6AADF-D373-CE5A-2D2C-26FB5BA9154D,ServiceName +{pandoraFMSagent} + +716175FD-DD14-46E4-AC3E-2E6483C6FF7D,Comment +{Ask the user if they want to proceed with the uninstall.} + +716175FD-DD14-46E4-AC3E-2E6483C6FF7D,Conditions +{2 conditions} + +73AB9FDF-9481-4EC3-8B31-C109BAA1086C,Alias +{Uninstall Actions} + +73AB9FDF-9481-4EC3-8B31-C109BAA1086C,Conditions +{0 conditions} + +73C87D6F-ACBB-026B-157C-1CC1FD4C4EEC,Conditions +{0 conditions} + +73C87D6F-ACBB-026B-157C-1CC1FD4C4EEC,ConsoleTitle +{<%AppName%> Deregistering Pandora FMS Agent service} + +73C87D6F-ACBB-026B-157C-1CC1FD4C4EEC,ProgramCommandLine +{PandoraAgent.exe --uninstall} + +73C87D6F-ACBB-026B-157C-1CC1FD4C4EEC,WorkingDirectory +{<%InstallDir%>} + +75288342-4CEB-473C-B242-450642503F74,Conditions +{0 conditions} + +75288342-4CEB-473C-B242-450642503F74,Height +{20} + +75288342-4CEB-473C-B242-450642503F74,LabelSide +{left} + +75288342-4CEB-473C-B242-450642503F74,LabelWidth +{28} + +75288342-4CEB-473C-B242-450642503F74,Text,subst +{1} + +75288342-4CEB-473C-B242-450642503F74,Type +{entry} + +75288342-4CEB-473C-B242-450642503F74,Value +{myserver.ipaddress.net} + +75288342-4CEB-473C-B242-450642503F74,VirtualText +{ServerIP} + +75288342-4CEB-473C-B242-450642503F74,Width +{420} + +75288342-4CEB-473C-B242-450642503F74,X +{20} + +75288342-4CEB-473C-B242-450642503F74,Y +{190} + +75B1D869-C9BA-42C4-9C07-E1D156DA80A8,Conditions +{0 conditions} + +7FB76BFF-92E4-4210-9CFA-D6CDDB7C2288,Conditions +{0 conditions} + +7FB76BFF-92E4-4210-9CFA-D6CDDB7C2288,UpdateFilePercentage +{Yes} + +7FB76BFF-92E4-4210-9CFA-D6CDDB7C2288,UpdateFileText +{Yes} + +81001CE5-6E0D-FAC5-A8BE-D7D06ADA70B2,Conditions +{0 conditions} + +81001CE5-6E0D-FAC5-A8BE-D7D06ADA70B2,ShortcutName +{<%Readme%>} + +81001CE5-6E0D-FAC5-A8BE-D7D06ADA70B2,TargetFileName +{<%ProgramReadme%>} + +81001CE5-6E0D-FAC5-A8BE-D7D06ADA70B2,WorkingDirectory +{<%InstallDir%>} + +8112E00E-C24D-458F-9C19-03E63937E908,CheckCondition +{Before Action is Executed} + +8112E00E-C24D-458F-9C19-03E63937E908,FailureMessage +{Service not initialized. Try to init Pandora Windows Agent Service manually.} + +8112E00E-C24D-458F-9C19-03E63937E908,Message,subst +{1} + +8112E00E-C24D-458F-9C19-03E63937E908,Title,subst +{1} + +811B66F7-9751-FF4C-8189-5AB5F50E19FC,Action +{Install Actions} + +811B66F7-9751-FF4C-8189-5AB5F50E19FC,Conditions +{0 conditions} + +8A1B144A-F5F6-430F-A334-C31494182599,Conditions +{0 conditions} + +946FC43B-0E32-4C38-86EF-4F9252C67E16,Destination +{<%InstallDir%>} + +946FC43B-0E32-4C38-86EF-4F9252C67E16,FileSize +{15267909} + +946FC43B-0E32-4C38-86EF-4F9252C67E16,Name +{Program Files} + +96F7BA2D-A593-40DC-89C9-AE7895FD0984,CheckCondition +{Before Action is Executed} + +96F7BA2D-A593-40DC-89C9-AE7895FD0984,Operator +{false} + +96F7BA2D-A593-40DC-89C9-AE7895FD0984,String +{<%Answer%>} + +9C96DF15-FD21-468D-9996-76D96466D335,Alias +{Install Actions} + +9C96DF15-FD21-468D-9996-76D96466D335,Conditions +{0 conditions} + +9D5D32C2-9AEC-46C1-98CA-F9A535E6ED82,CheckCondition +{Before Action is Executed} + +9D5D32C2-9AEC-46C1-98CA-F9A535E6ED82,Filename +{<%ProgramReadme%>} + +9F763EAB-21A4-41E7-B51B-EDC4ACF4C5C8,Action +{Install Actions} + +9F763EAB-21A4-41E7-B51B-EDC4ACF4C5C8,Conditions +{0 conditions} + +A2D703B9-395E-59F4-B03C-1655F2690FB7,Conditions +{0 conditions} + +A2D703B9-395E-59F4-B03C-1655F2690FB7,ExecuteAction +{Before Next Pane is Displayed} + +A2D703B9-395E-59F4-B03C-1655F2690FB7,Files +{pandora_agent.conf} + +A2D703B9-395E-59F4-B03C-1655F2690FB7,StringMap +{$ServerIP$ localhost + $ServerPath$ /var/spool/pandora/data_in + $AgentTemp$ <%InstallDir%>\\temp} + +A4155ACD-0377-4A2C-B952-2C19BF592347,Conditions +{0 conditions} + +A4155ACD-0377-4A2C-B952-2C19BF592347,FileName +{<%ShortAppName%>-uninstall} + +A4155ACD-0377-4A2C-B952-2C19BF592347,ShortcutName +{<%UninstallApplicationText%>} + +A4155ACD-0377-4A2C-B952-2C19BF592347,TargetFileName +{<%Uninstaller%>} + +A4155ACD-0377-4A2C-B952-2C19BF592347,WorkingDirectory +{<%InstallDir%>} + +A518E166-9DC7-454F-8EFE-CD4461F093FB,Action +{Uninstall Actions} + +A518E166-9DC7-454F-8EFE-CD4461F093FB,Conditions +{0 conditions} + +A87C1A6B-ED26-4B07-8736-750725FF34E4,Components +{FB96078B-BA3C-498C-8C20-B01C1F28ACA9} + +A87C1A6B-ED26-4B07-8736-750725FF34E4,Description,subst +{1} + +A87C1A6B-ED26-4B07-8736-750725FF34E4,DisplayName,subst +{1} + +A87C1A6B-ED26-4B07-8736-750725FF34E4,Name +{Typical} + +A87C1A6B-ED26-4B07-8736-750725FF34E4,ShowSetupType +{No} + +AA00EDED-9979-419F-A32C-DF1480E9EFF0,Alias +{Finish Actions} + +AA00EDED-9979-419F-A32C-DF1480E9EFF0,Conditions +{0 conditions} + +AA0A7460-2E6B-4DB1-A7EF-845A1C7B09CE,Conditions +{1 condition} + +ACFFE9C0-C404-4FD9-AD70-8F60E822DE65,Conditions +{0 conditions} + +AIX-ppc,Active +{No} + +AIX-ppc,BuildSeparateArchives +{No} + +AIX-ppc,DefaultDirectoryPermission +{0755} + +AIX-ppc,DefaultFilePermission +{0755} + +AIX-ppc,Executable +{<%AppName%>-<%Version%>-<%Platform%>-Install<%Ext%>} + +AIX-ppc,FallBackToConsole +{Yes} + +AIX-ppc,InstallDir +{<%Home%>/<%ShortAppName%>} + +AIX-ppc,InstallMode +{Standard} + +AIX-ppc,InstallType +{Typical} + +AIX-ppc,ProgramExecutable +{} + +AIX-ppc,ProgramFolderAllUsers +{No} + +AIX-ppc,ProgramFolderName +{<%AppName%>} + +AIX-ppc,ProgramLicense +{<%InstallDir%>/installer/LICENSE.txt} + +AIX-ppc,ProgramName +{} + +AIX-ppc,ProgramReadme +{<%InstallDir%>/installer/README.txt} + +AIX-ppc,PromptForRoot +{Yes} + +AIX-ppc,RequireRoot +{No} + +AIX-ppc,RootInstallDir +{/usr/local/<%ShortAppName%>} + +B26D8DB4-B899-384A-DA80-782EDCBC98D6,Conditions +{0 conditions} + +B26D8DB4-B899-384A-DA80-782EDCBC98D6,FolderName +{<%InstallDir%>\temp} + +B2E20690-C57D-4286-9977-F2541E04D71F,BackButton,subst +{1} + +B2E20690-C57D-4286-9977-F2541E04D71F,BrowseButton,subst +{1} + +B2E20690-C57D-4286-9977-F2541E04D71F,BrowseText,subst +{1} + +B2E20690-C57D-4286-9977-F2541E04D71F,Buttons +{Next/Cancel} + +B2E20690-C57D-4286-9977-F2541E04D71F,CancelButton,subst +{1} + +B2E20690-C57D-4286-9977-F2541E04D71F,Caption,subst +{1} + +B2E20690-C57D-4286-9977-F2541E04D71F,Conditions +{2 conditions} + +B2E20690-C57D-4286-9977-F2541E04D71F,Destination,subst +{1} + +B2E20690-C57D-4286-9977-F2541E04D71F,DestinationLabel,subst +{0} + +B2E20690-C57D-4286-9977-F2541E04D71F,Message,subst +{1} + +B2E20690-C57D-4286-9977-F2541E04D71F,NextButton,subst +{1} + +B2E20690-C57D-4286-9977-F2541E04D71F,Subtitle,subst +{1} + +B2E20690-C57D-4286-9977-F2541E04D71F,Title,subst +{1} + +B5904821-3970-1701-002C-0318B8BECA06,Conditions +{0 conditions} + +B5904821-3970-1701-002C-0318B8BECA06,Message,subst +{1} + +B923CC3C-CD18-4F8A-9648-51ADE1168D4A,Alias +{Startup Actions} + +B923CC3C-CD18-4F8A-9648-51ADE1168D4A,Conditions +{0 conditions} + +BC4AB013-F50F-49BF-BF98-FF7EBE16BCA4,Alias +{Cancel Actions} + +BC8CE18E-2121-7ECF-9CA3-FE3E7FC329A1,Conditions +{0 conditions} + +BC8CE18E-2121-7ECF-9CA3-FE3E7FC329A1,Directory +{<%InstallDir%>\util} + +BC8CE18E-2121-7ECF-9CA3-FE3E7FC329A1,Level +{system} + +C0AAD722-CF3D-4708-A62F-4EE9C92F7B24,BackButton,subst +{1} + +C0AAD722-CF3D-4708-A62F-4EE9C92F7B24,CancelButton,subst +{1} + +C0AAD722-CF3D-4708-A62F-4EE9C92F7B24,Caption,subst +{1} + +C0AAD722-CF3D-4708-A62F-4EE9C92F7B24,Conditions +{0 conditions} + +C0AAD722-CF3D-4708-A62F-4EE9C92F7B24,Message,subst +{1} + +C0AAD722-CF3D-4708-A62F-4EE9C92F7B24,NextButton,subst +{1} + +C19EE9A4-6BBE-4631-8013-7B7DCA588367,Conditions +{0 conditions} + +C19EE9A4-6BBE-4631-8013-7B7DCA588367,Default +{Yes} + +C19EE9A4-6BBE-4631-8013-7B7DCA588367,Prompt +{<%UninstallStartupText%>} + +C862BDC0-8F67-4546-B658-4A9A8ADCE385,BackButton,subst +{1} + +C862BDC0-8F67-4546-B658-4A9A8ADCE385,Buttons +{Next/Cancel} + +C862BDC0-8F67-4546-B658-4A9A8ADCE385,CancelButton,subst +{1} + +C862BDC0-8F67-4546-B658-4A9A8ADCE385,Caption,subst +{1} + +C862BDC0-8F67-4546-B658-4A9A8ADCE385,Conditions +{0 conditions} + +C862BDC0-8F67-4546-B658-4A9A8ADCE385,Message,subst +{1} + +C862BDC0-8F67-4546-B658-4A9A8ADCE385,NextButton,subst +{1} + +C862BDC0-8F67-4546-B658-4A9A8ADCE385,Subtitle,subst +{1} + +C862BDC0-8F67-4546-B658-4A9A8ADCE385,Text,subst +{1} + +C862BDC0-8F67-4546-B658-4A9A8ADCE385,Title,subst +{1} + +CAA5BD76-A403-3277-17F9-2E88C8EC540E,Conditions +{0 conditions} + +CAA5BD76-A403-3277-17F9-2E88C8EC540E,ConsoleTitle +{<%AppName%> Installing Pandora FMS Agent as windows service} + +CAA5BD76-A403-3277-17F9-2E88C8EC540E,ProgramCommandLine +{PandoraAgent.exe --install} + +CAA5BD76-A403-3277-17F9-2E88C8EC540E,WorkingDirectory +{<%InstallDir%>} + +CFEEDA4E-6870-4C25-8847-2ABB087DF90D,ExitType +{Finish} + +CFF365EA-C5AD-4E16-9D09-E20AADED45ED,Alias +{Cancel Actions} + +D05D0C20-4972-455A-885D-69F24E9AF177,Action +{Install Actions} + +D05D0C20-4972-455A-885D-69F24E9AF177,Conditions +{0 conditions} + +D2829903-F232-F03E-070A-386860F74F4A,Conditions +{0 conditions} + +D2829903-F232-F03E-070A-386860F74F4A,Files +{<%InstallDir%>\pandora_agent.log} + +D2829903-F232-F03E-070A-386860F74F4A,IgnoreErrors +{Yes} + +D567240B-2A30-47FD-97AA-3EDA09B64E9F,Alias +{Setup Actions} + +D567240B-2A30-47FD-97AA-3EDA09B64E9F,Conditions +{0 conditions} + +D8C1E7BD-813A-43ED-95A4-4F5DA45D5886,CheckCondition +{Before Action is Executed} + +D8C1E7BD-813A-43ED-95A4-4F5DA45D5886,Filename +{<%ProgramReadme%>} + +D945ADEC-CFCF-87DD-B8EC-480E6A87F4AF,Action +{Install Actions} + +D945ADEC-CFCF-87DD-B8EC-480E6A87F4AF,Conditions +{0 conditions} + +DAE5A5A9-35B4-44B5-89C0-F25FDD2771FB,CheckCondition +{Before Action is Executed} + +DAE5A5A9-35B4-44B5-89C0-F25FDD2771FB,Message,subst +{1} + +DAE5A5A9-35B4-44B5-89C0-F25FDD2771FB,Title,subst +{1} + +DAE5A5A9-35B4-44B5-89C0-F25FDD2771FB,TrueValue +{No} + +DE1D4DF7-A35C-4228-8A25-07106AD77C9E,AcceptRadiobutton,subst +{0} + +DE1D4DF7-A35C-4228-8A25-07106AD77C9E,Active +{Yes} + +DE1D4DF7-A35C-4228-8A25-07106AD77C9E,BackButton,subst +{1} + +DE1D4DF7-A35C-4228-8A25-07106AD77C9E,CancelButton,subst +{1} + +DE1D4DF7-A35C-4228-8A25-07106AD77C9E,Caption,subst +{1} + +DE1D4DF7-A35C-4228-8A25-07106AD77C9E,Conditions +{0 conditions} + +DE1D4DF7-A35C-4228-8A25-07106AD77C9E,DeclineRadiobutton,subst +{0} + +DE1D4DF7-A35C-4228-8A25-07106AD77C9E,Message,subst +{1} + +DE1D4DF7-A35C-4228-8A25-07106AD77C9E,NextButton,subst +{1} + +DE1D4DF7-A35C-4228-8A25-07106AD77C9E,Subtitle,subst +{1} + +DE1D4DF7-A35C-4228-8A25-07106AD77C9E,Text,subst +{1} + +DE1D4DF7-A35C-4228-8A25-07106AD77C9E,Title,subst +{1} + +E8952A0A-82A0-4AD0-8FA8-8902870AF848,CheckCondition +{Before Next Pane is Displayed} + +E8952A0A-82A0-4AD0-8FA8-8902870AF848,FailureMessage +{<%DirectoryPermissionText%>} + +E8952A0A-82A0-4AD0-8FA8-8902870AF848,Filename +{<%InstallDir%>} + +E8952A0A-82A0-4AD0-8FA8-8902870AF848,Permission +{can create} + +EAB473BD-3ECC-4FDE-AF62-B80B89DCAE38,Conditions +{2 conditions} + +EAB473BD-3ECC-4FDE-AF62-B80B89DCAE38,State +{disabled} + +EAB473BD-3ECC-4FDE-AF62-B80B89DCAE38,Widget +{NextButton} + +EC0536AE-91F2-712A-DDBD-E6DF378335EA,Conditions +{0 conditions} + +EC0536AE-91F2-712A-DDBD-E6DF378335EA,IgnoreErrors +{Yes} + +EC0536AE-91F2-712A-DDBD-E6DF378335EA,ProgramCommandLine +{install_service_restart.bat} + +EC0536AE-91F2-712A-DDBD-E6DF378335EA,WorkingDirectory +{<%InstallDir%>\scripts} + +EC33B744-E0BD-BCCA-7695-F6D12FBE74E6,Conditions +{0 conditions} + +EC33B744-E0BD-BCCA-7695-F6D12FBE74E6,IconPath +{<%InstallDir%>\pandora.ico} + +EC33B744-E0BD-BCCA-7695-F6D12FBE74E6,ShortcutName +{<%StartPandoraService%>} + +EC33B744-E0BD-BCCA-7695-F6D12FBE74E6,TargetFileName +{<%InstallDir%>\scripts\start_pandora_agent.bat} + +EC33B744-E0BD-BCCA-7695-F6D12FBE74E6,WorkingDirectory +{<%InstallDir%>} + +ED3D7C90-4A56-40EE-A2C5-E845C3A57C12,Alias +{Setup Actions} + +ED3D7C90-4A56-40EE-A2C5-E845C3A57C12,Conditions +{0 conditions} + +EDB4771C-ED91-462E-84D9-66E4AE0A9D9C,CheckCondition +{Before Action is Executed} + +EDB4771C-ED91-462E-84D9-66E4AE0A9D9C,String +{<%GuiMode%>} + +F037AAD5-E79E-4544-B8C0-AA98CDF5438E,BackButton,subst +{1} + +F037AAD5-E79E-4544-B8C0-AA98CDF5438E,CancelButton,subst +{1} + +F037AAD5-E79E-4544-B8C0-AA98CDF5438E,Caption,subst +{1} + +F037AAD5-E79E-4544-B8C0-AA98CDF5438E,Conditions +{0 conditions} + +F037AAD5-E79E-4544-B8C0-AA98CDF5438E,FileValue,subst +{1} + +F037AAD5-E79E-4544-B8C0-AA98CDF5438E,Message,subst +{1} + +F037AAD5-E79E-4544-B8C0-AA98CDF5438E,NextButton,subst +{1} + +F037AAD5-E79E-4544-B8C0-AA98CDF5438E,ProgressValue,subst +{1} + +F037AAD5-E79E-4544-B8C0-AA98CDF5438E,Subtitle,subst +{1} + +F037AAD5-E79E-4544-B8C0-AA98CDF5438E,Title,subst +{1} + +F0BC8450-668B-41B2-A442-F1BE095D1BFB,Conditions +{0 conditions} + +F6A6DB43-C89D-4A19-98D3-1E24284260AE,Comment +{Do not display this pane if this is an upgrade install unless there is more than one installation present} + +F6A6DB43-C89D-4A19-98D3-1E24284260AE,Script +{!<%UpgradeInstall%> || <%PreviousInstallCount%> != 1} + +F71872ED-E931-4B96-B4F8-1F65356FE848,Action +{Uninstall Actions} + +F71872ED-E931-4B96-B4F8-1F65356FE848,Conditions +{0 conditions} + +FB96078B-BA3C-498C-8C20-B01C1F28ACA9,Description,subst +{1} + +FB96078B-BA3C-498C-8C20-B01C1F28ACA9,DisplayName,subst +{1} + +FB96078B-BA3C-498C-8C20-B01C1F28ACA9,FileGroups +{946FC43B-0E32-4C38-86EF-4F9252C67E16} + +FB96078B-BA3C-498C-8C20-B01C1F28ACA9,Name +{Default Component} + +FB96078B-BA3C-498C-8C20-B01C1F28ACA9,RequiredComponent +{Yes} + +FreeBSD-4-x86,Active +{No} + +FreeBSD-4-x86,BuildSeparateArchives +{No} + +FreeBSD-4-x86,DefaultDirectoryPermission +{0755} + +FreeBSD-4-x86,DefaultFilePermission +{0755} + +FreeBSD-4-x86,Executable +{<%AppName%>-<%Version%>-<%Platform%>-Install<%Ext%>} + +FreeBSD-4-x86,FallBackToConsole +{Yes} + +FreeBSD-4-x86,InstallDir +{<%Home%>/<%ShortAppName%>} + +FreeBSD-4-x86,InstallMode +{Standard} + +FreeBSD-4-x86,InstallType +{Typical} + +FreeBSD-4-x86,ProgramExecutable +{} + +FreeBSD-4-x86,ProgramFolderAllUsers +{No} + +FreeBSD-4-x86,ProgramFolderName +{<%AppName%>} + +FreeBSD-4-x86,ProgramLicense +{<%InstallDir%>/LICENSE.txt} + +FreeBSD-4-x86,ProgramName +{} + +FreeBSD-4-x86,ProgramReadme +{<%InstallDir%>/README.txt} + +FreeBSD-4-x86,PromptForRoot +{Yes} + +FreeBSD-4-x86,RequireRoot +{No} + +FreeBSD-4-x86,RootInstallDir +{/usr/local/<%ShortAppName%>} + +FreeBSD-5-x86,Active +{No} + +FreeBSD-5-x86,BuildSeparateArchives +{No} + +FreeBSD-5-x86,DefaultDirectoryPermission +{0755} + +FreeBSD-5-x86,DefaultFilePermission +{0755} + +FreeBSD-5-x86,Executable +{<%AppName%>-<%Version%>-<%Platform%>-Install<%Ext%>} + +FreeBSD-5-x86,FallBackToConsole +{Yes} + +FreeBSD-5-x86,InstallDir +{<%Home%>/<%ShortAppName%>} + +FreeBSD-5-x86,InstallMode +{Standard} + +FreeBSD-5-x86,InstallType +{Typical} + +FreeBSD-5-x86,ProgramExecutable +{} + +FreeBSD-5-x86,ProgramFolderAllUsers +{No} + +FreeBSD-5-x86,ProgramFolderName +{<%AppName%>} + +FreeBSD-5-x86,ProgramLicense +{<%InstallDir%>/LICENSE.txt} + +FreeBSD-5-x86,ProgramName +{} + +FreeBSD-5-x86,ProgramReadme +{<%InstallDir%>/README.txt} + +FreeBSD-5-x86,PromptForRoot +{Yes} + +FreeBSD-5-x86,RequireRoot +{No} + +FreeBSD-5-x86,RootInstallDir +{/usr/local/<%ShortAppName%>} + +FreeBSD-6-x86,Active +{No} + +FreeBSD-6-x86,BuildSeparateArchives +{No} + +FreeBSD-6-x86,DefaultDirectoryPermission +{0755} + +FreeBSD-6-x86,DefaultFilePermission +{0755} + +FreeBSD-6-x86,Executable +{<%AppName%>-<%Version%>-<%Platform%>-Install<%Ext%>} + +FreeBSD-6-x86,FallBackToConsole +{Yes} + +FreeBSD-6-x86,InstallDir +{<%Home%>/<%ShortAppName%>} + +FreeBSD-6-x86,InstallMode +{Standard} + +FreeBSD-6-x86,InstallType +{Typical} + +FreeBSD-6-x86,ProgramExecutable +{} + +FreeBSD-6-x86,ProgramFolderAllUsers +{No} + +FreeBSD-6-x86,ProgramFolderName +{<%AppName%>} + +FreeBSD-6-x86,ProgramLicense +{<%InstallDir%>/LICENSE.txt} + +FreeBSD-6-x86,ProgramName +{} + +FreeBSD-6-x86,ProgramReadme +{<%InstallDir%>/README.txt} + +FreeBSD-6-x86,PromptForRoot +{Yes} + +FreeBSD-6-x86,RequireRoot +{No} + +FreeBSD-6-x86,RootInstallDir +{/usr/local/<%ShortAppName%>} + +FreeBSD-7-x86,Active +{No} + +FreeBSD-7-x86,BuildSeparateArchives +{No} + +FreeBSD-7-x86,DefaultDirectoryPermission +{0755} + +FreeBSD-7-x86,DefaultFilePermission +{0755} + +FreeBSD-7-x86,Executable +{<%AppName%>-<%Version%>-<%Platform%>-Install<%Ext%>} + +FreeBSD-7-x86,FallBackToConsole +{Yes} + +FreeBSD-7-x86,InstallDir +{<%Home%>/<%ShortAppName%>} + +FreeBSD-7-x86,InstallMode +{Standard} + +FreeBSD-7-x86,InstallType +{Typical} + +FreeBSD-7-x86,ProgramExecutable +{} + +FreeBSD-7-x86,ProgramFolderAllUsers +{No} + +FreeBSD-7-x86,ProgramFolderName +{<%AppName%>} + +FreeBSD-7-x86,ProgramLicense +{<%InstallDir%>/LICENSE.txt} + +FreeBSD-7-x86,ProgramName +{} + +FreeBSD-7-x86,ProgramReadme +{<%InstallDir%>/README.txt} + +FreeBSD-7-x86,PromptForRoot +{Yes} + +FreeBSD-7-x86,RequireRoot +{No} + +FreeBSD-7-x86,RootInstallDir +{/usr/local/<%ShortAppName%>} + +HPUX-hppa,Active +{No} + +HPUX-hppa,BuildSeparateArchives +{No} + +HPUX-hppa,DefaultDirectoryPermission +{0755} + +HPUX-hppa,DefaultFilePermission +{0755} + +HPUX-hppa,Executable +{<%AppName%>-<%Version%>-<%Platform%>-Install<%Ext%>} + +HPUX-hppa,FallBackToConsole +{Yes} + +HPUX-hppa,InstallDir +{<%Home%>/<%ShortAppName%>} + +HPUX-hppa,InstallMode +{Standard} + +HPUX-hppa,InstallType +{Typical} + +HPUX-hppa,ProgramExecutable +{} + +HPUX-hppa,ProgramFolderAllUsers +{No} + +HPUX-hppa,ProgramFolderName +{<%AppName%>} + +HPUX-hppa,ProgramLicense +{<%InstallDir%>/LICENSE.txt} + +HPUX-hppa,ProgramName +{} + +HPUX-hppa,ProgramReadme +{<%InstallDir%>/README.txt} + +HPUX-hppa,PromptForRoot +{Yes} + +HPUX-hppa,RequireRoot +{No} + +HPUX-hppa,RootInstallDir +{/usr/local/<%ShortAppName%>} + +Linux-x86,Active +{No} + +Linux-x86,BuildSeparateArchives +{No} + +Linux-x86,DefaultDirectoryPermission +{0755} + +Linux-x86,DefaultFilePermission +{0755} + +Linux-x86,Executable +{<%AppName%>-<%Version%>-<%Platform%>-Install<%Ext%>} + +Linux-x86,FallBackToConsole +{Yes} + +Linux-x86,InstallDir +{<%Home%>/<%ShortAppName%>} + +Linux-x86,InstallMode +{Standard} + +Linux-x86,InstallType +{Typical} + +Linux-x86,ProgramExecutable +{<%InstallDir%>/pandora_agent} + +Linux-x86,ProgramFolderAllUsers +{No} + +Linux-x86,ProgramFolderName +{<%AppName%>} + +Linux-x86,ProgramLicense +{<%InstallDir%>/LICENSE.txt} + +Linux-x86,ProgramName +{} + +Linux-x86,ProgramReadme +{<%InstallDir%>/README.txt} + +Linux-x86,PromptForRoot +{Yes} + +Linux-x86,RequireRoot +{No} + +Linux-x86,RootInstallDir +{/usr/local/<%ShortAppName%>} + +Linux-x86_64,Active +{No} + +Linux-x86_64,BuildSeparateArchives +{No} + +Linux-x86_64,DefaultDirectoryPermission +{0755} + +Linux-x86_64,DefaultFilePermission +{0755} + +Linux-x86_64,Executable +{<%AppName%>-<%Version%>-<%Platform%>-Install<%Ext%>} + +Linux-x86_64,FallBackToConsole +{Yes} + +Linux-x86_64,InstallDir +{<%Home%>/<%ShortAppName%>} + +Linux-x86_64,InstallMode +{Standard} + +Linux-x86_64,InstallType +{Typical} + +Linux-x86_64,ProgramExecutable +{} + +Linux-x86_64,ProgramFolderAllUsers +{No} + +Linux-x86_64,ProgramFolderName +{<%AppName%>} + +Linux-x86_64,ProgramLicense +{<%InstallDir%>/LICENSE.txt} + +Linux-x86_64,ProgramName +{} + +Linux-x86_64,ProgramReadme +{<%InstallDir%>/README.txt} + +Linux-x86_64,PromptForRoot +{Yes} + +Linux-x86_64,RequireRoot +{No} + +Linux-x86_64,RootInstallDir +{/usr/local/<%ShortAppName%>} + +Solaris-sparc,Active +{No} + +Solaris-sparc,BuildSeparateArchives +{No} + +Solaris-sparc,DefaultDirectoryPermission +{0755} + +Solaris-sparc,DefaultFilePermission +{0755} + +Solaris-sparc,Executable +{<%AppName%>-<%Version%>-<%Platform%>-Install<%Ext%>} + +Solaris-sparc,FallBackToConsole +{Yes} + +Solaris-sparc,InstallDir +{<%Home%>/<%ShortAppName%>} + +Solaris-sparc,InstallMode +{Standard} + +Solaris-sparc,InstallType +{Typical} + +Solaris-sparc,ProgramExecutable +{} + +Solaris-sparc,ProgramFolderAllUsers +{No} + +Solaris-sparc,ProgramFolderName +{<%AppName%>} + +Solaris-sparc,ProgramLicense +{<%InstallDir%>/LICENSE.txt} + +Solaris-sparc,ProgramName +{} + +Solaris-sparc,ProgramReadme +{<%InstallDir%>/README.txt} + +Solaris-sparc,PromptForRoot +{Yes} + +Solaris-sparc,RequireRoot +{No} + +Solaris-sparc,RootInstallDir +{/usr/local/<%ShortAppName%>} + +Solaris-x86,Active +{No} + +Solaris-x86,BuildSeparateArchives +{No} + +Solaris-x86,DefaultDirectoryPermission +{0755} + +Solaris-x86,DefaultFilePermission +{0755} + +Solaris-x86,Executable +{<%AppName%>-<%Version%>-<%Platform%>-Install<%Ext%>} + +Solaris-x86,FallBackToConsole +{Yes} + +Solaris-x86,InstallDir +{<%Home%>/<%ShortAppName%>} + +Solaris-x86,InstallMode +{Standard} + +Solaris-x86,InstallType +{Typical} + +Solaris-x86,ProgramExecutable +{} + +Solaris-x86,ProgramFolderAllUsers +{No} + +Solaris-x86,ProgramFolderName +{<%AppName%>} + +Solaris-x86,ProgramLicense +{<%InstallDir%>/LICENSE.txt} + +Solaris-x86,ProgramName +{} + +Solaris-x86,ProgramReadme +{<%InstallDir%>/README.txt} + +Solaris-x86,PromptForRoot +{Yes} + +Solaris-x86,RequireRoot +{No} + +Solaris-x86,RootInstallDir +{/usr/local/<%ShortAppName%>} + +TarArchive,Active +{No} + +TarArchive,BuildSeparateArchives +{No} + +TarArchive,CompressionLevel +{6} + +TarArchive,DefaultDirectoryPermission +{0755} + +TarArchive,DefaultFilePermission +{0755} + +TarArchive,Executable +{<%AppName%>-<%Version%>-<%Platform%>-Install<%Ext%>} + +TarArchive,FallBackToConsole +{Yes} + +TarArchive,InstallDir +{<%Home%>/<%ShortAppName%>} + +TarArchive,InstallMode +{Standard} + +TarArchive,InstallType +{Typical} + +TarArchive,OutputFileName +{<%ShortAppName%>-<%Version%>.tar.gz} + +TarArchive,ProgramExecutable +{} + +TarArchive,ProgramFolderAllUsers +{No} + +TarArchive,ProgramFolderName +{<%AppName%>} + +TarArchive,ProgramLicense +{<%InstallDir%>/LICENSE.txt} + +TarArchive,ProgramName +{} + +TarArchive,ProgramReadme +{<%InstallDir%>/README.txt} + +TarArchive,PromptForRoot +{Yes} + +TarArchive,RequireRoot +{No} + +TarArchive,RootInstallDir +{/usr/local/<%ShortAppName%>} + +TarArchive,VirtualTextMap +{<%InstallDir%> <%ShortAppName%>} + +Windows,Active +{Yes} + +Windows,BuildSeparateArchives +{No} + +Windows,Executable +{<%AppName%>-<%Version%>-Setup<%Ext%>} + +Windows,FileDescription +{<%AppName%> <%Version%> Setup} + +Windows,IncludeTWAPI +{No} + +Windows,InstallDir +{<%PROGRAM_FILES%>/pandora_agent} + +Windows,InstallMode +{Standard} + +Windows,InstallType +{Typical} + +Windows,LastRequireAdministrator +{Yes} + +Windows,ProgramExecutable +{<%InstallDir%>/PandoraAgent.exe} + +Windows,ProgramFolderAllUsers +{No} + +Windows,ProgramFolderName +{<%AppName%>} + +Windows,ProgramLicense +{<%InstallDir%>/LICENSE.txt} + +Windows,ProgramName +{} + +Windows,ProgramReadme +{<%InstallDir%>/README.txt} + +Windows,RequireAdministrator +{Yes} + +Windows,UseUncompressedBinaries +{No} + +Windows,WindowsIcon +{pandora.ico} + +ZipArchive,Active +{No} + +ZipArchive,BuildSeparateArchives +{No} + +ZipArchive,CompressionLevel +{6} + +ZipArchive,DefaultDirectoryPermission +{0755} + +ZipArchive,DefaultFilePermission +{0755} + +ZipArchive,Executable +{<%AppName%>-<%Version%>-<%Platform%>-Install<%Ext%>} + +ZipArchive,FallBackToConsole +{Yes} + +ZipArchive,InstallDir +{<%Home%>/<%ShortAppName%>} + +ZipArchive,InstallMode +{Standard} + +ZipArchive,InstallType +{Typical} + +ZipArchive,OutputFileName +{<%ShortAppName%>-<%Version%>.zip} + +ZipArchive,ProgramExecutable +{} + +ZipArchive,ProgramFolderAllUsers +{No} + +ZipArchive,ProgramFolderName +{<%AppName%>} + +ZipArchive,ProgramLicense +{<%InstallDir%>/LICENSE.txt} + +ZipArchive,ProgramName +{} + +ZipArchive,ProgramReadme +{<%InstallDir%>/README.txt} + +ZipArchive,PromptForRoot +{Yes} + +ZipArchive,RequireRoot +{No} + +ZipArchive,RootInstallDir +{/usr/local/<%ShortAppName%>} + +ZipArchive,VirtualTextMap +{<%InstallDir%> <%ShortAppName%>} + +} + +::msgcat::mcmset ca { +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Text +{} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,BackButton +{< <%Back%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,CancelButton +{<%Cancel%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Caption +{Llegenda} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Message +{Missatge} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,NextButton +{<%Next%> >} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Subtitle +{Subtítol} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Title +{Ròtul} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Message +{} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Title +{} + +B5904821-3970-1701-002C-0318B8BECA06,Message +{} + +} +::msgcat::mcmset cs { +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Text +{} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,BackButton +{< <%Back%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,CancelButton +{<%Cancel%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Caption +{Titulek} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Message +{Zpráva} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,NextButton +{<%Next%> >} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Subtitle +{Podnadpis} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Title +{Nadpis} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Message +{} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Title +{} + +B5904821-3970-1701-002C-0318B8BECA06,Message +{} + +} +::msgcat::mcmset de { +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Text +{Agent group name: } + +1957048E-B498-4FFF-A8BA-F2DF640463B1,Message +{Dies wird <%AppName%> auf Ihrem Computer installieren. + +Es wird empfohlen, das Sie alle anderen Anwendungen schließen, bevor Sie fortfahren. + +Nach der Installierung sollten Sie Konfigurationsdatei editieren, um Server IP Adresse und andere Rahmen zu definieren. + +Klicken Sie auf Weiter um Fortzufahren oder auf Abbrechen, um das Setup zu beenden.} + +1D572EE2-DD93-4F13-850E-DE0EEB1DA110,Message +{<%UninstallingApplicationText%>} + +2073DDB6-50AB-4708-82AD-02A6C3F3EDE1,Message +{<%InstallationCompleteText%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,BackButton +{< <%Back%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,CancelButton +{<%Cancel%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Caption +{This values will be written to the pandora_agent.conf file in the <%ProgramFolderName%> folder. Please change them to your own data.} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Message +{ } + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,NextButton +{<%Next%> >} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Subtitle +{Now it's time to configure your pandora_agent.conf file} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Title +{Pandora FMS Agent for Windows Configuration} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Message +{} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Title +{} + +4E1B9A69-B88E-4DE5-A0E1-08E04C4BE6B3,Message +{<%UninstallCompleteText%>} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Caption +{This values will be written to the pandora_agent.conf file in the <%ProgramFolderName%> folder. Please change them to your own data.} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Message +{ } + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Subtitle +{Now it's time to configure your pandora_agent.conf file} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Title +{Pandora FMS Agent for Windows Configuration} + +75288342-4CEB-473C-B242-450642503F74,Text +{Pandora Server IP Address:} + +B5904821-3970-1701-002C-0318B8BECA06,Message +{} + +BF861387-DA7F-4986-B5BB-F77358B58603,Message +{<%InstallingApplicationText%>} + +EditConfiguration +{Bearbeiten der Konfiguration} + +StartPandoraService +{Startet <%AppName%> Dienst} + +StopPandoraService +{Beendet <%AppName%> Dienst} + +} +::msgcat::mcmset en { +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Text +{Agent group (Must exists)} + +1957048E-B498-4FFF-A8BA-F2DF640463B1,Message +{This program will install <%AppName%> (build <%Version%>) in your computer. When you finish this installation, probably you will need to edit the agent configuration file to add aditional modules or review main setup parameters. + +Please click on Next button to continue, or Cancel to exit this setup. +} + +1D572EE2-DD93-4F13-850E-DE0EEB1DA110,Message +{<%UninstallingApplicationText%>} + +1F7BE720-7885-4150-9550-F25FB1C69423,Message +{The InstallJammer Wizard has successfully installed <%AppName%>. Click Finish to exit the wizard. + +NOTE: In some Windows systems, it is needed to restart the server after installing a Service and adding new directories to system path. We recommend to restart your server, but this is not always needed.} + +2073DDB6-50AB-4708-82AD-02A6C3F3EDE1,Message +{<%InstallationCompleteText%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,BackButton +{< <%Back%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,CancelButton +{<%Cancel%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Caption +{ + +Enter the group name for this agent. This group must exist in the Pandora FMS server at destination.} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Message +{ } + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,NextButton +{<%Next%> >} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Subtitle +{} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Title +{Pandora FMS Agent for Windows Configuration} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Message +{Do you want to start Pandora FMS Agent Service?} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Title +{Pandora FMS Windows Agent Service} + +4E1B9A69-B88E-4DE5-A0E1-08E04C4BE6B3,Message +{<%UninstallCompleteText%>} + +4F66C16F-6FAC-4A36-B0EA-CCA2324B27DF,Message +{<%InstallStartupText%>} + +4F66C16F-6FAC-4A36-B0EA-CCA2324B27DF,Title +{<%InstallApplicationText%>} + +5EA75DE2-F9E1-405D-800E-B28FB96CDC61,Caption +{<%ApplicationReadmeText%>} + +5EA75DE2-F9E1-405D-800E-B28FB96CDC61,Message +{} + +5EA75DE2-F9E1-405D-800E-B28FB96CDC61,Title +{<%ApplicationReadmeText%>} + +6057A263-437C-4EB8-93AB-DBC7055A759F,Description +{<%CustomInstallDescription%>} + +60CAEDF4-53E9-46C5-9A0F-5873E12F2328,Text +{<%ViewReadmeText%>} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Caption +{ + +Write here the IP address or FQN address to your Pandora FMS server.} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Message +{ } + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Subtitle +{} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Title +{Pandora FMS Agent for Windows Configuration} + +6FD08442-A7BA-4654-9ECE-3883DD747D00,Message +{Do you like to start Pandora FMS Windows Agent Service Now?} + +6FD08442-A7BA-4654-9ECE-3883DD747D00,Title +{Starting Pandora FMS service} + +75288342-4CEB-473C-B242-450642503F74,Text +{Pandora FMS Server address} + +8112E00E-C24D-458F-9C19-03E63937E908,Message +{Do you want to start Pandora FMS Agent Service?} + +8112E00E-C24D-458F-9C19-03E63937E908,Title +{Pandora FMS Windows Agent Service} + +A84F44C7-9ABD-43C6-AA57-CF527E0C82A5,Caption +{Please enter Server IP} + +A84F44C7-9ABD-43C6-AA57-CF527E0C82A5,Subtitle +{Enter the IP of the server you want to connect} + +A84F44C7-9ABD-43C6-AA57-CF527E0C82A5,Title +{Server IP} + +A87C1A6B-ED26-4B07-8736-750725FF34E4,Description +{<%TypicalInstallDescription%>} + +B5904821-3970-1701-002C-0318B8BECA06,Message +{Install finished. Don't forget to edit your pandora_agent.conf for define IP address of your Pandora FMS Server.} + +BF861387-DA7F-4986-B5BB-F77358B58603,Message +{<%InstallingApplicationText%>} + +C862BDC0-8F67-4546-B658-4A9A8ADCE385,Caption +{Setup has enough information to start copying the program files. If you want to review or change any settings, click Back. If you are satisfied with the settings, click Next to begin copying files.} + +DAE5A5A9-35B4-44B5-89C0-F25FDD2771FB,Message +{<%UninstallStartupText%>} + +DAE5A5A9-35B4-44B5-89C0-F25FDD2771FB,Title +{<%UninstallApplicationText%>} + +DE1D4DF7-A35C-4228-8A25-07106AD77C9E,Text +{GNU GENERAL PUBLIC LICENSE + +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + + c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS} + +EditConfiguration +{Edit Configuration} + +FB96078B-BA3C-498C-8C20-B01C1F28ACA9,Description +{<%ProgramFilesDescription%>} + +HelpGeneratingSSHKeys +{Help Generating SSH Keys} + +HowTo +{how_to_keys.html} + +PandoraLicense +{Pandora FMS License} + +Readme +{Readme} + +StartPandoraService +{Start <%AppName%> Service} + +StopPandoraService +{Stop <%AppName%> Service} + +} +::msgcat::mcmset es { +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Text +{Grupo del agente:} + +1957048E-B498-4FFF-A8BA-F2DF640463B1,Message +{Este programa instalará <%AppName%> (build <%Version%>) en su equipo. + +Se recomienda cerrar las demas aplicaciones antes de continuar. + +Al finalizar la instalación, debe editarse el fichero de configuración para definir la dirección IP del servidor y otros parámetros. + +Pulse Siguiente para continuar o Cancelar para salir de la instalación.} + +1D572EE2-DD93-4F13-850E-DE0EEB1DA110,Message +{<%UninstallingApplicationText%>} + +1F7BE720-7885-4150-9550-F25FB1C69423,Caption +{La instalación ha finalizado} + +1F7BE720-7885-4150-9550-F25FB1C69423,Message +{El instalador ha instalado <%AppName%> con éxito. Pulse Finalizar para salir de este instalador. + +NOTA: En algunos sistemas Windows es necesario reiniciar después de instalar un servicio y agregar un nuevo directorio al PATH del sistema. Recomendamos por tanto que reinicie este servidor.} + +2073DDB6-50AB-4708-82AD-02A6C3F3EDE1,Message +{<%InstallationCompleteText%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,BackButton +{< <%Back%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,CancelButton +{<%Cancel%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Caption +{ + + +Introduzca el nombre del grupo para este agente. El nombre del grupo debe existir en el servidor Pandora FMS de destino.} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Message +{ } + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,NextButton +{<%Next%> >} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Subtitle +{Configuración del fichero pandora_agent.conf del agente} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Title +{Configuración del agente de Pandora FMS para Windows} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Message +{¿Quiere iniciar el servicio del agente de Pandora FMS para Windows?} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Title +{} + +4E1B9A69-B88E-4DE5-A0E1-08E04C4BE6B3,Message +{<%UninstallCompleteText%>} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Caption +{ + +Escriba a continuación la dirección IP o el nombre del servidor de Pandora FMS al que enviará datos este agente.} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Message +{ } + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Subtitle +{} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Title +{Configuración del agente de Pandora FMS para Windows} + +6B06C7C2-97A8-4642-B286-3B089943F359,Message +{InstallJammer ha instalado <%AppName%> con éxito. Pulse Finalizar para salir de este instalador.} + +6FD08442-A7BA-4654-9ECE-3883DD747D00,Message +{¿Quiere iniciar ahora el servicio de Pandora FMS Windows Agent?} + +6FD08442-A7BA-4654-9ECE-3883DD747D00,Title +{Inicio del servicio Pandora FMS} + +75288342-4CEB-473C-B242-450642503F74,Text +{Dirección IP del servidor Pandora:} + +8112E00E-C24D-458F-9C19-03E63937E908,Message +{¿Quiere iniciar el servicio del agente de Pandora FMS para Windows?} + +B2E20690-C57D-4286-9977-F2541E04D71F,BrowseText +{Pulse Siguiente para continuar. Si desea seleccionar una carpeta diferente, pulse Examinar.} + +B2E20690-C57D-4286-9977-F2541E04D71F,Caption +{Se instalará <%AppName%> en la siguiente carpeta. + +Para instalar en esa carpeta, pulse Siguiente. Para instalar en una carpeta diferente, pulse Examinar y seleccione otra.} + +B5904821-3970-1701-002C-0318B8BECA06,Message +{} + +BF861387-DA7F-4986-B5BB-F77358B58603,Message +{<%InstallingApplicationText%>} + +C862BDC0-8F67-4546-B658-4A9A8ADCE385,Caption +{Se ha recopilado la información necesaria para comenzar a copiar los archivos del programa. Si desea revisar o cambiar la configuración, pulse Atrás. Si esta conforme con la configuración, pulse Siguiente para comenzar a copiar los archivos.} + +DE1D4DF7-A35C-4228-8A25-07106AD77C9E,Subtitle +{Por favor lea atentamente el siguiente acuerdo de licencia (en inglés).} + +EditConfiguration +{Editar fichero de configuración} + +HelpGeneratingSSHKeys +{Creación de claves SSH} + +HowTo +{how_to_keys_es.html} + +InstallStartupText +{Se va a instalar <%AppName%> en su equipo. ¿Desea continuar?} + +PandoraLicense +{Licencia de Pandora FMS (inglés)} + +Readme +{Léeme (inglés)} + +SeparatorText +{Instalador de Pandora FMS} + +StartPandoraService +{Pandora FMS Service - Iniciar Servicio} + +StopPandoraService +{Pandora FMS Service - Parar Servicio} + +StopPanodoraService +{Pandora FMS Service - Parar Servicio} + +UninstallStartupText +{Se eliminará completamente <%AppName%> de su sistema. ¿Seguro que desea continuar?} + +} +::msgcat::mcmset fr { +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Text +{Agent group name: } + +1957048E-B498-4FFF-A8BA-F2DF640463B1,Message +{Ceci installera <%AppName%> sur votre ordinateur. + +Il est recommandé de fermer toutes les autres applications avant de continuer. + +Après avoir terminé l'installation, il faut éditer le fichier de configuration pour définir l'adresse IP du serveur ainsi que d'autres paramètres. + +Cliquez sur SUIVANT pour continuer ou ANNULER pour quitter l'installation.} + +1D572EE2-DD93-4F13-850E-DE0EEB1DA110,Message +{<%UninstallingApplicationText%>} + +2073DDB6-50AB-4708-82AD-02A6C3F3EDE1,Message +{<%InstallationCompleteText%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,BackButton +{< <%Back%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,CancelButton +{<%Cancel%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Caption +{This values will be written to the pandora_agent.conf file in the <%ProgramFolderName%> folder. Please change them to your own data.} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Message +{ } + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,NextButton +{<%Next%> >} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Subtitle +{Now it's time to configure your pandora_agent.conf file} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Title +{Pandora FMS Agent for Windows Configuration} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Message +{} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Title +{} + +4E1B9A69-B88E-4DE5-A0E1-08E04C4BE6B3,Message +{<%UninstallCompleteText%>} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Caption +{This values will be written to the pandora_agent.conf file in the <%ProgramFolderName%> folder. Please change them to your own data.} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Message +{ } + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Subtitle +{Now it's time to configure your pandora_agent.conf file} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Title +{Pandora FMS Agent for Windows Configuration} + +75288342-4CEB-473C-B242-450642503F74,Text +{Pandora Server IP Address:} + +B5904821-3970-1701-002C-0318B8BECA06,Message +{} + +BF861387-DA7F-4986-B5BB-F77358B58603,Message +{<%InstallingApplicationText%>} + +EditConfiguration +{Modifier la configuration} + +StartPandoraService +{Démarre le service <%AppName%>} + +StopPandoraService +{Arrête le service <%AppName%>} + +} +::msgcat::mcmset hu { +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Text +{Pandora Server IP Address:} + +1957048E-B498-4FFF-A8BA-F2DF640463B1,Message +{Ez a <%AppName%> verzióját fogja telepíteni a számítógépére. + + Javasoljuk, hogy zárjon be minden alkalmazást, mielőtt folytatná. + + Kattintson a <%Next%> gombra a folytatáshoz vagy a <%Cancel%> gombra kilépéshez.} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,BackButton +{< <%Back%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,CancelButton +{<%Cancel%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Caption +{This values will be written to the pandora_agent.conf file in the <%ProgramFolderName%> folder. Please change them to your own data.} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Message +{ } + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,NextButton +{<%Next%> >} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Subtitle +{Now it's time to configure your pandora_agent.conf file} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Title +{Pandora FMS Agent for Windows Configuration} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Message +{} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Title +{} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Caption +{This values will be written to the pandora_agent.conf file in the <%ProgramFolderName%> folder. Please change them to your own data.} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Message +{ } + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Subtitle +{Now it's time to configure your pandora_agent.conf file} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Title +{Pandora FMS Agent for Windows Configuration} + +75288342-4CEB-473C-B242-450642503F74,Text +{Pandora Server IP Address:} + +B5904821-3970-1701-002C-0318B8BECA06,Message +{} + +StartPandoraService +{Start Pandora Service} + +StopPandoraService +{Stop Pandora Service} + +} +::msgcat::mcmset it { +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Text +{Pandora Server IP Address:} + +1957048E-B498-4FFF-A8BA-F2DF640463B1,Message +{Si sta per installare <%AppName%> sul computer. + +E' consigliata la chiusura di tutte le altre applicazioni prima di proseguire. + +Premere su Avanti per continuare o su Annulla per uscire dall'installazione.} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,BackButton +{< <%Back%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,CancelButton +{<%Cancel%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Caption +{This values will be written to the pandora_agent.conf file in the <%ProgramFolderName%> folder. Please change them to your own data.} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Message +{ } + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,NextButton +{<%Next%> >} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Subtitle +{Now it's time to configure your pandora_agent.conf file} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Title +{Pandora FMS Agent for Windows Configuration} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Message +{} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Title +{} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Caption +{This values will be written to the pandora_agent.conf file in the <%ProgramFolderName%> folder. Please change them to your own data.} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Message +{ } + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Subtitle +{Now it's time to configure your pandora_agent.conf file} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Title +{Pandora FMS Agent for Windows Configuration} + +75288342-4CEB-473C-B242-450642503F74,Text +{Pandora Server IP Address:} + +B5904821-3970-1701-002C-0318B8BECA06,Message +{} + +StartPandoraService +{Start Pandora Service} + +StopPandoraService +{Stop Pandora Service} + +} +::msgcat::mcmset lt { +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Text +{} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,BackButton +{< <%Back%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,CancelButton +{<%Cancel%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Caption +{Pavadinimas} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Message +{Praneðimas} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,NextButton +{<%Next%> >} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Subtitle +{Paantraðtë} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Title +{Antraðtë} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Message +{} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Title +{} + +B5904821-3970-1701-002C-0318B8BECA06,Message +{} + +} +::msgcat::mcmset nl { +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Text +{Pandora Server IP Address:} + +1957048E-B498-4FFF-A8BA-F2DF640463B1,Message +{Het is aan te raden alle overige applicaties te sluiten alvorens verder te gaan met deze installatie. + +Klik op <%Next%> om verder te gaan of op <%Cancel%> om deze installatie af te breken} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,BackButton +{< <%Back%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,CancelButton +{<%Cancel%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Caption +{This values will be written to the pandora_agent.conf file in the <%ProgramFolderName%> folder. Please change them to your own data.} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Message +{ } + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,NextButton +{<%Next%> >} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Subtitle +{Now it's time to configure your pandora_agent.conf file} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Title +{Pandora FMS Agent for Windows Configuration} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Message +{} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Title +{} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Caption +{This values will be written to the pandora_agent.conf file in the <%ProgramFolderName%> folder. Please change them to your own data.} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Message +{ } + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Subtitle +{Now it's time to configure your pandora_agent.conf file} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Title +{Pandora FMS Agent for Windows Configuration} + +75288342-4CEB-473C-B242-450642503F74,Text +{Pandora Server IP Address:} + +B5904821-3970-1701-002C-0318B8BECA06,Message +{} + +StartPandoraService +{Start Pandora Service} + +StopPandoraService +{Stop Pandora Service} + +} +::msgcat::mcmset pl { +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Text +{Pandora Server IP Address:} + +1957048E-B498-4FFF-A8BA-F2DF640463B1,Message +{Zainstaluje on <%AppName%> na twoim komputerze. + +Zalecane jest zamkniÄ™cie wszystkich programów przed instalacjÄ…. + +Kliknij Dalej, aby kontynuować lub Anuluj, aby opuÅ›cić instalator.} + +1D572EE2-DD93-4F13-850E-DE0EEB1DA110,Message +{<%UninstallingApplicationText%>} + +2073DDB6-50AB-4708-82AD-02A6C3F3EDE1,Message +{<%InstallationCompleteText%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,BackButton +{< <%Back%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,CancelButton +{<%Cancel%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Caption +{This values will be written to the pandora_agent.conf file in the <%ProgramFolderName%> folder. Please change them to your own data.} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Message +{ } + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,NextButton +{<%Next%> >} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Subtitle +{Now it's time to configure your pandora_agent.conf file} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Title +{Pandora FMS Agent for Windows Configuration} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Message +{} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Title +{} + +4E1B9A69-B88E-4DE5-A0E1-08E04C4BE6B3,Message +{<%UninstallCompleteText%>} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Caption +{This values will be written to the pandora_agent.conf file in the <%ProgramFolderName%> folder. Please change them to your own data.} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Message +{ } + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Subtitle +{Now it's time to configure your pandora_agent.conf file} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Title +{Pandora FMS Agent for Windows Configuration} + +75288342-4CEB-473C-B242-450642503F74,Text +{Pandora Server IP Address:} + +B5904821-3970-1701-002C-0318B8BECA06,Message +{} + +BF861387-DA7F-4986-B5BB-F77358B58603,Message +{<%InstallingApplicationText%>} + +StartPandoraService +{} + +StopPandoraService +{Stop Pandora Service} + +} +::msgcat::mcmset pt_br { +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Text +{Pandora Server IP Address:} + +1957048E-B498-4FFF-A8BA-F2DF640463B1,Message +{Será instalado <%AppName%> version <%Version%> em seu computador. + +É recomendado que você feche todos os outros programas antes de continuar. + +Depois da instalação, você deve editar o arquivo de configuração para definir o servidor endereço de IP e outros parâmetros. + +Clique em Próximo para continuar ou em Cancelar para sair da Instalação.} + +1D572EE2-DD93-4F13-850E-DE0EEB1DA110,Message +{<%UninstallingApplicationText%>} + +2073DDB6-50AB-4708-82AD-02A6C3F3EDE1,Message +{<%InstallationCompleteText%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,BackButton +{< <%Back%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,CancelButton +{<%Cancel%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Caption +{This values will be written to the pandora_agent.conf file in the <%ProgramFolderName%> folder. Please change them to your own data.} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Message +{ } + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,NextButton +{<%Next%> >} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Subtitle +{Now it's time to configure your pandora_agent.conf file} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Title +{Pandora FMS Agent for Windows Configuration} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Message +{} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Title +{} + +4E1B9A69-B88E-4DE5-A0E1-08E04C4BE6B3,Message +{<%UninstallCompleteText%>} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Caption +{This values will be written to the pandora_agent.conf file in the <%ProgramFolderName%> folder. Please change them to your own data.} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Message +{ } + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Subtitle +{Now it's time to configure your pandora_agent.conf file} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Title +{Pandora FMS Agent for Windows Configuration} + +75288342-4CEB-473C-B242-450642503F74,Text +{Pandora Server IP Address:} + +B5904821-3970-1701-002C-0318B8BECA06,Message +{} + +BF861387-DA7F-4986-B5BB-F77358B58603,Message +{<%InstallingApplicationText%>} + +EditConfiguration +{Editar a configuração} + +StartPandoraService +{Inicia o serviço <%AppName%>} + +StopPandoraService +{Interrompe o serviço <%AppName%>} + +} +::msgcat::mcmset ru { +0464C461-3BD5-93CE-C3BA-C59CA84AD70D,Text +{Agent group name:} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,BackButton +{< <%Back%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,CancelButton +{<%Cancel%>} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Caption +{This values will be written to the pandora_agent.conf file in the <%ProgramFolderName%> folder. Please change them to your own data.} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Message +{ } + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,NextButton +{<%Next%> >} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Subtitle +{Now it's time to configure your pandora_agent.conf file} + +22E3617C-DE0E-D452-41DC-8278EA3F9D76,Title +{Pandora FMS Agent for Windows Configuration} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Message +{} + +4DC6C83C-511B-300F-900F-8670A81A7F9C,Title +{} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Caption +{This values will be written to the pandora_agent.conf file in the <%ProgramFolderName%> folder. Please change them to your own data.} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Message +{ } + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Subtitle +{Now it's time to configure your pandora_agent.conf file} + +68A06F1C-625E-4BF0-AE3B-8BFBD37824C1,Title +{Pandora FMS Agent for Windows Configuration} + +75288342-4CEB-473C-B242-450642503F74,Text +{Pandora Server IP Address:} + +B5904821-3970-1701-002C-0318B8BECA06,Message +{} + +StartPandoraService +{Start Pandora Service} + +StopPanodoraService +{} + +} + diff --git a/pandora_agents/win32/modules/pandora_module.cc b/pandora_agents/win32/modules/pandora_module.cc index a1936912f2..296f42f2ea 100644 --- a/pandora_agents/win32/modules/pandora_module.cc +++ b/pandora_agents/win32/modules/pandora_module.cc @@ -368,7 +368,7 @@ Pandora_Module::getDataOutput (Pandora_Data *data) { } if (this->has_limits) { - if (value >= this->max || value <= this->min) { + if (value > this->max || value < this->min) { pandoraLog ("The returned value was not in the interval on module %s", this->module_name.c_str ()); throw Value_Error (); @@ -1789,5 +1789,9 @@ Pandora_Module::getIntensiveMatch () { return this->intensive_match; } +bool +Pandora_Module::getAsync () { + return this->async; +} diff --git a/pandora_agents/win32/modules/pandora_module.h b/pandora_agents/win32/modules/pandora_module.h index 4303b88eec..b2606d2442 100644 --- a/pandora_agents/win32/modules/pandora_module.h +++ b/pandora_agents/win32/modules/pandora_module.h @@ -91,7 +91,7 @@ namespace Pandora_Modules { MODULE_TCPCHECK, /**< The module checks whether a tcp port is open */ MODULE_REGEXP, /**< The module searches a file for matches of a regular expression */ MODULE_PLUGIN, /**< Plugin */ - MODULE_PING, /**< Ping module */ + MODULE_PING, /**< Ping module */ MODULE_SNMPGET /**< SNMP get module */ } Module_Kind; @@ -238,6 +238,7 @@ namespace Pandora_Modules { void setTimeout (int timeout); int getTimeout (); string getSave (); + bool getAsync (); virtual string getXml (); diff --git a/pandora_agents/win32/modules/pandora_module_factory.cc b/pandora_agents/win32/modules/pandora_module_factory.cc index 23ebaaf7e8..db33c1315a 100644 --- a/pandora_agents/win32/modules/pandora_module_factory.cc +++ b/pandora_agents/win32/modules/pandora_module_factory.cc @@ -1139,11 +1139,14 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module = new Pandora_Module_Freedisk_Percent (module_name, module_freedisk_percent); // Added a description with the memory free - char buffer[100]; - unsigned long memory = Pandora_Wmi::getDiskFreeSpace(module_freedisk_percent); - if (sprintf(buffer, "Free memory %s %dMB", + try { + char buffer[100]; + unsigned long memory = Pandora_Wmi::getDiskFreeSpace(module_freedisk_percent); + if (sprintf(buffer, "Free memory %s %dMB", module_freedisk_percent.c_str(), memory) > 0) { - module->setDescription(buffer); + module->setDescription(buffer); + } + } catch (Pandora_Wmi::Pandora_Wmi_Exception e) { } } else if (module_freememory != "") { module = new Pandora_Module_Freememory (module_name); diff --git a/pandora_agents/win32/modules/pandora_module_proc.cc b/pandora_agents/win32/modules/pandora_module_proc.cc index 91deab0efb..e8eed1f97d 100644 --- a/pandora_agents/win32/modules/pandora_module_proc.cc +++ b/pandora_agents/win32/modules/pandora_module_proc.cc @@ -52,6 +52,17 @@ Pandora_Module_Proc::Pandora_Module_Proc (string name, string process_name) this->retries = 3; this->start_delay = 5000; this->retry_delay = 2000; + this->thread = 0; +} +/** + * Destroys a Pandora_Module_Service object. + */ +Pandora_Module_Proc::~Pandora_Module_Proc () { + + // Close the thread if module is async + if (this->thread) { + TerminateThread(this->thread, 0); + } } string diff --git a/pandora_agents/win32/modules/pandora_module_proc.h b/pandora_agents/win32/modules/pandora_module_proc.h index 60615f189a..edab85cb88 100644 --- a/pandora_agents/win32/modules/pandora_module_proc.h +++ b/pandora_agents/win32/modules/pandora_module_proc.h @@ -38,6 +38,7 @@ namespace Pandora_Modules { int retry_delay; public: Pandora_Module_Proc (string name, string process_name); + ~Pandora_Module_Proc (); string getProcessName () const; string getStartCommand () const; diff --git a/pandora_agents/win32/modules/pandora_module_service.cc b/pandora_agents/win32/modules/pandora_module_service.cc index bbbe799f9e..bf82120aa8 100644 --- a/pandora_agents/win32/modules/pandora_module_service.cc +++ b/pandora_agents/win32/modules/pandora_module_service.cc @@ -49,6 +49,16 @@ Pandora_Module_Service::Pandora_Module_Service (string name, string service_name this->thread = 0; this->watchdog = false; } +/** + * Destroys a Pandora_Module_Service object. + */ +Pandora_Module_Service::~Pandora_Module_Service () { + + // Close the thread if module is async + if (this->thread) { + TerminateThread(this->thread, 0); + } +} string Pandora_Module_Service::getServiceName () const { diff --git a/pandora_agents/win32/modules/pandora_module_service.h b/pandora_agents/win32/modules/pandora_module_service.h index 6e82697985..bdec6152ed 100644 --- a/pandora_agents/win32/modules/pandora_module_service.h +++ b/pandora_agents/win32/modules/pandora_module_service.h @@ -36,6 +36,7 @@ namespace Pandora_Modules { bool watchdog; public: Pandora_Module_Service (string name, string service_name); + ~Pandora_Module_Service (); void run (); string getServiceName () const; diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 662ecd92d1..8adf0ead32 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG(Build 170411)") +#define PANDORA_VERSION ("7.0NG.712(Build 170908)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/pandora.cc.orig b/pandora_agents/win32/pandora.cc.orig new file mode 100644 index 0000000000..7ea551d506 --- /dev/null +++ b/pandora_agents/win32/pandora.cc.orig @@ -0,0 +1,345 @@ +/* Common functions to any Pandora program. + Copyright (C) 2006 Artica ST. + Written by Esteban Sanchez. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include +#include +#include +#include +#include +#include "pandora.h" +#include "pandora_strutils.h" + +using namespace std; +using namespace Pandora; +using namespace Pandora_Strutils; + +#define PATH_SIZE _MAX_PATH+1 +<<<<<<< HEAD +#define PANDORA_VERSION ("7.0NG(Build 170406)") +======= +#define PANDORA_VERSION ("7.0NG(Build 170418)") +>>>>>>> develop + +string pandora_path; +string pandora_dir; +bool pandora_debug; +bool pandora_log_disable; +string pandora_version = PANDORA_VERSION; + +/** + * Parses a string and initialize the key and the value. + * + * The string should be in the format: + * - key value + * - key "value with blankspaces" + */ +void +Key_Value::parseLine (string str) { + int pos; + list tokens; + list::iterator iter; + string trimmedstr; + + trimmedstr = trim (str); + + /* Check if the string has " */ + pos = trimmedstr.find ("\""); + if (pos == string::npos) { + stringtok (tokens, trimmedstr, " \t"); + } else { + stringtok (tokens, trimmedstr, "\""); + } + + /* Pick the first and the last value of the token list */ + iter = tokens.begin (); + key = trim (*iter); + transform (key.begin(), key.end(), key.begin(), (int(*)(int)) tolower); + iter = tokens.end (); + iter--; + /* Check if the line has only one token */ + if (iter != tokens.begin ()) { + value = trim (*iter); + } else { + value = ""; + } +} + +/** + * Parses a string by position and initialize the key and the value. + */ +void +Key_Value::parseLineByPosition (string str, int pos) { + string trimmedstr; + + trimmedstr = trim (str); + + key = trim (trimmedstr.substr (0, pos)); + value = trim (trimmedstr.substr (pos)); +} + +/** + * Get the key of the object. + * + * @return The key + */ +string +Key_Value::getKey () { + return key; +} + +/** + * Set the key of the object. + * + */ +void +Key_Value::setKey (const string key) { + this->key = key; +} + +/** + * Get the value of the object. + * + * @return The value + */ +string +Key_Value::getValue () { + return value; +} + +/** + * Set the value of the object. + * + * @return The value + */ +void +Key_Value::setValue (const string value) { + this->value = value; +} + +void +pandoraWriteLog (string filename, string line) { + string buffer; + char str_time[25]; + FILE *file; + string filepath; + SYSTEMTIME st; + + GetLocalTime(&st); + sprintf (str_time, "%d-%02d-%02d %02d:%02d:%02d ", st.wYear, st.wMonth, st.wDay, + st.wHour, st.wMinute, st.wSecond); + + buffer = (char *) str_time; + buffer += line; + + filepath = pandora_dir + filename; + + file = fopen (filepath.c_str (), "a+"); + if (file != NULL) { + fprintf (file, "%s\n", buffer.c_str ()); + fclose (file); + } +} + +/** + * Write a message in the log file. + * + * The log file is used to write the output of errors and problems of the + * agent. + * + * @param format String output format (like printf). + * @param ... Variable argument list + */ +void +Pandora::pandoraLog (const char *format, ...) { + if (!pandora_log_disable) { + va_list args; + char msg[5000]; + + va_start (args, format); + vsprintf (msg, format, args); + va_end (args); + + pandoraWriteLog ("pandora_agent.log", (char *) msg); + } + return; +} + +/** + * Write a message in the debug file. + * + * The log file is used to write the output of debugging information of the + * agent. + * + * @param format String output format. + * @param ... Variable argument list + */ +void +Pandora::pandoraDebug (const char *format, ...) { + if (pandora_debug) { + va_list args; + char msg[5000]; + + va_start (args, format); + vsprintf (msg, format, args); + va_end (args); + + pandoraWriteLog ("pandora_debug.log", (char *) msg); + } + return; +} + +/** + * Secure free of a pointer. + * + * @param pointer pointer to free. + */ +void +Pandora::pandoraFree (void * pointer) { + if (pointer != NULL) + free (pointer); + return; +} + +/** + * Set the installation directory of the application. + * + * This directory is the path to the directory which holds + * the binary file. + * + * @param dir The path to the directory. + * + * @see getPandoraInstallDir + */ +void +Pandora::setPandoraInstallDir (string dir) { + pandora_dir = dir; +} + +/** + * Get the installation directory of the application. + * + * This directory is the path to the directory which holds + * the binary file. + * + * @return The path to the directory. + * + * @see setPandoraInstallDir + */ +string +Pandora::getPandoraInstallDir () { + return pandora_dir; +} + +/** + * Set the installation path of the application. + * + * This the complete path to the binary file. + * + * @param path The path to the binary file. + * + * @see getPandoraInstallPath + */ +void +Pandora::setPandoraInstallPath (string path) { + pandora_path = path; +} + +/** + * Get the installation path of the application. + * + * This the complete path to the binary file. + * + * @return The path. + * + * @see setPandoraInstallPath + */ +string +Pandora::getPandoraInstallPath () { + return pandora_path; +} + +/** + * Set the debug flag. + * + * If the flag is true output wil be generated and XML files will not be deleted. + * + * @param dbg Turns the debug flag on/off. + * + * @see getPandoraDebug + * @see pandoraDebug + */ +void +Pandora::setPandoraDebug (bool dbg) { + pandora_debug = dbg; +} + +/** + * Get the debug flag value. + * + * If the flag is truee output wil be generated and XML files will not be deleted. + * + * @see setPandoraDebug + * @see pandoraDebug + */ +bool +Pandora::getPandoraDebug () { + return pandora_debug; +} + +/** + * Set the disable logfile flag. + * + * If the flag is true no logs will be written. + * + * @param dbg Turns the debug flag on/off. + * + */ +void +Pandora::setPandoraLogDisable (bool dbg) { + pandora_log_disable = dbg; +} + +/** + * Get the version of the agent. + * + * @return The version. + */ +string +Pandora::getPandoraAgentVersion () { + return pandora_version; +} + + +bool +Pandora::is_enabled (string value) { + static string enabled_values[] = {"enabled", "1", "on", "yes", "si", "sí", "ok", "true", ""}; + int i = 0; + + if (value == "") { + return false; + } + + while (enabled_values[i] != "") { + if (enabled_values[i] == value) { + return true; + } + i++; + } + return false; +} diff --git a/pandora_agents/win32/pandora_agent_conf.cc b/pandora_agents/win32/pandora_agent_conf.cc index 83675cdde6..94617243d5 100644 --- a/pandora_agents/win32/pandora_agent_conf.cc +++ b/pandora_agents/win32/pandora_agent_conf.cc @@ -228,6 +228,15 @@ Pandora::Pandora_Agent_Conf::setFile (string *all_conf){ key_values->push_back (kv); continue; } + + /*Check if is a agent_alias_cmd"*/ + pos = buffer.find("agent_alias_cmd"); + if (pos != string::npos){ + Key_Value kv; + kv.parseLineByPosition(buffer, 15); + key_values->push_back (kv); + continue; + } /*Check if is a collection*/ pos = buffer.find("file_collection"); diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index 3e9184102c..cad177411a 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -76,6 +76,7 @@ Pandora_Windows_Service::setValues (const char * svc_name, this->service_description = (char *) svc_description; execution_number = 0; this->modules = NULL; + this->broker_modules = NULL; this->conf = NULL; this->interval = 60000; this->timestamp = 0; @@ -105,6 +106,10 @@ Pandora_Windows_Service::~Pandora_Windows_Service () { if (this->modules != NULL) { delete this->modules; } + + if (this->broker_modules != NULL) { + delete this->broker_modules; + } pandoraLog ("Pandora agent stopped"); } @@ -136,10 +141,10 @@ Pandora_Windows_Service::pandora_init_broker (string file_conf) { this->conf = Pandora::Pandora_Agent_Conf::getInstance (); this->conf->setFile (file_conf); - if (this->modules != NULL) { - delete this->modules; + if (this->broker_modules != NULL) { + delete this->broker_modules; } - this->modules = new Pandora_Module_List (file_conf); + this->broker_modules = new Pandora_Module_List (file_conf); pandoraDebug ("Pandora broker agent started"); } @@ -208,9 +213,14 @@ Pandora_Windows_Service::check_broker_agents(string *all_conf){ void Pandora_Windows_Service::pandora_init () { + pandora_init(true); +} + +void +Pandora_Windows_Service::pandora_init (bool reload_modules) { string conf_file, interval, debug, disable_logfile, intensive_interval, util_dir, path, env; string udp_server_enabled, udp_server_port, udp_server_addr, udp_server_auth_addr; - string agent_name, agent_name_cmd, agent_alias, pandora_agent; + string agent_name, agent_name_cmd, agent_alias, agent_alias_cmd, pandora_agent; string proxy_mode, server_ip; string *all_conf; int pos, num; @@ -224,7 +234,7 @@ Pandora_Windows_Service::pandora_init () { this->conf = Pandora::Pandora_Agent_Conf::getInstance (); this->conf->setFile (all_conf); - if (this->modules != NULL) { + if (this->modules != NULL && reload_modules) { delete this->modules; } @@ -255,9 +265,40 @@ Pandora_Windows_Service::pandora_init () { this->setSleepTime (this->intensive_interval); // Read modules - this->modules = new Pandora_Module_List (conf_file); + if (reload_modules) { + this->modules = new Pandora_Module_List (conf_file); + } delete []all_conf; - + + // Get the agent alias. + agent_alias = conf->getValue ("agent_alias"); + if (agent_alias == "") { + agent_alias_cmd = conf->getValue ("agent_alias_cmd"); + if (agent_alias_cmd != "") { + agent_alias_cmd = "cmd.exe /c \"" + agent_alias_cmd + "\""; + static string temp_agent_alias = getAgentNameFromCmdExec(agent_alias_cmd); + + // Delete new line and carriage return. + pos = temp_agent_alias.find("\n"); + if(pos != string::npos) { + temp_agent_alias.erase(pos, temp_agent_alias.size () - pos); + } + pos = temp_agent_alias.find("\r"); + if(pos != string::npos) { + temp_agent_alias.erase(pos, temp_agent_alias.size () - pos); + } + + // Remove leading and trailing white spaces. + temp_agent_alias = trim(temp_agent_alias); + if (temp_agent_alias != "") { + agent_alias = temp_agent_alias; + } + } else { + agent_alias = Pandora_Windows_Info::getSystemName (); + } + } + this->conf->setValue("agent_alias", agent_alias); + // Get the agent name. agent_name = conf->getValue ("agent_name"); if (agent_name == "") { @@ -299,13 +340,6 @@ Pandora_Windows_Service::pandora_init () { this->conf->setValue("agent_name", agent_name); } - // Get the agent alias. - conf->getValue ("agent_alias"); - if (agent_alias == "") { - agent_alias = Pandora_Windows_Info::getSystemName (); - this->conf->setValue("agent_alias", agent_alias); - } - pandora_agent = "PANDORA_AGENT=" + agent_name; putenv(pandora_agent.c_str()); @@ -441,7 +475,7 @@ Pandora_Windows_Service::getXmlHeader () { agent_name = conf->getValue ("agent_name"); // Get agent alias - conf->getValue ("agent_alias"); + agent_alias = conf->getValue ("agent_alias"); // Get parent agent name parent_agent_name = conf->getValue ("parent_agent_name"); @@ -1519,7 +1553,7 @@ Pandora_Windows_Service::checkConfig (string file) { } /* Get agent name */ - tmp = conf->getValue ("agent_name"); + agent_name = conf->getValue ("agent_name"); /* Error getting agent name */ @@ -1834,19 +1868,19 @@ Pandora_Windows_Service::pandora_run_broker (string config) { server_addr = conf->getValue ("server_ip"); - if (this->modules != NULL) { - this->modules->goFirst (); + if (this->broker_modules != NULL) { + this->broker_modules->goFirst (); - while (! this->modules->isLast ()) { + while (! this->broker_modules->isLast ()) { Pandora_Module *module; - module = this->modules->getCurrentValue (); + module = this->broker_modules->getCurrentValue (); /* Check preconditions */ if (module->evaluatePreconditions () == 0) { pandoraDebug ("Preconditions not matched for module %s", module->getName ().c_str ()); module->setNoOutput (); - this->modules->goNext (); + this->broker_modules->goNext (); continue; } @@ -1854,15 +1888,23 @@ Pandora_Windows_Service::pandora_run_broker (string config) { if (module->checkCron (module->getInterval (), atoi (conf->getValue ("interval").c_str())) == 0) { pandoraDebug ("Cron not matched for module %s", module->getName ().c_str ()); module->setNoOutput (); - this->modules->goNext (); + this->broker_modules->goNext (); continue; } + /* Check async */ + if (module->getAsync()) { + pandoraDebug ("Forbidden async module %s in broker agents", module->getName ().c_str ()); + module->setNoOutput (); + this->broker_modules->goNext (); + continue; + } + pandoraDebug ("Run %s", module->getName ().c_str ()); module->run (); if (! module->hasOutput ()) { module->setNoOutput (); - this->modules->goNext (); + this->broker_modules->goNext (); continue; } @@ -1875,7 +1917,7 @@ Pandora_Windows_Service::pandora_run_broker (string config) { intensive_match = module->evaluateIntensiveConditions (); if (intensive_match == module->getIntensiveMatch () && module->getTimestamp () + module->getInterval () * this->interval_sec > this->run_time) { module->setNoOutput (); - this->modules->goNext (); + this->broker_modules->goNext (); continue; } module->setIntensiveMatch (intensive_match); @@ -1890,7 +1932,7 @@ Pandora_Windows_Service::pandora_run_broker (string config) { /* At least one module has data */ data_flag = 1; - this->modules->goNext (); + this->broker_modules->goNext (); } } @@ -1898,7 +1940,7 @@ Pandora_Windows_Service::pandora_run_broker (string config) { // Send the XML if (!server_addr.empty ()) { - this->sendXml (this->modules); + this->sendXml (this->broker_modules); } } @@ -2037,7 +2079,7 @@ Pandora_Windows_Service::pandora_run (int forced_run) { /* Reload the original configuration */ if (num != 0) { - pandora_init (); + pandora_init (false); } /* Reset time reference if necessary */ diff --git a/pandora_agents/win32/pandora_windows_service.h b/pandora_agents/win32/pandora_windows_service.h index be9a7a4eb3..17f0130884 100644 --- a/pandora_agents/win32/pandora_windows_service.h +++ b/pandora_agents/win32/pandora_windows_service.h @@ -42,6 +42,7 @@ namespace Pandora { private: Pandora_Agent_Conf *conf; Pandora_Module_List *modules; + Pandora_Module_List *broker_modules; long execution_number; string agent_name; string alias; @@ -98,6 +99,7 @@ namespace Pandora { void pandora_run (int forced_run); void pandora_run (); void pandora_init (); + void pandora_init (bool reload_modules); long interval; long interval_sec; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 89209dd79d..fc578b0d73 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG(Build 170411))" + VALUE "ProductVersion", "(7.0NG.712(Build 170908))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_agents/win32/versioninfo.rc.orig b/pandora_agents/win32/versioninfo.rc.orig new file mode 100644 index 0000000000..fe87b98faf --- /dev/null +++ b/pandora_agents/win32/versioninfo.rc.orig @@ -0,0 +1,28 @@ +1 VERSIONINFO +FILEVERSION 1,0,0,0 +PRODUCTVERSION 1,0,0,0 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904E4" + BEGIN + VALUE "CompanyName", "Artica ST" + VALUE "FileDescription", "Pandora FMS Agent for Windows Platform" + VALUE "LegalCopyright", "Artica ST" + VALUE "OriginalFilename", "PandoraAgent.exe" + VALUE "ProductName", "Pandora FMS Windows Agent" +<<<<<<< HEAD + VALUE "ProductVersion", "(7.0NG(Build 170406))" +======= + VALUE "ProductVersion", "(7.0NG(Build 170418))" +>>>>>>> develop + VALUE "FileVersion", "1.0.0.0" + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1252 + END +END + diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index a83f913f77..b183226957 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,10 +1,10 @@ package: pandorafms-console -Version: 7.0NG-170411 +Version: 7.0NG.712-170908 Architecture: all Priority: optional Section: admin Installed-Size: 42112 Maintainer: Artica ST Homepage: http://pandorafms.org/ -Depends: php5, php5-snmp, php5-gd, php5-mysql, php-db, php5-xmlrpc, php-gettext, php5-curl, graphviz, dbconfig-common, php5-ldap, mysql-client | virtual-mysql-client +Depends: php5.6 | php5, php5.6-snmp | php5-snmp, php5.6-gd | php5-gd, php5.6-mysql | php5-mysql, php-db, php5.6-xmlrpc | php5-xmlrpc, php-gettext, php5.6-curl | php5-curl, graphviz, dbconfig-common, php5.6-ldap | php5-ldap, mysql-client | virtual-mysql-client Description: Pandora FMS is an Open Source monitoring tool. It monitor your systems and applications, and allows you to control the status of any element of them. The web console is the graphical user interface (GUI) to manage the pool and to generate reports and graphs from the Pandora FMS monitoring process. diff --git a/pandora_console/DEBIAN/control.orig b/pandora_console/DEBIAN/control.orig new file mode 100644 index 0000000000..34fa326f6e --- /dev/null +++ b/pandora_console/DEBIAN/control.orig @@ -0,0 +1,14 @@ +package: pandorafms-console +<<<<<<< HEAD +Version: 7.0NG-170406 +======= +Version: 7.0NG-170418 +>>>>>>> develop +Architecture: all +Priority: optional +Section: admin +Installed-Size: 42112 +Maintainer: Artica ST +Homepage: http://pandorafms.org/ +Depends: php5, php5-snmp, php5-gd, php5-mysql, php-db, php5-xmlrpc, php-gettext, php5-curl, graphviz, dbconfig-common, php5-ldap, mysql-client | virtual-mysql-client +Description: Pandora FMS is an Open Source monitoring tool. It monitor your systems and applications, and allows you to control the status of any element of them. The web console is the graphical user interface (GUI) to manage the pool and to generate reports and graphs from the Pandora FMS monitoring process. diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index da9ca3b777..d89326f528 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG-170411" +pandora_version="7.0NG.712-170908" package_pear=0 package_pandora=1 diff --git a/pandora_console/DEBIAN/make_deb_package.sh.orig b/pandora_console/DEBIAN/make_deb_package.sh.orig new file mode 100644 index 0000000000..ba3a273b73 --- /dev/null +++ b/pandora_console/DEBIAN/make_deb_package.sh.orig @@ -0,0 +1,168 @@ +#!/bin/bash + +#Pandora FMS- http:#pandorafms.com +# ================================================== +# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas +# Please see http:#pandorafms.org for full contribution list + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; version 2 + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +<<<<<<< HEAD +pandora_version="7.0NG-170406" +======= +pandora_version="7.0NG-170418" +>>>>>>> develop + +package_pear=0 +package_pandora=1 + +for param in $@ +do + if [ $param = "-h" -o $param = "--help" ] + then + echo "For only make packages of pear type +pear" + echo "For not make packages of pear type -pear" + exit 0 + fi + + if [ $param = "+pear" ] + then + package_pandora=0 + fi + if [ $param = "-pear" ] + then + package_pear=0 + fi +done + +if [ $package_pandora -eq 1 ] +then + echo "Test if you have all the needed tools to make the packages." + whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null + if [ $? = 1 ] + then + echo "No found \"dpkg-deb\" aplication, please install." + exit 1 + else + echo "Found \"dpkg-debs\"." + fi +fi + +if [ $package_pear -eq 1 ] +then + whereis dh-make-pear | cut -d":" -f2 | grep dh-make-pear > /dev/null + if [ $? = 1 ] + then + echo " \"dh-make-pear\" aplication not found, please install." + exit 1 + else + echo "Found \"dh-make-pear\"." + fi + + whereis fakeroot | cut -d":" -f2 | grep fakeroot > /dev/null + if [ $? = 1 ] + then + echo " \"fakeroot\" aplication not found, please install." + exit 1 + else + echo "Found \"fakeroot\"." + fi +fi + +whereis dpkg-buildpackage | cut -d":" -f2 | grep dpkg-buildpackage > /dev/null +if [ $? = 1 ] +then + echo " \"dpkg-buildpackage\" aplication not found, please install." + exit 1 +else + echo "Found \"dpkg-buildpackage\"." +fi + +cd .. + +echo "Make a \"temp_package\" temporary dir for job." +mkdir -p temp_package +if [ $package_pandora -eq 1 ] +then + mkdir -p temp_package/var/www/pandora_console + mkdir -p temp_package/etc/logrotate.d + + echo "Make directory system tree for package." + cp -R $(ls | grep -v temp_package | grep -v DEBIAN ) temp_package/var/www/pandora_console + cp -R DEBIAN temp_package + cp -aRf pandora_console_logrotate_ubuntu temp_package/etc/logrotate.d/pandora_console + find temp_package/var/www/pandora_console -name ".svn" | xargs rm -Rf + rm -Rf temp_package/var/www/pandora_console/pandora_console.spec + chmod 755 -R temp_package/DEBIAN + touch temp_package/var/www/pandora_console/include/config.php + + + echo "Remove the SVN files and other temp files." + for item in `find temp_package` + do + echo -n "." + echo $item | grep "svn" > /dev/null + #last command success + if [ $? -eq 0 ] + then + rm -rf $item + fi + + echo $item | grep "make_deb_package.sh" > /dev/null + #last command success + if [ $? -eq 0 ] + then + rm -rf $item + fi + done + echo "END" + + echo "Calculate md5sum for md5sums package control file." + for item in `find temp_package` + do + echo -n "." + if [ ! -d $item ] + then + echo $item | grep "DEBIAN" > /dev/null + #last command success + if [ $? -eq 1 ] + then + md5=`md5sum $item | cut -d" " -f1` + + #delete "temp_package" in the path + final_path=${item#temp_package} + echo $md5" "$final_path >> temp_package/DEBIAN/md5sums + fi + fi + done + echo "END" + + echo "Make the package \"Pandorafms console\"." + dpkg-deb --build temp_package + mv temp_package.deb pandorafms.console_$pandora_version.deb +fi + +if [ $package_pear -eq 1 ] +then + echo "Make the package \"php-xml-rpc\"." + cd temp_package + dh-make-pear --maintainer "Miguel de Dios " XML_RPC + cd php-xml-rpc-* + dpkg-buildpackage -rfakeroot + cd .. + mv php-xml-rpc*.deb .. + cd .. +fi + + +echo "Delete the \"temp_package\" temporary dir for job." +rm -Rf temp_package + +echo "DONE: Package ready at: ../pandorafms.console_$pandora_version.deb" diff --git a/pandora_console/Dockerfile b/pandora_console/Dockerfile index 3f46b9c25b..ccbcef4cdd 100644 --- a/pandora_console/Dockerfile +++ b/pandora_console/Dockerfile @@ -24,7 +24,6 @@ RUN yum install -y \ cronie \ ntp \ openldap \ - anytermd \ nfdump \ wget \ curl \ @@ -51,8 +50,8 @@ RUN yum install -y \ #Clone the repo RUN git clone -b develop https://github.com/pandorafms/pandorafms.git /tmp/pandorafms -#Exposing ports for: HTTP, SNMP Traps, Anytermd (SSH), Anytermd (Telnet), Tentacle protocol -EXPOSE 80 162/udp 8022 8023 41121 +#Exposing ports for: HTTP, SNMP Traps, Tentacle protocol +EXPOSE 80 162/udp 41121 # Simple startup script to avoid some issues observed with container restart ADD docker_entrypoint.sh /entrypoint.sh diff --git a/pandora_console/docker_entrypoint.sh b/pandora_console/docker_entrypoint.sh index c7d749e483..9e7f24839b 100755 --- a/pandora_console/docker_entrypoint.sh +++ b/pandora_console/docker_entrypoint.sh @@ -69,13 +69,12 @@ sed "s/.*post_max_size =.*/post_max_size = 100M/" /etc/php.ini > /tmp/php.ini && cd /var/www/html/pandora_console && mv -f install.php install.php.done -#Create the pandora user to run the anyterd, mainly +#Create the pandora user /usr/sbin/useradd -d /home/pandora -s /bin/false -M -g 0 pandora #Rock n' roll! /etc/init.d/crond start & /etc/init.d/ntpd start & -/etc/init.d/anytermd start & rm -rf /run/httpd/* exec /usr/sbin/apachectl -D FOREGROUND diff --git a/pandora_console/extensions/agents_alerts.php b/pandora_console/extensions/agents_alerts.php index 72e5db9e40..97f1bc7589 100755 --- a/pandora_console/extensions/agents_alerts.php +++ b/pandora_console/extensions/agents_alerts.php @@ -60,9 +60,31 @@ function mainAgentsAlerts() { } $updated_time = $updated_info; + $create_alert = (int)get_parameter ("create_alert",0); + if($create_alert){ + $template2 = get_parameter("template"); + $module_action_threshold = get_parameter("module_action_threshold"); + + $id_alert = alerts_create_alert_agent_module ($create_alert, $template2); + + if ($id_alert !== false) { + $action_select = get_parameter("action_select",0); + + if ($action_select != 0) { + $values = array(); + $values['fires_min'] = 0; + $values['fires_max'] = 0; + $values['module_action_threshold'] = + (int)get_parameter ('module_action_threshold'); + + alerts_add_alert_agent_module_action ($id_alert, $action_select, $values); + } + } + + } $refr = get_parameter('refr', 30); // By default 30 seconds - + $show_modules = (bool) get_parameter ("show_modules",0); $group_id = get_parameter('group_id', 0); $offset = get_parameter('offset', 0); $hor_offset = get_parameter('hor_offset', 0); @@ -70,10 +92,12 @@ function mainAgentsAlerts() { $groups = users_get_groups (); - $filter_groups = ''; $filter_groups .= ''.__('Group').''; - $filter_groups .= html_print_select_groups(false, "AR", true, 'group_id', $group_id, 'this.form.submit()', '', '', true, false, true, '', false , 'width: 100px; margin-right: 10px;; margin-top: 5px;'); - $filter_groups .= ''; + $filter_groups .= html_print_select_groups(false, "AR", true, 'group_id', $group_id, false, '', '', true, false, true, '', false , 'margin-right: 10px; margin-top: 5px;'); + + $check = ''.__('Show modules without alerts').''; + $check .= html_print_checkbox('slides_ids[]', $d['id'], $show_modules, true, false, '', true); + $comborefr = '
'; $comborefr .= ''.__('Refresh').''; @@ -87,12 +111,12 @@ function mainAgentsAlerts() { $comborefr .= "
"; if ($config["pure"] == 0) { - $fullscreen['text'] = '' + $fullscreen['text'] = '' . html_print_image ("images/full_screen.png", true, array ("title" => __('Full screen mode'))) . ""; } else { - $fullscreen['text'] = '' + $fullscreen['text'] = '' . html_print_image ("images/normal_screen.png", true, array ("title" => __('Back to normal mode'))) . ""; $config['refr'] = $refr; @@ -113,161 +137,288 @@ function mainAgentsAlerts() { echo ''; echo ""; echo ""; + echo ""; if ($config['pure'] == 1) echo ""; echo ""; echo ""; echo "
" . $filter_groups . "" . $check . "" . $comborefr . " " . __("Full screen") . "" . $fullscreen['text'] . "
"; - $filter = array ('offset' => (int) $offset, - 'limit' => (int) $config['block_size']); - $filter_count = array(); - - if ($group_id > 0) { - $filter['id_grupo'] = $group_id; - $filter_count['id_grupo'] = $group_id; - } - - // Get the id of all agents with alerts - $sql = 'SELECT DISTINCT(id_agente) - FROM tagente_modulo - WHERE id_agente_modulo IN - (SELECT id_agent_module - FROM talert_template_modules)'; - $agents_with_alerts_raw = db_get_all_rows_sql($sql); - - if ($agents_with_alerts_raw === false) { - $agents_with_alerts_raw = array(); - } - - $agents_with_alerts = array(); - foreach ($agents_with_alerts_raw as $awar) { - $agents_with_alerts[] = $awar['id_agente']; - } - - $filter['id_agente'] = $agents_with_alerts; - $filter_count['id_agente'] = $agents_with_alerts; - - $agents = agents_get_agents ($filter); - - $nagents = count(agents_get_agents ($filter_count)); - - if ($agents == false) { - ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no agents with alerts') ) ); - return; - } - - $all_alerts = agents_get_alerts_simple (); - - if($config["pure"] == 1) { - $block = count($all_alerts); - } - - $templates = array(); - $agent_alerts = array(); - foreach ($all_alerts as $alert) { - $templates[$alert['id_alert_template']] = ''; - $agent_alerts[$alert['agent_name']][$alert['id_alert_template']][] = $alert; - } - - // Prepare pagination - ui_pagination ($nagents); - - echo ''; - echo ""; - - if ($hor_offset > 0) { - $new_hor_offset = $hor_offset-$block; - echo ""; - } - - $templates_raw = array(); - if (!empty($templates)) { - $sql = sprintf('SELECT id, name - FROM talert_templates - WHERE id IN (%s)',implode(',',array_keys($templates))); + if($show_modules){ - $templates_raw = db_get_all_rows_sql($sql); - } - - if (empty($templates_raw)) - $templates_raw = array(); - - $alerts = array(); - $ntemplates = 0; - foreach ($templates_raw as $temp) { - if (isset($templates[$temp['id']]) && $templates[$temp['id']] == '') { - $ntemplates++; - if ($ntemplates <= $hor_offset || $ntemplates > ($hor_offset+$block)) { - continue; + + if($group_id > 0){ + $grupo = " AND tagente.id_grupo = $group_id"; + } else { + $grupo =''; + } + + $offset_modules = get_parameter ("offset",0); + $sql_count = "SELECT COUNT(tagente_modulo.nombre) FROM tagente_modulo + INNER JOIN tagente ON tagente.id_agente = tagente_modulo.id_agente + WHERE id_agente_modulo NOT IN (SELECT id_agent_module FROM talert_template_modules) + $grupo"; + $count_agent_module = db_get_all_rows_sql($sql_count); + + $sql = "SELECT tagente.alias, tagente_modulo.nombre, + tagente_modulo.id_agente_modulo FROM tagente_modulo + INNER JOIN tagente ON tagente.id_agente = tagente_modulo.id_agente + WHERE id_agente_modulo NOT IN (SELECT id_agent_module FROM talert_template_modules) + $grupo LIMIT 20 OFFSET $offset_modules"; + $agent_modules = db_get_all_rows_sql($sql); + + ui_pagination ($count_agent_module[0]['COUNT(tagente_modulo.nombre)'], + ui_get_url_refresh(),0,0,false,'offset',true,'', + '',false,'alerts_modules'); + + $table->width = '100%'; + $table->class = "databox data"; + $table->id = "table_agent_module"; + $table->data = array (); + + $table->head[0] = __('Agents'); + $table->head[1] = __('Modules'); + $table->head[2] = __('Actions'); + + $table->style[0]= 'width: 25%;'; + $table->style[1]= 'width: 33%;'; + $table->style[2]= 'width: 33%;'; + + foreach($agent_modules as $agent_module) { + $data[0] = io_safe_output($agent_module['alias']); + $data[1] = io_safe_output($agent_module['nombre']); + $uniqid = $agent_module['id_agente_modulo']; + $data[2] = "".html_print_image('images/add_mc.png', true).""; + array_push ($table->data, $data); + + $table2->width = '100%'; + $table2->id = "table_add_alert"; + $table2->class = 'databox filters'; + $table2->data = array (); + // $data[0] = + $table2->data[0][0] = __('Actions'); + + $groups_user = users_get_groups($config["id_user"]); + if (!empty($groups_user)) { + $groups = implode(',', array_keys($groups_user)); + $sql = "SELECT id, name FROM talert_actions WHERE id_group IN ($groups)"; + $actions = db_get_all_rows_sql($sql); + } + + $table2->data[0][1] = html_print_select( + index_array($actions, 'id', 'name'), 'action_select', '', '', + __('Default action'), '0', true, '', true, '', false, + 'width: 250px;'); + $table2->data[0][1] .= ''; + if (check_acl ($config['id_user'], 0, "LM")) { + + $table2->data[0][1] .= ''; + $table2->data[0][1] .= html_print_image ('images/add.png', true); + $table2->data[0][1] .= ''.__('Create Action').''; + $table2->data[0][1] .= ''; + } + + $table2->data[1][0] = __('Template'); + $own_info = get_user_info ($config['id_user']); + if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) + $templates = alerts_get_alert_templates (false, array ('id', 'name')); + else { + $usr_groups = users_get_groups($config['id_user'], 'LW', true); + $filter_groups = ''; + $filter_groups = implode(',', array_keys($usr_groups)); + $templates = alerts_get_alert_templates (array ('id_group IN (' . $filter_groups . ')'), array ('id', 'name')); + } + + $table2->data[1][1] = html_print_select (index_array ($templates, 'id', 'name'), + 'template', '', '', __('Select'), 0, true, false, true, '', false, 'width: 250px;'); + $table2->data[1][1] .= ' '; + if (check_acl ($config['id_user'], 0, "LM")) { + $table2->data[1][1] .= ''; + $table2->data[1][1] .= html_print_image ('images/add.png', true); + $table2->data[1][1] .= ''.__('Create Template').''; + $table2->data[1][1] .= ''; + } + $table2->data[2][0] = __('Threshold'); + $table2->data[2][1] = html_print_input_text ('module_action_threshold', '0', '', 5, 7, true); + $table2->data[2][1] .= ' ' . __('seconds') . ui_print_help_icon ('action_threshold', true); + + $content2 = ''; + $content2 .= html_print_table($table2,true); + + $content2 .= '
'; + $content2 .= html_print_submit_button (__('Add alert'), 'add', false, 'class="sub wand"',true); + $content2 .= html_print_input_hidden ('create_alert', $uniqid,true); + $content2 .= '
'; + + $module_name = ui_print_truncate_text(io_safe_output($agent_module['nombre']), 40, false, true, false, '…', false); + echo ''; + } + + html_print_table($table); + + } else { + + $filter = array ('offset' => (int) $offset, + 'limit' => (int) $config['block_size']); + $filter_count = array(); + + if ($group_id > 0) { + $filter['id_grupo'] = $group_id; + $filter_count['id_grupo'] = $group_id; + } + + // Get the id of all agents with alerts + $sql = 'SELECT DISTINCT(id_agente) + FROM tagente_modulo + WHERE id_agente_modulo IN + (SELECT id_agent_module + FROM talert_template_modules)'; + $agents_with_alerts_raw = db_get_all_rows_sql($sql); + + if ($agents_with_alerts_raw === false) { + $agents_with_alerts_raw = array(); + } + + $agents_with_alerts = array(); + foreach ($agents_with_alerts_raw as $awar) { + $agents_with_alerts[] = $awar['id_agente']; + } + + $filter['id_agente'] = $agents_with_alerts; + $filter_count['id_agente'] = $agents_with_alerts; + + $agents = agents_get_agents ($filter); + + $nagents = count(agents_get_agents ($filter_count)); + + if ($agents == false) { + ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no agents with alerts') ) ); + return; + } + + $all_alerts = agents_get_alerts_simple (); + + if($config["pure"] == 1) { + $block = count($all_alerts); + } + + $templates = array(); + $agent_alerts = array(); + foreach ($all_alerts as $alert) { + $templates[$alert['id_alert_template']] = ''; + $agent_alerts[$alert['agent_name']][$alert['id_alert_template']][] = $alert; + } + + // Prepare pagination + ui_pagination ($nagents,false,0,0,false,'offset',true,'', + '',array('count' => '', 'offset' => 'offset_param'),'alerts_agents'); + + echo '
".__("Agents")." / ".__("Alert templates")." - ". - html_print_image("images/darrowleft.png",true, array('title' => __('Previous templates')))."
'; + echo ""; + + if ($hor_offset > 0) { + $new_hor_offset = $hor_offset-$block; + echo ""; + } + + $templates_raw = array(); + if (!empty($templates)) { + $sql = sprintf('SELECT id, name + FROM talert_templates + WHERE id IN (%s)',implode(',',array_keys($templates))); + + $templates_raw = db_get_all_rows_sql($sql); + } + + if (empty($templates_raw)) + $templates_raw = array(); + + $alerts = array(); + $ntemplates = 0; + foreach ($templates_raw as $temp) { + if (isset($templates[$temp['id']]) && $templates[$temp['id']] == '') { + $ntemplates++; + if ($ntemplates <= $hor_offset || $ntemplates > ($hor_offset+$block)) { + continue; + } + $templates[$temp['id']] = $temp['name']; } - $templates[$temp['id']] = $temp['name']; } - } - - foreach ($templates as $tid => $tname) { - if ($tname == '') { - continue; - } - echo '"; - } - - if (($hor_offset + $block) < $ntemplates) { - $new_hor_offset = $hor_offset+$block; - echo ""; - } - - foreach ($agents as $agent) { - $alias = db_get_row ('tagente', 'id_agente', $agent['id_agente']); - echo ''; - // Name of the agent - echo ''; - // Alerts of the agent - $anyfired = false; foreach ($templates as $tid => $tname) { if ($tname == '') { continue; } - if (isset($agent_alerts[$agent['nombre']][$tid])) { - foreach($agent_alerts[$agent['nombre']][$tid] as $alert) { - if($alert["times_fired"] > 0) { - $anyfired = true; - } - } - - $cellstyle = ''; - if($anyfired) { - $cellstyle = 'background:'.COL_ALERTFIRED.';'; - } - - echo ''; + echo '"; } - echo ''; + + if (($hor_offset + $block) < $ntemplates) { + $new_hor_offset = $hor_offset+$block; + echo ""; + } + + foreach ($agents as $agent) { + $alias = db_get_row ('tagente', 'id_agente', $agent['id_agente']); + echo ''; + // Name of the agent + echo ''; + + // Alerts of the agent + $anyfired = false; + foreach ($templates as $tid => $tname) { + if ($tname == '') { + continue; + } + if (isset($agent_alerts[$agent['nombre']][$tid])) { + foreach($agent_alerts[$agent['nombre']][$tid] as $alert) { + if($alert["times_fired"] > 0) { + $anyfired = true; + } + } + + $cellstyle = ''; + if($anyfired) { + $cellstyle = 'background:'.COL_ALERTFIRED.';'; + } + + echo ''; + } + echo ''; + } + + echo '
".__("Agents")." / ".__("Alert templates")." + ". + html_print_image("images/darrowleft.png",true, array('title' => __('Previous templates')))." '. io_safe_output($tname) . html_print_image('images/information_alerts.png', true, array('title' => io_safe_output($tname),'style' => 'margin-left:5px' )) ." - ".html_print_image("images/darrowright.png",true, array('title' => __('More templates')))."
'.$alias['alias'].' '; - - $uniqid = uniqid(); - echo "
"; - - echo count($agent_alerts[$agent['nombre']][$tid])." ".__('Alerts')." "; - - echo "".html_print_image('images/zoom.png', true).""; - - echo "
"; - - print_alerts_summary_modal_window($uniqid, $agent_alerts[$agent['nombre']][$tid]); - } - else { - echo '
'; - } - echo ''. io_safe_output($tname) . html_print_image('images/information_alerts.png', true, array('title' => io_safe_output($tname),'style' => 'margin-left:5px' )) ."
+ ".html_print_image("images/darrowright.png",true, array('title' => __('More templates')))."
'.$alias['alias'].' '; + + $uniqid = uniqid(); + echo "
"; + + echo count($agent_alerts[$agent['nombre']][$tid])." ".__('Alerts')." "; + + echo "".html_print_image('images/zoom.png', true).""; + + echo "
"; + + print_alerts_summary_modal_window($uniqid, $agent_alerts[$agent['nombre']][$tid]); + } + else { + echo '
'; + } + echo '
'; } - echo ''; + } // Print the modal window for the summary of each alerts group @@ -366,4 +517,40 @@ ui_require_jquery_file('pandora'); } }); } + + function show_add_alerts(id) { + $("#add_alerts_dialog_"+id).dialog({ + resizable: true, + draggable: true, + modal: true, + height: 235, + width: 600, + overlay: { + opacity: 0.5, + background: "black" + } + }); + } + + // checkbox-slides_ids + $(document).ready(function () { + $('#checkbox-slides_ids').click(function(){ + if ($('#checkbox-slides_ids').prop('checked')){ + var url = location.href.replace("&show_modules=true", ""); + location.href = url+"&show_modules=true"; + } else { + var url = location.href.replace("&show_modules=true", ""); + var re = /&offset=\d*/g; + location.href = url.replace(re, ""); + } + }); + + $('#group_id').change(function(){ + var regx = /&group_id=\d*/g; + var url = location.href.replace(regx, ""); + location.href = url+"&group_id="+$("#group_id").val(); + }); + + }); + diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index a81ff78b2a..cb6fe8cd42 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -17,6 +17,7 @@ include_once($config['homedir'] . "/include/functions_agents.php"); include_once($config['homedir'] . "/include/functions_modules.php"); include_once($config['homedir'] . '/include/functions_users.php'); +$refr = get_parameter('refresh', 0); // By default 30 seconds function mainAgentsModules() { global $config; @@ -63,7 +64,7 @@ function mainAgentsModules() { $updated_time = $updated_info; $modulegroup = get_parameter('modulegroup', 0); - $refr = get_parameter('refr', 30); // By default 30 seconds + $refr = get_parameter('refresh', 0); // By default 30 seconds $group_id = (int)get_parameter('group_id', 0); $offset = (int)get_parameter('offset', 0); @@ -74,6 +75,8 @@ function mainAgentsModules() { $modules_selected = (array)get_parameter('module', 0); $update_item = (string)get_parameter('edit_item',''); $save_serialize = (int)get_parameter('save_serialize', 0); + $full_modules_selected = explode(";",get_parameter('full_modules_selected', 0)); + $full_agents_id = explode(";",get_parameter('full_agents_id', 0)); if($save_serialize && $update_item == ''){ $unserialize_modules_selected = unserialize_in_temp($config['id_user']."_agent_module", true, 1); @@ -96,32 +99,40 @@ function mainAgentsModules() { if($agents_id[0] != -1 ){ serialize_in_temp($agents_id, $config['id_user']."_agents", 1); } - - $comborefr = '
'; - $comborefr .= ''.__('Refresh').''; - $comborefr .= html_print_select ( - array('30' => '30 ' . __('seconds'), - (string)SECONDS_1MINUTE => __('1 minute'), - (string)SECONDS_2MINUTES => __('2 minutes'), - (string)SECONDS_5MINUTES => __('5 minutes'), - (string)SECONDS_10MINUTES => __('10 minutes')), - 'refr', (int)get_parameter('refr', 0), - $script = 'this.form.submit()', '', 0, true, false, false, '', - false, 'width: 100px; margin-right: 10px; margin-top: 5px;'); - $comborefr .= "
"; - if ($config["pure"] == 0) { - $fullscreen['text'] = '' - . html_print_image ("images/full_screen.png", true, array ("title" => __('Full screen mode'))) - . ""; - } - else { - $fullscreen['text'] = '' - . html_print_image ("images/normal_screen.png", true, array ("title" => __('Back to normal mode'))) - . ""; - $config['refr'] = $refr; - } + if ($config["pure"] == 0) { + if($modules_selected[0] && $agents_id[0]){ + + $full_modules = urlencode(implode(";",$modules_selected)); + $full_agents = urlencode(implode(";",$agents_id)); + + $fullscreen['text'] = '' + . html_print_image ("images/full_screen.png", true, array ("title" => __('Full screen mode'))) + . ""; + + } else if($full_modules_selected[0] && $full_agents_id[0]){ + + $full_modules = urlencode(implode(";",$full_modules_selected)); + $full_agents = urlencode(implode(";",$full_agents_id)); + + $fullscreen['text'] = '' + . html_print_image ("images/full_screen.png", true, array ("title" => __('Full screen mode'))) + . ""; + + } else { + + $fullscreen['text'] = '' + . html_print_image ("images/full_screen.png", true, array ("title" => __('Full screen mode'))) + . ""; + } + } + $groups = users_get_groups (); //groups @@ -159,7 +170,7 @@ function mainAgentsModules() { //modules $all_modules = select_modules_for_agent_group($group_id, $agents_id, $selection_a_m, false); $filter_modules_label = ''.__('Module').''; - $filter_modules = html_print_select($all_modules, 'module[]', $modules_selected, '', '', 0, true, true, true, '', false, "min-width: 180px; max-width: 200px;"); + $filter_modules = html_print_select($all_modules, 'module[]', $modules_selected, '', '', 0, true, true, false, '', false, "min-width: 180px; max-width: 200px;"); //update $filter_update = html_print_submit_button(__('Update item'), 'edit_item', false, 'class="sub upd"', true); @@ -168,29 +179,74 @@ function mainAgentsModules() { 'combo_module_groups' => $filter_module_groups, 'combo_groups' => $filter_groups); - if ($config['pure'] == 1) { - $onheader['combo_refr'] = $comborefr; - } - - // Header - ui_print_page_header (__("Agents/Modules"), "images/module_mc.png", false, "", false, $updated_time); - // Old style table, we need a lot of special formatting,don't use table function // Prepare old-style table - echo ''; - echo ""; - if ($config['pure'] == 1){ - echo ""; - echo ""; + if ($config['pure'] == 0){ + // Header + ui_print_page_header (__("Agents/Modules"), "images/module_mc.png", false, "", false, $updated_time); + echo '
" . $comborefr . "" . $fullscreen['text'] . "
'; + echo ""; + echo ""; + echo ""; + echo "
" . $fullscreen['text'] . "
"; + } else { + if ($full_agents_id[0]){ + + $full_modules = urlencode(implode(";",$full_modules_selected)) ; + $full_agents = urlencode(implode(";",$full_agents_id)); + + $url =" index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset=$offset + &group_id=$group_id&modulegroup=$modulegroup&refresh=$refr&full_modules_selected=$full_modules + &full_agents_id=$full_agents&selection_agent_module=$selection_a_m"; + + } else { + $url =" index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset=$offset&group_id=$group_id&modulegroup=$modulegroup&refresh=$refr"; } - else{ - echo " " . $fullscreen['text'] . " "; - } - echo ""; - echo ""; + + // Floating menu - Start + echo '
'; + + echo ''; + + echo '
'; + // Floating menu - End + + ui_require_jquery_file('countdown'); + ui_require_css_file('countdown'); + } + if($config['pure'] != 1){ - echo '
'; + echo ''; + echo ''; echo ""; echo ""; @@ -219,9 +275,14 @@ function mainAgentsModules() { $agents = $agents_id; } else { - $agents = ''; - $agents = agents_get_group_agents($group_id,array('disabled' => 0)); - $agents = array_keys($agents); + if($full_agents_id[0]){ + $agents = $full_agents_id; + } else { + $agents = ''; + $agents = agents_get_group_agents($group_id,array('disabled' => 0)); + $agents = array_keys($agents); + } + } $filter_module_group = array('disabled' => 0); @@ -244,7 +305,6 @@ function mainAgentsModules() { if($agents_id[0] != -1){ $all_modules = array(); foreach ($modules_selected as $key => $value) { - //$all_modules[$value] = io_safe_output(modules_get_agentmodule_name($value)); $name = modules_get_agentmodule_name($value); $sql = "SELECT id_agente_modulo FROM tagente_modulo @@ -261,14 +321,34 @@ function mainAgentsModules() { } } else{ - $all_modules = agents_get_modules($agents, false, - $filter_module_group, true, true); + if ($full_modules_selected[0]){ + foreach ($full_modules_selected as $key => $value) { + $name = modules_get_agentmodule_name($value); + $sql = "SELECT id_agente_modulo + FROM tagente_modulo + WHERE nombre = '". $name ."';"; + + $result_sql = db_get_all_rows_sql($sql); + if(is_array($result_sql)){ + foreach ($result_sql as $key => $value) { + $all_modules[$value['id_agente_modulo']] = io_safe_output($name); + } + } + // $all_modules[$value] = modules_get_agentmodule_name($value); + } + + } else { + $all_modules = agents_get_modules($agents, false, + $filter_module_group, true, true); + } + } $modules_by_name = array(); $name = ''; $cont = 0; + foreach ($all_modules as $key => $module) { if ($module == $name) { $modules_by_name[$cont-1]['id'][] = $key; @@ -300,7 +380,7 @@ function mainAgentsModules() { $agents = agents_get_agents ($filter_groups); $nagents = count($agents); - + if ($all_modules == false || $agents == false) { ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no agents with modules') ) ); return; @@ -448,24 +528,24 @@ function mainAgentsModules() { echo ''; switch ($status) { case AGENT_MODULE_STATUS_NORMAL: - ui_print_status_image ('module_ok.png', modules_get_last_value($module_id), false, array('width' => '20px', 'height' => '20px')); + ui_print_status_image ('module_ok.png', modules_get_last_value($module_id), false); break; case AGENT_MODULE_STATUS_CRITICAL_BAD: - ui_print_status_image ('module_critical.png', modules_get_last_value($module_id), false, array('width' => '20px', 'height' => '20px')); + ui_print_status_image ('module_critical.png', modules_get_last_value($module_id), false); break; case AGENT_MODULE_STATUS_WARNING: - ui_print_status_image ('module_warning.png', modules_get_last_value($module_id), false, array('width' => '20px', 'height' => '20px')); + ui_print_status_image ('module_warning.png', modules_get_last_value($module_id), false); break; case AGENT_MODULE_STATUS_UNKNOWN: - ui_print_status_image ('module_unknown.png', modules_get_last_value($module_id), false, array('width' => '20px', 'height' => '20px')); + ui_print_status_image ('module_unknown.png', modules_get_last_value($module_id), false); break; case AGENT_MODULE_STATUS_NORMAL_ALERT: case AGENT_MODULE_STATUS_WARNING_ALERT: case AGENT_MODULE_STATUS_CRITICAL_ALERT: - ui_print_status_image ('module_alertsfired.png', modules_get_last_value($module_id), false, array('width' => '20px', 'height' => '20px')); + ui_print_status_image ('module_alertsfired.png', modules_get_last_value($module_id), false); break; case 4: - ui_print_status_image ('module_no_data.png', modules_get_last_value($module_id), false, array('width' => '20px', 'height' => '20px')); + ui_print_status_image ('module_no_data.png', modules_get_last_value($module_id), false); break; } echo ''; @@ -478,10 +558,9 @@ function mainAgentsModules() { echo ""; } } - echo ""; } - + echo "
" . $filter_groups_label . "
"; echo "
"; @@ -493,7 +572,7 @@ function mainAgentsModules() { echo "
" . __("Yellow cell when the module has a warning status") . ""; echo "
" . __("Green cell when the module has a normal status") . ""; echo "
" . __("Grey cell when the module has an unknown status") . ""; - echo "
" . __("Cell turns grey when the module is in 'not initialize' status") . ""; + echo "
" . __("Cell turns blue when the module is in 'not initialize' status") . ""; echo ""; echo "
"; @@ -538,9 +617,63 @@ function mainAgentsModules() { extensions_add_operation_menu_option(__("Agents/Modules view"), 'estado', 'agents_modules/icon_menu.png', "v1r1","view"); extensions_add_main_function('mainAgentsModules'); +$ignored_params['refresh']=''; + ?> \ No newline at end of file diff --git a/pandora_console/extensions/db_status.php b/pandora_console/extensions/db_status.php index ca69e0282b..e5e1d84331 100755 --- a/pandora_console/extensions/db_status.php +++ b/pandora_console/extensions/db_status.php @@ -127,7 +127,7 @@ function extension_db_status_execute_checks($db_user, $db_password, $db_host, $d ui_print_error_message( __('Unsuccessful installed tables into the testing DB')); } - else { + else {/* if (enterprise_installed()) { $install_tables_enterprise = extension_db_status_execute_sql_file( @@ -139,7 +139,7 @@ function extension_db_status_execute_checks($db_user, $db_password, $db_host, $d __('Unsuccessful installed enterprise tables into the testing DB')); } } - + */ extension_db_check_tables_differences( $connection_test, $connection_system, @@ -159,6 +159,7 @@ function extension_db_check_tables_differences($connection_test, global $config; + // --------- Check the tables -------------------------------------- mysql_select_db($db_name_test, $connection_test); $result = mysql_query("SHOW TABLES", $connection_test); @@ -170,9 +171,8 @@ function extension_db_check_tables_differences($connection_test, //~ $tables_test = array_merge($tables_test, //~ extension_db_status_extension_tables()); - - mysql_select_db($db_name_system, $connection_system); - $result = mysql_query("SHOW TABLES", $connection_system); + mysql_select_db($db_name_system, $connection_test); + $result = mysql_query("SHOW TABLES", $connection_test); $tables_system = array(); while ($row = mysql_fetch_array ($result)) { $tables_system[] = $row[0]; @@ -227,8 +227,8 @@ function extension_db_check_tables_differences($connection_test, - mysql_select_db($db_name_system, $connection_system); - $result = mysql_query("EXPLAIN " . $table, $connection_system); + mysql_select_db($db_name_system, $connection_test); + $result = mysql_query("EXPLAIN " . $table, $connection_test); $fields_system = array(); if (!empty($result)) { while ($row = mysql_fetch_array ($result)) { diff --git a/pandora_console/extensions/disabled/ssh_gateway.php b/pandora_console/extensions/disabled/ssh_gateway.php deleted file mode 100644 index 9ddcf50f53..0000000000 --- a/pandora_console/extensions/disabled/ssh_gateway.php +++ /dev/null @@ -1,98 +0,0 @@ -"; - - $id_agente = get_parameter ("id_agente"); - - $ip = db_get_sql ("SELECT direccion FROM tagente WHERE id_agente = $id_agente"); - - if ($HOST == "") - $HOST = $ip; - - if (($HOST == "") OR ($USER == "")) { - if ($COMMIT == 1) { - ui_print_error_message(__("You need to specify a user and a host address")); - } - - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo "
".__("Host address").""; - //echo "
".__("User")."" . ui_print_help_tip(__('For security reasons the following characters are not allowed: %s', '< > | ` $ ; &'), true); - echo "   "; - echo "
".__("Port (use 0 for default)").""; - echo ""; - echo __("Connect mode").""; - - - echo "
"; - } - - else { - if ($MODE == "telnet") { - if ($PORT == 0) - $PORT = 23; - } - else { - if ($PORT == 0) - $PORT = 22; - } - - if ($MODE == "ssh") - echo ""; - } -} -?> diff --git a/pandora_console/extensions/disabled/vnc_view.php b/pandora_console/extensions/disabled/vnc_view.php deleted file mode 100644 index 16bb353688..0000000000 --- a/pandora_console/extensions/disabled/vnc_view.php +++ /dev/null @@ -1,44 +0,0 @@ -"; - echo ""; - echo ""; - echo "
"; - echo __("VNC Display (:0 by default)") . " "; - echo ""; - echo ""; - echo ""; - echo "
"; - $port = 5800 + $display; - echo ""; -} - -$id_agente = get_parameter ("id_agente"); - -// This extension is usefull only if the agent has associated IP -$address = agents_get_address($id_agente); - -if (!empty($address) || empty($id_agente)) { - extensions_add_opemode_tab_agent('vnc_view', __('VNC view'), 'images/vnc.png', 'vnc_view', "v1r1", 'AW'); -} -?> diff --git a/pandora_console/extensions/insert_data.php b/pandora_console/extensions/insert_data.php index 33659b0c71..3e52a9138c 100644 --- a/pandora_console/extensions/insert_data.php +++ b/pandora_console/extensions/insert_data.php @@ -38,7 +38,7 @@ function createXMLData($agent, $agentModule, $time, $data) { io_safe_output($agent['os_version']), $agent['intervalo'], io_safe_output($agent['agent_version']), $time, io_safe_output($agent['nombre']), - io_safe_output($agent['alias']), $agent['timezone_offset'], + $agent['timezone_offset'], io_safe_output($agentModule['nombre']), io_safe_output($agentModule['descripcion']), modules_get_type_name($agentModule['id_tipo_modulo']), $data); diff --git a/pandora_console/extensions/pandora_logs.php b/pandora_console/extensions/pandora_logs.php index f129f7b45d..f20bcab720 100644 --- a/pandora_console/extensions/pandora_logs.php +++ b/pandora_console/extensions/pandora_logs.php @@ -39,10 +39,9 @@ function view_logfile ($file_name) { echo "

$file_name (" . __("File is too large than PHP memory allocated in the system.") . ")

"; echo "

" . __("The preview file is imposible.") . "

"; } - else if ($file_size > 512000) { - $data = file_get_contents ($file_name, false, NULL, $file_size - 512000); - echo "

$file_name (".__("File is too large (> 500KB)").")

"; - + else if ($file_size > ($config['max_log_size'] * 1000)) { + $data = file_get_contents ($file_name, false, NULL, $file_size - ($config['max_log_size'] * 1000)); + echo "

$file_name (".format_numeric(filesize ($file_name)/1024)." KB)

"; echo ""; +echo ""; +$container = folder_get_folders(); +$tree = folder_get_folders_tree_recursive($container); +$containers_tree = folder_flatten_tree_folders($tree,0); +$containers_tree = folder_get_select($containers_tree); + +unset($containers_tree[$id_container]); + +echo ""; +echo "".__("Parent container").""; +if($id_container === '1'){ + echo "" . html_print_select ($containers_tree, "id_parent", $id_parent, + '', __('none'), 0, true,'',false,'w130',true,'width: 195px',''); +} else { + echo "" . html_print_select ($containers_tree, "id_parent", $id_parent, + '', __('none'), 0, true,'',false,'w130','','width: 195px',''); +} + + +echo ""; + + +echo ""; + +if ($edit_container) { + if($id_container !== '1'){ + echo "
"; + } +} +else { + echo "
"; +} + +echo ""; + +echo "
"; +echo "
"; +echo "
"; + +if($edit_container){ + $period = SECONDS_15DAYS; + $periods = array (); + $periods[-1] = __('custom'); + $periods[SECONDS_1HOUR] = __('1 hour'); + $periods[SECONDS_2HOUR] = sprintf(__('%s hours'), '2 '); + $periods[SECONDS_6HOURS] = sprintf(__('%s hours'), '6 '); + $periods[SECONDS_12HOURS] = sprintf(__('%s hours'), '12 '); + $periods[SECONDS_1DAY] = __('1 day'); + $periods[SECONDS_2DAY] = sprintf(__('%s days'), '2 '); + $periods[SECONDS_5DAY] = sprintf(__('%s days'), '5 '); + $periods[SECONDS_1WEEK] = __('1 week'); + $periods[SECONDS_15DAYS] = __('15 days'); + $periods[SECONDS_1MONTH] = __('1 month'); + + $single_table = ""; + $single_table .= ""; + $single_table .= ""; + $single_table .= ""; + $single_table .= ""; + + $single_table .= ""; + $single_table .= ""; + $single_table .= ""; + $single_table .= ""; + + $single_table .= ""; + $single_table .= ""; + $single_table .= ""; + $single_table .= ""; + + $single_table .= ""; + $single_table .= ""; + $single_table .= ""; + $single_table .= ""; + $single_table .= ""; + $single_table .= ""; + $single_table .= ""; + $single_table .= ""; + $single_table .= "
"; + $single_table .= __('Time lapse'); + $single_table .= ui_print_help_tip(__('This is the interval or period of time with which the graph data will be obtained. For example, a week means data from a week ago from now. '),true); + $single_table .= ""; + $single_table .= html_print_extended_select_for_time('period_single', $period, + '', '', '0', 10, true,false,true,'',false,$periods); + $single_table .= "
"; + $single_table .= __('Agent'); + $single_table .= ""; + $params = array(); + + $params['show_helptip'] = false; + $params['input_name'] = 'agent'; + $params['value'] = ''; + $params['return'] = true; + + $params['javascript_is_function_select'] = true; + $params['selectbox_id'] = 'id_agent_module'; + $params['add_none_module'] = true; + $params['use_hidden_input_idagent'] = true; + $params['hidden_input_idagent_id'] = 'hidden-id_agent'; + + + $single_table .= ui_print_agent_autocomplete_input($params); + $single_table .= "
"; + $single_table .= __('Module'); + $single_table .= ""; + if ($idAgent) { + $single_table .= html_print_select_from_sql($sql_modules, 'id_agent_module', $idAgentModule, '', '', '0',true); + } else { + $single_table .= ""; + } + $single_table .= "
"; + $single_table .= __('Only average'); + $single_table .= ""; + $single_table .= html_print_checkbox('only_avg', 1, true,true); + $single_table .= "
"; + $single_table .= ""; + $single_table .= ""; + $single_table .= "
"; + + echo ""; + echo ""; + echo ""; + echo ""; + echo "
"; + echo ui_toggle($single_table,'Simple module graph', '', true, true); + echo "
"; + + $table = new stdClass(); + $table->id = 'custom_graph_table'; + $table->width = '100%'; + $table->cellspacing = 4; + $table->cellpadding = 4; + $table->class = 'dat'; + + $table->styleTable = 'font-weight: bold;'; + $table->style[0] = 'width: 12%'; + $table->data = array(); + + $data = array(); + $data[0] = __('Time lapse'); + $data[0] .= ui_print_help_tip(__('This is the interval or period of time with which the graph data will be obtained. For example, a week means data from a week ago from now. '),true); + $data[1] = html_print_extended_select_for_time('period_custom', $period,'', '', '0', 10, true,false,true,'',false,$periods); + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = array(); + $data[0] = __('Custom graph'); + + $list_custom_graphs = custom_graphs_get_user ($config['id_user'], false, true, "RR"); + + $graphs = array(); + foreach ($list_custom_graphs as $custom_graph) { + $graphs[$custom_graph['id_graph']] = $custom_graph['name']; + } + + $data[1] = html_print_select($graphs, 'id_custom_graph',$idCustomGraph, '', __('None'), 0,true); + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = array(); + $data[0] = ""; + $data[1] = ""; + $table->data[] = $data; + $table->rowclass[] = ''; + + echo ""; + echo ""; + echo ""; + echo ""; + echo "
"; + echo ui_toggle(html_print_table($table, true),'Custom graph', '', true, true); + echo "
"; + + unset($table); + + $table = new stdClass(); + $table->id = 'dynamic_rules_table'; + $table->width = '100%'; + $table->cellspacing = 4; + $table->cellpadding = 4; + $table->class = 'dat'; + + $table->styleTable = 'font-weight: bold;'; + $table->style[0] = 'width: 12%'; + $table->data = array(); + + $data = array(); + $data[0] = __('Time lapse'); + $data[0] .= ui_print_help_tip(__('This is the interval or period of time with which the graph data will be obtained. For example, a week means data from a week ago from now. '),true); + $data[1] = html_print_extended_select_for_time('period_dynamic', $period,'', '', '0', 10, true,false,true,'',false,$periods); + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = array(); + $data[0] = __('Group'); + $data[1] = html_print_select_groups($config['id_user'], 'RW', $return_all_groups, 'container_id_group', $id_group, '', '', '', true); + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = array(); + $data[0] = __('Module group'); + $data[1] = html_print_select_from_sql( + "SELECT * FROM tmodule_group ORDER BY name", + 'combo_modulegroup', $modulegroup, '',__('All'),false,true); + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = array(); + $data[0] = __('Agent'); + $data[1] = html_print_input_text ('text_agent', $textAgent, '', 30, 100, true); + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = array(); + $data[0] = __('Module'); + $data[1] = html_print_input_text ('text_agent_module', $textModule, '', 30, 100, true); + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = array(); + $data[0] = __('Tag'); + $select_tags = tags_search_tag (false, false, true); + $data[1] = html_print_select ($select_tags, 'tag', + $tag, '', __('Any'), 0, true, false, false); + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = array(); + $data[0] = __('Only average'); + $data[1] = html_print_checkbox('only_avg_2', 1, false,true); + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = array(); + $data[0] = ""; + $data[1] = ""; + $table->data[] = $data; + $table->rowclass[] = ''; + + echo ""; + echo ""; + echo ""; + echo ""; + echo "
"; + echo ui_toggle(html_print_table($table, true),'Dynamic rules for simple module graph', '', true, true); + echo "
"; + + $total_item = db_get_all_rows_sql("SELECT count(*) FROM tcontainer_item WHERE id_container = " . $id_container); + $result_item = db_get_all_rows_sql("SELECT * FROM tcontainer_item WHERE id_container = " . $id_container . " LIMIT 10 OFFSET ". $offset); + + if(!$result_item){ + echo "
".__('There are no defined item container')."
"; + } else { + ui_pagination ($total_item[0]['count(*)'],false,$offset,10); + $table = new stdClass(); + $table->width = '100%'; + $table->class = 'databox data'; + $table->id = 'item_table'; + $table->align = array (); + $table->head = array (); + $table->head[0] = __('Agent/Module'); + $table->head[1] = __('Custom graph'); + $table->head[2] = __('Group'); + $table->head[3] = __('M.Group'); + $table->head[4] = __('Agent'); + $table->head[5] = __('Module'); + $table->head[6] = __('Tag'); + $table->head[7] = __('Delete'); + + $table->data = array (); + + + foreach ($result_item as $item) { + $data = array (); + switch ($item['type']) { + case 'simple_graph': + $agent_alias = ui_print_truncate_text(agents_get_alias($item['id_agent'],20,false)); + $module_name = ui_print_truncate_text(modules_get_agentmodule_name($item['id_agent_module']),20,false); + $module_name = + $data[0] = $agent_alias . " / " .$module_name; + $data[1] = ''; + $data[2] = ''; + $data[3] = ''; + $data[4] = ''; + $data[5] = ''; + $data[6] = ''; + break; + + case 'custom_graph': + $data[0] = ''; + $name = db_get_value_filter('name','tgraph',array('id_graph' => $item['id_graph'])); + $data[1] = ui_print_truncate_text(io_safe_output($name),35,false); + $data[2] = ''; + $data[3] = ''; + $data[4] = ''; + $data[5] = ''; + $data[6] = ''; + break; + + case 'dynamic_graph': + $data[0] = ''; + $data[1] = ''; + + $data[2] = ui_print_group_icon($item['id_group'],true); + if ($item['id_module_group'] === '0') { + $data[3] = 'All'; + } else { + $data[3] = io_safe_output(db_get_value_filter('name','tmodule_group',array('id_mg' => $item['id_module_group']))); + + } + $data[4] = io_safe_output($item['agent']); + $data[5] = io_safe_output($item['module']); + if ($item['id_tag'] === '0') { + $data[6] = 'Any'; + } else { + $data[6] = io_safe_output(db_get_value_filter('name','ttag',array('id_tag' => $item['id_tag']))); + } + break; + + } + $data[7] = '' . html_print_image("images/cross.png", true, array('alt' => __('Delete'), 'title' => __('Delete'))) . ''; + + array_push ($table->data, $data); + } + html_print_table ($table); + } + + +} + +echo html_print_input_hidden('id_agent', 0); +?> + + \ No newline at end of file diff --git a/pandora_console/godmode/reporting/graph_builder.php b/pandora_console/godmode/reporting/graph_builder.php index ac342f3a13..317f562e6f 100644 --- a/pandora_console/godmode/reporting/graph_builder.php +++ b/pandora_console/godmode/reporting/graph_builder.php @@ -65,6 +65,17 @@ $change_weight = (bool) get_parameter('change_weight', false); $change_label = (bool) get_parameter('change_label', false); $id_graph = (int) get_parameter('id', 0); +if($id_graph !== 0){ + $sql = "SELECT * FROM tgraph + WHERE (private = 0 OR (private = 1 AND id_user = '".$config["id_user"]."')) + AND id_graph = ".$id_graph; + $control = db_process_sql($sql); + if(!$control){ + header('Location: index.php?sec=reporting&sec2=godmode/reporting/graphs'); + } +} + + if ($add_graph) { $name = get_parameter_post ("name"); $description = get_parameter_post ("description"); diff --git a/pandora_console/godmode/reporting/graph_container.php b/pandora_console/godmode/reporting/graph_container.php new file mode 100644 index 0000000000..6c4903fbb8 --- /dev/null +++ b/pandora_console/godmode/reporting/graph_container.php @@ -0,0 +1,140 @@ + $value) { + $parent = array( + 'parent' => 1); + db_process_sql_update('tcontainer', $parent, array('id_container' => $value['id_container'])); + } + } + db_process_sql_delete('tcontainer', array('id_container' => $id_container)); + +} + +$max_graph = $config['max_graph_container']; + +$buttons['graph_list'] = array('active' => false, + 'text' => '' . + html_print_image("images/list.png", true, array ("title" => __('Graph list'))) .''); + +$enterpriseEnable = false; +if (enterprise_include_once('include/functions_reporting.php') !== ENTERPRISE_NOT_HOOK) { + $enterpriseEnable = true; +} + +if ($enterpriseEnable) { + $buttons = reporting_enterprise_add_template_graph_tabs($buttons); +} + +$subsection = reporting_enterprise_add_graph_template_subsection('', $buttons); +reporting_enterprise_select_graph_template_tab(); + +$buttons['graph_container'] = array('active' => true, + 'text' => '' . + html_print_image("images/graph-container.png", true, array ("title" => __('Graph container'))) . ''); +// Header +ui_print_page_header (__('Graph container'), "", false, "",false,$buttons); + +$container = folder_get_folders(); + +$tree = folder_get_folders_tree_recursive($container); +echo folder_togge_tree_folders($tree); + +echo "
"; + echo '
'; + html_print_submit_button (__('Create container'), 'create', false, 'class="sub next" style="margin-right:5px;margin-top: 15px;"'); + echo "
"; +echo "
"; + +?> + + \ No newline at end of file diff --git a/pandora_console/godmode/reporting/graphs.php b/pandora_console/godmode/reporting/graphs.php index f37b7e0c2f..f235037070 100644 --- a/pandora_console/godmode/reporting/graphs.php +++ b/pandora_console/godmode/reporting/graphs.php @@ -65,7 +65,10 @@ switch ($activeTab) { reporting_enterprise_select_graph_template_tab($activeTab); break; } - +$buttons['graph_container'] = array('active' => false, + 'text' => '' . + html_print_image("images/graph-container.png", true, array ("title" => __('Graphs containers'))) .''); + $delete_graph = (bool) get_parameter ('delete_graph'); $view_graph = (bool) get_parameter ('view_graph'); $id = (int) get_parameter ('id'); diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 2e974b85fe..00df36a2c7 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -69,6 +69,8 @@ $exception_condition = REPORT_EXCEPTION_CONDITION_EVERYTHING; $exception_condition_value = 10; $modulegroup = 0; $period = SECONDS_1DAY; +$search = ""; +$log_number = 1000; // Added support for projection graphs $period_pg = SECONDS_5DAY; $projection_period = SECONDS_5DAY; @@ -120,6 +122,7 @@ switch ($action) { $description = null; $sql = null; $show_in_two_columns = 0; + $show_in_same_row = 0; $show_in_landscape = 0; $hide_notinit_agents = 0; $server_name = ''; @@ -158,6 +161,7 @@ switch ($action) { $description = null; $sql = null; $show_in_two_columns = 0; + $show_in_same_row = 0; $show_in_landscape = 0; $hide_notinit_agents = 0; $server_name = ''; @@ -182,6 +186,7 @@ switch ($action) { $style = json_decode(io_safe_output($item['style']), true); + $show_in_same_row = $style['show_in_same_row']; $show_in_two_columns = $style['show_in_two_columns']; $show_in_landscape = $style['show_in_landscape']; $hide_notinit_agents = $style['hide_notinit_agents']; @@ -198,9 +203,12 @@ switch ($action) { case 'event_report_log': $period = $item['period']; $description = $item['description']; + $es = json_decode($item['external_source'], true); $id_agents = $es['id_agents']; $source = $es['source']; + $search = $es['search']; + $log_number = empty($es['log_number']) ? $log_number : $es['log_number']; break; case 'simple_graph': $only_avg = isset($style['only_avg']) ? (bool) $style['only_avg'] : true; @@ -340,24 +348,28 @@ switch ($action) { $sql = $item['external_source']; $idCustom = $item['treport_custom_sql_id']; $header = $item['header_definition']; + $historical_db = $item['historical_db']; $period = 0; break; case 'sql_graph_pie': $description = $item['description']; $sql = $item['external_source']; $idCustom = $item['treport_custom_sql_id']; + $historical_db = $item['historical_db']; $period = 0; break; case 'sql_graph_vbar': $description = $item['description']; $sql = $item['external_source']; $idCustom = $item['treport_custom_sql_id']; + $historical_db = $item['historical_db']; $period = 0; break; case 'sql_graph_hbar': $description = $item['description']; $sql = $item['external_source']; $idCustom = $item['treport_custom_sql_id']; + $historical_db = $item['historical_db']; $period = 0; break; case 'url': @@ -658,7 +670,6 @@ You can of course remove the warnings, that's why we include the source and do n ?> - @@ -699,6 +710,29 @@ You can of course remove the warnings, that's why we include the source and do n + + + + + + + + + + + + + + + "; + ?> + + + $value) { + $agents2[$value['id_agente']] = $value['alias']; + } + + // $agents = agents_get_group_agents($group); + if ((empty($agents2)) || $agents2 == -1) $agents = array(); $agents_select = array(); if (is_array($id_agents) || is_object($id_agents)){ foreach ($id_agents as $id) { - foreach ($agents as $key => $a) { + foreach ($agents2 as $key => $a) { if ($key == (int)$id) { $agents_select[$key] = $key; } } } } - html_print_select($agents, 'id_agents2[]', $agents_select, $script = '', "", 0, false, true, true, '', false, "min-width: 180px"); + // html_debug($agents); + html_print_select($agents2, 'id_agents2[]', $agents_select, $script = '', "", 0, false, true, true, '', false, "min-width: 180px"); ?> @@ -1463,10 +1507,33 @@ You can of course remove the warnings, that's why we include the source and do n + + + + + + + + + - + + + + + + + + + + @@ -2549,6 +2616,8 @@ function chooseType() { $("#row_agent").hide(); $("#row_module").hide(); $("#row_period").hide(); + $("#row_search").hide(); + $("#row_log_number").hide(); $("#row_period1").hide(); $("#row_estimate").hide(); $("#row_interval").hide(); @@ -2579,6 +2648,8 @@ function chooseType() { $("#row_exception_condition_value").hide(); $("#row_exception_condition").hide(); $("#row_show_in_two_columns").hide(); + $("#row_show_in_same_row").hide(); + $("#row_historical_db_check").hide(); $("#row_show_in_landscape").hide(); $('#row_hide_notinit_agents').hide(); $("#row_module_group").hide(); @@ -2637,14 +2708,18 @@ function chooseType() { $("#row_event_graph_by_validated").show(); $("#row_filter_search").show(); + $("#row_historical_db_check").hide(); break; case 'event_report_log': $("#log_help_tip").css("visibility", "visible"); $("#row_description").show(); $("#row_period").show(); + $("#row_search").show(); + $("#row_log_number").show(); $("#agents_row").show(); $("#row_source").show(); + $("#row_historical_db_check").hide(); break; case 'simple_graph': @@ -2662,6 +2737,7 @@ function chooseType() { $("#row_show_in_two_columns").show(); $("#row_show_in_landscape").show(); $("#row_time_compare_overlapped").show(); + $("#row_historical_db_check").hide(); break; case 'projection_graph': @@ -2672,6 +2748,7 @@ function chooseType() { $("#row_estimate").show(); $("#row_show_in_two_columns").show(); $("#row_show_in_landscape").show(); + $("#row_historical_db_check").hide(); break; case 'prediction_date': @@ -2681,6 +2758,7 @@ function chooseType() { $("#row_module").show(); $("#row_interval").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'custom_graph': @@ -2690,6 +2768,7 @@ function chooseType() { $("#row_custom_graph").show(); $("#row_show_in_two_columns").show(); $("#row_show_in_landscape").show(); + $("#row_historical_db_check").hide(); break; case 'SLA': @@ -2701,6 +2780,7 @@ function chooseType() { $("#row_show_graph").show(); $("#row_sort").show(); $('#row_hide_notinit_agents').show(); + $("#row_historical_db_check").hide(); break; case 'availability_graph': @@ -2708,6 +2788,7 @@ function chooseType() { $("#row_period").show(); $("#sla_list").show(); $("#row_working_time").show(); + $("#row_historical_db_check").hide(); break; case 'module_histogram_graph': @@ -2715,6 +2796,7 @@ function chooseType() { $("#row_period").show(); $("#row_agent").show(); $("#row_module").show(); + $("#row_historical_db_check").hide(); break; case 'SLA_monthly': @@ -2724,6 +2806,7 @@ function chooseType() { $("#sla_list").show(); $("#row_working_time").show(); $("#row_sort").show(); + $("#row_historical_db_check").hide(); break; case 'SLA_services': @@ -2740,6 +2823,7 @@ function chooseType() { $(".sla_list_sla_max_col").hide(); $(".sla_list_sla_limit_col").hide(); $("#sla_list").show(); + $("#row_historical_db_check").hide(); break; case 'monitor_report': @@ -2748,6 +2832,7 @@ function chooseType() { $("#row_module").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'avg_value': @@ -2756,6 +2841,7 @@ function chooseType() { $("#row_module").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'max_value': @@ -2764,6 +2850,7 @@ function chooseType() { $("#row_module").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'min_value': @@ -2772,6 +2859,7 @@ function chooseType() { $("#row_module").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'sumatory': @@ -2780,6 +2868,7 @@ function chooseType() { $("#row_module").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'historical_data': @@ -2788,6 +2877,7 @@ function chooseType() { $("#row_module").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'agent_detailed': @@ -2795,12 +2885,14 @@ function chooseType() { $("#row_agent").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'text': $("#row_description").show(); $("#row_text").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'sql': @@ -2811,6 +2903,7 @@ function chooseType() { $("#row_custom_example").show(); $("#row_show_in_two_columns").show(); $("#row_servers").show(); + $("#row_historical_db_check").show(); break; case 'sql_graph_pie': @@ -2819,6 +2912,8 @@ function chooseType() { $("#row_show_in_two_columns").show(); $("#row_show_in_landscape").show(); $("#row_servers").show(); + $("#row_historical_db_check").show(); + break; case 'sql_graph_hbar': @@ -2827,6 +2922,7 @@ function chooseType() { $("#row_show_in_two_columns").show(); $("#row_show_in_landscape").show(); $("#row_servers").show(); + $("#row_historical_db_check").show(); break; case 'sql_graph_vbar': @@ -2835,11 +2931,13 @@ function chooseType() { $("#row_show_in_two_columns").show(); $("#row_show_in_landscape").show(); $("#row_servers").show(); + $("#row_historical_db_check").show(); break; case 'url': $("#row_description").show(); $("#row_url").show(); + $("#row_historical_db_check").hide(); break; case 'database_serialized': @@ -2851,6 +2949,7 @@ function chooseType() { $("#row_line_separator").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'TTRT': @@ -2859,6 +2958,7 @@ function chooseType() { $("#row_module").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'TTO': @@ -2867,6 +2967,7 @@ function chooseType() { $("#row_module").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'MTBF': @@ -2875,6 +2976,7 @@ function chooseType() { $("#row_module").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'MTTR': @@ -2883,6 +2985,7 @@ function chooseType() { $("#row_module").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'alert_report_module': @@ -2891,6 +2994,7 @@ function chooseType() { $("#row_module").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'alert_report_group': @@ -2899,6 +3003,7 @@ function chooseType() { $("#row_show_in_two_columns").show(); $("#row_group").show(); $("#row_servers").show(); + $("#row_historical_db_check").hide(); break; case 'alert_report_agent': @@ -2906,6 +3011,7 @@ function chooseType() { $("#row_agent").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'event_report_group': @@ -2924,6 +3030,7 @@ function chooseType() { $("#row_event_type").show(); $("#row_filter_search").show(); + $("#row_historical_db_check").hide(); break; @@ -2946,6 +3053,7 @@ function chooseType() { $('#agent_autocomplete').hide(); $('#agent_autocomplete_events').show(); $("#row_filter_search").show(); + $("#row_historical_db_check").hide(); break; case 'event_report_module': @@ -2966,6 +3074,7 @@ function chooseType() { $('#agent_autocomplete').hide(); $('#agent_autocomplete_events').show(); $("#row_filter_search").show(); + $("#row_historical_db_check").hide(); break; case 'general': @@ -2976,6 +3085,7 @@ function chooseType() { $("#row_order_uptodown").show(); $("#row_show_resume").show(); $("#row_show_in_two_columns").show(); + $("#row_show_in_same_row").show(); var checked = $("input[name='last_value']").prop("checked"); @@ -2984,6 +3094,7 @@ function chooseType() { $("#row_period").hide(); $("input[name='last_value']").prop("checked", true); } + $("#row_historical_db_check").hide(); break; case 'availability': @@ -2996,18 +3107,21 @@ function chooseType() { $("#row_show_resume").show(); $("#row_working_time").show(); $('#row_hide_notinit_agents').show(); + $("#row_historical_db_check").hide(); break; case 'group_report': $("#row_group").show(); $("#row_servers").show(); $("#row_description").show(); + $("#row_historical_db_check").hide(); break; case 'network_interfaces_report': $("#row_group").show(); $("#row_description").show(); $("#row_period").show(); + $("#row_historical_db_check").hide(); break; case 'top_n': @@ -3020,6 +3134,7 @@ function chooseType() { $("#row_show_resume").show(); $("#row_show_graph").show(); $("#row_show_in_two_columns").show(); + $("#row_historical_db_check").hide(); break; case 'exception': @@ -3040,6 +3155,7 @@ function chooseType() { $("#row_period").hide(); $("input[name='last_value']").prop("checked", true); } + $("#row_historical_db_check").hide(); break; case 'agent_module': @@ -3049,6 +3165,7 @@ function chooseType() { $("#select_agent_modules").show(); $("#agents_row").show(); $("#modules_row").show(); + $("#row_historical_db_check").hide(); break; case 'inventory_changes': @@ -3065,6 +3182,7 @@ function chooseType() { $("#combo_group").change(function() { updateAgents($(this).val(), ); }); + $("#row_historical_db_check").hide(); break; @@ -3099,18 +3217,22 @@ function chooseType() { if (!$("#hidden-date_selected").val()) updateInventoryDates(); + $("#row_historical_db_check").hide(); break; case 'inventory_changes': + $("#row_historical_db_check").hide(); break; case 'agent_configuration': $("#row_agent").show(); + $("#row_historical_db_check").hide(); break; case 'group_configuration': $("#row_group").show(); $("#row_servers").show(); + $("#row_historical_db_check").hide(); break; case 'netflow_area': @@ -3120,6 +3242,7 @@ function chooseType() { $("#row_max_values").show(); $("#row_resolution").show(); $("#row_servers").show(); + $("#row_historical_db_check").hide(); break; case 'netflow_pie': @@ -3129,6 +3252,7 @@ function chooseType() { $("#row_max_values").show(); $("#row_resolution").show(); $("#row_servers").show(); + $("#row_historical_db_check").hide(); break; case 'netflow_data': @@ -3138,6 +3262,7 @@ function chooseType() { $("#row_max_values").show(); $("#row_resolution").show(); $("#row_servers").show(); + $("#row_historical_db_check").hide(); break; case 'netflow_summary': @@ -3146,6 +3271,7 @@ function chooseType() { $("#row_period").show(); $("#row_resolution").show(); $("#row_servers").show(); + $("#row_historical_db_check").hide(); break; case 'netflow_statistics': @@ -3155,6 +3281,7 @@ function chooseType() { $("#row_max_values").show(); $("#row_resolution").show(); $("#row_servers").show(); + $("#row_historical_db_check").hide(); break; } switch (type) { diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index 7419f27c03..b4091b0e7e 100755 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -38,6 +38,9 @@ switch ($config['dbtype']) { break; } +$report_w = check_acl ($config['id_user'], 0, "RW"); +$report_m = check_acl ($config['id_user'], 0, "RM"); + if ($config ['metaconsole'] == 1 and defined('METACONSOLE')) { $agents = array(); $agents = metaconsole_get_report_agents($idReport); @@ -303,10 +306,14 @@ if ($items) { $table->head[5] = __('Name') . " / " . __('Description'); if (check_acl ($config['id_user'], 0, "RM")) { $table->head[6] = '' . __('Op.') . ''; + if ($report_w || $report_m) { + $table->head[6] .= html_print_checkbox('all_delete', 0, false, true, false, + 'check_all_checkboxes();'); + } } $table->head[7] = __('Sort'); - $table->align[6] = 'center'; + $table->align[6] = 'left'; $table->align[7] = 'center'; } else { @@ -544,6 +551,16 @@ echo ""; ?> - diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php index 5f03a29c64..04481885a2 100644 --- a/pandora_console/godmode/servers/servers.build_table.php +++ b/pandora_console/godmode/servers/servers.build_table.php @@ -83,7 +83,7 @@ foreach ($servers as $server) { $data = array (); $table->cellclass[][3] = "progress_bar"; $data[0] = '' . - $server['name'] . ''; + strip_tags($server['name']) . ''; //Status $data[1] = ui_print_status_image (STATUS_SERVER_OK, '', true); @@ -124,9 +124,14 @@ foreach ($servers as $server) { } $data[7] = ui_print_timestamp ($server['keepalive'], true); + + $ext = '_server'; + if ($server['type'] != 'data') + $ext = ''; + $safe_server_name = servers_get_name($server["id_server"]); - if (!isset($names_servers[$safe_server_name])){ - if (servers_check_remote_config ($safe_server_name) && enterprise_installed()) { + if (($server['type'] == 'data' || $server['type'] == 'enterprise satellite')) { + if (servers_check_remote_config ($safe_server_name . $ext) && enterprise_installed()) { $names_servers[$safe_server_name] = true; } else { $names_servers[$safe_server_name] = false; @@ -136,6 +141,14 @@ foreach ($servers as $server) { //Only Pandora Administrator can delete servers if (check_acl ($config["id_user"], 0, "PM")) { $data[8] = ''; + + if ($server['type'] == 'recon') { + $data[8] .= ''; + $data[8] .= html_print_image ('images/firts_task/icono_grande_reconserver.png', true, + array('title' => __('Manage recon tasks'),'style' => 'width:21px;height:21px;')); + $data[8] .= '  '; + } + if ($server['type'] == 'data') { $data[8] .= ''; $data[8] .= html_print_image ('images/target.png', true, @@ -154,8 +167,8 @@ foreach ($servers as $server) { array('title' => __('Edit'))); $data[8] .= ''; - if ($names_servers[$safe_server_name] === true) { - $data[8] .= ''; + if (($names_servers[$safe_server_name] === true) && ($server['type'] == 'data' || $server['type'] == 'enterprise satellite')) { + $data[8] .= ''; $data[8] .= html_print_image ('images/remote_configuration.png', true, array('title' => __('Remote configuration'))); $data[8] .= ''; diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index 89c9fa9d8d..ceeae084c8 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -138,6 +138,9 @@ $table_other->data[10][1] = html_print_input_text ('big_operation_step_datos_pur $table_other->data[11][0] = __('Small Operation Step to purge old data') . ui_print_help_tip(__('The number of rows that are processed in a single query in deletion. Default is 1000. Increase to 3000-5000 in fast systems. Decrease to 500 or 250 on systems with locks.'), true); $table_other->data[11][1] = html_print_input_text ('small_operation_step_datos_purge', $config["small_operation_step_datos_purge"], '', 5, 5, true); +$table_other->data[12][0] = __('Graph container - Max. Items') . ui_print_help_tip(__('The number of graphs that are viewed in a container. Default is 10 .Increasing this number could lead to performance problems'), true); +$table_other->data[12][1] = html_print_input_text ('max_graph_container', $config["max_graph_container"], '', 5, 5, true); + echo '
'; echo "
"; echo "" . __('Database maintenance options') . ""; diff --git a/pandora_console/godmode/setup/setup_auth.php b/pandora_console/godmode/setup/setup_auth.php index 0444731007..1b18f0f7ec 100644 --- a/pandora_console/godmode/setup/setup_auth.php +++ b/pandora_console/godmode/setup/setup_auth.php @@ -51,7 +51,8 @@ if (is_ajax ()) { $row['control'] = __('Yes').' '.html_print_radio_button('fallback_local_auth', 1, '', $config['fallback_local_auth'], true).'  '; $row['control'] .= __('No').' '.html_print_radio_button('fallback_local_auth', 0, '', $config['fallback_local_auth'], true); $table->data['fallback_local_auth'] = $row; - + + if (enterprise_installed()) { // Autocreate remote users $row = array(); $row['name'] = __('Autocreate remote users'); @@ -59,8 +60,7 @@ if (is_ajax ()) { $row['control'] .= __('No').' '.html_print_radio_button_extended('autocreate_remote_users', 0, '', $config['autocreate_remote_users'], false, '', '', true); $table->data['autocreate_remote_users'] = $row; - if (enterprise_installed()) { - add_enterprise_auth_autocreate_profiles($table, $type_auth); + add_enterprise_auth_autocreate_profiles($table, $type_auth); } } @@ -109,7 +109,6 @@ if (is_ajax ()) { break; case 'pandora': - case 'babel': case 'ad': case 'saml': case 'integria': diff --git a/pandora_console/godmode/setup/setup_ehorus.php b/pandora_console/godmode/setup/setup_ehorus.php index 82a177a0e9..8590f4ff87 100644 --- a/pandora_console/godmode/setup/setup_ehorus.php +++ b/pandora_console/godmode/setup/setup_ehorus.php @@ -84,7 +84,7 @@ $table_remote->data['ehorus_pass'] = $row; $row = array(); $row['name'] = __('API Hostname'); $row['control'] = html_print_input_text('ehorus_hostname', $config['ehorus_hostname'], '', 30, 100, true); -$row['control'] .= ui_print_help_tip(__('Hostname of the eHorus API') . '. ' . __('Without protocol and port') . '. ' . __('e.g., switch.ehorus.com'), true); +$row['control'] .= ui_print_help_tip(__('Hostname of the eHorus API') . '. ' . __('Without protocol and port') . '. ' . __('e.g., portal.ehorus.com'), true); $table_remote->data['ehorus_hostname'] = $row; // Directory port diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 7a676bb6d3..23a8805570 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -188,6 +188,10 @@ $table->data[32][0] = __('Server logs directory') . ui_print_help_tip (__("Direc $table->data[32][1] = html_print_input_text ('server_log_dir', $config["server_log_dir"], '', 50, 255, true); +$table->data[33][0] = __('Log size limit in system logs viewer extension') . ui_print_help_tip (__("Maximun size to show in system log extension."), true); +$table->data[33][1] = html_print_input_text ('max_log_size', + $config["max_log_size"], '', 10, 255, true) . html_print_label(" x1000", "max_log_size", true); + $modes_tutorial = array( 'full' => __('Full mode'), 'on_demand' => __('On demand'), @@ -200,23 +204,23 @@ $table->data['tutorial_mode'][1] = $config["tutorial_mode"], '', '', 0, true); $config["past_planned_downtimes"] = isset($config["past_planned_downtimes"]) ? $config["past_planned_downtimes"] : 1; -$table->data[33][0] = __('Allow create planned downtimes in the past') . +$table->data[34][0] = __('Allow create planned downtimes in the past') . ui_print_help_tip(__('The planned downtimes created in the past will affect the SLA reports'), true); -$table->data[33][1] = __('Yes').'   '.html_print_radio_button ('past_planned_downtimes', 1, '', $config["past_planned_downtimes"], true).'  '; -$table->data[33][1] .= __('No').'   '.html_print_radio_button ('past_planned_downtimes', 0, '', $config["past_planned_downtimes"], true); +$table->data[34][1] = __('Yes').'   '.html_print_radio_button ('past_planned_downtimes', 1, '', $config["past_planned_downtimes"], true).'  '; +$table->data[34][1] .= __('No').'   '.html_print_radio_button ('past_planned_downtimes', 0, '', $config["past_planned_downtimes"], true); -$table->data[34][0] = __('Limit parameters massive') . +$table->data[35][0] = __('Limit parameters massive') . ui_print_help_tip(__('Your PHP environment is setted with %d max_input_vars. Maybe you must not set this value with upper values.', ini_get("max_input_vars")), true); -$table->data[34][1] = html_print_input_text('limit_parameters_massive', +$table->data[35][1] = html_print_input_text('limit_parameters_massive', $config['limit_parameters_massive'], '', 10, 10, true); -$table->data[35][0] = __('Include agents manually disabled'); -$table->data[35][1] = __('Yes').'   '.html_print_radio_button ('include_agents', 1, '', $config["include_agents"], true).'  '; -$table->data[35][1] .= __('No').'   '.html_print_radio_button ('include_agents', 0, '', $config["include_agents"], true); +$table->data[36][0] = __('Include agents manually disabled'); +$table->data[36][1] = __('Yes').'   '.html_print_radio_button ('include_agents', 1, '', $config["include_agents"], true).'  '; +$table->data[36][1] .= __('No').'   '.html_print_radio_button ('include_agents', 0, '', $config["include_agents"], true); -$table->data[36][0] = __('audit log directory') . +$table->data[37][0] = __('audit log directory') . ui_print_help_tip (__("Directory where audit log is stored."), true); -$table->data[36][1] = html_print_input_text ('auditdir', io_safe_output($config["auditdir"]), '', 30, 100, true); +$table->data[37][1] = html_print_input_text ('auditdir', io_safe_output($config["auditdir"]), '', 30, 100, true); echo ''; diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index cb4958306e..a8ff68d74c 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -118,8 +118,9 @@ if (enterprise_installed()) { $table_behaviour->data[$row][1] = html_print_input_text ('service_label_font_size', $config["service_label_font_size"], '', 5, 5, true); $row++; - $table_behaviour->data[$row][0] = __('Space between items in Service maps'); - $table_behaviour->data[$row][1] = html_print_input_text ('service_item_padding_size', $config["service_item_padding_size"], '', 5, 5, true); + $table_behaviour->data[$row][0] = __('Space between items in Service maps') . + ui_print_help_tip(__('It must be bigger than 80'), true); + $table_behaviour->data[$row][1] = html_print_input_text ('service_item_padding_size', $config["service_item_padding_size"], '', 5, 5, true, false, false, "onChange=\"change_servicetree_nodes_padding()\""); $row++; } @@ -576,7 +577,7 @@ $row++; $dirItems = scandir($config['homedir'] . '/images/custom_logo'); foreach ($dirItems as $entryDir) { - if (strstr($entryDir, '.jpg') !== false) { + if (strstr($entryDir, '.jpg') !== false || strstr($entryDir, '.png') !== false) { $customLogos['images/custom_logo/' . $entryDir] = $entryDir; } } @@ -599,7 +600,7 @@ $table_other->data['custom_report_front-font'][1] = html_print_select ($_fonts, $table_other->data['custom_report_front-logo'][0] = __('Custom report front') . ' - ' . __('Custom logo') . ui_print_help_tip( - __("The dir of custom logos is in your www Pandora Console in \"images/custom_logo\". You can upload more files (ONLY JPEG) in upload tool in console."), true); + __("The dir of custom logos is in your www Pandora Console in \"images/custom_logo\". You can upload more files (ONLY JPEG AND PNG) in upload tool in console."), true); $table_other->data['custom_report_front-logo'][1] = html_print_select( $customLogos, 'custom_report_front_logo', @@ -756,6 +757,26 @@ $table_other->data[$row][1] .= html_print_input_hidden ('interval_to_delete', '' //---------------------------------------------------------------------- $row++; +$common_dividers = array( + ";" => ";", + "," => ",", + "|" => "|"); +$table_other->data[$row][0] = __('CSV divider'); +if ($config['csv_divider'] != ";" && $config['csv_divider'] != "," && $config['csv_divider'] != "|") { + $table_other->data[$row][1] = html_print_input_text ('csv_divider', $config['csv_divider'], "", 20, 255, true); + $table_other->data[$row][1] .= '' . + html_print_image('images/default_list.png', true, array('id' => 'select')) . + ""; +} +else { + $table_other->data[$row][1] = html_print_select ($common_dividers, 'csv_divider', $config['csv_divider'], "", '', '', true, false, false); + $table_other->data[$row][1] .= '' . + html_print_image('images/pencil.png', true, array('id' => 'pencil')) . + ""; +} +$row++; + + echo "
"; echo "" . __('Other configuration') . ""; html_print_table ($table_other); @@ -792,6 +813,27 @@ ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/'); ?> @@ -76,4 +81,4 @@ $baseurl = ui_get_full_url(false, false, false, false); + \ No newline at end of file diff --git a/pandora_console/godmode/update_manager/update_manager.online.php b/pandora_console/godmode/update_manager/update_manager.online.php index 747b6a0ece..117c020515 100644 --- a/pandora_console/godmode/update_manager/update_manager.online.php +++ b/pandora_console/godmode/update_manager/update_manager.online.php @@ -82,7 +82,7 @@ echo ""; echo ""; echo "

"; -echo "
" . __('The last version of package installed is:') . "

"; +echo "
" . __('The latest version of package installed is:') . "

"; echo "
" . $current_package . "
"; echo "'; enterprise_hook('close_meta_frame'); ?> + + diff --git a/pandora_console/images/auto_sla_graph.disabled.png b/pandora_console/images/auto_sla_graph.disabled.png new file mode 100644 index 0000000000..e3f0e4fe86 Binary files /dev/null and b/pandora_console/images/auto_sla_graph.disabled.png differ diff --git a/pandora_console/images/auto_sla_graph.png b/pandora_console/images/auto_sla_graph.png new file mode 100644 index 0000000000..7e76928400 Binary files /dev/null and b/pandora_console/images/auto_sla_graph.png differ diff --git a/pandora_console/images/console/signes/data_image.png b/pandora_console/images/console/signes/data_image.png new file mode 100644 index 0000000000..e3542c1ea3 Binary files /dev/null and b/pandora_console/images/console/signes/data_image.png differ diff --git a/pandora_console/images/console/signes/module-events.png b/pandora_console/images/console/signes/module-events.png new file mode 100644 index 0000000000..1393364a84 Binary files /dev/null and b/pandora_console/images/console/signes/module-events.png differ diff --git a/pandora_console/images/error_1.png b/pandora_console/images/error_1.png new file mode 100644 index 0000000000..8715248d54 Binary files /dev/null and b/pandora_console/images/error_1.png differ diff --git a/pandora_console/images/exito.png b/pandora_console/images/exito.png new file mode 100644 index 0000000000..eb9947e7bd Binary files /dev/null and b/pandora_console/images/exito.png differ diff --git a/pandora_console/images/graph-container.png b/pandora_console/images/graph-container.png new file mode 100644 index 0000000000..0a1b70b721 Binary files /dev/null and b/pandora_console/images/graph-container.png differ diff --git a/pandora_console/images/help/Ux10.JPG b/pandora_console/images/help/Ux10.JPG new file mode 100644 index 0000000000..b601785e70 Binary files /dev/null and b/pandora_console/images/help/Ux10.JPG differ diff --git a/pandora_console/images/help/Ux11.JPG b/pandora_console/images/help/Ux11.JPG new file mode 100644 index 0000000000..0f72caeace Binary files /dev/null and b/pandora_console/images/help/Ux11.JPG differ diff --git a/pandora_console/images/help/Ux13.JPG b/pandora_console/images/help/Ux13.JPG new file mode 100644 index 0000000000..2322811fa2 Binary files /dev/null and b/pandora_console/images/help/Ux13.JPG differ diff --git a/pandora_console/images/help/Ux14.JPG b/pandora_console/images/help/Ux14.JPG new file mode 100644 index 0000000000..1c26174101 Binary files /dev/null and b/pandora_console/images/help/Ux14.JPG differ diff --git a/pandora_console/images/help/Ux15.JPG b/pandora_console/images/help/Ux15.JPG new file mode 100644 index 0000000000..4cc7b65933 Binary files /dev/null and b/pandora_console/images/help/Ux15.JPG differ diff --git a/pandora_console/images/help/Ux16.JPG b/pandora_console/images/help/Ux16.JPG new file mode 100644 index 0000000000..c2c29d66a7 Binary files /dev/null and b/pandora_console/images/help/Ux16.JPG differ diff --git a/pandora_console/images/help/Ux6.JPG b/pandora_console/images/help/Ux6.JPG new file mode 100644 index 0000000000..b58a38b9e7 Binary files /dev/null and b/pandora_console/images/help/Ux6.JPG differ diff --git a/pandora_console/images/help/Ux7.JPG b/pandora_console/images/help/Ux7.JPG new file mode 100644 index 0000000000..0cfc0b4093 Binary files /dev/null and b/pandora_console/images/help/Ux7.JPG differ diff --git a/pandora_console/images/help/Ux9.JPG b/pandora_console/images/help/Ux9.JPG new file mode 100644 index 0000000000..36c10d0af6 Binary files /dev/null and b/pandora_console/images/help/Ux9.JPG differ diff --git a/pandora_console/images/help/WUX_v1.png b/pandora_console/images/help/WUX_v1.png new file mode 100644 index 0000000000..7fa3fc9903 Binary files /dev/null and b/pandora_console/images/help/WUX_v1.png differ diff --git a/pandora_console/images/help/WUX_v2.png b/pandora_console/images/help/WUX_v2.png new file mode 100644 index 0000000000..bf82b35d55 Binary files /dev/null and b/pandora_console/images/help/WUX_v2.png differ diff --git a/pandora_console/images/help/WUX_v3.png b/pandora_console/images/help/WUX_v3.png new file mode 100644 index 0000000000..0e033d5727 Binary files /dev/null and b/pandora_console/images/help/WUX_v3.png differ diff --git a/pandora_console/images/help/cascade_protection_agent.png b/pandora_console/images/help/cascade_protection_agent.png new file mode 100644 index 0000000000..620863bd58 Binary files /dev/null and b/pandora_console/images/help/cascade_protection_agent.png differ diff --git a/pandora_console/images/help/cascade_protection_module.png b/pandora_console/images/help/cascade_protection_module.png new file mode 100644 index 0000000000..30947aa92c Binary files /dev/null and b/pandora_console/images/help/cascade_protection_module.png differ diff --git a/pandora_console/images/icono-wux.png b/pandora_console/images/icono-wux.png new file mode 100644 index 0000000000..e48c08b8b2 Binary files /dev/null and b/pandora_console/images/icono-wux.png differ diff --git a/pandora_console/images/icono_mail.png b/pandora_console/images/icono_mail.png new file mode 100644 index 0000000000..fb9a8e953e Binary files /dev/null and b/pandora_console/images/icono_mail.png differ diff --git a/pandora_console/images/image_problem_area.png b/pandora_console/images/image_problem_area.png new file mode 100644 index 0000000000..d89324cf81 Binary files /dev/null and b/pandora_console/images/image_problem_area.png differ diff --git a/pandora_console/images/module-wux.png b/pandora_console/images/module-wux.png new file mode 100644 index 0000000000..3afc4e3152 Binary files /dev/null and b/pandora_console/images/module-wux.png differ diff --git a/pandora_console/images/reloj.png b/pandora_console/images/reloj.png new file mode 100644 index 0000000000..8dea142a7e Binary files /dev/null and b/pandora_console/images/reloj.png differ diff --git a/pandora_console/images/search_big.png b/pandora_console/images/search_big.png new file mode 100644 index 0000000000..30ae08a625 Binary files /dev/null and b/pandora_console/images/search_big.png differ diff --git a/pandora_console/images/sound_events_console_alert.gif b/pandora_console/images/sound_events_console_alert.gif new file mode 100644 index 0000000000..78a4d0f2ef Binary files /dev/null and b/pandora_console/images/sound_events_console_alert.gif differ diff --git a/pandora_console/images/spinner_green.gif b/pandora_console/images/spinner_green.gif new file mode 100644 index 0000000000..5182e7e42e Binary files /dev/null and b/pandora_console/images/spinner_green.gif differ diff --git a/pandora_console/images/tick_sound_events.png b/pandora_console/images/tick_sound_events.png new file mode 100644 index 0000000000..15f1cc4226 Binary files /dev/null and b/pandora_console/images/tick_sound_events.png differ diff --git a/pandora_console/images/tip-blanco.png b/pandora_console/images/tip-blanco.png new file mode 100644 index 0000000000..6e106d4c48 Binary files /dev/null and b/pandora_console/images/tip-blanco.png differ diff --git a/pandora_console/images/tip_grey.png b/pandora_console/images/tip_grey.png new file mode 100644 index 0000000000..5257d092bd Binary files /dev/null and b/pandora_console/images/tip_grey.png differ diff --git a/pandora_console/images/unknown.png b/pandora_console/images/unknown.png new file mode 100644 index 0000000000..b46c2497c2 Binary files /dev/null and b/pandora_console/images/unknown.png differ diff --git a/pandora_console/images/wux.png b/pandora_console/images/wux.png new file mode 100644 index 0000000000..72956e158d Binary files /dev/null and b/pandora_console/images/wux.png differ diff --git a/pandora_console/include/ajax/alert_list.ajax.php b/pandora_console/include/ajax/alert_list.ajax.php index de34dbdeea..9f1b454905 100644 --- a/pandora_console/include/ajax/alert_list.ajax.php +++ b/pandora_console/include/ajax/alert_list.ajax.php @@ -17,13 +17,6 @@ global $config; // Login check check_login (); -if (! check_acl ($config['id_user'], 0, "LW")) { - db_pandora_audit("ACL Violation", - "Trying to access Alert Management"); - require ("general/noaccess.php"); - exit; -} - require_once ('include/functions_agents.php'); require_once ('include/functions_alerts.php'); $isFunctionPolicies = enterprise_include ('include/functions_policies.php'); @@ -48,6 +41,13 @@ if ($get_agent_alerts_simple) { echo json_encode (false); return; } + + if (! check_acl ($config['id_user'], 0, "LW")) { + db_pandora_audit("ACL Violation", + "Trying to access Alert Management"); + echo json_encode (false); + return; + } require_once ('include/functions_agents.php'); require_once ('include/functions_alerts.php'); @@ -73,6 +73,12 @@ if ($get_agent_alerts_simple) { } if ($enable_alert) { + if (! check_acl ($config['id_user'], 0, "LW")) { + db_pandora_audit("ACL Violation", + "Trying to access Alert Management"); + return false; + } + $id_alert = (int) get_parameter ('id_alert'); $result = alerts_agent_module_disable ($id_alert, false); @@ -84,6 +90,11 @@ if ($enable_alert) { } if ($disable_alert) { + if (! check_acl ($config['id_user'], 0, "LW")) { + db_pandora_audit("ACL Violation", + "Trying to access Alert Management"); + return false; + } $id_alert = (int) get_parameter ('id_alert'); $result = alerts_agent_module_disable ($id_alert, true); @@ -95,6 +106,11 @@ if ($disable_alert) { } if ($get_actions_module) { + if (! check_acl ($config['id_user'], 0, "LW")) { + db_pandora_audit("ACL Violation", + "Trying to access Alert Management"); + return false; + } $id_module = get_parameter ('id_module'); if (empty($id_module)) @@ -107,6 +123,11 @@ if ($get_actions_module) { } if ($show_update_action_menu) { + if (! check_acl ($config['id_user'], 0, "LW")) { + db_pandora_audit("ACL Violation", + "Trying to access Alert Management"); + return false; + } $id_agent_module = (int) get_parameter ('id_agent_module'); $id_module_action = (int) get_parameter ('id_module_action'); $id_agent = (int) get_parameter ('id_agent'); diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 6d30983b7e..cad5efae1a 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -122,19 +122,64 @@ if ($perform_event_response) { global $config; $command = get_parameter('target',''); - - switch (PHP_OS) { - case "FreeBSD": - $timeout_bin = '/usr/local/bin/gtimeout'; - break; - case "NetBSD": - $timeout_bin = '/usr/pkg/bin/gtimeout'; - break; - default: - $timeout_bin = '/usr/bin/timeout'; - break; + $response_id = get_parameter ('response_id'); + + $event_response = db_get_row('tevent_response','id',$response_id); + + if (enterprise_installed()) { + if ($event_response['server_to_exec'] != 0 && $event_response['type'] == 'command') { + $commandExclusions = array ('vi', 'vim', 'nano'); + + $server_data = db_get_row('tserver','id_server', $event_response['server_to_exec']); + + if (in_array(strtolower($command),$commandExclusions)) { + echo "Only stdin/stdout commands are supported"; + } + else { + switch (PHP_OS) { + case "FreeBSD": + $timeout_bin = '/usr/local/bin/gtimeout'; + break; + case "NetBSD": + $timeout_bin = '/usr/pkg/bin/gtimeout'; + break; + default: + $timeout_bin = '/usr/bin/timeout'; + break; + } + + echo system("ssh pandora_exec_proxy@" . $server_data['ip_address'] . " \"" . $timeout_bin . " 90 " . io_safe_output($command) . " 2>&1\"", $ret_val); + } + } + else { + switch (PHP_OS) { + case "FreeBSD": + $timeout_bin = '/usr/local/bin/gtimeout'; + break; + case "NetBSD": + $timeout_bin = '/usr/pkg/bin/gtimeout'; + break; + default: + $timeout_bin = '/usr/bin/timeout'; + break; + } + echo system($timeout_bin . ' 90 '.io_safe_output($command).' 2>&1'); + } + } + else { + switch (PHP_OS) { + case "FreeBSD": + $timeout_bin = '/usr/local/bin/gtimeout'; + break; + case "NetBSD": + $timeout_bin = '/usr/pkg/bin/gtimeout'; + break; + default: + $timeout_bin = '/usr/bin/timeout'; + break; + } + echo system($timeout_bin . ' 90 '.io_safe_output($command).' 2>&1'); } - echo system($timeout_bin . ' 9 '.io_safe_output($command).' 2>&1'); return; } @@ -162,7 +207,7 @@ if ($dialogue_event_response) { echo "
"; echo "
"; break; case 'url': @@ -302,7 +347,7 @@ if ($get_extended_event) { $tabs .= "
  • ".html_print_image('images/pencil.png',true)."".__('Comments')."
  • "; if (!$readonly && - (tags_checks_event_acl($config["id_user"], $event["id_grupo"], "EM", $event['clean_tags'], $childrens_ids)) || (tags_checks_event_acl($config["id_user"], $event["id_grupo"], "EW", $event['clean_tags'],$childrens_ids))) { + ((tags_checks_event_acl($config["id_user"], $event["id_grupo"], "EM", $event['clean_tags'], $childrens_ids)) || (tags_checks_event_acl($config["id_user"], $event["id_grupo"], "EW", $event['clean_tags'],$childrens_ids)))) { $tabs .= "
  • ".html_print_image('images/event_responses_col.png',true)."".__('Responses')."
  • "; } if ($event['custom_data'] != '') { @@ -335,9 +380,9 @@ if ($get_extended_event) { $img_sev = "images/status_sets/default/severity_major.png"; break; } - + if (!$readonly && - (tags_checks_event_acl($config["id_user"], $event["id_grupo"], "EM", $event['clean_tags'], $childrens_ids)) || (tags_checks_event_acl($config["id_user"], $event["id_grupo"], "EW", $event['clean_tags'],$childrens_ids))) { + ((tags_checks_event_acl($config["id_user"], $event["id_grupo"], "EM", $event['clean_tags'], $childrens_ids)) || (tags_checks_event_acl($config["id_user"], $event["id_grupo"], "EW", $event['clean_tags'],$childrens_ids)))) { $responses = events_page_responses($event, $childrens_ids); } else { @@ -503,15 +548,27 @@ if ($table_events) { require_once ("include/functions_graph.php"); $id_agente = (int)get_parameter('id_agente', 0); + $all_events_24h = (int)get_parameter('all_events_24h', 0); // Fix: for tag functionality groups have to be all user_groups (propagate ACL funct!) $groups = users_get_groups($config["id_user"]); $tags_condition = tags_get_acl_tags($config['id_user'], array_keys($groups), 'ER', 'event_condition', 'AND'); - - events_print_event_table ("estado <> 1 $tags_condition", 10, '100%', - false, $id_agente,true); + echo '
    '; + echo ''; + echo html_print_checkbox('all_events_24h', $all_events_24h, $all_events_24h, true, false, '', true); + echo '
    '; + $date_subtract_day = time() - (24 * 60 * 60); + + if($all_events_24h){ + events_print_event_table ("utimestamp > $date_subtract_day", 200, '100%', + false, $id_agente,true); + } + else{ + events_print_event_table ("estado <> 1 $tags_condition", 200, '100%', + false, $id_agente,true); + } } if ($get_list_events_agents) { diff --git a/pandora_console/include/ajax/graph.ajax.php b/pandora_console/include/ajax/graph.ajax.php index 3244b387e1..1b537f8a48 100644 --- a/pandora_console/include/ajax/graph.ajax.php +++ b/pandora_console/include/ajax/graph.ajax.php @@ -18,6 +18,7 @@ require_once('include/functions_graph.php'); $save_custom_graph = (bool) get_parameter('save_custom_graph'); $print_custom_graph = (bool) get_parameter('print_custom_graph'); $print_sparse_graph = (bool) get_parameter('print_sparse_graph'); +$get_graphs = (bool)get_parameter('get_graphs_container'); if ($save_custom_graph) { $return = array(); @@ -111,4 +112,236 @@ if ($print_sparse_graph) { return; } +if ($get_graphs){ + $id_container = get_parameter('id_container',0); + //config token max_graph + $max_graph = $config['max_graph_container']; + $result_items = db_get_all_rows_sql("SELECT * FROM tcontainer_item WHERE id_container = " . $id_container); + if (!empty($result_items)){ + $hash = get_parameter('hash',0); + $period = get_parameter('time',0); + + $periods = array (); + $periods[1] = __('none'); + $periods[SECONDS_1HOUR] = __('1 hour'); + $periods[SECONDS_2HOUR] = sprintf(__('%s hours'), '2 '); + $periods[SECONDS_6HOURS] = sprintf(__('%s hours'), '6 '); + $periods[SECONDS_12HOURS] = sprintf(__('%s hours'), '12 '); + $periods[SECONDS_1DAY] = __('1 day'); + $periods[SECONDS_2DAY] = sprintf(__('%s days'), '2 '); + $periods[SECONDS_5DAY] = sprintf(__('%s days'), '5 '); + $periods[SECONDS_1WEEK] = __('1 week'); + $periods[SECONDS_15DAYS] = __('15 days'); + $periods[SECONDS_1MONTH] = __('1 month'); + + $table = ''; + $single_table = ""; + $single_table .= ""; + $single_table .= ""; + $single_table .= ""; + $single_table .= ""; + $single_table .= "
    "; + $single_table .= __('Time container lapse'); + // $single_table .= ui_print_help_tip(__('This is the range, or period of time over which the report renders the information for this report type. For example, a week means data from a week ago from now. '),true); + $single_table .= ""; + $single_table .= html_print_extended_select_for_time('period_container_'.$hash, $period, + '', '', '0', 10, true,'font-size: 9pt;width: 130px;',true,'',false,$periods,'vertical-align: middle;'); + $single_table .= "
    "; + + $table .= $single_table; + $contador = $config['max_graph_container']; + foreach ($result_items as $key => $value) { + $table .= "
    "; + if($period > 1){ + $value['time_lapse'] = $period; + } + switch ($value['type']) { + case 'simple_graph': + if ($contador > 0) { + $sql_modulo = db_get_all_rows_sql("SELECT nombre, id_agente FROM + tagente_modulo WHERE id_agente_modulo = ". $value['id_agent_module']); + $sql_alias = db_get_all_rows_sql("SELECT alias from tagente + WHERE id_agente = ". $sql_modulo[0]['id_agente']); + $table .= "

    AGENT " .$sql_alias[0]['alias']." MODULE ".$sql_modulo[0]['nombre']."


    "; + $table .= grafico_modulo_sparse( + $value['id_agent_module'], + $value['time_lapse'], + 0, + 1000, + 300, + '', + '', + false, + $value['only_average'], + false, + 0, + '', + 0, + 0, + 1, + false, + ui_get_full_url(false, false, false, false), + 1, + false, + 0, + false, + false, + 1, + 'white', + null, + false, + false, + 'area'); + $contador --; + } + // $table .= "
    "; + break; + case 'custom_graph': + if ($contador > 0) { + $graph = db_get_all_rows_field_filter('tgraph', 'id_graph',$value['id_graph']); + + $sources = db_get_all_rows_field_filter('tgraph_source', 'id_graph',$value['id_graph']); + $modules = array (); + $weights = array (); + $labels = array (); + foreach ($sources as $source) { + array_push ($modules, $source['id_agent_module']); + array_push ($weights, $source['weight']); + if ($source['label'] != ''){ + $item['type'] = 'custom_graph'; + $item['id_agent'] = agents_get_module_id($source['id_agent_module']); + $item['id_agent_module'] = $source['id_agent_module']; + $labels[$source['id_agent_module']] = reporting_label_macro($item, $source['label']); + } + } + + $homeurl = ui_get_full_url(false, false, false, false); + $graph_conf = db_get_row('tgraph', 'id_graph', $value['id_graph']); + + if($graph_conf['stacked'] == 4 || $graph_conf['stacked'] == 9){ + $height = 50; + } else if ($graph_conf['stacked'] == 5){ + $height = 200; + } else { + $height = 300; + } + $table .= "

    ".$graph[0]['name']."


    "; + $table .= graphic_combined_module($modules, + $weights, + $value['time_lapse'], + 1000, + $height, + '', + '', + 0, + 0, + 0, + $graph_conf['stacked'], + 0, + false, + $homeurl, + 1, + false, + false, + 'white', + array(), + array(), + 1, + 1, + 1, + 1, + $labels, + false, + false, + null, + false); + $contador --; + } + break; + case 'dynamic_graph': + if($value['agent'] != ''){ + $alias = " AND alias REGEXP '".$value['agent']."'"; + } + + if($value['id_group'] === '0'){ + $id_group = ""; + } else { + $id_group = " AND id_grupo = ".$value['id_group']; + } + + if($value['id_module_group'] === '0'){ + $id_module_group = ""; + } else { + $id_module_group = " AND id_module_group = ".$value['id_module_group']; + } + + if($value['id_tag'] === '0'){ + $tag = ""; + $id_tag = ""; + } else { + $tag = " INNER JOIN ttag_module ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo "; + $id_tag = " AND ttag_module.id_tag = ".$value['id_tag']; + } + + if($value['module'] != ''){ + $module_name = " AND nombre REGEXP '".$value['module']."'"; + } + + $id_agent_module = db_get_all_rows_sql("SELECT tagente_modulo.id_agente_modulo FROM tagente_modulo + ". $tag . "WHERE 1=1" . $id_module_group . $module_name . + " AND id_agente IN (SELECT id_agente FROM tagente WHERE 1=1" .$alias.$id_group.")" + . $id_tag); + + foreach ($id_agent_module as $key2 => $value2) { + if ($contador > 0) { + $sql_modulo2 = db_get_all_rows_sql("SELECT nombre, id_agente FROM + tagente_modulo WHERE id_agente_modulo = ". $value2['id_agente_modulo']); + + $sql_alias2 = db_get_all_rows_sql("SELECT alias from tagente + WHERE id_agente = ". $sql_modulo2[0]['id_agente']); + + $table .= "

    AGENT " .$sql_alias2[0]['alias']." MODULE ".$sql_modulo2[0]['nombre']."


    "; + + $table .= grafico_modulo_sparse( + $value2['id_agente_modulo'], + $value['time_lapse'], + 0, + 1000, + 300, + '', + '', + false, + $value['only_average'], + false, + 0, + '', + 0, + 0, + 1, + false, + ui_get_full_url(false, false, false, false), + 1, + false, + 0, + false, + false, + 1, + 'white', + null, + false, + false, + 'area'); + $contador --; + } + } + break; + } + } + $table .= "
    "; + echo $table; + return; + + } +} + ?> diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 6eb5b0e17a..d97d51264f 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -254,7 +254,9 @@ if ($get_module_detail) { $id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo', 'nombre', 'web_content_string'); - + + $post_process = db_get_value_filter('post_process','tagente_modulo',array('id_agente_modulo' => $module_id)); + foreach ($result as $row) { $data = array (); @@ -266,21 +268,16 @@ if ($get_module_detail) { foreach ($columns as $col => $attr) { if ($attr[1] != "modules_format_data") { $data[] = date('d F Y h:i:s A', $row['utimestamp']); - } elseif (($config['command_snapshot']) && (preg_match ("/[\n]+/i", $row[$attr[0]]))) { // Its a single-data, multiline data (data snapshot) ? - // Detect string data with \n and convert to
    's $datos = $row[$attr[0]]; - //$datos = preg_replace ('/\n/i','
    ',$row[$attr[0]]); - //$datos = preg_replace ('/\s/i',' ',$datos); // Because this *SHIT* of print_table monster, I cannot format properly this cells // so, eat this, motherfucker :)) - - $datos = io_safe_input($datos); + $datos = preg_replace("/\n/", "

    ", $datos); // I dont why, but using index (value) method, data is automatically converted to html entities ¿? $data[] = $datos; @@ -288,7 +285,6 @@ if ($get_module_detail) { elseif ($is_web_content_string) { //Fixed the goliat sends the strings from web //without HTML entities - $data[] = io_safe_input($row[$attr[0]]); } else { @@ -299,16 +295,19 @@ if ($get_module_detail) { $data[] = io_safe_input($row[$attr[0]]); } else if (is_numeric($row[$attr[0]]) && !modules_is_string_type($row['module_type']) ) { - - //~ $data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision'])); - //~ $data[] = (double) $row[$attr[0]]; switch($row['module_type']) { case 15: $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module_id); - if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') - $data[] = human_milliseconds_to_string($row['data']); - else + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0'){ + if($post_process > 0){ + $data[] = human_milliseconds_to_string($row['data'] / $post_process); + } else { + $data[] = human_milliseconds_to_string($row['data']); + } + }else{ $data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision'])); + } + break; default: $data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision'])); @@ -320,17 +319,12 @@ if ($get_module_detail) { $data[] = 'No data'; } else { - - if(is_snapshot_data($row[$attr[0]])){ - $data[] = ""; - } - else{ - $data[] = $row[$attr[0]]; - } - - - - + if(is_snapshot_data($row[$attr[0]])){ + $data[] = ""; + } + else{ + $data[] = $row[$attr[0]]; + } } } } @@ -970,10 +964,16 @@ if ($list_modules) { switch($module['id_tipo_modulo']) { case 15: $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']); - if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') - $salida = human_milliseconds_to_string($module['datos']); - else + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0'){ + if($module['post_process']>0){ + $salida = human_milliseconds_to_string($module['datos'] / $module['post_process']); + } else { + $salida = human_milliseconds_to_string($module['datos']); + } + } else { $salida = remove_right_zeros(number_format($module["datos"], $config['graph_precision'])); + } + break; default: $salida = remove_right_zeros(number_format($module["datos"], $config['graph_precision'])); @@ -986,16 +986,20 @@ if ($list_modules) { switch($module['id_tipo_modulo']) { case 15: $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']); - if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') - $salida = human_milliseconds_to_string($module['datos']); - else + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0'){ + if($module['post_process']>0){ + $salida = human_milliseconds_to_string($module['datos'] / $module['post_process']); + } else { + $salida = human_milliseconds_to_string($module['datos']); + } + } else { $salida = remove_right_zeros(number_format($module["datos"], $config['graph_precision'])); + } break; default: $salida = remove_right_zeros(number_format($module["datos"], $config['graph_precision'])); break; } - //~ $salida = (number_format($module["datos"], $config['graph_precision'])); } // Show units ONLY in numeric data types if (isset($module["unit"])) { @@ -1008,8 +1012,12 @@ if ($list_modules) { $module["current_interval"], $module["module_name"]); } } - + if($module["id_tipo_modulo"] != 25){ $data[6] = ui_print_module_warn_value ($module["max_warning"], $module["min_warning"], $module["str_warning"], $module["max_critical"], $module["min_critical"], $module["str_critical"]); + } + else{ + $data[6] = ""; + } $data[7] = $salida; $graph_type = return_graphtype ($module["id_tipo_modulo"]); diff --git a/pandora_console/include/ajax/snmp_browser.ajax.php b/pandora_console/include/ajax/snmp_browser.ajax.php new file mode 100644 index 0000000000..3376245093 --- /dev/null +++ b/pandora_console/include/ajax/snmp_browser.ajax.php @@ -0,0 +1,126 @@ + $target_oid) { + $oid = snmp_browser_get_oid ($target_ip, $community, + htmlspecialchars_decode($target_oid), $snmp_version, $snmp3_auth_user, + $snmp3_security_level, $snmp3_auth_method, $snmp3_auth_pass, + $snmp3_privacy_method, $snmp3_privacy_pass); + + + $name_check = db_get_value ('name', 'tnetwork_component', + 'name', $oid['oid']); + + if(empty($oid['description'])) { + $description = ''; + } else { + $description = io_safe_input($oid['description']); + } + + if(!$name_check){ + $id = network_components_create_network_component ($oid['oid'],17,1, + array ('description' => $description, + 'module_interval' => 300, + 'max' => 0, + 'min' => 0, + 'tcp_send' => $snmp_version, + 'tcp_rcv' => '', + 'tcp_port' => 0, + 'snmp_oid' => $oid['numeric_oid'], + 'snmp_community' => $community, + 'id_module_group' => 3, + 'id_modulo' => 2, + 'id_plugin' => 0, + 'plugin_user' => '', + 'plugin_pass' => '', + 'plugin_parameter' => '', + 'macros' => '', + 'max_timeout' => 0, + 'max_retries' => 0, + 'history_data' => '', + 'dynamic_interval' => 0, + 'dynamic_max' => 0, + 'dynamic_min' => 0, + 'dynamic_two_tailed' => 0, + 'min_warning' => 0, + 'max_warning' => 0, + 'str_warning' => '', + 'min_critical' => 0, + 'max_critical' => 0, + 'str_critical' => '', + 'min_ff_event' => 0, + 'custom_string_1' => '', + 'custom_string_2' => '', + 'custom_string_3' => '', + 'post_process' => 0, + 'unit' => '', + 'wizard_level' => 'nowizard', + 'macros' => '', + 'critical_instructions' => '', + 'warning_instructions' => '', + 'unknown_instructions' => '', + 'critical_inverse' => 0, + 'warning_inverse' => 0, + 'id_category' => 0, + 'tags' => '', + 'disabled_types_event' => '{"going_unknown":1}', + 'min_ff_event_normal' => 0, + 'min_ff_event_warning' => 0, + 'min_ff_event_critical' => 0, + 'each_ff' => 0)); + } + + if(empty($id)) { + array_push($fail_modules,$name_check); + } + } + } + + echo json_encode($fail_modules); + return; +} + + + +?> \ No newline at end of file diff --git a/pandora_console/include/ajax/update_manager.ajax.php b/pandora_console/include/ajax/update_manager.ajax.php index af1071fdb1..80c62539da 100644 --- a/pandora_console/include/ajax/update_manager.ajax.php +++ b/pandora_console/include/ajax/update_manager.ajax.php @@ -116,8 +116,16 @@ if ($install_package) { $package = trim($package); $chunks = explode("_", basename($package)); - $chunks = explode(".", $chunks[1]); - $version = $chunks[0]; + $chunks = explode(".", $chunks[1]); + if(is_numeric($chunks[0])){ + $version = $chunks[0]; + } else { + $current_package = db_get_value('value', 'tconfig', + 'token', 'current_package_enterprise'); + if (!empty($current_package)) { + $version = $current_package; + } + } // All files extracted $files_total = $package . "/files.txt"; diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index 74d99febd5..6f2bae0b40 100755 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -95,6 +95,7 @@ $top = get_parameter('top', null); $agent = get_parameter('agent', null); $id_module = get_parameter('module', null); $period = get_parameter('period', null); +$event_max_time_row = get_parameter('event_max_time_row', null); $width = get_parameter('width', null); $height = get_parameter('height', null); $parent = get_parameter('parent', null); @@ -139,7 +140,39 @@ switch ($action) { echo json_encode($return); break; - + case 'get_module_events': + $data = array (); + + $date = get_system_time (); + $datelimit = $date - $event_max_time_row; + + $events = db_get_row_filter ('tevento', + array ('id_agente' => $id_agent, + 'id_agentmodule' => $id_module, + 'utimestamp > ' . $datelimit, + 'utimestamp < ' . $date), 'criticity, utimestamp'); + + $return = array(); + if (!$events) { + $return['no_data'] = true; + if (!empty($id_metaconsole)) { + $connection = db_get_row_filter ('tmetaconsole_setup', + $id_metaconsole); + if (metaconsole_load_external_db($connection) != NOERR) { + continue; + } + } + $return['url'] = true; + if (!empty($id_metaconsole)) { + metaconsole_restore_db(); + } + } + else { + $return['no_data'] = false; + } + + echo json_encode($return); + break; case 'get_image_sparse': //Metaconsole db connection @@ -422,6 +455,7 @@ switch ($action) { $values['type'] = visual_map_get_simple_value_type( $process_simple_value); $values['period'] = $period; + $values['width'] = $width; } case 'percentile_bar': case 'percentile_item': @@ -429,6 +463,7 @@ switch ($action) { case 'module_graph': case 'label': case 'icon': + case 'auto_sla_graph': default: if ($type == 'label') { $values['type'] = LABEL; @@ -503,6 +538,18 @@ switch ($action) { $values['border_color'] = $line_color; break; // ------------------------------------------------- + case 'auto_sla_graph': + $values['type'] = AUTO_SLA_GRAPH; + if ($event_max_time_row !== null) { + $values['period'] = $event_max_time_row; + } + if ($width !== null) { + $values['width'] = $width; + } + if ($height !== null) { + $values['height'] = $height; + } + break; case 'box_item': $values['border_width'] = $border_width; $values['border_color'] = $border_color; @@ -616,10 +663,20 @@ switch ($action) { } } + $item_in_db = db_get_row_filter ('tlayout_data', array ('id' => $id_element)); + + if (($item_in_db['parent_item'] == 0) && ($values['parent_item'] != 0)) { + $new_line = 1; + } + $result = db_process_sql_update('tlayout_data', $values, array('id' => $id_element)); - echo (int)$result; + $return_val = array(); + $return_val['correct'] = (int)$result; + $return_val['new_line'] = $new_line; + + echo json_encode($return_val); break; } break; @@ -648,6 +705,7 @@ switch ($action) { case 'simple_value': case 'label': case 'icon': + case 'auto_sla_graph': $elementFields = db_get_row_filter('tlayout_data', array('id' => $id_element)); @@ -699,6 +757,8 @@ switch ($action) { } switch ($type) { + case 'auto_sla_graph': + $elementFields['event_max_time_row'] = $elementFields['period']; case 'percentile_item': case 'percentile_bar': $elementFields['width_percentile'] = $elementFields['width']; @@ -858,6 +918,12 @@ switch ($action) { } $values['period'] = $period; break; + case 'auto_sla_graph': + $values['type'] = AUTO_SLA_GRAPH; + $values['period'] = $event_max_time_row; + $values['width'] = $width; + $values['height'] = $height; + break; case 'percentile_item': case 'percentile_bar': if ($type_percentile == 'percentile') { @@ -887,6 +953,7 @@ switch ($action) { //This allows min, max and avg process in a simple value $values['type'] = visual_map_get_simple_value_type($process_simple_value); $values['period'] = $period; + $values['width'] = $width; break; case 'label': $values['type'] = LABEL; @@ -973,8 +1040,6 @@ switch ($action) { echo json_encode($return); break; - - case 'delete': if (db_process_sql_delete('tlayout_data', array('id' => $id_element, 'id_layout' => $id_visual_console)) === false) { $return['correct'] = 0; diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 53b9adc78e..a7e710dcb2 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -201,14 +201,6 @@ function process_user_login_remote ($login, $pass, $api = false) { } break; - // Remote Babel Enterprise - case 'babel': - if (enterprise_hook ('remote_babel_process_user_login', array ($login, $pass)) === false) { - $config["auth_error"] = "User not found in database or incorrect password"; - return false; - } - break; - // Remote Integria case 'integria': if (enterprise_hook ('remote_integria_process_user_login', array ($login, $pass)) === false) { diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index d0daa39d8a..8fb6b5254c 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,8 +22,8 @@ /** * Pandora build version and version */ -$build_version = 'PC170411'; -$pandora_version = 'v7.0NG'; +$build_version = 'PC170908'; +$pandora_version = 'v7.0NG.712'; // Do not overwrite default timezone set if defined. $script_tz = @date_default_timezone_get(); @@ -110,6 +110,53 @@ require_once ($ownDir . 'constants.php'); require_once ($ownDir . 'functions_db.php'); require_once ($ownDir . 'functions.php'); +// We need a timezone BEFORE calling config_process_config. +// If not we will get ugly warnings. Set Europe/Madrid by default +// Later will be replaced by the good one. +if(!is_dir($_SERVER['DOCUMENT_ROOT'] . $config["homeurl"]) || !is_dir($_SERVER['DOCUMENT_ROOT'] . $config["homeurl_static"])){ + $url = explode('/', $_SERVER['REQUEST_URI']); + $flag_url =0; + foreach ($url as $key => $value) { + if (strpos($value, 'index.php') !== false || $flag_url) { + $flag_url=1; + unset($url[$key]); + } + else if(strpos($value, 'enterprise') !== false || $flag_url){ + $flag_url=1; + unset($url[$key]); + } + } + $config["homeurl"] = rtrim(join("/", $url),"/"); + $config["homeurl_static"] = $config["homeurl"]; + $config["error"] = "homeurl_bad_defined"; + return; +} + + +if (!isset($config["homeurl_static"])) { + $config["homeurl_static"] = $config["homeurl"]; +} +else{ + if($config["homeurl_static"] != $config["homeurl"]){ + $url = explode('/', $_SERVER['REQUEST_URI']); + $flag_url =0; + foreach ($url as $key => $value) { + if (strpos($value, 'index.php') !== false || $flag_url) { + $flag_url=1; + unset($url[$key]); + } + else if(strpos($value, 'enterprise') !== false || $flag_url){ + $flag_url=1; + unset($url[$key]); + } + } + $config["homeurl"] = rtrim(join("/", $url),"/"); + $config["homeurl_static"] = $config["homeurl"]; + $config["error"] = "homeurl_bad_defined"; + return; + } +} + db_select_engine(); $config['dbconnection'] = db_connect(); @@ -122,37 +169,6 @@ if (! defined ('ENTERPRISE_DIR')) require_once ($ownDir. 'functions_config.php'); -// We need a timezone BEFORE calling config_process_config. -// If not we will get ugly warnings. Set Europe/Madrid by default -// Later will be replaced by the good one. -if (!defined('METACONSOLE')) { - if(!isset($config["homeurl"])){ - $url = explode('/', $_SERVER['REQUEST_URI']); - $config["homeurl"] = $url[1]; - $config["homeurl_static"] = $url[1]; - $config["error"] = "homeurl_bad_defined"; - return; - } - else{ - $url = explode('/', $_SERVER['REQUEST_URI']); - if($config["homeurl"] != '/'.$url[1]){ - $config["homeurl"] = '/'.$url[1]; - $config["homeurl_static"] = '/'.$url[1]; - $config["error"] = "homeurl_bad_defined"; - return; - } - } -} -if (!isset($config["homeurl_static"])) { - $config["homeurl_static"] = $config["homeurl"]; -} -else{ - if($config["homeurl_static"] != $config["homeurl"]){ - $config["error"] = "homeurl_bad_defined"; - return; - } -} - date_default_timezone_set("Europe/Madrid"); @@ -236,7 +252,7 @@ if (isset($_POST['vc_refr'])) { //======= Autorefresh code ============================================= -$select = db_process_sql("SELECT value FROM tconfig WHERE token='autorefresh_white_list'"); +$select = db_process_sql("SELECT autorefresh_white_list FROM tusuario WHERE id_user = '" . $config['id_user'] . "'"); $autorefresh_list = json_decode($select[0]['value']); $config['autorefresh_white_list'] = array(); $config['autorefresh_white_list'] = $autorefresh_list; diff --git a/pandora_console/include/config_process.php.orig b/pandora_console/include/config_process.php.orig new file mode 100644 index 0000000000..724f83f3dd --- /dev/null +++ b/pandora_console/include/config_process.php.orig @@ -0,0 +1,292 @@ +>>>>>> develop +$pandora_version = 'v7.0NG'; + +// Do not overwrite default timezone set if defined. +$script_tz = @date_default_timezone_get(); +if (empty($script_tz)) { + date_default_timezone_set("Europe/Berlin"); + ini_set("date.timezone", "Europe/Berlin"); +} +else { + ini_set("date.timezone", $script_tz); +} + +//home dir bad defined +if (!is_dir($config['homedir'])) { + $ownDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR; + $config['homedir'] = $ownDir; + $config["error"] = "homedir_bad_defined"; +} + + +/* Help to debug problems. Override global PHP configuration */ +global $develop_bypass; +if ($develop_bypass != 1) { + // error_reporting(E_ALL); + + if (version_compare(PHP_VERSION, '5.3.0') >= 0) + { + error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE); + } + else + { + error_reporting(E_ALL & ~E_NOTICE); + } + + ini_set("display_errors", 0); + ini_set("log_errors", 1); + ini_set("error_log", $config["homedir"]."/pandora_console.log"); +} +else { + // Develop mode, show all notices and errors on Console (and log it) + if (version_compare(PHP_VERSION, '5.3.0') >= 0) + { + error_reporting(E_ALL & ~E_DEPRECATED); + } + else + { + error_reporting(E_ALL); + } + ini_set("display_errors", 1); + ini_set("log_errors", 1); + ini_set("error_log", $config["homedir"]."/pandora_console.log"); +} + +// Check if mysqli is available +if (!(isset($config["mysqli"]))) { + $config["mysqli"] = extension_loaded(mysqli); +} + +$config['start_time'] = microtime (true); + +$ownDir = dirname(__FILE__) . '/'; +$ownDir = str_replace("\\", "/", $ownDir); + +//Set by default the MySQL connection for DB, because in older Pandora have not +//this token in the config.php +if (!isset($config['dbtype'])) { + $config['dbtype'] = 'mysql'; +} + +if (!isset($config['dbport'])) { + switch ($config['dbtype']) { + case 'mysql': + $config['dbport'] = '3306'; + break; + case 'postgresql': + $config['dbport'] = '5432'; + break; + case 'oracle': + $config['dbport'] = '1521'; + break; + } +} + +require_once ($ownDir . 'constants.php'); +require_once ($ownDir . 'functions_db.php'); +require_once ($ownDir . 'functions.php'); + +db_select_engine(); +$config['dbconnection'] = db_connect(); + + +if (! defined ('EXTENSIONS_DIR')) + define ('EXTENSIONS_DIR', 'extensions'); + +if (! defined ('ENTERPRISE_DIR')) + define ('ENTERPRISE_DIR', 'enterprise'); + +require_once ($ownDir. 'functions_config.php'); + +// We need a timezone BEFORE calling config_process_config. +// If not we will get ugly warnings. Set Europe/Madrid by default +// Later will be replaced by the good one. +if (!defined('METACONSOLE')) { + if(!isset($config["homeurl"])){ + $url = explode('/', $_SERVER['REQUEST_URI']); + $config["homeurl"] = $url[1]; + $config["homeurl_static"] = $url[1]; + $config["error"] = "homeurl_bad_defined"; + return; + } + else{ + $url = explode('/', $_SERVER['REQUEST_URI']); + if($config["homeurl"] != '/'.$url[1]){ + $config["homeurl"] = '/'.$url[1]; + $config["homeurl_static"] = '/'.$url[1]; + $config["error"] = "homeurl_bad_defined"; + return; + } + } +} +if (!isset($config["homeurl_static"])) { + $config["homeurl_static"] = $config["homeurl"]; +} +else{ + if($config["homeurl_static"] != $config["homeurl"]){ + $config["error"] = "homeurl_bad_defined"; + return; + } +} + +date_default_timezone_set("Europe/Madrid"); + + +config_process_config(); + +config_prepare_session(); +require_once ($config["homedir"].'/include/load_session.php'); +if(session_id() == '') { + $resultado = session_start(); +} + +// Set a the system timezone default +if ((!isset($config["timezone"])) OR ($config["timezone"] == "")) { + $config["timezone"] = "Europe/Berlin"; +} + +date_default_timezone_set($config["timezone"]); + +require_once ($ownDir . 'streams.php'); +require_once ($ownDir . 'gettext.php'); + +if (isset($_SERVER['REMOTE_ADDR'])) { + $config["remote_addr"] = $_SERVER['REMOTE_ADDR']; +} +else { + $config["remote_addr"] = null; +} + +// Save the global values +$config["global_block_size"] = $config["block_size"]; +$config["global_flash_charts"] = $config["flash_charts"]; + + +if (isset ($config['id_user'])) { + config_user_set_custom_config(); +} + +// Check if inventory_changes_blacklist is setted, if not create it +if (!isset($config['inventory_changes_blacklist'])) { + $config['inventory_changes_blacklist'] = array(); +} + +//NEW UPDATE MANAGER URL +if (!isset($config['url_update_manager'])) { + config_update_value('url_update_manager', + 'https://licensing.artica.es/pandoraupdate7/server.php'); +} + +if (defined('METACONSOLE')) { + enterprise_include_once('meta/include/functions_users_meta.php'); + enterprise_hook('set_meta_user_language'); +} +else + set_user_language(); + +require_once ($ownDir . 'functions_extensions.php'); + +$config['extensions'] = extensions_get_extensions (); + +// Detect if enterprise extension is installed +// NOTICE: This variable (config[enterprise_installed] is used in several +// sections. Faking or forcing to 1 will make pandora fails. + +if (file_exists ($config["homedir"] . '/' . ENTERPRISE_DIR . '/index.php')) { + $config['enterprise_installed'] = 1; + enterprise_include_once ('include/functions_enterprise.php'); +} +else { + $config['enterprise_installed'] = 0; +} + +// Function include_graphs_dependencies() it's called in the code below +require_once("include_graph_dependencies.php"); + +include_graphs_dependencies($config['homedir'] . '/'); + +// Updates autorefresh time +if (isset($_POST['vc_refr'])) { + config_update_value ('vc_refr', get_parameter('vc_refr', $config['vc_refr'])); +} + + +//======= Autorefresh code ============================================= +$select = db_process_sql("SELECT value FROM tconfig WHERE token='autorefresh_white_list'"); +$autorefresh_list = json_decode($select[0]['value']); +$config['autorefresh_white_list'] = array(); +$config['autorefresh_white_list'] = $autorefresh_list; +// Specific metaconsole autorefresh white list sections +if (defined('METACONSOLE')) { + $config['autorefresh_white_list'][] = 'monitoring/tactical'; + $config['autorefresh_white_list'][] = 'monitoring/group_view'; + $config['autorefresh_white_list'][] = 'operation/tree'; + $config['autorefresh_white_list'][] = 'screens/screens'; +} + +//====================================================================== + + +//====================================================================== +// Update the $config['homeurl'] with the full url with the special +// cases (reverse proxy, others ports...). +//====================================================================== +$config["homeurl"] = ui_get_full_url(false); + + +//====================================================================== +// Get the version of DB manager +//====================================================================== +switch ($config["dbtype"]) { + case "mysql": + if (!isset($config['quote_string'])) { + $config['db_quote_string'] = "\""; + } + break; + case "postgresql": + if (!isset($config['dbversion'])) { + $result = db_get_sql("select version();"); + $result_chunks = explode(" ", $result); + + $config['dbversion'] = $result_chunks[1]; + } + if (!isset($config['quote_string'])) { + $config['db_quote_string'] = "'"; + } + break; + case "oracle": + if (!isset($config['quote_string'])) { + $config['db_quote_string'] = "'"; + } + break; +} +//====================================================================== +?> diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index cee055d867..f039a90504 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -185,6 +185,7 @@ define('AGENT_STATUS_WARNING', 2); define('STATIC_GRAPH', 0); define('PERCENTILE_BAR', 3); define('MODULE_GRAPH', 1); +define('AUTO_SLA_GRAPH', 14); define('SIMPLE_VALUE', 2); define('LABEL', 4); define('ICON', 5); @@ -310,6 +311,7 @@ define ('MODULE_PLUGIN', 4); define ('MODULE_PREDICTION', 5); define ('MODULE_WMI', 6); define ('MODULE_WEB', 7); +define ('MODULE_WUX', 8); /* Type of Modules of Prediction */ define ('MODULE_PREDICTION_SERVICE', 2); @@ -350,6 +352,7 @@ define('SERVER_TYPE_ENTERPRISE_SATELLITE', 13); define('SERVER_TYPE_ENTERPRISE_TRANSACTIONAL', 14); define('SERVER_TYPE_MAINFRAME', 15); define('SERVER_TYPE_SYNC', 16); +define('SERVER_TYPE_WUX', 17); /* REPORTS */ define('REPORT_TOP_N_MAX', 1); @@ -467,6 +470,7 @@ define("OPTION_SINGLE_SELECT_TIME", 7); define("OPTION_CUSTOM_INPUT", 8); define("OPTION_AGENT_AUTOCOMPLETE", 9); define("OPTION_SELECT_MULTISELECTION", 10); +define("OPTION_COLOR_PICKER", 11); /* Transactional map constants */ define("NODE_TYPE", 0); diff --git a/pandora_console/include/ehorus/bundle.js b/pandora_console/include/ehorus/bundle.js index 5336b4c2ae..49cee67abc 100644 --- a/pandora_console/include/ehorus/bundle.js +++ b/pandora_console/include/ehorus/bundle.js @@ -1,97 +1,6762 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o> 2]; + result += toBase64Table[((data[i] & 0x03) << 4) + (data[i + 1] >> 4)]; + result += toBase64Table[((data[i + 1] & 0x0f) << 2) + (data[i + 2] >> 6)]; + result += toBase64Table[data[i + 2] & 0x3f]; + } + + // Convert the remaining 1 or 2 bytes, pad out to 4 characters. + var j = 0; + if (lengthpad === 2) { + j = length - lengthpad; + result += toBase64Table[data[j] >> 2]; + result += toBase64Table[((data[j] & 0x03) << 4) + (data[j + 1] >> 4)]; + result += toBase64Table[(data[j + 1] & 0x0f) << 2]; + result += toBase64Table[64]; + } else if (lengthpad === 1) { + j = length - lengthpad; + result += toBase64Table[data[j] >> 2]; + result += toBase64Table[(data[j] & 0x03) << 4]; + result += toBase64Table[64]; + result += toBase64Table[64]; + } + + return result; + }, + + /* Convert Base64 data to a string */ + /* jshint -W013 */ + toBinaryTable: [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1], + /* jshint +W013 */ + + decode: function (data, offset) { + "use strict"; + + offset = typeof offset !== 'undefined' ? offset : 0; + var toBinaryTable = this.toBinaryTable; + var base64Pad = this.base64Pad; + var result, result_length; + var leftbits = 0; // number of bits decoded, but yet to be appended + var leftdata = 0; // bits decoded, but yet to be appended + var data_length = data.indexOf('=') - offset; + + if (data_length < 0) { + data_length = data.length - offset; + } + + /* Every four characters is 3 resulting numbers */ + result_length = (data_length >> 2) * 3 + Math.floor(data_length % 4 / 1.5); + result = new Array(result_length); + + // Convert one by one. + for (var idx = 0, i = offset; i < data.length; i++) { + var c = toBinaryTable[data.charCodeAt(i) & 0x7f]; + var padding = data.charAt(i) === base64Pad; + // Skip illegal characters and whitespace + if (c === -1) { + console.error("Illegal character code " + data.charCodeAt(i) + " at position " + i); + continue; + } + + // Collect data into leftdata, update bitcount + leftdata = leftdata << 6 | c; + leftbits += 6; + + // If we have 8 or more bits, append 8 bits to the result + if (leftbits >= 8) { + leftbits -= 8; + // Append if not padding. + if (!padding) { + result[idx++] = leftdata >> leftbits & 0xff; + } + leftdata &= (1 << leftbits) - 1; + } + } + + // If there are any bits left, the base64 string was corrupted + if (leftbits) { + err = new Error('Corrupted base64 string'); + err.name = 'Base64-Error'; + throw err; + } + + return result; + } +}; /* End of Base64 namespace */ +},{}],2:[function(require,module,exports){ "use strict"; -exports["default"] = function (instance, Constructor) { +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = DES; +/* + * Ported from Flashlight VNC ActionScript implementation: + * http://www.wizhelp.com/flashlight-vnc/ + * + * Full attribution follows: + * + * ------------------------------------------------------------------------- + * + * This DES class has been extracted from package Acme.Crypto for use in VNC. + * The unnecessary odd parity code has been removed. + * + * These changes are: + * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + + * DesCipher - the DES encryption method + * + * The meat of this code is by Dave Zimmerman , and is: + * + * Copyright (c) 1996 Widget Workshop, Inc. All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this software + * and its documentation for NON-COMMERCIAL or COMMERCIAL purposes and + * without fee is hereby granted, provided that this copyright notice is kept + * intact. + * + * WIDGET WORKSHOP MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY + * OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED + * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. WIDGET WORKSHOP SHALL NOT BE LIABLE + * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. + * + * THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE + * CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE + * PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT + * NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE + * SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE + * SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE + * PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES"). WIDGET WORKSHOP + * SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR + * HIGH RISK ACTIVITIES. + * + * + * The rest is: + * + * Copyright (C) 1996 by Jef Poskanzer . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Visit the ACME Labs Java page for up-to-date versions of this and other + * fine Java utilities: http://www.acme.com/java/ + */ + +/* jslint white: false */ + +function DES(passwd) { + "use strict"; + + // Tables, permutations, S-boxes, etc. + // jshint -W013 + + var PC2 = [13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9, 22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1, 40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47, 43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31], + totrot = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28], + z = 0x0, + a, + b, + c, + d, + e, + f, + SP1, + SP2, + SP3, + SP4, + SP5, + SP6, + SP7, + SP8, + keys = []; + + // jshint -W015 + a = 1 << 16;b = 1 << 24;c = a | b;d = 1 << 2;e = 1 << 10;f = d | e; + SP1 = [c | e, z | z, a | z, c | f, c | d, a | f, z | d, a | z, z | e, c | e, c | f, z | e, b | f, c | d, b | z, z | d, z | f, b | e, b | e, a | e, a | e, c | z, c | z, b | f, a | d, b | d, b | d, a | d, z | z, z | f, a | f, b | z, a | z, c | f, z | d, c | z, c | e, b | z, b | z, z | e, c | d, a | z, a | e, b | d, z | e, z | d, b | f, a | f, c | f, a | d, c | z, b | f, b | d, z | f, a | f, c | e, z | f, b | e, b | e, z | z, a | d, a | e, z | z, c | d]; + a = 1 << 20;b = 1 << 31;c = a | b;d = 1 << 5;e = 1 << 15;f = d | e; + SP2 = [c | f, b | e, z | e, a | f, a | z, z | d, c | d, b | f, b | d, c | f, c | e, b | z, b | e, a | z, z | d, c | d, a | e, a | d, b | f, z | z, b | z, z | e, a | f, c | z, a | d, b | d, z | z, a | e, z | f, c | e, c | z, z | f, z | z, a | f, c | d, a | z, b | f, c | z, c | e, z | e, c | z, b | e, z | d, c | f, a | f, z | d, z | e, b | z, z | f, c | e, a | z, b | d, a | d, b | f, b | d, a | d, a | e, z | z, b | e, z | f, b | z, c | d, c | f, a | e]; + a = 1 << 17;b = 1 << 27;c = a | b;d = 1 << 3;e = 1 << 9;f = d | e; + SP3 = [z | f, c | e, z | z, c | d, b | e, z | z, a | f, b | e, a | d, b | d, b | d, a | z, c | f, a | d, c | z, z | f, b | z, z | d, c | e, z | e, a | e, c | z, c | d, a | f, b | f, a | e, a | z, b | f, z | d, c | f, z | e, b | z, c | e, b | z, a | d, z | f, a | z, c | e, b | e, z | z, z | e, a | d, c | f, b | e, b | d, z | e, z | z, c | d, b | f, a | z, b | z, c | f, z | d, a | f, a | e, b | d, c | z, b | f, z | f, c | z, a | f, z | d, c | d, a | e]; + a = 1 << 13;b = 1 << 23;c = a | b;d = 1 << 0;e = 1 << 7;f = d | e; + SP4 = [c | d, a | f, a | f, z | e, c | e, b | f, b | d, a | d, z | z, c | z, c | z, c | f, z | f, z | z, b | e, b | d, z | d, a | z, b | z, c | d, z | e, b | z, a | d, a | e, b | f, z | d, a | e, b | e, a | z, c | e, c | f, z | f, b | e, b | d, c | z, c | f, z | f, z | z, z | z, c | z, a | e, b | e, b | f, z | d, c | d, a | f, a | f, z | e, c | f, z | f, z | d, a | z, b | d, a | d, c | e, b | f, a | d, a | e, b | z, c | d, z | e, b | z, a | z, c | e]; + a = 1 << 25;b = 1 << 30;c = a | b;d = 1 << 8;e = 1 << 19;f = d | e; + SP5 = [z | d, a | f, a | e, c | d, z | e, z | d, b | z, a | e, b | f, z | e, a | d, b | f, c | d, c | e, z | f, b | z, a | z, b | e, b | e, z | z, b | d, c | f, c | f, a | d, c | e, b | d, z | z, c | z, a | f, a | z, c | z, z | f, z | e, c | d, z | d, a | z, b | z, a | e, c | d, b | f, a | d, b | z, c | e, a | f, b | f, z | d, a | z, c | e, c | f, z | f, c | z, c | f, a | e, z | z, b | e, c | z, z | f, a | d, b | d, z | e, z | z, b | e, a | f, b | d]; + a = 1 << 22;b = 1 << 29;c = a | b;d = 1 << 4;e = 1 << 14;f = d | e; + SP6 = [b | d, c | z, z | e, c | f, c | z, z | d, c | f, a | z, b | e, a | f, a | z, b | d, a | d, b | e, b | z, z | f, z | z, a | d, b | f, z | e, a | e, b | f, z | d, c | d, c | d, z | z, a | f, c | e, z | f, a | e, c | e, b | z, b | e, z | d, c | d, a | e, c | f, a | z, z | f, b | d, a | z, b | e, b | z, z | f, b | d, c | f, a | e, c | z, a | f, c | e, z | z, c | d, z | d, z | e, c | z, a | f, z | e, a | d, b | f, z | z, c | e, b | z, a | d, b | f]; + a = 1 << 21;b = 1 << 26;c = a | b;d = 1 << 1;e = 1 << 11;f = d | e; + SP7 = [a | z, c | d, b | f, z | z, z | e, b | f, a | f, c | e, c | f, a | z, z | z, b | d, z | d, b | z, c | d, z | f, b | e, a | f, a | d, b | e, b | d, c | z, c | e, a | d, c | z, z | e, z | f, c | f, a | e, z | d, b | z, a | e, b | z, a | e, a | z, b | f, b | f, c | d, c | d, z | d, a | d, b | z, b | e, a | z, c | e, z | f, a | f, c | e, z | f, b | d, c | f, c | z, a | e, z | z, z | d, c | f, z | z, a | f, c | z, z | e, b | d, b | e, z | e, a | d]; + a = 1 << 18;b = 1 << 28;c = a | b;d = 1 << 6;e = 1 << 12;f = d | e; + SP8 = [b | f, z | e, a | z, c | f, b | z, b | f, z | d, b | z, a | d, c | z, c | f, a | e, c | e, a | f, z | e, z | d, c | z, b | d, b | e, z | f, a | e, a | d, c | d, c | e, z | f, z | z, z | z, c | d, b | d, b | e, a | f, a | z, a | f, a | z, c | e, z | e, z | d, c | d, z | e, a | f, b | e, z | d, b | d, c | z, c | d, b | z, a | z, b | f, z | z, c | f, a | d, b | d, c | z, b | e, b | f, z | z, c | f, a | e, a | e, z | f, z | f, a | d, b | z, c | e]; + // jshint +W013,+W015 + + // Set the key. + function setKeys(keyBlock) { + var i, + j, + l, + m, + n, + o, + pc1m = [], + pcr = [], + kn = [], + raw0, + raw1, + rawi, + KnLi; + + for (j = 0, l = 56; j < 56; ++j, l -= 8) { + l += l < -5 ? 65 : l < -3 ? 31 : l < -1 ? 63 : l === 27 ? 35 : 0; // PC1 + m = l & 0x7; + pc1m[j] = (keyBlock[l >>> 3] & 1 << m) !== 0 ? 1 : 0; + } + + for (i = 0; i < 16; ++i) { + m = i << 1; + n = m + 1; + kn[m] = kn[n] = 0; + for (o = 28; o < 59; o += 28) { + for (j = o - 28; j < o; ++j) { + l = j + totrot[i]; + if (l < o) { + pcr[j] = pc1m[l]; + } else { + pcr[j] = pc1m[l - 28]; + } + } + } + for (j = 0; j < 24; ++j) { + if (pcr[PC2[j]] !== 0) { + kn[m] |= 1 << 23 - j; + } + if (pcr[PC2[j + 24]] !== 0) { + kn[n] |= 1 << 23 - j; + } + } + } + + // cookey + for (i = 0, rawi = 0, KnLi = 0; i < 16; ++i) { + raw0 = kn[rawi++]; + raw1 = kn[rawi++]; + keys[KnLi] = (raw0 & 0x00fc0000) << 6; + keys[KnLi] |= (raw0 & 0x00000fc0) << 10; + keys[KnLi] |= (raw1 & 0x00fc0000) >>> 10; + keys[KnLi] |= (raw1 & 0x00000fc0) >>> 6; + ++KnLi; + keys[KnLi] = (raw0 & 0x0003f000) << 12; + keys[KnLi] |= (raw0 & 0x0000003f) << 16; + keys[KnLi] |= (raw1 & 0x0003f000) >>> 4; + keys[KnLi] |= raw1 & 0x0000003f; + ++KnLi; + } + } + + // Encrypt 8 bytes of text + function enc8(text) { + var i = 0, + b = text.slice(), + fval, + keysi = 0, + l, + r, + x; // left, right, accumulator + + // Squash 8 bytes to 2 ints + l = b[i++] << 24 | b[i++] << 16 | b[i++] << 8 | b[i++]; + r = b[i++] << 24 | b[i++] << 16 | b[i++] << 8 | b[i++]; + + x = (l >>> 4 ^ r) & 0x0f0f0f0f; + r ^= x; + l ^= x << 4; + x = (l >>> 16 ^ r) & 0x0000ffff; + r ^= x; + l ^= x << 16; + x = (r >>> 2 ^ l) & 0x33333333; + l ^= x; + r ^= x << 2; + x = (r >>> 8 ^ l) & 0x00ff00ff; + l ^= x; + r ^= x << 8; + r = r << 1 | r >>> 31 & 1; + x = (l ^ r) & 0xaaaaaaaa; + l ^= x; + r ^= x; + l = l << 1 | l >>> 31 & 1; + + for (i = 0; i < 8; ++i) { + x = r << 28 | r >>> 4; + x ^= keys[keysi++]; + fval = SP7[x & 0x3f]; + fval |= SP5[x >>> 8 & 0x3f]; + fval |= SP3[x >>> 16 & 0x3f]; + fval |= SP1[x >>> 24 & 0x3f]; + x = r ^ keys[keysi++]; + fval |= SP8[x & 0x3f]; + fval |= SP6[x >>> 8 & 0x3f]; + fval |= SP4[x >>> 16 & 0x3f]; + fval |= SP2[x >>> 24 & 0x3f]; + l ^= fval; + x = l << 28 | l >>> 4; + x ^= keys[keysi++]; + fval = SP7[x & 0x3f]; + fval |= SP5[x >>> 8 & 0x3f]; + fval |= SP3[x >>> 16 & 0x3f]; + fval |= SP1[x >>> 24 & 0x3f]; + x = l ^ keys[keysi++]; + fval |= SP8[x & 0x0000003f]; + fval |= SP6[x >>> 8 & 0x3f]; + fval |= SP4[x >>> 16 & 0x3f]; + fval |= SP2[x >>> 24 & 0x3f]; + r ^= fval; + } + + r = r << 31 | r >>> 1; + x = (l ^ r) & 0xaaaaaaaa; + l ^= x; + r ^= x; + l = l << 31 | l >>> 1; + x = (l >>> 8 ^ r) & 0x00ff00ff; + r ^= x; + l ^= x << 8; + x = (l >>> 2 ^ r) & 0x33333333; + r ^= x; + l ^= x << 2; + x = (r >>> 16 ^ l) & 0x0000ffff; + l ^= x; + r ^= x << 16; + x = (r >>> 4 ^ l) & 0x0f0f0f0f; + l ^= x; + r ^= x << 4; + + // Spread ints to bytes + x = [r, l]; + for (i = 0; i < 8; i++) { + b[i] = (x[i >>> 2] >>> 8 * (3 - i % 4)) % 256; + if (b[i] < 0) { + b[i] += 256; + } // unsigned + } + return b; + } + + // Encrypt 16 bytes of text using passwd as key + function encrypt(t) { + return enc8(t.slice(0, 8)).concat(enc8(t.slice(8, 16))); + } + + setKeys(passwd); // Setup keys + return { 'encrypt': encrypt }; // Public interface +}; // function DES +},{}],3:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = Display; + +var _browsers = require('./util/browsers.js'); + +var _properties = require('./util/properties.js'); + +var _logging = require('./util/logging.js'); + +var Log = _interopRequireWildcard(_logging); + +var _base = require('./base64.js'); + +var _base2 = _interopRequireDefault(_base); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +/* + * noVNC: HTML5 VNC client + * Copyright (C) 2012 Joel Martin + * Copyright (C) 2015 Samuel Mannehed for Cendio AB + * Licensed under MPL 2.0 (see LICENSE.txt) + * + * See README.md for usage and integration instructions. + */ + +/*jslint browser: true, white: false */ +/*global Util, Base64, changeCursor */ + +function Display(defaults) { + this._drawCtx = null; + this._c_forceCanvas = false; + + this._renderQ = []; // queue drawing actions for in-oder rendering + this._flushing = false; + + // the full frame buffer (logical canvas) size + this._fb_width = 0; + this._fb_height = 0; + + this._prevDrawStyle = ""; + this._tile = null; + this._tile16x16 = null; + this._tile_x = 0; + this._tile_y = 0; + + (0, _properties.set_defaults)(this, defaults, { + 'true_color': true, + 'colourMap': [], + 'scale': 1.0, + 'viewport': false, + 'render_mode': '', + "onFlush": function () {} + }); + + Log.Debug(">> Display.constructor"); + + // The visible canvas + if (!this._target) { + throw new Error("Target must be set"); + } + + if (typeof this._target === 'string') { + throw new Error('target must be a DOM element'); + } + + if (!this._target.getContext) { + throw new Error("no getContext method"); + } + + this._targetCtx = this._target.getContext('2d'); + + // the visible canvas viewport (i.e. what actually gets seen) + this._viewportLoc = { 'x': 0, 'y': 0, 'w': this._target.width, 'h': this._target.height }; + + // The hidden canvas, where we do the actual rendering + this._backbuffer = document.createElement('canvas'); + this._drawCtx = this._backbuffer.getContext('2d'); + + this._damageBounds = { left: 0, top: 0, + right: this._backbuffer.width, + bottom: this._backbuffer.height }; + + Log.Debug("User Agent: " + navigator.userAgent); + if (_browsers.Engine.gecko) { + Log.Debug("Browser: gecko " + _browsers.Engine.gecko); + } + if (_browsers.Engine.webkit) { + Log.Debug("Browser: webkit " + _browsers.Engine.webkit); + } + if (_browsers.Engine.trident) { + Log.Debug("Browser: trident " + _browsers.Engine.trident); + } + if (_browsers.Engine.presto) { + Log.Debug("Browser: presto " + _browsers.Engine.presto); + } + + this.clear(); + + // Check canvas features + if ('createImageData' in this._drawCtx) { + this._render_mode = 'canvas rendering'; + } else { + throw new Error("Canvas does not support createImageData"); + } + + if (this._prefer_js === null) { + Log.Info("Prefering javascript operations"); + this._prefer_js = true; + } + + // Determine browser support for setting the cursor via data URI scheme + if (this._cursor_uri || this._cursor_uri === null || this._cursor_uri === undefined) { + this._cursor_uri = (0, _browsers.browserSupportsCursorURIs)(); + } + + Log.Debug("<< Display.constructor"); +}; + +var SUPPORTS_IMAGEDATA_CONSTRUCTOR = false; +try { + new ImageData(new Uint8ClampedArray(4), 1, 1); + SUPPORTS_IMAGEDATA_CONSTRUCTOR = true; +} catch (ex) { + // ignore failure +} + +Display.prototype = { + // Public methods + viewportChangePos: function (deltaX, deltaY) { + var vp = this._viewportLoc; + deltaX = Math.floor(deltaX); + deltaY = Math.floor(deltaY); + + if (!this._viewport) { + deltaX = -vp.w; // clamped later of out of bounds + deltaY = -vp.h; + } + + var vx2 = vp.x + vp.w - 1; + var vy2 = vp.y + vp.h - 1; + + // Position change + + if (deltaX < 0 && vp.x + deltaX < 0) { + deltaX = -vp.x; + } + if (vx2 + deltaX >= this._fb_width) { + deltaX -= vx2 + deltaX - this._fb_width + 1; + } + + if (vp.y + deltaY < 0) { + deltaY = -vp.y; + } + if (vy2 + deltaY >= this._fb_height) { + deltaY -= vy2 + deltaY - this._fb_height + 1; + } + + if (deltaX === 0 && deltaY === 0) { + return; + } + Log.Debug("viewportChange deltaX: " + deltaX + ", deltaY: " + deltaY); + + vp.x += deltaX; + vp.y += deltaY; + + this._damage(vp.x, vp.y, vp.w, vp.h); + + this.flip(); + }, + + viewportChangeSize: function (width, height) { + + if (!this._viewport || typeof width === "undefined" || typeof height === "undefined") { + + Log.Debug("Setting viewport to full display region"); + width = this._fb_width; + height = this._fb_height; + } + + if (width > this._fb_width) { + width = this._fb_width; + } + if (height > this._fb_height) { + height = this._fb_height; + } + + var vp = this._viewportLoc; + if (vp.w !== width || vp.h !== height) { + vp.w = width; + vp.h = height; + + var canvas = this._target; + canvas.width = width; + canvas.height = height; + + // The position might need to be updated if we've grown + this.viewportChangePos(0, 0); + + this._damage(vp.x, vp.y, vp.w, vp.h); + this.flip(); + + // Update the visible size of the target canvas + this._rescale(this._scale); + } + }, + + absX: function (x) { + return x / this._scale + this._viewportLoc.x; + }, + + absY: function (y) { + return y / this._scale + this._viewportLoc.y; + }, + + resize: function (width, height) { + this._prevDrawStyle = ""; + + this._fb_width = width; + this._fb_height = height; + + var canvas = this._backbuffer; + if (canvas.width !== width || canvas.height !== height) { + + // We have to save the canvas data since changing the size will clear it + var saveImg = null; + if (canvas.width > 0 && canvas.height > 0) { + saveImg = this._drawCtx.getImageData(0, 0, canvas.width, canvas.height); + } + + if (canvas.width !== width) { + canvas.width = width; + } + if (canvas.height !== height) { + canvas.height = height; + } + + if (saveImg) { + this._drawCtx.putImageData(saveImg, 0, 0); + } + } + + // Readjust the viewport as it may be incorrectly sized + // and positioned + var vp = this._viewportLoc; + this.viewportChangeSize(vp.w, vp.h); + this.viewportChangePos(0, 0); + }, + + // Track what parts of the visible canvas that need updating + _damage: function (x, y, w, h) { + if (x < this._damageBounds.left) { + this._damageBounds.left = x; + } + if (y < this._damageBounds.top) { + this._damageBounds.top = y; + } + if (x + w > this._damageBounds.right) { + this._damageBounds.right = x + w; + } + if (y + h > this._damageBounds.bottom) { + this._damageBounds.bottom = y + h; + } + }, + + // Update the visible canvas with the contents of the + // rendering canvas + flip: function (from_queue) { + if (this._renderQ.length !== 0 && !from_queue) { + this._renderQ_push({ + 'type': 'flip' + }); + } else { + var x, y, vx, vy, w, h; + + x = this._damageBounds.left; + y = this._damageBounds.top; + w = this._damageBounds.right - x; + h = this._damageBounds.bottom - y; + + vx = x - this._viewportLoc.x; + vy = y - this._viewportLoc.y; + + if (vx < 0) { + w += vx; + x -= vx; + vx = 0; + } + if (vy < 0) { + h += vy; + y -= vy; + vy = 0; + } + + if (vx + w > this._viewportLoc.w) { + w = this._viewportLoc.w - vx; + } + if (vy + h > this._viewportLoc.h) { + h = this._viewportLoc.h - vy; + } + + if (w > 0 && h > 0) { + // FIXME: We may need to disable image smoothing here + // as well (see copyImage()), but we haven't + // noticed any problem yet. + this._targetCtx.drawImage(this._backbuffer, x, y, w, h, vx, vy, w, h); + } + + this._damageBounds.left = this._damageBounds.top = 65535; + this._damageBounds.right = this._damageBounds.bottom = 0; + } + }, + + clear: function () { + if (this._logo) { + this.resize(this._logo.width, this._logo.height); + this.imageRect(0, 0, this._logo.type, this._logo.data); + } else { + this.resize(240, 20); + this._drawCtx.clearRect(0, 0, this._fb_width, this._fb_height); + } + this.flip(); + }, + + pending: function () { + return this._renderQ.length > 0; + }, + + flush: function () { + if (this._renderQ.length === 0) { + this._onFlush(); + } else { + this._flushing = true; + } + }, + + fillRect: function (x, y, width, height, color, from_queue) { + if (this._renderQ.length !== 0 && !from_queue) { + this._renderQ_push({ + 'type': 'fill', + 'x': x, + 'y': y, + 'width': width, + 'height': height, + 'color': color + }); + } else { + this._setFillColor(color); + this._drawCtx.fillRect(x, y, width, height); + this._damage(x, y, width, height); + } + }, + + copyImage: function (old_x, old_y, new_x, new_y, w, h, from_queue) { + if (this._renderQ.length !== 0 && !from_queue) { + this._renderQ_push({ + 'type': 'copy', + 'old_x': old_x, + 'old_y': old_y, + 'x': new_x, + 'y': new_y, + 'width': w, + 'height': h + }); + } else { + // Due to this bug among others [1] we need to disable the image-smoothing to + // avoid getting a blur effect when copying data. + // + // 1. https://bugzilla.mozilla.org/show_bug.cgi?id=1194719 + // + // We need to set these every time since all properties are reset + // when the the size is changed + this._drawCtx.mozImageSmoothingEnabled = false; + this._drawCtx.webkitImageSmoothingEnabled = false; + this._drawCtx.msImageSmoothingEnabled = false; + this._drawCtx.imageSmoothingEnabled = false; + + this._drawCtx.drawImage(this._backbuffer, old_x, old_y, w, h, new_x, new_y, w, h); + this._damage(new_x, new_y, w, h); + } + }, + + imageRect: function (x, y, mime, arr) { + var img = new Image(); + img.src = "data: " + mime + ";base64," + _base2.default.encode(arr); + this._renderQ_push({ + 'type': 'img', + 'img': img, + 'x': x, + 'y': y + }); + }, + + // start updating a tile + startTile: function (x, y, width, height, color) { + this._tile_x = x; + this._tile_y = y; + if (width === 16 && height === 16) { + this._tile = this._tile16x16; + } else { + this._tile = this._drawCtx.createImageData(width, height); + } + + if (this._prefer_js) { + var bgr; + if (this._true_color) { + bgr = color; + } else { + bgr = this._colourMap[color[0]]; + } + var red = bgr[2]; + var green = bgr[1]; + var blue = bgr[0]; + + var data = this._tile.data; + for (var i = 0; i < width * height * 4; i += 4) { + data[i] = red; + data[i + 1] = green; + data[i + 2] = blue; + data[i + 3] = 255; + } + } else { + this.fillRect(x, y, width, height, color, true); + } + }, + + // update sub-rectangle of the current tile + subTile: function (x, y, w, h, color) { + if (this._prefer_js) { + var bgr; + if (this._true_color) { + bgr = color; + } else { + bgr = this._colourMap[color[0]]; + } + var red = bgr[2]; + var green = bgr[1]; + var blue = bgr[0]; + var xend = x + w; + var yend = y + h; + + var data = this._tile.data; + var width = this._tile.width; + for (var j = y; j < yend; j++) { + for (var i = x; i < xend; i++) { + var p = (i + j * width) * 4; + data[p] = red; + data[p + 1] = green; + data[p + 2] = blue; + data[p + 3] = 255; + } + } + } else { + this.fillRect(this._tile_x + x, this._tile_y + y, w, h, color, true); + } + }, + + // draw the current tile to the screen + finishTile: function () { + if (this._prefer_js) { + this._drawCtx.putImageData(this._tile, this._tile_x, this._tile_y); + this._damage(this._tile_x, this._tile_y, this._tile.width, this._tile.height); + } + // else: No-op -- already done by setSubTile + }, + + blitImage: function (x, y, width, height, arr, offset, from_queue) { + if (this._renderQ.length !== 0 && !from_queue) { + // NB(directxman12): it's technically more performant here to use preallocated arrays, + // but it's a lot of extra work for not a lot of payoff -- if we're using the render queue, + // this probably isn't getting called *nearly* as much + var new_arr = new Uint8Array(width * height * 4); + new_arr.set(new Uint8Array(arr.buffer, 0, new_arr.length)); + this._renderQ_push({ + 'type': 'blit', + 'data': new_arr, + 'x': x, + 'y': y, + 'width': width, + 'height': height + }); + } else if (this._true_color) { + this._bgrxImageData(x, y, width, height, arr, offset); + } else { + this._cmapImageData(x, y, width, height, arr, offset); + } + }, + + blitRgbImage: function (x, y, width, height, arr, offset, from_queue) { + if (this._renderQ.length !== 0 && !from_queue) { + // NB(directxman12): it's technically more performant here to use preallocated arrays, + // but it's a lot of extra work for not a lot of payoff -- if we're using the render queue, + // this probably isn't getting called *nearly* as much + var new_arr = new Uint8Array(width * height * 3); + new_arr.set(new Uint8Array(arr.buffer, 0, new_arr.length)); + this._renderQ_push({ + 'type': 'blitRgb', + 'data': new_arr, + 'x': x, + 'y': y, + 'width': width, + 'height': height + }); + } else if (this._true_color) { + this._rgbImageData(x, y, width, height, arr, offset); + } else { + // probably wrong? + this._cmapImageData(x, y, width, height, arr, offset); + } + }, + + blitRgbxImage: function (x, y, width, height, arr, offset, from_queue) { + if (this._renderQ.length !== 0 && !from_queue) { + // NB(directxman12): it's technically more performant here to use preallocated arrays, + // but it's a lot of extra work for not a lot of payoff -- if we're using the render queue, + // this probably isn't getting called *nearly* as much + var new_arr = new Uint8Array(width * height * 4); + new_arr.set(new Uint8Array(arr.buffer, 0, new_arr.length)); + this._renderQ_push({ + 'type': 'blitRgbx', + 'data': new_arr, + 'x': x, + 'y': y, + 'width': width, + 'height': height + }); + } else { + this._rgbxImageData(x, y, width, height, arr, offset); + } + }, + + drawImage: function (img, x, y) { + this._drawCtx.drawImage(img, x, y); + this._damage(x, y, img.width, img.height); + }, + + changeCursor: function (pixels, mask, hotx, hoty, w, h) { + if (this._cursor_uri === false) { + Log.Warn("changeCursor called but no cursor data URI support"); + return; + } + + if (this._true_color) { + Display.changeCursor(this._target, pixels, mask, hotx, hoty, w, h); + } else { + Display.changeCursor(this._target, pixels, mask, hotx, hoty, w, h, this._colourMap); + } + }, + + defaultCursor: function () { + this._target.style.cursor = "default"; + }, + + disableLocalCursor: function () { + this._target.style.cursor = "none"; + }, + + clippingDisplay: function () { + var vp = this._viewportLoc; + return this._fb_width > vp.w || this._fb_height > vp.h; + }, + + // Overridden getters/setters + set_scale: function (scale) { + this._rescale(scale); + }, + + set_viewport: function (viewport) { + this._viewport = viewport; + // May need to readjust the viewport dimensions + var vp = this._viewportLoc; + this.viewportChangeSize(vp.w, vp.h); + this.viewportChangePos(0, 0); + }, + + get_width: function () { + return this._fb_width; + }, + get_height: function () { + return this._fb_height; + }, + + autoscale: function (containerWidth, containerHeight, downscaleOnly) { + var vp = this._viewportLoc; + var targetAspectRatio = containerWidth / containerHeight; + var fbAspectRatio = vp.w / vp.h; + + var scaleRatio; + if (fbAspectRatio >= targetAspectRatio) { + scaleRatio = containerWidth / vp.w; + } else { + scaleRatio = containerHeight / vp.h; + } + + if (scaleRatio > 1.0 && downscaleOnly) { + scaleRatio = 1.0; + } + + this._rescale(scaleRatio); + }, + + // Private Methods + _rescale: function (factor) { + this._scale = factor; + var vp = this._viewportLoc; + + // NB(directxman12): If you set the width directly, or set the + // style width to a number, the canvas is cleared. + // However, if you set the style width to a string + // ('NNNpx'), the canvas is scaled without clearing. + var width = Math.round(factor * vp.w) + 'px'; + var height = Math.round(factor * vp.h) + 'px'; + + if (this._target.style.width !== width || this._target.style.height !== height) { + this._target.style.width = width; + this._target.style.height = height; + } + }, + + _setFillColor: function (color) { + var bgr; + if (this._true_color) { + bgr = color; + } else { + bgr = this._colourMap[color]; + } + + var newStyle = 'rgb(' + bgr[2] + ',' + bgr[1] + ',' + bgr[0] + ')'; + if (newStyle !== this._prevDrawStyle) { + this._drawCtx.fillStyle = newStyle; + this._prevDrawStyle = newStyle; + } + }, + + _rgbImageData: function (x, y, width, height, arr, offset) { + var img = this._drawCtx.createImageData(width, height); + var data = img.data; + for (var i = 0, j = offset; i < width * height * 4; i += 4, j += 3) { + data[i] = arr[j]; + data[i + 1] = arr[j + 1]; + data[i + 2] = arr[j + 2]; + data[i + 3] = 255; // Alpha + } + this._drawCtx.putImageData(img, x, y); + this._damage(x, y, img.width, img.height); + }, + + _bgrxImageData: function (x, y, width, height, arr, offset) { + var img = this._drawCtx.createImageData(width, height); + var data = img.data; + for (var i = 0, j = offset; i < width * height * 4; i += 4, j += 4) { + data[i] = arr[j + 2]; + data[i + 1] = arr[j + 1]; + data[i + 2] = arr[j]; + data[i + 3] = 255; // Alpha + } + this._drawCtx.putImageData(img, x, y); + this._damage(x, y, img.width, img.height); + }, + + _rgbxImageData: function (x, y, width, height, arr, offset) { + // NB(directxman12): arr must be an Type Array view + var img; + if (SUPPORTS_IMAGEDATA_CONSTRUCTOR) { + img = new ImageData(new Uint8ClampedArray(arr.buffer, arr.byteOffset, width * height * 4), width, height); + } else { + img = this._drawCtx.createImageData(width, height); + img.data.set(new Uint8ClampedArray(arr.buffer, arr.byteOffset, width * height * 4)); + } + this._drawCtx.putImageData(img, x, y); + this._damage(x, y, img.width, img.height); + }, + + _cmapImageData: function (x, y, width, height, arr, offset) { + var img = this._drawCtx.createImageData(width, height); + var data = img.data; + var cmap = this._colourMap; + for (var i = 0, j = offset; i < width * height * 4; i += 4, j++) { + var bgr = cmap[arr[j]]; + data[i] = bgr[2]; + data[i + 1] = bgr[1]; + data[i + 2] = bgr[0]; + data[i + 3] = 255; // Alpha + } + this._drawCtx.putImageData(img, x, y); + this._damage(x, y, img.width, img.height); + }, + + _renderQ_push: function (action) { + this._renderQ.push(action); + if (this._renderQ.length === 1) { + // If this can be rendered immediately it will be, otherwise + // the scanner will wait for the relevant event + this._scan_renderQ(); + } + }, + + _resume_renderQ: function () { + // "this" is the object that is ready, not the + // display object + this.removeEventListener('load', this._noVNC_display._resume_renderQ); + this._noVNC_display._scan_renderQ(); + }, + + _scan_renderQ: function () { + var ready = true; + while (ready && this._renderQ.length > 0) { + var a = this._renderQ[0]; + switch (a.type) { + case 'flip': + this.flip(true); + break; + case 'copy': + this.copyImage(a.old_x, a.old_y, a.x, a.y, a.width, a.height, true); + break; + case 'fill': + this.fillRect(a.x, a.y, a.width, a.height, a.color, true); + break; + case 'blit': + this.blitImage(a.x, a.y, a.width, a.height, a.data, 0, true); + break; + case 'blitRgb': + this.blitRgbImage(a.x, a.y, a.width, a.height, a.data, 0, true); + break; + case 'blitRgbx': + this.blitRgbxImage(a.x, a.y, a.width, a.height, a.data, 0, true); + break; + case 'img': + if (a.img.complete) { + this.drawImage(a.img, a.x, a.y); + } else { + a.img._noVNC_display = this; + a.img.addEventListener('load', this._resume_renderQ); + // We need to wait for this image to 'load' + // to keep things in-order + ready = false; + } + break; + } + + if (ready) { + this._renderQ.shift(); + } + } + + if (this._renderQ.length === 0 && this._flushing) { + this._flushing = false; + this._onFlush(); + } + } +}; + +(0, _properties.make_properties)(Display, [['target', 'wo', 'dom'], // Canvas element for rendering +['context', 'ro', 'raw'], // Canvas 2D context for rendering (read-only) +['logo', 'rw', 'raw'], // Logo to display when cleared: {"width": w, "height": h, "type": mime-type, "data": data} +['true_color', 'rw', 'bool'], // Use true-color pixel data +['colourMap', 'rw', 'arr'], // Colour map array (when not true-color) +['scale', 'rw', 'float'], // Display area scale factor 0.0 - 1.0 +['viewport', 'rw', 'bool'], // Use viewport clipping +['width', 'ro', 'int'], // Display area width +['height', 'ro', 'int'], // Display area height + +['render_mode', 'ro', 'str'], // Canvas rendering mode (read-only) + +['prefer_js', 'rw', 'str'], // Prefer Javascript over canvas methods +['cursor_uri', 'rw', 'raw'], // Can we render cursor using data URI + +['onFlush', 'rw', 'func']]); + +// Class Methods +Display.changeCursor = function (target, pixels, mask, hotx, hoty, w0, h0, cmap) { + var w = w0; + var h = h0; + if (h < w) { + h = w; // increase h to make it square + } else { + w = h; // increase w to make it square + } + + var cur = []; + + // Push multi-byte little-endian values + cur.push16le = function (num) { + this.push(num & 0xFF, num >> 8 & 0xFF); + }; + cur.push32le = function (num) { + this.push(num & 0xFF, num >> 8 & 0xFF, num >> 16 & 0xFF, num >> 24 & 0xFF); + }; + + var IHDRsz = 40; + var RGBsz = w * h * 4; + var XORsz = Math.ceil(w * h / 8.0); + var ANDsz = Math.ceil(w * h / 8.0); + + cur.push16le(0); // 0: Reserved + cur.push16le(2); // 2: .CUR type + cur.push16le(1); // 4: Number of images, 1 for non-animated ico + + // Cursor #1 header (ICONDIRENTRY) + cur.push(w); // 6: width + cur.push(h); // 7: height + cur.push(0); // 8: colors, 0 -> true-color + cur.push(0); // 9: reserved + cur.push16le(hotx); // 10: hotspot x coordinate + cur.push16le(hoty); // 12: hotspot y coordinate + cur.push32le(IHDRsz + RGBsz + XORsz + ANDsz); + // 14: cursor data byte size + cur.push32le(22); // 18: offset of cursor data in the file + + // Cursor #1 InfoHeader (ICONIMAGE/BITMAPINFO) + cur.push32le(IHDRsz); // 22: InfoHeader size + cur.push32le(w); // 26: Cursor width + cur.push32le(h * 2); // 30: XOR+AND height + cur.push16le(1); // 34: number of planes + cur.push16le(32); // 36: bits per pixel + cur.push32le(0); // 38: Type of compression + + cur.push32le(XORsz + ANDsz); + // 42: Size of Image + cur.push32le(0); // 46: reserved + cur.push32le(0); // 50: reserved + cur.push32le(0); // 54: reserved + cur.push32le(0); // 58: reserved + + // 62: color data (RGBQUAD icColors[]) + var y, x; + for (y = h - 1; y >= 0; y--) { + for (x = 0; x < w; x++) { + if (x >= w0 || y >= h0) { + cur.push(0); // blue + cur.push(0); // green + cur.push(0); // red + cur.push(0); // alpha + } else { + var idx = y * Math.ceil(w0 / 8) + Math.floor(x / 8); + var alpha = mask[idx] << x % 8 & 0x80 ? 255 : 0; + if (cmap) { + idx = w0 * y + x; + var rgb = cmap[pixels[idx]]; + cur.push(rgb[2]); // blue + cur.push(rgb[1]); // green + cur.push(rgb[0]); // red + cur.push(alpha); // alpha + } else { + idx = (w0 * y + x) * 4; + cur.push(pixels[idx]); // blue + cur.push(pixels[idx + 1]); // green + cur.push(pixels[idx + 2]); // red + cur.push(alpha); // alpha + } + } + } + } + + // XOR/bitmask data (BYTE icXOR[]) + // (ignored, just needs to be the right size) + for (y = 0; y < h; y++) { + for (x = 0; x < Math.ceil(w / 8); x++) { + cur.push(0); + } + } + + // AND/bitmask data (BYTE icAND[]) + // (ignored, just needs to be the right size) + for (y = 0; y < h; y++) { + for (x = 0; x < Math.ceil(w / 8); x++) { + cur.push(0); + } + } + + var url = 'data:image/x-icon;base64,' + _base2.default.encode(cur); + target.style.cursor = 'url(' + url + ')' + hotx + ' ' + hoty + ', default'; +}; +},{"./base64.js":1,"./util/browsers.js":11,"./util/logging.js":14,"./util/properties.js":15}],4:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = Inflate; + +var _inflate = require("pako/lib/zlib/inflate.js"); + +var _zstream = require("pako/lib/zlib/zstream.js"); + +var _zstream2 = _interopRequireDefault(_zstream); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +Inflate.prototype = { + inflate: function (data, flush, expected) { + this.strm.input = data; + this.strm.avail_in = this.strm.input.length; + this.strm.next_in = 0; + this.strm.next_out = 0; + + // resize our output buffer if it's too small + // (we could just use multiple chunks, but that would cause an extra + // allocation each time to flatten the chunks) + if (expected > this.chunkSize) { + this.chunkSize = expected; + this.strm.output = new Uint8Array(this.chunkSize); + } + + this.strm.avail_out = this.chunkSize; + + (0, _inflate.inflate)(this.strm, flush); + + return new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out); + }, + + reset: function () { + (0, _inflate.inflateReset)(this.strm); + } +}; + +function Inflate() { + this.strm = new _zstream2.default(); + this.chunkSize = 1024 * 10 * 10; + this.strm.output = new Uint8Array(this.chunkSize); + this.windowBits = 5; + + (0, _inflate.inflateInit)(this.strm, this.windowBits); +}; +},{"pako/lib/zlib/inflate.js":234,"pako/lib/zlib/zstream.js":236}],5:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Mouse = exports.Keyboard = undefined; + +var _logging = require('../util/logging.js'); + +var Log = _interopRequireWildcard(_logging); + +var _browsers = require('../util/browsers.js'); + +var _events = require('../util/events.js'); + +var _properties = require('../util/properties.js'); + +var _util = require('./util.js'); + +var KeyboardUtil = _interopRequireWildcard(_util); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +// +// Keyboard event handler +// + +var Keyboard = function (defaults) { + this._keyDownList = []; // List of depressed keys + // (even if they are happy) + + (0, _properties.set_defaults)(this, defaults, { + 'target': document, + 'focused': true + }); + + // create the keyboard handler + this._handler = new KeyboardUtil.KeyEventDecoder(KeyboardUtil.ModifierSync(), KeyboardUtil.VerifyCharModifier( /* jshint newcap: false */ + KeyboardUtil.TrackKeyState(KeyboardUtil.EscapeModifiers(this._handleRfbEvent.bind(this))))); /* jshint newcap: true */ + + // keep these here so we can refer to them later + this._eventHandlers = { + 'keyup': this._handleKeyUp.bind(this), + 'keydown': this._handleKeyDown.bind(this), + 'keypress': this._handleKeyPress.bind(this), + 'blur': this._allKeysUp.bind(this) + }; +}; /* + * noVNC: HTML5 VNC client + * Copyright (C) 2012 Joel Martin + * Copyright (C) 2013 Samuel Mannehed for Cendio AB + * Licensed under MPL 2.0 or any later version (see LICENSE.txt) + */ + +/*jslint browser: true, white: false */ +/*global window, Util */ + +Keyboard.prototype = { + // private methods + + _handleRfbEvent: function (e) { + if (this._onKeyPress) { + Log.Debug("onKeyPress " + (e.type == 'keydown' ? "down" : "up") + ", keysym: " + e.keysym.keysym + "(" + e.keysym.keyname + ")"); + this._onKeyPress(e); + } + }, + + setQEMUVNCKeyboardHandler: function () { + this._handler = new KeyboardUtil.QEMUKeyEventDecoder(KeyboardUtil.ModifierSync(), KeyboardUtil.TrackQEMUKeyState(this._handleRfbEvent.bind(this))); + }, + + _handleKeyDown: function (e) { + if (!this._focused) { + return; + } + + if (this._handler.keydown(e)) { + // Suppress bubbling/default actions + (0, _events.stopEvent)(e); + } else { + // Allow the event to bubble and become a keyPress event which + // will have the character code translated + } + }, + + _handleKeyPress: function (e) { + if (!this._focused) { + return; + } + + if (this._handler.keypress(e)) { + // Suppress bubbling/default actions + (0, _events.stopEvent)(e); + } + }, + + _handleKeyUp: function (e) { + if (!this._focused) { + return; + } + + if (this._handler.keyup(e)) { + // Suppress bubbling/default actions + (0, _events.stopEvent)(e); + } + }, + + _allKeysUp: function () { + Log.Debug(">> Keyboard.allKeysUp"); + this._handler.releaseAll(); + Log.Debug("<< Keyboard.allKeysUp"); + }, + + // Public methods + + grab: function () { + //Log.Debug(">> Keyboard.grab"); + var c = this._target; + + c.addEventListener('keydown', this._eventHandlers.keydown); + c.addEventListener('keyup', this._eventHandlers.keyup); + c.addEventListener('keypress', this._eventHandlers.keypress); + + // Release (key up) if window loses focus + window.addEventListener('blur', this._eventHandlers.blur); + + //Log.Debug("<< Keyboard.grab"); + }, + + ungrab: function () { + //Log.Debug(">> Keyboard.ungrab"); + var c = this._target; + + c.removeEventListener('keydown', this._eventHandlers.keydown); + c.removeEventListener('keyup', this._eventHandlers.keyup); + c.removeEventListener('keypress', this._eventHandlers.keypress); + window.removeEventListener('blur', this._eventHandlers.blur); + + // Release (key up) all keys that are in a down state + this._allKeysUp(); + + //Log.Debug(">> Keyboard.ungrab"); + }, + + sync: function (e) { + this._handler.syncModifiers(e); + } +}; + +(0, _properties.make_properties)(Keyboard, [['target', 'wo', 'dom'], // DOM element that captures keyboard input +['focused', 'rw', 'bool'], // Capture and send key events + +['onKeyPress', 'rw', 'func'] // Handler for key press/release +]); + +var Mouse = function (defaults) { + this._mouseCaptured = false; + + this._doubleClickTimer = null; + this._lastTouchPos = null; + + // Configuration attributes + (0, _properties.set_defaults)(this, defaults, { + 'target': document, + 'focused': true, + 'touchButton': 1 + }); + + this._eventHandlers = { + 'mousedown': this._handleMouseDown.bind(this), + 'mouseup': this._handleMouseUp.bind(this), + 'mousemove': this._handleMouseMove.bind(this), + 'mousewheel': this._handleMouseWheel.bind(this), + 'mousedisable': this._handleMouseDisable.bind(this) + }; +}; + +Mouse.prototype = { + // private methods + _captureMouse: function () { + // capturing the mouse ensures we get the mouseup event + (0, _events.setCapture)(this._target); + + // some browsers give us mouseup events regardless, + // so if we never captured the mouse, we can disregard the event + this._mouseCaptured = true; + }, + + _releaseMouse: function () { + (0, _events.releaseCapture)(); + this._mouseCaptured = false; + }, + + _resetDoubleClickTimer: function () { + this._doubleClickTimer = null; + }, + + _handleMouseButton: function (e, down) { + if (!this._focused) { + return; + } + + if (this._notify) { + this._notify(e); + } + + var pos = this._getMousePosition(e); + + var bmask; + if (e.touches || e.changedTouches) { + // Touch device + + // When two touches occur within 500 ms of each other and are + // close enough together a double click is triggered. + if (down == 1) { + if (this._doubleClickTimer === null) { + this._lastTouchPos = pos; + } else { + clearTimeout(this._doubleClickTimer); + + // When the distance between the two touches is small enough + // force the position of the latter touch to the position of + // the first. + + var xs = this._lastTouchPos.x - pos.x; + var ys = this._lastTouchPos.y - pos.y; + var d = Math.sqrt(xs * xs + ys * ys); + + // The goal is to trigger on a certain physical width, the + // devicePixelRatio brings us a bit closer but is not optimal. + var threshold = 20 * (window.devicePixelRatio || 1); + if (d < threshold) { + pos = this._lastTouchPos; + } + } + this._doubleClickTimer = setTimeout(this._resetDoubleClickTimer.bind(this), 500); + } + bmask = this._touchButton; + // If bmask is set + } else if (e.which) { + /* everything except IE */ + bmask = 1 << e.button; + } else { + /* IE including 9 */ + bmask = (e.button & 0x1) + // Left + (e.button & 0x2) * 2 + // Right + (e.button & 0x4) / 2; // Middle + } + + if (this._onMouseButton) { + Log.Debug("onMouseButton " + (down ? "down" : "up") + ", x: " + pos.x + ", y: " + pos.y + ", bmask: " + bmask); + this._onMouseButton(pos.x, pos.y, down, bmask); + } + (0, _events.stopEvent)(e); + }, + + _handleMouseDown: function (e) { + this._captureMouse(); + this._handleMouseButton(e, 1); + }, + + _handleMouseUp: function (e) { + if (!this._mouseCaptured) { + return; + } + + this._handleMouseButton(e, 0); + this._releaseMouse(); + }, + + _handleMouseWheel: function (e) { + if (!this._focused) { + return; + } + + if (this._notify) { + this._notify(e); + } + + var pos = this._getMousePosition(e); + + if (this._onMouseButton) { + if (e.deltaX < 0) { + this._onMouseButton(pos.x, pos.y, 1, 1 << 5); + this._onMouseButton(pos.x, pos.y, 0, 1 << 5); + } else if (e.deltaX > 0) { + this._onMouseButton(pos.x, pos.y, 1, 1 << 6); + this._onMouseButton(pos.x, pos.y, 0, 1 << 6); + } + + if (e.deltaY < 0) { + this._onMouseButton(pos.x, pos.y, 1, 1 << 3); + this._onMouseButton(pos.x, pos.y, 0, 1 << 3); + } else if (e.deltaY > 0) { + this._onMouseButton(pos.x, pos.y, 1, 1 << 4); + this._onMouseButton(pos.x, pos.y, 0, 1 << 4); + } + } + + (0, _events.stopEvent)(e); + }, + + _handleMouseMove: function (e) { + if (!this._focused) { + return; + } + + if (this._notify) { + this._notify(e); + } + + var pos = this._getMousePosition(e); + if (this._onMouseMove) { + this._onMouseMove(pos.x, pos.y); + } + (0, _events.stopEvent)(e); + }, + + _handleMouseDisable: function (e) { + if (!this._focused) { + return; + } + + /* + * Stop propagation if inside canvas area + * Note: This is only needed for the 'click' event as it fails + * to fire properly for the target element so we have + * to listen on the document element instead. + */ + if (e.target == this._target) { + (0, _events.stopEvent)(e); + } + }, + + // Return coordinates relative to target + _getMousePosition: function (e) { + e = (0, _events.getPointerEvent)(e); + var bounds = this._target.getBoundingClientRect(); + var x, y; + // Clip to target bounds + if (e.clientX < bounds.left) { + x = 0; + } else if (e.clientX >= bounds.right) { + x = bounds.width - 1; + } else { + x = e.clientX - bounds.left; + } + if (e.clientY < bounds.top) { + y = 0; + } else if (e.clientY >= bounds.bottom) { + y = bounds.height - 1; + } else { + y = e.clientY - bounds.top; + } + return { x: x, y: y }; + }, + + // Public methods + grab: function () { + var c = this._target; + + if (_browsers.isTouchDevice) { + c.addEventListener('touchstart', this._eventHandlers.mousedown); + window.addEventListener('touchend', this._eventHandlers.mouseup); + c.addEventListener('touchend', this._eventHandlers.mouseup); + c.addEventListener('touchmove', this._eventHandlers.mousemove); + } + c.addEventListener('mousedown', this._eventHandlers.mousedown); + window.addEventListener('mouseup', this._eventHandlers.mouseup); + c.addEventListener('mouseup', this._eventHandlers.mouseup); + c.addEventListener('mousemove', this._eventHandlers.mousemove); + c.addEventListener('wheel', this._eventHandlers.mousewheel); + + /* Prevent middle-click pasting (see above for why we bind to document) */ + document.addEventListener('click', this._eventHandlers.mousedisable); + + /* preventDefault() on mousedown doesn't stop this event for some + reason so we have to explicitly block it */ + c.addEventListener('contextmenu', this._eventHandlers.mousedisable); + }, + + ungrab: function () { + var c = this._target; + + if (_browsers.isTouchDevice) { + c.removeEventListener('touchstart', this._eventHandlers.mousedown); + window.removeEventListener('touchend', this._eventHandlers.mouseup); + c.removeEventListener('touchend', this._eventHandlers.mouseup); + c.removeEventListener('touchmove', this._eventHandlers.mousemove); + } + c.removeEventListener('mousedown', this._eventHandlers.mousedown); + window.removeEventListener('mouseup', this._eventHandlers.mouseup); + c.removeEventListener('mouseup', this._eventHandlers.mouseup); + c.removeEventListener('mousemove', this._eventHandlers.mousemove); + c.removeEventListener('wheel', this._eventHandlers.mousewheel); + + document.removeEventListener('click', this._eventHandlers.mousedisable); + + c.removeEventListener('contextmenu', this._eventHandlers.mousedisable); + } +}; + +(0, _properties.make_properties)(Mouse, [['target', 'ro', 'dom'], // DOM element that captures mouse input +['notify', 'ro', 'func'], // Function to call to notify whenever a mouse event is received +['focused', 'rw', 'bool'], // Capture and send mouse clicks/movement + +['onMouseButton', 'rw', 'func'], // Handler for mouse button click/release +['onMouseMove', 'rw', 'func'], // Handler for mouse movement +['touchButton', 'rw', 'int'] // Button mask (1, 2, 4) for touch devices (0 means ignore clicks) +]); + +exports.Keyboard = Keyboard; +exports.Mouse = Mouse; +},{"../util/browsers.js":11,"../util/events.js":12,"../util/logging.js":14,"../util/properties.js":15,"./util.js":8}],6:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = { + XK_VoidSymbol: 0xffffff, /* Void symbol */ + + XK_BackSpace: 0xff08, /* Back space, back char */ + XK_Tab: 0xff09, + XK_Linefeed: 0xff0a, /* Linefeed, LF */ + XK_Clear: 0xff0b, + XK_Return: 0xff0d, /* Return, enter */ + XK_Pause: 0xff13, /* Pause, hold */ + XK_Scroll_Lock: 0xff14, + XK_Sys_Req: 0xff15, + XK_Escape: 0xff1b, + XK_Delete: 0xffff, /* Delete, rubout */ + + /* Cursor control & motion */ + + XK_Home: 0xff50, + XK_Left: 0xff51, /* Move left, left arrow */ + XK_Up: 0xff52, /* Move up, up arrow */ + XK_Right: 0xff53, /* Move right, right arrow */ + XK_Down: 0xff54, /* Move down, down arrow */ + XK_Prior: 0xff55, /* Prior, previous */ + XK_Page_Up: 0xff55, + XK_Next: 0xff56, /* Next */ + XK_Page_Down: 0xff56, + XK_End: 0xff57, /* EOL */ + XK_Begin: 0xff58, /* BOL */ + + /* Misc functions */ + + XK_Select: 0xff60, /* Select, mark */ + XK_Print: 0xff61, + XK_Execute: 0xff62, /* Execute, run, do */ + XK_Insert: 0xff63, /* Insert, insert here */ + XK_Undo: 0xff65, + XK_Redo: 0xff66, /* Redo, again */ + XK_Menu: 0xff67, + XK_Find: 0xff68, /* Find, search */ + XK_Cancel: 0xff69, /* Cancel, stop, abort, exit */ + XK_Help: 0xff6a, /* Help */ + XK_Break: 0xff6b, + XK_Mode_switch: 0xff7e, /* Character set switch */ + XK_script_switch: 0xff7e, /* Alias for mode_switch */ + XK_Num_Lock: 0xff7f, + + /* Keypad functions, keypad numbers cleverly chosen to map to ASCII */ + + XK_KP_Space: 0xff80, /* Space */ + XK_KP_Tab: 0xff89, + XK_KP_Enter: 0xff8d, /* Enter */ + XK_KP_F1: 0xff91, /* PF1, KP_A, ... */ + XK_KP_F2: 0xff92, + XK_KP_F3: 0xff93, + XK_KP_F4: 0xff94, + XK_KP_Home: 0xff95, + XK_KP_Left: 0xff96, + XK_KP_Up: 0xff97, + XK_KP_Right: 0xff98, + XK_KP_Down: 0xff99, + XK_KP_Prior: 0xff9a, + XK_KP_Page_Up: 0xff9a, + XK_KP_Next: 0xff9b, + XK_KP_Page_Down: 0xff9b, + XK_KP_End: 0xff9c, + XK_KP_Begin: 0xff9d, + XK_KP_Insert: 0xff9e, + XK_KP_Delete: 0xff9f, + XK_KP_Equal: 0xffbd, /* Equals */ + XK_KP_Multiply: 0xffaa, + XK_KP_Add: 0xffab, + XK_KP_Separator: 0xffac, /* Separator, often comma */ + XK_KP_Subtract: 0xffad, + XK_KP_Decimal: 0xffae, + XK_KP_Divide: 0xffaf, + + XK_KP_0: 0xffb0, + XK_KP_1: 0xffb1, + XK_KP_2: 0xffb2, + XK_KP_3: 0xffb3, + XK_KP_4: 0xffb4, + XK_KP_5: 0xffb5, + XK_KP_6: 0xffb6, + XK_KP_7: 0xffb7, + XK_KP_8: 0xffb8, + XK_KP_9: 0xffb9, + + /* + * Auxiliary functions; note the duplicate definitions for left and right + * function keys; Sun keyboards and a few other manufacturers have such + * function key groups on the left and/or right sides of the keyboard. + * We've not found a keyboard with more than 35 function keys total. + */ + + XK_F1: 0xffbe, + XK_F2: 0xffbf, + XK_F3: 0xffc0, + XK_F4: 0xffc1, + XK_F5: 0xffc2, + XK_F6: 0xffc3, + XK_F7: 0xffc4, + XK_F8: 0xffc5, + XK_F9: 0xffc6, + XK_F10: 0xffc7, + XK_F11: 0xffc8, + XK_L1: 0xffc8, + XK_F12: 0xffc9, + XK_L2: 0xffc9, + XK_F13: 0xffca, + XK_L3: 0xffca, + XK_F14: 0xffcb, + XK_L4: 0xffcb, + XK_F15: 0xffcc, + XK_L5: 0xffcc, + XK_F16: 0xffcd, + XK_L6: 0xffcd, + XK_F17: 0xffce, + XK_L7: 0xffce, + XK_F18: 0xffcf, + XK_L8: 0xffcf, + XK_F19: 0xffd0, + XK_L9: 0xffd0, + XK_F20: 0xffd1, + XK_L10: 0xffd1, + XK_F21: 0xffd2, + XK_R1: 0xffd2, + XK_F22: 0xffd3, + XK_R2: 0xffd3, + XK_F23: 0xffd4, + XK_R3: 0xffd4, + XK_F24: 0xffd5, + XK_R4: 0xffd5, + XK_F25: 0xffd6, + XK_R5: 0xffd6, + XK_F26: 0xffd7, + XK_R6: 0xffd7, + XK_F27: 0xffd8, + XK_R7: 0xffd8, + XK_F28: 0xffd9, + XK_R8: 0xffd9, + XK_F29: 0xffda, + XK_R9: 0xffda, + XK_F30: 0xffdb, + XK_R10: 0xffdb, + XK_F31: 0xffdc, + XK_R11: 0xffdc, + XK_F32: 0xffdd, + XK_R12: 0xffdd, + XK_F33: 0xffde, + XK_R13: 0xffde, + XK_F34: 0xffdf, + XK_R14: 0xffdf, + XK_F35: 0xffe0, + XK_R15: 0xffe0, + + /* Modifiers */ + + XK_Shift_L: 0xffe1, /* Left shift */ + XK_Shift_R: 0xffe2, /* Right shift */ + XK_Control_L: 0xffe3, /* Left control */ + XK_Control_R: 0xffe4, /* Right control */ + XK_Caps_Lock: 0xffe5, /* Caps lock */ + XK_Shift_Lock: 0xffe6, /* Shift lock */ + + XK_Meta_L: 0xffe7, /* Left meta */ + XK_Meta_R: 0xffe8, /* Right meta */ + XK_Alt_L: 0xffe9, /* Left alt */ + XK_Alt_R: 0xffea, /* Right alt */ + XK_Super_L: 0xffeb, /* Left super */ + XK_Super_R: 0xffec, /* Right super */ + XK_Hyper_L: 0xffed, /* Left hyper */ + XK_Hyper_R: 0xffee, /* Right hyper */ + + XK_ISO_Level3_Shift: 0xfe03, /* AltGr */ + + /* + * Latin 1 + * (ISO/IEC 8859-1: Unicode U+0020..U+00FF) + * Byte 3: 0 + */ + + XK_space: 0x0020, /* U+0020 SPACE */ + XK_exclam: 0x0021, /* U+0021 EXCLAMATION MARK */ + XK_quotedbl: 0x0022, /* U+0022 QUOTATION MARK */ + XK_numbersign: 0x0023, /* U+0023 NUMBER SIGN */ + XK_dollar: 0x0024, /* U+0024 DOLLAR SIGN */ + XK_percent: 0x0025, /* U+0025 PERCENT SIGN */ + XK_ampersand: 0x0026, /* U+0026 AMPERSAND */ + XK_apostrophe: 0x0027, /* U+0027 APOSTROPHE */ + XK_quoteright: 0x0027, /* deprecated */ + XK_parenleft: 0x0028, /* U+0028 LEFT PARENTHESIS */ + XK_parenright: 0x0029, /* U+0029 RIGHT PARENTHESIS */ + XK_asterisk: 0x002a, /* U+002A ASTERISK */ + XK_plus: 0x002b, /* U+002B PLUS SIGN */ + XK_comma: 0x002c, /* U+002C COMMA */ + XK_minus: 0x002d, /* U+002D HYPHEN-MINUS */ + XK_period: 0x002e, /* U+002E FULL STOP */ + XK_slash: 0x002f, /* U+002F SOLIDUS */ + XK_0: 0x0030, /* U+0030 DIGIT ZERO */ + XK_1: 0x0031, /* U+0031 DIGIT ONE */ + XK_2: 0x0032, /* U+0032 DIGIT TWO */ + XK_3: 0x0033, /* U+0033 DIGIT THREE */ + XK_4: 0x0034, /* U+0034 DIGIT FOUR */ + XK_5: 0x0035, /* U+0035 DIGIT FIVE */ + XK_6: 0x0036, /* U+0036 DIGIT SIX */ + XK_7: 0x0037, /* U+0037 DIGIT SEVEN */ + XK_8: 0x0038, /* U+0038 DIGIT EIGHT */ + XK_9: 0x0039, /* U+0039 DIGIT NINE */ + XK_colon: 0x003a, /* U+003A COLON */ + XK_semicolon: 0x003b, /* U+003B SEMICOLON */ + XK_less: 0x003c, /* U+003C LESS-THAN SIGN */ + XK_equal: 0x003d, /* U+003D EQUALS SIGN */ + XK_greater: 0x003e, /* U+003E GREATER-THAN SIGN */ + XK_question: 0x003f, /* U+003F QUESTION MARK */ + XK_at: 0x0040, /* U+0040 COMMERCIAL AT */ + XK_A: 0x0041, /* U+0041 LATIN CAPITAL LETTER A */ + XK_B: 0x0042, /* U+0042 LATIN CAPITAL LETTER B */ + XK_C: 0x0043, /* U+0043 LATIN CAPITAL LETTER C */ + XK_D: 0x0044, /* U+0044 LATIN CAPITAL LETTER D */ + XK_E: 0x0045, /* U+0045 LATIN CAPITAL LETTER E */ + XK_F: 0x0046, /* U+0046 LATIN CAPITAL LETTER F */ + XK_G: 0x0047, /* U+0047 LATIN CAPITAL LETTER G */ + XK_H: 0x0048, /* U+0048 LATIN CAPITAL LETTER H */ + XK_I: 0x0049, /* U+0049 LATIN CAPITAL LETTER I */ + XK_J: 0x004a, /* U+004A LATIN CAPITAL LETTER J */ + XK_K: 0x004b, /* U+004B LATIN CAPITAL LETTER K */ + XK_L: 0x004c, /* U+004C LATIN CAPITAL LETTER L */ + XK_M: 0x004d, /* U+004D LATIN CAPITAL LETTER M */ + XK_N: 0x004e, /* U+004E LATIN CAPITAL LETTER N */ + XK_O: 0x004f, /* U+004F LATIN CAPITAL LETTER O */ + XK_P: 0x0050, /* U+0050 LATIN CAPITAL LETTER P */ + XK_Q: 0x0051, /* U+0051 LATIN CAPITAL LETTER Q */ + XK_R: 0x0052, /* U+0052 LATIN CAPITAL LETTER R */ + XK_S: 0x0053, /* U+0053 LATIN CAPITAL LETTER S */ + XK_T: 0x0054, /* U+0054 LATIN CAPITAL LETTER T */ + XK_U: 0x0055, /* U+0055 LATIN CAPITAL LETTER U */ + XK_V: 0x0056, /* U+0056 LATIN CAPITAL LETTER V */ + XK_W: 0x0057, /* U+0057 LATIN CAPITAL LETTER W */ + XK_X: 0x0058, /* U+0058 LATIN CAPITAL LETTER X */ + XK_Y: 0x0059, /* U+0059 LATIN CAPITAL LETTER Y */ + XK_Z: 0x005a, /* U+005A LATIN CAPITAL LETTER Z */ + XK_bracketleft: 0x005b, /* U+005B LEFT SQUARE BRACKET */ + XK_backslash: 0x005c, /* U+005C REVERSE SOLIDUS */ + XK_bracketright: 0x005d, /* U+005D RIGHT SQUARE BRACKET */ + XK_asciicircum: 0x005e, /* U+005E CIRCUMFLEX ACCENT */ + XK_underscore: 0x005f, /* U+005F LOW LINE */ + XK_grave: 0x0060, /* U+0060 GRAVE ACCENT */ + XK_quoteleft: 0x0060, /* deprecated */ + XK_a: 0x0061, /* U+0061 LATIN SMALL LETTER A */ + XK_b: 0x0062, /* U+0062 LATIN SMALL LETTER B */ + XK_c: 0x0063, /* U+0063 LATIN SMALL LETTER C */ + XK_d: 0x0064, /* U+0064 LATIN SMALL LETTER D */ + XK_e: 0x0065, /* U+0065 LATIN SMALL LETTER E */ + XK_f: 0x0066, /* U+0066 LATIN SMALL LETTER F */ + XK_g: 0x0067, /* U+0067 LATIN SMALL LETTER G */ + XK_h: 0x0068, /* U+0068 LATIN SMALL LETTER H */ + XK_i: 0x0069, /* U+0069 LATIN SMALL LETTER I */ + XK_j: 0x006a, /* U+006A LATIN SMALL LETTER J */ + XK_k: 0x006b, /* U+006B LATIN SMALL LETTER K */ + XK_l: 0x006c, /* U+006C LATIN SMALL LETTER L */ + XK_m: 0x006d, /* U+006D LATIN SMALL LETTER M */ + XK_n: 0x006e, /* U+006E LATIN SMALL LETTER N */ + XK_o: 0x006f, /* U+006F LATIN SMALL LETTER O */ + XK_p: 0x0070, /* U+0070 LATIN SMALL LETTER P */ + XK_q: 0x0071, /* U+0071 LATIN SMALL LETTER Q */ + XK_r: 0x0072, /* U+0072 LATIN SMALL LETTER R */ + XK_s: 0x0073, /* U+0073 LATIN SMALL LETTER S */ + XK_t: 0x0074, /* U+0074 LATIN SMALL LETTER T */ + XK_u: 0x0075, /* U+0075 LATIN SMALL LETTER U */ + XK_v: 0x0076, /* U+0076 LATIN SMALL LETTER V */ + XK_w: 0x0077, /* U+0077 LATIN SMALL LETTER W */ + XK_x: 0x0078, /* U+0078 LATIN SMALL LETTER X */ + XK_y: 0x0079, /* U+0079 LATIN SMALL LETTER Y */ + XK_z: 0x007a, /* U+007A LATIN SMALL LETTER Z */ + XK_braceleft: 0x007b, /* U+007B LEFT CURLY BRACKET */ + XK_bar: 0x007c, /* U+007C VERTICAL LINE */ + XK_braceright: 0x007d, /* U+007D RIGHT CURLY BRACKET */ + XK_asciitilde: 0x007e, /* U+007E TILDE */ + + XK_nobreakspace: 0x00a0, /* U+00A0 NO-BREAK SPACE */ + XK_exclamdown: 0x00a1, /* U+00A1 INVERTED EXCLAMATION MARK */ + XK_cent: 0x00a2, /* U+00A2 CENT SIGN */ + XK_sterling: 0x00a3, /* U+00A3 POUND SIGN */ + XK_currency: 0x00a4, /* U+00A4 CURRENCY SIGN */ + XK_yen: 0x00a5, /* U+00A5 YEN SIGN */ + XK_brokenbar: 0x00a6, /* U+00A6 BROKEN BAR */ + XK_section: 0x00a7, /* U+00A7 SECTION SIGN */ + XK_diaeresis: 0x00a8, /* U+00A8 DIAERESIS */ + XK_copyright: 0x00a9, /* U+00A9 COPYRIGHT SIGN */ + XK_ordfeminine: 0x00aa, /* U+00AA FEMININE ORDINAL INDICATOR */ + XK_guillemotleft: 0x00ab, /* U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */ + XK_notsign: 0x00ac, /* U+00AC NOT SIGN */ + XK_hyphen: 0x00ad, /* U+00AD SOFT HYPHEN */ + XK_registered: 0x00ae, /* U+00AE REGISTERED SIGN */ + XK_macron: 0x00af, /* U+00AF MACRON */ + XK_degree: 0x00b0, /* U+00B0 DEGREE SIGN */ + XK_plusminus: 0x00b1, /* U+00B1 PLUS-MINUS SIGN */ + XK_twosuperior: 0x00b2, /* U+00B2 SUPERSCRIPT TWO */ + XK_threesuperior: 0x00b3, /* U+00B3 SUPERSCRIPT THREE */ + XK_acute: 0x00b4, /* U+00B4 ACUTE ACCENT */ + XK_mu: 0x00b5, /* U+00B5 MICRO SIGN */ + XK_paragraph: 0x00b6, /* U+00B6 PILCROW SIGN */ + XK_periodcentered: 0x00b7, /* U+00B7 MIDDLE DOT */ + XK_cedilla: 0x00b8, /* U+00B8 CEDILLA */ + XK_onesuperior: 0x00b9, /* U+00B9 SUPERSCRIPT ONE */ + XK_masculine: 0x00ba, /* U+00BA MASCULINE ORDINAL INDICATOR */ + XK_guillemotright: 0x00bb, /* U+00BB RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */ + XK_onequarter: 0x00bc, /* U+00BC VULGAR FRACTION ONE QUARTER */ + XK_onehalf: 0x00bd, /* U+00BD VULGAR FRACTION ONE HALF */ + XK_threequarters: 0x00be, /* U+00BE VULGAR FRACTION THREE QUARTERS */ + XK_questiondown: 0x00bf, /* U+00BF INVERTED QUESTION MARK */ + XK_Agrave: 0x00c0, /* U+00C0 LATIN CAPITAL LETTER A WITH GRAVE */ + XK_Aacute: 0x00c1, /* U+00C1 LATIN CAPITAL LETTER A WITH ACUTE */ + XK_Acircumflex: 0x00c2, /* U+00C2 LATIN CAPITAL LETTER A WITH CIRCUMFLEX */ + XK_Atilde: 0x00c3, /* U+00C3 LATIN CAPITAL LETTER A WITH TILDE */ + XK_Adiaeresis: 0x00c4, /* U+00C4 LATIN CAPITAL LETTER A WITH DIAERESIS */ + XK_Aring: 0x00c5, /* U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE */ + XK_AE: 0x00c6, /* U+00C6 LATIN CAPITAL LETTER AE */ + XK_Ccedilla: 0x00c7, /* U+00C7 LATIN CAPITAL LETTER C WITH CEDILLA */ + XK_Egrave: 0x00c8, /* U+00C8 LATIN CAPITAL LETTER E WITH GRAVE */ + XK_Eacute: 0x00c9, /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ + XK_Ecircumflex: 0x00ca, /* U+00CA LATIN CAPITAL LETTER E WITH CIRCUMFLEX */ + XK_Ediaeresis: 0x00cb, /* U+00CB LATIN CAPITAL LETTER E WITH DIAERESIS */ + XK_Igrave: 0x00cc, /* U+00CC LATIN CAPITAL LETTER I WITH GRAVE */ + XK_Iacute: 0x00cd, /* U+00CD LATIN CAPITAL LETTER I WITH ACUTE */ + XK_Icircumflex: 0x00ce, /* U+00CE LATIN CAPITAL LETTER I WITH CIRCUMFLEX */ + XK_Idiaeresis: 0x00cf, /* U+00CF LATIN CAPITAL LETTER I WITH DIAERESIS */ + XK_ETH: 0x00d0, /* U+00D0 LATIN CAPITAL LETTER ETH */ + XK_Eth: 0x00d0, /* deprecated */ + XK_Ntilde: 0x00d1, /* U+00D1 LATIN CAPITAL LETTER N WITH TILDE */ + XK_Ograve: 0x00d2, /* U+00D2 LATIN CAPITAL LETTER O WITH GRAVE */ + XK_Oacute: 0x00d3, /* U+00D3 LATIN CAPITAL LETTER O WITH ACUTE */ + XK_Ocircumflex: 0x00d4, /* U+00D4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX */ + XK_Otilde: 0x00d5, /* U+00D5 LATIN CAPITAL LETTER O WITH TILDE */ + XK_Odiaeresis: 0x00d6, /* U+00D6 LATIN CAPITAL LETTER O WITH DIAERESIS */ + XK_multiply: 0x00d7, /* U+00D7 MULTIPLICATION SIGN */ + XK_Oslash: 0x00d8, /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + XK_Ooblique: 0x00d8, /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + XK_Ugrave: 0x00d9, /* U+00D9 LATIN CAPITAL LETTER U WITH GRAVE */ + XK_Uacute: 0x00da, /* U+00DA LATIN CAPITAL LETTER U WITH ACUTE */ + XK_Ucircumflex: 0x00db, /* U+00DB LATIN CAPITAL LETTER U WITH CIRCUMFLEX */ + XK_Udiaeresis: 0x00dc, /* U+00DC LATIN CAPITAL LETTER U WITH DIAERESIS */ + XK_Yacute: 0x00dd, /* U+00DD LATIN CAPITAL LETTER Y WITH ACUTE */ + XK_THORN: 0x00de, /* U+00DE LATIN CAPITAL LETTER THORN */ + XK_Thorn: 0x00de, /* deprecated */ + XK_ssharp: 0x00df, /* U+00DF LATIN SMALL LETTER SHARP S */ + XK_agrave: 0x00e0, /* U+00E0 LATIN SMALL LETTER A WITH GRAVE */ + XK_aacute: 0x00e1, /* U+00E1 LATIN SMALL LETTER A WITH ACUTE */ + XK_acircumflex: 0x00e2, /* U+00E2 LATIN SMALL LETTER A WITH CIRCUMFLEX */ + XK_atilde: 0x00e3, /* U+00E3 LATIN SMALL LETTER A WITH TILDE */ + XK_adiaeresis: 0x00e4, /* U+00E4 LATIN SMALL LETTER A WITH DIAERESIS */ + XK_aring: 0x00e5, /* U+00E5 LATIN SMALL LETTER A WITH RING ABOVE */ + XK_ae: 0x00e6, /* U+00E6 LATIN SMALL LETTER AE */ + XK_ccedilla: 0x00e7, /* U+00E7 LATIN SMALL LETTER C WITH CEDILLA */ + XK_egrave: 0x00e8, /* U+00E8 LATIN SMALL LETTER E WITH GRAVE */ + XK_eacute: 0x00e9, /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */ + XK_ecircumflex: 0x00ea, /* U+00EA LATIN SMALL LETTER E WITH CIRCUMFLEX */ + XK_ediaeresis: 0x00eb, /* U+00EB LATIN SMALL LETTER E WITH DIAERESIS */ + XK_igrave: 0x00ec, /* U+00EC LATIN SMALL LETTER I WITH GRAVE */ + XK_iacute: 0x00ed, /* U+00ED LATIN SMALL LETTER I WITH ACUTE */ + XK_icircumflex: 0x00ee, /* U+00EE LATIN SMALL LETTER I WITH CIRCUMFLEX */ + XK_idiaeresis: 0x00ef, /* U+00EF LATIN SMALL LETTER I WITH DIAERESIS */ + XK_eth: 0x00f0, /* U+00F0 LATIN SMALL LETTER ETH */ + XK_ntilde: 0x00f1, /* U+00F1 LATIN SMALL LETTER N WITH TILDE */ + XK_ograve: 0x00f2, /* U+00F2 LATIN SMALL LETTER O WITH GRAVE */ + XK_oacute: 0x00f3, /* U+00F3 LATIN SMALL LETTER O WITH ACUTE */ + XK_ocircumflex: 0x00f4, /* U+00F4 LATIN SMALL LETTER O WITH CIRCUMFLEX */ + XK_otilde: 0x00f5, /* U+00F5 LATIN SMALL LETTER O WITH TILDE */ + XK_odiaeresis: 0x00f6, /* U+00F6 LATIN SMALL LETTER O WITH DIAERESIS */ + XK_division: 0x00f7, /* U+00F7 DIVISION SIGN */ + XK_oslash: 0x00f8, /* U+00F8 LATIN SMALL LETTER O WITH STROKE */ + XK_ooblique: 0x00f8, /* U+00F8 LATIN SMALL LETTER O WITH STROKE */ + XK_ugrave: 0x00f9, /* U+00F9 LATIN SMALL LETTER U WITH GRAVE */ + XK_uacute: 0x00fa, /* U+00FA LATIN SMALL LETTER U WITH ACUTE */ + XK_ucircumflex: 0x00fb, /* U+00FB LATIN SMALL LETTER U WITH CIRCUMFLEX */ + XK_udiaeresis: 0x00fc, /* U+00FC LATIN SMALL LETTER U WITH DIAERESIS */ + XK_yacute: 0x00fd, /* U+00FD LATIN SMALL LETTER Y WITH ACUTE */ + XK_thorn: 0x00fe, /* U+00FE LATIN SMALL LETTER THORN */ + XK_ydiaeresis: 0x00ff }; +},{}],7:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +// This file describes mappings from Unicode codepoints to the keysym values +// (and optionally, key names) expected by the RFB protocol +// How this file was generated: +// node /Users/jalf/dev/mi/novnc/utils/parse.js /opt/X11/include/X11/keysymdef.h + +var keynames = null; +var codepoints = { "32": 32, "33": 33, "34": 34, "35": 35, "36": 36, "37": 37, "38": 38, "39": 39, "40": 40, "41": 41, "42": 42, "43": 43, "44": 44, "45": 45, "46": 46, "47": 47, "48": 48, "49": 49, "50": 50, "51": 51, "52": 52, "53": 53, "54": 54, "55": 55, "56": 56, "57": 57, "58": 58, "59": 59, "60": 60, "61": 61, "62": 62, "63": 63, "64": 64, "65": 65, "66": 66, "67": 67, "68": 68, "69": 69, "70": 70, "71": 71, "72": 72, "73": 73, "74": 74, "75": 75, "76": 76, "77": 77, "78": 78, "79": 79, "80": 80, "81": 81, "82": 82, "83": 83, "84": 84, "85": 85, "86": 86, "87": 87, "88": 88, "89": 89, "90": 90, "91": 91, "92": 92, "93": 93, "94": 94, "95": 95, "96": 96, "97": 97, "98": 98, "99": 99, "100": 100, "101": 101, "102": 102, "103": 103, "104": 104, "105": 105, "106": 106, "107": 107, "108": 108, "109": 109, "110": 110, "111": 111, "112": 112, "113": 113, "114": 114, "115": 115, "116": 116, "117": 117, "118": 118, "119": 119, "120": 120, "121": 121, "122": 122, "123": 123, "124": 124, "125": 125, "126": 126, "160": 160, "161": 161, "162": 162, "163": 163, "164": 164, "165": 165, "166": 166, "167": 167, "168": 168, "169": 169, "170": 170, "171": 171, "172": 172, "173": 173, "174": 174, "175": 175, "176": 176, "177": 177, "178": 178, "179": 179, "180": 180, "181": 181, "182": 182, "183": 183, "184": 184, "185": 185, "186": 186, "187": 187, "188": 188, "189": 189, "190": 190, "191": 191, "192": 192, "193": 193, "194": 194, "195": 195, "196": 196, "197": 197, "198": 198, "199": 199, "200": 200, "201": 201, "202": 202, "203": 203, "204": 204, "205": 205, "206": 206, "207": 207, "208": 208, "209": 209, "210": 210, "211": 211, "212": 212, "213": 213, "214": 214, "215": 215, "216": 216, "217": 217, "218": 218, "219": 219, "220": 220, "221": 221, "222": 222, "223": 223, "224": 224, "225": 225, "226": 226, "227": 227, "228": 228, "229": 229, "230": 230, "231": 231, "232": 232, "233": 233, "234": 234, "235": 235, "236": 236, "237": 237, "238": 238, "239": 239, "240": 240, "241": 241, "242": 242, "243": 243, "244": 244, "245": 245, "246": 246, "247": 247, "248": 248, "249": 249, "250": 250, "251": 251, "252": 252, "253": 253, "254": 254, "255": 255, "256": 960, "257": 992, "258": 451, "259": 483, "260": 417, "261": 433, "262": 454, "263": 486, "264": 710, "265": 742, "266": 709, "267": 741, "268": 456, "269": 488, "270": 463, "271": 495, "272": 464, "273": 496, "274": 938, "275": 954, "278": 972, "279": 1004, "280": 458, "281": 490, "282": 460, "283": 492, "284": 728, "285": 760, "286": 683, "287": 699, "288": 725, "289": 757, "290": 939, "291": 955, "292": 678, "293": 694, "294": 673, "295": 689, "296": 933, "297": 949, "298": 975, "299": 1007, "300": 16777516, "301": 16777517, "302": 967, "303": 999, "304": 681, "305": 697, "308": 684, "309": 700, "310": 979, "311": 1011, "312": 930, "313": 453, "314": 485, "315": 934, "316": 950, "317": 421, "318": 437, "321": 419, "322": 435, "323": 465, "324": 497, "325": 977, "326": 1009, "327": 466, "328": 498, "330": 957, "331": 959, "332": 978, "333": 1010, "336": 469, "337": 501, "338": 5052, "339": 5053, "340": 448, "341": 480, "342": 931, "343": 947, "344": 472, "345": 504, "346": 422, "347": 438, "348": 734, "349": 766, "350": 426, "351": 442, "352": 425, "353": 441, "354": 478, "355": 510, "356": 427, "357": 443, "358": 940, "359": 956, "360": 989, "361": 1021, "362": 990, "363": 1022, "364": 733, "365": 765, "366": 473, "367": 505, "368": 475, "369": 507, "370": 985, "371": 1017, "372": 16777588, "373": 16777589, "374": 16777590, "375": 16777591, "376": 5054, "377": 428, "378": 444, "379": 431, "380": 447, "381": 430, "382": 446, "399": 16777615, "402": 2294, "415": 16777631, "416": 16777632, "417": 16777633, "431": 16777647, "432": 16777648, "437": 16777653, "438": 16777654, "439": 16777655, "466": 16777681, "486": 16777702, "487": 16777703, "601": 16777817, "629": 16777845, "658": 16777874, "711": 439, "728": 418, "729": 511, "731": 434, "733": 445, "901": 1966, "902": 1953, "904": 1954, "905": 1955, "906": 1956, "908": 1959, "910": 1960, "911": 1963, "912": 1974, "913": 1985, "914": 1986, "915": 1987, "916": 1988, "917": 1989, "918": 1990, "919": 1991, "920": 1992, "921": 1993, "922": 1994, "923": 1995, "924": 1996, "925": 1997, "926": 1998, "927": 1999, "928": 2000, "929": 2001, "931": 2002, "932": 2004, "933": 2005, "934": 2006, "935": 2007, "936": 2008, "937": 2009, "938": 1957, "939": 1961, "940": 1969, "941": 1970, "942": 1971, "943": 1972, "944": 1978, "945": 2017, "946": 2018, "947": 2019, "948": 2020, "949": 2021, "950": 2022, "951": 2023, "952": 2024, "953": 2025, "954": 2026, "955": 2027, "956": 2028, "957": 2029, "958": 2030, "959": 2031, "960": 2032, "961": 2033, "962": 2035, "963": 2034, "964": 2036, "965": 2037, "966": 2038, "967": 2039, "968": 2040, "969": 2041, "970": 1973, "971": 1977, "972": 1975, "973": 1976, "974": 1979, "1025": 1715, "1026": 1713, "1027": 1714, "1028": 1716, "1029": 1717, "1030": 1718, "1031": 1719, "1032": 1720, "1033": 1721, "1034": 1722, "1035": 1723, "1036": 1724, "1038": 1726, "1039": 1727, "1040": 1761, "1041": 1762, "1042": 1783, "1043": 1767, "1044": 1764, "1045": 1765, "1046": 1782, "1047": 1786, "1048": 1769, "1049": 1770, "1050": 1771, "1051": 1772, "1052": 1773, "1053": 1774, "1054": 1775, "1055": 1776, "1056": 1778, "1057": 1779, "1058": 1780, "1059": 1781, "1060": 1766, "1061": 1768, "1062": 1763, "1063": 1790, "1064": 1787, "1065": 1789, "1066": 1791, "1067": 1785, "1068": 1784, "1069": 1788, "1070": 1760, "1071": 1777, "1072": 1729, "1073": 1730, "1074": 1751, "1075": 1735, "1076": 1732, "1077": 1733, "1078": 1750, "1079": 1754, "1080": 1737, "1081": 1738, "1082": 1739, "1083": 1740, "1084": 1741, "1085": 1742, "1086": 1743, "1087": 1744, "1088": 1746, "1089": 1747, "1090": 1748, "1091": 1749, "1092": 1734, "1093": 1736, "1094": 1731, "1095": 1758, "1096": 1755, "1097": 1757, "1098": 1759, "1099": 1753, "1100": 1752, "1101": 1756, "1102": 1728, "1103": 1745, "1105": 1699, "1106": 1697, "1107": 1698, "1108": 1700, "1109": 1701, "1110": 1702, "1111": 1703, "1112": 1704, "1113": 1705, "1114": 1706, "1115": 1707, "1116": 1708, "1118": 1710, "1119": 1711, "1168": 1725, "1169": 1709, "1170": 16778386, "1171": 16778387, "1174": 16778390, "1175": 16778391, "1178": 16778394, "1179": 16778395, "1180": 16778396, "1181": 16778397, "1186": 16778402, "1187": 16778403, "1198": 16778414, "1199": 16778415, "1200": 16778416, "1201": 16778417, "1202": 16778418, "1203": 16778419, "1206": 16778422, "1207": 16778423, "1208": 16778424, "1209": 16778425, "1210": 16778426, "1211": 16778427, "1240": 16778456, "1241": 16778457, "1250": 16778466, "1251": 16778467, "1256": 16778472, "1257": 16778473, "1262": 16778478, "1263": 16778479, "1329": 16778545, "1330": 16778546, "1331": 16778547, "1332": 16778548, "1333": 16778549, "1334": 16778550, "1335": 16778551, "1336": 16778552, "1337": 16778553, "1338": 16778554, "1339": 16778555, "1340": 16778556, "1341": 16778557, "1342": 16778558, "1343": 16778559, "1344": 16778560, "1345": 16778561, "1346": 16778562, "1347": 16778563, "1348": 16778564, "1349": 16778565, "1350": 16778566, "1351": 16778567, "1352": 16778568, "1353": 16778569, "1354": 16778570, "1355": 16778571, "1356": 16778572, "1357": 16778573, "1358": 16778574, "1359": 16778575, "1360": 16778576, "1361": 16778577, "1362": 16778578, "1363": 16778579, "1364": 16778580, "1365": 16778581, "1366": 16778582, "1370": 16778586, "1371": 16778587, "1372": 16778588, "1373": 16778589, "1374": 16778590, "1377": 16778593, "1378": 16778594, "1379": 16778595, "1380": 16778596, "1381": 16778597, "1382": 16778598, "1383": 16778599, "1384": 16778600, "1385": 16778601, "1386": 16778602, "1387": 16778603, "1388": 16778604, "1389": 16778605, "1390": 16778606, "1391": 16778607, "1392": 16778608, "1393": 16778609, "1394": 16778610, "1395": 16778611, "1396": 16778612, "1397": 16778613, "1398": 16778614, "1399": 16778615, "1400": 16778616, "1401": 16778617, "1402": 16778618, "1403": 16778619, "1404": 16778620, "1405": 16778621, "1406": 16778622, "1407": 16778623, "1408": 16778624, "1409": 16778625, "1410": 16778626, "1411": 16778627, "1412": 16778628, "1413": 16778629, "1414": 16778630, "1415": 16778631, "1417": 16778633, "1418": 16778634, "1488": 3296, "1489": 3297, "1490": 3298, "1491": 3299, "1492": 3300, "1493": 3301, "1494": 3302, "1495": 3303, "1496": 3304, "1497": 3305, "1498": 3306, "1499": 3307, "1500": 3308, "1501": 3309, "1502": 3310, "1503": 3311, "1504": 3312, "1505": 3313, "1506": 3314, "1507": 3315, "1508": 3316, "1509": 3317, "1510": 3318, "1511": 3319, "1512": 3320, "1513": 3321, "1514": 3322, "1548": 1452, "1563": 1467, "1567": 1471, "1569": 1473, "1570": 1474, "1571": 1475, "1572": 1476, "1573": 1477, "1574": 1478, "1575": 1479, "1576": 1480, "1577": 1481, "1578": 1482, "1579": 1483, "1580": 1484, "1581": 1485, "1582": 1486, "1583": 1487, "1584": 1488, "1585": 1489, "1586": 1490, "1587": 1491, "1588": 1492, "1589": 1493, "1590": 1494, "1591": 1495, "1592": 1496, "1593": 1497, "1594": 1498, "1600": 1504, "1601": 1505, "1602": 1506, "1603": 1507, "1604": 1508, "1605": 1509, "1606": 1510, "1607": 1511, "1608": 1512, "1609": 1513, "1610": 1514, "1611": 1515, "1612": 1516, "1613": 1517, "1614": 1518, "1615": 1519, "1616": 1520, "1617": 1521, "1618": 1522, "1619": 16778835, "1620": 16778836, "1621": 16778837, "1632": 16778848, "1633": 16778849, "1634": 16778850, "1635": 16778851, "1636": 16778852, "1637": 16778853, "1638": 16778854, "1639": 16778855, "1640": 16778856, "1641": 16778857, "1642": 16778858, "1648": 16778864, "1657": 16778873, "1662": 16778878, "1670": 16778886, "1672": 16778888, "1681": 16778897, "1688": 16778904, "1700": 16778916, "1705": 16778921, "1711": 16778927, "1722": 16778938, "1726": 16778942, "1729": 16778945, "1740": 16778956, "1746": 16778962, "1748": 16778964, "1776": 16778992, "1777": 16778993, "1778": 16778994, "1779": 16778995, "1780": 16778996, "1781": 16778997, "1782": 16778998, "1783": 16778999, "1784": 16779000, "1785": 16779001, "3458": 16780674, "3459": 16780675, "3461": 16780677, "3462": 16780678, "3463": 16780679, "3464": 16780680, "3465": 16780681, "3466": 16780682, "3467": 16780683, "3468": 16780684, "3469": 16780685, "3470": 16780686, "3471": 16780687, "3472": 16780688, "3473": 16780689, "3474": 16780690, "3475": 16780691, "3476": 16780692, "3477": 16780693, "3478": 16780694, "3482": 16780698, "3483": 16780699, "3484": 16780700, "3485": 16780701, "3486": 16780702, "3487": 16780703, "3488": 16780704, "3489": 16780705, "3490": 16780706, "3491": 16780707, "3492": 16780708, "3493": 16780709, "3494": 16780710, "3495": 16780711, "3496": 16780712, "3497": 16780713, "3498": 16780714, "3499": 16780715, "3500": 16780716, "3501": 16780717, "3502": 16780718, "3503": 16780719, "3504": 16780720, "3505": 16780721, "3507": 16780723, "3508": 16780724, "3509": 16780725, "3510": 16780726, "3511": 16780727, "3512": 16780728, "3513": 16780729, "3514": 16780730, "3515": 16780731, "3517": 16780733, "3520": 16780736, "3521": 16780737, "3522": 16780738, "3523": 16780739, "3524": 16780740, "3525": 16780741, "3526": 16780742, "3530": 16780746, "3535": 16780751, "3536": 16780752, "3537": 16780753, "3538": 16780754, "3539": 16780755, "3540": 16780756, "3542": 16780758, "3544": 16780760, "3545": 16780761, "3546": 16780762, "3547": 16780763, "3548": 16780764, "3549": 16780765, "3550": 16780766, "3551": 16780767, "3570": 16780786, "3571": 16780787, "3572": 16780788, "3585": 3489, "3586": 3490, "3587": 3491, "3588": 3492, "3589": 3493, "3590": 3494, "3591": 3495, "3592": 3496, "3593": 3497, "3594": 3498, "3595": 3499, "3596": 3500, "3597": 3501, "3598": 3502, "3599": 3503, "3600": 3504, "3601": 3505, "3602": 3506, "3603": 3507, "3604": 3508, "3605": 3509, "3606": 3510, "3607": 3511, "3608": 3512, "3609": 3513, "3610": 3514, "3611": 3515, "3612": 3516, "3613": 3517, "3614": 3518, "3615": 3519, "3616": 3520, "3617": 3521, "3618": 3522, "3619": 3523, "3620": 3524, "3621": 3525, "3622": 3526, "3623": 3527, "3624": 3528, "3625": 3529, "3626": 3530, "3627": 3531, "3628": 3532, "3629": 3533, "3630": 3534, "3631": 3535, "3632": 3536, "3633": 3537, "3634": 3538, "3635": 3539, "3636": 3540, "3637": 3541, "3638": 3542, "3639": 3543, "3640": 3544, "3641": 3545, "3642": 3546, "3647": 3551, "3648": 3552, "3649": 3553, "3650": 3554, "3651": 3555, "3652": 3556, "3653": 3557, "3654": 3558, "3655": 3559, "3656": 3560, "3657": 3561, "3658": 3562, "3659": 3563, "3660": 3564, "3661": 3565, "3664": 3568, "3665": 3569, "3666": 3570, "3667": 3571, "3668": 3572, "3669": 3573, "3670": 3574, "3671": 3575, "3672": 3576, "3673": 3577, "4304": 16781520, "4305": 16781521, "4306": 16781522, "4307": 16781523, "4308": 16781524, "4309": 16781525, "4310": 16781526, "4311": 16781527, "4312": 16781528, "4313": 16781529, "4314": 16781530, "4315": 16781531, "4316": 16781532, "4317": 16781533, "4318": 16781534, "4319": 16781535, "4320": 16781536, "4321": 16781537, "4322": 16781538, "4323": 16781539, "4324": 16781540, "4325": 16781541, "4326": 16781542, "4327": 16781543, "4328": 16781544, "4329": 16781545, "4330": 16781546, "4331": 16781547, "4332": 16781548, "4333": 16781549, "4334": 16781550, "4335": 16781551, "4336": 16781552, "4337": 16781553, "4338": 16781554, "4339": 16781555, "4340": 16781556, "4341": 16781557, "4342": 16781558, "7682": 16784898, "7683": 16784899, "7690": 16784906, "7691": 16784907, "7710": 16784926, "7711": 16784927, "7734": 16784950, "7735": 16784951, "7744": 16784960, "7745": 16784961, "7766": 16784982, "7767": 16784983, "7776": 16784992, "7777": 16784993, "7786": 16785002, "7787": 16785003, "7808": 16785024, "7809": 16785025, "7810": 16785026, "7811": 16785027, "7812": 16785028, "7813": 16785029, "7818": 16785034, "7819": 16785035, "7840": 16785056, "7841": 16785057, "7842": 16785058, "7843": 16785059, "7844": 16785060, "7845": 16785061, "7846": 16785062, "7847": 16785063, "7848": 16785064, "7849": 16785065, "7850": 16785066, "7851": 16785067, "7852": 16785068, "7853": 16785069, "7854": 16785070, "7855": 16785071, "7856": 16785072, "7857": 16785073, "7858": 16785074, "7859": 16785075, "7860": 16785076, "7861": 16785077, "7862": 16785078, "7863": 16785079, "7864": 16785080, "7865": 16785081, "7866": 16785082, "7867": 16785083, "7868": 16785084, "7869": 16785085, "7870": 16785086, "7871": 16785087, "7872": 16785088, "7873": 16785089, "7874": 16785090, "7875": 16785091, "7876": 16785092, "7877": 16785093, "7878": 16785094, "7879": 16785095, "7880": 16785096, "7881": 16785097, "7882": 16785098, "7883": 16785099, "7884": 16785100, "7885": 16785101, "7886": 16785102, "7887": 16785103, "7888": 16785104, "7889": 16785105, "7890": 16785106, "7891": 16785107, "7892": 16785108, "7893": 16785109, "7894": 16785110, "7895": 16785111, "7896": 16785112, "7897": 16785113, "7898": 16785114, "7899": 16785115, "7900": 16785116, "7901": 16785117, "7902": 16785118, "7903": 16785119, "7904": 16785120, "7905": 16785121, "7906": 16785122, "7907": 16785123, "7908": 16785124, "7909": 16785125, "7910": 16785126, "7911": 16785127, "7912": 16785128, "7913": 16785129, "7914": 16785130, "7915": 16785131, "7916": 16785132, "7917": 16785133, "7918": 16785134, "7919": 16785135, "7920": 16785136, "7921": 16785137, "7922": 16785138, "7923": 16785139, "7924": 16785140, "7925": 16785141, "7926": 16785142, "7927": 16785143, "7928": 16785144, "7929": 16785145, "8194": 2722, "8195": 2721, "8196": 2723, "8197": 2724, "8199": 2725, "8200": 2726, "8201": 2727, "8202": 2728, "8210": 2747, "8211": 2730, "8212": 2729, "8213": 1967, "8215": 3295, "8216": 2768, "8217": 2769, "8218": 2813, "8220": 2770, "8221": 2771, "8222": 2814, "8224": 2801, "8225": 2802, "8226": 2790, "8229": 2735, "8230": 2734, "8240": 2773, "8242": 2774, "8243": 2775, "8248": 2812, "8254": 1150, "8304": 16785520, "8308": 16785524, "8309": 16785525, "8310": 16785526, "8311": 16785527, "8312": 16785528, "8313": 16785529, "8320": 16785536, "8321": 16785537, "8322": 16785538, "8323": 16785539, "8324": 16785540, "8325": 16785541, "8326": 16785542, "8327": 16785543, "8328": 16785544, "8329": 16785545, "8352": 16785568, "8353": 16785569, "8354": 16785570, "8355": 16785571, "8356": 16785572, "8357": 16785573, "8358": 16785574, "8359": 16785575, "8360": 16785576, "8361": 3839, "8362": 16785578, "8363": 16785579, "8364": 8364, "8453": 2744, "8470": 1712, "8471": 2811, "8478": 2772, "8482": 2761, "8531": 2736, "8532": 2737, "8533": 2738, "8534": 2739, "8535": 2740, "8536": 2741, "8537": 2742, "8538": 2743, "8539": 2755, "8540": 2756, "8541": 2757, "8542": 2758, "8592": 2299, "8593": 2300, "8594": 2301, "8595": 2302, "8658": 2254, "8660": 2253, "8706": 2287, "8709": 16785925, "8711": 2245, "8712": 16785928, "8713": 16785929, "8715": 16785931, "8728": 3018, "8730": 2262, "8731": 16785947, "8732": 16785948, "8733": 2241, "8734": 2242, "8743": 2270, "8744": 2271, "8745": 2268, "8746": 2269, "8747": 2239, "8748": 16785964, "8749": 16785965, "8756": 2240, "8757": 16785973, "8764": 2248, "8771": 2249, "8773": 16785992, "8775": 16785991, "8800": 2237, "8801": 2255, "8802": 16786018, "8803": 16786019, "8804": 2236, "8805": 2238, "8834": 2266, "8835": 2267, "8866": 3068, "8867": 3036, "8868": 3010, "8869": 3022, "8968": 3027, "8970": 3012, "8981": 2810, "8992": 2212, "8993": 2213, "9109": 3020, "9115": 2219, "9117": 2220, "9118": 2221, "9120": 2222, "9121": 2215, "9123": 2216, "9124": 2217, "9126": 2218, "9128": 2223, "9132": 2224, "9143": 2209, "9146": 2543, "9147": 2544, "9148": 2546, "9149": 2547, "9225": 2530, "9226": 2533, "9227": 2537, "9228": 2531, "9229": 2532, "9251": 2732, "9252": 2536, "9472": 2211, "9474": 2214, "9484": 2210, "9488": 2539, "9492": 2541, "9496": 2538, "9500": 2548, "9508": 2549, "9516": 2551, "9524": 2550, "9532": 2542, "9618": 2529, "9642": 2791, "9643": 2785, "9644": 2779, "9645": 2786, "9646": 2783, "9647": 2767, "9650": 2792, "9651": 2787, "9654": 2781, "9655": 2765, "9660": 2793, "9661": 2788, "9664": 2780, "9665": 2764, "9670": 2528, "9675": 2766, "9679": 2782, "9702": 2784, "9734": 2789, "9742": 2809, "9747": 2762, "9756": 2794, "9758": 2795, "9792": 2808, "9794": 2807, "9827": 2796, "9829": 2798, "9830": 2797, "9837": 2806, "9839": 2805, "10003": 2803, "10007": 2804, "10013": 2777, "10016": 2800, "10216": 2748, "10217": 2750, "10240": 16787456, "10241": 16787457, "10242": 16787458, "10243": 16787459, "10244": 16787460, "10245": 16787461, "10246": 16787462, "10247": 16787463, "10248": 16787464, "10249": 16787465, "10250": 16787466, "10251": 16787467, "10252": 16787468, "10253": 16787469, "10254": 16787470, "10255": 16787471, "10256": 16787472, "10257": 16787473, "10258": 16787474, "10259": 16787475, "10260": 16787476, "10261": 16787477, "10262": 16787478, "10263": 16787479, "10264": 16787480, "10265": 16787481, "10266": 16787482, "10267": 16787483, "10268": 16787484, "10269": 16787485, "10270": 16787486, "10271": 16787487, "10272": 16787488, "10273": 16787489, "10274": 16787490, "10275": 16787491, "10276": 16787492, "10277": 16787493, "10278": 16787494, "10279": 16787495, "10280": 16787496, "10281": 16787497, "10282": 16787498, "10283": 16787499, "10284": 16787500, "10285": 16787501, "10286": 16787502, "10287": 16787503, "10288": 16787504, "10289": 16787505, "10290": 16787506, "10291": 16787507, "10292": 16787508, "10293": 16787509, "10294": 16787510, "10295": 16787511, "10296": 16787512, "10297": 16787513, "10298": 16787514, "10299": 16787515, "10300": 16787516, "10301": 16787517, "10302": 16787518, "10303": 16787519, "10304": 16787520, "10305": 16787521, "10306": 16787522, "10307": 16787523, "10308": 16787524, "10309": 16787525, "10310": 16787526, "10311": 16787527, "10312": 16787528, "10313": 16787529, "10314": 16787530, "10315": 16787531, "10316": 16787532, "10317": 16787533, "10318": 16787534, "10319": 16787535, "10320": 16787536, "10321": 16787537, "10322": 16787538, "10323": 16787539, "10324": 16787540, "10325": 16787541, "10326": 16787542, "10327": 16787543, "10328": 16787544, "10329": 16787545, "10330": 16787546, "10331": 16787547, "10332": 16787548, "10333": 16787549, "10334": 16787550, "10335": 16787551, "10336": 16787552, "10337": 16787553, "10338": 16787554, "10339": 16787555, "10340": 16787556, "10341": 16787557, "10342": 16787558, "10343": 16787559, "10344": 16787560, "10345": 16787561, "10346": 16787562, "10347": 16787563, "10348": 16787564, "10349": 16787565, "10350": 16787566, "10351": 16787567, "10352": 16787568, "10353": 16787569, "10354": 16787570, "10355": 16787571, "10356": 16787572, "10357": 16787573, "10358": 16787574, "10359": 16787575, "10360": 16787576, "10361": 16787577, "10362": 16787578, "10363": 16787579, "10364": 16787580, "10365": 16787581, "10366": 16787582, "10367": 16787583, "10368": 16787584, "10369": 16787585, "10370": 16787586, "10371": 16787587, "10372": 16787588, "10373": 16787589, "10374": 16787590, "10375": 16787591, "10376": 16787592, "10377": 16787593, "10378": 16787594, "10379": 16787595, "10380": 16787596, "10381": 16787597, "10382": 16787598, "10383": 16787599, "10384": 16787600, "10385": 16787601, "10386": 16787602, "10387": 16787603, "10388": 16787604, "10389": 16787605, "10390": 16787606, "10391": 16787607, "10392": 16787608, "10393": 16787609, "10394": 16787610, "10395": 16787611, "10396": 16787612, "10397": 16787613, "10398": 16787614, "10399": 16787615, "10400": 16787616, "10401": 16787617, "10402": 16787618, "10403": 16787619, "10404": 16787620, "10405": 16787621, "10406": 16787622, "10407": 16787623, "10408": 16787624, "10409": 16787625, "10410": 16787626, "10411": 16787627, "10412": 16787628, "10413": 16787629, "10414": 16787630, "10415": 16787631, "10416": 16787632, "10417": 16787633, "10418": 16787634, "10419": 16787635, "10420": 16787636, "10421": 16787637, "10422": 16787638, "10423": 16787639, "10424": 16787640, "10425": 16787641, "10426": 16787642, "10427": 16787643, "10428": 16787644, "10429": 16787645, "10430": 16787646, "10431": 16787647, "10432": 16787648, "10433": 16787649, "10434": 16787650, "10435": 16787651, "10436": 16787652, "10437": 16787653, "10438": 16787654, "10439": 16787655, "10440": 16787656, "10441": 16787657, "10442": 16787658, "10443": 16787659, "10444": 16787660, "10445": 16787661, "10446": 16787662, "10447": 16787663, "10448": 16787664, "10449": 16787665, "10450": 16787666, "10451": 16787667, "10452": 16787668, "10453": 16787669, "10454": 16787670, "10455": 16787671, "10456": 16787672, "10457": 16787673, "10458": 16787674, "10459": 16787675, "10460": 16787676, "10461": 16787677, "10462": 16787678, "10463": 16787679, "10464": 16787680, "10465": 16787681, "10466": 16787682, "10467": 16787683, "10468": 16787684, "10469": 16787685, "10470": 16787686, "10471": 16787687, "10472": 16787688, "10473": 16787689, "10474": 16787690, "10475": 16787691, "10476": 16787692, "10477": 16787693, "10478": 16787694, "10479": 16787695, "10480": 16787696, "10481": 16787697, "10482": 16787698, "10483": 16787699, "10484": 16787700, "10485": 16787701, "10486": 16787702, "10487": 16787703, "10488": 16787704, "10489": 16787705, "10490": 16787706, "10491": 16787707, "10492": 16787708, "10493": 16787709, "10494": 16787710, "10495": 16787711, "12289": 1188, "12290": 1185, "12300": 1186, "12301": 1187, "12443": 1246, "12444": 1247, "12449": 1191, "12450": 1201, "12451": 1192, "12452": 1202, "12453": 1193, "12454": 1203, "12455": 1194, "12456": 1204, "12457": 1195, "12458": 1205, "12459": 1206, "12461": 1207, "12463": 1208, "12465": 1209, "12467": 1210, "12469": 1211, "12471": 1212, "12473": 1213, "12475": 1214, "12477": 1215, "12479": 1216, "12481": 1217, "12483": 1199, "12484": 1218, "12486": 1219, "12488": 1220, "12490": 1221, "12491": 1222, "12492": 1223, "12493": 1224, "12494": 1225, "12495": 1226, "12498": 1227, "12501": 1228, "12504": 1229, "12507": 1230, "12510": 1231, "12511": 1232, "12512": 1233, "12513": 1234, "12514": 1235, "12515": 1196, "12516": 1236, "12517": 1197, "12518": 1237, "12519": 1198, "12520": 1238, "12521": 1239, "12522": 1240, "12523": 1241, "12524": 1242, "12525": 1243, "12527": 1244, "12530": 1190, "12531": 1245, "12539": 1189, "12540": 1200 }; + +function lookup(k) { + return k ? { keysym: k, keyname: keynames ? keynames[k] : k } : undefined; +} +exports.default = { + fromUnicode: function (u) { + var keysym = codepoints[u]; + if (keysym === undefined) { + keysym = 0x01000000 | u; + } + return lookup(keysym); + }, + lookup: lookup +}; +},{}],8:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.substituteCodepoint = substituteCodepoint; +exports.hasShortcutModifier = hasShortcutModifier; +exports.hasCharModifier = hasCharModifier; +exports.ModifierSync = ModifierSync; +exports.getKey = getKey; +exports.getKeysym = getKeysym; +exports.keysymFromKeyCode = keysymFromKeyCode; +exports.nonCharacterKey = nonCharacterKey; +exports.QEMUKeyEventDecoder = QEMUKeyEventDecoder; +exports.TrackQEMUKeyState = TrackQEMUKeyState; +exports.KeyEventDecoder = KeyEventDecoder; +exports.VerifyCharModifier = VerifyCharModifier; +exports.TrackKeyState = TrackKeyState; +exports.EscapeModifiers = EscapeModifiers; + +var _keysym = require("./keysym.js"); + +var _keysym2 = _interopRequireDefault(_keysym); + +var _keysymdef = require("./keysymdef.js"); + +var _keysymdef2 = _interopRequireDefault(_keysymdef); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function substituteCodepoint(cp) { + // Any Unicode code points which do not have corresponding keysym entries + // can be swapped out for another code point by adding them to this table + var substitutions = { + // {S,s} with comma below -> {S,s} with cedilla + 0x218: 0x15e, + 0x219: 0x15f, + // {T,t} with comma below -> {T,t} with cedilla + 0x21a: 0x162, + 0x21b: 0x163 + }; + + var sub = substitutions[cp]; + return sub ? sub : cp; +} + +function isMac() { + return navigator && !!/mac/i.exec(navigator.platform); +} +function isWindows() { + return navigator && !!/win/i.exec(navigator.platform); +} +function isLinux() { + return navigator && !!/linux/i.exec(navigator.platform); +} + +// Return true if a modifier which is not the specified char modifier (and is not shift) is down +function hasShortcutModifier(charModifier, currentModifiers) { + var mods = {}; + for (var key in currentModifiers) { + if (parseInt(key) !== _keysym2.default.XK_Shift_L) { + mods[key] = currentModifiers[key]; + } + } + + var sum = 0; + for (var k in currentModifiers) { + if (mods[k]) { + ++sum; + } + } + if (hasCharModifier(charModifier, mods)) { + return sum > charModifier.length; + } else { + return sum > 0; + } +} + +// Return true if the specified char modifier is currently down +function hasCharModifier(charModifier, currentModifiers) { + if (charModifier.length === 0) { + return false; + } + + for (var i = 0; i < charModifier.length; ++i) { + if (!currentModifiers[charModifier[i]]) { + return false; + } + } + return true; +} + +// Helper object tracking modifier key state +// and generates fake key events to compensate if it gets out of sync +function ModifierSync(charModifier) { + if (!charModifier) { + if (isMac()) { + // on Mac, Option (AKA Alt) is used as a char modifier + charModifier = [_keysym2.default.XK_Alt_L]; + } else if (isWindows()) { + // on Windows, Ctrl+Alt is used as a char modifier + charModifier = [_keysym2.default.XK_Alt_L, _keysym2.default.XK_Control_L]; + } else if (isLinux()) { + // on Linux, ISO Level 3 Shift (AltGr) is used as a char modifier + charModifier = [_keysym2.default.XK_ISO_Level3_Shift]; + } else { + charModifier = []; + } + } + + var state = {}; + state[_keysym2.default.XK_Control_L] = false; + state[_keysym2.default.XK_Alt_L] = false; + state[_keysym2.default.XK_ISO_Level3_Shift] = false; + state[_keysym2.default.XK_Shift_L] = false; + state[_keysym2.default.XK_Meta_L] = false; + + function sync(evt, keysym) { + var result = []; + function syncKey(keysym) { + return { keysym: _keysymdef2.default.lookup(keysym), type: state[keysym] ? 'keydown' : 'keyup' }; + } + + if (evt.ctrlKey !== undefined && evt.ctrlKey !== state[_keysym2.default.XK_Control_L] && keysym !== _keysym2.default.XK_Control_L) { + state[_keysym2.default.XK_Control_L] = evt.ctrlKey; + result.push(syncKey(_keysym2.default.XK_Control_L)); + } + if (evt.altKey !== undefined && evt.altKey !== state[_keysym2.default.XK_Alt_L] && keysym !== _keysym2.default.XK_Alt_L) { + state[_keysym2.default.XK_Alt_L] = evt.altKey; + result.push(syncKey(_keysym2.default.XK_Alt_L)); + } + if (evt.altGraphKey !== undefined && evt.altGraphKey !== state[_keysym2.default.XK_ISO_Level3_Shift] && keysym !== _keysym2.default.XK_ISO_Level3_Shift) { + state[_keysym2.default.XK_ISO_Level3_Shift] = evt.altGraphKey; + result.push(syncKey(_keysym2.default.XK_ISO_Level3_Shift)); + } + if (evt.shiftKey !== undefined && evt.shiftKey !== state[_keysym2.default.XK_Shift_L] && keysym !== _keysym2.default.XK_Shift_L) { + state[_keysym2.default.XK_Shift_L] = evt.shiftKey; + result.push(syncKey(_keysym2.default.XK_Shift_L)); + } + if (evt.metaKey !== undefined && evt.metaKey !== state[_keysym2.default.XK_Meta_L] && keysym !== _keysym2.default.XK_Meta_L) { + state[_keysym2.default.XK_Meta_L] = evt.metaKey; + result.push(syncKey(_keysym2.default.XK_Meta_L)); + } + return result; + } + function syncKeyEvent(evt, down) { + var obj = getKeysym(evt); + var keysym = obj ? obj.keysym : null; + + // first, apply the event itself, if relevant + if (keysym !== null && state[keysym] !== undefined) { + state[keysym] = down; + } + return sync(evt, keysym); + } + + return { + // sync on the appropriate keyboard event + keydown: function (evt) { + return syncKeyEvent(evt, true); + }, + keyup: function (evt) { + return syncKeyEvent(evt, false); + }, + // Call this with a non-keyboard event (such as mouse events) to use its modifier state to synchronize anyway + syncAny: function (evt) { + return sync(evt); + }, + + // is a shortcut modifier down? + hasShortcutModifier: function () { + return hasShortcutModifier(charModifier, state); + }, + // if a char modifier is down, return the keys it consists of, otherwise return null + activeCharModifier: function () { + return hasCharModifier(charModifier, state) ? charModifier : null; + } + }; +} + +// Get a key ID from a keyboard event +// May be a string or an integer depending on the available properties +function getKey(evt) { + if ('keyCode' in evt && 'key' in evt) { + return evt.key + ':' + evt.keyCode; + } else if ('keyCode' in evt) { + return evt.keyCode; + } else { + return evt.key; + } +} + +// Get the most reliable keysym value we can get from a key event +// if char/charCode is available, prefer those, otherwise fall back to key/keyCode/which +function getKeysym(evt) { + var codepoint; + if (evt.char && evt.char.length === 1) { + codepoint = evt.char.charCodeAt(); + } else if (evt.charCode) { + codepoint = evt.charCode; + } else if (evt.keyCode && evt.type === 'keypress') { + // IE10 stores the char code as keyCode, and has no other useful properties + codepoint = evt.keyCode; + } + if (codepoint) { + return _keysymdef2.default.fromUnicode(substituteCodepoint(codepoint)); + } + // we could check evt.key here. + // Legal values are defined in http://www.w3.org/TR/DOM-Level-3-Events/#key-values-list, + // so we "just" need to map them to keysym, but AFAIK this is only available in IE10, which also provides evt.key + // so we don't *need* it yet + if (evt.keyCode) { + return _keysymdef2.default.lookup(keysymFromKeyCode(evt.keyCode, evt.shiftKey)); + } + if (evt.which) { + return _keysymdef2.default.lookup(keysymFromKeyCode(evt.which, evt.shiftKey)); + } + return null; +} + +// Given a keycode, try to predict which keysym it might be. +// If the keycode is unknown, null is returned. +function keysymFromKeyCode(keycode, shiftPressed) { + if (typeof keycode !== 'number') { + return null; + } + // won't be accurate for azerty + if (keycode >= 0x30 && keycode <= 0x39) { + return keycode; // digit + } + if (keycode >= 0x41 && keycode <= 0x5a) { + // remap to lowercase unless shift is down + return shiftPressed ? keycode : keycode + 32; // A-Z + } + if (keycode >= 0x60 && keycode <= 0x69) { + return _keysym2.default.XK_KP_0 + (keycode - 0x60); // numpad 0-9 + } + + switch (keycode) { + case 0x20: + return _keysym2.default.XK_space; + case 0x6a: + return _keysym2.default.XK_KP_Multiply; + case 0x6b: + return _keysym2.default.XK_KP_Add; + case 0x6c: + return _keysym2.default.XK_KP_Separator; + case 0x6d: + return _keysym2.default.XK_KP_Subtract; + case 0x6e: + return _keysym2.default.XK_KP_Decimal; + case 0x6f: + return _keysym2.default.XK_KP_Divide; + case 0xbb: + return _keysym2.default.XK_plus; + case 0xbc: + return _keysym2.default.XK_comma; + case 0xbd: + return _keysym2.default.XK_minus; + case 0xbe: + return _keysym2.default.XK_period; + } + + return nonCharacterKey({ keyCode: keycode }); +} + +// if the key is a known non-character key (any key which doesn't generate character data) +// return its keysym value. Otherwise return null +function nonCharacterKey(evt) { + // evt.key not implemented yet + if (!evt.keyCode) { + return null; + } + var keycode = evt.keyCode; + + if (keycode >= 0x70 && keycode <= 0x87) { + return _keysym2.default.XK_F1 + keycode - 0x70; // F1-F24 + } + switch (keycode) { + + case 8: + return _keysym2.default.XK_BackSpace; + case 13: + return _keysym2.default.XK_Return; + + case 9: + return _keysym2.default.XK_Tab; + + case 27: + return _keysym2.default.XK_Escape; + case 46: + return _keysym2.default.XK_Delete; + + case 36: + return _keysym2.default.XK_Home; + case 35: + return _keysym2.default.XK_End; + case 33: + return _keysym2.default.XK_Page_Up; + case 34: + return _keysym2.default.XK_Page_Down; + case 45: + return _keysym2.default.XK_Insert; + + case 37: + return _keysym2.default.XK_Left; + case 38: + return _keysym2.default.XK_Up; + case 39: + return _keysym2.default.XK_Right; + case 40: + return _keysym2.default.XK_Down; + + case 16: + return _keysym2.default.XK_Shift_L; + case 17: + return _keysym2.default.XK_Control_L; + case 18: + return _keysym2.default.XK_Alt_L; // also: Option-key on Mac + + case 224: + return _keysym2.default.XK_Meta_L; + case 225: + return _keysym2.default.XK_ISO_Level3_Shift; // AltGr + case 91: + return _keysym2.default.XK_Super_L; // also: Windows-key + case 92: + return _keysym2.default.XK_Super_R; // also: Windows-key + case 93: + return _keysym2.default.XK_Menu; // also: Windows-Menu, Command on Mac + default: + return null; + } +} + +function QEMUKeyEventDecoder(modifierState, next) { + "use strict"; + + function sendAll(evts) { + for (var i = 0; i < evts.length; ++i) { + next(evts[i]); + } + } + + var numPadCodes = ["Numpad0", "Numpad1", "Numpad2", "Numpad3", "Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9", "NumpadDecimal"]; + + var numLockOnKeySyms = { + "Numpad0": 0xffb0, "Numpad1": 0xffb1, "Numpad2": 0xffb2, + "Numpad3": 0xffb3, "Numpad4": 0xffb4, "Numpad5": 0xffb5, + "Numpad6": 0xffb6, "Numpad7": 0xffb7, "Numpad8": 0xffb8, + "Numpad9": 0xffb9, "NumpadDecimal": 0xffac + }; + + var numLockOnKeyCodes = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 108, 110]; + + function isNumPadMultiKey(evt) { + return numPadCodes.indexOf(evt.code) !== -1; + } + + function getNumPadKeySym(evt) { + if (numLockOnKeyCodes.indexOf(evt.keyCode) !== -1) { + return numLockOnKeySyms[evt.code]; + } + return 0; + } + + function process(evt, type) { + var result = { type: type }; + result.code = evt.code; + result.keysym = 0; + + if (isNumPadMultiKey(evt)) { + result.keysym = getNumPadKeySym(evt); + } + + var hasModifier = modifierState.hasShortcutModifier() || !!modifierState.activeCharModifier(); + var isShift = evt.keyCode === 0x10 || evt.key === 'Shift'; + + var suppress = !isShift && (type !== 'keydown' || modifierState.hasShortcutModifier() || !!nonCharacterKey(evt)); + + next(result); + return suppress; + } + return { + keydown: function (evt) { + sendAll(modifierState.keydown(evt)); + return process(evt, 'keydown'); + }, + keypress: function (evt) { + return true; + }, + keyup: function (evt) { + sendAll(modifierState.keyup(evt)); + return process(evt, 'keyup'); + }, + syncModifiers: function (evt) { + sendAll(modifierState.syncAny(evt)); + }, + releaseAll: function () { + next({ type: 'releaseall' }); + } + }; +}; + +function TrackQEMUKeyState(next) { + "use strict"; + + var state = []; + + return function (evt) { + var last = state.length !== 0 ? state[state.length - 1] : null; + + switch (evt.type) { + case 'keydown': + + if (!last || last.code !== evt.code) { + last = { code: evt.code }; + + if (state.length > 0 && state[state.length - 1].code == 'ControlLeft') { + if (evt.code !== 'AltRight') { + next({ code: 'ControlLeft', type: 'keydown', keysym: 0 }); + } else { + state.pop(); + } + } + state.push(last); + } + if (evt.code !== 'ControlLeft') { + next(evt); + } + break; + + case 'keyup': + if (state.length === 0) { + return; + } + var idx = null; + // do we have a matching key tracked as being down? + for (var i = 0; i !== state.length; ++i) { + if (state[i].code === evt.code) { + idx = i; + break; + } + } + // if we couldn't find a match (it happens), assume it was the last key pressed + if (idx === null) { + if (evt.code === 'ControlLeft') { + return; + } + idx = state.length - 1; + } + + state.splice(idx, 1); + next(evt); + break; + case 'releaseall': + /* jshint shadow: true */ + for (var i = 0; i < state.length; ++i) { + next({ code: state[i].code, keysym: 0, type: 'keyup' }); + } + /* jshint shadow: false */ + state = []; + } + }; +}; + +// Takes a DOM keyboard event and: +// - determines which keysym it represents +// - determines a keyId identifying the key that was pressed (corresponding to the key/keyCode properties on the DOM event) +// - synthesizes events to synchronize modifier key state between which modifiers are actually down, and which we thought were down +// - marks each event with an 'escape' property if a modifier was down which should be "escaped" +// - generates a "stall" event in cases where it might be necessary to wait and see if a keypress event follows a keydown +// This information is collected into an object which is passed to the next() function. (one call per event) +function KeyEventDecoder(modifierState, next) { + "use strict"; + + function sendAll(evts) { + for (var i = 0; i < evts.length; ++i) { + next(evts[i]); + } + } + function process(evt, type) { + var result = { type: type }; + var keyId = getKey(evt); + if (keyId) { + result.keyId = keyId; + } + + var keysym = getKeysym(evt); + + var hasModifier = modifierState.hasShortcutModifier() || !!modifierState.activeCharModifier(); + // Is this a case where we have to decide on the keysym right away, rather than waiting for the keypress? + // "special" keys like enter, tab or backspace don't send keypress events, + // and some browsers don't send keypresses at all if a modifier is down + if (keysym && (type !== 'keydown' || nonCharacterKey(evt) || hasModifier)) { + result.keysym = keysym; + } + + var isShift = evt.keyCode === 0x10 || evt.key === 'Shift'; + + // Should we prevent the browser from handling the event? + // Doing so on a keydown (in most browsers) prevents keypress from being generated + // so only do that if we have to. + var suppress = !isShift && (type !== 'keydown' || modifierState.hasShortcutModifier() || !!nonCharacterKey(evt)); + + // If a char modifier is down on a keydown, we need to insert a stall, + // so VerifyCharModifier knows to wait and see if a keypress is comnig + var stall = type === 'keydown' && modifierState.activeCharModifier() && !nonCharacterKey(evt); + + // if a char modifier is pressed, get the keys it consists of (on Windows, AltGr is equivalent to Ctrl+Alt) + var active = modifierState.activeCharModifier(); + + // If we have a char modifier down, and we're able to determine a keysym reliably + // then (a) we know to treat the modifier as a char modifier, + // and (b) we'll have to "escape" the modifier to undo the modifier when sending the char. + if (active && keysym) { + var isCharModifier = false; + for (var i = 0; i < active.length; ++i) { + if (active[i] === keysym.keysym) { + isCharModifier = true; + } + } + if (type === 'keypress' && !isCharModifier) { + result.escape = modifierState.activeCharModifier(); + } + } + + if (stall) { + // insert a fake "stall" event + next({ type: 'stall' }); + } + next(result); + + return suppress; + } + + return { + keydown: function (evt) { + sendAll(modifierState.keydown(evt)); + return process(evt, 'keydown'); + }, + keypress: function (evt) { + return process(evt, 'keypress'); + }, + keyup: function (evt) { + sendAll(modifierState.keyup(evt)); + return process(evt, 'keyup'); + }, + syncModifiers: function (evt) { + sendAll(modifierState.syncAny(evt)); + }, + releaseAll: function () { + next({ type: 'releaseall' }); + } + }; +}; + +// Combines keydown and keypress events where necessary to handle char modifiers. +// On some OS'es, a char modifier is sometimes used as a shortcut modifier. +// For example, on Windows, AltGr is synonymous with Ctrl-Alt. On a Danish keyboard layout, AltGr-2 yields a @, but Ctrl-Alt-D does nothing +// so when used with the '2' key, Ctrl-Alt counts as a char modifier (and should be escaped), but when used with 'D', it does not. +// The only way we can distinguish these cases is to wait and see if a keypress event arrives +// When we receive a "stall" event, wait a few ms before processing the next keydown. If a keypress has also arrived, merge the two +function VerifyCharModifier(next) { + "use strict"; + + var queue = []; + var timer = null; + function process() { + if (timer) { + return; + } + + var delayProcess = function () { + clearTimeout(timer); + timer = null; + process(); + }; + + while (queue.length !== 0) { + var cur = queue[0]; + queue = queue.splice(1); + switch (cur.type) { + case 'stall': + // insert a delay before processing available events. + /* jshint loopfunc: true */ + timer = setTimeout(delayProcess, 5); + /* jshint loopfunc: false */ + return; + case 'keydown': + // is the next element a keypress? Then we should merge the two + if (queue.length !== 0 && queue[0].type === 'keypress') { + // Firefox sends keypress even when no char is generated. + // so, if keypress keysym is the same as we'd have guessed from keydown, + // the modifier didn't have any effect, and should not be escaped + if (queue[0].escape && (!cur.keysym || cur.keysym.keysym !== queue[0].keysym.keysym)) { + cur.escape = queue[0].escape; + } + cur.keysym = queue[0].keysym; + queue = queue.splice(1); + } + break; + } + + // swallow stall events, and pass all others to the next stage + if (cur.type !== 'stall') { + next(cur); + } + } + } + return function (evt) { + queue.push(evt); + process(); + }; +}; + +// Keeps track of which keys we (and the server) believe are down +// When a keyup is received, match it against this list, to determine the corresponding keysym(s) +// in some cases, a single key may produce multiple keysyms, so the corresponding keyup event must release all of these chars +// key repeat events should be merged into a single entry. +// Because we can't always identify which entry a keydown or keyup event corresponds to, we sometimes have to guess +function TrackKeyState(next) { + "use strict"; + + var state = []; + + return function (evt) { + var last = state.length !== 0 ? state[state.length - 1] : null; + + switch (evt.type) { + case 'keydown': + // insert a new entry if last seen key was different. + if (!last || !evt.keyId || last.keyId !== evt.keyId) { + last = { keyId: evt.keyId, keysyms: {} }; + state.push(last); + } + if (evt.keysym) { + // make sure last event contains this keysym (a single "logical" keyevent + // can cause multiple key events to be sent to the VNC server) + last.keysyms[evt.keysym.keysym] = evt.keysym; + last.ignoreKeyPress = true; + next(evt); + } + break; + case 'keypress': + if (!last) { + last = { keyId: evt.keyId, keysyms: {} }; + state.push(last); + } + if (!evt.keysym) { + console.log('keypress with no keysym:', evt); + } + + // If we didn't expect a keypress, and already sent a keydown to the VNC server + // based on the keydown, make sure to skip this event. + if (evt.keysym && !last.ignoreKeyPress) { + last.keysyms[evt.keysym.keysym] = evt.keysym; + evt.type = 'keydown'; + next(evt); + } + break; + case 'keyup': + if (state.length === 0) { + return; + } + var idx = null; + // do we have a matching key tracked as being down? + for (var i = 0; i !== state.length; ++i) { + if (state[i].keyId === evt.keyId) { + idx = i; + break; + } + } + // if we couldn't find a match (it happens), assume it was the last key pressed + if (idx === null) { + idx = state.length - 1; + } + + var item = state.splice(idx, 1)[0]; + // for each keysym tracked by this key entry, clone the current event and override the keysym + var clone = function () { + function Clone() {} + return function (obj) { + Clone.prototype = obj;return new Clone(); + }; + }(); + for (var key in item.keysyms) { + var out = clone(evt); + out.keysym = item.keysyms[key]; + next(out); + } + break; + case 'releaseall': + /* jshint shadow: true */ + for (var i = 0; i < state.length; ++i) { + for (var key in state[i].keysyms) { + var keysym = state[i].keysyms[key]; + next({ keyId: 0, keysym: keysym, type: 'keyup' }); + } + } + /* jshint shadow: false */ + state = []; + } + }; +}; + +// Handles "escaping" of modifiers: if a char modifier is used to produce a keysym (such as AltGr-2 to generate an @), +// then the modifier must be "undone" before sending the @, and "redone" afterwards. +function EscapeModifiers(next) { + "use strict"; + + return function (evt) { + if (evt.type !== 'keydown' || evt.escape === undefined) { + next(evt); + return; + } + // undo modifiers + for (var i = 0; i < evt.escape.length; ++i) { + next({ type: 'keyup', keyId: 0, keysym: _keysymdef2.default.lookup(evt.escape[i]) }); + } + // send the character event + next(evt); + // redo modifiers + /* jshint shadow: true */ + for (var i = 0; i < evt.escape.length; ++i) { + next({ type: 'keydown', keyId: 0, keysym: _keysymdef2.default.lookup(evt.escape[i]) }); + } + /* jshint shadow: false */ + }; +}; +},{"./keysym.js":6,"./keysymdef.js":7}],9:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = { + "Escape": 0x0001, + "Digit1": 0x0002, + "Digit2": 0x0003, + "Digit3": 0x0004, + "Digit4": 0x0005, + "Digit5": 0x0006, + "Digit6": 0x0007, + "Digit7": 0x0008, + "Digit8": 0x0009, + "Digit9": 0x000A, + "Digit0": 0x000B, + "Minus": 0x000C, + "Equal": 0x000D, + "Backspace": 0x000E, + "Tab": 0x000F, + "KeyQ": 0x0010, + "KeyW": 0x0011, + "KeyE": 0x0012, + "KeyR": 0x0013, + "KeyT": 0x0014, + "KeyY": 0x0015, + "KeyU": 0x0016, + "KeyI": 0x0017, + "KeyO": 0x0018, + "KeyP": 0x0019, + "BracketLeft": 0x001A, + "BracketRight": 0x001B, + "Enter": 0x001C, + "ControlLeft": 0x001D, + "KeyA": 0x001E, + "KeyS": 0x001F, + "KeyD": 0x0020, + "KeyF": 0x0021, + "KeyG": 0x0022, + "KeyH": 0x0023, + "KeyJ": 0x0024, + "KeyK": 0x0025, + "KeyL": 0x0026, + "Semicolon": 0x0027, + "Quote": 0x0028, + "Backquote": 0x0029, + "ShiftLeft": 0x002A, + "Backslash": 0x002B, + "KeyZ": 0x002C, + "KeyX": 0x002D, + "KeyC": 0x002E, + "KeyV": 0x002F, + "KeyB": 0x0030, + "KeyN": 0x0031, + "KeyM": 0x0032, + "Comma": 0x0033, + "Period": 0x0034, + "Slash": 0x0035, + "ShiftRight": 0x0036, + "NumpadMultiply": 0x0037, + "AltLeft": 0x0038, + "Space": 0x0039, + "CapsLock": 0x003A, + "F1": 0x003B, + "F2": 0x003C, + "F3": 0x003D, + "F4": 0x003E, + "F5": 0x003F, + "F6": 0x0040, + "F7": 0x0041, + "F8": 0x0042, + "F9": 0x0043, + "F10": 0x0044, + "Pause": 0xE045, + "ScrollLock": 0x0046, + "Numpad7": 0x0047, + "Numpad8": 0x0048, + "Numpad9": 0x0049, + "NumpadSubtract": 0x004A, + "Numpad4": 0x004B, + "Numpad5": 0x004C, + "Numpad6": 0x004D, + "NumpadAdd": 0x004E, + "Numpad1": 0x004F, + "Numpad2": 0x0050, + "Numpad3": 0x0051, + "Numpad0": 0x0052, + "NumpadDecimal": 0x0053, + "IntlBackslash": 0x0056, + "F11": 0x0057, + "F12": 0x0058, + "IntlYen": 0x007D, + "MediaTrackPrevious": 0xE010, + "MediaTrackNext": 0xE019, + "NumpadEnter": 0xE01C, + "ControlRight": 0xE01D, + "VolumeMute": 0xE020, + "MediaPlayPause": 0xE022, + "MediaStop": 0xE024, + "VolumeDown": 0xE02E, + "VolumeUp": 0xE030, + "BrowserHome": 0xE032, + "NumpadDivide": 0xE035, + "PrintScreen": 0xE037, + "AltRight": 0xE038, + "NumLock": 0x0045, + "Home": 0xE047, + "ArrowUp": 0xE048, + "PageUp": 0xE049, + "ArrowLeft": 0xE04B, + "ArrowRight": 0xE04D, + "End": 0xE04F, + "ArrowDown": 0xE050, + "PageDown": 0xE051, + "Insert": 0xE052, + "Delete": 0xE053, + "MetaLeft": 0xE05B, + "MetaRight": 0xE05C, + "OSLeft": 0xE05B, // OSLeft and OSRight are kept for compatability since + "OSRight": 0xE05C, // Firefox haven't updated to MetaLeft and MetaRight yet + "ContextMenu": 0xE05D, + "BrowserSearch": 0xE065, + "BrowserFavorites": 0xE066, + "BrowserRefresh": 0xE067, + "BrowserStop": 0xE068, + "BrowserForward": 0xE069, + "BrowserBack": 0xE06A, + "NumpadComma": 0x007E, + "NumpadEqual": 0x0059, + "F13": 0x0064, + "F14": 0x0065, + "F15": 0x0066, + "F16": 0x0067, + "F17": 0x0068, + "F18": 0x0069, + "F19": 0x006A, + "F20": 0x006B, + "F21": 0x006C, + "F22": 0x006D, + "F23": 0x006E, + "F24": 0x0076, + "KanaMode": 0x0070, + "Lang2": 0x0071, + "Lang1": 0x0072, + "IntlRo": 0x0073, + "Convert": 0x0079, + "NonConvert": 0x007B, + "LaunchApp2": 0xE021, + "Power": 0xE05E, + "LaunchApp1": 0xE06B, + "LaunchMail": 0xE06C, + "MediaSelect": 0xE06D +}; +},{}],10:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = RFB; + +var _logging = require('./util/logging.js'); + +var Log = _interopRequireWildcard(_logging); + +var _localization = require('./util/localization.js'); + +var _localization2 = _interopRequireDefault(_localization); + +var _strings = require('./util/strings.js'); + +var _properties = require('./util/properties.js'); + +var _display = require('./display.js'); + +var _display2 = _interopRequireDefault(_display); + +var _devices = require('./input/devices.js'); + +var _websock = require('./websock.js'); + +var _websock2 = _interopRequireDefault(_websock); + +var _base = require('./base64.js'); + +var _base2 = _interopRequireDefault(_base); + +var _des = require('./des.js'); + +var _des2 = _interopRequireDefault(_des); + +var _keysym = require('./input/keysym.js'); + +var _keysym2 = _interopRequireDefault(_keysym); + +var _xtscancodes = require('./input/xtscancodes.js'); + +var _xtscancodes2 = _interopRequireDefault(_xtscancodes); + +var _inflator = require('./inflator.js'); + +var _inflator2 = _interopRequireDefault(_inflator); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +/*jslint white: false, browser: true */ +/*global window, Util, Display, Keyboard, Mouse, Websock, Websock_native, Base64, DES, KeyTable, Inflator, XtScancode */ + +/* + * noVNC: HTML5 VNC client + * Copyright (C) 2012 Joel Martin + * Copyright (C) 2016 Samuel Mannehed for Cendio AB + * Licensed under MPL 2.0 (see LICENSE.txt) + * + * See README.md for usage and integration instructions. + * + * TIGHT decoder portion: + * (c) 2012 Michael Tinglof, Joe Balaz, Les Piech (Mercuri.ca) + */ + +function RFB(defaults) { + "use strict"; + + if (!defaults) { + defaults = {}; + } + + this._rfb_host = ''; + this._rfb_port = 5900; + this._rfb_password = ''; + this._rfb_path = ''; + + this._rfb_connection_state = ''; + this._rfb_init_state = ''; + this._rfb_version = 0; + this._rfb_max_version = 3.8; + this._rfb_auth_scheme = ''; + this._rfb_disconnect_reason = ""; + + this._rfb_tightvnc = false; + this._rfb_xvp_ver = 0; + + // In preference order + this._encodings = [['COPYRECT', 0x01], ['TIGHT', 0x07], ['TIGHT_PNG', -260], ['HEXTILE', 0x05], ['RRE', 0x02], ['RAW', 0x00], + + // Psuedo-encoding settings + + //['JPEG_quality_lo', -32 ], + ['JPEG_quality_med', -26], + //['JPEG_quality_hi', -23 ], + //['compress_lo', -255 ], + ['compress_hi', -254], + //['compress_max', -247 ], + + ['DesktopSize', -223], ['last_rect', -224], ['Cursor', -239], ['QEMUExtendedKeyEvent', -258], ['ExtendedDesktopSize', -308], ['xvp', -309], ['Fence', -312], ['ContinuousUpdates', -313]]; + + this._encHandlers = {}; + this._encNames = {}; + this._encStats = {}; + + this._sock = null; // Websock object + this._display = null; // Display object + this._flushing = false; // Display flushing state + this._keyboard = null; // Keyboard input handler object + this._mouse = null; // Mouse input handler object + this._disconnTimer = null; // disconnection timer + + this._supportsFence = false; + + this._supportsContinuousUpdates = false; + this._enabledContinuousUpdates = false; + + // Frame buffer update state + this._FBU = { + rects: 0, + subrects: 0, // RRE + lines: 0, // RAW + tiles: 0, // HEXTILE + bytes: 0, + x: 0, + y: 0, + width: 0, + height: 0, + encoding: 0, + subencoding: -1, + background: null, + zlib: [] // TIGHT zlib streams + }; + + this._fb_Bpp = 4; + this._fb_depth = 3; + this._fb_width = 0; + this._fb_height = 0; + this._fb_name = ""; + + this._destBuff = null; + this._paletteBuff = new Uint8Array(1024); // 256 * 4 (max palette size * max bytes-per-pixel) + + this._rre_chunk_sz = 100; + + this._timing = { + last_fbu: 0, + fbu_total: 0, + fbu_total_cnt: 0, + full_fbu_total: 0, + full_fbu_cnt: 0, + + fbu_rt_start: 0, + fbu_rt_total: 0, + fbu_rt_cnt: 0, + pixels: 0 + }; + + this._supportsSetDesktopSize = false; + this._screen_id = 0; + this._screen_flags = 0; + + // Mouse state + this._mouse_buttonMask = 0; + this._mouse_arr = []; + this._viewportDragging = false; + this._viewportDragPos = {}; + this._viewportHasMoved = false; + + // QEMU Extended Key Event support - default to false + this._qemuExtKeyEventSupported = false; + + // set the default value on user-facing properties + (0, _properties.set_defaults)(this, defaults, { + 'target': 'null', // VNC display rendering Canvas object + 'focusContainer': document, // DOM element that captures keyboard input + 'encrypt': false, // Use TLS/SSL/wss encryption + 'true_color': true, // Request true color pixel data + 'local_cursor': false, // Request locally rendered cursor + 'shared': true, // Request shared mode + 'view_only': false, // Disable client mouse/keyboard + 'xvp_password_sep': '@', // Separator for XVP password fields + 'disconnectTimeout': 3, // Time (s) to wait for disconnection + 'wsProtocols': ['binary'], // Protocols to use in the WebSocket connection + 'repeaterID': '', // [UltraVNC] RepeaterID to connect to + 'viewportDrag': false, // Move the viewport on mouse drags + + // Callback functions + 'onUpdateState': function () {}, // onUpdateState(rfb, state, oldstate): connection state change + 'onNotification': function () {}, // onNotification(rfb, msg, level, options): notification for UI + 'onDisconnected': function () {}, // onDisconnected(rfb, reason): disconnection finished + 'onPasswordRequired': function () {}, // onPasswordRequired(rfb, msg): VNC password is required + 'onClipboard': function () {}, // onClipboard(rfb, text): RFB clipboard contents received + 'onBell': function () {}, // onBell(rfb): RFB Bell message received + 'onFBUReceive': function () {}, // onFBUReceive(rfb, fbu): RFB FBU received but not yet processed + 'onFBUComplete': function () {}, // onFBUComplete(rfb, fbu): RFB FBU received and processed + 'onFBResize': function () {}, // onFBResize(rfb, width, height): frame buffer resized + 'onDesktopName': function () {}, // onDesktopName(rfb, name): desktop name received + 'onXvpInit': function () {} // onXvpInit(version): XVP extensions active for this connection + }); + + // main setup + Log.Debug(">> RFB.constructor"); + + // populate encHandlers with bound versions + Object.keys(RFB.encodingHandlers).forEach(function (encName) { + this._encHandlers[encName] = RFB.encodingHandlers[encName].bind(this); + }.bind(this)); + + // Create lookup tables based on encoding number + for (var i = 0; i < this._encodings.length; i++) { + this._encHandlers[this._encodings[i][1]] = this._encHandlers[this._encodings[i][0]]; + this._encNames[this._encodings[i][1]] = this._encodings[i][0]; + this._encStats[this._encodings[i][1]] = [0, 0]; + } + + // NB: nothing that needs explicit teardown should be done + // before this point, since this can throw an exception + try { + this._display = new _display2.default({ target: this._target, + onFlush: this._onFlush.bind(this) }); + } catch (exc) { + Log.Error("Display exception: " + exc); + throw exc; + } + + this._keyboard = new _devices.Keyboard({ target: this._focusContainer, + onKeyPress: this._handleKeyPress.bind(this) }); + + this._mouse = new _devices.Mouse({ target: this._target, + onMouseButton: this._handleMouseButton.bind(this), + onMouseMove: this._handleMouseMove.bind(this), + notify: this._keyboard.sync.bind(this._keyboard) }); + + this._sock = new _websock2.default(); + this._sock.on('message', this._handle_message.bind(this)); + this._sock.on('open', function () { + if (this._rfb_connection_state === 'connecting' && this._rfb_init_state === '') { + this._rfb_init_state = 'ProtocolVersion'; + Log.Debug("Starting VNC handshake"); + } else { + this._fail("Unexpected server connection"); + } + }.bind(this)); + this._sock.on('close', function (e) { + Log.Warn("WebSocket on-close event"); + var msg = ""; + if (e.code) { + msg = " (code: " + e.code; + if (e.reason) { + msg += ", reason: " + e.reason; + } + msg += ")"; + } + switch (this._rfb_connection_state) { + case 'disconnecting': + this._updateConnectionState('disconnected'); + break; + case 'connecting': + this._fail('Failed to connect to server', msg); + break; + case 'connected': + // Handle disconnects that were initiated server-side + this._updateConnectionState('disconnecting'); + this._updateConnectionState('disconnected'); + break; + case 'disconnected': + this._fail("Unexpected server disconnect", "Already disconnected: " + msg); + break; + default: + this._fail("Unexpected server disconnect", "Not in any state yet: " + msg); + break; + } + this._sock.off('close'); + }.bind(this)); + this._sock.on('error', function (e) { + Log.Warn("WebSocket on-error event"); + }); + + this._init_vars(); + this._cleanup(); + + var rmode = this._display.get_render_mode(); + Log.Info("Using native WebSockets, render mode: " + rmode); + + Log.Debug("<< RFB.constructor"); +}; + +RFB.prototype = { + // Public methods + connect: function (host, port, password, path) { + this._rfb_host = host; + this._rfb_port = port; + this._rfb_password = password !== undefined ? password : ""; + this._rfb_path = path !== undefined ? path : ""; + + if (!this._rfb_host || !this._rfb_port) { + return this._fail((0, _localization2.default)("Must set host and port")); + } + + this._rfb_init_state = ''; + this._updateConnectionState('connecting'); + return true; + }, + + disconnect: function () { + this._updateConnectionState('disconnecting'); + this._sock.off('error'); + this._sock.off('message'); + this._sock.off('open'); + }, + + sendPassword: function (passwd) { + this._rfb_password = passwd; + setTimeout(this._init_msg.bind(this), 0); + }, + + sendCtrlAltDel: function () { + if (this._rfb_connection_state !== 'connected' || this._view_only) { + return false; + } + Log.Info("Sending Ctrl-Alt-Del"); + + RFB.messages.keyEvent(this._sock, _keysym2.default.XK_Control_L, 1); + RFB.messages.keyEvent(this._sock, _keysym2.default.XK_Alt_L, 1); + RFB.messages.keyEvent(this._sock, _keysym2.default.XK_Delete, 1); + RFB.messages.keyEvent(this._sock, _keysym2.default.XK_Delete, 0); + RFB.messages.keyEvent(this._sock, _keysym2.default.XK_Alt_L, 0); + RFB.messages.keyEvent(this._sock, _keysym2.default.XK_Control_L, 0); + return true; + }, + + xvpOp: function (ver, op) { + if (this._rfb_xvp_ver < ver) { + return false; + } + Log.Info("Sending XVP operation " + op + " (version " + ver + ")"); + this._sock.send_string("\xFA\x00" + String.fromCharCode(ver) + String.fromCharCode(op)); + return true; + }, + + xvpShutdown: function () { + return this.xvpOp(1, 2); + }, + + xvpReboot: function () { + return this.xvpOp(1, 3); + }, + + xvpReset: function () { + return this.xvpOp(1, 4); + }, + + // Send a key press. If 'down' is not specified then send a down key + // followed by an up key. + sendKey: function (keysym, down) { + if (this._rfb_connection_state !== 'connected' || this._view_only) { + return false; + } + if (typeof down !== 'undefined') { + Log.Info("Sending keysym (" + (down ? "down" : "up") + "): " + keysym); + RFB.messages.keyEvent(this._sock, keysym, down ? 1 : 0); + } else { + Log.Info("Sending keysym (down + up): " + keysym); + RFB.messages.keyEvent(this._sock, keysym, 1); + RFB.messages.keyEvent(this._sock, keysym, 0); + } + return true; + }, + + clipboardPasteFrom: function (text) { + if (this._rfb_connection_state !== 'connected' || this._view_only) { + return; + } + RFB.messages.clientCutText(this._sock, text); + }, + + // Requests a change of remote desktop size. This message is an extension + // and may only be sent if we have received an ExtendedDesktopSize message + requestDesktopSize: function (width, height) { + if (this._rfb_connection_state !== 'connected' || this._view_only) { + return false; + } + + if (this._supportsSetDesktopSize) { + RFB.messages.setDesktopSize(this._sock, width, height, this._screen_id, this._screen_flags); + this._sock.flush(); + return true; + } else { + return false; + } + }, + + // Private methods + + _connect: function () { + Log.Debug(">> RFB.connect"); + this._init_vars(); + + var uri; + if (typeof UsingSocketIO !== 'undefined') { + uri = 'http'; + } else { + uri = this._encrypt ? 'wss' : 'ws'; + } + + uri += '://' + this._rfb_host + ':' + this._rfb_port + '/' + this._rfb_path; + Log.Info("connecting to " + uri); + + try { + // WebSocket.onopen transitions to the RFB init states + this._sock.open(uri, this._wsProtocols); + } catch (e) { + if (e.name === 'SyntaxError') { + this._fail("Invalid host or port value given", e); + } else { + this._fail("Error while connecting", e); + } + } + + Log.Debug("<< RFB.connect"); + }, + + _disconnect: function () { + Log.Debug(">> RFB.disconnect"); + this._cleanup(); + this._sock.close(); + this._print_stats(); + Log.Debug("<< RFB.disconnect"); + }, + + _init_vars: function () { + // reset state + this._FBU.rects = 0; + this._FBU.subrects = 0; // RRE and HEXTILE + this._FBU.lines = 0; // RAW + this._FBU.tiles = 0; // HEXTILE + this._FBU.zlibs = []; // TIGHT zlib encoders + this._mouse_buttonMask = 0; + this._mouse_arr = []; + this._rfb_tightvnc = false; + + // Clear the per connection encoding stats + var i; + for (i = 0; i < this._encodings.length; i++) { + this._encStats[this._encodings[i][1]][0] = 0; + } + + for (i = 0; i < 4; i++) { + this._FBU.zlibs[i] = new _inflator2.default(); + } + }, + + _print_stats: function () { + Log.Info("Encoding stats for this connection:"); + var i, s; + for (i = 0; i < this._encodings.length; i++) { + s = this._encStats[this._encodings[i][1]]; + if (s[0] + s[1] > 0) { + Log.Info(" " + this._encodings[i][0] + ": " + s[0] + " rects"); + } + } + + Log.Info("Encoding stats since page load:"); + for (i = 0; i < this._encodings.length; i++) { + s = this._encStats[this._encodings[i][1]]; + Log.Info(" " + this._encodings[i][0] + ": " + s[1] + " rects"); + } + }, + + _cleanup: function () { + if (!this._view_only) { + this._keyboard.ungrab(); + } + if (!this._view_only) { + this._mouse.ungrab(); + } + this._display.defaultCursor(); + if (Log.get_logging() !== 'debug') { + // Show noVNC logo on load and when disconnected, unless in + // debug mode + this._display.clear(); + } + }, + + /* + * Connection states: + * connecting + * connected + * disconnecting + * disconnected - permanent state + */ + _updateConnectionState: function (state) { + var oldstate = this._rfb_connection_state; + + if (state === oldstate) { + Log.Debug("Already in state '" + state + "', ignoring"); + return; + } + + // The 'disconnected' state is permanent for each RFB object + if (oldstate === 'disconnected') { + Log.Error("Tried changing state of a disconnected RFB object"); + return; + } + + // Ensure proper transitions before doing anything + switch (state) { + case 'connected': + if (oldstate !== 'connecting') { + Log.Error("Bad transition to connected state, " + "previous connection state: " + oldstate); + return; + } + break; + + case 'disconnected': + if (oldstate !== 'disconnecting') { + Log.Error("Bad transition to disconnected state, " + "previous connection state: " + oldstate); + return; + } + break; + + case 'connecting': + if (oldstate !== '') { + Log.Error("Bad transition to connecting state, " + "previous connection state: " + oldstate); + return; + } + break; + + case 'disconnecting': + if (oldstate !== 'connected' && oldstate !== 'connecting') { + Log.Error("Bad transition to disconnecting state, " + "previous connection state: " + oldstate); + return; + } + break; + + default: + Log.Error("Unknown connection state: " + state); + return; + } + + // State change actions + + this._rfb_connection_state = state; + this._onUpdateState(this, state, oldstate); + + var smsg = "New state '" + state + "', was '" + oldstate + "'."; + Log.Debug(smsg); + + if (this._disconnTimer && state !== 'disconnecting') { + Log.Debug("Clearing disconnect timer"); + clearTimeout(this._disconnTimer); + this._disconnTimer = null; + + // make sure we don't get a double event + this._sock.off('close'); + } + + switch (state) { + case 'disconnected': + // Call onDisconnected callback after onUpdateState since + // we don't know if the UI only displays the latest message + if (this._rfb_disconnect_reason !== "") { + this._onDisconnected(this, this._rfb_disconnect_reason); + } else { + // No reason means clean disconnect + this._onDisconnected(this); + } + break; + + case 'connecting': + this._connect(); + break; + + case 'disconnecting': + this._disconnect(); + + this._disconnTimer = setTimeout(function () { + this._rfb_disconnect_reason = (0, _localization2.default)("Disconnect timeout"); + this._updateConnectionState('disconnected'); + }.bind(this), this._disconnectTimeout * 1000); + break; + } + }, + + /* Print errors and disconnect + * + * The optional parameter 'details' is used for information that + * should be logged but not sent to the user interface. + */ + _fail: function (msg, details) { + var fullmsg = msg; + if (typeof details !== 'undefined') { + fullmsg = msg + " (" + details + ")"; + } + switch (this._rfb_connection_state) { + case 'disconnecting': + Log.Error("Failed when disconnecting: " + fullmsg); + break; + case 'connected': + Log.Error("Failed while connected: " + fullmsg); + break; + case 'connecting': + Log.Error("Failed when connecting: " + fullmsg); + break; + default: + Log.Error("RFB failure: " + fullmsg); + break; + } + this._rfb_disconnect_reason = msg; //This is sent to the UI + + // Transition to disconnected without waiting for socket to close + this._updateConnectionState('disconnecting'); + this._updateConnectionState('disconnected'); + + return false; + }, + + /* + * Send a notification to the UI. Valid levels are: + * 'normal'|'warn'|'error' + * + * NOTE: Options could be added in the future. + * NOTE: If this function is called multiple times, remember that the + * interface could be only showing the latest notification. + */ + _notification: function (msg, level, options) { + switch (level) { + case 'normal': + case 'warn': + case 'error': + Log.Debug("Notification[" + level + "]:" + msg); + break; + default: + Log.Error("Invalid notification level: " + level); + return; + } + + if (options) { + this._onNotification(this, msg, level, options); + } else { + this._onNotification(this, msg, level); + } + }, + + _handle_message: function () { + if (this._sock.rQlen() === 0) { + Log.Warn("handle_message called on an empty receive queue"); + return; + } + + switch (this._rfb_connection_state) { + case 'disconnected': + Log.Error("Got data while disconnected"); + break; + case 'connected': + while (true) { + if (this._flushing) { + break; + } + if (!this._normal_msg()) { + break; + } + if (this._sock.rQlen() === 0) { + break; + } + } + break; + default: + this._init_msg(); + break; + } + }, + + _handleKeyPress: function (keyevent) { + if (this._view_only) { + return; + } // View only, skip keyboard, events + + var down = keyevent.type == 'keydown'; + if (this._qemuExtKeyEventSupported) { + var scancode = _xtscancodes2.default[keyevent.code]; + if (scancode) { + var keysym = keyevent.keysym; + RFB.messages.QEMUExtendedKeyEvent(this._sock, keysym, down, scancode); + } else { + Log.Error('Unable to find a xt scancode for code = ' + keyevent.code); + } + } else { + keysym = keyevent.keysym.keysym; + RFB.messages.keyEvent(this._sock, keysym, down); + } + }, + + _handleMouseButton: function (x, y, down, bmask) { + if (down) { + this._mouse_buttonMask |= bmask; + } else { + this._mouse_buttonMask ^= bmask; + } + + if (this._viewportDrag) { + if (down && !this._viewportDragging) { + this._viewportDragging = true; + this._viewportDragPos = { 'x': x, 'y': y }; + + // Skip sending mouse events + return; + } else { + this._viewportDragging = false; + + // If the viewport didn't actually move, then treat as a mouse click event + // Send the button down event here, as the button up event is sent at the end of this function + if (!this._viewportHasMoved && !this._view_only) { + RFB.messages.pointerEvent(this._sock, this._display.absX(x), this._display.absY(y), bmask); + } + this._viewportHasMoved = false; + } + } + + if (this._view_only) { + return; + } // View only, skip mouse events + + if (this._rfb_connection_state !== 'connected') { + return; + } + RFB.messages.pointerEvent(this._sock, this._display.absX(x), this._display.absY(y), this._mouse_buttonMask); + }, + + _handleMouseMove: function (x, y) { + if (this._viewportDragging) { + var deltaX = this._viewportDragPos.x - x; + var deltaY = this._viewportDragPos.y - y; + + // The goal is to trigger on a certain physical width, the + // devicePixelRatio brings us a bit closer but is not optimal. + var dragThreshold = 10 * (window.devicePixelRatio || 1); + + if (this._viewportHasMoved || Math.abs(deltaX) > dragThreshold || Math.abs(deltaY) > dragThreshold) { + this._viewportHasMoved = true; + + this._viewportDragPos = { 'x': x, 'y': y }; + this._display.viewportChangePos(deltaX, deltaY); + } + + // Skip sending mouse events + return; + } + + if (this._view_only) { + return; + } // View only, skip mouse events + + if (this._rfb_connection_state !== 'connected') { + return; + } + RFB.messages.pointerEvent(this._sock, this._display.absX(x), this._display.absY(y), this._mouse_buttonMask); + }, + + // Message Handlers + + _negotiate_protocol_version: function () { + if (this._sock.rQlen() < 12) { + return this._fail("Error while negotiating with server", "Incomplete protocol version"); + } + + var sversion = this._sock.rQshiftStr(12).substr(4, 7); + Log.Info("Server ProtocolVersion: " + sversion); + var is_repeater = 0; + switch (sversion) { + case "000.000": + // UltraVNC repeater + is_repeater = 1; + break; + case "003.003": + case "003.006": // UltraVNC + case "003.889": + // Apple Remote Desktop + this._rfb_version = 3.3; + break; + case "003.007": + this._rfb_version = 3.7; + break; + case "003.008": + case "004.000": // Intel AMT KVM + case "004.001": // RealVNC 4.6 + case "005.000": + // RealVNC 5.3 + this._rfb_version = 3.8; + break; + default: + return this._fail("Unsupported server", "Invalid server version: " + sversion); + } + + if (is_repeater) { + var repeaterID = this._repeaterID; + while (repeaterID.length < 250) { + repeaterID += "\0"; + } + this._sock.send_string(repeaterID); + return true; + } + + if (this._rfb_version > this._rfb_max_version) { + this._rfb_version = this._rfb_max_version; + } + + var cversion = "00" + parseInt(this._rfb_version, 10) + ".00" + this._rfb_version * 10 % 10; + this._sock.send_string("RFB " + cversion + "\n"); + Log.Debug('Sent ProtocolVersion: ' + cversion); + + this._rfb_init_state = 'Security'; + }, + + _negotiate_security: function () { + // Polyfill since IE and PhantomJS doesn't have + // TypedArray.includes() + function includes(item, array) { + for (var i = 0; i < array.length; i++) { + if (array[i] === item) { + return true; + } + } + return false; + } + + if (this._rfb_version >= 3.7) { + // Server sends supported list, client decides + var num_types = this._sock.rQshift8(); + if (this._sock.rQwait("security type", num_types, 1)) { + return false; + } + + if (num_types === 0) { + var strlen = this._sock.rQshift32(); + var reason = this._sock.rQshiftStr(strlen); + return this._fail("Error while negotiating with server", "Security failure: " + reason); + } + + var types = this._sock.rQshiftBytes(num_types); + Log.Debug("Server security types: " + types); + + // Look for each auth in preferred order + this._rfb_auth_scheme = 0; + if (includes(1, types)) { + this._rfb_auth_scheme = 1; // None + } else if (includes(22, types)) { + this._rfb_auth_scheme = 22; // XVP + } else if (includes(16, types)) { + this._rfb_auth_scheme = 16; // Tight + } else if (includes(2, types)) { + this._rfb_auth_scheme = 2; // VNC Auth + } else { + return this._fail("Unsupported server", "Unsupported security types: " + types); + } + + this._sock.send([this._rfb_auth_scheme]); + } else { + // Server decides + if (this._sock.rQwait("security scheme", 4)) { + return false; + } + this._rfb_auth_scheme = this._sock.rQshift32(); + } + + this._rfb_init_state = 'Authentication'; + Log.Debug('Authenticating using scheme: ' + this._rfb_auth_scheme); + + return this._init_msg(); // jump to authentication + }, + + // authentication + _negotiate_xvp_auth: function () { + var xvp_sep = this._xvp_password_sep; + var xvp_auth = this._rfb_password.split(xvp_sep); + if (xvp_auth.length < 3) { + var msg = 'XVP credentials required (user' + xvp_sep + 'target' + xvp_sep + 'password) -- got only ' + this._rfb_password; + this._onPasswordRequired(this, msg); + return false; + } + + var xvp_auth_str = String.fromCharCode(xvp_auth[0].length) + String.fromCharCode(xvp_auth[1].length) + xvp_auth[0] + xvp_auth[1]; + this._sock.send_string(xvp_auth_str); + this._rfb_password = xvp_auth.slice(2).join(xvp_sep); + this._rfb_auth_scheme = 2; + return this._negotiate_authentication(); + }, + + _negotiate_std_vnc_auth: function () { + if (this._rfb_password.length === 0) { + this._onPasswordRequired(this); + return false; + } + + if (this._sock.rQwait("auth challenge", 16)) { + return false; + } + + // TODO(directxman12): make genDES not require an Array + var challenge = Array.prototype.slice.call(this._sock.rQshiftBytes(16)); + var response = RFB.genDES(this._rfb_password, challenge); + this._sock.send(response); + this._rfb_init_state = "SecurityResult"; + return true; + }, + + _negotiate_tight_tunnels: function (numTunnels) { + var clientSupportedTunnelTypes = { + 0: { vendor: 'TGHT', signature: 'NOTUNNEL' } + }; + var serverSupportedTunnelTypes = {}; + // receive tunnel capabilities + for (var i = 0; i < numTunnels; i++) { + var cap_code = this._sock.rQshift32(); + var cap_vendor = this._sock.rQshiftStr(4); + var cap_signature = this._sock.rQshiftStr(8); + serverSupportedTunnelTypes[cap_code] = { vendor: cap_vendor, signature: cap_signature }; + } + + // choose the notunnel type + if (serverSupportedTunnelTypes[0]) { + if (serverSupportedTunnelTypes[0].vendor != clientSupportedTunnelTypes[0].vendor || serverSupportedTunnelTypes[0].signature != clientSupportedTunnelTypes[0].signature) { + return this._fail("Unsupported server", "Client's tunnel type had the incorrect " + "vendor or signature"); + } + this._sock.send([0, 0, 0, 0]); // use NOTUNNEL + return false; // wait until we receive the sub auth count to continue + } else { + return this._fail("Unsupported server", "Server wanted tunnels, but doesn't support " + "the notunnel type"); + } + }, + + _negotiate_tight_auth: function () { + if (!this._rfb_tightvnc) { + // first pass, do the tunnel negotiation + if (this._sock.rQwait("num tunnels", 4)) { + return false; + } + var numTunnels = this._sock.rQshift32(); + if (numTunnels > 0 && this._sock.rQwait("tunnel capabilities", 16 * numTunnels, 4)) { + return false; + } + + this._rfb_tightvnc = true; + + if (numTunnels > 0) { + this._negotiate_tight_tunnels(numTunnels); + return false; // wait until we receive the sub auth to continue + } + } + + // second pass, do the sub-auth negotiation + if (this._sock.rQwait("sub auth count", 4)) { + return false; + } + var subAuthCount = this._sock.rQshift32(); + if (subAuthCount === 0) { + // empty sub-auth list received means 'no auth' subtype selected + this._rfb_init_state = 'SecurityResult'; + return true; + } + + if (this._sock.rQwait("sub auth capabilities", 16 * subAuthCount, 4)) { + return false; + } + + var clientSupportedTypes = { + 'STDVNOAUTH__': 1, + 'STDVVNCAUTH_': 2 + }; + + var serverSupportedTypes = []; + + for (var i = 0; i < subAuthCount; i++) { + var capNum = this._sock.rQshift32(); + var capabilities = this._sock.rQshiftStr(12); + serverSupportedTypes.push(capabilities); + } + + for (var authType in clientSupportedTypes) { + if (serverSupportedTypes.indexOf(authType) != -1) { + this._sock.send([0, 0, 0, clientSupportedTypes[authType]]); + + switch (authType) { + case 'STDVNOAUTH__': + // no auth + this._rfb_init_state = 'SecurityResult'; + return true; + case 'STDVVNCAUTH_': + // VNC auth + this._rfb_auth_scheme = 2; + return this._init_msg(); + default: + return this._fail("Unsupported server", "Unsupported tiny auth scheme: " + authType); + } + } + } + + return this._fail("Unsupported server", "No supported sub-auth types!"); + }, + + _negotiate_authentication: function () { + switch (this._rfb_auth_scheme) { + case 0: + // connection failed + if (this._sock.rQwait("auth reason", 4)) { + return false; + } + var strlen = this._sock.rQshift32(); + var reason = this._sock.rQshiftStr(strlen); + return this._fail("Authentication failure", reason); + + case 1: + // no auth + if (this._rfb_version >= 3.8) { + this._rfb_init_state = 'SecurityResult'; + return true; + } + this._rfb_init_state = 'ClientInitialisation'; + return this._init_msg(); + + case 22: + // XVP auth + return this._negotiate_xvp_auth(); + + case 2: + // VNC authentication + return this._negotiate_std_vnc_auth(); + + case 16: + // TightVNC Security Type + return this._negotiate_tight_auth(); + + default: + return this._fail("Unsupported server", "Unsupported auth scheme: " + this._rfb_auth_scheme); + } + }, + + _handle_security_result: function () { + if (this._sock.rQwait('VNC auth response ', 4)) { + return false; + } + switch (this._sock.rQshift32()) { + case 0: + // OK + this._rfb_init_state = 'ClientInitialisation'; + Log.Debug('Authentication OK'); + return this._init_msg(); + case 1: + // failed + if (this._rfb_version >= 3.8) { + var length = this._sock.rQshift32(); + if (this._sock.rQwait("SecurityResult reason", length, 8)) { + return false; + } + var reason = this._sock.rQshiftStr(length); + return this._fail("Authentication failure", reason); + } else { + return this._fail("Authentication failure"); + } + return false; + case 2: + return this._fail("Too many authentication attempts"); + default: + return this._fail("Unsupported server", "Unknown SecurityResult"); + } + }, + + _negotiate_server_init: function () { + if (this._sock.rQwait("server initialization", 24)) { + return false; + } + + /* Screen size */ + this._fb_width = this._sock.rQshift16(); + this._fb_height = this._sock.rQshift16(); + this._destBuff = new Uint8Array(this._fb_width * this._fb_height * 4); + + /* PIXEL_FORMAT */ + var bpp = this._sock.rQshift8(); + var depth = this._sock.rQshift8(); + var big_endian = this._sock.rQshift8(); + var true_color = this._sock.rQshift8(); + + var red_max = this._sock.rQshift16(); + var green_max = this._sock.rQshift16(); + var blue_max = this._sock.rQshift16(); + var red_shift = this._sock.rQshift8(); + var green_shift = this._sock.rQshift8(); + var blue_shift = this._sock.rQshift8(); + this._sock.rQskipBytes(3); // padding + + // NB(directxman12): we don't want to call any callbacks or print messages until + // *after* we're past the point where we could backtrack + + /* Connection name/title */ + var name_length = this._sock.rQshift32(); + if (this._sock.rQwait('server init name', name_length, 24)) { + return false; + } + this._fb_name = (0, _strings.decodeUTF8)(this._sock.rQshiftStr(name_length)); + + if (this._rfb_tightvnc) { + if (this._sock.rQwait('TightVNC extended server init header', 8, 24 + name_length)) { + return false; + } + // In TightVNC mode, ServerInit message is extended + var numServerMessages = this._sock.rQshift16(); + var numClientMessages = this._sock.rQshift16(); + var numEncodings = this._sock.rQshift16(); + this._sock.rQskipBytes(2); // padding + + var totalMessagesLength = (numServerMessages + numClientMessages + numEncodings) * 16; + if (this._sock.rQwait('TightVNC extended server init header', totalMessagesLength, 32 + name_length)) { + return false; + } + + // we don't actually do anything with the capability information that TIGHT sends, + // so we just skip the all of this. + + // TIGHT server message capabilities + this._sock.rQskipBytes(16 * numServerMessages); + + // TIGHT client message capabilities + this._sock.rQskipBytes(16 * numClientMessages); + + // TIGHT encoding capabilities + this._sock.rQskipBytes(16 * numEncodings); + } + + // NB(directxman12): these are down here so that we don't run them multiple times + // if we backtrack + Log.Info("Screen: " + this._fb_width + "x" + this._fb_height + ", bpp: " + bpp + ", depth: " + depth + ", big_endian: " + big_endian + ", true_color: " + true_color + ", red_max: " + red_max + ", green_max: " + green_max + ", blue_max: " + blue_max + ", red_shift: " + red_shift + ", green_shift: " + green_shift + ", blue_shift: " + blue_shift); + + if (big_endian !== 0) { + Log.Warn("Server native endian is not little endian"); + } + + if (red_shift !== 16) { + Log.Warn("Server native red-shift is not 16"); + } + + if (blue_shift !== 0) { + Log.Warn("Server native blue-shift is not 0"); + } + + // we're past the point where we could backtrack, so it's safe to call this + this._onDesktopName(this, this._fb_name); + + if (this._true_color && this._fb_name === "Intel(r) AMT KVM") { + Log.Warn("Intel AMT KVM only supports 8/16 bit depths. Disabling true color"); + this._true_color = false; + } + + this._display.set_true_color(this._true_color); + this._display.resize(this._fb_width, this._fb_height); + this._onFBResize(this, this._fb_width, this._fb_height); + + if (!this._view_only) { + this._keyboard.grab(); + } + if (!this._view_only) { + this._mouse.grab(); + } + + if (this._true_color) { + this._fb_Bpp = 4; + this._fb_depth = 3; + } else { + this._fb_Bpp = 1; + this._fb_depth = 1; + } + + RFB.messages.pixelFormat(this._sock, this._fb_Bpp, this._fb_depth, this._true_color); + RFB.messages.clientEncodings(this._sock, this._encodings, this._local_cursor, this._true_color); + RFB.messages.fbUpdateRequest(this._sock, false, 0, 0, this._fb_width, this._fb_height); + + this._timing.fbu_rt_start = new Date().getTime(); + this._timing.pixels = 0; + + this._updateConnectionState('connected'); + return true; + }, + + /* RFB protocol initialization states: + * ProtocolVersion + * Security + * Authentication + * SecurityResult + * ClientInitialization - not triggered by server message + * ServerInitialization + */ + _init_msg: function () { + switch (this._rfb_init_state) { + case 'ProtocolVersion': + return this._negotiate_protocol_version(); + + case 'Security': + return this._negotiate_security(); + + case 'Authentication': + return this._negotiate_authentication(); + + case 'SecurityResult': + return this._handle_security_result(); + + case 'ClientInitialisation': + this._sock.send([this._shared ? 1 : 0]); // ClientInitialisation + this._rfb_init_state = 'ServerInitialisation'; + return true; + + case 'ServerInitialisation': + return this._negotiate_server_init(); + + default: + return this._fail("Internal error", "Unknown init state: " + this._rfb_init_state); + } + }, + + _handle_set_colour_map_msg: function () { + Log.Debug("SetColorMapEntries"); + this._sock.rQskip8(); // Padding + + var first_colour = this._sock.rQshift16(); + var num_colours = this._sock.rQshift16(); + if (this._sock.rQwait('SetColorMapEntries', num_colours * 6, 6)) { + return false; + } + + for (var c = 0; c < num_colours; c++) { + var red = parseInt(this._sock.rQshift16() / 256, 10); + var green = parseInt(this._sock.rQshift16() / 256, 10); + var blue = parseInt(this._sock.rQshift16() / 256, 10); + this._display.set_colourMap([blue, green, red], first_colour + c); + } + Log.Debug("colourMap: " + this._display.get_colourMap()); + Log.Info("Registered " + num_colours + " colourMap entries"); + + return true; + }, + + _handle_server_cut_text: function () { + Log.Debug("ServerCutText"); + + if (this._sock.rQwait("ServerCutText header", 7, 1)) { + return false; + } + this._sock.rQskipBytes(3); // Padding + var length = this._sock.rQshift32(); + if (this._sock.rQwait("ServerCutText", length, 8)) { + return false; + } + + var text = this._sock.rQshiftStr(length); + + if (this._view_only) { + return true; + } + + this._onClipboard(this, text); + + return true; + }, + + _handle_server_fence_msg: function () { + if (this._sock.rQwait("ServerFence header", 8, 1)) { + return false; + } + this._sock.rQskipBytes(3); // Padding + var flags = this._sock.rQshift32(); + var length = this._sock.rQshift8(); + + if (this._sock.rQwait("ServerFence payload", length, 9)) { + return false; + } + + if (length > 64) { + Log.Warn("Bad payload length (" + length + ") in fence response"); + length = 64; + } + + var payload = this._sock.rQshiftStr(length); + + this._supportsFence = true; + + /* + * Fence flags + * + * (1<<0) - BlockBefore + * (1<<1) - BlockAfter + * (1<<2) - SyncNext + * (1<<31) - Request + */ + + if (!(flags & 1 << 31)) { + return this._fail("Internal error", "Unexpected fence response"); + } + + // Filter out unsupported flags + // FIXME: support syncNext + flags &= 1 << 0 | 1 << 1; + + // BlockBefore and BlockAfter are automatically handled by + // the fact that we process each incoming message + // synchronuosly. + RFB.messages.clientFence(this._sock, flags, payload); + + return true; + }, + + _handle_xvp_msg: function () { + if (this._sock.rQwait("XVP version and message", 3, 1)) { + return false; + } + this._sock.rQskip8(); // Padding + var xvp_ver = this._sock.rQshift8(); + var xvp_msg = this._sock.rQshift8(); + + switch (xvp_msg) { + case 0: + // XVP_FAIL + Log.Error("Operation Failed"); + this._notification("XVP Operation Failed", 'error'); + break; + case 1: + // XVP_INIT + this._rfb_xvp_ver = xvp_ver; + Log.Info("XVP extensions enabled (version " + this._rfb_xvp_ver + ")"); + this._onXvpInit(this._rfb_xvp_ver); + break; + default: + this._fail("Unexpected server message", "Illegal server XVP message " + xvp_msg); + break; + } + + return true; + }, + + _normal_msg: function () { + var msg_type; + + if (this._FBU.rects > 0) { + msg_type = 0; + } else { + msg_type = this._sock.rQshift8(); + } + + switch (msg_type) { + case 0: + // FramebufferUpdate + var ret = this._framebufferUpdate(); + if (ret && !this._enabledContinuousUpdates) { + RFB.messages.fbUpdateRequest(this._sock, true, 0, 0, this._fb_width, this._fb_height); + } + return ret; + + case 1: + // SetColorMapEntries + return this._handle_set_colour_map_msg(); + + case 2: + // Bell + Log.Debug("Bell"); + this._onBell(this); + return true; + + case 3: + // ServerCutText + return this._handle_server_cut_text(); + + case 150: + // EndOfContinuousUpdates + var first = !this._supportsContinuousUpdates; + this._supportsContinuousUpdates = true; + this._enabledContinuousUpdates = false; + if (first) { + this._enabledContinuousUpdates = true; + this._updateContinuousUpdates(); + Log.Info("Enabling continuous updates."); + } else { + // FIXME: We need to send a framebufferupdaterequest here + // if we add support for turning off continuous updates + } + return true; + + case 248: + // ServerFence + return this._handle_server_fence_msg(); + + case 250: + // XVP + return this._handle_xvp_msg(); + + default: + this._fail("Unexpected server message", "Type:" + msg_type); + Log.Debug("sock.rQslice(0, 30): " + this._sock.rQslice(0, 30)); + return true; + } + }, + + _onFlush: function () { + this._flushing = false; + // Resume processing + if (this._sock.rQlen() > 0) { + this._handle_message(); + } + }, + + _framebufferUpdate: function () { + var ret = true; + var now; + + if (this._FBU.rects === 0) { + if (this._sock.rQwait("FBU header", 3, 1)) { + return false; + } + this._sock.rQskip8(); // Padding + this._FBU.rects = this._sock.rQshift16(); + this._FBU.bytes = 0; + this._timing.cur_fbu = 0; + if (this._timing.fbu_rt_start > 0) { + now = new Date().getTime(); + Log.Info("First FBU latency: " + (now - this._timing.fbu_rt_start)); + } + + // Make sure the previous frame is fully rendered first + // to avoid building up an excessive queue + if (this._display.pending()) { + this._flushing = true; + this._display.flush(); + return false; + } + } + + while (this._FBU.rects > 0) { + if (this._rfb_connection_state !== 'connected') { + return false; + } + + if (this._sock.rQwait("FBU", this._FBU.bytes)) { + return false; + } + if (this._FBU.bytes === 0) { + if (this._sock.rQwait("rect header", 12)) { + return false; + } + /* New FramebufferUpdate */ + + var hdr = this._sock.rQshiftBytes(12); + this._FBU.x = (hdr[0] << 8) + hdr[1]; + this._FBU.y = (hdr[2] << 8) + hdr[3]; + this._FBU.width = (hdr[4] << 8) + hdr[5]; + this._FBU.height = (hdr[6] << 8) + hdr[7]; + this._FBU.encoding = parseInt((hdr[8] << 24) + (hdr[9] << 16) + (hdr[10] << 8) + hdr[11], 10); + + this._onFBUReceive(this, { 'x': this._FBU.x, 'y': this._FBU.y, + 'width': this._FBU.width, 'height': this._FBU.height, + 'encoding': this._FBU.encoding, + 'encodingName': this._encNames[this._FBU.encoding] }); + + if (!this._encNames[this._FBU.encoding]) { + this._fail("Unexpected server message", "Unsupported encoding " + this._FBU.encoding); + return false; + } + } + + this._timing.last_fbu = new Date().getTime(); + + ret = this._encHandlers[this._FBU.encoding](); + + now = new Date().getTime(); + this._timing.cur_fbu += now - this._timing.last_fbu; + + if (ret) { + this._encStats[this._FBU.encoding][0]++; + this._encStats[this._FBU.encoding][1]++; + this._timing.pixels += this._FBU.width * this._FBU.height; + } + + if (this._timing.pixels >= this._fb_width * this._fb_height) { + if (this._FBU.width === this._fb_width && this._FBU.height === this._fb_height || this._timing.fbu_rt_start > 0) { + this._timing.full_fbu_total += this._timing.cur_fbu; + this._timing.full_fbu_cnt++; + Log.Info("Timing of full FBU, curr: " + this._timing.cur_fbu + ", total: " + this._timing.full_fbu_total + ", cnt: " + this._timing.full_fbu_cnt + ", avg: " + this._timing.full_fbu_total / this._timing.full_fbu_cnt); + } + + if (this._timing.fbu_rt_start > 0) { + var fbu_rt_diff = now - this._timing.fbu_rt_start; + this._timing.fbu_rt_total += fbu_rt_diff; + this._timing.fbu_rt_cnt++; + Log.Info("full FBU round-trip, cur: " + fbu_rt_diff + ", total: " + this._timing.fbu_rt_total + ", cnt: " + this._timing.fbu_rt_cnt + ", avg: " + this._timing.fbu_rt_total / this._timing.fbu_rt_cnt); + this._timing.fbu_rt_start = 0; + } + } + + if (!ret) { + return ret; + } // need more data + } + + this._display.flip(); + + this._onFBUComplete(this, { 'x': this._FBU.x, 'y': this._FBU.y, + 'width': this._FBU.width, 'height': this._FBU.height, + 'encoding': this._FBU.encoding, + 'encodingName': this._encNames[this._FBU.encoding] }); + + return true; // We finished this FBU + }, + + _updateContinuousUpdates: function () { + if (!this._enabledContinuousUpdates) { + return; + } + + RFB.messages.enableContinuousUpdates(this._sock, true, 0, 0, this._fb_width, this._fb_height); + } +}; + +(0, _properties.make_properties)(RFB, [['target', 'wo', 'dom'], // VNC display rendering Canvas object +['focusContainer', 'wo', 'dom'], // DOM element that captures keyboard input +['encrypt', 'rw', 'bool'], // Use TLS/SSL/wss encryption +['true_color', 'rw', 'bool'], // Request true color pixel data +['local_cursor', 'rw', 'bool'], // Request locally rendered cursor +['shared', 'rw', 'bool'], // Request shared mode +['view_only', 'rw', 'bool'], // Disable client mouse/keyboard +['xvp_password_sep', 'rw', 'str'], // Separator for XVP password fields +['disconnectTimeout', 'rw', 'int'], // Time (s) to wait for disconnection +['wsProtocols', 'rw', 'arr'], // Protocols to use in the WebSocket connection +['repeaterID', 'rw', 'str'], // [UltraVNC] RepeaterID to connect to +['viewportDrag', 'rw', 'bool'], // Move the viewport on mouse drags + +// Callback functions +['onUpdateState', 'rw', 'func'], // onUpdateState(rfb, state, oldstate): connection state change +['onNotification', 'rw', 'func'], // onNotification(rfb, msg, level, options): notification for the UI +['onDisconnected', 'rw', 'func'], // onDisconnected(rfb, reason): disconnection finished +['onPasswordRequired', 'rw', 'func'], // onPasswordRequired(rfb, msg): VNC password is required +['onClipboard', 'rw', 'func'], // onClipboard(rfb, text): RFB clipboard contents received +['onBell', 'rw', 'func'], // onBell(rfb): RFB Bell message received +['onFBUReceive', 'rw', 'func'], // onFBUReceive(rfb, fbu): RFB FBU received but not yet processed +['onFBUComplete', 'rw', 'func'], // onFBUComplete(rfb, fbu): RFB FBU received and processed +['onFBResize', 'rw', 'func'], // onFBResize(rfb, width, height): frame buffer resized +['onDesktopName', 'rw', 'func'], // onDesktopName(rfb, name): desktop name received +['onXvpInit', 'rw', 'func'] // onXvpInit(version): XVP extensions active for this connection +]); + +RFB.prototype.set_local_cursor = function (cursor) { + if (!cursor || cursor in { '0': 1, 'no': 1, 'false': 1 }) { + this._local_cursor = false; + this._display.disableLocalCursor(); //Only show server-side cursor + } else { + if (this._display.get_cursor_uri()) { + this._local_cursor = true; + } else { + Log.Warn("Browser does not support local cursor"); + this._display.disableLocalCursor(); + } + } + + // Need to send an updated list of encodings if we are connected + if (this._rfb_connection_state === "connected") { + RFB.messages.clientEncodings(this._sock, this._encodings, cursor, this._true_color); + } +}; + +RFB.prototype.set_view_only = function (view_only) { + this._view_only = view_only; + + if (this._rfb_connection_state === "connecting" || this._rfb_connection_state === "connected") { + if (view_only) { + this._keyboard.ungrab(); + this._mouse.ungrab(); + } else { + this._keyboard.grab(); + this._mouse.grab(); + } + } +}; + +RFB.prototype.get_display = function () { + return this._display; +}; +RFB.prototype.get_keyboard = function () { + return this._keyboard; +}; +RFB.prototype.get_mouse = function () { + return this._mouse; +}; + +// Class Methods +RFB.messages = { + keyEvent: function (sock, keysym, down) { + var buff = sock._sQ; + var offset = sock._sQlen; + + buff[offset] = 4; // msg-type + buff[offset + 1] = down; + + buff[offset + 2] = 0; + buff[offset + 3] = 0; + + buff[offset + 4] = keysym >> 24; + buff[offset + 5] = keysym >> 16; + buff[offset + 6] = keysym >> 8; + buff[offset + 7] = keysym; + + sock._sQlen += 8; + sock.flush(); + }, + + QEMUExtendedKeyEvent: function (sock, keysym, down, keycode) { + function getRFBkeycode(xt_scancode) { + var upperByte = keycode >> 8; + var lowerByte = keycode & 0x00ff; + if (upperByte === 0xe0 && lowerByte < 0x7f) { + lowerByte = lowerByte | 0x80; + return lowerByte; + } + return xt_scancode; + } + + var buff = sock._sQ; + var offset = sock._sQlen; + + buff[offset] = 255; // msg-type + buff[offset + 1] = 0; // sub msg-type + + buff[offset + 2] = down >> 8; + buff[offset + 3] = down; + + buff[offset + 4] = keysym >> 24; + buff[offset + 5] = keysym >> 16; + buff[offset + 6] = keysym >> 8; + buff[offset + 7] = keysym; + + var RFBkeycode = getRFBkeycode(keycode); + + buff[offset + 8] = RFBkeycode >> 24; + buff[offset + 9] = RFBkeycode >> 16; + buff[offset + 10] = RFBkeycode >> 8; + buff[offset + 11] = RFBkeycode; + + sock._sQlen += 12; + sock.flush(); + }, + + pointerEvent: function (sock, x, y, mask) { + var buff = sock._sQ; + var offset = sock._sQlen; + + buff[offset] = 5; // msg-type + + buff[offset + 1] = mask; + + buff[offset + 2] = x >> 8; + buff[offset + 3] = x; + + buff[offset + 4] = y >> 8; + buff[offset + 5] = y; + + sock._sQlen += 6; + sock.flush(); + }, + + // TODO(directxman12): make this unicode compatible? + clientCutText: function (sock, text) { + var buff = sock._sQ; + var offset = sock._sQlen; + + buff[offset] = 6; // msg-type + + buff[offset + 1] = 0; // padding + buff[offset + 2] = 0; // padding + buff[offset + 3] = 0; // padding + + var n = text.length; + + buff[offset + 4] = n >> 24; + buff[offset + 5] = n >> 16; + buff[offset + 6] = n >> 8; + buff[offset + 7] = n; + + for (var i = 0; i < n; i++) { + buff[offset + 8 + i] = text.charCodeAt(i); + } + + sock._sQlen += 8 + n; + sock.flush(); + }, + + setDesktopSize: function (sock, width, height, id, flags) { + var buff = sock._sQ; + var offset = sock._sQlen; + + buff[offset] = 251; // msg-type + buff[offset + 1] = 0; // padding + buff[offset + 2] = width >> 8; // width + buff[offset + 3] = width; + buff[offset + 4] = height >> 8; // height + buff[offset + 5] = height; + + buff[offset + 6] = 1; // number-of-screens + buff[offset + 7] = 0; // padding + + // screen array + buff[offset + 8] = id >> 24; // id + buff[offset + 9] = id >> 16; + buff[offset + 10] = id >> 8; + buff[offset + 11] = id; + buff[offset + 12] = 0; // x-position + buff[offset + 13] = 0; + buff[offset + 14] = 0; // y-position + buff[offset + 15] = 0; + buff[offset + 16] = width >> 8; // width + buff[offset + 17] = width; + buff[offset + 18] = height >> 8; // height + buff[offset + 19] = height; + buff[offset + 20] = flags >> 24; // flags + buff[offset + 21] = flags >> 16; + buff[offset + 22] = flags >> 8; + buff[offset + 23] = flags; + + sock._sQlen += 24; + sock.flush(); + }, + + clientFence: function (sock, flags, payload) { + var buff = sock._sQ; + var offset = sock._sQlen; + + buff[offset] = 248; // msg-type + + buff[offset + 1] = 0; // padding + buff[offset + 2] = 0; // padding + buff[offset + 3] = 0; // padding + + buff[offset + 4] = flags >> 24; // flags + buff[offset + 5] = flags >> 16; + buff[offset + 6] = flags >> 8; + buff[offset + 7] = flags; + + var n = payload.length; + + buff[offset + 8] = n; // length + + for (var i = 0; i < n; i++) { + buff[offset + 9 + i] = payload.charCodeAt(i); + } + + sock._sQlen += 9 + n; + sock.flush(); + }, + + enableContinuousUpdates: function (sock, enable, x, y, width, height) { + var buff = sock._sQ; + var offset = sock._sQlen; + + buff[offset] = 150; // msg-type + buff[offset + 1] = enable; // enable-flag + + buff[offset + 2] = x >> 8; // x + buff[offset + 3] = x; + buff[offset + 4] = y >> 8; // y + buff[offset + 5] = y; + buff[offset + 6] = width >> 8; // width + buff[offset + 7] = width; + buff[offset + 8] = height >> 8; // height + buff[offset + 9] = height; + + sock._sQlen += 10; + sock.flush(); + }, + + pixelFormat: function (sock, bpp, depth, true_color) { + var buff = sock._sQ; + var offset = sock._sQlen; + + buff[offset] = 0; // msg-type + + buff[offset + 1] = 0; // padding + buff[offset + 2] = 0; // padding + buff[offset + 3] = 0; // padding + + buff[offset + 4] = bpp * 8; // bits-per-pixel + buff[offset + 5] = depth * 8; // depth + buff[offset + 6] = 0; // little-endian + buff[offset + 7] = true_color ? 1 : 0; // true-color + + buff[offset + 8] = 0; // red-max + buff[offset + 9] = 255; // red-max + + buff[offset + 10] = 0; // green-max + buff[offset + 11] = 255; // green-max + + buff[offset + 12] = 0; // blue-max + buff[offset + 13] = 255; // blue-max + + buff[offset + 14] = 16; // red-shift + buff[offset + 15] = 8; // green-shift + buff[offset + 16] = 0; // blue-shift + + buff[offset + 17] = 0; // padding + buff[offset + 18] = 0; // padding + buff[offset + 19] = 0; // padding + + sock._sQlen += 20; + sock.flush(); + }, + + clientEncodings: function (sock, encodings, local_cursor, true_color) { + var buff = sock._sQ; + var offset = sock._sQlen; + + buff[offset] = 2; // msg-type + buff[offset + 1] = 0; // padding + + // offset + 2 and offset + 3 are encoding count + + var i, + j = offset + 4, + cnt = 0; + for (i = 0; i < encodings.length; i++) { + if (encodings[i][0] === "Cursor" && !local_cursor) { + Log.Debug("Skipping Cursor pseudo-encoding"); + } else if (encodings[i][0] === "TIGHT" && !true_color) { + // TODO: remove this when we have tight+non-true-color + Log.Warn("Skipping tight as it is only supported with true color"); + } else { + var enc = encodings[i][1]; + buff[j] = enc >> 24; + buff[j + 1] = enc >> 16; + buff[j + 2] = enc >> 8; + buff[j + 3] = enc; + + j += 4; + cnt++; + } + } + + buff[offset + 2] = cnt >> 8; + buff[offset + 3] = cnt; + + sock._sQlen += j - offset; + sock.flush(); + }, + + fbUpdateRequest: function (sock, incremental, x, y, w, h) { + var buff = sock._sQ; + var offset = sock._sQlen; + + if (typeof x === "undefined") { + x = 0; + } + if (typeof y === "undefined") { + y = 0; + } + + buff[offset] = 3; // msg-type + buff[offset + 1] = incremental ? 1 : 0; + + buff[offset + 2] = x >> 8 & 0xFF; + buff[offset + 3] = x & 0xFF; + + buff[offset + 4] = y >> 8 & 0xFF; + buff[offset + 5] = y & 0xFF; + + buff[offset + 6] = w >> 8 & 0xFF; + buff[offset + 7] = w & 0xFF; + + buff[offset + 8] = h >> 8 & 0xFF; + buff[offset + 9] = h & 0xFF; + + sock._sQlen += 10; + sock.flush(); + } +}; + +RFB.genDES = function (password, challenge) { + var passwd = []; + for (var i = 0; i < password.length; i++) { + passwd.push(password.charCodeAt(i)); + } + return new _des2.default(passwd).encrypt(challenge); +}; + +RFB.encodingHandlers = { + RAW: function () { + if (this._FBU.lines === 0) { + this._FBU.lines = this._FBU.height; + } + + this._FBU.bytes = this._FBU.width * this._fb_Bpp; // at least a line + if (this._sock.rQwait("RAW", this._FBU.bytes)) { + return false; + } + var cur_y = this._FBU.y + (this._FBU.height - this._FBU.lines); + var curr_height = Math.min(this._FBU.lines, Math.floor(this._sock.rQlen() / (this._FBU.width * this._fb_Bpp))); + this._display.blitImage(this._FBU.x, cur_y, this._FBU.width, curr_height, this._sock.get_rQ(), this._sock.get_rQi()); + this._sock.rQskipBytes(this._FBU.width * curr_height * this._fb_Bpp); + this._FBU.lines -= curr_height; + + if (this._FBU.lines > 0) { + this._FBU.bytes = this._FBU.width * this._fb_Bpp; // At least another line + } else { + this._FBU.rects--; + this._FBU.bytes = 0; + } + + return true; + }, + + COPYRECT: function () { + this._FBU.bytes = 4; + if (this._sock.rQwait("COPYRECT", 4)) { + return false; + } + this._display.copyImage(this._sock.rQshift16(), this._sock.rQshift16(), this._FBU.x, this._FBU.y, this._FBU.width, this._FBU.height); + + this._FBU.rects--; + this._FBU.bytes = 0; + return true; + }, + + RRE: function () { + var color; + if (this._FBU.subrects === 0) { + this._FBU.bytes = 4 + this._fb_Bpp; + if (this._sock.rQwait("RRE", 4 + this._fb_Bpp)) { + return false; + } + this._FBU.subrects = this._sock.rQshift32(); + color = this._sock.rQshiftBytes(this._fb_Bpp); // Background + this._display.fillRect(this._FBU.x, this._FBU.y, this._FBU.width, this._FBU.height, color); + } + + while (this._FBU.subrects > 0 && this._sock.rQlen() >= this._fb_Bpp + 8) { + color = this._sock.rQshiftBytes(this._fb_Bpp); + var x = this._sock.rQshift16(); + var y = this._sock.rQshift16(); + var width = this._sock.rQshift16(); + var height = this._sock.rQshift16(); + this._display.fillRect(this._FBU.x + x, this._FBU.y + y, width, height, color); + this._FBU.subrects--; + } + + if (this._FBU.subrects > 0) { + var chunk = Math.min(this._rre_chunk_sz, this._FBU.subrects); + this._FBU.bytes = (this._fb_Bpp + 8) * chunk; + } else { + this._FBU.rects--; + this._FBU.bytes = 0; + } + + return true; + }, + + HEXTILE: function () { + var rQ = this._sock.get_rQ(); + var rQi = this._sock.get_rQi(); + + if (this._FBU.tiles === 0) { + this._FBU.tiles_x = Math.ceil(this._FBU.width / 16); + this._FBU.tiles_y = Math.ceil(this._FBU.height / 16); + this._FBU.total_tiles = this._FBU.tiles_x * this._FBU.tiles_y; + this._FBU.tiles = this._FBU.total_tiles; + } + + while (this._FBU.tiles > 0) { + this._FBU.bytes = 1; + if (this._sock.rQwait("HEXTILE subencoding", this._FBU.bytes)) { + return false; + } + var subencoding = rQ[rQi]; // Peek + if (subencoding > 30) { + // Raw + this._fail("Unexpected server message", "Illegal hextile subencoding: " + subencoding); + return false; + } + + var subrects = 0; + var curr_tile = this._FBU.total_tiles - this._FBU.tiles; + var tile_x = curr_tile % this._FBU.tiles_x; + var tile_y = Math.floor(curr_tile / this._FBU.tiles_x); + var x = this._FBU.x + tile_x * 16; + var y = this._FBU.y + tile_y * 16; + var w = Math.min(16, this._FBU.x + this._FBU.width - x); + var h = Math.min(16, this._FBU.y + this._FBU.height - y); + + // Figure out how much we are expecting + if (subencoding & 0x01) { + // Raw + this._FBU.bytes += w * h * this._fb_Bpp; + } else { + if (subencoding & 0x02) { + // Background + this._FBU.bytes += this._fb_Bpp; + } + if (subencoding & 0x04) { + // Foreground + this._FBU.bytes += this._fb_Bpp; + } + if (subencoding & 0x08) { + // AnySubrects + this._FBU.bytes++; // Since we aren't shifting it off + if (this._sock.rQwait("hextile subrects header", this._FBU.bytes)) { + return false; + } + subrects = rQ[rQi + this._FBU.bytes - 1]; // Peek + if (subencoding & 0x10) { + // SubrectsColoured + this._FBU.bytes += subrects * (this._fb_Bpp + 2); + } else { + this._FBU.bytes += subrects * 2; + } + } + } + + if (this._sock.rQwait("hextile", this._FBU.bytes)) { + return false; + } + + // We know the encoding and have a whole tile + this._FBU.subencoding = rQ[rQi]; + rQi++; + if (this._FBU.subencoding === 0) { + if (this._FBU.lastsubencoding & 0x01) { + // Weird: ignore blanks are RAW + Log.Debug(" Ignoring blank after RAW"); + } else { + this._display.fillRect(x, y, w, h, this._FBU.background); + } + } else if (this._FBU.subencoding & 0x01) { + // Raw + this._display.blitImage(x, y, w, h, rQ, rQi); + rQi += this._FBU.bytes - 1; + } else { + if (this._FBU.subencoding & 0x02) { + // Background + if (this._fb_Bpp == 1) { + this._FBU.background = rQ[rQi]; + } else { + // fb_Bpp is 4 + this._FBU.background = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]]; + } + rQi += this._fb_Bpp; + } + if (this._FBU.subencoding & 0x04) { + // Foreground + if (this._fb_Bpp == 1) { + this._FBU.foreground = rQ[rQi]; + } else { + // this._fb_Bpp is 4 + this._FBU.foreground = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]]; + } + rQi += this._fb_Bpp; + } + + this._display.startTile(x, y, w, h, this._FBU.background); + if (this._FBU.subencoding & 0x08) { + // AnySubrects + subrects = rQ[rQi]; + rQi++; + + for (var s = 0; s < subrects; s++) { + var color; + if (this._FBU.subencoding & 0x10) { + // SubrectsColoured + if (this._fb_Bpp === 1) { + color = rQ[rQi]; + } else { + // _fb_Bpp is 4 + color = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]]; + } + rQi += this._fb_Bpp; + } else { + color = this._FBU.foreground; + } + var xy = rQ[rQi]; + rQi++; + var sx = xy >> 4; + var sy = xy & 0x0f; + + var wh = rQ[rQi]; + rQi++; + var sw = (wh >> 4) + 1; + var sh = (wh & 0x0f) + 1; + + this._display.subTile(sx, sy, sw, sh, color); + } + } + this._display.finishTile(); + } + this._sock.set_rQi(rQi); + this._FBU.lastsubencoding = this._FBU.subencoding; + this._FBU.bytes = 0; + this._FBU.tiles--; + } + + if (this._FBU.tiles === 0) { + this._FBU.rects--; + } + + return true; + }, + + getTightCLength: function (arr) { + var header = 1, + data = 0; + data += arr[0] & 0x7f; + if (arr[0] & 0x80) { + header++; + data += (arr[1] & 0x7f) << 7; + if (arr[1] & 0x80) { + header++; + data += arr[2] << 14; + } + } + return [header, data]; + }, + + display_tight: function (isTightPNG) { + if (this._fb_depth === 1) { + this._fail("Internal error", "Tight protocol handler only implements " + "true color mode"); + } + + this._FBU.bytes = 1; // compression-control byte + if (this._sock.rQwait("TIGHT compression-control", this._FBU.bytes)) { + return false; + } + + var checksum = function (data) { + var sum = 0; + for (var i = 0; i < data.length; i++) { + sum += data[i]; + if (sum > 65536) sum -= 65536; + } + return sum; + }; + + var resetStreams = 0; + var streamId = -1; + var decompress = function (data, expected) { + for (var i = 0; i < 4; i++) { + if (resetStreams >> i & 1) { + this._FBU.zlibs[i].reset(); + Log.Info("Reset zlib stream " + i); + } + } + + //var uncompressed = this._FBU.zlibs[streamId].uncompress(data, 0); + var uncompressed = this._FBU.zlibs[streamId].inflate(data, true, expected); + /*if (uncompressed.status !== 0) { + Log.Error("Invalid data in zlib stream"); + }*/ + + //return uncompressed.data; + return uncompressed; + }.bind(this); + + var indexedToRGBX2Color = function (data, palette, width, height) { + // Convert indexed (palette based) image data to RGB + // TODO: reduce number of calculations inside loop + var dest = this._destBuff; + var w = Math.floor((width + 7) / 8); + var w1 = Math.floor(width / 8); + + /*for (var y = 0; y < height; y++) { + var b, x, dp, sp; + var yoffset = y * width; + var ybitoffset = y * w; + var xoffset, targetbyte; + for (x = 0; x < w1; x++) { + xoffset = yoffset + x * 8; + targetbyte = data[ybitoffset + x]; + for (b = 7; b >= 0; b--) { + dp = (xoffset + 7 - b) * 3; + sp = (targetbyte >> b & 1) * 3; + dest[dp] = palette[sp]; + dest[dp + 1] = palette[sp + 1]; + dest[dp + 2] = palette[sp + 2]; + } + } + xoffset = yoffset + x * 8; + targetbyte = data[ybitoffset + x]; + for (b = 7; b >= 8 - width % 8; b--) { + dp = (xoffset + 7 - b) * 3; + sp = (targetbyte >> b & 1) * 3; + dest[dp] = palette[sp]; + dest[dp + 1] = palette[sp + 1]; + dest[dp + 2] = palette[sp + 2]; + } + }*/ + + for (var y = 0; y < height; y++) { + var b, x, dp, sp; + for (x = 0; x < w1; x++) { + for (b = 7; b >= 0; b--) { + dp = (y * width + x * 8 + 7 - b) * 4; + sp = (data[y * w + x] >> b & 1) * 3; + dest[dp] = palette[sp]; + dest[dp + 1] = palette[sp + 1]; + dest[dp + 2] = palette[sp + 2]; + dest[dp + 3] = 255; + } + } + + for (b = 7; b >= 8 - width % 8; b--) { + dp = (y * width + x * 8 + 7 - b) * 4; + sp = (data[y * w + x] >> b & 1) * 3; + dest[dp] = palette[sp]; + dest[dp + 1] = palette[sp + 1]; + dest[dp + 2] = palette[sp + 2]; + dest[dp + 3] = 255; + } + } + + return dest; + }.bind(this); + + var indexedToRGBX = function (data, palette, width, height) { + // Convert indexed (palette based) image data to RGB + var dest = this._destBuff; + var total = width * height * 4; + for (var i = 0, j = 0; i < total; i += 4, j++) { + var sp = data[j] * 3; + dest[i] = palette[sp]; + dest[i + 1] = palette[sp + 1]; + dest[i + 2] = palette[sp + 2]; + dest[i + 3] = 255; + } + + return dest; + }.bind(this); + + var rQi = this._sock.get_rQi(); + var rQ = this._sock.rQwhole(); + var cmode, data; + var cl_header, cl_data; + + var handlePalette = function () { + var numColors = rQ[rQi + 2] + 1; + var paletteSize = numColors * this._fb_depth; + this._FBU.bytes += paletteSize; + if (this._sock.rQwait("TIGHT palette " + cmode, this._FBU.bytes)) { + return false; + } + + var bpp = numColors <= 2 ? 1 : 8; + var rowSize = Math.floor((this._FBU.width * bpp + 7) / 8); + var raw = false; + if (rowSize * this._FBU.height < 12) { + raw = true; + cl_header = 0; + cl_data = rowSize * this._FBU.height; + //clength = [0, rowSize * this._FBU.height]; + } else { + // begin inline getTightCLength (returning two-item arrays is bad for performance with GC) + var cl_offset = rQi + 3 + paletteSize; + cl_header = 1; + cl_data = 0; + cl_data += rQ[cl_offset] & 0x7f; + if (rQ[cl_offset] & 0x80) { + cl_header++; + cl_data += (rQ[cl_offset + 1] & 0x7f) << 7; + if (rQ[cl_offset + 1] & 0x80) { + cl_header++; + cl_data += rQ[cl_offset + 2] << 14; + } + } + // end inline getTightCLength + } + + this._FBU.bytes += cl_header + cl_data; + if (this._sock.rQwait("TIGHT " + cmode, this._FBU.bytes)) { + return false; + } + + // Shift ctl, filter id, num colors, palette entries, and clength off + this._sock.rQskipBytes(3); + //var palette = this._sock.rQshiftBytes(paletteSize); + this._sock.rQshiftTo(this._paletteBuff, paletteSize); + this._sock.rQskipBytes(cl_header); + + if (raw) { + data = this._sock.rQshiftBytes(cl_data); + } else { + data = decompress(this._sock.rQshiftBytes(cl_data), rowSize * this._FBU.height); + } + + // Convert indexed (palette based) image data to RGB + var rgbx; + if (numColors == 2) { + rgbx = indexedToRGBX2Color(data, this._paletteBuff, this._FBU.width, this._FBU.height); + this._display.blitRgbxImage(this._FBU.x, this._FBU.y, this._FBU.width, this._FBU.height, rgbx, 0, false); + } else { + rgbx = indexedToRGBX(data, this._paletteBuff, this._FBU.width, this._FBU.height); + this._display.blitRgbxImage(this._FBU.x, this._FBU.y, this._FBU.width, this._FBU.height, rgbx, 0, false); + } + + return true; + }.bind(this); + + var handleCopy = function () { + var raw = false; + var uncompressedSize = this._FBU.width * this._FBU.height * this._fb_depth; + if (uncompressedSize < 12) { + raw = true; + cl_header = 0; + cl_data = uncompressedSize; + } else { + // begin inline getTightCLength (returning two-item arrays is for peformance with GC) + var cl_offset = rQi + 1; + cl_header = 1; + cl_data = 0; + cl_data += rQ[cl_offset] & 0x7f; + if (rQ[cl_offset] & 0x80) { + cl_header++; + cl_data += (rQ[cl_offset + 1] & 0x7f) << 7; + if (rQ[cl_offset + 1] & 0x80) { + cl_header++; + cl_data += rQ[cl_offset + 2] << 14; + } + } + // end inline getTightCLength + } + this._FBU.bytes = 1 + cl_header + cl_data; + if (this._sock.rQwait("TIGHT " + cmode, this._FBU.bytes)) { + return false; + } + + // Shift ctl, clength off + this._sock.rQshiftBytes(1 + cl_header); + + if (raw) { + data = this._sock.rQshiftBytes(cl_data); + } else { + data = decompress(this._sock.rQshiftBytes(cl_data), uncompressedSize); + } + + this._display.blitRgbImage(this._FBU.x, this._FBU.y, this._FBU.width, this._FBU.height, data, 0, false); + + return true; + }.bind(this); + + var ctl = this._sock.rQpeek8(); + + // Keep tight reset bits + resetStreams = ctl & 0xF; + + // Figure out filter + ctl = ctl >> 4; + streamId = ctl & 0x3; + + if (ctl === 0x08) cmode = "fill";else if (ctl === 0x09) cmode = "jpeg";else if (ctl === 0x0A) cmode = "png";else if (ctl & 0x04) cmode = "filter";else if (ctl < 0x04) cmode = "copy";else return this._fail("Unexpected server message", "Illegal tight compression received, " + "ctl: " + ctl); + + if (isTightPNG && (cmode === "filter" || cmode === "copy")) { + return this._fail("Unexpected server message", "filter/copy received in tightPNG mode"); + } + + switch (cmode) { + // fill use fb_depth because TPIXELs drop the padding byte + case "fill": + // TPIXEL + this._FBU.bytes += this._fb_depth; + break; + case "jpeg": + // max clength + this._FBU.bytes += 3; + break; + case "png": + // max clength + this._FBU.bytes += 3; + break; + case "filter": + // filter id + num colors if palette + this._FBU.bytes += 2; + break; + case "copy": + break; + } + + if (this._sock.rQwait("TIGHT " + cmode, this._FBU.bytes)) { + return false; + } + + // Determine FBU.bytes + switch (cmode) { + case "fill": + // skip ctl byte + this._display.fillRect(this._FBU.x, this._FBU.y, this._FBU.width, this._FBU.height, [rQ[rQi + 3], rQ[rQi + 2], rQ[rQi + 1]], false); + this._sock.rQskipBytes(4); + break; + case "png": + case "jpeg": + // begin inline getTightCLength (returning two-item arrays is for peformance with GC) + var cl_offset = rQi + 1; + cl_header = 1; + cl_data = 0; + cl_data += rQ[cl_offset] & 0x7f; + if (rQ[cl_offset] & 0x80) { + cl_header++; + cl_data += (rQ[cl_offset + 1] & 0x7f) << 7; + if (rQ[cl_offset + 1] & 0x80) { + cl_header++; + cl_data += rQ[cl_offset + 2] << 14; + } + } + // end inline getTightCLength + this._FBU.bytes = 1 + cl_header + cl_data; // ctl + clength size + jpeg-data + if (this._sock.rQwait("TIGHT " + cmode, this._FBU.bytes)) { + return false; + } + + // We have everything, render it + this._sock.rQskipBytes(1 + cl_header); // shift off clt + compact length + data = this._sock.rQshiftBytes(cl_data); + this._display.imageRect(this._FBU.x, this._FBU.y, "image/" + cmode, data); + break; + case "filter": + var filterId = rQ[rQi + 1]; + if (filterId === 1) { + if (!handlePalette()) { + return false; + } + } else { + // Filter 0, Copy could be valid here, but servers don't send it as an explicit filter + // Filter 2, Gradient is valid but not use if jpeg is enabled + this._fail("Unexpected server message", "Unsupported tight subencoding received, " + "filter: " + filterId); + } + break; + case "copy": + if (!handleCopy()) { + return false; + } + break; + } + + this._FBU.bytes = 0; + this._FBU.rects--; + + return true; + }, + + TIGHT: function () { + return this._encHandlers.display_tight(false); + }, + TIGHT_PNG: function () { + return this._encHandlers.display_tight(true); + }, + + last_rect: function () { + this._FBU.rects = 0; + return true; + }, + + handle_FB_resize: function () { + this._fb_width = this._FBU.width; + this._fb_height = this._FBU.height; + this._destBuff = new Uint8Array(this._fb_width * this._fb_height * 4); + this._display.resize(this._fb_width, this._fb_height); + this._onFBResize(this, this._fb_width, this._fb_height); + this._timing.fbu_rt_start = new Date().getTime(); + this._updateContinuousUpdates(); + + this._FBU.bytes = 0; + this._FBU.rects -= 1; + return true; + }, + + ExtendedDesktopSize: function () { + this._FBU.bytes = 1; + if (this._sock.rQwait("ExtendedDesktopSize", this._FBU.bytes)) { + return false; + } + + this._supportsSetDesktopSize = true; + var number_of_screens = this._sock.rQpeek8(); + + this._FBU.bytes = 4 + number_of_screens * 16; + if (this._sock.rQwait("ExtendedDesktopSize", this._FBU.bytes)) { + return false; + } + + this._sock.rQskipBytes(1); // number-of-screens + this._sock.rQskipBytes(3); // padding + + for (var i = 0; i < number_of_screens; i += 1) { + // Save the id and flags of the first screen + if (i === 0) { + this._screen_id = this._sock.rQshiftBytes(4); // id + this._sock.rQskipBytes(2); // x-position + this._sock.rQskipBytes(2); // y-position + this._sock.rQskipBytes(2); // width + this._sock.rQskipBytes(2); // height + this._screen_flags = this._sock.rQshiftBytes(4); // flags + } else { + this._sock.rQskipBytes(16); + } + } + + /* + * The x-position indicates the reason for the change: + * + * 0 - server resized on its own + * 1 - this client requested the resize + * 2 - another client requested the resize + */ + + // We need to handle errors when we requested the resize. + if (this._FBU.x === 1 && this._FBU.y !== 0) { + var msg = ""; + // The y-position indicates the status code from the server + switch (this._FBU.y) { + case 1: + msg = "Resize is administratively prohibited"; + break; + case 2: + msg = "Out of resources"; + break; + case 3: + msg = "Invalid screen layout"; + break; + default: + msg = "Unknown reason"; + break; + } + this._notification("Server did not accept the resize request: " + msg, 'normal'); + return true; + } + + this._encHandlers.handle_FB_resize(); + return true; + }, + + DesktopSize: function () { + this._encHandlers.handle_FB_resize(); + return true; + }, + + Cursor: function () { + Log.Debug(">> set_cursor"); + var x = this._FBU.x; // hotspot-x + var y = this._FBU.y; // hotspot-y + var w = this._FBU.width; + var h = this._FBU.height; + + var pixelslength = w * h * this._fb_Bpp; + var masklength = Math.floor((w + 7) / 8) * h; + + this._FBU.bytes = pixelslength + masklength; + if (this._sock.rQwait("cursor encoding", this._FBU.bytes)) { + return false; + } + + this._display.changeCursor(this._sock.rQshiftBytes(pixelslength), this._sock.rQshiftBytes(masklength), x, y, w, h); + + this._FBU.bytes = 0; + this._FBU.rects--; + + Log.Debug("<< set_cursor"); + return true; + }, + + QEMUExtendedKeyEvent: function () { + this._FBU.rects--; + + var keyboardEvent = document.createEvent("keyboardEvent"); + if (keyboardEvent.code !== undefined) { + this._qemuExtKeyEventSupported = true; + this._keyboard.setQEMUVNCKeyboardHandler(); + } + }, + + JPEG_quality_lo: function () { + Log.Error("Server sent jpeg_quality pseudo-encoding"); + }, + + compress_lo: function () { + Log.Error("Server sent compress level pseudo-encoding"); + } +}; +},{"./base64.js":1,"./des.js":2,"./display.js":3,"./inflator.js":4,"./input/devices.js":5,"./input/keysym.js":6,"./input/xtscancodes.js":9,"./util/localization.js":13,"./util/logging.js":14,"./util/properties.js":15,"./util/strings.js":16,"./websock.js":17}],11:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.isTouchDevice = exports.Engine = undefined; +exports.browserSupportsCursorURIs = browserSupportsCursorURIs; +exports._forceCursorURIs = _forceCursorURIs; + +var _logging = require('./logging.js'); + +var Log = _interopRequireWildcard(_logging); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +// Set browser engine versions. Based on mootools. +var Features = { xpath: !!document.evaluate, query: !!document.querySelector }; + +// 'presto': (function () { return (!window.opera) ? false : true; }()), +/* + * noVNC: HTML5 VNC client + * Copyright (C) 2012 Joel Martin + * Licensed under MPL 2.0 (see LICENSE.txt) + * + * See README.md for usage and integration instructions. + */ + +var detectPresto = function () { + return !!window.opera; +}; + +// 'trident': (function () { return (!window.ActiveXObject) ? false : ((window.XMLHttpRequest) ? ((document.querySelectorAll) ? 6 : 5) : 4); +var detectTrident = function () { + if (!window.ActiveXObject) { + return false; + } else { + if (window.XMLHttpRequest) { + return document.querySelectorAll ? 6 : 5; + } else { + return 4; + } + } +}; + +// 'webkit': (function () { try { return (navigator.taintEnabled) ? false : ((Features.xpath) ? ((Features.query) ? 525 : 420) : 419); } catch (e) { return false; } }()), +var detectInitialWebkit = function () { + try { + if (navigator.taintEnabled) { + return false; + } else { + if (Features.xpath) { + return Features.query ? 525 : 420; + } else { + return 419; + } + } + } catch (e) { + return false; + } +}; + +var detectActualWebkit = function (initial_ver) { + var re = /WebKit\/([0-9\.]*) /; + var str_ver = (navigator.userAgent.match(re) || ['', initial_ver])[1]; + return parseFloat(str_ver, 10); +}; + +// 'gecko': (function () { return (!document.getBoxObjectFor && window.mozInnerScreenX == null) ? false : ((document.getElementsByClassName) ? 19ssName) ? 19 : 18 : 18); }()) +var detectGecko = function () { + /* jshint -W041 */ + if (!document.getBoxObjectFor && window.mozInnerScreenX == null) { + return false; + } else { + return document.getElementsByClassName ? 19 : 18; + } + /* jshint +W041 */ +}; + +var isWebkitInitial = detectInitialWebkit(); + +var Engine = exports.Engine = { + // Version detection break in Opera 11.60 (errors on arguments.callee.caller reference) + //'presto': (function() { + // return (!window.opera) ? false : ((arguments.callee.caller) ? 960 : ((document.getElementsByClassName) ? 950 : 925)); }()), + 'presto': detectPresto(), + 'trident': detectTrident(), + 'webkit': isWebkitInitial ? detectActualWebkit(isWebkitInitial) : false, + 'gecko': detectGecko() +}; + +// Touch detection +var isTouchDevice = exports.isTouchDevice = 'ontouchstart' in document.documentElement || +// requried for Chrome debugger +document.ontouchstart !== undefined || +// required for MS Surface +navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; +window.addEventListener('touchstart', function onFirstTouch() { + exports.isTouchDevice = isTouchDevice = true; + window.removeEventListener('touchstart', onFirstTouch, false); +}, false); + +var _cursor_uris_supported = null; + +function browserSupportsCursorURIs() { + if (_cursor_uris_supported === null) { + try { + var target = document.createElement('canvas'); + target.style.cursor = 'url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default'; + + if (target.style.cursor) { + Log.Info("Data URI scheme cursor supported"); + _cursor_uris_supported = true; + } else { + Log.Warn("Data URI scheme cursor not supported"); + _cursor_uris_supported = false; + } + } catch (exc) { + Log.Error("Data URI scheme cursor test exception: " + exc); + _cursor_uris_supported = false; + } + } + + return _cursor_uris_supported; +}; + +function _forceCursorURIs(enabled) { + if (enabled === undefined || enabled) { + _cursor_uris_supported = true; + } else { + _cursor_uris_supported = false; + } +} +},{"./logging.js":14}],12:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getPointerEvent = getPointerEvent; +exports.stopEvent = stopEvent; +exports.setCapture = setCapture; +exports.releaseCapture = releaseCapture; + +var _logging = require("./logging.js"); + +var Log = _interopRequireWildcard(_logging); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function getPointerEvent(e) { + return e.changedTouches ? e.changedTouches[0] : e.touches ? e.touches[0] : e; +} /* + * noVNC: HTML5 VNC client + * Copyright (C) 2012 Joel Martin + * Licensed under MPL 2.0 (see LICENSE.txt) + * + * See README.md for usage and integration instructions. + */ + +/* + * Cross-browser event and position routines + */ + +; + +function stopEvent(e) { + e.stopPropagation(); + e.preventDefault(); +}; + +// Emulate Element.setCapture() when not supported +var _captureRecursion = false; +var _captureElem = null; +var _captureProxy = function (e) { + // Recursion protection as we'll see our own event + if (_captureRecursion) return; + + // Clone the event as we cannot dispatch an already dispatched event + var newEv = new e.constructor(e.type, e); + + _captureRecursion = true; + _captureElem.dispatchEvent(newEv); + _captureRecursion = false; + + // Avoid double events + e.stopPropagation(); + + // Respect the wishes of the redirected event handlers + if (newEv.defaultPrevented) { + e.preventDefault(); + } + + // Implicitly release the capture on button release + if (e.type === "mouseup" || e.type === "touchend") { + releaseCapture(); + } +}; + +// Follow cursor style of target element +var _captureElemChanged = function () { + var captureElem = document.getElementById("noVNC_mouse_capture_elem"); + captureElem.style.cursor = window.getComputedStyle(_captureElem).cursor; +}; +var _captureObserver = new MutationObserver(_captureElemChanged); + +var _captureIndex = 0; + +function setCapture(elem) { + if (elem.setCapture) { + + elem.setCapture(); + + // IE releases capture on 'click' events which might not trigger + elem.addEventListener('mouseup', releaseCapture); + elem.addEventListener('touchend', releaseCapture); + } else { + // Release any existing capture in case this method is + // called multiple times without coordination + releaseCapture(); + + // Safari on iOS 9 has a broken constructor for TouchEvent. + // We are fine in this case however, since Safari seems to + // have some sort of implicit setCapture magic anyway. + if (window.TouchEvent !== undefined) { + try { + new TouchEvent("touchstart"); + } catch (TypeError) { + return; + } + } + + var captureElem = document.getElementById("noVNC_mouse_capture_elem"); + + if (captureElem === null) { + captureElem = document.createElement("div"); + captureElem.id = "noVNC_mouse_capture_elem"; + captureElem.style.position = "fixed"; + captureElem.style.top = "0px"; + captureElem.style.left = "0px"; + captureElem.style.width = "100%"; + captureElem.style.height = "100%"; + captureElem.style.zIndex = 10000; + captureElem.style.display = "none"; + document.body.appendChild(captureElem); + + // This is to make sure callers don't get confused by having + // our blocking element as the target + captureElem.addEventListener('contextmenu', _captureProxy); + + captureElem.addEventListener('mousemove', _captureProxy); + captureElem.addEventListener('mouseup', _captureProxy); + + captureElem.addEventListener('touchmove', _captureProxy); + captureElem.addEventListener('touchend', _captureProxy); + } + + _captureElem = elem; + _captureIndex++; + + // Track cursor and get initial cursor + _captureObserver.observe(elem, { attributes: true }); + _captureElemChanged(); + + captureElem.style.display = null; + + // We listen to events on window in order to keep tracking if it + // happens to leave the viewport + window.addEventListener('mousemove', _captureProxy); + window.addEventListener('mouseup', _captureProxy); + + window.addEventListener('touchmove', _captureProxy); + window.addEventListener('touchend', _captureProxy); + } +}; + +function releaseCapture() { + if (document.releaseCapture) { + + document.releaseCapture(); + } else { + if (!_captureElem) { + return; + } + + // There might be events already queued, so we need to wait for + // them to flush. E.g. contextmenu in Microsoft Edge + window.setTimeout(function (expected) { + // Only clear it if it's the expected grab (i.e. no one + // else has initiated a new grab) + if (_captureIndex === expected) { + _captureElem = null; + } + }, 0, _captureIndex); + + _captureObserver.disconnect(); + + var captureElem = document.getElementById("noVNC_mouse_capture_elem"); + captureElem.style.display = "none"; + + window.removeEventListener('mousemove', _captureProxy); + window.removeEventListener('mouseup', _captureProxy); + + window.removeEventListener('touchmove', _captureProxy); + window.removeEventListener('touchend', _captureProxy); + } +}; +},{"./logging.js":14}],13:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Localizer = Localizer; +/* + * noVNC: HTML5 VNC client + * Copyright (C) 2012 Joel Martin + * Licensed under MPL 2.0 (see LICENSE.txt) + * + * See README.md for usage and integration instructions. + */ + +/* + * Localization Utilities + */ + +function Localizer() { + // Currently configured language + this.language = 'en'; + + // Current dictionary of translations + this.dictionary = undefined; +} + +Localizer.prototype = { + // Configure suitable language based on user preferences + setup: function (supportedLanguages) { + var userLanguages; + + this.language = 'en'; // Default: US English + + /* + * Navigator.languages only available in Chrome (32+) and FireFox (32+) + * Fall back to navigator.language for other browsers + */ + if (typeof window.navigator.languages == 'object') { + userLanguages = window.navigator.languages; + } else { + userLanguages = [navigator.language || navigator.userLanguage]; + } + + for (var i = 0; i < userLanguages.length; i++) { + var userLang = userLanguages[i]; + userLang = userLang.toLowerCase(); + userLang = userLang.replace("_", "-"); + userLang = userLang.split("-"); + + // Built-in default? + if (userLang[0] === 'en' && (userLang[1] === undefined || userLang[1] === 'us')) { + return; + } + + // First pass: perfect match + for (var j = 0; j < supportedLanguages.length; j++) { + var supLang = supportedLanguages[j]; + supLang = supLang.toLowerCase(); + supLang = supLang.replace("_", "-"); + supLang = supLang.split("-"); + + if (userLang[0] !== supLang[0]) continue; + if (userLang[1] !== supLang[1]) continue; + + this.language = supportedLanguages[j]; + return; + } + + // Second pass: fallback + for (var j = 0; j < supportedLanguages.length; j++) { + supLang = supportedLanguages[j]; + supLang = supLang.toLowerCase(); + supLang = supLang.replace("_", "-"); + supLang = supLang.split("-"); + + if (userLang[0] !== supLang[0]) continue; + if (supLang[1] !== undefined) continue; + + this.language = supportedLanguages[j]; + return; + } + } + }, + + // Retrieve localised text + get: function (id) { + if (typeof this.dictionary !== 'undefined' && this.dictionary[id]) { + return this.dictionary[id]; + } else { + return id; + } + }, + + // Traverses the DOM and translates relevant fields + // See https://html.spec.whatwg.org/multipage/dom.html#attr-translate + translateDOM: function () { + var self = this; + function process(elem, enabled) { + function isAnyOf(searchElement, items) { + return items.indexOf(searchElement) !== -1; + } + + function translateAttribute(elem, attr) { + var str = elem.getAttribute(attr); + str = self.get(str); + elem.setAttribute(attr, str); + } + + function translateTextNode(node) { + var str = node.data.trim(); + str = self.get(str); + node.data = str; + } + + if (elem.hasAttribute("translate")) { + if (isAnyOf(elem.getAttribute("translate"), ["", "yes"])) { + enabled = true; + } else if (isAnyOf(elem.getAttribute("translate"), ["no"])) { + enabled = false; + } + } + + if (enabled) { + if (elem.hasAttribute("abbr") && elem.tagName === "TH") { + translateAttribute(elem, "abbr"); + } + if (elem.hasAttribute("alt") && isAnyOf(elem.tagName, ["AREA", "IMG", "INPUT"])) { + translateAttribute(elem, "alt"); + } + if (elem.hasAttribute("download") && isAnyOf(elem.tagName, ["A", "AREA"])) { + translateAttribute(elem, "download"); + } + if (elem.hasAttribute("label") && isAnyOf(elem.tagName, ["MENUITEM", "MENU", "OPTGROUP", "OPTION", "TRACK"])) { + translateAttribute(elem, "label"); + } + // FIXME: Should update "lang" + if (elem.hasAttribute("placeholder") && isAnyOf(elem.tagName, ["INPUT", "TEXTAREA"])) { + translateAttribute(elem, "placeholder"); + } + if (elem.hasAttribute("title")) { + translateAttribute(elem, "title"); + } + if (elem.hasAttribute("value") && elem.tagName === "INPUT" && isAnyOf(elem.getAttribute("type"), ["reset", "button"])) { + translateAttribute(elem, "value"); + } + } + + for (var i = 0; i < elem.childNodes.length; i++) { + var node = elem.childNodes[i]; + if (node.nodeType === node.ELEMENT_NODE) { + process(node, enabled); + } else if (node.nodeType === node.TEXT_NODE && enabled) { + translateTextNode(node); + } + } + } + + process(document.body, true); + } +}; + +var l10n = exports.l10n = new Localizer(); +exports.default = l10n.get.bind(l10n); +},{}],14:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.init_logging = init_logging; +exports.get_logging = get_logging; +/* + * noVNC: HTML5 VNC client + * Copyright (C) 2012 Joel Martin + * Licensed under MPL 2.0 (see LICENSE.txt) + * + * See README.md for usage and integration instructions. + */ + +/* + * Logging/debug routines + */ + +var _log_level = 'warn'; + +var Debug = function (msg) {}; +var Info = function (msg) {}; +var Warn = function (msg) {}; +var Error = function (msg) {}; + +function init_logging(level) { + if (typeof level === 'undefined') { + level = _log_level; + } else { + _log_level = level; + } + + exports.Debug = Debug = exports.Info = Info = exports.Warn = Warn = exports.Error = Error = function (msg) {}; + if (typeof window.console !== "undefined") { + /* jshint -W086 */ + switch (level) { + case 'debug': + exports.Debug = Debug = console.debug.bind(window.console); + case 'info': + exports.Info = Info = console.info.bind(window.console); + case 'warn': + exports.Warn = Warn = console.warn.bind(window.console); + case 'error': + exports.Error = Error = console.error.bind(window.console); + case 'none': + break; + default: + throw new Error("invalid logging type '" + level + "'"); + } + /* jshint +W086 */ + } +}; +function get_logging() { + return _log_level; +}; +exports.Debug = Debug; +exports.Info = Info; +exports.Warn = Warn; +exports.Error = Error; + +// Initialize logging level + +init_logging(); +},{}],15:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.make_properties = make_properties; +exports.set_defaults = set_defaults; + +var _logging = require('./logging.js'); + +var Log = _interopRequireWildcard(_logging); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function make_property(proto, name, mode, type) { + "use strict"; + + var getter; + if (type === 'arr') { + getter = function (idx) { + if (typeof idx !== 'undefined') { + return this['_' + name][idx]; + } else { + return this['_' + name]; + } + }; + } else { + getter = function () { + return this['_' + name]; + }; + } + + var make_setter = function (process_val) { + if (process_val) { + return function (val, idx) { + if (typeof idx !== 'undefined') { + this['_' + name][idx] = process_val(val); + } else { + this['_' + name] = process_val(val); + } + }; + } else { + return function (val, idx) { + if (typeof idx !== 'undefined') { + this['_' + name][idx] = val; + } else { + this['_' + name] = val; + } + }; + } + }; + + var setter; + if (type === 'bool') { + setter = make_setter(function (val) { + if (!val || val in { '0': 1, 'no': 1, 'false': 1 }) { + return false; + } else { + return true; + } + }); + } else if (type === 'int') { + setter = make_setter(function (val) { + return parseInt(val, 10); + }); + } else if (type === 'float') { + setter = make_setter(parseFloat); + } else if (type === 'str') { + setter = make_setter(String); + } else if (type === 'func') { + setter = make_setter(function (val) { + if (!val) { + return function () {}; + } else { + return val; + } + }); + } else if (type === 'arr' || type === 'dom' || type == 'raw') { + setter = make_setter(); + } else { + throw new Error('Unknown property type ' + type); // some sanity checking + } + + // set the getter + if (typeof proto['get_' + name] === 'undefined') { + proto['get_' + name] = getter; + } + + // set the setter if needed + if (typeof proto['set_' + name] === 'undefined') { + if (mode === 'rw') { + proto['set_' + name] = setter; + } else if (mode === 'wo') { + proto['set_' + name] = function (val, idx) { + if (typeof this['_' + name] !== 'undefined') { + throw new Error(name + " can only be set once"); + } + setter.call(this, val, idx); + }; + } + } + + // make a special setter that we can use in set defaults + proto['_raw_set_' + name] = function (val, idx) { + setter.call(this, val, idx); + //delete this['_init_set_' + name]; // remove it after use + }; +} /* + * noVNC: HTML5 VNC client + * Copyright (C) 2012 Joel Martin + * Licensed under MPL 2.0 (see LICENSE.txt) + * + * See README.md for usage and integration instructions. + */ + +/* + * Getter/Setter Creation Utilities + */ + +; + +function make_properties(constructor, arr) { + "use strict"; + + for (var i = 0; i < arr.length; i++) { + make_property(constructor.prototype, arr[i][0], arr[i][1], arr[i][2]); + } +}; + +function set_defaults(obj, conf, defaults) { + var defaults_keys = Object.keys(defaults); + var conf_keys = Object.keys(conf); + var keys_obj = {}; + var i; + for (i = 0; i < defaults_keys.length; i++) { + keys_obj[defaults_keys[i]] = 1; + } + for (i = 0; i < conf_keys.length; i++) { + keys_obj[conf_keys[i]] = 1; + } + var keys = Object.keys(keys_obj); + + for (i = 0; i < keys.length; i++) { + var setter = obj['_raw_set_' + keys[i]]; + if (!setter) { + Log.Warn('Invalid property ' + keys[i]); + continue; + } + + if (keys[i] in conf) { + setter.call(obj, conf[keys[i]]); + } else { + setter.call(obj, defaults[keys[i]]); + } + } +}; +},{"./logging.js":14}],16:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.decodeUTF8 = decodeUTF8; +/* + * noVNC: HTML5 VNC client + * Copyright (C) 2012 Joel Martin + * Licensed under MPL 2.0 (see LICENSE.txt) + * + * See README.md for usage and integration instructions. + */ + +/* + * Decode from UTF-8 + */ +function decodeUTF8(utf8string) { + "use strict"; + + return decodeURIComponent(escape(utf8string)); +}; +},{}],17:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = Websock; + +var _logging = require('./util/logging.js'); + +var Log = _interopRequireWildcard(_logging); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +/*jslint browser: true, bitwise: true */ +/*global Util*/ + +function Websock() { + "use strict"; + + this._websocket = null; // WebSocket object + + this._rQi = 0; // Receive queue index + this._rQlen = 0; // Next write position in the receive queue + this._rQbufferSize = 1024 * 1024 * 4; // Receive queue buffer size (4 MiB) + this._rQmax = this._rQbufferSize / 8; + // called in init: this._rQ = new Uint8Array(this._rQbufferSize); + this._rQ = null; // Receive queue + + this._sQbufferSize = 1024 * 10; // 10 KiB + // called in init: this._sQ = new Uint8Array(this._sQbufferSize); + this._sQlen = 0; + this._sQ = null; // Send queue + + this._eventHandlers = { + 'message': function () {}, + 'open': function () {}, + 'close': function () {}, + 'error': function () {} + }; +} /* + * Websock: high-performance binary WebSockets + * Copyright (C) 2012 Joel Martin + * Licensed under MPL 2.0 (see LICENSE.txt) + * + * Websock is similar to the standard WebSocket object but with extra + * buffer handling. + * + * Websock has built-in receive queue buffering; the message event + * does not contain actual data but is simply a notification that + * there is new data available. Several rQ* methods are available to + * read binary data off of the receive queue. + */ + +; + +// this has performance issues in some versions Chromium, and +// doesn't gain a tremendous amount of performance increase in Firefox +// at the moment. It may be valuable to turn it on in the future. +var ENABLE_COPYWITHIN = false; + +var MAX_RQ_GROW_SIZE = 40 * 1024 * 1024; // 40 MiB + +var typedArrayToString = function () { + // This is only for PhantomJS, which doesn't like apply-ing + // with Typed Arrays + try { + var arr = new Uint8Array([1, 2, 3]); + String.fromCharCode.apply(null, arr); + return function (a) { + return String.fromCharCode.apply(null, a); + }; + } catch (ex) { + return function (a) { + return String.fromCharCode.apply(null, Array.prototype.slice.call(a)); + }; + } +}(); + +Websock.prototype = { + // Getters and Setters + get_sQ: function () { + return this._sQ; + }, + + get_rQ: function () { + return this._rQ; + }, + + get_rQi: function () { + return this._rQi; + }, + + set_rQi: function (val) { + this._rQi = val; + }, + + // Receive Queue + rQlen: function () { + return this._rQlen - this._rQi; + }, + + rQpeek8: function () { + return this._rQ[this._rQi]; + }, + + rQshift8: function () { + return this._rQ[this._rQi++]; + }, + + rQskip8: function () { + this._rQi++; + }, + + rQskipBytes: function (num) { + this._rQi += num; + }, + + // TODO(directxman12): test performance with these vs a DataView + rQshift16: function () { + return (this._rQ[this._rQi++] << 8) + this._rQ[this._rQi++]; + }, + + rQshift32: function () { + return (this._rQ[this._rQi++] << 24) + (this._rQ[this._rQi++] << 16) + (this._rQ[this._rQi++] << 8) + this._rQ[this._rQi++]; + }, + + rQshiftStr: function (len) { + if (typeof len === 'undefined') { + len = this.rQlen(); + } + var arr = new Uint8Array(this._rQ.buffer, this._rQi, len); + this._rQi += len; + return typedArrayToString(arr); + }, + + rQshiftBytes: function (len) { + if (typeof len === 'undefined') { + len = this.rQlen(); + } + this._rQi += len; + return new Uint8Array(this._rQ.buffer, this._rQi - len, len); + }, + + rQshiftTo: function (target, len) { + if (len === undefined) { + len = this.rQlen(); + } + // TODO: make this just use set with views when using a ArrayBuffer to store the rQ + target.set(new Uint8Array(this._rQ.buffer, this._rQi, len)); + this._rQi += len; + }, + + rQwhole: function () { + return new Uint8Array(this._rQ.buffer, 0, this._rQlen); + }, + + rQslice: function (start, end) { + if (end) { + return new Uint8Array(this._rQ.buffer, this._rQi + start, end - start); + } else { + return new Uint8Array(this._rQ.buffer, this._rQi + start, this._rQlen - this._rQi - start); + } + }, + + // Check to see if we must wait for 'num' bytes (default to FBU.bytes) + // to be available in the receive queue. Return true if we need to + // wait (and possibly print a debug message), otherwise false. + rQwait: function (msg, num, goback) { + var rQlen = this._rQlen - this._rQi; // Skip rQlen() function call + if (rQlen < num) { + if (goback) { + if (this._rQi < goback) { + throw new Error("rQwait cannot backup " + goback + " bytes"); + } + this._rQi -= goback; + } + return true; // true means need more data + } + return false; + }, + + // Send Queue + + flush: function () { + if (this._websocket.bufferedAmount !== 0) { + Log.Debug("bufferedAmount: " + this._websocket.bufferedAmount); + } + + if (this._sQlen > 0 && this._websocket.readyState === WebSocket.OPEN) { + this._websocket.send(this._encode_message()); + this._sQlen = 0; + } + }, + + send: function (arr) { + this._sQ.set(arr, this._sQlen); + this._sQlen += arr.length; + this.flush(); + }, + + send_string: function (str) { + this.send(str.split('').map(function (chr) { + return chr.charCodeAt(0); + })); + }, + + // Event Handlers + off: function (evt) { + this._eventHandlers[evt] = function () {}; + }, + + on: function (evt, handler) { + this._eventHandlers[evt] = handler; + }, + + _allocate_buffers: function () { + this._rQ = new Uint8Array(this._rQbufferSize); + this._sQ = new Uint8Array(this._sQbufferSize); + }, + + init: function () { + this._allocate_buffers(); + this._rQi = 0; + this._websocket = null; + }, + + open: function (uri, protocols) { + var ws_schema = uri.match(/^([a-z]+):\/\//)[1]; + this.init(); + + this._websocket = new WebSocket(uri, protocols); + this._websocket.binaryType = 'arraybuffer'; + + this._websocket.onmessage = this._recv_message.bind(this); + this._websocket.onopen = function () { + Log.Debug('>> WebSock.onopen'); + if (this._websocket.protocol) { + Log.Info("Server choose sub-protocol: " + this._websocket.protocol); + } + + this._eventHandlers.open(); + Log.Debug("<< WebSock.onopen"); + }.bind(this); + this._websocket.onclose = function (e) { + Log.Debug(">> WebSock.onclose"); + this._eventHandlers.close(e); + Log.Debug("<< WebSock.onclose"); + }.bind(this); + this._websocket.onerror = function (e) { + Log.Debug(">> WebSock.onerror: " + e); + this._eventHandlers.error(e); + Log.Debug("<< WebSock.onerror: " + e); + }.bind(this); + }, + + close: function () { + if (this._websocket) { + if (this._websocket.readyState === WebSocket.OPEN || this._websocket.readyState === WebSocket.CONNECTING) { + Log.Info("Closing WebSocket connection"); + this._websocket.close(); + } + + this._websocket.onmessage = function (e) { + return; + }; + } + }, + + // private methods + _encode_message: function () { + // Put in a binary arraybuffer + // according to the spec, you can send ArrayBufferViews with the send method + return new Uint8Array(this._sQ.buffer, 0, this._sQlen); + }, + + _expand_compact_rQ: function (min_fit) { + var resizeNeeded = min_fit || this._rQlen - this._rQi > this._rQbufferSize / 2; + if (resizeNeeded) { + if (!min_fit) { + // just double the size if we need to do compaction + this._rQbufferSize *= 2; + } else { + // otherwise, make sure we satisy rQlen - rQi + min_fit < rQbufferSize / 8 + this._rQbufferSize = (this._rQlen - this._rQi + min_fit) * 8; + } + } + + // we don't want to grow unboundedly + if (this._rQbufferSize > MAX_RQ_GROW_SIZE) { + this._rQbufferSize = MAX_RQ_GROW_SIZE; + if (this._rQbufferSize - this._rQlen - this._rQi < min_fit) { + throw new Exception("Receive Queue buffer exceeded " + MAX_RQ_GROW_SIZE + " bytes, and the new message could not fit"); + } + } + + if (resizeNeeded) { + var old_rQbuffer = this._rQ.buffer; + this._rQmax = this._rQbufferSize / 8; + this._rQ = new Uint8Array(this._rQbufferSize); + this._rQ.set(new Uint8Array(old_rQbuffer, this._rQi)); + } else { + if (ENABLE_COPYWITHIN) { + this._rQ.copyWithin(0, this._rQi); + } else { + this._rQ.set(new Uint8Array(this._rQ.buffer, this._rQi)); + } + } + + this._rQlen = this._rQlen - this._rQi; + this._rQi = 0; + }, + + _decode_message: function (data) { + // push arraybuffer values onto the end + var u8 = new Uint8Array(data); + if (u8.length > this._rQbufferSize - this._rQlen) { + this._expand_compact_rQ(u8.length); + } + this._rQ.set(u8, this._rQlen); + this._rQlen += u8.length; + }, + + _recv_message: function (e) { + try { + this._decode_message(e.data); + if (this.rQlen() > 0) { + this._eventHandlers.message(); + // Compact the receive queue + if (this._rQlen == this._rQi) { + this._rQlen = 0; + this._rQi = 0; + } else if (this._rQlen > this._rQmax) { + this._expand_compact_rQ(); + } + } else { + Log.Debug("Ignoring empty message"); + } + } catch (exc) { + var exception_str = ""; + if (exc.name) { + exception_str += "\n name: " + exc.name + "\n"; + exception_str += " message: " + exc.message + "\n"; + } + + if (typeof exc.description !== 'undefined') { + exception_str += " description: " + exc.description + "\n"; + } + + if (typeof exc.stack !== 'undefined') { + exception_str += exc.stack; + } + + if (exception_str.length > 0) { + Log.Error("recv_message, caught exception: " + exception_str); + } else { + Log.Error("recv_message, caught exception: " + exc); + } + + if (typeof exc.name !== 'undefined') { + this._eventHandlers.error(exc.name + ": " + exc.message); + } else { + this._eventHandlers.error(exc); + } + } + } +}; +},{"./util/logging.js":14}],18:[function(require,module,exports){ +"use strict"; + +exports.__esModule = true; + +exports.default = function () {}; + +module.exports = exports["default"]; +},{}],19:[function(require,module,exports){ +module.exports = { "default": require("core-js/library/fn/array/from"), __esModule: true }; +},{"core-js/library/fn/array/from":33}],20:[function(require,module,exports){ +module.exports = { "default": require("core-js/library/fn/object/assign"), __esModule: true }; +},{"core-js/library/fn/object/assign":34}],21:[function(require,module,exports){ +module.exports = { "default": require("core-js/library/fn/object/create"), __esModule: true }; +},{"core-js/library/fn/object/create":35}],22:[function(require,module,exports){ +module.exports = { "default": require("core-js/library/fn/object/entries"), __esModule: true }; +},{"core-js/library/fn/object/entries":36}],23:[function(require,module,exports){ +module.exports = { "default": require("core-js/library/fn/object/set-prototype-of"), __esModule: true }; +},{"core-js/library/fn/object/set-prototype-of":37}],24:[function(require,module,exports){ +module.exports = { "default": require("core-js/library/fn/object/values"), __esModule: true }; +},{"core-js/library/fn/object/values":38}],25:[function(require,module,exports){ +module.exports = { "default": require("core-js/library/fn/symbol"), __esModule: true }; +},{"core-js/library/fn/symbol":39}],26:[function(require,module,exports){ +module.exports = { "default": require("core-js/library/fn/symbol/iterator"), __esModule: true }; +},{"core-js/library/fn/symbol/iterator":40}],27:[function(require,module,exports){ +"use strict"; + +exports.__esModule = true; + +exports.default = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - -exports.__esModule = true; -},{}],18:[function(require,module,exports){ +},{}],28:[function(require,module,exports){ "use strict"; -var _Object$defineProperty = require("babel-runtime/core-js/object/define-property")["default"]; - -exports["default"] = (function () { - function defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - - _Object$defineProperty(target, descriptor.key, descriptor); - } - } - - return function (Constructor, protoProps, staticProps) { - if (protoProps) defineProperties(Constructor.prototype, protoProps); - if (staticProps) defineProperties(Constructor, staticProps); - return Constructor; - }; -})(); - exports.__esModule = true; -},{"babel-runtime/core-js/object/define-property":10}],19:[function(require,module,exports){ -"use strict"; -var _Object$defineProperty = require("babel-runtime/core-js/object/define-property")["default"]; +var _assign = require("../core-js/object/assign"); -exports["default"] = function (obj, key, value) { - if (key in obj) { - _Object$defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } +var _assign2 = _interopRequireDefault(_assign); - return obj; -}; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -exports.__esModule = true; -},{"babel-runtime/core-js/object/define-property":10}],20:[function(require,module,exports){ -"use strict"; - -var _Object$assign = require("babel-runtime/core-js/object/assign")["default"]; - -exports["default"] = _Object$assign || function (target) { +exports.default = _assign2.default || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; @@ -104,66 +6769,31 @@ exports["default"] = _Object$assign || function (target) { return target; }; - -exports.__esModule = true; -},{"babel-runtime/core-js/object/assign":8}],21:[function(require,module,exports){ +},{"../core-js/object/assign":20}],29:[function(require,module,exports){ "use strict"; -var _Object$getOwnPropertyDescriptor = require("babel-runtime/core-js/object/get-own-property-descriptor")["default"]; - -exports["default"] = function get(_x, _x2, _x3) { - var _again = true; - - _function: while (_again) { - var object = _x, - property = _x2, - receiver = _x3; - desc = parent = getter = undefined; - _again = false; - if (object === null) object = Function.prototype; - - var desc = _Object$getOwnPropertyDescriptor(object, property); - - if (desc === undefined) { - var parent = Object.getPrototypeOf(object); - - if (parent === null) { - return undefined; - } else { - _x = parent; - _x2 = property; - _x3 = receiver; - _again = true; - continue _function; - } - } else if ("value" in desc) { - return desc.value; - } else { - var getter = desc.get; - - if (getter === undefined) { - return undefined; - } - - return getter.call(receiver); - } - } -}; - exports.__esModule = true; -},{"babel-runtime/core-js/object/get-own-property-descriptor":11}],22:[function(require,module,exports){ -"use strict"; -var _Object$create = require("babel-runtime/core-js/object/create")["default"]; +var _setPrototypeOf = require("../core-js/object/set-prototype-of"); -var _Object$setPrototypeOf = require("babel-runtime/core-js/object/set-prototype-of")["default"]; +var _setPrototypeOf2 = _interopRequireDefault(_setPrototypeOf); -exports["default"] = function (subClass, superClass) { +var _create = require("../core-js/object/create"); + +var _create2 = _interopRequireDefault(_create); + +var _typeof2 = require("../helpers/typeof"); + +var _typeof3 = _interopRequireDefault(_typeof2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : (0, _typeof3.default)(superClass))); } - subClass.prototype = _Object$create(superClass && superClass.prototype, { + subClass.prototype = (0, _create2.default)(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, @@ -171,45 +6801,14 @@ exports["default"] = function (subClass, superClass) { configurable: true } }); - if (superClass) _Object$setPrototypeOf ? _Object$setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + if (superClass) _setPrototypeOf2.default ? (0, _setPrototypeOf2.default)(subClass, superClass) : subClass.__proto__ = superClass; }; - -exports.__esModule = true; -},{"babel-runtime/core-js/object/create":9,"babel-runtime/core-js/object/set-prototype-of":13}],23:[function(require,module,exports){ +},{"../core-js/object/create":21,"../core-js/object/set-prototype-of":23,"../helpers/typeof":32}],30:[function(require,module,exports){ "use strict"; -exports["default"] = function (obj) { - return obj && obj.__esModule ? obj : { - "default": obj - }; -}; - exports.__esModule = true; -},{}],24:[function(require,module,exports){ -"use strict"; -exports["default"] = function (obj) { - if (obj && obj.__esModule) { - return obj; - } else { - var newObj = {}; - - if (obj != null) { - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; - } - } - - newObj["default"] = obj; - return newObj; - } -}; - -exports.__esModule = true; -},{}],25:[function(require,module,exports){ -"use strict"; - -exports["default"] = function (obj, keys) { +exports.default = function (obj, keys) { var target = {}; for (var i in obj) { @@ -220,351 +6819,1291 @@ exports["default"] = function (obj, keys) { return target; }; - -exports.__esModule = true; -},{}],26:[function(require,module,exports){ +},{}],31:[function(require,module,exports){ "use strict"; -var _getIterator = require("babel-runtime/core-js/get-iterator")["default"]; +exports.__esModule = true; -var _isIterable = require("babel-runtime/core-js/is-iterable")["default"]; +var _typeof2 = require("../helpers/typeof"); -exports["default"] = (function () { - function sliceIterator(arr, i) { - var _arr = []; - var _n = true; - var _d = false; - var _e = undefined; +var _typeof3 = _interopRequireDefault(_typeof2); - try { - for (var _i = _getIterator(arr), _s; !(_n = (_s = _i.next()).done); _n = true) { - _arr.push(_s.value); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - if (i && _arr.length === i) break; - } - } catch (err) { - _d = true; - _e = err; - } finally { - try { - if (!_n && _i["return"]) _i["return"](); - } finally { - if (_d) throw _e; - } - } - - return _arr; +exports.default = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } - return function (arr, i) { - if (Array.isArray(arr)) { - return arr; - } else if (_isIterable(Object(arr))) { - return sliceIterator(arr, i); - } else { - throw new TypeError("Invalid attempt to destructure non-iterable instance"); - } - }; -})(); - -exports.__esModule = true; -},{"babel-runtime/core-js/get-iterator":2,"babel-runtime/core-js/is-iterable":3}],27:[function(require,module,exports){ + return call && ((typeof call === "undefined" ? "undefined" : (0, _typeof3.default)(call)) === "object" || typeof call === "function") ? call : self; +}; +},{"../helpers/typeof":32}],32:[function(require,module,exports){ "use strict"; -var _Array$from = require("babel-runtime/core-js/array/from")["default"]; +exports.__esModule = true; -exports["default"] = function (arr) { - if (Array.isArray(arr)) { - for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; +var _iterator = require("../core-js/symbol/iterator"); - return arr2; - } else { - return _Array$from(arr); +var _iterator2 = _interopRequireDefault(_iterator); + +var _symbol = require("../core-js/symbol"); + +var _symbol2 = _interopRequireDefault(_symbol); + +var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; }; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) { + return typeof obj === "undefined" ? "undefined" : _typeof(obj); +} : function (obj) { + return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj); +}; +},{"../core-js/symbol":25,"../core-js/symbol/iterator":26}],33:[function(require,module,exports){ +require('../../modules/es6.string.iterator'); +require('../../modules/es6.array.from'); +module.exports = require('../../modules/_core').Array.from; +},{"../../modules/_core":47,"../../modules/es6.array.from":106,"../../modules/es6.string.iterator":112}],34:[function(require,module,exports){ +require('../../modules/es6.object.assign'); +module.exports = require('../../modules/_core').Object.assign; +},{"../../modules/_core":47,"../../modules/es6.object.assign":108}],35:[function(require,module,exports){ +require('../../modules/es6.object.create'); +var $Object = require('../../modules/_core').Object; +module.exports = function create(P, D){ + return $Object.create(P, D); +}; +},{"../../modules/_core":47,"../../modules/es6.object.create":109}],36:[function(require,module,exports){ +require('../../modules/es7.object.entries'); +module.exports = require('../../modules/_core').Object.entries; +},{"../../modules/_core":47,"../../modules/es7.object.entries":114}],37:[function(require,module,exports){ +require('../../modules/es6.object.set-prototype-of'); +module.exports = require('../../modules/_core').Object.setPrototypeOf; +},{"../../modules/_core":47,"../../modules/es6.object.set-prototype-of":110}],38:[function(require,module,exports){ +require('../../modules/es7.object.values'); +module.exports = require('../../modules/_core').Object.values; +},{"../../modules/_core":47,"../../modules/es7.object.values":115}],39:[function(require,module,exports){ +require('../../modules/es6.symbol'); +require('../../modules/es6.object.to-string'); +require('../../modules/es7.symbol.async-iterator'); +require('../../modules/es7.symbol.observable'); +module.exports = require('../../modules/_core').Symbol; +},{"../../modules/_core":47,"../../modules/es6.object.to-string":111,"../../modules/es6.symbol":113,"../../modules/es7.symbol.async-iterator":116,"../../modules/es7.symbol.observable":117}],40:[function(require,module,exports){ +require('../../modules/es6.string.iterator'); +require('../../modules/web.dom.iterable'); +module.exports = require('../../modules/_wks-ext').f('iterator'); +},{"../../modules/_wks-ext":103,"../../modules/es6.string.iterator":112,"../../modules/web.dom.iterable":118}],41:[function(require,module,exports){ +module.exports = function(it){ + if(typeof it != 'function')throw TypeError(it + ' is not a function!'); + return it; +}; +},{}],42:[function(require,module,exports){ +module.exports = function(){ /* empty */ }; +},{}],43:[function(require,module,exports){ +var isObject = require('./_is-object'); +module.exports = function(it){ + if(!isObject(it))throw TypeError(it + ' is not an object!'); + return it; +}; +},{"./_is-object":65}],44:[function(require,module,exports){ +// false -> Array#indexOf +// true -> Array#includes +var toIObject = require('./_to-iobject') + , toLength = require('./_to-length') + , toIndex = require('./_to-index'); +module.exports = function(IS_INCLUDES){ + return function($this, el, fromIndex){ + var O = toIObject($this) + , length = toLength(O.length) + , index = toIndex(fromIndex, length) + , value; + // Array#includes uses SameValueZero equality algorithm + if(IS_INCLUDES && el != el)while(length > index){ + value = O[index++]; + if(value != value)return true; + // Array#toIndex ignores holes, Array#includes - not + } else for(;length > index; index++)if(IS_INCLUDES || index in O){ + if(O[index] === el)return IS_INCLUDES || index || 0; + } return !IS_INCLUDES && -1; + }; +}; +},{"./_to-index":95,"./_to-iobject":97,"./_to-length":98}],45:[function(require,module,exports){ +// getting tag from 19.1.3.6 Object.prototype.toString() +var cof = require('./_cof') + , TAG = require('./_wks')('toStringTag') + // ES3 wrong here + , ARG = cof(function(){ return arguments; }()) == 'Arguments'; + +// fallback for IE11 Script Access Denied error +var tryGet = function(it, key){ + try { + return it[key]; + } catch(e){ /* empty */ } +}; + +module.exports = function(it){ + var O, T, B; + return it === undefined ? 'Undefined' : it === null ? 'Null' + // @@toStringTag case + : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T + // builtinTag case + : ARG ? cof(O) + // ES3 arguments fallback + : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; +}; +},{"./_cof":46,"./_wks":104}],46:[function(require,module,exports){ +var toString = {}.toString; + +module.exports = function(it){ + return toString.call(it).slice(8, -1); +}; +},{}],47:[function(require,module,exports){ +var core = module.exports = {version: '2.4.0'}; +if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef +},{}],48:[function(require,module,exports){ +'use strict'; +var $defineProperty = require('./_object-dp') + , createDesc = require('./_property-desc'); + +module.exports = function(object, index, value){ + if(index in object)$defineProperty.f(object, index, createDesc(0, value)); + else object[index] = value; +}; +},{"./_object-dp":77,"./_property-desc":88}],49:[function(require,module,exports){ +// optional / simple context binding +var aFunction = require('./_a-function'); +module.exports = function(fn, that, length){ + aFunction(fn); + if(that === undefined)return fn; + switch(length){ + case 1: return function(a){ + return fn.call(that, a); + }; + case 2: return function(a, b){ + return fn.call(that, a, b); + }; + case 3: return function(a, b, c){ + return fn.call(that, a, b, c); + }; + } + return function(/* ...args */){ + return fn.apply(that, arguments); + }; +}; +},{"./_a-function":41}],50:[function(require,module,exports){ +// 7.2.1 RequireObjectCoercible(argument) +module.exports = function(it){ + if(it == undefined)throw TypeError("Can't call method on " + it); + return it; +}; +},{}],51:[function(require,module,exports){ +// Thank's IE8 for his funny defineProperty +module.exports = !require('./_fails')(function(){ + return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; +}); +},{"./_fails":56}],52:[function(require,module,exports){ +var isObject = require('./_is-object') + , document = require('./_global').document + // in old IE typeof document.createElement is 'object' + , is = isObject(document) && isObject(document.createElement); +module.exports = function(it){ + return is ? document.createElement(it) : {}; +}; +},{"./_global":57,"./_is-object":65}],53:[function(require,module,exports){ +// IE 8- don't enum bug keys +module.exports = ( + 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' +).split(','); +},{}],54:[function(require,module,exports){ +// all enumerable object keys, includes symbols +var getKeys = require('./_object-keys') + , gOPS = require('./_object-gops') + , pIE = require('./_object-pie'); +module.exports = function(it){ + var result = getKeys(it) + , getSymbols = gOPS.f; + if(getSymbols){ + var symbols = getSymbols(it) + , isEnum = pIE.f + , i = 0 + , key; + while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))result.push(key); + } return result; +}; +},{"./_object-gops":82,"./_object-keys":85,"./_object-pie":86}],55:[function(require,module,exports){ +var global = require('./_global') + , core = require('./_core') + , ctx = require('./_ctx') + , hide = require('./_hide') + , PROTOTYPE = 'prototype'; + +var $export = function(type, name, source){ + var IS_FORCED = type & $export.F + , IS_GLOBAL = type & $export.G + , IS_STATIC = type & $export.S + , IS_PROTO = type & $export.P + , IS_BIND = type & $export.B + , IS_WRAP = type & $export.W + , exports = IS_GLOBAL ? core : core[name] || (core[name] = {}) + , expProto = exports[PROTOTYPE] + , target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE] + , key, own, out; + if(IS_GLOBAL)source = name; + for(key in source){ + // contains in native + own = !IS_FORCED && target && target[key] !== undefined; + if(own && key in exports)continue; + // export native or passed + out = own ? target[key] : source[key]; + // prevent global pollution for namespaces + exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] + // bind timers to global for call from export context + : IS_BIND && own ? ctx(out, global) + // wrap global constructors for prevent change them in library + : IS_WRAP && target[key] == out ? (function(C){ + var F = function(a, b, c){ + if(this instanceof C){ + switch(arguments.length){ + case 0: return new C; + case 1: return new C(a); + case 2: return new C(a, b); + } return new C(a, b, c); + } return C.apply(this, arguments); + }; + F[PROTOTYPE] = C[PROTOTYPE]; + return F; + // make static versions for prototype methods + })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; + // export proto methods to core.%CONSTRUCTOR%.methods.%NAME% + if(IS_PROTO){ + (exports.virtual || (exports.virtual = {}))[key] = out; + // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME% + if(type & $export.R && expProto && !expProto[key])hide(expProto, key, out); + } + } +}; +// type bitmap +$export.F = 1; // forced +$export.G = 2; // global +$export.S = 4; // static +$export.P = 8; // proto +$export.B = 16; // bind +$export.W = 32; // wrap +$export.U = 64; // safe +$export.R = 128; // real proto method for `library` +module.exports = $export; +},{"./_core":47,"./_ctx":49,"./_global":57,"./_hide":59}],56:[function(require,module,exports){ +module.exports = function(exec){ + try { + return !!exec(); + } catch(e){ + return true; + } +}; +},{}],57:[function(require,module,exports){ +// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 +var global = module.exports = typeof window != 'undefined' && window.Math == Math + ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); +if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef +},{}],58:[function(require,module,exports){ +var hasOwnProperty = {}.hasOwnProperty; +module.exports = function(it, key){ + return hasOwnProperty.call(it, key); +}; +},{}],59:[function(require,module,exports){ +var dP = require('./_object-dp') + , createDesc = require('./_property-desc'); +module.exports = require('./_descriptors') ? function(object, key, value){ + return dP.f(object, key, createDesc(1, value)); +} : function(object, key, value){ + object[key] = value; + return object; +}; +},{"./_descriptors":51,"./_object-dp":77,"./_property-desc":88}],60:[function(require,module,exports){ +module.exports = require('./_global').document && document.documentElement; +},{"./_global":57}],61:[function(require,module,exports){ +module.exports = !require('./_descriptors') && !require('./_fails')(function(){ + return Object.defineProperty(require('./_dom-create')('div'), 'a', {get: function(){ return 7; }}).a != 7; +}); +},{"./_descriptors":51,"./_dom-create":52,"./_fails":56}],62:[function(require,module,exports){ +// fallback for non-array-like ES3 and non-enumerable old V8 strings +var cof = require('./_cof'); +module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){ + return cof(it) == 'String' ? it.split('') : Object(it); +}; +},{"./_cof":46}],63:[function(require,module,exports){ +// check on default Array iterator +var Iterators = require('./_iterators') + , ITERATOR = require('./_wks')('iterator') + , ArrayProto = Array.prototype; + +module.exports = function(it){ + return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); +}; +},{"./_iterators":71,"./_wks":104}],64:[function(require,module,exports){ +// 7.2.2 IsArray(argument) +var cof = require('./_cof'); +module.exports = Array.isArray || function isArray(arg){ + return cof(arg) == 'Array'; +}; +},{"./_cof":46}],65:[function(require,module,exports){ +module.exports = function(it){ + return typeof it === 'object' ? it !== null : typeof it === 'function'; +}; +},{}],66:[function(require,module,exports){ +// call something on iterator step with safe closing on error +var anObject = require('./_an-object'); +module.exports = function(iterator, fn, value, entries){ + try { + return entries ? fn(anObject(value)[0], value[1]) : fn(value); + // 7.4.6 IteratorClose(iterator, completion) + } catch(e){ + var ret = iterator['return']; + if(ret !== undefined)anObject(ret.call(iterator)); + throw e; + } +}; +},{"./_an-object":43}],67:[function(require,module,exports){ +'use strict'; +var create = require('./_object-create') + , descriptor = require('./_property-desc') + , setToStringTag = require('./_set-to-string-tag') + , IteratorPrototype = {}; + +// 25.1.2.1.1 %IteratorPrototype%[@@iterator]() +require('./_hide')(IteratorPrototype, require('./_wks')('iterator'), function(){ return this; }); + +module.exports = function(Constructor, NAME, next){ + Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)}); + setToStringTag(Constructor, NAME + ' Iterator'); +}; +},{"./_hide":59,"./_object-create":76,"./_property-desc":88,"./_set-to-string-tag":91,"./_wks":104}],68:[function(require,module,exports){ +'use strict'; +var LIBRARY = require('./_library') + , $export = require('./_export') + , redefine = require('./_redefine') + , hide = require('./_hide') + , has = require('./_has') + , Iterators = require('./_iterators') + , $iterCreate = require('./_iter-create') + , setToStringTag = require('./_set-to-string-tag') + , getPrototypeOf = require('./_object-gpo') + , ITERATOR = require('./_wks')('iterator') + , BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next` + , FF_ITERATOR = '@@iterator' + , KEYS = 'keys' + , VALUES = 'values'; + +var returnThis = function(){ return this; }; + +module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){ + $iterCreate(Constructor, NAME, next); + var getMethod = function(kind){ + if(!BUGGY && kind in proto)return proto[kind]; + switch(kind){ + case KEYS: return function keys(){ return new Constructor(this, kind); }; + case VALUES: return function values(){ return new Constructor(this, kind); }; + } return function entries(){ return new Constructor(this, kind); }; + }; + var TAG = NAME + ' Iterator' + , DEF_VALUES = DEFAULT == VALUES + , VALUES_BUG = false + , proto = Base.prototype + , $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT] + , $default = $native || getMethod(DEFAULT) + , $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined + , $anyNative = NAME == 'Array' ? proto.entries || $native : $native + , methods, key, IteratorPrototype; + // Fix native + if($anyNative){ + IteratorPrototype = getPrototypeOf($anyNative.call(new Base)); + if(IteratorPrototype !== Object.prototype){ + // Set @@toStringTag to native iterators + setToStringTag(IteratorPrototype, TAG, true); + // fix for some old engines + if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis); + } + } + // fix Array#{values, @@iterator}.name in V8 / FF + if(DEF_VALUES && $native && $native.name !== VALUES){ + VALUES_BUG = true; + $default = function values(){ return $native.call(this); }; + } + // Define iterator + if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){ + hide(proto, ITERATOR, $default); + } + // Plug for library + Iterators[NAME] = $default; + Iterators[TAG] = returnThis; + if(DEFAULT){ + methods = { + values: DEF_VALUES ? $default : getMethod(VALUES), + keys: IS_SET ? $default : getMethod(KEYS), + entries: $entries + }; + if(FORCED)for(key in methods){ + if(!(key in proto))redefine(proto, key, methods[key]); + } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods); + } + return methods; +}; +},{"./_export":55,"./_has":58,"./_hide":59,"./_iter-create":67,"./_iterators":71,"./_library":73,"./_object-gpo":83,"./_redefine":89,"./_set-to-string-tag":91,"./_wks":104}],69:[function(require,module,exports){ +var ITERATOR = require('./_wks')('iterator') + , SAFE_CLOSING = false; + +try { + var riter = [7][ITERATOR](); + riter['return'] = function(){ SAFE_CLOSING = true; }; + Array.from(riter, function(){ throw 2; }); +} catch(e){ /* empty */ } + +module.exports = function(exec, skipClosing){ + if(!skipClosing && !SAFE_CLOSING)return false; + var safe = false; + try { + var arr = [7] + , iter = arr[ITERATOR](); + iter.next = function(){ return {done: safe = true}; }; + arr[ITERATOR] = function(){ return iter; }; + exec(arr); + } catch(e){ /* empty */ } + return safe; +}; +},{"./_wks":104}],70:[function(require,module,exports){ +module.exports = function(done, value){ + return {value: value, done: !!done}; +}; +},{}],71:[function(require,module,exports){ +module.exports = {}; +},{}],72:[function(require,module,exports){ +var getKeys = require('./_object-keys') + , toIObject = require('./_to-iobject'); +module.exports = function(object, el){ + var O = toIObject(object) + , keys = getKeys(O) + , length = keys.length + , index = 0 + , key; + while(length > index)if(O[key = keys[index++]] === el)return key; +}; +},{"./_object-keys":85,"./_to-iobject":97}],73:[function(require,module,exports){ +module.exports = true; +},{}],74:[function(require,module,exports){ +var META = require('./_uid')('meta') + , isObject = require('./_is-object') + , has = require('./_has') + , setDesc = require('./_object-dp').f + , id = 0; +var isExtensible = Object.isExtensible || function(){ + return true; +}; +var FREEZE = !require('./_fails')(function(){ + return isExtensible(Object.preventExtensions({})); +}); +var setMeta = function(it){ + setDesc(it, META, {value: { + i: 'O' + ++id, // object ID + w: {} // weak collections IDs + }}); +}; +var fastKey = function(it, create){ + // return primitive with prefix + if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; + if(!has(it, META)){ + // can't set metadata to uncaught frozen object + if(!isExtensible(it))return 'F'; + // not necessary to add metadata + if(!create)return 'E'; + // add missing metadata + setMeta(it); + // return object ID + } return it[META].i; +}; +var getWeak = function(it, create){ + if(!has(it, META)){ + // can't set metadata to uncaught frozen object + if(!isExtensible(it))return true; + // not necessary to add metadata + if(!create)return false; + // add missing metadata + setMeta(it); + // return hash weak collections IDs + } return it[META].w; +}; +// add metadata on freeze-family methods calling +var onFreeze = function(it){ + if(FREEZE && meta.NEED && isExtensible(it) && !has(it, META))setMeta(it); + return it; +}; +var meta = module.exports = { + KEY: META, + NEED: false, + fastKey: fastKey, + getWeak: getWeak, + onFreeze: onFreeze +}; +},{"./_fails":56,"./_has":58,"./_is-object":65,"./_object-dp":77,"./_uid":101}],75:[function(require,module,exports){ +'use strict'; +// 19.1.2.1 Object.assign(target, source, ...) +var getKeys = require('./_object-keys') + , gOPS = require('./_object-gops') + , pIE = require('./_object-pie') + , toObject = require('./_to-object') + , IObject = require('./_iobject') + , $assign = Object.assign; + +// should work with symbols and should have deterministic property order (V8 bug) +module.exports = !$assign || require('./_fails')(function(){ + var A = {} + , B = {} + , S = Symbol() + , K = 'abcdefghijklmnopqrst'; + A[S] = 7; + K.split('').forEach(function(k){ B[k] = k; }); + return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K; +}) ? function assign(target, source){ // eslint-disable-line no-unused-vars + var T = toObject(target) + , aLen = arguments.length + , index = 1 + , getSymbols = gOPS.f + , isEnum = pIE.f; + while(aLen > index){ + var S = IObject(arguments[index++]) + , keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S) + , length = keys.length + , j = 0 + , key; + while(length > j)if(isEnum.call(S, key = keys[j++]))T[key] = S[key]; + } return T; +} : $assign; +},{"./_fails":56,"./_iobject":62,"./_object-gops":82,"./_object-keys":85,"./_object-pie":86,"./_to-object":99}],76:[function(require,module,exports){ +// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) +var anObject = require('./_an-object') + , dPs = require('./_object-dps') + , enumBugKeys = require('./_enum-bug-keys') + , IE_PROTO = require('./_shared-key')('IE_PROTO') + , Empty = function(){ /* empty */ } + , PROTOTYPE = 'prototype'; + +// Create object with fake `null` prototype: use iframe Object with cleared prototype +var createDict = function(){ + // Thrash, waste and sodomy: IE GC bug + var iframe = require('./_dom-create')('iframe') + , i = enumBugKeys.length + , lt = '<' + , gt = '>' + , iframeDocument; + iframe.style.display = 'none'; + require('./_html').appendChild(iframe); + iframe.src = 'javascript:'; // eslint-disable-line no-script-url + // createDict = iframe.contentWindow.Object; + // html.removeChild(iframe); + iframeDocument = iframe.contentWindow.document; + iframeDocument.open(); + iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); + iframeDocument.close(); + createDict = iframeDocument.F; + while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]]; + return createDict(); +}; + +module.exports = Object.create || function create(O, Properties){ + var result; + if(O !== null){ + Empty[PROTOTYPE] = anObject(O); + result = new Empty; + Empty[PROTOTYPE] = null; + // add "__proto__" for Object.getPrototypeOf polyfill + result[IE_PROTO] = O; + } else result = createDict(); + return Properties === undefined ? result : dPs(result, Properties); +}; + +},{"./_an-object":43,"./_dom-create":52,"./_enum-bug-keys":53,"./_html":60,"./_object-dps":78,"./_shared-key":92}],77:[function(require,module,exports){ +var anObject = require('./_an-object') + , IE8_DOM_DEFINE = require('./_ie8-dom-define') + , toPrimitive = require('./_to-primitive') + , dP = Object.defineProperty; + +exports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes){ + anObject(O); + P = toPrimitive(P, true); + anObject(Attributes); + if(IE8_DOM_DEFINE)try { + return dP(O, P, Attributes); + } catch(e){ /* empty */ } + if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!'); + if('value' in Attributes)O[P] = Attributes.value; + return O; +}; +},{"./_an-object":43,"./_descriptors":51,"./_ie8-dom-define":61,"./_to-primitive":100}],78:[function(require,module,exports){ +var dP = require('./_object-dp') + , anObject = require('./_an-object') + , getKeys = require('./_object-keys'); + +module.exports = require('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties){ + anObject(O); + var keys = getKeys(Properties) + , length = keys.length + , i = 0 + , P; + while(length > i)dP.f(O, P = keys[i++], Properties[P]); + return O; +}; +},{"./_an-object":43,"./_descriptors":51,"./_object-dp":77,"./_object-keys":85}],79:[function(require,module,exports){ +var pIE = require('./_object-pie') + , createDesc = require('./_property-desc') + , toIObject = require('./_to-iobject') + , toPrimitive = require('./_to-primitive') + , has = require('./_has') + , IE8_DOM_DEFINE = require('./_ie8-dom-define') + , gOPD = Object.getOwnPropertyDescriptor; + +exports.f = require('./_descriptors') ? gOPD : function getOwnPropertyDescriptor(O, P){ + O = toIObject(O); + P = toPrimitive(P, true); + if(IE8_DOM_DEFINE)try { + return gOPD(O, P); + } catch(e){ /* empty */ } + if(has(O, P))return createDesc(!pIE.f.call(O, P), O[P]); +}; +},{"./_descriptors":51,"./_has":58,"./_ie8-dom-define":61,"./_object-pie":86,"./_property-desc":88,"./_to-iobject":97,"./_to-primitive":100}],80:[function(require,module,exports){ +// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window +var toIObject = require('./_to-iobject') + , gOPN = require('./_object-gopn').f + , toString = {}.toString; + +var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames + ? Object.getOwnPropertyNames(window) : []; + +var getWindowNames = function(it){ + try { + return gOPN(it); + } catch(e){ + return windowNames.slice(); } }; -exports.__esModule = true; -},{"babel-runtime/core-js/array/from":1}],28:[function(require,module,exports){ -/*! - * Bowser - a browser detector - * https://github.com/ded/bowser - * MIT License | (c) Dustin Diaz 2014 - */ +module.exports.f = function getOwnPropertyNames(it){ + return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it)); +}; -!function (name, definition) { - if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition() - else if (typeof define == 'function' && define.amd) define(definition) - else this[name] = definition() -}('bowser', function () { - /** - * See useragents.js for examples of navigator.userAgent - */ +},{"./_object-gopn":81,"./_to-iobject":97}],81:[function(require,module,exports){ +// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) +var $keys = require('./_object-keys-internal') + , hiddenKeys = require('./_enum-bug-keys').concat('length', 'prototype'); - var t = true +exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O){ + return $keys(O, hiddenKeys); +}; +},{"./_enum-bug-keys":53,"./_object-keys-internal":84}],82:[function(require,module,exports){ +exports.f = Object.getOwnPropertySymbols; +},{}],83:[function(require,module,exports){ +// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) +var has = require('./_has') + , toObject = require('./_to-object') + , IE_PROTO = require('./_shared-key')('IE_PROTO') + , ObjectProto = Object.prototype; - function detect(ua) { +module.exports = Object.getPrototypeOf || function(O){ + O = toObject(O); + if(has(O, IE_PROTO))return O[IE_PROTO]; + if(typeof O.constructor == 'function' && O instanceof O.constructor){ + return O.constructor.prototype; + } return O instanceof Object ? ObjectProto : null; +}; +},{"./_has":58,"./_shared-key":92,"./_to-object":99}],84:[function(require,module,exports){ +var has = require('./_has') + , toIObject = require('./_to-iobject') + , arrayIndexOf = require('./_array-includes')(false) + , IE_PROTO = require('./_shared-key')('IE_PROTO'); - function getFirstMatch(regex) { - var match = ua.match(regex); - return (match && match.length > 1 && match[1]) || ''; - } - - function getSecondMatch(regex) { - var match = ua.match(regex); - return (match && match.length > 1 && match[2]) || ''; - } - - var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase() - , likeAndroid = /like android/i.test(ua) - , android = !likeAndroid && /android/i.test(ua) - , edgeVersion = getFirstMatch(/edge\/(\d+(\.\d+)?)/i) - , versionIdentifier = getFirstMatch(/version\/(\d+(\.\d+)?)/i) - , tablet = /tablet/i.test(ua) - , mobile = !tablet && /[^-]mobi/i.test(ua) - , result - - if (/opera|opr/i.test(ua)) { - result = { - name: 'Opera' - , opera: t - , version: versionIdentifier || getFirstMatch(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i) - } - } - else if (/windows phone/i.test(ua)) { - result = { - name: 'Windows Phone' - , windowsphone: t - } - if (edgeVersion) { - result.msedge = t - result.version = edgeVersion - } - else { - result.msie = t - result.version = getFirstMatch(/iemobile\/(\d+(\.\d+)?)/i) - } - } - else if (/msie|trident/i.test(ua)) { - result = { - name: 'Internet Explorer' - , msie: t - , version: getFirstMatch(/(?:msie |rv:)(\d+(\.\d+)?)/i) - } - } - else if (/chrome.+? edge/i.test(ua)) { - result = { - name: 'Microsoft Edge' - , msedge: t - , version: edgeVersion - } - } - else if (/chrome|crios|crmo/i.test(ua)) { - result = { - name: 'Chrome' - , chrome: t - , version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i) - } - } - else if (iosdevice) { - result = { - name : iosdevice == 'iphone' ? 'iPhone' : iosdevice == 'ipad' ? 'iPad' : 'iPod' - } - // WTF: version is not part of user agent in web apps - if (versionIdentifier) { - result.version = versionIdentifier - } - } - else if (/sailfish/i.test(ua)) { - result = { - name: 'Sailfish' - , sailfish: t - , version: getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i) - } - } - else if (/seamonkey\//i.test(ua)) { - result = { - name: 'SeaMonkey' - , seamonkey: t - , version: getFirstMatch(/seamonkey\/(\d+(\.\d+)?)/i) - } - } - else if (/firefox|iceweasel/i.test(ua)) { - result = { - name: 'Firefox' - , firefox: t - , version: getFirstMatch(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i) - } - if (/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(ua)) { - result.firefoxos = t - } - } - else if (/silk/i.test(ua)) { - result = { - name: 'Amazon Silk' - , silk: t - , version : getFirstMatch(/silk\/(\d+(\.\d+)?)/i) - } - } - else if (android) { - result = { - name: 'Android' - , version: versionIdentifier - } - } - else if (/phantom/i.test(ua)) { - result = { - name: 'PhantomJS' - , phantom: t - , version: getFirstMatch(/phantomjs\/(\d+(\.\d+)?)/i) - } - } - else if (/blackberry|\bbb\d+/i.test(ua) || /rim\stablet/i.test(ua)) { - result = { - name: 'BlackBerry' - , blackberry: t - , version: versionIdentifier || getFirstMatch(/blackberry[\d]+\/(\d+(\.\d+)?)/i) - } - } - else if (/(web|hpw)os/i.test(ua)) { - result = { - name: 'WebOS' - , webos: t - , version: versionIdentifier || getFirstMatch(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i) - }; - /touchpad\//i.test(ua) && (result.touchpad = t) - } - else if (/bada/i.test(ua)) { - result = { - name: 'Bada' - , bada: t - , version: getFirstMatch(/dolfin\/(\d+(\.\d+)?)/i) - }; - } - else if (/tizen/i.test(ua)) { - result = { - name: 'Tizen' - , tizen: t - , version: getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i) || versionIdentifier - }; - } - else if (/safari/i.test(ua)) { - result = { - name: 'Safari' - , safari: t - , version: versionIdentifier - } - } - else { - result = { - name: getFirstMatch(/^(.*)\/(.*) /), - version: getSecondMatch(/^(.*)\/(.*) /) - }; - } - - // set webkit or gecko flag for browsers based on these engines - if (!result.msedge && /(apple)?webkit/i.test(ua)) { - result.name = result.name || "Webkit" - result.webkit = t - if (!result.version && versionIdentifier) { - result.version = versionIdentifier - } - } else if (!result.opera && /gecko\//i.test(ua)) { - result.name = result.name || "Gecko" - result.gecko = t - result.version = result.version || getFirstMatch(/gecko\/(\d+(\.\d+)?)/i) - } - - // set OS flags for platforms that have multiple browsers - if (!result.msedge && (android || result.silk)) { - result.android = t - } else if (iosdevice) { - result[iosdevice] = t - result.ios = t - } - - // OS version extraction - var osVersion = ''; - if (result.windowsphone) { - osVersion = getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i); - } else if (iosdevice) { - osVersion = getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i); - osVersion = osVersion.replace(/[_\s]/g, '.'); - } else if (android) { - osVersion = getFirstMatch(/android[ \/-](\d+(\.\d+)*)/i); - } else if (result.webos) { - osVersion = getFirstMatch(/(?:web|hpw)os\/(\d+(\.\d+)*)/i); - } else if (result.blackberry) { - osVersion = getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i); - } else if (result.bada) { - osVersion = getFirstMatch(/bada\/(\d+(\.\d+)*)/i); - } else if (result.tizen) { - osVersion = getFirstMatch(/tizen[\/\s](\d+(\.\d+)*)/i); - } - if (osVersion) { - result.osversion = osVersion; - } - - // device type extraction - var osMajorVersion = osVersion.split('.')[0]; - if (tablet || iosdevice == 'ipad' || (android && (osMajorVersion == 3 || (osMajorVersion == 4 && !mobile))) || result.silk) { - result.tablet = t - } else if (mobile || iosdevice == 'iphone' || iosdevice == 'ipod' || android || result.blackberry || result.webos || result.bada) { - result.mobile = t - } - - // Graded Browser Support - // http://developer.yahoo.com/yui/articles/gbs - if (result.msedge || - (result.msie && result.version >= 10) || - (result.chrome && result.version >= 20) || - (result.firefox && result.version >= 20.0) || - (result.safari && result.version >= 6) || - (result.opera && result.version >= 10.0) || - (result.ios && result.osversion && result.osversion.split(".")[0] >= 6) || - (result.blackberry && result.version >= 10.1) - ) { - result.a = t; - } - else if ((result.msie && result.version < 10) || - (result.chrome && result.version < 20) || - (result.firefox && result.version < 20.0) || - (result.safari && result.version < 6) || - (result.opera && result.version < 10.0) || - (result.ios && result.osversion && result.osversion.split(".")[0] < 6) - ) { - result.c = t - } else result.x = t - - return result +module.exports = function(object, names){ + var O = toIObject(object) + , i = 0 + , result = [] + , key; + for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key); + // Don't enum bug & hidden keys + while(names.length > i)if(has(O, key = names[i++])){ + ~arrayIndexOf(result, key) || result.push(key); } + return result; +}; +},{"./_array-includes":44,"./_has":58,"./_shared-key":92,"./_to-iobject":97}],85:[function(require,module,exports){ +// 19.1.2.14 / 15.2.3.14 Object.keys(O) +var $keys = require('./_object-keys-internal') + , enumBugKeys = require('./_enum-bug-keys'); - var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent : '') +module.exports = Object.keys || function keys(O){ + return $keys(O, enumBugKeys); +}; +},{"./_enum-bug-keys":53,"./_object-keys-internal":84}],86:[function(require,module,exports){ +exports.f = {}.propertyIsEnumerable; +},{}],87:[function(require,module,exports){ +var getKeys = require('./_object-keys') + , toIObject = require('./_to-iobject') + , isEnum = require('./_object-pie').f; +module.exports = function(isEntries){ + return function(it){ + var O = toIObject(it) + , keys = getKeys(O) + , length = keys.length + , i = 0 + , result = [] + , key; + while(length > i)if(isEnum.call(O, key = keys[i++])){ + result.push(isEntries ? [key, O[key]] : O[key]); + } return result; + }; +}; +},{"./_object-keys":85,"./_object-pie":86,"./_to-iobject":97}],88:[function(require,module,exports){ +module.exports = function(bitmap, value){ + return { + enumerable : !(bitmap & 1), + configurable: !(bitmap & 2), + writable : !(bitmap & 4), + value : value + }; +}; +},{}],89:[function(require,module,exports){ +module.exports = require('./_hide'); +},{"./_hide":59}],90:[function(require,module,exports){ +// Works with __proto__ only. Old v8 can't work with null proto objects. +/* eslint-disable no-proto */ +var isObject = require('./_is-object') + , anObject = require('./_an-object'); +var check = function(O, proto){ + anObject(O); + if(!isObject(proto) && proto !== null)throw TypeError(proto + ": can't set as prototype!"); +}; +module.exports = { + set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line + function(test, buggy, set){ + try { + set = require('./_ctx')(Function.call, require('./_object-gopd').f(Object.prototype, '__proto__').set, 2); + set(test, []); + buggy = !(test instanceof Array); + } catch(e){ buggy = true; } + return function setPrototypeOf(O, proto){ + check(O, proto); + if(buggy)O.__proto__ = proto; + else set(O, proto); + return O; + }; + }({}, false) : undefined), + check: check +}; +},{"./_an-object":43,"./_ctx":49,"./_is-object":65,"./_object-gopd":79}],91:[function(require,module,exports){ +var def = require('./_object-dp').f + , has = require('./_has') + , TAG = require('./_wks')('toStringTag'); - bowser.test = function (browserList) { - for (var i = 0; i < browserList.length; ++i) { - var browserItem = browserList[i]; - if (typeof browserItem=== 'string') { - if (browserItem in bowser) { - return true; - } +module.exports = function(it, tag, stat){ + if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag}); +}; +},{"./_has":58,"./_object-dp":77,"./_wks":104}],92:[function(require,module,exports){ +var shared = require('./_shared')('keys') + , uid = require('./_uid'); +module.exports = function(key){ + return shared[key] || (shared[key] = uid(key)); +}; +},{"./_shared":93,"./_uid":101}],93:[function(require,module,exports){ +var global = require('./_global') + , SHARED = '__core-js_shared__' + , store = global[SHARED] || (global[SHARED] = {}); +module.exports = function(key){ + return store[key] || (store[key] = {}); +}; +},{"./_global":57}],94:[function(require,module,exports){ +var toInteger = require('./_to-integer') + , defined = require('./_defined'); +// true -> String#at +// false -> String#codePointAt +module.exports = function(TO_STRING){ + return function(that, pos){ + var s = String(defined(that)) + , i = toInteger(pos) + , l = s.length + , a, b; + if(i < 0 || i >= l)return TO_STRING ? '' : undefined; + a = s.charCodeAt(i); + return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff + ? TO_STRING ? s.charAt(i) : a + : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; + }; +}; +},{"./_defined":50,"./_to-integer":96}],95:[function(require,module,exports){ +var toInteger = require('./_to-integer') + , max = Math.max + , min = Math.min; +module.exports = function(index, length){ + index = toInteger(index); + return index < 0 ? max(index + length, 0) : min(index, length); +}; +},{"./_to-integer":96}],96:[function(require,module,exports){ +// 7.1.4 ToInteger +var ceil = Math.ceil + , floor = Math.floor; +module.exports = function(it){ + return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); +}; +},{}],97:[function(require,module,exports){ +// to indexed object, toObject with fallback for non-array-like ES3 strings +var IObject = require('./_iobject') + , defined = require('./_defined'); +module.exports = function(it){ + return IObject(defined(it)); +}; +},{"./_defined":50,"./_iobject":62}],98:[function(require,module,exports){ +// 7.1.15 ToLength +var toInteger = require('./_to-integer') + , min = Math.min; +module.exports = function(it){ + return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 +}; +},{"./_to-integer":96}],99:[function(require,module,exports){ +// 7.1.13 ToObject(argument) +var defined = require('./_defined'); +module.exports = function(it){ + return Object(defined(it)); +}; +},{"./_defined":50}],100:[function(require,module,exports){ +// 7.1.1 ToPrimitive(input [, PreferredType]) +var isObject = require('./_is-object'); +// instead of the ES6 spec version, we didn't implement @@toPrimitive case +// and the second argument - flag - preferred type is a string +module.exports = function(it, S){ + if(!isObject(it))return it; + var fn, val; + if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val; + if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val; + if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val; + throw TypeError("Can't convert object to primitive value"); +}; +},{"./_is-object":65}],101:[function(require,module,exports){ +var id = 0 + , px = Math.random(); +module.exports = function(key){ + return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); +}; +},{}],102:[function(require,module,exports){ +var global = require('./_global') + , core = require('./_core') + , LIBRARY = require('./_library') + , wksExt = require('./_wks-ext') + , defineProperty = require('./_object-dp').f; +module.exports = function(name){ + var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {}); + if(name.charAt(0) != '_' && !(name in $Symbol))defineProperty($Symbol, name, {value: wksExt.f(name)}); +}; +},{"./_core":47,"./_global":57,"./_library":73,"./_object-dp":77,"./_wks-ext":103}],103:[function(require,module,exports){ +exports.f = require('./_wks'); +},{"./_wks":104}],104:[function(require,module,exports){ +var store = require('./_shared')('wks') + , uid = require('./_uid') + , Symbol = require('./_global').Symbol + , USE_SYMBOL = typeof Symbol == 'function'; + +var $exports = module.exports = function(name){ + return store[name] || (store[name] = + USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name)); +}; + +$exports.store = store; +},{"./_global":57,"./_shared":93,"./_uid":101}],105:[function(require,module,exports){ +var classof = require('./_classof') + , ITERATOR = require('./_wks')('iterator') + , Iterators = require('./_iterators'); +module.exports = require('./_core').getIteratorMethod = function(it){ + if(it != undefined)return it[ITERATOR] + || it['@@iterator'] + || Iterators[classof(it)]; +}; +},{"./_classof":45,"./_core":47,"./_iterators":71,"./_wks":104}],106:[function(require,module,exports){ +'use strict'; +var ctx = require('./_ctx') + , $export = require('./_export') + , toObject = require('./_to-object') + , call = require('./_iter-call') + , isArrayIter = require('./_is-array-iter') + , toLength = require('./_to-length') + , createProperty = require('./_create-property') + , getIterFn = require('./core.get-iterator-method'); + +$export($export.S + $export.F * !require('./_iter-detect')(function(iter){ Array.from(iter); }), 'Array', { + // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) + from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){ + var O = toObject(arrayLike) + , C = typeof this == 'function' ? this : Array + , aLen = arguments.length + , mapfn = aLen > 1 ? arguments[1] : undefined + , mapping = mapfn !== undefined + , index = 0 + , iterFn = getIterFn(O) + , length, result, step, iterator; + if(mapping)mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2); + // if object isn't iterable or it's array with default iterator - use simple case + if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){ + for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){ + createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value); + } + } else { + length = toLength(O.length); + for(result = new C(length); length > index; index++){ + createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]); } } - return false; + result.length = index; + return result; } - - /* - * Set our detect method to the main bowser object so we can - * reuse it to test other user agents. - * This is needed to implement future tests. - */ - bowser._detect = detect; - - return bowser }); -},{}],29:[function(require,module,exports){ +},{"./_create-property":48,"./_ctx":49,"./_export":55,"./_is-array-iter":63,"./_iter-call":66,"./_iter-detect":69,"./_to-length":98,"./_to-object":99,"./core.get-iterator-method":105}],107:[function(require,module,exports){ +'use strict'; +var addToUnscopables = require('./_add-to-unscopables') + , step = require('./_iter-step') + , Iterators = require('./_iterators') + , toIObject = require('./_to-iobject'); -},{}],30:[function(require,module,exports){ +// 22.1.3.4 Array.prototype.entries() +// 22.1.3.13 Array.prototype.keys() +// 22.1.3.29 Array.prototype.values() +// 22.1.3.30 Array.prototype[@@iterator]() +module.exports = require('./_iter-define')(Array, 'Array', function(iterated, kind){ + this._t = toIObject(iterated); // target + this._i = 0; // next index + this._k = kind; // kind +// 22.1.5.2.1 %ArrayIteratorPrototype%.next() +}, function(){ + var O = this._t + , kind = this._k + , index = this._i++; + if(!O || index >= O.length){ + this._t = undefined; + return step(1); + } + if(kind == 'keys' )return step(0, index); + if(kind == 'values')return step(0, O[index]); + return step(0, [index, O[index]]); +}, 'values'); + +// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7) +Iterators.Arguments = Iterators.Array; + +addToUnscopables('keys'); +addToUnscopables('values'); +addToUnscopables('entries'); +},{"./_add-to-unscopables":42,"./_iter-define":68,"./_iter-step":70,"./_iterators":71,"./_to-iobject":97}],108:[function(require,module,exports){ +// 19.1.3.1 Object.assign(target, source) +var $export = require('./_export'); + +$export($export.S + $export.F, 'Object', {assign: require('./_object-assign')}); +},{"./_export":55,"./_object-assign":75}],109:[function(require,module,exports){ +var $export = require('./_export') +// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) +$export($export.S, 'Object', {create: require('./_object-create')}); +},{"./_export":55,"./_object-create":76}],110:[function(require,module,exports){ +// 19.1.3.19 Object.setPrototypeOf(O, proto) +var $export = require('./_export'); +$export($export.S, 'Object', {setPrototypeOf: require('./_set-proto').set}); +},{"./_export":55,"./_set-proto":90}],111:[function(require,module,exports){ + +},{}],112:[function(require,module,exports){ +'use strict'; +var $at = require('./_string-at')(true); + +// 21.1.3.27 String.prototype[@@iterator]() +require('./_iter-define')(String, 'String', function(iterated){ + this._t = String(iterated); // target + this._i = 0; // next index +// 21.1.5.2.1 %StringIteratorPrototype%.next() +}, function(){ + var O = this._t + , index = this._i + , point; + if(index >= O.length)return {value: undefined, done: true}; + point = $at(O, index); + this._i += point.length; + return {value: point, done: false}; +}); +},{"./_iter-define":68,"./_string-at":94}],113:[function(require,module,exports){ +'use strict'; +// ECMAScript 6 symbols shim +var global = require('./_global') + , has = require('./_has') + , DESCRIPTORS = require('./_descriptors') + , $export = require('./_export') + , redefine = require('./_redefine') + , META = require('./_meta').KEY + , $fails = require('./_fails') + , shared = require('./_shared') + , setToStringTag = require('./_set-to-string-tag') + , uid = require('./_uid') + , wks = require('./_wks') + , wksExt = require('./_wks-ext') + , wksDefine = require('./_wks-define') + , keyOf = require('./_keyof') + , enumKeys = require('./_enum-keys') + , isArray = require('./_is-array') + , anObject = require('./_an-object') + , toIObject = require('./_to-iobject') + , toPrimitive = require('./_to-primitive') + , createDesc = require('./_property-desc') + , _create = require('./_object-create') + , gOPNExt = require('./_object-gopn-ext') + , $GOPD = require('./_object-gopd') + , $DP = require('./_object-dp') + , $keys = require('./_object-keys') + , gOPD = $GOPD.f + , dP = $DP.f + , gOPN = gOPNExt.f + , $Symbol = global.Symbol + , $JSON = global.JSON + , _stringify = $JSON && $JSON.stringify + , PROTOTYPE = 'prototype' + , HIDDEN = wks('_hidden') + , TO_PRIMITIVE = wks('toPrimitive') + , isEnum = {}.propertyIsEnumerable + , SymbolRegistry = shared('symbol-registry') + , AllSymbols = shared('symbols') + , OPSymbols = shared('op-symbols') + , ObjectProto = Object[PROTOTYPE] + , USE_NATIVE = typeof $Symbol == 'function' + , QObject = global.QObject; +// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173 +var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild; + +// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 +var setSymbolDesc = DESCRIPTORS && $fails(function(){ + return _create(dP({}, 'a', { + get: function(){ return dP(this, 'a', {value: 7}).a; } + })).a != 7; +}) ? function(it, key, D){ + var protoDesc = gOPD(ObjectProto, key); + if(protoDesc)delete ObjectProto[key]; + dP(it, key, D); + if(protoDesc && it !== ObjectProto)dP(ObjectProto, key, protoDesc); +} : dP; + +var wrap = function(tag){ + var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]); + sym._k = tag; + return sym; +}; + +var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function(it){ + return typeof it == 'symbol'; +} : function(it){ + return it instanceof $Symbol; +}; + +var $defineProperty = function defineProperty(it, key, D){ + if(it === ObjectProto)$defineProperty(OPSymbols, key, D); + anObject(it); + key = toPrimitive(key, true); + anObject(D); + if(has(AllSymbols, key)){ + if(!D.enumerable){ + if(!has(it, HIDDEN))dP(it, HIDDEN, createDesc(1, {})); + it[HIDDEN][key] = true; + } else { + if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false; + D = _create(D, {enumerable: createDesc(0, false)}); + } return setSymbolDesc(it, key, D); + } return dP(it, key, D); +}; +var $defineProperties = function defineProperties(it, P){ + anObject(it); + var keys = enumKeys(P = toIObject(P)) + , i = 0 + , l = keys.length + , key; + while(l > i)$defineProperty(it, key = keys[i++], P[key]); + return it; +}; +var $create = function create(it, P){ + return P === undefined ? _create(it) : $defineProperties(_create(it), P); +}; +var $propertyIsEnumerable = function propertyIsEnumerable(key){ + var E = isEnum.call(this, key = toPrimitive(key, true)); + if(this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return false; + return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true; +}; +var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key){ + it = toIObject(it); + key = toPrimitive(key, true); + if(it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return; + var D = gOPD(it, key); + if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true; + return D; +}; +var $getOwnPropertyNames = function getOwnPropertyNames(it){ + var names = gOPN(toIObject(it)) + , result = [] + , i = 0 + , key; + while(names.length > i){ + if(!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META)result.push(key); + } return result; +}; +var $getOwnPropertySymbols = function getOwnPropertySymbols(it){ + var IS_OP = it === ObjectProto + , names = gOPN(IS_OP ? OPSymbols : toIObject(it)) + , result = [] + , i = 0 + , key; + while(names.length > i){ + if(has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true))result.push(AllSymbols[key]); + } return result; +}; + +// 19.4.1.1 Symbol([description]) +if(!USE_NATIVE){ + $Symbol = function Symbol(){ + if(this instanceof $Symbol)throw TypeError('Symbol is not a constructor!'); + var tag = uid(arguments.length > 0 ? arguments[0] : undefined); + var $set = function(value){ + if(this === ObjectProto)$set.call(OPSymbols, value); + if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false; + setSymbolDesc(this, tag, createDesc(1, value)); + }; + if(DESCRIPTORS && setter)setSymbolDesc(ObjectProto, tag, {configurable: true, set: $set}); + return wrap(tag); + }; + redefine($Symbol[PROTOTYPE], 'toString', function toString(){ + return this._k; + }); + + $GOPD.f = $getOwnPropertyDescriptor; + $DP.f = $defineProperty; + require('./_object-gopn').f = gOPNExt.f = $getOwnPropertyNames; + require('./_object-pie').f = $propertyIsEnumerable; + require('./_object-gops').f = $getOwnPropertySymbols; + + if(DESCRIPTORS && !require('./_library')){ + redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true); + } + + wksExt.f = function(name){ + return wrap(wks(name)); + } +} + +$export($export.G + $export.W + $export.F * !USE_NATIVE, {Symbol: $Symbol}); + +for(var symbols = ( + // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14 + 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables' +).split(','), i = 0; symbols.length > i; )wks(symbols[i++]); + +for(var symbols = $keys(wks.store), i = 0; symbols.length > i; )wksDefine(symbols[i++]); + +$export($export.S + $export.F * !USE_NATIVE, 'Symbol', { + // 19.4.2.1 Symbol.for(key) + 'for': function(key){ + return has(SymbolRegistry, key += '') + ? SymbolRegistry[key] + : SymbolRegistry[key] = $Symbol(key); + }, + // 19.4.2.5 Symbol.keyFor(sym) + keyFor: function keyFor(key){ + if(isSymbol(key))return keyOf(SymbolRegistry, key); + throw TypeError(key + ' is not a symbol!'); + }, + useSetter: function(){ setter = true; }, + useSimple: function(){ setter = false; } +}); + +$export($export.S + $export.F * !USE_NATIVE, 'Object', { + // 19.1.2.2 Object.create(O [, Properties]) + create: $create, + // 19.1.2.4 Object.defineProperty(O, P, Attributes) + defineProperty: $defineProperty, + // 19.1.2.3 Object.defineProperties(O, Properties) + defineProperties: $defineProperties, + // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) + getOwnPropertyDescriptor: $getOwnPropertyDescriptor, + // 19.1.2.7 Object.getOwnPropertyNames(O) + getOwnPropertyNames: $getOwnPropertyNames, + // 19.1.2.8 Object.getOwnPropertySymbols(O) + getOwnPropertySymbols: $getOwnPropertySymbols +}); + +// 24.3.2 JSON.stringify(value [, replacer [, space]]) +$JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function(){ + var S = $Symbol(); + // MS Edge converts symbol values to JSON as {} + // WebKit converts symbol values to JSON as null + // V8 throws on boxed symbols + return _stringify([S]) != '[null]' || _stringify({a: S}) != '{}' || _stringify(Object(S)) != '{}'; +})), 'JSON', { + stringify: function stringify(it){ + if(it === undefined || isSymbol(it))return; // IE8 returns string on undefined + var args = [it] + , i = 1 + , replacer, $replacer; + while(arguments.length > i)args.push(arguments[i++]); + replacer = args[1]; + if(typeof replacer == 'function')$replacer = replacer; + if($replacer || !isArray(replacer))replacer = function(key, value){ + if($replacer)value = $replacer.call(this, key, value); + if(!isSymbol(value))return value; + }; + args[1] = replacer; + return _stringify.apply($JSON, args); + } +}); + +// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint) +$Symbol[PROTOTYPE][TO_PRIMITIVE] || require('./_hide')($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf); +// 19.4.3.5 Symbol.prototype[@@toStringTag] +setToStringTag($Symbol, 'Symbol'); +// 20.2.1.9 Math[@@toStringTag] +setToStringTag(Math, 'Math', true); +// 24.3.3 JSON[@@toStringTag] +setToStringTag(global.JSON, 'JSON', true); +},{"./_an-object":43,"./_descriptors":51,"./_enum-keys":54,"./_export":55,"./_fails":56,"./_global":57,"./_has":58,"./_hide":59,"./_is-array":64,"./_keyof":72,"./_library":73,"./_meta":74,"./_object-create":76,"./_object-dp":77,"./_object-gopd":79,"./_object-gopn":81,"./_object-gopn-ext":80,"./_object-gops":82,"./_object-keys":85,"./_object-pie":86,"./_property-desc":88,"./_redefine":89,"./_set-to-string-tag":91,"./_shared":93,"./_to-iobject":97,"./_to-primitive":100,"./_uid":101,"./_wks":104,"./_wks-define":102,"./_wks-ext":103}],114:[function(require,module,exports){ +// https://github.com/tc39/proposal-object-values-entries +var $export = require('./_export') + , $entries = require('./_object-to-array')(true); + +$export($export.S, 'Object', { + entries: function entries(it){ + return $entries(it); + } +}); +},{"./_export":55,"./_object-to-array":87}],115:[function(require,module,exports){ +// https://github.com/tc39/proposal-object-values-entries +var $export = require('./_export') + , $values = require('./_object-to-array')(false); + +$export($export.S, 'Object', { + values: function values(it){ + return $values(it); + } +}); +},{"./_export":55,"./_object-to-array":87}],116:[function(require,module,exports){ +require('./_wks-define')('asyncIterator'); +},{"./_wks-define":102}],117:[function(require,module,exports){ +require('./_wks-define')('observable'); +},{"./_wks-define":102}],118:[function(require,module,exports){ +require('./es6.array.iterator'); +var global = require('./_global') + , hide = require('./_hide') + , Iterators = require('./_iterators') + , TO_STRING_TAG = require('./_wks')('toStringTag'); + +for(var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++){ + var NAME = collections[i] + , Collection = global[NAME] + , proto = Collection && Collection.prototype; + if(proto && !proto[TO_STRING_TAG])hide(proto, TO_STRING_TAG, NAME); + Iterators[NAME] = Iterators.Array; +} +},{"./_global":57,"./_hide":59,"./_iterators":71,"./_wks":104,"./es6.array.iterator":107}],119:[function(require,module,exports){ +arguments[4][111][0].apply(exports,arguments) +},{"dup":111}],120:[function(require,module,exports){ module.exports = function (uri) { var mime = uri.split(',')[0].split(':')[1].split(';')[0]; var bytes = atob(uri.split(',')[1]); @@ -600,7 +8139,7 @@ module.exports.init = function () { } } -},{}],31:[function(require,module,exports){ +},{}],121:[function(require,module,exports){ /*! Copyright (c) 2016 Jed Watson. Licensed under the MIT License (MIT), see @@ -650,1758 +8189,10 @@ module.exports.init = function () { } }()); -},{}],32:[function(require,module,exports){ -require('../../modules/es6.string.iterator'); -require('../../modules/es6.array.from'); -module.exports = require('../../modules/$.core').Array.from; -},{"../../modules/$.core":56,"../../modules/es6.array.from":108,"../../modules/es6.string.iterator":120}],33:[function(require,module,exports){ -require('../modules/web.dom.iterable'); -require('../modules/es6.string.iterator'); -module.exports = require('../modules/core.get-iterator'); -},{"../modules/core.get-iterator":106,"../modules/es6.string.iterator":120,"../modules/web.dom.iterable":123}],34:[function(require,module,exports){ -require('../modules/web.dom.iterable'); -require('../modules/es6.string.iterator'); -module.exports = require('../modules/core.is-iterable'); -},{"../modules/core.is-iterable":107,"../modules/es6.string.iterator":120,"../modules/web.dom.iterable":123}],35:[function(require,module,exports){ -require('../modules/es6.object.to-string'); -require('../modules/es6.string.iterator'); -require('../modules/web.dom.iterable'); -require('../modules/es6.map'); -require('../modules/es7.map.to-json'); -module.exports = require('../modules/$.core').Map; -},{"../modules/$.core":56,"../modules/es6.map":110,"../modules/es6.object.to-string":118,"../modules/es6.string.iterator":120,"../modules/es7.map.to-json":122,"../modules/web.dom.iterable":123}],36:[function(require,module,exports){ -require('../../modules/es6.number.is-nan'); -module.exports = require('../../modules/$.core').Number.isNaN; -},{"../../modules/$.core":56,"../../modules/es6.number.is-nan":111}],37:[function(require,module,exports){ -require('../../modules/es6.number.parse-float'); -module.exports = parseFloat; -},{"../../modules/es6.number.parse-float":112}],38:[function(require,module,exports){ -require('../../modules/es6.number.parse-int'); -module.exports = parseInt; -},{"../../modules/es6.number.parse-int":113}],39:[function(require,module,exports){ -require('../../modules/es6.object.assign'); -module.exports = require('../../modules/$.core').Object.assign; -},{"../../modules/$.core":56,"../../modules/es6.object.assign":114}],40:[function(require,module,exports){ -var $ = require('../../modules/$'); -module.exports = function create(P, D){ - return $.create(P, D); -}; -},{"../../modules/$":81}],41:[function(require,module,exports){ -var $ = require('../../modules/$'); -module.exports = function defineProperty(it, key, desc){ - return $.setDesc(it, key, desc); -}; -},{"../../modules/$":81}],42:[function(require,module,exports){ -var $ = require('../../modules/$'); -require('../../modules/es6.object.get-own-property-descriptor'); -module.exports = function getOwnPropertyDescriptor(it, key){ - return $.getDesc(it, key); -}; -},{"../../modules/$":81,"../../modules/es6.object.get-own-property-descriptor":115}],43:[function(require,module,exports){ -require('../../modules/es6.object.keys'); -module.exports = require('../../modules/$.core').Object.keys; -},{"../../modules/$.core":56,"../../modules/es6.object.keys":116}],44:[function(require,module,exports){ -require('../../modules/es6.object.set-prototype-of'); -module.exports = require('../../modules/$.core').Object.setPrototypeOf; -},{"../../modules/$.core":56,"../../modules/es6.object.set-prototype-of":117}],45:[function(require,module,exports){ -require('../modules/es6.object.to-string'); -require('../modules/es6.string.iterator'); -require('../modules/web.dom.iterable'); -require('../modules/es6.promise'); -module.exports = require('../modules/$.core').Promise; -},{"../modules/$.core":56,"../modules/es6.object.to-string":118,"../modules/es6.promise":119,"../modules/es6.string.iterator":120,"../modules/web.dom.iterable":123}],46:[function(require,module,exports){ -require('../../modules/es6.symbol'); -module.exports = require('../../modules/$.core').Symbol['for']; -},{"../../modules/$.core":56,"../../modules/es6.symbol":121}],47:[function(require,module,exports){ -require('../../modules/es6.string.iterator'); -require('../../modules/web.dom.iterable'); -module.exports = require('../../modules/$.wks')('iterator'); -},{"../../modules/$.wks":104,"../../modules/es6.string.iterator":120,"../../modules/web.dom.iterable":123}],48:[function(require,module,exports){ -module.exports = function(it){ - if(typeof it != 'function')throw TypeError(it + ' is not a function!'); - return it; -}; -},{}],49:[function(require,module,exports){ -module.exports = function(){ /* empty */ }; -},{}],50:[function(require,module,exports){ -var isObject = require('./$.is-object'); -module.exports = function(it){ - if(!isObject(it))throw TypeError(it + ' is not an object!'); - return it; -}; -},{"./$.is-object":74}],51:[function(require,module,exports){ -// getting tag from 19.1.3.6 Object.prototype.toString() -var cof = require('./$.cof') - , TAG = require('./$.wks')('toStringTag') - // ES3 wrong here - , ARG = cof(function(){ return arguments; }()) == 'Arguments'; - -module.exports = function(it){ - var O, T, B; - return it === undefined ? 'Undefined' : it === null ? 'Null' - // @@toStringTag case - : typeof (T = (O = Object(it))[TAG]) == 'string' ? T - // builtinTag case - : ARG ? cof(O) - // ES3 arguments fallback - : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; -}; -},{"./$.cof":52,"./$.wks":104}],52:[function(require,module,exports){ -var toString = {}.toString; - -module.exports = function(it){ - return toString.call(it).slice(8, -1); -}; -},{}],53:[function(require,module,exports){ -'use strict'; -var $ = require('./$') - , hide = require('./$.hide') - , redefineAll = require('./$.redefine-all') - , ctx = require('./$.ctx') - , strictNew = require('./$.strict-new') - , defined = require('./$.defined') - , forOf = require('./$.for-of') - , $iterDefine = require('./$.iter-define') - , step = require('./$.iter-step') - , ID = require('./$.uid')('id') - , $has = require('./$.has') - , isObject = require('./$.is-object') - , setSpecies = require('./$.set-species') - , DESCRIPTORS = require('./$.descriptors') - , isExtensible = Object.isExtensible || isObject - , SIZE = DESCRIPTORS ? '_s' : 'size' - , id = 0; - -var fastKey = function(it, create){ - // return primitive with prefix - if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; - if(!$has(it, ID)){ - // can't set id to frozen object - if(!isExtensible(it))return 'F'; - // not necessary to add id - if(!create)return 'E'; - // add missing object id - hide(it, ID, ++id); - // return object id with prefix - } return 'O' + it[ID]; -}; - -var getEntry = function(that, key){ - // fast case - var index = fastKey(key), entry; - if(index !== 'F')return that._i[index]; - // frozen object case - for(entry = that._f; entry; entry = entry.n){ - if(entry.k == key)return entry; - } -}; - -module.exports = { - getConstructor: function(wrapper, NAME, IS_MAP, ADDER){ - var C = wrapper(function(that, iterable){ - strictNew(that, C, NAME); - that._i = $.create(null); // index - that._f = undefined; // first entry - that._l = undefined; // last entry - that[SIZE] = 0; // size - if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that); - }); - redefineAll(C.prototype, { - // 23.1.3.1 Map.prototype.clear() - // 23.2.3.2 Set.prototype.clear() - clear: function clear(){ - for(var that = this, data = that._i, entry = that._f; entry; entry = entry.n){ - entry.r = true; - if(entry.p)entry.p = entry.p.n = undefined; - delete data[entry.i]; - } - that._f = that._l = undefined; - that[SIZE] = 0; - }, - // 23.1.3.3 Map.prototype.delete(key) - // 23.2.3.4 Set.prototype.delete(value) - 'delete': function(key){ - var that = this - , entry = getEntry(that, key); - if(entry){ - var next = entry.n - , prev = entry.p; - delete that._i[entry.i]; - entry.r = true; - if(prev)prev.n = next; - if(next)next.p = prev; - if(that._f == entry)that._f = next; - if(that._l == entry)that._l = prev; - that[SIZE]--; - } return !!entry; - }, - // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined) - // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined) - forEach: function forEach(callbackfn /*, that = undefined */){ - var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3) - , entry; - while(entry = entry ? entry.n : this._f){ - f(entry.v, entry.k, this); - // revert to the last existing entry - while(entry && entry.r)entry = entry.p; - } - }, - // 23.1.3.7 Map.prototype.has(key) - // 23.2.3.7 Set.prototype.has(value) - has: function has(key){ - return !!getEntry(this, key); - } - }); - if(DESCRIPTORS)$.setDesc(C.prototype, 'size', { - get: function(){ - return defined(this[SIZE]); - } - }); - return C; - }, - def: function(that, key, value){ - var entry = getEntry(that, key) - , prev, index; - // change existing entry - if(entry){ - entry.v = value; - // create new entry - } else { - that._l = entry = { - i: index = fastKey(key, true), // <- index - k: key, // <- key - v: value, // <- value - p: prev = that._l, // <- previous entry - n: undefined, // <- next entry - r: false // <- removed - }; - if(!that._f)that._f = entry; - if(prev)prev.n = entry; - that[SIZE]++; - // add to index - if(index !== 'F')that._i[index] = entry; - } return that; - }, - getEntry: getEntry, - setStrong: function(C, NAME, IS_MAP){ - // add .keys, .values, .entries, [@@iterator] - // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11 - $iterDefine(C, NAME, function(iterated, kind){ - this._t = iterated; // target - this._k = kind; // kind - this._l = undefined; // previous - }, function(){ - var that = this - , kind = that._k - , entry = that._l; - // revert to the last existing entry - while(entry && entry.r)entry = entry.p; - // get next entry - if(!that._t || !(that._l = entry = entry ? entry.n : that._t._f)){ - // or finish the iteration - that._t = undefined; - return step(1); - } - // return step by kind - if(kind == 'keys' )return step(0, entry.k); - if(kind == 'values')return step(0, entry.v); - return step(0, [entry.k, entry.v]); - }, IS_MAP ? 'entries' : 'values' , !IS_MAP, true); - - // add [@@species], 23.1.2.2, 23.2.2.2 - setSpecies(NAME); - } -}; -},{"./$":81,"./$.ctx":57,"./$.defined":58,"./$.descriptors":59,"./$.for-of":64,"./$.has":67,"./$.hide":68,"./$.is-object":74,"./$.iter-define":77,"./$.iter-step":79,"./$.redefine-all":88,"./$.set-species":92,"./$.strict-new":96,"./$.uid":103}],54:[function(require,module,exports){ -// https://github.com/DavidBruant/Map-Set.prototype.toJSON -var forOf = require('./$.for-of') - , classof = require('./$.classof'); -module.exports = function(NAME){ - return function toJSON(){ - if(classof(this) != NAME)throw TypeError(NAME + "#toJSON isn't generic"); - var arr = []; - forOf(this, false, arr.push, arr); - return arr; - }; -}; -},{"./$.classof":51,"./$.for-of":64}],55:[function(require,module,exports){ -'use strict'; -var $ = require('./$') - , global = require('./$.global') - , $export = require('./$.export') - , fails = require('./$.fails') - , hide = require('./$.hide') - , redefineAll = require('./$.redefine-all') - , forOf = require('./$.for-of') - , strictNew = require('./$.strict-new') - , isObject = require('./$.is-object') - , setToStringTag = require('./$.set-to-string-tag') - , DESCRIPTORS = require('./$.descriptors'); - -module.exports = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK){ - var Base = global[NAME] - , C = Base - , ADDER = IS_MAP ? 'set' : 'add' - , proto = C && C.prototype - , O = {}; - if(!DESCRIPTORS || typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function(){ - new C().entries().next(); - }))){ - // create collection constructor - C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER); - redefineAll(C.prototype, methods); - } else { - C = wrapper(function(target, iterable){ - strictNew(target, C, NAME); - target._c = new Base; - if(iterable != undefined)forOf(iterable, IS_MAP, target[ADDER], target); - }); - $.each.call('add,clear,delete,forEach,get,has,set,keys,values,entries'.split(','),function(KEY){ - var IS_ADDER = KEY == 'add' || KEY == 'set'; - if(KEY in proto && !(IS_WEAK && KEY == 'clear'))hide(C.prototype, KEY, function(a, b){ - if(!IS_ADDER && IS_WEAK && !isObject(a))return KEY == 'get' ? undefined : false; - var result = this._c[KEY](a === 0 ? 0 : a, b); - return IS_ADDER ? this : result; - }); - }); - if('size' in proto)$.setDesc(C.prototype, 'size', { - get: function(){ - return this._c.size; - } - }); - } - - setToStringTag(C, NAME); - - O[NAME] = C; - $export($export.G + $export.W + $export.F, O); - - if(!IS_WEAK)common.setStrong(C, NAME, IS_MAP); - - return C; -}; -},{"./$":81,"./$.descriptors":59,"./$.export":62,"./$.fails":63,"./$.for-of":64,"./$.global":66,"./$.hide":68,"./$.is-object":74,"./$.redefine-all":88,"./$.set-to-string-tag":93,"./$.strict-new":96}],56:[function(require,module,exports){ -var core = module.exports = {version: '1.2.6'}; -if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef -},{}],57:[function(require,module,exports){ -// optional / simple context binding -var aFunction = require('./$.a-function'); -module.exports = function(fn, that, length){ - aFunction(fn); - if(that === undefined)return fn; - switch(length){ - case 1: return function(a){ - return fn.call(that, a); - }; - case 2: return function(a, b){ - return fn.call(that, a, b); - }; - case 3: return function(a, b, c){ - return fn.call(that, a, b, c); - }; - } - return function(/* ...args */){ - return fn.apply(that, arguments); - }; -}; -},{"./$.a-function":48}],58:[function(require,module,exports){ -// 7.2.1 RequireObjectCoercible(argument) -module.exports = function(it){ - if(it == undefined)throw TypeError("Can't call method on " + it); - return it; -}; -},{}],59:[function(require,module,exports){ -// Thank's IE8 for his funny defineProperty -module.exports = !require('./$.fails')(function(){ - return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; -}); -},{"./$.fails":63}],60:[function(require,module,exports){ -var isObject = require('./$.is-object') - , document = require('./$.global').document - // in old IE typeof document.createElement is 'object' - , is = isObject(document) && isObject(document.createElement); -module.exports = function(it){ - return is ? document.createElement(it) : {}; -}; -},{"./$.global":66,"./$.is-object":74}],61:[function(require,module,exports){ -// all enumerable object keys, includes symbols -var $ = require('./$'); -module.exports = function(it){ - var keys = $.getKeys(it) - , getSymbols = $.getSymbols; - if(getSymbols){ - var symbols = getSymbols(it) - , isEnum = $.isEnum - , i = 0 - , key; - while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))keys.push(key); - } - return keys; -}; -},{"./$":81}],62:[function(require,module,exports){ -var global = require('./$.global') - , core = require('./$.core') - , ctx = require('./$.ctx') - , PROTOTYPE = 'prototype'; - -var $export = function(type, name, source){ - var IS_FORCED = type & $export.F - , IS_GLOBAL = type & $export.G - , IS_STATIC = type & $export.S - , IS_PROTO = type & $export.P - , IS_BIND = type & $export.B - , IS_WRAP = type & $export.W - , exports = IS_GLOBAL ? core : core[name] || (core[name] = {}) - , target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE] - , key, own, out; - if(IS_GLOBAL)source = name; - for(key in source){ - // contains in native - own = !IS_FORCED && target && key in target; - if(own && key in exports)continue; - // export native or passed - out = own ? target[key] : source[key]; - // prevent global pollution for namespaces - exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] - // bind timers to global for call from export context - : IS_BIND && own ? ctx(out, global) - // wrap global constructors for prevent change them in library - : IS_WRAP && target[key] == out ? (function(C){ - var F = function(param){ - return this instanceof C ? new C(param) : C(param); - }; - F[PROTOTYPE] = C[PROTOTYPE]; - return F; - // make static versions for prototype methods - })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; - if(IS_PROTO)(exports[PROTOTYPE] || (exports[PROTOTYPE] = {}))[key] = out; - } -}; -// type bitmap -$export.F = 1; // forced -$export.G = 2; // global -$export.S = 4; // static -$export.P = 8; // proto -$export.B = 16; // bind -$export.W = 32; // wrap -module.exports = $export; -},{"./$.core":56,"./$.ctx":57,"./$.global":66}],63:[function(require,module,exports){ -module.exports = function(exec){ - try { - return !!exec(); - } catch(e){ - return true; - } -}; -},{}],64:[function(require,module,exports){ -var ctx = require('./$.ctx') - , call = require('./$.iter-call') - , isArrayIter = require('./$.is-array-iter') - , anObject = require('./$.an-object') - , toLength = require('./$.to-length') - , getIterFn = require('./core.get-iterator-method'); -module.exports = function(iterable, entries, fn, that){ - var iterFn = getIterFn(iterable) - , f = ctx(fn, that, entries ? 2 : 1) - , index = 0 - , length, step, iterator; - if(typeof iterFn != 'function')throw TypeError(iterable + ' is not iterable!'); - // fast case for arrays with default iterator - if(isArrayIter(iterFn))for(length = toLength(iterable.length); length > index; index++){ - entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); - } else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){ - call(iterator, f, step.value, entries); - } -}; -},{"./$.an-object":50,"./$.ctx":57,"./$.is-array-iter":72,"./$.iter-call":75,"./$.to-length":101,"./core.get-iterator-method":105}],65:[function(require,module,exports){ -// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window -var toIObject = require('./$.to-iobject') - , getNames = require('./$').getNames - , toString = {}.toString; - -var windowNames = typeof window == 'object' && Object.getOwnPropertyNames - ? Object.getOwnPropertyNames(window) : []; - -var getWindowNames = function(it){ - try { - return getNames(it); - } catch(e){ - return windowNames.slice(); - } -}; - -module.exports.get = function getOwnPropertyNames(it){ - if(windowNames && toString.call(it) == '[object Window]')return getWindowNames(it); - return getNames(toIObject(it)); -}; -},{"./$":81,"./$.to-iobject":100}],66:[function(require,module,exports){ -// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 -var global = module.exports = typeof window != 'undefined' && window.Math == Math - ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); -if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef -},{}],67:[function(require,module,exports){ -var hasOwnProperty = {}.hasOwnProperty; -module.exports = function(it, key){ - return hasOwnProperty.call(it, key); -}; -},{}],68:[function(require,module,exports){ -var $ = require('./$') - , createDesc = require('./$.property-desc'); -module.exports = require('./$.descriptors') ? function(object, key, value){ - return $.setDesc(object, key, createDesc(1, value)); -} : function(object, key, value){ - object[key] = value; - return object; -}; -},{"./$":81,"./$.descriptors":59,"./$.property-desc":87}],69:[function(require,module,exports){ -module.exports = require('./$.global').document && document.documentElement; -},{"./$.global":66}],70:[function(require,module,exports){ -// fast apply, http://jsperf.lnkit.com/fast-apply/5 -module.exports = function(fn, args, that){ - var un = that === undefined; - switch(args.length){ - case 0: return un ? fn() - : fn.call(that); - case 1: return un ? fn(args[0]) - : fn.call(that, args[0]); - case 2: return un ? fn(args[0], args[1]) - : fn.call(that, args[0], args[1]); - case 3: return un ? fn(args[0], args[1], args[2]) - : fn.call(that, args[0], args[1], args[2]); - case 4: return un ? fn(args[0], args[1], args[2], args[3]) - : fn.call(that, args[0], args[1], args[2], args[3]); - } return fn.apply(that, args); -}; -},{}],71:[function(require,module,exports){ -// fallback for non-array-like ES3 and non-enumerable old V8 strings -var cof = require('./$.cof'); -module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){ - return cof(it) == 'String' ? it.split('') : Object(it); -}; -},{"./$.cof":52}],72:[function(require,module,exports){ -// check on default Array iterator -var Iterators = require('./$.iterators') - , ITERATOR = require('./$.wks')('iterator') - , ArrayProto = Array.prototype; - -module.exports = function(it){ - return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); -}; -},{"./$.iterators":80,"./$.wks":104}],73:[function(require,module,exports){ -// 7.2.2 IsArray(argument) -var cof = require('./$.cof'); -module.exports = Array.isArray || function(arg){ - return cof(arg) == 'Array'; -}; -},{"./$.cof":52}],74:[function(require,module,exports){ -module.exports = function(it){ - return typeof it === 'object' ? it !== null : typeof it === 'function'; -}; -},{}],75:[function(require,module,exports){ -// call something on iterator step with safe closing on error -var anObject = require('./$.an-object'); -module.exports = function(iterator, fn, value, entries){ - try { - return entries ? fn(anObject(value)[0], value[1]) : fn(value); - // 7.4.6 IteratorClose(iterator, completion) - } catch(e){ - var ret = iterator['return']; - if(ret !== undefined)anObject(ret.call(iterator)); - throw e; - } -}; -},{"./$.an-object":50}],76:[function(require,module,exports){ -'use strict'; -var $ = require('./$') - , descriptor = require('./$.property-desc') - , setToStringTag = require('./$.set-to-string-tag') - , IteratorPrototype = {}; - -// 25.1.2.1.1 %IteratorPrototype%[@@iterator]() -require('./$.hide')(IteratorPrototype, require('./$.wks')('iterator'), function(){ return this; }); - -module.exports = function(Constructor, NAME, next){ - Constructor.prototype = $.create(IteratorPrototype, {next: descriptor(1, next)}); - setToStringTag(Constructor, NAME + ' Iterator'); -}; -},{"./$":81,"./$.hide":68,"./$.property-desc":87,"./$.set-to-string-tag":93,"./$.wks":104}],77:[function(require,module,exports){ -'use strict'; -var LIBRARY = require('./$.library') - , $export = require('./$.export') - , redefine = require('./$.redefine') - , hide = require('./$.hide') - , has = require('./$.has') - , Iterators = require('./$.iterators') - , $iterCreate = require('./$.iter-create') - , setToStringTag = require('./$.set-to-string-tag') - , getProto = require('./$').getProto - , ITERATOR = require('./$.wks')('iterator') - , BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next` - , FF_ITERATOR = '@@iterator' - , KEYS = 'keys' - , VALUES = 'values'; - -var returnThis = function(){ return this; }; - -module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){ - $iterCreate(Constructor, NAME, next); - var getMethod = function(kind){ - if(!BUGGY && kind in proto)return proto[kind]; - switch(kind){ - case KEYS: return function keys(){ return new Constructor(this, kind); }; - case VALUES: return function values(){ return new Constructor(this, kind); }; - } return function entries(){ return new Constructor(this, kind); }; - }; - var TAG = NAME + ' Iterator' - , DEF_VALUES = DEFAULT == VALUES - , VALUES_BUG = false - , proto = Base.prototype - , $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT] - , $default = $native || getMethod(DEFAULT) - , methods, key; - // Fix native - if($native){ - var IteratorPrototype = getProto($default.call(new Base)); - // Set @@toStringTag to native iterators - setToStringTag(IteratorPrototype, TAG, true); - // FF fix - if(!LIBRARY && has(proto, FF_ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis); - // fix Array#{values, @@iterator}.name in V8 / FF - if(DEF_VALUES && $native.name !== VALUES){ - VALUES_BUG = true; - $default = function values(){ return $native.call(this); }; - } - } - // Define iterator - if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){ - hide(proto, ITERATOR, $default); - } - // Plug for library - Iterators[NAME] = $default; - Iterators[TAG] = returnThis; - if(DEFAULT){ - methods = { - values: DEF_VALUES ? $default : getMethod(VALUES), - keys: IS_SET ? $default : getMethod(KEYS), - entries: !DEF_VALUES ? $default : getMethod('entries') - }; - if(FORCED)for(key in methods){ - if(!(key in proto))redefine(proto, key, methods[key]); - } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods); - } - return methods; -}; -},{"./$":81,"./$.export":62,"./$.has":67,"./$.hide":68,"./$.iter-create":76,"./$.iterators":80,"./$.library":83,"./$.redefine":89,"./$.set-to-string-tag":93,"./$.wks":104}],78:[function(require,module,exports){ -var ITERATOR = require('./$.wks')('iterator') - , SAFE_CLOSING = false; - -try { - var riter = [7][ITERATOR](); - riter['return'] = function(){ SAFE_CLOSING = true; }; - Array.from(riter, function(){ throw 2; }); -} catch(e){ /* empty */ } - -module.exports = function(exec, skipClosing){ - if(!skipClosing && !SAFE_CLOSING)return false; - var safe = false; - try { - var arr = [7] - , iter = arr[ITERATOR](); - iter.next = function(){ return {done: safe = true}; }; - arr[ITERATOR] = function(){ return iter; }; - exec(arr); - } catch(e){ /* empty */ } - return safe; -}; -},{"./$.wks":104}],79:[function(require,module,exports){ -module.exports = function(done, value){ - return {value: value, done: !!done}; -}; -},{}],80:[function(require,module,exports){ -module.exports = {}; -},{}],81:[function(require,module,exports){ -var $Object = Object; -module.exports = { - create: $Object.create, - getProto: $Object.getPrototypeOf, - isEnum: {}.propertyIsEnumerable, - getDesc: $Object.getOwnPropertyDescriptor, - setDesc: $Object.defineProperty, - setDescs: $Object.defineProperties, - getKeys: $Object.keys, - getNames: $Object.getOwnPropertyNames, - getSymbols: $Object.getOwnPropertySymbols, - each: [].forEach -}; -},{}],82:[function(require,module,exports){ -var $ = require('./$') - , toIObject = require('./$.to-iobject'); -module.exports = function(object, el){ - var O = toIObject(object) - , keys = $.getKeys(O) - , length = keys.length - , index = 0 - , key; - while(length > index)if(O[key = keys[index++]] === el)return key; -}; -},{"./$":81,"./$.to-iobject":100}],83:[function(require,module,exports){ -module.exports = true; -},{}],84:[function(require,module,exports){ -var global = require('./$.global') - , macrotask = require('./$.task').set - , Observer = global.MutationObserver || global.WebKitMutationObserver - , process = global.process - , Promise = global.Promise - , isNode = require('./$.cof')(process) == 'process' - , head, last, notify; - -var flush = function(){ - var parent, domain, fn; - if(isNode && (parent = process.domain)){ - process.domain = null; - parent.exit(); - } - while(head){ - domain = head.domain; - fn = head.fn; - if(domain)domain.enter(); - fn(); // <- currently we use it only for Promise - try / catch not required - if(domain)domain.exit(); - head = head.next; - } last = undefined; - if(parent)parent.enter(); -}; - -// Node.js -if(isNode){ - notify = function(){ - process.nextTick(flush); - }; -// browsers with MutationObserver -} else if(Observer){ - var toggle = 1 - , node = document.createTextNode(''); - new Observer(flush).observe(node, {characterData: true}); // eslint-disable-line no-new - notify = function(){ - node.data = toggle = -toggle; - }; -// environments with maybe non-completely correct, but existent Promise -} else if(Promise && Promise.resolve){ - notify = function(){ - Promise.resolve().then(flush); - }; -// for other environments - macrotask based on: -// - setImmediate -// - MessageChannel -// - window.postMessag -// - onreadystatechange -// - setTimeout -} else { - notify = function(){ - // strange IE + webpack dev server bug - use .call(global) - macrotask.call(global, flush); - }; -} - -module.exports = function asap(fn){ - var task = {fn: fn, next: undefined, domain: isNode && process.domain}; - if(last)last.next = task; - if(!head){ - head = task; - notify(); - } last = task; -}; -},{"./$.cof":52,"./$.global":66,"./$.task":98}],85:[function(require,module,exports){ -// 19.1.2.1 Object.assign(target, source, ...) -var $ = require('./$') - , toObject = require('./$.to-object') - , IObject = require('./$.iobject'); - -// should work with symbols and should have deterministic property order (V8 bug) -module.exports = require('./$.fails')(function(){ - var a = Object.assign - , A = {} - , B = {} - , S = Symbol() - , K = 'abcdefghijklmnopqrst'; - A[S] = 7; - K.split('').forEach(function(k){ B[k] = k; }); - return a({}, A)[S] != 7 || Object.keys(a({}, B)).join('') != K; -}) ? function assign(target, source){ // eslint-disable-line no-unused-vars - var T = toObject(target) - , $$ = arguments - , $$len = $$.length - , index = 1 - , getKeys = $.getKeys - , getSymbols = $.getSymbols - , isEnum = $.isEnum; - while($$len > index){ - var S = IObject($$[index++]) - , keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S) - , length = keys.length - , j = 0 - , key; - while(length > j)if(isEnum.call(S, key = keys[j++]))T[key] = S[key]; - } - return T; -} : Object.assign; -},{"./$":81,"./$.fails":63,"./$.iobject":71,"./$.to-object":102}],86:[function(require,module,exports){ -// most Object methods by ES6 should accept primitives -var $export = require('./$.export') - , core = require('./$.core') - , fails = require('./$.fails'); -module.exports = function(KEY, exec){ - var fn = (core.Object || {})[KEY] || Object[KEY] - , exp = {}; - exp[KEY] = exec(fn); - $export($export.S + $export.F * fails(function(){ fn(1); }), 'Object', exp); -}; -},{"./$.core":56,"./$.export":62,"./$.fails":63}],87:[function(require,module,exports){ -module.exports = function(bitmap, value){ - return { - enumerable : !(bitmap & 1), - configurable: !(bitmap & 2), - writable : !(bitmap & 4), - value : value - }; -}; -},{}],88:[function(require,module,exports){ -var redefine = require('./$.redefine'); -module.exports = function(target, src){ - for(var key in src)redefine(target, key, src[key]); - return target; -}; -},{"./$.redefine":89}],89:[function(require,module,exports){ -module.exports = require('./$.hide'); -},{"./$.hide":68}],90:[function(require,module,exports){ -// 7.2.9 SameValue(x, y) -module.exports = Object.is || function is(x, y){ - return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y; -}; -},{}],91:[function(require,module,exports){ -// Works with __proto__ only. Old v8 can't work with null proto objects. -/* eslint-disable no-proto */ -var getDesc = require('./$').getDesc - , isObject = require('./$.is-object') - , anObject = require('./$.an-object'); -var check = function(O, proto){ - anObject(O); - if(!isObject(proto) && proto !== null)throw TypeError(proto + ": can't set as prototype!"); -}; -module.exports = { - set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line - function(test, buggy, set){ - try { - set = require('./$.ctx')(Function.call, getDesc(Object.prototype, '__proto__').set, 2); - set(test, []); - buggy = !(test instanceof Array); - } catch(e){ buggy = true; } - return function setPrototypeOf(O, proto){ - check(O, proto); - if(buggy)O.__proto__ = proto; - else set(O, proto); - return O; - }; - }({}, false) : undefined), - check: check -}; -},{"./$":81,"./$.an-object":50,"./$.ctx":57,"./$.is-object":74}],92:[function(require,module,exports){ -'use strict'; -var core = require('./$.core') - , $ = require('./$') - , DESCRIPTORS = require('./$.descriptors') - , SPECIES = require('./$.wks')('species'); - -module.exports = function(KEY){ - var C = core[KEY]; - if(DESCRIPTORS && C && !C[SPECIES])$.setDesc(C, SPECIES, { - configurable: true, - get: function(){ return this; } - }); -}; -},{"./$":81,"./$.core":56,"./$.descriptors":59,"./$.wks":104}],93:[function(require,module,exports){ -var def = require('./$').setDesc - , has = require('./$.has') - , TAG = require('./$.wks')('toStringTag'); - -module.exports = function(it, tag, stat){ - if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag}); -}; -},{"./$":81,"./$.has":67,"./$.wks":104}],94:[function(require,module,exports){ -var global = require('./$.global') - , SHARED = '__core-js_shared__' - , store = global[SHARED] || (global[SHARED] = {}); -module.exports = function(key){ - return store[key] || (store[key] = {}); -}; -},{"./$.global":66}],95:[function(require,module,exports){ -// 7.3.20 SpeciesConstructor(O, defaultConstructor) -var anObject = require('./$.an-object') - , aFunction = require('./$.a-function') - , SPECIES = require('./$.wks')('species'); -module.exports = function(O, D){ - var C = anObject(O).constructor, S; - return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S); -}; -},{"./$.a-function":48,"./$.an-object":50,"./$.wks":104}],96:[function(require,module,exports){ -module.exports = function(it, Constructor, name){ - if(!(it instanceof Constructor))throw TypeError(name + ": use the 'new' operator!"); - return it; -}; -},{}],97:[function(require,module,exports){ -var toInteger = require('./$.to-integer') - , defined = require('./$.defined'); -// true -> String#at -// false -> String#codePointAt -module.exports = function(TO_STRING){ - return function(that, pos){ - var s = String(defined(that)) - , i = toInteger(pos) - , l = s.length - , a, b; - if(i < 0 || i >= l)return TO_STRING ? '' : undefined; - a = s.charCodeAt(i); - return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff - ? TO_STRING ? s.charAt(i) : a - : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; - }; -}; -},{"./$.defined":58,"./$.to-integer":99}],98:[function(require,module,exports){ -var ctx = require('./$.ctx') - , invoke = require('./$.invoke') - , html = require('./$.html') - , cel = require('./$.dom-create') - , global = require('./$.global') - , process = global.process - , setTask = global.setImmediate - , clearTask = global.clearImmediate - , MessageChannel = global.MessageChannel - , counter = 0 - , queue = {} - , ONREADYSTATECHANGE = 'onreadystatechange' - , defer, channel, port; -var run = function(){ - var id = +this; - if(queue.hasOwnProperty(id)){ - var fn = queue[id]; - delete queue[id]; - fn(); - } -}; -var listner = function(event){ - run.call(event.data); -}; -// Node.js 0.9+ & IE10+ has setImmediate, otherwise: -if(!setTask || !clearTask){ - setTask = function setImmediate(fn){ - var args = [], i = 1; - while(arguments.length > i)args.push(arguments[i++]); - queue[++counter] = function(){ - invoke(typeof fn == 'function' ? fn : Function(fn), args); - }; - defer(counter); - return counter; - }; - clearTask = function clearImmediate(id){ - delete queue[id]; - }; - // Node.js 0.8- - if(require('./$.cof')(process) == 'process'){ - defer = function(id){ - process.nextTick(ctx(run, id, 1)); - }; - // Browsers with MessageChannel, includes WebWorkers - } else if(MessageChannel){ - channel = new MessageChannel; - port = channel.port2; - channel.port1.onmessage = listner; - defer = ctx(port.postMessage, port, 1); - // Browsers with postMessage, skip WebWorkers - // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' - } else if(global.addEventListener && typeof postMessage == 'function' && !global.importScripts){ - defer = function(id){ - global.postMessage(id + '', '*'); - }; - global.addEventListener('message', listner, false); - // IE8- - } else if(ONREADYSTATECHANGE in cel('script')){ - defer = function(id){ - html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function(){ - html.removeChild(this); - run.call(id); - }; - }; - // Rest old browsers - } else { - defer = function(id){ - setTimeout(ctx(run, id, 1), 0); - }; - } -} -module.exports = { - set: setTask, - clear: clearTask -}; -},{"./$.cof":52,"./$.ctx":57,"./$.dom-create":60,"./$.global":66,"./$.html":69,"./$.invoke":70}],99:[function(require,module,exports){ -// 7.1.4 ToInteger -var ceil = Math.ceil - , floor = Math.floor; -module.exports = function(it){ - return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); -}; -},{}],100:[function(require,module,exports){ -// to indexed object, toObject with fallback for non-array-like ES3 strings -var IObject = require('./$.iobject') - , defined = require('./$.defined'); -module.exports = function(it){ - return IObject(defined(it)); -}; -},{"./$.defined":58,"./$.iobject":71}],101:[function(require,module,exports){ -// 7.1.15 ToLength -var toInteger = require('./$.to-integer') - , min = Math.min; -module.exports = function(it){ - return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 -}; -},{"./$.to-integer":99}],102:[function(require,module,exports){ -// 7.1.13 ToObject(argument) -var defined = require('./$.defined'); -module.exports = function(it){ - return Object(defined(it)); -}; -},{"./$.defined":58}],103:[function(require,module,exports){ -var id = 0 - , px = Math.random(); -module.exports = function(key){ - return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); -}; -},{}],104:[function(require,module,exports){ -var store = require('./$.shared')('wks') - , uid = require('./$.uid') - , Symbol = require('./$.global').Symbol; -module.exports = function(name){ - return store[name] || (store[name] = - Symbol && Symbol[name] || (Symbol || uid)('Symbol.' + name)); -}; -},{"./$.global":66,"./$.shared":94,"./$.uid":103}],105:[function(require,module,exports){ -var classof = require('./$.classof') - , ITERATOR = require('./$.wks')('iterator') - , Iterators = require('./$.iterators'); -module.exports = require('./$.core').getIteratorMethod = function(it){ - if(it != undefined)return it[ITERATOR] - || it['@@iterator'] - || Iterators[classof(it)]; -}; -},{"./$.classof":51,"./$.core":56,"./$.iterators":80,"./$.wks":104}],106:[function(require,module,exports){ -var anObject = require('./$.an-object') - , get = require('./core.get-iterator-method'); -module.exports = require('./$.core').getIterator = function(it){ - var iterFn = get(it); - if(typeof iterFn != 'function')throw TypeError(it + ' is not iterable!'); - return anObject(iterFn.call(it)); -}; -},{"./$.an-object":50,"./$.core":56,"./core.get-iterator-method":105}],107:[function(require,module,exports){ -var classof = require('./$.classof') - , ITERATOR = require('./$.wks')('iterator') - , Iterators = require('./$.iterators'); -module.exports = require('./$.core').isIterable = function(it){ - var O = Object(it); - return O[ITERATOR] !== undefined - || '@@iterator' in O - || Iterators.hasOwnProperty(classof(O)); -}; -},{"./$.classof":51,"./$.core":56,"./$.iterators":80,"./$.wks":104}],108:[function(require,module,exports){ -'use strict'; -var ctx = require('./$.ctx') - , $export = require('./$.export') - , toObject = require('./$.to-object') - , call = require('./$.iter-call') - , isArrayIter = require('./$.is-array-iter') - , toLength = require('./$.to-length') - , getIterFn = require('./core.get-iterator-method'); -$export($export.S + $export.F * !require('./$.iter-detect')(function(iter){ Array.from(iter); }), 'Array', { - // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) - from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){ - var O = toObject(arrayLike) - , C = typeof this == 'function' ? this : Array - , $$ = arguments - , $$len = $$.length - , mapfn = $$len > 1 ? $$[1] : undefined - , mapping = mapfn !== undefined - , index = 0 - , iterFn = getIterFn(O) - , length, result, step, iterator; - if(mapping)mapfn = ctx(mapfn, $$len > 2 ? $$[2] : undefined, 2); - // if object isn't iterable or it's array with default iterator - use simple case - if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){ - for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){ - result[index] = mapping ? call(iterator, mapfn, [step.value, index], true) : step.value; - } - } else { - length = toLength(O.length); - for(result = new C(length); length > index; index++){ - result[index] = mapping ? mapfn(O[index], index) : O[index]; - } - } - result.length = index; - return result; - } -}); - -},{"./$.ctx":57,"./$.export":62,"./$.is-array-iter":72,"./$.iter-call":75,"./$.iter-detect":78,"./$.to-length":101,"./$.to-object":102,"./core.get-iterator-method":105}],109:[function(require,module,exports){ -'use strict'; -var addToUnscopables = require('./$.add-to-unscopables') - , step = require('./$.iter-step') - , Iterators = require('./$.iterators') - , toIObject = require('./$.to-iobject'); - -// 22.1.3.4 Array.prototype.entries() -// 22.1.3.13 Array.prototype.keys() -// 22.1.3.29 Array.prototype.values() -// 22.1.3.30 Array.prototype[@@iterator]() -module.exports = require('./$.iter-define')(Array, 'Array', function(iterated, kind){ - this._t = toIObject(iterated); // target - this._i = 0; // next index - this._k = kind; // kind -// 22.1.5.2.1 %ArrayIteratorPrototype%.next() -}, function(){ - var O = this._t - , kind = this._k - , index = this._i++; - if(!O || index >= O.length){ - this._t = undefined; - return step(1); - } - if(kind == 'keys' )return step(0, index); - if(kind == 'values')return step(0, O[index]); - return step(0, [index, O[index]]); -}, 'values'); - -// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7) -Iterators.Arguments = Iterators.Array; - -addToUnscopables('keys'); -addToUnscopables('values'); -addToUnscopables('entries'); -},{"./$.add-to-unscopables":49,"./$.iter-define":77,"./$.iter-step":79,"./$.iterators":80,"./$.to-iobject":100}],110:[function(require,module,exports){ -'use strict'; -var strong = require('./$.collection-strong'); - -// 23.1 Map Objects -require('./$.collection')('Map', function(get){ - return function Map(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); }; -}, { - // 23.1.3.6 Map.prototype.get(key) - get: function get(key){ - var entry = strong.getEntry(this, key); - return entry && entry.v; - }, - // 23.1.3.9 Map.prototype.set(key, value) - set: function set(key, value){ - return strong.def(this, key === 0 ? 0 : key, value); - } -}, strong, true); -},{"./$.collection":55,"./$.collection-strong":53}],111:[function(require,module,exports){ -// 20.1.2.4 Number.isNaN(number) -var $export = require('./$.export'); - -$export($export.S, 'Number', { - isNaN: function isNaN(number){ - return number != number; - } -}); -},{"./$.export":62}],112:[function(require,module,exports){ -// 20.1.2.12 Number.parseFloat(string) -var $export = require('./$.export'); - -$export($export.S, 'Number', {parseFloat: parseFloat}); -},{"./$.export":62}],113:[function(require,module,exports){ -// 20.1.2.13 Number.parseInt(string, radix) -var $export = require('./$.export'); - -$export($export.S, 'Number', {parseInt: parseInt}); -},{"./$.export":62}],114:[function(require,module,exports){ -// 19.1.3.1 Object.assign(target, source) -var $export = require('./$.export'); - -$export($export.S + $export.F, 'Object', {assign: require('./$.object-assign')}); -},{"./$.export":62,"./$.object-assign":85}],115:[function(require,module,exports){ -// 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) -var toIObject = require('./$.to-iobject'); - -require('./$.object-sap')('getOwnPropertyDescriptor', function($getOwnPropertyDescriptor){ - return function getOwnPropertyDescriptor(it, key){ - return $getOwnPropertyDescriptor(toIObject(it), key); - }; -}); -},{"./$.object-sap":86,"./$.to-iobject":100}],116:[function(require,module,exports){ -// 19.1.2.14 Object.keys(O) -var toObject = require('./$.to-object'); - -require('./$.object-sap')('keys', function($keys){ - return function keys(it){ - return $keys(toObject(it)); - }; -}); -},{"./$.object-sap":86,"./$.to-object":102}],117:[function(require,module,exports){ -// 19.1.3.19 Object.setPrototypeOf(O, proto) -var $export = require('./$.export'); -$export($export.S, 'Object', {setPrototypeOf: require('./$.set-proto').set}); -},{"./$.export":62,"./$.set-proto":91}],118:[function(require,module,exports){ -arguments[4][29][0].apply(exports,arguments) -},{"dup":29}],119:[function(require,module,exports){ -'use strict'; -var $ = require('./$') - , LIBRARY = require('./$.library') - , global = require('./$.global') - , ctx = require('./$.ctx') - , classof = require('./$.classof') - , $export = require('./$.export') - , isObject = require('./$.is-object') - , anObject = require('./$.an-object') - , aFunction = require('./$.a-function') - , strictNew = require('./$.strict-new') - , forOf = require('./$.for-of') - , setProto = require('./$.set-proto').set - , same = require('./$.same-value') - , SPECIES = require('./$.wks')('species') - , speciesConstructor = require('./$.species-constructor') - , asap = require('./$.microtask') - , PROMISE = 'Promise' - , process = global.process - , isNode = classof(process) == 'process' - , P = global[PROMISE] - , empty = function(){ /* empty */ } - , Wrapper; - -var testResolve = function(sub){ - var test = new P(empty), promise; - if(sub)test.constructor = function(exec){ - exec(empty, empty); - }; - (promise = P.resolve(test))['catch'](empty); - return promise === test; -}; - -var USE_NATIVE = function(){ - var works = false; - function P2(x){ - var self = new P(x); - setProto(self, P2.prototype); - return self; - } - try { - works = P && P.resolve && testResolve(); - setProto(P2, P); - P2.prototype = $.create(P.prototype, {constructor: {value: P2}}); - // actual Firefox has broken subclass support, test that - if(!(P2.resolve(5).then(function(){}) instanceof P2)){ - works = false; - } - // actual V8 bug, https://code.google.com/p/v8/issues/detail?id=4162 - if(works && require('./$.descriptors')){ - var thenableThenGotten = false; - P.resolve($.setDesc({}, 'then', { - get: function(){ thenableThenGotten = true; } - })); - works = thenableThenGotten; - } - } catch(e){ works = false; } - return works; -}(); - -// helpers -var sameConstructor = function(a, b){ - // library wrapper special case - if(LIBRARY && a === P && b === Wrapper)return true; - return same(a, b); -}; -var getConstructor = function(C){ - var S = anObject(C)[SPECIES]; - return S != undefined ? S : C; -}; -var isThenable = function(it){ - var then; - return isObject(it) && typeof (then = it.then) == 'function' ? then : false; -}; -var PromiseCapability = function(C){ - var resolve, reject; - this.promise = new C(function($$resolve, $$reject){ - if(resolve !== undefined || reject !== undefined)throw TypeError('Bad Promise constructor'); - resolve = $$resolve; - reject = $$reject; - }); - this.resolve = aFunction(resolve), - this.reject = aFunction(reject) -}; -var perform = function(exec){ - try { - exec(); - } catch(e){ - return {error: e}; - } -}; -var notify = function(record, isReject){ - if(record.n)return; - record.n = true; - var chain = record.c; - asap(function(){ - var value = record.v - , ok = record.s == 1 - , i = 0; - var run = function(reaction){ - var handler = ok ? reaction.ok : reaction.fail - , resolve = reaction.resolve - , reject = reaction.reject - , result, then; - try { - if(handler){ - if(!ok)record.h = true; - result = handler === true ? value : handler(value); - if(result === reaction.promise){ - reject(TypeError('Promise-chain cycle')); - } else if(then = isThenable(result)){ - then.call(result, resolve, reject); - } else resolve(result); - } else reject(value); - } catch(e){ - reject(e); - } - }; - while(chain.length > i)run(chain[i++]); // variable length - can't use forEach - chain.length = 0; - record.n = false; - if(isReject)setTimeout(function(){ - var promise = record.p - , handler, console; - if(isUnhandled(promise)){ - if(isNode){ - process.emit('unhandledRejection', value, promise); - } else if(handler = global.onunhandledrejection){ - handler({promise: promise, reason: value}); - } else if((console = global.console) && console.error){ - console.error('Unhandled promise rejection', value); - } - } record.a = undefined; - }, 1); - }); -}; -var isUnhandled = function(promise){ - var record = promise._d - , chain = record.a || record.c - , i = 0 - , reaction; - if(record.h)return false; - while(chain.length > i){ - reaction = chain[i++]; - if(reaction.fail || !isUnhandled(reaction.promise))return false; - } return true; -}; -var $reject = function(value){ - var record = this; - if(record.d)return; - record.d = true; - record = record.r || record; // unwrap - record.v = value; - record.s = 2; - record.a = record.c.slice(); - notify(record, true); -}; -var $resolve = function(value){ - var record = this - , then; - if(record.d)return; - record.d = true; - record = record.r || record; // unwrap - try { - if(record.p === value)throw TypeError("Promise can't be resolved itself"); - if(then = isThenable(value)){ - asap(function(){ - var wrapper = {r: record, d: false}; // wrap - try { - then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1)); - } catch(e){ - $reject.call(wrapper, e); - } - }); - } else { - record.v = value; - record.s = 1; - notify(record, false); - } - } catch(e){ - $reject.call({r: record, d: false}, e); // wrap - } -}; - -// constructor polyfill -if(!USE_NATIVE){ - // 25.4.3.1 Promise(executor) - P = function Promise(executor){ - aFunction(executor); - var record = this._d = { - p: strictNew(this, P, PROMISE), // <- promise - c: [], // <- awaiting reactions - a: undefined, // <- checked in isUnhandled reactions - s: 0, // <- state - d: false, // <- done - v: undefined, // <- value - h: false, // <- handled rejection - n: false // <- notify - }; - try { - executor(ctx($resolve, record, 1), ctx($reject, record, 1)); - } catch(err){ - $reject.call(record, err); - } - }; - require('./$.redefine-all')(P.prototype, { - // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected) - then: function then(onFulfilled, onRejected){ - var reaction = new PromiseCapability(speciesConstructor(this, P)) - , promise = reaction.promise - , record = this._d; - reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true; - reaction.fail = typeof onRejected == 'function' && onRejected; - record.c.push(reaction); - if(record.a)record.a.push(reaction); - if(record.s)notify(record, false); - return promise; - }, - // 25.4.5.1 Promise.prototype.catch(onRejected) - 'catch': function(onRejected){ - return this.then(undefined, onRejected); - } - }); -} - -$export($export.G + $export.W + $export.F * !USE_NATIVE, {Promise: P}); -require('./$.set-to-string-tag')(P, PROMISE); -require('./$.set-species')(PROMISE); -Wrapper = require('./$.core')[PROMISE]; - -// statics -$export($export.S + $export.F * !USE_NATIVE, PROMISE, { - // 25.4.4.5 Promise.reject(r) - reject: function reject(r){ - var capability = new PromiseCapability(this) - , $$reject = capability.reject; - $$reject(r); - return capability.promise; - } -}); -$export($export.S + $export.F * (!USE_NATIVE || testResolve(true)), PROMISE, { - // 25.4.4.6 Promise.resolve(x) - resolve: function resolve(x){ - // instanceof instead of internal slot check because we should fix it without replacement native Promise core - if(x instanceof P && sameConstructor(x.constructor, this))return x; - var capability = new PromiseCapability(this) - , $$resolve = capability.resolve; - $$resolve(x); - return capability.promise; - } -}); -$export($export.S + $export.F * !(USE_NATIVE && require('./$.iter-detect')(function(iter){ - P.all(iter)['catch'](function(){}); -})), PROMISE, { - // 25.4.4.1 Promise.all(iterable) - all: function all(iterable){ - var C = getConstructor(this) - , capability = new PromiseCapability(C) - , resolve = capability.resolve - , reject = capability.reject - , values = []; - var abrupt = perform(function(){ - forOf(iterable, false, values.push, values); - var remaining = values.length - , results = Array(remaining); - if(remaining)$.each.call(values, function(promise, index){ - var alreadyCalled = false; - C.resolve(promise).then(function(value){ - if(alreadyCalled)return; - alreadyCalled = true; - results[index] = value; - --remaining || resolve(results); - }, reject); - }); - else resolve(results); - }); - if(abrupt)reject(abrupt.error); - return capability.promise; - }, - // 25.4.4.4 Promise.race(iterable) - race: function race(iterable){ - var C = getConstructor(this) - , capability = new PromiseCapability(C) - , reject = capability.reject; - var abrupt = perform(function(){ - forOf(iterable, false, function(promise){ - C.resolve(promise).then(capability.resolve, reject); - }); - }); - if(abrupt)reject(abrupt.error); - return capability.promise; - } -}); -},{"./$":81,"./$.a-function":48,"./$.an-object":50,"./$.classof":51,"./$.core":56,"./$.ctx":57,"./$.descriptors":59,"./$.export":62,"./$.for-of":64,"./$.global":66,"./$.is-object":74,"./$.iter-detect":78,"./$.library":83,"./$.microtask":84,"./$.redefine-all":88,"./$.same-value":90,"./$.set-proto":91,"./$.set-species":92,"./$.set-to-string-tag":93,"./$.species-constructor":95,"./$.strict-new":96,"./$.wks":104}],120:[function(require,module,exports){ -'use strict'; -var $at = require('./$.string-at')(true); - -// 21.1.3.27 String.prototype[@@iterator]() -require('./$.iter-define')(String, 'String', function(iterated){ - this._t = String(iterated); // target - this._i = 0; // next index -// 21.1.5.2.1 %StringIteratorPrototype%.next() -}, function(){ - var O = this._t - , index = this._i - , point; - if(index >= O.length)return {value: undefined, done: true}; - point = $at(O, index); - this._i += point.length; - return {value: point, done: false}; -}); -},{"./$.iter-define":77,"./$.string-at":97}],121:[function(require,module,exports){ -'use strict'; -// ECMAScript 6 symbols shim -var $ = require('./$') - , global = require('./$.global') - , has = require('./$.has') - , DESCRIPTORS = require('./$.descriptors') - , $export = require('./$.export') - , redefine = require('./$.redefine') - , $fails = require('./$.fails') - , shared = require('./$.shared') - , setToStringTag = require('./$.set-to-string-tag') - , uid = require('./$.uid') - , wks = require('./$.wks') - , keyOf = require('./$.keyof') - , $names = require('./$.get-names') - , enumKeys = require('./$.enum-keys') - , isArray = require('./$.is-array') - , anObject = require('./$.an-object') - , toIObject = require('./$.to-iobject') - , createDesc = require('./$.property-desc') - , getDesc = $.getDesc - , setDesc = $.setDesc - , _create = $.create - , getNames = $names.get - , $Symbol = global.Symbol - , $JSON = global.JSON - , _stringify = $JSON && $JSON.stringify - , setter = false - , HIDDEN = wks('_hidden') - , isEnum = $.isEnum - , SymbolRegistry = shared('symbol-registry') - , AllSymbols = shared('symbols') - , useNative = typeof $Symbol == 'function' - , ObjectProto = Object.prototype; - -// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 -var setSymbolDesc = DESCRIPTORS && $fails(function(){ - return _create(setDesc({}, 'a', { - get: function(){ return setDesc(this, 'a', {value: 7}).a; } - })).a != 7; -}) ? function(it, key, D){ - var protoDesc = getDesc(ObjectProto, key); - if(protoDesc)delete ObjectProto[key]; - setDesc(it, key, D); - if(protoDesc && it !== ObjectProto)setDesc(ObjectProto, key, protoDesc); -} : setDesc; - -var wrap = function(tag){ - var sym = AllSymbols[tag] = _create($Symbol.prototype); - sym._k = tag; - DESCRIPTORS && setter && setSymbolDesc(ObjectProto, tag, { - configurable: true, - set: function(value){ - if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false; - setSymbolDesc(this, tag, createDesc(1, value)); - } - }); - return sym; -}; - -var isSymbol = function(it){ - return typeof it == 'symbol'; -}; - -var $defineProperty = function defineProperty(it, key, D){ - if(D && has(AllSymbols, key)){ - if(!D.enumerable){ - if(!has(it, HIDDEN))setDesc(it, HIDDEN, createDesc(1, {})); - it[HIDDEN][key] = true; - } else { - if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false; - D = _create(D, {enumerable: createDesc(0, false)}); - } return setSymbolDesc(it, key, D); - } return setDesc(it, key, D); -}; -var $defineProperties = function defineProperties(it, P){ - anObject(it); - var keys = enumKeys(P = toIObject(P)) - , i = 0 - , l = keys.length - , key; - while(l > i)$defineProperty(it, key = keys[i++], P[key]); - return it; -}; -var $create = function create(it, P){ - return P === undefined ? _create(it) : $defineProperties(_create(it), P); -}; -var $propertyIsEnumerable = function propertyIsEnumerable(key){ - var E = isEnum.call(this, key); - return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] - ? E : true; -}; -var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key){ - var D = getDesc(it = toIObject(it), key); - if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true; - return D; -}; -var $getOwnPropertyNames = function getOwnPropertyNames(it){ - var names = getNames(toIObject(it)) - , result = [] - , i = 0 - , key; - while(names.length > i)if(!has(AllSymbols, key = names[i++]) && key != HIDDEN)result.push(key); - return result; -}; -var $getOwnPropertySymbols = function getOwnPropertySymbols(it){ - var names = getNames(toIObject(it)) - , result = [] - , i = 0 - , key; - while(names.length > i)if(has(AllSymbols, key = names[i++]))result.push(AllSymbols[key]); - return result; -}; -var $stringify = function stringify(it){ - if(it === undefined || isSymbol(it))return; // IE8 returns string on undefined - var args = [it] - , i = 1 - , $$ = arguments - , replacer, $replacer; - while($$.length > i)args.push($$[i++]); - replacer = args[1]; - if(typeof replacer == 'function')$replacer = replacer; - if($replacer || !isArray(replacer))replacer = function(key, value){ - if($replacer)value = $replacer.call(this, key, value); - if(!isSymbol(value))return value; - }; - args[1] = replacer; - return _stringify.apply($JSON, args); -}; -var buggyJSON = $fails(function(){ - var S = $Symbol(); - // MS Edge converts symbol values to JSON as {} - // WebKit converts symbol values to JSON as null - // V8 throws on boxed symbols - return _stringify([S]) != '[null]' || _stringify({a: S}) != '{}' || _stringify(Object(S)) != '{}'; -}); - -// 19.4.1.1 Symbol([description]) -if(!useNative){ - $Symbol = function Symbol(){ - if(isSymbol(this))throw TypeError('Symbol is not a constructor'); - return wrap(uid(arguments.length > 0 ? arguments[0] : undefined)); - }; - redefine($Symbol.prototype, 'toString', function toString(){ - return this._k; - }); - - isSymbol = function(it){ - return it instanceof $Symbol; - }; - - $.create = $create; - $.isEnum = $propertyIsEnumerable; - $.getDesc = $getOwnPropertyDescriptor; - $.setDesc = $defineProperty; - $.setDescs = $defineProperties; - $.getNames = $names.get = $getOwnPropertyNames; - $.getSymbols = $getOwnPropertySymbols; - - if(DESCRIPTORS && !require('./$.library')){ - redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true); - } -} - -var symbolStatics = { - // 19.4.2.1 Symbol.for(key) - 'for': function(key){ - return has(SymbolRegistry, key += '') - ? SymbolRegistry[key] - : SymbolRegistry[key] = $Symbol(key); - }, - // 19.4.2.5 Symbol.keyFor(sym) - keyFor: function keyFor(key){ - return keyOf(SymbolRegistry, key); - }, - useSetter: function(){ setter = true; }, - useSimple: function(){ setter = false; } -}; -// 19.4.2.2 Symbol.hasInstance -// 19.4.2.3 Symbol.isConcatSpreadable -// 19.4.2.4 Symbol.iterator -// 19.4.2.6 Symbol.match -// 19.4.2.8 Symbol.replace -// 19.4.2.9 Symbol.search -// 19.4.2.10 Symbol.species -// 19.4.2.11 Symbol.split -// 19.4.2.12 Symbol.toPrimitive -// 19.4.2.13 Symbol.toStringTag -// 19.4.2.14 Symbol.unscopables -$.each.call(( - 'hasInstance,isConcatSpreadable,iterator,match,replace,search,' + - 'species,split,toPrimitive,toStringTag,unscopables' -).split(','), function(it){ - var sym = wks(it); - symbolStatics[it] = useNative ? sym : wrap(sym); -}); - -setter = true; - -$export($export.G + $export.W, {Symbol: $Symbol}); - -$export($export.S, 'Symbol', symbolStatics); - -$export($export.S + $export.F * !useNative, 'Object', { - // 19.1.2.2 Object.create(O [, Properties]) - create: $create, - // 19.1.2.4 Object.defineProperty(O, P, Attributes) - defineProperty: $defineProperty, - // 19.1.2.3 Object.defineProperties(O, Properties) - defineProperties: $defineProperties, - // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) - getOwnPropertyDescriptor: $getOwnPropertyDescriptor, - // 19.1.2.7 Object.getOwnPropertyNames(O) - getOwnPropertyNames: $getOwnPropertyNames, - // 19.1.2.8 Object.getOwnPropertySymbols(O) - getOwnPropertySymbols: $getOwnPropertySymbols -}); - -// 24.3.2 JSON.stringify(value [, replacer [, space]]) -$JSON && $export($export.S + $export.F * (!useNative || buggyJSON), 'JSON', {stringify: $stringify}); - -// 19.4.3.5 Symbol.prototype[@@toStringTag] -setToStringTag($Symbol, 'Symbol'); -// 20.2.1.9 Math[@@toStringTag] -setToStringTag(Math, 'Math', true); -// 24.3.3 JSON[@@toStringTag] -setToStringTag(global.JSON, 'JSON', true); -},{"./$":81,"./$.an-object":50,"./$.descriptors":59,"./$.enum-keys":61,"./$.export":62,"./$.fails":63,"./$.get-names":65,"./$.global":66,"./$.has":67,"./$.is-array":73,"./$.keyof":82,"./$.library":83,"./$.property-desc":87,"./$.redefine":89,"./$.set-to-string-tag":93,"./$.shared":94,"./$.to-iobject":100,"./$.uid":103,"./$.wks":104}],122:[function(require,module,exports){ -// https://github.com/DavidBruant/Map-Set.prototype.toJSON -var $export = require('./$.export'); - -$export($export.P, 'Map', {toJSON: require('./$.collection-to-json')('Map')}); -},{"./$.collection-to-json":54,"./$.export":62}],123:[function(require,module,exports){ -require('./es6.array.iterator'); -var Iterators = require('./$.iterators'); -Iterators.NodeList = Iterators.HTMLCollection = Iterators.Array; -},{"./$.iterators":80,"./es6.array.iterator":109}],124:[function(require,module,exports){ +},{}],122:[function(require,module,exports){ !function() { var d3 = { - version: "3.5.16" + version: "3.5.17" }; var d3_arraySlice = [].slice, d3_array = function(list) { return d3_arraySlice.call(list); @@ -5926,7 +11717,7 @@ Iterators.NodeList = Iterators.HTMLCollection = Iterators.Array; λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point; } } - return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1; + return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < -ε) ^ winding & 1; } function d3_geo_clipCircle(radius) { var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); @@ -11953,635 +17744,410 @@ Iterators.NodeList = Iterators.HTMLCollection = Iterators.Array; }); if (typeof define === "function" && define.amd) this.d3 = d3, define(d3); else if (typeof module === "object" && module.exports) module.exports = d3; else this.d3 = d3; }(); -},{}],125:[function(require,module,exports){ -(function (process){ -/** - * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); - -/** - * Colors. - */ - -exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' -]; - -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - -function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window && typeof window.process !== 'undefined' && window.process.type === 'renderer') { - return true; - } - - // is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document && 'WebkitAppearance' in document.documentElement.style) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window && window.console && (console.firebug || (console.exception && console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || - // double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); -} - -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - -exports.formatters.j = function(v) { - try { - return JSON.stringify(v); - } catch (err) { - return '[UnexpectedJSONParseError]: ' + err.message; - } -}; - - -/** - * Colorize log arguments if enabled. - * - * @api public - */ - -function formatArgs(args) { - var useColors = this.useColors; - - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); - - if (!useColors) return; - - var c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit') - - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - - args.splice(lastC, 0, c); -} - -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ - -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - try { - return exports.storage.debug; - } catch(e) {} - - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (typeof process !== 'undefined' && 'env' in process) { - return process.env.DEBUG; - } -} - -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ - -exports.enable(load()); - -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ - -function localstorage() { - try { - return window.localStorage; - } catch (e) {} -} - -}).call(this,require('_process')) - -},{"./debug":126,"_process":295}],126:[function(require,module,exports){ - -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; -exports.coerce = coerce; -exports.disable = disable; -exports.enable = enable; -exports.enabled = enabled; -exports.humanize = require('ms'); - -/** - * The currently active debug mode names, and names to skip. - */ - -exports.names = []; -exports.skips = []; - -/** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - -exports.formatters = {}; - -/** - * Previous log timestamp. - */ - -var prevTime; - -/** - * Select a color. - * @param {String} namespace - * @return {Number} - * @api private - */ - -function selectColor(namespace) { - var hash = 0, i; - - for (i in namespace) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } - - return exports.colors[Math.abs(hash) % exports.colors.length]; -} - -/** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - -function createDebug(namespace) { - - function debug() { - // disabled? - if (!debug.enabled) return; - - var self = debug; - - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; - - // turn the `arguments` into a proper Array - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } - - args[0] = exports.coerce(args[0]); - - if ('string' !== typeof args[0]) { - // anything else let's inspect with %O - args.unshift('%O'); - } - - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); - - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); - - // apply env-specific formatting (colors, etc.) - exports.formatArgs.call(self, args); - - var logFn = debug.log || exports.log || console.log.bind(console); - logFn.apply(self, args); - } - - debug.namespace = namespace; - debug.enabled = exports.enabled(namespace); - debug.useColors = exports.useColors(); - debug.color = selectColor(namespace); - - // env-specific initialization logic for debug instances - if ('function' === typeof exports.init) { - exports.init(debug); - } - - return debug; -} - -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - -function enable(namespaces) { - exports.save(namespaces); - - exports.names = []; - exports.skips = []; - - var split = (namespaces || '').split(/[\s,]+/); - var len = split.length; - - for (var i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } -} - -/** - * Disable debug output. - * - * @api public - */ - -function disable() { - exports.enable(''); -} - -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - -function enabled(name) { - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } - } - return false; -} - -/** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} - -},{"ms":280}],127:[function(require,module,exports){ +},{}],123:[function(require,module,exports){ 'use strict'; -var babelHelpers = require('./util/babelHelpers.js'); - -exports.__esModule = true; - -/** - * document.activeElement - */ -exports['default'] = activeElement; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = activeElement; var _ownerDocument = require('./ownerDocument'); -var _ownerDocument2 = babelHelpers.interopRequireDefault(_ownerDocument); +var _ownerDocument2 = _interopRequireDefault(_ownerDocument); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function activeElement() { - var doc = arguments[0] === undefined ? document : arguments[0]; + var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (0, _ownerDocument2.default)(); try { return doc.activeElement; - } catch (e) {} + } catch (e) {/* ie throws if no active element */} } - module.exports = exports['default']; -},{"./ownerDocument":136,"./util/babelHelpers.js":149}],128:[function(require,module,exports){ -'use strict'; -var hasClass = require('./hasClass'); - -module.exports = function addClass(element, className) { - if (element.classList) element.classList.add(className);else if (!hasClass(element)) element.className = element.className + ' ' + className; -}; -},{"./hasClass":129}],129:[function(require,module,exports){ -'use strict'; -module.exports = function hasClass(element, className) { - if (element.classList) return !!className && element.classList.contains(className);else return (' ' + element.className + ' ').indexOf(' ' + className + ' ') !== -1; -}; -},{}],130:[function(require,module,exports){ +},{"./ownerDocument":133}],124:[function(require,module,exports){ 'use strict'; -module.exports = { - addClass: require('./addClass'), - removeClass: require('./removeClass'), - hasClass: require('./hasClass') -}; -},{"./addClass":128,"./hasClass":129,"./removeClass":131}],131:[function(require,module,exports){ +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = addClass; + +var _hasClass = require('./hasClass'); + +var _hasClass2 = _interopRequireDefault(_hasClass); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function addClass(element, className) { + if (element.classList) element.classList.add(className);else if (!(0, _hasClass2.default)(element)) element.className = element.className + ' ' + className; +} +module.exports = exports['default']; +},{"./hasClass":125}],125:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = hasClass; +function hasClass(element, className) { + if (element.classList) return !!className && element.classList.contains(className);else return (" " + element.className + " ").indexOf(" " + className + " ") !== -1; +} +module.exports = exports["default"]; +},{}],126:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.hasClass = exports.removeClass = exports.addClass = undefined; + +var _addClass = require('./addClass'); + +var _addClass2 = _interopRequireDefault(_addClass); + +var _removeClass = require('./removeClass'); + +var _removeClass2 = _interopRequireDefault(_removeClass); + +var _hasClass = require('./hasClass'); + +var _hasClass2 = _interopRequireDefault(_hasClass); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.addClass = _addClass2.default; +exports.removeClass = _removeClass2.default; +exports.hasClass = _hasClass2.default; +exports.default = { addClass: _addClass2.default, removeClass: _removeClass2.default, hasClass: _hasClass2.default }; +},{"./addClass":124,"./hasClass":125,"./removeClass":127}],127:[function(require,module,exports){ 'use strict'; module.exports = function removeClass(element, className) { if (element.classList) element.classList.remove(className);else element.className = element.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)', 'g'), '$1').replace(/\s+/g, ' ').replace(/^\s*|\s*$/g, ''); }; -},{}],132:[function(require,module,exports){ +},{}],128:[function(require,module,exports){ 'use strict'; -var contains = require('../query/contains'), - qsa = require('../query/querySelectorAll'); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = filterEvents; -module.exports = function (selector, handler) { - return function (e) { +var _contains = require('../query/contains'); + +var _contains2 = _interopRequireDefault(_contains); + +var _querySelectorAll = require('../query/querySelectorAll'); + +var _querySelectorAll2 = _interopRequireDefault(_querySelectorAll); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function filterEvents(selector, handler) { + return function filterHandler(e) { var top = e.currentTarget, target = e.target, - matches = qsa(top, selector); + matches = (0, _querySelectorAll2.default)(top, selector); if (matches.some(function (match) { - return contains(match, target); + return (0, _contains2.default)(match, target); })) handler.call(this, e); }; -}; -},{"../query/contains":137,"../query/querySelectorAll":142}],133:[function(require,module,exports){ +} +module.exports = exports['default']; +},{"../query/contains":134,"../query/querySelectorAll":139}],129:[function(require,module,exports){ 'use strict'; -var on = require('./on'), - off = require('./off'), - filter = require('./filter'); -module.exports = { on: on, off: off, filter: filter }; -},{"./filter":132,"./off":134,"./on":135}],134:[function(require,module,exports){ +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.listen = exports.filter = exports.off = exports.on = undefined; + +var _on = require('./on'); + +var _on2 = _interopRequireDefault(_on); + +var _off = require('./off'); + +var _off2 = _interopRequireDefault(_off); + +var _filter = require('./filter'); + +var _filter2 = _interopRequireDefault(_filter); + +var _listen = require('./listen'); + +var _listen2 = _interopRequireDefault(_listen); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.on = _on2.default; +exports.off = _off2.default; +exports.filter = _filter2.default; +exports.listen = _listen2.default; +exports.default = { on: _on2.default, off: _off2.default, filter: _filter2.default, listen: _listen2.default }; +},{"./filter":128,"./listen":130,"./off":131,"./on":132}],130:[function(require,module,exports){ 'use strict'; -var canUseDOM = require('../util/inDOM'); + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _inDOM = require('../util/inDOM'); + +var _inDOM2 = _interopRequireDefault(_inDOM); + +var _on = require('./on'); + +var _on2 = _interopRequireDefault(_on); + +var _off = require('./off'); + +var _off2 = _interopRequireDefault(_off); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var listen = function listen() {}; + +if (_inDOM2.default) { + listen = function listen(node, eventName, handler, capture) { + (0, _on2.default)(node, eventName, handler, capture); + return function () { + (0, _off2.default)(node, eventName, handler, capture); + }; + }; +} + +exports.default = listen; +module.exports = exports['default']; +},{"../util/inDOM":151,"./off":131,"./on":132}],131:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _inDOM = require('../util/inDOM'); + +var _inDOM2 = _interopRequireDefault(_inDOM); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + var off = function off() {}; - -if (canUseDOM) { - - off = (function () { - +if (_inDOM2.default) { + off = function () { if (document.addEventListener) return function (node, eventName, handler, capture) { return node.removeEventListener(eventName, handler, capture || false); };else if (document.attachEvent) return function (node, eventName, handler) { return node.detachEvent('on' + eventName, handler); }; - })(); + }(); } -module.exports = off; -},{"../util/inDOM":154}],135:[function(require,module,exports){ +exports.default = off; +module.exports = exports['default']; +},{"../util/inDOM":151}],132:[function(require,module,exports){ 'use strict'; -var canUseDOM = require('../util/inDOM'); -var on = function on() {}; -if (canUseDOM) { - on = (function () { +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _inDOM = require('../util/inDOM'); + +var _inDOM2 = _interopRequireDefault(_inDOM); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var on = function on() {}; +if (_inDOM2.default) { + on = function () { if (document.addEventListener) return function (node, eventName, handler, capture) { return node.addEventListener(eventName, handler, capture || false); };else if (document.attachEvent) return function (node, eventName, handler) { - return node.attachEvent('on' + eventName, handler); + return node.attachEvent('on' + eventName, function (e) { + e = e || window.event; + e.target = e.target || e.srcElement; + e.currentTarget = node; + handler.call(node, e); + }); }; - })(); + }(); } -module.exports = on; -},{"../util/inDOM":154}],136:[function(require,module,exports){ +exports.default = on; +module.exports = exports['default']; +},{"../util/inDOM":151}],133:[function(require,module,exports){ "use strict"; -exports.__esModule = true; -exports["default"] = ownerDocument; - +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = ownerDocument; function ownerDocument(node) { return node && node.ownerDocument || document; } - module.exports = exports["default"]; -},{}],137:[function(require,module,exports){ -'use strict'; -var canUseDOM = require('../util/inDOM'); - -var contains = (function () { - var root = canUseDOM && document.documentElement; - - return root && root.contains ? function (context, node) { - return context.contains(node); - } : root && root.compareDocumentPosition ? function (context, node) { - return context === node || !!(context.compareDocumentPosition(node) & 16); - } : function (context, node) { - if (node) do { - if (node === context) return true; - } while (node = node.parentNode); - - return false; - }; -})(); - -module.exports = contains; -},{"../util/inDOM":154}],138:[function(require,module,exports){ +},{}],134:[function(require,module,exports){ 'use strict'; -module.exports = function getWindow(node) { +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _inDOM = require('../util/inDOM'); + +var _inDOM2 = _interopRequireDefault(_inDOM); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function () { + // HTML DOM and SVG DOM may have different support levels, + // so we need to check on context instead of a document root element. + return _inDOM2.default ? function (context, node) { + if (context.contains) { + return context.contains(node); + } else if (context.compareDocumentPosition) { + return context === node || !!(context.compareDocumentPosition(node) & 16); + } else { + return fallback(context, node); + } + } : fallback; +}(); + +function fallback(context, node) { + if (node) do { + if (node === context) return true; + } while (node = node.parentNode); + + return false; +} +module.exports = exports['default']; +},{"../util/inDOM":151}],135:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = getWindow; +function getWindow(node) { return node === node.window ? node : node.nodeType === 9 ? node.defaultView || node.parentWindow : false; -}; -},{}],139:[function(require,module,exports){ +} +module.exports = exports["default"]; +},{}],136:[function(require,module,exports){ 'use strict'; -var contains = require('./contains'), - getWindow = require('./isWindow'), - ownerDocument = require('../ownerDocument'); -module.exports = function offset(node) { - var doc = ownerDocument(node), - win = getWindow(doc), +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = offset; + +var _contains = require('./contains'); + +var _contains2 = _interopRequireDefault(_contains); + +var _isWindow = require('./isWindow'); + +var _isWindow2 = _interopRequireDefault(_isWindow); + +var _ownerDocument = require('../ownerDocument'); + +var _ownerDocument2 = _interopRequireDefault(_ownerDocument); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function offset(node) { + var doc = (0, _ownerDocument2.default)(node), + win = (0, _isWindow2.default)(doc), docElem = doc && doc.documentElement, box = { top: 0, left: 0, height: 0, width: 0 }; if (!doc) return; // Make sure it's not a disconnected DOM node - if (!contains(docElem, node)) return box; + if (!(0, _contains2.default)(docElem, node)) return box; if (node.getBoundingClientRect !== undefined) box = node.getBoundingClientRect(); - if (box.width || box.height) { - - box = { - top: box.top + (win.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0), - left: box.left + (win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0), - width: (box.width == null ? node.offsetWidth : box.width) || 0, - height: (box.height == null ? node.offsetHeight : box.height) || 0 - }; - } + // IE8 getBoundingClientRect doesn't support width & height + box = { + top: box.top + (win.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0), + left: box.left + (win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0), + width: (box.width == null ? node.offsetWidth : box.width) || 0, + height: (box.height == null ? node.offsetHeight : box.height) || 0 + }; return box; -}; -},{"../ownerDocument":136,"./contains":137,"./isWindow":138}],140:[function(require,module,exports){ +} +module.exports = exports['default']; +},{"../ownerDocument":133,"./contains":134,"./isWindow":135}],137:[function(require,module,exports){ 'use strict'; -var babelHelpers = require('../util/babelHelpers.js'); - -exports.__esModule = true; -exports['default'] = offsetParent; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = offsetParent; var _ownerDocument = require('../ownerDocument'); -var _ownerDocument2 = babelHelpers.interopRequireDefault(_ownerDocument); +var _ownerDocument2 = _interopRequireDefault(_ownerDocument); var _style = require('../style'); -var _style2 = babelHelpers.interopRequireDefault(_style); +var _style2 = _interopRequireDefault(_style); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function nodeName(node) { return node.nodeName && node.nodeName.toLowerCase(); } function offsetParent(node) { - var doc = (0, _ownerDocument2['default'])(node), + var doc = (0, _ownerDocument2.default)(node), offsetParent = node && node.offsetParent; - while (offsetParent && nodeName(node) !== 'html' && (0, _style2['default'])(offsetParent, 'position') === 'static') { + while (offsetParent && nodeName(node) !== 'html' && (0, _style2.default)(offsetParent, 'position') === 'static') { offsetParent = offsetParent.offsetParent; } return offsetParent || doc.documentElement; } - module.exports = exports['default']; -},{"../ownerDocument":136,"../style":146,"../util/babelHelpers.js":149}],141:[function(require,module,exports){ +},{"../ownerDocument":133,"../style":143}],138:[function(require,module,exports){ 'use strict'; -var babelHelpers = require('../util/babelHelpers.js'); +Object.defineProperty(exports, "__esModule", { + value: true +}); -exports.__esModule = true; -exports['default'] = position; +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +exports.default = position; var _offset = require('./offset'); -var _offset2 = babelHelpers.interopRequireDefault(_offset); +var _offset2 = _interopRequireDefault(_offset); var _offsetParent = require('./offsetParent'); -var _offsetParent2 = babelHelpers.interopRequireDefault(_offsetParent); +var _offsetParent2 = _interopRequireDefault(_offsetParent); var _scrollTop = require('./scrollTop'); -var _scrollTop2 = babelHelpers.interopRequireDefault(_scrollTop); +var _scrollTop2 = _interopRequireDefault(_scrollTop); var _scrollLeft = require('./scrollLeft'); -var _scrollLeft2 = babelHelpers.interopRequireDefault(_scrollLeft); +var _scrollLeft2 = _interopRequireDefault(_scrollLeft); var _style = require('../style'); -var _style2 = babelHelpers.interopRequireDefault(_style); +var _style2 = _interopRequireDefault(_style); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function nodeName(node) { return node.nodeName && node.nodeName.toLowerCase(); @@ -12593,35 +18159,39 @@ function position(node, offsetParent) { // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, // because it is its only offset parent - if ((0, _style2['default'])(node, 'position') === 'fixed') { + if ((0, _style2.default)(node, 'position') === 'fixed') { offset = node.getBoundingClientRect(); } else { - offsetParent = offsetParent || (0, _offsetParent2['default'])(node); - offset = (0, _offset2['default'])(node); + offsetParent = offsetParent || (0, _offsetParent2.default)(node); + offset = (0, _offset2.default)(node); - if (nodeName(offsetParent) !== 'html') parentOffset = (0, _offset2['default'])(offsetParent); + if (nodeName(offsetParent) !== 'html') parentOffset = (0, _offset2.default)(offsetParent); - parentOffset.top += parseInt((0, _style2['default'])(offsetParent, 'borderTopWidth'), 10) - (0, _scrollTop2['default'])(offsetParent) || 0; - parentOffset.left += parseInt((0, _style2['default'])(offsetParent, 'borderLeftWidth'), 10) - (0, _scrollLeft2['default'])(offsetParent) || 0; + parentOffset.top += parseInt((0, _style2.default)(offsetParent, 'borderTopWidth'), 10) - (0, _scrollTop2.default)(offsetParent) || 0; + parentOffset.left += parseInt((0, _style2.default)(offsetParent, 'borderLeftWidth'), 10) - (0, _scrollLeft2.default)(offsetParent) || 0; } // Subtract parent offsets and node margins - return babelHelpers._extends({}, offset, { - top: offset.top - parentOffset.top - (parseInt((0, _style2['default'])(node, 'marginTop'), 10) || 0), - left: offset.left - parentOffset.left - (parseInt((0, _style2['default'])(node, 'marginLeft'), 10) || 0) + return _extends({}, offset, { + top: offset.top - parentOffset.top - (parseInt((0, _style2.default)(node, 'marginTop'), 10) || 0), + left: offset.left - parentOffset.left - (parseInt((0, _style2.default)(node, 'marginLeft'), 10) || 0) }); } - module.exports = exports['default']; -},{"../style":146,"../util/babelHelpers.js":149,"./offset":139,"./offsetParent":140,"./scrollLeft":143,"./scrollTop":144}],142:[function(require,module,exports){ +},{"../style":143,"./offset":136,"./offsetParent":137,"./scrollLeft":140,"./scrollTop":141}],139:[function(require,module,exports){ 'use strict'; -// Zepto.js -// (c) 2010-2015 Thomas Fuchs -// Zepto.js may be freely distributed under the MIT license. -var simpleSelectorRE = /^[\w-]*$/, - toArray = Function.prototype.bind.call(Function.prototype.call, [].slice); -module.exports = function qsa(element, selector) { +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = qsa; +// Zepto.js +// (c) 2010-2015 Thomas Fuchs +// Zepto.js may be freely distributed under the MIT license. +var simpleSelectorRE = /^[\w-]*$/; +var toArray = Function.prototype.bind.call(Function.prototype.call, [].slice); + +function qsa(element, selector) { var maybeID = selector[0] === '#', maybeClass = selector[0] === '.', nameOnly = maybeID || maybeClass ? selector.slice(1) : selector, @@ -12640,50 +18210,79 @@ module.exports = function qsa(element, selector) { } return toArray(element.querySelectorAll(selector)); -}; -},{}],143:[function(require,module,exports){ +} +module.exports = exports['default']; +},{}],140:[function(require,module,exports){ 'use strict'; -var getWindow = require('./isWindow'); -module.exports = function scrollTop(node, val) { - var win = getWindow(node); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = scrollTop; + +var _isWindow = require('./isWindow'); + +var _isWindow2 = _interopRequireDefault(_isWindow); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function scrollTop(node, val) { + var win = (0, _isWindow2.default)(node); if (val === undefined) return win ? 'pageXOffset' in win ? win.pageXOffset : win.document.documentElement.scrollLeft : node.scrollLeft; if (win) win.scrollTo(val, 'pageYOffset' in win ? win.pageYOffset : win.document.documentElement.scrollTop);else node.scrollLeft = val; -}; -},{"./isWindow":138}],144:[function(require,module,exports){ +} +module.exports = exports['default']; +},{"./isWindow":135}],141:[function(require,module,exports){ 'use strict'; -var getWindow = require('./isWindow'); -module.exports = function scrollTop(node, val) { - var win = getWindow(node); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = scrollTop; + +var _isWindow = require('./isWindow'); + +var _isWindow2 = _interopRequireDefault(_isWindow); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function scrollTop(node, val) { + var win = (0, _isWindow2.default)(node); if (val === undefined) return win ? 'pageYOffset' in win ? win.pageYOffset : win.document.documentElement.scrollTop : node.scrollTop; if (win) win.scrollTo('pageXOffset' in win ? win.pageXOffset : win.document.documentElement.scrollLeft, val);else node.scrollTop = val; -}; -},{"./isWindow":138}],145:[function(require,module,exports){ +} +module.exports = exports['default']; +},{"./isWindow":135}],142:[function(require,module,exports){ 'use strict'; -var babelHelpers = require('../util/babelHelpers.js'); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = _getComputedStyle; -var _utilCamelizeStyle = require('../util/camelizeStyle'); +var _camelizeStyle = require('../util/camelizeStyle'); -var _utilCamelizeStyle2 = babelHelpers.interopRequireDefault(_utilCamelizeStyle); +var _camelizeStyle2 = _interopRequireDefault(_camelizeStyle); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var rposition = /^(top|right|bottom|left)$/; var rnumnonpx = /^([+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|))(?!px)[a-z%]+$/i; -module.exports = function _getComputedStyle(node) { +function _getComputedStyle(node) { if (!node) throw new TypeError('No Element passed to `getComputedStyle()`'); var doc = node.ownerDocument; - return 'defaultView' in doc ? doc.defaultView.opener ? node.ownerDocument.defaultView.getComputedStyle(node, null) : window.getComputedStyle(node, null) : { //ie 8 "magic" from: https://github.com/jquery/jquery/blob/1.11-stable/src/css/curCSS.js#L72 + return 'defaultView' in doc ? doc.defaultView.opener ? node.ownerDocument.defaultView.getComputedStyle(node, null) : window.getComputedStyle(node, null) : { + //ie 8 "magic" from: https://github.com/jquery/jquery/blob/1.11-stable/src/css/curCSS.js#L72 getPropertyValue: function getPropertyValue(prop) { var style = node.style; - prop = (0, _utilCamelizeStyle2['default'])(prop); + prop = (0, _camelizeStyle2.default)(prop); if (prop == 'float') prop = 'styleFloat'; @@ -12711,186 +18310,300 @@ module.exports = function _getComputedStyle(node) { return current; } }; -}; -},{"../util/babelHelpers.js":149,"../util/camelizeStyle":151}],146:[function(require,module,exports){ +} +module.exports = exports['default']; +},{"../util/camelizeStyle":148}],143:[function(require,module,exports){ 'use strict'; -var camelize = require('../util/camelizeStyle'), - hyphenate = require('../util/hyphenateStyle'), - _getComputedStyle = require('./getComputedStyle'), - removeStyle = require('./removeStyle'); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = style; -var has = Object.prototype.hasOwnProperty; +var _camelizeStyle = require('../util/camelizeStyle'); -module.exports = function style(node, property, value) { - var css = '', - props = property; +var _camelizeStyle2 = _interopRequireDefault(_camelizeStyle); + +var _hyphenateStyle = require('../util/hyphenateStyle'); + +var _hyphenateStyle2 = _interopRequireDefault(_hyphenateStyle); + +var _getComputedStyle2 = require('./getComputedStyle'); + +var _getComputedStyle3 = _interopRequireDefault(_getComputedStyle2); + +var _removeStyle = require('./removeStyle'); + +var _removeStyle2 = _interopRequireDefault(_removeStyle); + +var _properties = require('../transition/properties'); + +var _isTransform = require('../transition/isTransform'); + +var _isTransform2 = _interopRequireDefault(_isTransform); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function style(node, property, value) { + var css = ''; + var transforms = ''; + var props = property; if (typeof property === 'string') { - - if (value === undefined) return node.style[camelize(property)] || _getComputedStyle(node).getPropertyValue(hyphenate(property));else (props = {})[property] = value; + if (value === undefined) { + return node.style[(0, _camelizeStyle2.default)(property)] || (0, _getComputedStyle3.default)(node).getPropertyValue((0, _hyphenateStyle2.default)(property)); + } else { + (props = {})[property] = value; + } } - for (var key in props) if (has.call(props, key)) { - !props[key] && props[key] !== 0 ? removeStyle(node, hyphenate(key)) : css += hyphenate(key) + ':' + props[key] + ';'; + Object.keys(props).forEach(function (key) { + var value = props[key]; + if (!value && value !== 0) { + (0, _removeStyle2.default)(node, (0, _hyphenateStyle2.default)(key)); + } else if ((0, _isTransform2.default)(key)) { + transforms += key + '(' + value + ') '; + } else { + css += (0, _hyphenateStyle2.default)(key) + ': ' + value + ';'; + } + }); + + if (transforms) { + css += _properties.transform + ': ' + transforms + ';'; } node.style.cssText += ';' + css; -}; -},{"../util/camelizeStyle":151,"../util/hyphenateStyle":153,"./getComputedStyle":145,"./removeStyle":147}],147:[function(require,module,exports){ +} +module.exports = exports['default']; +},{"../transition/isTransform":145,"../transition/properties":146,"../util/camelizeStyle":148,"../util/hyphenateStyle":150,"./getComputedStyle":142,"./removeStyle":144}],144:[function(require,module,exports){ 'use strict'; -module.exports = function removeStyle(node, key) { +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = removeStyle; +function removeStyle(node, key) { return 'removeProperty' in node.style ? node.style.removeProperty(key) : node.style.removeAttribute(key); -}; -},{}],148:[function(require,module,exports){ +} +module.exports = exports['default']; +},{}],145:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = isTransform; +var supportedTransforms = /^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i; + +function isTransform(property) { + return !!(property && supportedTransforms.test(property)); +} +module.exports = exports["default"]; +},{}],146:[function(require,module,exports){ 'use strict'; -var canUseDOM = require('../util/inDOM'); -var has = Object.prototype.hasOwnProperty, - transform = 'transform', - transition = {}, - transitionTiming, - transitionDuration, - transitionProperty, - transitionDelay; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.animationEnd = exports.animationDelay = exports.animationTiming = exports.animationDuration = exports.animationName = exports.transitionEnd = exports.transitionDuration = exports.transitionDelay = exports.transitionTiming = exports.transitionProperty = exports.transform = undefined; -if (canUseDOM) { - transition = getTransitionProperties(); +var _inDOM = require('../util/inDOM'); - transform = transition.prefix + transform; +var _inDOM2 = _interopRequireDefault(_inDOM); - transitionProperty = transition.prefix + 'transition-property'; - transitionDuration = transition.prefix + 'transition-duration'; - transitionDelay = transition.prefix + 'transition-delay'; - transitionTiming = transition.prefix + 'transition-timing-function'; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var transform = 'transform'; +var prefix = void 0, + transitionEnd = void 0, + animationEnd = void 0; +var transitionProperty = void 0, + transitionDuration = void 0, + transitionTiming = void 0, + transitionDelay = void 0; +var animationName = void 0, + animationDuration = void 0, + animationTiming = void 0, + animationDelay = void 0; + +if (_inDOM2.default) { + var _getTransitionPropert = getTransitionProperties(); + + prefix = _getTransitionPropert.prefix; + exports.transitionEnd = transitionEnd = _getTransitionPropert.transitionEnd; + exports.animationEnd = animationEnd = _getTransitionPropert.animationEnd; + + + exports.transform = transform = prefix + '-' + transform; + exports.transitionProperty = transitionProperty = prefix + '-transition-property'; + exports.transitionDuration = transitionDuration = prefix + '-transition-duration'; + exports.transitionDelay = transitionDelay = prefix + '-transition-delay'; + exports.transitionTiming = transitionTiming = prefix + '-transition-timing-function'; + + exports.animationName = animationName = prefix + '-animation-name'; + exports.animationDuration = animationDuration = prefix + '-animation-duration'; + exports.animationTiming = animationTiming = prefix + '-animation-delay'; + exports.animationDelay = animationDelay = prefix + '-animation-timing-function'; } -module.exports = { +exports.transform = transform; +exports.transitionProperty = transitionProperty; +exports.transitionTiming = transitionTiming; +exports.transitionDelay = transitionDelay; +exports.transitionDuration = transitionDuration; +exports.transitionEnd = transitionEnd; +exports.animationName = animationName; +exports.animationDuration = animationDuration; +exports.animationTiming = animationTiming; +exports.animationDelay = animationDelay; +exports.animationEnd = animationEnd; +exports.default = { transform: transform, - end: transition.end, + end: transitionEnd, property: transitionProperty, timing: transitionTiming, delay: transitionDelay, duration: transitionDuration }; + function getTransitionProperties() { - var endEvent, - prefix = '', - transitions = { - O: 'otransitionend', - Moz: 'transitionend', - Webkit: 'webkitTransitionEnd', - ms: 'MSTransitionEnd' + var style = document.createElement('div').style; + + var vendorMap = { + O: function O(e) { + return 'o' + e.toLowerCase(); + }, + Moz: function Moz(e) { + return e.toLowerCase(); + }, + Webkit: function Webkit(e) { + return 'webkit' + e; + }, + ms: function ms(e) { + return 'MS' + e; + } }; - var element = document.createElement('div'); + var vendors = Object.keys(vendorMap); - for (var vendor in transitions) if (has.call(transitions, vendor)) { - if (element.style[vendor + 'TransitionProperty'] !== undefined) { - prefix = '-' + vendor.toLowerCase() + '-'; - endEvent = transitions[vendor]; + var transitionEnd = void 0, + animationEnd = void 0; + var prefix = ''; + + for (var i = 0; i < vendors.length; i++) { + var vendor = vendors[i]; + + if (vendor + 'TransitionProperty' in style) { + prefix = '-' + vendor.toLowerCase(); + transitionEnd = vendorMap[vendor]('TransitionEnd'); + animationEnd = vendorMap[vendor]('AnimationEnd'); break; } } - if (!endEvent && element.style.transitionProperty !== undefined) endEvent = 'transitionend'; + if (!transitionEnd && 'transitionProperty' in style) transitionEnd = 'transitionend'; - return { end: endEvent, prefix: prefix }; + if (!animationEnd && 'animationName' in style) animationEnd = 'animationend'; + + style = null; + + return { animationEnd: animationEnd, transitionEnd: transitionEnd, prefix: prefix }; } -},{"../util/inDOM":154}],149:[function(require,module,exports){ -(function (root, factory) { - if (typeof define === "function" && define.amd) { - define(["exports"], factory); - } else if (typeof exports === "object") { - factory(exports); - } else { - factory(root.babelHelpers = {}); - } -})(this, function (global) { - var babelHelpers = global; - - babelHelpers.interopRequireDefault = function (obj) { - return obj && obj.__esModule ? obj : { - "default": obj - }; - }; - - babelHelpers._extends = Object.assign || function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i]; - - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - } - - return target; - }; -}) -},{}],150:[function(require,module,exports){ +},{"../util/inDOM":151}],147:[function(require,module,exports){ "use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = camelize; var rHyphen = /-(.)/g; -module.exports = function camelize(string) { +function camelize(string) { return string.replace(rHyphen, function (_, chr) { return chr.toUpperCase(); }); -}; -},{}],151:[function(require,module,exports){ -/** - * Copyright 2014-2015, Facebook, Inc. - * All rights reserved. - * https://github.com/facebook/react/blob/2aeb8a2a6beb00617a4217f7f8284924fa2ad819/src/vendor/core/camelizeStyleName.js - */ - +} +module.exports = exports["default"]; +},{}],148:[function(require,module,exports){ 'use strict'; -var camelize = require('./camelize'); -var msPattern = /^-ms-/; -module.exports = function camelizeStyleName(string) { - return camelize(string.replace(msPattern, 'ms-')); -}; -},{"./camelize":150}],152:[function(require,module,exports){ +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = camelizeStyleName; + +var _camelize = require('./camelize'); + +var _camelize2 = _interopRequireDefault(_camelize); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var msPattern = /^-ms-/; /** + * Copyright 2014-2015, Facebook, Inc. + * All rights reserved. + * https://github.com/facebook/react/blob/2aeb8a2a6beb00617a4217f7f8284924fa2ad819/src/vendor/core/camelizeStyleName.js + */ +function camelizeStyleName(string) { + return (0, _camelize2.default)(string.replace(msPattern, 'ms-')); +} +module.exports = exports['default']; +},{"./camelize":147}],149:[function(require,module,exports){ 'use strict'; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = hyphenate; + var rUpper = /([A-Z])/g; -module.exports = function hyphenate(string) { +function hyphenate(string) { return string.replace(rUpper, '-$1').toLowerCase(); -}; -},{}],153:[function(require,module,exports){ -/** - * Copyright 2013-2014, Facebook, Inc. - * All rights reserved. - * https://github.com/facebook/react/blob/2aeb8a2a6beb00617a4217f7f8284924fa2ad819/src/vendor/core/hyphenateStyleName.js - */ - -"use strict"; - -var hyphenate = require("./hyphenate"); -var msPattern = /^ms-/; - -module.exports = function hyphenateStyleName(string) { - return hyphenate(string).replace(msPattern, "-ms-"); -}; -},{"./hyphenate":152}],154:[function(require,module,exports){ -'use strict'; -module.exports = !!(typeof window !== 'undefined' && window.document && window.document.createElement); -},{}],155:[function(require,module,exports){ +} +module.exports = exports['default']; +},{}],150:[function(require,module,exports){ 'use strict'; -var canUseDOM = require('./inDOM'); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = hyphenateStyleName; -var size; +var _hyphenate = require('./hyphenate'); -module.exports = function (recalc) { +var _hyphenate2 = _interopRequireDefault(_hyphenate); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var msPattern = /^ms-/; /** + * Copyright 2013-2014, Facebook, Inc. + * All rights reserved. + * https://github.com/facebook/react/blob/2aeb8a2a6beb00617a4217f7f8284924fa2ad819/src/vendor/core/hyphenateStyleName.js + */ + +function hyphenateStyleName(string) { + return (0, _hyphenate2.default)(string).replace(msPattern, '-ms-'); +} +module.exports = exports['default']; +},{"./hyphenate":149}],151:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = !!(typeof window !== 'undefined' && window.document && window.document.createElement); +module.exports = exports['default']; +},{}],152:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +exports.default = function (recalc) { if (!size || recalc) { - if (canUseDOM) { + if (_inDOM2.default) { var scrollDiv = document.createElement('div'); scrollDiv.style.position = 'absolute'; @@ -12907,7 +18620,17 @@ module.exports = function (recalc) { return size; }; -},{"./inDOM":154}],156:[function(require,module,exports){ + +var _inDOM = require('./inDOM'); + +var _inDOM2 = _interopRequireDefault(_inDOM); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var size = void 0; + +module.exports = exports['default']; +},{"./inDOM":151}],153:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -12967,8 +18690,12 @@ EventEmitter.prototype.emit = function(type) { er = arguments[1]; if (er instanceof Error) { throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; } - throw TypeError('Uncaught, unspecified "error" event.'); } } @@ -12991,18 +18718,11 @@ EventEmitter.prototype.emit = function(type) { break; // slower default: - len = arguments.length; - args = new Array(len - 1); - for (i = 1; i < len; i++) - args[i - 1] = arguments[i]; + args = Array.prototype.slice.call(arguments, 1); handler.apply(this, args); } } else if (isObject(handler)) { - len = arguments.length; - args = new Array(len - 1); - for (i = 1; i < len; i++) - args[i - 1] = arguments[i]; - + args = Array.prototype.slice.call(arguments, 1); listeners = handler.slice(); len = listeners.length; for (i = 0; i < len; i++) @@ -13040,7 +18760,6 @@ EventEmitter.prototype.addListener = function(type, listener) { // Check for listener leak if (isObject(this._events[type]) && !this._events[type].warned) { - var m; if (!isUndefined(this._maxListeners)) { m = this._maxListeners; } else { @@ -13162,7 +18881,7 @@ EventEmitter.prototype.removeAllListeners = function(type) { if (isFunction(listeners)) { this.removeListener(type, listeners); - } else { + } else if (listeners) { // LIFO order while (listeners.length) this.removeListener(type, listeners[listeners.length - 1]); @@ -13183,15 +18902,20 @@ EventEmitter.prototype.listeners = function(type) { return ret; }; +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; + + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; + } + return 0; +}; + EventEmitter.listenerCount = function(emitter, type) { - var ret; - if (!emitter._events || !emitter._events[type]) - ret = 0; - else if (isFunction(emitter._events[type])) - ret = 1; - else - ret = emitter._events[type].length; - return ret; + return emitter.listenerCount(type); }; function isFunction(arg) { @@ -13210,7 +18934,7 @@ function isUndefined(arg) { return arg === void 0; } -},{}],157:[function(require,module,exports){ +},{}],154:[function(require,module,exports){ /** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. @@ -13227,7 +18951,7 @@ var fbemitter = { module.exports = fbemitter; -},{"./lib/BaseEventEmitter":158,"./lib/EmitterSubscription":159}],158:[function(require,module,exports){ +},{"./lib/BaseEventEmitter":155,"./lib/EmitterSubscription":156}],155:[function(require,module,exports){ (function (process){ /** * Copyright (c) 2014-present, Facebook, Inc. @@ -13422,7 +19146,7 @@ var BaseEventEmitter = (function () { module.exports = BaseEventEmitter; }).call(this,require('_process')) -},{"./EmitterSubscription":159,"./EventSubscriptionVendor":161,"_process":295,"fbjs/lib/emptyFunction":162,"fbjs/lib/invariant":163}],159:[function(require,module,exports){ +},{"./EmitterSubscription":156,"./EventSubscriptionVendor":158,"_process":239,"fbjs/lib/emptyFunction":166,"fbjs/lib/invariant":174}],156:[function(require,module,exports){ /** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. @@ -13471,7 +19195,7 @@ var EmitterSubscription = (function (_EventSubscription) { })(EventSubscription); module.exports = EmitterSubscription; -},{"./EventSubscription":160}],160:[function(require,module,exports){ +},{"./EventSubscription":157}],157:[function(require,module,exports){ /** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. @@ -13521,7 +19245,7 @@ var EventSubscription = (function () { })(); module.exports = EventSubscription; -},{}],161:[function(require,module,exports){ +},{}],158:[function(require,module,exports){ (function (process){ /** * Copyright (c) 2014-present, Facebook, Inc. @@ -13628,7 +19352,450 @@ var EventSubscriptionVendor = (function () { module.exports = EventSubscriptionVendor; }).call(this,require('_process')) -},{"_process":295,"fbjs/lib/invariant":163}],162:[function(require,module,exports){ +},{"_process":239,"fbjs/lib/invariant":174}],159:[function(require,module,exports){ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @typechecks + */ + +var emptyFunction = require('./emptyFunction'); + +/** + * Upstream version of event listener. Does not take into account specific + * nature of platform. + */ +var EventListener = { + /** + * Listen to DOM events during the bubble phase. + * + * @param {DOMEventTarget} target DOM element to register listener on. + * @param {string} eventType Event type, e.g. 'click' or 'mouseover'. + * @param {function} callback Callback function. + * @return {object} Object with a `remove` method. + */ + listen: function listen(target, eventType, callback) { + if (target.addEventListener) { + target.addEventListener(eventType, callback, false); + return { + remove: function remove() { + target.removeEventListener(eventType, callback, false); + } + }; + } else if (target.attachEvent) { + target.attachEvent('on' + eventType, callback); + return { + remove: function remove() { + target.detachEvent('on' + eventType, callback); + } + }; + } + }, + + /** + * Listen to DOM events during the capture phase. + * + * @param {DOMEventTarget} target DOM element to register listener on. + * @param {string} eventType Event type, e.g. 'click' or 'mouseover'. + * @param {function} callback Callback function. + * @return {object} Object with a `remove` method. + */ + capture: function capture(target, eventType, callback) { + if (target.addEventListener) { + target.addEventListener(eventType, callback, true); + return { + remove: function remove() { + target.removeEventListener(eventType, callback, true); + } + }; + } else { + if ("development" !== 'production') { + console.error('Attempted to listen to events during the capture phase on a ' + 'browser that does not support the capture phase. Your application ' + 'will not receive some events.'); + } + return { + remove: emptyFunction + }; + } + }, + + registerDefault: function registerDefault() {} +}; + +module.exports = EventListener; +},{"./emptyFunction":166}],160:[function(require,module,exports){ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +'use strict'; + +var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); + +/** + * Simple, lightweight module assisting with the detection and context of + * Worker. Helps avoid circular dependencies and allows code to reason about + * whether or not they are in a Worker, even if they never include the main + * `ReactWorker` dependency. + */ +var ExecutionEnvironment = { + + canUseDOM: canUseDOM, + + canUseWorkers: typeof Worker !== 'undefined', + + canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent), + + canUseViewport: canUseDOM && !!window.screen, + + isInWorker: !canUseDOM // For now, this is true - might change in the future. + +}; + +module.exports = ExecutionEnvironment; +},{}],161:[function(require,module,exports){ +"use strict"; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +var _hyphenPattern = /-(.)/g; + +/** + * Camelcases a hyphenated string, for example: + * + * > camelize('background-color') + * < "backgroundColor" + * + * @param {string} string + * @return {string} + */ +function camelize(string) { + return string.replace(_hyphenPattern, function (_, character) { + return character.toUpperCase(); + }); +} + +module.exports = camelize; +},{}],162:[function(require,module,exports){ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +'use strict'; + +var camelize = require('./camelize'); + +var msPattern = /^-ms-/; + +/** + * Camelcases a hyphenated CSS property name, for example: + * + * > camelizeStyleName('background-color') + * < "backgroundColor" + * > camelizeStyleName('-moz-transition') + * < "MozTransition" + * > camelizeStyleName('-ms-transition') + * < "msTransition" + * + * As Andi Smith suggests + * (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix + * is converted to lowercase `ms`. + * + * @param {string} string + * @return {string} + */ +function camelizeStyleName(string) { + return camelize(string.replace(msPattern, 'ms-')); +} + +module.exports = camelizeStyleName; +},{"./camelize":161}],163:[function(require,module,exports){ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +var isTextNode = require('./isTextNode'); + +/*eslint-disable no-bitwise */ + +/** + * Checks if a given DOM node contains or is another DOM node. + */ +function containsNode(outerNode, innerNode) { + if (!outerNode || !innerNode) { + return false; + } else if (outerNode === innerNode) { + return true; + } else if (isTextNode(outerNode)) { + return false; + } else if (isTextNode(innerNode)) { + return containsNode(outerNode, innerNode.parentNode); + } else if ('contains' in outerNode) { + return outerNode.contains(innerNode); + } else if (outerNode.compareDocumentPosition) { + return !!(outerNode.compareDocumentPosition(innerNode) & 16); + } else { + return false; + } +} + +module.exports = containsNode; +},{"./isTextNode":176}],164:[function(require,module,exports){ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +var invariant = require('./invariant'); + +/** + * Convert array-like objects to arrays. + * + * This API assumes the caller knows the contents of the data type. For less + * well defined inputs use createArrayFromMixed. + * + * @param {object|function|filelist} obj + * @return {array} + */ +function toArray(obj) { + var length = obj.length; + + // Some browsers builtin objects can report typeof 'function' (e.g. NodeList + // in old versions of Safari). + !(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function')) ? "development" !== 'production' ? invariant(false, 'toArray: Array-like object expected') : invariant(false) : void 0; + + !(typeof length === 'number') ? "development" !== 'production' ? invariant(false, 'toArray: Object needs a length property') : invariant(false) : void 0; + + !(length === 0 || length - 1 in obj) ? "development" !== 'production' ? invariant(false, 'toArray: Object should have keys for indices') : invariant(false) : void 0; + + !(typeof obj.callee !== 'function') ? "development" !== 'production' ? invariant(false, 'toArray: Object can\'t be `arguments`. Use rest params ' + '(function(...args) {}) or Array.from() instead.') : invariant(false) : void 0; + + // Old IE doesn't give collections access to hasOwnProperty. Assume inputs + // without method will throw during the slice call and skip straight to the + // fallback. + if (obj.hasOwnProperty) { + try { + return Array.prototype.slice.call(obj); + } catch (e) { + // IE < 9 does not support Array#slice on collections objects + } + } + + // Fall back to copying key by key. This assumes all keys have a value, + // so will not preserve sparsely populated inputs. + var ret = Array(length); + for (var ii = 0; ii < length; ii++) { + ret[ii] = obj[ii]; + } + return ret; +} + +/** + * Perform a heuristic test to determine if an object is "array-like". + * + * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?" + * Joshu replied: "Mu." + * + * This function determines if its argument has "array nature": it returns + * true if the argument is an actual array, an `arguments' object, or an + * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()). + * + * It will return false for other array-like objects like Filelist. + * + * @param {*} obj + * @return {boolean} + */ +function hasArrayNature(obj) { + return ( + // not null/false + !!obj && ( + // arrays are objects, NodeLists are functions in Safari + typeof obj == 'object' || typeof obj == 'function') && + // quacks like an array + 'length' in obj && + // not window + !('setInterval' in obj) && + // no DOM node should be considered an array-like + // a 'select' element has 'length' and 'item' properties on IE8 + typeof obj.nodeType != 'number' && ( + // a real array + Array.isArray(obj) || + // arguments + 'callee' in obj || + // HTMLCollection/NodeList + 'item' in obj) + ); +} + +/** + * Ensure that the argument is an array by wrapping it in an array if it is not. + * Creates a copy of the argument if it is already an array. + * + * This is mostly useful idiomatically: + * + * var createArrayFromMixed = require('createArrayFromMixed'); + * + * function takesOneOrMoreThings(things) { + * things = createArrayFromMixed(things); + * ... + * } + * + * This allows you to treat `things' as an array, but accept scalars in the API. + * + * If you need to convert an array-like object, like `arguments`, into an array + * use toArray instead. + * + * @param {*} obj + * @return {array} + */ +function createArrayFromMixed(obj) { + if (!hasArrayNature(obj)) { + return [obj]; + } else if (Array.isArray(obj)) { + return obj.slice(); + } else { + return toArray(obj); + } +} + +module.exports = createArrayFromMixed; +},{"./invariant":174}],165:[function(require,module,exports){ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +/*eslint-disable fb-www/unsafe-html*/ + +var ExecutionEnvironment = require('./ExecutionEnvironment'); + +var createArrayFromMixed = require('./createArrayFromMixed'); +var getMarkupWrap = require('./getMarkupWrap'); +var invariant = require('./invariant'); + +/** + * Dummy container used to render all markup. + */ +var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null; + +/** + * Pattern used by `getNodeName`. + */ +var nodeNamePattern = /^\s*<(\w+)/; + +/** + * Extracts the `nodeName` of the first element in a string of markup. + * + * @param {string} markup String of markup. + * @return {?string} Node name of the supplied markup. + */ +function getNodeName(markup) { + var nodeNameMatch = markup.match(nodeNamePattern); + return nodeNameMatch && nodeNameMatch[1].toLowerCase(); +} + +/** + * Creates an array containing the nodes rendered from the supplied markup. The + * optionally supplied `handleScript` function will be invoked once for each + * '; + + if (!$return) { + echo $output; + } + else { + return $output; + } +} + + +?> diff --git a/pandora_console/include/functions_cron.php b/pandora_console/include/functions_cron.php index bb20efd74d..cf131eac8e 100644 --- a/pandora_console/include/functions_cron.php +++ b/pandora_console/include/functions_cron.php @@ -26,7 +26,13 @@ function cron_update_module_interval ($module_id, $cron) { return; } - return db_process_sql ('UPDATE tagente_estado SET current_interval = ' . cron_next_execution ($cron) . ' WHERE id_agente_modulo = ' . (int) $module_id); + if($cron == "* * * * *"){ + $module_interval = db_get_value_filter('module_interval','tagente_modulo',array("id_agente_modulo" => $module_id)); + return db_process_sql ('UPDATE tagente_estado SET current_interval = ' . $module_interval . ' WHERE id_agente_modulo = ' . (int) $module_id); + } else { + return db_process_sql ('UPDATE tagente_estado SET current_interval = ' . cron_next_execution ($cron) . ' WHERE id_agente_modulo = ' . (int) $module_id); + } + } diff --git a/pandora_console/include/functions_custom_graphs.php b/pandora_console/include/functions_custom_graphs.php index af41801336..499a8a817f 100644 --- a/pandora_console/include/functions_custom_graphs.php +++ b/pandora_console/include/functions_custom_graphs.php @@ -164,7 +164,7 @@ function custom_graphs_print($id_graph, $height, $width, $period, $background_color = 'white', $modules_param = array(), $homeurl = '', $name_list = array(), $unit_list = array(), $show_last = true, $show_max = true, $show_min = true, $show_avg = true, $ttl = 1, - $dashboard = false, $vconsole = false, $percentil = null, $from_interface = false) { + $dashboard = false, $vconsole = false, $percentil = null, $from_interface = false,$id_widget_dashboard=false) { global $config; @@ -251,7 +251,7 @@ function custom_graphs_print($id_graph, $height, $width, $period, false, $background_color, $name_list, - $unit_list, + array(), $show_last, $show_max, $show_min, @@ -260,7 +260,8 @@ function custom_graphs_print($id_graph, $height, $width, $period, $dashboard, $vconsole, $percentil, - $from_interface); + $from_interface, + $id_widget_dashboard); if ($return) return $output; diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index e682e1e138..06c85ef194 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -64,8 +64,23 @@ function db_connect($host = null, $db = null, $user = null, $pass = null, $port // Something went wrong if ($return === false) { if ($critical) { + $url = explode('/', $_SERVER['REQUEST_URI']); + $flag_url =0; + foreach ($url as $key => $value) { + if (strpos($value, 'index.php') !== false || $flag_url) { + $flag_url=1; + unset($url[$key]); + } + else if(strpos($value, 'enterprise') !== false || $flag_url){ + $flag_url=1; + unset($url[$key]); + } + } + $config["homeurl"] = rtrim(join("/", $url),"/"); + $config["homeurl_static"] = $config["homeurl"]; + $ownDir = dirname(__FILE__) . DIRECTORY_SEPARATOR; + $config['homedir'] = $ownDir; $login_screen = 'error_authconfig'; - require($config['homedir'] . '/general/error_screen.php'); exit; } @@ -569,7 +584,13 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f if ((!isset($tstart)) || ($tstart === false)) { // Return data from the begining - $tstart = 0; + // Get first available utimestamp in active DB + $query_first_man_time = " SELECT utimestamp FROM tagente_datos "; + $query_first_man_time .= " WHERE id_agente_modulo = $id_agente_modulo"; + $query_first_man_time .= " ORDER BY utimestamp ASC LIMIT 1"; + + $first_man_time = db_get_all_rows_sql( $query_first_man_time, false); + $tstart = $first_man_time[0]['utimestamp']; } if ((!isset($tend)) || ($tend === false)) { @@ -581,7 +602,6 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f return false; } - $search_historydb = false; $table = "tagente_datos"; @@ -596,13 +616,11 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f $table = "tagente_datos_string"; } - // Get first available utimestamp in active DB $query = " SELECT utimestamp, datos FROM $table "; $query .= " WHERE id_agente_modulo=$id_agente_modulo AND utimestamp < $tstart"; $query .= " ORDER BY utimestamp DESC LIMIT 1"; - $ret = db_get_all_rows_sql( $query , $search_historydb); if ( ( $ret === false ) || (( isset($ret[0]["utimestamp"]) && ($ret[0]["utimestamp"] > $tstart )))) { @@ -610,6 +628,10 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f $search_historydb = true; $ret = db_get_all_rows_sql( $query , $search_historydb); + + if ($ret) { + $tstart = $ret[0]["utimestamp"]; + } } else { $first_data["utimestamp"] = $ret[0]["utimestamp"]; diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 8c11eb1316..5acd48e5df 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -703,7 +703,7 @@ function events_create_event ($event, $id_group, $id_agent, $status = 0, $id_user = "", $event_type = "unknown", $priority = 0, $id_agent_module = 0, $id_aam = 0, $critical_instructions = '', $warning_instructions = '', $unknown_instructions = '', - $source="Pandora", $tags="", $custom_data="", $server_id = 0) { + $source="Pandora", $tags="", $custom_data="", $server_id = 0, $id_extra ="") { global $config; @@ -719,15 +719,15 @@ function events_create_event ($event, $id_group, $id_agent, $status = 0, event_type, criticity, id_agentmodule, id_alert_am, critical_instructions, warning_instructions, unknown_instructions, source, tags, custom_data, - server_id) + server_id, id_extra) VALUES (%d, %d, "%s", NOW(), %d, UNIX_TIMESTAMP(NOW()), "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", - "%s", "%s", %d)', + "%s", "%s", %d, "%s")', $id_agent, $id_group, $event, $status, $id_user, $event_type, $priority, $id_agent_module, $id_aam, $critical_instructions, $warning_instructions, $unknown_instructions, $source, $tags, $custom_data, - $server_id); + $server_id, $id_extra); break; case "postgresql": $sql = sprintf (' @@ -736,16 +736,16 @@ function events_create_event ($event, $id_group, $id_agent, $status = 0, event_type, criticity, id_agentmodule, id_alert_am, critical_instructions, warning_instructions, unknown_instructions, source, tags, custom_data, - server_id) + server_id, id_extra) VALUES (%d, %d, "%s", NOW(), %d, ceil(date_part(\'epoch\', CURRENT_TIMESTAMP)), "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s", - "%s", %d)', + "%s", %d, "%s")', $id_agent, $id_group, $event, $status, $id_user, $event_type, $priority, $id_agent_module, $id_aam, $critical_instructions, $warning_instructions, $unknown_instructions, $source, $tags, $custom_data, - $server_id); + $server_id, $id_extra); break; case "oracle": $sql = sprintf (' @@ -754,15 +754,15 @@ function events_create_event ($event, $id_group, $id_agent, $status = 0, event_type, criticity, id_agentmodule, id_alert_am, critical_instructions, warning_instructions, unknown_instructions, source, tags, custom_data, - server_id) + server_id, id_extra) VALUES (%d, %d, "%s", CURRENT_TIMESTAMP, %d, UNIX_TIMESTAMP, "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", - "%s", "%s", %d)', + "%s", "%s", %d, "%s")', $id_agent, $id_group, $event, $status, $id_user, $event_type, $priority, $id_agent_module, $id_aam, $critical_instructions, $warning_instructions, $unknown_instructions, $source, $tags, $custom_data, - $server_id); + $server_id, $id_extra); break; } } @@ -774,13 +774,13 @@ function events_create_event ($event, $id_group, $id_agent, $status = 0, timestamp, estado, utimestamp, id_usuario, event_type, criticity, id_agentmodule, id_alert_am, critical_instructions, warning_instructions, - unknown_instructions, source, tags, custom_data) + unknown_instructions, source, tags, custom_data, id_extra) VALUES (%d, %d, "%s", NOW(), %d, UNIX_TIMESTAMP(NOW()), - "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s", "%s")', + "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s", "%s", "%s")', $id_agent, $id_group, $event, $status, $id_user, $event_type, $priority, $id_agent_module, $id_aam, $critical_instructions, $warning_instructions, - $unknown_instructions, $source, $tags, $custom_data); + $unknown_instructions, $source, $tags, $custom_data, $id_extra); break; case "postgresql": $sql = sprintf (' @@ -788,14 +788,14 @@ function events_create_event ($event, $id_group, $id_agent, $status = 0, timestamp, estado, utimestamp, id_usuario, event_type, criticity, id_agentmodule, id_alert_am, critical_instructions, warning_instructions, - unknown_instructions, source, tags, custom_data) + unknown_instructions, source, tags, custom_data, id_extra) VALUES (%d, %d, "%s", NOW(), %d, ceil(date_part(\'epoch\', CURRENT_TIMESTAMP)), "%s", - "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s", "%s")', + "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s", "%s", "%s")', $id_agent, $id_group, $event, $status, $id_user, $event_type, $priority, $id_agent_module, $id_aam, $critical_instructions, $warning_instructions, - $unknown_instructions, $source, $tags, $custom_data); + $unknown_instructions, $source, $tags, $custom_data, $id_extra); break; case "oracle": $sql = sprintf (" @@ -803,13 +803,13 @@ function events_create_event ($event, $id_group, $id_agent, $status = 0, timestamp, estado, utimestamp, id_usuario, event_type, criticity, id_agentmodule, id_alert_am, critical_instructions, warning_instructions, - unknown_instructions, source, tags, custom_data) + unknown_instructions, source, tags, custom_data, id_extra) VALUES (%d, %d, '%s', CURRENT_TIMESTAMP, %d, UNIX_TIMESTAMP, - '%s', '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s')", + '%s', '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $id_agent, $id_group, $event, $status, $id_user, $event_type, $priority, $id_agent_module, $id_aam, $critical_instructions, $warning_instructions, - $unknown_instructions, $source, $tags, $custom_data); + $unknown_instructions, $source, $tags, $custom_data, $id_extra); break; } } @@ -2115,7 +2115,7 @@ function events_page_details ($event, $server = "") { "type" => $graph_type, "period" => SECONDS_1DAY, "id" => $module["id_agente_modulo"], - "label" => rawurlencode(urlencode(base64_encode($module["nombre"]))), + "label" => base64_encode($module["nombre"]), "refresh" => SECONDS_10MINUTES ); @@ -2336,7 +2336,8 @@ function events_page_general ($event) { $data = array(); $data[0] = __('Event name'); - $data[1] = strip_tags(io_safe_output($event["evento"])); + $event["evento"] = str_replace ( ' ' , '
    ' , $event["evento"]); + $data[1] = io_safe_output($event["evento"]); $table_general->data[] = $data; $data = array(); @@ -2349,6 +2350,8 @@ function events_page_general ($event) { } $table_general->data[] = $data; + $event["owner_user"] = $event["id_usuario"]; + $data = array(); $data[0] = __('Owner'); if (empty($event["owner_user"])) { @@ -3393,9 +3396,9 @@ function events_sql_events_grouped_agents($id_agent, $server_id = -1, $sql_post .= " AND (utimestamp <= " . $udate_to . ")"; } } - + //Search by tag - if (!empty($tag_with)) { + if (!empty($tag_with) && (io_safe_output($tag_with) != "[]") && (io_safe_output($tag_with) != "[\"0\"]")) { $sql_post .= ' AND ( '; $first = true; foreach ($tag_with as $id_tag) { @@ -3405,7 +3408,7 @@ function events_sql_events_grouped_agents($id_agent, $server_id = -1, } $sql_post .= ' ) '; } - if (!empty($tag_without)) { + if (!empty($tag_without) && (io_safe_output($tag_without) != "[]") && (io_safe_output($tag_with) != "[\"0\"]")) { $sql_post .= ' AND ( '; $first = true; foreach ($tag_without as $id_tag) { diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index cbd4b28b69..8f1a02f9f0 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -368,6 +368,7 @@ function gis_activate_ajax_refresh($layers = null, $lastTimeOfData = null, $publ } } } + EventZoomEnd(null,map.zoom); } }); } @@ -396,7 +397,7 @@ function gis_activate_ajax_refresh($layers = null, $lastTimeOfData = null, $publ } ?> } - + last_time_of_data = Math.round(new Date().getTime() / 1000); //Unixtimestamp //Test if the user change the refresh time. @@ -405,11 +406,16 @@ function gis_activate_ajax_refresh($layers = null, $lastTimeOfData = null, $publ idIntervalAjax = setInterval("clock_ajax_refresh()", refreshAjaxIntervalSeconds); oldRefreshAjaxIntervalSeconds = refreshAjaxIntervalSeconds; } + + EventZoomEnd(null,map.zoom); + + } $(document).ready ( function () { idIntervalAjax = setInterval("clock_ajax_refresh()", refreshAjaxIntervalSeconds); + EventZoomEnd(null,map.zoom); } ); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 8582655e82..d6ced0e99c 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -232,14 +232,14 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i $projection, $avg_only = false, $uncompressed_module = false, $show_events = false, $show_alerts = false, $show_unknown = false, $baseline = false, $baseline_data = array(), $events = array(), $series_suffix = '', $start_unknown = false, - $percentil = null) { + $percentil = null, $fullscale = false) { global $config; global $chart_extra_data; global $series_type; global $max_value; global $min_value; - + $max_value = 0; $min_value = null; $flash_chart = $config['flash_charts']; @@ -252,12 +252,14 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i // Calculate chart data $last_known = $previous_data; - - + for ($i = 0; $i <= $resolution; $i++) { $timestamp = $datelimit + ($interval * $i); - - + + if ($fullscale && ($resolution > ($config['graph_res'] * 50))) { + $timestamp = $data[$i]['utimestamp']; + } + $total = 0; $count = 0; @@ -279,6 +281,7 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i else if ($data[$data_i]['datos'] < $interval_min) { $interval_min = $data[$data_i]['datos']; } + $total += $data[$data_i]['datos']; $last_known = $data[$data_i]['datos']; $count++; @@ -353,9 +356,12 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i elseif ($period < SECONDS_1MONTH) { $time_format = "M \nd H\h"; } - else { + elseif ($period < SECONDS_6MONTHS) { $time_format = "M \nd H\h"; } + else { + $time_format = "Y M \nd H\h"; + } } else { // Set the title and time format @@ -371,16 +377,21 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i elseif ($period < SECONDS_1MONTH) { $time_format = "M d H\h"; } - else { + elseif ($period < SECONDS_6MONTHS) { $time_format = "M d H\h"; } + else { + $time_format = "Y M d H\h"; + } } $timestamp_short = date($time_format, $timestamp); $long_index[$timestamp_short] = date( html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp); if (!$projection) { - $timestamp = $timestamp_short; + if (!$fullscale) { + $timestamp = $timestamp_short; + } } // Data @@ -444,8 +455,14 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i $series_type['no_data'.$series_suffix] = 'area'; } else { - $chart[$timestamp]['no_data'.$series_suffix] = $last_known; - $series_type['no_data'.$series_suffix] = 'area'; + if($uncompressed_module){ + $chart[$timestamp]['sum'.$series_suffix] = $last_known; + $series_type['sum'.$series_suffix] = 'area'; + } + else{ + $chart[$timestamp]['no_data'.$series_suffix] = $last_known; + $series_type['no_data'.$series_suffix] = 'area'; + } } } @@ -458,20 +475,6 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i $series_type['unknown'.$series_suffix] = 'area'; } - //$chart[$timestamp]['count'] = 0; - ///////// - //$chart[$timestamp]['timestamp_bottom'] = $timestamp; - //$chart[$timestamp]['timestamp_top'] = $timestamp + $interval; - ///////// - - //Baseline was replaced by compare graphs feature - /*if ($baseline) { - $chart[$timestamp]['baseline'.$series_suffix] = array_shift ($baseline_data); - if ($chart[$timestamp]['baseline'.$series_suffix] == NULL) { - $chart[$timestamp]['baseline'.$series_suffix] = 0; - } - }*/ - if (!empty($event_ids)) { $chart_extra_data[count($chart)-1]['events'] = implode(',',$event_ids); } @@ -498,7 +501,8 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $show_alerts = false, $avg_only = 0, $date = 0, $unit = '', $baseline = 0, $return_data = 0, $show_title = true, $projection = false, $adapt_key = '', $compare = false, $series_suffix = '', $series_suffix_str = '', - $show_unknown = false, $percentil = null, $dashboard = false, $vconsole = false,$type_graph='area') { + $show_unknown = false, $percentil = null, $dashboard = false, $vconsole = false, + $type_graph='area', $fullscale = false) { global $config; global $chart; @@ -565,13 +569,57 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, } // Get module data - $data = db_get_all_rows_filter ('tagente_datos', - array ('id_agente_modulo' => (int)$agent_module_id, - "utimestamp > $datelimit", - "utimestamp < $date", - 'order' => 'utimestamp ASC'), - array ('datos', 'utimestamp'), 'AND', $search_in_history_db); - + if ($fullscale) { + $data = db_get_all_rows_filter ('tagente_datos', + array ('id_agente_modulo' => (int)$agent_module_id, + "utimestamp > $datelimit", + "utimestamp < $date", + 'order' => 'utimestamp ASC'), + array ('datos', 'utimestamp'), 'AND', true); + } + else { + $data = db_get_all_rows_filter ('tagente_datos', + array ('id_agente_modulo' => (int)$agent_module_id, + "utimestamp > $datelimit", + "utimestamp < $date", + 'order' => 'utimestamp ASC'), + array ('datos', 'utimestamp'), 'AND', false); + + if ($search_in_history_db) { + $cache = false; + $history = false; + + $sql = "SELECT datos, utimestamp FROM tagente_datos WHERE id_agente_modulo = " . (int)$agent_module_id . + " AND utimestamp > " . $datelimit . " AND utimestamp < " . $date . + " ORDER BY utimestamp ASC"; + + // Connect to the history DB + if (! isset ($config['history_db_connection']) || $config['history_db_connection'] === false) { + $config['history_db_connection'] = db_connect($config['history_db_host'], $config['history_db_name'], $config['history_db_user'], io_output_password($config['history_db_pass']), $config['history_db_port'], false); + } + if ($config['history_db_connection'] !== false) { + $history = mysql_db_process_sql ($sql, 'affected_rows', $config['history_db_connection'], false); + } + + if ($history === false) { + $history = array (); + } + + $new_data = array(); + $last_timestamp = 0; + foreach($history as $h) { + $new_data[] = $h; + $last_timestamp = $h['utimestamp']; + } + foreach($data as $d) { + if ($d['utimestamp'] > $last_timestamp) { + $new_data[] = $d; + $last_timestamp = $d['utimestamp']; + } + } + $data = $new_data; + } + } // Get module warning_min and critical_min $warning_min = db_get_value('min_warning','tagente_modulo','id_agente_modulo',$agent_module_id); @@ -612,7 +660,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $min_necessary = 2; } - + // Check available data if (count ($data) < $min_necessary) { if (!$graphic_type) { @@ -655,6 +703,13 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, if (empty($unit)) { $unit = modules_get_unit($agent_module_id); } + + if ($fullscale) { + if (count($data) > $resolution) { + $resolution = count($data); //Number of points of the graph + $interval = (int) ($period / $resolution); + } + } // Calculate chart data grafico_modulo_sparse_data_chart ($chart, $chart_data_extra, $long_index, @@ -662,10 +717,29 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $projection, $avg_only, $uncompressed_module, $show_events, $show_alerts, $show_unknown, $baseline, $baseline_data, $events, $series_suffix, $start_unknown, - $percentil); - - - + $percentil, $fullscale); + + if ($fullscale) { + if (!$flash_chart) { + $time_format = "Y M \nd H:i:s"; + } + else { + $time_format = "Y M d H:i:s"; + } + + $new_chart = array(); + $new_long_index = array(); + foreach ($chart as $c_timestamp => $c_data) { + $timestamp_short = date($time_format, $c_timestamp); + $new_long_index[$timestamp_short] = date( + html_entity_decode($time_format, ENT_QUOTES, "UTF-8"), $c_timestamp); + $new_chart[$timestamp_short] = $c_data; + } + + $long_index = $new_long_index; + $chart = $new_chart; + } + // Return chart data and don't draw if ($return_data == 1) { return $chart; @@ -736,8 +810,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $color['min'.$series_suffix] = array( 'border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => CHART_DEFAULT_ALPHA); - //Baseline was replaced by compare graph feature - //$color['baseline'.$series_suffix] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10); + $color['unit'.$series_suffix] = array('border' => null, 'color' => '#0097BC', 'alpha' => 10); if ($show_events) { @@ -749,7 +822,17 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $chart_extra_data['legend_alerts'] = $legend['alert'.$series_suffix_str]; } - if ($dashboard || $vconsole) { + if ($vconsole) { + $legend['sum'.$series_suffix] = + __('Last') . ': ' . remove_right_zeros(number_format($graph_stats['sum']['last'], $config['graph_precision'])) . ($unit ? ' ' . $unit : '') . ' ; ' + . __('Avg') . ': ' . remove_right_zeros(number_format($graph_stats['sum']['avg'], $config['graph_precision'])) . ($unit ? ' ' . $unit : ''); + } + else if ($dashboard && !$avg_only) { + $legend['max'.$series_suffix] = __('Max').$series_suffix_str.': '.__('Avg').': '.remove_right_zeros(number_format($graph_stats['max']['avg'], $config['graph_precision'])).' '.$unit.' ; '.__('Max').': '.remove_right_zeros(number_format($graph_stats['max']['max'], $config['graph_precision'])).' '.$unit.' ; '.__('Min').': '.remove_right_zeros(number_format($graph_stats['max']['min'], $config['graph_precision'])).' '.$unit; + $legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Avg').': '.remove_right_zeros(number_format($graph_stats['sum']['avg'], $config['graph_precision'])).' '.$unit.' ; '.__('Max').': '.remove_right_zeros(number_format($graph_stats['sum']['max'], $config['graph_precision'])).' '.$unit.' ; '.__('Min').': '.remove_right_zeros(number_format($graph_stats['sum']['min'], $config['graph_precision'])).' '.$unit; + $legend['min'.$series_suffix] = __('Min').$series_suffix_str.': '.__('Avg').': '.remove_right_zeros(number_format($graph_stats['min']['avg'], $config['graph_precision'])).' '.$unit.' ; '.__('Max').': '.remove_right_zeros(number_format($graph_stats['min']['max'], $config['graph_precision'])).' '.$unit.' ; '.__('Min').': '.remove_right_zeros(number_format($graph_stats['min']['min'], $config['graph_precision'])).' '.$unit; + } + else if ($dashboard) { $legend['sum'.$series_suffix] = __('Last') . ': ' . remove_right_zeros(number_format($graph_stats['sum']['last'], $config['graph_precision'])) . ($unit ? ' ' . $unit : '') . ' ; ' . __('Avg') . ': ' . remove_right_zeros(number_format($graph_stats['sum']['avg'], $config['graph_precision'])) . ($unit ? ' ' . $unit : ''); @@ -762,12 +845,6 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, else { $legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Avg').': '.remove_right_zeros(number_format($graph_stats['sum']['avg'], $config['graph_precision'])).' '.$unit.' ; '.__('Max').': '.remove_right_zeros(number_format($graph_stats['sum']['max'], $config['graph_precision'])).' '.$unit.' ; '.__('Min').': '.remove_right_zeros(number_format($graph_stats['sum']['min'], $config['graph_precision'])).' '.$unit; } - //Baseline was replaced by compare graph feature - /*if ($baseline) { - $legend['baseline'.$series_suffix] = __('Baseline'); - }*/ - //$legend['no_data'.$series_suffix] = __('No data').$series_suffix_str; - //$chart_extra_data['legend_no_data'] = $legend['no_data'.$series_suffix_str]; if ($show_unknown) { $legend['unknown'.$series_suffix] = __('Unknown').$series_suffix_str; @@ -790,7 +867,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $only_image = false, $homeurl = '', $ttl = 1, $projection = false, $adapt_key = '', $compare = false, $show_unknown = false, $menu = true, $backgroundColor = 'white', $percentil = null, - $dashboard = false, $vconsole = false, $type_graph = 'area') { + $dashboard = false, $vconsole = false, $type_graph = 'area', $fullscale = false, + $id_widget_dashboard = false) { global $config; global $graphic_type; @@ -820,7 +898,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $show_alerts, $avg_only, $date-$period, $unit, $baseline, $return_data, $show_title, $projection, $adapt_key, $compare, $series_suffix, $series_suffix_str, - $show_unknown, $percentil, $dashboard, $vconsole,$type_graph); + $show_unknown, $percentil, $dashboard, $vconsole,$type_graph, + $fullscale); switch ($compare) { case 'separated': @@ -853,9 +932,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $show_alerts, $avg_only, $date, $unit, $baseline, $return_data, $show_title, $projection, $adapt_key, $compare, '', '', $show_unknown, - $percentil, $dashboard, $vconsole,$type_graph); - - + $percentil, $dashboard, $vconsole, $type_graph, $fullscale); + if ($return_data) { return $data_returned; } @@ -906,6 +984,13 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, } else { // Color commented not to restrict serie colors + if($id_widget_dashboard){ + $opcion = unserialize(db_get_value_filter('options','twidget_dashboard',array('id' => $id_widget_dashboard))); + $color['min']['color'] = $opcion['min']; + $color['sum']['color'] = $opcion['avg']; + $color['max']['color'] = $opcion['max']; + } + return area_graph($flash_chart, $chart, $width, $height, $color, $legend, $long_index, @@ -923,13 +1008,13 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, line_graph($flash_chart, $chart, $width, $height/2, $color, $legend, $long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", $unit, $water_mark, $config['fontpath'], + $title, $unit, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor). '
    '. line_graph($flash_chart, $chart_prev, $width, $height/2, $color, $legend, $long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", $unit, $water_mark, $config['fontpath'], + $title, $unit, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor); } else { @@ -938,7 +1023,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, line_graph($flash_chart, $chart, $width, $height, $color, $legend, $long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", $unit, $water_mark, $config['fontpath'], + $title, $unit, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor); } } @@ -992,7 +1077,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, $prediction_period = false, $background_color = 'white', $name_list = array(), $unit_list = array(), $show_last = true, $show_max = true, $show_min = true, $show_avg = true, $labels = array(), $dashboard = false, - $vconsole = false, $percentil = null, $from_interface = false) { + $vconsole = false, $percentil = null, $from_interface = false, $id_widget_dashboard=false) { global $config; global $graphic_type; @@ -1007,21 +1092,29 @@ function graphic_combined_module ($module_list, $weight_list, $period, // Set the title and time format if ($temp_range <= SECONDS_1DAY) { - $time_format = 'd.m.Y H:i:s'; + $time_format = 'Y M d H:i:s'; } elseif ($temp_range < SECONDS_15DAYS) { - $time_format = 'M d'; + $time_format = 'Y M d'; $time_format_2 = 'H:i'; if ($projection != false) { $time_format_2 = 'H\h'; } } elseif ($temp_range <= SECONDS_1MONTH) { - $time_format = 'M d'; + $time_format = 'Y M d'; $time_format_2 = 'H\h'; - } + } + elseif ($temp_range <= SECONDS_1MONTH) { + $time_format = 'Y M d'; + $time_format_2 = 'H\h'; + } + elseif ($period < SECONDS_6MONTHS) { + $time_format = 'Y M d'; + $time_format_2 = 'H\h'; + } else { - $time_format = 'M d'; + $time_format = "Y M d"; $time_format_2 = 'H\h'; } @@ -1040,7 +1133,6 @@ function graphic_combined_module ($module_list, $weight_list, $period, while ($in_range) { $timestamp_f = graph_get_formatted_date($j, $time_format, $time_format_2); - //$timestamp_f = date('d M Y H:i:s', $j); $before_projection[$timestamp_f] = 0; if ($j > $date) { @@ -1290,7 +1382,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, // Calculate chart data $last_known = $previous_data; - for ($l = 0; $l < $resolution; $l++) { + + for ($l = 0; $l <= $resolution; $l++) { $countAvg ++; $timestamp = $datelimit + ($interval * $l); @@ -1306,6 +1399,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, // Read data that falls in the current interval $interval_min = $last_known; $interval_max = $last_known; + while (isset ($data[$j]) && $data[$j]['utimestamp'] >= $timestamp && $data[$j]['utimestamp'] < ($timestamp + $interval)) { if ($data[$j]['datos'] > $interval_max) { $interval_max = $data[$j]['datos']; @@ -1423,9 +1517,6 @@ function graphic_combined_module ($module_list, $weight_list, $period, if (!empty($unit_list) && $units_number == $module_number && isset($unit_list[$i])) { $unit = $unit_list[$i]; } - else { - $unit = modules_get_unit($agent_module_id); - } if ($projection == false or ($projection != false and $i == 0)) { $module_name_list[$i] .= ": "; @@ -1765,22 +1856,12 @@ function graphic_combined_module ($module_list, $weight_list, $period, $graph_values = $temp; - /* - for ($i = 0; $i < $module_number; $i++) { - if ($weight_list[$i] != 1) { - $module_name_list[$i] .= " (x". format_numeric ($weight_list[$i], 1).")"; - } - } - */ - if($config["fixed_graph"] == false){ $water_mark = array( 'file' => $config['homedir'] . "/images/logo_vertical_water.png", 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)); } - - //Work around for fixed the agents name with huge size chars. $fixed_font_size = $config['font_size']; @@ -1833,6 +1914,15 @@ function graphic_combined_module ($module_list, $weight_list, $period, $color[15] = array('border' => '#000000', 'color' => COL_GRAPH13, 'alpha' => CHART_DEFAULT_ALPHA); + + if($id_widget_dashboard){ + $opcion = unserialize(db_get_value_filter('options','twidget_dashboard',array('id' => $id_widget_dashboard))); + foreach ($module_list as $key => $value) { + if(!empty($opcion[$value])){ + $color[$key]['color'] = $opcion[$value]; + } + } + } $threshold_data = array(); @@ -2304,10 +2394,9 @@ function progress_bar($progress, $width, $height, $title = '', $mode = 1, $value require_once("include_graph_dependencies.php"); include_graphs_dependencies($config['homedir'].'/'); - $src = ui_get_full_url( "/include/graphs/fgraph.php?homeurl=../../&graph_type=progressbar" . - "&width=".$width."&height=".$height."&progress=".$progress. + "&width=".$width."&homedir=".$config['homedir']."&height=".$height."&progress=".$progress. "&mode=" . $mode . "&out_of_lim_str=".$out_of_lim_str . "&title=".$title."&font=".$config['fontpath']."&value_text=". $value_text . "&colorRGB=". $colorRGB, false, false, false @@ -3383,6 +3472,12 @@ function graph_custom_sql_graph ($id, $width, $height, global $config; $report_content = db_get_row ('treport_content', 'id_rc', $id); + if($id != null){ + $historical_db = db_get_value_sql("SELECT historical_db from treport_content where id_rc =".$id); + } + else{ + $historical_db = $content['historical_db']; + } if ($report_content["external_source"] != "") { $sql = io_safe_output ($report_content["external_source"]); } @@ -3414,8 +3509,9 @@ function graph_custom_sql_graph ($id, $width, $height, break; } + $data_result = db_get_all_rows_sql ($sql,$historical_db); + - $data_result = db_get_all_rows_sql ($sql); if (($config['metaconsole'] == 1) && defined('METACONSOLE')) enterprise_hook('metaconsole_restore_db'); @@ -3439,17 +3535,16 @@ function graph_custom_sql_graph ($id, $width, $height, switch ($type) { case 'sql_graph_vbar': // vertical bar case 'sql_graph_hbar': // horizontal bar - $data[$label]['g'] = $value; + $data[$label."_".$count]['g'] = $value; break; case 'sql_graph_pie': // Pie - $data[$label] = $value; + $data[$label."_".$count] = $value; break; } } $flash_charts = $config['flash_charts']; - - + if ($only_image) { $flash_charts = false; } @@ -3488,7 +3583,7 @@ function graph_custom_sql_graph ($id, $width, $height, * @param string homeurl * @param bool return or echo the result */ -function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $homeurl, $return = false) { +function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $homeurl, $return = false, $from_agent_view = false) { global $config; global $graphic_type; @@ -3505,13 +3600,119 @@ function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $ho $data = array (); $legend = array(); $full_legend = array(); + $full_legend_date = array(); $cont = 0; for ($i = 0; $i < $interval; $i++) { $bottom = $datelimit + ($periodtime * $i); if (! $graphic_type) { if ($config['flash_charts']) { - $name = date('H:i', $bottom); + $name = date('H:i:s', $bottom); + } + else { + $name = date('H\h', $bottom); + } + } + else { + $name = $bottom; + } + + // Show less values in legend + if ($cont == 0 or $cont % 2) + $legend[$cont] = $name; + + if ($from_agent_view) { + $full_date = date('Y/m/d', $bottom); + $full_legend_date[$cont] = $full_date; + } + + $full_legend[$cont] = $name; + + $top = $datelimit + ($periodtime * ($i + 1)); + $event = db_get_row_filter ('tevento', + array ('id_agente' => $id_agent, + 'utimestamp > '.$bottom, + 'utimestamp < '.$top), 'criticity, utimestamp'); + + if (!empty($event['utimestamp'])) { + $data[$cont]['utimestamp'] = $periodtime; + switch ($event['criticity']) { + case EVENT_CRIT_WARNING: + $data[$cont]['data'] = 2; + break; + case EVENT_CRIT_CRITICAL: + $data[$cont]['data'] = 3; + break; + default: + $data[$cont]['data'] = 1; + break; + } + } + else { + $data[$cont]['utimestamp'] = $periodtime; + $data[$cont]['data'] = 1; + } + $cont++; + } + + $colors = array(1 => COL_NORMAL, 2 => COL_WARNING, 3 => COL_CRITICAL, 4 => COL_UNKNOWN); + + // Draw slicebar graph + if ($config['flash_charts']) { + $out = flot_slicesbar_graph($data, $period, $width, $height, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', '', false, $id_agent, $full_legend_date); + } + else { + $out = slicesbar_graph($data, $period, $width, $height, $colors, $config['fontpath'], $config['round_corner'], $homeurl); + + // Draw legend + $out .= "
    "; + $out .= " "; + foreach ($legend as $hour) { + $out .= "" . $hour . ""; + $out .= " "; + } + } + + if ($return) { + return $out; + } + else { + echo $out; + } +} + +/** + * Print a static graph with event data of agents + * + * @param integer id_agent Agent ID + * @param integer width pie graph width + * @param integer height pie graph height + * @param integer period time period + * @param string homeurl + * @param bool return or echo the result + */ +function graph_graphic_moduleevents ($id_agent, $id_module, $width, $height, $period = 0, $homeurl, $return = false) { + global $config; + global $graphic_type; + + $data = array (); + + $resolution = $config['graph_res'] * ($period * 2 / $width); // Number of "slices" we want in graph + $interval = (int) ($period / $resolution); + $date = get_system_time (); + $datelimit = $date - $period; + $periodtime = floor ($period / $interval); + $time = array (); + $data = array (); + $legend = array(); + $full_legend = array(); + + $cont = 0; + for ($i = 0; $i < $interval; $i++) { + $bottom = $datelimit + ($periodtime * $i); + if (! $graphic_type) { + if ($config['flash_charts']) { + $name = date('H:i:s', $bottom); } else { $name = date('H\h', $bottom); @@ -3528,11 +3729,13 @@ function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $ho $full_legend[$cont] = $name; $top = $datelimit + ($periodtime * ($i + 1)); + $event = db_get_row_filter ('tevento', array ('id_agente' => $id_agent, + 'id_agentmodule' => $id_module, 'utimestamp > '.$bottom, 'utimestamp < '.$top), 'criticity, utimestamp'); - + if (!empty($event['utimestamp'])) { $data[$cont]['utimestamp'] = $periodtime; switch ($event['criticity']) { @@ -3589,7 +3792,8 @@ function fs_error_image ($width = 300, $height = 110) { function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $unit_name, $show_alerts, $avg_only = 0, - $date = 0, $series_suffix = '', $series_suffix_str = '', $show_unknown = false) { + $date = 0, $series_suffix = '', $series_suffix_str = '', $show_unknown = false, + $fullscale = false) { global $config; global $chart; @@ -3598,8 +3802,7 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, global $long_index; global $series_type; global $chart_extra_data; - - + $chart = array(); $color = array(); $legend = array(); @@ -3646,13 +3849,30 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, } } - // Get module data - $data = db_get_all_rows_filter ('tagente_datos', - array ('id_agente_modulo' => $agent_module_id, - "utimestamp > $datelimit", - "utimestamp < $date", - 'order' => 'utimestamp ASC'), - array ('datos', 'utimestamp'), 'AND', $search_in_history_db); + if ($fullscale) { + // Get module data + $data = db_get_all_rows_filter ('tagente_datos', + array ('id_agente_modulo' => $agent_module_id, + "utimestamp > $datelimit", + "utimestamp < $date", + 'order' => 'utimestamp ASC'), + array ('datos', 'utimestamp'), 'AND', true); + + if (count($data) > $resolution) { + $resolution = count($data); //Number of points of the graph + $interval = (int) ($period / $resolution); + } + } + else { + // Get module data + $data = db_get_all_rows_filter ('tagente_datos', + array ('id_agente_modulo' => $agent_module_id, + "utimestamp > $datelimit", + "utimestamp < $date", + 'order' => 'utimestamp ASC'), + array ('datos', 'utimestamp'), 'AND', $search_in_history_db); + } + if ($data === false) { $data = array (); } @@ -3717,11 +3937,34 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, } $max_value = 0; + + if ($fullscale) { + $data2 = array(); + $previus_datas_cont = -1; + $k = 0; + for ($i = 0; $i <= $resolution; $i++) { + $timestamp = $datelimit + ($interval * $i); + + if ($timestamp < $data[0]['utimestamp']) { + $previus_datas_cont++; + $data2[$k]['utimestamp'] = $timestamp; + $data2[$k]['datos'] = 0; + $k++; + } + } + + $data = array_merge($data2, $data); + $resolution += $previus_datas_cont; + } // Calculate chart data $last_known = $previous_data; for ($i = 0; $i <= $resolution; $i++) { $timestamp = $datelimit + ($interval * $i); + + if ($fullscale && ($resolution > ($config['graph_res'] * 50))) { + $timestamp = $data[$i]['utimestamp']; + } $zero = 0; $total = 0; @@ -3802,7 +4045,7 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, } elseif ($period < SECONDS_1MONTH) { $time_format = 'M d H\h'; - } + } else { $time_format = 'M d H\h'; } @@ -3810,7 +4053,9 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $timestamp_short = date($time_format, $timestamp); $long_index[$timestamp_short] = date( html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp); - $timestamp = $timestamp_short; + if (!$fullscale) { + $timestamp = $timestamp_short; + } ///////////////////////////////////////////////////////////////// if ($total > $max_value) { @@ -3834,13 +4079,6 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $series_type['alert'.$series_suffix] = 'points'; } - //The order filling the array is very important to get the same colors - //in legends and graphs!!! - //Boolean graph doesn't have max!!! - /*if (!$avg_only) { - $chart[$timestamp]['max'.$series_suffix] = 0; - }*/ - // Data and zeroes (draw a step) if ($zero == 1 && $count > 0) { @@ -3875,11 +4113,6 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $series_type['sum' . $series_suffix] = 'boolean'; - //Boolean graph doesn't have min!!! - /*if (!$avg_only) { - $chart[$timestamp]['min'.$series_suffix] = 0; - }*/ - if (!empty($event_ids)) { $chart_extra_data[count($chart)-1]['events'] = implode(',',$event_ids); } @@ -3925,6 +4158,9 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, elseif ($period < SECONDS_1MONTH) { $time_format = 'M d H\h'; } + elseif ($period < SECONDS_6MONTHS) { + $time_format = "M d H\h"; + } else { $time_format = 'M d H\h'; } @@ -3943,17 +4179,7 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $chart_extra_data['legend_alerts'] = $legend['alert'.$series_suffix]; } - if (!$avg_only) { - //Boolean graph doesn't have max!!! - //$legend['max'.$series_suffix] = __('Max').$series_suffix_str .': '.__('Last').': '.$graph_stats['max']['last'].' '.$unit.' ; '.__('Avg').': '.$graph_stats['max']['avg'].' '.$unit.' ; '.__('Max').': '.$graph_stats['max']['max'].' '.$unit.' ; '.__('Min').': '.$graph_stats['max']['min'].' '.$unit; - $legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Last').': '.remove_right_zeros(number_format($graph_stats['sum']['last'], $config['graph_precision'])).' '.$unit.' ; '.__('Avg').': '.remove_right_zeros(number_format($graph_stats['sum']['avg'], $config['graph_precision'])).' '.$unit.' ; '.__('Max').': '.remove_right_zeros(number_format($graph_stats['sum']['max'], $config['graph_precision'])).' '.$unit.' ; '.__('Min').': '.remove_right_zeros(number_format($graph_stats['sum']['min'], $config['graph_precision'])).' '.$unit; - // Boolean graph doesn't have min!!! - // $legend['min'.$series_suffix] = __('Min').$series_suffix_str .': '.__('Last').': '.number_format($graph_stats['min']['last'], $config['graph_precision']).' '.$unit.' ; '.__('Avg').': '.number_format($graph_stats['min']['avg'], $config['graph_precision']).' '.$unit.' ; '.__('Max').': '.number_format($graph_stats['min']['max'], $config['graph_precision']).' '.$unit.' ; '.__('Min').': '.number_format($graph_stats['min']['min'], $config['graph_precision']).' '.$unit; - } - else { - $legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Last').': '.remove_right_zeros(number_format($graph_stats['sum']['last'], $config['graph_precision'])).' '.$unit.' ; '.__('Avg').': '.remove_right_zeros(number_format($graph_stats['sum']['avg'], $config['graph_precision'])).' '.$unit.' ; '.__('Max').': '.remove_right_zeros(number_format($graph_stats['sum']['max'], $config['graph_precision'])).' '.$unit.' ; '.__('Min').': '.remove_right_zeros(number_format($graph_stats['sum']['min'], $config['graph_precision'])).' '.$unit; - - } + $legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Last').': '.remove_right_zeros(number_format($graph_stats['sum']['last'], $config['graph_precision'])).' '.$unit.' ; '.__('Avg').': '.remove_right_zeros(number_format($graph_stats['sum']['avg'], $config['graph_precision'])).' '.$unit.' ; '.__('Max').': '.remove_right_zeros(number_format($graph_stats['sum']['max'], $config['graph_precision'])).' '.$unit.' ; '.__('Min').': '.remove_right_zeros(number_format($graph_stats['sum']['min'], $config['graph_precision'])).' '.$unit; if ($show_unknown) { $legend['unknown'.$series_suffix] = __('Unknown').$series_suffix_str; @@ -3985,13 +4211,12 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, array('border' => '#999999', 'color' => '#999999', 'alpha' => CHART_DEFAULT_ALPHA); } - //$color['baseline'.$series_suffix] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10); } function grafico_modulo_boolean ($agent_module_id, $period, $show_events, $width, $height , $title='', $unit_name, $show_alerts, $avg_only = 0, $pure=0, $date = 0, $only_image = false, $homeurl = '', $adapt_key = '', $compare = false, - $show_unknown = false, $menu = true) { + $show_unknown = false, $menu = true, $fullscale = false) { global $config; global $graphic_type; @@ -4012,7 +4237,6 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, else $unit = $unit_name; - $series_suffix_str = ''; if ($compare !== false) { $series_suffix = '2'; @@ -4020,7 +4244,7 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, // Build the data of the previous period grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $unit_name, $show_alerts, $avg_only, $date-$period, $series_suffix, - $series_suffix_str, $show_unknown); + $series_suffix_str, $show_unknown, $fullscale); switch ($compare) { case 'separated': // Store the chart calculated @@ -4046,7 +4270,28 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, } grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, - $unit_name, $show_alerts, $avg_only, $date, '', '', $show_unknown); + $unit_name, $show_alerts, $avg_only, $date, '', '', $show_unknown, $fullscale); + + if ($fullscale) { + if (!$flash_chart) { + $time_format = "Y M \nd H:i:s"; + } + else { + $time_format = "Y M d H:i:s"; + } + + $new_chart = array(); + $new_long_index = array(); + foreach ($chart as $c_timestamp => $c_data) { + $timestamp_short = date($time_format, $c_timestamp); + $new_long_index[$timestamp_short] = date( + html_entity_decode($time_format, ENT_QUOTES, "UTF-8"), $c_timestamp); + $new_chart[$timestamp_short] = $c_data; + } + + $long_index = $new_long_index; + $chart = $new_chart; + } if ($compare === 'overlapped') { $i = 0; @@ -4112,7 +4357,7 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, line_graph($flash_chart, $chart, $width, $height, $color, $legend, $long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", $unit, $water_mark, $config['fontpath'], + $title, $unit, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor); } } @@ -4145,8 +4390,11 @@ function graph_netflow_aggregate_area ($data, $period, $width, $height, $unit = elseif ($period < SECONDS_1MONTH) { $chart_time_format = 'M d H\h'; } + elseif ($period < SECONDS_6MONTHS) { + $chart_time_format = "M d H\h"; + } else { - $chart_time_format = 'M d H\h'; + $chart_time_format = "Y M d H\h"; } // Calculate source indexes @@ -4271,8 +4519,11 @@ function graph_netflow_total_area ($data, $period, $width, $height, $unit = '', elseif ($period < SECONDS_1MONTH) { $chart_time_format = 'M d H\h'; } - else { - $chart_time_format = 'M d H\h'; + elseif ($period < SECONDS_6MONTHS) { + $chart_time_format = "M d H\h"; + } + else { + $chart_time_format = "Y M d H\h"; } // Calculate min, max and avg values @@ -4567,8 +4818,11 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events, elseif ($period < SECONDS_1MONTH) { $time_format = 'M d H\h'; } + elseif ($period < SECONDS_6MONTHS) { + $time_format = "M d H\h"; + } else { - $time_format = 'M d H\h'; + $time_format = "Y M d H\h"; } $timestamp_short = date($time_format, $timestamp); @@ -4686,7 +4940,7 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events, if ($type_graph === 'area') { return area_graph($flash_chart, $chart, $width, $height, $color, - $legend, array(), '', "", $unit, $homeurl, + $legend, array(), '', $title, $unit, $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, 1, array(), array(), 0, 0, $adapt_key, true, '', $menu); } @@ -4695,7 +4949,7 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events, line_graph($flash_chart, $chart, $width, $height, $color, $legend, $long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", $unit, $water_mark, $config['fontpath'], + $title, $unit, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor); } } @@ -4742,8 +4996,11 @@ function graphic_module_events ($id_module, $width, $height, $period = 0, $homeu elseif ($period < SECONDS_1MONTH) { $time_format = 'M d H\h'; } - else { - $time_format = 'M d H\h'; + elseif ($period < SECONDS_6MONTHS) { + $time_format = "M d H\h"; + } + else { + $time_format = "Y M d H\h"; } $legend = array(); @@ -5586,4 +5843,4 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { return d3_sunburst_graph ($graph_data, $width, $height, true); } -?> +?> \ No newline at end of file diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 2af6eebf8e..3de688c84a 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -385,13 +385,28 @@ function html_print_select_groups($id_user = false, $privilege = "AR", $nothing = '', $nothing_value = 0, $return = false, $multiple = false, $sort = true, $class = '', $disabled = false, $style = false, $option_style = false, $id_group = false, - $keys_field = 'id_grupo', $strict_user = false) { + $keys_field = 'id_grupo', $strict_user = false, $delete_groups = false , $include_groups = false) { global $config; $fields = users_get_groups_for_select($id_user, $privilege, $returnAllGroup, true, $id_group, $keys_field); + + if ($delete_groups && is_array($delete_groups)){ + foreach ($delete_groups as $value) { + unset($fields[$value]); + } + } + + if (is_array($include_groups)){ + $field = array(); + foreach ($include_groups as $value) { + $field[$value] = $fields[$value]; + } + $fields = array_intersect($fields, $field); + } + if ($strict_user) { $fields = users_get_strict_mode_groups($config['id_user'], $returnAllGroup); } @@ -609,7 +624,7 @@ function html_print_select_from_sql ($sql, $name, $selected = '', function html_print_extended_select_for_post_process($name, $selected = '', $script = '', $nothing = '', $nothing_value = '0', $size = false, $return = false, $select_style = false, $unique_name = true, - $disabled = false) { + $disabled = false, $no_change = 0) { global $config; @@ -617,6 +632,10 @@ function html_print_extended_select_for_post_process($name, $selected = '', $fields = post_process_get_custom_values(); + if($no_change != 0){ + $fields[-1] = __('No change'); + } + $selected_float = (float)$selected; $found = false; @@ -700,12 +719,17 @@ function html_print_extended_select_for_post_process($name, $selected = '', function html_print_extended_select_for_time ($name, $selected = '', $script = '', $nothing = '', $nothing_value = '0', $size = false, $return = false, $select_style = false, $unique_name = true, $class='', - $readonly = false) { + $readonly = false, $custom_fields = false,$style_icon = '') { global $config; - $fields = get_periods(); - + if($custom_fields){ + $fields = $custom_fields; + } else { + $fields = get_periods(); + } + + if ( ! $selected ) { foreach( $fields as $t_key => $t_value){ if ( $t_key != -1 ) { @@ -737,7 +761,7 @@ function html_print_extended_select_for_time ($name, $selected = '', if (!is_user_admin($config['id_user'])) { unset($fields[-1]); - $returnString = html_print_select ($fields, $name, $selected,"" . $script, + $returnString = html_print_select ($fields, $name . '_select', $selected,"" . $script, $nothing, $nothing_value, true, false, false, '', false, 'font-size: xx-small;'.$select_style); if ($return) { @@ -770,7 +794,7 @@ function html_print_extended_select_for_time ($name, $selected = '', array('class' => $uniq_name . '_toggler', 'alt' => __('Custom'), 'title' => __('Custom'), - 'style' => 'width: 18px;'), false, false, true) . + 'style' => 'width: 18px;'.$style_icon), false, false, true) . ''; echo ''; @@ -784,7 +808,7 @@ function html_print_extended_select_for_time ($name, $selected = '', html_print_image('images/default_list.png', true, array('class' => $uniq_name . '_toggler', 'alt' => __('List'), - 'title' => __('List'), 'style' => 'width: 18px;')) . + 'title' => __('List'), 'style' => 'width: 18px;'.$style_icon)) . ''; echo ''; echo " diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index c951576511..de10fcaf91 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -660,6 +660,28 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, return $output; } +function ui_print_type_agent_icon ( $id_os = false, $remote_contact = false, $contact = false, + $return = false, $remote = 0, $version = ""){ + + if($id_os == 19){ + //Satellite + $options['title'] = __('Satellite'); + $output = html_print_image("images/op_satellite.png", true, $options, false, false, false, true); + } + else if ($remote_contact == $contact && $remote == 0 && $version == ""){ + //Network + $options['title'] = __('Network'); + $output = html_print_image("images/network.png", true, $options, false, false, false, true); + } + else{ + //Software + $options['title'] = __('Software'); + $output = html_print_image("images/data.png", true, $options, false, false, false, true); + } + + return $output; +} + /** * Prints an agent name with the correct link * @@ -1068,6 +1090,8 @@ function ui_print_alert_template_example ($id_alert_template, $return = false, $ * @return string The help tip */ function ui_print_help_icon ($help_id, $return = false, $home_url = '', $image = "images/help.png") { + global $config; + if (empty($home_url)) $home_url = ""; @@ -1078,7 +1102,7 @@ function ui_print_help_icon ($help_id, $return = false, $home_url = '', $image = $output = html_print_image ($image, true, array ("class" => "img_help", "title" => __('Help'), - "onclick" => "open_help ('" . $help_id . "','" . $home_url . "')")); + "onclick" => "open_help ('" . $help_id . "','" . $home_url . "','" . $config['id_user'] . "')")); if (!$return) echo $output; @@ -1298,8 +1322,8 @@ function ui_process_page_head ($string, $bitfield) { $_GET['sec2'] == 'enterprise/dashboard/main_dashboard') { $query = ui_get_url_refresh (false, false); - $output .= ''; + //$output .= ''; } } @@ -1583,6 +1607,7 @@ function ui_process_page_body ($string, $bitfield) { * @param bool $return Whether to return or print this * @param string $offset_name The name of parameter for the offset. * @param bool $print_total_items Show the text with the total items. By default true. + * @param string $set_id Set id of div. * * @return string The pagination div or nothing if no pagination needs to be done */ @@ -1590,7 +1615,7 @@ function ui_pagination ($count, $url = false, $offset = 0, $pagination = 0, $return = false, $offset_name = 'offset', $print_total_items = true, $other_class = '', $script = "", - $parameter_script = array('count' => '', 'offset' => 'offset_param')) { + $parameter_script = array('count' => '', 'offset' => 'offset_param'), $set_id = '') { global $config; @@ -1611,6 +1636,23 @@ function ui_pagination ($count, $url = false, $offset = 0, $url = ui_get_url_refresh (array ($offset_name => false)); } + if(!empty($set_id)){ + $set_id= " id = '$set_id'"; + } + + // Pagination links for users include delete, create and other params, now not use these params, and not retry the previous action when go to pagination link. + + $remove = array("user_del","disable_user","delete_user"); + $url = explode("&",$url); + + $finalUrl = array(); + foreach ($url as $key => $value) { + if(strpos($value, $remove[0]) === false && strpos($value, $remove[1]) === false && strpos($value, $remove[2]) === false){ + array_push($finalUrl,$value); + } + } + $url = implode("&",$finalUrl); + /* URL passed render links with some parameter &offset - Offset records passed to next page @@ -1622,7 +1664,7 @@ function ui_pagination ($count, $url = false, $offset = 0, if ($count <= $pagination) { if ($print_total_items) { - $output = "