/[dtapublic]/to_be_filed/webprojs/php_libraries/php_library/general/suid.inc
ViewVC logotype

Contents of /to_be_filed/webprojs/php_libraries/php_library/general/suid.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 35 - (show annotations) (download)
Sat Oct 8 23:35:33 2016 UTC (7 years, 5 months ago) by dashley
File size: 2569 byte(s)
Initial commit.
1 <?php
2 if (!isset($GENERAL_PUTS_INCLUDED))
3 {
4 include("general/puts.inc");
5 $GENERAL_PUTS_INCLUDED=1;
6 }
7 ?>
8 <?php
9 //********************************************************************************
10 //Copyright (C) 2006 David T. Ashley
11 //********************************************************************************
12 //This program or source file is free software; you can redistribute it and/or
13 //modify it under the terms of the GNU General Public License as published by
14 //the Free Software Foundation; either version 2 of the License, or (at your
15 //option) any later version.
16 //
17 //This program or source file is distributed in the hope that it will
18 //be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 //GNU General Public License for more details.
21 //
22 //You may have received a copy of the GNU General Public License
23 //along with this program; if not, write to the Free Software
24 //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 //********************************************************************************
26 //Dave Ashley, 01/06
27 //
28 //This source file provides the code to create globally-unique identifiers.
29 //The rationale is that since no process can have the same PID at the same
30 //time as another process, using the PID concatenated with a guaranteed
31 //unique time should provide an identifier that can never recur in the lifetime
32 //of the server.
33 //
34 //A SUID is 104 bits of information (26 hexadecimal
35 //digits). The breakdown is:
36 //
37 // a)First 32 bits (8 hexadecimal digits) is the PID. At present, PIDs
38 // are only 16 bits, but in the future (faster systems, etc.) they may be
39 // expanded to 32 bits.
40 //
41 // b)Second 40 bits (10 hexadecimal digits). The integer time, in seconds
42 // since the Unix epoch. The extra 8 bits are reserved due to the impending
43 // Unix 2037 AD issue.
44 //
45 // c)Third 32 bits (8 hexadecimal digits). The nanoseconds representing the
46 // fractional part of the integer seconds.
47 //
48 //Note that both of the data sizes above are designed to allow future
49 //expansion. The integer part is designed for the Unix 2037 issue. The
50 //fractional part is designed for faster hardware in the future.
51 //
52 //
53 function SUID_suid()
54 {
55 return(sprintf("%08X", getmypid()) . PUTS_timestamp());
56 }
57 //
58 //
59 //Returns the size of a SUID (in bytes).
60 //
61 function SUID_suid_size()
62 {
63 return(8 + PUTS_timestamp_size());
64 }
65 ?>

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25