├── .gitignore ├── .htaccess ├── README.md ├── assets-int ├── logo.afphoto └── logo.png ├── assets ├── 594blue.gif ├── BlobhajHeart.png ├── akt_reiter_l.gif ├── akt_reiter_r.gif ├── aufshandy_icon.gif ├── banner-styles.css ├── blahaj-large.png ├── blobhaj.png ├── bundle-playback.js ├── ecke_head.gif ├── favicon.ico ├── favicon.png ├── global.css ├── html-midi-player.js ├── iconochive.css ├── jquery-3.7.0.min.js ├── jspdudecoder.css ├── jspdudecoder.js ├── line.gif ├── link_pfeil.gif ├── logo.png ├── los_button.gif ├── mccmnc.js ├── nav_home_top (Kopie 1).gif ├── nav_home_top.gif ├── nav_home_top.png ├── nav_star.gif ├── nokia_logo.gif ├── phonebook.jpg ├── prelistening.js ├── reiter_l.gif ├── reiter_r.gif ├── rt_icon.gif ├── trans.gif └── wombat.js ├── bootstrap.php ├── composer.json ├── composer.lock ├── helper ├── import-content.php └── wbxml.php ├── index.php ├── kannel-sms.php ├── libs ├── BubblewrapSandbox.php ├── Content.php ├── Device.php ├── ImageMagick.php ├── Kannel.php ├── Logging.php ├── OperatorLogo.php ├── RTTTL.php ├── RingtoneTools.php ├── SMS.php ├── SQL.php ├── Session.php ├── SessionHandlerSQL.php ├── UAProf.php └── WAPPush.php ├── media.php ├── media_wap.php ├── pages ├── content-details.php ├── content.php ├── customupload.php ├── fahrplan.php ├── faq.php ├── index.php ├── logjson.php ├── manualsms.php ├── metrics.php ├── phonebook.php ├── statistics.php └── transfer.php ├── robots.txt ├── smpp-daemon.php ├── templates ├── footerads.html ├── header.html ├── menu.html ├── pages │ ├── 404.html │ ├── content-details.html │ ├── content.html │ ├── customupload.html │ ├── fahrplan.html │ ├── faq.html │ ├── include-phone-select.html │ ├── include-sms-pdu-decode.html │ ├── include-transfer-form.html │ ├── index.html │ ├── manualsms.html │ ├── phonebook.html │ ├── statistics.html │ └── transfer.html └── template.html ├── vendor-native ├── bwrap-seccomp │ ├── .gitignore │ ├── Makefile │ ├── README.md │ ├── genseccomp-imagemagick.c │ ├── genseccomp-ringtonetools.c │ └── shell.nix └── ringtonetools │ ├── LICENSE │ ├── Makefile │ ├── builds │ ├── pkginfo │ └── prototype │ ├── docs │ ├── README │ └── incomplete_see_webpage_instead │ ├── samples │ ├── face.txt │ ├── hemglass.mid │ ├── ionian.rtttl │ ├── usa.emelody │ └── yngwie_trilogy.rtttl │ └── src │ ├── 3210.c │ ├── Makefile │ ├── api.c │ ├── bmp.c │ ├── emelody.c │ ├── ems.c │ ├── fileoutput.c │ ├── fileoutput.h │ ├── general.c │ ├── gif.c │ ├── imelody.c │ ├── kyocera.c │ ├── kyocera6035.c │ ├── lzw.h │ ├── midi.c │ ├── motorola.c │ ├── nokia.c │ ├── parse_3210.c │ ├── parse_bmp.c │ ├── parse_emelody.c │ ├── parse_ems.c │ ├── parse_gif.c │ ├── parse_imelody.c │ ├── parse_kws.c │ ├── parse_logo.c │ ├── parse_midi.c │ ├── parse_morsecode.c │ ├── parse_rtttl.c │ ├── parse_sckl.c │ ├── parse_siemens.c │ ├── ringtonetools.c │ ├── ringtonetools.def │ ├── ringtonetools.h │ ├── rtttl.c │ ├── samsung.c │ ├── seo.c │ ├── siemens.c │ ├── treo.c │ └── wav.c └── wap ├── .htaccess ├── dl.php ├── dl_wap.php ├── ep.php ├── heart.wbmp ├── index.php ├── lib.php ├── logo.wbmp ├── pages ├── content-dl.php ├── content.php └── index.php └── vcal.php /.gitignore: -------------------------------------------------------------------------------- 1 | original-file.html 2 | .DS_Store 3 | vendor/ 4 | composer.phar 5 | .Makefile.swp 6 | *.o 7 | vendor-native/ringtonetools/ringtonetools 8 | vendor-native/bwrap-seccomp/genseccomp-imagemagick 9 | vendor-native/bwrap-seccomp/genseccomp-ringtonetools 10 | vendor-native/bwrap-seccomp/seccomp-imagemagick.bpf 11 | vendor-native/bwrap-seccomp/seccomp-ringtonetools.bpf 12 | vendor-native/libwbxml-libwbxml-0.11.8 13 | test* 14 | wap/ 15 | -------------------------------------------------------------------------------- /.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | 3 | # Deny access to hidden files - files that start with a dot (.) 4 | RewriteRule (^\.|/\.) - [F] 5 | 6 | # Allow access to .well-known directory 7 | RewriteRule ^\.well-known/ - [L] 8 | 9 | RewriteCond %{REQUEST_FILENAME} !-d 10 | RewriteCond %{REQUEST_FILENAME} !-f 11 | RewriteRule ^([^/]*)$ /index.php?page=$1 [L] 12 | RewriteRule ^([^/]*)/$ /index.php?page=$1 [L] 13 | RewriteRule ^([^/]*)/details/([0-9]*)$ /index.php?page=content-details&id=$2 [L] 14 | RewriteRule ^([^/]*)/download/([0-9]*)$ /media.php?type=download&id=$2 [L] 15 | RewriteRule ^([^/]*)/preview/([0-9]*)$ /media.php?type=preview&id=$2 [L] 16 | 17 | 18 | 19 | AddOutputFilterByType DEFLATE application/javascript 20 | AddOutputFilterByType DEFLATE application/rss+xml 21 | AddOutputFilterByType DEFLATE application/vnd.ms-fontobject 22 | AddOutputFilterByType DEFLATE application/x-font 23 | AddOutputFilterByType DEFLATE application/x-font-opentype 24 | AddOutputFilterByType DEFLATE application/x-font-otf 25 | AddOutputFilterByType DEFLATE application/x-font-truetype 26 | AddOutputFilterByType DEFLATE application/x-font-ttf 27 | AddOutputFilterByType DEFLATE application/x-javascript 28 | AddOutputFilterByType DEFLATE application/xhtml+xml 29 | AddOutputFilterByType DEFLATE application/xml 30 | AddOutputFilterByType DEFLATE font/opentype 31 | AddOutputFilterByType DEFLATE font/otf 32 | AddOutputFilterByType DEFLATE font/ttf 33 | AddOutputFilterByType DEFLATE image/svg+xml 34 | AddOutputFilterByType DEFLATE image/x-icon 35 | AddOutputFilterByType DEFLATE text/css 36 | AddOutputFilterByType DEFLATE text/html 37 | AddOutputFilterByType DEFLATE text/javascript 38 | AddOutputFilterByType DEFLATE text/plain 39 | AddOutputFilterByType DEFLATE text/xml 40 | 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # blamba 2 | 3 | Apache2 config: 4 | ``` 5 | SetEnv ap_trust_cgilike_cl 1 6 | ``` 7 | Content-Length header is being set by PHP. Apache2 usually doesn't trust Content-Length headers, which then results in a missing progress indication on file downloads. -------------------------------------------------------------------------------- /assets-int/logo.afphoto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets-int/logo.afphoto -------------------------------------------------------------------------------- /assets-int/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets-int/logo.png -------------------------------------------------------------------------------- /assets/594blue.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/594blue.gif -------------------------------------------------------------------------------- /assets/BlobhajHeart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/BlobhajHeart.png -------------------------------------------------------------------------------- /assets/akt_reiter_l.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/akt_reiter_l.gif -------------------------------------------------------------------------------- /assets/akt_reiter_r.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/akt_reiter_r.gif -------------------------------------------------------------------------------- /assets/aufshandy_icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/aufshandy_icon.gif -------------------------------------------------------------------------------- /assets/blahaj-large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/blahaj-large.png -------------------------------------------------------------------------------- /assets/blobhaj.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/blobhaj.png -------------------------------------------------------------------------------- /assets/ecke_head.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/ecke_head.gif -------------------------------------------------------------------------------- /assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/favicon.ico -------------------------------------------------------------------------------- /assets/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/favicon.png -------------------------------------------------------------------------------- /assets/jspdudecoder.css: -------------------------------------------------------------------------------- 1 | /*@import url("reset.css"); 2 | 3 | body { 4 | font-family: 'Verdana', sans-serif; 5 | } 6 | 7 | h1 { 8 | margin: 1em; 9 | 10 | font-size: 1.5em; 11 | text-align: center; 12 | } 13 | 14 | div#content { 15 | margin: 1em; 16 | 17 | } 18 | 19 | form, div#output { 20 | width: 90%; 21 | 22 | margin: 0 auto; 23 | } 24 | 25 | form li { 26 | margin: 1ex 0; 27 | } 28 | 29 | form fieldset { 30 | border: 1px solid black; 31 | padding: 1em; 32 | } 33 | 34 | form legend { 35 | padding: 0 1em; 36 | } 37 | */ 38 | table.data, table.data table { 39 | border-collapse: separate; 40 | border-spacing: 0.5ex; 41 | 42 | background-color: #EEEEEE; 43 | } 44 | 45 | table.data td { 46 | padding: 0.5ex; 47 | 48 | vertical-align: middle; 49 | 50 | background-color: #DDDDDD; 51 | } 52 | 53 | table.data td.one { 54 | background-color: #BBBBBB; 55 | } 56 | 57 | table.data table { 58 | background-color: #DDDDDD; 59 | } 60 | 61 | table.data table td { 62 | background-color: #CCCCCC; 63 | } 64 | -------------------------------------------------------------------------------- /assets/line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/line.gif -------------------------------------------------------------------------------- /assets/link_pfeil.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/link_pfeil.gif -------------------------------------------------------------------------------- /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/logo.png -------------------------------------------------------------------------------- /assets/los_button.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/los_button.gif -------------------------------------------------------------------------------- /assets/nav_home_top (Kopie 1).gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/nav_home_top (Kopie 1).gif -------------------------------------------------------------------------------- /assets/nav_home_top.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/nav_home_top.gif -------------------------------------------------------------------------------- /assets/nav_home_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/nav_home_top.png -------------------------------------------------------------------------------- /assets/nav_star.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/nav_star.gif -------------------------------------------------------------------------------- /assets/nokia_logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/nokia_logo.gif -------------------------------------------------------------------------------- /assets/phonebook.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/phonebook.jpg -------------------------------------------------------------------------------- /assets/prelistening.js: -------------------------------------------------------------------------------- 1 | var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; }; 2 | if (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } } 3 | { 4 | let window = _____WB$wombat$assign$function_____("window"); 5 | let self = _____WB$wombat$assign$function_____("self"); 6 | let document = _____WB$wombat$assign$function_____("document"); 7 | let location = _____WB$wombat$assign$function_____("location"); 8 | let top = _____WB$wombat$assign$function_____("top"); 9 | let parent = _____WB$wombat$assign$function_____("parent"); 10 | let frames = _____WB$wombat$assign$function_____("frames"); 11 | let opener = _____WB$wombat$assign$function_____("opener"); 12 | 13 | 34 | 35 | } 36 | /* 37 | FILE ARCHIVED ON 14:52:31 Apr 03, 2005 AND RETRIEVED FROM THE 38 | INTERNET ARCHIVE ON 23:36:45 May 06, 2023. 39 | JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. 40 | 41 | ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. 42 | SECTION 108(a)(3)). 43 | */ 44 | /* 45 | playback timings (ms): 46 | captures_list: 119.925 47 | exclusion.robots: 0.082 48 | exclusion.robots.policy: 0.071 49 | RedisCDXSource: 0.559 50 | esindex: 0.009 51 | LoadShardBlock: 99.133 (3) 52 | PetaboxLoader3.datanode: 195.06 (4) 53 | load_resource: 203.222 54 | PetaboxLoader3.resolve: 80.19 55 | */ -------------------------------------------------------------------------------- /assets/reiter_l.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/reiter_l.gif -------------------------------------------------------------------------------- /assets/reiter_r.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/reiter_r.gif -------------------------------------------------------------------------------- /assets/rt_icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/rt_icon.gif -------------------------------------------------------------------------------- /assets/trans.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/assets/trans.gif -------------------------------------------------------------------------------- /bootstrap.php: -------------------------------------------------------------------------------- 1 | false, 17 | 'auto_reload' => true, 18 | 'autoescape' => 'html' 19 | ]); 20 | 21 | // MySQL connection 22 | $db = new SQL(); 23 | $db->connect($config["db_hostname"], $config["db_username"], $config["db_password"], $config["db_database"]); 24 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "minimum-stability": "dev", 3 | "require": { 4 | "twig/twig": "^3.0", 5 | "alexandr-mironov/php8-smpp": "dev-main" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /helper/import-content.php: -------------------------------------------------------------------------------- 1 | ['txt'], 16 | 'polyphonic-ring' => ['mid'], 17 | 'operator-logo' => ['gif', 'bmp', 'png'], 18 | 'splash-logo' => ['gif', 'bmp', 'png'], 19 | 'amr' => ['amr'], 20 | 'j2me' => ['jar'], 21 | 'bitmap' => ['gif', 'bmp', 'png'], 22 | ]; 23 | 24 | $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path . "/" . $type . "/")); 25 | 26 | /** @var SplFileInfo $file */ 27 | foreach ($rii as $file) 28 | { 29 | if ($file->isDir()) 30 | { 31 | continue; 32 | } 33 | 34 | if (!in_array($file->getExtension(), $validExtensions[$type])) 35 | { 36 | continue; 37 | } 38 | 39 | $short_path = str_replace($path . "/", "", $file->getPathname()); 40 | $filename = $file->getBasename("." . $file->getExtension()); 41 | 42 | if ($db->prepared_fetch_one("SELECT * FROM `content` WHERE `path` = ? LIMIT 0,1", "s", $short_path) === NULL) 43 | { 44 | echo "new one!\n"; 45 | $db->prepared_query("INSERT INTO `content`(`type`, `author`, `name`, `path`) VALUES ( 46 | ?, 47 | ?, 48 | ?, 49 | ? 50 | )", "siss", $type, 2, $filename, $short_path); 51 | } 52 | else 53 | { 54 | echo "had that one already\n"; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /helper/wbxml.php: -------------------------------------------------------------------------------- 1 | init(); 4 | 5 | $page = strtolower(trim(preg_replace('/[^0-9a-zA-Z\-]/', '', $_GET['page'] ?? 'index'))); 6 | 7 | // special handling for each page with the name of a content type 8 | if (Content::is_valid_content_type($page)) 9 | { 10 | $type = $page; 11 | $page = "content"; 12 | } 13 | 14 | $php = SERVER_PATH . "/pages/" . $page . ".php"; 15 | if (file_exists($php)) 16 | { 17 | require_once($php); 18 | } 19 | else 20 | { 21 | http_response_code(404); 22 | echo $twig->render('pages/404.html', []); 23 | } -------------------------------------------------------------------------------- /kannel-sms.php: -------------------------------------------------------------------------------- 1 | prepared_fetch_one("SELECT * FROM gateways WHERE token = ? AND enabled = 1;", "s", $token); 6 | 7 | if (!$gateway) 8 | { 9 | http_return_code(403); 10 | echo "access denied"; 11 | die(); 12 | } 13 | 14 | $sms_from = $_SERVER["HTTP_X_KANNEL_FROM"]; 15 | $sms_message = file_get_contents("php://input"); 16 | 17 | SMS::parse_inbound_sms($gateway, $sms_message, $sms_from); -------------------------------------------------------------------------------- /libs/BubblewrapSandbox.php: -------------------------------------------------------------------------------- 1 | array("pipe", "r"), // stdin 53 | 1 => array("pipe", "w"), // stdout 54 | 2 => array("pipe", "w"), // stderr 55 | 10 => array("file", $seccomp_bpf_path, "r") // FD 10 is a BPF program containing seccomp rules limiting the allowed syscalls 56 | ); 57 | 58 | //var_dump($cmd); 59 | 60 | $process = proc_open($cmd, $descriptorspec, $pipes, $workdir, []); 61 | $success = false; 62 | $output = false; 63 | $stdout = false; 64 | $stderr = false; 65 | 66 | if (is_resource($process)) 67 | { 68 | $stdout = stream_get_contents($pipes[1]); 69 | fclose($pipes[1]); 70 | $stderr = stream_get_contents($pipes[2]); 71 | fclose($pipes[2]); 72 | 73 | proc_close($process); 74 | 75 | if (!is_link($workdir . "output") && is_file($workdir . "output")) 76 | { 77 | $success = true; 78 | $output = file_get_contents($workdir . "output"); 79 | } 80 | } 81 | 82 | $cmd = "rm -r " . escapeshellarg($workdir); 83 | `$cmd`; 84 | 85 | return [ 86 | "success" => $success, 87 | "output" => $output, 88 | "stdout" => $stdout, 89 | "stderr" => $stderr 90 | ]; 91 | } 92 | 93 | static function create_workdir() 94 | { 95 | global $config; 96 | $tempdir = $config['tempdir']; 97 | if (!file_exists($tempdir)) 98 | { 99 | mkdir($tempdir); 100 | } 101 | 102 | $workdir = $tempdir . uniqid("", true) . "/"; 103 | mkdir($workdir); 104 | return $workdir; 105 | } 106 | 107 | } -------------------------------------------------------------------------------- /libs/Content.php: -------------------------------------------------------------------------------- 1 | prepared_fetch_one("SELECT content.*,authors.name as `authorname` FROM content, authors WHERE content.id = ? AND author = authors.id AND content.visible = 1;", "i", $content_id); 59 | 60 | if ($content === null) 61 | { 62 | SMS::send_text_sms($gateway, $sender, "The content " . $content_id . " could not be found. Please try again."); 63 | return false; 64 | } 65 | 66 | $db->prepared_query("UPDATE content SET sent = sent + 1 WHERE `id` = ? AND `visible` = 1;", "i", $content_id); 67 | 68 | $sms = false; 69 | switch ($content["type"]) 70 | { 71 | case 'rtttl': 72 | $sms = RTTTL::convert_to_nokia_sms($content_path . $content["path"]); 73 | break; 74 | case 'operator-logo': 75 | $sms = OperatorLogo::convert_to_nokia_sms_operator($content_path . $content["path"], 901, 70, "-monochrome -threshold 0 -negate"); 76 | break; 77 | case 'bitmap': 78 | case 'polyphonic-ring': 79 | $wappush = WAPPush::generate_stored( $content["type"], $content["name"], basename($content["path"]), $sender, [ 80 | "id" => $content['id'], 81 | "name" => $content["name"] 82 | ]); 83 | if ($plain) 84 | { 85 | SMS::send_text_sms($gateway, $sender, $wappush["url"]); 86 | return true; 87 | } 88 | $sms = WAPPush::generate_wap_push($wappush["url"], $wappush["name"]); 89 | break; 90 | default: 91 | SMS::send_text_sms($gateway, $sender, "The content " . $content_id . " cannot be requested via SMS. Please use www.blamba.de."); 92 | return true; 93 | break; 94 | } 95 | 96 | SMS::send_udh_sms($gateway, $sender, $sms); 97 | return true; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /libs/Device.php: -------------------------------------------------------------------------------- 1 | prepared_fetch_one("SELECT id FROM `sessions` WHERE `registration_token` = ?", "i", $registration_token) == NULL) 13 | { 14 | error_log("generated token: " . $registration_token); 15 | $_SESSION['registration_token'] = $registration_token; 16 | Session::current()->save(); 17 | } 18 | } 19 | 20 | return $_SESSION['registration_token']; 21 | } 22 | 23 | static function check_registration_token($gateway, $registration_token, $msn) 24 | { 25 | global $db; 26 | 27 | $session = $db->prepared_fetch_one("SELECT id FROM `sessions` WHERE `registration_token` = ?", "i", (int) $registration_token); 28 | if ($session !== NULL) 29 | { 30 | $db->prepared_query("DELETE FROM `devices` WHERE `msn` = ? AND `gateway` = ?;", "si", $msn, $gateway['id']); 31 | $db->prepared_query("INSERT INTO `devices` (`user`, `msn`, `gateway`) VALUES (?, ?, ?);", "ssi", $session['id'], $msn, $gateway['id']); 32 | return true; 33 | } 34 | 35 | return false; 36 | } 37 | } -------------------------------------------------------------------------------- /libs/ImageMagick.php: -------------------------------------------------------------------------------- 1 | $infile, 'additional_im_params' => $additional_im_params, 'sandboxResult' => $sandboxResult]); 11 | 12 | return $sandboxResult; 13 | } 14 | } -------------------------------------------------------------------------------- /libs/Kannel.php: -------------------------------------------------------------------------------- 1 | $destination, 9 | "text" => $data, 10 | ]); 11 | } 12 | 13 | static function send_udh_sms($gateway, $destination, $data) 14 | { 15 | global $config; 16 | 17 | $data = hex2bin($data); 18 | 19 | $udhHeaderLength = ord($data[0]) + 1; 20 | $udhHeader = substr($data, 0, $udhHeaderLength); 21 | $content = substr($data, $udhHeaderLength); 22 | 23 | return self::send_kannel_smsbox_request($gateway, [ 24 | "to" => $destination, 25 | "udh" => $udhHeader, 26 | "text" => $content, 27 | ]); 28 | } 29 | 30 | static function send_kannel_smsbox_request($gateway, $data) 31 | { 32 | global $config; 33 | 34 | $data["username"] = $gateway["kannel_username"]; 35 | $data["password"] = $gateway["kannel_password"]; 36 | $data["from"] = $gateway["sender_msn"]; 37 | 38 | $ch = curl_init(); 39 | 40 | curl_setopt($ch, CURLOPT_URL, $gateway["kannel_url"] . "/cgi-bin/sendsms?" . http_build_query($data)); 41 | curl_setopt($ch, CURLOPT_HEADER, false); 42 | curl_setopt($ch, CURLOPT_TIMEOUT, 10); 43 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 44 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); 45 | 46 | $body = curl_exec($ch); 47 | $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); 48 | 49 | if (curl_errno($ch) !== 0) 50 | { 51 | return [ 52 | "success" => false, 53 | "body" => curl_error($ch) 54 | ]; 55 | } 56 | 57 | return [ 58 | "success" => true, 59 | "status" => $status, 60 | "body" => $body 61 | ]; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /libs/Logging.php: -------------------------------------------------------------------------------- 1 | prepared_query("INSERT INTO `log` (`date`, `session_id`, `phonenumber`, `type`, `log`) VALUES (NOW(), ?, ?, ?, ?);", "ssss", session_id(), $phonenumber, $type, $log); 13 | } 14 | } -------------------------------------------------------------------------------- /libs/OperatorLogo.php: -------------------------------------------------------------------------------- 1 | $infile, 'command' => $command, 'sandboxResult' => $sandboxResult]); 19 | return $sandboxResult; 20 | } 21 | } -------------------------------------------------------------------------------- /libs/SQL.php: -------------------------------------------------------------------------------- 1 | db = false; 8 | } 9 | 10 | function __destruct() 11 | { 12 | $this->disconnect(); 13 | } 14 | 15 | function connect( $address, $user, $pwd, $db ) 16 | { 17 | $this->db = @mysqli_connect( $address, $user, $pwd ); 18 | if( $this->db ) 19 | { 20 | mysqli_set_charset( $this->db, "utf8mb4" ); 21 | 22 | return mysqli_select_db( $this->db, $db ); 23 | } 24 | } 25 | 26 | function isConnected() 27 | { 28 | return $this->db; 29 | } 30 | 31 | function disconnect() 32 | { 33 | if( $this->db && @mysqli_close( $this->db ) ) 34 | { 35 | $this->db = false; 36 | return true; 37 | } 38 | } 39 | 40 | function affectedRows() 41 | { 42 | return $this->db->affected_rows; 43 | } 44 | 45 | function insertID() 46 | { 47 | return $this->db->insert_id; 48 | } 49 | 50 | function nextInsertID( $table ) 51 | { 52 | return 1 + $this->fetch( "SELECT COUNT( LAST_INSERT_ID() ) AS `count` FROM `" . $db->escape( $table ) . "`", "count" ); 53 | } 54 | 55 | function escape( $string ) 56 | { 57 | return mysqli_real_escape_string( $this->db, $string ); 58 | } 59 | 60 | function prepared_query ( ...$args ) 61 | { 62 | if (count($args) < 3) 63 | throw new Exception("to few arguments for SQL::prepare_query()"); 64 | 65 | $stmt = $this->db->prepare($args[0]); 66 | array_shift($args); 67 | $stmt->bind_param(...$args); 68 | $stmt->execute(); 69 | 70 | if ($stmt->error != "") 71 | { 72 | Logging::log("prepared_query", ["error" => $stmt->error, "args" => $args]); 73 | return false; 74 | } 75 | 76 | $resource = $stmt->get_result(); 77 | if( gettype( $resource ) == "object" ) 78 | { 79 | $q = new Query( $resource ); 80 | return $q; 81 | } 82 | elseif( $resource ) 83 | { 84 | return $resource; 85 | } 86 | 87 | return true; 88 | } 89 | 90 | function prepared_fetch ( ...$args ) 91 | { 92 | $q = $this->prepared_query ( ...$args ); 93 | if( $q ) 94 | return $q->fetch(); 95 | } 96 | 97 | function prepared_fetch_one ( ...$args ) 98 | { 99 | $q = $this->prepared_query ( ...$args ); 100 | if( $q ) 101 | return $q->fetch(true); 102 | } 103 | 104 | function query( $query ) 105 | { 106 | if( !$query ) 107 | return false; 108 | 109 | $return = false; 110 | 111 | $resource = mysqli_query( $this->db, $query ); 112 | 113 | if( gettype( $resource ) == "object" ) 114 | { 115 | $q = new Query( $resource ); 116 | 117 | return $q; 118 | } 119 | elseif( $resource ) 120 | { 121 | return $resource; 122 | } 123 | else 124 | { 125 | //echo $query . "
" . $this->error(); 126 | error_log("SQL error occured. " . $this->error()); 127 | } 128 | 129 | return false; 130 | } 131 | 132 | function fetch( $query, $specific = NULL ) 133 | { 134 | $q = $this->query( $query ); 135 | if( $q ) 136 | return $q->fetch( $specific ); 137 | } 138 | 139 | function error() 140 | { 141 | return $this->db->error; 142 | } 143 | 144 | public static function & current() 145 | { 146 | static $instance = null; 147 | return $instance = ( empty( $instance ) ) ? new self() : $instance; 148 | } 149 | } 150 | 151 | class Query 152 | { 153 | protected $query; 154 | 155 | function __construct($query) 156 | { 157 | $this->query = $query; 158 | } 159 | 160 | function numRows() 161 | { 162 | return $this->query->num_rows; 163 | } 164 | 165 | function fetch( $specific = NULL ) 166 | { 167 | if( is_string( $specific )) 168 | { 169 | $result = mysqli_fetch_assoc ( $this->query ); 170 | return $result[ $specific ]; 171 | } 172 | elseif( isset( $specific ) ) 173 | { 174 | return mysqli_fetch_assoc ( $this->query ); 175 | } 176 | else 177 | { 178 | $results = array(); 179 | for( $i = 0; $i < $this->query->num_rows ; $i++ ) 180 | $results[] = mysqli_fetch_assoc( $this->query ); 181 | 182 | return $results; 183 | } 184 | } 185 | 186 | function fetchRow() 187 | { 188 | return mysqli_fetch_assoc( $this->query ); 189 | } 190 | 191 | function __destruct() 192 | { 193 | mysqli_free_result( $this->query ); 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /libs/Session.php: -------------------------------------------------------------------------------- 1 | true, 19 | 'cookie_httponly' => true, 20 | 'cookie_lifetime' => 365 * 24 * 60 * 60, 21 | 'gc_maxlifetime' => 365 * 24 * 60 * 60, 22 | ]); 23 | 24 | $this->handler = $session_handler; 25 | self::$instance = $this; 26 | 27 | Device::generate_registration_token(); 28 | } 29 | } 30 | 31 | public function reload() 32 | { 33 | $data = $this->handler->read(session_id()); 34 | session_decode($data); 35 | } 36 | 37 | public function save() 38 | { 39 | global $db; 40 | if ($this->handler instanceof SessionHandlerSQL) 41 | { 42 | $db->prepared_query(" 43 | INSERT INTO `sessions` (`id`, `data`, `registration_token`, `insert_date`, `updated_at`) VALUES ( ?, ?, ?, NOW(), NOW()) ON DUPLICATE KEY UPDATE 44 | `data` = VALUES( `data` ), `registration_token` = VALUES( `registration_token` ), `updated_at` = NOW()", "ssi", session_id(), session_encode(), $_SESSION['registration_token'] ?? null); 45 | } 46 | } 47 | 48 | public static function current() 49 | { 50 | return ( empty( self::$instance ) ? new self() : self::$instance ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /libs/SessionHandlerSQL.php: -------------------------------------------------------------------------------- 1 | prepared_fetch_one("SELECT * FROM `sessions` WHERE `id` = ?", "s", $id); 18 | 19 | if ( $row !== false and !is_null( $row ) ) 20 | { 21 | return $row[ 'data' ]; 22 | } 23 | return ""; 24 | } 25 | 26 | public function write( $id, $data ) 27 | { 28 | return true; 29 | } 30 | 31 | public function destroy( $id ) 32 | { 33 | global $db; 34 | $result = $db->prepared_query("DELETE FROM `sessions` WHERE id = ?", "s", $id); 35 | return ( $result !== false ); 36 | } 37 | 38 | public function gc( $max ) 39 | { 40 | global $db; 41 | $db->query( "DELETE FROM `sessions` WHERE `updated_at` < DATE_SUB(NOW(), INTERVAL 24 HOUR);" ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /libs/UAProf.php: -------------------------------------------------------------------------------- 1 | prepared_fetch_one("SELECT * FROM uaprof WHERE uaprof_url = ? LIMIT 0,1;", "s", $url); 15 | 16 | if ($uaprof != null) 17 | { 18 | error_log($url . " already loaded"); 19 | } 20 | else 21 | { 22 | self::load_from_webarchive($phonename, $url); 23 | } 24 | } 25 | 26 | static function load_from_webarchive($basename, $url) 27 | { 28 | global $db; 29 | 30 | error_log($url); 31 | 32 | $fetched = true; 33 | 34 | // id_ suffix will force a raw file download (without the JavaScript/HTML web.archive.org header) 35 | $webarchive_url = "https://web.archive.org/web/20001101000000id_/" . $url; 36 | $ch = curl_init(); 37 | curl_setopt($ch, CURLOPT_URL, $webarchive_url); 38 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 39 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 40 | curl_setopt($ch, CURLOPT_USERAGENT, "Blamba! retro phone service - Contact blamba@tbspace.de"); 41 | 42 | $output = curl_exec($ch); 43 | 44 | if(curl_errno($ch)) 45 | { 46 | $fetched = false; 47 | $output = curl_error($ch); 48 | } 49 | 50 | $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 51 | if ($http_code != 200) 52 | { 53 | $fetched = false; 54 | $output = ''; 55 | } 56 | 57 | curl_close($ch); 58 | 59 | $db->prepared_query("INSERT INTO `uaprof` (`uaprof_url`, `fetched`, `last_return`, `last_tried`, `uaprof_xml`) VALUES (?, ?, ?, NOW(), ?);", "siis", $url, $fetched, $http_code, $output); 60 | } 61 | } -------------------------------------------------------------------------------- /libs/WAPPush.php: -------------------------------------------------------------------------------- 1 | $url, "text" => $text]); 7 | 8 | $data = [ 9 | "\x01", // trans id 10 | "\x06", // Push 11 | "\x04", // Header Length 12 | "\x03", // Length 13 | "\xAE", // Content type (application/vnd.wap.sic) 14 | "\x81", // Character Set (01 once removed high bit) 15 | "\xEA", // UTF-8 (6A once removed high bit) 16 | "\x02", // WBXML Version 1.2 17 | "\x05", // SI Identifier 18 | "\x6A", // UTF-8 19 | "\x00", // End Data 20 | "\x45", // SI WBXML Tag 21 | "\xC6", // Indication Tag 22 | "\x0B", // href 23 | "\x03", // Open Text 24 | $url, // URL 25 | "\x00", // End Data 26 | "\x0A", // Created (date) 27 | "\xC3", // Data Follows 28 | "\x07", // Data Length 29 | hex2bin(date("YmdHis") ), // Date 30 | "\x01", // Close Attribute 31 | "\x03", // Open Text 32 | $text, // Linktext 33 | "\x00", // End Data 34 | "\x01", // Close Indication Tag 35 | "\x01", // Close SI Tag 36 | ]; 37 | 38 | // IANA WAP-Push Multimedia Messaging Service port 39 | return SMS::generate_udh(2948, implode("", $data)); 40 | } 41 | 42 | static function generate_wap_push_service_load($url, $text) 43 | { 44 | // NOTE: This function doens't seem to work well with most phones I've tested. 45 | Logging::log("generate_wap_push", ["url" => $url, "text" => $text]); 46 | 47 | // https://www.openmobilealliance.org/release/Push/V2_1-20051122-C/WAP-168-ServiceLoad-20010731-a.pdf 48 | $data = [ 49 | "\x06", // UDH length 50 | "\x05", // Application Port Addressing, 16 bit address 51 | "\x04", // content length 52 | "\x0B\x84", // Destination port number, IANA WAP-Push Multimedia Messaging Service port (2948) 53 | "\x23\xF0", // Source port number 54 | "\x01", // trans id 55 | "\x06", // Push 56 | "\x04", // Header Length 57 | "\x03", // Length 58 | "\xB0", // Content type (application/vnd.wap.slc) 59 | "\x81", // Character Set (01 once removed high bit) 60 | "\xEA", // UTF-8 (6A once removed high bit) 61 | "\x02", // WBXML Version 1.2 62 | "\x06", // SL Identifier 63 | "\x6A", // UTF-8 64 | "\x00", // End Data 65 | "\x85", // SL WBXML Tag 66 | "\x08", // href 67 | "\x03", // Open Text 68 | $url, // URL 69 | "\x00", // End Data 70 | /*"\x0A", // Created (date) 71 | "\xC3", // Data Follows 72 | "\x07", // Data Length 73 | hex2bin(date("YmdHis") ), // Date 74 | "\x01", // Close Attribute 75 | "\x01", // Close Indication Tag*/ 76 | //"\x05", // Action Attribute ( 0x05 = execute-low ) 77 | "\x01", // Close SL Tag 78 | ]; 79 | 80 | $bindata = implode("", $data); 81 | if (strlen($bindata) > 140) 82 | throw new Exception("WAP Push message length exceeds 140 bytes."); 83 | 84 | return bin2hex($bindata); 85 | } 86 | 87 | static function generate_wap_push_gif($filename) 88 | { 89 | $data = [ 90 | "\x01", // trans id 91 | "\x06", // Push 92 | "\x02", // Header Length 93 | "\x01", // Length 94 | "\x9D", // Content type (image/gif) 95 | ]; 96 | 97 | $data[] = file_get_contents($filename); 98 | 99 | // IANA WAP-Push Multimedia Messaging Service port 100 | return SMS::generate_udh(2948, implode("", $data)); 101 | } 102 | 103 | static function generate_stored( $type, $name, $filename, $msn, $data ) 104 | { 105 | global $db; 106 | $uuid = self::generate_wap_push_uuid(); 107 | 108 | $data = json_encode($data, JSON_PRETTY_PRINT); 109 | $db->prepared_query("UPDATE `wappush` SET `msn` = ?, `type` = ?, `filename` = ?, `params` = ? WHERE `uuid` = ?;", "sssss", $msn, $type, $filename, $data, $uuid); 110 | 111 | return [ 112 | "uuid" => $uuid, 113 | "url" => "http://wap.blamba.de/wp/" . $uuid . "/" . urlencode($filename), 114 | "name" => $name 115 | ]; 116 | } 117 | 118 | static function generate_wap_push_uuid() 119 | { 120 | global $db; 121 | 122 | while (true) 123 | { 124 | $uuid = self::base64url_encode(random_bytes(16)); 125 | $result = $db->prepared_query("INSERT INTO `wappush` (`uuid`, `created`) VALUES (?, NOW());", "s", $uuid); 126 | 127 | if ($result === true) 128 | { 129 | break; 130 | } 131 | } 132 | 133 | return $uuid; 134 | } 135 | 136 | static function base64url_encode( $data ) 137 | { 138 | return rtrim( strtr( base64_encode( $data ), '+/', '-_'), '='); 139 | } 140 | } -------------------------------------------------------------------------------- /media.php: -------------------------------------------------------------------------------- 1 | prepared_fetch_one("SELECT * FROM content WHERE `id` = ? AND `visible` = 1;", "i", $id); 8 | if (is_null($content)) 9 | { 10 | http_response_code(404); 11 | echo $twig->render('pages/404.html', []); 12 | exit; 13 | } 14 | 15 | if ($content['type'] == "rtttl" || $content['type'] == "polyphonic-ring") 16 | $db->prepared_query("UPDATE content SET played = played + 1 WHERE `id` = ? AND `visible` = 1;", "i", $content['id']); 17 | 18 | switch ($content['type']) 19 | { 20 | case 'rtttl': 21 | if ($type == "preview") 22 | { 23 | header('Content-Type: audio/midi'); 24 | echo RTTTL::convert_to_midi($content_path . $content["path"]); 25 | exit; 26 | } 27 | break; 28 | default: 29 | download_file($content_path . $content["path"], false, $type); 30 | break; 31 | } 32 | 33 | function download_file($file, $mime = false) 34 | { 35 | if (file_exists($file)) 36 | { 37 | header('Content-Description: File Transfer'); 38 | if ($mime !== false) 39 | { 40 | header('Content-Type: ' . $mime); 41 | } 42 | else 43 | { 44 | header('Content-Type: application/octet-stream'); 45 | } 46 | header('Content-Disposition: attachment; filename="'.basename($file).'"'); 47 | header('Expires: 0'); 48 | header('Cache-Control: must-revalidate'); 49 | header('Pragma: public'); 50 | header('Content-Length: ' . filesize($file)); 51 | readfile($file); 52 | exit; 53 | } 54 | } -------------------------------------------------------------------------------- /media_wap.php: -------------------------------------------------------------------------------- 1 | prepared_fetch_one("SELECT * FROM wappush WHERE `uuid` = ?;", "s", $_GET['id']); 6 | if (is_null($wappush)) 7 | { 8 | http_response_code(404); 9 | echo "Content could not be found!"; 10 | exit; 11 | } 12 | 13 | Logging::log("storedwap_media", $_SERVER, $wappush["msn"]); 14 | 15 | // We might've just learned which type of device this is... 16 | // If we know the MSN for this download, let's save the useragent and UAProf URL 17 | if (!empty($wappush["msn"])) 18 | { 19 | $wapprofile = false; 20 | // WAP 2.0 (direct TCP/IP access via HTTP) 21 | if (!empty($_SERVER["HTTP_X_WAP_PROFILE"] ?? "")) 22 | { 23 | $wapprofile = trim($_SERVER["HTTP_X_WAP_PROFILE"] ?? "", '"'); 24 | } 25 | 26 | // WAP 1.1 (via WAP gateway/Kannel) 27 | if (!empty($_SERVER["HTTP_PROFILE"] ?? "")) 28 | { 29 | $wapprofile = trim($_SERVER["HTTP_PROFILE"] ?? "", '"'); 30 | } 31 | 32 | if ($wapprofile) 33 | { 34 | $useragent = $_SERVER["HTTP_USER_AGENT"] ?? ""; 35 | $accept = $_SERVER["HTTP_ACCEPT"] ?? ""; 36 | 37 | $phonetype = explode(" ", $useragent)[0]; // Nokia6220/2.0 Profile/MIDP-1.0 Configuration/CLDC-1.0 -> Nokia6220 38 | $db->prepared_query("UPDATE `devices` SET `type` = ?, `useragent` = ?, `wap-profile` = ?, `accept` = ? WHERE `msn` = ?;", "sssss", $phonetype, $useragent, $wapprofile, $accept, $wappush["msn"]); 39 | } 40 | } 41 | 42 | $db->prepared_query("UPDATE wappush SET download_count = download_count + 1 WHERE `uuid` = ?;", "s", $_GET['id']); 43 | $wappush_params = json_decode($wappush["params"], true); 44 | 45 | // User-defined custom file upload 46 | if (($wappush_params["mode"] ?? '') == "custom" ) 47 | { 48 | download_file($userupload_path . "/" . $wappush["uuid"]); 49 | } 50 | else 51 | { 52 | // Regular content 53 | $id = $wappush_params["id"]; 54 | $content = $db->prepared_fetch_one("SELECT * FROM content WHERE `id` = ? AND `visible` = 1;", "i", $id); 55 | if (is_null($content)) 56 | { 57 | http_response_code(404); 58 | echo "Content could not be found!"; 59 | exit; 60 | } 61 | $db->prepared_query("UPDATE content SET played = played + 1 WHERE `id` = ? AND `visible` = 1;", "i", $content['id']); 62 | download_file($content_path . $content["path"]); 63 | } 64 | 65 | 66 | function download_file($file) 67 | { 68 | if (file_exists($file)) 69 | { 70 | $mime_type = mime_content_type($file); 71 | // if has a .jar extension, we need to force it to "application/java-archive" to make it work on some devices 72 | if (pathinfo($file, PATHINFO_EXTENSION) == "jar" || $mime_type == "application/zip") { 73 | $mime_type = "application/java-archive"; 74 | } 75 | 76 | header('Content-Type: ' . $mime_type); 77 | header('Content-Length: ' . filesize($file)); 78 | readfile($file); 79 | exit; 80 | } 81 | } -------------------------------------------------------------------------------- /pages/content-details.php: -------------------------------------------------------------------------------- 1 | prepared_fetch_one("SELECT content.*,authors.name as `authorname` FROM content, authors WHERE content.id = ? AND author = authors.id AND content.visible = 1;", "i", $id); 4 | 5 | if (is_null($content)) 6 | { 7 | echo $twig->render('pages/404.html',[]); 8 | exit(); 9 | } 10 | 11 | if ($content["type"] == "rtttl") 12 | { 13 | $rtttldata = file_get_contents($content_path . $content["path"]); 14 | } 15 | 16 | $devices = $db->prepared_fetch("SELECT * FROM devices WHERE user = ?;", "s", session_id()); 17 | 18 | echo $twig->render('pages/' . $page . '.html', 19 | [ 20 | 'type' => $content["type"], 21 | 'type_human' => Content::human_readable_type($content["type"]), 22 | 'content' => $content, 23 | 'file_basename' => basename($content['path']), 24 | 'file_size' => filesize($content_path . $content['path']), 25 | 'rtttldata' => $rtttldata, 26 | 'devices' => $devices, 27 | 'registration_token' => $_SESSION['registration_token'], 28 | 'config' => $config, 29 | ]); -------------------------------------------------------------------------------- /pages/content.php: -------------------------------------------------------------------------------- 1 | prepared_fetch("SELECT * FROM content WHERE type = ? AND visible = 1 ORDER BY sent DESC, played DESC;", "s", $type); 3 | 4 | echo $twig->render('pages/' . $page . '.html', 5 | [ 6 | 'type' => $type, 7 | 'type_human' => Content::human_readable_type($type), 8 | 'content' => $content 9 | ]); -------------------------------------------------------------------------------- /pages/customupload.php: -------------------------------------------------------------------------------- 1 | prepared_fetch("SELECT * FROM devices WHERE user = ?;", "s", session_id()); 3 | 4 | function sanity_check_file($file, $mime) 5 | { 6 | if ($file["error"]) 7 | return "Keine Datei ausgewaehlt oder Upload fehlgeschlagen"; 8 | 9 | if ($file["size"] > 512 * 1024) 10 | return "Datei zu gross"; 11 | 12 | if (!in_array($file["type"], $mime)) 13 | { 14 | return "Falsch uebermittelter MIME-Type"; 15 | } 16 | 17 | if (!in_array(mime_content_type($file['tmp_name']), $mime)) 18 | { 19 | return "Falscher MIME-Type"; 20 | } 21 | 22 | return false; 23 | } 24 | 25 | function sanitize_filename($file, $extensions) 26 | { 27 | $pathinfo = pathinfo($file["name"]); 28 | $filename = preg_replace('/[^A-Za-z0-9\-\_]/', '', $pathinfo['filename']); 29 | $extension = preg_replace('/[^a-z]/', '', strtolower($pathinfo['extension'])); 30 | 31 | if (!in_array($extension, $extensions)) 32 | { 33 | return false; 34 | } 35 | 36 | return $filename . "." . $extension; 37 | } 38 | 39 | function save_upload($file, $type, $extensions, $msn, $data) 40 | { 41 | global $userupload_path; 42 | $filename = sanitize_filename($file, $extensions); 43 | if (!$filename) 44 | return false; 45 | 46 | $wappush = WAPPush::generate_stored( $type, "custom", $filename, $msn, $data ); 47 | move_uploaded_file($file["tmp_name"], $userupload_path . "/" . $wappush["uuid"]); 48 | 49 | return WAPPush::generate_wap_push($wappush["url"], $wappush["name"]); 50 | } 51 | 52 | if (isset($_POST["type"])) 53 | { 54 | $device = $db->prepared_fetch_one("SELECT * FROM devices WHERE user = ? AND id = ?;", "ss", session_id(), (int)$_POST['msn']); 55 | if (is_null($device)) 56 | { 57 | echo $twig->render('pages/404.html', []); exit(); 58 | } 59 | $gateway = $db->prepared_fetch_one("SELECT * FROM gateways WHERE enabled = 1 AND id = ?;", "i", $device["gateway"]); 60 | 61 | $data = ""; 62 | 63 | switch ($_POST["type"]) 64 | { 65 | case 'operator-logo': 66 | case 'group-logo': 67 | if (($error = sanity_check_file($_FILES["file-graphics"], ["image/png", "image/jpeg", "image/gif", "image/bmp"])) === false) 68 | { 69 | if ($_POST["type"] == "operator-logo") 70 | $data = OperatorLogo::convert_to_nokia_sms_operator($_FILES["file-graphics"]["tmp_name"], 262, 42, "-monochrome -threshold 0 -negate"); 71 | 72 | if ($_POST["type"] == "group-logo") 73 | $data = OperatorLogo::convert_to_nokia_sms_group($_FILES["file-graphics"]["tmp_name"], "-monochrome -threshold 0 -negate"); 74 | } 75 | break; 76 | case 'rtttl': 77 | if (($error = sanity_check_file($_FILES["file-rtttl"], ["text/plain"])) === false) 78 | { 79 | $data = RTTTL::convert_to_nokia_sms($_FILES["file-rtttl"]["tmp_name"]); 80 | } 81 | break; 82 | case 'bitmap': 83 | if (($error = sanity_check_file($_FILES["file-graphics"], ["image/png", "image/jpeg", "image/gif", "image/bmp"])) === false) 84 | { 85 | $data = save_upload($_FILES["file-graphics"], "bitmap", ["png", "jpg", "jpeg", "gif", "bmp"], $device["msn"], ["mode" => "custom"]); 86 | } 87 | break; 88 | case 'polyphonic-ring': 89 | if (($error = sanity_check_file($_FILES["file-midi"], ["audio/midi", "audio/x-midi"])) === false) 90 | { 91 | $data = save_upload($_FILES["file-midi"], "polyphonic-ring", ["mid", "midi"], $device["msn"], ["mode" => "custom"]); 92 | } 93 | break; 94 | case 'j2me': 95 | if (($error = sanity_check_file($_FILES["file-java"], ["application/java-archive", "application/x-java-applet", "application/java", "application/zip"])) === false) 96 | { 97 | $data = save_upload($_FILES["file-java"], "j2me", ["jar"], $device["msn"], ["mode" => "custom"]); 98 | } 99 | break; 100 | } 101 | 102 | $error = SMS::sanity_check_udh_array($data); 103 | if (trim($data) == "") 104 | { 105 | $error = "Die Datei konnte nicht umgewandelt werden."; 106 | } 107 | if ($error == "") 108 | { 109 | $success = "Nachrichten wurden zum Versand hinterlegt."; 110 | SMS::send_udh_sms($gateway, $device["msn"], $data); 111 | } 112 | } 113 | 114 | echo $twig->render('pages/' . $page . '.html', 115 | [ 116 | 'success' => $success, 117 | 'error' => $error, 118 | 'data' => $data, 119 | 'smsarray' => SMS::split_sms_string($data), 120 | 'devices' => $devices, 121 | 'registration_token' => $_SESSION['registration_token'], 122 | 'config' => $config, 123 | ]); -------------------------------------------------------------------------------- /pages/fahrplan.php: -------------------------------------------------------------------------------- 1 | $schedule_day) 23 | { 24 | foreach ($schedule_day["rooms"] as $room => $roomEvents) 25 | { 26 | foreach ($roomEvents as $eventKey => $event) 27 | { 28 | $event["weekday"] = $weekdays[date("w", strtotime($event["date"]))]; 29 | $events[] = $event; 30 | } 31 | 32 | } 33 | } 34 | 35 | $data = ""; 36 | $success = false; 37 | if (isset($_POST["msn"])) 38 | { 39 | $device = $db->prepared_fetch_one("SELECT * FROM devices WHERE user = ? AND id = ?;", "ss", session_id(), (int)$_POST['msn']); 40 | if (is_null($device)) 41 | { 42 | echo $twig->render('pages/404.html', []); exit(); 43 | } 44 | $gateway = $db->prepared_fetch_one("SELECT * FROM gateways WHERE enabled = 1 AND id = ?;", "i", $device["gateway"]); 45 | 46 | $count = 0; 47 | foreach ($events as $event) 48 | { 49 | if (isset($_POST["event" . $event["id"]])) 50 | { 51 | $count++; 52 | if ($count > 11) 53 | { 54 | break; 55 | } 56 | 57 | // We're only sending a single Event per SMS, 58 | // sending multiple breaks old Nokias (like the 6310i) 59 | $sms = SMS::generate_vcal_udh([$event]); 60 | SMS::send_udh_sms($gateway, $device["msn"], $sms); 61 | 62 | $data .= $sms . "\n\n"; 63 | $success = "Die Fahrplaneinträge wurden an dein Handy geschickt!"; 64 | } 65 | } 66 | } 67 | 68 | $devices = $db->prepared_fetch("SELECT * FROM devices WHERE user = ?;", "s", session_id()); 69 | 70 | echo $twig->render('pages/' . $page . '.html', 71 | [ 72 | 'success' => $success, 73 | 'data' => $data, 74 | 'smsarray' => SMS::split_sms_string($data), 75 | 'events' => $events, 76 | 'devices' => $devices, 77 | 'registration_token' => $_SESSION['registration_token'], 78 | 'config' => $config, 79 | ]); 80 | -------------------------------------------------------------------------------- /pages/faq.php: -------------------------------------------------------------------------------- 1 | render('pages/' . $page . '.html', []); -------------------------------------------------------------------------------- /pages/index.php: -------------------------------------------------------------------------------- 1 | prepared_fetch("SELECT * FROM devices WHERE user = ?;", "s", session_id()); 3 | 4 | $top_poly = $db->fetch("SELECT * FROM `content` WHERE `type` = 'polyphonic-ring' ORDER BY `played` DESC LIMIT 0,6"); 5 | $top_operator = $db->fetch("SELECT * FROM `content` WHERE `type` = 'operator-logo' ORDER BY `played` DESC LIMIT 0,21"); 6 | $top_bitmap = $db->fetch("SELECT * FROM `content` WHERE `type` = 'bitmap' ORDER BY `played` DESC LIMIT 0,4"); 7 | 8 | echo $twig->render('pages/' . $page . '.html', [ 9 | 'config' => $config, 10 | 'devices' => $devices, 11 | 'registration_token' => $_SESSION['registration_token'], 12 | "top_poly" => $top_poly, 13 | "top_operator" => $top_operator, 14 | "top_bitmap" => $top_bitmap, 15 | ]); -------------------------------------------------------------------------------- /pages/logjson.php: -------------------------------------------------------------------------------- 1 | fetch("SELECT * FROM `log` WHERE `type` NOT IN ('convert_image_to_gif', 'run_sandboxed_ringtonetools') ORDER BY id DESC LIMIT 0, 100"); 8 | 9 | echo json_encode($log, JSON_PRETTY_PRINT); -------------------------------------------------------------------------------- /pages/manualsms.php: -------------------------------------------------------------------------------- 1 | prepared_fetch_one("SELECT * FROM devices WHERE user = ? AND id = ?;", "ss", session_id(), (int)$_POST['msn']); 18 | if (is_null($device)) 19 | { 20 | echo $twig->render('pages/404.html', []); exit(); 21 | } 22 | $gateway = $db->prepared_fetch_one("SELECT * FROM gateways WHERE enabled = 1 AND id = ?;", "i", $device["gateway"]); 23 | 24 | SMS::send_udh_sms($gateway, $device["msn"], $data); 25 | $smsarray = SMS::split_sms_string($data); 26 | } 27 | } 28 | 29 | $devices = $db->prepared_fetch("SELECT * FROM devices WHERE user = ?;", "s", session_id()); 30 | 31 | echo $twig->render('pages/' . $page . '.html', 32 | [ 33 | 'success' => $success, 34 | 'error' => $error, 35 | 'smsarray' => $smsarray, 36 | 'data' => $data, 37 | 'devices' => $devices, 38 | 'registration_token' => $_SESSION['registration_token'], 39 | 'config' => $config, 40 | ]); -------------------------------------------------------------------------------- /pages/metrics.php: -------------------------------------------------------------------------------- 1 | fetch("SELECT COUNT(*) as `sum` FROM `blamba`.`devices`", "sum"); 7 | 8 | $received_sms = $db->fetch("SELECT COUNT(*) as `sum` FROM `blamba`.`log` WHERE `type` = 'parse_inbound_sms' ", "sum"); 9 | $sent_wappush = $db->fetch("SELECT COUNT(*) as `sum` FROM `blamba`.`wappush` ", "sum"); 10 | 11 | $sent_ringtones = $db->fetch("SELECT SUM(sent) as `sum` FROM `blamba`.`content` WHERE `type` = 'polyphonic-ring' OR `type` = 'rtttl'", "sum"); 12 | $sent_logos = $db->fetch("SELECT SUM(sent) as `sum` FROM `blamba`.`content` WHERE `type` = 'bitmap' OR `type` = 'operator-logo'", "sum"); 13 | $sent_java = $db->fetch("SELECT SUM(sent) as `sum` FROM `blamba`.`content` WHERE `type` = 'j2me'", "sum"); 14 | 15 | $available_ringtones = $db->fetch("SELECT COUNT(*) as `sum` FROM `blamba`.`content` WHERE `type` = 'polyphonic-ring' OR `type` = 'rtttl'", "sum"); 16 | $available_logos = $db->fetch("SELECT COUNT(*) as `sum` FROM `blamba`.`content` WHERE `type` = 'bitmap' OR `type` = 'operator-logo'", "sum"); 17 | 18 | $sent_text_sms = $db->fetch("SELECT COUNT(*) as `sum` FROM `blamba`.`log` WHERE `type` = 'send_text_sms' ", "sum"); 19 | $sent_udh_sms = $db->fetch("SELECT COUNT(*) as `sum` FROM `blamba`.`log` WHERE `type` = 'send_udh_sms' ", "sum"); 20 | 21 | ?> 22 | # HELP blamba_registered_devices Registered devices. 23 | # TYPE blamba_registered_devices gauge 24 | blamba_registered_devices 25 | 26 | # HELP blamba_sent_wappush Sent WAP Push messages. 27 | # TYPE blamba_sent_wappush gauge 28 | blamba_sent_wappush 29 | 30 | # HELP blamba_sent_ringtones Sent ringtones. 31 | # TYPE blamba_sent_ringtones gauge 32 | blamba_sent_ringtones 33 | 34 | # HELP blamba_sent_logos Sent logos. 35 | # TYPE blamba_sent_logos gauge 36 | blamba_sent_logos 37 | 38 | # HELP blamba_sent_java Sent Java applications. 39 | # TYPE blamba_sent_java gauge 40 | blamba_sent_java 41 | 42 | # HELP blamba_available_ringtones Available ringtones. 43 | # TYPE blamba_available_ringtones gauge 44 | blamba_available_ringtones 45 | 46 | # HELP blamba_available_logos Available logos. 47 | # TYPE blamba_available_logos gauge 48 | blamba_available_logos 49 | 50 | # HELP blamba_received_sms Received SMS. 51 | # TYPE blamba_received_sms gauge 52 | blamba_received_sms 53 | 54 | # HELP blamba_sent_text_sms Sent Text SMS. 55 | # TYPE blamba_sent_text_sms gauge 56 | blamba_sent_text_sms 57 | 58 | # HELP blamba_sent_udh_sms Sent UDH SMS. 59 | # TYPE blamba_sent_udh_sms gauge 60 | blamba_sent_udh_sms 61 | -------------------------------------------------------------------------------- /pages/phonebook.php: -------------------------------------------------------------------------------- 1 | prepared_fetch_one("SELECT * FROM devices WHERE user = ? AND id = ?;", "ss", session_id(), (int)$_POST['msn']); 8 | if (is_null($device)) 9 | { 10 | echo $twig->render('pages/404.html', []); exit(); 11 | } 12 | $gateway = $db->prepared_fetch_one("SELECT * FROM gateways WHERE enabled = 1 AND id = ?;", "i", $device["gateway"]); 13 | 14 | $sms = WAPPush::generate_wap_push("http://wap.blamba.de/ep/", "Telefonbuch"); 15 | SMS::send_udh_sms($gateway, $device["msn"], $sms); 16 | 17 | $data .= $sms . "\n\n"; 18 | $success = "Das Lesezeichen wurde an dein Handy geschickt!"; 19 | } 20 | 21 | $devices = $db->prepared_fetch("SELECT * FROM devices WHERE user = ?;", "s", session_id()); 22 | 23 | echo $twig->render('pages/' . $page . '.html', 24 | [ 25 | 'success' => $success, 26 | 'data' => $data, 27 | 'smsarray' => SMS::split_sms_string($data), 28 | 'events' => $events, 29 | 'devices' => $devices, 30 | 'registration_token' => $_SESSION['registration_token'], 31 | 'config' => $config, 32 | ]); -------------------------------------------------------------------------------- /pages/statistics.php: -------------------------------------------------------------------------------- 1 | fetch("SELECT COUNT(*) as `sum` FROM `blamba`.`devices`", "sum"); 7 | 8 | $received_sms = $db->fetch("SELECT COUNT(*) as `sum` FROM `blamba`.`log` WHERE `type` = 'parse_inbound_sms' ", "sum"); 9 | $sent_wappush = $db->fetch("SELECT COUNT(*) as `sum` FROM `blamba`.`wappush` ", "sum"); 10 | 11 | $sent_ringtones = $db->fetch("SELECT SUM(sent) as `sum` FROM `blamba`.`content` WHERE `type` = 'polyphonic-ring' OR `type` = 'rtttl'", "sum"); 12 | $sent_logos = $db->fetch("SELECT SUM(sent) as `sum` FROM `blamba`.`content` WHERE `type` = 'bitmap' OR `type` = 'operator-logo'", "sum"); 13 | $sent_java = $db->fetch("SELECT SUM(sent) as `sum` FROM `blamba`.`content` WHERE `type` = 'j2me'", "sum"); 14 | 15 | $available_ringtones = $db->fetch("SELECT COUNT(*) as `sum` FROM `blamba`.`content` WHERE `type` = 'polyphonic-ring' OR `type` = 'rtttl'", "sum"); 16 | $available_logos = $db->fetch("SELECT COUNT(*) as `sum` FROM `blamba`.`content` WHERE `type` = 'bitmap' OR `type` = 'operator-logo'", "sum"); 17 | 18 | $sent_text_sms = $db->fetch("SELECT COUNT(*) as `sum` FROM `blamba`.`log` WHERE `type` = 'send_text_sms' ", "sum"); 19 | $sent_udh_sms = $db->fetch("SELECT COUNT(*) as `sum` FROM `blamba`.`log` WHERE `type` = 'send_udh_sms' ", "sum"); 20 | 21 | echo $twig->render('pages/' . $page . '.html', 22 | [ 23 | 'registered_devices' => $registered_devices, 24 | 'sent_wappush' => $sent_wappush, 25 | 26 | 'sent_ringtones' => $sent_ringtones, 27 | 'sent_logos' => $sent_logos, 28 | 'sent_java' => $sent_java, 29 | 'available_ringtones' => $available_ringtones, 30 | 'available_logos' => $available_logos, 31 | 'received_sms' => $received_sms, 32 | 'sent_text_sms' => $sent_text_sms, 33 | 'sent_udh_sms' => $sent_udh_sms, 34 | 35 | 'devices' => $devices, 36 | 'registration_token' => $_SESSION['registration_token'], 37 | 'config' => $config, 38 | ]); 39 | -------------------------------------------------------------------------------- /pages/transfer.php: -------------------------------------------------------------------------------- 1 | prepared_fetch_one("SELECT content.*,authors.name as `authorname` FROM content, authors WHERE content.id = ? AND author = authors.id AND content.visible = 1;", "i", $id); 4 | 5 | if (is_null($content)) 6 | { 7 | echo $twig->render('pages/404.html', []); exit(); 8 | } 9 | 10 | // permissions, is this user allowed to access that device? 11 | $device = $db->prepared_fetch_one("SELECT * FROM devices WHERE user = ? AND id = ?;", "ss", session_id(), (int)$_POST['msn']); 12 | if (is_null($device)) 13 | { 14 | echo $twig->render('pages/404.html', []); exit(); 15 | } 16 | $gateway = $db->prepared_fetch_one("SELECT * FROM gateways WHERE enabled = 1 AND id = ?;", "i", $device["gateway"]); 17 | 18 | Logging::log("web_transfer", $_POST, $device["msn"]); 19 | 20 | $db->prepared_query("UPDATE content SET sent = sent + 1 WHERE `id` = ? AND `visible` = 1;", "i", $content['id']); 21 | 22 | // encode the actual data 23 | $sms = false; 24 | switch ($content["type"]) 25 | { 26 | case 'rtttl': 27 | $sms = RTTTL::convert_to_nokia_sms($content_path . $content["path"]); 28 | break; 29 | case 'operator-logo': 30 | // Invert image or not? (ImageMagick command line arguments) 31 | $im_params = "-monochrome -threshold 0 -negate"; 32 | if ($_POST["invert"] == "true") 33 | { 34 | $im_params = "-monochrome -threshold 0 -negate -negate"; 35 | } 36 | 37 | if ($_POST["logotype"] == "operator-logo") 38 | { 39 | $sms = OperatorLogo::convert_to_nokia_sms_operator($content_path . $content["path"], (int)$_POST["mcc"], (int)$_POST["mnc"], $im_params); 40 | } 41 | if ($_POST["logotype"] == "group-logo") 42 | { 43 | $sms = OperatorLogo::convert_to_nokia_sms_group($content_path . $content["path"], $im_params); 44 | } 45 | break; 46 | case 'j2me': 47 | case 'bitmap': 48 | case 'polyphonic-ring': 49 | $wappush = WAPPush::generate_stored( $content["type"], $content["name"], basename($content["path"]), $device["msn"], [ 50 | "id" => $content['id'], 51 | "name" => $content["name"] 52 | ]); 53 | $sms = WAPPush::generate_wap_push($wappush["url"], $wappush["name"]); 54 | break; 55 | default: 56 | break; 57 | } 58 | 59 | // actually send the SMS 60 | SMS::send_udh_sms($gateway, $device["msn"], $sms); 61 | 62 | // statistics, count SMSes and data bytes 63 | $smscount = 0; 64 | $smsbytes = 0; 65 | $smsarray = []; 66 | foreach (explode("\n", $sms) as $line) 67 | { 68 | $line = trim($line); 69 | if ($line != '') 70 | { 71 | $smscount++; 72 | $smsbytes += strlen(hex2bin($line)); 73 | $smsarray[] = bin2hex(hex2bin($line)); 74 | } 75 | } 76 | 77 | echo $twig->render('pages/' . $page . '.html', 78 | [ 79 | 'type' => $content["type"], 80 | 'type_human' => Content::human_readable_type($content["type"]), 81 | 'content' => $content, 82 | 'registration_token' => $_SESSION['registration_token'], 83 | 'config' => $config, 84 | 'sms' => $sms, 85 | 'smsarray' => $smsarray, 86 | 'smscount' => $smscount, 87 | 'smsbytes' => $smsbytes 88 | ]); -------------------------------------------------------------------------------- /robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: / 3 | -------------------------------------------------------------------------------- /smpp-daemon.php: -------------------------------------------------------------------------------- 1 | prepared_fetch_one("SELECT * FROM gateways WHERE id = ?;", "i", 6); 6 | 7 | $timeout = 1000; 8 | $debug = true; 9 | 10 | Socket::$defaultDebug = true; 11 | 12 | $transport = new Socket([$gateway["smpp_hostname"]], (int) $gateway["smpp_port"]); 13 | $transport->setRecvTimeout($timeout); 14 | 15 | // Hack to make protected function submitShortMessage() callable 16 | $smppClient = new class($transport) extends SmppClient { 17 | public function submitShortMessage( 18 | Address $source, 19 | Address $destination, 20 | string $shortMessage = null, 21 | array $tags = null, 22 | int $dataCoding = Smpp::DATA_CODING_DEFAULT, 23 | int $priority = 0x00, 24 | string $scheduleDeliveryTime = null, 25 | string $validityPeriod = null, 26 | string $esmClass = null 27 | ): string { 28 | return parent::submitShortMessage($source, 29 | $destination, 30 | $shortMessage, 31 | $tags, 32 | $dataCoding, 33 | $priority, 34 | $scheduleDeliveryTime, 35 | $validityPeriod, 36 | $esmClass); 37 | } 38 | }; 39 | 40 | $from = new Address($gateway["sender_name"],SMPP::TON_ALPHANUMERIC); 41 | 42 | $transport->open(); 43 | $smppClient->bindTransceiver($gateway["smpp_username"], $gateway["smpp_password"] ?? ''); 44 | 45 | while ($transport->isOpen()) 46 | { 47 | // receiving messages 48 | $sms = $smppClient->readSMS(); 49 | if ($sms) 50 | { 51 | var_dump($sms); 52 | SMS::parse_inbound_sms($gateway, $sms->message, $sms->source->value); 53 | } 54 | 55 | // sending messages 56 | while (($outgoing_sms = $db->fetch("SELECT * FROM `sms_queue` WHERE sent_at IS NULL AND error_at IS NULL ORDER BY queued_at ASC LIMIT 0,1", true)) != null) 57 | { 58 | $to = new Address($outgoing_sms['destination'], \smpp\SMPP::TON_INTERNATIONAL, SMPP::NPI_E164); 59 | if ($outgoing_sms['type'] == "text") 60 | { 61 | $smppClient->sendSMS($from, $to, $outgoing_sms['data'], null, SMPP::DATA_CODING_DEFAULT); 62 | } 63 | if ($outgoing_sms['type'] == "udh") 64 | { 65 | $udh_binary = hex2bin($outgoing_sms['data']); 66 | if ($udh_binary === false) 67 | { 68 | $db->prepared_query("UPDATE `sms_queue` SET `error_at` = NOW(), `error` = 'invalid hex data' WHERE `id` = ?;", "i", $outgoing_sms['id']); 69 | continue; 70 | } 71 | 72 | $res = $smppClient->submitShortMessage( 73 | $from, 74 | $to, 75 | $udh_binary, 76 | null, 77 | SMPP::DATA_CODING_BINARY, 78 | 0x00, 79 | null, 80 | null, 81 | 0x40 82 | ); 83 | } 84 | 85 | $db->prepared_query("UPDATE `sms_queue` SET `sent_at` = NOW() WHERE `id` = ?;", "i", $outgoing_sms['id']); 86 | } 87 | } 88 | 89 | $smppClient->close(); 90 | -------------------------------------------------------------------------------- /templates/footerads.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 34 | 35 | 36 | 37 | 38 | 44 | 45 | 46 |
39 | 43 |
47 | -------------------------------------------------------------------------------- /templates/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Blåmba! - Ringtones, Logos, J2ME games 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /templates/pages/404.html: -------------------------------------------------------------------------------- 1 | {% extends "template.html" %} 2 | 3 | {% block head %} 4 | {{ parent() }} 5 | {% endblock %} 6 | {% block content %} 7 | 404... This page doesn't exist. 8 | {% endblock %} 9 | -------------------------------------------------------------------------------- /templates/pages/content-details.html: -------------------------------------------------------------------------------- 1 | {% extends "template.html" %} 2 | 3 | {% block head %} 4 | {{ parent() }} 5 | {% endblock %} 6 | {% block content %} 7 | 8 | 9 | 10 | 23 | 24 | 25 | 26 |
11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 |
16 | Details - {{ content.name }} 17 |
22 |
27 | 28 | 29 | 30 | 31 | 110 | 111 | 112 |
32 | 33 | 34 | 35 | 97 | 98 | 99 | 100 | 101 | {{ include('pages/include-transfer-form.html') }} 102 | 103 | 104 | 105 | 106 | 107 |
36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
47 | 48 | 49 | 50 | 51 | {% if content.author != 2 %} 52 | 53 | 54 | 55 | 56 | {% endif %} 57 | 58 | 59 | 60 | 61 | {% if content.type == "rtttl" or content.type == "polyphonic-ring" %} 62 | 63 | 69 | 70 | {% endif %} 71 | 72 | {% if content.type == "rtttl" %} 73 | 74 | 78 | 79 | {% endif %} 80 | 81 | {% if content.type == "operator-logo" or content.type == "bitmap" %} 82 | 83 | 93 | 94 | {% endif %} 95 |
Title:{{ content.name }}
Author:{{ content.authorname }}
Filename:{{ file_basename }} ({{ file_size }} Bytes)
64 | 65 | 68 |
75 | RTTTL-Data (Nokring): 76 | 77 |
84 | {% if content.type == "operator-logo" %} 85 | 86 | {% endif %} 87 | 88 | {% if content.type == "bitmap" %} 89 | 90 | {% endif %} 91 | 92 |
96 |
108 | 109 |
113 | 114 | 115 | 116 | 117 | {% endblock %} 118 | -------------------------------------------------------------------------------- /templates/pages/content.html: -------------------------------------------------------------------------------- 1 | {% extends "template.html" %} 2 | 3 | {% block head %} 4 | {{ parent() }} 5 | {% endblock %} 6 | {% block content %} 7 | 8 | 9 | 10 | 23 | 24 | 25 | 26 |
11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 |
16 | {{type_human}} 17 |
22 |
27 | 28 | 29 | 30 | 31 | 105 | 106 | 107 |
32 | 33 | 34 | 35 | 101 | 102 | 103 |
36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | {% for item in content %} 46 | {% if item.type == "rtttl" or item.type == "polyphonic-ring" %} 47 | 48 | 49 | 50 | 51 | 52 | {% endif %} 53 | 54 | {% if item.type == "bitmap" %} 55 | {% if (loop.index0 % 2) == 0 %} 56 | 57 | {% endif %} 58 | 62 | 63 | {% if (loop.index0 % 2) == 1 %} 64 | 65 | {% endif %} 66 | {% endif %} 67 | 68 | {% if item.type == "operator-logo" %} 69 | 70 | 71 | 74 | 75 | 76 | {% endif %} 77 | 78 | {% if item.type == "j2me" %} 79 | 80 | 81 | 84 | 85 | 86 | {% endif %} 87 | 88 | {% else %} 89 | 90 | 91 | 92 | {% endfor %} 93 | 94 | 95 | 96 | 97 | 98 |
{{ '%05d'|format(item.id) }}. {{ item.name }}PlaySend to phone
59 | {{ '%05d'|format(item.id) }}. {{ item.name }}
60 |
61 |
Send to phone
{{ '%05d'|format(item.id) }}. {{ item.name }} 72 | 73 | Send to phone
{{ '%05d'|format(item.id) }}. {{ item.name }} 82 |   83 | Send to phone
No content yet. Please feel free to add some :)
99 | 100 |
104 |
108 | {% endblock %} 109 | -------------------------------------------------------------------------------- /templates/pages/fahrplan.html: -------------------------------------------------------------------------------- 1 | {% extends "template.html" %} 2 | 3 | {% block head %} 4 | {{ parent() }} 5 | {% endblock %} 6 | {% block content %} 7 | 8 | 9 | 10 | 23 | 24 | 25 | 26 |
11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 |
16 | Fahrplan 17 |
22 |
27 | 28 | 29 | 30 | 31 | 86 | 87 | 88 |
32 | 33 | 34 | 35 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 |
36 |
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 48 | 49 | 50 | 53 | 54 | {% if data != "" %} 55 | 56 | 60 | 61 | {% endif %} 62 | 63 | {% for event in events %} 64 | 65 | 66 | 67 | 68 | {% endfor %} 69 | 70 | 71 |
46 | Send calender entries for talks directly to your phone: 47 |
51 | {{ success | nl2br }} 52 |
57 | Rohdaten:
58 | {{ include('pages/include-sms-pdu-decode.html') }} 59 |
72 | {{ include('pages/include-phone-select.html') }} 73 |
74 |
84 | 85 |
89 | 90 | 91 | 92 | 93 | 113 | {% endblock %} 114 | -------------------------------------------------------------------------------- /templates/pages/faq.html: -------------------------------------------------------------------------------- 1 | {% extends "template.html" %} 2 | 3 | {% block head %} 4 | {{ parent() }} 5 | {% endblock %} 6 | {% block content %} 7 |

