From 61c1751407b35ed4fe98d5e1e39608c7940349d2 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 9 Sep 2007 22:29:50 +0000 Subject: *** empty log message *** --- src/Makefile.am | 7 +++-- src/add.c | 19 +++++------- src/crc.c | 27 ++++++++++------- src/disk.c | 5 ++-- src/disk.h | 9 +++--- src/entry.c | 49 +++++++++++++++++------------- src/gpt.c | 9 ++++-- src/gpt.h | 19 ++++++++++-- src/guid.c | 22 +++++++++----- src/guid.h | 4 --- src/header.c | 57 +++++++++++++++++++---------------- src/new.c | 57 +++++++++++++++++------------------ src/pmbr.c | 90 ++++++++++++++++++++++++++++++-------------------------- src/project.h | 6 +++- src/prototypes.h | 52 ++++++++++++++++---------------- src/show.c | 35 ++++++++++------------ src/util.c | 38 +++++++++++++----------- src/version.c | 7 +++-- 18 files changed, 282 insertions(+), 230 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 79e36c2..ed73d14 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,9 +5,12 @@ # Copyright (c) 2007 James McKenzie , # All rights reserved. # -# $Id: Makefile.am,v 1.2 2007/09/08 18:21:23 root Exp $ +# $Id: Makefile.am,v 1.3 2007/09/09 22:29:50 root Exp $ # # $Log: Makefile.am,v $ +# Revision 1.3 2007/09/09 22:29:50 root +# *** empty log message *** +# # Revision 1.2 2007/09/08 18:21:23 root # *** empty log message *** # @@ -25,7 +28,7 @@ noinst_HEADERS=project.h prototypes.h bin_PROGRAMS = gpt -SRCS=gpt.c version.c util.c guid.c crc.c header.c +SRCS=gpt.c version.c util.c guid.c crc.c header.c disk.c pmbr.c show.c entry.c new.c add.c gpt_SOURCES = ${SRCS} gpt_LDADD = diff --git a/src/add.c b/src/add.c index fb6bf25..9ffc852 100644 --- a/src/add.c +++ b/src/add.c @@ -2,20 +2,15 @@ -void add(DISK *d,int n,char *guid,int start,int end) +void +add (DISK * d, int n, char *guid, int start, int end) { -GPT_header *h; -GPT_entry *e; + GPT_header *h; + GPT_entry *e; -uint8_t buf[512]; + uint8_t buf[512]; -disk_read(d,buf,1,1); -h=(GPT_header *)buf; + disk_read (d, buf, 1, 1); + h = (GPT_header *) buf; } - - - - - - diff --git a/src/crc.c b/src/crc.c index de1a085..7aceb5c 100644 --- a/src/crc.c +++ b/src/crc.c @@ -55,23 +55,30 @@ static const uint32_t crc_table[256] = { 0x2d02ef8dL }; -#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); +#define DO1(buf) crc = crc_table[(crc ^ (uint32_t) (*buf++)) & 0xff] ^ (crc >> 8); #define DO2(buf) DO1(buf); DO1(buf); #define DO4(buf) DO2(buf); DO2(buf); #define DO8(buf) DO4(buf); DO4(buf); -uint32_t crc32(uint32_t crc, const uint8_t *buf, int len) +uint32_t +crc32 (uint32_t crc, const void *_buf, int len) { - if (!buf) return 0; + uint8_t *buf = (uint8_t *) _buf; + if (!buf) + return 0; - crc = crc ^ 0xffffffffL; - while (len >= 8) + + crc = crc ^ 0xffffffffL; + while (len >= 8) { - DO8(buf); + DO8 (buf); len -= 8; } - if (len) do { - DO1(buf); - } while (--len); - return crc ^ 0xffffffffL; + if (len) + do + { + DO1 (buf); + } + while (--len); + return crc ^ 0xffffffffL; } diff --git a/src/disk.c b/src/disk.c index 8ccaf8e..a36a7df 100644 --- a/src/disk.c +++ b/src/disk.c @@ -67,7 +67,8 @@ disk_write (DISK * d, void *buf, uint64_t lba, int lbas) } } -uint64_t disk_lbas(DISK *d) +uint64_t +disk_lbas (DISK * d) { -return d->lbas; + return d->lbas; } diff --git a/src/disk.h b/src/disk.h index 468813a..fa83f9b 100644 --- a/src/disk.h +++ b/src/disk.h @@ -1,6 +1,7 @@ -typedef struct { - char *name; - int fd; - uint64_t lbas; +typedef struct +{ + char *name; + int fd; + uint64_t lbas; } DISK; diff --git a/src/entry.c b/src/entry.c index 2044813..441e858 100644 --- a/src/entry.c +++ b/src/entry.c @@ -1,40 +1,47 @@ #include "project.h" -void entry_write(DISK *d,GPT_header *h,int n,GPT_entry *e) +void +entry_write (DISK * d, GPT_header * h, int n, GPT_entry * e) { -uint8_t buf[SECTOR_SIZE]; -uint64_t lba=GPT_ENTRY_LBA (h, n); + uint8_t buf[SECTOR_SIZE]; + uint64_t lba = GPT_ENTRY_LBA (h, n); -disk_read (d, buf, lba,1); -memcpy(&buf[GPT_ENTRY_OFFSET(h,n)],e,sizeof(*e)); -disk_write (d, buf, lba, 1); + disk_read (d, buf, lba, 1); + memcpy (&buf[GPT_ENTRY_OFFSET (h, n)], e, sizeof (*e)); + disk_write (d, buf, lba, 1); } -GPT_entry entry_read(DISK *d,GPT_header *h,int n) +GPT_entry +entry_read (DISK * d, GPT_header * h, int n) { -uint8_t buf[SECTOR_SIZE]; -GPT_entry e; + uint8_t buf[SECTOR_SIZE]; + GPT_entry e; -disk_read (d, buf, GPT_ENTRY_LBA (h, n), 1); -memcpy(&e,&buf[GPT_ENTRY_OFFSET(h,n)],sizeof(e)); -return e; + disk_read (d, buf, GPT_ENTRY_LBA (h, n), 1); + memcpy (&e, &buf[GPT_ENTRY_OFFSET (h, n)], sizeof (e)); + return e; } -int entry_empty(GPT_entry *e) { -GUID empty=GUID_TYPE_EMPTY; -return !guid_cmp(&e->type,&empty); +int +entry_empty (GPT_entry * e) +{ + GUID empty = GUID_TYPE_EMPTY; + return !guid_cmp (&e->type, &empty); } -void entry_show(GPT_entry *e) +void +entry_show (GPT_entry * e) { -char name[sizeof(e->name)+1]; + char name[sizeof (e->name) + 1]; -utf16_to_ascii(e->name,sizeof(e->name),name,sizeof(name)); + utf16_to_ascii (e->name, sizeof (e->name), name, sizeof (name)); -printf(" Name %s\n",name); -printf(" Flags %16x Label %s\n",(int) e->flags,guid_to_a(e->label)); -printf(" Start %10lld End %10lld Type %s\n",(long long) e->start,(long long) e->end,guid_to_a(e->type)); + printf (" Name %s\n", name); + printf (" Flags %16x Label %s\n", (int) e->flags, + guid_to_a (e->label)); + printf (" Start %10lld End %10lld Type %s\n", (long long) e->start, + (long long) e->end, guid_to_a (e->type)); } diff --git a/src/gpt.c b/src/gpt.c index 2084fca..2f4aea2 100644 --- a/src/gpt.c +++ b/src/gpt.c @@ -6,10 +6,13 @@ * */ -static char rcsid[] = "$Id: gpt.c,v 1.3 2007/09/09 22:29:50 root Exp $"; +static char rcsid[] = "$Id: gpt.c,v 1.4 2007/09/09 22:30:05 root Exp $"; /* * $Log: gpt.c,v $ + * Revision 1.4 2007/09/09 22:30:05 root + * *** empty log message *** + * * Revision 1.3 2007/09/09 22:29:50 root * *** empty log message *** * @@ -36,8 +39,8 @@ main (int argc, char *argv[]) //new(d); - add(d,1,"linux-ext3",10*1024*2,30*1024*2); - show(d); + add (d, 1, "linux-ext3", 10 * 1024 * 2, 30 * 1024 * 2); + show (d); #if 0 diff --git a/src/gpt.h b/src/gpt.h index 5f1857c..2d1f263 100644 --- a/src/gpt.h +++ b/src/gpt.h @@ -4,6 +4,7 @@ #define GUID_TYPE_LINUX_EXT3 MAKE_GUID(EBD0A0A2,B9E5,4433,87C0,68B6B72699C7) #define GUID_TYPE_LINUX_SWAP MAKE_GUID(0657FD6D,A4AB,43C4,84E5,0933C84B4F4F) #define GUID_TYPE_APPLE_HFS MAKE_GUID(48465300,0000,11AA,AA11,00306543ECAC) +#define GUID_TYPE_APPLE_TV MAKE_GUID(5265636F,7665,11AA,AA11,00306543ECAC) #define GPT_ENTRY_FLAG_SYSTEM 1 typedef struct @@ -18,6 +19,13 @@ typedef struct #define GPT_HEADER_SIGNATURE "EFI PART" #define GPT_HEADER_REVISION_EFI10 0x00010000 +#define GPT_PARITION_ENTRIES 128 +#define SECTOR_SIZE 512 + +#define GPT_ENTRIES_PER_SECTOR(h) (SECTOR_SIZE/((h)->partition_entry_size)) + +#define GPT_ENTRY_LBA(h,n) (((h)->partition_entry_lba)+(uint64_t) ((n)/GPT_ENTRIES_PER_SECTOR(h))) +#define GPT_ENTRY_OFFSET(h,n) (((n)%GPT_ENTRIES_PER_SECTOR(h))*((h)->partition_entry_size)) typedef struct { @@ -25,7 +33,7 @@ typedef struct uint32_t revision; uint32_t header_size; uint32_t header_crc; - uint8_t reserved[20]; + uint8_t reserved[4]; uint64_t my_lba; uint64_t alternate_lba; uint64_t first_usable_lba; @@ -43,11 +51,14 @@ typedef struct #define MBR_PARTITION_TYPE_EFI 0xee #define MBR_PARTITION_BOOTABLE 0x80 +#define MBR_SECTOR(a) ((a) & 0x3f) +#define MBR_CYLINDER(a) (((a) & 0xc0 ) << 2 | (((a)>>8) & 0xff )) +#define MBR_CS(c,s) (((s) & 0x3f) | (((c) & 0xff) <<8 ) | (((c) & 0x300) >> 2)) + typedef struct { uint8_t head; - uint8_t sector; - uint8_t track; + uint16_t cs; } PACKED CHS; typedef struct @@ -60,6 +71,8 @@ typedef struct uint32_t size; } PACKED MBR_entry; +#define MBR_SIGNATURE "\125\252" + typedef struct { uint8_t boot_code[440]; diff --git a/src/guid.c b/src/guid.c index 006c4e2..a4b49be 100644 --- a/src/guid.c +++ b/src/guid.c @@ -7,13 +7,21 @@ static struct known_struct char *name; } known_guids[] = { - { GUID_TYPE_EMPTY, "empty"}, - { GUID_TYPE_SYSTEM, "EFI SYSTEM"}, - { GUID_TYPE_LINUX_EXT3, "linux-ext3"}, - { GUID_TYPE_LINUX_SWAP, "linux-swap"}, - { GUID_TYPE_APPLE_HFS, "apple-hfs"}, - { GUID_TYPE_APPLE_TV, "apple-tv"}, - { { 0}, NULL} + { + GUID_TYPE_EMPTY, "empty"}, + { + GUID_TYPE_SYSTEM, "EFI SYSTEM"}, + { + GUID_TYPE_LINUX_EXT3, "linux-ext3"}, + { + GUID_TYPE_LINUX_SWAP, "linux-swap"}, + { + GUID_TYPE_APPLE_HFS, "apple-hfs"}, + { + GUID_TYPE_APPLE_TV, "apple-tv"}, + { + { + 0}, NULL} }; diff --git a/src/guid.h b/src/guid.h index f92607d..b72cd29 100644 --- a/src/guid.h +++ b/src/guid.h @@ -34,7 +34,3 @@ typedef struct { uint8_t d[16]; } PACKED GUID; - - - - diff --git a/src/header.c b/src/header.c index e92fd5d..4e68934 100644 --- a/src/header.c +++ b/src/header.c @@ -59,7 +59,7 @@ header_calc_ent_crc (DISK * d, GPT_header * h) for (i = 0; i < h->n_partition_entries; ++i) { - e=entry_read(d,h,i); + e = entry_read (d, h, i); crc = crc32 (crc, &e, h->partition_entry_size); } @@ -68,46 +68,51 @@ header_calc_ent_crc (DISK * d, GPT_header * h) void -header_show (DISK *d,GPT_header *h) +header_show (DISK * d, GPT_header * h) { - GPT_header c=*h; + GPT_header c = *h; uint32_t crc; int i; - if (h->my_lbaalternate_lba) { - printf(" GPT:\n"); - } else { - printf(" ALTERNATE GPT:\n"); - } + if (h->my_lba < h->alternate_lba) + { + printf (" GPT:\n"); + } + else + { + printf (" ALTERNATE GPT:\n"); + } - c.header_crc=0; - crc=crc32(0,&c,sizeof(c)); + c.header_crc = 0; + crc = crc32 (0, &c, sizeof (c)); + + printf (" Signature %s, CRC %s\n", + (memcmp (h->signature, GPT_HEADER_SIGNATURE, sizeof (h->signature))) + ? "INVALID" : "valid", + (crc == h->header_crc) ? "matches" : "DOES NOT MATCH"); - printf(" Signature %s, CRC %s\n", - (memcmp(h->signature, GPT_HEADER_SIGNATURE,sizeof(h->signature))) ? "INVALID":"valid", - (crc==h->header_crc) ?"matches":"DOES NOT MATCH"); - printf (" rev=0x%08x lba=%lld alternate=%lld\n", - h->revision, - (long long) h->my_lba, (long long) h->alternate_lba); + h->revision, (long long) h->my_lba, (long long) h->alternate_lba); printf (" usable lbas %lld-%lld\n", (long long) h->first_usable_lba, (long long) h->last_usable_lba); printf (" DISK GUID: %s\n", guid_to_a (h->disk_guid)); - crc=header_calc_ent_crc(d,h); + crc = header_calc_ent_crc (d, h); printf (" patitions (at lba %lld) CRC %s:\n", (long long) h->partition_entry_lba, - (crc == h->partition_entry_crc) ? "matches":"DOES NOT MATCH"); - - for (i=0;in_partition_entries;++i) { - GPT_entry e=entry_read(d,h,i); - if (!entry_empty(&e)) { - printf(" %d:\n",i); - entry_show(&e); - } - } + (crc == h->partition_entry_crc) ? "matches" : "DOES NOT MATCH"); + + for (i = 0; i < h->n_partition_entries; ++i) + { + GPT_entry e = entry_read (d, h, i); + if (!entry_empty (&e)) + { + printf (" %d:\n", i); + entry_show (&e); + } + } } diff --git a/src/new.c b/src/new.c index d8c177f..2d603ff 100644 --- a/src/new.c +++ b/src/new.c @@ -3,45 +3,46 @@ -void new(DISK *d) +void +new (DISK * d) { -uint8_t buf[SECTOR_SIZE]; + uint8_t buf[SECTOR_SIZE]; -MBR m; -GPT_header h,alt_h; -GPT_entry e={0}; -GUID disk_guid; -uint64_t lbas; -int n; + MBR m; + GPT_header h, alt_h; + GPT_entry e = { 0 }; + GUID disk_guid; + uint64_t lbas; + int n; -lbas=disk_lbas(d); + lbas = disk_lbas (d); -disk_guid=guid_random(); + disk_guid = guid_random (); -m=mbr_new(lbas); -memcpy(buf,&m,sizeof(m)); -disk_write(d,buf,0,1); + m = mbr_new (lbas); + memcpy (buf, &m, sizeof (m)); + disk_write (d, buf, 0, 1); -h=header_new ( disk_guid, lbas,0); -alt_h=header_new(disk_guid,lbas,1); + h = header_new (disk_guid, lbas, 0); + alt_h = header_new (disk_guid, lbas, 1); -for (n=0;nbootable, - MBR_CYLINDER(e->chs_start.cs), - e->chs_start.head, - MBR_SECTOR(e->chs_start.cs), - e->start); - -printf(" system %02x end chs %5d/%3d/%2d end sector %10d\n", - e->system, - MBR_CYLINDER(e->chs_end.cs), - e->chs_end.head, - MBR_SECTOR(e->chs_end.cs), - e->size+e->start); + printf (" flags %02x start chs %5d/%3d/%2d start sector %10d\n", + e->bootable, + MBR_CYLINDER (e->chs_start.cs), + e->chs_start.head, MBR_SECTOR (e->chs_start.cs), e->start); + + printf (" system %02x end chs %5d/%3d/%2d end sector %10d\n", + e->system, + MBR_CYLINDER (e->chs_end.cs), + e->chs_end.head, MBR_SECTOR (e->chs_end.cs), e->size + e->start); } -void mbr_show(MBR *m) + +void +mbr_show (MBR * m) { -int i; + int i; -printf(" PMBR:\n"); + printf (" PMBR:\n"); -for (i=0;i<4;++i) { -if (m->entry[i].system) { -printf(" Entry %d:\n",i); -mbr_entry_show(&m->entry[i]); -} -} -if (memcmp(m->signature,MBR_SIGNATURE,sizeof(m->signature))) { -printf(" Signature INVALID\n"); -} else { -printf(" Signature valid\n"); -} + for (i = 0; i < 4; ++i) + { + if (m->entry[i].system) + { + printf (" Entry %d:\n", i); + mbr_entry_show (&m->entry[i]); + } + } + if (memcmp (m->signature, MBR_SIGNATURE, sizeof (m->signature))) + { + printf (" Signature INVALID\n"); + } + else + { + printf (" Signature valid\n"); + } } -MBR mbr_new(uint64_t lbas) +MBR +mbr_new (uint64_t lbas) { -uint64_t cyls=lbas; -MBR ret={0}; + uint64_t cyls = lbas; + MBR ret = { 0 }; -cyls=cyls/(63*255); -if (cyls>1023) cyls=1023; + cyls = cyls / (63 * 255); + if (cyls > 1023) + cyls = 1023; -ret.entry[0].bootable=0; -ret.entry[0].chs_start.cs=MBR_CS(0,1); -ret.entry[0].system=MBR_PARTITION_TYPE_EFI; -ret.entry[0].chs_end.head=254; -ret.entry[0].chs_end.cs=MBR_CS(cyls,63); -ret.entry[0].start=1; -ret.entry[0].size=lbas-1; + ret.entry[0].bootable = 0; + ret.entry[0].chs_start.cs = MBR_CS (0, 1); + ret.entry[0].system = MBR_PARTITION_TYPE_EFI; + ret.entry[0].chs_end.head = 254; + ret.entry[0].chs_end.cs = MBR_CS (cyls, 63); + ret.entry[0].start = 1; + ret.entry[0].size = lbas - 1; -memcpy(ret.signature,MBR_SIGNATURE,sizeof(ret.signature)); + memcpy (ret.signature, MBR_SIGNATURE, sizeof (ret.signature)); -return ret; + return ret; } diff --git a/src/project.h b/src/project.h index d3e7562..0429202 100644 --- a/src/project.h +++ b/src/project.h @@ -7,11 +7,14 @@ */ /* - * $Id: project.h,v 1.2 2007/09/08 18:21:24 root Exp $ + * $Id: project.h,v 1.3 2007/09/09 22:29:50 root Exp $ */ /* * $Log: project.h,v $ + * Revision 1.3 2007/09/09 22:29:50 root + * *** empty log message *** + * * Revision 1.2 2007/09/08 18:21:24 root * *** empty log message *** * @@ -68,6 +71,7 @@ #define PACKED __attribute__((packed)) +#include "disk.h" #include "guid.h" #include "gpt.h" diff --git a/src/prototypes.h b/src/prototypes.h index 630e5c0..6ad5bc8 100644 --- a/src/prototypes.h +++ b/src/prototypes.h @@ -1,38 +1,38 @@ /* gpt.c */ -int main(int argc, char *argv[]); +int main (int argc, char *argv[]); /* version.c */ /* util.c */ -void hexdump(FILE *f, uint8_t *data, int s, int l); -void utf16_to_ascii(uint16_t *u16, int u16_len, uint8_t *u8, int u8_len); +void hexdump (FILE * f, uint8_t * data, int s, int l); +void utf16_to_ascii (uint16_t * u16, int u16_len, uint8_t * u8, int u8_len); /* guid.c */ -int guid_cmp(GUID *a, GUID *b); -char *guid_to_a(GUID g); -int a_to_guid(char *a, GUID *g); -GUID guid_random(void); +int guid_cmp (GUID * a, GUID * b); +char *guid_to_a (GUID g); +int a_to_guid (char *a, GUID * g); +GUID guid_random (void); /* crc.c */ -uint32_t crc32(uint32_t crc, const void *_buf, int len); +uint32_t crc32 (uint32_t crc, const void *_buf, int len); /* header.c */ -void header_calc_crc(GPT_header *h); -GPT_header header_new(GUID disk_guid, int lbas, int alt); -uint32_t header_calc_ent_crc(DISK *d, GPT_header *h); -void header_show(DISK *d, GPT_header *h); +void header_calc_crc (GPT_header * h); +GPT_header header_new (GUID disk_guid, int lbas, int alt); +uint32_t header_calc_ent_crc (DISK * d, GPT_header * h); +void header_show (DISK * d, GPT_header * h); /* disk.c */ -DISK *disk_open(char *fn); -void disk_read(DISK *d, void *buf, uint64_t lba, int lbas); -void disk_write(DISK *d, void *buf, uint64_t lba, int lbas); -uint64_t disk_lbas(DISK *d); +DISK *disk_open (char *fn); +void disk_read (DISK * d, void *buf, uint64_t lba, int lbas); +void disk_write (DISK * d, void *buf, uint64_t lba, int lbas); +uint64_t disk_lbas (DISK * d); /* pmbr.c */ -void mbr_entry_show(MBR_entry *e); -void mbr_show(MBR *m); -MBR mbr_new(uint64_t lbas); +void mbr_entry_show (MBR_entry * e); +void mbr_show (MBR * m); +MBR mbr_new (uint64_t lbas); /* show.c */ -void show(DISK *d); +void show (DISK * d); /* entry.c */ -void entry_write(DISK *d, GPT_header *h, int n, GPT_entry *e); -GPT_entry entry_read(DISK *d, GPT_header *h, int n); -int entry_empty(GPT_entry *e); -void entry_show(GPT_entry *e); +void entry_write (DISK * d, GPT_header * h, int n, GPT_entry * e); +GPT_entry entry_read (DISK * d, GPT_header * h, int n); +int entry_empty (GPT_entry * e); +void entry_show (GPT_entry * e); /* new.c */ -void new(DISK *d); +void new (DISK * d); /* add.c */ -void add(DISK *d, int n, char *guid, int start, int end); +void add (DISK * d, int n, char *guid, int start, int end); diff --git a/src/show.c b/src/show.c index 6297c85..443bd24 100644 --- a/src/show.c +++ b/src/show.c @@ -2,30 +2,25 @@ -void show(DISK *d) +void +show (DISK * d) { -MBR *m; -GPT_header *h; -GPT_entry *e; + MBR *m; + GPT_header *h; + GPT_entry *e; -uint8_t buf[512]; + uint8_t buf[512]; -disk_read(d,buf,0,1); -m=(MBR *)buf; -mbr_show(m); + disk_read (d, buf, 0, 1); + m = (MBR *) buf; + mbr_show (m); -disk_read(d,buf,1,1); -h=(GPT_header *)buf; -header_show(d,h); + disk_read (d, buf, 1, 1); + h = (GPT_header *) buf; + header_show (d, h); -disk_read(d,buf,disk_lbas(d)-1,1); -h=(GPT_header *)buf; -header_show(d,h); + disk_read (d, buf, disk_lbas (d) - 1, 1); + h = (GPT_header *) buf; + header_show (d, h); } - - - - - - diff --git a/src/util.c b/src/util.c index 6fddd57..104a16c 100644 --- a/src/util.c +++ b/src/util.c @@ -52,25 +52,29 @@ hexdump (FILE * f, uint8_t * data, int s, int l) } -void utf16_to_ascii(uint16_t *u16,int u16_len,uint8_t *u8, int u8_len) +void +utf16_to_ascii (uint16_t * u16, int u16_len, uint8_t * u8, int u8_len) { -u16_len >>=1; + u16_len >>= 1; -if (u8_len==1) { - *u8=0; - return; -} -while (*u16 && u16_len) { -*(u8++)=*(u16++); -u16_len--; -u8_len--; + if (u8_len == 1) + { + *u8 = 0; + return; + } + while (*u16 && u16_len) + { + *(u8++) = *(u16++); + u16_len--; + u8_len--; -if (u8_len==1) { - *u8=0; - return; -} -} + if (u8_len == 1) + { + *u8 = 0; + return; + } + } - *u8=0; - return; + *u8 = 0; + return; } diff --git a/src/version.c b/src/version.c index 49ad791..e784248 100644 --- a/src/version.c +++ b/src/version.c @@ -6,10 +6,13 @@ * */ -static char rcsid[] = "$Id: version.c,v 1.1 2007/09/08 16:49:37 root Exp $"; +static char rcsid[] = "$Id: version.c,v 1.2 2007/09/09 22:29:50 root Exp $"; /* * $Log: version.c,v $ + * Revision 1.2 2007/09/09 22:29:50 root + * *** empty log message *** + * * Revision 1.1 2007/09/08 16:49:37 root * *** empty log message *** * @@ -19,7 +22,7 @@ static char rcsid[] = "$Id: version.c,v 1.1 2007/09/08 16:49:37 root Exp $"; #include "version.h" static char * -GetVersion(void) +GetVersion (void) { return VERSION; } -- cgit v1.2.3