Commit 18607dcb7ce42da3e36f1c9bf6c77f28ebf293c8
1 parent
96d30e48
added cutils.c
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2310 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
6 changed files
with
91 additions
and
91 deletions
Makefile
@@ -39,7 +39,7 @@ subdir-%: dyngen$(EXESUF) | @@ -39,7 +39,7 @@ subdir-%: dyngen$(EXESUF) | ||
39 | 39 | ||
40 | recurse-all: $(patsubst %,subdir-%, $(TARGET_DIRS)) | 40 | recurse-all: $(patsubst %,subdir-%, $(TARGET_DIRS)) |
41 | 41 | ||
42 | -qemu-img$(EXESUF): qemu-img.c block.c block-raw.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c block-dmg.c block-bochs.c block-vpc.c block-vvfat.c block-qcow2.c | 42 | +qemu-img$(EXESUF): qemu-img.c cutils.c block.c block-raw.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c block-dmg.c block-bochs.c block-vpc.c block-vvfat.c block-qcow2.c |
43 | $(CC) -DQEMU_TOOL $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^ -lz $(LIBS) | 43 | $(CC) -DQEMU_TOOL $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^ -lz $(LIBS) |
44 | 44 | ||
45 | dyngen$(EXESUF): dyngen.c | 45 | dyngen$(EXESUF): dyngen.c |
Makefile.target
@@ -300,6 +300,7 @@ endif | @@ -300,6 +300,7 @@ endif | ||
300 | 300 | ||
301 | # must use static linking to avoid leaving stuff in virtual address space | 301 | # must use static linking to avoid leaving stuff in virtual address space |
302 | VL_OBJS=vl.o osdep.o readline.o monitor.o pci.o console.o loader.o isa_mmio.o | 302 | VL_OBJS=vl.o osdep.o readline.o monitor.o pci.o console.o loader.o isa_mmio.o |
303 | +VL_OBJS+=cutils.o | ||
303 | VL_OBJS+=block.o block-raw.o | 304 | VL_OBJS+=block.o block-raw.o |
304 | VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o block-qcow2.o | 305 | VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o block-qcow2.o |
305 | ifdef CONFIG_WIN32 | 306 | ifdef CONFIG_WIN32 |
cutils.c
0 → 100644
1 | +/* | ||
2 | + * Simple C functions to supplement the C library | ||
3 | + * | ||
4 | + * Copyright (c) 2006 Fabrice Bellard | ||
5 | + * | ||
6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
7 | + * of this software and associated documentation files (the "Software"), to deal | ||
8 | + * in the Software without restriction, including without limitation the rights | ||
9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
10 | + * copies of the Software, and to permit persons to whom the Software is | ||
11 | + * furnished to do so, subject to the following conditions: | ||
12 | + * | ||
13 | + * The above copyright notice and this permission notice shall be included in | ||
14 | + * all copies or substantial portions of the Software. | ||
15 | + * | ||
16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
19 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
22 | + * THE SOFTWARE. | ||
23 | + */ | ||
24 | +#include "vl.h" | ||
25 | + | ||
26 | +void pstrcpy(char *buf, int buf_size, const char *str) | ||
27 | +{ | ||
28 | + int c; | ||
29 | + char *q = buf; | ||
30 | + | ||
31 | + if (buf_size <= 0) | ||
32 | + return; | ||
33 | + | ||
34 | + for(;;) { | ||
35 | + c = *str++; | ||
36 | + if (c == 0 || q >= buf + buf_size - 1) | ||
37 | + break; | ||
38 | + *q++ = c; | ||
39 | + } | ||
40 | + *q = '\0'; | ||
41 | +} | ||
42 | + | ||
43 | +/* strcat and truncate. */ | ||
44 | +char *pstrcat(char *buf, int buf_size, const char *s) | ||
45 | +{ | ||
46 | + int len; | ||
47 | + len = strlen(buf); | ||
48 | + if (len < buf_size) | ||
49 | + pstrcpy(buf + len, buf_size - len, s); | ||
50 | + return buf; | ||
51 | +} | ||
52 | + | ||
53 | +int strstart(const char *str, const char *val, const char **ptr) | ||
54 | +{ | ||
55 | + const char *p, *q; | ||
56 | + p = str; | ||
57 | + q = val; | ||
58 | + while (*q != '\0') { | ||
59 | + if (*p != *q) | ||
60 | + return 0; | ||
61 | + p++; | ||
62 | + q++; | ||
63 | + } | ||
64 | + if (ptr) | ||
65 | + *ptr = p; | ||
66 | + return 1; | ||
67 | +} | ||
68 | + | ||
69 | +int stristart(const char *str, const char *val, const char **ptr) | ||
70 | +{ | ||
71 | + const char *p, *q; | ||
72 | + p = str; | ||
73 | + q = val; | ||
74 | + while (*q != '\0') { | ||
75 | + if (toupper(*p) != toupper(*q)) | ||
76 | + return 0; | ||
77 | + p++; | ||
78 | + q++; | ||
79 | + } | ||
80 | + if (ptr) | ||
81 | + *ptr = p; | ||
82 | + return 1; | ||
83 | +} |
qemu-img.c
@@ -62,49 +62,6 @@ char *qemu_strdup(const char *str) | @@ -62,49 +62,6 @@ char *qemu_strdup(const char *str) | ||
62 | return ptr; | 62 | return ptr; |
63 | } | 63 | } |
64 | 64 | ||
65 | -void pstrcpy(char *buf, int buf_size, const char *str) | ||
66 | -{ | ||
67 | - int c; | ||
68 | - char *q = buf; | ||
69 | - | ||
70 | - if (buf_size <= 0) | ||
71 | - return; | ||
72 | - | ||
73 | - for(;;) { | ||
74 | - c = *str++; | ||
75 | - if (c == 0 || q >= buf + buf_size - 1) | ||
76 | - break; | ||
77 | - *q++ = c; | ||
78 | - } | ||
79 | - *q = '\0'; | ||
80 | -} | ||
81 | - | ||
82 | -/* strcat and truncate. */ | ||
83 | -char *pstrcat(char *buf, int buf_size, const char *s) | ||
84 | -{ | ||
85 | - int len; | ||
86 | - len = strlen(buf); | ||
87 | - if (len < buf_size) | ||
88 | - pstrcpy(buf + len, buf_size - len, s); | ||
89 | - return buf; | ||
90 | -} | ||
91 | - | ||
92 | -int strstart(const char *str, const char *val, const char **ptr) | ||
93 | -{ | ||
94 | - const char *p, *q; | ||
95 | - p = str; | ||
96 | - q = val; | ||
97 | - while (*q != '\0') { | ||
98 | - if (*p != *q) | ||
99 | - return 0; | ||
100 | - p++; | ||
101 | - q++; | ||
102 | - } | ||
103 | - if (ptr) | ||
104 | - *ptr = p; | ||
105 | - return 1; | ||
106 | -} | ||
107 | - | ||
108 | void term_printf(const char *fmt, ...) | 65 | void term_printf(const char *fmt, ...) |
109 | { | 66 | { |
110 | va_list ap; | 67 | va_list ap; |
vl.c
@@ -306,49 +306,6 @@ void isa_unassign_ioport(int start, int length) | @@ -306,49 +306,6 @@ void isa_unassign_ioport(int start, int length) | ||
306 | 306 | ||
307 | /***********************************************************/ | 307 | /***********************************************************/ |
308 | 308 | ||
309 | -void pstrcpy(char *buf, int buf_size, const char *str) | ||
310 | -{ | ||
311 | - int c; | ||
312 | - char *q = buf; | ||
313 | - | ||
314 | - if (buf_size <= 0) | ||
315 | - return; | ||
316 | - | ||
317 | - for(;;) { | ||
318 | - c = *str++; | ||
319 | - if (c == 0 || q >= buf + buf_size - 1) | ||
320 | - break; | ||
321 | - *q++ = c; | ||
322 | - } | ||
323 | - *q = '\0'; | ||
324 | -} | ||
325 | - | ||
326 | -/* strcat and truncate. */ | ||
327 | -char *pstrcat(char *buf, int buf_size, const char *s) | ||
328 | -{ | ||
329 | - int len; | ||
330 | - len = strlen(buf); | ||
331 | - if (len < buf_size) | ||
332 | - pstrcpy(buf + len, buf_size - len, s); | ||
333 | - return buf; | ||
334 | -} | ||
335 | - | ||
336 | -int strstart(const char *str, const char *val, const char **ptr) | ||
337 | -{ | ||
338 | - const char *p, *q; | ||
339 | - p = str; | ||
340 | - q = val; | ||
341 | - while (*q != '\0') { | ||
342 | - if (*p != *q) | ||
343 | - return 0; | ||
344 | - p++; | ||
345 | - q++; | ||
346 | - } | ||
347 | - if (ptr) | ||
348 | - *ptr = p; | ||
349 | - return 1; | ||
350 | -} | ||
351 | - | ||
352 | void cpu_outb(CPUState *env, int addr, int val) | 309 | void cpu_outb(CPUState *env, int addr, int val) |
353 | { | 310 | { |
354 | #ifdef DEBUG_IOPORT | 311 | #ifdef DEBUG_IOPORT |
vl.h
@@ -102,6 +102,12 @@ static inline char *realpath(const char *path, char *resolved_path) | @@ -102,6 +102,12 @@ static inline char *realpath(const char *path, char *resolved_path) | ||
102 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) | 102 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) |
103 | #endif | 103 | #endif |
104 | 104 | ||
105 | +/* cutils.c */ | ||
106 | +void pstrcpy(char *buf, int buf_size, const char *str); | ||
107 | +char *pstrcat(char *buf, int buf_size, const char *s); | ||
108 | +int strstart(const char *str, const char *val, const char **ptr); | ||
109 | +int stristart(const char *str, const char *val, const char **ptr); | ||
110 | + | ||
105 | /* vl.c */ | 111 | /* vl.c */ |
106 | uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c); | 112 | uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c); |
107 | 113 | ||
@@ -109,10 +115,6 @@ void hw_error(const char *fmt, ...); | @@ -109,10 +115,6 @@ void hw_error(const char *fmt, ...); | ||
109 | 115 | ||
110 | extern const char *bios_dir; | 116 | extern const char *bios_dir; |
111 | 117 | ||
112 | -void pstrcpy(char *buf, int buf_size, const char *str); | ||
113 | -char *pstrcat(char *buf, int buf_size, const char *s); | ||
114 | -int strstart(const char *str, const char *val, const char **ptr); | ||
115 | - | ||
116 | extern int vm_running; | 118 | extern int vm_running; |
117 | 119 | ||
118 | typedef struct vm_change_state_entry VMChangeStateEntry; | 120 | typedef struct vm_change_state_entry VMChangeStateEntry; |