8 | What is this?
9 | A ringtone provider, similar to popular commercial providers from the early 2000s. 10 |

11 |

12 | Is this real?
13 | Yes! If you have a supported mobile phone (mostly Nokia at this point), you can send all the content available directly to your phone. 14 |

15 |

16 | Where does this work?
17 | Blåmba needs some mechanism to send raw binary data to participants. We can do this without creating any costs in the private GSM networks at hacker conferences (like CCC events or EMF). 18 |

19 |

20 | Does this cost money?
21 | No! 22 | No sneaky subscriptions, either :) 23 |

24 |

25 | Which phones are supported?
26 | Nokia 6310i, Nokia 6220 and Nokia 6233 were used for development.
27 | Many other Nokia phones will work fine as well.
28 | Other vendors (Sony Ericsson, etc.) aren't implemented due to a lack of devices (and knowledge about them). 29 | If you have such a phone and know how to encode data for it, please contact us! 30 |

31 |

32 | My phone needs a WAP/WSP gateway / IP address settings!
33 | Blåmba operates a public WAP gateway, which can be used via GPRS from the phone.
34 | It uses an IP / ASN-based allowlist to prevent abuse. Most german phone providers and the CCC event network are allowed.
35 | 36 | The IPv4 address is: 157.90.145.189 (no username/password).
37 | If you're using a different carrier/provider, please write us a message with your public IPv4 address or the ASN of your carrier. 38 |

