mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Compare commits
67 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2696a9c5e7 | ||
|
|
7c170972a0 | ||
|
|
d00dfd82c1 | ||
|
|
9003139119 | ||
|
|
36e867ec76 | ||
|
|
cf4813979c | ||
|
|
7e12c3eff1 | ||
|
|
281cc985bf | ||
|
|
dcc2be0781 | ||
|
|
161d076bfd | ||
|
|
09fbcc9a72 | ||
|
|
ee2b92cf82 | ||
|
|
720914b290 | ||
|
|
16f8e54ed7 | ||
|
|
50ecb63058 | ||
|
|
586650f01c | ||
|
|
ae753e6e88 | ||
|
|
04a2845e91 | ||
|
|
acb20d95ca | ||
|
|
d3ebe1844d | ||
|
|
fc8492e8f7 | ||
|
|
ff5ffd0482 | ||
|
|
50db6d0150 | ||
|
|
2e0b854428 | ||
|
|
1dfb44cff7 | ||
|
|
0a8fad2040 | ||
|
|
9b97d3ac8a | ||
|
|
26e78c0c1b | ||
|
|
b036e8d3c2 | ||
|
|
f84a904ad8 | ||
|
|
b1684037d6 | ||
|
|
1c85d0b38a | ||
|
|
ec3434cf1d | ||
|
|
0e20f6d454 | ||
|
|
d92d208a45 | ||
|
|
b798e28bfb | ||
|
|
ebd6077cd7 | ||
|
|
9e9500dfa9 | ||
|
|
04cc100fba | ||
|
|
31e33f99f2 | ||
|
|
7c51b90586 | ||
|
|
2b36f73da6 | ||
|
|
d96dd473b8 | ||
|
|
f9066ffb7b | ||
|
|
945941d529 | ||
|
|
10e875e899 | ||
|
|
d24e5c938e | ||
|
|
aa069a336f | ||
|
|
662fc2ee9d | ||
|
|
567cd6ef68 | ||
|
|
887a050db9 | ||
|
|
bda895eaae | ||
|
|
2e49c06f47 | ||
|
|
ae137847b4 | ||
|
|
5443dc50a3 | ||
|
|
fc435a2541 | ||
|
|
04394750e7 | ||
|
|
e415a1351b | ||
|
|
6ec907a915 | ||
|
|
1f55f01fa9 | ||
|
|
5d79b88875 | ||
|
|
458890b4b9 | ||
|
|
89267f792d | ||
|
|
b183fcca05 | ||
|
|
684a57dbc0 | ||
|
|
400086a5c8 | ||
|
|
da6cf8dbb4 |
4
Rakefile
4
Rakefile
@@ -3,9 +3,7 @@ require 'rake/testtask'
|
||||
|
||||
task :default => :test
|
||||
|
||||
Rake::TestTask.new do |t|
|
||||
t.warning = true
|
||||
end
|
||||
Rake::TestTask.new
|
||||
|
||||
task :samples do
|
||||
require 'linguist/samples'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Gem::Specification.new do |s|
|
||||
s.name = 'github-linguist'
|
||||
s.version = '2.3.0'
|
||||
s.version = '2.4.0'
|
||||
s.summary = "GitHub Language detection"
|
||||
|
||||
s.authors = "GitHub"
|
||||
@@ -11,7 +11,8 @@ Gem::Specification.new do |s|
|
||||
s.add_dependency 'charlock_holmes', '~> 0.6.6'
|
||||
s.add_dependency 'escape_utils', '~> 0.2.3'
|
||||
s.add_dependency 'mime-types', '~> 1.19'
|
||||
s.add_dependency 'pygments.rb', '>= 0.2.13'
|
||||
s.add_dependency 'pygments.rb', '>= 0.3.0'
|
||||
s.add_development_dependency 'mocha'
|
||||
s.add_development_dependency 'json'
|
||||
s.add_development_dependency 'rake'
|
||||
s.add_development_dependency 'yajl-ruby'
|
||||
|
||||
@@ -160,7 +160,7 @@ module Linguist
|
||||
#
|
||||
# Return true or false
|
||||
def safe_to_colorize?
|
||||
text? && !large? && !high_ratio_of_long_lines?
|
||||
!large? && text? && !high_ratio_of_long_lines?
|
||||
end
|
||||
|
||||
# Internal: Does the blob have a ratio of long lines?
|
||||
@@ -204,7 +204,31 @@ module Linguist
|
||||
#
|
||||
# Returns an Array of lines
|
||||
def lines
|
||||
@lines ||= (viewable? && data) ? data.split("\n", -1) : []
|
||||
@lines ||=
|
||||
if viewable? && data
|
||||
data.split(line_split_character, -1)
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
# Character used to split lines. This is almost always "\n" except when Mac
|
||||
# Format is detected in which case it's "\r".
|
||||
#
|
||||
# Returns a split pattern string.
|
||||
def line_split_character
|
||||
@line_split_character ||= (mac_format?? "\r" : "\n")
|
||||
end
|
||||
|
||||
# Public: Is the data in ** Mac Format **. This format uses \r (0x0d) characters
|
||||
# for line ends and does not include a \n (0x0a).
|
||||
#
|
||||
# Returns true when mac format is detected.
|
||||
def mac_format?
|
||||
return if !viewable?
|
||||
if pos = data[0, 4096].index("\r")
|
||||
data[pos + 1] != ?\n
|
||||
end
|
||||
end
|
||||
|
||||
# Public: Get number of lines of code
|
||||
@@ -250,7 +274,9 @@ module Linguist
|
||||
#
|
||||
# Return true or false
|
||||
def indexable?
|
||||
if binary?
|
||||
if size > 100 * 1024
|
||||
false
|
||||
elsif binary?
|
||||
false
|
||||
elsif extname == '.txt'
|
||||
true
|
||||
@@ -260,8 +286,6 @@ module Linguist
|
||||
false
|
||||
elsif generated?
|
||||
false
|
||||
elsif size > 100 * 1024
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
@@ -278,7 +302,7 @@ module Linguist
|
||||
if defined?(@data) && @data.is_a?(String)
|
||||
data = @data
|
||||
else
|
||||
data = lambda { binary_mime_type? ? "" : self.data }
|
||||
data = lambda { (binary_mime_type? || binary?) ? "" : self.data }
|
||||
end
|
||||
|
||||
@language = Language.detect(name.to_s, data, mode)
|
||||
|
||||
@@ -84,7 +84,9 @@ module Linguist
|
||||
|
||||
if possible_languages.length > 1
|
||||
data = data.call() if data.respond_to?(:call)
|
||||
if result = Classifier.classify(Samples::DATA, data, possible_languages.map(&:name)).first
|
||||
if data.nil? || data == ""
|
||||
nil
|
||||
elsif result = Classifier.classify(Samples::DATA, data, possible_languages.map(&:name)).first
|
||||
Language[result[0]]
|
||||
end
|
||||
else
|
||||
@@ -220,6 +222,7 @@ module Linguist
|
||||
raise(ArgumentError, "#{@name} is missing lexer")
|
||||
|
||||
@ace_mode = attributes[:ace_mode]
|
||||
@wrap = attributes[:wrap] || false
|
||||
|
||||
# Set legacy search term
|
||||
@search_term = attributes[:search_term] || default_alias_name
|
||||
@@ -310,6 +313,11 @@ module Linguist
|
||||
# Returns a String name or nil
|
||||
attr_reader :ace_mode
|
||||
|
||||
# Public: Should language lines be wrapped
|
||||
#
|
||||
# Returns true or false
|
||||
attr_reader :wrap
|
||||
|
||||
# Public: Get extensions
|
||||
#
|
||||
# Examples
|
||||
@@ -460,6 +468,7 @@ module Linguist
|
||||
:aliases => options['aliases'],
|
||||
:lexer => options['lexer'],
|
||||
:ace_mode => options['ace_mode'],
|
||||
:wrap => options['wrap'],
|
||||
:group_name => options['group'],
|
||||
:searchable => options.key?('searchable') ? options['searchable'] : true,
|
||||
:search_term => options['search_term'],
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
# aliases - An Array of additional aliases (implicitly
|
||||
# includes name.downcase)
|
||||
# ace_mode - A String name of Ace Mode (if available)
|
||||
# wrap - Boolean wrap to enable line wrapping (default: false)
|
||||
# extension - An Array of associated extensions
|
||||
# primary_extension - A String for the main extension associated with
|
||||
# the language. Must be unique. Used when a Language is picked
|
||||
@@ -62,6 +63,12 @@ Ada:
|
||||
- .adb
|
||||
- .ads
|
||||
|
||||
ApacheConf:
|
||||
type: markup
|
||||
aliases:
|
||||
- apache
|
||||
primary_extension: .apacheconf
|
||||
|
||||
Apex:
|
||||
type: programming
|
||||
lexer: Text only
|
||||
@@ -179,8 +186,10 @@ C++:
|
||||
- cpp
|
||||
primary_extension: .cpp
|
||||
extensions:
|
||||
- .C
|
||||
- .c++
|
||||
- .cxx
|
||||
- .H
|
||||
- .h++
|
||||
- .hh
|
||||
- .hxx
|
||||
@@ -243,6 +252,7 @@ CoffeeScript:
|
||||
color: "#244776"
|
||||
aliases:
|
||||
- coffee
|
||||
- coffee-script
|
||||
primary_extension: .coffee
|
||||
extensions:
|
||||
- ._coffee
|
||||
@@ -367,6 +377,14 @@ Ecere Projects:
|
||||
extensions:
|
||||
- .epj
|
||||
|
||||
Ecl:
|
||||
type: programming
|
||||
color: "#8a1267"
|
||||
primary_extension: .ecl
|
||||
lexer: ECL
|
||||
extensions:
|
||||
- .eclxml
|
||||
|
||||
Eiffel:
|
||||
type: programming
|
||||
lexer: Text only
|
||||
@@ -383,6 +401,12 @@ Elixir:
|
||||
- .ex
|
||||
- .exs
|
||||
|
||||
Elm:
|
||||
type: programming
|
||||
lexer: Haskell
|
||||
group: Haskell
|
||||
primary_extension: .elm
|
||||
|
||||
Emacs Lisp:
|
||||
type: programming
|
||||
lexer: Scheme
|
||||
@@ -536,6 +560,8 @@ Groovy Server Pages:
|
||||
HTML:
|
||||
type: markup
|
||||
ace_mode: html
|
||||
aliases:
|
||||
- xhtml
|
||||
primary_extension: .html
|
||||
extensions:
|
||||
- .htm
|
||||
@@ -554,6 +580,8 @@ HTML+ERB:
|
||||
type: markup
|
||||
group: HTML
|
||||
lexer: RHTML
|
||||
aliases:
|
||||
- erb
|
||||
primary_extension: .erb
|
||||
extensions:
|
||||
- .erb
|
||||
@@ -566,22 +594,20 @@ HTML+PHP:
|
||||
extensions:
|
||||
- .phtml
|
||||
|
||||
HaXe:
|
||||
type: programming
|
||||
lexer: haXe
|
||||
ace_mode: haxe
|
||||
color: "#346d51"
|
||||
primary_extension: .hx
|
||||
extensions:
|
||||
- .hx
|
||||
- .hxml
|
||||
- .mtt
|
||||
HTTP:
|
||||
type: data
|
||||
primary_extension: .http
|
||||
|
||||
Haml:
|
||||
group: HTML
|
||||
type: markup
|
||||
primary_extension: .haml
|
||||
|
||||
Handlebars:
|
||||
type: markup
|
||||
lexer: Text only
|
||||
primary_extension: .handlebars
|
||||
|
||||
Haskell:
|
||||
type: programming
|
||||
color: "#29b544"
|
||||
@@ -590,6 +616,15 @@ Haskell:
|
||||
- .hs
|
||||
- .hsc
|
||||
|
||||
Haxe:
|
||||
type: programming
|
||||
lexer: haXe
|
||||
ace_mode: haxe
|
||||
color: "#346d51"
|
||||
primary_extension: .hx
|
||||
extensions:
|
||||
- .hxsl
|
||||
|
||||
INI:
|
||||
type: data
|
||||
extensions:
|
||||
@@ -714,6 +749,8 @@ Lua:
|
||||
- .nse
|
||||
|
||||
Makefile:
|
||||
aliases:
|
||||
- make
|
||||
extensions:
|
||||
- .mak
|
||||
- .mk
|
||||
@@ -733,6 +770,7 @@ Markdown:
|
||||
type: markup
|
||||
lexer: Text only
|
||||
ace_mode: markdown
|
||||
wrap: true
|
||||
primary_extension: .md
|
||||
extensions:
|
||||
- .markdown
|
||||
@@ -788,6 +826,11 @@ Nemerle:
|
||||
color: "#0d3c6e"
|
||||
primary_extension: .n
|
||||
|
||||
Nginx:
|
||||
type: markup
|
||||
lexer: Nginx configuration file
|
||||
primary_extension: .nginxconf
|
||||
|
||||
Nimrod:
|
||||
type: programming
|
||||
color: "#37775b"
|
||||
@@ -833,6 +876,9 @@ ObjDump:
|
||||
Objective-C:
|
||||
type: programming
|
||||
color: "#438eff"
|
||||
aliases:
|
||||
- obj-c
|
||||
- objc
|
||||
primary_extension: .m
|
||||
extensions:
|
||||
- .mm
|
||||
@@ -840,6 +886,8 @@ Objective-C:
|
||||
Objective-J:
|
||||
type: programming
|
||||
color: "#ff0c5a"
|
||||
aliases:
|
||||
- obj-j
|
||||
primary_extension: .j
|
||||
extensions:
|
||||
- .j
|
||||
@@ -1114,10 +1162,6 @@ Shell:
|
||||
- bash
|
||||
- zsh
|
||||
primary_extension: .sh
|
||||
filenames:
|
||||
- .zsh
|
||||
- bashrc
|
||||
- zshrc
|
||||
|
||||
Smalltalk:
|
||||
type: programming
|
||||
@@ -1162,6 +1206,8 @@ Tcsh:
|
||||
TeX:
|
||||
type: markup
|
||||
ace_mode: latex
|
||||
aliases:
|
||||
- latex
|
||||
primary_extension: .tex
|
||||
extensions:
|
||||
- .aux
|
||||
@@ -1180,6 +1226,7 @@ Textile:
|
||||
type: markup
|
||||
lexer: Text only
|
||||
ace_mode: textile
|
||||
wrap: true
|
||||
primary_extension: .textile
|
||||
extensions:
|
||||
- .textile
|
||||
@@ -1250,6 +1297,11 @@ Visual Basic:
|
||||
XML:
|
||||
type: markup
|
||||
ace_mode: xml
|
||||
aliases:
|
||||
- rss
|
||||
- xsd
|
||||
- xsl
|
||||
- wsdl
|
||||
primary_extension: .xml
|
||||
extensions:
|
||||
- .glade
|
||||
@@ -1295,6 +1347,8 @@ XSLT:
|
||||
|
||||
YAML:
|
||||
type: markup
|
||||
aliases:
|
||||
- yml
|
||||
primary_extension: .yml
|
||||
extensions:
|
||||
- .yaml
|
||||
@@ -1324,6 +1378,7 @@ ooc:
|
||||
|
||||
reStructuredText:
|
||||
type: markup
|
||||
wrap: true
|
||||
search_term: rst
|
||||
aliases:
|
||||
- rst
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -76,12 +76,14 @@ module Linguist
|
||||
db['extnames'][language_name] ||= []
|
||||
if !db['extnames'][language_name].include?(sample[:extname])
|
||||
db['extnames'][language_name] << sample[:extname]
|
||||
db['extnames'][language_name].sort!
|
||||
end
|
||||
end
|
||||
|
||||
if sample[:filename]
|
||||
db['filenames'][language_name] ||= []
|
||||
db['filenames'][language_name] << sample[:filename]
|
||||
db['filenames'][language_name].sort!
|
||||
end
|
||||
|
||||
data = File.read(sample[:path])
|
||||
|
||||
@@ -16,6 +16,9 @@ module Linguist
|
||||
new.extract_tokens(data)
|
||||
end
|
||||
|
||||
# Read up to 100KB
|
||||
BYTE_LIMIT = 100_000
|
||||
|
||||
# Start state on token, ignore anything till the next newline
|
||||
SINGLE_LINE_COMMENTS = [
|
||||
'//', # C
|
||||
@@ -55,6 +58,8 @@ module Linguist
|
||||
|
||||
tokens = []
|
||||
until s.eos?
|
||||
break if s.pos >= BYTE_LIMIT
|
||||
|
||||
if token = s.scan(/^#!.+$/)
|
||||
if name = extract_shebang(token)
|
||||
tokens << "SHEBANG#!#{name}"
|
||||
@@ -133,7 +138,7 @@ module Linguist
|
||||
s.scan(/\s+/)
|
||||
script = s.scan(/\S+/)
|
||||
end
|
||||
script = script[/[^\d]+/, 0]
|
||||
script = script[/[^\d]+/, 0] if script
|
||||
return script
|
||||
end
|
||||
|
||||
|
||||
26
samples/ApacheConf/filenames/.htaccess
Normal file
26
samples/ApacheConf/filenames/.htaccess
Normal file
@@ -0,0 +1,26 @@
|
||||
ServerSignature Off
|
||||
RewriteCond %{REQUEST_METHOD} ^(HEAD|TRACE|DELETE|TRACK) [NC,OR]
|
||||
RewriteCond %{THE_REQUEST} (\\r|\\n|%0A|%0D) [NC,OR]
|
||||
|
||||
RewriteCond %{HTTP_REFERER} (<|>|’|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
|
||||
RewriteCond %{HTTP_COOKIE} (<|>|’|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
|
||||
RewriteCond %{REQUEST_URI} ^/(,|;|:|<|>|”>|”<|/|\\\.\.\\).{0,9999} [NC,OR]
|
||||
|
||||
RewriteCond %{HTTP_USER_AGENT} ^$ [OR]
|
||||
RewriteCond %{HTTP_USER_AGENT} ^(java|curl|wget) [NC,OR]
|
||||
RewriteCond %{HTTP_USER_AGENT} (winhttp|HTTrack|clshttp|archiver|loader|email|harvest|extract|grab|miner) [NC,OR]
|
||||
RewriteCond %{HTTP_USER_AGENT} (libwww-perl|curl|wget|python|nikto|scan) [NC,OR]
|
||||
RewriteCond %{HTTP_USER_AGENT} (<|>|’|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
|
||||
|
||||
#Block mySQL injects
|
||||
RewriteCond %{QUERY_STRING} (;|<|>|’|”|\)|%0A|%0D|%22|%27|%3C|%3E|%00).*(/\*|union|select|insert|cast|set|declare|drop|update|md5|benchmark) [NC,OR]
|
||||
|
||||
RewriteCond %{QUERY_STRING} \.\./\.\. [OR]
|
||||
|
||||
RewriteCond %{QUERY_STRING} (localhost|loopback|127\.0\.0\.1) [NC,OR]
|
||||
RewriteCond %{QUERY_STRING} \.[a-z0-9] [NC,OR]
|
||||
RewriteCond %{QUERY_STRING} (<|>|’|%0A|%0D|%27|%3C|%3E|%00) [NC]
|
||||
# Note: The final RewriteCond must NOT use the [OR] flag.
|
||||
|
||||
# Return 403 Forbidden error.
|
||||
RewriteRule .* index.php [F]
|
||||
470
samples/ApacheConf/filenames/apache2.conf
Normal file
470
samples/ApacheConf/filenames/apache2.conf
Normal file
@@ -0,0 +1,470 @@
|
||||
# This is the main Apache HTTP server configuration file. It contains the
|
||||
# configuration directives that give the server its instructions.
|
||||
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
|
||||
# In particular, see
|
||||
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
|
||||
# for a discussion of each configuration directive.
|
||||
#
|
||||
# Do NOT simply read the instructions in here without understanding
|
||||
# what they do. They're here only as hints or reminders. If you are unsure
|
||||
# consult the online docs. You have been warned.
|
||||
#
|
||||
# Configuration and logfile names: If the filenames you specify for many
|
||||
# of the server's control files begin with "/" (or "drive:/" for Win32), the
|
||||
# server will use that explicit path. If the filenames do *not* begin
|
||||
# with "/", the value of ServerRoot is prepended -- so "/var/log/apache2/foo.log"
|
||||
# with ServerRoot set to "" will be interpreted by the
|
||||
# server as "//var/log/apache2/foo.log".
|
||||
|
||||
#
|
||||
# ServerRoot: The top of the directory tree under which the server's
|
||||
# configuration, error, and log files are kept.
|
||||
#
|
||||
# Do not add a slash at the end of the directory path. If you point
|
||||
# ServerRoot at a non-local disk, be sure to point the LockFile directive
|
||||
# at a local disk. If you wish to share the same ServerRoot for multiple
|
||||
# httpd daemons, you will need to change at least LockFile and PidFile.
|
||||
#
|
||||
ServerRoot ""
|
||||
|
||||
#
|
||||
# Listen: Allows you to bind Apache to specific IP addresses and/or
|
||||
# ports, instead of the default. See also the <VirtualHost>
|
||||
# directive.
|
||||
#
|
||||
# Change this to Listen on specific IP addresses as shown below to
|
||||
# prevent Apache from glomming onto all bound IP addresses.
|
||||
#
|
||||
#Listen 12.34.56.78:80
|
||||
Listen 80
|
||||
|
||||
#
|
||||
# Dynamic Shared Object (DSO) Support
|
||||
#
|
||||
# To be able to use the functionality of a module which was built as a DSO you
|
||||
# have to place corresponding `LoadModule' lines at this location so the
|
||||
# directives contained in it are actually available _before_ they are used.
|
||||
# Statically compiled modules (those listed by `httpd -l') do not need
|
||||
# to be loaded here.
|
||||
#
|
||||
# Example:
|
||||
# LoadModule foo_module modules/mod_foo.so
|
||||
#
|
||||
LoadModule authn_file_module /usr/lib/apache2/modules/mod_authn_file.so
|
||||
LoadModule authn_dbm_module /usr/lib/apache2/modules/mod_authn_dbm.so
|
||||
LoadModule authn_anon_module /usr/lib/apache2/modules/mod_authn_anon.so
|
||||
LoadModule authn_dbd_module /usr/lib/apache2/modules/mod_authn_dbd.so
|
||||
LoadModule authn_default_module /usr/lib/apache2/modules/mod_authn_default.so
|
||||
LoadModule authn_alias_module /usr/lib/apache2/modules/mod_authn_alias.so
|
||||
LoadModule authz_host_module /usr/lib/apache2/modules/mod_authz_host.so
|
||||
LoadModule authz_groupfile_module /usr/lib/apache2/modules/mod_authz_groupfile.so
|
||||
LoadModule authz_user_module /usr/lib/apache2/modules/mod_authz_user.so
|
||||
LoadModule authz_dbm_module /usr/lib/apache2/modules/mod_authz_dbm.so
|
||||
LoadModule authz_owner_module /usr/lib/apache2/modules/mod_authz_owner.so
|
||||
LoadModule authnz_ldap_module /usr/lib/apache2/modules/mod_authnz_ldap.so
|
||||
LoadModule authz_default_module /usr/lib/apache2/modules/mod_authz_default.so
|
||||
LoadModule auth_basic_module /usr/lib/apache2/modules/mod_auth_basic.so
|
||||
LoadModule auth_digest_module /usr/lib/apache2/modules/mod_auth_digest.so
|
||||
LoadModule file_cache_module /usr/lib/apache2/modules/mod_file_cache.so
|
||||
LoadModule cache_module /usr/lib/apache2/modules/mod_cache.so
|
||||
LoadModule disk_cache_module /usr/lib/apache2/modules/mod_disk_cache.so
|
||||
LoadModule mem_cache_module /usr/lib/apache2/modules/mod_mem_cache.so
|
||||
LoadModule dbd_module /usr/lib/apache2/modules/mod_dbd.so
|
||||
LoadModule dumpio_module /usr/lib/apache2/modules/mod_dumpio.so
|
||||
LoadModule ext_filter_module /usr/lib/apache2/modules/mod_ext_filter.so
|
||||
LoadModule include_module /usr/lib/apache2/modules/mod_include.so
|
||||
LoadModule filter_module /usr/lib/apache2/modules/mod_filter.so
|
||||
LoadModule charset_lite_module /usr/lib/apache2/modules/mod_charset_lite.so
|
||||
LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so
|
||||
LoadModule ldap_module /usr/lib/apache2/modules/mod_ldap.so
|
||||
LoadModule log_forensic_module /usr/lib/apache2/modules/mod_log_forensic.so
|
||||
LoadModule env_module /usr/lib/apache2/modules/mod_env.so
|
||||
LoadModule mime_magic_module /usr/lib/apache2/modules/mod_mime_magic.so
|
||||
LoadModule cern_meta_module /usr/lib/apache2/modules/mod_cern_meta.so
|
||||
LoadModule expires_module /usr/lib/apache2/modules/mod_expires.so
|
||||
LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so
|
||||
LoadModule ident_module /usr/lib/apache2/modules/mod_ident.so
|
||||
LoadModule usertrack_module /usr/lib/apache2/modules/mod_usertrack.so
|
||||
LoadModule unique_id_module /usr/lib/apache2/modules/mod_unique_id.so
|
||||
LoadModule setenvif_module /usr/lib/apache2/modules/mod_setenvif.so
|
||||
LoadModule version_module /usr/lib/apache2/modules/mod_version.so
|
||||
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
|
||||
LoadModule proxy_connect_module /usr/lib/apache2/modules/mod_proxy_connect.so
|
||||
LoadModule proxy_ftp_module /usr/lib/apache2/modules/mod_proxy_ftp.so
|
||||
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
|
||||
LoadModule proxy_ajp_module /usr/lib/apache2/modules/mod_proxy_ajp.so
|
||||
LoadModule proxy_balancer_module /usr/lib/apache2/modules/mod_proxy_balancer.so
|
||||
LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so
|
||||
LoadModule mime_module /usr/lib/apache2/modules/mod_mime.so
|
||||
LoadModule dav_module /usr/lib/apache2/modules/mod_dav.so
|
||||
LoadModule status_module /usr/lib/apache2/modules/mod_status.so
|
||||
LoadModule autoindex_module /usr/lib/apache2/modules/mod_autoindex.so
|
||||
LoadModule asis_module /usr/lib/apache2/modules/mod_asis.so
|
||||
LoadModule info_module /usr/lib/apache2/modules/mod_info.so
|
||||
LoadModule suexec_module /usr/lib/apache2/modules/mod_suexec.so
|
||||
LoadModule cgid_module /usr/lib/apache2/modules/mod_cgid.so
|
||||
LoadModule cgi_module /usr/lib/apache2/modules/mod_cgi.so
|
||||
LoadModule dav_fs_module /usr/lib/apache2/modules/mod_dav_fs.so
|
||||
LoadModule dav_lock_module /usr/lib/apache2/modules/mod_dav_lock.so
|
||||
LoadModule vhost_alias_module /usr/lib/apache2/modules/mod_vhost_alias.so
|
||||
LoadModule negotiation_module /usr/lib/apache2/modules/mod_negotiation.so
|
||||
LoadModule dir_module /usr/lib/apache2/modules/mod_dir.so
|
||||
LoadModule imagemap_module /usr/lib/apache2/modules/mod_imagemap.so
|
||||
LoadModule actions_module /usr/lib/apache2/modules/mod_actions.so
|
||||
LoadModule speling_module /usr/lib/apache2/modules/mod_speling.so
|
||||
LoadModule userdir_module /usr/lib/apache2/modules/mod_userdir.so
|
||||
LoadModule alias_module /usr/lib/apache2/modules/mod_alias.so
|
||||
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
|
||||
|
||||
<IfModule !mpm_netware_module>
|
||||
#
|
||||
# If you wish httpd to run as a different user or group, you must run
|
||||
# httpd as root initially and it will switch.
|
||||
#
|
||||
# User/Group: The name (or #number) of the user/group to run httpd as.
|
||||
# It is usually good practice to create a dedicated user and group for
|
||||
# running httpd, as with most system services.
|
||||
#
|
||||
User daemon
|
||||
Group daemon
|
||||
</IfModule>
|
||||
|
||||
# 'Main' server configuration
|
||||
#
|
||||
# The directives in this section set up the values used by the 'main'
|
||||
# server, which responds to any requests that aren't handled by a
|
||||
# <VirtualHost> definition. These values also provide defaults for
|
||||
# any <VirtualHost> containers you may define later in the file.
|
||||
#
|
||||
# All of these directives may appear inside <VirtualHost> containers,
|
||||
# in which case these default settings will be overridden for the
|
||||
# virtual host being defined.
|
||||
#
|
||||
|
||||
#
|
||||
# ServerAdmin: Your address, where problems with the server should be
|
||||
# e-mailed. This address appears on some server-generated pages, such
|
||||
# as error documents. e.g. admin@your-domain.com
|
||||
#
|
||||
ServerAdmin you@example.com
|
||||
|
||||
#
|
||||
# ServerName gives the name and port that the server uses to identify itself.
|
||||
# This can often be determined automatically, but we recommend you specify
|
||||
# it explicitly to prevent problems during startup.
|
||||
#
|
||||
# If your host doesn't have a registered DNS name, enter its IP address here.
|
||||
#
|
||||
#ServerName www.example.com:80
|
||||
|
||||
#
|
||||
# DocumentRoot: The directory out of which you will serve your
|
||||
# documents. By default, all requests are taken from this directory, but
|
||||
# symbolic links and aliases may be used to point to other locations.
|
||||
#
|
||||
DocumentRoot "/usr/share/apache2/default-site/htdocs"
|
||||
|
||||
#
|
||||
# Each directory to which Apache has access can be configured with respect
|
||||
# to which services and features are allowed and/or disabled in that
|
||||
# directory (and its subdirectories).
|
||||
#
|
||||
# First, we configure the "default" to be a very restrictive set of
|
||||
# features.
|
||||
#
|
||||
<Directory />
|
||||
Options FollowSymLinks
|
||||
AllowOverride None
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</Directory>
|
||||
|
||||
#
|
||||
# Note that from this point forward you must specifically allow
|
||||
# particular features to be enabled - so if something's not working as
|
||||
# you might expect, make sure that you have specifically enabled it
|
||||
# below.
|
||||
#
|
||||
|
||||
#
|
||||
# This should be changed to whatever you set DocumentRoot to.
|
||||
#
|
||||
<Directory "/usr/share/apache2/default-site/htdocs">
|
||||
#
|
||||
# Possible values for the Options directive are "None", "All",
|
||||
# or any combination of:
|
||||
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
|
||||
#
|
||||
# Note that "MultiViews" must be named *explicitly* --- "Options All"
|
||||
# doesn't give it to you.
|
||||
#
|
||||
# The Options directive is both complicated and important. Please see
|
||||
# http://httpd.apache.org/docs/2.2/mod/core.html#options
|
||||
# for more information.
|
||||
#
|
||||
Options Indexes FollowSymLinks
|
||||
|
||||
#
|
||||
# AllowOverride controls what directives may be placed in .htaccess files.
|
||||
# It can be "All", "None", or any combination of the keywords:
|
||||
# Options FileInfo AuthConfig Limit
|
||||
#
|
||||
AllowOverride None
|
||||
|
||||
#
|
||||
# Controls who can get stuff from this server.
|
||||
#
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
|
||||
</Directory>
|
||||
|
||||
#
|
||||
# DirectoryIndex: sets the file that Apache will serve if a directory
|
||||
# is requested.
|
||||
#
|
||||
<IfModule dir_module>
|
||||
DirectoryIndex index.html
|
||||
</IfModule>
|
||||
|
||||
#
|
||||
# The following lines prevent .htaccess and .htpasswd files from being
|
||||
# viewed by Web clients.
|
||||
#
|
||||
<FilesMatch "^\.ht">
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
Satisfy All
|
||||
</FilesMatch>
|
||||
|
||||
#
|
||||
# ErrorLog: The location of the error log file.
|
||||
# If you do not specify an ErrorLog directive within a <VirtualHost>
|
||||
# container, error messages relating to that virtual host will be
|
||||
# logged here. If you *do* define an error logfile for a <VirtualHost>
|
||||
# container, that host's errors will be logged there and not here.
|
||||
#
|
||||
ErrorLog /var/log/apache2/error_log
|
||||
|
||||
#
|
||||
# LogLevel: Control the number of messages logged to the error_log.
|
||||
# Possible values include: debug, info, notice, warn, error, crit,
|
||||
# alert, emerg.
|
||||
#
|
||||
LogLevel warn
|
||||
|
||||
<IfModule log_config_module>
|
||||
#
|
||||
# The following directives define some format nicknames for use with
|
||||
# a CustomLog directive (see below).
|
||||
#
|
||||
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
|
||||
LogFormat "%h %l %u %t \"%r\" %>s %b" common
|
||||
|
||||
<IfModule logio_module>
|
||||
# You need to enable mod_logio.c to use %I and %O
|
||||
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
|
||||
</IfModule>
|
||||
|
||||
#
|
||||
# The location and format of the access logfile (Common Logfile Format).
|
||||
# If you do not define any access logfiles within a <VirtualHost>
|
||||
# container, they will be logged here. Contrariwise, if you *do*
|
||||
# define per-<VirtualHost> access logfiles, transactions will be
|
||||
# logged therein and *not* in this file.
|
||||
#
|
||||
CustomLog /var/log/apache2/access_log common
|
||||
|
||||
#
|
||||
# If you prefer a logfile with access, agent, and referer information
|
||||
# (Combined Logfile Format) you can use the following directive.
|
||||
#
|
||||
#CustomLog /var/log/apache2/access_log combined
|
||||
</IfModule>
|
||||
|
||||
<IfModule alias_module>
|
||||
#
|
||||
# Redirect: Allows you to tell clients about documents that used to
|
||||
# exist in your server's namespace, but do not anymore. The client
|
||||
# will make a new request for the document at its new location.
|
||||
# Example:
|
||||
# Redirect permanent /foo http://www.example.com/bar
|
||||
|
||||
#
|
||||
# Alias: Maps web paths into filesystem paths and is used to
|
||||
# access content that does not live under the DocumentRoot.
|
||||
# Example:
|
||||
# Alias /webpath /full/filesystem/path
|
||||
#
|
||||
# If you include a trailing / on /webpath then the server will
|
||||
# require it to be present in the URL. You will also likely
|
||||
# need to provide a <Directory> section to allow access to
|
||||
# the filesystem path.
|
||||
|
||||
#
|
||||
# ScriptAlias: This controls which directories contain server scripts.
|
||||
# ScriptAliases are essentially the same as Aliases, except that
|
||||
# documents in the target directory are treated as applications and
|
||||
# run by the server when requested rather than as documents sent to the
|
||||
# client. The same rules about trailing "/" apply to ScriptAlias
|
||||
# directives as to Alias.
|
||||
#
|
||||
ScriptAlias /cgi-bin/ "/usr/lib/cgi-bin/"
|
||||
|
||||
</IfModule>
|
||||
|
||||
<IfModule cgid_module>
|
||||
#
|
||||
# ScriptSock: On threaded servers, designate the path to the UNIX
|
||||
# socket used to communicate with the CGI daemon of mod_cgid.
|
||||
#
|
||||
#Scriptsock /var/run/apache2/cgisock
|
||||
</IfModule>
|
||||
|
||||
#
|
||||
# "/usr/lib/cgi-bin" should be changed to whatever your ScriptAliased
|
||||
# CGI directory exists, if you have that configured.
|
||||
#
|
||||
<Directory "/usr/lib/cgi-bin">
|
||||
AllowOverride None
|
||||
Options None
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
</Directory>
|
||||
|
||||
#
|
||||
# DefaultType: the default MIME type the server will use for a document
|
||||
# if it cannot otherwise determine one, such as from filename extensions.
|
||||
# If your server contains mostly text or HTML documents, "text/plain" is
|
||||
# a good value. If most of your content is binary, such as applications
|
||||
# or images, you may want to use "application/octet-stream" instead to
|
||||
# keep browsers from trying to display binary files as though they are
|
||||
# text.
|
||||
#
|
||||
DefaultType text/plain
|
||||
|
||||
<IfModule mime_module>
|
||||
#
|
||||
# TypesConfig points to the file containing the list of mappings from
|
||||
# filename extension to MIME-type.
|
||||
#
|
||||
TypesConfig /etc/apache2/mime.types
|
||||
|
||||
#
|
||||
# AddType allows you to add to or override the MIME configuration
|
||||
# file specified in TypesConfig for specific file types.
|
||||
#
|
||||
#AddType application/x-gzip .tgz
|
||||
#
|
||||
# AddEncoding allows you to have certain browsers uncompress
|
||||
# information on the fly. Note: Not all browsers support this.
|
||||
#
|
||||
#AddEncoding x-compress .Z
|
||||
#AddEncoding x-gzip .gz .tgz
|
||||
#
|
||||
# If the AddEncoding directives above are commented-out, then you
|
||||
# probably should define those extensions to indicate media types:
|
||||
#
|
||||
AddType application/x-compress .Z
|
||||
AddType application/x-gzip .gz .tgz
|
||||
|
||||
#
|
||||
# AddHandler allows you to map certain file extensions to "handlers":
|
||||
# actions unrelated to filetype. These can be either built into the server
|
||||
# or added with the Action directive (see below)
|
||||
#
|
||||
# To use CGI scripts outside of ScriptAliased directories:
|
||||
# (You will also need to add "ExecCGI" to the "Options" directive.)
|
||||
#
|
||||
#AddHandler cgi-script .cgi
|
||||
|
||||
# For type maps (negotiated resources):
|
||||
#AddHandler type-map var
|
||||
|
||||
#
|
||||
# Filters allow you to process content before it is sent to the client.
|
||||
#
|
||||
# To parse .shtml files for server-side includes (SSI):
|
||||
# (You will also need to add "Includes" to the "Options" directive.)
|
||||
#
|
||||
#AddType text/html .shtml
|
||||
#AddOutputFilter INCLUDES .shtml
|
||||
</IfModule>
|
||||
|
||||
#
|
||||
# The mod_mime_magic module allows the server to use various hints from the
|
||||
# contents of the file itself to determine its type. The MIMEMagicFile
|
||||
# directive tells the module where the hint definitions are located.
|
||||
#
|
||||
#MIMEMagicFile /etc/apache2/magic
|
||||
|
||||
#
|
||||
# Customizable error responses come in three flavors:
|
||||
# 1) plain text 2) local redirects 3) external redirects
|
||||
#
|
||||
# Some examples:
|
||||
#ErrorDocument 500 "The server made a boo boo."
|
||||
#ErrorDocument 404 /missing.html
|
||||
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
|
||||
#ErrorDocument 402 http://www.example.com/subscription_info.html
|
||||
#
|
||||
|
||||
#
|
||||
# EnableMMAP and EnableSendfile: On systems that support it,
|
||||
# memory-mapping or the sendfile syscall is used to deliver
|
||||
# files. This usually improves server performance, but must
|
||||
# be turned off when serving from networked-mounted
|
||||
# filesystems or if support for these functions is otherwise
|
||||
# broken on your system.
|
||||
#
|
||||
#EnableMMAP off
|
||||
#EnableSendfile off
|
||||
|
||||
# Supplemental configuration
|
||||
#
|
||||
# The configuration files in the /etc/apache2/extra/ directory can be
|
||||
# included to add extra features or to modify the default configuration of
|
||||
# the server, or you may simply copy their contents here and change as
|
||||
# necessary.
|
||||
|
||||
# Server-pool management (MPM specific)
|
||||
#Include /etc/apache2/extra/httpd-mpm.conf
|
||||
|
||||
# Multi-language error messages
|
||||
#Include /etc/apache2/extra/httpd-multilang-errordoc.conf
|
||||
|
||||
# Fancy directory listings
|
||||
#Include /etc/apache2/extra/httpd-autoindex.conf
|
||||
|
||||
# Language settings
|
||||
#Include /etc/apache2/extra/httpd-languages.conf
|
||||
|
||||
# User home directories
|
||||
#Include /etc/apache2/extra/httpd-userdir.conf
|
||||
|
||||
# Real-time info on requests and configuration
|
||||
#Include /etc/apache2/extra/httpd-info.conf
|
||||
|
||||
# Virtual hosts
|
||||
#Include /etc/apache2/extra/httpd-vhosts.conf
|
||||
|
||||
# Local access to the Apache HTTP Server Manual
|
||||
#Include /etc/apache2/extra/httpd-manual.conf
|
||||
|
||||
# Distributed authoring and versioning (WebDAV)
|
||||
#Include /etc/apache2/extra/httpd-dav.conf
|
||||
|
||||
# Various default settings
|
||||
#Include /etc/apache2/extra/httpd-default.conf
|
||||
|
||||
# Secure (SSL/TLS) connections
|
||||
#Include /etc/apache2/extra/httpd-ssl.conf
|
||||
#
|
||||
# Note: The following must must be present to support
|
||||
# starting without SSL on platforms with no /dev/random equivalent
|
||||
# but a statically compiled-in mod_ssl.
|
||||
#
|
||||
<IfModule ssl_module>
|
||||
SSLRandomSeed startup builtin
|
||||
SSLRandomSeed connect builtin
|
||||
</IfModule>
|
||||
500
samples/ApacheConf/filenames/httpd.conf
Normal file
500
samples/ApacheConf/filenames/httpd.conf
Normal file
@@ -0,0 +1,500 @@
|
||||
#
|
||||
# This is the main Apache HTTP server configuration file. It contains the
|
||||
# configuration directives that give the server its instructions.
|
||||
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
|
||||
# In particular, see
|
||||
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
|
||||
# for a discussion of each configuration directive.
|
||||
#
|
||||
# Do NOT simply read the instructions in here without understanding
|
||||
# what they do. They're here only as hints or reminders. If you are unsure
|
||||
# consult the online docs. You have been warned.
|
||||
#
|
||||
# Configuration and logfile names: If the filenames you specify for many
|
||||
# of the server's control files begin with "/" (or "drive:/" for Win32), the
|
||||
# server will use that explicit path. If the filenames do *not* begin
|
||||
# with "/", the value of ServerRoot is prepended -- so "log/foo_log"
|
||||
# with ServerRoot set to "/usr" will be interpreted by the
|
||||
# server as "/usr/log/foo_log".
|
||||
|
||||
#
|
||||
# ServerRoot: The top of the directory tree under which the server's
|
||||
# configuration, error, and log files are kept.
|
||||
#
|
||||
# Do not add a slash at the end of the directory path. If you point
|
||||
# ServerRoot at a non-local disk, be sure to point the LockFile directive
|
||||
# at a local disk. If you wish to share the same ServerRoot for multiple
|
||||
# httpd daemons, you will need to change at least LockFile and PidFile.
|
||||
#
|
||||
ServerRoot "/usr"
|
||||
|
||||
#
|
||||
# Listen: Allows you to bind Apache to specific IP addresses and/or
|
||||
# ports, instead of the default. See also the <VirtualHost>
|
||||
# directive.
|
||||
#
|
||||
# Change this to Listen on specific IP addresses as shown below to
|
||||
# prevent Apache from glomming onto all bound IP addresses.
|
||||
#
|
||||
#Listen 12.34.56.78:80
|
||||
Listen 80
|
||||
|
||||
#
|
||||
# Dynamic Shared Object (DSO) Support
|
||||
#
|
||||
# To be able to use the functionality of a module which was built as a DSO you
|
||||
# have to place corresponding `LoadModule' lines at this location so the
|
||||
# directives contained in it are actually available _before_ they are used.
|
||||
# Statically compiled modules (those listed by `httpd -l') do not need
|
||||
# to be loaded here.
|
||||
#
|
||||
# Example:
|
||||
# LoadModule foo_module modules/mod_foo.so
|
||||
#
|
||||
LoadModule authn_file_module libexec/apache2/mod_authn_file.so
|
||||
LoadModule authn_dbm_module libexec/apache2/mod_authn_dbm.so
|
||||
LoadModule authn_anon_module libexec/apache2/mod_authn_anon.so
|
||||
LoadModule authn_dbd_module libexec/apache2/mod_authn_dbd.so
|
||||
LoadModule authn_default_module libexec/apache2/mod_authn_default.so
|
||||
LoadModule authz_host_module libexec/apache2/mod_authz_host.so
|
||||
LoadModule authz_groupfile_module libexec/apache2/mod_authz_groupfile.so
|
||||
LoadModule authz_user_module libexec/apache2/mod_authz_user.so
|
||||
LoadModule authz_dbm_module libexec/apache2/mod_authz_dbm.so
|
||||
LoadModule authz_owner_module libexec/apache2/mod_authz_owner.so
|
||||
LoadModule authz_default_module libexec/apache2/mod_authz_default.so
|
||||
LoadModule auth_basic_module libexec/apache2/mod_auth_basic.so
|
||||
LoadModule auth_digest_module libexec/apache2/mod_auth_digest.so
|
||||
LoadModule cache_module libexec/apache2/mod_cache.so
|
||||
LoadModule disk_cache_module libexec/apache2/mod_disk_cache.so
|
||||
LoadModule mem_cache_module libexec/apache2/mod_mem_cache.so
|
||||
LoadModule dbd_module libexec/apache2/mod_dbd.so
|
||||
LoadModule dumpio_module libexec/apache2/mod_dumpio.so
|
||||
LoadModule reqtimeout_module libexec/apache2/mod_reqtimeout.so
|
||||
LoadModule ext_filter_module libexec/apache2/mod_ext_filter.so
|
||||
LoadModule include_module libexec/apache2/mod_include.so
|
||||
LoadModule filter_module libexec/apache2/mod_filter.so
|
||||
LoadModule substitute_module libexec/apache2/mod_substitute.so
|
||||
LoadModule deflate_module libexec/apache2/mod_deflate.so
|
||||
LoadModule log_config_module libexec/apache2/mod_log_config.so
|
||||
LoadModule log_forensic_module libexec/apache2/mod_log_forensic.so
|
||||
LoadModule logio_module libexec/apache2/mod_logio.so
|
||||
LoadModule env_module libexec/apache2/mod_env.so
|
||||
LoadModule mime_magic_module libexec/apache2/mod_mime_magic.so
|
||||
LoadModule cern_meta_module libexec/apache2/mod_cern_meta.so
|
||||
LoadModule expires_module libexec/apache2/mod_expires.so
|
||||
LoadModule headers_module libexec/apache2/mod_headers.so
|
||||
LoadModule ident_module libexec/apache2/mod_ident.so
|
||||
LoadModule usertrack_module libexec/apache2/mod_usertrack.so
|
||||
#LoadModule unique_id_module libexec/apache2/mod_unique_id.so
|
||||
LoadModule setenvif_module libexec/apache2/mod_setenvif.so
|
||||
LoadModule version_module libexec/apache2/mod_version.so
|
||||
LoadModule proxy_module libexec/apache2/mod_proxy.so
|
||||
LoadModule proxy_connect_module libexec/apache2/mod_proxy_connect.so
|
||||
LoadModule proxy_ftp_module libexec/apache2/mod_proxy_ftp.so
|
||||
LoadModule proxy_http_module libexec/apache2/mod_proxy_http.so
|
||||
LoadModule proxy_scgi_module libexec/apache2/mod_proxy_scgi.so
|
||||
LoadModule proxy_ajp_module libexec/apache2/mod_proxy_ajp.so
|
||||
LoadModule proxy_balancer_module libexec/apache2/mod_proxy_balancer.so
|
||||
LoadModule ssl_module libexec/apache2/mod_ssl.so
|
||||
LoadModule mime_module libexec/apache2/mod_mime.so
|
||||
LoadModule dav_module libexec/apache2/mod_dav.so
|
||||
LoadModule status_module libexec/apache2/mod_status.so
|
||||
LoadModule autoindex_module libexec/apache2/mod_autoindex.so
|
||||
LoadModule asis_module libexec/apache2/mod_asis.so
|
||||
LoadModule info_module libexec/apache2/mod_info.so
|
||||
LoadModule cgi_module libexec/apache2/mod_cgi.so
|
||||
LoadModule dav_fs_module libexec/apache2/mod_dav_fs.so
|
||||
LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
|
||||
LoadModule negotiation_module libexec/apache2/mod_negotiation.so
|
||||
LoadModule dir_module libexec/apache2/mod_dir.so
|
||||
LoadModule imagemap_module libexec/apache2/mod_imagemap.so
|
||||
LoadModule actions_module libexec/apache2/mod_actions.so
|
||||
LoadModule speling_module libexec/apache2/mod_speling.so
|
||||
LoadModule userdir_module libexec/apache2/mod_userdir.so
|
||||
LoadModule alias_module libexec/apache2/mod_alias.so
|
||||
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
|
||||
#LoadModule perl_module libexec/apache2/mod_perl.so
|
||||
#LoadModule php5_module libexec/apache2/libphp5.so
|
||||
#LoadModule hfs_apple_module libexec/apache2/mod_hfs_apple.so
|
||||
|
||||
<IfModule !mpm_netware_module>
|
||||
<IfModule !mpm_winnt_module>
|
||||
#
|
||||
# If you wish httpd to run as a different user or group, you must run
|
||||
# httpd as root initially and it will switch.
|
||||
#
|
||||
# User/Group: The name (or #number) of the user/group to run httpd as.
|
||||
# It is usually good practice to create a dedicated user and group for
|
||||
# running httpd, as with most system services.
|
||||
#
|
||||
User _www
|
||||
Group _www
|
||||
|
||||
</IfModule>
|
||||
</IfModule>
|
||||
|
||||
# 'Main' server configuration
|
||||
#
|
||||
# The directives in this section set up the values used by the 'main'
|
||||
# server, which responds to any requests that aren't handled by a
|
||||
# <VirtualHost> definition. These values also provide defaults for
|
||||
# any <VirtualHost> containers you may define later in the file.
|
||||
#
|
||||
# All of these directives may appear inside <VirtualHost> containers,
|
||||
# in which case these default settings will be overridden for the
|
||||
# virtual host being defined.
|
||||
#
|
||||
|
||||
#
|
||||
# ServerAdmin: Your address, where problems with the server should be
|
||||
# e-mailed. This address appears on some server-generated pages, such
|
||||
# as error documents. e.g. admin@your-domain.com
|
||||
#
|
||||
ServerAdmin you@example.com
|
||||
|
||||
#
|
||||
# ServerName gives the name and port that the server uses to identify itself.
|
||||
# This can often be determined automatically, but we recommend you specify
|
||||
# it explicitly to prevent problems during startup.
|
||||
#
|
||||
# If your host doesn't have a registered DNS name, enter its IP address here.
|
||||
#
|
||||
#ServerName www.example.com:80
|
||||
|
||||
#
|
||||
# DocumentRoot: The directory out of which you will serve your
|
||||
# documents. By default, all requests are taken from this directory, but
|
||||
# symbolic links and aliases may be used to point to other locations.
|
||||
#
|
||||
DocumentRoot "/Library/WebServer/Documents"
|
||||
|
||||
#
|
||||
# Each directory to which Apache has access can be configured with respect
|
||||
# to which services and features are allowed and/or disabled in that
|
||||
# directory (and its subdirectories).
|
||||
#
|
||||
# First, we configure the "default" to be a very restrictive set of
|
||||
# features.
|
||||
#
|
||||
<Directory />
|
||||
Options FollowSymLinks
|
||||
AllowOverride None
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</Directory>
|
||||
|
||||
#
|
||||
# Note that from this point forward you must specifically allow
|
||||
# particular features to be enabled - so if something's not working as
|
||||
# you might expect, make sure that you have specifically enabled it
|
||||
# below.
|
||||
#
|
||||
|
||||
#
|
||||
# This should be changed to whatever you set DocumentRoot to.
|
||||
#
|
||||
<Directory "/Library/WebServer/Documents">
|
||||
#
|
||||
# Possible values for the Options directive are "None", "All",
|
||||
# or any combination of:
|
||||
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
|
||||
#
|
||||
# Note that "MultiViews" must be named *explicitly* --- "Options All"
|
||||
# doesn't give it to you.
|
||||
#
|
||||
# The Options directive is both complicated and important. Please see
|
||||
# http://httpd.apache.org/docs/2.2/mod/core.html#options
|
||||
# for more information.
|
||||
#
|
||||
Options Indexes FollowSymLinks MultiViews
|
||||
|
||||
#
|
||||
# AllowOverride controls what directives may be placed in .htaccess files.
|
||||
# It can be "All", "None", or any combination of the keywords:
|
||||
# Options FileInfo AuthConfig Limit
|
||||
#
|
||||
AllowOverride None
|
||||
|
||||
#
|
||||
# Controls who can get stuff from this server.
|
||||
#
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
|
||||
</Directory>
|
||||
|
||||
#
|
||||
# DirectoryIndex: sets the file that Apache will serve if a directory
|
||||
# is requested.
|
||||
#
|
||||
<IfModule dir_module>
|
||||
DirectoryIndex index.html
|
||||
</IfModule>
|
||||
|
||||
#
|
||||
# The following lines prevent .htaccess and .htpasswd files from being
|
||||
# viewed by Web clients.
|
||||
#
|
||||
<FilesMatch "^\.([Hh][Tt]|[Dd][Ss]_[Ss])">
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
Satisfy All
|
||||
</FilesMatch>
|
||||
|
||||
#
|
||||
# Apple specific filesystem protection.
|
||||
#
|
||||
<Files "rsrc">
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
Satisfy All
|
||||
</Files>
|
||||
<DirectoryMatch ".*\.\.namedfork">
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
Satisfy All
|
||||
</DirectoryMatch>
|
||||
|
||||
#
|
||||
# ErrorLog: The location of the error log file.
|
||||
# If you do not specify an ErrorLog directive within a <VirtualHost>
|
||||
# container, error messages relating to that virtual host will be
|
||||
# logged here. If you *do* define an error logfile for a <VirtualHost>
|
||||
# container, that host's errors will be logged there and not here.
|
||||
#
|
||||
ErrorLog "/private/var/log/apache2/error_log"
|
||||
|
||||
#
|
||||
# LogLevel: Control the number of messages logged to the error_log.
|
||||
# Possible values include: debug, info, notice, warn, error, crit,
|
||||
# alert, emerg.
|
||||
#
|
||||
LogLevel warn
|
||||
|
||||
<IfModule log_config_module>
|
||||
#
|
||||
# The following directives define some format nicknames for use with
|
||||
# a CustomLog directive (see below).
|
||||
#
|
||||
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
|
||||
LogFormat "%h %l %u %t \"%r\" %>s %b" common
|
||||
|
||||
<IfModule logio_module>
|
||||
# You need to enable mod_logio.c to use %I and %O
|
||||
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
|
||||
</IfModule>
|
||||
|
||||
#
|
||||
# The location and format of the access logfile (Common Logfile Format).
|
||||
# If you do not define any access logfiles within a <VirtualHost>
|
||||
# container, they will be logged here. Contrariwise, if you *do*
|
||||
# define per-<VirtualHost> access logfiles, transactions will be
|
||||
# logged therein and *not* in this file.
|
||||
#
|
||||
CustomLog "/private/var/log/apache2/access_log" common
|
||||
|
||||
#
|
||||
# If you prefer a logfile with access, agent, and referer information
|
||||
# (Combined Logfile Format) you can use the following directive.
|
||||
#
|
||||
#CustomLog "/private/var/log/apache2/access_log" combined
|
||||
</IfModule>
|
||||
|
||||
<IfModule alias_module>
|
||||
#
|
||||
# Redirect: Allows you to tell clients about documents that used to
|
||||
# exist in your server's namespace, but do not anymore. The client
|
||||
# will make a new request for the document at its new location.
|
||||
# Example:
|
||||
# Redirect permanent /foo http://www.example.com/bar
|
||||
|
||||
#
|
||||
# Alias: Maps web paths into filesystem paths and is used to
|
||||
# access content that does not live under the DocumentRoot.
|
||||
# Example:
|
||||
# Alias /webpath /full/filesystem/path
|
||||
#
|
||||
# If you include a trailing / on /webpath then the server will
|
||||
# require it to be present in the URL. You will also likely
|
||||
# need to provide a <Directory> section to allow access to
|
||||
# the filesystem path.
|
||||
|
||||
#
|
||||
# ScriptAlias: This controls which directories contain server scripts.
|
||||
# ScriptAliases are essentially the same as Aliases, except that
|
||||
# documents in the target directory are treated as applications and
|
||||
# run by the server when requested rather than as documents sent to the
|
||||
# client. The same rules about trailing "/" apply to ScriptAlias
|
||||
# directives as to Alias.
|
||||
#
|
||||
ScriptAliasMatch ^/cgi-bin/((?!(?i:webobjects)).*$) "/Library/WebServer/CGI-Executables/$1"
|
||||
|
||||
</IfModule>
|
||||
|
||||
<IfModule cgid_module>
|
||||
#
|
||||
# ScriptSock: On threaded servers, designate the path to the UNIX
|
||||
# socket used to communicate with the CGI daemon of mod_cgid.
|
||||
#
|
||||
#Scriptsock /private/var/run/cgisock
|
||||
</IfModule>
|
||||
|
||||
#
|
||||
# "/Library/WebServer/CGI-Executables" should be changed to whatever your ScriptAliased
|
||||
# CGI directory exists, if you have that configured.
|
||||
#
|
||||
<Directory "/Library/WebServer/CGI-Executables">
|
||||
AllowOverride None
|
||||
Options None
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
</Directory>
|
||||
|
||||
#
|
||||
# DefaultType: the default MIME type the server will use for a document
|
||||
# if it cannot otherwise determine one, such as from filename extensions.
|
||||
# If your server contains mostly text or HTML documents, "text/plain" is
|
||||
# a good value. If most of your content is binary, such as applications
|
||||
# or images, you may want to use "application/octet-stream" instead to
|
||||
# keep browsers from trying to display binary files as though they are
|
||||
# text.
|
||||
#
|
||||
DefaultType text/plain
|
||||
|
||||
<IfModule mime_module>
|
||||
#
|
||||
# TypesConfig points to the file containing the list of mappings from
|
||||
# filename extension to MIME-type.
|
||||
#
|
||||
TypesConfig /private/etc/apache2/mime.types
|
||||
|
||||
#
|
||||
# AddType allows you to add to or override the MIME configuration
|
||||
# file specified in TypesConfig for specific file types.
|
||||
#
|
||||
#AddType application/x-gzip .tgz
|
||||
#
|
||||
# AddEncoding allows you to have certain browsers uncompress
|
||||
# information on the fly. Note: Not all browsers support this.
|
||||
#
|
||||
#AddEncoding x-compress .Z
|
||||
#AddEncoding x-gzip .gz .tgz
|
||||
#
|
||||
# If the AddEncoding directives above are commented-out, then you
|
||||
# probably should define those extensions to indicate media types:
|
||||
#
|
||||
AddType application/x-compress .Z
|
||||
AddType application/x-gzip .gz .tgz
|
||||
|
||||
#
|
||||
# AddHandler allows you to map certain file extensions to "handlers":
|
||||
# actions unrelated to filetype. These can be either built into the server
|
||||
# or added with the Action directive (see below)
|
||||
#
|
||||
# To use CGI scripts outside of ScriptAliased directories:
|
||||
# (You will also need to add "ExecCGI" to the "Options" directive.)
|
||||
#
|
||||
#AddHandler cgi-script .cgi
|
||||
|
||||
# For type maps (negotiated resources):
|
||||
#AddHandler type-map var
|
||||
|
||||
#
|
||||
# Filters allow you to process content before it is sent to the client.
|
||||
#
|
||||
# To parse .shtml files for server-side includes (SSI):
|
||||
# (You will also need to add "Includes" to the "Options" directive.)
|
||||
#
|
||||
#AddType text/html .shtml
|
||||
#AddOutputFilter INCLUDES .shtml
|
||||
</IfModule>
|
||||
|
||||
#
|
||||
# The mod_mime_magic module allows the server to use various hints from the
|
||||
# contents of the file itself to determine its type. The MIMEMagicFile
|
||||
# directive tells the module where the hint definitions are located.
|
||||
#
|
||||
#MIMEMagicFile /private/etc/apache2/magic
|
||||
|
||||
#
|
||||
# Customizable error responses come in three flavors:
|
||||
# 1) plain text 2) local redirects 3) external redirects
|
||||
#
|
||||
# Some examples:
|
||||
#ErrorDocument 500 "The server made a boo boo."
|
||||
#ErrorDocument 404 /missing.html
|
||||
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
|
||||
#ErrorDocument 402 http://www.example.com/subscription_info.html
|
||||
#
|
||||
|
||||
#
|
||||
# MaxRanges: Maximum number of Ranges in a request before
|
||||
# returning the entire resource, or one of the special
|
||||
# values 'default', 'none' or 'unlimited'.
|
||||
# Default setting is to accept 200 Ranges.
|
||||
#MaxRanges unlimited
|
||||
|
||||
#
|
||||
# EnableMMAP and EnableSendfile: On systems that support it,
|
||||
# memory-mapping or the sendfile syscall is used to deliver
|
||||
# files. This usually improves server performance, but must
|
||||
# be turned off when serving from networked-mounted
|
||||
# filesystems or if support for these functions is otherwise
|
||||
# broken on your system.
|
||||
#
|
||||
#EnableMMAP off
|
||||
#EnableSendfile off
|
||||
|
||||
# 6894961
|
||||
TraceEnable off
|
||||
|
||||
# Supplemental configuration
|
||||
#
|
||||
# The configuration files in the /private/etc/apache2/extra/ directory can be
|
||||
# included to add extra features or to modify the default configuration of
|
||||
# the server, or you may simply copy their contents here and change as
|
||||
# necessary.
|
||||
|
||||
# Server-pool management (MPM specific)
|
||||
Include /private/etc/apache2/extra/httpd-mpm.conf
|
||||
|
||||
# Multi-language error messages
|
||||
#Include /private/etc/apache2/extra/httpd-multilang-errordoc.conf
|
||||
|
||||
# Fancy directory listings
|
||||
Include /private/etc/apache2/extra/httpd-autoindex.conf
|
||||
|
||||
# Language settings
|
||||
Include /private/etc/apache2/extra/httpd-languages.conf
|
||||
|
||||
# User home directories
|
||||
Include /private/etc/apache2/extra/httpd-userdir.conf
|
||||
|
||||
# Real-time info on requests and configuration
|
||||
#Include /private/etc/apache2/extra/httpd-info.conf
|
||||
|
||||
# Virtual hosts
|
||||
#Include /private/etc/apache2/extra/httpd-vhosts.conf
|
||||
|
||||
# Local access to the Apache HTTP Server Manual
|
||||
Include /private/etc/apache2/extra/httpd-manual.conf
|
||||
|
||||
# Distributed authoring and versioning (WebDAV)
|
||||
#Include /private/etc/apache2/extra/httpd-dav.conf
|
||||
|
||||
# Various default settings
|
||||
#Include /private/etc/apache2/extra/httpd-default.conf
|
||||
|
||||
# Secure (SSL/TLS) connections
|
||||
#Include /private/etc/apache2/extra/httpd-ssl.conf
|
||||
#
|
||||
# Note: The following must must be present to support
|
||||
# starting without SSL on platforms with no /dev/random equivalent
|
||||
# but a statically compiled-in mod_ssl.
|
||||
#
|
||||
<IfModule ssl_module>
|
||||
SSLRandomSeed startup builtin
|
||||
SSLRandomSeed connect builtin
|
||||
</IfModule>
|
||||
|
||||
Include /private/etc/apache2/other/*.conf
|
||||
69
samples/C++/gdsdbreader.h
Normal file
69
samples/C++/gdsdbreader.h
Normal file
@@ -0,0 +1,69 @@
|
||||
#ifndef GDSDBREADER_H
|
||||
#define GDSDBREADER_H
|
||||
|
||||
// This file contains core structures, classes and types for the entire gds app
|
||||
// WARNING: DO NOT MODIFY UNTIL IT'S STRICTLY NECESSARY
|
||||
|
||||
#include <QDir>
|
||||
#include "diagramwidget/qgldiagramwidget.h"
|
||||
|
||||
#define GDS_DIR "gdsdata"
|
||||
|
||||
enum level {LEVEL_ONE, LEVEL_TWO, LEVEL_THREE};
|
||||
|
||||
// The internal structure of the db to store information about each node (each level)
|
||||
// this will be serialized before being written to file
|
||||
class dbDataStructure
|
||||
{
|
||||
public:
|
||||
QString label;
|
||||
quint32 depth;
|
||||
quint32 userIndex;
|
||||
QByteArray data; // This is COMPRESSED data, optimize ram and disk space, is decompressed
|
||||
// just when needed (to display the comments)
|
||||
|
||||
// The following ID is used to create second-third level files
|
||||
quint64 uniqueID;
|
||||
// All the next items linked to this one
|
||||
QVector<dbDataStructure*> nextItems;
|
||||
// Corresponding indices vector (used to store data)
|
||||
QVector<quint32> nextItemsIndices;
|
||||
// The father element (or NULL if it's root)
|
||||
dbDataStructure* father;
|
||||
// Corresponding indices vector (used to store data)
|
||||
quint32 fatherIndex;
|
||||
bool noFatherRoot; // Used to tell if this node is the root (so hasn't a father)
|
||||
|
||||
// These fields will be useful for levels 2 and 3
|
||||
QString fileName; // Relative filename for the associated code file
|
||||
QByteArray firstLineData; // Compressed first line data, this will be used with the line number to retrieve info
|
||||
QVector<quint32> linesNumbers; // First and next lines (next are relative to the first) numbers
|
||||
|
||||
// -- Generic system data not to be stored on disk
|
||||
void *glPointer; // GL pointer
|
||||
|
||||
// These operator overrides prevent the glPointer and other non-disk-necessary data serialization
|
||||
friend QDataStream& operator<<(QDataStream& stream, const dbDataStructure& myclass)
|
||||
// Notice: this function has to be "friend" because it cannot be a member function, member functions
|
||||
// have an additional parameter "this" which isn't in the argument list of an operator overload. A friend
|
||||
// function has full access to private data of the class without having the "this" argument
|
||||
{
|
||||
// Don't write glPointer and every pointer-dependent structure
|
||||
return stream << myclass.label << myclass.depth << myclass.userIndex << qCompress(myclass.data)
|
||||
<< myclass.uniqueID << myclass.nextItemsIndices << myclass.fatherIndex << myclass.noFatherRoot
|
||||
<< myclass.fileName << qCompress(myclass.firstLineData) << myclass.linesNumbers;
|
||||
}
|
||||
friend QDataStream& operator>>(QDataStream& stream, dbDataStructure& myclass)
|
||||
{
|
||||
//Don't read it, either
|
||||
stream >> myclass.label >> myclass.depth >> myclass.userIndex >> myclass.data
|
||||
>> myclass.uniqueID >> myclass.nextItemsIndices >> myclass.fatherIndex >> myclass.noFatherRoot
|
||||
>> myclass.fileName >> myclass.firstLineData >> myclass.linesNumbers;
|
||||
myclass.data = qUncompress(myclass.data);
|
||||
myclass.firstLineData = qUncompress(myclass.firstLineData);
|
||||
return stream;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // GDSDBREADER_H
|
||||
1267
samples/C/rf_io.c
Normal file
1267
samples/C/rf_io.c
Normal file
File diff suppressed because it is too large
Load Diff
682
samples/C/rf_io.h
Normal file
682
samples/C/rf_io.h
Normal file
@@ -0,0 +1,682 @@
|
||||
/**
|
||||
** Copyright (c) 2011-2012, Karapetsas Eleftherios
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
** 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the distribution.
|
||||
** 3. Neither the name of the Original Author of Refu nor the names of its contributors may be used to endorse or promote products derived from
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
|
||||
**/
|
||||
|
||||
|
||||
#ifndef REFU_IO_H
|
||||
#define REFU_IO_H
|
||||
|
||||
#include <rf_setup.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{// opening bracket for calling from C++
|
||||
#endif
|
||||
|
||||
// New line feed
|
||||
#define RF_LF 0xA
|
||||
// Carriage Return
|
||||
#define RF_CR 0xD
|
||||
|
||||
#ifdef REFU_WIN32_VERSION
|
||||
#define i_PLUSB_WIN32 "b"
|
||||
#else
|
||||
#define i_PLUSB_WIN32 ""
|
||||
#endif
|
||||
|
||||
// This is the type that represents the file offset
|
||||
#ifdef _MSC_VER
|
||||
typedef __int64 foff_rft;
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
typedef off64_t foff_rft;
|
||||
#endif
|
||||
///Fseek and Ftelll definitions
|
||||
#ifdef _MSC_VER
|
||||
#define rfFseek(i_FILE_,i_OFFSET_,i_WHENCE_) _fseeki64(i_FILE_,i_OFFSET_,i_WHENCE_)
|
||||
#define rfFtell(i_FILE_) _ftelli64(i_FILE_)
|
||||
#else
|
||||
#define rfFseek(i_FILE_,i_OFFSET_,i_WHENCE_) fseeko64(i_FILE_,i_OFFSET_,i_WHENCE_)
|
||||
#define rfFtell(i_FILE_) ftello64(i_FILE_)
|
||||
#endif
|
||||
|
||||
/**
|
||||
** @defgroup RF_IOGRP I/O
|
||||
** @addtogroup RF_IOGRP
|
||||
** @{
|
||||
**/
|
||||
|
||||
// @brief Reads a UTF-8 file descriptor until end of line or EOF is found and returns a UTF-8 byte buffer
|
||||
//
|
||||
// The file descriptor at @c f must have been opened in <b>binary</b> and not text mode. That means that if under
|
||||
// Windows make sure to call fopen with "wb", "rb" e.t.c. instead of the simple "w", "r" e.t.c. since the initial
|
||||
// default value under Windows is text mode. Alternatively you can set the initial value using _get_fmode() and
|
||||
// _set_fmode(). For more information take a look at the msdn pages here:
|
||||
// http://msdn.microsoft.com/en-us/library/ktss1a9b.aspx
|
||||
//
|
||||
// When the compile flag @c RF_NEWLINE_CRLF is defined (the default case at Windows) then this function
|
||||
// shall not be adding any CR character that is found in the file behind a newline character since this is
|
||||
// the Windows line ending scheme. Beware though that the returned read bytes value shall still count the CR character inside.
|
||||
//
|
||||
// @param[in] f The file descriptor to read
|
||||
// @param[out] utf8 Give here a refence to an unitialized char* that will be allocated inside the function
|
||||
// and contain the utf8 byte buffer. Needs to be freed by the caller explicitly later
|
||||
// @param[out] byteLength Give an @c uint32_t here to receive the length of the @c utf8 buffer in bytes
|
||||
// @param[out] bufferSize Give an @c uint32_t here to receive the capacity of the @c utf8 buffer in bytes
|
||||
// @param[out] eof Pass a pointer to a char to receive a true or false value in case the end of file
|
||||
// with reading this line
|
||||
// @return Returns either a positive number for success that represents the number of bytes read from @c f and and error in case something goes wrong.
|
||||
// The possible errors to return are the same as rfFgets_UTF8()
|
||||
i_DECLIMEX_ int32_t rfFReadLine_UTF8(FILE* f,char** utf8,uint32_t* byteLength,uint32_t* bufferSize,char* eof);
|
||||
// @brief Reads a Big Endian UTF-16 file descriptor until end of line or EOF is found and returns a UTF-8 byte buffer
|
||||
//
|
||||
// The file descriptor at @c f must have been opened in <b>binary</b> and not text mode. That means that if under
|
||||
// Windows make sure to call fopen with "wb", "rb" e.t.c. instead of the simple "w", "r" e.t.c. since the initial
|
||||
// default value under Windows is text mode. Alternatively you can set the initial value using _get_fmode() and
|
||||
// _set_fmode(). For more information take a look at the msdn pages here:
|
||||
// http://msdn.microsoft.com/en-us/library/ktss1a9b.aspx
|
||||
//
|
||||
// When the compile flag @c RF_NEWLINE_CRLF is defined (the default case at Windows) then this function
|
||||
// shall not be adding any CR character that is found in the file behind a newline character since this is
|
||||
// the Windows line ending scheme. Beware though that the returned read bytes value shall still count the CR character inside.
|
||||
//
|
||||
// @param[in] f The file descriptor to read
|
||||
// @param[out] utf8 Give here a refence to an unitialized char* that will be allocated inside the function
|
||||
// and contain the utf8 byte buffer. Needs to be freed by the caller explicitly later
|
||||
// @param[out] byteLength Give an @c uint32_t here to receive the length of the @c utf8 buffer in bytes
|
||||
// @param[out] eof Pass a pointer to a char to receive a true or false value in case the end of file
|
||||
// with reading this line
|
||||
// @return Returns either a positive number for success that represents the number of bytes read from @c f and and error in case something goes wrong.
|
||||
// + Any error that can be returned by @ref rfFgets_UTF16BE()
|
||||
// + @c RE_UTF16_INVALID_SEQUENCE: Failed to decode the UTF-16 byte stream of the file descriptor
|
||||
// + @c RE_UTF8_ENCODING: Failed to encode the UTF-16 of the file descriptor into UTF-8
|
||||
i_DECLIMEX_ int32_t rfFReadLine_UTF16BE(FILE* f,char** utf8,uint32_t* byteLength,char* eof);
|
||||
// @brief Reads a Little Endian UTF-16 file descriptor until end of line or EOF is found and returns a UTF-8 byte buffer
|
||||
//
|
||||
// The file descriptor at @c f must have been opened in <b>binary</b> and not text mode. That means that if under
|
||||
// Windows make sure to call fopen with "wb", "rb" e.t.c. instead of the simple "w", "r" e.t.c. since the initial
|
||||
// default value under Windows is text mode. Alternatively you can set the initial value using _get_fmode() and
|
||||
// _set_fmode(). For more information take a look at the msdn pages here:
|
||||
// http://msdn.microsoft.com/en-us/library/ktss1a9b.aspx
|
||||
//
|
||||
// When the compile flag @c RF_NEWLINE_CRLF is defined (the default case at Windows) then this function
|
||||
// shall not be adding any CR character that is found in the file behind a newline character since this is
|
||||
// the Windows line ending scheme. Beware though that the returned read bytes value shall still count the CR character inside.
|
||||
//
|
||||
// @param[in] f The file descriptor to read
|
||||
// @param[out] utf8 Give here a refence to an unitialized char* that will be allocated inside the function
|
||||
// and contain the utf8 byte buffer. Needs to be freed by the caller explicitly later
|
||||
// @param[out] byteLength Give an @c uint32_t here to receive the length of the @c utf8 buffer in bytes
|
||||
// @param[out] eof Pass a pointer to a char to receive a true or false value in case the end of file
|
||||
// with reading this line
|
||||
// @return Returns either a positive number for success that represents the number of bytes read from @c f and and error in case something goes wrong.
|
||||
// + Any error that can be returned by @ref rfFgets_UTF16LE()
|
||||
// + @c RE_UTF16_INVALID_SEQUENCE: Failed to decode the UTF-16 byte stream of the file descriptor
|
||||
// + @c RE_UTF8_ENCODING: Failed to encode the UTF-16 of the file descriptor into UTF-8
|
||||
i_DECLIMEX_ int32_t rfFReadLine_UTF16LE(FILE* f,char** utf8,uint32_t* byteLength,char* eof);
|
||||
|
||||
// @brief Reads a Big Endian UTF-32 file descriptor until end of line or EOF is found and returns a UTF-8 byte buffer
|
||||
//
|
||||
// The file descriptor at @c f must have been opened in <b>binary</b> and not text mode. That means that if under
|
||||
// Windows make sure to call fopen with "wb", "rb" e.t.c. instead of the simple "w", "r" e.t.c. since the initial
|
||||
// default value under Windows is text mode. Alternatively you can set the initial value using _get_fmode() and
|
||||
// _set_fmode(). For more information take a look at the msdn pages here:
|
||||
// http://msdn.microsoft.com/en-us/library/ktss1a9b.aspx
|
||||
//
|
||||
// When the compile flag @c RF_NEWLINE_CRLF is defined (the default case at Windows) then this function
|
||||
// shall not be adding any CR character that is found in the file behind a newline character since this is
|
||||
// the Windows line ending scheme. Beware though that the returned read bytes value shall still count the CR character inside.
|
||||
//
|
||||
// @param[in] f The file descriptor to read
|
||||
// @param[out] utf8 Give here a refence to an unitialized char* that will be allocated inside the function
|
||||
// and contain the utf8 byte buffer. Needs to be freed by the caller explicitly later
|
||||
// @param[out] byteLength Give an @c uint32_t here to receive the length of the @c utf8 buffer in bytes
|
||||
// @param[out] eof Pass a pointer to a char to receive a true or false value in case the end of file
|
||||
// with reading this line
|
||||
// @return Returns either a positive number for success that represents the number of bytes read from @c f and and error in case something goes wrong.
|
||||
// + Any error that can be returned by @ref rfFgets_UTF32BE()
|
||||
// + @c RE_UTF8_ENCODING: Failed to encode the UTF-16 of the file descriptor into UTF-8
|
||||
i_DECLIMEX_ int32_t rfFReadLine_UTF32BE(FILE* f,char** utf8,uint32_t* byteLength,char* eof);
|
||||
// @brief Reads a Little Endian UTF-32 file descriptor until end of line or EOF is found and returns a UTF-8 byte buffer
|
||||
//
|
||||
// The file descriptor at @c f must have been opened in <b>binary</b> and not text mode. That means that if under
|
||||
// Windows make sure to call fopen with "wb", "rb" e.t.c. instead of the simple "w", "r" e.t.c. since the initial
|
||||
// default value under Windows is text mode. Alternatively you can set the initial value using _get_fmode() and
|
||||
// _set_fmode(). For more information take a look at the msdn pages here:
|
||||
// http://msdn.microsoft.com/en-us/library/ktss1a9b.aspx
|
||||
//
|
||||
// When the compile flag @c RF_NEWLINE_CRLF is defined (the default case at Windows) then this function
|
||||
// shall not be adding any CR character that is found in the file behind a newline character since this is
|
||||
// the Windows line ending scheme. Beware though that the returned read bytes value shall still count the CR character inside.
|
||||
//
|
||||
// @param[in] f The file descriptor to read
|
||||
// @param[out] utf8 Give here a refence to an unitialized char* that will be allocated inside the function
|
||||
// and contain the utf8 byte buffer. Needs to be freed by the caller explicitly later
|
||||
// @param[out] byteLength Give an @c uint32_t here to receive the length of the @c utf8 buffer in bytes
|
||||
// @param[out] eof Pass a pointer to a char to receive a true or false value in case the end of file
|
||||
// with reading this line
|
||||
// @return Returns either a positive number for success that represents the number of bytes read from @c f and and error in case something goes wrong.
|
||||
// + Any error that can be returned by @ref rfFgets_UTF32LE()
|
||||
// + @c RE_UTF8_ENCODING: Failed to encode the UTF-16 of the file descriptor into UTF-8
|
||||
i_DECLIMEX_ int32_t rfFReadLine_UTF32LE(FILE* f,char** utf8,uint32_t* byteLength,char* eof);
|
||||
|
||||
// @brief Gets a number of bytes from a BIG endian UTF-32 file descriptor
|
||||
//
|
||||
// This is a function that's similar to c library fgets but it also returns the number of bytes read. Reads in from the file until @c num bytes
|
||||
// have been read or new line or EOF character has been encountered.
|
||||
//
|
||||
// The function will read until @c num characters are read and if @c num
|
||||
// would take us to the middle of a UTF32 character then the next character shall also be read
|
||||
// and the function will return the number of bytes read.
|
||||
// Since the function null terminates the buffer the given @c buff needs to be of at least
|
||||
// @c num+7 size to cater for the worst case.
|
||||
//
|
||||
// The final bytestream stored inside @c buff is in the endianess of the system.
|
||||
//
|
||||
// If right after the last character read comes the EOF, the function
|
||||
// shall detect so and assign @c true to @c eof.
|
||||
//
|
||||
// In Windows where file endings are in the form of 2 bytes CR-LF (Carriage return - NewLine) this function
|
||||
// shall just ignore the carriage returns and not return it inside the return buffer at @c buff.
|
||||
//
|
||||
// The file descriptor at @c f must have been opened in <b>binary</b> and not text mode. That means that if under
|
||||
// Windows make sure to call fopen with "wb", "rb" e.t.c. instead of the simple "w", "r" e.t.c. since the initial
|
||||
// default value under Windows is text mode. Alternatively you can set the initial value using _get_fmode() and
|
||||
// _set_fmode(). For more information take a look at the msdn pages here:
|
||||
// http://msdn.microsoft.com/en-us/library/ktss1a9b.aspx
|
||||
//
|
||||
// @param[in] buff A buffer to be filled with the contents of the file. Should be of size at least @c num+7
|
||||
// @param[in] num The maximum number of bytes to read from within the file NOT including the null terminating character(which in itelf is 4 bytes). Should be a multiple of 4
|
||||
// @param[in] f A valid FILE descriptor from which to read the bytes
|
||||
// @param[out] eof Pass a reference to a char to receive a true/false value for whether EOF has been reached.
|
||||
// @return Returns the actual number of bytes read or an error if there was a problem.
|
||||
// The possible errors are:
|
||||
// + @c RE_FILE_READ: If during reading the file there was an unknown read error
|
||||
// + @c RE_FILE_READ_BLOCK: If the read operation failed due to the file descriptor being occupied by another thread
|
||||
// + @c RE_FILE_MODE: If during reading the file the file descriptor's mode was not correctly set for reading
|
||||
// + @c RE_FILE_POS_OVERFLOW: If during reading, the current file position can't be represented by the system
|
||||
// + @c RE_INTERRUPT: If during reading, there was a system interrupt
|
||||
// + @c RE_FILE_IO: If there was a physical I/O error
|
||||
// + @c RE_FILE_NOSPACE: If reading failed due to insufficient storage space
|
||||
i_DECLIMEX_ int32_t rfFgets_UTF32BE(char* buff,uint32_t num,FILE* f,char* eof);
|
||||
// @brief Gets a number of bytes from a Little endian UTF-32 file descriptor
|
||||
//
|
||||
// This is a function that's similar to c library fgets but it also returns the number of bytes read. Reads in from the file until @c num bytes
|
||||
// have been read or new line or EOF character has been encountered.
|
||||
//
|
||||
// The function will read until @c num characters are read and if @c num
|
||||
// would take us to the middle of a UTF32 character then the next character shall also be read
|
||||
// and the function will return the number of bytes read.
|
||||
// Since the function null terminates the buffer the given @c buff needs to be of at least
|
||||
// @c num+7 size to cater for the worst case.
|
||||
//
|
||||
// The final bytestream stored inside @c buff is in the endianess of the system.
|
||||
//
|
||||
// If right after the last character read comes the EOF, the function
|
||||
// shall detect so and assign @c true to @c eof.
|
||||
//
|
||||
// In Windows where file endings are in the form of 2 bytes CR-LF (Carriage return - NewLine) this function
|
||||
// shall just ignore the carriage returns and not return it inside the return buffer at @c buff.
|
||||
//
|
||||
// The file descriptor at @c f must have been opened in <b>binary</b> and not text mode. That means that if under
|
||||
// Windows make sure to call fopen with "wb", "rb" e.t.c. instead of the simple "w", "r" e.t.c. since the initial
|
||||
// default value under Windows is text mode. Alternatively you can set the initial value using _get_fmode() and
|
||||
// _set_fmode(). For more information take a look at the msdn pages here:
|
||||
// http://msdn.microsoft.com/en-us/library/ktss1a9b.aspx
|
||||
//
|
||||
// @param[in] buff A buffer to be filled with the contents of the file. Should be of size at least @c num+7
|
||||
// @param[in] num The maximum number of bytes to read from within the file NOT including the null terminating character(which in itelf is 4 bytes). Should be a multiple of 4
|
||||
// @param[in] f A valid FILE descriptor from which to read the bytes
|
||||
// @param[out] eof Pass a reference to a char to receive a true/false value for whether EOF has been reached.
|
||||
// @return Returns the actual number of bytes read or an error if there was a problem.
|
||||
// The possible errors are:
|
||||
// + @c RE_FILE_READ: If during reading the file there was an unknown read error
|
||||
// + @c RE_FILE_READ_BLOCK: If the read operation failed due to the file descriptor being occupied by another thread
|
||||
// + @c RE_FILE_MODE: If during reading the file the file descriptor's mode was not correctly set for reading
|
||||
// + @c RE_FILE_POS_OVERFLOW: If during reading, the current file position can't be represented by the system
|
||||
// + @c RE_INTERRUPT: If during reading, there was a system interrupt
|
||||
// + @c RE_FILE_IO: If there was a physical I/O error
|
||||
// + @c RE_FILE_NOSPACE: If reading failed due to insufficient storage space
|
||||
i_DECLIMEX_ int32_t rfFgets_UTF32LE(char* buff,uint32_t num,FILE* f,char* eof);
|
||||
|
||||
// @brief Gets a number of bytes from a BIG endian UTF-16 file descriptor
|
||||
//
|
||||
// This is a function that's similar to c library fgets but it also returns the number of bytes read. Reads in from the file until @c num bytes
|
||||
// have been read or new line or EOF character has been encountered.
|
||||
//
|
||||
// The function will read until @c num characters are read and if @c num
|
||||
// would take us to the middle of a UTF16 character then the next character shall also be read
|
||||
// and the function will return the number of bytes read.
|
||||
// Since the function null terminates the buffer the given @c buff needs to be of at least
|
||||
// @c num+5 size to cater for the worst case.
|
||||
//
|
||||
// The final bytestream stored inside @c buff is in the endianess of the system.
|
||||
//
|
||||
// If right after the last character read comes the EOF, the function
|
||||
// shall detect so and assign @c true to @c eof.
|
||||
//
|
||||
// In Windows where file endings are in the form of 2 bytes CR-LF (Carriage return - NewLine) this function
|
||||
// shall just ignore the carriage returns and not return it inside the return buffer at @c buff.
|
||||
//
|
||||
// The file descriptor at @c f must have been opened in <b>binary</b> and not text mode. That means that if under
|
||||
// Windows make sure to call fopen with "wb", "rb" e.t.c. instead of the simple "w", "r" e.t.c. since the initial
|
||||
// default value under Windows is text mode. Alternatively you can set the initial value using _get_fmode() and
|
||||
// _set_fmode(). For more information take a look at the msdn pages here:
|
||||
// http://msdn.microsoft.com/en-us/library/ktss1a9b.aspx
|
||||
//
|
||||
// @param[in] buff A buffer to be filled with the contents of the file. Should be of size at least @c num+5
|
||||
// @param[in] num The maximum number of bytes to read from within the file NOT including the null terminating character(which in itelf is 2 bytes). Should be a multiple of 2
|
||||
// @param[in] f A valid FILE descriptor from which to read the bytes
|
||||
// @param[out] eof Pass a reference to a char to receive a true/false value for whether EOF has been reached.
|
||||
// @return Returns the actual number of bytes read or an error if there was a problem.
|
||||
// The possible errors are:
|
||||
// + @c RE_FILE_READ: If during reading the file there was an unknown read error
|
||||
// + @c RE_FILE_READ_BLOCK: If the read operation failed due to the file descriptor being occupied by another thread
|
||||
// + @c RE_FILE_MODE: If during reading the file the file descriptor's mode was not correctly set for reading
|
||||
// + @c RE_FILE_POS_OVERFLOW: If during reading, the current file position can't be represented by the system
|
||||
// + @c RE_INTERRUPT: If during reading, there was a system interrupt
|
||||
// + @c RE_FILE_IO: If there was a physical I/O error
|
||||
// + @c RE_FILE_NOSPACE: If reading failed due to insufficient storage space
|
||||
i_DECLIMEX_ int32_t rfFgets_UTF16BE(char* buff,uint32_t num,FILE* f,char* eof);
|
||||
// @brief Gets a number of bytes from a Little endian UTF-16 file descriptor
|
||||
//
|
||||
// This is a function that's similar to c library fgets but it also returns the number of bytes read. Reads in from the file until @c num bytes
|
||||
// have been read or new line or EOF character has been encountered.
|
||||
//
|
||||
// The function will read until @c num characters are read and if @c num
|
||||
// would take us to the middle of a UTF16 character then the next character shall also be read
|
||||
// and the function will return the number of bytes read.
|
||||
// Since the function null terminates the buffer the given @c buff needs to be of at least
|
||||
// @c num+5 size to cater for the worst case.
|
||||
//
|
||||
// The final bytestream stored inside @c buff is in the endianess of the system.
|
||||
//
|
||||
// If right after the last character read comes the EOF, the function
|
||||
// shall detect so and assign @c true to @c eof.
|
||||
//
|
||||
// In Windows where file endings are in the form of 2 bytes CR-LF (Carriage return - NewLine) this function
|
||||
// shall just ignore the carriage returns and not return it inside the return buffer at @c buff.
|
||||
//
|
||||
// The file descriptor at @c f must have been opened in <b>binary</b> and not text mode. That means that if under
|
||||
// Windows make sure to call fopen with "wb", "rb" e.t.c. instead of the simple "w", "r" e.t.c. since the initial
|
||||
// default value under Windows is text mode. Alternatively you can set the initial value using _get_fmode() and
|
||||
// _set_fmode(). For more information take a look at the msdn pages here:
|
||||
// http://msdn.microsoft.com/en-us/library/ktss1a9b.aspx
|
||||
//
|
||||
// @param[in] buff A buffer to be filled with the contents of the file. Should be of size at least @c num+2
|
||||
// @param[in] num The maximum number of bytes to read from within the file NOT including the null terminating character(which in itelf is 2 bytes). Should be a multiple of 2
|
||||
// @param[in] f A valid FILE descriptor from which to read the bytes
|
||||
// @param[out] eof Pass a reference to a char to receive a true/false value for whether EOF has been reached.
|
||||
// @return Returns the actual number of bytes read or an error if there was a problem.
|
||||
// The possible errors are:
|
||||
// + @c RE_FILE_READ: If during reading the file there was an unknown read error
|
||||
// + @c RE_FILE_READ_BLOCK: If the read operation failed due to the file descriptor being occupied by another thread
|
||||
// + @c RE_FILE_MODE: If during reading the file the file descriptor's mode was not correctly set for reading
|
||||
// + @c RE_FILE_POS_OVERFLOW: If during reading, the current file position can't be represented by the system
|
||||
// + @c RE_INTERRUPT: If during reading, there was a system interrupt
|
||||
// + @c RE_FILE_IO: If there was a physical I/O error
|
||||
// + @c RE_FILE_NOSPACE: If reading failed due to insufficient storage space
|
||||
i_DECLIMEX_ int32_t rfFgets_UTF16LE(char* buff,uint32_t num,FILE* f,char* eof);
|
||||
// @brief Gets a number of bytes from a UTF-8 file descriptor
|
||||
//
|
||||
// This is a function that's similar to c library fgets but it also returns the number of bytes read. Reads in from the file until @c num characters
|
||||
// have been read or new line or EOF character has been encountered.
|
||||
//
|
||||
// The function automatically adds a null termination character at the end of
|
||||
// @c buff but this character is not included in the returned actual number of bytes.
|
||||
//
|
||||
// The function will read until @c num characters are read and if @c num
|
||||
// would take us to the middle of a UTF8 character then the next character shall also be read
|
||||
// and the function will return the number of bytes read.
|
||||
// Since the function null terminates the buffer the given @c buff needs to be of at least
|
||||
// @c num+4 size to cater for the worst case.
|
||||
//
|
||||
// If right after the last character read comes the EOF, the function
|
||||
// shall detect so and assign @c true to @c eof.
|
||||
//
|
||||
// In Windows where file endings are in the form of 2 bytes CR-LF (Carriage return - NewLine) this function
|
||||
// shall just ignore the carriage returns and not return it inside the return buffer at @c buff.
|
||||
//
|
||||
// The file descriptor at @c f must have been opened in <b>binary</b> and not text mode. That means that if under
|
||||
// Windows make sure to call fopen with "wb", "rb" e.t.c. instead of the simple "w", "r" e.t.c. since the initial
|
||||
// default value under Windows is text mode. Alternatively you can set the initial value using _get_fmode() and
|
||||
// _set_fmode(). For more information take a look at the msdn pages here:
|
||||
// http://msdn.microsoft.com/en-us/library/ktss1a9b.aspx
|
||||
//
|
||||
// @param[in] buff A buffer to be filled with the contents of the file. Should of size at least @c num+4
|
||||
// @param[in] num The maximum number of bytes to read from within the file NOT including the null terminating character(which in itelf is 1 byte)
|
||||
// @param[in] f A valid FILE descriptor from which to read the bytes
|
||||
// @param[out] eof Pass a reference to a char to receive a true/false value for whether EOF has been reached.
|
||||
// @return Returns the actual number of bytes read or an error if there was a problem.
|
||||
// The possible errors are:
|
||||
// + @c RE_UTF8_INVALID_SEQUENCE_INVALID_BYTE: If an invalid UTF-8 byte has been found
|
||||
// + @c RE_UTF8_INVALID_SEQUENCE_CONBYTE: If during parsing the file we were expecting a continuation
|
||||
// byte and did not find it
|
||||
// + @c RE_UTF8_INVALID_SEQUENCE_END: If the null character is encountered in between bytes that should
|
||||
// have been continuation bytes
|
||||
// + @c RE_FILE_READ: If during reading the file there was an unknown read error
|
||||
// + @c RE_FILE_READ_BLOCK: If the read operation failed due to the file descriptor being occupied by another thread
|
||||
// + @c RE_FILE_MODE: If during reading the file the file descriptor's mode was not correctly set for reading
|
||||
// + @c RE_FILE_POS_OVERFLOW: If during reading, the current file position can't be represented by the system
|
||||
// + @c RE_INTERRUPT: If during reading, there was a system interrupt
|
||||
// + @c RE_FILE_IO: If there was a physical I/O error
|
||||
// + @c RE_FILE_NOSPACE: If reading failed due to insufficient storage space
|
||||
i_DECLIMEX_ int32_t rfFgets_UTF8(char* buff,uint32_t num,FILE* f,char* eof);
|
||||
|
||||
// @brief Gets a unicode character from a UTF-8 file descriptor
|
||||
//
|
||||
// This function attempts to assume a more modern fgetc() role for UTF-8 encoded files.
|
||||
// Reads bytes from the File descriptor @c f until a full UTF-8 unicode character has been read
|
||||
//
|
||||
// After this function the file pointer will have moved either by @c 1, @c 2, @c 3 or @c 4
|
||||
// bytes if the return value is positive. You can see how much by checking the return value.
|
||||
//
|
||||
// You shall need to provide an integer at @c c to contain either the decoded Unicode
|
||||
// codepoint or the UTF-8 endoced byte depending on the value of the @c cp argument.
|
||||
//
|
||||
// @param f A valid FILE descriptor from which to read the bytes
|
||||
// @param c Pass an int that will receive either the unicode code point value or
|
||||
// the UTF8 bytes depending on the value of the @c cp flag
|
||||
// @param cp A boolean flag. If @c true then the int passed at @c c will contain the unicode code point
|
||||
// of the read character, so the UTF-8 will be decoded.
|
||||
// If @c false the int passed at @c c will contain the value of the read bytes in UTF-8 without any decoding
|
||||
// @return Returns the number of bytes read (either @c 1, @c 2, @c 3 or @c 4) or an error if the function
|
||||
// fails for some reason. Possible error values are:
|
||||
// + @c RE_FILE_EOF: The end of file has been found while reading. If the end of file is encountered
|
||||
// in the middle of a UTF-8 encoded character where we would be expecting something different
|
||||
// and @c RE_UTF8_INVALID_SEQUENCE_END error is also logged
|
||||
// + @c RE_UTF8_INVALID_SEQUENCE_INVALID_BYTE: If an invalid UTF-8 byte has been found
|
||||
// + @c RE_UTF8_INVALID_SEQUENCE_CONBYTE: If during parsing the file we were expecting a continuation
|
||||
// byte and did not find it
|
||||
// + @c RE_UTF8_INVALID_SEQUENCE_END: If the null character is encountered in between bytes that should
|
||||
// have been continuation bytes
|
||||
// + @c RE_FILE_READ: If during reading the file there was an unknown read error
|
||||
// + @c RE_FILE_READ_BLOCK: If the read operation failed due to the file descriptor being occupied by another thread
|
||||
// + @c RE_FILE_MODE: If during reading the file the file descriptor's mode was not correctly set for reading
|
||||
// + @c RE_FILE_POS_OVERFLOW: If during reading, the current file position can't be represented by the system
|
||||
// + @c RE_INTERRUPT: If during reading, there was a system interrupt
|
||||
// + @c RE_FILE_IO: If there was a physical I/O error
|
||||
// + @c RE_FILE_NOSPACE: If reading failed due to insufficient storage space
|
||||
i_DECLIMEX_ int32_t rfFgetc_UTF8(FILE* f,uint32_t *c,char cp);
|
||||
// @brief Gets a unicode character from a UTF-16 Big Endian file descriptor
|
||||
//
|
||||
// This function attempts to assume a more modern fgetc() role for UTF-16 encoded files.
|
||||
// Reads bytes from the File descriptor @c f until a full UTF-16 unicode character has been read
|
||||
//
|
||||
// After this function the file pointer will have moved either by @c 2 or @c 4
|
||||
// bytes if the return value is positive. You can see how much by checking the return value.
|
||||
//
|
||||
// You shall need to provide an integer at @c c to contain either the decoded Unicode
|
||||
// codepoint or the Bigendian encoded UTF-16 bytes depending on the value of @c the cp argument.
|
||||
//
|
||||
// @param f A valid FILE descriptor from which to read the bytes
|
||||
// @param c Pass an int that will receive either the unicode code point value or
|
||||
// the UTF16 bytes depending on the value of the @c cp flag
|
||||
// @param cp A boolean flag. If @c true then the int passed at @c c will contain the unicode code point
|
||||
// of the read character, so the UTF-16 will be decoded.
|
||||
// If @c false the int passed at @c c will contain the value of the read bytes in UTF-16 without any decoding
|
||||
// @return Returns the number of bytes read (either @c 2 or @c 4) or an error if the function
|
||||
// fails for some reason. Possible error values are:
|
||||
// + @c RE_UTF16_INVALID_SEQUENCE: Either the read word or its surrogate pair if 4 bytes were read held illegal values
|
||||
// + @c RE_UTF16_NO_SURRPAIR: According to the first read word a surrogate pair was expected but none was found
|
||||
// + @c RE_FILE_EOF: The end of file has been found while reading. If the end of file is encountered
|
||||
// while we expect a UTF-16 surrogate pair an appropriate error is logged
|
||||
// + @c RE_FILE_READ: If during reading the file there was an unknown read error
|
||||
// + @c RE_FILE_READ_BLOCK: If the read operation failed due to the file descriptor being occupied by another thread
|
||||
// + @c RE_FILE_MODE: If during reading the file the file descriptor's mode was not correctly set for reading
|
||||
// + @c RE_FILE_POS_OVERFLOW: If during reading, the current file position can't be represented by the system
|
||||
// + @c RE_INTERRUPT: If during reading, there was a system interrupt
|
||||
// + @c RE_FILE_IO: If there was a physical I/O error
|
||||
// + @c RE_FILE_NOSPACE: If reading failed due to insufficient storage space
|
||||
i_DECLIMEX_ int32_t rfFgetc_UTF16BE(FILE* f,uint32_t *c,char cp);
|
||||
// @brief Gets a unicode character from a UTF-16 Little Endian file descriptor
|
||||
//
|
||||
// This function attempts to assume a more modern fgetc() role for UTF-16 encoded files.
|
||||
// Reads bytes from the File descriptor @c f until a full UTF-16 unicode character has been read
|
||||
//
|
||||
// After this function the file pointer will have moved either by @c 2 or @c 4
|
||||
// bytes if the return value is positive. You can see how much by checking the return value.
|
||||
//
|
||||
// You shall need to provide an integer at @c c to contain either the decoded Unicode
|
||||
// codepoint or the Bigendian encoded UTF-16 bytes depending on the value of @c the cp argument.
|
||||
//
|
||||
// @param f A valid FILE descriptor from which to read the bytes
|
||||
// @param c Pass an int that will receive either the unicode code point value or
|
||||
// the UTF16 bytes depending on the value of the @c cp flag
|
||||
// @param cp A boolean flag. If @c true then the int passed at @c c will contain the unicode code point
|
||||
// of the read character, so the UTF-16 will be decoded.
|
||||
// If @c false the int passed at @c c will contain the value of the read bytes in UTF-16 without any decoding
|
||||
// @return Returns the number of bytes read (either @c 2 or @c 4) or an error if the function
|
||||
// fails for some reason. Possible error values are:
|
||||
// + @c RE_UTF16_INVALID_SEQUENCE: Either the read word or its surrogate pair if 4 bytes were read held illegal values
|
||||
// + @c RE_UTF16_NO_SURRPAIR: According to the first read word a surrogate pair was expected but none was found
|
||||
// + @c RE_FILE_EOF: The end of file has been found while reading. If the end of file is encountered
|
||||
// while we expect a UTF-16 surrogate pair an appropriate error is logged
|
||||
// + @c RE_FILE_READ: If during reading the file there was an unknown read error
|
||||
// + @c RE_FILE_READ_BLOCK: If the read operation failed due to the file descriptor being occupied by another thread
|
||||
// + @c RE_FILE_MODE: If during reading the file the file descriptor's mode was not correctly set for reading
|
||||
// + @c RE_FILE_POS_OVERFLOW: If during reading, the current file position can't be represented by the system
|
||||
// + @c RE_INTERRUPT: If during reading, there was a system interrupt
|
||||
// + @c RE_FILE_IO: If there was a physical I/O error
|
||||
// + @c RE_FILE_NOSPACE: If reading failed due to insufficient storage space
|
||||
i_DECLIMEX_ int32_t rfFgetc_UTF16LE(FILE* f,uint32_t *c,char cp);
|
||||
// @brief Gets a unicode character from a UTF-32 Little Endian file descriptor
|
||||
//
|
||||
// This function attempts to assume a more modern fgetc() role for UTF-32 encoded files.
|
||||
// Reads bytes from the File descriptor @c f until a full UTF-32 unicode character has been read
|
||||
//
|
||||
// After this function the file pointer will have moved by @c 4
|
||||
// bytes if the return value is positive.
|
||||
//
|
||||
// You shall need to provide an integer at @c to contain the UTF-32 codepoint.
|
||||
//
|
||||
// @param f A valid FILE descriptor from which to read the bytes
|
||||
// @param c Pass an int that will receive either the unicode code point value or
|
||||
// the UTF16 bytes depending on the value of the @c cp flag
|
||||
// If @c false the int passed at @c c will contain the value of the read bytes in UTF-16 without any decoding
|
||||
// @return Returns either @c RF_SUCCESS for succesfull readin or one of the following errors:
|
||||
// + @c RE_FILE_EOF: The end of file has been found while reading.
|
||||
// + @c RE_FILE_READ: If during reading the file there was an unknown read error
|
||||
// + @c RE_FILE_READ_BLOCK: If the read operation failed due to the file descriptor being occupied by another thread
|
||||
// + @c RE_FILE_MODE: If during reading the file the file descriptor's mode was not correctly set for reading
|
||||
// + @c RE_FILE_POS_OVERFLOW: If during reading, the current file position can't be represented by the system
|
||||
// + @c RE_INTERRUPT: If during reading, there was a system interrupt
|
||||
// + @c RE_FILE_IO: If there was a physical I/O error
|
||||
// + @c RE_FILE_NOSPACE: If reading failed due to insufficient storage space
|
||||
i_DECLIMEX_ int32_t rfFgetc_UTF32LE(FILE* f,uint32_t *c);
|
||||
// @brief Gets a unicode character from a UTF-32 Big Endian file descriptor
|
||||
//
|
||||
// This function attempts to assume a more modern fgetc() role for UTF-32 encoded files.
|
||||
// Reads bytes from the File descriptor @c f until a full UTF-32 unicode character has been read
|
||||
//
|
||||
// After this function the file pointer will have moved by @c 4
|
||||
// bytes if the return value is positive.
|
||||
//
|
||||
// You shall need to provide an integer at @c to contain the UTF-32 codepoint.
|
||||
//
|
||||
// @param f A valid FILE descriptor from which to read the bytes
|
||||
// @param c Pass an int that will receive either the unicode code point value or
|
||||
// the UTF16 bytes depending on the value of the @c cp flag
|
||||
// If @c false the int passed at @c c will contain the value of the read bytes in UTF-16 without any decoding
|
||||
// @return Returns either @c RF_SUCCESS for succesfull readin or one of the following errors:
|
||||
// + @c RE_FILE_EOF: The end of file has been found while reading.
|
||||
// + @c RE_FILE_READ: If during reading the file there was an unknown read error
|
||||
// + @c RE_FILE_READ_BLOCK: If the read operation failed due to the file descriptor being occupied by another thread
|
||||
// + @c RE_FILE_MODE: If during reading the file the file descriptor's mode was not correctly set for reading
|
||||
// + @c RE_FILE_POS_OVERFLOW: If during reading, the current file position can't be represented by the system
|
||||
// + @c RE_INTERRUPT: If during reading, there was a system interrupt
|
||||
// + @c RE_FILE_IO: If there was a physical I/O error
|
||||
// + @c RE_FILE_NOSPACE: If reading failed due to insufficient storage space
|
||||
i_DECLIMEX_ int32_t rfFgetc_UTF32BE(FILE* f,uint32_t *c);
|
||||
|
||||
// @brief Moves a unicode character backwards in a big endian UTF-32 file stream
|
||||
//
|
||||
// @param f The file stream
|
||||
// @param c Returns the character we moved back to as a unicode codepoint
|
||||
// @return Returns either @c RF_SUCCESS for success or one of the following errors:
|
||||
// + @c RE_FILE_POS_OVERFLOW: If during trying to read the current file's position it can't be represented by the system
|
||||
// + @c RE_FILE_BAD: If The file descriptor is corrupt/illegal
|
||||
// + @c RE_FILE_NOTFILE: If the file descriptor is not a file but something else. e.g. socket.
|
||||
// + @c RE_FILE_GETFILEPOS: If the file's position could not be retrieved for some unknown reason
|
||||
// + @c RE_FILE_WRITE_BLOCK: While attempting to move the file pointer, it was occupied by another thread, and the no block flag was set
|
||||
// + @c RE_INTERRUPT: Operating on the file failed due to a system interrupt
|
||||
// + @c RE_FILE_IO: There was a physical I/O error
|
||||
// + @c RE_FILE_NOSPACE: There was no space on the device holding the file
|
||||
// + @c RE_FILE_NOTFILE: The device we attempted to manipulate is non-existent
|
||||
// + @c RE_FILE_READ: If during reading the file there was an error
|
||||
// + @c RE_FILE_READ_BLOCK: If during reading the file the read operation failed due to the file being occupied by another thread
|
||||
// + @c RE_FILE_MODE: If during reading the file the underlying file descriptor's mode was not correctly set for reading
|
||||
i_DECLIMEX_ int32_t rfFback_UTF32BE(FILE* f,uint32_t *c);
|
||||
// @brief Moves a unicode character backwards in a little endian UTF-32 file stream
|
||||
//
|
||||
// The file descriptor at @c f must have been opened in <b>binary</b> and not text mode. That means that if under
|
||||
// Windows make sure to call fopen with "wb", "rb" e.t.c. instead of the simple "w", "r" e.t.c. since the initial
|
||||
// default value under Windows is text mode. Alternatively you can set the initial value using _get_fmode() and
|
||||
// _set_fmode(). For more information take a look at the msdn pages here:
|
||||
// http://msdn.microsoft.com/en-us/library/ktss1a9b.aspx
|
||||
//
|
||||
// @param f The file stream
|
||||
// @param c Returns the character we moved back to as a unicode codepoint
|
||||
// @return Returns either @c RF_SUCCESS for success or one of the following errors:
|
||||
// + @c RE_FILE_POS_OVERFLOW: If during trying to read the current file's position it can't be represented by the system
|
||||
// + @c RE_FILE_BAD: If The file descriptor is corrupt/illegal
|
||||
// + @c RE_FILE_NOTFILE: If the file descriptor is not a file but something else. e.g. socket.
|
||||
// + @c RE_FILE_GETFILEPOS: If the file's position could not be retrieved for some unknown reason
|
||||
// + @c RE_FILE_WRITE_BLOCK: While attempting to move the file pointer, it was occupied by another thread, and the no block flag was set
|
||||
// + @c RE_INTERRUPT: Operating on the file failed due to a system interrupt
|
||||
// + @c RE_FILE_IO: There was a physical I/O error
|
||||
// + @c RE_FILE_NOSPACE: There was no space on the device holding the file
|
||||
// + @c RE_FILE_NOTFILE: The device we attempted to manipulate is non-existent
|
||||
// + @c RE_FILE_READ: If during reading the file there was an error
|
||||
// + @c RE_FILE_READ_BLOCK: If during reading the file the read operation failed due to the file being occupied by another thread
|
||||
// + @c RE_FILE_MODE: If during reading the file the underlying file descriptor's mode was not correctly set for reading
|
||||
i_DECLIMEX_ int32_t rfFback_UTF32LE(FILE* f,uint32_t *c);
|
||||
// @brief Moves a unicode character backwards in a big endian UTF-16 file stream
|
||||
//
|
||||
// The file descriptor at @c f must have been opened in <b>binary</b> and not text mode. That means that if under
|
||||
// Windows make sure to call fopen with "wb", "rb" e.t.c. instead of the simple "w", "r" e.t.c. since the initial
|
||||
// default value under Windows is text mode. Alternatively you can set the initial value using _get_fmode() and
|
||||
// _set_fmode(). For more information take a look at the msdn pages here:
|
||||
// http://msdn.microsoft.com/en-us/library/ktss1a9b.aspx
|
||||
//
|
||||
// @param f The file stream
|
||||
// @param c Returns the character we moved back to as a unicode codepoint
|
||||
// @return Returns either the number of bytes moved backwards (either @c 4 or @c 2) for success or one of the following errors:
|
||||
// + @c RE_UTF16_INVALID_SEQUENCE: Either the read word or its surrogate pair if 4 bytes were read held illegal values
|
||||
// + @c RE_FILE_POS_OVERFLOW: If during trying to read the current file's position it can't be represented by the system
|
||||
// + @c RE_FILE_BAD: If The file descriptor is corrupt/illegal
|
||||
// + @c RE_FILE_NOTFILE: If the file descriptor is not a file but something else. e.g. socket.
|
||||
// + @c RE_FILE_GETFILEPOS: If the file's position could not be retrieved for some unknown reason
|
||||
// + @c RE_FILE_WRITE_BLOCK: While attempting to move the file pointer, it was occupied by another thread, and the no block flag was set
|
||||
// + @c RE_INTERRUPT: Operating on the file failed due to a system interrupt
|
||||
// + @c RE_FILE_IO: There was a physical I/O error
|
||||
// + @c RE_FILE_NOSPACE: There was no space on the device holding the file
|
||||
// + @c RE_FILE_NOTFILE: The device we attempted to manipulate is non-existent
|
||||
// + @c RE_FILE_READ: If during reading the file there was an error
|
||||
// + @c RE_FILE_READ_BLOCK: If during reading the file the read operation failed due to the file being occupied by another thread
|
||||
// + @c RE_FILE_MODE: If during reading the file the underlying file descriptor's mode was not correctly set for reading
|
||||
i_DECLIMEX_ int32_t rfFback_UTF16BE(FILE* f,uint32_t *c);
|
||||
// @brief Moves a unicode character backwards in a little endian UTF-16 file stream
|
||||
//
|
||||
// The file descriptor at @c f must have been opened in <b>binary</b> and not text mode. That means that if under
|
||||
// Windows make sure to call fopen with "wb", "rb" e.t.c. instead of the simple "w", "r" e.t.c. since the initial
|
||||
// default value under Windows is text mode. Alternatively you can set the initial value using _get_fmode() and
|
||||
// _set_fmode(). For more information take a look at the msdn pages here:
|
||||
// http://msdn.microsoft.com/en-us/library/ktss1a9b.aspx
|
||||
//
|
||||
// @param f The file stream
|
||||
// @param c Returns the character we moved back to as a unicode codepoint
|
||||
// @return Returns either the number of bytes moved backwards (either @c 4 or @c 2) for success or one of the following errors:
|
||||
// + @c RE_UTF16_INVALID_SEQUENCE: Either the read word or its surrogate pair if 4 bytes were read held illegal values
|
||||
// + @c RE_FILE_POS_OVERFLOW: If during trying to read the current file's position it can't be represented by the system
|
||||
// + @c RE_FILE_BAD: If The file descriptor is corrupt/illegal
|
||||
// + @c RE_FILE_NOTFILE: If the file descriptor is not a file but something else. e.g. socket.
|
||||
// + @c RE_FILE_GETFILEPOS: If the file's position could not be retrieved for some unknown reason
|
||||
// + @c RE_FILE_WRITE_BLOCK: While attempting to move the file pointer, it was occupied by another thread, and the no block flag was set
|
||||
// + @c RE_INTERRUPT: Operating on the file failed due to a system interrupt
|
||||
// + @c RE_FILE_IO: There was a physical I/O error
|
||||
// + @c RE_FILE_NOSPACE: There was no space on the device holding the file
|
||||
// + @c RE_FILE_NOTFILE: The device we attempted to manipulate is non-existent
|
||||
// + @c RE_FILE_READ: If during reading the file there was an error
|
||||
// + @c RE_FILE_READ_BLOCK: If during reading the file the read operation failed due to the file being occupied by another thread
|
||||
// + @c RE_FILE_MODE: If during reading the file the underlying file descriptor's mode was not correctly set for reading
|
||||
i_DECLIMEX_ int32_t rfFback_UTF16LE(FILE* f,uint32_t *c);
|
||||
// @brief Moves a unicode character backwards in a UTF-8 file stream
|
||||
//
|
||||
// The file descriptor at @c f must have been opened in <b>binary</b> and not text mode. That means that if under
|
||||
// Windows make sure to call fopen with "wb", "rb" e.t.c. instead of the simple "w", "r" e.t.c. since the initial
|
||||
// default value under Windows is text mode. Alternatively you can set the initial value using _get_fmode() and
|
||||
// _set_fmode(). For more information take a look at the msdn pages here:
|
||||
// http://msdn.microsoft.com/en-us/library/ktss1a9b.aspx
|
||||
//
|
||||
// @param f The file stream
|
||||
// @param c Returns the character we moved back to as a unicode codepoint
|
||||
// @return Returns either the number of bytes moved backwards for success (either @c 4, @c 3, @c 2 or @c 1) or one of the following errors:
|
||||
// + @c RE_UTF8_INVALID_SEQUENCE: If during moving bacwards in the file unexpected UTF-8 bytes were found
|
||||
// + @c RE_FILE_POS_OVERFLOW: If during trying to read the current file's position it can't be represented by the system
|
||||
// + @c RE_FILE_BAD: If The file descriptor is corrupt/illegal
|
||||
// + @c RE_FILE_NOTFILE: If the file descriptor is not a file but something else. e.g. socket.
|
||||
// + @c RE_FILE_GETFILEPOS: If the file's position could not be retrieved for some unknown reason
|
||||
// + @c RE_FILE_WRITE_BLOCK: While attempting to move the file pointer, it was occupied by another thread, and the no block flag was set
|
||||
// + @c RE_INTERRUPT: Operating on the file failed due to a system interrupt
|
||||
// + @c RE_FILE_IO: There was a physical I/O error
|
||||
// + @c RE_FILE_NOSPACE: There was no space on the device holding the file
|
||||
// + @c RE_FILE_NOTFILE: The device we attempted to manipulate is non-existent
|
||||
// + @c RE_FILE_READ: If during reading the file there was an error
|
||||
// + @c RE_FILE_READ_BLOCK: If during reading the file the read operation failed due to the file being occupied by another thread
|
||||
// + @c RE_FILE_MODE: If during reading the file the underlying file descriptor's mode was not correctly set for reading
|
||||
i_DECLIMEX_ int32_t rfFback_UTF8(FILE* f,uint32_t *c);
|
||||
|
||||
// @brief Opens another process as a pipe
|
||||
//
|
||||
// This function is a cross-platform popen wrapper. In linux it uses popen and in Windows it uses
|
||||
// _popen.
|
||||
// @lmsFunction
|
||||
// @param command The string with the command to execute. Is basically the name of the program/process you want to spawn
|
||||
// with its full path and its parameters. @inhtype{String,StringX} @tmpSTR
|
||||
// @param mode The mode you want the pipe to work in. There are two possible values:
|
||||
// + @c "r" The calling process can read the spawned command's standard output via the returned stream.
|
||||
// + @c "w" The calling process can write to the spawned command's standard input via the returned stream.
|
||||
//
|
||||
// Anything else will result in an error
|
||||
// @return For success popen will return a FILE descriptor that can be used to either read or write from the pipe.
|
||||
// If there was an error @c 0 is returned and an error is logged.
|
||||
#ifdef RF_IAMHERE_FOR_DOXYGEN
|
||||
i_DECLIMEX_ FILE* rfPopen(void* command,const char* mode);
|
||||
#else
|
||||
i_DECLIMEX_ FILE* i_rfPopen(void* command,const char* mode);
|
||||
#define rfPopen(i_CMD_,i_MODE_) i_rfLMS_WRAP2(FILE*,i_rfPopen,i_CMD_,i_MODE_)
|
||||
#endif
|
||||
|
||||
// @brief Closes a pipe
|
||||
//
|
||||
// This function is a cross-platform wrapper for pclose. It closes a file descriptor opened with @ref rfPopen() and
|
||||
// returns the exit code of the process that was running
|
||||
// @param stream The file descriptor of the pipe returned by @ref rfPopen() that we want to close
|
||||
// @return Returns the exit code of the process or -1 if there was an error
|
||||
i_DECLIMEX_ int rfPclose(FILE* stream);
|
||||
|
||||
// @} End of I/O group
|
||||
|
||||
#ifdef __cplusplus
|
||||
}///closing bracket for calling from C++
|
||||
#endif
|
||||
|
||||
|
||||
#endif//include guards end
|
||||
2348
samples/C/rfc_string.c
Normal file
2348
samples/C/rfc_string.c
Normal file
File diff suppressed because it is too large
Load Diff
1459
samples/C/rfc_string.h
Normal file
1459
samples/C/rfc_string.h
Normal file
File diff suppressed because it is too large
Load Diff
1363
samples/C/wglew.h
Normal file
1363
samples/C/wglew.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,3 @@
|
||||
(************************************************************************)
|
||||
(* v * The Coq Proof Assistant / The Coq Development Team *)
|
||||
(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2010 *)
|
||||
(* \VV/ **************************************************************)
|
||||
(* // * This file is distributed under the terms of the *)
|
||||
(* * GNU Lesser General Public License Version 2.1 *)
|
||||
(************************************************************************)
|
||||
|
||||
(** This file is deprecated, for a tree on list, use [Mergesort.v]. *)
|
||||
|
||||
(** A development of Treesort on Heap trees. It has an average
|
||||
complexity of O(n.log n) but of O(n²) in the worst case (e.g. if
|
||||
the list is already sorted) *)
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
(************************************************************************)
|
||||
(* v * The Coq Proof Assistant / The Coq Development Team *)
|
||||
(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2010 *)
|
||||
(* \VV/ **************************************************************)
|
||||
(* // * This file is distributed under the terms of the *)
|
||||
(* * GNU Lesser General Public License Version 2.1 *)
|
||||
(************************************************************************)
|
||||
|
||||
Require Import Omega Relations Multiset SetoidList.
|
||||
|
||||
(** This file is deprecated, use [Permutation.v] instead.
|
||||
|
||||
@@ -1,17 +1,5 @@
|
||||
(************************************************************************)
|
||||
(* v * The Coq Proof Assistant / The Coq Development Team *)
|
||||
(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2010 *)
|
||||
(* \VV/ **************************************************************)
|
||||
(* // * This file is distributed under the terms of the *)
|
||||
(* * GNU Lesser General Public License Version 2.1 *)
|
||||
(************************************************************************)
|
||||
|
||||
(*********************************************************************)
|
||||
(** * List permutations as a composition of adjacent transpositions *)
|
||||
(*********************************************************************)
|
||||
|
||||
(* Adapted in May 2006 by Jean-Marc Notin from initial contents by
|
||||
Laurent Théry (Huffmann contribution, October 2003) *)
|
||||
Laurent Thery (Huffmann contribution, October 2003) *)
|
||||
|
||||
Require Import List Setoid Compare_dec Morphisms.
|
||||
Import ListNotations. (* For notations [] and [a;b;c] *)
|
||||
|
||||
@@ -1,10 +1,2 @@
|
||||
(************************************************************************)
|
||||
(* v * The Coq Proof Assistant / The Coq Development Team *)
|
||||
(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2010 *)
|
||||
(* \VV/ **************************************************************)
|
||||
(* // * This file is distributed under the terms of the *)
|
||||
(* * GNU Lesser General Public License Version 2.1 *)
|
||||
(************************************************************************)
|
||||
|
||||
Require Export Sorted.
|
||||
Require Export Mergesort.
|
||||
|
||||
42
samples/Ecl/sample.ecl
Normal file
42
samples/Ecl/sample.ecl
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Multi-line comment
|
||||
*/
|
||||
#option ('slidingJoins', true);
|
||||
|
||||
namesRecord :=
|
||||
RECORD
|
||||
string20 surname;
|
||||
string10 forename;
|
||||
integer2 age;
|
||||
integer2 dadAge;
|
||||
integer2 mumAge;
|
||||
END;
|
||||
|
||||
namesRecord2 :=
|
||||
record
|
||||
string10 extra;
|
||||
namesRecord;
|
||||
end;
|
||||
|
||||
namesTable := dataset('x',namesRecord,FLAT);
|
||||
namesTable2 := dataset('y',namesRecord2,FLAT);
|
||||
|
||||
integer2 aveAgeL(namesRecord l) := (l.dadAge+l.mumAge)/2;
|
||||
integer2 aveAgeR(namesRecord2 r) := (r.dadAge+r.mumAge)/2;
|
||||
|
||||
// Standard join on a function of left and right
|
||||
output(join(namesTable, namesTable2, aveAgeL(left) = aveAgeR(right)));
|
||||
|
||||
//Several simple examples of sliding join syntax
|
||||
output(join(namesTable, namesTable2, left.age >= right.age - 10 and left.age <= right.age +10));
|
||||
output(join(namesTable, namesTable2, left.age between right.age - 10 and right.age +10));
|
||||
output(join(namesTable, namesTable2, left.age between right.age + 10 and right.age +30));
|
||||
output(join(namesTable, namesTable2, left.age between (right.age + 20) - 10 and (right.age +20) + 10));
|
||||
output(join(namesTable, namesTable2, aveAgeL(left) between aveAgeR(right)+10 and aveAgeR(right)+40));
|
||||
|
||||
//Same, but on strings. Also includes age to ensure sort is done by non-sliding before sliding.
|
||||
output(join(namesTable, namesTable2, left.surname between right.surname[1..10]+'AAAAAAAAAA' and right.surname[1..10]+'ZZZZZZZZZZ' and left.age=right.age));
|
||||
output(join(namesTable, namesTable2, left.surname between right.surname[1..10]+'AAAAAAAAAA' and right.surname[1..10]+'ZZZZZZZZZZ' and left.age=right.age,all));
|
||||
|
||||
//This should not generate a self join
|
||||
output(join(namesTable, namesTable, left.age between right.age - 10 and right.age +10));
|
||||
127
samples/Elm/Basic.elm
Normal file
127
samples/Elm/Basic.elm
Normal file
@@ -0,0 +1,127 @@
|
||||
|
||||
import List (intercalate,intersperse)
|
||||
import Website.Skeleton
|
||||
import Website.ColorScheme
|
||||
|
||||
addFolder folder lst =
|
||||
let add (x,y) = (x, folder ++ y ++ ".elm") in
|
||||
let f (n,xs) = (n, map add xs) in
|
||||
map f lst
|
||||
|
||||
elements = addFolder "Elements/"
|
||||
[ ("Primitives",
|
||||
[ ("Text" , "HelloWorld")
|
||||
, ("Images", "Image")
|
||||
, ("Fitted Images", "FittedImage")
|
||||
, ("Videos", "Video")
|
||||
, ("Markdown", "Markdown")
|
||||
])
|
||||
, ("Formatting",
|
||||
[ ("Size" , "Size")
|
||||
, ("Opacity" , "Opacity")
|
||||
, ("Text" , "Text")
|
||||
, ("Typeface", "Typeface")
|
||||
])
|
||||
, ("Layout",
|
||||
[ ("Simple Flow", "FlowDown1a")
|
||||
, ("Flow Down" , "FlowDown2")
|
||||
, ("Layers" , "Layers")
|
||||
, ("Positioning", "Position")
|
||||
, ("Spacers" , "Spacer")
|
||||
])
|
||||
, ("Collage", [ ("Lines" , "Lines")
|
||||
, ("Shapes" , "Shapes")
|
||||
, ("Sprites" , "Sprite")
|
||||
, ("Elements" , "ToForm")
|
||||
, ("Colors" , "Color")
|
||||
, ("Textures" , "Texture")
|
||||
, ("Transforms", "Transforms")
|
||||
])
|
||||
]
|
||||
|
||||
|
||||
functional = addFolder "Functional/"
|
||||
[ ("Recursion",
|
||||
[ ("Factorial" , "Factorial")
|
||||
, ("List Length", "Length")
|
||||
, ("Zip" , "Zip")
|
||||
, ("Quick Sort" , "QuickSort")
|
||||
])
|
||||
, ("Functions",
|
||||
[ ("Anonymous Functions", "Anonymous")
|
||||
, ("Application" , "Application")
|
||||
, ("Composition" , "Composition")
|
||||
, ("Infix Operators" , "Infix")
|
||||
])
|
||||
, ("Higher-Order",
|
||||
[ ("Map" , "Map")
|
||||
, ("Fold" , "Sum")
|
||||
, ("Filter" , "Filter")
|
||||
, ("ZipWith", "ZipWith")
|
||||
])
|
||||
, ("Data Types",
|
||||
[ ("Maybe", "Maybe")
|
||||
, ("Boolean Expressions", "BooleanExpressions")
|
||||
, ("Tree", "Tree")
|
||||
])
|
||||
]
|
||||
|
||||
reactive = addFolder "Reactive/"
|
||||
[ ("Mouse", [ ("Position", "Position")
|
||||
, ("Presses" , "IsDown")
|
||||
, ("Clicks" , "CountClicks")
|
||||
, ("Position+Image", "ResizeYogi")
|
||||
, ("Position+Collage" , "Transforms")
|
||||
-- , ("Hover" , "IsAbove")
|
||||
])
|
||||
,("Keyboard",[ ("Keys Down" , "KeysDown")
|
||||
, ("Key Presses", "CharPressed")
|
||||
])
|
||||
, ("Window", [ ("Size", "ResizePaint")
|
||||
, ("Centering", "Centering")
|
||||
])
|
||||
, ("Time", [ ("Before and After", "Between")
|
||||
, ("Every" , "Every")
|
||||
, ("Clock" , "Clock")
|
||||
])
|
||||
, ("Input", [ ("Text Fields", "TextField")
|
||||
, ("Passwords" , "Password")
|
||||
, ("Check Boxes", "CheckBox")
|
||||
, ("String Drop Down", "StringDropDown")
|
||||
, ("Drop Down", "DropDown")
|
||||
])
|
||||
, ("Random", [ ("Randomize", "Randomize") ])
|
||||
, ("HTTP", [ ("Zip Codes", "ZipCodes") ])
|
||||
, ("Filters",[ ("Sample", "SampleOn")
|
||||
, ("Keep If", "KeepIf")
|
||||
, ("Drop Repeats", "DropRepeats")
|
||||
])
|
||||
]
|
||||
|
||||
example (name, loc) = Text.link ("/edit/examples/" ++ loc) (toText name)
|
||||
toLinks (title, links) =
|
||||
flow right [ width 130 (text $ toText " " ++ italic (toText title))
|
||||
, text (intercalate (bold . Text.color accent4 $ toText " · ") $ map example links)
|
||||
]
|
||||
|
||||
insertSpace lst = case lst of { x:xs -> x : spacer 1 5 : xs ; [] -> [] }
|
||||
|
||||
subsection w (name,info) =
|
||||
flow down . insertSpace . intersperse (spacer 1 1) . map (width w) $
|
||||
(text . bold $ toText name) : map toLinks info
|
||||
|
||||
words = [markdown|
|
||||
|
||||
### Basic Examples
|
||||
|
||||
Each example listed below focuses on a single function or concept.
|
||||
These examples demonstrate all of the basic building blocks of Elm.
|
||||
|
||||
|]
|
||||
|
||||
content w =
|
||||
words : map (subsection w) [ ("Display",elements), ("React",reactive), ("Compute",functional) ]
|
||||
|
||||
exampleSets w = flow down . map (width w) . intersperse (plainText " ") $ content w
|
||||
|
||||
main = lift (skeleton exampleSets) Window.width
|
||||
32
samples/Elm/QuickSort.elm
Normal file
32
samples/Elm/QuickSort.elm
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
main = asText (qsort [3,9,1,8,5,4,7])
|
||||
|
||||
qsort lst =
|
||||
case lst of
|
||||
x:xs -> qsort (filter ((>=)x) xs) ++ [x] ++ qsort (filter ((<)x) xs)
|
||||
[] -> []
|
||||
|
||||
|
||||
{---------------------
|
||||
|
||||
QuickSort works as follows:
|
||||
- Choose a pivot element which be placed in the "middle" of the sorted list.
|
||||
In our case we are choosing the first element as the pivot.
|
||||
- Gather all of the elements less than the pivot (the first filter).
|
||||
We know that these must come before our pivot element in the sorted list.
|
||||
Note: ((>=)x) === (\y -> (>=) x y) === (\y -> x >= y)
|
||||
- Gather all of the elements greater than the pivot (the second filter).
|
||||
We know that these must come after our pivot element in the sorted list.
|
||||
- Run `qsort` on the lesser elements, producing a sorted list that contains
|
||||
only elements less than the pivot. Put these before the pivot.
|
||||
- Run `qsort` on the greater elements, producing a sorted list. Put these
|
||||
after the pivot.
|
||||
|
||||
Note that choosing a bad pivot can have bad effects. Take a sorted list with
|
||||
N elements. The pivot will always be the lowest member, meaning that it does
|
||||
not divide the list very evenly. The list of lessers has 0 elements
|
||||
and the list of greaters has N-1 elemens. This means qsort will be called
|
||||
N times, each call looking through the entire list. This means, in the worst
|
||||
case, QuickSort will make N^2 comparisons.
|
||||
|
||||
----------------------}
|
||||
91
samples/Elm/Tree.elm
Normal file
91
samples/Elm/Tree.elm
Normal file
@@ -0,0 +1,91 @@
|
||||
|
||||
{-----------------------------------------------------------------
|
||||
|
||||
Overview: A "Tree" represents a binary tree. A "Node" in a binary
|
||||
tree always has two children. A tree can also be "Empty". Below
|
||||
I have defined "Tree" and a number of useful functions.
|
||||
|
||||
This example also includes some challenge problems :)
|
||||
|
||||
-----------------------------------------------------------------}
|
||||
|
||||
|
||||
data Tree a = Node a (Tree a) (Tree a) | Empty
|
||||
|
||||
empty = Empty
|
||||
singleton v = Node v Empty Empty
|
||||
|
||||
insert x tree =
|
||||
case tree of
|
||||
Empty -> singleton x
|
||||
Node y left right ->
|
||||
if x == y then tree else
|
||||
if x < y then Node y (insert x left) right
|
||||
else Node y left (insert x right)
|
||||
|
||||
fromList xs = foldl insert empty xs
|
||||
|
||||
depth tree =
|
||||
case tree of
|
||||
Node v left right -> 1 + max (depth left) (depth right)
|
||||
Empty -> 0
|
||||
|
||||
map f tree =
|
||||
case tree of
|
||||
Node v left right -> Node (f v) (map f left) (map f right)
|
||||
Empty -> Empty
|
||||
|
||||
t1 = fromList [1,2,3]
|
||||
t2 = fromList [2,1,3]
|
||||
|
||||
main = flow down [ display "depth" depth t1
|
||||
, display "depth" depth t2
|
||||
, display "map ((+)1)" (map ((+)1)) t2
|
||||
]
|
||||
|
||||
display name f v =
|
||||
text . monospace . toText $
|
||||
concat [ show (f v), " ⇐ ", name, " ", show v ]
|
||||
|
||||
{-----------------------------------------------------------------
|
||||
|
||||
Exercises:
|
||||
|
||||
(1) Sum all of the elements of a tree.
|
||||
|
||||
sum :: Tree Number -> Number
|
||||
|
||||
(2) Flatten a tree into a list.
|
||||
|
||||
flatten :: Tree a -> [a]
|
||||
|
||||
(3) Check to see if an element is in a given tree.
|
||||
|
||||
isElement :: a -> Tree a -> Bool
|
||||
|
||||
(4) Write a general fold function that acts on trees. The fold
|
||||
function does not need to guarantee a particular order of
|
||||
traversal.
|
||||
|
||||
fold :: (a -> b -> b) -> b -> Tree a -> b
|
||||
|
||||
(5) Use "fold" to do exercises 1-3 in one line each. The best
|
||||
readable versions I have come up have the following length
|
||||
in characters including spaces and function name:
|
||||
sum: 16
|
||||
flatten: 21
|
||||
isElement: 46
|
||||
See if you can match or beat me! Don't forget about currying
|
||||
and partial application!
|
||||
|
||||
(6) Can "fold" be used to implement "map" or "depth"?
|
||||
|
||||
(7) Try experimenting with different ways to traverse a
|
||||
tree: pre-order, in-order, post-order, depth-first, etc.
|
||||
More info at: http://en.wikipedia.org/wiki/Tree_traversal
|
||||
|
||||
-----------------------------------------------------------------}
|
||||
|
||||
|
||||
|
||||
|
||||
6
samples/Handlebars/basic.handlebars
Normal file
6
samples/Handlebars/basic.handlebars
Normal file
@@ -0,0 +1,6 @@
|
||||
<div class="entry">
|
||||
<h1>{{title}}</h1>
|
||||
<div class="body">
|
||||
{{body}}
|
||||
</div>
|
||||
</div>
|
||||
11
samples/Handlebars/each.hbs
Normal file
11
samples/Handlebars/each.hbs
Normal file
@@ -0,0 +1,11 @@
|
||||
<div class="post">
|
||||
<h1>By {{fullName author}}</h1>
|
||||
<div class="body">{{body}}</div>
|
||||
|
||||
<h1>Comments</h1>
|
||||
|
||||
{{#each comments}}
|
||||
<h2>By {{fullName author}}</h2>
|
||||
<div class="body">{{body}}</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
70
samples/Nginx/filenames/nginx.conf
Normal file
70
samples/Nginx/filenames/nginx.conf
Normal file
@@ -0,0 +1,70 @@
|
||||
user www www;
|
||||
worker_processes 5;
|
||||
error_log logs/error.log;
|
||||
pid logs/nginx.pid;
|
||||
worker_rlimit_nofile 8192;
|
||||
|
||||
events {
|
||||
worker_connections 4096;
|
||||
}
|
||||
|
||||
http {
|
||||
include conf/mime.types;
|
||||
include /etc/nginx/proxy.conf;
|
||||
include /etc/nginx/fastcgi.conf;
|
||||
index index.html index.htm index.php;
|
||||
|
||||
default_type application/octet-stream;
|
||||
log_format main '$remote_addr - $remote_user [$time_local] $status '
|
||||
'"$request" $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
access_log logs/access.log main;
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
|
||||
|
||||
server { # php/fastcgi
|
||||
listen 80;
|
||||
server_name domain1.com www.domain1.com;
|
||||
access_log logs/domain1.access.log main;
|
||||
root html;
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass 127.0.0.1:1025;
|
||||
}
|
||||
}
|
||||
|
||||
server { # simple reverse-proxy
|
||||
listen 80;
|
||||
server_name domain2.com www.domain2.com;
|
||||
access_log logs/domain2.access.log main;
|
||||
|
||||
# serve static files
|
||||
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
|
||||
root /var/www/virtual/big.server.com/htdocs;
|
||||
expires 30d;
|
||||
}
|
||||
|
||||
# pass requests for dynamic content to rails/turbogears/zope, et al
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
}
|
||||
}
|
||||
|
||||
upstream big_server_com {
|
||||
server 127.0.0.3:8000 weight=5;
|
||||
server 127.0.0.3:8001 weight=5;
|
||||
server 192.168.0.1:8000;
|
||||
server 192.168.0.1:8001;
|
||||
}
|
||||
|
||||
server { # simple load balancing
|
||||
listen 80;
|
||||
server_name big.server.com;
|
||||
access_log logs/big.server.access.log main;
|
||||
|
||||
location / {
|
||||
proxy_pass http://big_server_com;
|
||||
}
|
||||
}
|
||||
}
|
||||
4
samples/PHP/php-script.script!
Normal file
4
samples/PHP/php-script.script!
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
echo "PHP\n";
|
||||
4
samples/PHP/php.script!
Normal file
4
samples/PHP/php.script!
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
echo "PHP\n";
|
||||
1
samples/Shell/filenames/.bash_logout
Normal file
1
samples/Shell/filenames/.bash_logout
Normal file
@@ -0,0 +1 @@
|
||||
/usr/bin/clear
|
||||
@@ -1 +1,36 @@
|
||||
export PATH="/usr/local/bin:/usr/bin:/bin"
|
||||
##
|
||||
# Environment...
|
||||
##
|
||||
# Set up some variables for 'screen'
|
||||
if [ -z "${SCREENDIR}" ];then echo -n
|
||||
export SCREENDIR="${HOME}/.screen"
|
||||
# Save my screen sockets within my $HOME dir
|
||||
fi
|
||||
## PATH
|
||||
export PATH=/usr/local/bin:/usr/local/sbin:/usr/xpg4/bin:/usr/sbin:/usr/bin:/usr/sfw/bin:/usr/ccs/bin:/usr/openwin/bin:/opt/mysql/current/bin
|
||||
export MANPATH=/usr/local/man:/usr/share/man
|
||||
|
||||
## Random ENV...
|
||||
# Set $TERM to 'vt100' (a safe default) if, for some
|
||||
# reason, it is set to 'network' (which is not valid!)
|
||||
if [ ${TERM} == 'network' ];then echo -n
|
||||
export TERM='vt100'
|
||||
# not 'nsterm' because if its 'network' we're
|
||||
# probly not in Terminal.app
|
||||
fi
|
||||
# Set $COLORTERM, all this does is trick *some* apps into
|
||||
# using color in the terminal, which should happen anyway.
|
||||
if [ -z "${COLORTERM}" ];then echo -n
|
||||
export COLORTERM="${TERM}"
|
||||
fi
|
||||
# another color option, this one for BSD's ls
|
||||
if [ -z "${CLICOLOR}" ];then echo -n
|
||||
export CLICOLOR='1' # can be set to anything, actually
|
||||
fi
|
||||
# If $DISPLAY is not already set, set it!
|
||||
if [ -z "${DISPLAY}" ];then echo -n
|
||||
export DISPLAY=':0'
|
||||
fi
|
||||
##
|
||||
# Source the bash rc file
|
||||
[ -r "${HOME}/.bashrc" ] && . "${HOME}/.bashrc"
|
||||
|
||||
@@ -1 +1,119 @@
|
||||
export PATH="/usr/local/bin:/usr/bin:/bin"
|
||||
##
|
||||
# Functions... *MUCH* better than aliases, and they do more too!
|
||||
# but they clutter the environment... (try typing just 'set' at the prompt)
|
||||
##
|
||||
# The reason that some of these are... odd... is because
|
||||
# I had to convert them early because bash can't do positional
|
||||
# arguments in aliases! functionName () { do something $@<-arguments ; }
|
||||
function ls { command ls -Fh "$@"; }
|
||||
# 'command ls' to prevent loop; -A for .file, -F for dir/ link@,
|
||||
# -h for 5k 3m 1g, -o for printing flags (uchg)...
|
||||
function l { ls -l "$@"; } # -l to list in long format...
|
||||
function ll { l "$@" | less -XF ; } # pipe into 'more'
|
||||
|
||||
##
|
||||
# Tips and Ticks... from http://www.caliban.org/bash/index.shtml
|
||||
##
|
||||
# The $CDPATH variable is so that you can be in /path/to/something and 'cd'
|
||||
# to 'somethingElse' and end up in /not/the/same/path/to/somethingElse.
|
||||
# iWould use it if it didn't ALWAYS echo the directory it changes to!
|
||||
#CDPATH='.:~'
|
||||
#
|
||||
# HISTIGNORE="&:l:ls:ls *:l *:cd:cd *:[bf]g:exit:quit:q:sleep *"
|
||||
# History ignores commands that include any l/ls/cd etc
|
||||
# This kicks-ass! It drops repeats and other useless
|
||||
# things from the command history!
|
||||
HISTIGNORE="[bf]g:exit:quit:q:sleep *"
|
||||
# I want to see l/ls/cd in my history
|
||||
HISTCONTROL=ignoreboth
|
||||
# ignores both commands that start with a space or a tab, and duplicates
|
||||
# other options are as follows:
|
||||
# `ignorespace' means to not enter lines which begin with a space or tab into the history list.
|
||||
# `ignoredups' means to not enter lines which match the last entered line.
|
||||
# `ignoreboth' combines the two options.
|
||||
|
||||
shopt -s cdspell extglob progcomp
|
||||
# Spell check for 'cd', extended globbing, programmable completion
|
||||
|
||||
##
|
||||
# Bash Completion... Cannibalised from bash_completion 20030929
|
||||
# Completion defaults... Yes, its long...
|
||||
# Basically this sets up many useful defaults for command completion, these
|
||||
# should probly be built into bash. Use bash_completions itself if you want
|
||||
# more functionality and don't mind the hacks it uses.
|
||||
complete -f -X '!*.?(t)bz2' bunzip2 bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep
|
||||
complete -f -X '!*.@(zip|ZIP|jar|JAR|exe|EXE|pk3|war|wsz|ear|zargo|xpi)' unzip zipinfo
|
||||
complete -f -X '*.Z' compress znew
|
||||
complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' gunzip zcmp zdiff zcat zegrep zfgrep zgrep zless zmore
|
||||
complete -f -X '!*.Z' uncompress
|
||||
complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|GIF|JP?(E)G|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA)' ee display
|
||||
complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|GIF|JPG|JP?(E)G|TIF?(F)|PNG|P[BGP]M|BMP|X[BP]M|RLE|RGB|PCX|FITS|PM)' xv qiv
|
||||
complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.Z))' gv ggv
|
||||
complete -f -X '!*.@(dvi|DVI)?(.@(gz|Z|bz2))' xdvi
|
||||
complete -f -X '!*.@(dvi|DVI)' dvips dviselect dvitype
|
||||
complete -f -X '!*.@(pdf|PDF)' acroread xpdf
|
||||
complete -f -X '!*.texi*' makeinfo texi2html
|
||||
complete -f -X '!*.@(?(la)tex|?(LA)TEX|texi|TEXI|dtx|DTX|ins|INS)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi
|
||||
complete -f -X '!*.@(mp3|MP3|m3u)' mpg123 mpg321
|
||||
complete -f -X '!*.@(mp?(e)g|MP?(E)G|wma|avi|AVI|asf|vob|bin|dat|vcd|ps|pes|fli|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp3|MP3|ogg|OGG|ogm|OGM|mp4|MP4|wav|WAV)' xine
|
||||
complete -f -X '!*.@(avi|asf|wmv)' aviplay
|
||||
complete -f -X '!*.@(rm|ram|smi?(l))' realplay
|
||||
complete -f -X '!*.@(mp?(e)g|avi|mov|qt)' xanim
|
||||
complete -f -X '!*.@(ogg|OGG|m3u)' ogg123
|
||||
complete -f -X '!*.@(mp3|MP3|ogg|OGG|pls|m3u)' gqmpeg freeamp
|
||||
complete -f -X '!*.@(mp[23]|MP[23]|ogg|OGG|wav|WAV|pls|m3u|xm|mod|s[3t]m|it|mtm|ult|flac)' xmms
|
||||
complete -f -X '!*.fig' xfig
|
||||
complete -f -X '!*.@(mid?(i))' timidity playmidi
|
||||
complete -f -X '.*|*.@(o|so|so.!(conf)|a|tar?(.@(gz|bz2))|tgz|tbz2|rpm|zip|ZIP|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mp?(e)g|MPG|avi|AVI|asf|ASF|ogg|OGG|class|CLASS)' vi vim gvim rvim view rview rgvim rgview gview emacs
|
||||
complete -f -X '!*.@(exe|EXE|com|COM|scr|SCR)' wine
|
||||
complete -f -X '!*.@(zip|ZIP|z|Z|gz|GZ|tgz|TGZ)' bzme
|
||||
complete -f -X '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx opera w3m galeon curl dillo elinks links
|
||||
#
|
||||
complete -u su passwd groups # user commands see only users
|
||||
complete -A stopped -P '%' bg # bg completes with stopped jobs
|
||||
complete -j -P '%' fg jobs disown # other job commands
|
||||
complete -v readonly unset export # readonly and unset complete with shell variables
|
||||
complete -A setopt set # set completes with set options
|
||||
complete -A shopt shopt # shopt completes with shopt options
|
||||
complete -A helptopic help # helptopics
|
||||
complete -a unalias # unalias completes with aliases
|
||||
complete -A binding bind # bind completes with readline bindings (make this more intelligent)
|
||||
complete -c command type which man #sudo # type, which, man complete on commands
|
||||
complete -d pushd cd rmdir # Make directory commands see only directories
|
||||
complete -W ' ' alias # no filenames for alias,
|
||||
|
||||
##
|
||||
# Set the prompt
|
||||
##
|
||||
PS1="[\h:\w] \[\033[1;34m\]\u\[\033[0m\]\\$ "
|
||||
# My prompt line: "[gaelicWizard:~/Documents] user$ " user is in blue
|
||||
# Or: "[gaelicWizard:~/Documents] root# " root is in blue
|
||||
##
|
||||
# Aliases:
|
||||
##
|
||||
# Aliases frequently used...
|
||||
alias ..='cd ..;l'
|
||||
alias cd..='cd ..'
|
||||
alias which='type' # 'which' in (t)csh is same(?) as 'type' in bash...
|
||||
alias quit='exit'
|
||||
alias q='quit' # and 'q' is even shorter! :-D
|
||||
alias v='vim'
|
||||
alias rehash='. ~/.bashrc;' # source ~/.bashrc after I edit it
|
||||
alias pg='ps -afe|grep -v grep|grep'
|
||||
alias make='gmake'
|
||||
alias patch='gpatch'
|
||||
alias sed='gsed'
|
||||
alias awk='nawk'
|
||||
alias diff='gdiff'
|
||||
alias grep='ggrep'
|
||||
alias find='gfind'
|
||||
alias ps='/usr/ucb/ps'
|
||||
alias whoami='/usr/ucb/whoami'
|
||||
alias ping='ping -s'
|
||||
alias man='GROFF_NO_SGR= TCAT="less -s" TROFF="groff -Tascii" man -t'
|
||||
|
||||
|
||||
# The rest are uncategorised and fairly random... :-)
|
||||
shopt -s histappend
|
||||
PROMPT_COMMAND='echo -ne "\033]0;${USER} on ${HOSTNAME} at ${PWD}\007" && history -a'
|
||||
export PATH=/usr/local/bin:/usr/local/sbin:/usr/xpg4/bin:/usr/sbin:/usr/bin:/usr/sfw/bin:/usr/ccs/bin:/usr/openwin/bin:/opt/mysql/current/bin
|
||||
|
||||
5
samples/Shell/filenames/.cshrc
Normal file
5
samples/Shell/filenames/.cshrc
Normal file
@@ -0,0 +1,5 @@
|
||||
umask 022
|
||||
set path=(/opt/local/bin /opt/local/sbin /bin /usr/bin)
|
||||
if ( $?prompt ) then
|
||||
set history=32
|
||||
endif
|
||||
2
samples/Shell/filenames/.login
Normal file
2
samples/Shell/filenames/.login
Normal file
@@ -0,0 +1,2 @@
|
||||
stty -istrip
|
||||
# setenv TERM `tset -Q -`
|
||||
3
samples/Shell/filenames/.zlogout
Normal file
3
samples/Shell/filenames/.zlogout
Normal file
@@ -0,0 +1,3 @@
|
||||
# Store dirs stack
|
||||
# See ~/.dotfiles/oh-my-zsh/plugins/dirspersist.plugin.zsh
|
||||
dirpersiststore
|
||||
28
samples/Shell/filenames/.zprofile
Normal file
28
samples/Shell/filenames/.zprofile
Normal file
@@ -0,0 +1,28 @@
|
||||
##############################################################################
|
||||
#Import the shell-agnostic (Bash or Zsh) environment config
|
||||
##############################################################################
|
||||
source ~/.profile
|
||||
|
||||
##############################################################################
|
||||
# History Configuration
|
||||
##############################################################################
|
||||
HISTSIZE=5000 #How many lines of history to keep in memory
|
||||
HISTFILE=~/.zsh_history #Where to save history to disk
|
||||
SAVEHIST=5000 #Number of history entries to save to disk
|
||||
HISTDUP=erase #Erase duplicates in the history file
|
||||
setopt appendhistory #Append history to the history file (no overwriting)
|
||||
setopt sharehistory #Share history across terminals
|
||||
setopt incappendhistory #Immediately append to the history file, not just when a term is killed
|
||||
|
||||
##############################################################################
|
||||
# sjl/z-zsh setup
|
||||
##############################################################################
|
||||
#. ~/.dotfiles/z-zsh/z.sh
|
||||
#function precmd () {
|
||||
# z --add "$(pwd -P)"
|
||||
#}
|
||||
|
||||
##############################################################################
|
||||
# rupa/z setup
|
||||
##############################################################################
|
||||
. ~/.dotfiles/z-rupa/z.sh
|
||||
2
samples/Shell/filenames/.zshenv
Normal file
2
samples/Shell/filenames/.zshenv
Normal file
@@ -0,0 +1,2 @@
|
||||
fpath=($fpath $HOME/.zsh/func)
|
||||
typeset -U fpath
|
||||
1
samples/Shell/filenames/bash_logout
Normal file
1
samples/Shell/filenames/bash_logout
Normal file
@@ -0,0 +1 @@
|
||||
/usr/bin/clear
|
||||
36
samples/Shell/filenames/bash_profile
Normal file
36
samples/Shell/filenames/bash_profile
Normal file
@@ -0,0 +1,36 @@
|
||||
##
|
||||
# Environment...
|
||||
##
|
||||
# Set up some variables for 'screen'
|
||||
if [ -z "${SCREENDIR}" ];then echo -n
|
||||
export SCREENDIR="${HOME}/.screen"
|
||||
# Save my screen sockets within my $HOME dir
|
||||
fi
|
||||
## PATH
|
||||
export PATH=/usr/local/bin:/usr/local/sbin:/usr/xpg4/bin:/usr/sbin:/usr/bin:/usr/sfw/bin:/usr/ccs/bin:/usr/openwin/bin:/opt/mysql/current/bin
|
||||
export MANPATH=/usr/local/man:/usr/share/man
|
||||
|
||||
## Random ENV...
|
||||
# Set $TERM to 'vt100' (a safe default) if, for some
|
||||
# reason, it is set to 'network' (which is not valid!)
|
||||
if [ ${TERM} == 'network' ];then echo -n
|
||||
export TERM='vt100'
|
||||
# not 'nsterm' because if its 'network' we're
|
||||
# probly not in Terminal.app
|
||||
fi
|
||||
# Set $COLORTERM, all this does is trick *some* apps into
|
||||
# using color in the terminal, which should happen anyway.
|
||||
if [ -z "${COLORTERM}" ];then echo -n
|
||||
export COLORTERM="${TERM}"
|
||||
fi
|
||||
# another color option, this one for BSD's ls
|
||||
if [ -z "${CLICOLOR}" ];then echo -n
|
||||
export CLICOLOR='1' # can be set to anything, actually
|
||||
fi
|
||||
# If $DISPLAY is not already set, set it!
|
||||
if [ -z "${DISPLAY}" ];then echo -n
|
||||
export DISPLAY=':0'
|
||||
fi
|
||||
##
|
||||
# Source the bash rc file
|
||||
[ -r "${HOME}/.bashrc" ] && . "${HOME}/.bashrc"
|
||||
119
samples/Shell/filenames/bashrc
Normal file
119
samples/Shell/filenames/bashrc
Normal file
@@ -0,0 +1,119 @@
|
||||
##
|
||||
# Functions... *MUCH* better than aliases, and they do more too!
|
||||
# but they clutter the environment... (try typing just 'set' at the prompt)
|
||||
##
|
||||
# The reason that some of these are... odd... is because
|
||||
# I had to convert them early because bash can't do positional
|
||||
# arguments in aliases! functionName () { do something $@<-arguments ; }
|
||||
function ls { command ls -Fh "$@"; }
|
||||
# 'command ls' to prevent loop; -A for .file, -F for dir/ link@,
|
||||
# -h for 5k 3m 1g, -o for printing flags (uchg)...
|
||||
function l { ls -l "$@"; } # -l to list in long format...
|
||||
function ll { l "$@" | less -XF ; } # pipe into 'more'
|
||||
|
||||
##
|
||||
# Tips and Ticks... from http://www.caliban.org/bash/index.shtml
|
||||
##
|
||||
# The $CDPATH variable is so that you can be in /path/to/something and 'cd'
|
||||
# to 'somethingElse' and end up in /not/the/same/path/to/somethingElse.
|
||||
# iWould use it if it didn't ALWAYS echo the directory it changes to!
|
||||
#CDPATH='.:~'
|
||||
#
|
||||
# HISTIGNORE="&:l:ls:ls *:l *:cd:cd *:[bf]g:exit:quit:q:sleep *"
|
||||
# History ignores commands that include any l/ls/cd etc
|
||||
# This kicks-ass! It drops repeats and other useless
|
||||
# things from the command history!
|
||||
HISTIGNORE="[bf]g:exit:quit:q:sleep *"
|
||||
# I want to see l/ls/cd in my history
|
||||
HISTCONTROL=ignoreboth
|
||||
# ignores both commands that start with a space or a tab, and duplicates
|
||||
# other options are as follows:
|
||||
# `ignorespace' means to not enter lines which begin with a space or tab into the history list.
|
||||
# `ignoredups' means to not enter lines which match the last entered line.
|
||||
# `ignoreboth' combines the two options.
|
||||
|
||||
shopt -s cdspell extglob progcomp
|
||||
# Spell check for 'cd', extended globbing, programmable completion
|
||||
|
||||
##
|
||||
# Bash Completion... Cannibalised from bash_completion 20030929
|
||||
# Completion defaults... Yes, its long...
|
||||
# Basically this sets up many useful defaults for command completion, these
|
||||
# should probly be built into bash. Use bash_completions itself if you want
|
||||
# more functionality and don't mind the hacks it uses.
|
||||
complete -f -X '!*.?(t)bz2' bunzip2 bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep
|
||||
complete -f -X '!*.@(zip|ZIP|jar|JAR|exe|EXE|pk3|war|wsz|ear|zargo|xpi)' unzip zipinfo
|
||||
complete -f -X '*.Z' compress znew
|
||||
complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' gunzip zcmp zdiff zcat zegrep zfgrep zgrep zless zmore
|
||||
complete -f -X '!*.Z' uncompress
|
||||
complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|GIF|JP?(E)G|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA)' ee display
|
||||
complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|GIF|JPG|JP?(E)G|TIF?(F)|PNG|P[BGP]M|BMP|X[BP]M|RLE|RGB|PCX|FITS|PM)' xv qiv
|
||||
complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.Z))' gv ggv
|
||||
complete -f -X '!*.@(dvi|DVI)?(.@(gz|Z|bz2))' xdvi
|
||||
complete -f -X '!*.@(dvi|DVI)' dvips dviselect dvitype
|
||||
complete -f -X '!*.@(pdf|PDF)' acroread xpdf
|
||||
complete -f -X '!*.texi*' makeinfo texi2html
|
||||
complete -f -X '!*.@(?(la)tex|?(LA)TEX|texi|TEXI|dtx|DTX|ins|INS)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi
|
||||
complete -f -X '!*.@(mp3|MP3|m3u)' mpg123 mpg321
|
||||
complete -f -X '!*.@(mp?(e)g|MP?(E)G|wma|avi|AVI|asf|vob|bin|dat|vcd|ps|pes|fli|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp3|MP3|ogg|OGG|ogm|OGM|mp4|MP4|wav|WAV)' xine
|
||||
complete -f -X '!*.@(avi|asf|wmv)' aviplay
|
||||
complete -f -X '!*.@(rm|ram|smi?(l))' realplay
|
||||
complete -f -X '!*.@(mp?(e)g|avi|mov|qt)' xanim
|
||||
complete -f -X '!*.@(ogg|OGG|m3u)' ogg123
|
||||
complete -f -X '!*.@(mp3|MP3|ogg|OGG|pls|m3u)' gqmpeg freeamp
|
||||
complete -f -X '!*.@(mp[23]|MP[23]|ogg|OGG|wav|WAV|pls|m3u|xm|mod|s[3t]m|it|mtm|ult|flac)' xmms
|
||||
complete -f -X '!*.fig' xfig
|
||||
complete -f -X '!*.@(mid?(i))' timidity playmidi
|
||||
complete -f -X '.*|*.@(o|so|so.!(conf)|a|tar?(.@(gz|bz2))|tgz|tbz2|rpm|zip|ZIP|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mp?(e)g|MPG|avi|AVI|asf|ASF|ogg|OGG|class|CLASS)' vi vim gvim rvim view rview rgvim rgview gview emacs
|
||||
complete -f -X '!*.@(exe|EXE|com|COM|scr|SCR)' wine
|
||||
complete -f -X '!*.@(zip|ZIP|z|Z|gz|GZ|tgz|TGZ)' bzme
|
||||
complete -f -X '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx opera w3m galeon curl dillo elinks links
|
||||
#
|
||||
complete -u su passwd groups # user commands see only users
|
||||
complete -A stopped -P '%' bg # bg completes with stopped jobs
|
||||
complete -j -P '%' fg jobs disown # other job commands
|
||||
complete -v readonly unset export # readonly and unset complete with shell variables
|
||||
complete -A setopt set # set completes with set options
|
||||
complete -A shopt shopt # shopt completes with shopt options
|
||||
complete -A helptopic help # helptopics
|
||||
complete -a unalias # unalias completes with aliases
|
||||
complete -A binding bind # bind completes with readline bindings (make this more intelligent)
|
||||
complete -c command type which man #sudo # type, which, man complete on commands
|
||||
complete -d pushd cd rmdir # Make directory commands see only directories
|
||||
complete -W ' ' alias # no filenames for alias,
|
||||
|
||||
##
|
||||
# Set the prompt
|
||||
##
|
||||
PS1="[\h:\w] \[\033[1;34m\]\u\[\033[0m\]\\$ "
|
||||
# My prompt line: "[gaelicWizard:~/Documents] user$ " user is in blue
|
||||
# Or: "[gaelicWizard:~/Documents] root# " root is in blue
|
||||
##
|
||||
# Aliases:
|
||||
##
|
||||
# Aliases frequently used...
|
||||
alias ..='cd ..;l'
|
||||
alias cd..='cd ..'
|
||||
alias which='type' # 'which' in (t)csh is same(?) as 'type' in bash...
|
||||
alias quit='exit'
|
||||
alias q='quit' # and 'q' is even shorter! :-D
|
||||
alias v='vim'
|
||||
alias rehash='. ~/.bashrc;' # source ~/.bashrc after I edit it
|
||||
alias pg='ps -afe|grep -v grep|grep'
|
||||
alias make='gmake'
|
||||
alias patch='gpatch'
|
||||
alias sed='gsed'
|
||||
alias awk='nawk'
|
||||
alias diff='gdiff'
|
||||
alias grep='ggrep'
|
||||
alias find='gfind'
|
||||
alias ps='/usr/ucb/ps'
|
||||
alias whoami='/usr/ucb/whoami'
|
||||
alias ping='ping -s'
|
||||
alias man='GROFF_NO_SGR= TCAT="less -s" TROFF="groff -Tascii" man -t'
|
||||
|
||||
|
||||
# The rest are uncategorised and fairly random... :-)
|
||||
shopt -s histappend
|
||||
PROMPT_COMMAND='echo -ne "\033]0;${USER} on ${HOSTNAME} at ${PWD}\007" && history -a'
|
||||
export PATH=/usr/local/bin:/usr/local/sbin:/usr/xpg4/bin:/usr/sbin:/usr/bin:/usr/sfw/bin:/usr/ccs/bin:/usr/openwin/bin:/opt/mysql/current/bin
|
||||
5
samples/Shell/filenames/cshrc
Normal file
5
samples/Shell/filenames/cshrc
Normal file
@@ -0,0 +1,5 @@
|
||||
umask 022
|
||||
set path=(/opt/local/bin /opt/local/sbin /bin /usr/bin)
|
||||
if ( $?prompt ) then
|
||||
set history=32
|
||||
endif
|
||||
2
samples/Shell/filenames/login
Normal file
2
samples/Shell/filenames/login
Normal file
@@ -0,0 +1,2 @@
|
||||
stty -istrip
|
||||
# setenv TERM `tset -Q -`
|
||||
1
samples/Shell/filenames/profile
Normal file
1
samples/Shell/filenames/profile
Normal file
@@ -0,0 +1 @@
|
||||
export PATH="/usr/local/bin:/usr/bin:/bin"
|
||||
1
samples/Shell/filenames/zlogin
Normal file
1
samples/Shell/filenames/zlogin
Normal file
@@ -0,0 +1 @@
|
||||
export PATH="/usr/local/bin:/usr/bin:/bin"
|
||||
3
samples/Shell/filenames/zlogout
Normal file
3
samples/Shell/filenames/zlogout
Normal file
@@ -0,0 +1,3 @@
|
||||
# Store dirs stack
|
||||
# See ~/.dotfiles/oh-my-zsh/plugins/dirspersist.plugin.zsh
|
||||
dirpersiststore
|
||||
28
samples/Shell/filenames/zprofile
Normal file
28
samples/Shell/filenames/zprofile
Normal file
@@ -0,0 +1,28 @@
|
||||
##############################################################################
|
||||
#Import the shell-agnostic (Bash or Zsh) environment config
|
||||
##############################################################################
|
||||
source ~/.profile
|
||||
|
||||
##############################################################################
|
||||
# History Configuration
|
||||
##############################################################################
|
||||
HISTSIZE=5000 #How many lines of history to keep in memory
|
||||
HISTFILE=~/.zsh_history #Where to save history to disk
|
||||
SAVEHIST=5000 #Number of history entries to save to disk
|
||||
HISTDUP=erase #Erase duplicates in the history file
|
||||
setopt appendhistory #Append history to the history file (no overwriting)
|
||||
setopt sharehistory #Share history across terminals
|
||||
setopt incappendhistory #Immediately append to the history file, not just when a term is killed
|
||||
|
||||
##############################################################################
|
||||
# sjl/z-zsh setup
|
||||
##############################################################################
|
||||
#. ~/.dotfiles/z-zsh/z.sh
|
||||
#function precmd () {
|
||||
# z --add "$(pwd -P)"
|
||||
#}
|
||||
|
||||
##############################################################################
|
||||
# rupa/z setup
|
||||
##############################################################################
|
||||
. ~/.dotfiles/z-rupa/z.sh
|
||||
2
samples/Shell/filenames/zshenv
Normal file
2
samples/Shell/filenames/zshenv
Normal file
@@ -0,0 +1,2 @@
|
||||
fpath=($fpath $HOME/.zsh/func)
|
||||
typeset -U fpath
|
||||
1
samples/Shell/filenames/zshrc
Normal file
1
samples/Shell/filenames/zshrc
Normal file
@@ -0,0 +1 @@
|
||||
export PATH="/usr/local/bin:/usr/bin:/bin"
|
||||
3
samples/Shell/invalid-shebang.sh
Normal file
3
samples/Shell/invalid-shebang.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env
|
||||
|
||||
echo "wat"
|
||||
432
samples/Shell/sbt.script!
Executable file
432
samples/Shell/sbt.script!
Executable file
@@ -0,0 +1,432 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# A more capable sbt runner, coincidentally also called sbt.
|
||||
# Author: Paul Phillips <paulp@typesafe.com>
|
||||
|
||||
# todo - make this dynamic
|
||||
declare -r sbt_release_version=0.11.3
|
||||
declare -r sbt_snapshot_version=0.13.0-SNAPSHOT
|
||||
|
||||
unset sbt_jar sbt_dir sbt_create sbt_snapshot sbt_launch_dir
|
||||
unset scala_version java_home sbt_explicit_version
|
||||
unset verbose debug quiet
|
||||
|
||||
build_props_sbt () {
|
||||
if [[ -f project/build.properties ]]; then
|
||||
versionLine=$(grep ^sbt.version project/build.properties)
|
||||
versionString=${versionLine##sbt.version=}
|
||||
echo "$versionString"
|
||||
fi
|
||||
}
|
||||
|
||||
update_build_props_sbt () {
|
||||
local ver="$1"
|
||||
local old=$(build_props_sbt)
|
||||
|
||||
if [[ $ver == $old ]]; then
|
||||
return
|
||||
elif [[ -f project/build.properties ]]; then
|
||||
perl -pi -e "s/^sbt\.version=.*\$/sbt.version=${ver}/" project/build.properties
|
||||
grep -q '^sbt.version=' project/build.properties || echo "sbt.version=${ver}" >> project/build.properties
|
||||
|
||||
echo !!!
|
||||
echo !!! Updated file project/build.properties setting sbt.version to: $ver
|
||||
echo !!! Previous value was: $old
|
||||
echo !!!
|
||||
fi
|
||||
}
|
||||
|
||||
sbt_version () {
|
||||
if [[ -n $sbt_explicit_version ]]; then
|
||||
echo $sbt_explicit_version
|
||||
else
|
||||
local v=$(build_props_sbt)
|
||||
if [[ -n $v ]]; then
|
||||
echo $v
|
||||
else
|
||||
echo $sbt_release_version
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
echoerr () {
|
||||
echo 1>&2 "$@"
|
||||
}
|
||||
vlog () {
|
||||
[[ $verbose || $debug ]] && echoerr "$@"
|
||||
}
|
||||
dlog () {
|
||||
[[ $debug ]] && echoerr "$@"
|
||||
}
|
||||
|
||||
# this seems to cover the bases on OSX, and someone will
|
||||
# have to tell me about the others.
|
||||
get_script_path () {
|
||||
local path="$1"
|
||||
[[ -L "$path" ]] || { echo "$path" ; return; }
|
||||
|
||||
local target=$(readlink "$path")
|
||||
if [[ "${target:0:1}" == "/" ]]; then
|
||||
echo "$target"
|
||||
else
|
||||
echo "$(dirname $path)/$target"
|
||||
fi
|
||||
}
|
||||
|
||||
# a ham-fisted attempt to move some memory settings in concert
|
||||
# so they need not be dicked around with individually.
|
||||
get_mem_opts () {
|
||||
local mem=${1:-1536}
|
||||
local perm=$(( $mem / 4 ))
|
||||
(( $perm > 256 )) || perm=256
|
||||
(( $perm < 1024 )) || perm=1024
|
||||
local codecache=$(( $perm / 2 ))
|
||||
|
||||
echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m"
|
||||
}
|
||||
|
||||
die() {
|
||||
echo "Aborting: $@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
make_url () {
|
||||
groupid="$1"
|
||||
category="$2"
|
||||
version="$3"
|
||||
|
||||
echo "http://typesafe.artifactoryonline.com/typesafe/ivy-$category/$groupid/sbt-launch/$version/sbt-launch.jar"
|
||||
}
|
||||
|
||||
declare -r default_jvm_opts="-Dfile.encoding=UTF8"
|
||||
declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled"
|
||||
declare -r default_sbt_mem=1536
|
||||
declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy"
|
||||
declare -r sbt_opts_file=".sbtopts"
|
||||
declare -r jvm_opts_file=".jvmopts"
|
||||
declare -r latest_28="2.8.2"
|
||||
declare -r latest_29="2.9.1"
|
||||
declare -r latest_210="2.10.0-SNAPSHOT"
|
||||
|
||||
declare -r script_path=$(get_script_path "$BASH_SOURCE")
|
||||
declare -r script_dir="$(dirname $script_path)"
|
||||
declare -r script_name="$(basename $script_path)"
|
||||
|
||||
# some non-read-onlies set with defaults
|
||||
declare java_cmd=java
|
||||
declare sbt_launch_dir="$script_dir/.lib"
|
||||
declare sbt_mem=$default_sbt_mem
|
||||
|
||||
# pull -J and -D options to give to java.
|
||||
declare -a residual_args
|
||||
declare -a java_args
|
||||
declare -a scalac_args
|
||||
declare -a sbt_commands
|
||||
|
||||
build_props_scala () {
|
||||
if [[ -f project/build.properties ]]; then
|
||||
versionLine=$(grep ^build.scala.versions project/build.properties)
|
||||
versionString=${versionLine##build.scala.versions=}
|
||||
echo ${versionString%% .*}
|
||||
fi
|
||||
}
|
||||
|
||||
execRunner () {
|
||||
# print the arguments one to a line, quoting any containing spaces
|
||||
[[ $verbose || $debug ]] && echo "# Executing command line:" && {
|
||||
for arg; do
|
||||
if printf "%s\n" "$arg" | grep -q ' '; then
|
||||
printf "\"%s\"\n" "$arg"
|
||||
else
|
||||
printf "%s\n" "$arg"
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
}
|
||||
|
||||
exec "$@"
|
||||
}
|
||||
|
||||
sbt_groupid () {
|
||||
case $(sbt_version) in
|
||||
0.7.*) echo org.scala-tools.sbt ;;
|
||||
0.10.*) echo org.scala-tools.sbt ;;
|
||||
0.11.[12]) echo org.scala-tools.sbt ;;
|
||||
*) echo org.scala-sbt ;;
|
||||
esac
|
||||
}
|
||||
|
||||
sbt_artifactory_list () {
|
||||
local version0=$(sbt_version)
|
||||
local version=${version0%-SNAPSHOT}
|
||||
local url="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/$(sbt_groupid)/sbt-launch/"
|
||||
dlog "Looking for snapshot list at: $url "
|
||||
|
||||
curl -s --list-only "$url" | \
|
||||
grep -F $version | \
|
||||
perl -e 'print reverse <>' | \
|
||||
perl -pe 's#^<a href="([^"/]+).*#$1#;'
|
||||
}
|
||||
|
||||
make_release_url () {
|
||||
make_url $(sbt_groupid) releases $(sbt_version)
|
||||
}
|
||||
|
||||
# argument is e.g. 0.13.0-SNAPSHOT
|
||||
# finds the actual version (with the build id) at artifactory
|
||||
make_snapshot_url () {
|
||||
for ver in $(sbt_artifactory_list); do
|
||||
local url=$(make_url $(sbt_groupid) snapshots $ver)
|
||||
dlog "Testing $url"
|
||||
curl -s --head "$url" >/dev/null
|
||||
dlog "curl returned: $?"
|
||||
echo "$url"
|
||||
return
|
||||
done
|
||||
}
|
||||
|
||||
jar_url () {
|
||||
case $(sbt_version) in
|
||||
0.7.*) echo "http://simple-build-tool.googlecode.com/files/sbt-launch-0.7.7.jar" ;;
|
||||
*-SNAPSHOT) make_snapshot_url ;;
|
||||
*) make_release_url ;;
|
||||
esac
|
||||
}
|
||||
|
||||
jar_file () {
|
||||
echo "$sbt_launch_dir/$1/sbt-launch.jar"
|
||||
}
|
||||
|
||||
download_url () {
|
||||
local url="$1"
|
||||
local jar="$2"
|
||||
|
||||
echo "Downloading sbt launcher $(sbt_version):"
|
||||
echo " From $url"
|
||||
echo " To $jar"
|
||||
|
||||
mkdir -p $(dirname "$jar") && {
|
||||
if which curl >/dev/null; then
|
||||
curl --fail --silent "$url" --output "$jar"
|
||||
elif which wget >/dev/null; then
|
||||
wget --quiet -O "$jar" "$url"
|
||||
fi
|
||||
} && [[ -f "$jar" ]]
|
||||
}
|
||||
|
||||
acquire_sbt_jar () {
|
||||
sbt_url="$(jar_url)"
|
||||
sbt_jar="$(jar_file $(sbt_version))"
|
||||
|
||||
[[ -f "$sbt_jar" ]] || download_url "$sbt_url" "$sbt_jar"
|
||||
}
|
||||
|
||||
usage () {
|
||||
cat <<EOM
|
||||
Usage: $script_name [options]
|
||||
|
||||
-h | -help print this message
|
||||
-v | -verbose this runner is chattier
|
||||
-d | -debug set sbt log level to Debug
|
||||
-q | -quiet set sbt log level to Error
|
||||
-no-colors disable ANSI color codes
|
||||
-sbt-create start sbt even if current directory contains no sbt project
|
||||
-sbt-dir <path> path to global settings/plugins directory (default: ~/.sbt/<version>)
|
||||
-sbt-boot <path> path to shared boot directory (default: ~/.sbt/boot in 0.11 series)
|
||||
-ivy <path> path to local Ivy repository (default: ~/.ivy2)
|
||||
-mem <integer> set memory options (default: $sbt_mem, which is
|
||||
$(get_mem_opts $sbt_mem) )
|
||||
-no-share use all local caches; no sharing
|
||||
-offline put sbt in offline mode
|
||||
-jvm-debug <port> Turn on JVM debugging, open at the given port.
|
||||
-batch Disable interactive mode
|
||||
|
||||
# sbt version (default: from project/build.properties if present, else latest release)
|
||||
!!! The only way to accomplish this pre-0.12.0 if there is a build.properties file which
|
||||
!!! contains an sbt.version property is to update the file on disk. That's what this does.
|
||||
-sbt-version <version> use the specified version of sbt
|
||||
-sbt-jar <path> use the specified jar as the sbt launcher
|
||||
-sbt-snapshot use a snapshot version of sbt
|
||||
-sbt-launch-dir <path> directory to hold sbt launchers (default: $sbt_launch_dir)
|
||||
|
||||
# scala version (default: as chosen by sbt)
|
||||
-28 use $latest_28
|
||||
-29 use $latest_29
|
||||
-210 use $latest_210
|
||||
-scala-home <path> use the scala build at the specified directory
|
||||
-scala-version <version> use the specified version of scala
|
||||
|
||||
# java version (default: java from PATH, currently $(java -version |& grep version))
|
||||
-java-home <path> alternate JAVA_HOME
|
||||
|
||||
# jvm options and output control
|
||||
JAVA_OPTS environment variable holding jvm args, if unset uses "$default_jvm_opts"
|
||||
SBT_OPTS environment variable holding jvm args, if unset uses "$default_sbt_opts"
|
||||
.jvmopts if file is in sbt root, it is prepended to the args given to the jvm
|
||||
.sbtopts if file is in sbt root, it is prepended to the args given to **sbt**
|
||||
-Dkey=val pass -Dkey=val directly to the jvm
|
||||
-J-X pass option -X directly to the jvm (-J is stripped)
|
||||
-S-X add -X to sbt's scalacOptions (-S is stripped)
|
||||
|
||||
In the case of duplicated or conflicting options, the order above
|
||||
shows precedence: JAVA_OPTS lowest, command line options highest.
|
||||
EOM
|
||||
}
|
||||
|
||||
addJava () {
|
||||
dlog "[addJava] arg = '$1'"
|
||||
java_args=( "${java_args[@]}" "$1" )
|
||||
}
|
||||
addSbt () {
|
||||
dlog "[addSbt] arg = '$1'"
|
||||
sbt_commands=( "${sbt_commands[@]}" "$1" )
|
||||
}
|
||||
addScalac () {
|
||||
dlog "[addScalac] arg = '$1'"
|
||||
scalac_args=( "${scalac_args[@]}" "$1" )
|
||||
}
|
||||
addResidual () {
|
||||
dlog "[residual] arg = '$1'"
|
||||
residual_args=( "${residual_args[@]}" "$1" )
|
||||
}
|
||||
addResolver () {
|
||||
addSbt "set resolvers in ThisBuild += $1"
|
||||
}
|
||||
addDebugger () {
|
||||
addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1"
|
||||
}
|
||||
get_jvm_opts () {
|
||||
# echo "${JAVA_OPTS:-$default_jvm_opts}"
|
||||
# echo "${SBT_OPTS:-$default_sbt_opts}"
|
||||
|
||||
[[ -f "$jvm_opts_file" ]] && cat "$jvm_opts_file"
|
||||
}
|
||||
|
||||
process_args ()
|
||||
{
|
||||
require_arg () {
|
||||
local type="$1"
|
||||
local opt="$2"
|
||||
local arg="$3"
|
||||
|
||||
if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then
|
||||
die "$opt requires <$type> argument"
|
||||
fi
|
||||
}
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-h|-help) usage; exit 1 ;;
|
||||
-v|-verbose) verbose=1 && shift ;;
|
||||
-d|-debug) debug=1 && shift ;;
|
||||
-q|-quiet) quiet=1 && shift ;;
|
||||
|
||||
-ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;;
|
||||
-mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;;
|
||||
-no-colors) addJava "-Dsbt.log.noformat=true" && shift ;;
|
||||
-no-share) addJava "$noshare_opts" && shift ;;
|
||||
-sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;;
|
||||
-sbt-dir) require_arg path "$1" "$2" && sbt_dir="$2" && shift 2 ;;
|
||||
-debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;;
|
||||
-offline) addSbt "set offline := true" && shift ;;
|
||||
-jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;;
|
||||
-batch) exec </dev/null && shift ;;
|
||||
|
||||
-sbt-create) sbt_create=true && shift ;;
|
||||
-sbt-snapshot) sbt_explicit_version=$sbt_snapshot_version && shift ;;
|
||||
-sbt-jar) require_arg path "$1" "$2" && sbt_jar="$2" && shift 2 ;;
|
||||
-sbt-version) require_arg version "$1" "$2" && sbt_explicit_version="$2" && shift 2 ;;
|
||||
-sbt-launch-dir) require_arg path "$1" "$2" && sbt_launch_dir="$2" && shift 2 ;;
|
||||
-scala-version) require_arg version "$1" "$2" && addSbt "set scalaVersion := \"$2\"" && shift 2 ;;
|
||||
-scala-home) require_arg path "$1" "$2" && addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))" && shift 2 ;;
|
||||
-java-home) require_arg path "$1" "$2" && java_cmd="$2/bin/java" && shift 2 ;;
|
||||
|
||||
-D*) addJava "$1" && shift ;;
|
||||
-J*) addJava "${1:2}" && shift ;;
|
||||
-S*) addScalac "${1:2}" && shift ;;
|
||||
-28) addSbt "++ $latest_28" && shift ;;
|
||||
-29) addSbt "++ $latest_29" && shift ;;
|
||||
-210) addSbt "++ $latest_210" && shift ;;
|
||||
|
||||
*) addResidual "$1" && shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ $debug ]] && {
|
||||
case $(sbt_version) in
|
||||
0.7.*) addSbt "debug" ;;
|
||||
*) addSbt "set logLevel in Global := Level.Debug" ;;
|
||||
esac
|
||||
}
|
||||
[[ $quiet ]] && {
|
||||
case $(sbt_version) in
|
||||
0.7.*) ;;
|
||||
*) addSbt "set logLevel in Global := Level.Error" ;;
|
||||
esac
|
||||
}
|
||||
}
|
||||
|
||||
# if .sbtopts exists, prepend its contents to $@ so it can be processed by this runner
|
||||
[[ -f "$sbt_opts_file" ]] && {
|
||||
sbtargs=()
|
||||
while IFS= read -r arg; do
|
||||
sbtargs=( "${sbtargs[@]}" "$arg" )
|
||||
done <"$sbt_opts_file"
|
||||
|
||||
set -- "${sbtargs[@]}" "$@"
|
||||
}
|
||||
|
||||
# process the combined args, then reset "$@" to the residuals
|
||||
process_args "$@"
|
||||
set -- "${residual_args[@]}"
|
||||
argumentCount=$#
|
||||
|
||||
# set scalacOptions if we were given any -S opts
|
||||
[[ ${#scalac_args[@]} -eq 0 ]] || addSbt "set scalacOptions in ThisBuild += \"${scalac_args[@]}\""
|
||||
|
||||
# Update build.properties no disk to set explicit version - sbt gives us no choice
|
||||
[[ -n "$sbt_explicit_version" ]] && update_build_props_sbt "$sbt_explicit_version"
|
||||
echo "Detected sbt version $(sbt_version)"
|
||||
|
||||
[[ -n "$scala_version" ]] && echo "Overriding scala version to $scala_version"
|
||||
|
||||
# no args - alert them there's stuff in here
|
||||
(( $argumentCount > 0 )) || echo "Starting $script_name: invoke with -help for other options"
|
||||
|
||||
# verify this is an sbt dir or -create was given
|
||||
[[ -f ./build.sbt || -d ./project || -n "$sbt_create" ]] || {
|
||||
cat <<EOM
|
||||
$(pwd) doesn't appear to be an sbt project.
|
||||
If you want to start sbt anyway, run:
|
||||
$0 -sbt-create
|
||||
|
||||
EOM
|
||||
exit 1
|
||||
}
|
||||
|
||||
# pick up completion if present; todo
|
||||
[[ -f .sbt_completion.sh ]] && source .sbt_completion.sh
|
||||
|
||||
# no jar? download it.
|
||||
[[ -f "$sbt_jar" ]] || acquire_sbt_jar || {
|
||||
# still no jar? uh-oh.
|
||||
echo "Download failed. Obtain the jar manually and place it at $sbt_jar"
|
||||
exit 1
|
||||
}
|
||||
|
||||
[[ -n "$sbt_dir" ]] || {
|
||||
sbt_dir=~/.sbt/$(sbt_version)
|
||||
addJava "-Dsbt.global.base=$sbt_dir"
|
||||
echo "Using $sbt_dir as sbt dir, -sbt-dir to override."
|
||||
}
|
||||
|
||||
# since sbt 0.7 doesn't understand iflast
|
||||
(( ${#residual_args[@]} == 0 )) && residual_args=( "shell" )
|
||||
|
||||
# run sbt
|
||||
execRunner "$java_cmd" \
|
||||
$(get_mem_opts $sbt_mem) \
|
||||
$(get_jvm_opts) \
|
||||
${java_args[@]} \
|
||||
-jar "$sbt_jar" \
|
||||
"${sbt_commands[@]}" \
|
||||
"${residual_args[@]}"
|
||||
1
samples/Text/mac.txt
Normal file
1
samples/Text/mac.txt
Normal file
@@ -0,0 +1 @@
|
||||
line 1
|
||||
@@ -2,6 +2,7 @@ require 'linguist/file_blob'
|
||||
require 'linguist/samples'
|
||||
|
||||
require 'test/unit'
|
||||
require 'mocha'
|
||||
require 'mime/types'
|
||||
require 'pygments'
|
||||
|
||||
@@ -64,6 +65,14 @@ class TestBlob < Test::Unit::TestCase
|
||||
assert_equal ["module Foo", "end", ""], blob("Ruby/foo.rb").lines
|
||||
end
|
||||
|
||||
def test_mac_format
|
||||
assert blob("Text/mac.txt").mac_format?
|
||||
end
|
||||
|
||||
def test_lines_mac_format
|
||||
assert_equal ["line 1", "line 2", ""], blob("Text/mac.txt").lines
|
||||
end
|
||||
|
||||
def test_size
|
||||
assert_equal 15, blob("Ruby/foo.rb").size
|
||||
end
|
||||
@@ -261,6 +270,12 @@ class TestBlob < Test::Unit::TestCase
|
||||
assert !blob("Text/dump.sql").indexable?
|
||||
assert !blob("Binary/github.po").indexable?
|
||||
assert !blob("Binary/linguist.gem").indexable?
|
||||
|
||||
# large binary blobs should fail on size check first, not call
|
||||
# into charlock_holmes and alloc big buffers for testing encoding
|
||||
b = blob("Binary/octocat.ai")
|
||||
b.expects(:binary?).never
|
||||
assert !b.indexable?
|
||||
end
|
||||
|
||||
def test_language
|
||||
@@ -276,11 +291,10 @@ class TestBlob < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_colorize
|
||||
assert_equal <<-HTML, blob("Ruby/foo.rb").colorize
|
||||
assert_equal <<-HTML.chomp, blob("Ruby/foo.rb").colorize
|
||||
<div class="highlight"><pre><span class="k">module</span> <span class="nn">Foo</span>
|
||||
<span class="k">end</span>
|
||||
</pre>
|
||||
</div>
|
||||
</pre></div>
|
||||
HTML
|
||||
end
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ class TestLanguage < Test::Unit::TestCase
|
||||
assert_equal Lexer['HTML'], Language['HTML'].lexer
|
||||
assert_equal Lexer['HTML+Django/Jinja'], Language['HTML+Django'].lexer
|
||||
assert_equal Lexer['HTML+PHP'], Language['HTML+PHP'].lexer
|
||||
assert_equal Lexer['HTTP'], Language['HTTP'].lexer
|
||||
assert_equal Lexer['JSON'], Language['JSON'].lexer
|
||||
assert_equal Lexer['Java'], Language['ChucK'].lexer
|
||||
assert_equal Lexer['Java'], Language['Java'].lexer
|
||||
@@ -51,7 +52,7 @@ class TestLanguage < Test::Unit::TestCase
|
||||
assert_equal Lexer['Verilog'], Language['Verilog'].lexer
|
||||
assert_equal Lexer['XSLT'], Language['XSLT'].lexer
|
||||
assert_equal Lexer['aspx-vb'], Language['ASP'].lexer
|
||||
assert_equal Lexer['haXe'], Language['HaXe'].lexer
|
||||
assert_equal Lexer['haXe'], Language['Haxe'].lexer
|
||||
assert_equal Lexer['reStructuredText'], Language['reStructuredText'].lexer
|
||||
end
|
||||
|
||||
@@ -60,6 +61,7 @@ class TestLanguage < Test::Unit::TestCase
|
||||
assert_equal Language['ASP'], Language.find_by_alias('aspx')
|
||||
assert_equal Language['ASP'], Language.find_by_alias('aspx-vb')
|
||||
assert_equal Language['ActionScript'], Language.find_by_alias('as3')
|
||||
assert_equal Language['ApacheConf'], Language.find_by_alias('apache')
|
||||
assert_equal Language['Assembly'], Language.find_by_alias('nasm')
|
||||
assert_equal Language['Batchfile'], Language.find_by_alias('bat')
|
||||
assert_equal Language['C#'], Language.find_by_alias('c#')
|
||||
@@ -68,6 +70,7 @@ class TestLanguage < Test::Unit::TestCase
|
||||
assert_equal Language['C++'], Language.find_by_alias('c++')
|
||||
assert_equal Language['C++'], Language.find_by_alias('cpp')
|
||||
assert_equal Language['CoffeeScript'], Language.find_by_alias('coffee')
|
||||
assert_equal Language['CoffeeScript'], Language.find_by_alias('coffee-script')
|
||||
assert_equal Language['ColdFusion'], Language.find_by_alias('cfm')
|
||||
assert_equal Language['Common Lisp'], Language.find_by_alias('common-lisp')
|
||||
assert_equal Language['Common Lisp'], Language.find_by_alias('lisp')
|
||||
@@ -78,7 +81,9 @@ class TestLanguage < Test::Unit::TestCase
|
||||
assert_equal Language['Emacs Lisp'], Language.find_by_alias('emacs-lisp')
|
||||
assert_equal Language['Gettext Catalog'], Language.find_by_alias('pot')
|
||||
assert_equal Language['HTML'], Language.find_by_alias('html')
|
||||
assert_equal Language['HTML'], Language.find_by_alias('xhtml')
|
||||
assert_equal Language['HTML+ERB'], Language.find_by_alias('html+erb')
|
||||
assert_equal Language['HTML+ERB'], Language.find_by_alias('erb')
|
||||
assert_equal Language['IRC log'], Language.find_by_alias('irc')
|
||||
assert_equal Language['JSON'], Language.find_by_alias('json')
|
||||
assert_equal Language['Java Server Pages'], Language.find_by_alias('jsp')
|
||||
@@ -87,6 +92,7 @@ class TestLanguage < Test::Unit::TestCase
|
||||
assert_equal Language['JavaScript'], Language.find_by_alias('js')
|
||||
assert_equal Language['Literate Haskell'], Language.find_by_alias('lhs')
|
||||
assert_equal Language['Literate Haskell'], Language.find_by_alias('literate-haskell')
|
||||
assert_equal Language['Objective-C'], Language.find_by_alias('objc')
|
||||
assert_equal Language['OpenEdge ABL'], Language.find_by_alias('openedge')
|
||||
assert_equal Language['OpenEdge ABL'], Language.find_by_alias('progress')
|
||||
assert_equal Language['OpenEdge ABL'], Language.find_by_alias('abl')
|
||||
@@ -106,6 +112,7 @@ class TestLanguage < Test::Unit::TestCase
|
||||
assert_equal Language['VimL'], Language.find_by_alias('vim')
|
||||
assert_equal Language['VimL'], Language.find_by_alias('viml')
|
||||
assert_equal Language['reStructuredText'], Language.find_by_alias('rst')
|
||||
assert_equal Language['YAML'], Language.find_by_alias('yml')
|
||||
end
|
||||
|
||||
def test_groups
|
||||
@@ -224,10 +231,16 @@ class TestLanguage < Test::Unit::TestCase
|
||||
assert_equal [Language['Ruby']], Language.find_by_filename('foo/bar.rb')
|
||||
assert_equal [Language['Ruby']], Language.find_by_filename('Rakefile')
|
||||
assert_equal [Language['Ruby']], Language.find_by_filename('PKGBUILD.rb')
|
||||
assert_equal Language['ApacheConf'], Language.find_by_filename('httpd.conf').first
|
||||
assert_equal [Language['ApacheConf']], Language.find_by_filename('.htaccess')
|
||||
assert_equal Language['Nginx'], Language.find_by_filename('nginx.conf').first
|
||||
assert_equal ['C', 'C++', 'Objective-C'], Language.find_by_filename('foo.h').map(&:name).sort
|
||||
assert_equal [], Language.find_by_filename('rb')
|
||||
assert_equal [], Language.find_by_filename('.rb')
|
||||
assert_equal [], Language.find_by_filename('.nkt')
|
||||
assert_equal [Language['Shell']], Language.find_by_filename('.bashrc')
|
||||
assert_equal [Language['Shell']], Language.find_by_filename('bash_profile')
|
||||
assert_equal [Language['Shell']], Language.find_by_filename('.zshrc')
|
||||
end
|
||||
|
||||
def test_find
|
||||
@@ -286,6 +299,11 @@ class TestLanguage < Test::Unit::TestCase
|
||||
assert !Language.ace_modes.include?(Language['FORTRAN'])
|
||||
end
|
||||
|
||||
def test_wrap
|
||||
assert_equal false, Language['C'].wrap
|
||||
assert_equal true, Language['Markdown'].wrap
|
||||
end
|
||||
|
||||
def test_extensions
|
||||
assert Language['Perl'].extensions.include?('.pl')
|
||||
assert Language['Python'].extensions.include?('.py')
|
||||
@@ -314,12 +332,11 @@ class TestLanguage < Test::Unit::TestCase
|
||||
|
||||
|
||||
def test_colorize
|
||||
assert_equal <<-HTML, Language['Ruby'].colorize("def foo\n 'foo'\nend\n")
|
||||
assert_equal <<-HTML.chomp, Language['Ruby'].colorize("def foo\n 'foo'\nend\n")
|
||||
<div class="highlight"><pre><span class="k">def</span> <span class="nf">foo</span>
|
||||
<span class="s1">'foo'</span>
|
||||
<span class="k">end</span>
|
||||
</pre>
|
||||
</div>
|
||||
</pre></div>
|
||||
HTML
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
require 'linguist/samples'
|
||||
require 'tempfile'
|
||||
require 'yajl'
|
||||
|
||||
require 'test/unit'
|
||||
|
||||
@@ -12,6 +14,19 @@ class TestSamples < Test::Unit::TestCase
|
||||
# Just warn, it shouldn't scare people off by breaking the build.
|
||||
if serialized['md5'] != latest['md5']
|
||||
warn "Samples database is out of date. Run `bundle exec rake samples`."
|
||||
|
||||
expected = Tempfile.new('expected.json')
|
||||
expected.write Yajl::Encoder.encode(serialized, :pretty => true)
|
||||
expected.close
|
||||
|
||||
actual = Tempfile.new('actual.json')
|
||||
actual.write Yajl::Encoder.encode(latest, :pretty => true)
|
||||
actual.close
|
||||
|
||||
warn `diff #{expected.path} #{actual.path}`
|
||||
|
||||
expected.unlink
|
||||
actual.unlink
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -94,6 +94,8 @@ class TestTokenizer < Test::Unit::TestCase
|
||||
assert_equal "SHEBANG#!ruby", tokenize(:"Ruby/ruby.script!")[0]
|
||||
assert_equal "SHEBANG#!ruby", tokenize(:"Ruby/ruby2.script!")[0]
|
||||
assert_equal "SHEBANG#!node", tokenize(:"JavaScript/js.script!")[0]
|
||||
assert_equal "SHEBANG#!php", tokenize(:"PHP/php.script!")[0]
|
||||
assert_equal "echo", tokenize(:"Shell/invalid-shebang.sh")[0]
|
||||
end
|
||||
|
||||
def test_javascript_tokens
|
||||
|
||||
Reference in New Issue
Block a user