2 /** FusionForge Subversion plugin
4 * Copyright 2003-2010, Roland Mas, Franck Villaume
5 * Copyright 2004, GForge, LLC
6 * Copyright 2010, Alain Peyrat <aljeux@free.fr>
7 * Copyright 2012-2013, Franck Villaume - TrivialDev
8 * Copyright 2013, French Ministry of National Education
10 * This file is part of FusionForge.
12 * FusionForge is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published
14 * by the Free Software Foundation; either version 2 of the License,
15 * or (at your option) any later version.
17 * FusionForge is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 forge_define_config_item('default_server', 'scmsvn', forge_get_config ('web_host'));
28 forge_define_config_item('repos_path', 'scmsvn', forge_get_config('chroot').'/scmrepos/svn');
29 forge_define_config_item('use_ssh', 'scmsvn', false);
30 forge_set_config_item_bool('use_ssh', 'scmsvn');
31 forge_define_config_item('use_dav', 'scmsvn', true);
32 forge_set_config_item_bool('use_dav', 'scmsvn');
33 forge_define_config_item('use_ssl', 'scmsvn', true);
34 forge_set_config_item_bool('use_ssl', 'scmsvn');
35 forge_define_config_item('anonsvn_login','scmsvn', 'anonsvn');
36 forge_define_config_item('anonsvn_password','scmsvn', 'anonsvn');
38 class SVNPlugin extends SCMPlugin {
39 function SVNPlugin() {
41 $this->name = 'scmsvn';
42 $this->text = 'Subversion';
43 $this->svn_root_fs = '/scmrepos/svn';
44 if (!file_exists($this->svn_root_fs.'/.')) {
45 $this->svn_root_fs = forge_get_config('repos_path',
48 $this->svn_root_dav = '/svn';
49 $this->_addHook('scm_browser_page');
50 $this->_addHook('scm_update_repolist');
51 $this->_addHook('scm_generate_snapshots');
52 $this->_addHook('scm_gather_stats');
53 $this->_addHook('activity');
55 $this->provides['svn'] = true;
60 function getDefaultServer() {
61 return forge_get_config('default_server', 'scmsvn') ;
64 function printShortStats($params) {
65 $project = $this->checkParams($params);
70 if ($project->usesPlugin($this->name)) {
71 $result = db_query_params('SELECT sum(commits) AS commits, sum(adds) AS adds FROM stats_cvs_group WHERE group_id=$1',
72 array ($project->getID())) ;
73 $commit_num = db_result($result,0,'commits');
74 $add_num = db_result($result,0,'adds');
81 echo ' (Subversion: '.sprintf(_('<strong>%1$s</strong> commits, <strong>%2$s</strong> adds'), number_format($commit_num, 0), number_format($add_num, 0)).")";
86 return '<p>' . _('Documentation for Subversion (sometimes referred to as "SVN") is available <a href="http://svnbook.red-bean.com/">here</a>.') . '</p>';
89 function topModule($project) {
90 // Check toplevel module presence
91 $repo = 'file://' . forge_get_config('repos_path', $this->name).'/'.$project->getUnixName().'/';
94 if (!(exec("svn ls '$repo'", $res) && in_array($module.'/', $res)))
102 function getInstructionsForAnon($project) {
103 $b = '<h2>' . _('Anonymous Subversion Access') . '</h2>';
105 $b .= _("This project's SVN repository can be checked out through anonymous access with the following command(s).");
109 $module = $this->topModule($project);
110 if (forge_get_config('use_ssh', 'scmsvn')) {
111 $b .= '<tt>svn checkout svn://'.$this->getBoxForProject($project).$this->svn_root_fs.'/'.$project->getUnixName().$module.'</tt><br />';
113 if (forge_get_config('use_dav', 'scmsvn')) {
114 $b .= '<tt>svn checkout --username '.forge_get_config('anonsvn_login', 'scmsvn').' http'.((forge_get_config('use_ssl', 'scmsvn')) ? 's' : '').'://' . $this->getBoxForProject($project). $this->svn_root_dav .'/'. $project->getUnixName() .$module.'</tt><br />';
115 $b .= _('The password is ').forge_get_config('anonsvn_password', 'scmsvn').'<br />';
121 function getInstructionsForRW($project) {
124 $module = $this->topModule($project);
126 if (session_loggedin()) {
127 $u =& user_get_object(user_getid());
128 $d = $u->getUnixName() ;
129 if (forge_get_config('use_ssh', 'scmsvn')) {
131 $b .= _('Developer Subversion Access via SSH');
134 $b .= _('Only project developers can access the SVN tree via this method. SSH must be installed on your client machine. Enter your site password when prompted.');
136 $b .= '<p><tt>svn checkout svn+ssh://'.$d.'@' . $this->getBoxForProject($project) . $this->svn_root_fs .'/'. $project->getUnixName().$module.'</tt></p>' ;
138 if (forge_get_config('use_dav', 'scmsvn')) {
140 $b .= _('Developer Subversion Access via DAV');
143 $b .= _('Only project developers can access the SVN tree via this method. Enter your site password when prompted.');
145 $b .= '<p><tt>svn checkout --username '.$d.' http'.((forge_get_config('use_ssl', 'scmsvn')) ? 's' : '').'://'. $this->getBoxForProject($project) . $this->svn_root_dav .'/'.$project->getUnixName().$module.'</tt></p>' ;
148 if (forge_get_config('use_ssh', 'scmsvn')) {
150 $b .= _('Developer Subversion Access via SSH');
153 $b .= _('Only project developers can access the SVN tree via this method. SSH must be installed on your client machine. Substitute <i>developername</i> with the proper values. Enter your site password when prompted.');
155 $b .= '<p><tt>svn checkout svn+ssh://<i>'._('developername').'</i>@' . $this->getBoxForProject($project) . $this->svn_root_fs .'/'. $project->getUnixName().$module.'</tt></p>' ;
157 if (forge_get_config('use_dav', 'scmsvn')) {
159 $b .= _('Developer Subversion Access via DAV');
162 $b .= _('Only project developers can access the SVN tree via this method. Substitute <i>developername</i> with the proper values. Enter your site password when prompted.');
164 $b .= '<p><tt>svn checkout --username <i>'._('developername').'</i> http'.((forge_get_config('use_ssl', 'scmsvn')) ? 's' : '').'://'. $this->getBoxForProject($project) . $this->svn_root_dav .'/'.$project->getUnixName().$module.'</tt></p>' ;
170 function getSnapshotPara($project) {
174 function getBrowserLinkBlock($project) {
176 $b = $HTML->boxMiddle(_('Subversion Repository Browser'));
178 $b .= _('Browsing the Subversion tree gives you a view into the current status of this project\'s code. You may also view the complete histories of any file in the repository.');
181 $b .= util_make_link ("/scm/browser.php?group_id=".$project->getID(),
182 _('Browse Subversion Repository')
188 function getStatsBlock($project) {
192 $result = db_query_params('SELECT u.realname, u.user_name, u.user_id, sum(commits) as commits, sum(adds) as adds, sum(adds+commits) as combined FROM stats_cvs_user s, users u WHERE group_id=$1 AND s.user_id=u.user_id AND (commits>0 OR adds >0) GROUP BY u.user_id, realname, user_name, u.user_id ORDER BY combined DESC, realname',
193 array ($project->getID()));
195 if (db_numrows($result) > 0) {
196 $b .= $HTML->boxMiddle(_('Repository Statistics'));
198 $tableHeaders = array(
203 $b .= $HTML->listTableTop($tableHeaders);
206 $total = array('adds' => 0, 'commits' => 0);
208 while($data = db_fetch_array($result)) {
209 $b .= '<tr '. $HTML->boxGetAltRowStyle($i) .'>';
210 $b .= '<td width="50%">' ;
211 $b .= util_make_link_u ($data['user_name'], $data['user_id'], $data['realname']) ;
212 $b .= '</td><td width="25%" align="right">'.$data['adds']. '</td>'.
213 '<td width="25%" align="right">'.$data['commits'].'</td></tr>';
214 $total['adds'] += $data['adds'];
215 $total['commits'] += $data['commits'];
218 $b .= '<tr '. $HTML->boxGetAltRowStyle($i) .'>';
219 $b .= '<td width="50%"><strong>'._('Total').':</strong></td>'.
220 '<td width="25%" align="right"><strong>'.$total['adds']. '</strong></td>'.
221 '<td width="25%" align="right"><strong>'.$total['commits'].'</strong></td>';
223 $b .= $HTML->listTableBottom();
229 function printBrowserPage($params) {
230 $project = $this->checkParams($params);
235 if ($project->usesPlugin($this->name)) {
236 if ($this->browserDisplayable($project)) {
237 session_redirect("/scm/viewvc.php/?root=".$project->getUnixName());
242 function createOrUpdateRepo($params) {
243 $project = $this->checkParams($params);
248 if (! $project->usesPlugin($this->name)) {
252 $repo = forge_get_config('repos_path', 'scmsvn') . '/' . $project->getUnixName();
254 if (!is_dir ($repo) || !is_file ("$repo/format")) {
255 if (!mkdir($repo, 0700, true)) {
259 system ("svnadmin create $repo", $ret);
263 if (forge_get_config('use_ssh', 'scmsvn')) {
264 $unix_group = 'scm_' . $project->getUnixName() ;
265 system ("find $repo -type d | xargs -I{} chmod g+s {}") ;
266 if ($project->enableAnonSCM()) {
267 system ("chmod -R g+wX,o+rX-w $repo") ;
269 system ("chmod -R g+wX,o-rwx $repo") ;
271 system ("chgrp -R $unix_group $repo") ;
273 $unix_user = forge_get_config('apache_user');
274 $unix_group = forge_get_config('apache_group');
275 system ("chmod -R g-rwx,o-rwx $repo") ;
276 system ("chown -R $unix_user:$unix_group $repo") ;
278 system ("svn mkdir -m'Init' file:///$repo/trunk file:///$repo/tags file:///$repo/branches >/dev/null") ;
281 $this->installOrUpdateCmds($project, $project->getUnixName(), $repo);
283 if (forge_get_config('use_ssh', 'scmsvn')) {
284 $unix_group = 'scm_' . $project->getUnixName();
285 system("find $repo -type d | xargs -I{} chmod g+s {}");
286 if (forge_get_config('use_dav', 'scmsvn')) {
287 $unix_user = forge_get_config('apache_user');
288 system("chown $unix_user:$unix_group $repo");
290 system("chgrp $unix_group $repo");
292 if ($project->enableAnonSCM()) {
293 system("chmod g+wX,o+rX-w $repo") ;
295 system("chmod g+wX,o-rwx $repo") ;
298 $unix_user = forge_get_config('apache_user');
299 $unix_group = forge_get_config('apache_group');
300 system("chown $unix_user:$unix_group $repo") ;
301 system("chmod g-rwx,o-rwx $repo") ;
305 function updateRepositoryList($params) {
306 $groups = $this->getGroups();
308 // Update WebDAV stuff
309 if (!forge_get_config('use_dav', 'scmsvn')) {
315 $engine = RBACEngine::getInstance() ;
318 foreach ($groups as $project) {
319 if ( !$project->isActive()) {
322 if ( !$project->usesSCM()) {
325 $access_data .= '[' . $project->getUnixName() . ":/]\n";
327 $users = $engine->getUsersByAllowedAction('scm',$project->getID(),'read');
328 foreach ($users as $user) {
329 $svnusers[$user->getID()] = $user;
330 if (forge_check_perm_for_user($user,
334 $access_data .= $user->getUnixName() . "= rw\n";
336 $access_data .= $user->getUnixName() . "= r\n";
340 if ($project->enableAnonSCM()) {
341 $access_data .= forge_get_config('anonsvn_login', 'scmsvn')." = r\n";
342 $access_data .= "* = r\n";
345 $access_data .= "\n";
348 foreach ($svnusers as $user_id => $user) {
349 $password_data .= $user->getUnixName().':'.$user->getUnixPasswd()."\n";
351 $password_data .= forge_get_config('anonsvn_login', 'scmsvn').":".htpasswd_apr1_md5(forge_get_config('anonsvn_password', 'scmsvn'))."\n";
353 $fname = forge_get_config('data_path').'/svnroot-authfile';
354 $f = fopen($fname.'.new', 'w');
355 fwrite($f, $password_data);
357 chmod($fname.'.new', 0644);
358 rename($fname.'.new', $fname);
360 $fname = forge_get_config('data_path').'/svnroot-access';
361 $f = fopen($fname.'.new', 'w');
362 fwrite($f, $access_data);
364 chmod($fname.'.new', 0644);
365 rename($fname.'.new', $fname);
368 function gatherStats($params) {
369 global $last_user, $last_time, $last_tag, $time_ok, $start_time, $end_time,
370 $adds, $deletes, $updates, $commits, $date_key,
371 $usr_adds, $usr_deletes, $usr_updates;
375 $project = $this->checkParams($params);
380 if (! $project->usesPlugin($this->name)) {
384 if ($params['mode'] == 'day') {
387 $year = $params['year'];
388 $month = $params['month'];
389 $day = $params['day'];
390 $month_string = sprintf("%04d%02d", $year, $month);
391 $start_time = gmmktime(0, 0, 0, $month, $day, $year);
392 $end_time = $start_time + 86400;
397 $usr_updates = array();
399 $repo = forge_get_config('repos_path', 'scmsvn') . '/' . $project->getUnixName();
400 if (!is_dir ($repo) || !is_file ("$repo/format")) {
401 echo "No repository\n";
406 $d1 = date('Y-m-d', $start_time - 150000);
407 $d2 = date('Y-m-d', $end_time + 150000);
409 $pipe = popen ("svn log file://$repo --xml -v -q -r '".'{'.$d2.'}:{'.$d1.'}'."' 2> /dev/null", 'r' ) ;
411 // cleaning stats_cvs_* table for the current day
412 $res = db_query_params('DELETE FROM stats_cvs_group WHERE month=$1 AND day=$2 AND group_id=$3',
417 echo "Error while cleaning stats_cvs_group\n" ;
422 $res = db_query_params ('DELETE FROM stats_cvs_user WHERE month=$1 AND day=$2 AND group_id=$3',
423 array ($month_string,
425 $project->getID())) ;
427 echo "Error while cleaning stats_cvs_user\n" ;
432 $xml_parser = xml_parser_create();
433 xml_set_element_handler($xml_parser, "SVNPluginStartElement", "SVNPluginEndElement");
434 xml_set_character_data_handler($xml_parser, "SVNPluginCharData");
436 // Analyzing history stream
437 while (!feof($pipe) &&
438 $data = fgets ($pipe, 4096)) {
439 if (!xml_parse ($xml_parser, $data, feof ($pipe))) {
440 debug("Unable to parse XML with error " .
441 xml_error_string(xml_get_error_code($xml_parser)) .
443 xml_get_current_line_number($xml_parser));
450 xml_parser_free($xml_parser);
452 // inserting group results in stats_cvs_groups
453 if ($updates > 0 || $adds > 0) {
454 if (!db_query_params('INSERT INTO stats_cvs_group (month,day,group_id,checkouts,commits,adds) VALUES ($1,$2,$3,$4,$5,$6)',
455 array ($month_string,
461 echo "Error while inserting into stats_cvs_group\n" ;
467 // building the user list
468 $user_list = array_unique( array_merge( array_keys( $usr_adds ), array_keys( $usr_updates ) ) );
470 foreach ( $user_list as $user ) {
471 // trying to get user id from user name
472 $u = &user_get_object_by_name ($user) ;
474 $user_id = $u->getID();
479 $uu = isset($usr_updates[$user]) ? $usr_updates[$user] : 0 ;
480 $ua = isset($usr_adds[$user]) ? $usr_adds[$user] : 0 ;
481 if ($uu > 0 || $ua > 0) {
482 if (!db_query_params ('INSERT INTO stats_cvs_user (month,day,group_id,user_id,commits,adds) VALUES ($1,$2,$3,$4,$5,$6)',
483 array ($month_string,
489 echo "Error while inserting into stats_cvs_user\n" ;
499 function generateSnapshots($params) {
501 $project = $this->checkParams($params);
506 $group_name = $project->getUnixName();
508 $snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar'.util_get_compressed_file_extension();
509 $tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar'.util_get_compressed_file_extension();
511 if (! $project->usesPlugin($this->name)) {
515 if (! $project->enableAnonSCM()) {
516 if (is_file($snapshot)) {
519 if (is_file($tarball)) {
525 $toprepo = forge_get_config('repos_path', 'scmsvn');
526 $repo = $toprepo . '/' . $project->getUnixName();
528 if (!is_dir ($repo) || !is_file ("$repo/format")) {
529 if (is_file($snapshot)) {
532 if (is_file($tarball)) {
538 $tmp = trim (`mktemp -d`) ;
542 $today = date ('Y-m-d') ;
543 $dir = $project->getUnixName ()."-$today" ;
544 system ("mkdir -p $tmp") ;
546 system ("svn ls file://$repo/trunk > /dev/null", $code) ;
548 system ("cd $tmp ; svn export file://$repo/trunk $dir > /dev/null 2>&1") ;
549 system ("tar cCf $tmp - $dir |".forge_get_config('compression_method')."> $tmp/snapshot") ;
550 chmod ("$tmp/snapshot", 0644) ;
551 copy ("$tmp/snapshot", $snapshot) ;
552 unlink ("$tmp/snapshot") ;
553 system ("rm -rf $tmp/$dir") ;
555 if (is_file($snapshot)) {
560 system ("tar cCf $toprepo - ".$project->getUnixName() ."|".forge_get_config('compression_method')."> $tmp/tarball") ;
561 chmod ("$tmp/tarball", 0644) ;
562 copy ("$tmp/tarball", $tarball) ;
563 unlink ("$tmp/tarball") ;
564 system ("rm -rf $tmp") ;
567 function activity($params) {
568 global $last_user, $last_time, $last_tag, $time_ok, $start_time, $end_time,
569 $adds, $deletes, $updates, $commits, $date_key,
570 $usr_adds, $usr_deletes, $usr_updates,
571 $messages, $last_message, $times, $revisions;
572 $group_id = $params['group'];
573 $project = group_get_object($group_id);
574 if (! $project->usesPlugin($this->name)) {
578 if (in_array('scmsvn', $params['show']) || (count($params['show']) < 1)) {
579 $start_time = $params['begin'];
580 $end_time = $params['end'];
581 $d1 = date('Y-m-d', $start_time - 80000);
582 $d2 = date('Y-m-d', $end_time + 80000);
584 $repo = forge_get_config('repos_path', 'scmsvn') . '/' . $project->getUnixName();
585 $pipe = popen("svn log file://$repo --xml -v -r '".'{'.$d2.'}:{'.$d1.'}'."' 2> /dev/null", 'r' );
586 $xml_parser = xml_parser_create();
587 xml_set_element_handler($xml_parser, "SVNPluginStartElement", "SVNPluginEndElement");
588 xml_set_character_data_handler($xml_parser, "SVNPluginCharData");
589 while (!feof($pipe) && $data = fgets($pipe, 4096)) {
590 if (!xml_parse($xml_parser, $data, feof ($pipe))) {
591 debug("Unable to parse XML with error " .
592 xml_error_string(xml_get_error_code($xml_parser)) .
594 xml_get_current_line_number($xml_parser));
599 xml_parser_free($xml_parser);
600 if ($adds > 0 || $updates > 0) {
602 foreach ($messages as $message) {
604 $result['section'] = 'scm';
605 $result['group_id'] = $group_id;
606 $result['ref_id'] = 'viewvc.php/?root='.$project->getUnixName();
607 $result['description'] = $message.' (r'.$revisions[$i].')';
608 $result['user_name'] = $users[$i];
609 $userObject = user_get_object_by_name($users[$i]);
610 if (is_a($userObject, 'GFUser')) {
611 $result['realname'] = $user->getFirstName().' '.$user->getLastName();
612 $result['user_id'] = $user->getId();
614 $result['realname'] = '';
615 $result['user_id'] = '';
617 $result['activity_date'] = $times[$i];
618 $result['subref_id'] = '&view=rev&revision='.$revisions[$i];
619 $params['results'][] = $result;
624 $params['ids'][] = 'scm';
625 $params['texts'][] = _('SCM SVN Commits');
629 function installOrUpdateCmds($project, $unix_group_name, $repos) {
633 $params['unix_group_name'] = $unix_group_name;
634 $group = group_get_object_by_name($unix_group_name);
635 $params['group_id'] = $group->getID();
636 $params['repos'] = $repos;
637 $params['hooks'] = &$hooks;
638 plugin_hook_by_reference('cmd_for_post_commit_hook', $params);
640 foreach ($params['hooks'] as $plugin => $cmd ) {
641 if (getenv('sys_localinc')) {
642 $cmd = 'sys_localinc='.getenv(sys_localinc).' '.$cmd;
644 $contents = @file_get_contents($repos."/hooks/post-commit");
645 if ($project->usesPlugin($plugin)) {
646 if (strstr($contents, "#begin added by $plugin") === false ) {
647 $this->installCmdInHook($repos, $plugin, $cmd);
649 $this->updateCmdInHook($repos, $plugin, $cmd);
651 } elseif (!$project->usesPlugin($plugin) &&
652 (strstr($contents, "#begin added by $plugin") !== false )) {
653 $this->removeCmdInHook($repos, $plugin);
658 function installCmdInHook($repos, $name, $text) {
660 if (file_exists($repos.'/hooks/post-commit')) {
661 $FOut = fopen($repos.'/hooks/post-commit', "a+");
664 $FOut = fopen($repos.'/hooks/post-commit', "w");
665 $Line = '#!/bin/sh'."\n"; // add this line to first line or else the script fails
669 $Line .= "\n#begin added by $name\n$text\n#end added by $name\n";
671 fwrite($FOut, $Line);
673 system("chmod 700 $repos/hooks/post-commit");
678 function updateCmdInHook($repos, $plugin, $text) {
680 $contents = @file_get_contents($repos."/hooks/post-commit");
682 $new = preg_replace("/(#begin added by $plugin\n)(.*)(\n#end added by $plugin)/s", '$1{COMMAND}$3', $contents);
683 $new = str_replace('{COMMAND}', $text, $new);
685 if ($contents !== $new) {
686 $fout = fopen($repos.'/hooks/post-commit', "w");
692 function removeCmdInHook($repos, $plugin) {
694 $contents = @file_get_contents($repos."/hooks/post-commit");
695 $new = preg_replace("/#begin added by $plugin\n.*?\n#end added by $plugin/s", '', $contents);
697 if ($contents !== $new) {
698 if (preg_match("/^#\!\/bin\/sh(\n+)$/s", $new)) {
699 unlink($repos.'/hooks/post-commit');
701 $fout = fopen($repos.'/hooks/post-commit', "w");
709 // End of class, helper functions now
711 function SVNPluginCharData($parser, $chars) {
712 global $last_tag, $last_user, $last_time, $start_time, $end_time,
713 $time_ok, $user_list, $last_message, $messages, $times;
716 $last_user = preg_replace('/[^a-z0-9_-]/', '', strtolower(trim($chars)));
720 $chars = preg_replace('/T(\d\d:\d\d:\d\d)\.\d+Z?$/', ' ${1}', $chars);
721 $last_time = strtotime($chars);
722 if ($start_time <= $last_time && $last_time < $end_time) {
727 $times[] = $last_time;
731 $messages[] = $chars;
737 function SVNPluginStartElement($parser, $name, $attrs) {
738 global $last_user, $last_time, $last_tag, $time_ok,
739 $adds, $updates, $usr_adds, $usr_updates, $last_message, $messages, $times, $revisions;
743 // Make sure we clean up before doing a new log entry
746 $revisions[] = $attrs['REVISION'];
751 if ($attrs['ACTION'] == "M") {
754 $usr_updates[$last_user] = isset($usr_updates[$last_user]) ? ($usr_updates[$last_user]+1) : 1 ;
756 } elseif ($attrs['ACTION'] == "A") {
759 $usr_adds[$last_user] = isset($usr_adds[$last_user]) ? ($usr_adds[$last_user]+1) : 1 ;
768 function SVNPluginEndElement($parser, $name) {
769 global $time_ok, $last_tag, $commits;
770 if ($name == "LOGENTRY" && $time_ok) {
778 // c-file-style: "bsd"