39 | 40 |

41 | How does this work?
42 | Operator logos und RTTTL ringtones will be sent via SMS.
43 | MIDI files, J2ME applications and games will be sent via WAP-Push (basically a special link via SMS).
44 | If you're interested in the nitty-gritty details, the source code is linked in the menu. 45 |

46 |

47 | I have a cool logo/ringtone/game/application.
48 | Awesome! Please send a pull request to the blamba-content-ingest repository. 49 |

50 |

51 | I found a security vulnurability.
52 | Please send an e-mail to blamba@tbspace.de. 53 |

54 | 55 |

56 | My phone doesn't support WAP push (e.g. iPhone). What can I do?
57 | Prefix the catalog number with "plain" ("plain 12345").
58 | Blåmba! will then send a regular text SMS with an HTTP-URL. 59 |

60 | 61 |

62 | What are operator logos? What are group logos?
63 | Operator logos are little logos, which are assigned to a specific mobile network.
64 | When a phone connects to a specific network, it will display the logo for this carrier on the home screen.
65 | The carrier/network will be detected using the globally unique MCC/MNC IDs.
66 | The CCC Event network usually uses 262/42. Deutsche Telekom uses 262/01. 67 |

68 | Group logos use the same graphics format and encoding, but can be assigned to contacts and contact groups. 69 | They will then be displayed when such a contact or contact group calls. 70 |

