Subversion Repositories php_utils

Rev

Rev 36 | Rev 38 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36 Rev 37
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 * ISO/IEC 7816-5 Application Identifier decoder for PHP
4
 * ISO/IEC 7816-5 Application Identifier decoder for PHP
5
 * Copyright 2022 Daniel Marschall, ViaThinkSoft
5
 * Copyright 2022 Daniel Marschall, ViaThinkSoft
6
 * Version 2022-07-31
6
 * Version 2022-08-17
7
 *
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
10
 * You may obtain a copy of the License at
11
 *
11
 *
Line 575... Line 575...
575
        if (strlen($aid) > 1) {
575
        if (strlen($aid) > 1) {
576
                $out[] = array(" ".substr($aid,1), "Unknown composition");
576
                $out[] = array(" ".substr($aid,1), "Unknown composition");
577
        }
577
        }
578
        return $out;
578
        return $out;
579
}
579
}
-
 
580
 
-
 
581
/* --- Small extra function: not part of the decoder --- */
-
 
582
 
-
 
583
function aid_split_rid_pix($a, &$rid=null, &$pix=null) {
-
 
584
        // "Quick'n'Dirty" function which does not do any consistency checks!
-
 
585
        // It expects that the string is a valid AID!
-
 
586
 
-
 
587
        $cat = substr($a,0,1);
-
 
588
        if (is_numeric($cat)) {
-
 
589
                $p = strpos($a,'F');
-
 
590
                if ($p%2 != 0) $p++;
-
 
591
        } else if (($cat == 'A') || ($cat == 'D')) {
-
 
592
                $p = 10;
-
 
593
        } else if ($cat == 'F') {
-
 
594
                $p = 1;
-
 
595
        } else {
-
 
596
                $p = 0;
-
 
597
        }
-
 
598
 
-
 
599
        if ($rid !== null) $rid = substr($a, 0, $p);
-
 
600
        if ($pix !== null) $pix = substr($a, $p);
-
 
601
 
-
 
602
        return $p;
-
 
603
}