LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 result.append(u'\n'); | 86 result.append(u'\n'); |
87 } | 87 } |
88 return result; | 88 return result; |
89 } | 89 } |
90 | 90 |
91 Subscription* Subscription::FromID(const String& id) | 91 Subscription* Subscription::FromID(const String& id) |
92 { | 92 { |
93 if (id.empty()) | 93 if (id.empty()) |
94 { | 94 { |
95 // Generate a new random ID | 95 // Generate a new random ID |
96 unsigned seed = knownSubscriptions.size(); | 96 unsigned int seed = knownSubscriptions.size(); |
97 OwnedString randomID(u"~user~000000"_str); | 97 OwnedString randomID(u"~user~000000"_str); |
98 do | 98 do |
99 { | 99 { |
100 int number = rand_r(&seed); | 100 int number = rand_r(&seed); |
101 for (int i = randomID.length() - 6; i < randomID.length(); i++) | 101 for (int i = randomID.length() - 6; i < randomID.length(); i++) |
102 { | 102 { |
103 randomID[i] = '0' + (number % 10); | 103 randomID[i] = '0' + (number % 10); |
104 number /= 10; | 104 number /= 10; |
105 } | 105 } |
106 } while (knownSubscriptions.find(randomID)); | 106 } while (knownSubscriptions.find(randomID)); |
(...skipping 15 matching lines...) Expand all Loading... |
122 | 122 |
123 // This is a hack: we looked up the entry using id but create it using | 123 // This is a hack: we looked up the entry using id but create it using |
124 // subscription->mID. This works because both are equal at this point. | 124 // subscription->mID. This works because both are equal at this point. |
125 // However, id refers to a temporary buffer which will go away. | 125 // However, id refers to a temporary buffer which will go away. |
126 enter_context("Adding to known subscriptions"); | 126 enter_context("Adding to known subscriptions"); |
127 knownSubscription.assign(subscription->mID, subscription.get()); | 127 knownSubscription.assign(subscription->mID, subscription.get()); |
128 exit_context(); | 128 exit_context(); |
129 | 129 |
130 return subscription.release(); | 130 return subscription.release(); |
131 } | 131 } |
LEFT | RIGHT |