71 |

72 |   73 |

74 | {% endblock %} 75 | -------------------------------------------------------------------------------- /templates/pages/include-phone-select.html: -------------------------------------------------------------------------------- 1 | 2 | {% if devices|length == 0 %} 3 | 4 | No device registered yet!!
5 | Send a SMS with text "REGISTER {{ '%06d'|format(registration_token) }}" to {{ config.smpp_sender_msn }}! 6 | 7 | {% else %} 8 | 9 | 10 | 15 | 16 | 17 | 18 | {% endif %} 19 | -------------------------------------------------------------------------------- /templates/pages/include-sms-pdu-decode.html: -------------------------------------------------------------------------------- 1 | {% for smsdata in smsarray %} 2 |
3 | SMS {{ loop.index }} 4 |
{{ smsdata }}
5 |
6 | {% endfor %} 7 | 8 | 15 |
-------------------------------------------------------------------------------- /templates/pages/include-transfer-form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | {% if content.type == "operator-logo" %} 9 | 10 | 11 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 33 | 34 | {% endif %} 35 | 36 | {{ include('pages/include-phone-select.html') }} 37 | 38 | {% if content.type == "rtttl" %} 39 | 40 | 43 | {% endif %} 44 | 45 | {% if content.type == "operator-logo" %} 46 | 47 | 50 | {% endif %} 51 | 52 | {% if content.type == "polyphonic-ring" %} 53 | 54 | 57 | {% endif %} 58 | {% if content.type == "bitmap" %} 59 | 60 | 63 | {% endif %} 64 | 65 |
Type: 12 | 13 | 14 | 15 | 16 |
MCC/MNC: 21 |   22 | 23 |
Invert logo: 28 | 29 | 30 | 31 | 32 |
Transmission format: 41 | SMS (Nokia Smart Messaging, WDP port 1581) 42 | Transmission format: 48 | SMS (Nokia Smart Messaging, WDP port 1582) 49 | Transmission format: 55 | WAP Push SI (Service Indication) 56 | Transmission format: 61 | WAP Push SI (Service Indication) 62 |
66 | 67 | 68 |
69 | 70 | 103 | -------------------------------------------------------------------------------- /templates/pages/manualsms.html: -------------------------------------------------------------------------------- 1 | {% extends "template.html" %} 2 | 3 | {% block head %} 4 | {{ parent() }} 5 | {% endblock %} 6 | {% block content %} 7 | 8 | 9 | 10 | 23 | 24 | 25 | 26 |
11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 |
16 | Custom SMS transmission 17 |
22 |
27 | 28 | 29 | 30 | 31 | 89 | 90 | 91 |
32 | 33 | 34 | 35 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 |
36 |
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 55 | 56 | 57 | 60 | 61 | 62 | 65 | 66 | 67 | 72 | 73 | 74 |
46 | You can use this tool to send custom SMS with 8-bit binary data to your registered devices. 47 | Example invocations for ringtonetools:
48 |
ringtonetools -u -s 280 -intype rtttl -outtype nokia monkey.txt -
49 | ringtonetools -u -s 280 -intype gif -outtype nokia fox.gif -
50 | Each line is getting sent as a seperate SMS. Each line must only contain hex digits.
51 | Empty lines will be ignored. Lines with //SCKL header are not supported.
52 | Maximum of 5 SMS per invocation. Maximum of 140 bytes per SMS.
53 | Malformed SMS can crash or even damage (if they are stored) your phone. Be careful! 54 |
58 | {{ error | nl2br }} 59 |
63 | {{ success | nl2br }} 64 |
68 |

69 | 70 | {{ include('pages/include-sms-pdu-decode.html') }} 71 |
75 | {{ include('pages/include-phone-select.html') }} 76 |
77 |
87 | 88 |
92 | 93 | 94 | 95 | 96 | {% endblock %} 97 | -------------------------------------------------------------------------------- /templates/pages/phonebook.html: -------------------------------------------------------------------------------- 1 | {% extends "template.html" %} 2 | 3 | {% block head %} 4 | {{ parent() }} 5 | {% endblock %} 6 | {% block content %} 7 | 8 | 9 | 10 | 23 | 24 | 25 | 26 |
11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 |
16 | Phonebook 17 |
22 |
27 | 28 | 29 | 30 | 31 | 89 | 90 | 91 |
32 | 33 | 34 | 35 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 |
36 |
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 51 | 52 | 53 | 56 | 57 | {% if data != "" %} 58 | 59 | 63 | 64 | {% endif %} 65 | 66 | 67 | 71 | 72 | 73 | 74 |
46 | Blamba! offers a WAP UI for the Eventphone GURU3 phonebook:

47 | Photo of Nokia 6310i, showing the WAP phonebook 48 |

49 | Open http://wap.blamba.de/ep/ via WAP on your phone to search for contacts. 50 |
54 | {{ success | nl2br }} 55 |
60 | Raw data:
61 | {{ include('pages/include-sms-pdu-decode.html') }} 62 |
68 |
69 | Send a bookmark for the phonebook to your device: 70 |
75 | {{ include('pages/include-phone-select.html') }} 76 |
77 |
87 | 88 |
92 | 93 | 94 | 95 | 96 | 116 | {% endblock %} 117 | -------------------------------------------------------------------------------- /templates/pages/statistics.html: -------------------------------------------------------------------------------- 1 | {% extends "template.html" %} 2 | 3 | {% block head %} 4 | {{ parent() }} 5 | {% endblock %} 6 | {% block content %} 7 | 8 | 9 | 10 | 23 | 24 | 25 | 26 |
11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 |
16 | Statistics 17 |
22 |
27 | 28 | 29 | 30 | 31 | 103 | 104 | 105 |
32 | 33 | 34 | 35 | 99 | 100 | 101 |
36 |
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 |
46 | The Blamba! usage statistics are currently: 47 |
48 |
Registered devices:{{registered_devices}}
Received SMS:{{ received_sms }}
Sent text SMS:{{ sent_text_sms }}
Sent binary SMS:{{ sent_udh_sms }}
Sent WAP Push Indications:{{ sent_wappush }}
Available Ringtones:{{ available_ringtones }}
Available Logos:{{ available_logos }}
Sent Ringtones:{{ sent_ringtones }}
Sent Logos:{{ sent_logos }}
97 |
98 |
102 |
106 | 126 | {% endblock %} 127 | -------------------------------------------------------------------------------- /templates/pages/transfer.html: -------------------------------------------------------------------------------- 1 | {% extends "template.html" %} 2 | 3 | {% block head %} 4 | {{ parent() }} 5 | {% endblock %} 6 | {% block content %} 7 | 8 | 9 | 10 | 23 | 24 | 25 | 26 |
11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 |
16 | Transmission - {{ content.name }} 17 |
22 |
27 | 28 | 29 | 30 | 31 | 73 | 74 | 75 |
32 | 33 | 34 | 35 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 |
36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
47 | 48 | 49 | 60 | 61 |
50 | Content will be transmitted!

51 | 52 | Technical details:
53 | {{ smscount }} SMS message(s), {{ smsbytes }} bytes

54 | 55 | {{ include('pages/include-sms-pdu-decode.html') }} 56 | 57 | 58 | 59 |
62 |
71 | 72 |
76 | 77 | 78 | 79 | 80 | {% endblock %} 81 | -------------------------------------------------------------------------------- /templates/template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{ include('header.html') }} 5 | 6 | 7 |
8 | 9 | 10 | 11 | 14 | 15 | 54 | 55 | 56 |
12 | {{ include('menu.html') }} 13 | 16 | 17 | 18 | 19 | 49 | 50 | 51 |
20 | 21 | 22 | 23 | 28 | 31 | 32 | 33 |
24 | Ringtones, Logos, J2ME games!
25 | 26 | 27 |
29 | 30 |
34 | 35 | 36 | 37 | 38 | 44 | 45 | 46 |
39 | Welcome to Blåmba!

40 | 38C3 is over, it was great fun. Thanks everyone for playing :)

41 | Blåmba now has support for direct WAP access!
On a supported phone (even on a commercial network) visit
42 | http://wap.blamba.de/ to use Blåmba! 43 |
47 | 48 |
52 | {% block content %}{% endblock %} 53 |
57 | {{ include('footerads.html') }} 58 | 59 | 60 | 61 | 64 | 65 | 66 |
62 | 63 |
67 |
68 | 69 | 70 | -------------------------------------------------------------------------------- /vendor-native/bwrap-seccomp/.gitignore: -------------------------------------------------------------------------------- 1 | genseccomp 2 | seccomp.bpf 3 | -------------------------------------------------------------------------------- /vendor-native/bwrap-seccomp/Makefile: -------------------------------------------------------------------------------- 1 | all: build generate 2 | 3 | build: 4 | gcc -o genseccomp-imagemagick genseccomp-imagemagick.c -lseccomp 5 | gcc -o genseccomp-ringtonetools genseccomp-ringtonetools.c -lseccomp 6 | 7 | generate: build 8 | ./genseccomp-imagemagick > seccomp-imagemagick.bpf 9 | ./genseccomp-ringtonetools > seccomp-ringtonetools.bpf 10 | clean: 11 | rm -f seccomp-ringtonetools.bpf 12 | rm -f genseccomp-ringtonetools 13 | rm -f seccomp-imagemagick.bpf 14 | rm -f genseccomp-imagemagick 15 | -------------------------------------------------------------------------------- /vendor-native/bwrap-seccomp/README.md: -------------------------------------------------------------------------------- 1 | # bwrap-seccomp 2 | 3 | Written by Jennifer Graul, @netali 4 | Highly modified to be default deny by @manawyrm 5 | 6 | https://gitlab.fem-net.de/webhosting/bwrap-seccomp 7 | -------------------------------------------------------------------------------- /vendor-native/bwrap-seccomp/genseccomp-imagemagick.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | /* 9 | Based on https://gitlab.fem-net.de/webhosting/bwrap-seccomp, 10 | highly modified to only allow a very small subset of syscalls. 11 | */ 12 | 13 | int main(int argc, char *argv[]) { 14 | scmp_filter_ctx ctx = seccomp_init(SCMP_ACT_ERRNO(EPERM)); 15 | //scmp_filter_ctx ctx = seccomp_init(SCMP_ACT_ALLOW); 16 | 17 | // syscalls for bubblewrap 18 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(execve), 0); 19 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(brk), 0); 20 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(arch_prctl), 0); 21 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(uname), 0); 22 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(readlink), 0); 23 | 24 | // syscalls for ImageMagick 25 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(wait4), 0); 26 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(mmap), 0); 27 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(access), 0); 28 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(openat), 0); 29 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(newfstatat), 0); 30 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(close), 0); 31 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 0); 32 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(pread64), 0); 33 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(munmap), 0); 34 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(mprotect), 0); 35 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(lseek), 0); 36 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 0); 37 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(exit_group), 0); 38 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(times), 0); 39 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(faccessat), 0); 40 | 41 | // ImageMagick tries to execute these syscalls, but they seem to be optional: 42 | //seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(arch_prctl), 0); 43 | //seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(getrandom), 0); 44 | //seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(sched_getaffinity), 0); 45 | //seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(clock_gettime), 0); 46 | //seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(rt_sigprocmask), 0); 47 | //seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(rt_sigaction), 0); 48 | //seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(sysinfo), 0); 49 | 50 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(set_robust_list), 0); 51 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(rseq), 0); 52 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(prlimit64), 0); 53 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(readlinkat), 0); 54 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(getrandom), 0); 55 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(mprotect), 0); 56 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(newfstatat), 0); 57 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(set_tid_address), 0); 58 | 59 | seccomp_export_bpf(ctx, 1); 60 | seccomp_release(ctx); 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /vendor-native/bwrap-seccomp/genseccomp-ringtonetools.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | /* 9 | Based on https://gitlab.fem-net.de/webhosting/bwrap-seccomp, 10 | highly modified to only allow a very small subset of syscalls. 11 | */ 12 | 13 | int main(int argc, char *argv[]) { 14 | scmp_filter_ctx ctx = seccomp_init(SCMP_ACT_KILL); 15 | 16 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(execve), 0); 17 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(brk), 0); 18 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(arch_prctl), 0); 19 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(uname), 0); 20 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(readlink), 0); 21 | 22 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(openat), 0); 23 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 0); 24 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 0); 25 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(lseek), 0); 26 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(fstat), 0); 27 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(wait4), 0); 28 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(close), 0); 29 | 30 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(set_robust_list), 0); 31 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(rseq), 0); 32 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(prlimit64), 0); 33 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(readlinkat), 0); 34 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(getrandom), 0); 35 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(mprotect), 0); 36 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(newfstatat), 0); 37 | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(set_tid_address), 0); 38 | 39 | seccomp_export_bpf(ctx, 1); 40 | seccomp_release(ctx); 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /vendor-native/bwrap-seccomp/shell.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import {} }: 2 | pkgs.mkShell { 3 | nativeBuildInputs = with pkgs; [ file gcc libseccomp ]; 4 | } 5 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | 3 | LICENSE for Ringtonetools 4 | 5 | Author: Michael Kohn 6 | http://ringtonetools.mikekohn.net/ 7 | 8 | 9 | You may NOT use this in any kind of commercial environment 10 | without permission of the author (Michael Kohn). 11 | 12 | You may NOT use any part of the code for another project 13 | either commerical or open without permission of the 14 | author. 15 | 16 | You are free to distribute this program unmodified with 17 | any compilation cd or operating system distribution 18 | (this includes the Linux operating systems, FreeBSD, 19 | Solaris, or whoever wants to distribute it). You may 20 | also distribute this on your own website. 21 | 22 | Really the reason for this license is I don't think it's 23 | fair for someone to make a truck load of money off this 24 | program without compensating me with at least a small donation 25 | for the hours I put into this program. Be nice and if you 26 | want to make money on this just make a small donation to me. 27 | 28 | :) 29 | 30 | For the rest of you.. FREE RINGTONES FOR ALL! 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/Makefile: -------------------------------------------------------------------------------- 1 | 2 | PREFIX=/usr/local 3 | 4 | all: 5 | @cd src && make 6 | @if [ -e src/ringtonetools.exe ]; then mv src/ringtonetools.exe ringtonetools.exe; fi 7 | @if [ -e src/ringtonetools ]; then mv src/ringtonetools .; fi 8 | 9 | dll: 10 | @cd src && make dll 11 | @if [ -e src/ringtonetools.dll ]; then mv src/ringtonetools.dll .; fi 12 | 13 | lib: 14 | @cd src && make lib 15 | @if [ -e src/ringtonetools.so ]; then mv src/ringtonetools.so .; fi 16 | 17 | 18 | clean: 19 | @if [ -e ringtonetools ]; then rm ringtonetools; fi 20 | @if [ -e ringtonetools.exe ]; then rm ringtonetools.exe; fi 21 | @if [ -e ringtonetools.dll ]; then rm ringtonetools.dll; fi 22 | @if [ -e ringtonetools.so ]; then rm ringtonetools.so; fi 23 | @cd src && make clean 24 | @echo "Clean!" 25 | 26 | install: 27 | @if [ ! -d $(PREFIX)/bin ]; then mkdir -p $(PREFIX)/bin; fi 28 | @if [ ! -d $(PREFIX)/lib ]; then mkdir -p $(PREFIX)/lib; fi 29 | @if [ -e ringtonetools ]; then install ringtonetools $(PREFIX)/bin; fi 30 | @if [ -e ringtonetools.so ]; then install ringtonetools.so $(PREFIX)/lib; fi 31 | @if [ -e src/ringtonetools.h ]; then install src/ringtonetools.h $(PREFIX)/include; fi 32 | 33 | uninstall: 34 | @if [ -e $(PREFIX)/bin/ringtonetools ]; then rm $(PREFIX)/bin/ringtonetools; fi 35 | @if [ -e $(PREFIX)/lib/ringtonetools.so ]; then rm $(PREFIX)/lib/ringtonetools.so; fi 36 | @if [ -e $(PREFIX)/include/ringtonetools.h ]; then rm $(PREFIX)/include/ringtonetools.h; fi 37 | 38 | solaris: 39 | pkgmk -d /tmp 40 | pkgtrans -s /tmp ringtonetools-2.19-sol9-sparc-local KOHNmobl 41 | 42 | 43 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/builds/pkginfo: -------------------------------------------------------------------------------- 1 | PKG=KOHNmobl 2 | ARCH=sparc 3 | VERSION=2.19 4 | NAME=ringtonetools 5 | DESC=Create ringtones and logos for mobile phones 6 | CATEGORY=phone 7 | BASEDIR=/usr/local 8 | VENDOR=Michael A. Kohn 9 | EMAIL=mike@mikekohn.net 10 | 11 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/builds/prototype: -------------------------------------------------------------------------------- 1 | 1 i pkginfo 2 | 1 d none bin 3 | 1 f none bin/ringtonetools 4 | 5 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/docs/README: -------------------------------------------------------------------------------- 1 | 2 | NAME: Ringtonetools 3 | AUTHOR: Michael Kohn 4 | EMAIL: mike@mikekohn.net 5 | WEB: http://ringtonetools.mikekohn.net/ 6 | HOMPAGE: http://www.mikekohn.net/ 7 | PURPOSE: Helps in the creation of ringtones 8 | 9 | ------------------------------------------------------------------- 10 | 11 | NOTE: For most up to date docs please read: 12 | http://ringtonetools.mikekohn.net/ 13 | 14 | I don't always update this file very well 15 | 16 | ------------------------------------------------------------------- 17 | 18 | THIS MAY NOT BE USED IN COMMERCIAL ENVIRONMENTS WITHOUT 19 | PERMISSION OF THE AUTHOR. PLEASE READ THE LICENSE. 20 | 21 | Usage: ringtonetools [ options ] 22 | -intype [ imelody/rtttl/rtx/midi/kws/bmp/text/siemens ] 23 | -outtype [ wav/kws/mot/pdb/nokia/rtttl/samsung1/samsung2/siemens] 24 | -name 25 | -t 26 | iMelody options: 27 | -a [force ringtonetools to ignore @'s in imelody's] 28 | Kyeocera options: 29 | -pause 30 | Motorola options: 31 | -keypress [ Make keypress sequence for phones like v60t ] 32 | wav output options: 33 | -b 34 | -f 35 | logo options: 36 | -h [ Height of Logo (default 14) ] 37 | -w [ Width of Logo (default 72) ] 38 | -l [ Operator Logo (requires MCC and MNC) ] 39 | -m Send a picture message 40 | -r [ reverse black n white ] 41 | -ss Send as screensaver 42 | nokia options: 43 | -x [ exclude //SCKL header ] 44 | -u [ only user-data-header (8bit) ] 45 | -k [ include user-data-header and //SCKL ] 46 | -s [ Maximum size of SMS message (default 140) 47 | -transpose [ raise or lower song by n octaves ] 48 | midi options: 49 | -channel [ channel ] 50 | -track [ track ] 51 | 52 | 53 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/docs/incomplete_see_webpage_instead: -------------------------------------------------------------------------------- 1 | 2 | Can't you read the filename? Sheeesh! :) 3 | 4 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/samples/face.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | ************ 4 | * * 5 | * * * * 6 | * * * 7 | * * 8 | * ****** * 9 | * * 10 | ************ 11 | 12 | 13 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/samples/hemglass.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blamba-de/blamba/b5d5c5368d3247bfa95d066d617a3247b760129d/vendor-native/ringtonetools/samples/hemglass.mid -------------------------------------------------------------------------------- /vendor-native/ringtonetools/samples/ionian.rtttl: -------------------------------------------------------------------------------- 1 | Ionian:d=8,o=5,b=240:c,d,e,f,g,a,b,c6; 2 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/samples/usa.emelody: -------------------------------------------------------------------------------- 1 | USA:+CaFpAp+Cp+Fp+A+g+FpApBp+Cp+C+c+Ap+Gp+Fp+Ep+D+e+Fp+Fp+CpAF 2 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/samples/yngwie_trilogy.rtttl: -------------------------------------------------------------------------------- 1 | Trilogy:d=8,o=5,b=240:a,c6,e6,a,c6,e6,b,d6,f6,b,d6,f6,g#,b,d6,g#,b,d6,a,c6,e6,a,c6,e6,f,a,c6,f,a,c6,f#,a,c6,f#,a,c6,f6,e6,d6,c6,b,f#,g#,a,b,e6,f6,g6; 2 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/3210.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "ringtonetools.h" 6 | #include "fileoutput.h" 7 | 8 | /* 9 | 10 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 11 | This falls under the Kohnian license. Please read 12 | it at http://ringtonetools.mikekohn.net/ 13 | 14 | This program is NOT opensourced. You may not use any part 15 | of this program for your own software. 16 | 17 | */ 18 | 19 | /* 3210 */ 20 | 21 | void write_3210_header(FILE *out, struct rtt_info_t *rtt_info) 22 | { 23 | if (rtt_info->songname[0]==0) 24 | { strcpy(rtt_info->songname,"unamed"); } 25 | 26 | fprintf(out,"%s:Tempo=%d\n",rtt_info->songname,rtt_info->bpm); 27 | } 28 | 29 | void write_3210_note(FILE *out, struct rtt_info_t *rtt_info) 30 | { 31 | if (rtt_info->note_count>0) fprintf(out," "); 32 | 33 | fprintf(out,"%d",(1<<(rtt_info->length))); 34 | 35 | if (rtt_info->modifier!=0) fprintf(out,"."); 36 | 37 | if (rtt_info->tone==0) fprintf(out,"-"); 38 | else 39 | if (rtt_info->tone==1) fprintf(out,"c"); 40 | else 41 | if (rtt_info->tone==2) fprintf(out,"#c"); 42 | else 43 | if (rtt_info->tone==3) fprintf(out,"d"); 44 | else 45 | if (rtt_info->tone==4) fprintf(out,"#d"); 46 | else 47 | if (rtt_info->tone==5) fprintf(out,"e"); 48 | else 49 | if (rtt_info->tone==6) fprintf(out,"f"); 50 | else 51 | if (rtt_info->tone==7) fprintf(out,"#f"); 52 | else 53 | if (rtt_info->tone==8) fprintf(out,"g"); 54 | else 55 | if (rtt_info->tone==9) fprintf(out,"#g"); 56 | else 57 | if (rtt_info->tone==10) fprintf(out,"a"); 58 | else 59 | if (rtt_info->tone==11) fprintf(out,"#a"); 60 | else 61 | if (rtt_info->tone==12) fprintf(out,"b"); 62 | /* if (rtt_info->tone==12) fprintf(out,"h"); */ 63 | 64 | if (rtt_info->tone!=0) 65 | { 66 | fprintf(out,"%d",rtt_info->scale+1); 67 | } 68 | } 69 | 70 | void write_3210_footer(FILE *out, struct rtt_info_t *rtt_info) 71 | { 72 | fprintf(out,"\n"); 73 | } 74 | 75 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/Makefile: -------------------------------------------------------------------------------- 1 | #DEBUG = -DDEBUG 2 | CC = gcc 3 | 4 | # static build, we want to run a sandbox later 5 | WARN = -static 6 | 7 | # from https://github.com/ossf/wg-best-practices-os-developers/blob/main/docs/Compiler_Hardening_Guides/Compiler-Options-Hardening-Guide-for-C-and-C%2B%2B.md 8 | FLAGS = $(DEBUG) -O2 -Wall -Wformat=2 -Wtrampolines \ 9 | -D_FORTIFY_SOURCE=3 \ 10 | -D_GLIBCXX_ASSERTIONS \ 11 | -fstack-clash-protection -fstack-protector-strong \ 12 | -Wl,-z,nodlopen -Wl,-z,nodump -Wl,-z,noexecstack -Wl,-z,noexecheap \ 13 | -Wl,-z,relro -Wl,-z,now \ 14 | -fPIE -pie -fPIC 15 | 16 | #DSP = -DDSP 17 | #WINDOWS = -DWINDOWS -lwinmm 18 | 19 | default: 20 | $(CC) -c 3210.c $(FLAGS) $(WARN) 21 | $(CC) -c bmp.c $(FLAGS) $(WARN) 22 | $(CC) -c emelody.c $(FLAGS) $(WARN) 23 | $(CC) -c ems.c $(FLAGS) $(WARN) 24 | $(CC) -c fileoutput.c $(FLAGS) $(WARN) $(DSP) 25 | $(CC) -c general.c $(FLAGS) $(WARN) 26 | $(CC) -c gif.c $(FLAGS) $(WARN) 27 | $(CC) -c imelody.c $(FLAGS) $(WARN) 28 | $(CC) -c kyocera.c $(FLAGS) $(WARN) 29 | $(CC) -c kyocera6035.c $(FLAGS) $(WARN) 30 | $(CC) -c midi.c $(FLAGS) $(WARN) 31 | $(CC) -c motorola.c $(FLAGS) $(WARN) 32 | $(CC) -c nokia.c $(FLAGS) $(WARN) 33 | $(CC) -c parse_3210.c $(FLAGS) $(WARN) 34 | $(CC) -c parse_bmp.c $(FLAGS) $(WARN) 35 | $(CC) -c parse_emelody.c $(FLAGS) $(WARN) 36 | $(CC) -c parse_ems.c $(FLAGS) $(WARN) 37 | $(CC) -c parse_gif.c $(FLAGS) $(WARN) 38 | $(CC) -c parse_imelody.c $(FLAGS) $(WARN) 39 | $(CC) -c parse_kws.c $(FLAGS) $(WARN) 40 | $(CC) -c parse_logo.c $(FLAGS) $(WARN) 41 | $(CC) -c parse_midi.c $(FLAGS) $(WARN) 42 | $(CC) -c parse_morsecode.c $(FLAGS) $(WARN) 43 | $(CC) -c parse_rtttl.c $(FLAGS) $(WARN) 44 | $(CC) -c parse_siemens.c $(FLAGS) $(WARN) 45 | $(CC) -c parse_sckl.c $(FLAGS) $(WARN) 46 | $(CC) -c rtttl.c $(FLAGS) $(WARN) 47 | $(CC) -c samsung.c $(FLAGS) $(WARN) 48 | $(CC) -c siemens.c $(FLAGS) $(WARN) 49 | $(CC) -c seo.c $(FLAGS) $(WARN) 50 | $(CC) -c treo.c $(FLAGS) $(WARN) 51 | $(CC) -c wav.c $(FLAGS) $(WARN) $(DSP) 52 | $(CC) -o ringtonetools ringtonetools.c 3210.o bmp.o emelody.o \ 53 | ems.o fileoutput.o general.o gif.o imelody.o kyocera.o\ 54 | kyocera6035.o midi.o motorola.o nokia.o parse_3210.o \ 55 | parse_bmp.o parse_emelody.o parse_ems.o parse_gif.o \ 56 | parse_imelody.o parse_kws.o parse_logo.o parse_midi.o \ 57 | parse_morsecode.o parse_rtttl.o parse_siemens.o \ 58 | parse_sckl.o rtttl.o samsung.o siemens.o seo.o treo.o \ 59 | wav.o $(FLAGS) $(WARN) $(DSP) $(LIBS) 60 | 61 | clean: 62 | @if [ -e 3210.o ]; then rm 3210.o; fi; 63 | @if [ -e api.o ]; then rm api.o; fi; 64 | @if [ -e bmp.o ]; then rm bmp.o; fi; 65 | @if [ -e emelody.o ]; then rm emelody.o; fi; 66 | @if [ -e ems.o ]; then rm ems.o; fi; 67 | @if [ -e fileoutput.o ]; then rm fileoutput.o; fi; 68 | @if [ -e general.o ]; then rm general.o; fi; 69 | @if [ -e gif.o ]; then rm gif.o; fi; 70 | @if [ -e imelody.o ]; then rm imelody.o; fi; 71 | @if [ -e kyocera.o ]; then rm kyocera.o; fi; 72 | @if [ -e kyocera6035.o ]; then rm kyocera6035.o; fi; 73 | @if [ -e midi.o ]; then rm midi.o; fi; 74 | @if [ -e motorola.o ]; then rm motorola.o; fi; 75 | @if [ -e nokia.o ]; then rm nokia.o; fi; 76 | @if [ -e parse_3210.o ]; then rm parse_3210.o; fi; 77 | @if [ -e parse_bmp.o ]; then rm parse_bmp.o; fi; 78 | @if [ -e parse_emelody.o ]; then rm parse_emelody.o; fi; 79 | @if [ -e parse_ems.o ]; then rm parse_ems.o; fi; 80 | @if [ -e parse_gif.o ]; then rm parse_gif.o; fi; 81 | @if [ -e parse_imelody.o ]; then rm parse_imelody.o; fi; 82 | @if [ -e parse_kws.o ]; then rm parse_kws.o; fi; 83 | @if [ -e parse_logo.o ]; then rm parse_logo.o; fi; 84 | @if [ -e parse_midi.o ]; then rm parse_midi.o; fi; 85 | @if [ -e parse_morsecode.o ]; then rm parse_morsecode.o; fi; 86 | @if [ -e parse_rtttl.o ]; then rm parse_rtttl.o; fi; 87 | @if [ -e parse_siemens.o ]; then rm parse_siemens.o; fi; 88 | @if [ -e parse_sckl.o ]; then rm parse_sckl.o; fi; 89 | @if [ -e rtttl.o ]; then rm rtttl.o; fi; 90 | @if [ -e samsung.o ]; then rm samsung.o; fi; 91 | @if [ -e siemens.o ]; then rm siemens.o; fi; 92 | @if [ -e seo.o ]; then rm seo.o; fi; 93 | @if [ -e treo.o ]; then rm treo.o; fi; 94 | @if [ -e wav.o ]; then rm wav.o; fi; 95 | @if [ -e ringtonetools ]; then rm ringtonetools; fi; 96 | @if [ -e ringtonetools.exe ]; then rm ringtonetools.exe; fi; 97 | @if [ -e ringtonetools.dll ]; then rm ringtonetools.dll; fi; 98 | @if [ -e ringtonetools.so ]; then rm ringtonetools.so; fi; 99 | 100 | dll: default 101 | $(CC) -c api.c $(FLAGS) $(WARN) 102 | dllwrap --def ringtonetools.def --dllname ringtonetools -o \ 103 | ringtonetools.dll \ 104 | 3210.o api.o bmp.o emelody.o \ 105 | ems.o fileoutput.o general.o gif.o imelody.o kyocera.o\ 106 | kyocera6035.o midi.o motorola.o nokia.o parse_3210.o \ 107 | parse_bmp.o parse_emelody.o parse_ems.o parse_gif.o \ 108 | parse_imelody.o parse_kws.o parse_logo.o parse_midi.o \ 109 | parse_morsecode.o parse_rtttl.o parse_siemens.o \ 110 | parse_sckl.o rtttl.o samsung.o siemens.o seo.o treo.o \ 111 | wav.o 112 | 113 | lib: default 114 | $(CC) -c api.c $(FLAGS) $(WARN) 115 | gcc -o ringtonetools.so -shared\ 116 | 3210.o api.o bmp.o emelody.o \ 117 | ems.o fileoutput.o general.o gif.o imelody.o kyocera.o\ 118 | kyocera6035.o midi.o motorola.o nokia.o parse_3210.o \ 119 | parse_bmp.o parse_emelody.o parse_ems.o parse_gif.o \ 120 | parse_imelody.o parse_kws.o parse_logo.o parse_midi.o \ 121 | parse_morsecode.o parse_rtttl.o parse_siemens.o \ 122 | parse_sckl.o rtttl.o samsung.o siemens.o seo.o treo.o \ 123 | wav.o 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/api.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "ringtonetools.h" 8 | #include "fileoutput.h" 9 | 10 | /* 11 | 12 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 13 | This falls under the Kohnian license. Please read 14 | it at http://ringtonetools.mikekohn.net/ 15 | 16 | This program is NOT opensourced. You may not use any part 17 | of this program for your own software. 18 | 19 | */ 20 | 21 | int rtt_set_filenames(struct rtt_info_t *rtt_info, char *input_filename, char *output_filename) 22 | { 23 | 24 | strcpy(rtt_info->inname,input_filename); 25 | strcpy(rtt_info->outname,output_filename); 26 | 27 | return 0; 28 | } 29 | 30 | /* struct rtt_info_t *rtt_info note_alloc() */ 31 | int rtt_info_alloc() 32 | { 33 | /* return (struct rtt_info_t*)malloc(sizeof(struct rtt_info_t)); */ 34 | return (int)malloc(sizeof(struct rtt_info_t)); 35 | } 36 | 37 | int rtt_info_free(struct rtt_info_t *rtt_info) 38 | { 39 | 40 | free(rtt_info); 41 | 42 | return 0; 43 | } 44 | 45 | int rtt_set_logo_dims(struct rtt_info_t *rtt_info, int width, int height) 46 | { 47 | rtt_info->width=width; 48 | rtt_info->height=height; 49 | 50 | return 0; 51 | } 52 | 53 | int rtt_set_types(struct rtt_info_t *rtt_info, int in_type, int out_type) 54 | { 55 | rtt_info->in_type=in_type; 56 | rtt_info->out_type=out_type; 57 | 58 | return 0; 59 | } 60 | 61 | int rtt_set_tempo(struct rtt_info_t *rtt_info, int bpm) 62 | { 63 | rtt_info->bpm=bpm; 64 | 65 | return 0; 66 | } 67 | 68 | int rtt_set_name(struct rtt_info_t *rtt_info, char *songname) 69 | { 70 | strncpy(rtt_info->songname,songname,SONGNAME_LEN); 71 | rtt_info->songname[SONGNAME_LEN-1]=0; 72 | 73 | return 0; 74 | } 75 | 76 | int rtt_set_pause(struct rtt_info_t *rtt_info, int pause) 77 | { 78 | rtt_info->pause=pause; 79 | 80 | return 0; 81 | } 82 | 83 | int rtt_set_wav_options(struct rtt_info_t *rtt_info, int bits_per_sample, int sample_rate) 84 | { 85 | rtt_info->bytes=bits_per_sample/8; 86 | rtt_info->sample_rate=sample_rate; 87 | 88 | return 0; 89 | } 90 | 91 | int rtt_set_mcc_mnc(struct rtt_info_t *rtt_info, int mcc, int mnc) 92 | { 93 | rtt_info->mcc=mcc; 94 | rtt_info->mnc=mnc; 95 | 96 | return 0; 97 | } 98 | 99 | int rtt_transpose(struct rtt_info_t *rtt_info, int transpose) 100 | { 101 | rtt_info->trans=transpose; 102 | 103 | return 0; 104 | } 105 | 106 | int rtt_set_sms_size(struct rtt_info_t *rtt_info, int sms_size) 107 | { 108 | rtt_info->full_sms_size=sms_size; 109 | 110 | return 0; 111 | } 112 | 113 | int rtt_set_volume(struct rtt_info_t *rtt_info, int volume) 114 | { 115 | rtt_info->volume=volume; 116 | 117 | return 0; 118 | } 119 | 120 | int rtt_set_midi_options(struct rtt_info_t *rtt_info, int channel, int track) 121 | { 122 | rtt_info->mcc=channel; 123 | rtt_info->mnc=track; 124 | 125 | return 0; 126 | } 127 | 128 | int rtt_set_header_options(struct rtt_info_t *rtt_info, int header_option) 129 | { 130 | rtt_info->headers=header_option; 131 | 132 | return 0; 133 | } 134 | 135 | int rtt_get_version(char *version_str) 136 | { 137 | sprintf(version_str,"%s - %s",VERSION,DATE_RELEASED); 138 | 139 | return 0; 140 | } 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/emelody.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "ringtonetools.h" 7 | #include "fileoutput.h" 8 | 9 | /* 10 | 11 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 12 | This falls under the Kohnian license. Please read 13 | it at http://ringtonetools.mikekohn.net/ 14 | 15 | This program is NOT opensourced. You may not use any part 16 | of this program for your own software. 17 | 18 | */ 19 | 20 | /* eMelody for older Ericsson */ 21 | 22 | void write_emelody_header(FILE *out, struct rtt_info_t *rtt_info) 23 | { 24 | 25 | } 26 | 27 | void write_emelody_note(FILE *out, struct rtt_info_t *rtt_info) 28 | { 29 | char outchars[5]; 30 | 31 | if (rtt_info->scale==1) 32 | { fprintf(out,"+"); } 33 | else 34 | if (rtt_info->scale>=2) 35 | { fprintf(out,"++"); } 36 | 37 | if (rtt_info->tone==0) strcpy(outchars,"P"); 38 | else 39 | if (rtt_info->tone==1) strcpy(outchars,"C"); 40 | else 41 | if (rtt_info->tone==2) strcpy(outchars,"C#"); 42 | else 43 | if (rtt_info->tone==3) strcpy(outchars,"D"); 44 | else 45 | if (rtt_info->tone==4) strcpy(outchars,"D#"); 46 | else 47 | if (rtt_info->tone==5) strcpy(outchars,"E"); 48 | else 49 | if (rtt_info->tone==6) strcpy(outchars,"F"); 50 | else 51 | if (rtt_info->tone==7) strcpy(outchars,"F#"); 52 | else 53 | if (rtt_info->tone==8) strcpy(outchars,"G"); 54 | else 55 | if (rtt_info->tone==9) strcpy(outchars,"G#"); 56 | else 57 | if (rtt_info->tone==10) strcpy(outchars,"A"); 58 | else 59 | if (rtt_info->tone==11) strcpy(outchars,"A#"); 60 | else 61 | if (rtt_info->tone==12) strcpy(outchars,"B"); 62 | else 63 | { strcpy(outchars,"C"); } 64 | 65 | if (rtt_info->length>=3) outchars[0]=tolower(outchars[0]); 66 | 67 | if (rtt_info->modifier>0) strcat(outchars,"."); 68 | 69 | fprintf(out,"%s",outchars); 70 | } 71 | 72 | void write_emelody_footer(FILE *out, struct rtt_info_t *rtt_info) 73 | { 74 | 75 | } 76 | 77 | 78 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/ems.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "ringtonetools.h" 6 | #include "fileoutput.h" 7 | 8 | /* 9 | 10 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 11 | This falls under the Kohnian license. Please read 12 | it at http://ringtonetools.mikekohn.net/ 13 | 14 | This program is NOT opensourced. You may not use any part 15 | of this program for your own software. 16 | 17 | */ 18 | 19 | /* EMS */ 20 | 21 | void write_ems_header(FILE *out, struct rtt_info_t *rtt_info) 22 | { 23 | 24 | } 25 | 26 | void write_ems(struct rtt_info_t *rtt_info, char *s) 27 | { 28 | int l,t; 29 | 30 | l=strlen(s); 31 | 32 | for (t=0; tring_stack[rtt_info->stackptr++]=s[t]; 35 | } 36 | } 37 | 38 | void write_ems_footer(FILE *out, struct rtt_info_t *rtt_info) 39 | { 40 | int t; 41 | 42 | if (rtt_info->stackptr>128) 43 | { 44 | if (quiet==0) 45 | { 46 | printf("Error: EMS data exceeds 128 octets. Message is truncated.\n"); 47 | rtt_info->stackptr=128; 48 | } 49 | } 50 | 51 | fprintf(out,"%02X0C%02X00",rtt_info->stackptr+3,rtt_info->stackptr+1); 52 | 53 | for (t=0; tstackptr; t++) 54 | { 55 | fprintf(out,"%02X",rtt_info->ring_stack[t]); 56 | } 57 | } 58 | 59 | void write_ems_logo_header(FILE *out, struct rtt_info_t *rtt_info) 60 | { 61 | if (rtt_info->width==16 && rtt_info->height==16) 62 | { 63 | rtt_info->width=16; 64 | rtt_info->height=16; 65 | rtt_info->ems=0x11; 66 | } 67 | else 68 | if (rtt_info->width==32 && rtt_info->height==32) 69 | { 70 | rtt_info->width=32; 71 | rtt_info->height=32; 72 | rtt_info->ems=0x10; 73 | } 74 | else 75 | { 76 | rtt_info->ems=0x12; 77 | } 78 | } 79 | 80 | void write_ems_logo_footer(FILE *out, struct rtt_info_t *rtt_info) 81 | { 82 | int x,y,b,c,ptr; 83 | int octets,k; 84 | 85 | ptr=0; 86 | octets=0; 87 | 88 | for (y=0; yheight; y++) 89 | { 90 | x=0; 91 | while (xwidth) 92 | { 93 | k=0; 94 | 95 | for (b=7; b>=0; b--) 96 | { 97 | if (xwidth) 98 | { 99 | c=rtt_info->picture[ptr++]; 100 | c=((c&255)+((c>>8)&255)+((c>>16)&255))/3; 101 | 102 | if (c>COLOR_THRESHOLD) 103 | { k=k+(1<picture[octets++]=k; 109 | } 110 | } 111 | 112 | if (octets>128) 113 | { 114 | if (quiet==0) 115 | { 116 | printf("Warning: EMS data exceeds 128 octets. Message has been tructated.\n"); 117 | } 118 | octets=128; 119 | } 120 | 121 | if (rtt_info->ems==0x12) 122 | { 123 | if ((rtt_info->width%8)!=0) 124 | { 125 | printf("Warning: Width needs to be a multiple of 8 pixels.\n"); 126 | rtt_info->width=rtt_info->width+(8-(rtt_info->width%8)); 127 | } 128 | fprintf(out,"%02X%02X%02X00",octets+5,rtt_info->ems,octets+3); 129 | fprintf(out,"%02X%02X",rtt_info->width/8,rtt_info->height); 130 | } 131 | else 132 | { fprintf(out,"%02X%02X%02X00",octets+3,rtt_info->ems,octets+1); } 133 | 134 | for (k=0; kpicture[k]); 137 | } 138 | } 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/imelody.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "ringtonetools.h" 7 | #include "fileoutput.h" 8 | 9 | /* 10 | 11 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 12 | This falls under the Kohnian license. Please read 13 | it at http://ringtonetools.mikekohn.net/ 14 | 15 | This program is NOT opensourced. You may not use any part 16 | of this program for your own software. 17 | 18 | */ 19 | 20 | /* iMelody for newer Ericsson, Motorola, Siemens and others */ 21 | 22 | void write_imelody_header(FILE *out, struct rtt_info_t *rtt_info) 23 | { 24 | char header[2048]; 25 | char temp[128]; 26 | 27 | header[0]=0; 28 | 29 | if (rtt_info->headers>=2) 30 | { 31 | strcat(header,"BEGIN:IMELODY\r\n"); 32 | } 33 | 34 | if (rtt_info->headers>=5) 35 | { 36 | strcat(header,"VERSION:1.0\r\n"); 37 | strcat(header,"FORMAT:CLASS 1.0\r\n"); 38 | } 39 | 40 | if (rtt_info->headers>=3) 41 | { 42 | sprintf(temp,"NAME:%s\r\n",rtt_info->songname); 43 | strcat(header,temp); 44 | sprintf(temp,"BEAT:%d\r\n",rtt_info->bpm); 45 | strcat(header,temp); 46 | } 47 | 48 | if (rtt_info->headers>=4) 49 | { 50 | sprintf(temp,"STYLE:S%d\r\n",rtt_info->style); 51 | strcat(header,temp); 52 | } 53 | 54 | if (rtt_info->headers>=1) 55 | { 56 | strcat(header,"MELODY:"); 57 | } 58 | 59 | if (rtt_info->ems==0) 60 | { fprintf(out,header); } 61 | else 62 | { 63 | write_ems(rtt_info,header); 64 | } 65 | 66 | rtt_info->prev_scale=1; 67 | } 68 | 69 | void write_imelody_note(FILE *out, struct rtt_info_t *rtt_info) 70 | { 71 | char outchars[16]; 72 | char temp[16]; 73 | 74 | outchars[0]=0; 75 | 76 | /* if (rtt_info->prev_scale!=rtt_info->scale) */ 77 | 78 | if (rtt_info->tone!=0) 79 | { 80 | sprintf(outchars,"*%d",rtt_info->scale+3); 81 | rtt_info->prev_scale=rtt_info->scale; 82 | } 83 | 84 | if (rtt_info->tone==0) strcat(outchars,"r"); 85 | else 86 | if (rtt_info->tone==1) strcat(outchars,"c"); 87 | else 88 | if (rtt_info->tone==2) strcat(outchars,"#c"); 89 | else 90 | if (rtt_info->tone==3) strcat(outchars,"d"); 91 | else 92 | if (rtt_info->tone==4) strcat(outchars,"#d"); 93 | else 94 | if (rtt_info->tone==5) strcat(outchars,"e"); 95 | else 96 | if (rtt_info->tone==6) strcat(outchars,"f"); 97 | else 98 | if (rtt_info->tone==7) strcat(outchars,"#f"); 99 | else 100 | if (rtt_info->tone==8) strcat(outchars,"g"); 101 | else 102 | if (rtt_info->tone==9) strcat(outchars,"#g"); 103 | else 104 | if (rtt_info->tone==10) strcat(outchars,"a"); 105 | else 106 | if (rtt_info->tone==11) strcat(outchars,"#a"); 107 | else 108 | if (rtt_info->tone==12) strcat(outchars,"b"); 109 | else 110 | { strcat(outchars,"c"); } 111 | 112 | if (rtt_info->length<6) 113 | { sprintf(temp,"%d",rtt_info->length); } 114 | else 115 | { sprintf(temp,"5"); } 116 | strcat(outchars,temp); 117 | 118 | if (rtt_info->modifier==1) strcat(outchars,"."); 119 | else 120 | if (rtt_info->modifier==2) strcat(outchars,":"); 121 | else 122 | if (rtt_info->modifier==3) strcat(outchars,";"); 123 | 124 | if (rtt_info->ems==0) 125 | { fprintf(out,"%s",outchars); } 126 | else 127 | { write_ems(rtt_info,outchars); } 128 | } 129 | 130 | void write_imelody_footer(FILE *out, struct rtt_info_t *rtt_info) 131 | { 132 | char header[64]; 133 | 134 | header[0]=0; 135 | 136 | strcat(header,"\r\n"); 137 | 138 | if (rtt_info->headers>=2) 139 | { 140 | strcat(header,"END:IMELODY\r\n"); 141 | } 142 | 143 | if (rtt_info->ems==0) 144 | { fprintf(out,"%s",header); } 145 | else 146 | { 147 | write_ems(rtt_info,header); 148 | write_ems_footer(out,rtt_info); 149 | } 150 | } 151 | 152 | 153 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/kyocera.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "ringtonetools.h" 5 | #include "fileoutput.h" 6 | 7 | /* 8 | 9 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 10 | This falls under the Kohnian license. Please read 11 | it at http://ringtonetools.mikekohn.net/ 12 | 13 | This program is NOT opensourced. You may not use any part 14 | of this program for your own software. 15 | 16 | */ 17 | 18 | /* Kyocera KWS */ 19 | 20 | void write_kws_header(FILE *out, struct rtt_info_t *rtt_info) 21 | { 22 | 23 | } 24 | 25 | void write_kws_note(FILE *out, struct rtt_info_t *rtt_info) 26 | { 27 | int d,a,b; 28 | 29 | rtt_info->ring_stack[rtt_info->stackptr++]=rtt_info->tone+(rtt_info->scale*12); 30 | 31 | if (rtt_info->tone!=0) 32 | { rtt_info->ring_stack[rtt_info->stackptr++]=0x04; } 33 | else 34 | { rtt_info->ring_stack[rtt_info->stackptr++]=0x00; } 35 | 36 | d=(int)(((float)60000/(float)rtt_info->bpm)*(float)((float)4/(float)(1<length))); 37 | 38 | if (rtt_info->modifier==1) 39 | { d=d+(d/2); } 40 | else 41 | if (rtt_info->modifier==2) 42 | { d=d+(d/2)+(d/4); } 43 | 44 | a=d&255; 45 | b=(d>>8)&255; 46 | 47 | a=a^(b<<1); 48 | 49 | rtt_info->ring_stack[rtt_info->stackptr++]=a; 50 | rtt_info->ring_stack[rtt_info->stackptr++]=b; 51 | } 52 | 53 | void write_kws_footer(FILE *out, struct rtt_info_t *rtt_info) 54 | { 55 | int data_length; 56 | int a,b,d; 57 | 58 | if (rtt_info->pause!=0) 59 | { 60 | rtt_info->ring_stack[rtt_info->stackptr++]=0; 61 | rtt_info->ring_stack[rtt_info->stackptr++]=0; 62 | 63 | d=(int)(((float)60000/(float)rtt_info->bpm)*(float)((float)4/(float)(1<<2))); 64 | d=d*rtt_info->pause; 65 | 66 | a=d&255; 67 | b=(d>>8)&255; 68 | 69 | a=a^(b<<1); 70 | 71 | rtt_info->ring_stack[rtt_info->stackptr++]=a; 72 | rtt_info->ring_stack[rtt_info->stackptr++]=b; 73 | 74 | rtt_info->note_count++; 75 | } 76 | 77 | data_length=rtt_info->stackptr+10; 78 | write_long(out,(data_length^0xffffffff)); 79 | write_word(out,rtt_info->note_count); 80 | 81 | for (d=0; dstackptr; d++) putc(rtt_info->ring_stack[d],out); 82 | 83 | write_long(out,(data_length^0xffffffff)); 84 | } 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/kyocera6035.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "ringtonetools.h" 8 | #include "fileoutput.h" 9 | 10 | #define RECORD_SIZE 60000 11 | 12 | /* 13 | 14 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 15 | This falls under the Kohnian license. Please read 16 | it at http://ringtonetools.mikekohn.net/ 17 | 18 | This program is NOT opensourced. You may not use any part 19 | of this program for your own software. 20 | 21 | */ 22 | 23 | int wav2pdb(FILE *in, FILE *out, struct rtt_info_t *rtt_info) 24 | { 25 | char name[32],riff_type[5]; 26 | int ch,ch1,t,l,r; 27 | int channels,sample_rate,bytes_per_sample; 28 | int data_length,records; 29 | 30 | read_chars(in,name,4); 31 | l=read_long(in); 32 | read_chars(in,riff_type,4); 33 | 34 | if (strcasecmp(name,"RIFF")!=0 || strcasecmp(riff_type,"wave")!=0) 35 | { 36 | printf("Invalid WAV file: %s\n",rtt_info->inname); 37 | return 1; 38 | } 39 | 40 | if (rtt_info->songname[0]==0) 41 | { strcpy(name,"Ringtone Tools"); } 42 | else 43 | { strncpy(name,rtt_info->songname,32); } 44 | 45 | l=strlen(name); 46 | if (l>31) l=31; 47 | 48 | for (t=0; t 2 | #include 3 | #include 4 | 5 | #include "ringtonetools.h" 6 | #include "fileoutput.h" 7 | 8 | /* 9 | 10 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 11 | This falls under the Kohnian license. Please read 12 | it at http://ringtonetools.mikekohn.net/ 13 | 14 | This program is NOT opensourced. You may not use any part 15 | of this program for your own software. 16 | 17 | */ 18 | 19 | /* MIDI */ 20 | 21 | #define DIVISIONS 240 22 | 23 | void write_var(FILE *out, int i) 24 | { 25 | int t,k; 26 | 27 | t=7; 28 | while((i>>t)!=0) 29 | { 30 | t=t+7; 31 | } 32 | 33 | t=t-7; 34 | for (k=t; k>=0; k=k-7) 35 | { 36 | if (k!=0) 37 | { putc(((i>>k)&127)+128,out); } 38 | else 39 | { putc(((i>>k)&127),out); } 40 | } 41 | } 42 | 43 | void write_midi_header(FILE *out, struct rtt_info_t *rtt_info) 44 | { 45 | char *i={ "Created by Ringtone Tools (http://ringtonetools.mikekohn.net/)." }; 46 | int d; 47 | 48 | fprintf(out,"MThd"); 49 | write_long_b(out,6); 50 | write_word_b(out,0); 51 | write_word_b(out,1); 52 | write_word_b(out,DIVISIONS); 53 | 54 | fprintf(out,"MTrk"); 55 | rtt_info->marker=ftell(out); 56 | write_long_b(out,0); 57 | 58 | if (rtt_info->songname[0]!=0) 59 | { 60 | write_var(out,0); 61 | putc(0xff,out); 62 | putc(0x03,out); 63 | write_var(out,strlen(rtt_info->songname)); 64 | fprintf(out,"%s",rtt_info->songname); 65 | } 66 | 67 | write_var(out,0); 68 | putc(0xff,out); 69 | putc(0x01,out); 70 | write_var(out,strlen(i)); 71 | fprintf(out,"%s",i); 72 | 73 | write_var(out,0); 74 | putc(0xff,out); 75 | putc(0x51,out); 76 | putc(0x03,out); 77 | d=60000000/rtt_info->bpm; 78 | putc(d>>16,out); 79 | putc((d>>8)&255,out); 80 | putc(d&255,out); 81 | } 82 | 83 | void write_midi_note(FILE *out, struct rtt_info_t *rtt_info) 84 | { 85 | int d,i; 86 | 87 | d=(int)((float)DIVISIONS*((float)4/(float)(1<length))); 88 | 89 | if (rtt_info->modifier==1) d=d+(d/2); 90 | else 91 | if (rtt_info->modifier==2) d=d+(d/2)+(d/4); 92 | 93 | write_var(out,0); 94 | putc(0x90,out); 95 | if (rtt_info->tone==0) 96 | { putc(0,out); } 97 | else 98 | { putc(60+(rtt_info->tone-1)+(rtt_info->scale*12),out); } 99 | putc(64,out); 100 | 101 | write_var(out,d); 102 | putc(0x80,out); 103 | if (rtt_info->tone==0) 104 | { 105 | putc(0,out); 106 | putc(0,out); 107 | } 108 | else 109 | { 110 | putc(60+(rtt_info->tone-1)+(rtt_info->scale*12),out); 111 | i=(int)((float)255*((float)rtt_info->volume/(float)14)); 112 | if (i>255) i=255; 113 | putc(i,out); 114 | } 115 | } 116 | 117 | void write_midi_footer(FILE *out, struct rtt_info_t *rtt_info) 118 | { 119 | int i; 120 | 121 | write_var(out,0); 122 | putc(0xff,out); 123 | putc(0x2f,out); 124 | putc(0x00,out); 125 | 126 | i=ftell(out); 127 | fseek(out,rtt_info->marker,0); 128 | write_long_b(out,(i-rtt_info->marker)-4); 129 | fseek(out,i,0); 130 | } 131 | 132 | void write_midi_bpm(FILE *out, struct rtt_info_t *rtt_info) 133 | { 134 | int d; 135 | 136 | write_var(out,0); 137 | putc(0xff,out); 138 | putc(0x51,out); 139 | putc(0x03,out); 140 | d=60000000/rtt_info->bpm; 141 | putc(d>>16,out); 142 | putc((d>>8)&255,out); 143 | putc(d&255,out); 144 | } 145 | 146 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/motorola.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "ringtonetools.h" 5 | #include "fileoutput.h" 6 | 7 | /* 8 | 9 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 10 | This falls under the Kohnian license. Please read 11 | it at http://ringtonetools.mikekohn.net/ 12 | 13 | This program is NOT opensourced. You may not use any part 14 | of this program for your own software. 15 | 16 | */ 17 | 18 | /* Motorola */ 19 | 20 | void write_mot_header(FILE *out, struct rtt_info_t *rtt_info) 21 | { 22 | char outchars[10]; 23 | int tempo; 24 | 25 | if (rtt_info->bpm<=110) 26 | { tempo=3; } 27 | else 28 | { tempo=4; } 29 | 30 | sprintf(outchars,"L35&%d ",tempo); 31 | write_chars(out,outchars); 32 | 33 | rtt_info->mcc=0; 34 | } 35 | 36 | void write_mot_note(FILE *out, struct rtt_info_t *rtt_info) 37 | { 38 | char outnote[10]; 39 | char notes[]={ 'R','C','C','D','D','E','F','F','G','G','A','A','B' }; 40 | char flats[]={ 0 , 0, 1, 0, 1, -1, 0, 1, 0, 1, 0, 1, -1 }; 41 | char flmap[]={ 0 , 1, 1, 2, 2, -1, 4, 4, 8, 8, 16, 16, -1 }; 42 | int t,d; 43 | 44 | t=0; 45 | 46 | if (rtt_info->note_count<35) 47 | { 48 | outnote[t++]=notes[rtt_info->tone]; 49 | if (flats[rtt_info->tone]!=-1) 50 | { 51 | if (((rtt_info->flats&flmap[rtt_info->tone])==0 && flats[rtt_info->tone]==1) || 52 | ((rtt_info->flats&flmap[rtt_info->tone])!=0 && flats[rtt_info->tone]==0)) 53 | { 54 | outnote[t++]='#'; 55 | rtt_info->flats^=flmap[rtt_info->tone]; 56 | } 57 | } 58 | 59 | if (rtt_info->scale!=0) 60 | { outnote[t++]='+'; } 61 | 62 | d=5-rtt_info->length; 63 | outnote[t++]=d+'0'; 64 | 65 | outnote[t]=0; 66 | 67 | #ifdef DEBUG 68 | printf("%s",outnote); 69 | #endif 70 | 71 | fprintf(out,"%s",outnote); 72 | for (d=0; dmcc=rtt_info->mcc^outnote[d]; 73 | } 74 | } 75 | 76 | void write_mot_footer(FILE *out, struct rtt_info_t *rtt_info) 77 | { 78 | char outchars[20]; 79 | 80 | sprintf(outchars,"&&%c%c",((rtt_info->mcc>>4)+0x30),((rtt_info->mcc&15)+0x30)); 81 | write_chars(out,outchars); 82 | 83 | if (rtt_info->note_count>35) 84 | { 85 | if (quiet==0) 86 | { 87 | printf("Warning: Motorola's format only supports 35 notes.\n"); 88 | printf(" This song has been truncated.\n"); 89 | } 90 | } 91 | } 92 | 93 | void write_mot_key_header(FILE *out, struct rtt_info_t *rtt_info) 94 | { 95 | if (rtt_info->songname[0]!=0) 96 | { 97 | #ifdef DEBUG 98 | fprintf(out,"%s:",rtt_info->songname); 99 | #endif 100 | } 101 | } 102 | 103 | void write_mot_key_note(FILE *out, struct rtt_info_t *rtt_info) 104 | { 105 | if (rtt_info->note_count!=0) fprintf(out," "); 106 | 107 | if (rtt_info->tone!=0) 108 | { 109 | if (rtt_info->scale==0) 110 | { fprintf(out,"1"); } 111 | else 112 | if (rtt_info->scale==1) 113 | { fprintf(out,"11"); } 114 | else 115 | { fprintf(out,"111"); } 116 | } 117 | 118 | if (rtt_info->tone==0) fprintf(out,"44"); 119 | else 120 | if (rtt_info->tone==1) fprintf(out,"222"); 121 | else 122 | if (rtt_info->tone==2) fprintf(out,"2227"); 123 | else 124 | if (rtt_info->tone==3) fprintf(out,"3"); 125 | else 126 | if (rtt_info->tone==4) fprintf(out,"37"); 127 | else 128 | if (rtt_info->tone==5) fprintf(out,"33"); 129 | else 130 | if (rtt_info->tone==6) fprintf(out,"333"); 131 | else 132 | if (rtt_info->tone==7) fprintf(out,"3337"); 133 | else 134 | if (rtt_info->tone==8) fprintf(out,"4"); 135 | else 136 | if (rtt_info->tone==9) fprintf(out,"47"); 137 | else 138 | if (rtt_info->tone==10) fprintf(out,"2"); 139 | else 140 | if (rtt_info->tone==11) fprintf(out,"27"); 141 | else 142 | if (rtt_info->tone==12) fprintf(out,"22"); 143 | 144 | if (rtt_info->length<2) fprintf(out,"w"); 145 | else 146 | if (rtt_info->length==2) fprintf(out,"h"); 147 | else 148 | { fprintf(out,"q"); } 149 | } 150 | 151 | void write_mot_key_footer(FILE *out, struct rtt_info_t *rtt_info) 152 | { 153 | 154 | } 155 | 156 | 157 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/parse_3210.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "ringtonetools.h" 7 | #include "fileoutput.h" 8 | 9 | /* 10 | 11 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 12 | This falls under the Kohnian license. Please read 13 | it at http://ringtonetools.mikekohn.net/ 14 | 15 | This program is NOT opensourced. You may not use any part 16 | of this program for your own software. 17 | 18 | */ 19 | 20 | extern int pushback; 21 | extern int gettoken(FILE *fp, char *token, int flag); 22 | 23 | int get_3210_tempo(FILE *fp) 24 | { 25 | int marker; 26 | char token[100]; 27 | int t,ch; 28 | 29 | marker=ftell(fp); 30 | gettoken(fp,token,1); 31 | 32 | if (strcasecmp(token,"tempo")!=0) 33 | { 34 | pushback=-1; 35 | fseek(fp,marker,0); 36 | return 63; 37 | } 38 | 39 | gettoken(fp,token,1); 40 | if (strcmp(token,"=")!=0) printf("Expecting '=' and got '%s'\n",token); 41 | gettoken(fp,token,1); 42 | 43 | t=atoi(token); 44 | if (t<1) return 63; 45 | 46 | while (1) 47 | { 48 | ch=getc(fp); 49 | if (ch=='\n' || ch=='\r' || ch==':' || ch=='\t') continue; 50 | if (ch==EOF) { printf("Premature end of file\n"); break; } 51 | else 52 | { 53 | ungetc(ch,fp); 54 | break; 55 | } 56 | } 57 | 58 | return t; 59 | } 60 | 61 | int parse_3210(FILE *in, FILE *out, struct rtt_info_t *rtt_info) 62 | { 63 | char token[16]; 64 | int t,l,ch,f; 65 | int tone_modifier; 66 | 67 | l=0; t=0; f=0; 68 | if (rtt_info->songname[0]!=0) t=1; 69 | while(1) 70 | { 71 | ch=getc(in); 72 | if (f==0 && (ch=='\n' || ch=='\r')) continue; 73 | if (ch==':' || ch=='\n' || ch=='\r') break; 74 | f=1; 75 | if (ch==EOF) 76 | { 77 | printf("Error: Illegal keypress format file\n"); 78 | return -1; 79 | } 80 | 81 | if (lsongname[l++]=ch; 82 | } 83 | 84 | if (t!=0) rtt_info->songname[l]=0; 85 | 86 | rtt_info->bpm=get_3210_tempo(in); 87 | 88 | #ifdef DEBUG 89 | printf("\n Song Name: %s\n",rtt_info->songname); 90 | printf("Beats Per Minute: %d\n",rtt_info->bpm); 91 | #endif 92 | 93 | header_route(out,rtt_info); 94 | 95 | while(1) 96 | { 97 | tone_modifier=0; 98 | rtt_info->modifier=0; 99 | 100 | t=gettoken(in,token,1); 101 | if (t==-1) 102 | { break; } 103 | 104 | if (token[0]==':') continue; 105 | 106 | rtt_info->length=atoi(token); 107 | 108 | if (rtt_info->length==1) rtt_info->length=0; 109 | else 110 | if (rtt_info->length==2) rtt_info->length=1; 111 | else 112 | if (rtt_info->length==4) rtt_info->length=2; 113 | else 114 | if (rtt_info->length==8) rtt_info->length=3; 115 | else 116 | if (rtt_info->length==16) rtt_info->length=4; 117 | else 118 | if (rtt_info->length==32) rtt_info->length=5; 119 | 120 | while(1) 121 | { 122 | t=gettoken(in,token,1); 123 | 124 | if (strcmp(token,".")==0) 125 | { rtt_info->modifier++; } 126 | else 127 | if (strcmp(token,"#")==0) 128 | { tone_modifier++; } 129 | else 130 | { break; } 131 | } 132 | 133 | token[0]=tolower(token[0]); 134 | 135 | if (token[0]=='p' || token[0]=='-') rtt_info->tone=0; 136 | else 137 | if (token[0]=='a') rtt_info->tone=10; 138 | else 139 | if (token[0]=='h' || token[0]=='b') rtt_info->tone=12; 140 | else 141 | if (token[0]=='c') rtt_info->tone=1; 142 | else 143 | if (token[0]=='d') rtt_info->tone=3; 144 | else 145 | if (token[0]=='e') rtt_info->tone=5; 146 | else 147 | if (token[0]=='f') rtt_info->tone=6; 148 | else 149 | if (token[0]=='g') rtt_info->tone=8; 150 | 151 | rtt_info->tone=rtt_info->tone+tone_modifier; 152 | 153 | if (rtt_info->tone!=0) 154 | { 155 | t=gettoken(in,token,1); 156 | rtt_info->scale=atoi(token)-1; 157 | } 158 | 159 | if (rtt_info->tone>12) 160 | { 161 | rtt_info->tone=rtt_info->tone-12; 162 | rtt_info->scale++; 163 | } 164 | 165 | note_route(out,rtt_info); 166 | } 167 | 168 | footer_route(out,rtt_info); 169 | 170 | return (0); 171 | } 172 | 173 | 174 | 175 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/parse_emelody.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "ringtonetools.h" 7 | #include "fileoutput.h" 8 | 9 | #define MAX_EMS_LEN 2048 10 | 11 | /* 12 | 13 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 14 | This falls under the Kohnian license. Please read 15 | it at http://ringtonetools.mikekohn.net/ 16 | 17 | This program is NOT opensourced. You may not use any part 18 | of this program for your own software. 19 | 20 | */ 21 | 22 | int parse_emelody(FILE *in, FILE *out, struct rtt_info_t *rtt_info) 23 | { 24 | char song[MAX_EMS_LEN]; 25 | int t,l,ptr,ch; 26 | int scale; 27 | int length=0,tone=0,octave,modifier; 28 | int tone_modifier; 29 | int default_octave; 30 | 31 | scale=-1; 32 | default_octave=0; 33 | rtt_info->bpm=120; 34 | 35 | check_songname(in,rtt_info->songname); 36 | 37 | ptr=0; 38 | while ((ch=getc(in))!=EOF) 39 | { 40 | song[ptr++]=ch; 41 | if (ptr>MAX_EMS_LEN-8) break; 42 | } 43 | 44 | song[ptr]=0; 45 | 46 | #ifdef DEBUG 47 | printf("\n Song Name: %s\n",rtt_info->songname); 48 | printf("Beats Per Minute: %d\n",rtt_info->bpm); 49 | #endif 50 | 51 | header_route(out,rtt_info); 52 | 53 | for (t=0; tats==0) 66 | { l++; continue; } 67 | 68 | if (song[l]=='*') 69 | { 70 | l++; 71 | default_octave=(song[l++]-'0')-3; 72 | } 73 | 74 | if (song[l]=='+' && song[l+1]=='+') { octave=2+default_octave; l=l+2; } 75 | else 76 | if (song[l]=='+') { octave=1+default_octave; l++; } 77 | else 78 | { octave=default_octave; } 79 | 80 | tone_modifier=0; 81 | 82 | if (song[l]=='#') 83 | { 84 | tone_modifier=tone_modifier+1; 85 | l++; 86 | } 87 | 88 | if (song[l]=='&' || song[l]=='@') 89 | { 90 | tone_modifier=tone_modifier-1; 91 | l++; 92 | } 93 | 94 | if (song[l]=='(' && song[l+1]=='b' && song[l+2]==')') 95 | { 96 | tone_modifier=tone_modifier-1; 97 | l=l+3; 98 | } 99 | 100 | if (tolower(song[l])=='a') tone=10; 101 | else 102 | if (tolower(song[l])=='h' || tolower(song[l])=='b') tone=12; 103 | else 104 | if (tolower(song[l])=='c') tone=1; 105 | else 106 | if (tolower(song[l])=='d') tone=3; 107 | else 108 | if (tolower(song[l])=='e') tone=5; 109 | else 110 | if (tolower(song[l])=='f') tone=6; 111 | else 112 | if (tolower(song[l])=='g') tone=8; 113 | else 114 | if (tolower(song[l])=='p') tone=0; 115 | 116 | if (song[l]>='a' && song[l]<='z') length=3; 117 | else 118 | if (song[l]>='A' && song[l]<='Z') length=2; 119 | 120 | if (song[l]=='p') 121 | { 122 | if (song[l+1]=='p' && song[l+2]=='p' && song[l+3]=='p') 123 | { length=1; l=l+4; } 124 | else 125 | if (song[l+1]=='p') 126 | { length=2; l=l+2; } 127 | else 128 | { l++; } 129 | } 130 | else 131 | { l++; } 132 | 133 | if (song[l]=='.') 134 | { 135 | modifier=1; 136 | l++; 137 | } 138 | else 139 | if (song[l]==':') 140 | { 141 | modifier=2; 142 | l++; 143 | } 144 | 145 | if (song[l]>='0' && song[l]<='3') 146 | { 147 | if (song[l]=='0') 148 | { modifier=1; length=2; } 149 | else 150 | if (song[l]=='1') 151 | { modifier=0; length=2; } 152 | else 153 | if (song[l]=='2') 154 | { modifier=1; length=3; } 155 | else 156 | if (song[l]=='3') 157 | { modifier=0; length=3; } 158 | 159 | l++; 160 | } 161 | 162 | tone=tone+tone_modifier; 163 | 164 | if (tone>12) 165 | { 166 | tone=tone-12; 167 | octave++; 168 | } 169 | 170 | if (scale!=octave) 171 | { 172 | scale=octave; 173 | } 174 | 175 | modifier=0; 176 | 177 | if (song[l]=='.') 178 | { 179 | modifier=1; 180 | l++; 181 | } 182 | 183 | rtt_info->tone=tone; 184 | rtt_info->length=length; 185 | rtt_info->modifier=modifier; 186 | rtt_info->scale=scale; 187 | 188 | note_route(out,rtt_info); 189 | } 190 | 191 | footer_route(out,rtt_info); 192 | 193 | return (0); 194 | } 195 | 196 | 197 | 198 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/parse_ems.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "ringtonetools.h" 7 | #include "fileoutput.h" 8 | 9 | /* 10 | 11 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 12 | This falls under the Kohnian license. Please read 13 | it at http://ringtonetools.mikekohn.net/ 14 | 15 | This program is NOT opensourced. You may not use any part 16 | of this program for your own software. 17 | 18 | */ 19 | 20 | int parse_ems(FILE *in, FILE *out, struct rtt_info_t *rtt_info) 21 | { 22 | unsigned char buffer[8192]; 23 | int s,t,ch,c,ptr,k; 24 | 25 | ptr=0; 26 | t=0; c=0; 27 | while((ch=getc(in))!=EOF) 28 | { 29 | ch=tolower(ch); 30 | if ((ch>='0' && ch<='9') || (ch>='a' && ch<='f')) 31 | { 32 | if (ch>='0' && ch<='9') 33 | { t=(t<<4)+(ch-'0'); } 34 | else 35 | { t=(t<<4)+(ch-'a')+10; } 36 | c++; 37 | 38 | if ((c%2)==0) 39 | { 40 | buffer[ptr++]=t; 41 | t=0; 42 | } 43 | } 44 | } 45 | 46 | s=4; 47 | if (buffer[1]==0x11) 48 | { 49 | rtt_info->width=16; 50 | rtt_info->height=16; 51 | } 52 | else 53 | if (buffer[1]==0x10) 54 | { 55 | rtt_info->width=32; 56 | rtt_info->height=32; 57 | } 58 | else 59 | if (buffer[1]==0x12) 60 | { 61 | rtt_info->width=buffer[4]*8; 62 | rtt_info->height=buffer[5]; 63 | s=s+2; 64 | } 65 | else 66 | { 67 | printf("Unknown or unsupported EMS type\n"); 68 | return 1; 69 | } 70 | 71 | logo_header_route(out,rtt_info); 72 | 73 | k=0; 74 | for (c=s; c=0; t--) 78 | { 79 | if (((buffer[c]>>t)&1)==0) 80 | { rtt_info->picture[k++]=0; } 81 | else 82 | { rtt_info->picture[k++]=0xffffff; } 83 | } 84 | } 85 | 86 | logo_footer_route(out,rtt_info); 87 | 88 | return (0); 89 | } 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/parse_kws.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "ringtonetools.h" 7 | #include "fileoutput.h" 8 | 9 | /* 10 | 11 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 12 | This falls under the Kohnian license. Please read 13 | it at http://ringtonetools.mikekohn.net/ 14 | 15 | This program is NOT opensourced. You may not use any part 16 | of this program for your own software. 17 | 18 | */ 19 | 20 | int get_duration(float duration); 21 | 22 | int parse_kws(FILE *in, FILE *out, struct rtt_info_t *rtt_info) 23 | { 24 | char notes[2048]; 25 | int duration[2048]; 26 | int file_length,count; 27 | int t,a,b,ch; 28 | int quarter_note=1; 29 | 30 | t=0; 31 | if (rtt_info->songname[0]==0) 32 | { 33 | while(rtt_info->inname[t]!='.' && rtt_info->inname[t]!=0 && t<14) 34 | { 35 | rtt_info->songname[t]=rtt_info->inname[t]; 36 | t++; 37 | } 38 | rtt_info->songname[t]=0; 39 | } 40 | 41 | file_length=read_long(in); 42 | file_length=file_length^0xffffffff; 43 | count=read_word(in); 44 | 45 | fseek(in,0,SEEK_END); 46 | 47 | if (ftell(in)!=file_length) 48 | { 49 | printf("This is not a KWS file.\n"); 50 | return -1; 51 | } 52 | fseek(in,6,SEEK_SET); 53 | 54 | if (count>2040) 55 | { 56 | printf("This song is too long.\n"); 57 | return -1; 58 | } 59 | 60 | for (t=0; tbpm=60000/quarter_note; 81 | if (rtt_info->bpm<250) break; 82 | 83 | quarter_note=quarter_note*2; 84 | t++; 85 | } 86 | 87 | t=0; 88 | while(t<8) 89 | { 90 | if (rtt_info->bpm>90) break; 91 | quarter_note=quarter_note/2; 92 | rtt_info->bpm=60000/quarter_note; 93 | 94 | t++; 95 | } 96 | 97 | header_route(out,rtt_info); 98 | 99 | for (t=0; ttone=0; 104 | } 105 | else 106 | { 107 | rtt_info->tone=(notes[t]-1)%12+1; 108 | rtt_info->scale=(notes[t]-1)/12; 109 | } 110 | 111 | a=get_duration((float)duration[t]/((float)quarter_note*4)); 112 | rtt_info->length=a/2; 113 | rtt_info->modifier=(a%2)^1; 114 | 115 | if (t!=count-1 || rtt_info->tone!=0) 116 | { 117 | note_route(out,rtt_info); 118 | } 119 | } 120 | 121 | footer_route(out,rtt_info); 122 | 123 | return (0); 124 | } 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/parse_logo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "ringtonetools.h" 6 | #include "fileoutput.h" 7 | 8 | #define COLOR_BMP 1 9 | 10 | /* 11 | 12 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 13 | This falls under the Kohnian license. Please read 14 | it at http://ringtonetools.mikekohn.net/ 15 | 16 | This program is NOT opensourced. You may not use any part 17 | of this program for your own software. 18 | 19 | */ 20 | 21 | int parse_text(FILE *in, FILE *out, struct rtt_info_t *rtt_info) 22 | { 23 | int x,y,lastch,ch; 24 | 25 | logo_header_route(out,rtt_info); 26 | 27 | x=0; y=0; lastch=0; 28 | while ((ch=getc(in))!=EOF) 29 | { 30 | if (ch=='\n' || ch=='\r') 31 | { 32 | if ((lastch=='\r' || lastch=='\n') && (ch!=lastch && lastch!=0)) 33 | { continue; } 34 | 35 | x=0; y++; 36 | lastch=ch; 37 | continue; 38 | } 39 | 40 | if (xwidth) 41 | { 42 | if (ch==' ') 43 | { rtt_info->picture[x+(y*rtt_info->width)]=0; } 44 | else 45 | { rtt_info->picture[x+(y*rtt_info->width)]=0xffffff; } 46 | } 47 | 48 | x++; 49 | } 50 | 51 | logo_footer_route(out,rtt_info); 52 | 53 | return 0; 54 | } 55 | 56 | int parse_ngg(FILE *in, FILE *out, struct rtt_info_t *rtt_info) 57 | { 58 | char temp[7]; 59 | int t,ptr,count,ch; 60 | 61 | read_chars(in,temp,6); 62 | temp[3]=0; 63 | 64 | if (strcasecmp(temp,"nol")==0) 65 | { 66 | rtt_info->mcc=read_word(in); 67 | rtt_info->mnc=read_word(in); 68 | } 69 | 70 | rtt_info->width=read_word(in); 71 | rtt_info->height=read_word(in); 72 | read_chars(in,temp,6); 73 | 74 | count=rtt_info->width*rtt_info->height; 75 | 76 | logo_header_route(out,rtt_info); 77 | 78 | ptr=0; 79 | for (t=0; tpicture[ptr++]=0; } 84 | else 85 | { rtt_info->picture[ptr++]=0xffffff; } 86 | } 87 | 88 | logo_footer_route(out,rtt_info); 89 | 90 | return 0; 91 | } 92 | 93 | #ifdef DEBUG 94 | void debug_logo(struct rtt_info_t *rtt_info) 95 | { 96 | int x,y,c,ptr; 97 | 98 | printf("%d x %d\n",rtt_info->width,rtt_info->height); 99 | 100 | ptr=0; 101 | for (y=0; yheight; y++) 102 | { 103 | for (x=0; xwidth; x++) 104 | { 105 | c=rtt_info->picture[ptr++]; 106 | c=((c&255)+((c>>8)&255)+((c>>16)&255))/3; 107 | 108 | if (COLOR_BMP==1) 109 | { 110 | if (c<20) 111 | { printf(" "); } 112 | else 113 | if (c<40) 114 | { printf("."); } 115 | else 116 | if (c<60) 117 | { printf(","); } 118 | else 119 | if (c<80) 120 | { printf(":"); } 121 | else 122 | if (c<100) 123 | { printf("|"); } 124 | else 125 | if (c<120) 126 | { printf("&"); } 127 | else 128 | if (c<180) 129 | { printf("@"); } 130 | else 131 | if (c<210) 132 | { printf("*"); } 133 | else 134 | { printf("#"); } 135 | } 136 | else 137 | { 138 | if (c>COLOR_THRESHOLD) 139 | { printf("*"); } 140 | else 141 | { printf(" "); } 142 | } 143 | } 144 | printf("|\n"); 145 | } 146 | 147 | } 148 | #endif 149 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/parse_morsecode.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "ringtonetools.h" 7 | #include "fileoutput.h" 8 | 9 | /* 10 | 11 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 12 | This falls under the Kohnian license. Please read 13 | it at http://ringtonetools.mikekohn.net/ 14 | 15 | This program is NOT opensourced. You may not use any part 16 | of this program for your own software. 17 | 18 | */ 19 | 20 | int parse_morsecode(FILE *in, FILE *out, struct rtt_info_t *rtt_info) 21 | { 22 | int ch,s,t; 23 | char *p; 24 | char code_alpha[50][5]={".-","-...","-.-.","-..",".","..-.","--.", /* A - G */ 25 | "....","..",".---","-.-",".-..","--", /* H - M */ 26 | "-.","---",".--.","--.-",".-.","...","-", /* N - T */ 27 | "..-","...-",".--","-..-","-.--","--.." }; /* U - Z */ 28 | char code_numbers[14][7]={"-----",".----","..---","...--","....-", /* 0 - 4 */ 29 | ".....","-....","--...","---..","----.", /* 5 - 9 */ 30 | ".-.-.-","--..--","..--.."," " }; /* Stop , ? */ 31 | 32 | header_route(out,rtt_info); 33 | rtt_info->scale=0; 34 | rtt_info->modifier=0; 35 | rtt_info->tone=1; 36 | 37 | while ((ch=getc(in))!=EOF) 38 | { 39 | ch=tolower(ch); 40 | if (ch>='a' && ch <='z') p=code_alpha[ch-'a']; 41 | else 42 | if (ch>='0' && ch <='9') p=code_numbers[ch-'0']; 43 | else 44 | if (ch==',') p=code_numbers[11]; 45 | else 46 | if (ch=='?') p=code_numbers[12]; 47 | else 48 | if (ch=='$') p=code_numbers[10]; /* Full Stop? */ 49 | else 50 | if (ch==' ') p=code_numbers[13]; 51 | else 52 | { continue; } 53 | 54 | s=strlen(p); 55 | 56 | for (t=0; tlength=3; 61 | rtt_info->tone=9; 62 | rtt_info->modifier=1; 63 | note_route(out,rtt_info); 64 | } 65 | else 66 | if (p[t]=='.') 67 | { 68 | rtt_info->length=4; 69 | rtt_info->tone=9; 70 | rtt_info->modifier=0; 71 | note_route(out,rtt_info); 72 | /* 73 | rtt_info->length=4; 74 | rtt_info->tone=0; 75 | note_route(out,rtt_info); 76 | */ 77 | } 78 | else 79 | if (p[t]==' ') 80 | { 81 | rtt_info->length=3; 82 | rtt_info->tone=0; 83 | rtt_info->modifier=1; 84 | note_route(out,rtt_info); 85 | } 86 | } 87 | } 88 | 89 | footer_route(out,rtt_info); 90 | 91 | return (0); 92 | } 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/parse_siemens.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "ringtonetools.h" 7 | #include "fileoutput.h" 8 | 9 | /* 10 | 11 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 12 | This falls under the Kohnian license. Please read 13 | it at http://ringtonetools.mikekohn.net/ 14 | 15 | This program is NOT opensourced. You may not use any part 16 | of this program for your own software. 17 | 18 | */ 19 | 20 | int getnext(FILE *in) 21 | { 22 | int ch; 23 | 24 | while(1) 25 | { 26 | ch=getc(in); 27 | 28 | if (ch==' ' || ch=='\t' || ch=='\n' || ch=='\r') 29 | { continue; } 30 | else 31 | { return tolower(ch); } 32 | } 33 | 34 | return 0; 35 | } 36 | 37 | int parse_siemens(FILE *in, FILE *out, struct rtt_info_t *rtt_info) 38 | { 39 | char token[16]; 40 | int t,ch,ptr; 41 | 42 | check_songname(in,rtt_info->songname); 43 | 44 | #ifdef DEBUG 45 | printf("\n Song Name: %s\n",rtt_info->songname); 46 | #endif 47 | 48 | header_route(out,rtt_info); 49 | rtt_info->modifier=0; 50 | 51 | while(1) 52 | { 53 | rtt_info->tone=-1; 54 | rtt_info->scale=0; 55 | rtt_info->length=2; 56 | 57 | ch=getnext(in); 58 | if (ch==EOF) break; 59 | 60 | if (ch=='p') rtt_info->tone=0; 61 | else 62 | if (ch=='c') rtt_info->tone=1; 63 | else 64 | if (ch=='d') rtt_info->tone=3; 65 | else 66 | if (ch=='e') rtt_info->tone=5; 67 | else 68 | if (ch=='f') rtt_info->tone=6; 69 | else 70 | if (ch=='g') rtt_info->tone=8; 71 | else 72 | if (ch=='a') rtt_info->tone=10; 73 | else 74 | if (ch=='b' || ch=='h') rtt_info->tone=12; 75 | 76 | ch=getnext(in); 77 | if (rtt_info->tone!=0) 78 | { 79 | if (ch==EOF) break; 80 | 81 | if (ch=='i') 82 | { 83 | ch=getnext(in); 84 | if (ch==EOF) break; 85 | if (ch!='s') printf("Error: expecting 's'\n"); 86 | rtt_info->tone++; 87 | 88 | ch=getnext(in); 89 | if (ch==EOF) break; 90 | } 91 | 92 | if (ch>='0' && ch<='9') 93 | { 94 | rtt_info->scale=(ch-'0'); 95 | ch=getnext(in); 96 | if (ch==EOF) break; 97 | } 98 | else 99 | { rtt_info->scale=0; } 100 | } 101 | 102 | if (ch=='(') 103 | { 104 | ptr=0; 105 | 106 | while(1) 107 | { 108 | ch=getnext(in); 109 | if (ch==EOF) break; 110 | if (ch=='/' || ch==')') break; 111 | } 112 | if (ch==EOF) break; 113 | 114 | ptr=0; 115 | while(1) 116 | { 117 | ch=getnext(in); 118 | if (ch==EOF) break; 119 | if (ch==')') break; 120 | if (ch>='0' && ch<='9') token[ptr++]=ch; 121 | if (ptr>2) break; 122 | } 123 | token[ptr]=0; 124 | 125 | t=atoi(token); 126 | if (t>32) t=32; 127 | 128 | if (t==1) rtt_info->length=0; 129 | else 130 | if (t==2) rtt_info->length=1; 131 | else 132 | if (t==4) rtt_info->length=2; 133 | else 134 | if (t==8) rtt_info->length=3; 135 | else 136 | if (t==16) rtt_info->length=4; 137 | else 138 | if (t==32) rtt_info->length=5; 139 | 140 | if (ch==EOF) break; 141 | } 142 | else 143 | { 144 | ungetc(ch,in); 145 | } 146 | 147 | note_route(out,rtt_info); 148 | } 149 | 150 | if (rtt_info->tone!=-1) note_route(out,rtt_info); 151 | 152 | footer_route(out,rtt_info); 153 | 154 | return (0); 155 | } 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/ringtonetools.def: -------------------------------------------------------------------------------- 1 | 2 | EXPORTS 3 | rtt_init_info 4 | rtt_convert 5 | rtt_info_alloc 6 | rtt_info_free 7 | 8 | rtt_set_logo_dims 9 | rtt_set_types 10 | rtt_set_tempo 11 | rtt_set_name 12 | rtt_set_pause 13 | rtt_set_wav_options 14 | rtt_set_mcc_mnc 15 | rtt_transpose 16 | rtt_set_sms_size 17 | rtt_set_volume 18 | rtt_set_header_options 19 | 20 | rtt_get_outtype 21 | rtt_get_intype 22 | rtt_add_extension_to_file 23 | rtt_convert 24 | rtt_set_filenames 25 | 26 | rtt_get_version 27 | 28 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/ringtonetools.h: -------------------------------------------------------------------------------- 1 | 2 | #define VERSION "3.00alpha5" 3 | #define DATE_RELEASED "April 2, 2006" 4 | #define VOLUME 7 5 | #define SMS_SIZE 140 6 | #define RINGSTACK_SIZE 8192 7 | #define COPYRIGHT "Copyright 2001-2006 - Michael Kohn (mike@mikekohn.net)\n\n" \ 8 | "THIS MAY NOT BE USED IN COMMERCIAL ENVIRONMENTS WITHOUT\n" \ 9 | "PERMISSION OF THE AUTHOR. PLEASE READ THE LICENSE.\n\n" 10 | 11 | #define SONGNAME_LEN 64 12 | #define MAX_WIDTH 640 13 | #define MAX_HEIGHT 480 14 | #define COLOR_THRESHOLD 50 15 | 16 | #define RTT_TYPE_UNDEFINED 0 17 | #define RTT_TYPE_RTTTL 1 18 | #define RTT_TYPE_RTX 2 19 | #define RTT_TYPE_EMELODY 3 20 | #define RTT_TYPE_IMELODY 4 21 | #define RTT_TYPE_MIDI 5 22 | #define RTT_TYPE_KWS 6 /* Kyocera Keypress */ 23 | #define RTT_TYPE_SEO 7 /* Siemens */ 24 | #define RTT_TYPE_BMP 8 25 | #define RTT_TYPE_NOKIA3210 9 /* Nokia 3210 Keypress */ 26 | #define RTT_TYPE_SCKL 10 27 | #define RTT_TYPE_MORSECODE 11 28 | #define RTT_TYPE_EMS 12 29 | #define RTT_TYPE_NOL 13 /* Nokia Operator Logo */ 30 | #define RTT_TYPE_NGG 14 /* Nokia Graphic */ 31 | #define RTT_TYPE_WBMP 15 32 | #define RTT_TYPE_ICO 16 /* Windows ICO File */ 33 | #define RTT_TYPE_GIF 17 34 | #define RTT_TYPE_SAMSUNG1 18 35 | #define RTT_TYPE_SAMSUNG2 19 36 | #define RTT_TYPE_PDB 20 37 | #define RTT_TYPE_WAV 21 38 | #define RTT_TYPE_MOT 22 /* Motorola Monophonic */ 39 | #define RTT_TYPE_MOT_KEYPRESS 23 /* Motorola Keypress */ 40 | #define RTT_TYPE_OTT 24 41 | #define RTT_TYPE_RNG 24 42 | #define RTT_TYPE_DSP 25 43 | #define RTT_TYPE_TEXT 26 44 | 45 | #define RTT_NO_ERROR 0 46 | #define RTT_UNSUPPORTED_OUTTYPE -10 47 | #define RTT_UNSUPPORTED_INTYPE -11 48 | 49 | #define RTT_HEADERS_NONE 0 50 | #define RTT_HEADERS_DEFAULT 1 51 | #define RTT_HEADERS_LESS 2 52 | #define RTT_HEADERS_MOST 3 53 | #define RTT_HEADERS_STD 4 54 | #define RTT_HEADERS_FULL 5 55 | 56 | struct rtt_info_t 57 | { 58 | char inname[1024]; 59 | char outname[1024]; 60 | char songname[SONGNAME_LEN]; 61 | char channels; 62 | int sample_rate; 63 | unsigned int samples_per_beat; 64 | int bpm; 65 | int pause; 66 | int bytes; 67 | int scale; 68 | int prev_scale; 69 | int tone; 70 | int length; 71 | int modifier; 72 | int style; 73 | int transpose; 74 | int flats; 75 | int volume; 76 | int a440,ats; 77 | int width,height,mcc,mnc,bmp_flags; 78 | int note_count; 79 | int marker; 80 | int ems; 81 | int trans; 82 | unsigned char loop; 83 | int *picture; 84 | unsigned char *message; 85 | unsigned char *wav_buffer; 86 | short int ring_stack[RINGSTACK_SIZE]; 87 | int stackptr; 88 | int bitptr; 89 | int headers; 90 | int full_sms_size; 91 | int out_type; 92 | int in_type; 93 | }; 94 | 95 | extern int quiet; 96 | 97 | /* API CALLS */ 98 | 99 | int rtt_info_alloc(); 100 | int rtt_init_info(struct rtt_info_t *rtt_info); 101 | int rtt_info_free(struct rtt_info_t *rtt_info); 102 | 103 | int rtt_set_filenames(struct rtt_info_t *rtt_info, char *input_filename, char *output_filename); 104 | int rtt_add_extension_to_file(struct rtt_info_t *rtt_info); 105 | int rtt_get_outtype(struct rtt_info_t *rtt_info, char *param); 106 | int rtt_get_intype(struct rtt_info_t *rtt_info, char *param); 107 | 108 | int rtt_set_logo_dims(struct rtt_info_t *rtt_info, int width, int height); 109 | int rtt_set_types(struct rtt_info_t *rtt_info, int in_type, int out_type); 110 | int rtt_set_tempo(struct rtt_info_t *rtt_info, int bpm); 111 | int rtt_set_name(struct rtt_info_t *rtt_info, char *songname); 112 | int rtt_set_pause(struct rtt_info_t *rtt_info, int pause); 113 | int rtt_set_wav_options(struct rtt_info_t *rtt_info, int bits_per_sample, int sample_rate); 114 | int rtt_set_mcc_mnc(struct rtt_info_t *rtt_info, int mcc, int mnc); 115 | int rtt_transpose(struct rtt_info_t *rtt_info, int transpose); 116 | int rtt_set_sms_size(struct rtt_info_t *rtt_info, int sms_size); 117 | int rtt_set_volume(struct rtt_info_t *rtt_info, int volume); 118 | int rtt_set_midi_options(struct rtt_info_t *rtt_info, int channel, int track); 119 | int rtt_set_header_options(struct rtt_info_t *rtt_info, int header_option); 120 | int rtt_convert(struct rtt_info_t *rtt_info); 121 | int rtt_get_version(char *version_str); 122 | 123 | /* OTHER CALLS */ 124 | 125 | int reverse_tempo(int l); 126 | int get_tempo(int tempo); 127 | int push(int data, int size, struct rtt_info_t *rtt_info); 128 | /* int push_addr(int data, int size, int stackptr, int bitptr); */ 129 | int push_addr(int data, int size, struct rtt_info_t *rtt_info); 130 | void print_hex(int t); 131 | void write_codes(FILE *out, char *port, struct rtt_info_t *rtt_info); 132 | 133 | void check_songname(FILE *in, char *songname); 134 | int gettoken(FILE *fp, char *token, int flag); 135 | int convcolor(char *s); 136 | 137 | int color_distance(int c1, int c2); 138 | int get_color(int col, int *palette, int palette_count); 139 | 140 | 141 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/rtttl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "ringtonetools.h" 6 | #include "fileoutput.h" 7 | 8 | /* 9 | 10 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 11 | This falls under the Kohnian license. Please read 12 | it at http://ringtonetools.mikekohn.net/ 13 | 14 | This program is NOT opensourced. You may not use any part 15 | of this program for your own software. 16 | 17 | */ 18 | 19 | /* RTTTL and RTX */ 20 | 21 | #define DEFAULT_LENGTH 2 22 | 23 | void write_rtttl_header(FILE *out, struct rtt_info_t *rtt_info) 24 | { 25 | if (rtt_info->songname[0]==0) 26 | { strcpy(rtt_info->songname,"unamed"); } 27 | 28 | if (rtt_info->out_type==RTT_TYPE_RTTTL) 29 | { fprintf(out,"%s:d=%d,o=5,b=%d:",rtt_info->songname,1<bpm); } 30 | else 31 | { 32 | if (rtt_info->loop==0) 33 | { fprintf(out,"%s:d=%d,o=4,b=%d:",rtt_info->songname,1<bpm); } 34 | else 35 | { fprintf(out,"%s:d=%d,o=4,b=%d,l=%d:",rtt_info->songname,1<bpm,rtt_info->loop); } 36 | } 37 | } 38 | 39 | void write_rtttl_note(FILE *out, struct rtt_info_t *rtt_info) 40 | { 41 | if (rtt_info->note_count>0) fprintf(out,","); 42 | 43 | if (rtt_info->length!=DEFAULT_LENGTH) fprintf(out,"%d",(1<<(rtt_info->length))); 44 | 45 | if (rtt_info->tone==0) fprintf(out,"p"); 46 | else 47 | if (rtt_info->tone==1) fprintf(out,"c"); 48 | else 49 | if (rtt_info->tone==2) fprintf(out,"c#"); 50 | else 51 | if (rtt_info->tone==3) fprintf(out,"d"); 52 | else 53 | if (rtt_info->tone==4) fprintf(out,"d#"); 54 | else 55 | if (rtt_info->tone==5) fprintf(out,"e"); 56 | else 57 | if (rtt_info->tone==6) fprintf(out,"f"); 58 | else 59 | if (rtt_info->tone==7) fprintf(out,"f#"); 60 | else 61 | if (rtt_info->tone==8) fprintf(out,"g"); 62 | else 63 | if (rtt_info->tone==9) fprintf(out,"g#"); 64 | else 65 | if (rtt_info->tone==10) fprintf(out,"a"); 66 | else 67 | if (rtt_info->tone==11) fprintf(out,"a#"); 68 | else 69 | if (rtt_info->tone==12) fprintf(out,"h"); 70 | 71 | if (rtt_info->tone!=0) 72 | { 73 | if (rtt_info->out_type==RTT_TYPE_RTTTL) 74 | { if (rtt_info->scale!=0) fprintf(out,"%d",rtt_info->scale+5); } 75 | else 76 | { if (rtt_info->scale!=0) fprintf(out,"%d",rtt_info->scale+4); } 77 | } 78 | 79 | if (rtt_info->modifier!=0) fprintf(out,"."); 80 | } 81 | 82 | void write_rtttl_footer(FILE *out, struct rtt_info_t *rtt_info) 83 | { 84 | /* fprintf(out,";"); */ 85 | } 86 | 87 | void write_rtx_bpm(FILE *out, struct rtt_info_t *rtt_info) 88 | { 89 | if (rtt_info->note_count>0) fprintf(out,","); 90 | fprintf(out,"b=%d",rtt_info->bpm); 91 | } 92 | 93 | 94 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/seo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "ringtonetools.h" 7 | #include "fileoutput.h" 8 | 9 | /* 10 | 11 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 12 | This falls under the Kohnian license. Please read 13 | it at http://ringtonetools.mikekohn.net/ 14 | 15 | This program is NOT opensourced. You may not use any part 16 | of this program for your own software. 17 | 18 | */ 19 | 20 | /* Siemans supporting SEO (bmp and midi) */ 21 | 22 | int write_seo(FILE *in, FILE *out, struct rtt_info_t *rtt_info) 23 | { 24 | FILE *fp; 25 | int file_size; 26 | int packets=0,n=0,ptr=0,datasize,headsize,num=1; 27 | int max,i; 28 | char filename[1024]; 29 | char objectname[1024]; 30 | unsigned int referenceid; 31 | 32 | fseek(in,0,SEEK_END); 33 | file_size=ftell(in); 34 | rewind(in); 35 | 36 | referenceid=time(NULL); 37 | 38 | if (file_size==0) return 0; 39 | 40 | /* n=strlen(rtt_info->outname); */ 41 | n=strlen(rtt_info->inname); 42 | while(n>=0 && (rtt_info->inname[n]!='/' && rtt_info->inname[n]!='\\')) n--; 43 | if (n<0) n=0; 44 | strcpy(objectname,&rtt_info->inname[n]); 45 | 46 | datasize=rtt_info->full_sms_size-24-strlen(objectname)-1; 47 | packets=file_size/datasize; 48 | if (file_size%datasize!=0) packets++; 49 | 50 | headsize=rtt_info->full_sms_size-datasize; 51 | 52 | n=strlen(rtt_info->outname); 53 | while(n>0 && rtt_info->outname[n]!='.') n--; 54 | rtt_info->outname[n]=0; 55 | max=0; 56 | 57 | ptr=0; 58 | while(ptroutname,num); 61 | fprintf(out,"%s\n",filename); 62 | fp=fopen(filename,"wb"); 63 | 64 | if (datasize+ptr>file_size) datasize=file_size-ptr; 65 | 66 | fprintf(fp,"//SEO%c",1); 67 | if (max==0) 68 | { write_word(fp,datasize); } 69 | else 70 | { write_word(fp,max); } 71 | write_long(fp,referenceid); 72 | write_word(fp,num); 73 | write_word(fp,packets); 74 | write_long(fp,file_size); 75 | if (rtt_info->in_type==RTT_TYPE_BMP) 76 | { fprintf(fp,"%cbmp",3); } 77 | else 78 | if (rtt_info->in_type==RTT_TYPE_MIDI) 79 | { fprintf(fp,"%cmid",3); } 80 | putc(strlen(objectname),fp); 81 | fprintf(fp,"%s",objectname); 82 | 83 | for (n=0; n 2 | #include 3 | #include 4 | 5 | #include "ringtonetools.h" 6 | #include "fileoutput.h" 7 | 8 | /* 9 | 10 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 11 | This falls under the Kohnian license. Please read 12 | it at http://ringtonetools.mikekohn.net/ 13 | 14 | This program is NOT opensourced. You may not use any part 15 | of this program for your own software. 16 | 17 | */ 18 | 19 | /* Siemens Older Models */ 20 | 21 | void write_siemens_header(FILE *out, struct rtt_info_t *rtt_info) 22 | { 23 | rtt_info->bytes=0; 24 | } 25 | 26 | void write_siemens_note(FILE *out, struct rtt_info_t *rtt_info) 27 | { 28 | char outchars[20]; 29 | char temp[20]; 30 | 31 | outchars[0]=0; 32 | 33 | if (rtt_info->tone==0) strcpy(outchars,"P"); 34 | else 35 | if (rtt_info->tone==1) strcpy(outchars,"C"); 36 | else 37 | if (rtt_info->tone==2) strcpy(outchars,"Cis"); 38 | else 39 | if (rtt_info->tone==3) strcpy(outchars,"D"); 40 | else 41 | if (rtt_info->tone==4) strcpy(outchars,"Dis"); 42 | else 43 | if (rtt_info->tone==5) strcpy(outchars,"E"); 44 | else 45 | if (rtt_info->tone==6) strcpy(outchars,"F"); 46 | else 47 | if (rtt_info->tone==7) strcpy(outchars,"Fis"); 48 | else 49 | if (rtt_info->tone==8) strcpy(outchars,"G"); 50 | else 51 | if (rtt_info->tone==9) strcpy(outchars,"Gis"); 52 | else 53 | if (rtt_info->tone==10) strcpy(outchars,"A"); 54 | else 55 | if (rtt_info->tone==11) strcpy(outchars,"Ais"); 56 | else 57 | if (rtt_info->tone==12) strcpy(outchars,"H"); 58 | else 59 | { strcpy(outchars,"0"); } 60 | 61 | if (rtt_info->tone!=0) 62 | { 63 | sprintf(temp,"%d",(rtt_info->scale+1)); 64 | strcat(outchars,temp); 65 | } 66 | 67 | sprintf(temp,"(1/%d) ",1<length); 68 | strcat(outchars,temp); 69 | 70 | fprintf(out,"%s",outchars); 71 | 72 | rtt_info->bytes=rtt_info->bytes+strlen(outchars); 73 | 74 | if (rtt_info->bytes>70) 75 | { 76 | fprintf(out,"\n"); 77 | rtt_info->bytes=0; 78 | } 79 | } 80 | 81 | void write_siemens_footer(FILE *out, struct rtt_info_t *rtt_info) 82 | { 83 | fprintf(out,"\n"); 84 | } 85 | 86 | 87 | -------------------------------------------------------------------------------- /vendor-native/ringtonetools/src/treo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "ringtonetools.h" 8 | #include "fileoutput.h" 9 | 10 | #define RECORD_SIZE 60000 11 | 12 | /* 13 | 14 | Ringtone Tools - Copyright 2001-2006 Michael Kohn (mike@mikekohn.net) 15 | This falls under the Kohnian license. Please read 16 | it at http://ringtonetools.mikekohn.net/ 17 | 18 | This program is NOT opensourced. You may not use any part 19 | of this program for your own software. 20 | 21 | */ 22 | 23 | /* Handspring Treo output */ 24 | 25 | int write_treo_pdb(FILE *in, FILE *out, struct rtt_info_t *rtt_info) 26 | { 27 | char name[32]; 28 | int ch,t,l,r; 29 | int records; 30 | 31 | read_chars(in,name,4); 32 | 33 | if (strcasecmp(name,"MThd")!=0) 34 | { 35 | printf("Invalid MIDI file: %s\n",rtt_info->inname); 36 | return 1; 37 | } 38 | 39 | if (rtt_info->songname[0]==0) 40 | { strcpy(name,"Ringtone Tools"); } 41 | else 42 | { strcpy(name,rtt_info->songname); } 43 | 44 | l=strlen(name); 45 | if (l>31) l=31; 46 | 47 | for (t=0; tsongname); 75 | 76 | /* if (lsongname[4]=0; 101 | for (t=0; t<4; t++) 102 | { if (rtt_info->songname[t]==0) rtt_info->songname[t]=' '; } 103 | */ 104 | 105 | /* write_chars(out,"Kohn"); */ 106 | write_chars(out,rtt_info->songname); 107 | putc(0,out); 108 | 109 | for (t=0; t