This repository was archived by the owner on Apr 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskolimaUtilz.cpp
97 lines (86 loc) · 2.58 KB
/
skolimaUtilz.cpp
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
/*
written for Imp-GG project
Copyright (C) 2005 Skolima (skolima.prv.pl)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// <code author="Winthux">
#include "stdafx.h"
// </code>
#include "skolimaUtilz.h"
char * cleanupUIDs(char* UIDlist,char* ownerUID)
{
char * list = strtok(UIDlist,";");
char * tokens[1000];
char result[65000];
int arr_pointer = 0;
if(strcmp(list,ownerUID)!=0)tokens[arr_pointer++]=list;
while((list = strtok(NULL, ";")) != NULL)//pociêcie
{
if(strcmp(list,ownerUID)!=0)tokens[arr_pointer++]=list;
}
for(int i=0;i<arr_pointer;i++)//bubble sort
{
bool changed = false;
for(int j=0;j<arr_pointer-1;j++)
{
int compare = strcmp(tokens[j],tokens[j+1]);
if(compare>0)
{
char * tmp = tokens[j];
tokens[j] = tokens[j+1];
tokens[j+1] = tmp;
changed = true;
}
}
if(!changed)break;//bubble sort end
}
for(int i=0;i<arr_pointer-1;i++)//delete duplicates
{
if((tokens[i]!=NULL&&tokens[i+1]!=NULL)&&(strcmp(tokens[i],tokens[i+1])==0))tokens[i+1]=NULL;
}
for(int i=0;i<arr_pointer;i++)//przepisanie
{
if(tokens[i]!=NULL)
if(i==0)sprintf(result,"%s",tokens[i]);
else sprintf(result,"%s;%s",result,tokens[i]);
}
sprintf(UIDlist,"%s",result);
return UIDlist;
}
// zamiana tekstu w char by SIJA
// <code modifyBy="Winthux">
string StringReplace ( string text, const char * srch, char * chg )
{
// szukamy pierwszego pokazania sie 'srch'
size_t index = text.find ( srch );
// pêtelka na dane
while ( index != std::string::npos )
{
// zamieniamy
text.replace ( index, strlen ( srch ), chg );
// szukamy kolejnego
index = text.find ( srch, index + strlen ( chg ) );
}
// zwracamy wynik
return text;
}
string Icon32( int ico )
{
char txt[32];
std::string buff;
sprintf( txt, "reg://IML32/%i.ICON", ico );
buff = AP_IMGURL;
buff += txt;
return buff;
}
// </code>