/usr/share/defoma/libdefoma-id.pl is in defoma 0.11.12ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | sub com_id_list_cache {
usage_and_exit if (@ARGV == 0);
my $app = shift(@ARGV);
my @caches = get_files("id-cache.*", $ROOTDIR . "/$app.d");
foreach my $i (@caches) {
if ($i eq 'id-cache') {
$i = '#DEFAULT#';
} else {
$i =~ s/id-cache\.//;
}
}
printm("Id Cache: " . join(' ', @caches));
exit 0;
}
sub com_id_common {
my $com = shift;
usage_and_exit if (@ARGV < 3);
my $appcache = shift(@ARGV);
my $id = shift(@ARGV);
my $font = shift(@ARGV);
my $app;
my $cache;
if ($appcache =~ /^([^\/]+)\/(.*)/) {
$app = $1;
$cache = $2;
$cache = '' if ($cache eq '#DEFAULT#');
} else {
$app = $appcache;
$cache = '';
}
my $obj = defoma_id_open_cache($cache, $app);
unless ($obj) {
$cache = '#DEFAULT#' if ($cache eq '');
printw("id-cache $app/$cache not found.");
exit ERROR;
}
mylock(1);
init_all();
if ($com eq 'unset') {
defoma_id_unset($obj, $id, $font);
} else {
defoma_id_set($obj, $id, $font, $com);
}
term_all();
defoma_id_close_cache($obj);
mylock(0);
exit 0;
}
sub com_id_alias {
my $com = shift;
usage_and_exit if ($com eq 'add-alias' && @ARGV < 4);
usage_and_exit if ($com eq 'remove-alias' && @ARGV < 3);
my $appcache = shift(@ARGV);
my $id = shift(@ARGV);
my $font = shift(@ARGV);
my $alias = shift(@ARGV);
my $app;
my $cache;
if ($appcache =~ /^([^\/]+)\/(.*)/) {
$app = $1;
$cache = $2;
$cache = '' if ($cache eq '#DEFAULT#');
} else {
$app = $appcache;
$cache = '';
}
my $obj = defoma_id_open_cache($cache, $app);
unless ($obj) {
$cache = '#DEFAULT#' if ($cache eq '');
printw("id-cache $app/$cache not found.");
exit ERROR;
}
unless (exists($obj->{hash01}->{$id . ' ' . $font})) {
printw("id/font $id/$font not found.");
exit ERROR;
}
my $i = $obj->{hash01}->{$id . ' ' . $font};
if ($com eq 'add-alias') {
my $pri = $obj->{3}->[$i];
my $ctg = $obj->{4}->[$i];
mylock(1);
init_all();
defoma_id_register($obj, type => 'useralias', id => $alias,
font => $font, priority => $pri,
category => $ctg, origin => $id);
} else {
if ($obj->{2}->[$i] !~ /^Ua/) {
printw("id $id is not user-defined alias.");
exit ERROR;
}
mylock(1);
init_all();
defoma_id_unregister($obj, type => 'useralias', id => $id,
font => $font);
}
term_all();
defoma_id_close_cache($obj);
mylock(0);
exit 0;
}
sub main {
my $command = shift;
if ($command eq 'list-cache') {
com_id_list_cache();
} elsif ($command eq 'install' || $command eq 'exclude') {
com_id_common($command);
} elsif ($command eq 'unset') {
com_id_common('unset');
} elsif ($command eq 'add-alias' || $command eq 'remove-alias') {
com_id_alias($command);
}
}
1;
|