Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
5f87fa53
Commit
5f87fa53
authored
Aug 24, 2010
by
Damjan Jovanovic
Committed by
Alexandre Julliard
Aug 25, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winemenubuilder: Move utility functions to the top of the file.
parent
f7b2add8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
128 additions
and
127 deletions
+128
-127
winemenubuilder.c
programs/winemenubuilder/winemenubuilder.c
+128
-127
No files found.
programs/winemenubuilder/winemenubuilder.c
View file @
5f87fa53
...
...
@@ -171,6 +171,134 @@ static char *xdg_desktop_dir;
static
WCHAR
*
assoc_query
(
ASSOCSTR
assocStr
,
LPCWSTR
name
,
LPCWSTR
extra
);
static
HRESULT
open_icon
(
LPCWSTR
filename
,
int
index
,
BOOL
bWait
,
IStream
**
ppStream
);
/* Utility routines */
static
unsigned
short
crc16
(
const
char
*
string
)
{
unsigned
short
crc
=
0
;
int
i
,
j
,
xor_poly
;
for
(
i
=
0
;
string
[
i
]
!=
0
;
i
++
)
{
char
c
=
string
[
i
];
for
(
j
=
0
;
j
<
8
;
c
>>=
1
,
j
++
)
{
xor_poly
=
(
c
^
crc
)
&
1
;
crc
>>=
1
;
if
(
xor_poly
)
crc
^=
0xa001
;
}
}
return
crc
;
}
static
char
*
strdupA
(
const
char
*
str
)
{
char
*
ret
;
if
(
!
str
)
return
NULL
;
if
((
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
str
)
+
1
)))
strcpy
(
ret
,
str
);
return
ret
;
}
static
char
*
heap_printf
(
const
char
*
format
,
...)
{
va_list
args
;
int
size
=
4096
;
char
*
buffer
,
*
ret
;
int
n
;
va_start
(
args
,
format
);
while
(
1
)
{
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
if
(
buffer
==
NULL
)
break
;
n
=
vsnprintf
(
buffer
,
size
,
format
,
args
);
if
(
n
==
-
1
)
size
*=
2
;
else
if
(
n
>=
size
)
size
=
n
+
1
;
else
break
;
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
va_end
(
args
);
if
(
!
buffer
)
return
NULL
;
ret
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
buffer
,
strlen
(
buffer
)
+
1
);
if
(
!
ret
)
ret
=
buffer
;
return
ret
;
}
static
void
write_xml_text
(
FILE
*
file
,
const
char
*
text
)
{
int
i
;
for
(
i
=
0
;
text
[
i
];
i
++
)
{
if
(
text
[
i
]
==
'&'
)
fputs
(
"&"
,
file
);
else
if
(
text
[
i
]
==
'<'
)
fputs
(
"<"
,
file
);
else
if
(
text
[
i
]
==
'>'
)
fputs
(
">"
,
file
);
else
if
(
text
[
i
]
==
'\''
)
fputs
(
"'"
,
file
);
else
if
(
text
[
i
]
==
'"'
)
fputs
(
"""
,
file
);
else
fputc
(
text
[
i
],
file
);
}
}
static
BOOL
create_directories
(
char
*
directory
)
{
BOOL
ret
=
TRUE
;
int
i
;
for
(
i
=
0
;
directory
[
i
];
i
++
)
{
if
(
i
>
0
&&
directory
[
i
]
==
'/'
)
{
directory
[
i
]
=
0
;
mkdir
(
directory
,
0777
);
directory
[
i
]
=
'/'
;
}
}
if
(
mkdir
(
directory
,
0777
)
&&
errno
!=
EEXIST
)
ret
=
FALSE
;
return
ret
;
}
static
char
*
wchars_to_utf8_chars
(
LPCWSTR
string
)
{
char
*
ret
;
INT
size
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
string
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
if
(
ret
)
WideCharToMultiByte
(
CP_UTF8
,
0
,
string
,
-
1
,
ret
,
size
,
NULL
,
NULL
);
return
ret
;
}
static
char
*
wchars_to_unix_chars
(
LPCWSTR
string
)
{
char
*
ret
;
INT
size
=
WideCharToMultiByte
(
CP_UNIXCP
,
0
,
string
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
if
(
ret
)
WideCharToMultiByte
(
CP_UNIXCP
,
0
,
string
,
-
1
,
ret
,
size
,
NULL
,
NULL
);
return
ret
;
}
static
WCHAR
*
utf8_chars_to_wchars
(
LPCSTR
string
)
{
WCHAR
*
ret
;
INT
size
=
MultiByteToWideChar
(
CP_UTF8
,
0
,
string
,
-
1
,
NULL
,
0
);
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
*
sizeof
(
WCHAR
));
if
(
ret
)
MultiByteToWideChar
(
CP_UTF8
,
0
,
string
,
-
1
,
ret
,
size
);
return
ret
;
}
/* Icon extraction routines
*
* FIXME: should use PrivateExtractIcons and friends
...
...
@@ -629,133 +757,6 @@ static HRESULT open_icon(LPCWSTR filename, int index, BOOL bWait, IStream **ppSt
return
hr
;
}
static
unsigned
short
crc16
(
const
char
*
string
)
{
unsigned
short
crc
=
0
;
int
i
,
j
,
xor_poly
;
for
(
i
=
0
;
string
[
i
]
!=
0
;
i
++
)
{
char
c
=
string
[
i
];
for
(
j
=
0
;
j
<
8
;
c
>>=
1
,
j
++
)
{
xor_poly
=
(
c
^
crc
)
&
1
;
crc
>>=
1
;
if
(
xor_poly
)
crc
^=
0xa001
;
}
}
return
crc
;
}
static
char
*
strdupA
(
const
char
*
str
)
{
char
*
ret
;
if
(
!
str
)
return
NULL
;
if
((
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
str
)
+
1
)))
strcpy
(
ret
,
str
);
return
ret
;
}
static
char
*
heap_printf
(
const
char
*
format
,
...)
{
va_list
args
;
int
size
=
4096
;
char
*
buffer
,
*
ret
;
int
n
;
va_start
(
args
,
format
);
while
(
1
)
{
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
if
(
buffer
==
NULL
)
break
;
n
=
vsnprintf
(
buffer
,
size
,
format
,
args
);
if
(
n
==
-
1
)
size
*=
2
;
else
if
(
n
>=
size
)
size
=
n
+
1
;
else
break
;
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
va_end
(
args
);
if
(
!
buffer
)
return
NULL
;
ret
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
buffer
,
strlen
(
buffer
)
+
1
);
if
(
!
ret
)
ret
=
buffer
;
return
ret
;
}
static
void
write_xml_text
(
FILE
*
file
,
const
char
*
text
)
{
int
i
;
for
(
i
=
0
;
text
[
i
];
i
++
)
{
if
(
text
[
i
]
==
'&'
)
fputs
(
"&"
,
file
);
else
if
(
text
[
i
]
==
'<'
)
fputs
(
"<"
,
file
);
else
if
(
text
[
i
]
==
'>'
)
fputs
(
">"
,
file
);
else
if
(
text
[
i
]
==
'\''
)
fputs
(
"'"
,
file
);
else
if
(
text
[
i
]
==
'"'
)
fputs
(
"""
,
file
);
else
fputc
(
text
[
i
],
file
);
}
}
static
BOOL
create_directories
(
char
*
directory
)
{
BOOL
ret
=
TRUE
;
int
i
;
for
(
i
=
0
;
directory
[
i
];
i
++
)
{
if
(
i
>
0
&&
directory
[
i
]
==
'/'
)
{
directory
[
i
]
=
0
;
mkdir
(
directory
,
0777
);
directory
[
i
]
=
'/'
;
}
}
if
(
mkdir
(
directory
,
0777
)
&&
errno
!=
EEXIST
)
ret
=
FALSE
;
return
ret
;
}
static
char
*
wchars_to_utf8_chars
(
LPCWSTR
string
)
{
char
*
ret
;
INT
size
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
string
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
if
(
ret
)
WideCharToMultiByte
(
CP_UTF8
,
0
,
string
,
-
1
,
ret
,
size
,
NULL
,
NULL
);
return
ret
;
}
static
char
*
wchars_to_unix_chars
(
LPCWSTR
string
)
{
char
*
ret
;
INT
size
=
WideCharToMultiByte
(
CP_UNIXCP
,
0
,
string
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
if
(
ret
)
WideCharToMultiByte
(
CP_UNIXCP
,
0
,
string
,
-
1
,
ret
,
size
,
NULL
,
NULL
);
return
ret
;
}
static
WCHAR
*
utf8_chars_to_wchars
(
LPCSTR
string
)
{
WCHAR
*
ret
;
INT
size
=
MultiByteToWideChar
(
CP_UTF8
,
0
,
string
,
-
1
,
NULL
,
0
);
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
*
sizeof
(
WCHAR
));
if
(
ret
)
MultiByteToWideChar
(
CP_UTF8
,
0
,
string
,
-
1
,
ret
,
size
);
return
ret
;
}
/* extract an icon from an exe or icon file; helper for IPersistFile_fnSave */
static
char
*
extract_icon
(
LPCWSTR
path
,
int
index
,
const
char
*
destFilename
,
BOOL
bWait
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment