From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- files/ru/generating_guids/index.html | 75 ++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 files/ru/generating_guids/index.html (limited to 'files/ru/generating_guids/index.html') diff --git a/files/ru/generating_guids/index.html b/files/ru/generating_guids/index.html new file mode 100644 index 0000000000..c618a7d72c --- /dev/null +++ b/files/ru/generating_guids/index.html @@ -0,0 +1,75 @@ +--- +title: Генерация GUID'ов +slug: Generating_GUIDs +translation_of: Mozilla/Tech/XPCOM/Generating_GUIDs +--- +

GUIDs are used in Mozilla programming for identifying several types of entities, including XPCOM Interfaces (this type of GUIDs is callled IID), components (CID), and legacy add-ons—like extensions and themes—that were created prior to Firefox 1.5. Add-ons can (and should) be identified with IDs of the form extensionname@organization.tld since Firefox 1.5.

+

+

Предупреждение: If you just want an ID for your add-on, generating a GUID is almost definitely not what you want to do. Using the extensionname@organization.tld form is approximately one thousand times easier for everyone involved. Don't have a domain name? Do you have a blog on a subdomain? Use that. If all else fails, using extensionname@yourusername.addons.mozilla.org should be fine; no one will care. Remember, these are identifiers, not e-mail addresses, and they're never resolved.

+

+

Canonical form

+

The common form of a GUID is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx, where each x stands for a hexadecimal digit. There are a number of tools that can be used to generate a GUID in the canonical form.

+
+

Note: If you do choose to use an email-style ID for your add-on, you probably don't want it to be a real email address, since it might attract spam.

+
+

Online tools

+ +

Windows

+

Пользвоатели Windows могут использовать утилиту GuidGen от Microsoft для получения GUID. (Эта утилита является частью MS Visual C++)

+

Linux

+

Используйте /usr/bin/uuidgen. Является частью пакета libuuid1 (Debian).

+

Mac OS X

+

Используйте /usr/bin/uuidgen.

+

Perl

+ +

nsIUUIDGenerator

+

A UUID can be generated from privileged Mozilla code using nsIUUIDGenerator. See the linked page for details.

+

Формат COM/XPCOM

+

Используя #define для IID и CID в коде Mozilla C++, вы должны использовать следующий формат:

+
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
+#define NS_...ID \
+{ 0xXXXXXXXX, 0xXXXX, 0xXXXX, \
+  { 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX } }
+
+

You can generate code in this format using one of the following tools.

+

Онлайн утилита

+ +

guidgen

+

guidgen.exe, часть Microsoft Visual Studio, может генерировать UUID в нужном формате.

+

bash

+

Можете добавить в файл .bashrc следующий код:

+
uuidgen-c++()
+{
+    local UUID=$(uuidgen)
+    echo "// $UUID"
+    echo "#define NS__IID \\"
+    echo "{ 0x${UUID:0:8}, 0x${UUID:9:4}, 0x${UUID:14:4}, \\"
+    echo -n "  { 0x${UUID:19:2}, 0x${UUID:21:2}, 0x${UUID:24:2}, "
+    echo -n "0x${UUID:26:2}, 0x${UUID:28:2}, 0x${UUID:30:2}, "
+    echo "0x${UUID:32:2}, 0x${UUID:34:2} } }"
+}
+
+

Perl

+
#!/usr/bin/perl
+$uuid = `uuidgen`;
+chomp $uuid;
+print $uuid, "\n";
+@parts = ($uuid =~ /^(.{8})-(.{4})-(.{4})-(..)(..)-(..)(..)(..)(..)(..)(..)$/);
+print "{ 0x$parts[0], 0x$parts[1], 0x$parts[2], \\", "\n", " { ";
+for (3 .. 9) {
+  print "0x$parts[$_], ";
+}
+print "0x$parts[10] } }", "\n";
+
+
+  
-- cgit v1.2.3-54-g00ecf