From stippi at mail.berlios.de Sun Jul 1 15:09:28 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 1 Jul 2007 15:09:28 +0200 Subject: [Haiku-commits] r21535 - in haiku/trunk: headers/private/audio src/add-ons/kernel/drivers/audio/usb_audio Message-ID: <200707011309.l61D9S1Y031658@sheep.berlios.de> Author: stippi Date: 2007-07-01 15:09:27 +0200 (Sun, 01 Jul 2007) New Revision: 21535 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21535&view=rev Added: haiku/trunk/headers/private/audio/audio_driver.h Removed: haiku/trunk/src/add-ons/kernel/drivers/audio/usb_audio/audio_driver.h Log: * moved R3 audio driver interface definition to private headers along with R3MediaDefs.h Copied: haiku/trunk/headers/private/audio/audio_driver.h (from rev 21534, haiku/trunk/src/add-ons/kernel/drivers/audio/usb_audio/audio_driver.h) Deleted: haiku/trunk/src/add-ons/kernel/drivers/audio/usb_audio/audio_driver.h From stippi at mail.berlios.de Sun Jul 1 15:15:03 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 1 Jul 2007 15:15:03 +0200 Subject: [Haiku-commits] r21536 - in haiku/trunk/src/add-ons/kernel/drivers/audio: . cmedia Message-ID: <200707011315.l61DF3li032110@sheep.berlios.de> Author: stippi Date: 2007-07-01 15:15:01 +0200 (Sun, 01 Jul 2007) New Revision: 21536 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21536&view=rev Added: haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/ haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/Jamfile haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/cm.c haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/cm_private.h haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/cmedia_pci.h haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/joy.c haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/joystick_driver.h haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/midi.c haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/midi_driver.h haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/mixer.c haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/mux.c haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/pcm.c haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/sound.h Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/Jamfile Log: * added C-Media CMI8338/8738-based sound card device driver, it originates from C-Media itself, and was later improved upon by Marko Koscak * includes some fixes by Dr. Hartmut Reh * uses old audio driver API * builds, but I don't know if it works yet. I do have such a card, but on another computer... will check if it works and add it to the image if it does Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/Jamfile 2007-07-01 13:09:27 UTC (rev 21535) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/Jamfile 2007-07-01 13:15:01 UTC (rev 21536) @@ -1,6 +1,7 @@ SubDir HAIKU_TOP src add-ons kernel drivers audio ; SubInclude HAIKU_TOP src add-ons kernel drivers audio ac97 ; +SubInclude HAIKU_TOP src add-ons kernel drivers audio cmedia ; SubInclude HAIKU_TOP src add-ons kernel drivers audio echo ; SubInclude HAIKU_TOP src add-ons kernel drivers audio emuxki ; SubInclude HAIKU_TOP src add-ons kernel drivers audio hda ; Added: haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/Jamfile 2007-07-01 13:09:27 UTC (rev 21535) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/Jamfile 2007-07-01 13:15:01 UTC (rev 21536) @@ -0,0 +1,22 @@ +SubDir HAIKU_TOP src add-ons kernel drivers audio cmedia ; + +SetSubDirSupportedPlatformsBeOSCompatible ; + +UsePrivateHeaders audio ; + +KernelAddon cmedia : + cm.c + joy.c + midi.c + mixer.c + mux.c + pcm.c +; + +Package haiku-cmedia-cvs + : + cmedia + : + boot home config add-ons kernel drivers bin ; + +PackageDriverSymLink haiku-cmedia-cvs : audio cmedia ; Added: haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/cm.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/cm.c 2007-07-01 13:09:27 UTC (rev 21535) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/cm.c 2007-07-01 13:15:01 UTC (rev 21536) @@ -0,0 +1,784 @@ +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. +*/ + +#include "cmedia_pci.h" +#include "cm_private.h" + +#include +#include + +#if !defined(_KERNEL_EXPORT_H) +#include +#endif + + +#if DEBUG +#define KPRINTF(x) kprintf x +#else +#define KPRINTF(x) +#endif + +EXPORT status_t init_hardware(void); +EXPORT status_t init_driver(void); +EXPORT void uninit_driver(void); +EXPORT const char ** publish_devices(void); +EXPORT device_hooks * find_device(const char *); + + +static char pci_name[] = B_PCI_MODULE_NAME; +static pci_module_info *pci; +static char gameport_name[] = "generic/gameport/v1"; +generic_gameport_module * gameport; +static char mpu401_name[] = B_MPU_401_MODULE_NAME; +generic_mpu401_module * mpu401; + +#define DO_JOY 1 +#define DO_MIDI 1 +#define DO_PCM 1 +#define DO_MUX 0 +#define DO_MIXER 0 + +#if DO_MIDI +extern device_hooks midi_hooks; +#endif /* DO_MIDI */ +#if DO_JOY +extern device_hooks joy_hooks; +#endif /* DO_JOY */ +#if DO_PCM +extern device_hooks pcm_hooks; +#endif /* DO_PCM */ +#if DO_MUX +extern device_hooks mux_hooks; +#endif /* DO_MUX */ +#if DO_MIXER +extern device_hooks mixer_hooks; +#endif /* DO_MIXER */ + + +int32 num_cards; +cmedia_pci_dev cards[NUM_CARDS]; +int num_names; +char * names[NUM_CARDS*7+1]; +/* vuchar *io_base; */ + + +/* ---------- + PCI_IO_RD - read a byte from pci i/o space +----- */ + +uint8 +PCI_IO_RD (int offset) +{ + return (*pci->read_io_8) (offset); +} + + +/* ---------- + PCI_IO_RD_32 - read a 32 bit value from pci i/o space +----- */ + +uint32 +PCI_IO_RD_32 (int offset) +{ + return (*pci->read_io_32) (offset); +} +/* ---------- + PCI_IO_WR - write a byte to pci i/o space +----- */ + +void +PCI_IO_WR (int offset, uint8 val) +{ + (*pci->write_io_8) (offset, val); +} + + +/* detect presence of our hardware */ +status_t +init_hardware(void) +{ + int ix=0; + pci_info info; + status_t err = ENODEV; + + ddprintf(("cmedia_pci: init_hardware()\n")); + + if (get_module(pci_name, (module_info **)&pci)) + return ENOSYS; + + while ((*pci->get_nth_pci_info)(ix, &info) == B_OK) { + if (info.vendor_id == CMEDIA_PCI_VENDOR_ID && + (info.device_id == CMEDIA_8338A_DEVICE_ID || + info.device_id == CMEDIA_8338B_DEVICE_ID || + info.device_id == CMEDIA_8738A_DEVICE_ID || + info.device_id == CMEDIA_8738B_DEVICE_ID )) { + err = B_OK; + } + ix++; + } +#if defined(__POWERPC__) && 0 + { + char area_name [32]; + area_info area; + area_id id; + + sprintf (area_name, "pci_bus%d_isa_io", info.bus); + id = find_area (area_name); + if (id < 0) + err = id; + else if ((err = get_area_info (id, &area)) == B_OK) + io_base = area.address; + } +#endif + + put_module(pci_name); + + return err; +} + + +void set_direct( cmedia_pci_dev * card, int regno, uchar value, uchar mask) +{ + if (mask == 0) + { + return; + } + if (mask != 0xff) + { + uchar old = PCI_IO_RD(card->enhanced+regno); + value = (value&mask)|(old&~mask); + } + PCI_IO_WR(card->enhanced+regno, value); + ddprintf(("cmedia_pci: CM%02x = %02x\n", regno, value)); +} + + +uchar get_direct(cmedia_pci_dev * card, int regno) +{ + uchar ret = PCI_IO_RD(card->enhanced+regno); + return ret; +} + + + +void set_indirect(cmedia_pci_dev * card, int regno, uchar value, uchar mask) +{ + PCI_IO_WR(card->enhanced+0x23, regno); + EIEIO(); + if (mask == 0) + { + return; + } + if (mask != 0xff) + { + uchar old = PCI_IO_RD(card->enhanced+0x22); + value = (value&mask)|(old&~mask); + } + PCI_IO_WR(card->enhanced+0x22, value); + EIEIO(); + ddprintf(("cmedia_pci: CMX%02x = %02x\n", regno, value)); +} + + + +uchar get_indirect(cmedia_pci_dev * card,int regno) +{ + uchar ret; + PCI_IO_WR(card->enhanced+0x23, regno); + EIEIO(); + ret = PCI_IO_RD(card->enhanced+0x22); + return ret; +} + + +#if 0 +void dump_card(cmedia_pci_dev * card) +{ + int ix; + dprintf("\n"); + dprintf("CM: "); + for (ix=0; ix<6; ix++) { + if (ix == 2 || ix == 3) dprintf(" "); + else dprintf(" %02x", get_direct(card, ix)); + } + for (ix=0; ix<0x32; ix++) { + if (!(ix & 7)) { + dprintf("\nCMX%02x:", ix); + } + dprintf(" %02x", get_indirect(card, ix)); + } + dprintf("\n"); + dprintf("\n"); +} +#else +void dump_card(cmedia_pci_dev * card) +{ +} +#endif + + +static void +disable_card_interrupts(cmedia_pci_dev * card) +{ + set_direct(card, 0x0e, 0x00, 0x03); +} + + +static status_t +setup_dma(cmedia_pci_dev * card) +{ + /* we're appropriating some ISA space here... */ + /* need kernel support to do it right */ + const uint16 base = card->enhanced+0x80; + ddprintf(("cmedia_pci: dma base is 0x%04x\n", base)); + if(0 == base) + return B_DEV_RESOURCE_CONFLICT; + card->dma_base = base; + return B_OK; +} + + +static void +set_default_registers( + cmedia_pci_dev * card) +{ + static uchar values[] = { +#ifdef DO_JOY + 0x04, 0x02, 0x02, /* enable joystick */ +#endif + + 0x0a, 0x01, 0x01, /* enable SPDIF inverse before SPDIF_LOOP */ + 0x04, 0x80, 0x80, /* enable SPDIF_LOOP */ + + 0x1a, 0x00, 0x20, /* SPD32SEL disable */ + 0x1a, 0x00, 0x10, /* SPDFLOOPI disable */ + + 0x1b, 0x04, 0x04, /* dual channel mode enable */ + 0x1a, 0x00, 0x80, /* Double DAC structure disable */ + + 0x24, 0x00, 0x02, /* 3D surround disable */ + + 0x24, 0x00, 0x01, /* disable SPDIF_IN PCM to DAC */ +#ifdef DO_MIDI + 0x04, 0x04, 0x04, /* enable MPU-401 */ + 0x17, 0x00, 0x60, /* default at 0x330 */ +#endif + }; + uchar * ptr = values; + + while (ptr < values+sizeof(values)) { + set_direct(card, ptr[0], ptr[1], ptr[2]); + ptr += 3; + } +} + + +static void +make_device_names( + cmedia_pci_dev * card) +{ + char * name = card->name; + sprintf(name, "cmedia_pci/%ld", card-cards+1); + +#if DO_MIDI + sprintf(card->midi.name, "midi/%s", name); + names[num_names++] = card->midi.name; +#endif /* DO_MIDI */ +#if DO_JOY + sprintf(card->joy.name1, "joystick/%s", name); + names[num_names++] = card->joy.name1; +#endif /* DO_JOY */ +#if DO_PCM + /* cmedia_pci DMA doesn't work when physical NULL isn't NULL from PCI */ + /* this is a hack to not export bad devices on BeBox hardware */ + if ((*pci->ram_address)(NULL) == NULL) { + sprintf(card->pcm.name, "audio/raw/%s", name); + names[num_names++] = card->pcm.name; + sprintf(card->pcm.oldname, "audio/old/%s", name); + names[num_names++] = card->pcm.oldname; + } +#endif /* DO_PCM */ +#if DO_MUX + sprintf(card->mux.name, "audio/mux/%s", name); + names[num_names++] = card->mux.name; +#endif /* DO_MUX */ +#if DO_MIXER + sprintf(card->mixer.name, "audio/mix/%s", name); + names[num_names++] = card->mixer.name; +#endif /* DO_MIXER */ + names[num_names] = NULL; +} + + +/* We use the SV chip in ISA DMA addressing mode, which is 24 bits */ +/* so we need to find suitable, locked, contiguous memory in that */ +/* physical address range. */ + +static status_t +find_low_memory( + cmedia_pci_dev * card) +{ + size_t low_size = (MIN_MEMORY_SIZE+(B_PAGE_SIZE-1))&~(B_PAGE_SIZE-1); + physical_entry where; + size_t trysize; + area_id curarea; + void * addr; + char name[DEVNAME]; + + sprintf(name, "%s_low", card->name); + if (low_size < MIN_MEMORY_SIZE) { + low_size = MIN_MEMORY_SIZE; + } + trysize = low_size; + + curarea = find_area(name); + if (curarea >= 0) { /* area there from previous run */ + area_info ainfo; + ddprintf(("cmedia_pci: testing likely candidate...\n")); + if (get_area_info(curarea, &ainfo)) { + ddprintf(("cmedia_pci: no info\n")); + goto allocate; + } + /* test area we found */ + trysize = ainfo.size; + addr = ainfo.address; + if (trysize < low_size) { + ddprintf(("cmedia_pci: too small (%lx)\n", trysize)); + goto allocate; + } + if (get_memory_map(addr, trysize, &where, 1) < B_OK) { + ddprintf(("cmedia_pci: no memory map\n")); + goto allocate; + } + if ((uint32)where.address & 0xff000000) { + ddprintf(("cmedia_pci: bad physical address\n")); + goto allocate; + } + if (ainfo.lock < B_FULL_LOCK || where.size < low_size) { + ddprintf(("cmedia_pci: lock not contiguous\n")); + goto allocate; + } +dprintf("cmedia_pci: physical %p logical %p\n", where.address, ainfo.address); + goto a_o_k; + } + +allocate: + if (curarea >= 0) { + delete_area(curarea); /* area didn't work */ + curarea = -1; + } + ddprintf(("cmedia_pci: allocating new low area\n")); + + curarea = create_area(name, &addr, B_ANY_KERNEL_ADDRESS, + trysize, B_LOMEM, B_READ_AREA | B_WRITE_AREA); + ddprintf(("cmedia_pci: create_area(%lx) returned %lx logical %p\n", + trysize, curarea, addr)); + if (curarea < 0) { + goto oops; + } + if (get_memory_map(addr, low_size, &where, 1) < 0) { + delete_area(curarea); + curarea = B_ERROR; + goto oops; + } + ddprintf(("cmedia_pci: physical %p\n", where.address)); + if ((uint32)where.address & 0xff000000) { + delete_area(curarea); + curarea = B_ERROR; + goto oops; + } + if ((((uint32)where.address)+low_size) & 0xff000000) { + delete_area(curarea); + curarea = B_ERROR; + goto oops; + } + /* hey, it worked! */ + if (trysize > low_size) { /* don't waste */ + resize_area(curarea, low_size); + } + +oops: + if (curarea < 0) { + dprintf("cmedia_pci: failed to create low_mem area\n"); + return curarea; + } +a_o_k: + ddprintf(("cmedia_pci: successfully found or created low area!\n")); + card->low_size = low_size; + card->low_mem = addr; + card->low_phys = (vuchar *)where.address; + card->map_low = curarea; + return B_OK; +} + + +static status_t +setup_cmedia_pci( + cmedia_pci_dev * card) +{ + status_t err = B_OK; +/* cpu_status cp; */ + + ddprintf(("cmedia_pci: setup_cmedia_pci(%p)\n", card)); + + if ((card->pcm.init_sem = create_sem(1, "cm pcm init")) < B_OK) + goto bail; +#if 1 + if ((*mpu401->create_device)(0x330, &card->midi.driver, +#else + if ((*mpu401->create_device)(card->info.u.h0.base_registers[3], &card->midi.driver, +#endif + 0, midi_interrupt_op, &card->midi) < B_OK) + goto bail3; +#if 1 + if ((*gameport->create_device)(0x201, &card->joy.driver) < B_OK) +#else + if ((*gameport->create_device)(card->info.u.h0.base_registers[4], &card->joy.driver) < B_OK) +#endif + goto bail4; + ddprintf(("midi %p gameport %p\n", card->midi.driver, card->joy.driver)); + card->midi.card = card; + + err = find_low_memory(card); + if (err < B_OK) { + goto bail5; + } + + //cp = disable_interrupts(); + //acquire_spinlock(&card->hardware); + + make_device_names(card); + card->enhanced = card->info.u.h0.base_registers[0]; + ddprintf(("cmedia_pci: %s enhanced at %x\n", card->name, card->enhanced)); + + ddprintf(("cmedia_pci: revision %x\n", get_indirect(card, 0x15))); + + disable_card_interrupts(card); + if (setup_dma(card) != B_OK) + { + dprintf("cmedia pci: can't setup DMA\n"); + goto bail6; + } + + set_default_registers(card); + + //release_spinlock(&card->hardware); + //restore_interrupts(cp); + + return B_OK; + +bail6: + // deallocate low memory +bail5: + (*gameport->delete_device)(card->joy.driver); +bail4: + (*mpu401->delete_device)(card->midi.driver); +bail3: + delete_sem(card->pcm.init_sem); +bail: + return err < B_OK ? err : B_ERROR; +} + + +static int +debug_cmedia( + int argc, + char * argv[]) +{ + int ix = 0; + if (argc == 2) { + ix = parse_expression(argv[1])-1; + } + if (argc > 2 || ix < 0 || ix >= num_cards) { + dprintf("cmedia_pci: dude, you gotta watch your syntax!\n"); + return -1; + } + dprintf("%s: enhanced registers at 0x%x\n", cards[ix].name, + cards[ix].enhanced); + dprintf("%s: open %ld dma_a at 0x%x dma_c 0x%x\n", cards[ix].pcm.name, + cards[ix].pcm.open_count, cards[ix].pcm.dma_a, cards[ix].pcm.dma_c); + if (cards[ix].pcm.open_count) { + dprintf(" dma_a: 0x%lx+0x%lx dma_c: 0x%lx+0x%lx\n", + PCI_IO_RD_32((int)cards[ix].pcm.dma_a), PCI_IO_RD_32((int)cards[ix].pcm.dma_a+4), + PCI_IO_RD_32((int)cards[ix].pcm.dma_c), PCI_IO_RD_32((int)cards[ix].pcm.dma_c+4)); + } + return 0; +} + + +status_t +init_driver(void) +{ + int ix=0; + pci_info info; + num_cards = 0; + + ddprintf(("cmedia_pci: init_driver()\n")); + load_driver_symbols("cmedia_pci"); + + if (get_module(pci_name, (module_info **) &pci)) + return ENOSYS; + + if (get_module(gameport_name, (module_info **) &gameport)) { + put_module(pci_name); + return ENOSYS; + } + ddprintf(("MPU\n")); + if (get_module(mpu401_name, (module_info **) &mpu401)) { + put_module(gameport_name); + put_module(pci_name); + return ENOSYS; + } + + ddprintf(("MPU: %p\n", mpu401)); + + while ((*pci->get_nth_pci_info)(ix, &info) == B_OK) { + if (info.vendor_id == CMEDIA_PCI_VENDOR_ID && + (info.device_id == CMEDIA_8338A_DEVICE_ID || + info.device_id == CMEDIA_8338B_DEVICE_ID || + info.device_id == CMEDIA_8738A_DEVICE_ID || + info.device_id == CMEDIA_8738B_DEVICE_ID )) { + if (num_cards == NUM_CARDS) { + dprintf("Too many C-Media cards installed!\n"); + break; + } + memset(&cards[num_cards], 0, sizeof(cmedia_pci_dev)); + cards[num_cards].info = info; + if (setup_cmedia_pci(&cards[num_cards])) { + dprintf("Setup of C-Media %ld failed\n", num_cards+1); + } + else { + num_cards++; + } + } + ix++; + } + if (!num_cards) { + KPRINTF(("no cards\n")); + put_module(mpu401_name); + put_module(gameport_name); + put_module(pci_name); + ddprintf(("cmedia_pci: no suitable cards found\n")); + return ENODEV; + } + +#if DEBUG + add_debugger_command("cmedia", debug_cmedia, "cmedia [card# (1-n)]"); +#endif + return B_OK; +} + + +static void +teardown_cmedia_pci( + cmedia_pci_dev * card) +{ + static uchar regs[] = { +#ifdef DO_JOY + 0x04, 0x00, 0x02, /* enable joystick */ +#endif +#ifdef DO_MIDI + 0x04, 0x00, 0x04, /* enable MPU-401 */ +#endif + }; + uchar * ptr = regs; + cpu_status cp; + + /* remove created devices */ + (*gameport->delete_device)(card->joy.driver); + (*mpu401->delete_device)(card->midi.driver); + + cp = disable_interrupts(); + acquire_spinlock(&card->hardware); + + while (ptr < regs+sizeof(regs)) { + set_direct(card, ptr[0], ptr[1], ptr[2]); + ptr += 3; + } + disable_card_interrupts(card); + + release_spinlock(&card->hardware); + restore_interrupts(cp); + + delete_sem(card->pcm.init_sem); +} + + +void +uninit_driver(void) +{ + int ix, cnt = num_cards; + num_cards = 0; + + ddprintf(("cmedia_pci: uninit_driver()\n")); + remove_debugger_command("cmedia", debug_cmedia); + + for (ix=0; ixhardware); + + status = get_direct(card, 0x10); + +#if DEBUG +/* kprintf("%x\n", status); / * */ +#endif +#if DO_PCM + if (status & 0x02) { + if (dma_c_interrupt(card)) { + handled = B_INVOKE_SCHEDULER; + } + else { + handled = B_HANDLED_INTERRUPT; + } + /* acknowledge interrupt */ + set_direct(card, 0x0e, 0x00, 0x02); + set_direct(card, 0x0e, 0x02, 0x02); + } + if (status & 0x01) { + if (dma_a_interrupt(card)) { + handled = B_INVOKE_SCHEDULER; + } + else { + handled = B_HANDLED_INTERRUPT; + } + /* acknowledge interrupt */ + set_direct(card, 0x0e, 0x00, 0x01); + set_direct(card, 0x0e, 0x01, 0x01); + } +#endif +#if DO_MIDI + status = get_direct(card, 0x12); + if (status & 0x01) { + if (midi_interrupt(card)) { + handled = B_INVOKE_SCHEDULER; + } else { + handled = B_HANDLED_INTERRUPT; + } + } +#endif + + /* Sometimes, the Sonic Vibes will receive a byte of Midi data... + ** And duly note it in the MPU401 status register... + ** And generate an interrupt... + ** But not bother setting the midi interrupt bit in the ISR. + ** Thanks a lot, S3. + */ + if(handled == B_UNHANDLED_INTERRUPT){ + if (midi_interrupt(card)) { + handled = B_INVOKE_SCHEDULER; + } + } + +/* KTRACE(); / * */ + release_spinlock(&card->hardware); + restore_interrupts(cp); + + return handled; +// return (handled == B_INVOKE_SCHEDULER) ? B_HANDLED_INTERRUPT : handled; +} + + +void +increment_interrupt_handler( + cmedia_pci_dev * card) +{ + KPRINTF(("cmedia_pci: increment_interrupt_handler()\n")); + if (atomic_add(&card->inth_count, 1) == 0) { + // !!! + KPRINTF(("cmedia_pci: intline %d int %p\n", card->info.u.h0.interrupt_line, cmedia_pci_interrupt)); + install_io_interrupt_handler(card->info.u.h0.interrupt_line, + cmedia_pci_interrupt, card, 0); + } +} + + +void +decrement_interrupt_handler( + cmedia_pci_dev * card) +{ + KPRINTF(("cmedia_pci: decrement_interrupt_handler()\n")); + if (atomic_add(&card->inth_count, -1) == 1) { + KPRINTF(("cmedia_pci: remove_io_interrupt_handler()\n")); + remove_io_interrupt_handler(card->info.u.h0.interrupt_line, cmedia_pci_interrupt, card); + } +} + + Added: haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/cm_private.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/cm_private.h 2007-07-01 13:09:27 UTC (rev 21535) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/cmedia/cm_private.h 2007-07-01 13:15:01 UTC (rev 21536) @@ -0,0 +1,194 @@ +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. +*/ + +#if !defined(_CM_PRIVATE_H) +#define _CM_PRIVATE_H + +#if !defined(_CMEDIA_PCI_H) +#include "cmedia_pci.h" +#endif + +#if !defined(_PCI_H) +#include +#endif + +#if !defined(DEBUG) +#define DEBUG 0 +#endif + + +#define NUM_CARDS 3 +#define DEVNAME 32 + + +#define EXPORT __declspec(dllexport) + +#if defined(__INTEL__) +#define EIEIO() +#elif defined(__POWERPC__) +#define EIEIO() __eieio() +#endif + +#if DEBUG +#define ddprintf(x) dprintf x +#define KTRACE() kprintf("%s %d\n", __FILE__, __LINE__) +#else +#define ddprintf(x) +#define KTRACE() +#endif + +/* neither value may be larger than 65536 */ +#define PLAYBACK_BUF_SIZE 2048 +#define RECORD_BUF_SIZE PLAYBACK_BUF_SIZE +/* always create this much, so larger buffers can be requested */ +#define MIN_MEMORY_SIZE 32768 + +/* clock crystal frequency */ +#define F_REF 24576000 +/* data book says 80 MHz ... */ +#define MIN_FREQ 80000000 +/* tolerance for sample rate clock derivation - book has this at 0.005 */ +#define TOLERANCE 0.001 + +/* there are five logical devices: midi, joystick, pcm, mux and mixer */ + +typedef struct _midi_dev +{ + struct _cmedia_pci_dev *card; + void * driver; + void * cookie; + int32 count; + char name[64]; +} midi_dev; + +typedef struct _joy_dev +{ + void * driver; + char name1[64]; +} joy_dev; + +typedef cmedia_pci_audio_format pcm_cfg; +typedef cmedia_pci_audio_buf_header pcm_buf_hdr; + +enum +{ /* these map to the mode enable bits in the CMX13 register */ + kPlayback = 1, + kRecord = 2 +}; + +typedef struct +{ + struct _cmedia_pci_dev * card; + char name[DEVNAME]; + char oldname[DEVNAME]; + sem_id init_sem; + int32 open_count; + int32 open_mode; + +/* playback from a cyclic, small-ish buffer */ + + int32 wr_lock; + int dma_a; + vuchar * wr_1; + vuchar * wr_2; + vuchar * wr_cur; + size_t wr_size; + int wr_silence; + int32 write_waiting; + sem_id write_sem; + size_t was_written; + uint32 wr_skipped; + sem_id wr_entry; + bigtime_t wr_time; + uint64 wr_total; + sem_id wr_time_sem; + int32 wr_time_wait; + +/* recording into a cyclic, somewhat larger buffer */ + + int32 rd_lock; + int dma_c; + vuchar * rd_1; + vuchar * rd_2; + vuchar * rd_cur; + size_t rd_size; + int32 read_waiting; + sem_id read_sem; + size_t was_read; + bigtime_t next_rd_time; + bigtime_t rd_time; + uint32 rd_skipped; /* count of misses */ + sem_id rd_entry; + uint64 rd_total; + sem_id rd_time_sem; + int32 rd_time_wait; + +/* buffers are owned by the device record (because of allocation) */ + + pcm_cfg config; + + sem_id old_cap_sem; + sem_id old_play_sem; +} pcm_dev; + +typedef struct +{ + struct _cmedia_pci_dev * card; + char name[DEVNAME]; + int32 open_count; +} mux_dev; + +typedef struct +{ + struct _cmedia_pci_dev * card; + char name[DEVNAME]; + int32 open_count; +} mixer_dev; + +typedef struct _cmedia_pci_dev +{ + char name[DEVNAME]; /* used for resources */ + int32 hardware; /* spinlock */ + int enhanced; /* offset to port */ + int32 inth_count; + int dma_base; + size_t low_size; /* size of low memory */ + vuchar * low_mem; + vuchar * low_phys; /* physical address */ + area_id map_low; /* area pointing to low memory */ + pci_info info; + midi_dev midi; + joy_dev joy; + pcm_dev pcm; [... truncated: 3131 lines follow ...] From stippi at mail.berlios.de Sun Jul 1 16:57:42 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 1 Jul 2007 16:57:42 +0200 Subject: [Haiku-commits] r21537 - haiku/trunk/src/kits/interface Message-ID: <200707011457.l61EvgbQ006043@sheep.berlios.de> Author: stippi Date: 2007-07-01 16:57:41 +0200 (Sun, 01 Jul 2007) New Revision: 21537 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21537&view=rev Modified: haiku/trunk/src/kits/interface/Window.cpp Log: * this should fix BWindow::FindChild(BPoint) Modified: haiku/trunk/src/kits/interface/Window.cpp =================================================================== --- haiku/trunk/src/kits/interface/Window.cpp 2007-07-01 13:15:01 UTC (rev 21536) +++ haiku/trunk/src/kits/interface/Window.cpp 2007-07-01 14:57:41 UTC (rev 21537) @@ -1082,7 +1082,8 @@ case _UPDATE_: { - //bigtime_t now = system_time(); +//bigtime_t now = system_time(); +//bigtime_t drawTime = 0; STRACE(("info:BWindow handling _UPDATE_.\n")); BRect updateRect; @@ -1136,23 +1137,26 @@ // draw int32 count = tokens.CountItems(); for (int32 i = 0; i < count; i++) { +//bigtime_t drawStart = system_time(); if (BView* view = _FindView((int32)tokens.ItemAtFast(i))) view->_Draw(updateRect); else printf("_UPDATE_ - didn't find view by token: %ld\n", (int32)tokens.ItemAtFast(i)); +//drawTime += system_time() - drawStart; } // TODO: the tokens are actually hirachically sorted, // so traversing the list in revers and calling // child->DrawAfterChildren would actually work correctly, // only that drawing outside a view is not yet supported // in the app_server. +//printf(" %ld views drawn, total Draw() time: %lld\n", count, drawTime); } fLink->StartMessage(AS_END_UPDATE); fLink->Flush(); fInTransaction = false; - //printf("BWindow(%s) - UPDATE took %lld usecs\n", Title(), system_time() - now); +//printf("BWindow(%s) - UPDATE took %lld usecs\n", Title(), system_time() - now); break; } @@ -1658,6 +1662,8 @@ BWindow::FindView(BPoint point) const { BAutolock _(const_cast(this)); + // point is assumed to be in window coordinates, + // fTopView has same bounds as window return _FindView(fTopView, point); } @@ -3274,20 +3280,20 @@ } -BView * -BWindow::_FindView(BView *view, BPoint point) const +BView* +BWindow::_FindView(BView* view, BPoint point) const { - // TODO: this is totally broken (bounds vs. frame) - since - // BView::Bounds() potentially queries the app_server - // anyway, we could just let the app_server answer this - // query directly. + // point is assumed to be already in view's coordinates + // TODO: since BView::Bounds() potentially queries the app_server anyway, + // we could just let the app_server answer this query directly. if (view->Bounds().Contains(point) && !view->fFirstChild) return view; - BView *child = view->fFirstChild; + BView* child = view->fFirstChild; while (child != NULL) { - if ((view = _FindView(child, point)) != NULL) + BPoint childPoint = point - child->LeftTop(); + if ((view = _FindView(child, childPoint)) != NULL) return view; child = child->fNextSibling; @@ -3297,7 +3303,7 @@ } -BView * +BView* BWindow::_FindNextNavigable(BView* focus, uint32 flags) { if (focus == NULL) From axeld at mail.berlios.de Sun Jul 1 17:51:42 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 1 Jul 2007 17:51:42 +0200 Subject: [Haiku-commits] r21538 - haiku/trunk/src/kits/translation Message-ID: <200707011551.l61FpgFM009117@sheep.berlios.de> Author: axeld Date: 2007-07-01 17:51:42 +0200 (Sun, 01 Jul 2007) New Revision: 21538 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21538&view=rev Modified: haiku/trunk/src/kits/translation/TranslatorRoster.cpp Log: Fixed a stupid copy&paste bug; one version of Translate() did not lock the private translator handle - and therefore ran into a debugger call. Was triggered by WonderBrush's export function. Modified: haiku/trunk/src/kits/translation/TranslatorRoster.cpp =================================================================== --- haiku/trunk/src/kits/translation/TranslatorRoster.cpp 2007-07-01 14:57:41 UTC (rev 21537) +++ haiku/trunk/src/kits/translation/TranslatorRoster.cpp 2007-07-01 15:51:42 UTC (rev 21538) @@ -1536,6 +1536,9 @@ if (source == NULL || destination == NULL) return B_BAD_VALUE; + if (!fPrivate->Lock()) + return B_ERROR; + BTranslator* translator = fPrivate->FindTranslator(id); if (translator != NULL) { translator->Acquire(); From axeld at mail.berlios.de Mon Jul 2 00:59:12 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 2 Jul 2007 00:59:12 +0200 Subject: [Haiku-commits] r21539 - haiku/trunk/src/add-ons/translators/jpeg Message-ID: <200707012259.l61MxCq7026438@sheep.berlios.de> Author: axeld Date: 2007-07-02 00:59:11 +0200 (Mon, 02 Jul 2007) New Revision: 21539 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21539&view=rev Modified: haiku/trunk/src/add-ons/translators/jpeg/JPEGTranslator.cpp Log: * Fixed two crashing bugs I introduced in JPEG compression code in r20635. * Also broke big endian 32 to 24 bit conversion. Modified: haiku/trunk/src/add-ons/translators/jpeg/JPEGTranslator.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/jpeg/JPEGTranslator.cpp 2007-07-01 15:51:42 UTC (rev 21538) +++ haiku/trunk/src/add-ons/translators/jpeg/JPEGTranslator.cpp 2007-07-01 22:59:11 UTC (rev 21539) @@ -370,6 +370,8 @@ inline void convert_from_32_to_24(uint8* in, uint8* out, int32 inRowBytes) { + inRowBytes /= 4; + for (int32 i = 0; i < inRowBytes; i++) { out[0] = in[2]; out[1] = in[1]; @@ -384,10 +386,12 @@ inline void convert_from_32b_to_24(uint8* in, uint8* out, int32 inRowBytes) { + inRowBytes /= 4; + for (int32 i = 0; i < inRowBytes; i++) { - out[1] = in[0]; - out[2] = in[1]; - out[3] = in[2]; + out[0] = in[1]; + out[1] = in[2]; + out[2] = in[3]; in += 4; out += 3; From axeld at mail.berlios.de Mon Jul 2 20:53:55 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 2 Jul 2007 20:53:55 +0200 Subject: [Haiku-commits] r21540 - in haiku/trunk/src: add-ons/kernel/partitioning_systems/efi tests/system/boot/loader Message-ID: <200707021853.l62IrtHT001257@sheep.berlios.de> Author: axeld Date: 2007-07-02 20:53:55 +0200 (Mon, 02 Jul 2007) New Revision: 21540 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21540&view=rev Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.h haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/guid.h haiku/trunk/src/tests/system/boot/loader/Jamfile Log: * The EFI partitioning module is now able to detect partitions and file systems (currently, only the HFS+ GUID is known). * The header and partition table CRCs are not yet validated, though. * Enabled EFI in the boot loader test app. Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp 2007-07-01 22:59:11 UTC (rev 21539) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp 2007-07-02 18:53:55 UTC (rev 21540) @@ -16,6 +16,7 @@ #include #include +#include #include @@ -31,12 +32,31 @@ #define EFI_PARTITION_NAME "EFI GUID Partition Table" +struct static_guid { + uint32 data1; + uint16 data2; + uint16 data3; + uint64 data4; + + inline bool operator==(const guid &other) const; +}; + +const static struct type_map { + static_guid guid; + const char *type; +} kTypeMap[] = { + {{0x48465300, 0x0000, 0x11aa, 0xaa1100306543ECACLL}, "HFS+ File System"} +}; + + +namespace EFI { + class Header { public: Header(int fd, off_t block, uint32 blockSize); ~Header(); - status_t InitCheck(); + status_t InitCheck() const; bool IsPrimary() const { return fBlock == EFI_HEADER_LOCATION; } @@ -46,11 +66,14 @@ { return *(const efi_partition_entry*) (fEntries + fHeader.EntrySize() * index); } - void Dump(); + private: +#ifdef TRACE_EFI_GPT + const char *_PrintGUID(const guid_t &id); + void _Dump(); + void _DumpPartitions(); +#endif - private: - - bool _ValidateCRC(uint8 *data, size_t size); + bool _ValidateCRC(uint8 *data, size_t size) const; size_t _EntryArraySize() const { return fHeader.EntrySize() * fHeader.EntryCount(); } @@ -61,7 +84,81 @@ uint8 *fEntries; }; +} // namespace EFI + +const static guid_t kEmptyGUID = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}}; + + +inline bool +static_guid::operator==(const guid_t &other) const +{ + return B_HOST_TO_LENDIAN_INT32(data1) == other.data1 + && B_HOST_TO_LENDIAN_INT16(data2) == other.data2 + && B_HOST_TO_LENDIAN_INT16(data3) == other.data3 + && B_HOST_TO_BENDIAN_INT64(*(uint64 *)&data4) == *(uint64 *)other.data4; + // the last 8 bytes are in big-endian order +} + + +static void +put_utf8_byte(char *&to, size_t &left, char c) +{ + if (left <= 1) + return; + + *(to++) = c; + left--; +} + + +static void +to_utf8(const uint16 *from, size_t maxFromLength, char *to, size_t toSize) +{ + for (uint32 i = 0; i < maxFromLength; i++) { + uint16 c = B_LENDIAN_TO_HOST_INT16(from[i]); + if (!c) + break; + + if (c < 0x80) + put_utf8_byte(to, toSize, c); + else if (c < 0x800) { + put_utf8_byte(to, toSize, 0xc0 | (c >> 6)); + put_utf8_byte(to, toSize, 0x80 | (c & 0x3f)); + } else if (c < 0x10000) { + put_utf8_byte(to, toSize, 0xe0 | (c >> 12)); + put_utf8_byte(to, toSize, 0x80 | ((c >> 6) & 0x3f)); + put_utf8_byte(to, toSize, 0x80 | (c & 0x3f)); + } else if (c <= 0x10ffff) { + put_utf8_byte(to, toSize, 0xf0 | (c >> 18)); + put_utf8_byte(to, toSize, 0x80 | ((c >> 12) & 0x3f)); + put_utf8_byte(to, toSize, 0x80 | ((c >> 6) & 0x3f)); + put_utf8_byte(to, toSize, 0x80 | (c & 0x3f)); + } + } + + if (toSize > 0) + *to = '\0'; +} + + +const char * +get_partition_type(const guid_t &guid) +{ + for (uint32 i = 0; i < sizeof(kTypeMap) / sizeof(kTypeMap[0]); i++) { + if (kTypeMap[i].guid == guid) + return kTypeMap[i].type; + } + + return NULL; +} + + +// #pragma mark - + + +namespace EFI { + Header::Header(int fd, off_t block, uint32 blockSize) : fBlock(block), @@ -118,8 +215,12 @@ return; } +#ifdef TRACE_EFI_GPT + _Dump(); + _DumpPartitions(); +#endif + fStatus = B_OK; - Dump(); } @@ -130,28 +231,79 @@ status_t -Header::InitCheck() +Header::InitCheck() const { return fStatus; } bool -Header::_ValidateCRC(uint8 *data, size_t size) +Header::_ValidateCRC(uint8 *data, size_t size) const { // TODO: implement! return true; } +#ifdef TRACE_EFI_GPT +const char * +Header::_PrintGUID(const guid_t &id) +{ + static char guid[48]; + snprintf(guid, sizeof(guid), "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + B_LENDIAN_TO_HOST_INT32(id.data1), B_LENDIAN_TO_HOST_INT16(id.data2), + B_LENDIAN_TO_HOST_INT16(id.data3), id.data4[0], id.data4[1], id.data4[2], + id.data4[3], id.data4[4], id.data4[5], id.data4[6], id.data4[7]); + return guid; +} + + void -Header::Dump() +Header::_Dump() { + dprintf("EFI header: %.8s\n", fHeader.header); + dprintf("EFI revision: %ld\n", fHeader.Revision()); + dprintf("header size: %ld\n", fHeader.HeaderSize()); + dprintf("header CRC: %ld\n", fHeader.HeaderCRC()); + dprintf("absolute block: %Ld\n", fHeader.AbsoluteBlock()); + dprintf("alternate block: %Ld\n", fHeader.AlternateBlock()); + dprintf("first usable block: %Ld\n", fHeader.FirstUsableBlock()); + dprintf("last usable block: %Ld\n", fHeader.LastUsableBlock()); + dprintf("disk GUID: %s\n", _PrintGUID(fHeader.disk_guid)); + dprintf("entries block: %Ld\n", fHeader.EntriesBlock()); dprintf("entry size: %ld\n", fHeader.EntrySize()); dprintf("entry count: %ld\n", fHeader.EntryCount()); + dprintf("entries CRC: %ld\n", fHeader.EntriesCRC()); } +void +Header::_DumpPartitions() +{ + for (uint32 i = 0; i < EntryCount(); i++) { + const efi_partition_entry &entry = EntryAt(i); + + if (entry.partition_type == kEmptyGUID) + continue; + + dprintf("[%3ld] partition type: %s\n", i, _PrintGUID(entry.partition_type)); + dprintf(" unique id: %s\n", _PrintGUID(entry.unique_guid)); + dprintf(" start block: %Ld\n", entry.StartBlock()); + dprintf(" end block: %Ld\n", entry.EndBlock()); + dprintf(" size: %g MB\n", (entry.EndBlock() - entry.StartBlock()) + * 512 / 1024.0 / 1024.0); + dprintf(" attributes: %Lx\n", entry.Attributes()); + + char name[64]; + to_utf8(entry.name, EFI_PARTITION_NAME_LENGTH, name, sizeof(name)); + dprintf(" name: %s\n", name); + } +} +#endif // TRACE_EFI_GPT + +} // namespace EFI + + // #pragma mark - public module interface @@ -171,7 +323,16 @@ static float efi_gpt_identify_partition(int fd, partition_data *partition, void **_cookie) { - return B_ERROR; + EFI::Header *header = new (std::nothrow) EFI::Header(fd, EFI_HEADER_LOCATION, + partition->block_size); + status_t status = header->InitCheck(); + if (status < B_OK) { + delete header; + return status; + } + + *_cookie = header; + return 0.7; } @@ -179,25 +340,52 @@ efi_gpt_scan_partition(int fd, partition_data *partition, void *_cookie) { TRACE(("efi_gpt_scan_partition(cookie = %p)\n", _cookie)); + EFI::Header *header = (EFI::Header *)_cookie; partition->status = B_PARTITION_VALID; - partition->flags |= B_PARTITION_PARTITIONING_SYSTEM - | B_PARTITION_READ_ONLY; + partition->flags |= B_PARTITION_PARTITIONING_SYSTEM | B_PARTITION_READ_ONLY; partition->content_size = partition->size; // scan all children - status_t status = B_ERROR; - if (status == B_ENTRY_NOT_FOUND) - return B_OK; + uint32 index = 0; - return status; + for (uint32 i = 0; i < header->EntryCount(); i++) { + const efi_partition_entry &entry = header->EntryAt(i); + + if (entry.partition_type == kEmptyGUID) + continue; + + if (entry.EndBlock() * partition->block_size > (uint64)partition->size) { + TRACE(("efi_gpt: child partition exceeds existing space (%Ld MB)\n", + (entry.EndBlock() - entry.StartBlock()) * partition->block_size / 1024 / 1024)); + continue; + } + + partition_data *child = create_child_partition(partition->id, index++, -1); + if (child == NULL) { + TRACE(("efi_gpt: Creating child at index %ld failed\n", index - 1)); + return B_ERROR; + } + + char name[B_OS_NAME_LENGTH]; + to_utf8(entry.name, EFI_PARTITION_NAME_LENGTH, name, sizeof(name)); + child->name = strdup(name); + child->type = strdup(get_partition_type(entry.partition_type)); + + child->offset = partition->offset + entry.StartBlock() * partition->block_size; + child->size = (entry.EndBlock() - entry.StartBlock()) * partition->block_size; + child->block_size = partition->block_size; + } + + return B_OK; } static void efi_gpt_free_identify_partition_cookie(partition_data *partition, void *_cookie) { + delete (EFI::Header *)_cookie; } @@ -219,8 +407,6 @@ efi_gpt_scan_partition, efi_gpt_free_identify_partition_cookie, NULL, -// efi_gpt_free_partition_cookie, -// efi_gpt_free_partition_content_cookie, }; #ifndef _BOOT_MODE Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.h =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.h 2007-07-01 22:59:11 UTC (rev 21539) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.h 2007-07-02 18:53:55 UTC (rev 21540) @@ -55,7 +55,7 @@ { return B_LENDIAN_TO_HOST_INT32(entry_size); } uint32 EntriesCRC() const { return B_LENDIAN_TO_HOST_INT32(entries_crc); } -}; +} _PACKED; #define EFI_PARTITION_HEADER "EFI PART" #define EFI_HEADER_LOCATION 1 @@ -65,11 +65,18 @@ struct efi_partition_entry { guid_t partition_type; guid_t unique_guid; - uint64 start_lba; - uint64 end_lba; + uint64 start_block; + uint64 end_block; uint64 attributes; uint16 name[EFI_PARTITION_NAME_LENGTH]; -}; + uint64 StartBlock() const + { return B_LENDIAN_TO_HOST_INT64(start_block); } + uint64 EndBlock() const + { return B_LENDIAN_TO_HOST_INT64(end_block); } + uint64 Attributes() const + { return B_LENDIAN_TO_HOST_INT64(attributes); } +} _PACKED; + #endif /* EFI_GPT_H */ Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/guid.h =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/guid.h 2007-07-01 22:59:11 UTC (rev 21539) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/guid.h 2007-07-02 18:53:55 UTC (rev 21540) @@ -10,11 +10,34 @@ typedef struct guid { - uint32 a; - uint16 b; - uint16 c; - uint8 d[8]; + uint32 data1; + uint16 data2; + uint16 data3; + uint8 data4[8]; + + inline bool operator==(const guid &other) const; + inline bool operator!=(const guid &other) const; } _PACKED guid_t; + +inline bool +guid_t::operator==(const guid_t &other) const +{ + return data1 == other.data1 + && data2 == other.data2 + && data3 == other.data3 + && *(uint64 *)data4 == *(uint64 *)other.data4; +} + + +inline bool +guid_t::operator!=(const guid_t &other) const +{ + return data1 != other.data1 + || data2 != other.data2 + || data3 != other.data3 + || *(uint64 *)data4 != *(uint64 *)other.data4; +} + #endif /* GUID_H */ Modified: haiku/trunk/src/tests/system/boot/loader/Jamfile =================================================================== --- haiku/trunk/src/tests/system/boot/loader/Jamfile 2007-07-01 22:59:11 UTC (rev 21539) +++ haiku/trunk/src/tests/system/boot/loader/Jamfile 2007-07-02 18:53:55 UTC (rev 21540) @@ -52,6 +52,7 @@ BOOT_SUPPORT_PARTITION_AMIGA BOOT_SUPPORT_PARTITION_APPLE + BOOT_SUPPORT_PARTITION_EFI BOOT_SUPPORT_PARTITION_INTEL BOOT_SUPPORT_FILE_SYSTEM_BFS From jackburton at mail.berlios.de Mon Jul 2 22:13:41 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 2 Jul 2007 22:13:41 +0200 Subject: [Haiku-commits] r21541 - haiku/trunk/src/apps/terminal Message-ID: <200707022013.l62KDfrg009017@sheep.berlios.de> Author: jackburton Date: 2007-07-02 22:13:40 +0200 (Mon, 02 Jul 2007) New Revision: 21541 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21541&view=rev Modified: haiku/trunk/src/apps/terminal/TermApp.cpp haiku/trunk/src/apps/terminal/Terminal.cpp Log: Moved gTermPref to TermApp.cpp. Moved deleting of gTermPref to the TermApp destructor, so it's symmetric to its creation. Modified: haiku/trunk/src/apps/terminal/TermApp.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-02 18:53:55 UTC (rev 21540) +++ haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-02 20:13:40 UTC (rev 21541) @@ -32,8 +32,8 @@ #include -// Preference temporary -extern PrefHandler *gTermPref; +// Globals +PrefHandler *gTermPref; extern char gWindowName[]; bool gUsageRequested = false; @@ -101,6 +101,7 @@ TermApp::~TermApp() { + delete gTermPref; } @@ -140,7 +141,6 @@ _UnregisterTerminal(); } - delete gTermPref; BApplication::Quit(); } Modified: haiku/trunk/src/apps/terminal/Terminal.cpp =================================================================== --- haiku/trunk/src/apps/terminal/Terminal.cpp 2007-07-02 18:53:55 UTC (rev 21540) +++ haiku/trunk/src/apps/terminal/Terminal.cpp 2007-07-02 20:13:40 UTC (rev 21541) @@ -31,12 +31,8 @@ #include #include "TermApp.h" -#include "PrefHandler.h" -PrefHandler *gTermPref; /* Preference temporary */ - - int main() { From jackburton at mail.berlios.de Mon Jul 2 22:37:46 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 2 Jul 2007 22:37:46 +0200 Subject: [Haiku-commits] r21542 - haiku/trunk/src/apps/terminal Message-ID: <200707022037.l62KbkwQ010886@sheep.berlios.de> Author: jackburton Date: 2007-07-02 22:37:45 +0200 (Mon, 02 Jul 2007) New Revision: 21542 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21542&view=rev Modified: haiku/trunk/src/apps/terminal/TermApp.cpp haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermWindow.cpp haiku/trunk/src/apps/terminal/TermWindow.h haiku/trunk/src/apps/terminal/spawn.cpp haiku/trunk/src/apps/terminal/spawn.h Log: more style cleanups, removed unused global Modified: haiku/trunk/src/apps/terminal/TermApp.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-02 20:13:40 UTC (rev 21541) +++ haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-02 20:37:45 UTC (rev 21542) @@ -135,7 +135,7 @@ if (!gUsageRequested){ int status; - kill(-sh_pid, SIGHUP); + kill(-gShPid, SIGHUP); wait(&status); _UnregisterTerminal(); Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-02 20:13:40 UTC (rev 21541) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-02 20:37:45 UTC (rev 21542) @@ -1015,7 +1015,7 @@ ws.ws_row = fTermRows; ws.ws_col = fTermColumns; ioctl(fTerminalFd, TIOCSWINSZ, &ws); - kill(-sh_pid, SIGWINCH); + kill(-gShPid, SIGWINCH); fFrameResized = 0; if (fScrRegionSet == 0) @@ -1214,7 +1214,7 @@ tcgetattr(fTerminalFd, &tio); if (*bytes == tio.c_cc[VINTR]) { if (tio.c_lflag & ISIG) - kill(-sh_pid, SIGINT); + kill(-gShPid, SIGINT); } // Terminal changes RET, ENTER, F1...F12, and ARROW key code. Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-02 20:13:40 UTC (rev 21541) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-02 20:37:45 UTC (rev 21542) @@ -311,7 +311,7 @@ // try launching two different ways to work around possible problems if (be_roster->Launch(&info.ref)!=B_OK) - be_roster->Launch(TERM_SIGNATURE); + be_roster->Launch(TERM_SIGNATURE); break; } case MENU_PREF_OPEN: { @@ -546,9 +546,9 @@ break; } case MSG_FONT_CHANGED: { - gTermPref->setString (PREF_HALF_FONT_FAMILY, fNewFontMenu->FindMarked()->Label()); - this->PostMessage (MSG_HALF_FONT_CHANGED); - break; + gTermPref->setString (PREF_HALF_FONT_FAMILY, fNewFontMenu->FindMarked()->Label()); + PostMessage (MSG_HALF_FONT_CHANGED); + break; } case MSG_COLOR_CHANGED: { fBaseView->SetViewColor (gTermPref->getRGB (PREF_TEXT_BACK_COLOR)); @@ -604,19 +604,6 @@ } -//! Get Machine Timezone. -int -TermWindow::GetTimeZone() -{ - struct timeval tv; - struct timezone tm; - - gettimeofday (&tv, &tm); - - return -tm.tz_minuteswest / 60; -} - - void TermWindow::TermWinActivate() { @@ -635,27 +622,30 @@ status_t TermWindow::GetSupportedSuites(BMessage *msg) { - static property_info prop_list[] = { - { "encode", - {B_GET_PROPERTY, 0}, - {B_DIRECT_SPECIFIER, 0}, - "get muterminal encode"}, - { "encode", - {B_SET_PROPERTY, 0}, - {B_DIRECT_SPECIFIER, 0}, - "set muterminal encode"}, - { "tty", - {B_GET_PROPERTY, 0}, - {B_DIRECT_SPECIFIER, 0}, - "get tty_name."}, - { 0 } - - }; - msg->AddString("suites", "suite/vnd.naan-termwindow"); - BPropertyInfo prop_info(prop_list); - msg->AddFlat("messages", &prop_info); - return BWindow::GetSupportedSuites(msg); + static property_info propList[] = { + { "encode", + {B_GET_PROPERTY, 0}, + {B_DIRECT_SPECIFIER, 0}, + "get muterminal encode"}, + { "encode", + {B_SET_PROPERTY, 0}, + {B_DIRECT_SPECIFIER, 0}, + "set muterminal encode"}, + { "tty", + {B_GET_PROPERTY, 0}, + {B_DIRECT_SPECIFIER, 0}, + "get tty_name."}, + { 0 } + + }; + + msg->AddString("suites", "suite/vnd.naan-termwindow"); + BPropertyInfo propInfo(propList); + msg->AddFlat("messages", &propInfo); + return BWindow::GetSupportedSuites(msg); } + + //////////////////////////////////////////////////////////////////////////// // ResolveSpecifier // @@ -665,28 +655,26 @@ BMessage *specifier, int32 form, const char *property) { - if ( (strcmp(property, "encode") == 0) - && ((msg->what == B_SET_PROPERTY) || (msg->what == B_GET_PROPERTY) )) - return this; - else if ( (strcmp(property, "tty") == 0) - && (msg->what == B_GET_PROPERTY) ) - return this; + if (((strcmp(property, "encode") == 0) + && ((msg->what == B_SET_PROPERTY) || (msg->what == B_GET_PROPERTY))) + || ((strcmp(property, "tty") == 0) && (msg->what == B_GET_PROPERTY))) + return this; - return BWindow::ResolveSpecifier(msg, index, specifier, form, property); + return BWindow::ResolveSpecifier(msg, index, specifier, form, property); } + //////////////////////////////////////////////////////////////////////////// // SetCoding // Set coding utility functions. //////////////////////////////////////////////////////////////////////////// -void SetCoding (int coding) +void +SetCoding(int coding) { - const etable *p = encoding_table; - p += coding; + const etable *p = encoding_table; + p += coding; - gNowCoding = coding; - - return; + gNowCoding = coding; } Modified: haiku/trunk/src/apps/terminal/TermWindow.h =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-02 20:13:40 UTC (rev 21541) +++ haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-02 20:37:45 UTC (rev 21542) @@ -68,7 +68,6 @@ private: void InitWindow(); void SetupMenu(); - int GetTimeZone(); status_t DoPageSetup(); void DoPrint(); Modified: haiku/trunk/src/apps/terminal/spawn.cpp =================================================================== --- haiku/trunk/src/apps/terminal/spawn.cpp 2007-07-02 20:13:40 UTC (rev 21541) +++ haiku/trunk/src/apps/terminal/spawn.cpp 2007-07-02 20:37:45 UTC (rev 21542) @@ -112,7 +112,7 @@ /* global variables */ -pid_t sh_pid; +pid_t gShPid; static status_t @@ -184,12 +184,12 @@ thread_id terminalThread = find_thread(NULL); /* Fork a child process. */ - if ((sh_pid = fork()) < 0) { + if ((gShPid = fork()) < 0) { close(master); return -1; } - if (sh_pid == 0) { + if (gShPid == 0) { // Now in child process. /* @@ -442,7 +442,7 @@ handshake.row = row; handshake.col = col; handshake.status = PTY_WS; - send_handshake_message(sh_pid, handshake); + send_handshake_message(gShPid, handshake); break; } } Modified: haiku/trunk/src/apps/terminal/spawn.h =================================================================== --- haiku/trunk/src/apps/terminal/spawn.h 2007-07-02 20:13:40 UTC (rev 21541) +++ haiku/trunk/src/apps/terminal/spawn.h 2007-07-02 20:37:45 UTC (rev 21542) @@ -87,8 +87,7 @@ int spawn_shell (int, int, const char *, const char *); void Setenv (const char *, const char *); -extern pid_t sh_pid; /* shell process ID */ -extern int gPfd_num; /* number of gPfd */ +extern pid_t gShPid; /* shell process ID */ #endif /* SPAWN_H */ From axeld at mail.berlios.de Tue Jul 3 02:48:53 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 3 Jul 2007 02:48:53 +0200 Subject: [Haiku-commits] r21543 - haiku/trunk/src/servers/app Message-ID: <200707030048.l630mrEZ011703@sheep.berlios.de> Author: axeld Date: 2007-07-03 02:48:52 +0200 (Tue, 03 Jul 2007) New Revision: 21543 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21543&view=rev Modified: haiku/trunk/src/servers/app/WorkspacesLayer.cpp Log: No longer avoids switching the workspace when a window one clicked on is not movable. This fixes bug #1229. Modified: haiku/trunk/src/servers/app/WorkspacesLayer.cpp =================================================================== --- haiku/trunk/src/servers/app/WorkspacesLayer.cpp 2007-07-02 20:37:45 UTC (rev 21542) +++ haiku/trunk/src/servers/app/WorkspacesLayer.cpp 2007-07-03 00:48:52 UTC (rev 21543) @@ -410,11 +410,11 @@ } // If this window is movable, we keep it selected + // (we prevent our own window from being moved, too) if (fSelectedWindow != NULL && (fSelectedWindow->Flags() & B_NOT_MOVABLE) != 0 || fSelectedWindow == Window()) { fSelectedWindow = NULL; - index = -1; } fLeftTopOffset = where - windowFrame.LeftTop(); From axeld at mail.berlios.de Tue Jul 3 15:00:46 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 3 Jul 2007 15:00:46 +0200 Subject: [Haiku-commits] r21544 - haiku/trunk/src/add-ons/kernel/bus_managers/ps2 Message-ID: <200707031300.l63D0kEA028704@sheep.berlios.de> Author: axeld Date: 2007-07-03 15:00:46 +0200 (Tue, 03 Jul 2007) New Revision: 21544 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21544&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ps2/ps2_mouse.c Log: Update the last click time only if there actually was a click - this fixes the wrong double click as reported in bug #1015. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ps2/ps2_mouse.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/ps2/ps2_mouse.c 2007-07-03 00:48:52 UTC (rev 21543) +++ haiku/trunk/src/add-ons/kernel/bus_managers/ps2/ps2_mouse.c 2007-07-03 13:00:46 UTC (rev 21544) @@ -125,15 +125,16 @@ bigtime_t currentTime = system_time(); int8 wheel_ydelta = 0; int8 wheel_xdelta = 0; - + if (buttons != 0 && cookie->buttons_state == 0) { if (cookie->click_last_time + cookie->click_speed > currentTime) cookie->click_count++; else cookie->click_count = 1; + + cookie->click_last_time = currentTime; } - cookie->click_last_time = currentTime; cookie->buttons_state = buttons; if (cookie->packet_size == PS2_PACKET_INTELLIMOUSE) { From bonefish at mail.berlios.de Tue Jul 3 16:15:16 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 3 Jul 2007 16:15:16 +0200 Subject: [Haiku-commits] r21545 - haiku/trunk/headers/build/os/support Message-ID: <200707031415.l63EFGUu003165@sheep.berlios.de> Author: bonefish Date: 2007-07-03 16:15:15 +0200 (Tue, 03 Jul 2007) New Revision: 21545 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21545&view=rev Modified: haiku/trunk/headers/build/os/support/Errors.h Log: Undefine ENOATTR. We redefine it below. Modified: haiku/trunk/headers/build/os/support/Errors.h =================================================================== --- haiku/trunk/headers/build/os/support/Errors.h 2007-07-03 13:00:46 UTC (rev 21544) +++ haiku/trunk/headers/build/os/support/Errors.h 2007-07-03 14:15:15 UTC (rev 21545) @@ -311,6 +311,7 @@ #undef ELOOP #undef ENOEXEC #undef EPIPE + #undef ENOATTR #define E2BIG HAIKU_E2BIG #define ECHILD HAIKU_ECHILD From bonefish at mail.berlios.de Tue Jul 3 16:17:04 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 3 Jul 2007 16:17:04 +0200 Subject: [Haiku-commits] r21546 - in haiku/trunk/src: build/libbe/app kits/app Message-ID: <200707031417.l63EH4qQ003276@sheep.berlios.de> Author: bonefish Date: 2007-07-03 16:17:03 +0200 (Tue, 03 Jul 2007) New Revision: 21546 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21546&view=rev Modified: haiku/trunk/src/build/libbe/app/Message.cpp haiku/trunk/src/kits/app/Message.cpp Log: ain't a standard header. Should fix the build on platforms that don't have it. Modified: haiku/trunk/src/build/libbe/app/Message.cpp =================================================================== --- haiku/trunk/src/build/libbe/app/Message.cpp 2007-07-03 14:15:15 UTC (rev 21545) +++ haiku/trunk/src/build/libbe/app/Message.cpp 2007-07-03 14:17:03 UTC (rev 21546) @@ -25,8 +25,8 @@ #include #include -#include #include +#include #include Modified: haiku/trunk/src/kits/app/Message.cpp =================================================================== --- haiku/trunk/src/kits/app/Message.cpp 2007-07-03 14:15:15 UTC (rev 21545) +++ haiku/trunk/src/kits/app/Message.cpp 2007-07-03 14:17:03 UTC (rev 21546) @@ -28,8 +28,8 @@ #include #include -#include #include +#include #include From axeld at mail.berlios.de Wed Jul 4 16:06:21 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 4 Jul 2007 16:06:21 +0200 Subject: [Haiku-commits] r21547 - haiku/trunk/src/system/libroot/posix Message-ID: <200707041406.l64E6L1b026948@sheep.berlios.de> Author: axeld Date: 2007-07-04 16:06:20 +0200 (Wed, 04 Jul 2007) New Revision: 21547 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21547&view=rev Modified: haiku/trunk/src/system/libroot/posix/syslog.cpp Log: LOG_CONS is now also honoured when sending the message to the syslog daemon failed (and not just because it doesn't run). Modified: haiku/trunk/src/system/libroot/posix/syslog.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/syslog.cpp 2007-07-03 14:17:03 UTC (rev 21546) +++ haiku/trunk/src/system/libroot/posix/syslog.cpp 2007-07-04 14:06:20 UTC (rev 21547) @@ -1,7 +1,7 @@ -/* -** Copyright 2003, Axel D?rfler, axeld at pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ +/* + * Copyright 2003-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ #include @@ -43,15 +43,14 @@ } -/** This function returns the current syslog context structure. - * If there is none for the current thread, it will create one - * that inherits the context attributes from the team and put it - * into TLS. - * If it could not allocate a thread context, it will return the - * team context; this function is guaranteed to return a valid - * syslog context. - */ - +/*! This function returns the current syslog context structure. + If there is none for the current thread, it will create one + that inherits the context attributes from the team and put it + into TLS. + If it could not allocate a thread context, it will return the + team context; this function is guaranteed to return a valid + syslog context. +*/ static syslog_context * get_context() { @@ -91,14 +90,28 @@ } -/** Creates the message from the given context and sends it to the syslog - * daemon, if the priority mask matches. - * If the message couldn't be delivered, and LOG_CONS was set, it will - * redirect the message to stderr. - */ +//! Prints simplified syslog message to stderr. +static void +message_to_console(syslog_context *context, const char *text, va_list args) +{ + if (context->ident[0]) + fprintf(stderr, "'%s' ", context->ident); + if (context->options & LOG_PID) + fprintf(stderr, "[%ld] ", find_thread(NULL)); + vfprintf(stderr, text, args); + fputc('\n', stderr); +} + + +/*! Creates the message from the given context and sends it to the syslog + daemon, if the priority mask matches. + If the message couldn't be delivered, and LOG_CONS was set, it will + redirect the message to stderr. +*/ static void -send_syslog_message(syslog_context *context, int priority, const char *text, va_list args) +send_syslog_message(syslog_context *context, int priority, const char *text, + va_list args) { int options = context->options; @@ -107,17 +120,10 @@ return; port_id port = find_port(SYSLOG_PORT_NAME); - if ((options & LOG_PERROR) != 0 || ((options & LOG_CONS) != 0 && port < B_OK)) { // if asked for, print out the (simplified) message on stderr - if (context->ident[0]) - fprintf(stderr, "'%s' ", context->ident); - if (context->options & LOG_PID) - fprintf(stderr, "[%ld] ", find_thread(NULL)); - - vfprintf(stderr, text, args); - fputc('\n', stderr); + message_to_console(context, text, args); } if (port < B_OK) { // apparently, there is no syslog daemon running; @@ -137,17 +143,26 @@ message.priority = priority; strcpy(message.ident, context->ident); - int length = vsnprintf(message.message, sizeof(buffer) - sizeof(syslog_message), text, args); + int length = vsnprintf(message.message, sizeof(buffer) + - sizeof(syslog_message), text, args); - while (write_port(port, SYSLOG_MESSAGE, &message, sizeof(syslog_message) + length) == B_INTERRUPTED); + status_t status; + do { // make sure the message gets send (if there is a valid port) + status = write_port(port, SYSLOG_MESSAGE, &message, + sizeof(syslog_message) + length); + } while (status == B_INTERRUPTED); - // ToDo: if write_port() returns an error, LOG_CONS is not respected + if (status < B_OK && (options & LOG_CONS) != 0 + && (options & LOG_PERROR) == 0) { + // LOG_CONS redirects all output to the console in case contacting + // the syslog daemon failed + message_to_console(context, text, args); + } } -// #pragma mark - -// public Be API +// #pragma mark - public Be API // ToDo: it would probably be better to export these symbols as weak symbols only @@ -240,8 +255,7 @@ } -// #pragma mark - -// POSIX API - just uses the thread syslog functions +// #pragma mark - POSIX API void From axeld at mail.berlios.de Wed Jul 4 18:33:58 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 4 Jul 2007 18:33:58 +0200 Subject: [Haiku-commits] r21548 - in haiku/trunk/src/bin/network: . login Message-ID: <200707041633.l64GXwiS012673@sheep.berlios.de> Author: axeld Date: 2007-07-04 18:33:57 +0200 (Wed, 04 Jul 2007) New Revision: 21548 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21548&view=rev Added: haiku/trunk/src/bin/network/login/ haiku/trunk/src/bin/network/login/Jamfile haiku/trunk/src/bin/network/login/login.cpp Removed: haiku/trunk/src/bin/network/tcptester/ Modified: haiku/trunk/src/bin/network/Jamfile Log: * Implemented a basic "login" command - does not yet support real passwords (it currently does a plain string comparison with whatever passwd::pw_passwd contains. * Removed left-over tcptester directory. Modified: haiku/trunk/src/bin/network/Jamfile =================================================================== --- haiku/trunk/src/bin/network/Jamfile 2007-07-04 14:06:20 UTC (rev 21547) +++ haiku/trunk/src/bin/network/Jamfile 2007-07-04 16:33:57 UTC (rev 21548) @@ -3,6 +3,7 @@ SubInclude HAIKU_TOP src bin network arp ; SubInclude HAIKU_TOP src bin network ftp ; SubInclude HAIKU_TOP src bin network ifconfig ; +SubInclude HAIKU_TOP src bin network login ; SubInclude HAIKU_TOP src bin network mount_nfs ; SubInclude HAIKU_TOP src bin network nc ; SubInclude HAIKU_TOP src bin network netstat ; Added: haiku/trunk/src/bin/network/login/Jamfile =================================================================== --- haiku/trunk/src/bin/network/login/Jamfile 2007-07-04 14:06:20 UTC (rev 21547) +++ haiku/trunk/src/bin/network/login/Jamfile 2007-07-04 16:33:57 UTC (rev 21548) @@ -0,0 +1,5 @@ +SubDir HAIKU_TOP src bin network login ; + +BinCommand login : + login.cpp +; Added: haiku/trunk/src/bin/network/login/login.cpp =================================================================== --- haiku/trunk/src/bin/network/login/login.cpp 2007-07-04 14:06:20 UTC (rev 21547) +++ haiku/trunk/src/bin/network/login/login.cpp 2007-07-04 16:33:57 UTC (rev 21548) @@ -0,0 +1,284 @@ +/* + * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel D?rfler, axeld at pinc-software.de + */ + + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +extern const char* __progname; +const char* kProgramName = __progname; + +const uint32 kRetries = 3; +const uint32 kTimeout = 60; + + +static status_t +set_tty_echo(bool enabled) +{ + struct termios termios; + + if (ioctl(STDIN_FILENO, TCGETA, &termios) != 0) + return errno; + + // do we have to change the current setting at all? + if (enabled == (termios.c_lflag & ECHO) != 0) + return B_OK; + + if (enabled) + termios.c_lflag |= ECHO; + else + termios.c_lflag &= ~ECHO; + + if (ioctl(STDIN_FILENO, TCSETA, &termios) != 0) + return errno; + + return B_OK; +} + + +static status_t +read_string(char* string, size_t bufferSize) +{ + // TODO: setup timeout handler + + // read everything until the next carriage return + char c; + while ((c = fgetc(stdin)) != EOF && c != '\r' && c != '\n') { + if (bufferSize > 1) { + string[0] = c; + string++; + bufferSize--; + } + } + + if (ferror(stdin) != 0) + return ferror(stdin); + + string[0] = '\0'; + return B_OK; +} + + +static status_t +login(const char* user, struct passwd** _passwd) +{ + char userBuffer[64]; + + if (user == NULL) { + char host[64]; + if (gethostname(host, sizeof(host)) != 0) + host[0] = '\0'; + + if (host[0]) + printf("%s ", host); + printf("login: "); + fflush(stdout); + + set_tty_echo(true); + + status_t status = read_string(userBuffer, sizeof(userBuffer)); + if (status < B_OK) + return status; + + putchar('\n'); + user = userBuffer; + } + + // if no user is given, we exit immediately + if (!user[0]) + exit(1); + + printf("password: "); + fflush(stdout); + + set_tty_echo(false); + + char password[64]; + status_t status = read_string(password, sizeof(password)); + + set_tty_echo(true); + putchar('\n'); + + if (status < B_OK) + return status; + + struct passwd* passwd = getpwnam(user); + if (passwd == NULL || passwd->pw_passwd == NULL) + return B_ERROR; + + // TODO: do a real password check! + if (strcmp(password, passwd->pw_passwd)) + return B_PERMISSION_DENIED; + + *_passwd = passwd; + return B_OK; +} + + +static status_t +setup_environment(struct passwd* passwd, bool preserveEnvironment) +{ + const char* term = getenv("TERM"); + if (!preserveEnvironment) { + static char *empty[1]; + environ = empty; + } + + // always preserve $TERM + if (term != NULL) + setenv("TERM", term, false); + if (passwd->pw_shell) + setenv("SHELL", passwd->pw_shell, true); + if (passwd->pw_dir) + setenv("HOME", passwd->pw_dir, true); + + setenv("USER", passwd->pw_name, true); + + pid_t pid = getpid(); + if (ioctl(STDIN_FILENO, TIOCSPGRP, &pid) != 0) + return errno; + + const char* home = getenv("HOME"); + if (home == NULL) + return B_ENTRY_NOT_FOUND; + + if (chdir(home) != 0) + return errno; + + return B_OK; +} + + +static const char* +get_from(const char* host) +{ + if (host == NULL) + return ""; + + static char buffer[64]; + snprintf(buffer, sizeof(buffer), " from %s", host); + return buffer; +} + + +static void +usage() +{ + fprintf(stderr, "usage: %s [-fp] [-h hostname] [username]\n", kProgramName); + exit(1); +} + + +int +main(int argc, char *argv[]) +{ + bool noAuthentification = false; + bool preserveEnvironment = false; + const char* fromHost = NULL; + + char c; + while ((c = getopt(argc, argv, "fh:p")) != -1) { + switch (c) { + case 'f': + noAuthentification = true; + break; + case 'h': + if (geteuid() != 0) { + fprintf(stderr, "%s: %s\n", kProgramName, + strerror(B_NOT_ALLOWED)); + exit(-1); + } + + fromHost = optarg; + break; + case 'p': + preserveEnvironment = true; + break; + + default: + usage(); + break; + } + } + + argc -= optind; + argv += optind; + + const char* user = NULL; + if (argc > 0) + user = argv[0]; + + // login + + alarm(kTimeout); + openlog(kProgramName, 0, LOG_AUTH); + + uint32 retries = kRetries; + status_t status = B_ERROR; + struct passwd* passwd = NULL; + + while (retries > 0) { + status = login(user, &passwd); + if (status == B_OK) + break; + + fprintf(stderr, "Login failed.\n"); + sleep(1); + + user = NULL; + // ask for the user name as well after the first failure + } + + alarm(0); + + if (status < B_OK) { + // login failure + syslog(LOG_NOTICE, "login%s failed for \"%s\"", get_from(fromHost), + passwd->pw_name); + exit(-1); + } + + // setup environment for the user + + status = setup_environment(passwd, preserveEnvironment); + if (status < B_OK) { + // refused login + fprintf(stderr, "%s: Refused login. Setting up environment failed: %s\n", + kProgramName, strerror(status)); + syslog(LOG_NOTICE, "login%s refused for \"%s\"", get_from(fromHost), + passwd->pw_name); + exit(-1); + } + + syslog(LOG_INFO, "login%s as \"%s\"", get_from(fromHost), passwd->pw_name); + + // start login shell + + const char* args[] = {getenv("SHELL"), "-login", NULL}; + execv(args[0], (char **)args); + + // try default shell + args[0] = "/bin/sh"; + execv(args[0], (char **)args); + + fprintf(stderr, "%s: starting the shell failed: %s", kProgramName, + strerror(errno)); + + return -1; +} + From axeld at mail.berlios.de Wed Jul 4 18:34:51 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 4 Jul 2007 18:34:51 +0200 Subject: [Haiku-commits] r21549 - haiku/trunk/build/jam Message-ID: <200707041634.l64GYpqm014389@sheep.berlios.de> Author: axeld Date: 2007-07-04 18:34:43 +0200 (Wed, 04 Jul 2007) New Revision: 21549 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21549&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: Added "login" to the image. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-07-04 16:33:57 UTC (rev 21548) +++ haiku/trunk/build/jam/HaikuImage 2007-07-04 16:34:43 UTC (rev 21549) @@ -29,7 +29,7 @@ $(X86_ONLY)gdb grep groups gzip gzexe hd head hey hostname id ident ideinfo idestatus ifconfig install installsound iroster isvolume join keymap kill less lessecho lesskey link listarea listattr listdev listimage - listport listres listsem ln locate logger logname ls lsindex m4 make + listport listres listsem ln locate logger login logname ls lsindex m4 make makebootable md5sum merge mimeset mkdos mkdir mkindex modifiers mount mount_nfs mountvolume mv nc netstat nl od open pack_cis paste patch pathchk pc ping play playfile playsound playwav pr prio printenv printf ps ptx pwd From axeld at mail.berlios.de Wed Jul 4 18:43:34 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 4 Jul 2007 18:43:34 +0200 Subject: [Haiku-commits] r21550 - haiku/trunk/src/add-ons/kernel/network/stack Message-ID: <200707041643.l64GhYgm028636@sheep.berlios.de> Author: axeld Date: 2007-07-04 18:43:32 +0200 (Wed, 04 Jul 2007) New Revision: 21550 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21550&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp Log: Cleanup. Modified: haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp 2007-07-04 16:34:43 UTC (rev 21549) +++ haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp 2007-07-04 16:43:32 UTC (rev 21550) @@ -39,8 +39,10 @@ void socket_delete(net_socket *socket); -int socket_bind(net_socket *socket, const struct sockaddr *address, socklen_t addressLength); +int socket_bind(net_socket *socket, const struct sockaddr *address, + socklen_t addressLength); + struct list sSocketList; benaphore sSocketLock; @@ -69,8 +71,10 @@ socket->receive.low_water_mark = 1; socket->receive.timeout = B_INFINITE_TIMEOUT; - list_init_etc(&socket->pending_children, offsetof(net_socket_private, link)); - list_init_etc(&socket->connected_children, offsetof(net_socket_private, link)); + list_init_etc(&socket->pending_children, offsetof(net_socket_private, + link)); + list_init_etc(&socket->connected_children, offsetof(net_socket_private, + link)); status = get_domain_protocols(socket); if (status < B_OK) @@ -142,14 +146,16 @@ status_t -socket_readv(net_socket *socket, const iovec *vecs, size_t vecCount, size_t *_length) +socket_readv(net_socket *socket, const iovec *vecs, size_t vecCount, + size_t *_length) { return -1; } status_t -socket_writev(net_socket *socket, const iovec *vecs, size_t vecCount, size_t *_length) +socket_writev(net_socket *socket, const iovec *vecs, size_t vecCount, + size_t *_length) { if (socket->peer.ss_len == 0) return ECONNRESET; @@ -253,7 +259,8 @@ net_socket_private *socket = NULL; uint32 cookie = *_cookie; uint32 count = 0; - while ((socket = (net_socket_private *)list_get_next_item(&sSocketList, socket)) != NULL) { + while ((socket = (net_socket_private *)list_get_next_item(&sSocketList, + socket)) != NULL) { // TODO: also traverse the pending connections if (count == cookie) break; @@ -303,8 +310,8 @@ return ENOBUFS; net_socket_private *socket; - status_t status = create_socket(parent->family, parent->type, parent->protocol, - &socket); + status_t status = create_socket(parent->family, parent->type, + parent->protocol, &socket); if (status < B_OK) return status; @@ -381,10 +388,12 @@ BenaphoreLocker _(parent->lock); - int count = 0; - for (void *it = list_get_first_item(&parent->connected_children); - it != NULL; it = list_get_next_item(&parent->connected_children, it)) + ssize_t count = 0; + void *item = NULL; + while ((item = list_get_next_item(&parent->connected_children, + item)) != NULL) { count++; + } return count; } @@ -401,15 +410,18 @@ benaphore_lock(&socket->lock); - // first remove the pending connections, then the already connected ones as needed + // first remove the pending connections, then the already connected + // ones as needed net_socket_private *child; while (socket->child_count > backlog - && (child = (net_socket_private *)list_remove_tail_item(&socket->pending_children)) != NULL) { + && (child = (net_socket_private *)list_remove_tail_item( + &socket->pending_children)) != NULL) { child->parent = NULL; socket->child_count--; } while (socket->child_count > backlog - && (child = (net_socket_private *)list_remove_tail_item(&socket->connected_children)) != NULL) { + && (child = (net_socket_private *)list_remove_tail_item( + &socket->connected_children)) != NULL) { child->parent = NULL; socket_delete(child); socket->child_count--; @@ -472,14 +484,16 @@ case B_SELECT_READ: { ssize_t available = socket_read_avail(socket); - if ((ssize_t)socket->receive.low_water_mark <= available || available < B_OK) + if ((ssize_t)socket->receive.low_water_mark <= available + || available < B_OK) notify_select_event(sync, ref, event); break; } case B_SELECT_WRITE: { ssize_t available = socket_send_avail(socket); - if ((ssize_t)socket->send.low_water_mark <= available || available < B_OK) + if ((ssize_t)socket->send.low_water_mark <= available + || available < B_OK) notify_select_event(sync, ref, event); break; } @@ -515,12 +529,14 @@ switch (event) { case B_SELECT_READ: - if ((ssize_t)socket->receive.low_water_mark > value && value >= B_OK) + if ((ssize_t)socket->receive.low_water_mark > value + && value >= B_OK) notify = false; break; case B_SELECT_WRITE: - if ((ssize_t)socket->send.low_water_mark > value && value >= B_OK) + if ((ssize_t)socket->send.low_water_mark > value + && value >= B_OK) notify = false; break; @@ -543,8 +559,8 @@ int -socket_accept(net_socket *socket, struct sockaddr *address, socklen_t *_addressLength, - net_socket **_acceptedSocket) +socket_accept(net_socket *socket, struct sockaddr *address, + socklen_t *_addressLength, net_socket **_acceptedSocket) { if ((socket->options & SO_ACCEPTCONN) == 0) return B_BAD_VALUE; @@ -567,7 +583,8 @@ int -socket_bind(net_socket *socket, const struct sockaddr *address, socklen_t addressLength) +socket_bind(net_socket *socket, const struct sockaddr *address, + socklen_t addressLength) { sockaddr empty; if (address == NULL) { @@ -601,7 +618,8 @@ int -socket_connect(net_socket *socket, const struct sockaddr *address, socklen_t addressLength) +socket_connect(net_socket *socket, const struct sockaddr *address, + socklen_t addressLength) { if (address == NULL || addressLength == 0) return ENETUNREACH; @@ -618,7 +636,8 @@ int -socket_getpeername(net_socket *socket, struct sockaddr *address, socklen_t *_addressLength) +socket_getpeername(net_socket *socket, struct sockaddr *address, + socklen_t *_addressLength) { if (socket->peer.ss_len == 0) return ENOTCONN; @@ -630,12 +649,14 @@ int -socket_getsockname(net_socket *socket, struct sockaddr *address, socklen_t *_addressLength) +socket_getsockname(net_socket *socket, struct sockaddr *address, + socklen_t *_addressLength) { if (socket->address.ss_len == 0) return ENOTCONN; - memcpy(address, &socket->address, min_c(*_addressLength, socket->address.ss_len)); + memcpy(address, &socket->address, min_c(*_addressLength, + socket->address.ss_len)); *_addressLength = socket->address.ss_len; return B_OK; } @@ -759,7 +780,8 @@ int socket_listen(net_socket *socket, int backlog) { - status_t status = socket->first_info->listen(socket->first_protocol, backlog); + status_t status = socket->first_info->listen(socket->first_protocol, + backlog); if (status == B_OK) socket->options |= SO_ACCEPTCONN; @@ -917,14 +939,16 @@ if (header) { // copy additional data into buffer for (int i = 1; i < header->msg_iovlen; i++) { - iovec tmp; - if (user_memcpy(&tmp, header->msg_iov + i, sizeof(iovec)) < B_OK || - gNetBufferModule.append(buffer, tmp.iov_base, tmp.iov_len) < B_OK) { + iovec vec; + if (user_memcpy(&vec, header->msg_iov + i, sizeof(iovec)) < B_OK) + return B_BAD_ADDRESS; + if (gNetBufferModule.append(buffer, vec.iov_base, + vec.iov_len) < B_OK) { gNetBufferModule.free(buffer); return ENOBUFS; } - length += tmp.iov_len; + length += vec.iov_len; } } @@ -938,7 +962,8 @@ size_t size = buffer->size; gNetBufferModule.free(buffer); - if (size != length && (status == B_INTERRUPTED || status == B_WOULD_BLOCK)) { + if (size != length + && (status == B_INTERRUPTED || status == B_WOULD_BLOCK)) { // this appears to be a partial write return length - size; } From axeld at mail.berlios.de Wed Jul 4 18:47:21 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 4 Jul 2007 18:47:21 +0200 Subject: [Haiku-commits] r21551 - haiku/trunk/src/servers/net Message-ID: <200707041647.l64GlLsA000758@sheep.berlios.de> Author: axeld Date: 2007-07-04 18:47:20 +0200 (Wed, 04 Jul 2007) New Revision: 21551 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21551&view=rev Modified: haiku/trunk/src/servers/net/Services.cpp Log: * _Update() was called too early in the constructor of class Service; that caused incorrect values in fSet, and fMinSocket which also resulted in select() never to return (in would only work for settings you changed after the net_server was run). * Minor cleanup. Modified: haiku/trunk/src/servers/net/Services.cpp =================================================================== --- haiku/trunk/src/servers/net/Services.cpp 2007-07-04 16:43:32 UTC (rev 21550) +++ haiku/trunk/src/servers/net/Services.cpp 2007-07-04 16:47:20 UTC (rev 21551) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -126,8 +126,6 @@ fUpdate(0), fMaxSocket(0) { - _Update(services); - // setup pipe to communicate with the listener thread - as the listener // blocks on select(), we need a mechanism to interrupt it if (pipe(&fReadPipe) < 0) { @@ -144,6 +142,8 @@ fMinSocket = fWritePipe + 1; fMaxSocket = fWritePipe + 1; + _Update(services); + fListener = spawn_thread(_Listener, "services listener", B_NORMAL_PRIORITY, this); if (fListener >= B_OK) resume_thread(fListener); @@ -237,7 +237,7 @@ } _NotifyListener(); -printf("Starting service '%s'\n", service.name.c_str()); + printf("Starting service '%s'\n", service.name.c_str()); return B_OK; } @@ -256,7 +256,8 @@ for (; iterator != service.addresses.end(); iterator++) { const service_address& address = *iterator; - ServiceSocketMap::iterator socketIterator = fSocketMap.find(address.socket); + ServiceSocketMap::iterator socketIterator + = fSocketMap.find(address.socket); if (socketIterator != fSocketMap.end()) fSocketMap.erase(socketIterator); @@ -440,7 +441,8 @@ pid_t child = fork(); if (child == 0) { setsid(); - // make sure we're in our own session, and don't accidently quit the net_server + // make sure we're in our own session, and don't accidently quit + // the net_server // We're the child, replace standard input/output dup2(socket, STDIN_FILENO); @@ -480,7 +482,6 @@ snooze(1000000LL); } -printf("select returned!\n"); if (FD_ISSET(fReadPipe, &set)) { char command; if (read(fReadPipe, &command, 1) == 1 && command == 'q') From axeld at mail.berlios.de Wed Jul 4 19:33:23 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 4 Jul 2007 19:33:23 +0200 Subject: [Haiku-commits] r21552 - haiku/trunk/src/system/kernel/fs Message-ID: <200707041733.l64HXNNu024002@sheep.berlios.de> Author: axeld Date: 2007-07-04 19:33:22 +0200 (Wed, 04 Jul 2007) New Revision: 21552 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21552&view=rev Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp Log: Cleanup. Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/devfs.cpp 2007-07-04 16:47:20 UTC (rev 21551) +++ haiku/trunk/src/system/kernel/fs/devfs.cpp 2007-07-04 17:33:22 UTC (rev 21552) @@ -131,10 +131,11 @@ }; -static void get_device_name(struct devfs_vnode *vnode, char *buffer, size_t size); +static void get_device_name(struct devfs_vnode *vnode, char *buffer, + size_t size); static status_t publish_device(struct devfs *fs, const char *path, - device_node_info *deviceNode, pnp_devfs_driver_info *info, - driver_entry *driver, device_hooks *ops, int32 apiVersion); + device_node_info *deviceNode, pnp_devfs_driver_info *info, + driver_entry *driver, device_hooks *ops, int32 apiVersion); /* the one and only allowed devfs instance */ @@ -195,10 +196,8 @@ int32 defaultApiVersion = 1; int32 *apiVersion = &defaultApiVersion; - if (get_image_symbol(image, "api_version", B_SYMBOL_TYPE_DATA, (void **)&apiVersion) == B_OK) { - // According to Be newsletter, vol II, issue 36, - // version 2 added readv/writev, which we don't support, but also select/deselect. - // So we must make sure not to use invalid pointers in publish_device. + if (get_image_symbol(image, "api_version", B_SYMBOL_TYPE_DATA, + (void **)&apiVersion) == B_OK) { #if B_CUR_DRIVER_API_VERSION != 2 // just in case someone decides to bump up the api version #error Add checks here for new vs old api version! @@ -218,8 +217,10 @@ device_hooks *(*find_device)(const char *); const char **(*publish_devices)(void); - if (get_image_symbol(image, "publish_devices", B_SYMBOL_TYPE_TEXT, (void **)&publish_devices) != B_OK - || get_image_symbol(image, "find_device", B_SYMBOL_TYPE_TEXT, (void **)&find_device) != B_OK) { + if (get_image_symbol(image, "publish_devices", B_SYMBOL_TYPE_TEXT, + (void **)&publish_devices) != B_OK + || get_image_symbol(image, "find_device", B_SYMBOL_TYPE_TEXT, + (void **)&find_device) != B_OK) { dprintf("%s: mandatory driver symbol(s) missing!\n", name); status = B_BAD_VALUE; goto error1; @@ -298,13 +299,14 @@ } -/** This is no longer part of the public kernel API, so we just export the symbol */ - +/*! This is no longer part of the public kernel API, so we just export the + symbol +*/ status_t load_driver_symbols(const char *driverName); status_t load_driver_symbols(const char *driverName) { - // This will be globally done for the whole kernel via the settings file. + // This is done globally for the whole kernel via the settings file. // We don't have to do anything here. return B_OK; @@ -399,7 +401,8 @@ static status_t -devfs_delete_vnode(struct devfs *fs, struct devfs_vnode *vnode, bool force_delete) +devfs_delete_vnode(struct devfs *fs, struct devfs_vnode *vnode, + bool force_delete) { // cant delete it if it's in a directory or is a directory // and has children @@ -437,7 +440,8 @@ { struct devfs_dir_cookie *cookie = NULL; - while ((cookie = (devfs_dir_cookie *)list_get_next_item(&dir->stream.u.dir.cookies, cookie)) != NULL) { + while ((cookie = (devfs_dir_cookie *)list_get_next_item( + &dir->stream.u.dir.cookies, cookie)) != NULL) { if (cookie->current == vnode) cookie->current = vnode->dir_next; } @@ -494,8 +498,10 @@ vnode->parent = dir; dir->modification_time = time(NULL); - notify_entry_created(sDeviceFileSystem->id, dir->id, vnode->name, vnode->id); - notify_stat_changed(sDeviceFileSystem->id, dir->id, B_STAT_MODIFICATION_TIME); + notify_entry_created(sDeviceFileSystem->id, dir->id, vnode->name, + vnode->id); + notify_stat_changed(sDeviceFileSystem->id, dir->id, + B_STAT_MODIFICATION_TIME); return B_OK; } @@ -519,8 +525,10 @@ vnode->dir_next = NULL; dir->modification_time = time(NULL); - notify_entry_removed(sDeviceFileSystem->id, dir->id, vnode->name, vnode->id); - notify_stat_changed(sDeviceFileSystem->id, dir->id, B_STAT_MODIFICATION_TIME); + notify_entry_removed(sDeviceFileSystem->id, dir->id, vnode->name, + vnode->id); + notify_stat_changed(sDeviceFileSystem->id, dir->id, + B_STAT_MODIFICATION_TIME); return B_OK; } } @@ -547,7 +555,8 @@ return B_BAD_VALUE; // create partition - struct devfs_partition *partition = (struct devfs_partition *)malloc(sizeof(struct devfs_partition)); + struct devfs_partition *partition = (struct devfs_partition *)malloc( + sizeof(struct devfs_partition)); if (partition == NULL) return B_NO_MEMORY; @@ -597,7 +606,8 @@ static inline void -translate_partition_access(devfs_partition *partition, off_t &offset, size_t &size) +translate_partition_access(devfs_partition *partition, off_t &offset, + size_t &size) { if (offset < 0) offset = 0; @@ -615,7 +625,8 @@ static pnp_devfs_driver_info * create_new_driver_info(device_hooks *ops, int32 version) { - pnp_devfs_driver_info *info = (pnp_devfs_driver_info *)malloc(sizeof(pnp_devfs_driver_info)); + pnp_devfs_driver_info *info = (pnp_devfs_driver_info *)malloc( + sizeof(pnp_devfs_driver_info)); if (info == NULL) return NULL; @@ -637,9 +648,12 @@ // old devices can't know how to do physical page access if (version >= 2) { + // According to Be newsletter, vol II, issue 36, + // version 2 added readv/writev, which we don't support, but also + // select/deselect. info->select = ops->select; info->deselect = ops->deselect; - + // ops->readv; // ops->writev; // we don't implement scatter-gather atm, so ignore those. @@ -650,7 +664,8 @@ static status_t -get_node_for_path(struct devfs *fs, const char *path, struct devfs_vnode **_node) +get_node_for_path(struct devfs *fs, const char *path, + struct devfs_vnode **_node) { return vfs_get_fs_node_from_path(fs->id, path, true, (void **)_node); } @@ -846,9 +861,10 @@ static status_t publish_device(struct devfs *fs, const char *path, device_node_info *deviceNode, - pnp_devfs_driver_info *info, driver_entry *driver, device_hooks *ops, int32 apiVersion) + pnp_devfs_driver_info *info, driver_entry *driver, device_hooks *ops, + int32 apiVersion) { - TRACE(("publish_device(path = \"%s\", node = %p, info = %p, hooks = %p, apiVersion = %d)\n", + TRACE(("publish_device(path = \"%s\", node = %p, info = %p, hooks = %p, apiVersion = %ld)\n", path, deviceNode, info, ops, apiVersion)); if (sDeviceFileSystem == NULL) { @@ -1539,7 +1555,8 @@ struct devfs_vnode *nextChildNode = NULL; int32 nextState = cookie->state; - TRACE(("devfs_read_dir: vnode %p, cookie %p, buffer %p, size %ld\n", _vnode, cookie, dirent, bufferSize)); + TRACE(("devfs_read_dir: vnode %p, cookie %p, buffer %p, size %ld\n", + _vnode, cookie, dirent, bufferSize)); if (!S_ISDIR(vnode->stream.type)) return B_BAD_VALUE; @@ -1613,10 +1630,9 @@ } -/** Forwards the opcode to the device driver, but also handles some devfs specific - * functionality, like partitions. - */ - +/*! Forwards the opcode to the device driver, but also handles some devfs + specific functionality, like partitions. +*/ static status_t devfs_ioctl(fs_volume _fs, fs_vnode _vnode, fs_cookie _cookie, ulong op, void *buffer, size_t length) @@ -1628,13 +1644,14 @@ TRACE(("devfs_ioctl: vnode %p, cookie %p, op %ld, buf %p, len %ld\n", _vnode, _cookie, op, buffer, length)); - // we are actually checking for a *device* here, we don't make the distinction - // between char and block devices + // we are actually checking for a *device* here, we don't make the + // distinction between char and block devices if (S_ISCHR(vnode->stream.type)) { switch (op) { case B_GET_GEOMETRY: { - struct devfs_partition *partition = vnode->stream.u.dev.partition; + struct devfs_partition *partition + = vnode->stream.u.dev.partition; if (partition == NULL) break; @@ -1670,13 +1687,15 @@ case B_GET_PARTITION_INFO: { - struct devfs_partition *partition = vnode->stream.u.dev.partition; + struct devfs_partition *partition + = vnode->stream.u.dev.partition; if (!S_ISCHR(vnode->stream.type) || partition == NULL || length != sizeof(partition_info)) return B_BAD_VALUE; - return user_memcpy(buffer, &partition->info, sizeof(partition_info)); + return user_memcpy(buffer, &partition->info, + sizeof(partition_info)); } case B_SET_PARTITION: @@ -1730,8 +1749,8 @@ if (!S_ISCHR(vnode->stream.type)) return B_NOT_ALLOWED; - return vnode->stream.u.dev.info->control(cookie->device_cookie, flags & O_NONBLOCK ? - B_SET_NONBLOCKING_IO : B_SET_BLOCKING_IO, NULL, 0); + return vnode->stream.u.dev.info->control(cookie->device_cookie, + flags & O_NONBLOCK ? B_SET_NONBLOCKING_IO : B_SET_BLOCKING_IO, NULL, 0); } @@ -1803,10 +1822,13 @@ || cookie == NULL) return B_NOT_ALLOWED; - if (vnode->stream.u.dev.partition) - translate_partition_access(vnode->stream.u.dev.partition, pos, *_numBytes); + if (vnode->stream.u.dev.partition) { + translate_partition_access(vnode->stream.u.dev.partition, pos, + *_numBytes); + } - return vnode->stream.u.dev.info->read_pages(cookie->device_cookie, pos, vecs, count, _numBytes); + return vnode->stream.u.dev.info->read_pages(cookie->device_cookie, pos, + vecs, count, _numBytes); } @@ -1824,10 +1846,13 @@ || cookie == NULL) return B_NOT_ALLOWED; - if (vnode->stream.u.dev.partition) - translate_partition_access(vnode->stream.u.dev.partition, pos, *_numBytes); + if (vnode->stream.u.dev.partition) { + translate_partition_access(vnode->stream.u.dev.partition, pos, + *_numBytes); + } - return vnode->stream.u.dev.info->write_pages(cookie->device_cookie, pos, vecs, count, _numBytes); + return vnode->stream.u.dev.info->write_pages(cookie->device_cookie, pos, + vecs, count, _numBytes); } @@ -1836,7 +1861,8 @@ { struct devfs_vnode *vnode = (struct devfs_vnode *)_vnode; - TRACE(("devfs_read_stat: vnode %p (%Ld), stat %p\n", vnode, vnode->id, stat)); + TRACE(("devfs_read_stat: vnode %p (%Ld), stat %p\n", vnode, vnode->id, + stat)); stat->st_ino = vnode->id; stat->st_size = 0; @@ -1878,12 +1904,14 @@ static status_t -devfs_write_stat(fs_volume _fs, fs_vnode _vnode, const struct stat *stat, uint32 statMask) +devfs_write_stat(fs_volume _fs, fs_vnode _vnode, const struct stat *stat, + uint32 statMask) { struct devfs *fs = (struct devfs *)_fs; struct devfs_vnode *vnode = (struct devfs_vnode *)_vnode; - TRACE(("devfs_write_stat: vnode %p (0x%Lx), stat %p\n", vnode, vnode->id, stat)); + TRACE(("devfs_write_stat: vnode %p (0x%Lx), stat %p\n", vnode, vnode->id, + stat)); // we cannot change the size of anything if (statMask & FS_WRITE_STAT_SIZE) @@ -1891,8 +1919,10 @@ RecursiveLocker locker(&fs->lock); - if (statMask & FS_WRITE_STAT_MODE) - vnode->stream.type = (vnode->stream.type & ~S_IUMSK) | (stat->st_mode & S_IUMSK); + if (statMask & FS_WRITE_STAT_MODE) { + vnode->stream.type = (vnode->stream.type & ~S_IUMSK) + | (stat->st_mode & S_IUMSK); + } if (statMask & FS_WRITE_STAT_UID) vnode->uid = stat->st_uid; @@ -1990,7 +2020,8 @@ &devfs_create_dir, NULL, // remove_dir &devfs_open_dir, - &devfs_close, // same as for files - it does nothing for directories, anyway + &devfs_close, + // same as for files - it does nothing for directories, anyway &devfs_free_dir_cookie, &devfs_read_dir, &devfs_rewind_dir, @@ -2024,7 +2055,8 @@ TRACE(("pnp_devfs_probe()\n")); - if (sDeviceManager->get_attr_string(parent, PNP_DEVFS_FILENAME, &filename, true) != B_OK) { + if (sDeviceManager->get_attr_string(parent, PNP_DEVFS_FILENAME, + &filename, true) != B_OK) { dprintf("devfs: Item containing file name is missing\n"); status = B_ERROR; goto err1; @@ -2032,20 +2064,24 @@ TRACE(("Adding %s\n", filename)); - status = sDeviceManager->register_device(parent, pnp_devfs_attrs, NULL, &node); + status = sDeviceManager->register_device(parent, pnp_devfs_attrs, NULL, + &node); if (status != B_OK || node == NULL) goto err1; - // ToDo: this is a hack to get things working (init_driver() only works for registered nodes) + // ToDo: this is a hack to get things working (init_driver() only + // works for registered nodes) parent->registered = true; pnp_devfs_driver_info *info; - status = sDeviceManager->init_driver(parent, NULL, (driver_module_info **)&info, NULL); + status = sDeviceManager->init_driver(parent, NULL, + (driver_module_info **)&info, NULL); if (status != B_OK) goto err2; //add_device(device); - status = publish_device(sDeviceFileSystem, filename, node, info, NULL, NULL, 0); + status = publish_device(sDeviceFileSystem, filename, node, info, NULL, + NULL, 0); if (status != B_OK) goto err3; //nudge(); @@ -2127,7 +2163,8 @@ { switch (op) { case B_MODULE_INIT: - return get_module(B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&sDeviceManager); + return get_module(B_DEVICE_MANAGER_MODULE_NAME, + (module_info **)&sDeviceManager); case B_MODULE_UNINIT: put_module(B_DEVICE_MANAGER_MODULE_NAME); @@ -2264,7 +2301,8 @@ return B_BAD_VALUE; devfs_vnode *device; - status_t status = get_node_for_path(sDeviceFileSystem, info->device, &device); + status_t status = get_node_for_path(sDeviceFileSystem, info->device, + &device); if (status != B_OK) return status; From kirilla at mail.berlios.de Wed Jul 4 19:55:03 2007 From: kirilla at mail.berlios.de (kirilla at BerliOS) Date: Wed, 4 Jul 2007 19:55:03 +0200 Subject: [Haiku-commits] r21553 - haiku/trunk/src/bin/desklink Message-ID: <200707041755.l64Ht3ZG025355@sheep.berlios.de> Author: kirilla Date: 2007-07-04 19:55:03 +0200 (Wed, 04 Jul 2007) New Revision: 21553 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21553&view=rev Modified: haiku/trunk/src/bin/desklink/desklink.cpp Log: More readable use of the BDeskbar API when removing desklink replicants. Clean ups. Modified: haiku/trunk/src/bin/desklink/desklink.cpp =================================================================== --- haiku/trunk/src/bin/desklink/desklink.cpp 2007-07-04 17:33:22 UTC (rev 21552) +++ haiku/trunk/src/bin/desklink/desklink.cpp 2007-07-04 17:55:03 UTC (rev 21553) @@ -42,7 +42,7 @@ #define SET_VOLUME_WHICH 'svwh' #define VOLUME_CTL_NAME "MediaReplicant" - /* R5 name needed, Media prefs manel removes by name */ + // R5 name needed, Media prefs manel removes by name #define SETTINGS_FILE "x-vnd.Haiku-desklink" @@ -82,9 +82,9 @@ BBitmap* fSegments; VolumeSlider* fVolumeSlider; bool fDontBeep; - /* don't beep on volume change */ + // don't beep on volume change int32 fVolumeWhich; - /* which volume parameter to act on (Mixer/Phys.Output) */ + // which volume parameter to act on (Mixer/Phys.Output) }; // @@ -312,7 +312,7 @@ void MediaReplicant::MouseUp(BPoint point) { - /* don't Quit() ! thanks for FFM users */ + // don't Quit() ! thanks for FFM users } @@ -363,40 +363,44 @@ bool atLeastOnePath = false; BList titleList; BList actionList; + BDeskbar deskbar; + status_t err = B_OK; for (int32 i = 1; argv[i]!=NULL; i++) { if (strcmp(argv[i], "--help") == 0) break; if (strcmp(argv[i], "--list") == 0) { - BDeskbar db; int32 i, found = 0, count; - count = db.CountItems(); + count = deskbar.CountItems(); printf("Deskbar items:\n"); - /* the API is doomed, so don't try to enum for too long */ + // the API is doomed, so don't try to enum for too long for (i = 0; (found < count) && (i >= 0) && (i < 5000); i++) { - const char scratch[2] = ""; /* BDeskbar is buggy */ + const char scratch[2] = ""; // BDeskbar is buggy const char *name=scratch; - if (db.GetItemInfo(i, &name) >= B_OK) { + if (deskbar.GetItemInfo(i, &name) >= B_OK) { found++; printf("Item %ld: '%s'\n", i, name); - free((void *)name); /* INTENDED */ + free((void *)name); // INTENDED } } return 0; } if (strcmp(argv[i], "--remove") == 0) { - BDeskbar db; int32 found = 0; - uint32 count = db.CountItems(); - /* BDeskbar is definitely doomed ! */ - while ((db.RemoveItem("DeskButton") == B_OK) && (db.CountItems() < count)) { - count = db.CountItems(); + int32 found_id; + while (deskbar.GetItemInfo("DeskButton", &found_id) == B_OK) { + err = deskbar.RemoveItem(found_id); + if (err != B_OK) { + printf("desklink: Error removing replicant id %ld: %s\n", + found_id, strerror(err)); + break; + } found++; } - printf("removed %ld items.\n", found); - return 0; + printf("Removed %ld items.\n", found); + return err; } if (strncmp(argv[i], "cmd=", 4) == 0) { @@ -425,7 +429,7 @@ entry_ref ref; entry.GetRef(&ref); - status_t err = BDeskbar().AddItem(new DeskButton(BRect(0, 0, 15, 15), + err = deskbar.AddItem(new DeskButton(BRect(0, 0, 15, 15), &ref, "DeskButton", titleList, actionList)); if (err != B_OK) { printf("desklink: Deskbar refuses link to '%s': %s\n", argv[i], strerror(err)); @@ -436,7 +440,6 @@ } if (!atLeastOnePath) { - // print a simple usage string printf( "usage: desklink { [ --list|--remove|[cmd=title:action ... ] path ] } ...\n" "--list: list all Deskbar addons.\n" "--remove: delete all desklink addons.\n"); From axeld at mail.berlios.de Wed Jul 4 20:48:17 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 4 Jul 2007 20:48:17 +0200 Subject: [Haiku-commits] r21554 - haiku/trunk/src/kits/storage Message-ID: <200707041848.l64ImHFe028908@sheep.berlios.de> Author: axeld Date: 2007-07-04 20:48:16 +0200 (Wed, 04 Jul 2007) New Revision: 21554 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21554&view=rev Modified: haiku/trunk/src/kits/storage/Jamfile haiku/trunk/src/kits/storage/PathMonitor.cpp Log: * Added a work-around if the file to be watched does actually exist when starting to watch it. * Now adds the path to be watched to the update message (not the path of the file that actually changed, though). * Made debug output conditionally compiled in when TRACE_PATH_MONITOR is defined. * Added PathMonitor.cpp to libbe.so Modified: haiku/trunk/src/kits/storage/Jamfile =================================================================== --- haiku/trunk/src/kits/storage/Jamfile 2007-07-04 17:55:03 UTC (rev 21553) +++ haiku/trunk/src/kits/storage/Jamfile 2007-07-04 18:48:16 UTC (rev 21554) @@ -28,6 +28,7 @@ NodeMonitor.cpp OffsetFile.cpp Path.cpp + PathMonitor.cpp Query.cpp QueryPredicate.cpp ResourceFile.cpp Modified: haiku/trunk/src/kits/storage/PathMonitor.cpp =================================================================== --- haiku/trunk/src/kits/storage/PathMonitor.cpp 2007-07-04 17:55:03 UTC (rev 21553) +++ haiku/trunk/src/kits/storage/PathMonitor.cpp 2007-07-04 18:48:16 UTC (rev 21554) @@ -24,6 +24,14 @@ #include #include +#undef TRACE +//#define TRACE_PATH_MONITOR +#ifdef TRACE_PATH_MONITOR +# define TRACE(x) printf x +#else +# define TRACE(x) ; +#endif + using namespace BPrivate; using namespace std; @@ -57,7 +65,9 @@ void Quit(); virtual void MessageReceived(BMessage* message); +#ifdef TRACE_PATH_MONITOR void Dump(); +#endif private: status_t _GetClosest(const char* path, bool updatePath, @@ -166,6 +176,11 @@ looper->Unlock(); fStatus = _AddDirectory(nodeRef); + + // TODO: work-around for existing files (should not watch the directory in this case) + BEntry entry(path); + if (entry.Exists() && !entry.IsDirectory()) + _AddFile(entry); } @@ -189,6 +204,7 @@ } +#ifdef TRACE_PATH_MONITOR void PathHandler::Dump() { @@ -205,6 +221,7 @@ printf(" %ld:%Ld\n", j->device, j->node); } } +#endif status_t @@ -282,8 +299,8 @@ // ignore the directory if it's already known if (entry.GetNodeRef(&nodeRef) == B_OK && _HasDirectory(nodeRef)) { - printf(" WE ALREADY HAVE DIR %s, %ld:%Ld\n", - name, nodeRef.device, nodeRef.node); + TRACE((" WE ALREADY HAVE DIR %s, %ld:%Ld\n", + name, nodeRef.device, nodeRef.node)); return; } @@ -294,7 +311,7 @@ || _WatchFilesOnly()) notify = parentContained; } else if (entryContained) { - printf(" NEW ENTRY PARENT CONTAINED: %d\n", parentContained); + TRACE((" NEW ENTRY PARENT CONTAINED: %d\n", parentContained)); _AddFile(entry); } @@ -364,9 +381,9 @@ // something has been added to our watched directories nodeRef.node = node; -printf(" ADDED TO PARENT (%d), has entry %d/%d, entry %d %d\n", -parentContained, _HasDirectory(nodeRef), _HasFile(nodeRef), -entryContained, _CloserToPath(entry)); + TRACE((" ADDED TO PARENT (%d), has entry %d/%d, entry %d %d\n", + parentContained, _HasDirectory(nodeRef), _HasFile(nodeRef), + entryContained, _CloserToPath(entry))); if (entry.IsDirectory()) { if (!_HasDirectory(nodeRef) @@ -468,7 +485,9 @@ break; } +#ifdef TRACE_PATH_MONITOR Dump(); +#endif } @@ -538,6 +557,8 @@ { BMessage update(*message); update.what = B_PATH_MONITOR; + update.AddString("path", fPath.Path()); + fTarget.SendMessage(&update); } @@ -550,13 +571,13 @@ if (status != B_OK) return status; -//#ifdef TRACE_MONITOR +#ifdef TRACE_PATH_MONITOR { BPath path(&entry); printf(" ADD DIRECTORY %s, %ld:%Ld\n", path.Path(), directory.node.device, directory.node.node); } -//#endif +#endif // check if we are already know this directory @@ -607,7 +628,7 @@ status_t PathHandler::_RemoveDirectory(const node_ref& nodeRef, ino_t directoryNode) { - printf(" REMOVE DIRECTORY %ld:%Ld\n", nodeRef.device, nodeRef.node); + TRACE((" REMOVE DIRECTORY %ld:%Ld\n", nodeRef.device, nodeRef.node)); watched_directory directory; directory.node = nodeRef; @@ -661,10 +682,12 @@ if ((fFlags & (WATCH_NODE_FLAG_MASK & ~B_WATCH_DIRECTORY)) == 0) return B_OK; +#ifdef TRACE_PATH_MONITOR { BPath path(&entry); printf(" ADD FILE %s\n", path.Path()); } +#endif node_ref nodeRef; status_t status = entry.GetNodeRef(&nodeRef); @@ -688,7 +711,7 @@ status_t PathHandler::_RemoveFile(const node_ref& nodeRef) { - printf(" REMOVE FILE %ld:%Ld\n", nodeRef.device, nodeRef.node); + TRACE((" REMOVE FILE %ld:%Ld\n", nodeRef.device, nodeRef.node)); FileSet::iterator iterator = fFiles.find(nodeRef); if (iterator == fFiles.end()) From axeld at mail.berlios.de Wed Jul 4 20:53:51 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 4 Jul 2007 20:53:51 +0200 Subject: [Haiku-commits] r21555 - haiku/trunk/src/servers/net Message-ID: <200707041853.l64IrpYc029409@sheep.berlios.de> Author: axeld Date: 2007-07-04 20:53:51 +0200 (Wed, 04 Jul 2007) New Revision: 21555 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21555&view=rev Modified: haiku/trunk/src/servers/net/Jamfile haiku/trunk/src/servers/net/NetServer.cpp haiku/trunk/src/servers/net/Services.cpp haiku/trunk/src/servers/net/Settings.cpp Log: * Now uses BPathMonitor instead of the node monitor; this fixes several issues with changes to settings files that were ignored (for example, watching "services" did only work if "interfaces" existed). * On services update, Services::_Update() accidently compared the pointers of the service objects, instead of the objects themselves. * Implemented comparison of address changes in service objects; IOW when you change the addresses a service should bind itself to, but leave the rest of the service unchanged, this will now be detected as well. Modified: haiku/trunk/src/servers/net/Jamfile =================================================================== --- haiku/trunk/src/servers/net/Jamfile 2007-07-04 18:48:16 UTC (rev 21554) +++ haiku/trunk/src/servers/net/Jamfile 2007-07-04 18:53:51 UTC (rev 21555) @@ -1,6 +1,6 @@ SubDir HAIKU_TOP src servers net ; -UsePrivateHeaders app net ; +UsePrivateHeaders app net storage ; #UseHeaders [ FDirName $(HAIKU_TOP) src add-ons kernel network ppp shared libppp headers ] ; #UseHeaders [ FDirName $(HAIKU_TOP) src add-ons kernel network ppp shared libkernelppp headers ] ; Modified: haiku/trunk/src/servers/net/NetServer.cpp =================================================================== --- haiku/trunk/src/servers/net/NetServer.cpp 2007-07-04 18:48:16 UTC (rev 21554) +++ haiku/trunk/src/servers/net/NetServer.cpp 2007-07-04 18:53:51 UTC (rev 21555) @@ -16,8 +16,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -278,7 +278,7 @@ NetServer::MessageReceived(BMessage* message) { switch (message->what) { - case B_NODE_MONITOR: + case B_PATH_MONITOR: fSettings.Update(message); break; Modified: haiku/trunk/src/servers/net/Services.cpp =================================================================== --- haiku/trunk/src/servers/net/Services.cpp 2007-07-04 18:48:16 UTC (rev 21554) +++ haiku/trunk/src/servers/net/Services.cpp 2007-07-04 18:53:51 UTC (rev 21555) @@ -30,6 +30,8 @@ int type; int protocol; sockaddr address; + + bool operator==(const struct service_address& other) const; }; typedef vector AddressList; @@ -42,8 +44,8 @@ AddressList addresses; ~service(); - bool operator!=(const struct service& other); - bool operator==(const struct service& other); + bool operator!=(const struct service& other) const; + bool operator==(const struct service& other) const; }; @@ -86,6 +88,20 @@ // #pragma mark - +bool +service_address::operator==(const struct service_address& other) const +{ + return family == other.family + && type == other.type + && protocol == other.protocol + && address.sa_len == other.address.sa_len + && !memcmp(&address, &other.address, address.sa_len); +} + + +// #pragma mark - + + service::~service() { // close all open sockets @@ -99,20 +115,38 @@ bool -service::operator!=(const struct service& other) +service::operator!=(const struct service& other) const { return !(*this == other); } bool -service::operator==(const struct service& other) +service::operator==(const struct service& other) const { if (name != other.name - || launch != other.launch) + || launch != other.launch + || addresses.size() != other.addresses.size()) return false; - // TODO: compare addresses! + // compare addresses + + AddressList::const_iterator iterator = addresses.begin(); + for (; iterator != addresses.end(); iterator++) { + const service_address& address = *iterator; + + // find address in other addresses + + AddressList::const_iterator otherIterator = other.addresses.begin(); + for (; otherIterator != other.addresses.end(); otherIterator++) { + if (address == *otherIterator) + break; + } + + if (otherIterator == other.addresses.end()) + return false; + } + return true; } @@ -419,7 +453,7 @@ } else { // this service does already exist - check for any changes - if (service != iterator->second) { + if (*service != *iterator->second) { _StopService(*iterator->second); _StartService(*service); } Modified: haiku/trunk/src/servers/net/Settings.cpp =================================================================== --- haiku/trunk/src/servers/net/Settings.cpp 2007-07-04 18:48:16 UTC (rev 21554) +++ haiku/trunk/src/servers/net/Settings.cpp 2007-07-04 18:53:51 UTC (rev 21555) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -11,8 +11,9 @@ #include #include -#include +#include #include +#include #include #include @@ -158,7 +159,8 @@ } } - if (settingsTemplate->type == B_MESSAGE_TYPE && parameter.parameter_count > 0) { + if (settingsTemplate->type == B_MESSAGE_TYPE + && parameter.parameter_count > 0) { status_t status = B_OK; BMessage subMessage; for (int32 j = 0; j < parameter.parameter_count; j++) { @@ -248,17 +250,7 @@ if (status < B_OK) return status; - BNode node; - status = node.SetTo(path.Path()); - if (status < B_OK) - return status; - - node_ref ref; - status = node.GetNodeRef(&ref); - if (status < B_OK) - return status; - - return watch_node(&ref, name != NULL ? B_WATCH_STAT : B_WATCH_DIRECTORY, + return BPrivate::BPathMonitor::StartWatching(path.Path(), B_WATCH_STAT, target); } @@ -273,10 +265,8 @@ fListener = target; - status_t status = _StartWatching(NULL, target); + status_t status = _StartWatching("interfaces", target); if (status == B_OK) - status = _StartWatching("interfaces", target); - if (status == B_OK) status = _StartWatching("services", target); return status; @@ -288,24 +278,37 @@ { // TODO: this needs to be changed in case the server will watch // anything else but settings - return stop_watching(target); + return BPrivate::BPathMonitor::StopWatching(target); } status_t Settings::Update(BMessage* message) { - const char* name; + message->PrintToStream(); + const char* pathName; int32 opcode; if (message->FindInt32("opcode", &opcode) < B_OK - || message->FindString("name", &name) < B_OK) + || message->FindString("path", &pathName) < B_OK) return B_BAD_VALUE; - if (opcode == B_ENTRY_REMOVED) + if (message->FindBool("removed")) { + // for now, we only consider existing settings files + // (ie. deleting "services" won't stop any) return B_OK; + } + int32 fields; + if (opcode == B_STAT_CHANGED + && message->FindInt32("fields", &fields) == B_OK + && (fields & FS_WRITE_STAT_MTIME) == 0) { + // only update when the modified time has changed + return B_OK; + } + + BPath path(pathName); uint32 type; - if (_Load(name, &type) == B_OK) { + if (_Load(path.Leaf(), &type) == B_OK) { BMessage update(type); fListener.SendMessage(&update); } From axeld at mail.berlios.de Wed Jul 4 21:42:17 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 4 Jul 2007 21:42:17 +0200 Subject: [Haiku-commits] r21556 - haiku/trunk/src/servers/net Message-ID: <200707041942.l64JgHoa000878@sheep.berlios.de> Author: axeld Date: 2007-07-04 21:42:16 +0200 (Wed, 04 Jul 2007) New Revision: 21556 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21556&view=rev Modified: haiku/trunk/src/servers/net/Settings.cpp haiku/trunk/src/servers/net/Settings.h Log: Optionally allows a different settings format; now you can write: interface /dev/net/... { ... } instead of: interface { device /dev/net/... ... } This will also work with service::name, and address::family. Modified: haiku/trunk/src/servers/net/Settings.cpp =================================================================== --- haiku/trunk/src/servers/net/Settings.cpp 2007-07-04 18:53:51 UTC (rev 21555) +++ haiku/trunk/src/servers/net/Settings.cpp 2007-07-04 19:42:16 UTC (rev 21556) @@ -20,10 +20,17 @@ #include +struct settings_template { + uint32 type; + const char* name; + const settings_template* sub_template; + bool parent_value; +}; + // Interface templates const static settings_template kInterfaceAddressTemplate[] = { - {B_STRING_TYPE, "family", NULL}, + {B_STRING_TYPE, "family", NULL, true}, {B_STRING_TYPE, "address", NULL}, {B_STRING_TYPE, "mask", NULL}, {B_STRING_TYPE, "peer", NULL}, @@ -34,7 +41,7 @@ }; const static settings_template kInterfaceTemplate[] = { - {B_STRING_TYPE, "device", NULL}, + {B_STRING_TYPE, "device", NULL, true}, {B_MESSAGE_TYPE, "address", kInterfaceAddressTemplate}, {B_INT32_TYPE, "flags", NULL}, {B_INT32_TYPE, "metric", NULL}, @@ -50,7 +57,7 @@ // Service templates const static settings_template kServiceAddressTemplate[] = { - {B_STRING_TYPE, "family", NULL}, + {B_STRING_TYPE, "family", NULL, true}, {B_STRING_TYPE, "type", NULL}, {B_STRING_TYPE, "protocol", NULL}, {B_STRING_TYPE, "address", NULL}, @@ -59,7 +66,7 @@ }; const static settings_template kServiceTemplate[] = { - {B_STRING_TYPE, "name", NULL}, + {B_STRING_TYPE, "name", NULL, true}, {B_MESSAGE_TYPE, "address", kServiceAddressTemplate}, {B_STRING_TYPE, "user", NULL}, {B_STRING_TYPE, "group", NULL}, @@ -129,36 +136,64 @@ } -status_t -Settings::_ConvertFromDriverParameter(const driver_parameter& parameter, - const settings_template* settingsTemplate, BMessage& message) +const settings_template* +Settings::_FindParentValueTemplate(const settings_template* settingsTemplate) { - settingsTemplate = _FindSettingsTemplate(settingsTemplate, parameter.name); - if (settingsTemplate == NULL) { - fprintf(stderr, "unknown parameter %s\n", parameter.name); - return B_BAD_VALUE; + settingsTemplate = settingsTemplate->sub_template; + if (settingsTemplate == NULL) + return NULL; + + while (settingsTemplate->name != NULL) { + if (settingsTemplate->parent_value) + return settingsTemplate; + + settingsTemplate++; } + return NULL; +} + + +status_t +Settings::_AddParameter(const driver_parameter& parameter, const char* name, + uint32 type, BMessage& message) +{ for (int32 i = 0; i < parameter.value_count; i++) { - switch (settingsTemplate->type) { + switch (type) { case B_STRING_TYPE: - message.AddString(parameter.name, parameter.values[i]); + message.AddString(name, parameter.values[i]); break; case B_INT32_TYPE: - message.AddInt32(parameter.name, atoi(parameter.values[i])); + message.AddInt32(name, atoi(parameter.values[i])); break; case B_BOOL_TYPE: if (!strcasecmp(parameter.values[i], "true") || !strcasecmp(parameter.values[i], "on") || !strcasecmp(parameter.values[i], "enabled") || !strcasecmp(parameter.values[i], "1")) - message.AddBool(parameter.name, true); + message.AddBool(name, true); else - message.AddBool(parameter.name, false); + message.AddBool(name, false); break; } } + return B_OK; +} + + +status_t +Settings::_ConvertFromDriverParameter(const driver_parameter& parameter, + const settings_template* settingsTemplate, BMessage& message) +{ + settingsTemplate = _FindSettingsTemplate(settingsTemplate, parameter.name); + if (settingsTemplate == NULL) { + fprintf(stderr, "unknown parameter %s\n", parameter.name); + return B_BAD_VALUE; + } + + _AddParameter(parameter, parameter.name, settingsTemplate->type, message); + if (settingsTemplate->type == B_MESSAGE_TYPE && parameter.parameter_count > 0) { status_t status = B_OK; @@ -168,6 +203,13 @@ settingsTemplate->sub_template, subMessage); if (status < B_OK) break; + + const settings_template* parentValueTemplate + = _FindParentValueTemplate(settingsTemplate); + if (parentValueTemplate != NULL) { + _AddParameter(parameter, parentValueTemplate->name, + parentValueTemplate->type, subMessage); + } } if (status == B_OK) message.AddMessage(parameter.name, &subMessage); Modified: haiku/trunk/src/servers/net/Settings.h =================================================================== --- haiku/trunk/src/servers/net/Settings.h 2007-07-04 18:53:51 UTC (rev 21555) +++ haiku/trunk/src/servers/net/Settings.h 2007-07-04 19:42:16 UTC (rev 21556) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -13,16 +13,11 @@ #include #include + class BPath; +struct settings_template; -struct settings_template { - uint32 type; - const char* name; - const settings_template* sub_template; -}; - - class Settings { public: Settings(); @@ -42,8 +37,13 @@ status_t _GetPath(const char* name, BPath& path); status_t _StartWatching(const char* name, const BMessenger& target); - const settings_template* _FindSettingsTemplate(const settings_template* settingsTemplate, - const char* name); + const settings_template* _FindSettingsTemplate( + const settings_template* settingsTemplate, const char* name); + const settings_template* _FindParentValueTemplate( + const settings_template* settingsTemplate); + status_t _AddParameter(const driver_parameter& parameter, + const char* name, uint32 type, BMessage& message); + status_t _ConvertFromDriverParameter(const driver_parameter& parameter, const settings_template* settingsTemplate, BMessage& message); status_t _ConvertFromDriverSettings(const driver_settings& settings, From jackburton at mail.berlios.de Wed Jul 4 22:11:19 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Wed, 4 Jul 2007 22:11:19 +0200 Subject: [Haiku-commits] r21557 - haiku/trunk/src/apps/terminal Message-ID: <200707042011.l64KBJt4003101@sheep.berlios.de> Author: jackburton Date: 2007-07-04 22:11:17 +0200 (Wed, 04 Jul 2007) New Revision: 21557 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21557&view=rev Added: haiku/trunk/src/apps/terminal/Coding.cpp Modified: haiku/trunk/src/apps/terminal/CodeConv.cpp haiku/trunk/src/apps/terminal/Coding.h haiku/trunk/src/apps/terminal/Jamfile haiku/trunk/src/apps/terminal/MenuUtil.cpp haiku/trunk/src/apps/terminal/MenuUtil.h haiku/trunk/src/apps/terminal/PrefHandler.cpp haiku/trunk/src/apps/terminal/PrefView.cpp haiku/trunk/src/apps/terminal/TermApp.cpp haiku/trunk/src/apps/terminal/TermApp.h haiku/trunk/src/apps/terminal/TermParse.cpp haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermWindow.cpp haiku/trunk/src/apps/terminal/TermWindow.h haiku/trunk/src/apps/terminal/Terminal.cpp Log: Big refactoring. Got rid of some global variables by putting code in global functions (at least for now), removed useless globals, restyled the code. Not yet done. Modified: haiku/trunk/src/apps/terminal/CodeConv.cpp =================================================================== --- haiku/trunk/src/apps/terminal/CodeConv.cpp 2007-07-04 19:42:16 UTC (rev 21556) +++ haiku/trunk/src/apps/terminal/CodeConv.cpp 2007-07-04 20:11:17 UTC (rev 21557) @@ -61,10 +61,6 @@ int32 CodeConv::ConvertFromInternal(const char *src, int32 srclen, char *dst, int coding) { - int32 dstlen = 0; - long state = 0; - int theCoding; - if (srclen == -1) srclen = strlen(src); @@ -74,11 +70,10 @@ return srclen; } - theCoding = coding_translation_table[coding]; + int theCoding = coding_translation_table[coding]; - - dstlen = srclen * 256; - + int32 dstlen = srclen * 256; + long state = 0; convert_from_utf8(theCoding, (char *)src, &srclen, (char *)dst, &dstlen, &state, '?'); @@ -97,10 +92,6 @@ int32 CodeConv::ConvertToInternal(const char *src, int32 srclen, char *dst, int coding) { - int32 dstlen = 4; - long state = 0; - int theCoding; - if (srclen == -1) srclen = strlen(src); @@ -126,8 +117,9 @@ #endif #endif - theCoding = coding_translation_table[coding]; - + int theCoding = coding_translation_table[coding]; + int32 dstlen = 4; + long state = 0; convert_to_utf8(theCoding, (char *)src, &srclen, (char *)dst, &dstlen, &state, '?'); Added: haiku/trunk/src/apps/terminal/Coding.cpp =================================================================== --- haiku/trunk/src/apps/terminal/Coding.cpp 2007-07-04 19:42:16 UTC (rev 21556) +++ haiku/trunk/src/apps/terminal/Coding.cpp 2007-07-04 20:11:17 UTC (rev 21557) @@ -0,0 +1,122 @@ +#include "Coding.h" + +struct etable { + const char *name; // long name for menu item. + const char *shortname; // short name (use for command-line etc.) + const char shortcut; // short cut key code + const uint32 id; // encoding id +}; + + +/* + * encoding_table ... use encoding menu, message, and preference keys. + */ +const static etable kEncodingTable[] = +{ + {"UTF-8", "UTF8", 'U', M_UTF8}, + {"ISO-8859-1", "8859-1", '1', M_ISO_8859_1}, + {"ISO-8859-2", "8859-2", '2', M_ISO_8859_2}, + {"ISO-8859-3", "8859-3", '3', M_ISO_8859_3}, + {"ISO-8859-4", "8859-4", '4', M_ISO_8859_4}, + {"ISO-8859-5", "8859-5", '5', M_ISO_8859_5}, + {"ISO-8859-6", "8859-6", '6', M_ISO_8859_6}, + {"ISO-8859-7", "8859-7", '7', M_ISO_8859_7}, + {"ISO-8859-8", "8859-8", '8', M_ISO_8859_8}, + {"ISO-8859-9", "8859-9", '9', M_ISO_8859_9}, + {"ISO-8859-10", "8859-10", '0', M_ISO_8859_10}, + {"MacRoman", "MacRoman",'M', M_MAC_ROMAN}, + {"JIS", "JIS", 'J', M_ISO_2022_JP}, + {"Shift-JIS", "SJIS", 'S', M_SJIS}, + {"EUC-jp", "EUCJ", 'E', M_EUC_JP}, + {"EUC-kr", "EUCK", 'K', M_EUC_KR}, + + /* Not Implement. + {"EUC-tw", "EUCT", "T", M_EUC_TW}, + {"Big5", "Big5", 'B', M_BIG5}, + {"ISO-2022-cn", "ISOC", 'C', M_ISO_2022_CN}, + {"ISO-2022-kr", "ISOK", 'R', M_ISO_2022_KR}, + */ + + {NULL, NULL, 0, 0}, +}; + + +static int sCurrentEncoding = M_UTF8; + + +status_t +get_nth_encoding(int i, int *id) +{ + if (id == NULL) + return B_BAD_VALUE; + + if (i < 0 || i >= sizeof(kEncodingTable) / sizeof(etable)) + return B_BAD_INDEX; + + *id = kEncodingTable[i].id; + + return B_OK; +} + + +int +longname2id(const char *longname) +{ + int id = M_UTF8; + const etable *s = kEncodingTable; + + for (int i = 0; s->name; s++, i++) { + if (!strcmp(s->name, longname)) { + id = s->id; + break; + } + } + return id; +} + + +const char * +longname2shortname(const char *longname) +{ + const char *shortName = NULL; + + const etable *p = kEncodingTable; + while (p->name) { + if (!strcmp(p->name, longname)) { + shortName = p->shortname; + break; + } + p++; + } + + return shortName; +} + + +const char * +id2longname(int id) +{ + return kEncodingTable[id].name; +} + + +const char +id2shortcut(int id) +{ + return kEncodingTable[id].shortcut; +} + + +void +SetEncoding(int encoding) +{ + sCurrentEncoding = encoding; +} + + +int +GetEncoding() +{ + return sCurrentEncoding; +} + Modified: haiku/trunk/src/apps/terminal/Coding.h =================================================================== --- haiku/trunk/src/apps/terminal/Coding.h 2007-07-04 19:42:16 UTC (rev 21556) +++ haiku/trunk/src/apps/terminal/Coding.h 2007-07-04 20:11:17 UTC (rev 21557) @@ -82,45 +82,16 @@ B_EUC_KR_CONVERSION /* EUC Korean */ }; -struct etable -{ - const char *name; // long name for menu item. - const char *shortname; // short name (use for command-line etc.) - const char shortcut; // short cut key code - const uint32 op; // encodeing opcode -}; -/* - * encoding_table ... use encoding menu, message, and preference keys. - */ -const etable encoding_table[]= -{ - {"UTF-8", "UTF8", 'U', M_UTF8}, - {"ISO-8859-1", "8859-1", '1', M_ISO_8859_1}, - {"ISO-8859-2", "8859-2", '2', M_ISO_8859_2}, - {"ISO-8859-3", "8859-3", '3', M_ISO_8859_3}, - {"ISO-8859-4", "8859-4", '4', M_ISO_8859_4}, - {"ISO-8859-5", "8859-5", '5', M_ISO_8859_5}, - {"ISO-8859-6", "8859-6", '6', M_ISO_8859_6}, - {"ISO-8859-7", "8859-7", '7', M_ISO_8859_7}, - {"ISO-8859-8", "8859-8", '8', M_ISO_8859_8}, - {"ISO-8859-9", "8859-9", '9', M_ISO_8859_9}, - {"ISO-8859-10", "8859-10", '0', M_ISO_8859_10}, - {"MacRoman", "MacRoman",'M', M_MAC_ROMAN}, - {"JIS", "JIS", 'J', M_ISO_2022_JP}, - {"Shift-JIS", "SJIS", 'S', M_SJIS}, - {"EUC-jp", "EUCJ", 'E', M_EUC_JP}, - {"EUC-kr", "EUCK", 'K', M_EUC_KR}, +status_t get_nth_encoding(int i, int *op); - /* Not Implement. - {"EUC-tw", "EUCT", "T", M_EUC_TW}, - {"Big5", "Big5", 'B', M_BIG5}, - {"ISO-2022-cn", "ISOC", 'C', M_ISO_2022_CN}, - {"ISO-2022-kr", "ISOK", 'R', M_ISO_2022_KR}, - */ +int longname2id(const char *longname); +const char * longname2shortname(const char *longname); +const char * id2longname(int op); +const char id2shortcut(int op); - {NULL, NULL, 0, 0}, -}; +void SetEncoding(int encoding); +int GetEncoding(); #endif /* _CODING_H_ */ Modified: haiku/trunk/src/apps/terminal/Jamfile =================================================================== --- haiku/trunk/src/apps/terminal/Jamfile 2007-07-04 19:42:16 UTC (rev 21556) +++ haiku/trunk/src/apps/terminal/Jamfile 2007-07-04 20:11:17 UTC (rev 21557) @@ -7,6 +7,7 @@ Application Terminal : AppearPrefView.cpp CodeConv.cpp + Coding.cpp CurPos.cpp FindWindow.cpp MenuUtil.cpp Modified: haiku/trunk/src/apps/terminal/MenuUtil.cpp =================================================================== --- haiku/trunk/src/apps/terminal/MenuUtil.cpp 2007-07-04 19:42:16 UTC (rev 21556) +++ haiku/trunk/src/apps/terminal/MenuUtil.cpp 2007-07-04 20:11:17 UTC (rev 21557) @@ -40,44 +40,24 @@ return menu; } -int -longname2op(const char *longname) -{ - int op = M_UTF8; - const etable *s = encoding_table; - - for (int i = 0; s->name; s++, i++) { - if (!strcmp(s->name, longname)) { - op = s->op; - break; - } - } - return op; -} -const char * -op2longname(int op) -{ - return encoding_table[op].name; -} void -MakeEncodingMenu(BMenu *eMenu, int coding, bool flag) +MakeEncodingMenu(BMenu *eMenu, int marked, bool flag) { - const etable *e = encoding_table; + int encoding; int i = 0; - while (e->name) { + while (get_nth_encoding(i, &encoding) == B_OK) { BMessage *msg = new BMessage(MENU_ENCODING); - msg->AddInt32("op", (int32)e->op); + msg->AddInt32("op", (int32)encoding); if (flag) - eMenu->AddItem(new BMenuItem(e->name, msg, e->shortcut)); + eMenu->AddItem(new BMenuItem(id2longname(encoding), msg, id2shortcut(encoding))); else - eMenu->AddItem(new BMenuItem(e->name, msg)); + eMenu->AddItem(new BMenuItem(id2longname(encoding), msg)); - if (i == coding) + if (i == marked) eMenu->ItemAt(i)->SetMarked(true); - e++; i++; } } Modified: haiku/trunk/src/apps/terminal/MenuUtil.h =================================================================== --- haiku/trunk/src/apps/terminal/MenuUtil.h 2007-07-04 19:42:16 UTC (rev 21556) +++ haiku/trunk/src/apps/terminal/MenuUtil.h 2007-07-04 20:11:17 UTC (rev 21557) @@ -12,9 +12,6 @@ #include -#ifdef __cplusplus -extern "C" { -#endif class BPopUpMenu; class BMenu; @@ -22,13 +19,10 @@ BPopUpMenu * MakeMenu(ulong msg, const char **items, const char *defaultItemName); -int longname2op(const char *longname); -const char * op2longname(int op); + void MakeEncodingMenu(BMenu *eMenu, int coding, bool flag); void LoadLocaleFile (PrefHandler *); -#ifdef __cplusplus -} -#endif + #endif Modified: haiku/trunk/src/apps/terminal/PrefHandler.cpp =================================================================== --- haiku/trunk/src/apps/terminal/PrefHandler.cpp 2007-07-04 19:42:16 UTC (rev 21556) +++ haiku/trunk/src/apps/terminal/PrefHandler.cpp 2007-07-04 20:11:17 UTC (rev 21557) @@ -373,7 +373,7 @@ setRGB(PREF_CURSOR_FORE_COLOR, prefs.curfg); setRGB(PREF_SELECT_BACK_COLOR, prefs.selbg); setRGB(PREF_SELECT_FORE_COLOR, prefs.selfg); - setString(PREF_TEXT_ENCODING, encoding_table[prefs.encoding].name); + setString(PREF_TEXT_ENCODING, id2longname(prefs.encoding)); return B_OK; } Modified: haiku/trunk/src/apps/terminal/PrefView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/PrefView.cpp 2007-07-04 19:42:16 UTC (rev 21556) +++ haiku/trunk/src/apps/terminal/PrefView.cpp 2007-07-04 20:11:17 UTC (rev 21557) @@ -58,23 +58,27 @@ PrefView::PrefView (BRect frame, const char *name) :BView (frame, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - fLabel.SetTo(name); + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fLabel.SetTo(name); } + //////////////////////////////////////////////////////////////////////////// // ~PrefView () // Destructor. //////////////////////////////////////////////////////////////////////////// PrefView::~PrefView() { +} -} + const char * PrefView::ViewLabel (void) const { return fLabel.String(); } + + //////////////////////////////////////////////////////////////////////////// // CanApply() // Determines whether view can respont Apply command or not. @@ -82,17 +86,17 @@ bool PrefView::CanApply () { - return true; + return true; } + void PrefView::MessageReceived(BMessage* msg) { - BControl *control; - - switch (msg->what) { + switch (msg->what) { case MSG_TEXT_MODIFIED: { TTextControl* textControl; + BControl *control; if (msg->FindPointer("source", (void**)&control) >= B_OK && (textControl = dynamic_cast(control))) { textControl->ModifiedText(true); @@ -106,8 +110,6 @@ } - - ////////////////////////////////////////////////////////////////////////////// // SetupBColorControl // Make BColorControl. @@ -115,10 +117,8 @@ BColorControl * PrefView::SetupBColorControl(BPoint p, color_control_layout layout, float cell_size, ulong msg) { - BColorControl *col; - - col = new BColorControl( p, layout, cell_size, "", new BMessage(msg)); - AddChild(col); - return col; + BColorControl *col = new BColorControl( p, layout, cell_size, "", new BMessage(msg)); + AddChild(col); + return col; } Modified: haiku/trunk/src/apps/terminal/TermApp.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-04 19:42:16 UTC (rev 21556) +++ haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-04 20:11:17 UTC (rev 21557) @@ -34,7 +34,6 @@ // Globals PrefHandler *gTermPref; -extern char gWindowName[]; bool gUsageRequested = false; bool gGeometryRequested = false; @@ -336,18 +335,6 @@ status_t TermApp::_MakeTermWindow(BRect &frame) { - const char *encoding = gTermPref->getString(PREF_TEXT_ENCODING); - - // Get encoding name (setenv TTYPE in spawn_shell functions) - const etable *p = encoding_table; - while (p->name) { - if (!strcmp(p->name, encoding)) { - encoding = p->shortname; - break; - } - p++; - } - const char *command = NULL; if (CommandLine.Length() > 0) command = CommandLine.String(); @@ -362,6 +349,8 @@ if (cols < MIN_COLS) gTermPref->setInt32(PREF_COLS, cols = MIN_COLS); + // Get encoding name (setenv TTYPE in spawn_shell functions) + const char *encoding = longname2shortname(gTermPref->getString(PREF_TEXT_ENCODING)); int pfd = spawn_shell(rows, cols, command, encoding); if (pfd < 0) return pfd; Modified: haiku/trunk/src/apps/terminal/TermApp.h =================================================================== --- haiku/trunk/src/apps/terminal/TermApp.h 2007-07-04 19:42:16 UTC (rev 21556) +++ haiku/trunk/src/apps/terminal/TermApp.h 2007-07-04 20:11:17 UTC (rev 21557) @@ -36,9 +36,6 @@ #include -extern int gPfd; -extern char *ptyname; - class TermWindow; class TermParse; class BRect; Modified: haiku/trunk/src/apps/terminal/TermParse.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-04 19:42:16 UTC (rev 21556) +++ haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-04 20:11:17 UTC (rev 21557) @@ -42,8 +42,6 @@ extern int mbcstable[]; /* ESC $ */ -// MuTerminal coding system (global varriable) -int gNowCoding = M_UTF8; #define DEFAULT -1 #define NPARAM 10 // Max parameters @@ -271,11 +269,11 @@ if (GetReaderBuf(c) < B_OK) break; - if (now_coding != gNowCoding) { + if (now_coding != GetEncoding()) { /* * Change coding, change parse table. */ - switch (gNowCoding) { + switch (GetEncoding()) { case M_UTF8: groundtable = utf8_groundtable; break; @@ -301,7 +299,7 @@ break; } parsestate = groundtable; - now_coding = gNowCoding; + now_coding = GetEncoding(); } switch (parsestate[c]) { Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-04 19:42:16 UTC (rev 21556) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-04 20:11:17 UTC (rev 21557) @@ -49,7 +49,6 @@ extern int function_keycode_table[]; extern char *function_key_char_table[]; -extern int gNowCoding; // defined in TermParse.cpp extern PrefHandler *gTermPref; // Global Preference Handler const static rgb_color kTermColorTable[16] = { @@ -1339,9 +1338,9 @@ } else { // input multibyte character - if (gNowCoding != M_UTF8) { + if (GetEncoding() != M_UTF8) { int cnum = fCodeConv->ConvertFromInternal(bytes, numBytes, - (char *)dstbuf, gNowCoding); + (char *)dstbuf, GetEncoding()); write(fTerminalFd, dstbuf, cnum); return; } @@ -1586,10 +1585,10 @@ void TermView::WritePTY(const uchar *text, int numBytes) { - if (gNowCoding != M_UTF8) { + if (GetEncoding() != M_UTF8) { uchar *destBuffer = (uchar *)malloc(numBytes * 3); numBytes = fCodeConv->ConvertFromInternal((char*)text, numBytes, - (char*)destBuffer, gNowCoding); + (char*)destBuffer, GetEncoding()); write(fTerminalFd, destBuffer, numBytes); free(destBuffer); } else { Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-04 19:42:16 UTC (rev 21556) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-04 20:11:17 UTC (rev 21557) @@ -53,11 +53,7 @@ //#define GPL_FILE "/gpl.html" //#define CHLP_FILE "file:///boot/beos/documentation/Shell%20Tools/index.html" -extern int gNowCoding; /* defined TermParce.cpp */ -void SetCoding(int); - - TermWindow::TermWindow(BRect frame, const char* title, int fd) : BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE), fPfd(fd) @@ -180,7 +176,7 @@ fEditmenu->SetTargetForItems(fTermView); // Initialize TermParse - gNowCoding = longname2op(gTermPref->getString(PREF_TEXT_ENCODING)); + SetEncoding(longname2id(gTermPref->getString(PREF_TEXT_ENCODING))); fTermParse = new TermParse(fPfd, this, fTermView, fCodeConv); if (fTermParse->StartThreads() < B_OK) return; @@ -203,7 +199,7 @@ TermWindow::MenusBeginning(void) { // Syncronize Encode Menu Pop-up menu and Preference. - (fEncodingmenu->FindItem(op2longname(gNowCoding)))->SetMarked(true); + (fEncodingmenu->FindItem(id2longname(GetEncoding())))->SetMarked(true); BWindow::MenusBeginning(); } @@ -277,7 +273,7 @@ fEncodingmenu = new BMenu("Font Encoding"); fEncodingmenu->SetRadioMode(true); - MakeEncodingMenu(fEncodingmenu, gNowCoding, true); + MakeEncodingMenu(fEncodingmenu, GetEncoding(), true); fHelpmenu->AddItem(fWindowSizeMenu); fHelpmenu->AddItem(fEncodingmenu); // fHelpmenu->AddItem(fNewFontMenu); @@ -398,8 +394,7 @@ case MENU_ENCODING: { message->FindInt32 ("op", &coding_id); - gNowCoding = coding_id; - SetCoding(coding_id); + SetEncoding(coding_id); break; } // Extended B_SET_PROPERTY. Dispatch this message, @@ -410,8 +405,7 @@ message->GetCurrentSpecifier(&i, &spe); if (!strcmp("encode", spe.FindString("property", i))){ message->FindInt32 ("data", &coding_id); - gNowCoding = coding_id; - SetCoding (coding_id); + SetEncoding (coding_id); message->SendReply(B_REPLY); } else { @@ -427,7 +421,7 @@ message->GetCurrentSpecifier(&i, &spe); if (!strcmp("encode", spe.FindString("property", i))){ BMessage reply(B_REPLY); - reply.AddInt32("result", gNowCoding); + reply.AddInt32("result", GetEncoding()); message->SendReply(&reply); } else if (!strcmp("tty", spe.FindString("property", i))) { @@ -664,20 +658,6 @@ } -//////////////////////////////////////////////////////////////////////////// -// SetCoding -// Set coding utility functions. -//////////////////////////////////////////////////////////////////////////// -void -SetCoding(int coding) -{ - const etable *p = encoding_table; - p += coding; - - gNowCoding = coding; -} - - status_t TermWindow::DoPageSetup() { Modified: haiku/trunk/src/apps/terminal/TermWindow.h =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-04 19:42:16 UTC (rev 21556) +++ haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-04 20:11:17 UTC (rev 21557) @@ -49,7 +49,7 @@ class TermWindow : public BWindow { public: - TermWindow(BRect frame, const char* title, int gPfd); + TermWindow(BRect frame, const char* title, int fd); virtual ~TermWindow(); void TermWinActivate(); Modified: haiku/trunk/src/apps/terminal/Terminal.cpp =================================================================== --- haiku/trunk/src/apps/terminal/Terminal.cpp 2007-07-04 19:42:16 UTC (rev 21556) +++ haiku/trunk/src/apps/terminal/Terminal.cpp 2007-07-04 20:11:17 UTC (rev 21557) @@ -28,7 +28,6 @@ * */ -#include #include "TermApp.h" From jackburton at mail.berlios.de Wed Jul 4 22:20:10 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Wed, 4 Jul 2007 22:20:10 +0200 Subject: [Haiku-commits] r21558 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200707042020.l64KKADi003734@sheep.berlios.de> Author: jackburton Date: 2007-07-04 22:20:09 +0200 (Wed, 04 Jul 2007) New Revision: 21558 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21558&view=rev Modified: haiku/trunk/headers/os/interface/TextView.h haiku/trunk/src/kits/interface/TextView.cpp Log: Added _Show/_HideCaret() and used them in place of more bug-prone code. Modified: haiku/trunk/headers/os/interface/TextView.h =================================================================== --- haiku/trunk/headers/os/interface/TextView.h 2007-07-04 20:11:17 UTC (rev 21557) +++ haiku/trunk/headers/os/interface/TextView.h 2007-07-04 20:20:09 UTC (rev 21558) @@ -337,6 +337,8 @@ int32 startOffset = -1, bool erase = false); void DrawCaret(int32 offset); + void _ShowCaret(); + void _HideCaret(); void InvertCaret(); void DragCaret(int32 offset); Modified: haiku/trunk/src/kits/interface/TextView.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextView.cpp 2007-07-04 20:11:17 UTC (rev 21557) +++ haiku/trunk/src/kits/interface/TextView.cpp 2007-07-04 20:20:09 UTC (rev 21558) @@ -467,9 +467,7 @@ if (!IsFocus()) MakeFocus(); - // hide the caret if it's visible - if (fCaretVisible) - InvertCaret(); + _HideCaret(); StopMouseTracking(); @@ -669,8 +667,7 @@ // hide the cursor and caret be_app->ObscureCursor(); - if (fCaretVisible) - InvertCaret(); + _HideCaret(); switch (keyPressed) { case B_BACKSPACE: @@ -715,10 +712,8 @@ } // draw the caret - if (fSelStart == fSelEnd) { - if (!fCaretVisible) - InvertCaret(); - } + if (fSelStart == fSelEnd) + _ShowCaret(); } @@ -994,8 +989,7 @@ if (fSelStart != fSelEnd) Highlight(fSelStart, fSelEnd); else { - if (fCaretVisible) - InvertCaret(); + _HideCaret(); } } @@ -1012,10 +1006,8 @@ ScrollToOffset(fSelStart); // draw the caret - if (fActive) { - if (!fCaretVisible) - InvertCaret(); - } + if (fActive) + _ShowCaret(); } @@ -1056,10 +1048,8 @@ ScrollToOffset(fSelStart); // draw the caret - if (fActive) { - if (!fCaretVisible) - InvertCaret(); - } + if (fActive) + _ShowCaret(); } @@ -1120,10 +1110,8 @@ if (fActive) { if (fSelStart != fSelEnd) Highlight(fSelStart, fSelEnd); - else { - if (fCaretVisible) - InvertCaret(); - } + else + _HideCaret(); } // remove data from buffer DeleteText(startOffset, endOffset); @@ -1140,10 +1128,8 @@ Refresh(startOffset, endOffset, true, true); // draw the caret - if (fActive) { - if (!fCaretVisible) - InvertCaret(); - } + if (fActive) + _ShowCaret(); } @@ -1383,9 +1369,7 @@ fStyles->InvalidateNullStyle(); - // hide the caret - if (fCaretVisible) - InvertCaret(); + _HideCaret(); if (startOffset == endOffset) { if (fSelStart != fSelEnd) { @@ -2137,8 +2121,7 @@ fStyles->InvalidateNullStyle(); if (Window() != NULL && fActive) { if (!fEditable) { - if (fCaretVisible) - InvertCaret(); + _HideCaret(); CancelInputMethod(); } } @@ -2171,8 +2154,7 @@ if (fSelStart != fSelEnd) Highlight(fSelStart, fSelEnd); else { - if (fCaretVisible) - InvertCaret(); + _HideCaret(); } } @@ -2183,10 +2165,8 @@ // show the caret, hilite the selection if (fSelStart != fSelEnd && fSelectable) Highlight(fSelStart, fSelEnd); - else { - if (!fCaretVisible) - InvertCaret(); - } + else + _ShowCaret(); } } } @@ -2352,8 +2332,8 @@ if (fSelStart != fSelEnd && fSelectable) Highlight(fSelStart, fSelEnd); - else if (fCaretVisible) - InvertCaret(); + else + _HideCaret(); } } } else { @@ -3751,6 +3731,22 @@ } +inline void +BTextView::_ShowCaret() +{ + if (!fCaretVisible) + InvertCaret(); +} + + +inline void +BTextView::_HideCaret() +{ + if (fCaretVisible) + InvertCaret(); +} + + /*! \brief Inverts the blinking caret status. Hides the caret if it is being shown, and if it's hidden, shows it. */ @@ -4170,7 +4166,7 @@ Highlight(fSelStart, fSelEnd); } else { if (fEditable) - InvertCaret(); + _ShowCaret(); } BPoint where; @@ -4194,10 +4190,8 @@ if (fSelStart != fSelEnd) { if (fSelectable) Highlight(fSelStart, fSelEnd); - } else { - if (fCaretVisible) - InvertCaret(); - } + } else + _HideCaret(); BPoint where; ulong buttons; From axeld at mail.berlios.de Thu Jul 5 00:11:25 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 5 Jul 2007 00:11:25 +0200 Subject: [Haiku-commits] r21559 - haiku/trunk/headers/compatibility/bsd Message-ID: <200707042211.l64MBPAH013016@sheep.berlios.de> Author: axeld Date: 2007-07-05 00:11:24 +0200 (Thu, 05 Jul 2007) New Revision: 21559 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21559&view=rev Modified: haiku/trunk/headers/compatibility/bsd/paths.h Log: * Adapted the path of "login" - eventually, telnetd should just use the standard $PATH, though. * Telnetting into Haiku is now finally working as expected. Modified: haiku/trunk/headers/compatibility/bsd/paths.h =================================================================== --- haiku/trunk/headers/compatibility/bsd/paths.h 2007-07-04 20:20:09 UTC (rev 21558) +++ haiku/trunk/headers/compatibility/bsd/paths.h 2007-07-04 22:11:24 UTC (rev 21559) @@ -66,7 +66,7 @@ #define _PATH_KMEM "/dev/kmem" #define _PATH_LIBMAP_CONF "/etc/libmap.conf" #define _PATH_LOCALE "/usr/share/locale" -#define _PATH_LOGIN "/usr/bin/login" +#define _PATH_LOGIN "/bin/login" #define _PATH_MAILDIR "/var/mail" #define _PATH_MAN "/usr/share/man" #define _PATH_MDCONFIG "/sbin/mdconfig" @@ -77,14 +77,14 @@ #define _PATH_NOLOGIN "/var/run/nologin" #define _PATH_RCP "/bin/rcp" #define _PATH_REBOOT "/sbin/reboot" -#define _PATH_RLOGIN "/usr/bin/rlogin" +#define _PATH_RLOGIN "/bin/rlogin" #define _PATH_RM "/bin/rm" #define _PATH_RSH "/usr/bin/rsh" #define _PATH_SENDMAIL "/usr/sbin/sendmail" #define _PATH_SHELLS "/etc/shells" #define _PATH_TTY "/dev/tty" #define _PATH_UNIX "don't use _PATH_UNIX" -#define _PATH_VI "/usr/bin/vi" +#define _PATH_VI "/bin/vim" #define _PATH_WALL "/usr/bin/wall" /* Provide trailing slash, since mostly used for building pathnames. */ From bonefish at mail.berlios.de Thu Jul 5 00:26:30 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 5 Jul 2007 00:26:30 +0200 Subject: [Haiku-commits] r21560 - in haiku/trunk/src: build/libbe/storage build/libhaikucompat tools Message-ID: <200707042226.l64MQUWR015424@sheep.berlios.de> Author: bonefish Date: 2007-07-05 00:26:29 +0200 (Thu, 05 Jul 2007) New Revision: 21560 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21560&view=rev Modified: haiku/trunk/src/build/libbe/storage/AppFileInfo.cpp haiku/trunk/src/build/libhaikucompat/Jamfile haiku/trunk/src/tools/Jamfile Log: Temporary kludge to fix the build problem under BeOS regarding missing icons for add-ons/libraries that don't have a signature. I threw our BAppFileInfo code into libhaikucompat_build.a and link mimeset and setversion against it, thus overriding the uncooperative BAppFileInfo implementation in the host platform's libbe. Earlier or later we should use libbe_build.so on BeOS compatible platforms as well, though. Modified: haiku/trunk/src/build/libbe/storage/AppFileInfo.cpp =================================================================== --- haiku/trunk/src/build/libbe/storage/AppFileInfo.cpp 2007-07-04 22:11:24 UTC (rev 21559) +++ haiku/trunk/src/build/libbe/storage/AppFileInfo.cpp 2007-07-04 22:26:29 UTC (rev 21560) @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include Modified: haiku/trunk/src/build/libhaikucompat/Jamfile =================================================================== --- haiku/trunk/src/build/libhaikucompat/Jamfile 2007-07-04 22:11:24 UTC (rev 21559) +++ haiku/trunk/src/build/libhaikucompat/Jamfile 2007-07-04 22:26:29 UTC (rev 21560) @@ -9,12 +9,29 @@ libbeTestSources = misc.cpp syscalls.cpp ; } +# TODO: This is a temporary kludge. We should actually build libbe_build.so +# and use it for the build tools even on BeOS compatible platforms. For the +# time being we build the classes we need (BAppFileInfo and its dependencies) +# into libhaikucompat_build.a. +local libbePatchSources ; +if $(HOST_PLATFORM) in r5 bone dano { + libbePatchSources += AppFileInfo.cpp Bitmap.cpp GraphicsDefs.cpp ; + ObjectSysHdrs $(libbePatchSources) + : [ FDirName $(HAIKU_TOP) headers build os app ] ; + ObjectSysHdrs $(libbePatchSources) + : [ FDirName $(HAIKU_TOP) headers build os interface ] ; + ObjectSysHdrs $(libbePatchSources) + : [ FDirName $(HAIKU_TOP) headers build os storage ] ; +} + BuildPlatformStaticLibrary libhaikucompat_build.a : atomic.S strcasestr.c strlcat.c strlcpy.c strnlen.c + + $(libbePatchSources) ; StaticLibrary libhaikucompat.a : @@ -30,3 +47,7 @@ = [ FDirName $(HAIKU_TOP) src system libroot posix string ] ; SEARCH on [ FGristFiles atomic.S ] = [ FDirName $(HAIKU_TOP) src system libroot os arch $(HOST_ARCH) ] ; +SEARCH on [ FGristFiles Bitmap.cpp GraphicsDefs.cpp ] + = [ FDirName $(HAIKU_TOP) src build libbe interface ] ; +SEARCH on [ FGristFiles AppFileInfo.cpp ] + = [ FDirName $(HAIKU_TOP) src build libbe storage ] ; Modified: haiku/trunk/src/tools/Jamfile =================================================================== --- haiku/trunk/src/tools/Jamfile 2007-07-04 22:11:24 UTC (rev 21559) +++ haiku/trunk/src/tools/Jamfile 2007-07-04 22:26:29 UTC (rev 21560) @@ -19,6 +19,12 @@ USES_BE_API on $(tools) = true ; +# TODO: temporary kludge +local libHaikuCompat ; +if $(HOST_PLATFORM) in r5 bone dano { + libHaikuCompat = libhaikucompat_build.a ; +} + BuildPlatformMain catattr : catattr.cpp : $(HOST_LIBBE) ; BuildPlatformMain copyattr : copyattr.cpp @@ -35,7 +41,7 @@ database_support.cpp UpdateMimeInfoThread.cpp MimeUpdateThread.cpp - : $(HOST_LIBBE) $(HOST_LIBSTDC++) $(HOST_LIBSUPC++) + : $(HOST_LIBBE) $(HOST_LIBSTDC++) $(HOST_LIBSUPC++) $(libHaikuCompat) ; BuildPlatformMain mkindex : mkindex.cpp : $(HOST_LIBBE) ; @@ -49,7 +55,7 @@ $(HOST_LIBSTDC++) $(HOST_LIBSUPC++) ; BuildPlatformMain setversion : setversion.cpp : $(HOST_LIBBE) - $(HOST_LIBSTDC++) $(HOST_LIBSUPC++) ; + $(HOST_LIBSTDC++) $(HOST_LIBSUPC++) $(libHaikuCompat) ; BuildPlatformMain xres : xres.cpp : $(HOST_LIBBE) $(HOST_LIBSTDC++) $(HOST_LIBSUPC++) ; From axeld at mail.berlios.de Thu Jul 5 00:26:43 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 5 Jul 2007 00:26:43 +0200 Subject: [Haiku-commits] r21561 - in haiku/trunk: build/jam data/settings data/settings/network Message-ID: <200707042226.l64MQhtB015463@sheep.berlios.de> Author: axeld Date: 2007-07-05 00:26:42 +0200 (Thu, 05 Jul 2007) New Revision: 21561 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21561&view=rev Added: haiku/trunk/data/settings/network/ haiku/trunk/data/settings/network/services Modified: haiku/trunk/build/jam/HaikuImage Log: Added default "services" configuration that enables telnetd for now. To log in, user is "baron" (if you haven't overridden the $USER environment variable), and the password is empty (ie. just press return). Note, the password is currently hardcoded into src/system/libroot/posix/pwd.c. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-07-04 22:26:29 UTC (rev 21560) +++ haiku/trunk/build/jam/HaikuImage 2007-07-04 22:26:42 UTC (rev 21561) @@ -315,6 +315,11 @@ AddFilesToHaikuImage home config settings kernel drivers : $(driverSettingsFiles) ; +local networkSettingsFiles = services ; +SEARCH on $(networkSettingsFiles) + = [ FDirName $(HAIKU_TOP) data settings network ] ; +AddFilesToHaikuImage common config settings network : $(networkSettingsFiles) ; + AddSymlinkToHaikuImage home config settings : /boot/beos/etc/timezones/Europe/Paris : timezone ; Added: haiku/trunk/data/settings/network/services =================================================================== --- haiku/trunk/data/settings/network/services 2007-07-04 22:26:29 UTC (rev 21560) +++ haiku/trunk/data/settings/network/services 2007-07-04 22:26:42 UTC (rev 21561) @@ -0,0 +1,3 @@ +service telnet { + launch telnetd +} From axeld at mail.berlios.de Thu Jul 5 01:20:06 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 5 Jul 2007 01:20:06 +0200 Subject: [Haiku-commits] r21562 - in haiku/trunk/headers: build/os/app build/os/storage os/app os/storage Message-ID: <200707042320.l64NK6ic019084@sheep.berlios.de> Author: axeld Date: 2007-07-05 01:20:05 +0200 (Thu, 05 Jul 2007) New Revision: 21562 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21562&view=rev Modified: haiku/trunk/headers/build/os/app/Message.h haiku/trunk/headers/build/os/storage/Node.h haiku/trunk/headers/os/app/Message.h haiku/trunk/headers/os/storage/Node.h Log: Fixed build under Dano (and probably Zeta, too); our headers used entry_ref resp. BDirectory without declaring it first. Since that's an actual bug, I made the changes in the Haiku headers, and copied them back to the build headers. Modified: haiku/trunk/headers/build/os/app/Message.h =================================================================== --- haiku/trunk/headers/build/os/app/Message.h 2007-07-04 22:26:42 UTC (rev 21561) +++ haiku/trunk/headers/build/os/app/Message.h 2007-07-04 23:20:05 UTC (rev 21562) @@ -8,6 +8,7 @@ #ifndef _MESSAGE_H #define _MESSAGE_H + #include #include #include @@ -21,6 +22,7 @@ class BMessenger; class BHandler; class BString; +struct entry_ref; // Name lengths and Scripting specifiers Modified: haiku/trunk/headers/build/os/storage/Node.h =================================================================== --- haiku/trunk/headers/build/os/storage/Node.h 2007-07-04 22:26:42 UTC (rev 21561) +++ haiku/trunk/headers/build/os/storage/Node.h 2007-07-04 23:20:05 UTC (rev 21562) @@ -1,25 +1,15 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -//--------------------------------------------------------------------- -/*! - \file Node.h - BNode and node_ref interface declarations. -*/ - +/* + * Copyright 2002-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _NODE_H #define _NODE_H + #include -#ifdef USE_OPENBEOS_NAMESPACE -namespace OpenBeOS { -#endif +class BDirectory; -//--------------------------------------------------------------- -// node_ref -//--------------------------------------------------------------- - //! Reference structure to a particular vnode on a particular device /*! node_ref - A node reference. @@ -30,7 +20,7 @@ struct node_ref { node_ref(); node_ref(const node_ref &ref); - + bool operator==(const node_ref &ref) const; bool operator!=(const node_ref &ref) const; node_ref& operator=(const node_ref &ref); @@ -40,16 +30,12 @@ return (device < ref.device || device == ref.device && node < ref.node); } - + dev_t device; ino_t node; }; -//--------------------------------------------------------------- -// BNode -//--------------------------------------------------------------- - //! A BNode represents a chunk of data in the filesystem. /*! The BNode class provides an interface for manipulating the data and attributes belonging to filesystem entries. The BNode is unaware of the name that refers @@ -63,7 +49,6 @@ */ class BNode : public BStatable { public: - BNode(); BNode(const entry_ref *ref); BNode(const BEntry *entry); @@ -136,12 +121,4 @@ status_t InitAttrDir(); }; - - -#ifdef USE_OPENBEOS_NAMESPACE -}; // namespace OpenBeOS -#endif - #endif // _NODE_H - - Modified: haiku/trunk/headers/os/app/Message.h =================================================================== --- haiku/trunk/headers/os/app/Message.h 2007-07-04 22:26:42 UTC (rev 21561) +++ haiku/trunk/headers/os/app/Message.h 2007-07-04 23:20:05 UTC (rev 21562) @@ -8,6 +8,7 @@ #ifndef _MESSAGE_H #define _MESSAGE_H + #include #include #include @@ -21,6 +22,7 @@ class BMessenger; class BHandler; class BString; +struct entry_ref; // Name lengths and Scripting specifiers Modified: haiku/trunk/headers/os/storage/Node.h =================================================================== --- haiku/trunk/headers/os/storage/Node.h 2007-07-04 22:26:42 UTC (rev 21561) +++ haiku/trunk/headers/os/storage/Node.h 2007-07-04 23:20:05 UTC (rev 21562) @@ -1,25 +1,15 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -//--------------------------------------------------------------------- -/*! - \file Node.h - BNode and node_ref interface declarations. -*/ - +/* + * Copyright 2002-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _NODE_H #define _NODE_H + #include -#ifdef USE_OPENBEOS_NAMESPACE -namespace OpenBeOS { -#endif +class BDirectory; -//--------------------------------------------------------------- -// node_ref -//--------------------------------------------------------------- - //! Reference structure to a particular vnode on a particular device /*! node_ref - A node reference. @@ -30,20 +20,16 @@ struct node_ref { node_ref(); node_ref(const node_ref &ref); - + bool operator==(const node_ref &ref) const; bool operator!=(const node_ref &ref) const; node_ref& operator=(const node_ref &ref); - + dev_t device; ino_t node; }; -//--------------------------------------------------------------- -// BNode -//--------------------------------------------------------------- - //! A BNode represents a chunk of data in the filesystem. /*! The BNode class provides an interface for manipulating the data and attributes belonging to filesystem entries. The BNode is unaware of the name that refers @@ -57,7 +43,6 @@ */ class BNode : public BStatable { public: - BNode(); BNode(const entry_ref *ref); BNode(const BEntry *entry); @@ -130,12 +115,4 @@ status_t InitAttrDir(); }; - - -#ifdef USE_OPENBEOS_NAMESPACE -}; // namespace OpenBeOS -#endif - #endif // _NODE_H - - From kirilla at mail.berlios.de Thu Jul 5 02:28:03 2007 From: kirilla at mail.berlios.de (kirilla at BerliOS) Date: Thu, 5 Jul 2007 02:28:03 +0200 Subject: [Haiku-commits] r21563 - haiku/trunk/src/bin/desklink Message-ID: <200707050028.l650S3Ug007601@sheep.berlios.de> Author: kirilla Date: 2007-07-05 02:28:02 +0200 (Thu, 05 Jul 2007) New Revision: 21563 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21563&view=rev Modified: haiku/trunk/src/bin/desklink/desklink.cpp Log: Allow application signature as argument. If target has a replicant (e.g. ProcessController) give that precedence over desklink replicant. Modified: haiku/trunk/src/bin/desklink/desklink.cpp =================================================================== --- haiku/trunk/src/bin/desklink/desklink.cpp 2007-07-04 23:20:05 UTC (rev 21562) +++ haiku/trunk/src/bin/desklink/desklink.cpp 2007-07-05 00:28:02 UTC (rev 21563) @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -421,18 +422,30 @@ atLeastOnePath = true; BEntry entry(argv[i], true); - if(!entry.Exists()) { + entry_ref ref; + + if(entry.Exists()) { + entry.GetRef(&ref); + } + else if (BMimeType::IsValid(argv[i])) { + if (be_roster->FindApp(argv[i], &ref) != B_OK) { + printf("desklink: cannot find '%s'\n", argv[i]); + return 1; + } + } + else { printf("desklink: cannot find '%s'\n", argv[i]); return 1; } - - entry_ref ref; - entry.GetRef(&ref); - - err = deskbar.AddItem(new DeskButton(BRect(0, 0, 15, 15), - &ref, "DeskButton", titleList, actionList)); + + err = deskbar.AddItem(&ref); if (err != B_OK) { - printf("desklink: Deskbar refuses link to '%s': %s\n", argv[i], strerror(err)); + err = deskbar.AddItem(new DeskButton(BRect(0, 0, 15, 15), + &ref, "DeskButton", titleList, actionList)); + if (err != B_OK) { + printf("desklink: Deskbar refuses link to '%s': %s\n", argv[i], strerror(err)); + return 1; + } } titleList.MakeEmpty(); @@ -440,7 +453,7 @@ } if (!atLeastOnePath) { - printf( "usage: desklink { [ --list|--remove|[cmd=title:action ... ] path ] } ...\n" + printf( "usage: desklink { [ --list|--remove|[cmd=title:action ... ] [ path|signature ] } ...\n" "--list: list all Deskbar addons.\n" "--remove: delete all desklink addons.\n"); return 1; From darkwyrm at earthlink.net Thu Jul 5 04:30:17 2007 From: darkwyrm at earthlink.net (DarkWyrm) Date: Wed, 04 Jul 2007 22:30:17 -0400 EDT Subject: [Haiku-commits] r21559 - haiku/trunk/headers/compatibility/bsd In-Reply-To: <200707042211.l64MBPAH013016@sheep.berlios.de> Message-ID: <1664306470-BeMail@tourmalline> > Author: axeld > Date: 2007-07-05 00:11:24 +0200 (Thu, 05 Jul 2007) > New Revision: 21559 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21559&view=rev > > Modified: > haiku/trunk/headers/compatibility/bsd/paths.h > Log: > * Adapted the path of "login" - eventually, telnetd should just use > the standard > $PATH, though. > * Telnetting into Haiku is now finally working as expected. Nice! Congratulations! --Jon From axeld at pinc-software.de Thu Jul 5 10:50:16 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 05 Jul 2007 10:50:16 +0200 CEST Subject: [Haiku-commits] r21563 - haiku/trunk/src/bin/desklink In-Reply-To: <200707050028.l650S3Ug007601@sheep.berlios.de> Message-ID: <875814746-BeMail@zon> kirilla at BerliOS wrote: > + if(entry.Exists()) { > + entry.GetRef(&ref); > + } > + else if (BMimeType::IsValid(argv[i])) { > + if (be_roster->FindApp(argv[i], &ref) != B_OK) { > + printf("desklink: cannot find '%s'\n", argv[i]); > + return 1; > + } > + } > + else { That would be: if (...) { ... } else { ... } else { ... IOW: there is a space between "if" and the opening parenthesis, and there is no newline before "else" and the closing bracket. Bye, Axel. From jackburton at mail.berlios.de Thu Jul 5 11:01:59 2007 From: jackburton at mail.berlios.de (jackburton at mail.berlios.de) Date: Thu, 5 Jul 2007 11:01:59 +0200 Subject: [Haiku-commits] r21564 - haiku/trunk/src/kits/interface Message-ID: <200707050901.l6591xiW015011@sheep.berlios.de> Author: jackburton Date: 2007-07-05 11:01:54 +0200 (Thu, 05 Jul 2007) New Revision: 21564 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21564&view=rev Modified: haiku/trunk/src/kits/interface/InterfaceDefs.cpp Log: added default clause to the switch statement. This fixes a memory corruption bug in case the caller supplied an invalid value. Now we use B_TRUNCATE_MIDDLE in that case. Found by Andrea Anzani Modified: haiku/trunk/src/kits/interface/InterfaceDefs.cpp =================================================================== --- haiku/trunk/src/kits/interface/InterfaceDefs.cpp 2007-07-05 00:28:02 UTC (rev 21563) +++ haiku/trunk/src/kits/interface/InterfaceDefs.cpp 2007-07-05 09:01:54 UTC (rev 21564) @@ -1319,6 +1319,7 @@ // TODO: implement, though it was never implemented on R5 // FALL THROUGH (at least do something) case B_TRUNCATE_MIDDLE: + default: truncated = truncate_middle(source, dest, numChars, escapementArray, width, ellipsisWidth, fontSize); break; From superstippi at gmx.de Thu Jul 5 11:27:47 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 05 Jul 2007 11:27:47 +0200 Subject: [Haiku-commits] broken build Message-ID: <20070705112747.985.4@stippis2.1183619996.fake> Hi Ingo, the AppFileInfo change broke the build for me (ZETA). It seems it chokes on the "_IMPEXP_BE" stuff in the headers it includes. Best regards, -Stephan From hannabreuer at arcor.de Thu Jul 5 11:13:21 2007 From: hannabreuer at arcor.de (Hanna Breuer) Date: Thu, 05 Jul 2007 11:13:21 +0200 Subject: [Haiku-commits] broken build Message-ID: <20070705111321.875.3@stippis2.1183619996.fake> Hi Ingo, the AppFileInfo change broke the build for me (ZETA). It seems it chokes on the "_IMPEXP_BE" stuff in the headers it includes. Best regards, -Stephan From kirilla at mail.berlios.de Thu Jul 5 13:47:49 2007 From: kirilla at mail.berlios.de (kirilla at BerliOS) Date: Thu, 5 Jul 2007 13:47:49 +0200 Subject: [Haiku-commits] r21565 - haiku/trunk/src/bin/desklink Message-ID: <200707051147.l65Blnvi008799@sheep.berlios.de> Author: kirilla Date: 2007-07-05 13:47:49 +0200 (Thu, 05 Jul 2007) New Revision: 21565 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21565&view=rev Modified: haiku/trunk/src/bin/desklink/desklink.cpp Log: code style fixes Modified: haiku/trunk/src/bin/desklink/desklink.cpp =================================================================== --- haiku/trunk/src/bin/desklink/desklink.cpp 2007-07-05 09:01:54 UTC (rev 21564) +++ haiku/trunk/src/bin/desklink/desklink.cpp 2007-07-05 11:47:49 UTC (rev 21565) @@ -424,16 +424,14 @@ BEntry entry(argv[i], true); entry_ref ref; - if(entry.Exists()) { + if (entry.Exists()) { entry.GetRef(&ref); - } - else if (BMimeType::IsValid(argv[i])) { + } else if (BMimeType::IsValid(argv[i])) { if (be_roster->FindApp(argv[i], &ref) != B_OK) { printf("desklink: cannot find '%s'\n", argv[i]); return 1; } - } - else { + } else { printf("desklink: cannot find '%s'\n", argv[i]); return 1; } From axeld at mail.berlios.de Thu Jul 5 14:16:22 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 5 Jul 2007 14:16:22 +0200 Subject: [Haiku-commits] r21566 - haiku/trunk/src/servers/net Message-ID: <200707051216.l65CGMki011634@sheep.berlios.de> Author: axeld Date: 2007-07-05 14:16:22 +0200 (Thu, 05 Jul 2007) New Revision: 21566 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21566&view=rev Modified: haiku/trunk/src/servers/net/Services.cpp haiku/trunk/src/servers/net/Services.h Log: * Now a service is quit when it is removed from the settings file. * When deleting the Services handler, it will now also stop all running services, and close the command pipe (since it's only quit when the net_server quits, that wasn't much of a problem, though). Modified: haiku/trunk/src/servers/net/Services.cpp =================================================================== --- haiku/trunk/src/servers/net/Services.cpp 2007-07-05 11:47:49 UTC (rev 21565) +++ haiku/trunk/src/servers/net/Services.cpp 2007-07-05 12:16:22 UTC (rev 21566) @@ -37,11 +37,12 @@ typedef vector AddressList; struct service { - std::string name; + std::string name; std::string launch; - uid_t user; - gid_t group; - AddressList addresses; + uid_t user; + gid_t group; + AddressList addresses; + uint32 update; ~service(); bool operator!=(const struct service& other) const; @@ -187,6 +188,15 @@ Services::~Services() { wait_for_thread(fListener, NULL); + + close(fReadPipe); + close(fWritePipe); + + // stop all services + + while (!fNameMap.empty()) { + _StopService(*fNameMap.begin()->second); + } } @@ -260,6 +270,7 @@ // add service to maps and activate it fNameMap[service.name] = &service; + service.update = fUpdate; iterator = service.addresses.begin(); for (; iterator != service.addresses.end(); iterator++) { @@ -456,9 +467,23 @@ if (*service != *iterator->second) { _StopService(*iterator->second); _StartService(*service); - } + } else + service->update = fUpdate; } } + + // stop all services that are not part of the update message + + ServiceNameMap::iterator iterator = fNameMap.begin(); + while (iterator != fNameMap.end()) { + struct service* service = iterator->second; + iterator++; + + if (service->update != fUpdate) { + // this service has to be removed + _StopService(*service); + } + } } Modified: haiku/trunk/src/servers/net/Services.h =================================================================== --- haiku/trunk/src/servers/net/Services.h 2007-07-05 11:47:49 UTC (rev 21565) +++ haiku/trunk/src/servers/net/Services.h 2007-07-05 12:16:22 UTC (rev 21566) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -48,7 +48,7 @@ BLocker fLock; ServiceNameMap fNameMap; ServiceSocketMap fSocketMap; - int32 fUpdate; + uint32 fUpdate; int fReadPipe; int fWritePipe; int fMinSocket; From axeld at mail.berlios.de Thu Jul 5 14:24:11 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 5 Jul 2007 14:24:11 +0200 Subject: [Haiku-commits] r21567 - haiku/trunk/src/servers/net Message-ID: <200707051224.l65COBqZ012330@sheep.berlios.de> Author: axeld Date: 2007-07-05 14:24:11 +0200 (Thu, 05 Jul 2007) New Revision: 21567 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21567&view=rev Modified: haiku/trunk/src/servers/net/Settings.cpp Log: Accidently left in some debug output. Modified: haiku/trunk/src/servers/net/Settings.cpp =================================================================== --- haiku/trunk/src/servers/net/Settings.cpp 2007-07-05 12:16:22 UTC (rev 21566) +++ haiku/trunk/src/servers/net/Settings.cpp 2007-07-05 12:24:11 UTC (rev 21567) @@ -327,7 +327,6 @@ status_t Settings::Update(BMessage* message) { - message->PrintToStream(); const char* pathName; int32 opcode; if (message->FindInt32("opcode", &opcode) < B_OK From bonefish at cs.tu-berlin.de Thu Jul 5 14:48:06 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Thu, 05 Jul 2007 14:48:06 +0200 Subject: [Haiku-commits] broken build In-Reply-To: <20070705112747.985.4@stippis2.1183619996.fake> References: <20070705112747.985.4@stippis2.1183619996.fake> Message-ID: <20070705144806.541.1@cs.tu-berlin.de> On 2007-07-05 at 11:27:47 [+0200], Stephan Assmus wrote: > > the AppFileInfo change broke the build for me (ZETA). It seems it chokes on > the "_IMPEXP_BE" stuff in the headers it includes. Would you mind being a bit more specific? CU, Ingo From superstippi at gmx.de Thu Jul 5 16:37:08 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 05 Jul 2007 14:37:08 +0000 Subject: [Haiku-commits] broken build In-Reply-To: <20070705144806.541.1@cs.tu-berlin.de> References: <20070705112747.985.4@stippis2.1183619996.fake> <20070705144806.541.1@cs.tu-berlin.de> Message-ID: <20070705143708.2137.6@stippis2.1183644655.fake> Ingo Weinhold wrote (2007-07-05, 12:48:06 [+0000]): > > On 2007-07-05 at 11:27:47 [+0200], Stephan Assmus > wrote: > > > > the AppFileInfo change broke the build for me (ZETA). It seems it chokes > > on > > the "_IMPEXP_BE" stuff in the headers it includes. > > Would you mind being a bit more specific? Sorry, I thought you might already be able to tell from just that. Here is the full output: ...patience... ...found 51610 target(s)... ...updating 2004 target(s)... InitScript1 generated/haiku.image-init-vars C++ generated/objects/dano/x86/release/build/libhaikucompat/AppFileInfo.o In file included from /boot/home/projects/develop/Haiku/headers/build/os/interface/Rect.h:31, from /boot/home/projects/develop/Haiku/headers/build/os/app/Message.h:16, from /boot/home/projects/develop/Haiku/headers/build/os/app/Messenger.h:36, from /boot/home/projects/develop/Haiku/headers/build/os/storage/MimeType.h:15, from /boot/home/projects/develop/Haiku/headers/build/os/storage/Mime.h:63, from /boot/home/projects/develop/Haiku/headers/build/os/storage/NodeInfo.h:17, from /boot/home/projects/develop/Haiku/headers/build/os/storage/AppFileInfo.h:12, from /boot/home/projects/develop/Haiku/src/build/libbe/storage/AppFileInfo.cpp:14: /boot/home/projects/develop/Haiku/headers/build/os/interface/Point.h:72: syntax error before `const' In file included from /boot/home/projects/develop/Haiku/headers/build/os/storage/MimeType.h:15, from /boot/home/projects/develop/Haiku/headers/build/os/storage/Mime.h:63, from /boot/home/projects/develop/Haiku/headers/build/os/storage/NodeInfo.h:17, from /boot/home/projects/develop/Haiku/headers/build/os/storage/AppFileInfo.h:12, from /boot/home/projects/develop/Haiku/src/build/libbe/storage/AppFileInfo.cpp:14: /boot/home/projects/develop/Haiku/headers/build/os/app/Messenger.h:85: syntax error before `bool' /boot/home/projects/develop/Haiku/headers/build/os/app/Messenger.h:86: syntax error before `bool' In file included from /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 34, from /boot/home/projects/develop/Haiku/headers/build/os/interface/Bitmap.h:16, from /boot/home/projects/develop/Haiku/src/build/libbe/storage/AppFileInfo.cpp:15: /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:6 2: syntax error before `const' /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:6 3: syntax error before `const' /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:6 4: syntax error before `const' /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:9 3: syntax error before `const' /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:9 4: syntax error before `const' /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:9 5: syntax error before `const' /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:9 6: syntax error before `const' /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:9 7: syntax error before `const' /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:9 8: syntax error before `const' /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:1 00: syntax error before `const' /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:1 01: syntax error before `const' /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:1 38: syntax error before `const' /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:2 50: syntax error before `bool' /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:2 59: syntax error before `get_pixel_size_for' In file included from /boot/home/projects/develop/Haiku/headers/build/os/interface/Bitmap.h:16, from /boot/home/projects/develop/Haiku/src/build/libbe/storage/AppFileInfo.cpp:15: /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 267: syntax error before `get_deskbar_frame' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 269: syntax error before `const' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 271: syntax error before `set_screen_space' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 274: syntax error before `get_scroll_bar_info' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 275: syntax error before `set_scroll_bar_info' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 277: syntax error before `get_mouse_type' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 278: syntax error before `set_mouse_type' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 279: syntax error before `get_mouse_map' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 280: syntax error before `set_mouse_map' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 281: syntax error before `get_click_speed' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 282: syntax error before `set_click_speed' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 283: syntax error before `get_mouse_speed' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 284: syntax error before `set_mouse_speed' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 285: syntax error before `get_mouse_acceleration' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 286: syntax error before `set_mouse_acceleration' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 288: syntax error before `get_key_repeat_rate' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 289: syntax error before `set_key_repeat_rate' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 290: syntax error before `get_key_repeat_delay' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 291: syntax error before `set_key_repeat_delay' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 293: syntax error before `modifiers' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 294: syntax error before `get_key_info' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 295: syntax error before `void' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 296: syntax error before `get_keyboard_id' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 297: syntax error before `void' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 298: syntax error before `void' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 300: syntax error before `keyboard_navigation_color' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 302: syntax error before `count_workspaces' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 303: syntax error before `void' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 304: syntax error before `current_workspace' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 305: syntax error before `void' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 307: syntax error before `idle_time' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 309: syntax error before `void' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 310: syntax error before `void' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 311: syntax error before `void' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 313: syntax error before `void' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 314: syntax error before `bool' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 323: syntax error before `void' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 324: syntax error before `mouse_mode' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 368: syntax error before `ui_color' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h: 369: syntax error before `tint_color' In file included from /boot/home/projects/develop/Haiku/src/build/libbe/storage/AppFileInfo.cpp:15: /boot/home/projects/develop/Haiku/headers/build/os/interface/Bitmap.h:40: `B_MAIN_SCREEN_ID' was not declared in this scope /boot/home/projects/develop/Haiku/headers/build/os/interface/Bitmap.h:40: confused by earlier errors, bailing out gcc -c "src/build/libbe/storage/AppFileInfo.cpp" -O2 -Wall -Wno-ctor-dtor-privacy -Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare -Wno-multichar -D_ZETA_USING_DEPRECATED_API_=1 -D_ZETA_TS_FIND_DIR_=1 -DARCH_x86 -D_NO_INLINE_ASM -DCOMPILE_FOR_R5 -DHAIKU_HOST_PLATFORM_DANO -Isrc/build/libhaikucompat -Igenerated/objects/common/build/libhaikucompat -Igenerated/objects/dano/x86/common/build/libhaikucompat -Igenerated/objects/haiku/x86/common/build/libhaikucompat -I- -Iheaders/build/private/kernel -Iheaders/build/os/app -Iheaders/build/os/interface -Iheaders/build/os/storage -Iheaders/build/host/dano -o "generated/objects/dano/x86/release/build/libhaikucompat/AppFileInfo.o" ; ...failed C++ generated/objects/dano/x86/release/build/libhaikucompat/AppFileInfo.o ... ...skipped libhaikucompat_build.a for lack of AppFileInfo.o... ...skipped bfs_shell for lack of libhaikucompat_build.a... ...skipped haiku.image-init-vars for lack of bfs_shell... ...skipped install-haiku for lack of haiku.image-init-vars... ...failed updating 1 target(s)... ...skipped 4 target(s)... ...updated 1 target(s)... $ Best regards, -Stephan From axeld at mail.berlios.de Thu Jul 5 16:48:17 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 5 Jul 2007 16:48:17 +0200 Subject: [Haiku-commits] r21568 - haiku/trunk/headers/os/drivers Message-ID: <200707051448.l65EmHsF021810@sheep.berlios.de> Author: axeld Date: 2007-07-05 16:48:16 +0200 (Thu, 05 Jul 2007) New Revision: 21568 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21568&view=rev Modified: haiku/trunk/headers/os/drivers/fs_cache.h haiku/trunk/headers/os/drivers/fs_interface.h Log: Obviously forgot to commit these; they were part of the mount_id/vnode_id to dev_t/ino_t conversion. Modified: haiku/trunk/headers/os/drivers/fs_cache.h =================================================================== --- haiku/trunk/headers/os/drivers/fs_cache.h 2007-07-05 12:24:11 UTC (rev 21567) +++ haiku/trunk/headers/os/drivers/fs_cache.h 2007-07-05 14:48:16 UTC (rev 21568) @@ -5,7 +5,7 @@ #ifndef _FS_CACHE_H #define _FS_CACHE_H -//! File System File and Block Caches +/*! File System File and Block Caches */ #include @@ -56,7 +56,7 @@ extern void block_cache_put(void *_cache, off_t blockNumber); /* file cache */ -extern void *file_cache_create(mount_id mountID, vnode_id vnodeID, off_t size, +extern void *file_cache_create(dev_t mountID, ino_t vnodeID, off_t size, int fd); extern void file_cache_delete(void *_cacheRef); extern status_t file_cache_set_size(void *_cacheRef, off_t size); Modified: haiku/trunk/headers/os/drivers/fs_interface.h =================================================================== --- haiku/trunk/headers/os/drivers/fs_interface.h 2007-07-05 12:24:11 UTC (rev 21567) +++ haiku/trunk/headers/os/drivers/fs_interface.h 2007-07-05 14:48:16 UTC (rev 21568) @@ -1,12 +1,13 @@ -/* File System Interface Layer Definition - * - * Copyright 2004-2006, Haiku Inc. All Rights Reserved. +/* + * Copyright 2004-2007, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _FS_INTERFACE_H #define _FS_INTERFACE_H +/*! File System Interface Layer Definition */ + #include #include #include @@ -20,9 +21,6 @@ struct fs_info; struct select_sync; -typedef dev_t mount_id; -typedef ino_t vnode_id; - /* the file system's private data structures */ typedef void *fs_volume; typedef void *fs_cookie; @@ -69,8 +67,8 @@ void (*free_partition_content_cookie)(partition_data *partition); /* general operations */ - status_t (*mount)(mount_id id, const char *device, uint32 flags, - const char *args, fs_volume *_fs, vnode_id *_rootVnodeID); + status_t (*mount)(dev_t id, const char *device, uint32 flags, + const char *args, fs_volume *_fs, ino_t *_rootVnodeID); status_t (*unmount)(fs_volume fs); status_t (*read_fs_info)(fs_volume fs, struct fs_info *info); @@ -80,11 +78,11 @@ /* vnode operations */ status_t (*lookup)(fs_volume fs, fs_vnode dir, const char *name, - vnode_id *_id, int *_type); + ino_t *_id, int *_type); status_t (*get_vnode_name)(fs_volume fs, fs_vnode vnode, char *buffer, size_t bufferSize); - status_t (*get_vnode)(fs_volume fs, vnode_id id, fs_vnode *_vnode, + status_t (*get_vnode)(fs_volume fs, ino_t id, fs_vnode *_vnode, bool reenter); status_t (*put_vnode)(fs_volume fs, fs_vnode vnode, bool reenter); status_t (*remove_vnode)(fs_volume fs, fs_vnode vnode, bool reenter); @@ -132,7 +130,7 @@ /* file operations */ status_t (*create)(fs_volume fs, fs_vnode dir, const char *name, int openMode, int perms, fs_cookie *_cookie, - vnode_id *_newVnodeID); + ino_t *_newVnodeID); status_t (*open)(fs_volume fs, fs_vnode vnode, int openMode, fs_cookie *_cookie); status_t (*close)(fs_volume fs, fs_vnode vnode, fs_cookie cookie); @@ -144,7 +142,7 @@ /* directory operations */ status_t (*create_dir)(fs_volume fs, fs_vnode parent, const char *name, - int perms, vnode_id *_newVnodeID); + int perms, ino_t *_newVnodeID); status_t (*remove_dir)(fs_volume fs, fs_vnode parent, const char *name); status_t (*open_dir)(fs_volume fs, fs_vnode vnode, fs_cookie *_cookie); status_t (*close_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie); @@ -255,40 +253,40 @@ /* file system add-ons only prototypes */ -extern status_t new_vnode(mount_id mountID, vnode_id vnodeID, +extern status_t new_vnode(dev_t mountID, ino_t vnodeID, fs_vnode privateNode); -extern status_t publish_vnode(mount_id mountID, vnode_id vnodeID, +extern status_t publish_vnode(dev_t mountID, ino_t vnodeID, fs_vnode privateNode); -extern status_t get_vnode(mount_id mountID, vnode_id vnodeID, +extern status_t get_vnode(dev_t mountID, ino_t vnodeID, fs_vnode *_privateNode); -extern status_t put_vnode(mount_id mountID, vnode_id vnodeID); -extern status_t remove_vnode(mount_id mountID, vnode_id vnodeID); -extern status_t unremove_vnode(mount_id mountID, vnode_id vnodeID); -extern status_t get_vnode_removed(mount_id mountID, vnode_id vnodeID, +extern status_t put_vnode(dev_t mountID, ino_t vnodeID); +extern status_t remove_vnode(dev_t mountID, ino_t vnodeID); +extern status_t unremove_vnode(dev_t mountID, ino_t vnodeID); +extern status_t get_vnode_removed(dev_t mountID, ino_t vnodeID, bool* removed); // Deprecated! Will disappear soon! -extern status_t notify_listener(int op, mount_id device, vnode_id parentNode, - vnode_id toParentNode, vnode_id node, const char *name); +extern status_t notify_listener(int op, dev_t device, ino_t parentNode, + ino_t toParentNode, ino_t node, const char *name); -extern status_t notify_entry_created(mount_id device, vnode_id directory, - const char *name, vnode_id node); -extern status_t notify_entry_removed(mount_id device, vnode_id directory, - const char *name, vnode_id node); -extern status_t notify_entry_moved(mount_id device, vnode_id fromDirectory, - const char *fromName, vnode_id toDirectory, - const char *toName, vnode_id node); -extern status_t notify_stat_changed(mount_id device, vnode_id node, +extern status_t notify_entry_created(dev_t device, ino_t directory, + const char *name, ino_t node); +extern status_t notify_entry_removed(dev_t device, ino_t directory, + const char *name, ino_t node); +extern status_t notify_entry_moved(dev_t device, ino_t fromDirectory, + const char *fromName, ino_t toDirectory, + const char *toName, ino_t node); +extern status_t notify_stat_changed(dev_t device, ino_t node, uint32 statFields); -extern status_t notify_attribute_changed(mount_id device, vnode_id node, +extern status_t notify_attribute_changed(dev_t device, ino_t node, const char *attribute, int32 cause); extern status_t notify_query_entry_created(port_id port, int32 token, - mount_id device, vnode_id directory, const char *name, - vnode_id node); + dev_t device, ino_t directory, const char *name, + ino_t node); extern status_t notify_query_entry_removed(port_id port, int32 token, - mount_id device, vnode_id directory, const char *name, - vnode_id node); + dev_t device, ino_t directory, const char *name, + ino_t node); #ifdef __cplusplus } From bonefish at cs.tu-berlin.de Thu Jul 5 17:54:32 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Thu, 05 Jul 2007 17:54:32 +0200 Subject: [Haiku-commits] broken build In-Reply-To: <20070705143708.2137.6@stippis2.1183644655.fake> References: <20070705112747.985.4@stippis2.1183619996.fake> <20070705144806.541.1@cs.tu-berlin.de> <20070705143708.2137.6@stippis2.1183644655.fake> Message-ID: <20070705175432.1437.5@cs.tu-berlin.de> On 2007-07-05 at 16:37:08 [+0200], Stephan Assmus wrote: > Ingo Weinhold wrote (2007-07-05, 12:48:06 [+0000]): > > On 2007-07-05 at 11:27:47 [+0200], Stephan Assmus > > wrote: > > > > > > the AppFileInfo change broke the build for me (ZETA). It seems it chokes > > > on > > > the "_IMPEXP_BE" stuff in the headers it includes. > > > > Would you mind being a bit more specific? > > Sorry, I thought you might already be able to tell from just that. Here is > the full output: [...] Does the attached patch fix the issue? CU, Ingo -------------- next part -------------- Index: src/build/libhaikucompat/Jamfile =================================================================== --- src/build/libhaikucompat/Jamfile (revision 21560) +++ src/build/libhaikucompat/Jamfile (working copy) @@ -22,6 +22,9 @@ : [ FDirName $(HAIKU_TOP) headers build os interface ] ; ObjectSysHdrs $(libbePatchSources) : [ FDirName $(HAIKU_TOP) headers build os storage ] ; + $(HOST_PLATFORM) in r5 bone dano { + ObjectDefines $(libbePatchSources) : _IMPEXP_BE ; + } } BuildPlatformStaticLibrary libhaikucompat_build.a : From axeld at pinc-software.de Thu Jul 5 17:57:12 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 05 Jul 2007 17:57:12 +0200 CEST Subject: [Haiku-commits] broken build In-Reply-To: <20070705175432.1437.5@cs.tu-berlin.de> Message-ID: <26491569179-BeMail@zon> Ingo Weinhold wrote: > Does the attached patch fix the issue? Alternatively, we could just get rid of those, couldn't we? Bye, Axel. From superstippi at gmx.de Thu Jul 5 18:04:25 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 05 Jul 2007 16:04:25 +0000 Subject: [Haiku-commits] broken build In-Reply-To: <20070705175432.1437.5@cs.tu-berlin.de> References: <20070705112747.985.4@stippis2.1183619996.fake> <20070705144806.541.1@cs.tu-berlin.de> <20070705143708.2137.6@stippis2.1183644655.fake> <20070705175432.1437.5@cs.tu-berlin.de> Message-ID: <20070705160425.2260.7@stippis2.1183644655.fake> Ingo Weinhold wrote (2007-07-05, 15:54:32 [+0000]): > > On 2007-07-05 at 16:37:08 [+0200], Stephan Assmus > wrote: > > Ingo Weinhold wrote (2007-07-05, 12:48:06 [+0000]): > > > On 2007-07-05 at 11:27:47 [+0200], Stephan Assmus > > > wrote: > > > > > > > > the AppFileInfo change broke the build for me (ZETA). It seems it > > > > chokes > > > > on > > > > the "_IMPEXP_BE" stuff in the headers it includes. > > > > > > Would you mind being a bit more specific? > > > > Sorry, I thought you might already be able to tell from just that. Here is > > the full output: > [...] > > Does the attached patch fix the issue? No the patch as you sent it just gives syntax errors. + $(HOST_PLATFORM) in r5 bone dano { + ObjectDefines $(libbePatchSources) : _IMPEXP_BE ; + } Best regards, -Stephan From bonefish at cs.tu-berlin.de Thu Jul 5 18:25:46 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Thu, 05 Jul 2007 18:25:46 +0200 Subject: [Haiku-commits] broken build In-Reply-To: <20070705160425.2260.7@stippis2.1183644655.fake> References: <20070705112747.985.4@stippis2.1183619996.fake> <20070705144806.541.1@cs.tu-berlin.de> <20070705143708.2137.6@stippis2.1183644655.fake> <20070705175432.1437.5@cs.tu-berlin.de> <20070705160425.2260.7@stippis2.1183644655.fake> Message-ID: <20070705182546.1542.6@cs.tu-berlin.de> On 2007-07-05 at 18:04:25 [+0200], Stephan Assmus wrote: > Ingo Weinhold wrote (2007-07-05, 15:54:32 [+0000]): > > On 2007-07-05 at 16:37:08 [+0200], Stephan Assmus > > wrote: > > > Ingo Weinhold wrote (2007-07-05, 12:48:06 [+0000]): > > > > On 2007-07-05 at 11:27:47 [+0200], Stephan Assmus > > > > wrote: > > > > > > > > > > the AppFileInfo change broke the build for me (ZETA). It seems it > > > > > chokes > > > > > on > > > > > the "_IMPEXP_BE" stuff in the headers it includes. > > > > > > > > Would you mind being a bit more specific? > > > > > > Sorry, I thought you might already be able to tell from just that. Here > > > is > > > the full output: > > [...] > > > > Does the attached patch fix the issue? > > No the patch as you sent it just gives syntax errors. Oh, yeah. Saving the end result before creating the diff helps tremendously. :-P CU, Ingo -------------- next part -------------- Index: src/build/libhaikucompat/Jamfile =================================================================== --- src/build/libhaikucompat/Jamfile (revision 21560) +++ src/build/libhaikucompat/Jamfile (working copy) @@ -22,6 +22,9 @@ : [ FDirName $(HAIKU_TOP) headers build os interface ] ; ObjectSysHdrs $(libbePatchSources) : [ FDirName $(HAIKU_TOP) headers build os storage ] ; + if $(HOST_PLATFORM) = dano { + ObjectDefines $(libbePatchSources) : _IMPEXP_BE ; + } } BuildPlatformStaticLibrary libhaikucompat_build.a : From bonefish at cs.tu-berlin.de Thu Jul 5 18:29:36 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Thu, 05 Jul 2007 18:29:36 +0200 Subject: [Haiku-commits] broken build In-Reply-To: <26491569179-BeMail@zon> References: <26491569179-BeMail@zon> Message-ID: <20070705182936.1589.7@cs.tu-berlin.de> On 2007-07-05 at 17:57:12 [+0200], Axel D?rfler wrote: > Ingo Weinhold wrote: > > Does the attached patch fix the issue? > > Alternatively, we could just get rid of those, couldn't we? Yeah, we should. I'm just reluctant, since most of those headers are actually original Be headers, in the worse cases even with replaced copyright headers. CU, Ingo From superstippi at gmx.de Thu Jul 5 18:31:44 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 05 Jul 2007 16:31:44 +0000 Subject: [Haiku-commits] broken build In-Reply-To: <20070705182546.1542.6@cs.tu-berlin.de> References: <20070705112747.985.4@stippis2.1183619996.fake> <20070705144806.541.1@cs.tu-berlin.de> <20070705143708.2137.6@stippis2.1183644655.fake> <20070705175432.1437.5@cs.tu-berlin.de> <20070705160425.2260.7@stippis2.1183644655.fake> <20070705182546.1542.6@cs.tu-berlin.de> Message-ID: <20070705163144.11737.10@stippis2.1183644655.fake> Hi Ingo, Ingo Weinhold wrote (2007-07-05, 16:25:46 [+0000]): > On 2007-07-05 at 18:04:25 [+0200], Stephan Assmus > wrote: > > Ingo Weinhold wrote (2007-07-05, 15:54:32 [+0000]): > > > On 2007-07-05 at 16:37:08 [+0200], Stephan Assmus > > > wrote: > > > > Ingo Weinhold wrote (2007-07-05, 12:48:06 [+0000]): > > > > > On 2007-07-05 at 11:27:47 [+0200], Stephan Assmus > > > > > > > > > > wrote: > > > > > > > > > > > > the AppFileInfo change broke the build for me (ZETA). It seems it > > > > > > chokes > > > > > > on > > > > > > the "_IMPEXP_BE" stuff in the headers it includes. > > > > > > > > > > Would you mind being a bit more specific? > > > > > > > > Sorry, I thought you might already be able to tell from just that. > > > > Here > > > > is > > > > the full output: > > > [...] > > > > > > Does the attached patch fix the issue? > > > > No the patch as you sent it just gives syntax errors. > > Oh, yeah. Saving the end result before creating the diff helps tremendously. > :-P Hehe, but no, unfortunately, it just changes the error: ...patience... ...found 51610 target(s)... ...updating 810 target(s)... InitScript1 generated/haiku.image-init-vars C++ generated/objects/dano/x86/release/build/libhaikucompat/AppFileInfo.o In file included from /boot/home/projects/develop/Haiku/headers/build/os/interface/Rect.h:31, from /boot/home/projects/develop/Haiku/headers/build/os/app/Message.h:16, from /boot/home/projects/develop/Haiku/headers/build/os/app/Messenger.h:36, from /boot/home/projects/develop/Haiku/headers/build/os/storage/MimeType.h:15, from /boot/home/projects/develop/Haiku/headers/build/os/storage/Mime.h:63, from /boot/home/projects/develop/Haiku/headers/build/os/storage/NodeInfo.h:17, from /boot/home/projects/develop/Haiku/headers/build/os/storage/AppFileInfo.h:12, from /boot/home/projects/develop/Haiku/src/build/libbe/storage/AppFileInfo.cpp:14: /boot/home/projects/develop/Haiku/headers/build/os/interface/Point.h:72: parse error before `1' In file included from /boot/home/projects/develop/Haiku/headers/build/os/storage/MimeType.h:15, from /boot/home/projects/develop/Haiku/headers/build/os/storage/Mime.h:63, from /boot/home/projects/develop/Haiku/headers/build/os/storage/NodeInfo.h:17, from /boot/home/projects/develop/Haiku/headers/build/os/storage/AppFileInfo.h:12, from /boot/home/projects/develop/Haiku/src/build/libbe/storage/AppFileInfo.cpp:14: /boot/home/projects/develop/Haiku/headers/build/os/app/Messenger.h:85: parse error before `1' In file included from /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h:3 4, from /boot/home/projects/develop/Haiku/headers/build/os/interface/Bitmap.h:16, from /boot/home/projects/develop/Haiku/src/build/libbe/storage/AppFileInfo.cpp:15: /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:62 : parse error before `1' /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:93 : parse error before `1' /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:13 8: parse error before `1' /boot/home/projects/develop/Haiku/headers/build/os/interface/GraphicsDefs.h:25 0: parse error before `1' In file included from /boot/home/projects/develop/Haiku/headers/build/os/interface/Bitmap.h:16, from /boot/home/projects/develop/Haiku/src/build/libbe/storage/AppFileInfo.cpp:15: /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h:2 67: parse error before `1' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h:3 23: parse error before `1' /boot/home/projects/develop/Haiku/headers/build/os/interface/InterfaceDefs.h:3 68: parse error before `1' In file included from /boot/home/projects/develop/Haiku/src/build/libbe/storage/AppFileInfo.cpp:15: /boot/home/projects/develop/Haiku/headers/build/os/interface/Bitmap.h:40: `B_MAIN_SCREEN_ID' was not declared in this scope /boot/home/projects/develop/Haiku/headers/build/os/interface/Bitmap.h:40: confused by earlier errors, bailing out gcc -c "src/build/libbe/storage/AppFileInfo.cpp" -O2 -Wall -Wno-ctor-dtor-privacy -Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare -Wno-multichar -D_ZETA_USING_DEPRECATED_API_=1 -D_ZETA_TS_FIND_DIR_=1 -D_IMPEXP_BE -DARCH_x86 -D_NO_INLINE_ASM -DCOMPILE_FOR_R5 -DHAIKU_HOST_PLATFORM_DANO -Isrc/build/libhaikucompat -Igenerated/objects/common/build/libhaikucompat -Igenerated/objects/dano/x86/common/build/libhaikucompat -Igenerated/objects/haiku/x86/common/build/libhaikucompat -I- -Iheaders/build/private/kernel -Iheaders/build/os/app -Iheaders/build/os/interface -Iheaders/build/os/storage -Iheaders/build/host/dano -o "generated/objects/dano/x86/release/build/libhaikucompat/AppFileInfo.o" ; ...failed C++ generated/objects/dano/x86/release/build/libhaikucompat/AppFileInfo.o ... ...skipped libhaikucompat_build.a for lack of AppFileInfo.o... ...skipped bfs_shell for lack of libhaikucompat_build.a... ...skipped haiku.image-init-vars for lack of bfs_shell... ...skipped install-haiku for lack of haiku.image-init-vars... ...failed updating 1 target(s)... ...skipped 4 target(s)... ...updated 1 target(s)... Best regards, -Stephan From marcusoverhagen at mail.berlios.de Thu Jul 5 18:39:41 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Thu, 5 Jul 2007 18:39:41 +0200 Subject: [Haiku-commits] r21569 - haiku/trunk/headers/private/graphics/nvidia Message-ID: <200707051639.l65GdfQj013282@sheep.berlios.de> Author: marcusoverhagen Date: 2007-07-05 18:39:38 +0200 (Thu, 05 Jul 2007) New Revision: 21569 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21569&view=rev Modified: haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h Log: cleanup Modified: haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h =================================================================== --- haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h 2007-07-05 14:48:16 UTC (rev 21568) +++ haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h 2007-07-05 16:39:38 UTC (rev 21569) @@ -18,8 +18,8 @@ #include #include "AGP.h" -#define DRIVER_PREFIX "nvidia" // apsed -#define DEVICE_FORMAT "%04x_%04x_%02x%02x%02x" // apsed +#define DRIVER_PREFIX "nvidia" +#define DEVICE_FORMAT "%04x_%04x_%02x%02x%02x" /* Internal driver state (also for sharing info between driver and accelerant) From bonefish at cs.tu-berlin.de Thu Jul 5 18:42:15 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Thu, 05 Jul 2007 18:42:15 +0200 Subject: [Haiku-commits] broken build In-Reply-To: <20070705163144.11737.10@stippis2.1183644655.fake> References: <20070705112747.985.4@stippis2.1183619996.fake> <20070705144806.541.1@cs.tu-berlin.de> <20070705143708.2137.6@stippis2.1183644655.fake> <20070705175432.1437.5@cs.tu-berlin.de> <20070705160425.2260.7@stippis2.1183644655.fake> <20070705182546.1542.6@cs.tu-berlin.de> <20070705163144.11737.10@stippis2.1183644655.fake> Message-ID: <20070705184215.1738.8@cs.tu-berlin.de> On 2007-07-05 at 18:31:44 [+0200], Stephan Assmus wrote: > Ingo Weinhold wrote (2007-07-05, 16:25:46 [+0000]): > > On 2007-07-05 at 18:04:25 [+0200], Stephan Assmus > > wrote: > > > Ingo Weinhold wrote (2007-07-05, 15:54:32 [+0000]): > > > > On 2007-07-05 at 16:37:08 [+0200], Stephan Assmus > > > > wrote: > > > > > Ingo Weinhold wrote (2007-07-05, 12:48:06 [+0000]): > > > > > > On 2007-07-05 at 11:27:47 [+0200], Stephan Assmus > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > the AppFileInfo change broke the build for me (ZETA). It seems > > > > > > > it > > > > > > > chokes > > > > > > > on > > > > > > > the "_IMPEXP_BE" stuff in the headers it includes. > > > > > > > > > > > > Would you mind being a bit more specific? > > > > > > > > > > Sorry, I thought you might already be able to tell from just that. > > > > > Here > > > > > is > > > > > the full output: > > > > [...] > > > > > > > > Does the attached patch fix the issue? > > > > > > No the patch as you sent it just gives syntax errors. > > > > Oh, yeah. Saving the end result before creating the diff helps > > tremendously. > > :-P > > Hehe, but no, unfortunately, it just changes the error: Stupid me, -D defines macros to 1 by default. Once more... CU, Ingo -------------- next part -------------- Index: src/build/libhaikucompat/Jamfile =================================================================== --- src/build/libhaikucompat/Jamfile (revision 21560) +++ src/build/libhaikucompat/Jamfile (working copy) @@ -22,6 +22,9 @@ : [ FDirName $(HAIKU_TOP) headers build os interface ] ; ObjectSysHdrs $(libbePatchSources) : [ FDirName $(HAIKU_TOP) headers build os storage ] ; + if $(HOST_PLATFORM) = dano { + ObjectDefines $(libbePatchSources) : _IMPEXP_BE= ; + } } BuildPlatformStaticLibrary libhaikucompat_build.a : From marcusoverhagen at mail.berlios.de Thu Jul 5 18:42:59 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Thu, 5 Jul 2007 18:42:59 +0200 Subject: [Haiku-commits] r21570 - haiku/trunk/src/add-ons/kernel/drivers/graphics/nvidia Message-ID: <200707051642.l65GgxnA017620@sheep.berlios.de> Author: marcusoverhagen Date: 2007-07-05 18:42:46 +0200 (Thu, 05 Jul 2007) New Revision: 21570 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21570&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/nvidia/nvidia.settings Log: spolling fex Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/nvidia/nvidia.settings =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/graphics/nvidia/nvidia.settings 2007-07-05 16:39:38 UTC (rev 21569) +++ haiku/trunk/src/add-ons/kernel/drivers/graphics/nvidia/nvidia.settings 2007-07-05 16:42:46 UTC (rev 21570) @@ -5,7 +5,7 @@ # # nv.driver parameters: -#accelerant "nv.accelerant" # if enabled selects accelerant filename to be used +#accelerant "nvidia.accelerant" # if enabled selects accelerant filename to be used #primary "10de_0110_010000" # if enabled selects device to be used as primary device ('hack') dumprom false # dump bios rom to file (in home folder) From superstippi at gmx.de Thu Jul 5 19:04:19 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 05 Jul 2007 17:04:19 +0000 Subject: [Haiku-commits] broken build In-Reply-To: <20070705184215.1738.8@cs.tu-berlin.de> References: <20070705112747.985.4@stippis2.1183619996.fake> <20070705144806.541.1@cs.tu-berlin.de> <20070705143708.2137.6@stippis2.1183644655.fake> <20070705175432.1437.5@cs.tu-berlin.de> <20070705160425.2260.7@stippis2.1183644655.fake> <20070705182546.1542.6@cs.tu-berlin.de> <20070705163144.11737.10@stippis2.1183644655.fake> <20070705184215.1738.8@cs.tu-berlin.de> Message-ID: <20070705170419.12043.11@stippis2.1183644655.fake> Ingo Weinhold wrote (2007-07-05, 16:42:15 [+0000]): > > On 2007-07-05 at 18:31:44 [+0200], Stephan Assmus > wrote: > > Ingo Weinhold wrote (2007-07-05, 16:25:46 [+0000]): > > > On 2007-07-05 at 18:04:25 [+0200], Stephan Assmus > > > wrote: > > > > Ingo Weinhold wrote (2007-07-05, 15:54:32 [+0000]): > > > > > On 2007-07-05 at 16:37:08 [+0200], Stephan Assmus > > > > > > > > > > wrote: > > > > > > Ingo Weinhold wrote (2007-07-05, 12:48:06 [+0000]): > > > > > > > On 2007-07-05 at 11:27:47 [+0200], Stephan Assmus > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > the AppFileInfo change broke the build for me (ZETA). It seems > > > > > > > > it > > > > > > > > chokes > > > > > > > > on > > > > > > > > the "_IMPEXP_BE" stuff in the headers it includes. > > > > > > > > > > > > > > Would you mind being a bit more specific? > > > > > > > > > > > > Sorry, I thought you might already be able to tell from just that. > > > > > > Here > > > > > > is > > > > > > the full output: > > > > > [...] > > > > > > > > > > Does the attached patch fix the issue? > > > > > > > > No the patch as you sent it just gives syntax errors. > > > > > > Oh, yeah. Saving the end result before creating the diff helps > > > tremendously. > > > :-P > > > > Hehe, but no, unfortunately, it just changes the error: > > Stupid me, -D defines macros to 1 by default. Once more... Thanks a lot, that fixes it! :-D Best regards, -Stephan From phoudoin at mail.berlios.de Thu Jul 5 20:01:26 2007 From: phoudoin at mail.berlios.de (phoudoin at BerliOS) Date: Thu, 5 Jul 2007 20:01:26 +0200 Subject: [Haiku-commits] r21571 - haiku/trunk/src/tests/kits/opengl/glinfo Message-ID: <200707051801.l65I1Qgv015844@sheep.berlios.de> Author: phoudoin Date: 2007-07-05 20:01:25 +0200 (Thu, 05 Jul 2007) New Revision: 21571 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21571&view=rev Modified: haiku/trunk/src/tests/kits/opengl/glinfo/GLInfo.cpp Log: Moved capabilities info under a sublevel. Modified: haiku/trunk/src/tests/kits/opengl/glinfo/GLInfo.cpp =================================================================== --- haiku/trunk/src/tests/kits/opengl/glinfo/GLInfo.cpp 2007-07-05 16:42:46 UTC (rev 21570) +++ haiku/trunk/src/tests/kits/opengl/glinfo/GLInfo.cpp 2007-07-05 18:01:25 UTC (rev 21571) @@ -84,13 +84,16 @@ LockLooper(); gl->LockGL(); + + // ---- OpenGL info - // list->AddItem(new BStringItem("OpenGL", 0)); AddItem(list, 0, "OpenGL"); AddItem(list, 1, "Version: %s", glGetString(GL_VERSION)); AddItem(list, 1, "Vendor Name: %s", glGetString(GL_VENDOR)); AddItem(list, 1, "Renderer Name: %s", glGetString(GL_RENDERER)); + // Renderer capabilities + int lights = 0; int clipping_planes = 0; int model_stack = 0; @@ -127,27 +130,30 @@ glGetIntegerv (GL_MAX_ELEMENTS_VERTICES, &max_vertex); glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &texture_units); - AddItem(list, 1, "Auxiliary buffer(s): %d", buffers); + AddItem(list, 1, "Capabilities"); - AddItem(list, 1, "Model stack size: %d", model_stack); - AddItem(list, 1, "Projection stack size: %d", projection_stack); - AddItem(list, 1, "Texture stack size: %d", texture_stack); - AddItem(list, 1, "Name stack size: %d", name_stack); - AddItem(list, 1, "List stack size: %d", list_stack); - AddItem(list, 1, "Attributes stack size: %d", attrib_stack); + AddItem(list, 2, "Auxiliary buffer(s): %d", buffers); - AddItem(list, 1, "Maximum 3D texture size: %d", max_tex3d); - AddItem(list, 1, "Maximum 2D texture size: %d", max_tex2d); - AddItem(list, 1, "Maximum texture units: %d", texture_units); + AddItem(list, 2, "Model stack size: %d", model_stack); + AddItem(list, 2, "Projection stack size: %d", projection_stack); + AddItem(list, 2, "Texture stack size: %d", texture_stack); + AddItem(list, 2, "Name stack size: %d", name_stack); + AddItem(list, 2, "List stack size: %d", list_stack); + AddItem(list, 2, "Attributes stack size: %d", attrib_stack); - AddItem(list, 1, "Maximum lights: %d", lights); - AddItem(list, 1, "Maximum clipping planes: %d", clipping_planes); - AddItem(list, 1, "Maximum evaluators equation order: %d", max_poly); - AddItem(list, 1, "Maximum convolution: %d x %d", + AddItem(list, 2, "Maximum 3D texture size: %d", max_tex3d); + AddItem(list, 2, "Maximum 2D texture size: %d", max_tex2d); + AddItem(list, 2, "Maximum texture units: %d", texture_units); + + AddItem(list, 2, "Maximum lights: %d", lights); + AddItem(list, 2, "Maximum clipping planes: %d", clipping_planes); + AddItem(list, 2, "Maximum evaluators equation order: %d", max_poly); + AddItem(list, 2, "Maximum convolution: %d x %d", convolution_width, convolution_height); - AddItem(list, 1, "Maximum recommended index elements: %d", max_index); - AddItem(list, 1, "Maximum recommended vertex elements: %d", max_vertex); + AddItem(list, 2, "Maximum recommended index elements: %d", max_index); + AddItem(list, 2, "Maximum recommended vertex elements: %d", max_vertex); + // Renderer supported extensions string = (char *) glGetString(GL_EXTENSIONS); if (string) { AddItem(list, 1, "Extensions"); @@ -163,6 +169,8 @@ } } + // ---- GLU info + AddItem(list, 0, "GLU"); AddItem(list, 1, "Version: %s", gluGetString(GLU_VERSION)); @@ -182,6 +190,7 @@ } #ifdef GLUT_INFO + // ---- GLUT Info AddItem(list, 0, "GLUT"); AddItem(list, 1, "API version: %d", GLUT_API_VERSION); #endif From axeld at mail.berlios.de Thu Jul 5 20:27:28 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 5 Jul 2007 20:27:28 +0200 Subject: [Haiku-commits] r21572 - haiku/trunk/src/system/kernel Message-ID: <200707051827.l65IRSXI018173@sheep.berlios.de> Author: axeld Date: 2007-07-05 20:27:27 +0200 (Thu, 05 Jul 2007) New Revision: 21572 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21572&view=rev Modified: haiku/trunk/src/system/kernel/thread.c Log: Because of ongoing problems with thread_yield() and our current scheduler, I've disabled yielding for now; it will now just snooze a bit. Modified: haiku/trunk/src/system/kernel/thread.c =================================================================== --- haiku/trunk/src/system/kernel/thread.c 2007-07-05 18:01:25 UTC (rev 21571) +++ haiku/trunk/src/system/kernel/thread.c 2007-07-05 18:27:27 UTC (rev 21572) @@ -1292,6 +1292,9 @@ void thread_yield(void) { + // snooze for roughly 3 thread quantums + snooze_etc(9000, B_SYSTEM_TIMEBASE, B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT); +#if 0 cpu_status state; struct thread *thread = thread_get_current_thread(); @@ -1308,6 +1311,7 @@ RELEASE_THREAD_LOCK(); restore_interrupts(state); +#endif } From axeld at mail.berlios.de Thu Jul 5 21:32:59 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 5 Jul 2007 21:32:59 +0200 Subject: [Haiku-commits] r21573 - haiku/trunk/src/bin Message-ID: <200707051932.l65JWxHB022372@sheep.berlios.de> Author: axeld Date: 2007-07-05 21:32:59 +0200 (Thu, 05 Jul 2007) New Revision: 21573 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21573&view=rev Modified: haiku/trunk/src/bin/mountvolume.cpp Log: Made the output of the volume listing more useful: added size, and device information. size_string() was taken from df. Modified: haiku/trunk/src/bin/mountvolume.cpp =================================================================== --- haiku/trunk/src/bin/mountvolume.cpp 2007-07-05 18:27:27 UTC (rev 21572) +++ haiku/trunk/src/bin/mountvolume.cpp 2007-07-05 19:32:59 UTC (rev 21573) @@ -1,5 +1,5 @@ /* - * Copyright 2005-2006, Ingo Weinhold, bonefish at users.sf.net. All rights reserved. + * Copyright 2005-2007, Ingo Weinhold, bonefish at users.sf.net. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -83,7 +83,33 @@ exit(error ? 0 : 1); } -// MountVisitor +static const char * +size_string(int64 size) +{ + double blocks = size; + static char string[64]; + + if (size < 1024) + sprintf(string, "%Ld", size); + else { + char *units[] = {"K", "M", "G", NULL}; + int32 i = -1; + + do { + blocks /= 1024.0; + i++; + } while (blocks >= 1024 && units[i + 1]); + + snprintf(string, sizeof(string), "%.1f%s", blocks, units[i]); + } + + return string; +} + + +// #pragma mark - + + struct MountVisitor : public BDiskDeviceVisitor { MountVisitor() : silent(false), @@ -219,12 +245,28 @@ if (type == NULL) type = ""; + // shorten known types for display + if (!strcmp(type, kPartitionTypeMultisession)) + type = "Multisession"; + else if (!strcmp(type, kPartitionTypeIntelExtended)) + type = "Intel Extended"; + BPath path; + partition->GetPath(&path); + + // cut off beginning of the device path (if /dev/disk/) + int32 skip = strlen("/dev/disk/"); + if (strncmp(path.Path(), "/dev/disk/", skip)) + skip = 0; + + BPath mountPoint; if (partition->IsMounted()) - partition->GetMountPoint(&path); + partition->GetMountPoint(&mountPoint); - printf("%-16s %-20s %s\n", - name, type, partition->IsMounted() ? path.Path() : ""); + printf("%-14s %-20s %8s %s (%s)\n", + name, type, size_string(partition->Size()), + partition->IsMounted() ? mountPoint.Path() : "", + path.Path() + skip); return false; } @@ -233,7 +275,9 @@ }; -// main +// #pragma mark - + + int main(int argc, char **argv) { @@ -328,8 +372,8 @@ } if (printPartitionsVisitor.IsUsed()) { - puts("Volume File System Mounted At"); - puts("----------------------------------------------------------"); + puts("Volume File System Size Mounted At (Device)"); + puts("---------------------------------------------------------------------"); if (printPartitionsVisitor.listAllPartitions) deviceList.VisitEachPartition(&printPartitionsVisitor); From axeld at mail.berlios.de Thu Jul 5 21:41:48 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 5 Jul 2007 21:41:48 +0200 Subject: [Haiku-commits] r21574 - in haiku/trunk: headers/private/storage src/add-ons/kernel/partitioning_systems/efi src/kits/storage Message-ID: <200707051941.l65Jfmq3022832@sheep.berlios.de> Author: axeld Date: 2007-07-05 21:41:47 +0200 (Thu, 05 Jul 2007) New Revision: 21574 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21574&view=rev Modified: haiku/trunk/headers/private/storage/DiskDeviceTypes.h haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp haiku/trunk/src/kits/storage/DiskDeviceTypes.cpp Log: * Renamed "EFI GUID Partition Table" to "EFI GUID Partition Map" to be consistent with the other partition types. * Added kPartitionTypeEFI to the constants. Modified: haiku/trunk/headers/private/storage/DiskDeviceTypes.h =================================================================== --- haiku/trunk/headers/private/storage/DiskDeviceTypes.h 2007-07-05 19:32:59 UTC (rev 21573) +++ haiku/trunk/headers/private/storage/DiskDeviceTypes.h 2007-07-05 19:41:47 UTC (rev 21574) @@ -1,15 +1,10 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -//--------------------------------------------------------------------- - +/* + * Copyright 2003-2007, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _DISK_DEVICE_TYPES_H #define _DISK_DEVICE_TYPES_H -#ifdef __cplusplus -extern "C" { -#endif - // Device Types extern const char *kDeviceTypeFloppyDisk; @@ -27,6 +22,7 @@ extern const char *kPartitionTypeAmiga; extern const char *kPartitionTypeApple; +extern const char *kPartitionTypeEFI; extern const char *kPartitionTypeIntel; extern const char *kPartitionTypeIntelPrimary; @@ -45,8 +41,4 @@ extern const char *kPartitionTypeReiser; extern const char *kPartitionTypeUDF; -#ifdef __cplusplus -} -#endif - #endif // _DISK_DEVICE_TYPES_H Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp 2007-07-05 19:32:59 UTC (rev 21573) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp 2007-07-05 19:41:47 UTC (rev 21574) @@ -29,7 +29,7 @@ #define EFI_PARTITION_MODULE_NAME "partitioning_systems/efi_gpt/v1" -#define EFI_PARTITION_NAME "EFI GUID Partition Table" +#define EFI_PARTITION_NAME "EFI GUID Partition Map" struct static_guid { Modified: haiku/trunk/src/kits/storage/DiskDeviceTypes.cpp =================================================================== --- haiku/trunk/src/kits/storage/DiskDeviceTypes.cpp 2007-07-05 19:32:59 UTC (rev 21573) +++ haiku/trunk/src/kits/storage/DiskDeviceTypes.cpp 2007-07-05 19:41:47 UTC (rev 21574) @@ -1,10 +1,15 @@ -//---------------------------------------------------------------------- -// This software is part of the Haiku distribution and is covered -// by the MIT license. -//--------------------------------------------------------------------- +/* + * Copyright 2003-2007, Haiku Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Tyler Akidau + */ + #include + // Device Types const char *kDeviceTypeFloppyDisk = "Floppy Disk Media"; @@ -22,6 +27,7 @@ const char *kPartitionTypeAmiga = "Amiga Partition Map"; const char *kPartitionTypeApple = "Apple Partition Map"; +const char *kPartitionTypeEFI = "EFI GUID Partition Map"; const char *kPartitionTypeIntel = "Intel Partition Map"; const char *kPartitionTypeIntelPrimary = "Intel Primary Partition"; From axeld at pinc-software.de Thu Jul 5 22:47:34 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 05 Jul 2007 22:47:34 +0200 CEST Subject: [Haiku-commits] broken build In-Reply-To: <20070705182936.1589.7@cs.tu-berlin.de> Message-ID: <672765519-BeMail@zon> Ingo Weinhold wrote: > On 2007-07-05 at 17:57:12 [+0200], Axel D?rfler > > wrote: > > Ingo Weinhold wrote: > > > Does the attached patch fix the issue? > > Alternatively, we could just get rid of those, couldn't we? > Yeah, we should. I'm just reluctant, since most of those headers are > actually original Be headers, in the worse cases even with replaced > copyright headers. Replaced copyright headers don't sound too good - are there anyones in particular you were thinking of? I guess we need to compile a list of all those headers and replace them for good. How to learn typing... :-) Bye, Axel. From stippi at mail.berlios.de Thu Jul 5 23:00:28 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 5 Jul 2007 23:00:28 +0200 Subject: [Haiku-commits] r21575 - haiku/trunk/src/build/libhaikucompat Message-ID: <200707052100.l65L0S5l029445@sheep.berlios.de> Author: stippi Date: 2007-07-05 23:00:27 +0200 (Thu, 05 Jul 2007) New Revision: 21575 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21575&view=rev Modified: haiku/trunk/src/build/libhaikucompat/Jamfile Log: * compile fix for ZETA, provided by Ingo Modified: haiku/trunk/src/build/libhaikucompat/Jamfile =================================================================== --- haiku/trunk/src/build/libhaikucompat/Jamfile 2007-07-05 19:41:47 UTC (rev 21574) +++ haiku/trunk/src/build/libhaikucompat/Jamfile 2007-07-05 21:00:27 UTC (rev 21575) @@ -22,6 +22,9 @@ : [ FDirName $(HAIKU_TOP) headers build os interface ] ; ObjectSysHdrs $(libbePatchSources) : [ FDirName $(HAIKU_TOP) headers build os storage ] ; + if $(HOST_PLATFORM) = dano { + ObjectDefines $(libbePatchSources) : _IMPEXP_BE= ; + } } BuildPlatformStaticLibrary libhaikucompat_build.a : From bonefish at cs.tu-berlin.de Fri Jul 6 02:00:49 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Fri, 06 Jul 2007 02:00:49 +0200 Subject: [Haiku-commits] broken build In-Reply-To: <672765519-BeMail@zon> References: <672765519-BeMail@zon> Message-ID: <20070706020049.768.2@cs.tu-berlin.de> On 2007-07-05 at 22:47:34 [+0200], Axel D?rfler wrote: > Ingo Weinhold wrote: > > On 2007-07-05 at 17:57:12 [+0200], Axel D?rfler > > > wrote: > > > Ingo Weinhold wrote: > > > > Does the attached patch fix the issue? > > > Alternatively, we could just get rid of those, couldn't we? > > Yeah, we should. I'm just reluctant, since most of those headers are > > actually original Be headers, in the worse cases even with replaced > > copyright headers. > > Replaced copyright headers don't sound too good - are there anyones in > particular you were thinking of? grep'ing for IMPEXP produces some good candidates: BeBuild.h -> Be copyright, but modified by us. app/Application.h -> Went through several cleanup and modification cycles and has a Haiku copyright, but I believe it originally was the Be header. app/Messenger.h -> Written by me. I rewrote all headers of classes I implemented years ago, so I think this one should be OK. device/Joystick.h -> Be copyright game/WindowScreen.h -> Haiku copyright; looks safe interface/GraphicsDefs.h -> OpenBeOS copyright, but clearly the reformatted original Be header interface/Input.h -> Be copyright interface/InterfaceDefs.h -> Haiku copyright; looks very much like Be's header (the B_*_TINT comments are bytewise identical), though there are only so many ways to format function prototypes and enums. interface/Menu.h -> Be copyright interface/Point.h -> Haiku copyright; looks OK kernel/image.h -> Be copyright kernel/scheduler.h -> Be copyright mail/E-mail.h -> Be copyright media/MediaDefs.h -> Be copyright media/MediaFile.h -> no copyright; almost identical to Be's header (which didn't have a copyright notice either) media/MediaFormats.h media/ParameterWeb.h media/PlaySound.h media/RealtimeAlloc.h media/TimeCode.h media/TimedEventQueue.h -> Be copyright midi/Synth.h -> no copyright; looks basically OK, though all (non-style conforming) parameter names are identical to those in Be's header net/net_settings.h -> Be copyright storage/Alias.h -> Be copyright; can be removed, I think, since it is neither documented nor fully understood or implemented support/Debug.h -> Haiku copyright; some indications from being directly derived from Be's header (identical upper/lower case macro parameters, two-line comment at the end) support/TypeConstants.h -> Haiku copyright; derived from Be's header -- e.g. the older version in headers/build/os/ still features the multiline comment above the URL types. translation/TranslatorFormats.h -> Be copyright > I guess we need to compile a list of all those headers and replace them > for good. Yep. > How to learn typing... :-) Uh, just go ahead. :-P CU, Ingo From axeld at mail.berlios.de Fri Jul 6 12:35:24 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 6 Jul 2007 12:35:24 +0200 Subject: [Haiku-commits] r21576 - in haiku/trunk/headers/os: app game interface storage Message-ID: <200707061035.l66AZOEQ031016@sheep.berlios.de> Author: axeld Date: 2007-07-06 12:35:17 +0200 (Fri, 06 Jul 2007) New Revision: 21576 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21576&view=rev Removed: haiku/trunk/headers/os/storage/Alias.h Modified: haiku/trunk/headers/os/app/Messenger.h haiku/trunk/headers/os/game/WindowScreen.h haiku/trunk/headers/os/interface/Point.h Log: * Removed the _IMPEXP* stuff from the headers Ingo clearly identified as ours. * Removed storage/Alias.h as that stuff isn't even available on BeOS. Modified: haiku/trunk/headers/os/app/Messenger.h =================================================================== --- haiku/trunk/headers/os/app/Messenger.h 2007-07-05 21:00:27 UTC (rev 21575) +++ haiku/trunk/headers/os/app/Messenger.h 2007-07-06 10:35:17 UTC (rev 21576) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005, Haiku, Inc. All Rights Reserved. + * Copyright 2001-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -73,7 +73,7 @@ int32 _reserved[3]; }; -_IMPEXP_BE bool operator<(const BMessenger &a, const BMessenger &b); -_IMPEXP_BE bool operator!=(const BMessenger &a, const BMessenger &b); +bool operator<(const BMessenger &a, const BMessenger &b); +bool operator!=(const BMessenger &a, const BMessenger &b); #endif // _MESSENGER_H Modified: haiku/trunk/headers/os/game/WindowScreen.h =================================================================== --- haiku/trunk/headers/os/game/WindowScreen.h 2007-07-05 21:00:27 UTC (rev 21575) +++ haiku/trunk/headers/os/game/WindowScreen.h 2007-07-06 10:35:17 UTC (rev 21576) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _WINDOW_SCREEN_H @@ -14,7 +14,7 @@ #include -_IMPEXP_GAME void set_mouse_position(int32 x, int32 y); +void set_mouse_position(int32 x, int32 y); // Controls the mouse cursor position on screen Modified: haiku/trunk/headers/os/interface/Point.h =================================================================== --- haiku/trunk/headers/os/interface/Point.h 2007-07-05 21:00:27 UTC (rev 21575) +++ haiku/trunk/headers/os/interface/Point.h 2007-07-06 10:35:17 UTC (rev 21576) @@ -8,6 +8,7 @@ #ifndef _POINT_H #define _POINT_H + #include #include @@ -39,9 +40,11 @@ bool operator==(const BPoint &p) const; }; -extern _IMPEXP_BE const BPoint B_ORIGIN; // returns (0,0) +extern const BPoint B_ORIGIN; + // returns (0,0) + inline BPoint::BPoint() { Deleted: haiku/trunk/headers/os/storage/Alias.h From axeld at mail.berlios.de Fri Jul 6 14:52:01 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 6 Jul 2007 14:52:01 +0200 Subject: [Haiku-commits] r21577 - in haiku/trunk/headers: build/os os Message-ID: <200707061252.l66Cq1MK015479@sheep.berlios.de> Author: axeld Date: 2007-07-06 14:52:01 +0200 (Fri, 06 Jul 2007) New Revision: 21577 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21577&view=rev Modified: haiku/trunk/headers/build/os/StorageKit.h haiku/trunk/headers/os/StorageKit.h Log: StorageKit.h still included the Alias.h header file I removed with the previous commit. Modified: haiku/trunk/headers/build/os/StorageKit.h =================================================================== --- haiku/trunk/headers/build/os/StorageKit.h 2007-07-06 10:35:17 UTC (rev 21576) +++ haiku/trunk/headers/build/os/StorageKit.h 2007-07-06 12:52:01 UTC (rev 21577) @@ -2,7 +2,6 @@ * Master include file for the Storage Kit. * */ -#include #include #include #include Modified: haiku/trunk/headers/os/StorageKit.h =================================================================== --- haiku/trunk/headers/os/StorageKit.h 2007-07-06 10:35:17 UTC (rev 21576) +++ haiku/trunk/headers/os/StorageKit.h 2007-07-06 12:52:01 UTC (rev 21577) @@ -2,7 +2,6 @@ * Master include file for the Storage Kit. * */ -#include #include #include #include From marcusoverhagen at mail.berlios.de Sat Jul 7 02:02:13 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 7 Jul 2007 02:02:13 +0200 Subject: [Haiku-commits] r21578 - haiku/trunk/src/kits/storage Message-ID: <200707070002.l6702DWK025743@sheep.berlios.de> Author: marcusoverhagen Date: 2007-07-07 02:02:12 +0200 (Sat, 07 Jul 2007) New Revision: 21578 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21578&view=rev Modified: haiku/trunk/src/kits/storage/PathMonitor.cpp Log: gcc4 fix Modified: haiku/trunk/src/kits/storage/PathMonitor.cpp =================================================================== --- haiku/trunk/src/kits/storage/PathMonitor.cpp 2007-07-06 12:52:01 UTC (rev 21577) +++ haiku/trunk/src/kits/storage/PathMonitor.cpp 2007-07-07 00:02:12 UTC (rev 21578) @@ -526,7 +526,7 @@ bool -PathHandler::_HasDirectory(const node_ref& nodeRef, bool* _contained = NULL) const +PathHandler::_HasDirectory(const node_ref& nodeRef, bool* _contained /* = NULL */) const { watched_directory directory; directory.node = nodeRef; From marcusoverhagen at mail.berlios.de Sat Jul 7 02:36:13 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 7 Jul 2007 02:36:13 +0200 Subject: [Haiku-commits] r21579 - haiku/trunk/src/kits/storage Message-ID: <200707070036.l670aD7O029527@sheep.berlios.de> Author: marcusoverhagen Date: 2007-07-07 02:36:11 +0200 (Sat, 07 Jul 2007) New Revision: 21579 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21579&view=rev Modified: haiku/trunk/src/kits/storage/PathMonitor.cpp Log: gcc4 compile fix, but C++ predicates are ugly Modified: haiku/trunk/src/kits/storage/PathMonitor.cpp =================================================================== --- haiku/trunk/src/kits/storage/PathMonitor.cpp 2007-07-07 00:02:12 UTC (rev 21578) +++ haiku/trunk/src/kits/storage/PathMonitor.cpp 2007-07-07 00:36:11 UTC (rev 21579) @@ -40,13 +40,28 @@ namespace BPrivate { +#if __GNUC__ > 3 + bool operator<(const node_ref& a, const node_ref& b); + class node_ref_less : public binary_function + { + public: + bool operator() (const node_ref& a, const node_ref& b) const + { + return a < b; + } + }; + typedef set FileSet; +#else + typedef set FileSet; +#endif + struct watched_directory { node_ref node; bool contained; }; typedef set DirectorySet; -typedef set FileSet; + class PathHandler; typedef map HandlerMap; From marcusoverhagen at mail.berlios.de Sat Jul 7 02:37:12 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 7 Jul 2007 02:37:12 +0200 Subject: [Haiku-commits] r21580 - haiku/trunk/src/apps/terminal Message-ID: <200707070037.l670bCCq029633@sheep.berlios.de> Author: marcusoverhagen Date: 2007-07-07 02:37:11 +0200 (Sat, 07 Jul 2007) New Revision: 21580 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21580&view=rev Modified: haiku/trunk/src/apps/terminal/Coding.cpp Log: compile fix, header file for strcmp was missing Modified: haiku/trunk/src/apps/terminal/Coding.cpp =================================================================== --- haiku/trunk/src/apps/terminal/Coding.cpp 2007-07-07 00:36:11 UTC (rev 21579) +++ haiku/trunk/src/apps/terminal/Coding.cpp 2007-07-07 00:37:11 UTC (rev 21580) @@ -1,4 +1,5 @@ #include "Coding.h" +#include struct etable { const char *name; // long name for menu item. From bonefish at mail.berlios.de Sat Jul 7 03:28:07 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 7 Jul 2007 03:28:07 +0200 Subject: [Haiku-commits] r21581 - in haiku/trunk/src: libs/zlib system/boot/loader tests/system/boot/loader tests/system/boot/loader/file_systems/amiga_ffs tests/system/boot/loader/file_systems/bfs tests/system/boot/loader/file_systems/tarfs Message-ID: <200707070128.l671S7DO032557@sheep.berlios.de> Author: bonefish Date: 2007-07-07 03:28:04 +0200 (Sat, 07 Jul 2007) New Revision: 21581 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21581&view=rev Modified: haiku/trunk/src/libs/zlib/Jamfile haiku/trunk/src/system/boot/loader/load_driver_settings.cpp haiku/trunk/src/tests/system/boot/loader/Jamfile haiku/trunk/src/tests/system/boot/loader/file_systems/amiga_ffs/Jamfile haiku/trunk/src/tests/system/boot/loader/file_systems/bfs/Jamfile haiku/trunk/src/tests/system/boot/loader/file_systems/tarfs/Jamfile Log: Allow building the BootLoaderTest (and zlib) for BeOS. Modified: haiku/trunk/src/libs/zlib/Jamfile =================================================================== --- haiku/trunk/src/libs/zlib/Jamfile 2007-07-07 00:37:11 UTC (rev 21580) +++ haiku/trunk/src/libs/zlib/Jamfile 2007-07-07 01:28:04 UTC (rev 21581) @@ -1,5 +1,7 @@ SubDir HAIKU_TOP src libs zlib ; +SetSubDirSupportedPlatformsBeOSCompatible ; + UseLibraryHeaders zlib ; local shared_files = Modified: haiku/trunk/src/system/boot/loader/load_driver_settings.cpp =================================================================== --- haiku/trunk/src/system/boot/loader/load_driver_settings.cpp 2007-07-07 00:37:11 UTC (rev 21580) +++ haiku/trunk/src/system/boot/loader/load_driver_settings.cpp 2007-07-07 01:28:04 UTC (rev 21581) @@ -15,6 +15,7 @@ #include #include +#include static status_t Modified: haiku/trunk/src/tests/system/boot/loader/Jamfile =================================================================== --- haiku/trunk/src/tests/system/boot/loader/Jamfile 2007-07-07 00:37:11 UTC (rev 21580) +++ haiku/trunk/src/tests/system/boot/loader/Jamfile 2007-07-07 01:28:04 UTC (rev 21581) @@ -1,5 +1,7 @@ SubDir HAIKU_TOP src tests system boot loader ; +SetSubDirSupportedPlatformsBeOSCompatible ; + UsePrivateHeaders [ FDirName kernel ] ; UsePrivateHeaders [ FDirName kernel disk_device_manager ] ; UsePrivateHeaders [ FDirName storage ] ; @@ -12,6 +14,11 @@ SubDirHdrs $(HAIKU_TOP) src add-ons kernel partitioning_systems efi ; SubDirHdrs $(HAIKU_TOP) src add-ons kernel partitioning_systems intel ; +if $(TARGET_PLATFORM) != haiku { + UsePublicHeaders drivers ; # disk_device_manager.h + UsePublicHeaders storage ; # DiskDeviceDefs.h +} + # we need to redefine certain calls in the boot loader so that # they will really be used instead of their POSIX counterparts # in libroot.so Modified: haiku/trunk/src/tests/system/boot/loader/file_systems/amiga_ffs/Jamfile =================================================================== --- haiku/trunk/src/tests/system/boot/loader/file_systems/amiga_ffs/Jamfile 2007-07-07 00:37:11 UTC (rev 21580) +++ haiku/trunk/src/tests/system/boot/loader/file_systems/amiga_ffs/Jamfile 2007-07-07 01:28:04 UTC (rev 21581) @@ -1,11 +1,18 @@ SubDir HAIKU_TOP src tests system boot loader file_systems amiga_ffs ; +SetSubDirSupportedPlatformsBeOSCompatible ; + UsePrivateHeaders [ FDirName kernel ] ; UsePrivateHeaders [ FDirName kernel disk_device_manager ] ; UsePrivateHeaders [ FDirName storage ] ; SubDirSysHdrs $(HAIKU_TOP) src tests system boot loader ; SubDirHdrs $(HAIKU_TOP) src system boot loader file_systems amiga_ffs ; +if $(TARGET_PLATFORM) != haiku { + UsePublicHeaders drivers ; # disk_device_manager.h + UsePublicHeaders storage ; # DiskDeviceDefs.h +} + ObjectDefines amiga_ffs.cpp Volume.cpp Modified: haiku/trunk/src/tests/system/boot/loader/file_systems/bfs/Jamfile =================================================================== --- haiku/trunk/src/tests/system/boot/loader/file_systems/bfs/Jamfile 2007-07-07 00:37:11 UTC (rev 21580) +++ haiku/trunk/src/tests/system/boot/loader/file_systems/bfs/Jamfile 2007-07-07 01:28:04 UTC (rev 21581) @@ -1,5 +1,7 @@ SubDir HAIKU_TOP src tests system boot loader file_systems bfs ; +SetSubDirSupportedPlatformsBeOSCompatible ; + UsePrivateHeaders [ FDirName kernel ] ; UsePrivateHeaders [ FDirName kernel disk_device_manager ] ; UsePrivateHeaders [ FDirName storage ] ; @@ -7,6 +9,11 @@ SubDirHdrs $(HAIKU_TOP) src system boot loader file_systems bfs ; SubDirHdrs $(HAIKU_TOP) src add-ons kernel file_systems bfs ; +if $(TARGET_PLATFORM) != haiku { + UsePublicHeaders drivers ; # disk_device_manager.h + UsePublicHeaders storage ; # DiskDeviceDefs.h +} + ObjectDefines bfs.cpp Directory.cpp Modified: haiku/trunk/src/tests/system/boot/loader/file_systems/tarfs/Jamfile =================================================================== --- haiku/trunk/src/tests/system/boot/loader/file_systems/tarfs/Jamfile 2007-07-07 00:37:11 UTC (rev 21580) +++ haiku/trunk/src/tests/system/boot/loader/file_systems/tarfs/Jamfile 2007-07-07 01:28:04 UTC (rev 21581) @@ -1,11 +1,20 @@ SubDir HAIKU_TOP src tests system boot loader file_systems tarfs ; +SetSubDirSupportedPlatformsBeOSCompatible ; + UsePrivateHeaders [ FDirName kernel disk_device_manager ] ; UsePrivateHeaders kernel shared storage ; SubDirSysHdrs $(HAIKU_TOP) src tests system boot loader ; SubDirSysHdrs $(HAIKU_TOP) headers libs zlib ; SubDirHdrs $(HAIKU_TOP) src system boot loader file_systems tarfs ; +if $(TARGET_PLATFORM) != haiku { + UsePublicHeaders drivers ; # disk_device_manager.h + UsePublicHeaders storage ; # DiskDeviceDefs.h + + ObjectDefines tarfs.cpp : B_BUFFER_OVERFLOW=B_BAD_VALUE ; +} + ObjectDefines tarfs.cpp : From bonefish at mail.berlios.de Sat Jul 7 03:41:56 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 7 Jul 2007 03:41:56 +0200 Subject: [Haiku-commits] r21582 - haiku/trunk/headers/private/shared Message-ID: <200707070141.l671fuwN001036@sheep.berlios.de> Author: bonefish Date: 2007-07-07 03:41:55 +0200 (Sat, 07 Jul 2007) New Revision: 21582 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21582&view=rev Modified: haiku/trunk/headers/private/shared/AutoDeleter.h Log: Added AutoDeleter::Get(). Modified: haiku/trunk/headers/private/shared/AutoDeleter.h =================================================================== --- haiku/trunk/headers/private/shared/AutoDeleter.h 2007-07-07 01:28:04 UTC (rev 21581) +++ haiku/trunk/headers/private/shared/AutoDeleter.h 2007-07-07 01:41:55 UTC (rev 21582) @@ -72,6 +72,11 @@ SetTo(NULL); } + inline C *Get() const + { + return fObject; + } + inline C *Detach() { C *object = fObject; From bonefish at mail.berlios.de Sat Jul 7 03:49:04 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 7 Jul 2007 03:49:04 +0200 Subject: [Haiku-commits] r21583 - haiku/trunk/src/system/boot/loader/file_systems/tarfs Message-ID: <200707070149.l671n4RQ001594@sheep.berlios.de> Author: bonefish Date: 2007-07-07 03:49:02 +0200 (Sat, 07 Jul 2007) New Revision: 21583 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21583&view=rev Modified: haiku/trunk/src/system/boot/loader/file_systems/tarfs/tarfs.cpp haiku/trunk/src/system/boot/loader/file_systems/tarfs/tarfs.h Log: * Added support for symlinks. * Prepared for other uses than just boot floppies (/CDs). We first try to inflate the contents of the given device at offset 0 before using the floppy disk offset. This will make it easy to mount tgz files loaded via network or built into the boot loader itself. * Increased the max possible size of inflated data to 32 MB. Modified: haiku/trunk/src/system/boot/loader/file_systems/tarfs/tarfs.cpp =================================================================== --- haiku/trunk/src/system/boot/loader/file_systems/tarfs/tarfs.cpp 2007-07-07 01:41:55 UTC (rev 21582) +++ haiku/trunk/src/system/boot/loader/file_systems/tarfs/tarfs.cpp 2007-07-07 01:49:02 UTC (rev 21583) @@ -1,5 +1,5 @@ /* - * Copyright 2005, Ingo Weinhold, bonefish at cs.tu-berlin.de. All rights reserved. + * Copyright 2005-2007, Ingo Weinhold, bonefish at cs.tu-berlin.de. * Copyright 2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * * Distributed under the terms of the MIT License. @@ -33,8 +33,8 @@ #endif -static const uint32 kCompressedArchiveOffset = 192 * 1024; // at 192 kB -static const size_t kTarRegionSize = 4 * 1024 * 1024; // 4 MB +static const uint32 kFloppyArchiveOffset = 192 * 1024; // at 192 kB +static const size_t kTarRegionSize = 32 * 1024 * 1024; // 32 MB namespace TarFS { @@ -126,6 +126,31 @@ EntryList fEntries; }; + +class Symlink : public ::Node, public Entry { + public: + Symlink(tar_header *header, const char *name); + virtual ~Symlink(); + + virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer, + size_t bufferSize); + virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer, + size_t bufferSize); + + virtual status_t GetName(char *nameBuffer, size_t bufferSize) const; + + virtual int32 Type() const; + virtual off_t Size() const; + virtual ino_t Inode() const; + + virtual ::Node *ToNode() { return this; } + + private: + tar_header *fHeader; + size_t fSize; +}; + + class Volume : public TarFS::Directory { public: Volume(); @@ -134,6 +159,11 @@ status_t Init(boot::Partition *partition); TarFS::Directory *Root() { return this; } + + private: + status_t _Inflate(boot::Partition *partition, void* cookie, + off_t offset, RegionDeleter& regionDeleter, + size_t* inflatedBytes); }; } // namespace TarFS @@ -453,12 +483,19 @@ return error; } - // create the file - TarFS::File *file = new(nothrow) TarFS::File(header, leaf); - if (!file) + // create the entry + TarFS::Entry *entry; + if (header->type == TAR_FILE || header->type == TAR_FILE2) + entry = new(nothrow) TarFS::File(header, leaf); + else if (header->type == TAR_SYMLINK) + entry = new(nothrow) TarFS::Symlink(header, leaf); + else + return B_BAD_VALUE; + + if (!entry) return B_NO_MEMORY; - dir->fEntries.Add(file); + dir->fEntries.Add(entry); return B_OK; } @@ -481,6 +518,83 @@ // #pragma mark - +TarFS::Symlink::Symlink(tar_header *header, const char *name) + : TarFS::Entry(name), + fHeader(header) +{ + fSize = strnlen(header->linkname, sizeof(header->linkname)); + // null-terminate for sure (might overwrite a byte of the magic) + header->linkname[fSize++] = '\0'; +} + + +TarFS::Symlink::~Symlink() +{ +} + + +ssize_t +TarFS::Symlink::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize) +{ + TRACE(("tarfs: symlink read at %Ld, %lu bytes, fSize = %Ld\n", pos, + bufferSize, fSize)); + + if (pos < 0 || !buffer) + return B_BAD_VALUE; + + if (pos >= fSize || bufferSize == 0) + return 0; + + size_t toRead = fSize - pos; + if (toRead > bufferSize) + toRead = bufferSize; + + memcpy(buffer, fHeader->linkname + pos, toRead); + + return toRead; +} + + +ssize_t +TarFS::Symlink::WriteAt(void *cookie, off_t pos, const void *buffer, + size_t bufferSize) +{ + return B_NOT_ALLOWED; +} + + +status_t +TarFS::Symlink::GetName(char *nameBuffer, size_t bufferSize) const +{ + return strlcpy(nameBuffer, Name(), bufferSize) >= bufferSize + ? B_BUFFER_OVERFLOW : B_OK; +} + + +int32 +TarFS::Symlink::Type() const +{ + return S_IFLNK; +} + + +off_t +TarFS::Symlink::Size() const +{ + return fSize; +} + + +ino_t +TarFS::Symlink::Inode() const +{ + return fID; +} + + +// #pragma mark - + + TarFS::Volume::Volume() : TarFS::Directory("Boot from CD-ROM") { @@ -516,79 +630,22 @@ } } _(partition, cookie); + // inflate the tar file -- try offset 0 and the archive offset on a floppy + // disk RegionDeleter regionDeleter; - - char *out = NULL; - - char in[2048]; - z_stream zStream = { - (Bytef*)in, // next in - sizeof(in), // avail in - 0, // total in - NULL, // next out - 0, // avail out - 0, // total out - 0, // msg - 0, // state - Z_NULL, // zalloc - Z_NULL, // zfree - Z_NULL, // opaque - 0, // data type - 0, // adler - 0, // reserved - }; - - int status; - uint32 offset = kCompressedArchiveOffset; - - do { - if (partition->ReadAt(cookie, offset, in, sizeof(in)) != sizeof(in)) { - status = Z_STREAM_ERROR; - break; - } - - zStream.avail_in = sizeof(in); - zStream.next_in = (Bytef *)in; - - if (offset == kCompressedArchiveOffset) { - // check and skip gzip header - if (!skip_gzip_header(&zStream)) - return B_BAD_DATA; - - if (platform_allocate_region((void **)&out, kTarRegionSize, - B_READ_AREA | B_WRITE_AREA, false) != B_OK) { - TRACE(("tarfs: allocating region failed!\n")); - return B_NO_MEMORY; - } - - regionDeleter.SetTo(out); - zStream.avail_out = kTarRegionSize; - zStream.next_out = (Bytef *)out; - - status = inflateInit2(&zStream, -15); - if (status != Z_OK) - return B_ERROR; - } - - status = inflate(&zStream, Z_SYNC_FLUSH); - offset += sizeof(in); - - if (zStream.avail_in != 0 && status != Z_STREAM_END) - dprintf("tarfs: didn't read whole block!\n"); - } while (status == Z_OK); - - inflateEnd(&zStream); - - if (status != Z_STREAM_END) { - TRACE(("tarfs: inflating failed: %d!\n", status)); - return B_BAD_DATA; + size_t inflatedBytes; + status_t status = _Inflate(partition, cookie, 0, regionDeleter, + &inflatedBytes); + if (status != B_OK) { + status = _Inflate(partition, cookie, kFloppyArchiveOffset, + regionDeleter, &inflatedBytes); } + if (status != B_OK) + return status; - status = B_OK; - // parse the tar file - char *block = out; - int blockCount = zStream.total_out / BLOCK_SIZE; + char *block = (char*)regionDeleter.Get(); + int blockCount = inflatedBytes / BLOCK_SIZE; int blockIndex = 0; while (blockIndex < blockCount) { @@ -615,6 +672,7 @@ switch (header->type) { case TAR_FILE: case TAR_FILE2: + case TAR_SYMLINK: status = AddFile(header); break; @@ -626,6 +684,7 @@ // this is a long file name // TODO: read long name default: + dprintf("tarfs: unsupported file type: %d ('%c')\n", header->type, header->type); // unsupported type status = B_ERROR; break; @@ -646,6 +705,89 @@ } +status_t +TarFS::Volume::_Inflate(boot::Partition *partition, void* cookie, off_t offset, + RegionDeleter& regionDeleter, size_t* inflatedBytes) +{ + char in[2048]; + z_stream zStream = { + (Bytef*)in, // next in + sizeof(in), // avail in + 0, // total in + NULL, // next out + 0, // avail out + 0, // total out + 0, // msg + 0, // state + Z_NULL, // zalloc + Z_NULL, // zfree + Z_NULL, // opaque + 0, // data type + 0, // adler + 0, // reserved + }; + + int status; + char* out = (char*)regionDeleter.Get(); + bool headerRead = false; + + do { + ssize_t bytesRead = partition->ReadAt(cookie, offset, in, sizeof(in)); + if (bytesRead != (ssize_t)sizeof(in)) { + if (bytesRead <= 0) { + status = Z_STREAM_ERROR; + break; + } + } + + zStream.avail_in = bytesRead; + zStream.next_in = (Bytef *)in; + + if (!headerRead) { + // check and skip gzip header + if (!skip_gzip_header(&zStream)) + return B_BAD_DATA; + headerRead = true; + + if (!out) { + // allocate memory for the uncompressed data + if (platform_allocate_region((void **)&out, kTarRegionSize, + B_READ_AREA | B_WRITE_AREA, false) != B_OK) { + TRACE(("tarfs: allocating region failed!\n")); + return B_NO_MEMORY; + } + regionDeleter.SetTo(out); + } + + zStream.avail_out = kTarRegionSize; + zStream.next_out = (Bytef *)out; + + status = inflateInit2(&zStream, -15); + if (status != Z_OK) + return B_ERROR; + } + + status = inflate(&zStream, Z_SYNC_FLUSH); + offset += bytesRead; + + if (zStream.avail_in != 0 && status != Z_STREAM_END) + dprintf("tarfs: didn't read whole block!\n"); + } while (status == Z_OK); + + inflateEnd(&zStream); + + if (status != Z_STREAM_END) { + TRACE(("tarfs: inflating failed: %d!\n", status)); + return B_BAD_DATA; + } + + *inflatedBytes = zStream.total_out; + + return B_OK; +} + + + // #pragma mark - Modified: haiku/trunk/src/system/boot/loader/file_systems/tarfs/tarfs.h =================================================================== --- haiku/trunk/src/system/boot/loader/file_systems/tarfs/tarfs.h 2007-07-07 01:41:55 UTC (rev 21582) +++ haiku/trunk/src/system/boot/loader/file_systems/tarfs/tarfs.h 2007-07-07 01:49:02 UTC (rev 21583) @@ -38,6 +38,7 @@ enum { TAR_FILE = '0', TAR_FILE2 = '\0', + TAR_SYMLINK = '2', TAR_DIRECTORY = '5', TAR_LONG_NAME = 'L', }; From nielx at mail.berlios.de Sat Jul 7 10:29:52 2007 From: nielx at mail.berlios.de (nielx at BerliOS) Date: Sat, 7 Jul 2007 10:29:52 +0200 Subject: [Haiku-commits] r21584 - haiku/trunk/docs/user/drivers Message-ID: <200707070829.l678TqqS011602@sheep.berlios.de> Author: nielx Date: 2007-07-07 10:29:52 +0200 (Sat, 07 Jul 2007) New Revision: 21584 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21584&view=rev Modified: haiku/trunk/docs/user/drivers/fs_interface.dox Log: Update to the latest prototypes of fs_interface.h Modified: haiku/trunk/docs/user/drivers/fs_interface.dox =================================================================== --- haiku/trunk/docs/user/drivers/fs_interface.dox 2007-07-07 01:49:02 UTC (rev 21583) +++ haiku/trunk/docs/user/drivers/fs_interface.dox 2007-07-07 08:29:52 UTC (rev 21584) @@ -6,7 +6,7 @@ * Ingo Weinhold * Niels Sascha Reedijk * Corresponds to: - * /trunk/headers/os/drivers/fs_interface.h rev 20724 + * /trunk/headers/os/drivers/fs_interface.h rev 21568 */ /*! @@ -20,16 +20,6 @@ ///// Typedefs ///// -/*! - \typedef typedef dev_t mount_id - \brief A \c mount_id refers to a mounted volume. -*/ - -/*! - \typedef typedef ino_t vnode_id - \brief A \c vnode_id refers to one of the available vnodes. -*/ - /*! \typedef typedef void *fs_volume \brief Private data structure for the filesystem to store data associated @@ -189,8 +179,8 @@ //! @{ /*! - \fn status_t (*file_system_module_info::mount)(mount_id id, const char *device, - uint32 flags, const char *args, fs_volume *_fs, vnode_id *_rootVnodeID) + \fn status_t (*file_system_module_info::mount)(ino_t id, const char *device, + uint32 flags, const char *args, fs_volume *_fs, ino_t *_rootVnodeID) \brief Mount a volume according to the specified parameters. Invoked by the VFS when it has been requested to mount the volume. The FS is @@ -309,7 +299,7 @@ /*! \fn status_t (*file_system_module_info::lookup)(fs_volume fs, fs_vnode dir, - const char *name, vnode_id *_id, int *_type) + const char *name, ino_t *_id, int *_type) \brief Looks up the node a directory entry refers to. The VFS uses this hook to resolve path names to vnodes. It is used quite @@ -353,7 +343,7 @@ */ /*! - \fn status_t (*file_system_module_info::get_vnode)(fs_volume fs, vnode_id id, + \fn status_t (*file_system_module_info::get_vnode)(fs_volume fs, ino_t id, fs_vnode *_vnode, bool reenter) \brief Creates the private data handle to be associated with the node referred to by \a id. @@ -696,7 +686,7 @@ /*! \fn status_t (*file_system_module_info::create)(fs_volume fs, fs_vnode dir, const char *name, int openMode, int perms, fs_cookie *_cookie, - vnode_id *_newVnodeID) + ino_t *_newVnodeID) \brief Create a new file. Your implementation shall check whether it is possible to create the node. @@ -843,7 +833,7 @@ /*! \fn status_t (*file_system_module_info::create_dir)(fs_volume fs, fs_vnode - parent, const char *name, int perms, vnode_id *_newVnodeID) + parent, const char *name, int perms, ino_t *_newVnodeID) \brief Create a new directory. Your implementation should make sure that the directory actually can be @@ -1567,7 +1557,7 @@ ///// Global Functions ///// /*! - \fn status_t new_vnode(mount_id mountID, vnode_id vnodeID, + \fn status_t new_vnode(dev_t mountID, ino_t vnodeID, fs_vnode privateNode) \brief Create the vnode with ID \a vnodeID and associates it with the private data handle \a privateNode, but leaves is in an unpublished state. @@ -1591,7 +1581,7 @@ */ /*! - \fn status_t publish_vnode(mount_id mountID, vnode_id vnodeID, + \fn status_t publish_vnode(dev_t mountID, ino_t vnodeID, fs_vnode privateNode) \brief Creates the vnode with ID \a vnodeID and associates it with the private data handle \a privateNode or just marks it published. @@ -1612,7 +1602,7 @@ */ /*! - \fn status_t get_vnode(mount_id mountID, vnode_id vnodeID, + \fn status_t get_vnode(dev_t mountID, ino_t vnodeID, fs_vnode *_privateNode) \brief Retrieves the private data handle for the node with the given ID. @@ -1627,7 +1617,7 @@ */ /*! - \fn status_t put_vnode(mount_id mountID, vnode_id vnodeID) + \fn status_t put_vnode(dev_t mountID, ino_t vnodeID) \brief Surrenders a reference to the specified vnode. \param mountID The ID of the volume. \param vnodeID The ID of the node. @@ -1635,7 +1625,7 @@ */ /*! - \fn status_t remove_vnode(mount_id mountID, vnode_id vnodeID) + \fn status_t remove_vnode(dev_t mountID, ino_t vnodeID) \brief Marks the specified vnode removed. The caller must own a reference to the vnode or at least ensure that a @@ -1653,7 +1643,7 @@ */ /*! - \fn status_t unremove_vnode(mount_id mountID, vnode_id vnodeID); + \fn status_t unremove_vnode(dev_t mountID, ino_t vnodeID); \brief Clears the "removed" mark of the specified vnode. The caller must own a reference to the vnode or at least ensure that a @@ -1669,7 +1659,7 @@ */ /*! - \fn status_t get_vnode_removed(mount_id mountID, vnode_id vnodeID, + \fn status_t get_vnode_removed(dev_t mountID, ino_t vnodeID, bool* removed); \brief Returns whether the specified vnode is marked removed. @@ -1695,53 +1685,53 @@ //! @{ /*! - \fn status_t notify_listener(int op, mount_id device, vnode_id parentNode, - vnode_id toParentNode, vnode_id node, const char *name) + \fn status_t notify_listener(int op, dev_t device, ino_t parentNode, + ino_t toParentNode, ino_t node, const char *name) \brief Deprecated. This feature will be removed in future versions. */ /*! - \fn status_t notify_entry_created(mount_id device, vnode_id directory, - const char *name, vnode_id node) + \fn status_t notify_entry_created(dev_t device, ino_t directory, + const char *name, ino_t node) \brief Deprecated. This feature will be removed in future versions. */ /*! - \fn status_t notify_entry_removed(mount_id device, vnode_id directory, - const char *name, vnode_id node) + \fn status_t notify_entry_removed(dev_t device, ino_t directory, + const char *name, ino_t node) \brief Deprecated. This feature will be removed in future versions. */ /*! - \fn status_t notify_entry_moved(mount_id device, vnode_id fromDirectory, - const char *fromName, vnode_id toDirectory, - const char *toName, vnode_id node) + \fn status_t notify_entry_moved(dev_t device, ino_t fromDirectory, + const char *fromName, ino_t toDirectory, + const char *toName, ino_t node) \brief Deprecated. This feature will be removed in future versions. */ /*! - \fn status_t notify_stat_changed(mount_id device, vnode_id node, + \fn status_t notify_stat_changed(dev_t device, ino_t node, uint32 statFields) \brief Deprecated. This feature will be removed in future versions. */ /*! - \fn status_t notify_attribute_changed(mount_id device, vnode_id node, + \fn status_t notify_attribute_changed(dev_t device, ino_t node, const char *attribute, int32 cause) \brief Deprecated. This feature will be removed in future versions. */ /*! \fn status_t notify_query_entry_created(port_id port, int32 token, - mount_id device, vnode_id directory, const char *name, - vnode_id node) + dev_t device, ino_t directory, const char *name, + ino_t node) \brief Deprecated. This feature will be removed in future versions. */ /*! \fn status_t notify_query_entry_removed(port_id port, int32 token, - mount_id device, vnode_id directory, const char *name, - vnode_id node) + dev_t device, ino_t directory, const char *name, + ino_t node) \brief Deprecated. This feature will be removed in future versions. */ From jonas at kirilla.com Sat Jul 7 13:32:09 2007 From: jonas at kirilla.com (Jonas =?iso-8859-1?q?Sundstr=F6m?=) Date: Sat, 07 Jul 2007 13:32:09 +0200 CEST Subject: [Haiku-commits] broken build In-Reply-To: <20070706020049.768.2@cs.tu-berlin.de> Message-ID: <2834911545-BeMail@kirilla> Ingo Weinhold wrote: > On 2007-07-05 at 22:47:34 [+0200], Axel D?rfler ... > BeBuild.h > -> Be copyright, but modified by us. ... > > I guess we need to compile a list of all those > > headers and replace them for good. How should one approach this? Is there a safe method? Are there any dead wrong methods? Has anyone started on it? I suppose it would be nice to commit a bunch of these together, so not everyone has to rebuild much of the tree again and again. /Jonas. From kirilla at mail.berlios.de Sat Jul 7 18:29:45 2007 From: kirilla at mail.berlios.de (kirilla at BerliOS) Date: Sat, 7 Jul 2007 18:29:45 +0200 Subject: [Haiku-commits] r21585 - haiku/trunk/src/bin/desklink Message-ID: <200707071629.l67GTjje016318@sheep.berlios.de> Author: kirilla Date: 2007-07-07 18:29:44 +0200 (Sat, 07 Jul 2007) New Revision: 21585 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21585&view=rev Modified: haiku/trunk/src/bin/desklink/desklink.cpp Log: Allow removing any Deskbar replicants, by name. Modified: haiku/trunk/src/bin/desklink/desklink.cpp =================================================================== --- haiku/trunk/src/bin/desklink/desklink.cpp 2007-07-07 08:29:52 UTC (rev 21584) +++ haiku/trunk/src/bin/desklink/desklink.cpp 2007-07-07 16:29:44 UTC (rev 21585) @@ -388,10 +388,19 @@ return 0; } - if (strcmp(argv[i], "--remove") == 0) { + if (strncmp(argv[i], "--remove", 8) == 0) { + BString replicant = "DeskButton"; + if (strncmp(argv[i] + 8, "=", 1) == 0) { + if (strlen(argv[i] + 9) > 0) { + replicant = argv[i] + 9; + } else { + printf("desklink: Missing replicant name.\n"); + return 1; + } + } int32 found = 0; int32 found_id; - while (deskbar.GetItemInfo("DeskButton", &found_id) == B_OK) { + while (deskbar.GetItemInfo(replicant.String(), &found_id) == B_OK) { err = deskbar.RemoveItem(found_id); if (err != B_OK) { printf("desklink: Error removing replicant id %ld: %s\n", @@ -453,7 +462,8 @@ if (!atLeastOnePath) { printf( "usage: desklink { [ --list|--remove|[cmd=title:action ... ] [ path|signature ] } ...\n" "--list: list all Deskbar addons.\n" - "--remove: delete all desklink addons.\n"); + "--remove: remove all desklink addons.\n" + "--remove=name: remove all 'name' addons.\n"); return 1; } From threedeyes at mail.berlios.de Mon Jul 9 06:55:47 2007 From: threedeyes at mail.berlios.de (threedeyes at BerliOS) Date: Mon, 9 Jul 2007 06:55:47 +0200 Subject: [Haiku-commits] r21586 - in haiku/trunk/src/add-ons/kernel/file_systems/ntfs: . libntfs settings Message-ID: <200707090455.l694tl7Y023422@sheep.berlios.de> Author: threedeyes Date: 2007-07-09 06:55:36 +0200 (Mon, 09 Jul 2007) New Revision: 21586 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21586&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fs_func.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/attrib.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/dir.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/dir.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/index.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/inode.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/lcnalloc.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/logfile.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/logging.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/mft.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/misc.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/misc.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/unix_io.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/volume.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/volume.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/settings/ntfs Log: update libntfs-3g to 1.616 Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fs_func.c =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fs_func.c 2007-07-07 16:29:44 UTC (rev 21585) +++ haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fs_func.c 2007-07-09 04:55:36 UTC (rev 21586) @@ -92,7 +92,7 @@ if(strlen(ntVolume->vol_name)>0) strcpy(cookie->label,ntVolume->vol_name); - ntfs_device_umount( ntVolume, true ); + ntfs_umount( ntVolume, true ); *_cookie = cookie; @@ -230,7 +230,7 @@ ERRPRINT("fs_unmount - ENTER\n"); - ntfs_device_umount( ns->ntvol, true ); + ntfs_umount( ns->ntvol, true ); #ifdef __HAIKU__ recursive_lock_destroy(&(ns->vlock)); Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/attrib.c =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/attrib.c 2007-07-07 16:29:44 UTC (rev 21585) +++ haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/attrib.c 2007-07-09 04:55:36 UTC (rev 21586) @@ -544,8 +544,9 @@ if (!next_vcn) { if (a->lowest_vcn) { errno = EIO; - ntfs_log_perror("Attribute first extent has " - "non-zero lowest_vcn"); + ntfs_log_perror("First extent of inode %llu " + "attribute has non-zero lowest_vcn", + (unsigned long long)na->ni->mft_no); goto err_out; } /* Get the last vcn in the attribute. */ @@ -566,7 +567,8 @@ /* Avoid endless loops due to corruption. */ if (next_vcn < sle64_to_cpu(a->lowest_vcn)) { errno = EIO; - ntfs_log_perror("Inode has corrupt attribute list"); + ntfs_log_perror("Inode %llu has corrupt attribute list", + (unsigned long long)na->ni->mft_no); goto err_out; } } @@ -576,8 +578,9 @@ } if (highest_vcn && highest_vcn != last_vcn - 1) { errno = EIO; - ntfs_log_perror("Couldn't load full runlist: " - "highest_vcn = 0x%llx, last_vcn = 0x%llx", + ntfs_log_perror("Failed to load full runlist: inode: %llu " + "highest_vcn: 0x%llx last_vcn: 0x%llx", + (unsigned long long)na->ni->mft_no, (long long)highest_vcn, (long long)last_vcn); goto err_out; } @@ -988,10 +991,8 @@ ((*ofs + to_write - 1) >> vol->cluster_size_bits) + 1 + (*rl)->vcn - from_vcn, lcn_seek_from, DATA_ZONE); - if (!rlc) { - ntfs_log_perror("Hole filling cluster allocation failed"); + if (!rlc) goto err_out; - } *rl = ntfs_runlists_merge(na->rl, rlc); if (!*rl) { Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/dir.c =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/dir.c 2007-07-07 16:29:44 UTC (rev 21585) +++ haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/dir.c 2007-07-09 04:55:36 UTC (rev 21586) @@ -466,11 +466,14 @@ q++; } - len = ntfs_mbstoucs(p, &unicode, NTFS_MAX_NAME_LEN); + len = ntfs_mbstoucs(p, &unicode, MAX_PATH); if (len < 0) { ntfs_log_debug("Couldn't convert name to Unicode: %s.\n", p); err = errno; goto close; + } else if (len > NTFS_MAX_NAME_LEN) { + err = ENAMETOOLONG; + goto close; } inum = ntfs_inode_lookup_by_name(ni, unicode, len); @@ -482,7 +485,10 @@ } if (ni != parent) - ntfs_inode_close(ni); + if (ntfs_inode_close(ni)) { + err = errno; + goto out; + } inum = MREF(inum); ni = ntfs_inode_open(vol, inum); @@ -502,7 +508,9 @@ ni = NULL; close: if (ni && (ni != parent)) - ntfs_inode_close(ni); + if (ntfs_inode_close(ni) && !err) + err = errno; +out: free(ascii); free(unicode); if (err) @@ -1045,12 +1053,15 @@ errno = EINVAL; return NULL; } - /* Allocate MFT record for new file. */ + + if (dir_ni->flags & FILE_ATTR_REPARSE_POINT) { + errno = EOPNOTSUPP; + return NULL; + } + ni = ntfs_mft_record_alloc(dir_ni->vol, NULL); - if (!ni) { - ntfs_log_perror("Could not allocate new MFT record"); + if (!ni) return NULL; - } /* * Create STANDARD_INFORMATION attribute. Write STANDARD_INFORMATION * version 1.2, windows will upgrade it to version 3 if needed. @@ -1299,7 +1310,7 @@ } /* Non-empty directory? */ - if ((na->data_size != sizeof(INDEX_ROOT) + sizeof(INDEX_ENTRY_HEADER))) { + if ((na->data_size != sizeof(INDEX_ROOT) + sizeof(INDEX_ENTRY_HEADER))){ /* Both ENOTEMPTY and EEXIST are ok. We use the more common. */ errno = EEXIST; ntfs_log_debug("Directory is not empty\n"); @@ -1416,7 +1427,7 @@ if (ntfs_names_are_equal(fn->file_name, fn->file_name_length, name, name_len, case_sensitive, - ni->vol->upcase, ni->vol->upcase_len)) { + ni->vol->upcase, ni->vol->upcase_len)){ if (fn->file_name_type == FILE_NAME_WIN32) { looking_for_dos_name = TRUE; @@ -1525,8 +1536,8 @@ ntfs_attr_put_search_ctx(actx); if (ictx) ntfs_index_ctx_put(ictx); - if (ni) - ntfs_inode_close(ni); + if (ni && ntfs_inode_close(ni) && !err) + err = errno; if (err) { errno = err; ntfs_log_debug("Could not delete file: %s\n", strerror(errno)); @@ -1567,6 +1578,12 @@ ntfs_log_perror("ntfs_link wrong arguments"); goto err_out; } + + if (ni->flags & FILE_ATTR_REPARSE_POINT) { + err = EOPNOTSUPP; + goto err_out; + } + /* Create FILE_NAME attribute. */ fn_len = sizeof(FILE_NAME_ATTR) + name_len * sizeof(ntfschar); fn = ntfs_calloc(fn_len); @@ -1628,7 +1645,6 @@ err_out: free(fn); errno = err; - ntfs_log_perror("Hard link failed"); return -1; } Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/dir.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/dir.h 2007-07-07 16:29:44 UTC (rev 21585) +++ haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/dir.h 2007-07-09 04:55:36 UTC (rev 21586) @@ -40,6 +40,7 @@ #define S_IFSOCK 0140000 #endif #endif + /* * We do not have these under DJGPP, so define our version that do not conflict * with other S_IFs defined under DJGPP. Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/index.c =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/index.c 2007-07-07 16:29:44 UTC (rev 21585) +++ haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/index.c 2007-07-09 04:55:36 UTC (rev 21586) @@ -1417,6 +1417,7 @@ fn = ntfs_ie_filename_get(ie); ntfs_log_trace("file: '%s'\n", fn); + ntfs_attr_name_free(&fn); while (1) { @@ -1461,7 +1462,6 @@ ret = STATUS_OK; err_out: - ntfs_attr_name_free(&fn); ntfs_log_trace("%s\n", ret ? "Failed" : "Done"); return ret; } Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/inode.c =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/inode.c 2007-07-07 16:29:44 UTC (rev 21585) +++ haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/inode.c 2007-07-09 04:55:36 UTC (rev 21586) @@ -107,15 +107,16 @@ * * Returns: */ -static int __ntfs_inode_release(ntfs_inode *ni) +static void __ntfs_inode_release(ntfs_inode *ni) { if (NInoDirty(ni)) - ntfs_log_debug("Eeek. Discarding dirty inode!\n"); + ntfs_log_error("Releasing dirty inode %lld!\n", + (long long)ni->mft_no); if (NInoAttrList(ni) && ni->attr_list) free(ni->attr_list); free(ni->mrec); free(ni); - return 0; + return; } /** @@ -271,7 +272,7 @@ if (!ni) return 0; - ntfs_log_trace("Entering for inode 0x%llx.\n", (long long) ni->mft_no); + ntfs_log_trace("Entering for inode 0x%llx.\n", (long long)ni->mft_no); /* If we have dirty metadata, write it out. */ if (NInoDirty(ni) || NInoAttrListDirty(ni)) { @@ -330,11 +331,18 @@ i = -1; break; } + + /* + * We could successfully sync, so only log this error + * and try to sync other inode extents too. + */ if (i != -1) - ntfs_log_debug("Extent inode was not attached to base inode! " - "Weird! Continuing regardless.\n"); + ntfs_log_error("Extent inode %lld was not found\n", + (long long)ni->mft_no); } - return __ntfs_inode_release(ni); + + __ntfs_inode_release(ni); + return 0; } /** @@ -425,9 +433,7 @@ base_ni->extent_nis[base_ni->nr_extents++] = ni; return ni; err_out: - i = errno; __ntfs_inode_release(ni); - errno = i; ntfs_log_perror("Failed to open extent inode"); return NULL; } @@ -536,12 +542,11 @@ FILE_NAME_ATTR *fn; int err = 0; - ntfs_log_trace("Entering for inode 0x%llx.\n", (long long) ni->mft_no); + ntfs_log_trace("Entering for inode %lld\n", (long long)ni->mft_no); ctx = ntfs_attr_get_search_ctx(ni, NULL); if (!ctx) { err = errno; - ntfs_log_trace("Failed to get attribute search context.\n"); goto err_out; } /* Walk through all FILE_NAME attributes and update them. */ @@ -550,27 +555,29 @@ le16_to_cpu(ctx->attr->value_offset)); if (MREF_LE(fn->parent_directory) == ni->mft_no) { /* - * WARNING: We cheater here and obtain 2 attribute + * WARNING: We cheat here and obtain 2 attribute * search contexts for one inode (first we obtained * above, second will be obtained inside * ntfs_index_lookup), it's acceptable for library, - * but will lock kernel. + * but will deadlock in the kernel. */ index_ni = ni; } else - index_ni = ntfs_inode_open(ni->vol, - le64_to_cpu(fn->parent_directory)); + index_ni = ntfs_inode_open(ni->vol, + le64_to_cpu(fn->parent_directory)); if (!index_ni) { if (!err) err = errno; - ntfs_log_trace("Failed to open inode with index.\n"); + ntfs_log_perror("Failed to open inode %lld with index", + le64_to_cpu(fn->parent_directory)); continue; } ictx = ntfs_index_ctx_get(index_ni, NTFS_INDEX_I30, 4); if (!ictx) { if (!err) err = errno; - ntfs_log_trace("Failed to get index context.\n"); + ntfs_log_perror("Failed to get index ctx, inode %lld", + (long long)index_ni->mft_no); ntfs_inode_close(index_ni); continue; } @@ -581,7 +588,8 @@ else err = errno; } - ntfs_log_trace("Index lookup failed.\n"); + ntfs_log_perror("Index lookup failed, inode %lld", + (long long)index_ni->mft_no); ntfs_index_ctx_put(ictx); ntfs_inode_close(index_ni); continue; @@ -599,13 +607,14 @@ fn->last_access_time = utc2ntfs(ni->last_access_time); ntfs_index_entry_mark_dirty(ictx); ntfs_index_ctx_put(ictx); - if (ni != index_ni) - ntfs_inode_close(index_ni); + if ((ni != index_ni) && ntfs_inode_close(index_ni) && !err) + err = errno; } /* Check for real error occurred. */ if (errno != ENOENT) { err = errno; - ntfs_log_trace("Attribute lookup failed.\n"); + ntfs_log_perror("Attribute lookup failed, inode %lld", + (long long)ni->mft_no); goto err_out; } ntfs_attr_put_search_ctx(ctx); @@ -646,10 +655,11 @@ if (!ni) { errno = EINVAL; + ntfs_log_error("Failed to sync NULL inode\n"); return -1; } - ntfs_log_trace("Entering for inode 0x%llx.\n", (long long) ni->mft_no); + ntfs_log_trace("Entering for inode %lld\n", (long long)ni->mft_no); /* Update STANDARD_INFORMATION. */ if ((ni->mrec->flags & MFT_RECORD_IN_USE) && ni->nr_extents != -1 && @@ -659,7 +669,8 @@ if (err != EIO) err = EBUSY; } - ntfs_log_trace("Failed to sync standard information.\n"); + ntfs_log_perror("Failed to sync standard info (inode %lld)", + (long long)ni->mft_no); } /* Update FILE_NAME's in the index. */ @@ -671,7 +682,8 @@ if (err != EIO) err = EBUSY; } - ntfs_log_trace("Failed to sync FILE_NAME attributes.\n"); + ntfs_log_perror("Failed to sync FILE_NAME (inode %lld)", + (long long)ni->mft_no); NInoFileNameSetDirty(ni); } @@ -686,33 +698,37 @@ err = errno; if (err != EIO) err = EBUSY; - ntfs_log_trace("Attribute list sync failed (open " - "failed).\n"); + ntfs_log_perror("Attribute list sync failed " + "(open, inode %lld)", + (long long)ni->mft_no); } NInoAttrListSetDirty(ni); - } else { - if (na->data_size == ni->attr_list_size) { - if (ntfs_attr_pwrite(na, 0, ni->attr_list_size, - ni->attr_list) != - ni->attr_list_size) { - if (!err || errno == EIO) { - err = errno; - if (err != EIO) - err = EBUSY; - ntfs_log_trace("Attribute list sync " - "failed (write failed).\n"); - } - NInoAttrListSetDirty(ni); + goto sync_inode; + } + + if (na->data_size == ni->attr_list_size) { + if (ntfs_attr_pwrite(na, 0, ni->attr_list_size, + ni->attr_list) != ni->attr_list_size) { + if (!err || errno == EIO) { + err = errno; + if (err != EIO) + err = EBUSY; + ntfs_log_perror("Attribute list sync " + "failed (write, inode %lld)", + (long long)ni->mft_no); } - } else { - err = EIO; - ntfs_log_trace("Attribute list sync failed (invalid size).\n"); NInoAttrListSetDirty(ni); } - ntfs_attr_close(na); + } else { + err = EIO; + ntfs_log_error("Attribute list sync failed (bad size, " + "inode %lld)\n", (long long)ni->mft_no); + NInoAttrListSetDirty(ni); } + ntfs_attr_close(na); } - + +sync_inode: /* Write this inode out to the $MFT (and $MFTMirr if applicable). */ if (NInoTestAndClearDirty(ni)) { if (ntfs_mft_record_write(ni->vol, ni->mft_no, ni->mrec)) { @@ -722,7 +738,8 @@ err = EBUSY; } NInoSetDirty(ni); - ntfs_log_trace("Base MFT record sync failed.\n"); + ntfs_log_perror("MFT record sync failed, inode %lld", + (long long)ni->mft_no); } } @@ -734,18 +751,21 @@ ntfs_inode *eni; eni = ni->extent_nis[i]; - if (NInoTestAndClearDirty(eni)) { - if (ntfs_mft_record_write(eni->vol, eni->mft_no, - eni->mrec)) { - if (!err || errno == EIO) { - err = errno; - if (err != EIO) - err = EBUSY; - } - NInoSetDirty(eni); - ntfs_log_trace("Extent MFT record sync " - "failed.\n"); + if (!NInoTestAndClearDirty(eni)) + continue; + + if (ntfs_mft_record_write(eni->vol, eni->mft_no, + eni->mrec)) { + if (!err || errno == EIO) { + err = errno; + if (err != EIO) + err = EBUSY; } + NInoSetDirty(eni); + ntfs_log_perror("Extent MFT record sync failed," + " inode %lld/%lld", + (long long)ni->mft_no, + (long long)eni->mft_no); } } } Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/lcnalloc.c =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/lcnalloc.c 2007-07-07 16:29:44 UTC (rev 21585) +++ haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/lcnalloc.c 2007-07-09 04:55:36 UTC (rev 21586) @@ -2,8 +2,8 @@ * lcnalloc.c - Cluster (de)allocation code. Originated from the Linux-NTFS project. * * Copyright (c) 2002-2004 Anton Altaparmakov - * Copyright (c) 2004-2007 Szabolcs Szakacsits * Copyright (c) 2004 Yura Pakhuchiy + * Copyright (c) 2004-2007 Szabolcs Szakacsits * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -45,56 +45,91 @@ #include "logging.h" #include "misc.h" -#define NTFS_LCNALLOC_BSIZE 512 +/* + * Plenty possibilities for big optimizations all over in the cluster + * allocation, however at the moment the dominant bottleneck (~ 90%) is + * the update of the mapping pairs which converges to the cubic Faulhaber's + * formula as the function of the number of extents (fragments, runs). + */ +#define NTFS_LCNALLOC_BSIZE 1024 +#define NTFS_LCNALLOC_SKIP NTFS_LCNALLOC_BSIZE -#define NTFS_LCNALLOC_SKIP 4096 - -static void ntfs_cluster_set_zone_pos(LCN zone_start, LCN zone_end, - LCN *zone_pos, LCN tc, LCN bmp_initial_pos) +static void ntfs_cluster_set_zone_pos(LCN start, LCN end, LCN *pos, LCN tc) { - ntfs_log_trace("Before: zone_pos: %lld\n", (long long)*zone_pos); + ntfs_log_trace("pos: %lld tc: %lld\n", (long long)*pos, tc); - if (tc >= zone_end) { - *zone_pos = zone_start; - // FIXME: seems to be bogus and only MFT zone used it - if (!zone_end) - *zone_pos = 0; - } else if ((bmp_initial_pos >= *zone_pos || tc > *zone_pos) && - tc >= zone_start) - *zone_pos = tc; - - ntfs_log_trace("After: zone_pos: %lld\n", (long long)*zone_pos); + if (tc >= end) + *pos = start; + else if (tc >= start) + *pos = tc; } -static int ntfs_cluster_update_zone_pos(ntfs_volume *vol, u8 zone, LCN tc, - LCN bmp_initial_pos) +static void ntfs_cluster_update_zone_pos(ntfs_volume *vol, u8 zone, LCN tc) { ntfs_log_trace("tc = %lld, zone = %d\n", (long long)tc, zone); - switch (zone) { - case 1: - ntfs_cluster_set_zone_pos(vol->mft_lcn, - vol->mft_zone_end, - &vol->mft_zone_pos, - tc, bmp_initial_pos); - break; - case 2: - ntfs_cluster_set_zone_pos(vol->mft_zone_end, - vol->nr_clusters, - &vol->data1_zone_pos, - tc, bmp_initial_pos); - break; - case 4: - ntfs_cluster_set_zone_pos(0, - vol->mft_zone_start, - &vol->data2_zone_pos, - tc, bmp_initial_pos); - break; - default: - ntfs_log_error("Invalid zone: %d\n", zone); - return -1; + if (zone == 1) + ntfs_cluster_set_zone_pos(vol->mft_lcn, vol->mft_zone_end, + &vol->mft_zone_pos, tc); + else if (zone == 2) + ntfs_cluster_set_zone_pos(vol->mft_zone_end, vol->nr_clusters, + &vol->data1_zone_pos, tc); + else /* zone == 4 */ + ntfs_cluster_set_zone_pos(0, vol->mft_zone_start, + &vol->data2_zone_pos, tc); +} + +static s64 max_empty_bit_range(unsigned char *buf, int size) +{ + int i, j, run = 0; + int max_range = 0; + s64 start_pos = -1; + + ntfs_log_trace("Entering"); + + for (i = 0; i < size; i++, buf++) { + + for (j = 0; j < 8; j++) { + + int bit = *buf & (1 << j); + + if (bit) { + if (run > max_range) { + max_range = run; + start_pos = i * 8 + j - run; + } + run = 0; + } else + run++; + } } + if (run > max_range) + start_pos = i * 8 - run; + + return start_pos; +} + +static int bitmap_writeback(ntfs_volume *vol, s64 pos, s64 size, void *b, + u8 *writeback) +{ + s64 written; + + ntfs_log_trace("Entering"); + + if (!*writeback) + return 0; + + *writeback = 0; + + written = ntfs_attr_pwrite(vol->lcnbmp_na, pos, size, b); + if (written != size) { + if (!written) + errno = EIO; + ntfs_log_perror("Bitmap write error (%lld, %lld)", pos, size); + return -1; + } + return 0; } @@ -126,45 +161,33 @@ * expanded to cover the start of the volume in order to reserve space for the * mft bitmap attribute. * - * This is not the prettiest function but the complexity stems from the need of - * implementing the mft vs data zoned approach and from the fact that we have - * access to the lcn bitmap via up to NTFS_LCNALLOC_BSIZE bytes at a time, so we - * need to cope with crossing over boundaries of two buffers. Further, the fact - * that the allocator allows for caller supplied hints as to the location of - * where allocation should begin and the fact that the allocator keeps track of - * where in the data zones the next natural allocation should occur, contribute - * to the complexity of the function. But it should all be worthwhile, because - * this allocator should: 1) be a full implementation of the MFT zone approach - * used by Windows, 2) cause reduction in fragmentation as much as possible, - * and 3) be speedy in allocations (the code is not optimized for speed, but - * the algorithm is, so further speed improvements are probably possible). - * - * FIXME: We should be monitoring cluster allocation and increment the MFT zone - * size dynamically but this is something for the future. We will just cause - * heavier fragmentation by not doing it and I am not even sure Windows would - * grow the MFT zone dynamically, so it might even be correct not to do this. - * The overhead in doing dynamic MFT zone expansion would be very large and - * unlikely worth the effort. (AIA) - * - * TODO: I have added in double the required zone position pointer wrap around - * logic which can be optimized to having only one of the two logic sets. - * However, having the double logic will work fine, but if we have only one of - * the sets and we get it wrong somewhere, then we get into trouble, so - * removing the duplicate logic requires _very_ careful consideration of _all_ - * possible code paths. So at least for now, I am leaving the double logic - - * better safe than sorry... (AIA) + * The complexity stems from the need of implementing the mft vs data zoned + * approach and from the fact that we have access to the lcn bitmap via up to + * NTFS_LCNALLOC_BSIZE bytes at a time, so we need to cope with crossing over + * boundaries of two buffers. Further, the fact that the allocator allows for + * caller supplied hints as to the location of where allocation should begin + * and the fact that the allocator keeps track of where in the data zones the + * next natural allocation should occur, contribute to the complexity of the + * function. But it should all be worthwhile, because this allocator: + * 1) implements MFT zone reservation + * 2) causes reduction in fragmentation. + * The code is not optimized for speed. */ runlist *ntfs_cluster_alloc(ntfs_volume *vol, VCN start_vcn, s64 count, LCN start_lcn, const NTFS_CLUSTER_ALLOCATION_ZONES zone) { - LCN zone_start, zone_end, bmp_pos, bmp_initial_pos, last_read_pos, lcn; - LCN prev_lcn = 0, prev_run_len = 0, mft_zone_size; + LCN zone_start, zone_end; /* current search range */ + LCN last_read_pos, lcn; + LCN bmp_pos; /* current bit position inside the bitmap */ + LCN prev_lcn = 0, prev_run_len = 0; s64 clusters, br; runlist *rl = NULL, *trl; - u8 *buf, *byte; + u8 *buf, *byte, bit, writeback; + u8 pass = 1; /* 1: inside zone; 2: start of zone */ + u8 search_zone; /* 4: data2 (start) 1: mft (middle) 2: data1 (end) */ + u8 done_zones = 0; + u8 has_guess, used_zone_pos; int err = 0, rlpos, rlsize, buf_size; - u8 pass, done_zones, search_zone, need_writeback, bit; - u8 first_try = 1; ntfs_log_trace("Entering with count = 0x%llx, start_lcn = 0x%llx, " "zone = %s_ZONE.\n", (long long)count, (long long) @@ -181,490 +204,280 @@ /* Return empty runlist if @count == 0 */ if (!count) { rl = ntfs_malloc(0x1000); - if (!rl) - return NULL; - rl[0].vcn = start_vcn; - rl[0].lcn = LCN_RL_NOT_MAPPED; - rl[0].length = 0; + if (rl) { + rl[0].vcn = start_vcn; + rl[0].lcn = LCN_RL_NOT_MAPPED; + rl[0].length = 0; + } return rl; } - /* Allocate memory. */ buf = ntfs_malloc(NTFS_LCNALLOC_BSIZE); if (!buf) return NULL; /* - * If no specific @start_lcn was requested, use the current data zone - * position, otherwise use the requested @start_lcn but make sure it - * lies outside the mft zone. Also set done_zones to 0 (no zones done) - * and pass depending on whether we are starting inside a zone (1) or - * at the beginning of a zone (2). If requesting from the MFT_ZONE, - * we either start at the current position within the mft zone or at - * the specified position. If the latter is out of bounds then we start - * at the beginning of the MFT_ZONE. + * If no @start_lcn was requested, use the current zone + * position otherwise use the requested @start_lcn. */ - done_zones = 0; - pass = 1; - /* - * zone_start and zone_end are the current search range. search_zone - * is 1 for mft zone, 2 for data zone 1 (end of mft zone till end of - * volume) and 4 for data zone 2 (start of volume till start of mft - * zone). - */ + has_guess = 1; zone_start = start_lcn; + if (zone_start < 0) { if (zone == DATA_ZONE) zone_start = vol->data1_zone_pos; else zone_start = vol->mft_zone_pos; - if (!zone_start) { - /* - * Zone starts at beginning of volume which means a - * single pass is sufficient. - */ - pass = 2; - } - } else if (zone == DATA_ZONE && zone_start >= vol->mft_zone_start && - zone_start < vol->mft_zone_end) { - zone_start = vol->mft_zone_end; - /* - * Starting at beginning of data1_zone which means a single - * pass in this zone is sufficient. - */ - pass = 2; - } else if (zone == MFT_ZONE && (zone_start < vol->mft_zone_start || - zone_start >= vol->mft_zone_end)) { - zone_start = vol->mft_lcn; - if (!vol->mft_zone_end) - zone_start = 0; - /* - * Starting at beginning of volume which means a single pass - * is sufficient. - */ - pass = 2; + has_guess = 0; } - if (zone == MFT_ZONE) { + + used_zone_pos = has_guess ? 0 : 1; + + if (!zone_start || zone_start == vol->mft_zone_start || + zone_start == vol->mft_zone_end) + pass = 2; + + if (zone_start < vol->mft_zone_start) { + zone_end = vol->mft_zone_start; + search_zone = 4; + } else if (zone_start < vol->mft_zone_end) { zone_end = vol->mft_zone_end; search_zone = 1; - } else /* if (zone == DATA_ZONE) */ { - /* Skip searching the mft zone. */ - done_zones |= 1; - if (zone_start >= vol->mft_zone_end) { - zone_end = vol->nr_clusters; - search_zone = 2; - } else { - zone_end = vol->mft_zone_start; - search_zone = 4; - } + } else { + zone_end = vol->nr_clusters; + search_zone = 2; } - /* - * bmp_pos is the current bit position inside the bitmap. We use - * bmp_initial_pos to determine whether or not to do a zone switch. - */ - bmp_pos = bmp_initial_pos = zone_start; + + bmp_pos = zone_start; - /* Loop until all clusters are allocated, i.e. clusters == 0. */ + /* Loop until all clusters are allocated. */ clusters = count; rlpos = rlsize = 0; while (1) { - ntfs_log_trace("Start of outer while loop: done_zones = 0x%x, " - "search_zone = %i, pass = %i, zone_start = " - "0x%llx, zone_end = 0x%llx, bmp_initial_pos = " - "0x%llx, bmp_pos = 0x%llx, rlpos = %i, rlsize = " - "%i.\n", done_zones, search_zone, pass, - (long long)zone_start, (long long)zone_end, - (long long)bmp_initial_pos, (long long)bmp_pos, - rlpos, rlsize); - /* Loop until we run out of free clusters. */ last_read_pos = bmp_pos >> 3; - ntfs_log_trace("last_read_pos = 0x%llx.\n", (long long)last_read_pos); - br = ntfs_attr_pread(vol->lcnbmp_na, last_read_pos, NTFS_LCNALLOC_BSIZE, buf); + br = ntfs_attr_pread(vol->lcnbmp_na, last_read_pos, + NTFS_LCNALLOC_BSIZE, buf); if (br <= 0) { - if (!br) { - /* Reached end of attribute. */ - ntfs_log_trace("End of attribute reached. Skipping " - "to zone_pass_done.\n"); + if (!br) goto zone_pass_done; - } err = errno; - ntfs_log_perror("ntfs_attr_pread() failed"); + ntfs_log_perror("Reading $BITMAP failed"); goto err_ret; } /* - * We might have read less than NTFS_LCNALLOC_BSIZE bytes if we are close to - * the end of the attribute. + * We might have read less than NTFS_LCNALLOC_BSIZE bytes + * if we are close to the end of the attribute. */ buf_size = (int)br << 3; lcn = bmp_pos & 7; bmp_pos &= ~7; - need_writeback = 0; - ntfs_log_trace("Before inner while loop: buf_size = %i, lcn = " - "0x%llx, bmp_pos = 0x%llx, need_writeback = %i.\n", - buf_size, (long long)lcn, (long long)bmp_pos, - need_writeback); - while (lcn < buf_size && lcn + bmp_pos < zone_end) { + writeback = 0; + + while (1) { byte = buf + (lcn >> 3); - ntfs_log_trace("In inner while loop: buf_size = %i, lcn = " - "0x%llx, bmp_pos = 0x%llx, " - "need_writeback = %i, byte ofs = 0x%x, " - "*byte = 0x%x.\n", buf_size, - (long long)lcn, (long long)bmp_pos, - need_writeback, (unsigned int)(lcn >> 3), - (unsigned int)*byte); - /* Skip full bytes. */ - if (*byte == 0xff) { - lcn = (lcn + 8) & ~7; - ntfs_log_trace("continuing while loop 1.\n"); - if (first_try) { - first_try = 0; - lcn += NTFS_LCNALLOC_SKIP; - } - continue; - } bit = 1 << (lcn & 7); - ntfs_log_trace("bit = %i.\n", bit); - /* If the bit is already set, go onto the next one. */ - if (*byte & bit) { - lcn++; - ntfs_log_trace("continuing while loop 2.\n"); - if (first_try) { - first_try = 0; - lcn += NTFS_LCNALLOC_SKIP; + if (has_guess) { + if (*byte & bit) { + has_guess = 0; + break; } + } else { + lcn = max_empty_bit_range(buf, br); + if (lcn < 0) + break; + has_guess = 1; continue; } + + /* First free bit is at lcn + bmp_pos. */ + /* Reallocate memory if necessary. */ if ((rlpos + 2) * (int)sizeof(runlist) >= rlsize) { - ntfs_log_trace("Reallocating space.\n"); - if (!rl) - ntfs_log_trace("First free bit is at LCN = " - "0x%llx.\n", (long long)(lcn + bmp_pos)); rlsize += 4096; - trl = (runlist*)realloc(rl, rlsize); + trl = realloc(rl, rlsize); if (!trl) { err = ENOMEM; - ntfs_log_perror("Failed to allocate memory"); + ntfs_log_perror("realloc() failed"); goto wb_err_ret; } rl = trl; - ntfs_log_trace("Reallocated memory, rlsize = " - "0x%x.\n", rlsize); } + /* Allocate the bitmap bit. */ *byte |= bit; - /* We need to write this bitmap buffer back to disk! */ - need_writeback = 1; - ntfs_log_trace("*byte = 0x%x, need_writeback is set.\n", - (unsigned int)*byte); + writeback = 1; + /* * Coalesce with previous run if adjacent LCNs. * Otherwise, append a new run. */ - ntfs_log_trace("Adding run (lcn 0x%llx, len 0x%llx), " - "prev_lcn = 0x%llx, lcn = 0x%llx, " - "bmp_pos = 0x%llx, prev_run_len = " - "0x%llx, rlpos = %i.\n", - (long long)(lcn + bmp_pos), 1LL, - (long long)prev_lcn, (long long)lcn, - (long long)bmp_pos, - (long long)prev_run_len, rlpos); - if (prev_lcn == lcn + bmp_pos - prev_run_len && rlpos) { - ntfs_log_trace("Coalescing to run (lcn 0x%llx, len " - "0x%llx).\n", - (long long)rl[rlpos - 1].lcn, - (long long) rl[rlpos - 1].length); + if (prev_lcn == lcn + bmp_pos - prev_run_len && rlpos) rl[rlpos - 1].length = ++prev_run_len; - ntfs_log_trace("Run now (lcn 0x%llx, len 0x%llx), " - "prev_run_len = 0x%llx.\n", - (long long)rl[rlpos - 1].lcn, - (long long)rl[rlpos - 1].length, - (long long)prev_run_len); - } else { - if (rlpos) { - ntfs_log_trace("Adding new run, (previous " - "run lcn 0x%llx, len 0x%llx).\n", - (long long) rl[rlpos - 1].lcn, - (long long) rl[rlpos - 1].length); + else { + if (rlpos) rl[rlpos].vcn = rl[rlpos - 1].vcn + prev_run_len; - } else { - ntfs_log_trace("Adding new run, is first run.\n"); + else rl[rlpos].vcn = start_vcn; - } + rl[rlpos].lcn = prev_lcn = lcn + bmp_pos; rl[rlpos].length = prev_run_len = 1; rlpos++; } + /* Done? */ if (!--clusters) { - if (ntfs_cluster_update_zone_pos(vol, - search_zone, lcn + bmp_pos + 1 - + NTFS_LCNALLOC_SKIP, - bmp_initial_pos)) { - free(rl); - free(buf); - return NULL; - } + if (used_zone_pos) [... truncated: 1381 lines follow ...] From axeld at pinc-software.de Mon Jul 9 10:58:04 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Mon, 09 Jul 2007 10:58:04 +0200 CEST Subject: [Haiku-commits] r21579 - haiku/trunk/src/kits/storage In-Reply-To: <200707070036.l670aD7O029527@sheep.berlios.de> Message-ID: <589321372-BeMail@zon> marcusoverhagen at BerliOS wrote: > +#if __GNUC__ > 3 > + bool operator<(const node_ref& a, const node_ref& b); > + class node_ref_less : public binary_function bool> > + { > + public: > + bool operator() (const node_ref& a, const node_ref& b) const > + { > + return a < b; > + } > + }; > + typedef set FileSet; > +#else Thanks! Where are we exporting the < operator method BTW? Bye, Axel. From stippi at mail.berlios.de Mon Jul 9 11:09:33 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 9 Jul 2007 11:09:33 +0200 Subject: [Haiku-commits] r21587 - haiku/trunk/src/preferences Message-ID: <200707090909.l6999XKI008150@sheep.berlios.de> Author: stippi Date: 2007-07-09 11:09:33 +0200 (Mon, 09 Jul 2007) New Revision: 21587 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21587&view=rev Added: haiku/trunk/src/preferences/network_old/ Removed: haiku/trunk/src/preferences/network/ Modified: haiku/trunk/src/preferences/Jamfile Log: * moved network to network_old to make room for new preflet by Andre Garzia Modified: haiku/trunk/src/preferences/Jamfile =================================================================== --- haiku/trunk/src/preferences/Jamfile 2007-07-09 04:55:36 UTC (rev 21586) +++ haiku/trunk/src/preferences/Jamfile 2007-07-09 09:09:33 UTC (rev 21587) @@ -15,7 +15,7 @@ SubInclude HAIKU_TOP src preferences media ; SubInclude HAIKU_TOP src preferences menu ; SubInclude HAIKU_TOP src preferences mouse ; -SubInclude HAIKU_TOP src preferences network ; +#SubInclude HAIKU_TOP src preferences network ; SubInclude HAIKU_TOP src preferences print ; SubInclude HAIKU_TOP src preferences screen ; SubInclude HAIKU_TOP src preferences screensaver ; Copied: haiku/trunk/src/preferences/network_old (from rev 21572, haiku/trunk/src/preferences/network) From stippi at mail.berlios.de Mon Jul 9 11:14:25 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 9 Jul 2007 11:14:25 +0200 Subject: [Haiku-commits] r21588 - in haiku/trunk/src/preferences: . network Message-ID: <200707090914.l699EPKq008333@sheep.berlios.de> Author: stippi Date: 2007-07-09 11:14:25 +0200 (Mon, 09 Jul 2007) New Revision: 21588 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21588&view=rev Added: haiku/trunk/src/preferences/network/ haiku/trunk/src/preferences/network/EthernetSettings.cpp haiku/trunk/src/preferences/network/EthernetSettings.h haiku/trunk/src/preferences/network/EthernetSettingsView.cpp haiku/trunk/src/preferences/network/EthernetSettingsView.h haiku/trunk/src/preferences/network/EthernetSettingsWindow.cpp haiku/trunk/src/preferences/network/EthernetSettingsWindow.h haiku/trunk/src/preferences/network/Jamfile Modified: haiku/trunk/src/preferences/Jamfile Log: * work in progress new Network preflet by Andre Garzia (GSoC student) - can currently display the configuration of a chosen ethernet device Modified: haiku/trunk/src/preferences/Jamfile =================================================================== --- haiku/trunk/src/preferences/Jamfile 2007-07-09 09:09:33 UTC (rev 21587) +++ haiku/trunk/src/preferences/Jamfile 2007-07-09 09:14:25 UTC (rev 21588) @@ -15,7 +15,7 @@ SubInclude HAIKU_TOP src preferences media ; SubInclude HAIKU_TOP src preferences menu ; SubInclude HAIKU_TOP src preferences mouse ; -#SubInclude HAIKU_TOP src preferences network ; +SubInclude HAIKU_TOP src preferences network ; SubInclude HAIKU_TOP src preferences print ; SubInclude HAIKU_TOP src preferences screen ; SubInclude HAIKU_TOP src preferences screensaver ; Added: haiku/trunk/src/preferences/network/EthernetSettings.cpp =================================================================== --- haiku/trunk/src/preferences/network/EthernetSettings.cpp 2007-07-09 09:09:33 UTC (rev 21587) +++ haiku/trunk/src/preferences/network/EthernetSettings.cpp 2007-07-09 09:14:25 UTC (rev 21588) @@ -0,0 +1,36 @@ +/* + * Copyright 2004-2007 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Author: + * Andre Alves Garzia, andre at andregarzia.com + * With code from: + * Axel Dorfler + * Hugo Santos + */ + +#include "EthernetSettings.h" +#include "EthernetSettingsWindow.h" + +EthernetSettings::EthernetSettings() + : BApplication("application/x-vnd.Haiku-EthernetSettings") +{ +} + +EthernetSettings::~EthernetSettings() +{ +} + +void EthernetSettings::ReadyToRun() +{ + fEthWindow = new EthernetSettingsWindow(); + fEthWindow->Show(); +} + +int main(int argc, char** argv) +{ + EthernetSettings app; + app.Run(); + + return 0; +} Added: haiku/trunk/src/preferences/network/EthernetSettings.h =================================================================== --- haiku/trunk/src/preferences/network/EthernetSettings.h 2007-07-09 09:09:33 UTC (rev 21587) +++ haiku/trunk/src/preferences/network/EthernetSettings.h 2007-07-09 09:14:25 UTC (rev 21588) @@ -0,0 +1,32 @@ +/* + * Copyright 2004-2007 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Author: + * Andre Alves Garzia, andre at andregarzia.com + * With code from: + * Axel Dorfler + * Hugo Santos + */ + +#ifndef ETHERNET_SETTINGS_H +#define ETHERNET_SETTINGS_H + +#include +#include +#include + +#include "EthernetSettingsWindow.h" + +class EthernetSettings : public BApplication { + public: + EthernetSettings(); + virtual ~EthernetSettings(); + + virtual void ReadyToRun(); + private: + EthernetSettingsWindow *fEthWindow; +}; + + +#endif /* ETHERNET_SETTINGS_H */ Added: haiku/trunk/src/preferences/network/EthernetSettingsView.cpp =================================================================== --- haiku/trunk/src/preferences/network/EthernetSettingsView.cpp 2007-07-09 09:09:33 UTC (rev 21587) +++ haiku/trunk/src/preferences/network/EthernetSettingsView.cpp 2007-07-09 09:14:25 UTC (rev 21588) @@ -0,0 +1,339 @@ +/* + * Copyright 2004-2007 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Author: + * Andre Alves Garzia, andre at andregarzia.com + * With code from: + * Axel Dorfler + * Hugo Santos + */ + +#include "EthernetSettingsView.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + + + +bool EthernetSettingsView::_PrepareRequest(struct ifreq& request, const char* name) +{ + //This function is used for talking direct to the stack. + //It?s used by _ShowConfiguration. + + if (strlen(name) > IF_NAMESIZE) + return false; + + strcpy(request.ifr_name, name); + return true; +} + +void EthernetSettingsView::_GatherInterfaces() { + // iterate over all interfaces and retrieve minimal status + + ifconf config; + config.ifc_len = sizeof(config.ifc_value); + if (ioctl(fSocket, SIOCGIFCOUNT, &config, sizeof(struct ifconf)) < 0) + return; + + uint32 count = (uint32)config.ifc_value; + if (count == 0) + return; + + void *buffer = malloc(count * sizeof(struct ifreq)); + if (buffer == NULL) + return; + + config.ifc_len = count * sizeof(struct ifreq); + config.ifc_buf = buffer; + if (ioctl(fSocket, SIOCGIFCONF, &config, sizeof(struct ifconf)) < 0) + return; + + ifreq *interface = (ifreq *)buffer; + + fInterfaces.MakeEmpty(); + + for (uint32 i = 0; i < count; i++) { + if (strncmp(interface->ifr_name, "loop", 4) && interface->ifr_name[0]) { + fInterfaces.AddItem(new BString(interface->ifr_name)); + + } + + interface = (ifreq *)((addr_t)interface + IF_NAMESIZE + + interface->ifr_addr.sa_len); + } + + free(buffer); + +} + + +void EthernetSettingsView::AttachedToWindow() +{ + fOKButton->SetTarget(this); + fApplyButton->SetTarget(this); +} + + +void EthernetSettingsView::DetachedFromWindow() +{ + close(fSocket); +} + + +EthernetSettingsView::EthernetSettingsView(BRect rect) : BView(rect, "EthernetSettingsView", B_FOLLOW_ALL, B_WILL_DRAW) +{ + float defaultWidth = 190; + float inset = ceilf(be_plain_font->Size() * 0.8); + BRect frame(inset,inset, defaultWidth, 50); + + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + + fSocket = socket(AF_INET, SOCK_DGRAM, 0); + _GatherInterfaces(); + + BPopUpMenu* devmenu = new BPopUpMenu("devices"); + + for (int32 i = 0; i < fInterfaces.CountItems(); i++) { + BString& name = *fInterfaces.ItemAt(i); + BString label = name; + BMessage* info = new BMessage(kMsgInfo); + info->AddString("interface", name.String()); + BMenuItem* item = new BMenuItem(label.String(), info); + devmenu->AddItem(item); + item->SetTarget(this); + + } + + + + BPopUpMenu* modemenu = new BPopUpMenu("modes"); + BMenuItem* modeitem = new BMenuItem("dummy", NULL); + modemenu->AddItem(modeitem); + + fDeviceMenuField = new BMenuField(frame, "networkcards", "Adapter:", devmenu); + fDeviceMenuField->SetDivider(fDeviceMenuField->StringWidth(fDeviceMenuField->Label()) + 8); + AddChild(fDeviceMenuField); + fDeviceMenuField->ResizeToPreferred(); + + + fTypeMenuField = new BMenuField(frame, "type", "Mode:", modemenu); + fTypeMenuField->SetDivider(fTypeMenuField->StringWidth(fTypeMenuField->Label()) + 8); + fTypeMenuField->MoveTo(fDeviceMenuField->Frame().LeftBottom() + BPoint(0,10)); + AddChild(fTypeMenuField); + fTypeMenuField->ResizeToPreferred(); + + fIPTextControl = new BTextControl(frame, "ip", "IP Address:", "", NULL, B_FOLLOW_TOP, B_WILL_DRAW ); + fIPTextControl->SetDivider(fIPTextControl->StringWidth(fIPTextControl->Label()) + 8); + fIPTextControl->MoveTo(fTypeMenuField->Frame().LeftBottom() + BPoint(0,10)); + fIPTextControl->ResizeToPreferred(); + AddChild(fIPTextControl); + + fNetMaskTextControl = new BTextControl(frame, "mask", "Netmask:", "", NULL, B_FOLLOW_TOP, B_WILL_DRAW ); + fNetMaskTextControl->SetDivider(fNetMaskTextControl->StringWidth(fNetMaskTextControl->Label()) + 8); + fNetMaskTextControl->MoveTo(fIPTextControl->Frame().LeftBottom() + BPoint(0,10)); + AddChild(fNetMaskTextControl); + fNetMaskTextControl->ResizeToPreferred(); + + fGatewayTextControl = new BTextControl(frame, "gateway", "Gateway:", "", NULL, B_FOLLOW_TOP, B_WILL_DRAW ); + fGatewayTextControl->SetDivider(fGatewayTextControl->StringWidth(fGatewayTextControl->Label()) + 8); + fGatewayTextControl->MoveTo(fNetMaskTextControl->Frame().LeftBottom() + BPoint(0,10)); + AddChild(fGatewayTextControl); + fGatewayTextControl->ResizeToPreferred(); + + fPrimaryDNSTextControl = new BTextControl(frame, "dns1", "DNS #1:", "", NULL, B_FOLLOW_TOP, B_WILL_DRAW ); + fPrimaryDNSTextControl->SetDivider(fPrimaryDNSTextControl->StringWidth(fPrimaryDNSTextControl->Label()) + 8); + fPrimaryDNSTextControl->MoveTo(fGatewayTextControl->Frame().LeftBottom() + BPoint(0,10)); + AddChild(fPrimaryDNSTextControl); + fPrimaryDNSTextControl->ResizeToPreferred(); + + fSecondaryDNSTextControl = new BTextControl(frame, "dns2", "DNS #2:", "", NULL, B_FOLLOW_TOP, B_WILL_DRAW ); + fSecondaryDNSTextControl->SetDivider(fSecondaryDNSTextControl->StringWidth(fSecondaryDNSTextControl->Label()) + 8); + fSecondaryDNSTextControl->MoveTo(fPrimaryDNSTextControl->Frame().LeftBottom() + BPoint(0,10)); + AddChild(fSecondaryDNSTextControl); + fSecondaryDNSTextControl->ResizeToPreferred(); + + fApplyButton = new BButton(frame, "apply", "Apply", new BMessage(kMsgApply)); + fApplyButton->ResizeToPreferred(); + fApplyButton->MoveTo(fSecondaryDNSTextControl->Frame().LeftBottom() + BPoint(0,10)); + AddChild(fApplyButton); + + fOKButton = new BButton(frame, "ok", "OK", new BMessage(kMsgOK)); + fOKButton->ResizeToPreferred(); + fOKButton->MoveTo(fApplyButton->Frame().RightTop() + BPoint(10,0)); + AddChild(fOKButton); + +} + +EthernetSettingsView::~EthernetSettingsView() +{ +} + +void EthernetSettingsView::_ShowConfiguration(BMessage* message) +{ + + const char *name; + if (message->FindString("interface", &name) != B_OK) + return; + + ifreq request; + if (!_PrepareRequest(request, name)) + return; + + BString text = "dummy"; + char address[32]; + sockaddr_in* inetAddress = NULL; + + // Obtain IP. + if (ioctl(fSocket, SIOCGIFADDR, &request, + sizeof(request)) < 0) { + return; + } + + inetAddress = (sockaddr_in*)&request.ifr_addr; + if (inet_ntop(AF_INET, &inetAddress->sin_addr, address, + sizeof(address)) == NULL) { + return; + } + + fIPTextControl->SetText(address); + + // Obtain netmask. + if (ioctl(fSocket, SIOCGIFNETMASK, &request, + sizeof(request)) < 0) { + return; + } + + inetAddress = (sockaddr_in*)&request.ifr_mask; + if (inet_ntop(AF_INET, &inetAddress->sin_addr, address, + sizeof(address)) == NULL) { + return; + } + + fNetMaskTextControl->SetText(address); + + // Obtain gateway + + char *gwAddress; + ifconf config; + config.ifc_len = sizeof(config.ifc_value); + if (ioctl(fSocket, SIOCGRTSIZE, &config, sizeof(struct ifconf)) < 0) + return; + + uint32 size = (uint32)config.ifc_value; + if (size == 0) + return; + + void *buffer = malloc(size); + if (buffer == NULL) + return; + + config.ifc_len = size; + config.ifc_buf = buffer; + + if (ioctl(fSocket, SIOCGRTTABLE, &config, sizeof(struct ifconf)) < 0) + return; + + ifreq *interface = (ifreq *)buffer; + ifreq *end = (ifreq *)((uint8 *)buffer + size); + + + while (interface < end) { + route_entry& route = interface->ifr_route; + + + if (route.flags & RTF_GATEWAY) { + inetAddress = (sockaddr_in *)route.gateway; + + + gwAddress = inet_ntoa(inetAddress->sin_addr); + fGatewayTextControl->SetText(gwAddress); + } + + int32 addressSize = 0; + if (route.destination != NULL) + addressSize += route.destination->sa_len; + if (route.mask != NULL) + addressSize += route.mask->sa_len; + if (route.gateway != NULL) + addressSize += route.gateway->sa_len; + + interface = (ifreq *)((addr_t)interface + IF_NAMESIZE + sizeof(route_entry) + addressSize); + + } + + free(buffer); + + // Obtain DNS + + //resolv.conf is always actual. + BFile file; + BString* line; + int i = 0; + char* ch = "0"; + + if (file.SetTo("/etc/resolv.conf", B_READ_ONLY) != B_OK) + return; + + off_t length; + + file.GetSize(&length); + + /* + The idea here is to iterate over resolv.conf + and look for the nameservers. + + Both netserver and DHCPClient will write to resolv.conf + so we can trust that the information on the file is actual. + + I need help with this routine :$ + */ + + + +} + +void EthernetSettingsView::MessageReceived(BMessage* message) +{ + switch (message->what) { + case kMsgInfo: + _ShowConfiguration(message); + break; + default: + BView::MessageReceived(message); + } +} Added: haiku/trunk/src/preferences/network/EthernetSettingsView.h =================================================================== --- haiku/trunk/src/preferences/network/EthernetSettingsView.h 2007-07-09 09:09:33 UTC (rev 21587) +++ haiku/trunk/src/preferences/network/EthernetSettingsView.h 2007-07-09 09:14:25 UTC (rev 21588) @@ -0,0 +1,57 @@ +/* + * Copyright 2004-2007 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Author: + * Andre Alves Garzia, andre at andregarzia.com + * With code from: + * Axel Dorfler + * Hugo Santos + */ +#ifndef ETHERNET_SETTINGS_VIEW_H +#define ETHERNET_SETTINGS_VIEW_H + +#include +#include + +class BButton; +class BMenuField; +class BTextControl; + +static const uint32 kMsgApply = 'aply'; +static const uint32 kMsgClose = 'clse'; +static const uint32 kMsgOK = 'okok'; +static const uint32 kMsgField = 'fild'; +static const uint32 kMsgInfo = 'info'; + +class EthernetSettingsView : public BView { + public: + EthernetSettingsView(BRect rect); + virtual ~EthernetSettingsView(); + + virtual void MessageReceived(BMessage* message); + virtual void AttachedToWindow(); + virtual void DetachedFromWindow(); + + private: + + BButton* fCloseButton; + BButton* fApplyButton; + BButton* fOKButton; + BMenuField* fDeviceMenuField; + BMenuField* fTypeMenuField; + BTextControl* fIPTextControl; + BTextControl* fNetMaskTextControl; + BTextControl* fGatewayTextControl; + BTextControl* fPrimaryDNSTextControl; + BTextControl* fSecondaryDNSTextControl; + BObjectList fInterfaces; + int32 fStatus; + int fSocket; + void _GatherInterfaces(); + bool _PrepareRequest(struct ifreq& request, const char* name); + void _ShowConfiguration(BMessage* message); + +}; + +#endif /* ETHERNET_SETTINGS_VIEW_H */ Added: haiku/trunk/src/preferences/network/EthernetSettingsWindow.cpp =================================================================== --- haiku/trunk/src/preferences/network/EthernetSettingsWindow.cpp 2007-07-09 09:09:33 UTC (rev 21587) +++ haiku/trunk/src/preferences/network/EthernetSettingsWindow.cpp 2007-07-09 09:14:25 UTC (rev 21588) @@ -0,0 +1,51 @@ +/* + * Copyright 2004-2007 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Author: + * Andre Alves Garzia, andre at andregarzia.com + * With code from: + * Axel Dorfler + * Hugo Santos + */ + +#include + +#include "EthernetSettingsWindow.h" +#include "EthernetSettingsView.h" + + +EthernetSettingsWindow::EthernetSettingsWindow() : BWindow(BRect(50, 50, 269, 302), + "Ethernet Settings", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) +{ + + fEthView = new EthernetSettingsView(Bounds()); + + AddChild(fEthView); + + Show(); +} + + +void EthernetSettingsWindow::MessageReceived(BMessage* message) +{ + switch (message->what) { + case kMsgInfo: + fEthView->MessageReceived(message); + break; + default: + BWindow::MessageReceived(message); + } + +} + +EthernetSettingsWindow::~EthernetSettingsWindow() +{ +} + + +bool EthernetSettingsWindow::QuitRequested() +{ + be_app->PostMessage(B_QUIT_REQUESTED); + return true; +} Added: haiku/trunk/src/preferences/network/EthernetSettingsWindow.h =================================================================== --- haiku/trunk/src/preferences/network/EthernetSettingsWindow.h 2007-07-09 09:09:33 UTC (rev 21587) +++ haiku/trunk/src/preferences/network/EthernetSettingsWindow.h 2007-07-09 09:14:25 UTC (rev 21588) @@ -0,0 +1,30 @@ +/* + * Copyright 2004-2007 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Author: + * Andre Alves Garzia, andre at andregarzia.com + * With code from: + * Axel Dorfler + * Hugo Santos + */ +#ifndef ETHERNET_SETTINGS_WINDOW_H +#define ETHERNET_SETTINGS_WINDOW_H + +#include +#include "EthernetSettingsView.h" + +class EthernetSettingsWindow : public BWindow { + public: + EthernetSettingsWindow(); + virtual ~EthernetSettingsWindow(); + virtual bool QuitRequested(); + virtual void EthernetSettingsWindow::MessageReceived(BMessage* mesage); + + private: + EthernetSettingsView *fEthView; + +}; + + +#endif /* ETHERNET_SETTINGS_WINDOW_H */ Added: haiku/trunk/src/preferences/network/Jamfile =================================================================== --- haiku/trunk/src/preferences/network/Jamfile 2007-07-09 09:09:33 UTC (rev 21587) +++ haiku/trunk/src/preferences/network/Jamfile 2007-07-09 09:14:25 UTC (rev 21588) @@ -0,0 +1,17 @@ +SubDir HAIKU_TOP src preferences network ; + +SetSubDirSupportedPlatformsBeOSCompatible ; + +UsePrivateHeaders shared ; + +Preference Network : + EthernetSettingsWindow.cpp + EthernetSettingsView.cpp + EthernetSettings.cpp + : be root $(NETWORK_LIBS) + ; + +Package haiku-networksettings : + Network : + boot home Desktop haiku-networksettings ; + From axeld at pinc-software.de Mon Jul 9 11:58:55 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Mon, 09 Jul 2007 11:58:55 +0200 CEST Subject: [Haiku-commits] r21588 - in haiku/trunk/src/preferences: . network In-Reply-To: <200707090914.l699EPKq008333@sheep.berlios.de> Message-ID: <4240394278-BeMail@zon> stippi at BerliOS wrote: > +void EthernetSettingsView::_GatherInterfaces() { Please make sure he'll follow our coding style more consistently. The above would be: void EthernetSettingsView::_GatherInterfaces() { ... Bye, Axel. From marcusoverhagen at arcor.de Mon Jul 9 12:03:13 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Mon, 9 Jul 2007 12:03:13 +0200 (CEST) Subject: [Haiku-commits] r21579 - haiku/trunk/src/kits/storage Message-ID: <1603454.1183975393084.JavaMail.ngmail@webmail18> Axel D?rfler wrote: > marcusoverhagen at BerliOS wrote: > > + bool operator<(const node_ref& a, const node_ref& b); > Thanks! Where are we exporting the < operator method BTW? Somewhere down in PathMonitor.cpp, but it's in namespace BPrivate. We should probably move it to Node.cpp / Node.h and might be able to remove the node_ref_less predicate after that, but appeareantly the original author (some strange fellow named axeld) who wrote all that decided to not make it public. ;) I just needed a quick build fix, because the build seems to be regularly broken when i want to do some coding at the weekends. bye Marcus Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 39,85 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From superstippi at gmx.de Mon Jul 9 12:23:52 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Mon, 09 Jul 2007 12:23:52 +0200 Subject: [Haiku-commits] r21588 - in haiku/trunk/src/preferences: . network In-Reply-To: <4240394278-BeMail@zon> References: <4240394278-BeMail@zon> Message-ID: <20070709122352.3163.5@stippis2.1183966877.fake> Axel D?rfler wrote (2007-07-09, 11:58:55 [+0200]): > stippi at BerliOS wrote: > > +void EthernetSettingsView::_GatherInterfaces() { > > Please make sure he'll follow our coding style more consistently. > The above would be: > > void > EthernetSettingsView::_GatherInterfaces() > { > ... I know, I pointed it out to him. It will be fixed in the next patch I suppose. Best regards, -Stephan From korli at users.berlios.de Mon Jul 9 17:19:50 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Mon, 9 Jul 2007 17:19:50 +0200 Subject: [Haiku-commits] r21548 - in haiku/trunk/src/bin/network: . login In-Reply-To: <200707041633.l64GXwiS012673@sheep.berlios.de> References: <200707041633.l64GXwiS012673@sheep.berlios.de> Message-ID: Hi Axel, please, make sure to exit with 1 instead of -1 at the following places. Thanks, J?r?me 2007/7/4, axeld at BerliOS : > > + fprintf(stderr, "%s: %s\n", > kProgramName, > + strerror(B_NOT_ALLOWED)); > + exit(-1); > + } + > + syslog(LOG_NOTICE, "login%s failed for \"%s\"", > get_from(fromHost), > + passwd->pw_name); > + exit(-1); + syslog(LOG_NOTICE, "login%s refused for \"%s\"", > get_from(fromHost), > + passwd->pw_name); > + exit(-1); + > + return -1; > +} > + > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From korli at mail.berlios.de Mon Jul 9 22:19:02 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 9 Jul 2007 22:19:02 +0200 Subject: [Haiku-commits] r21589 - haiku/trunk/src/build/libbe/app Message-ID: <200707092019.l69KJ2ls001478@sheep.berlios.de> Author: korli Date: 2007-07-09 22:19:02 +0200 (Mon, 09 Jul 2007) New Revision: 21589 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21589&view=rev Modified: haiku/trunk/src/build/libbe/app/MessageAdapter.cpp Log: uint32 => addr_t Modified: haiku/trunk/src/build/libbe/app/MessageAdapter.cpp =================================================================== --- haiku/trunk/src/build/libbe/app/MessageAdapter.cpp 2007-07-09 09:14:25 UTC (rev 21588) +++ haiku/trunk/src/build/libbe/app/MessageAdapter.cpp 2007-07-09 20:19:02 UTC (rev 21589) @@ -329,7 +329,7 @@ r5header->flags = flags; // store the header size - used for the checksum later - ssize_t headerSize = (uint32)pointer - (uint32)buffer; + ssize_t headerSize = (addr_t)pointer - (addr_t)buffer; // collect and add the data BMessage::field_header *field = messagePrivate.GetMessageFields(); @@ -405,7 +405,7 @@ pointer++; // calculate the flattened size from the pointers - r5header->flattened_size = (uint32)pointer - (uint32)buffer; + r5header->flattened_size = (addr_t)pointer - (addr_t)buffer; r5header->checksum = CalculateChecksum((uint8 *)(buffer + 8), headerSize - 8); From axeld at mail.berlios.de Mon Jul 9 23:41:44 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 9 Jul 2007 23:41:44 +0200 Subject: [Haiku-commits] r21590 - haiku/trunk/src/bin/network/login Message-ID: <200707092141.l69LfiBF007257@sheep.berlios.de> Author: axeld Date: 2007-07-09 23:41:44 +0200 (Mon, 09 Jul 2007) New Revision: 21590 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21590&view=rev Modified: haiku/trunk/src/bin/network/login/login.cpp Log: Fixed failure return codes as pointed out by Jerome. Modified: haiku/trunk/src/bin/network/login/login.cpp =================================================================== --- haiku/trunk/src/bin/network/login/login.cpp 2007-07-09 20:19:02 UTC (rev 21589) +++ haiku/trunk/src/bin/network/login/login.cpp 2007-07-09 21:41:44 UTC (rev 21590) @@ -201,7 +201,7 @@ if (geteuid() != 0) { fprintf(stderr, "%s: %s\n", kProgramName, strerror(B_NOT_ALLOWED)); - exit(-1); + exit(1); } fromHost = optarg; @@ -250,7 +250,7 @@ // login failure syslog(LOG_NOTICE, "login%s failed for \"%s\"", get_from(fromHost), passwd->pw_name); - exit(-1); + exit(1); } // setup environment for the user @@ -262,7 +262,7 @@ kProgramName, strerror(status)); syslog(LOG_NOTICE, "login%s refused for \"%s\"", get_from(fromHost), passwd->pw_name); - exit(-1); + exit(1); } syslog(LOG_INFO, "login%s as \"%s\"", get_from(fromHost), passwd->pw_name); @@ -279,6 +279,6 @@ fprintf(stderr, "%s: starting the shell failed: %s", kProgramName, strerror(errno)); - return -1; + return 1; } From axeld at pinc-software.de Mon Jul 9 23:41:58 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Mon, 09 Jul 2007 23:41:58 +0200 CEST Subject: [Haiku-commits] r21548 - in haiku/trunk/src/bin/network: . login In-Reply-To: Message-ID: <46423739183-BeMail@zon> "J?r?me Duval" wrote: > please, make sure to exit with 1 instead of -1 at the following > places. Thanks! Bye, Axel. From bonefish at mail.berlios.de Wed Jul 11 03:04:38 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 11 Jul 2007 03:04:38 +0200 Subject: [Haiku-commits] r21591 - in haiku/trunk: . build/jam build/scripts Message-ID: <200707110104.l6B14cPr024697@sheep.berlios.de> Author: bonefish Date: 2007-07-11 03:04:35 +0200 (Wed, 11 Jul 2007) New Revision: 21591 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21591&view=rev Added: haiku/trunk/build/jam/NetBootArchive haiku/trunk/build/scripts/build_tgz_archive Modified: haiku/trunk/Jamfile haiku/trunk/build/jam/BuildSetup haiku/trunk/build/jam/HaikuImage haiku/trunk/build/jam/ImageRules haiku/trunk/build/jam/UserBuildConfig.sample Log: * Refactored the image creation rules. There are now generalized rules that work on arbitrary "containers". The image rules are just specializations. * Added rules, a definition file (build/jam/NetBootArchive), and a shell script for creating a gzipped tar archive containing kernel and modules required for network booting (the contents may need some fine-tuning). ATM it can be built via the haiku-netboot-archive pseudo target. It is generated in the output directory (e.g. "generated"). Modified: haiku/trunk/Jamfile =================================================================== --- haiku/trunk/Jamfile 2007-07-09 21:41:44 UTC (rev 21590) +++ haiku/trunk/Jamfile 2007-07-11 01:04:35 UTC (rev 21591) @@ -142,8 +142,9 @@ SubInclude HAIKU_TOP src ; } -# specify the Haiku image contents +# specify the Haiku image and network boot archive contents include [ FDirName $(HAIKU_BUILD_RULES_DIR) HaikuImage ] ; +include [ FDirName $(HAIKU_BUILD_RULES_DIR) NetBootArchive ] ; # Perform deferred SubIncludes. ExecuteDeferredSubIncludes ; Modified: haiku/trunk/build/jam/BuildSetup =================================================================== --- haiku/trunk/build/jam/BuildSetup 2007-07-09 21:41:44 UTC (rev 21590) +++ haiku/trunk/build/jam/BuildSetup 2007-07-11 01:04:35 UTC (rev 21591) @@ -33,7 +33,7 @@ } else if $(JAM_TARGETS[1]) = update-image || $(JAM_TARGETS[1]) = update-vmware-image || $(JAM_TARGETS[1]) = update-install { - HAIKU_IMAGE_UPDATE_ONLY = 1 ; + SetUpdateHaikuImageOnly 1 ; HAIKU_INCLUDE_IN_IMAGE on $(JAM_TARGETS[2-]) = 1 ; if $(JAM_TARGETS[1]) = update-image { @@ -724,6 +724,25 @@ } +#pragma mark - container settings + +# Haiku image +HAIKU_IMAGE_CONTAINER_NAME = haiku-image-container ; +HAIKU_CONTAINER_GRIST on $(HAIKU_IMAGE_CONTAINER_NAME) = HaikuImage ; +HAIKU_INCLUDE_IN_CONTAINER_VAR on $(HAIKU_IMAGE_CONTAINER_NAME) + = HAIKU_INCLUDE_IN_IMAGE ; +HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_IMAGE_CONTAINER_NAME) + = HAIKU_IMAGE_INSTALL_TARGETS ; + +# network boot archive +HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME = haiku-netboot-archive-container ; +HAIKU_CONTAINER_GRIST on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) + = NetBootArchive ; +# HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported +HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) + = HAIKU_NET_BOOT_ARCHIVE_INSTALL_TARGETS ; + + #pragma mark - # common stuff Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-07-09 21:41:44 UTC (rev 21590) +++ haiku/trunk/build/jam/HaikuImage 2007-07-11 01:04:35 UTC (rev 21591) @@ -1,3 +1,6 @@ +# This file defines what ends up on the Haiku image (respectively in the Haiku +# installation directory) and it executes the rules building the image +# (respectively installing the files in the installation directory). # create directories that will remain empty AddDirectoryToHaikuImage home Desktop ; @@ -6,18 +9,17 @@ AddDirectoryToHaikuImage var log ; AddDirectoryToHaikuImage var tmp ; +local X86_ONLY = ; +local PPC_ONLY = ; if $(TARGET_ARCH) = x86 { X86_ONLY = "" ; - PPC_ONLY = ; } else if $(TARGET_ARCH) = ppc { X86_ONLY = ; - PPC_ONLY = "" ; } +local GPL_ONLY = ; if $(INCLUDE_GPL_ADDONS) = 1 { GPL_ONLY = "" ; -} else { - GPL_ONLY = ; } BEOS_BIN = "[" addattr alert arp basename bc beep bzip2 cat cardctl catattr chgrp @@ -329,9 +331,9 @@ AddFilesToHaikuImage beos system : zbeos ; # boot module links -AddBootModuleSymlinks config_manager bfs block_io fast_log generic_ide_pci - $(X86_ONLY)isa ide ide_adapter $(X86_ONLY)ide_isa intel locked_pool - $(PPC_ONLY)openpic pci scsi scsi_cd scsi_dsk scsi_periph +AddBootModuleSymlinksToHaikuImage config_manager bfs block_io fast_log + generic_ide_pci $(X86_ONLY)isa ide ide_adapter $(X86_ONLY)ide_isa intel + locked_pool $(PPC_ONLY)openpic pci scsi scsi_cd scsi_dsk scsi_periph ahci silicon_image_3112 ; @@ -395,7 +397,7 @@ HAIKU_INSTALL_DIR ?= /Haiku ; # the pseudo target all image contents is attached to -NotFile haiku-image-contents ; +NotFile $(HAIKU_IMAGE_CONTAINER_NAME) ; # prepare the script that initializes the shell variables HAIKU_IMAGE_INIT_VARIABLES_SCRIPT = haiku.image-init-vars ; Modified: haiku/trunk/build/jam/ImageRules =================================================================== --- haiku/trunk/build/jam/ImageRules 2007-07-09 21:41:44 UTC (rev 21590) +++ haiku/trunk/build/jam/ImageRules 2007-07-11 01:04:35 UTC (rev 21591) @@ -95,15 +95,18 @@ } -rule AddDirectoryToHaikuImage directoryTokens +#pragma mark - + +rule AddDirectoryToContainer container : directoryTokens { - # AddDirectoryToHaikuImage + # AddDirectoryToContainer : + local containerGrist = [ on $(container) return $(HAIKU_CONTAINER_GRIST) ] ; local directory = [ FDirName $(directoryTokens) ] ; - directory = $(directory:G=HaikuImage) ; + directory = $(directory:G=$(containerGrist)) ; if ! [ on $(directory) return $(__is_on_image) ] { - INSTALL_DIRECTORIES on haiku-image-contents += $(directory) ; + HAIKU_INSTALL_DIRECTORIES on $(container) += $(directory) ; __is_on_image on $(directory) = true ; NotFile $(directory) ; @@ -112,7 +115,7 @@ parent = [ FReverse $(parent[2-]) ] ; if $(parent) { parent = [ FDirName $(parent) ] ; - parent = $(parent:G=HaikuImage) ; + parent = $(parent:G=$(containerGrist)) ; DONT_CREATE on $(parent) = true ; } } @@ -120,35 +123,43 @@ return $(directory) ; } -rule FilterImageUpdateTargets targets +rule FilterContainerUpdateTargets targets : filterVariable { - # FilterImageUpdateTargets targets + # FilterContainerUpdateTargets targets : filterVariable local filteredTargets ; local target ; for target in $(targets) { - if [ on $(target) return $(HAIKU_INCLUDE_IN_IMAGE) ] { + if [ on $(target) return $($(filterVariable)) ] { filteredTargets += $(target) ; } } return $(filteredTargets) ; } -rule AddFilesToHaikuImage +rule AddFilesToContainer container : directoryTokens : targets : destName { - # AddFilesToHaikuImage : [ : dest name ] + # AddFilesToContainer : : + # [ : dest name ] # - local directory = [ AddDirectoryToHaikuImage $(1) ] ; - local targets = $(2) ; - local destName = $(3) ; + local directory = [ AddDirectoryToContainer $(container) + : $(directoryTokens) ] ; + local containerGrist = [ on $(container) return $(HAIKU_CONTAINER_GRIST) ] ; # If the image shall only be updated, we filter out all targets not marked # accordingly. - if $(HAIKU_IMAGE_UPDATE_ONLY) { - targets = [ FilterImageUpdateTargets $(targets) ] ; + if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ] { + local filterVar + = [ on $(container) return $(HAIKU_INCLUDE_IN_CONTAINER_VAR) ] ; + if $(filterVar) { + targets = [ FilterContainerUpdateTargets $(targets) + : $(filterVar) ] ; + } } # We create a unique dummy target per target to install. + local installTargetsVar + = [ on $(container) return $(HAIKU_INSTALL_TARGETS_VAR) ] ; local target ; for target in $(targets) { local name ; @@ -158,25 +169,27 @@ name = $(target:G=:D=) ; } - local destTarget = $(name:G=HaikuImage__$(directory:G=)) ; + local destTarget = $(name:G=$(containerGrist)__$(directory:G=)) ; TARGET on $(destTarget) = $(target) ; INSTALL_DIR on $(destTarget) = $(directory) ; - INSTALL_TARGETS on $(target) += $(destTarget) ; + $(installTargetsVar) on $(target) += $(destTarget) ; TARGETS_TO_INSTALL on $(directory) += $(destTarget) ; } } -rule AddSymlinkToHaikuImage directoryTokens : linkTarget : linkName +rule AddSymlinkToContainer container : directoryTokens : linkTarget : linkName { - # AddSymlinkToHaikuImage : [ : ] ; + # AddSymlinkToContainer : : + # [ : ] ; # # If the image shall only be updated, we don't add any symlinks. - if $(HAIKU_IMAGE_UPDATE_ONLY) { + if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ] { return ; } - local directory = [ AddDirectoryToHaikuImage $(directoryTokens) ] ; + local directory = [ AddDirectoryToContainer $(container) + : $(directoryTokens) ] ; if ! $(linkName) { local path = [ FReverse [ FSplitPath $(linkTarget) ] ] ; @@ -188,30 +201,18 @@ SYMLINKS_TO_INSTALL on $(directory) += $(link) ; } -rule AddSourceDirectoryToHaikuImage dirTokens : alwaysUpdate +rule AddDriversToContainer container : relativeDirectoryTokens : targets { - # AddSourceDirectoryToHaikuImage : ; - - # If the image shall only be updated, we update sources only, if explicitely - # requested. - if ! $(HAIKU_IMAGE_UPDATE_ONLY) || $(alwaysUpdate) { - HAIKU_INSTALL_SOURCE_DIRS += [ FDirName $(HAIKU_TOP) $(dirTokens) ] ; - } -} - -rule AddDriversToHaikuImage -{ - # AddDriversToHaikuImage : ; + # AddDriversToContainer : : ; # - local relativeDirectoryTokens = $(1) ; - local targets = $(2) ; local directoryTokens = beos system add-ons kernel drivers dev $(relativeDirectoryTokens) ; - AddFilesToHaikuImage beos system add-ons kernel drivers bin : $(targets) ; + AddFilesToContainer $(container) : beos system add-ons kernel drivers bin + : $(targets) ; # If the image shall only be updated, we don't add any symlinks. - if $(HAIKU_IMAGE_UPDATE_ONLY) { + if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ] { return ; } @@ -225,18 +226,17 @@ # add the symlinks local name ; for name in $(targets:BS) { - AddSymlinkToHaikuImage $(directoryTokens) + AddSymlinkToContainer $(container) : $(directoryTokens) : [ FDirName $(linkPrefix) $(name) ] : $(name) ; } } -rule AddDriverRegistrationToHaikuImage +rule AddDriverRegistrationToContainer container : relativeDirectoryTokens + : target : links { - # AddDriverRegistrationToHaikuImage : : ] ; + # AddDriverRegistrationToContainer : + # : : ] ; # - local relativeDirectoryTokens = $(1) ; - local target = $(2) ; - local links = $(3) ; local directoryTokens = beos system add-ons kernel registration $(relativeDirectoryTokens) ; @@ -248,44 +248,46 @@ linkPrefix += .. drivers bin ; # add the symlink - AddSymlinkToHaikuImage $(directoryTokens) + AddSymlinkToContainer $(container) : $(directoryTokens) : [ FDirName $(linkPrefix) $(target:BS) ] : $(links) ; } -rule AddBootModuleSymlinks targets +rule AddBootModuleSymlinksToContainer container : targets { - # AddBootModuleSymlinks ; + # AddBootModuleSymlinksToContainer : ; # # If the image shall only be updated, we don't add any symlinks. - if $(HAIKU_IMAGE_UPDATE_ONLY) { + if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ] { return ; } # add the symlinks + local installTargetsVar + = [ on $(container) return $(HAIKU_INSTALL_TARGETS_VAR) ] ; local target ; for target in $(targets) { # Symlink to the first place where the target has been installed. - local destTarget = [ on $(target) return $(INSTALL_TARGETS[1]) ] ; + local destTarget = [ on $(target) return $($(installTargetsVar)[1]) ] ; local installDir = [ on $(destTarget) return $(INSTALL_DIR) ] ; if ! $(installDir) { - Echo "ERROR: AddBootModuleSymlinks: Can't create a symlink to" - "target" \"$(target)"\"." ; - Exit "ERROR: Add*ToHaikuImage has not been invoked for it yet." ; + Echo "ERROR: AddBootModuleSymlinksToContainer: Can't create a " + "symlink to target" \"$(target)"\"." ; + Exit "ERROR: Add*ToContainer has not been invoked for it yet." ; } local name = $(target:BS) ; local linkTarget = [ FDirName /boot $(installDir:G=) $(name) ] ; - AddSymlinkToHaikuImage beos system add-ons kernel boot + AddSymlinkToContainer $(container) : beos system add-ons kernel boot : $(linkTarget) : $(name) ; } } -rule CreateHaikuImageMakeDirectoriesScript + +rule CreateContainerMakeDirectoriesScript container : script { - local script = $(1) ; MakeLocate $(script) : $(HAIKU_OUTPUT_DIR) ; Always $(script) ; @@ -299,7 +301,7 @@ local dirsToCreate ; local dir ; - for dir in [ on haiku-image-contents return $(INSTALL_DIRECTORIES) ] { + for dir in [ on $(container) return $(HAIKU_INSTALL_DIRECTORIES) ] { if ! [ on $(dir) return $(DONT_CREATE) ] { dirsToCreate += $(dir) ; } @@ -307,19 +309,19 @@ Depends $(scriptBody) : $(dirsToCreate) ; # If the image shall only be updated, we don't create directories. - if $(dirsToCreate) && ! $(HAIKU_IMAGE_UPDATE_ONLY) { - CreateHaikuImageMakeDirectoriesScript1 $(scriptBody) : $(dirsToCreate) ; + if $(dirsToCreate) + && ! [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ] { + CreateContainerMakeDirectoriesScript1 $(scriptBody) : $(dirsToCreate) ; } } -actions piecemeal CreateHaikuImageMakeDirectoriesScript1 +actions piecemeal CreateContainerMakeDirectoriesScript1 { echo \$mkdir -p "\"\${tPrefix}$(2:G=)\"" >> $(1) } -rule CreateHaikuImageCopyFilesScript +rule CreateContainerCopyFilesScript container : script { - local script = $(1) ; MakeLocate $(script) : $(HAIKU_OUTPUT_DIR) ; Always $(script) ; @@ -332,7 +334,7 @@ Depends $(script) : $(scriptBody) ; local dir ; - for dir in [ on haiku-image-contents return $(INSTALL_DIRECTORIES) ] { + for dir in [ on $(container) return $(HAIKU_INSTALL_DIRECTORIES) ] { # filter the targets that shall be renamed; they have to be copied # individually local destTargets = [ on $(dir) return $(TARGETS_TO_INSTALL) ] ; @@ -352,7 +354,7 @@ Depends $(dummyTarget) : $(initScript) $(target) ; Depends $(script) : $(dummyTarget) ; - AppendToHaikuImageCopyFilesScriptSingleFile $(dummyTarget) + AppendToContainerCopyFilesScriptSingleFile $(dummyTarget) : $(initScript) $(target) ; } else { remainingTargets += $(target) ; @@ -371,7 +373,7 @@ Depends $(script) : $(dummyTarget) ; OUTPUT_SCRIPT on $(dummyTarget) = $(initScript) ; - AppendToHaikuImageCopyFilesScript $(dummyTarget) : $(targets) ; + AppendToContainerCopyFilesScript $(dummyTarget) : $(targets) ; } local symlinks = [ on $(dir) return $(SYMLINKS_TO_INSTALL) ] ; @@ -382,34 +384,108 @@ Depends $(script) : $(symlink) ; Depends $(symlink) : $(initScript) ; - AddSymlinkToHaikuImageCopyFilesScript $(symlink) : $(initScript) ; + AddSymlinkToContainerCopyFilesScript $(symlink) : $(initScript) ; } } } -actions piecemeal AppendToHaikuImageCopyFilesScript bind OUTPUT_SCRIPT +actions piecemeal AppendToContainerCopyFilesScript bind OUTPUT_SCRIPT { echo \$cp "\"\${sPrefix}$(2)\"" "\"\${tPrefix}$(TARGET_DIR)\"" >> $(OUTPUT_SCRIPT) } -actions AppendToHaikuImageCopyFilesScriptSingleFile +actions AppendToContainerCopyFilesScriptSingleFile { echo \$cp "\"\${sPrefix}$(2[2])\"" \ "\"\${tPrefix}$(TARGET_DIR)/$(INSTALL_TARGET_NAME)\"" >> $(2[1]) } -actions AddSymlinkToHaikuImageCopyFilesScript +actions AddSymlinkToContainerCopyFilesScript { echo \$ln -sfn "\"$(SYMLINK_TARGET)\"" "\"\${tPrefix}$(1:G=)\"" >> $(2[1]) } -rule BuildHaikuImage + +#pragma mark - Haiku Image rules + +rule SetUpdateHaikuImageOnly flag { + HAIKU_CONTAINER_UPDATE_ONLY on $(HAIKU_IMAGE_CONTAINER_NAME) = $(flag) ; +} + +rule AddDirectoryToHaikuImage directoryTokens +{ + # AddDirectoryToHaikuImage + + return [ AddDirectoryToContainer $(HAIKU_IMAGE_CONTAINER_NAME) + : $(directoryTokens) ] ; +} + +rule AddFilesToHaikuImage directory : targets : destName +{ + # AddFilesToHaikuImage : [ : dest name ] + + AddFilesToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(directory) + : $(targets) : $(destName) ; +} + +rule AddSymlinkToHaikuImage directoryTokens : linkTarget : linkName +{ + # AddSymlinkToHaikuImage : [ : ] ; + + AddSymlinkToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(directoryTokens) + : $(linkTarget) : $(linkName) ; +} + +rule AddSourceDirectoryToHaikuImage dirTokens : alwaysUpdate +{ + # AddSourceDirectoryToHaikuImage : ; + + # If the image shall only be updated, we update sources only, if explicitely + # requested. + if ! $(HAIKU_IMAGE_UPDATE_ONLY) || $(alwaysUpdate) { + HAIKU_INSTALL_SOURCE_DIRS += [ FDirName $(HAIKU_TOP) $(dirTokens) ] ; + } +} + +rule AddDriversToHaikuImage relativeDirectoryTokens : targets +{ + # AddDriversToHaikuImage : ; + + AddDriversToContainer $(HAIKU_IMAGE_CONTAINER_NAME) + : $(relativeDirectoryTokens) : $(targets) ; +} + +rule AddDriverRegistrationToHaikuImage relativeDirectoryTokens : target : links +{ + # AddDriverRegistrationToHaikuImage : : ] ; + + AddDriverRegistrationToContainer $(HAIKU_IMAGE_CONTAINER_NAME) + : $(relativeDirectoryTokens) : $(target) : $(links) ; +} + +rule AddBootModuleSymlinksToHaikuImage targets +{ + # AddBootModuleSymlinksToHaikuImage ; + + AddBootModuleSymlinksToContainer $(HAIKU_IMAGE_CONTAINER_NAME) + : $(targets) ; +} + +rule CreateHaikuImageMakeDirectoriesScript script +{ + CreateContainerMakeDirectoriesScript $(HAIKU_IMAGE_CONTAINER_NAME) + : $(script) ; +} + +rule CreateHaikuImageCopyFilesScript script +{ + CreateContainerCopyFilesScript $(HAIKU_IMAGE_CONTAINER_NAME) : $(script) ; +} + +rule BuildHaikuImage haikuImage : scripts : isImage +{ # BuildHaikuImage : : ; - # - local haikuImage = $(1) ; - local scripts = $(2) ; - local isImage = $(3) ; if $(isImage) = 1 || $(isImage) = true { IS_IMAGE on $(haikuImage) = 1 ; @@ -446,3 +522,84 @@ $(2[1]) -h 64k -i$(IMAGE_SIZE)M $(1) && cat $(2[2]) >> $(1) } + + +#pragma mark - Network Boot Archive rules + +rule AddDirectoryToNetBootArchive directoryTokens +{ + # AddDirectoryToNetBootArchive + + return [ AddDirectoryToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) + : $(directoryTokens) ] ; +} + +rule AddFilesToNetBootArchive directory : targets : destName +{ + # AddFilesToNetBootArchive : [ : dest name ] + + AddFilesToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) : $(directory) + : $(targets) : $(destName) ; +} + +rule AddSymlinkToNetBootArchive directoryTokens : linkTarget : linkName +{ + # AddSymlinkToNetBootArchive : [ : ] ; + + AddSymlinkToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) + : $(directoryTokens) : $(linkTarget) : $(linkName) ; +} + +rule AddDriversToNetBootArchive relativeDirectoryTokens : targets +{ + # AddDriversToNetBootArchive : ; + + AddDriversToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) + : $(relativeDirectoryTokens) : $(targets) ; +} + +rule AddDriverRegistrationToNetBootArchive relativeDirectoryTokens : target + : links +{ + # AddDriverRegistrationToNetBootArchive : + # : ] ; + + AddDriverRegistrationToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) + : $(relativeDirectoryTokens) : $(target) : $(links) ; +} + +rule AddBootModuleSymlinksToNetBootArchive targets +{ + # AddBootModuleSymlinksToNetBootArchive ; + + AddBootModuleSymlinksToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) + : $(targets) ; +} + +rule CreateNetBootArchiveMakeDirectoriesScript script +{ + CreateContainerMakeDirectoriesScript + $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) : $(script) ; +} + +rule CreateNetBootArchiveCopyFilesScript script +{ + CreateContainerCopyFilesScript $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) + : $(script) ; +} + +rule BuildNetBootArchive archive : scripts +{ + # BuildHNetBootArchive : ; + + local mainScript = build_tgz_archive ; + SEARCH on $(mainScript) = [ FDirName $(HAIKU_TOP) build scripts ] ; + + Depends $(archive) : $(mainScript) $(scripts) ; + BuildNetBootArchive1 $(archive) : $(mainScript) $(scripts) ; +} + +actions BuildNetBootArchive1 +{ + $(2[1]) $(1) $(2[2-]) +} Added: haiku/trunk/build/jam/NetBootArchive =================================================================== --- haiku/trunk/build/jam/NetBootArchive 2007-07-09 21:41:44 UTC (rev 21590) +++ haiku/trunk/build/jam/NetBootArchive 2007-07-11 01:04:35 UTC (rev 21591) @@ -0,0 +1,133 @@ +# This file defines what ends up in the network boot archive and it executes the +# rules building the archive. + +local X86_ONLY = ; +local PPC_ONLY = ; +if $(TARGET_ARCH) = x86 { + X86_ONLY = "" ; +} else if $(TARGET_ARCH) = ppc { + X86_ONLY = ; +} + +local GPL_ONLY = ; +if $(INCLUDE_GPL_ADDONS) = 1 { + GPL_ONLY = "" ; +} + +BEOS_NETWORK_DEVICES = ethernet loopback ; +BEOS_NETWORK_DATALINK_PROTOCOLS = ethernet_frame arp loopback_frame + ipv4_datagram ; +BEOS_NETWORK_PROTOCOLS = ipv4 tcp udp icmp ; + +BEOS_ADD_ONS_DRIVERS_NET = etherpci ipro1000 rtl8139 rtl8169 sis900 + via-rhine wb840 net_stack vlance + $(GPL_ONLY)bcm440x $(GPL_ONLY)bcm570x +; +BEOS_ADD_ONS_BUS_MANAGERS = pci $(X86_ONLY)ps2 $(X86_ONLY)isa ide scsi + config_manager $(X86_ONLY)agp +; +BEOS_ADD_ONS_FILE_SYSTEMS = bfs cdda dos googlefs iso9660 nfs ; + + +# modules +AddFilesToNetBootArchive beos system add-ons kernel bus_managers + : $(BEOS_ADD_ONS_BUS_MANAGERS) ; +AddFilesToNetBootArchive beos system add-ons kernel busses ide + : ahci generic_ide_pci $(X86_ONLY)ide_isa silicon_image_3112 ; +AddFilesToNetBootArchive beos system add-ons kernel console : vga_text ; +AddFilesToNetBootArchive beos system add-ons kernel file_systems + : $(BEOS_ADD_ONS_FILE_SYSTEMS) ; +AddFilesToNetBootArchive beos system add-ons kernel generic + : block_io fast_log ide_adapter locked_pool mpu401 scsi_periph ; +AddFilesToNetBootArchive beos system add-ons kernel partitioning_systems + : intel session ; +AddFilesToNetBootArchive beos system add-ons kernel interrupt_controllers + : $(PPC_ONLY)openpic ; + +if $(TARGET_ARCH) = x86 { + AddFilesToNetBootArchive beos system add-ons kernel cpu : generic_x86 ; +} + +# drivers +AddDriversToNetBootArchive : console dprintf $(X86_ONLY)keyboard + null random tty zero ; +AddDriversToNetBootArchive disk scsi : scsi_cd scsi_dsk ; +AddDriversToNetBootArchive disk virtual : nbd ; +AddDriversToNetBootArchive net : $(BEOS_ADD_ONS_DRIVERS_NET) ; + +# kernel +AddFilesToNetBootArchive beos system : kernel_$(TARGET_ARCH) ; + +# scripts and data files + +local driverSettingsFiles = kernel ; +SEARCH on $(driverSettingsFiles) + = [ FDirName $(HAIKU_TOP) data settings kernel drivers ] ; +AddFilesToNetBootArchive home config settings kernel drivers + : $(driverSettingsFiles) ; + +# boot module links +#AddBootModuleSymlinksToNetBootArchive config_manager bfs block_io fast_log +# generic_ide_pci $(X86_ONLY)isa ide ide_adapter $(X86_ONLY)ide_isa intel +# locked_pool $(PPC_ONLY)openpic pci scsi scsi_cd scsi_dsk scsi_periph +# ahci silicon_image_3112 +#; + +# add-ons +AddFilesToNetBootArchive beos system add-ons kernel network + : stack socket ; +AddFilesToNetBootArchive beos system add-ons kernel network devices + : $(BEOS_NETWORK_DEVICES) ; +AddFilesToNetBootArchive beos system add-ons kernel network datalink_protocols + : $(BEOS_NETWORK_DATALINK_PROTOCOLS) ; +AddFilesToNetBootArchive beos system add-ons kernel network ppp + : $(BEOS_NETWORK_PPP) ; +AddFilesToNetBootArchive beos system add-ons kernel network protocols + : $(BEOS_NETWORK_PROTOCOLS) ; + + +#pragma mark - Build The Archive + +# archive target +HAIKU_NET_BOOT_ARCHIVE = haiku-netboot.tgz ; +MakeLocate $(haiku-netboot-archive) : $(HAIKU_OUTPUT_DIR) ; + +# the pseudo target all archive contents is attached to +NotFile $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) ; + +# prepare the script that initializes the shell variables +local initVarsScript = haiku-netboot-init-vars ; +local script = $(initVarsScript) ; +MakeLocate $(script) : $(HAIKU_OUTPUT_DIR) ; +Always $(script) ; + +AddVariableToScript $(script) : tmpDir : $(HAIKU_TMP_DIR) ; +AddVariableToScript $(script) : addBuildCompatibilityLibDir + : $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) ; +AddTargetVariableToScript $(script) : copyattr ; + +# create the other scripts +local makeDirsScript = haiku-netboot-make-dirs ; +local copyFilesScript = haiku-netboot-copy-files ; +MakeLocate $(makeDirsScript) $(copyFilesScript) : $(HAIKU_OUTPUT_DIR) ; + +CreateNetBootArchiveMakeDirectoriesScript $(makeDirsScript) ; +CreateNetBootArchiveCopyFilesScript $(copyFilesScript) ; + +# build the archive + +BuildNetBootArchive $(HAIKU_NET_BOOT_ARCHIVE) : + $(initVarsScript) + $(makeDirsScript) + $(copyFilesScript) +; + +# remove the scripts we have generated +RmTemps $(HAIKU_NET_BOOT_ARCHIVE) : + $(initVarsScript) + $(makeDirsScript) + $(copyFilesScript) +; + +NotFile haiku-netboot-archive ; +Depends haiku-netboot-archive : $(HAIKU_NET_BOOT_ARCHIVE) ; Modified: haiku/trunk/build/jam/UserBuildConfig.sample =================================================================== --- haiku/trunk/build/jam/UserBuildConfig.sample 2007-07-09 21:41:44 UTC (rev 21590) +++ haiku/trunk/build/jam/UserBuildConfig.sample 2007-07-11 01:04:35 UTC (rev 21591) @@ -38,13 +38,14 @@ # Affects the haiku-image, haiku-vmware-image, and install-haiku targets. Only # targets on which the HAIKU_INCLUDE_IN_IMAGE variable has been set will be # updated in the image file/installation directory. -# The update-image, update-vmware-image, and update-install targets always set -# this variable, so one likely doesn't ever need to set it manually. -HAIKU_IMAGE_UPDATE_ONLY = 1 ; +# The update-image, update-vmware-image, and update-install targets always invoke +# this rule, so one likely doesn't ever need to do it manually. +SetUpdateHaikuImageOnly 1 ; # libbe.so and the kernel will be updated on image updates. Note that this -# doesn't work for pseudo targets like "kernel". -HAIKU_INCLUDE_IN_IMAGE on libbe.so kernel_x86 = 1 ; +# generally doesn't work for pseudo targets (it does where special support +# has been added, like for "kernel"). +HAIKU_INCLUDE_IN_IMAGE on libbe.so kernel = 1 ; # Add "crashing_app" to the beos/bin directory of the Haiku image/installation. # Note, that this also makes the image depend on the target, i.e. it is Added: haiku/trunk/build/scripts/build_tgz_archive =================================================================== --- haiku/trunk/build/scripts/build_tgz_archive 2007-07-09 21:41:44 UTC (rev 21590) +++ haiku/trunk/build/scripts/build_tgz_archive 2007-07-11 01:04:35 UTC (rev 21591) @@ -0,0 +1,53 @@ +#!/bin/sh + +if [ $# -lt 2 ]; then + echo "Usage: $0 ..." +fi + +# get the archive name +archive=$1 +shift + +# The second argument is the shell script that initializes the variables: +# tmpDir +# addBuildCompatibilityLibDir +# +# copyattr +# +. $1 +shift + +outputDir=$tmpDir/archive + +# this adds the build library dir to LD_LIBRARY_PATH +eval "$addBuildCompatibilityLibDir" + +# map the shell commands +sPrefix= +tPrefix="$outputDir/" +cd=cd +scd=: +cp="$copyattr -d" +ln=ln +mkdir=mkdir +rm=rm + +# clear output dir +$rm -rf $outputDir +$mkdir $outputDir + +# populate output dir +echo "Preparing contents of archive $archive ..." +while [ $# -gt 0 ]; do + . $1 + shift +done + +# build the archive +echo "Building archive $archive ..." +$rm -f $archive +contents=$(cd $outputDir; ls) +tar -C $outputDir -czf $archive $contents || exit 1 + +# clean up +$rm -rf $outputDir Property changes on: haiku/trunk/build/scripts/build_tgz_archive ___________________________________________________________________ Name: svn:executable + * From korli at mail.berlios.de Wed Jul 11 20:55:27 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Wed, 11 Jul 2007 20:55:27 +0200 Subject: [Haiku-commits] r21592 - haiku/trunk/headers/os/support Message-ID: <200707111855.l6BItRRh009417@sheep.berlios.de> Author: korli Date: 2007-07-11 20:55:27 +0200 (Wed, 11 Jul 2007) New Revision: 21592 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21592&view=rev Modified: haiku/trunk/headers/os/support/Debug.h Log: added printf format attributes for gcc Modified: haiku/trunk/headers/os/support/Debug.h =================================================================== --- haiku/trunk/headers/os/support/Debug.h 2007-07-11 01:04:35 UTC (rev 21591) +++ haiku/trunk/headers/os/support/Debug.h 2007-07-11 18:55:27 UTC (rev 21592) @@ -23,8 +23,13 @@ _IMPEXP_ROOT bool _debugFlag(void); _IMPEXP_ROOT bool _setDebugFlag(bool); - _IMPEXP_ROOT int _debugPrintf(const char *, ...); - _IMPEXP_ROOT int _sPrintf(const char *, ...); +#if __GNUC__ + int _debugPrintf(const char *, ...) __attribute__ ((format (__printf__, 1, 2))); + int _sPrintf(const char *, ...) __attribute__ ((format (__printf__, 1, 2))); +#else + int _debugPrintf(const char *, ...); + int _sPrintf(const char *, ...); +#endif _IMPEXP_ROOT int _xdebugPrintf(const char *, ...); _IMPEXP_ROOT int _debuggerAssert(const char *, int, char *); #ifdef __cplusplus From phoudoin at mail.berlios.de Wed Jul 11 22:31:23 2007 From: phoudoin at mail.berlios.de (phoudoin at BerliOS) Date: Wed, 11 Jul 2007 22:31:23 +0200 Subject: [Haiku-commits] r21593 - haiku/trunk/src/add-ons/kernel/bus_managers/acpi Message-ID: <200707112031.l6BKVNZG016690@sheep.berlios.de> Author: phoudoin Date: 2007-07-11 22:31:23 +0200 (Wed, 11 Jul 2007) New Revision: 21593 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21593&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_device.c Log: Fix build on fro non-haiku targets, on which libroot.so lacks snprintf()... Modified: haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_device.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_device.c 2007-07-11 18:55:27 UTC (rev 21592) +++ haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_device.c 2007-07-11 20:31:23 UTC (rev 21593) @@ -67,10 +67,16 @@ device->path = path; device->type = type; device->node = node; - + +#ifdef __HAIKU__ snprintf(device->name, sizeof(device->name), "acpi_device %s", path); - +#else + strncpy(device->name, "acpi_device ", sizeof(device->name) - 1); + strncat(device->name, path, sizeof(device->name) - 1); + device->name[sizeof(device->name) - 1] = '\0'; +#endif + *cookie = device; return status; From phoudoin at mail.berlios.de Wed Jul 11 22:35:24 2007 From: phoudoin at mail.berlios.de (phoudoin at BerliOS) Date: Wed, 11 Jul 2007 22:35:24 +0200 Subject: [Haiku-commits] r21594 - haiku/trunk/src/add-ons/kernel/generic/dpc Message-ID: <200707112035.l6BKZOpd017040@sheep.berlios.de> Author: phoudoin Date: 2007-07-11 22:35:24 +0200 (Wed, 11 Jul 2007) New Revision: 21594 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21594&view=rev Modified: haiku/trunk/src/add-ons/kernel/generic/dpc/dpc.c Log: Changed snprintf() (un)availability test from COMPILE_FOR_R5 to __HAIKU__. Modified: haiku/trunk/src/add-ons/kernel/generic/dpc/dpc.c =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/dpc/dpc.c 2007-07-11 20:31:23 UTC (rev 21593) +++ haiku/trunk/src/add-ons/kernel/generic/dpc/dpc.c 2007-07-11 20:35:24 UTC (rev 21594) @@ -89,12 +89,13 @@ queue->count = 0; queue->lock = 0; // Init the spinlock -#ifdef COMPILE_FOR_R5 +#ifdef __HAIKU__ + snprintf(str, sizeof(str), "%.*s_wakeup_sem", + (int) sizeof(str) - 11, name); +#else strncpy(str, name, sizeof(str) - 1); strncat(str, "_wakeup_sem", sizeof(str) - 1); str[sizeof(str) - 1] = '\0'; -#else - snprintf(str, sizeof(str), "%.*s_wakeup_sem", (int) sizeof(str) - 11, name); #endif queue->wakeup_sem = create_sem(0, str); From phoudoin at mail.berlios.de Fri Jul 13 11:33:17 2007 From: phoudoin at mail.berlios.de (phoudoin at BerliOS) Date: Fri, 13 Jul 2007 11:33:17 +0200 Subject: [Haiku-commits] r21595 - haiku/trunk/src/add-ons/kernel/bus_managers/acpi Message-ID: <200707130933.l6D9XHRK014298@sheep.berlios.de> Author: phoudoin Date: 2007-07-13 11:33:17 +0200 (Fri, 13 Jul 2007) New Revision: 21595 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21595&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c Log: Fixed ACPI main module for non-haiku targets: * On these targets, we must load ACPI's modules dependencies ourself! * Only the main B_ACPI_MODULE_NAME will work on non-Haiku targets, as the (work-in-progress?) extra ACPI modules (ACPI_ROOT_MODULE_NAME, ACPI_NS_DUMP_MODULE_NAME, and ACPI_DEVICE_MODULE_NAME) needs Haiku's Device Manager. * "cat /dev/power/namespace" was successfully tested on a BeOS R5+Bone system. * My P5W DH Deluxe-based system have a huge ACPI namespace ;-) * A graphical ACPI Namespace Viewer will be welcomed (Hint) Modified: haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c 2007-07-11 20:35:24 UTC (rev 21594) +++ haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c 2007-07-13 09:33:17 UTC (rev 21595) @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -27,6 +28,8 @@ extern dpc_module_info *gDPC; void *gDPChandle = NULL; +extern pci_module_info *gPCIManager; + struct acpi_module_info acpi_module = { { { @@ -85,6 +88,20 @@ return ENOSYS; } + #ifndef __HAIKU__ + { + // Once upon a time, there was no module(s) dependency(ies) automatic loading feature. + // Let's do it the old way + status_t status; + + status = get_module(B_DPC_MODULE_NAME, (module_info **) &gDPC); + if (status != B_OK) return status; + + status = get_module(B_PCI_MODULE_NAME, (module_info **) &gPCIManager); + if (status != B_OK) return status; + } + #endif + gDPChandle = gDPC->new_dpc_queue("acpi_task", B_NORMAL_PRIORITY, 10); #ifdef ACPI_DEBUG_OUTPUT @@ -131,6 +148,13 @@ gDPChandle = NULL; } + #ifndef __HAIKU__ + // Once upon a time, there was no module(s) dependency(ies) automatic UNloading feature. + // Let's do it the old way + put_module(B_DPC_MODULE_NAME); + put_module(B_PCI_MODULE_NAME); + #endif + break; default: return B_ERROR; From jackburton at mail.berlios.de Fri Jul 13 12:39:08 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Fri, 13 Jul 2007 12:39:08 +0200 Subject: [Haiku-commits] r21596 - haiku/trunk/src/apps/terminal Message-ID: <200707131039.l6DAd8qI002365@sheep.berlios.de> Author: jackburton Date: 2007-07-13 12:38:58 +0200 (Fri, 13 Jul 2007) New Revision: 21596 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21596&view=rev Modified: haiku/trunk/src/apps/terminal/CodeConv.cpp haiku/trunk/src/apps/terminal/CodeConv.h haiku/trunk/src/apps/terminal/TermApp.cpp haiku/trunk/src/apps/terminal/TermApp.h haiku/trunk/src/apps/terminal/spawn.cpp Log: More style changes, replaced sprintf use with snprintf. Removed unused variables and code. Modified: haiku/trunk/src/apps/terminal/CodeConv.cpp =================================================================== --- haiku/trunk/src/apps/terminal/CodeConv.cpp 2007-07-13 09:33:17 UTC (rev 21595) +++ haiku/trunk/src/apps/terminal/CodeConv.cpp 2007-07-13 10:38:58 UTC (rev 21596) @@ -27,6 +27,9 @@ #include "CodeConv.h" +#define BEGINS_CHAR(byte) ((byte & 0xc0) >= 0x80) + + extern char utf8_width_table[]; /* define UTF8WidthTbl.c */ Modified: haiku/trunk/src/apps/terminal/CodeConv.h =================================================================== --- haiku/trunk/src/apps/terminal/CodeConv.h 2007-07-13 09:33:17 UTC (rev 21595) +++ haiku/trunk/src/apps/terminal/CodeConv.h 2007-07-13 10:38:58 UTC (rev 21596) @@ -11,8 +11,6 @@ #include #include "Coding.h" -#define BEGINS_CHAR(byte) ((byte & 0xc0) >= 0x80) - class CodeConv { public: CodeConv(); Modified: haiku/trunk/src/apps/terminal/TermApp.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-13 09:33:17 UTC (rev 21595) +++ haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-13 10:38:58 UTC (rev 21596) @@ -35,9 +35,9 @@ // Globals PrefHandler *gTermPref; -bool gUsageRequested = false; -bool gGeometryRequested = false; -bool gColorRequested = false; +static bool sUsageRequested = false; +static bool sGeometryRequested = false; +static bool sColorRequested = false; struct standard_args { char *name; @@ -53,22 +53,10 @@ { "-p", "--preference", 80, 1, NULL }, { "-t", "--title", 70, 1, NULL }, { "-geom", "--geometry", 50, 1, NULL }, -#if 0 - { "-fg", "--text-fore-color", 40, 1, PREF_TEXT_FORE_COLOR }, - { "-bg", "--text-back-color", 35, 1, PREF_TEXT_BACK_COLOR }, - { "-curfg", "--cursor-fore-color", 30, 1, PREF_CURSOR_FORE_COLOR }, - { "-curbg", "--cursor-back-color", 25, 1, PREF_CURSOR_BACK_COLOR }, - { "-selfg", "--select-fore-color", 20, 1, PREF_SELECT_FORE_COLOR }, - { "-selbg", "--select-back-color", 15, 1, PREF_SELECT_BACK_COLOR }, - { "-imfg", "--im-fore-color", 10, 1, PREF_IM_FORE_COLOR }, - { "-imbg", "--im-back-color", 5, 1, PREF_IM_BACK_COLOR }, - { "-imsel", "--im-select-color", 0, 1, PREF_IM_SELECT_COLOR }, -#endif }; int argmatch(char **, int, char *, char *, int, char **, int *); void sort_args(int, char **); -int text_to_rgb(char *, rgb_color *, char *); const ulong MSG_ACTIVATE_TERM = 'msat'; @@ -108,7 +96,7 @@ TermApp::ReadyToRun() { // Prevent opeing window when option -h is given. - if (gUsageRequested) + if (sUsageRequested) return; status_t status = _MakeTermWindow(fTermFrame); @@ -131,7 +119,7 @@ void TermApp::Quit() { - if (!gUsageRequested){ + if (!sUsageRequested){ int status; kill(-gShPid, SIGHUP); @@ -209,7 +197,7 @@ // Print usage if (argmatch(argv, argc, "-help", "--help", 3, NULL, &skip_args)) { _Usage(argv[0]); - gUsageRequested = true; + sUsageRequested = true; PostMessage(B_QUIT_REQUESTED); } @@ -225,8 +213,8 @@ if (argmatch(argv ,argc, "-t", "--title", 3, &value, &skip_args)) fWindowTitle = value; - // Set window geometry - if (argmatch(argv, argc, "-geom", "--geometry", 4, &value, &skip_args)) { + // Set window geometry + if (argmatch(argv, argc, "-geom", "--geometry", 4, &value, &skip_args)) { int width, height, xpos, ypos; sscanf(value, "%dx%d+%d+%d", &width, &height, &xpos, &ypos); @@ -234,46 +222,16 @@ || width >= 256 || height >= 256 || xpos >= 2048 || ypos >= 2048) { fprintf(stderr, "%s: invalid geometry format or value.\n", argv[0]); fprintf(stderr, "Try `%s --help' for more information.\n", argv[0]); - gUsageRequested = true; + sUsageRequested = true; PostMessage(B_QUIT_REQUESTED); } gTermPref->setInt32(PREF_COLS, width); gTermPref->setInt32(PREF_ROWS, height); fTermFrame.Set(xpos, ypos, xpos + 50, ypos + 50); - gGeometryRequested = true; - } + sGeometryRequested = true; + } -#if 0 - // Open '/etc/rgb.txt' file - BFile inFile; - off_t size = 0; - - status_t status = inFile.SetTo("/etc/rgb.txt", B_READ_ONLY); - if (status != B_OK) { - fprintf(stderr, "%s: Can't open /etc/rgb.txt file.\n", argv[0]); - gUsageRequested = true; - PostMessage(B_QUIT_REQUESTED); - } - - inFile.GetSize(&size); - char *buffer = new char [size]; - inFile.Read(buffer, size); - - // Set window, cursor, area and IM color - for (int i = 4; i < 13; i++) { - if (argmatch(argv, argc, standard_args[i].name, standard_args[i].longname, - 9, &value, &skip_args)) { - rgb_color color; - if (text_to_rgb(value, &color, buffer)) - gTermPref->setRGB(standard_args[i].prefname, color); - else - fprintf(stderr, "%s: invalid color string -- %s\n", argv[0], value); - } - } - - delete[] buffer; -#endif skip_args++; if (skip_args < argc) { @@ -282,14 +240,14 @@ if (*argv[skip_args] == '-') { fprintf(stderr, "%s: invalid option `%s'\n", argv[0], argv[skip_args]); fprintf(stderr, "Try `%s --help' for more information.\n", argv[0]); - gUsageRequested = true; + sUsageRequested = true; PostMessage(B_QUIT_REQUESTED); } - CommandLine += argv[skip_args++]; + fCommandLine += argv[skip_args++]; while (skip_args < argc) { - CommandLine += ' '; - CommandLine += argv[skip_args++]; + fCommandLine += ' '; + fCommandLine += argv[skip_args++]; } } } @@ -336,8 +294,8 @@ TermApp::_MakeTermWindow(BRect &frame) { const char *command = NULL; - if (CommandLine.Length() > 0) - command = CommandLine.String(); + if (fCommandLine.Length() > 0) + command = fCommandLine.String(); else command = gTermPref->getString(PREF_SHELL); @@ -625,55 +583,10 @@ " -t, --title set window title\n" " -geom, --geometry set window geometry\n" " An example of geometry is \"80x25+100+100\"\n"); -#if 0 - fprintf(stderr, " -fg, --text-fore-color set window foreground color\n" - " -bg, --text-back-color set window background color\n" - " -curfg, --cursor-fore-color set cursor foreground color\n" - " -curbg, --cursor-back-color set cursor background color\n" - " -selfg, --select-fore-color set selection area foreground color\n" - " -selbg, --select-back-color set selection area background color\n" - " Examples of color are \"#FF00FF\" and \"purple\"\n"); -#endif } -int -text_to_rgb(char *name, rgb_color *color, char *buffer) -{ - if (name[0] != '#') { - // Convert from /etc/rgb.txt. - BString inStr(buffer); - int32 point, offset = 0; - // Search color name - do { - point = inStr.FindFirst(name, offset); - if (point < 0) - return false; - offset = point + 1; - } while(*(buffer + point -1) != '\t'); - - char *p = buffer + point; - while (*p != '\n') - p--; - p++; - - if (sscanf(p, "%d %d %d", (int *)&color->red, (int *)&color->green, - (int *)&color->blue) == EOF) - return false; - - color->alpha = 0; - } else if (name[0] == '#') { - // Convert from #RRGGBB format - sscanf(name, "#%2x%2x%2x", (int *)&color->red, (int *)&color->green, - (int *)&color->blue); - color->alpha = 0; - } else - return false; - - return true; -} - // This routine copy from GNU Emacs. // TODO: This might be a GPL licensing issue here. Investigate. int Modified: haiku/trunk/src/apps/terminal/TermApp.h =================================================================== --- haiku/trunk/src/apps/terminal/TermApp.h 2007-07-13 09:33:17 UTC (rev 21595) +++ haiku/trunk/src/apps/terminal/TermApp.h 2007-07-13 10:38:58 UTC (rev 21596) @@ -39,7 +39,6 @@ class TermWindow; class TermParse; class BRect; -class AboutDlg; class TermApp : public BApplication { public: @@ -68,17 +67,13 @@ void _Usage(char *name); - port_id fRegistrationPort; - int32 fRows, fCols, fXpos, fYpos; bool fStartFullscreen; BString fWindowTitle; int32 fWindowNumber; - rgb_color fFg, fBg, fCurFg, fCurBg, fSelFg, fSelbg; - rgb_color fImfg, fImbg, fImSel; + TermWindow* fTermWindow; - TermParse* fTermParse; BRect fTermFrame; - BString CommandLine; + BString fCommandLine; }; #endif // TERM_APP_H Modified: haiku/trunk/src/apps/terminal/spawn.cpp =================================================================== --- haiku/trunk/src/apps/terminal/spawn.cpp 2007-07-13 09:33:17 UTC (rev 21595) +++ haiku/trunk/src/apps/terminal/spawn.cpp 2007-07-13 10:38:58 UTC (rev 21596) @@ -76,7 +76,7 @@ /* found it */ if (overwrite) { environ[envindex] = (char *)malloc((unsigned)len + val_len + 2); - sprintf(environ[envindex], "%s=%s", var, value); + snprintf(environ[envindex], "%s=%s", var, value); } return 0; } @@ -133,10 +133,6 @@ int spawn_shell(int row, int col, const char *command, const char *coding) { - struct winsize ws; - - handshake_t handshake; - signal(SIGTTOU, SIG_IGN); /* @@ -144,7 +140,7 @@ * directory. The oparationg system will not allow us to open a master * which is already in use, so we simply go until the open succeeds. */ - char tty_name[B_PATH_NAME_LENGTH]; + char ttyName[B_PATH_NAME_LENGTH]; int master = -1; DIR *dir = opendir("/dev/pt/"); if (dir != NULL) { @@ -155,12 +151,12 @@ continue; char ptyName[B_PATH_NAME_LENGTH]; - sprintf(ptyName, "/dev/pt/%s", dirEntry->d_name); + snprintf(ptyName, sizeof(ptyName), "/dev/pt/%s", dirEntry->d_name); master = open(ptyName, O_RDWR); if (master >= 0) { // Set the tty that corresponds to the pty we found - sprintf(tty_name, "/dev/tt/%s", dirEntry->d_name); + snprintf(ttyName, sizeof(ttyName), "/dev/tt/%s", dirEntry->d_name); break; } else { // B_BUSY is a normal case @@ -172,8 +168,8 @@ } if (master < 0) { - printf("didn't find any available pesudo ttys."); - return -1; + printf("didn't find any available pseudo ttys."); + return -1; } /* @@ -189,6 +185,9 @@ return -1; } + + handshake_t handshake; + if (gShPid == 0) { // Now in child process. @@ -207,15 +206,15 @@ } /* change pty owner and access mode. */ - chown(tty_name, getuid(), getgid()); - chmod(tty_name, S_IRUSR | S_IWUSR); + chown(ttyName, getuid(), getgid()); + chmod(ttyName, S_IRUSR | S_IWUSR); /* open slave pty */ int slave = -1; - if ((slave = open(tty_name, O_RDWR)) < 0) { + if ((slave = open(ttyName, O_RDWR)) < 0) { handshake.status = PTY_NG; snprintf(handshake.msg, sizeof(handshake.msg), - "can't open tty (%s).", tty_name); + "can't open tty (%s).", ttyName); send_handshake_message(terminalThread, handshake); exit(1); } @@ -323,6 +322,8 @@ exit(1); } + struct winsize ws; + ws.ws_row = handshake.row; ws.ws_col = handshake.col; @@ -351,7 +352,7 @@ * setenv TERM and TTY. */ setenv("TERM", "beterm", true); - setenv("TTY", tty_name, true); + setenv("TTY", ttyName, true); setenv("TTYPE", coding, true); /* From jackburton at mail.berlios.de Fri Jul 13 13:28:00 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Fri, 13 Jul 2007 13:28:00 +0200 Subject: [Haiku-commits] r21597 - haiku/trunk/src/apps/terminal Message-ID: <200707131128.l6DBS0xR003583@sheep.berlios.de> Author: jackburton Date: 2007-07-13 13:27:59 +0200 (Fri, 13 Jul 2007) New Revision: 21597 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21597&view=rev Modified: haiku/trunk/src/apps/terminal/TermApp.cpp haiku/trunk/src/apps/terminal/TermWindow.cpp haiku/trunk/src/apps/terminal/TermWindow.h Log: Moved spawning the shell from TermApp to TermWindow Modified: haiku/trunk/src/apps/terminal/TermApp.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-13 10:38:58 UTC (rev 21596) +++ haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-13 11:27:59 UTC (rev 21597) @@ -37,7 +37,6 @@ static bool sUsageRequested = false; static bool sGeometryRequested = false; -static bool sColorRequested = false; struct standard_args { char *name; @@ -102,6 +101,7 @@ status_t status = _MakeTermWindow(fTermFrame); // failed spawn, print stdout and open alert panel + // TODO: This alert does never show up. if (status < B_OK) { (new BAlert("alert", "Terminal couldn't start the shell. Sorry.", "ok", NULL, NULL, B_WIDTH_FROM_LABEL, @@ -298,22 +298,15 @@ command = fCommandLine.String(); else command = gTermPref->getString(PREF_SHELL); - - int rows = gTermPref->getInt32(PREF_ROWS); - if (rows < 1) - gTermPref->setInt32(PREF_ROWS, rows = 1); - int cols = gTermPref->getInt32(PREF_COLS); - if (cols < MIN_COLS) - gTermPref->setInt32(PREF_COLS, cols = MIN_COLS); + try { + fTermWindow = new TermWindow(frame, fWindowTitle.String(), command); + } catch (int error) { + return (status_t)error; + } catch (...) { + return B_ERROR; + } - // Get encoding name (setenv TTYPE in spawn_shell functions) - const char *encoding = longname2shortname(gTermPref->getString(PREF_TEXT_ENCODING)); - int pfd = spawn_shell(rows, cols, command, encoding); - if (pfd < 0) - return pfd; - - fTermWindow = new TermWindow(frame, fWindowTitle.String(), pfd); fTermWindow->Show(); return B_OK; Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-13 10:38:58 UTC (rev 21596) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-13 11:27:59 UTC (rev 21597) @@ -54,15 +54,53 @@ //#define CHLP_FILE "file:///boot/beos/documentation/Shell%20Tools/index.html" -TermWindow::TermWindow(BRect frame, const char* title, int fd) +TermWindow::TermWindow(BRect frame, const char* title, const char *command) : BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE), - fPfd(fd) + fPfd(-1), + fTermParse(NULL), + fMenubar(NULL), + fFilemenu(NULL), + fEditmenu(NULL), + fEncodingmenu(NULL), + fHelpmenu(NULL), + fFontMenu(NULL), + fWindowSizeMenu(NULL), + fNewFontMenu(NULL), + fTermView(NULL), + fBaseView(NULL), + fCodeConv(NULL), + fPrintSettings(NULL), + fPrefWindow(NULL), + fFindPanel(NULL), + fWindowUpdate(NULL), + fSavedFrame(0, 0, 0, 0), + fFindString(""), + fFindForwardMenuItem(NULL), + fFindBackwardMenuItem(NULL), + fFindSelection(false), + fForwardSearch(false), + fMatchCase(false), + fMatchWord(false) { + int rows = gTermPref->getInt32(PREF_ROWS); + if (rows < 1) { + rows = 1; + gTermPref->setInt32(PREF_ROWS, rows); + } + + int cols = gTermPref->getInt32(PREF_COLS); + if (cols < MIN_COLS) { + cols = MIN_COLS; + gTermPref->setInt32(PREF_COLS, cols); + } + + // Get encoding name (setenv TTYPE in spawn_shell functions) + const char *encoding = longname2shortname(gTermPref->getString(PREF_TEXT_ENCODING)); + fPfd = spawn_shell(rows, cols, command, encoding); + if (fPfd < 0) + throw fPfd; + InitWindow(); - - fPrintSettings = NULL; - fPrefWindow = NULL; - fFindPanel = NULL; } @@ -87,9 +125,8 @@ /** Initialize Window object. */ - void -TermWindow::InitWindow(void) +TermWindow::InitWindow() { // make menu bar SetupMenu(); @@ -584,7 +621,7 @@ // Dispatch Mesasge. //////////////////////////////////////////////////////////////////////////// void -TermWindow::WindowActivated (bool ) +TermWindow::WindowActivated(bool) { } Modified: haiku/trunk/src/apps/terminal/TermWindow.h =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-13 10:38:58 UTC (rev 21596) +++ haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-13 11:27:59 UTC (rev 21597) @@ -49,7 +49,7 @@ class TermWindow : public BWindow { public: - TermWindow(BRect frame, const char* title, int fd); + TermWindow(BRect frame, const char* title, const char *command); virtual ~TermWindow(); void TermWinActivate(); From axeld at pinc-software.de Fri Jul 13 13:44:17 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Fri, 13 Jul 2007 13:44:17 +0200 CEST Subject: [Haiku-commits] r21597 - haiku/trunk/src/apps/terminal In-Reply-To: <200707131128.l6DBS0xR003583@sheep.berlios.de> Message-ID: <10486129796-BeMail@zon> jackburton at BerliOS wrote: > + if (fPfd < 0) > + throw fPfd; Ah, Jerome's favourite: you should throw "errno" here if you want to return the actual error code :-) Bye, Axel. From stefano.ceccherini at gmail.com Fri Jul 13 13:46:11 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Fri, 13 Jul 2007 13:46:11 +0200 Subject: [Haiku-commits] r21597 - haiku/trunk/src/apps/terminal In-Reply-To: <10486129796-BeMail@zon> References: <200707131128.l6DBS0xR003583@sheep.berlios.de> <10486129796-BeMail@zon> Message-ID: <894b9700707130446q11e92f92x98673146bb91467b@mail.gmail.com> 2007/7/13, Axel D?rfler : > jackburton at BerliOS wrote: > > + if (fPfd < 0) > > + throw fPfd; > > Ah, Jerome's favourite: you should throw "errno" here if you want to > return the actual error code :-) Actually, spawn_shell() already returns errno on error. Although we may want to change that :) From axeld at pinc-software.de Fri Jul 13 20:07:43 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Fri, 13 Jul 2007 20:07:43 +0200 CEST Subject: [Haiku-commits] r21597 - haiku/trunk/src/apps/terminal In-Reply-To: <894b9700707130446q11e92f92x98673146bb91467b@mail.gmail.com> Message-ID: <33492125921-BeMail@zon> "Stefano Ceccherini" wrote: > 2007/7/13, Axel D?rfler : > > jackburton at BerliOS wrote: > > > + if (fPfd < 0) > > > + throw fPfd; > > Ah, Jerome's favourite: you should throw "errno" here if you want > > to > > return the actual error code :-) > Actually, spawn_shell() already returns errno on error. Although we > may want to change that :) No, why should we? Anyway, sorry for bothering :-) Bye, Axel. From mmu_man at mail.berlios.de Sat Jul 14 11:26:22 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sat, 14 Jul 2007 11:26:22 +0200 Subject: [Haiku-commits] r21598 - haiku/trunk/headers/os Message-ID: <200707140926.l6E9QMJl010577@sheep.berlios.de> Author: mmu_man Date: 2007-07-14 11:26:22 +0200 (Sat, 14 Jul 2007) New Revision: 21598 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21598&view=rev Modified: haiku/trunk/headers/os/NetworkKit.h Log: Official place for socket.h is sys/ Modified: haiku/trunk/headers/os/NetworkKit.h =================================================================== --- haiku/trunk/headers/os/NetworkKit.h 2007-07-13 11:27:59 UTC (rev 21597) +++ haiku/trunk/headers/os/NetworkKit.h 2007-07-14 09:26:22 UTC (rev 21598) @@ -2,7 +2,7 @@ * Master include file for the Network Kit. * */ -#include +#include #include #include #include From mmu_man at mail.berlios.de Sat Jul 14 11:37:58 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sat, 14 Jul 2007 11:37:58 +0200 Subject: [Haiku-commits] r21599 - haiku/trunk/build/jam Message-ID: <200707140937.l6E9bwDQ011157@sheep.berlios.de> Author: mmu_man Date: 2007-07-14 11:37:58 +0200 (Sat, 14 Jul 2007) New Revision: 21599 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21599&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: Add CodyCam to the image Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-07-14 09:26:22 UTC (rev 21598) +++ haiku/trunk/build/jam/HaikuImage 2007-07-14 09:37:58 UTC (rev 21599) @@ -46,7 +46,7 @@ ; -BEOS_APPS = AboutSystem DeskCalc DiskProbe CDPlayer Expander Icon-O-Matic +BEOS_APPS = AboutSystem CodyCam DeskCalc DiskProbe CDPlayer Expander Icon-O-Matic Installer LaunchBox Magnify Mail MediaPlayer MidiPlayer NetworkStatus People PowerStatus ProcessController ShowImage SoundRecorder StyledEdit Terminal TV Workspaces From emitrax at gmail.com Sat Jul 14 11:55:08 2007 From: emitrax at gmail.com (Salvatore Benedetto) Date: Sat, 14 Jul 2007 11:55:08 +0200 Subject: [Haiku-commits] r21599 - haiku/trunk/build/jam In-Reply-To: <200707140937.l6E9bwDQ011157@sheep.berlios.de> References: <200707140937.l6E9bwDQ011157@sheep.berlios.de> Message-ID: The entry in the apps menu would also be nice :) On 7/14/07, mmu_man at BerliOS wrote: > > Author: mmu_man > Date: 2007-07-14 11:37:58 +0200 (Sat, 14 Jul 2007) > New Revision: 21599 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21599&view=rev > > Modified: > haiku/trunk/build/jam/HaikuImage > Log: > Add CodyCam to the image > > > Modified: haiku/trunk/build/jam/HaikuImage > =================================================================== > --- haiku/trunk/build/jam/HaikuImage 2007-07-14 09:26:22 UTC (rev > 21598) > +++ haiku/trunk/build/jam/HaikuImage 2007-07-14 09:37:58 UTC (rev > 21599) > @@ -46,7 +46,7 @@ > ; > > > -BEOS_APPS = AboutSystem DeskCalc DiskProbe CDPlayer Expander Icon-O-Matic > +BEOS_APPS = AboutSystem CodyCam DeskCalc DiskProbe CDPlayer Expander > Icon-O-Matic > Installer LaunchBox Magnify Mail MediaPlayer MidiPlayer > NetworkStatus > People PowerStatus ProcessController ShowImage SoundRecorder > StyledEdit > Terminal TV Workspaces > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > -- Salvatore Benedetto (a.k.a. emitrax) Student of Computer and Telecommunications Engineering University of Messina (Italy) www.messinalug.org Siti di vera informazione Italiana www.beppegrillo.it Please do not send me any word, excel or power point file http://www.gnu.org/philosophy/no-word-attachments.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From korli at mail.berlios.de Sat Jul 14 13:41:10 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Sat, 14 Jul 2007 13:41:10 +0200 Subject: [Haiku-commits] r21600 - haiku/trunk/build/jam Message-ID: <200707141141.l6EBfAFH032061@sheep.berlios.de> Author: korli Date: 2007-07-14 13:41:09 +0200 (Sat, 14 Jul 2007) New Revision: 21600 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21600&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: added CodyCam to the menu Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-07-14 09:37:58 UTC (rev 21599) +++ haiku/trunk/build/jam/HaikuImage 2007-07-14 11:41:09 UTC (rev 21600) @@ -191,6 +191,8 @@ # Deskbar Application links AddDirectoryToHaikuImage home config be Applications ; AddSymlinkToHaikuImage home config be Applications + : /boot/beos/apps/CodyCam : CodyCam ; +AddSymlinkToHaikuImage home config be Applications : /boot/beos/apps/CDPlayer : CDPlayer ; AddSymlinkToHaikuImage home config be Applications : /boot/beos/apps/DeskCalc : DeskCalc ; From korli at mail.berlios.de Sat Jul 14 16:16:14 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Sat, 14 Jul 2007 16:16:14 +0200 Subject: [Haiku-commits] r21601 - in haiku/trunk: headers/private src/add-ons/kernel/bus_managers src/add-ons/kernel/drivers/bus src/bin Message-ID: <200707141416.l6EEGEG9007421@sheep.berlios.de> Author: korli Date: 2007-07-14 16:16:14 +0200 (Sat, 14 Jul 2007) New Revision: 21601 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21601&view=rev Added: haiku/trunk/headers/private/firewire/ haiku/trunk/src/add-ons/kernel/bus_managers/firewire/ haiku/trunk/src/add-ons/kernel/drivers/bus/firewire/ haiku/trunk/src/bin/fwcontrol/ Log: added directories to hold firewire sources (on behalf of absabs) From bonefish at mail.berlios.de Sun Jul 15 02:04:28 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 15 Jul 2007 02:04:28 +0200 Subject: [Haiku-commits] r21602 - in haiku/trunk: build/jam src/tools Message-ID: <200707150004.l6F04SHx030681@sheep.berlios.de> Author: bonefish Date: 2007-07-15 02:04:27 +0200 (Sun, 15 Jul 2007) New Revision: 21602 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21602&view=rev Added: haiku/trunk/src/tools/data_to_source.cpp Modified: haiku/trunk/build/jam/FileRules haiku/trunk/src/tools/Jamfile Log: Added small tool source_to_data, which takes an arbitrary data file and generates a C source file defining an array variable containing the file's data. DataFileToSourceFile is the respective jam rule. The idea is to directly built the boot archive into the boot loader for network booting (and thus avoiding to download it from somewhere). In case of PXE this doesn't work, though, due to restrictions to the size of the NBP. Maybe Open Firmware is less restrictive. Modified: haiku/trunk/build/jam/FileRules =================================================================== --- haiku/trunk/build/jam/FileRules 2007-07-14 14:16:14 UTC (rev 21601) +++ haiku/trunk/build/jam/FileRules 2007-07-15 00:04:27 UTC (rev 21602) @@ -253,3 +253,23 @@ $(2[2]) $(1) ${revision} } +rule DataFileToSourceFile sourceFile : dataFile : dataVariable : sizeVariable +{ + sourceFile = [ FGristFiles $(sourceFile) ] ; + MakeLocateCommonPlatform $(sourceFile) ; + + sizeVariable ?= $(dataVariable)Size ; + + DATA_VARIABLE on $(sourceFile) = $(dataVariable) ; + SIZE_VARIABLE on $(sourceFile) = $(sizeVariable) ; + + Depends $(sourceFile) : data_to_source $(dataFile) ; + DataFileToSourceFile1 $(sourceFile) : data_to_source $(dataFile) ; + LocalClean clean : $(sourceFile) ; +} + +actions DataFileToSourceFile1 +{ + $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) + $(2[1]) $(DATA_VARIABLE) $(SIZE_VARIABLE) $(2[2]) $(1) +} Modified: haiku/trunk/src/tools/Jamfile =================================================================== --- haiku/trunk/src/tools/Jamfile 2007-07-14 14:16:14 UTC (rev 21601) +++ haiku/trunk/src/tools/Jamfile 2007-07-15 00:04:27 UTC (rev 21602) @@ -30,6 +30,9 @@ BuildPlatformMain copyattr : copyattr.cpp : $(HOST_LIBBE) $(HOST_LIBSTDC++) $(HOST_LIBSUPC++) ; +BuildPlatformMain data_to_source : data_to_source.cpp + : $(HOST_LIBSUPC++) ; + BuildPlatformMain listattr : listattr.cpp : $(HOST_LIBBE) ; if $(HOST_PLATFORM_BEOS_COMPATIBLE) { Added: haiku/trunk/src/tools/data_to_source.cpp =================================================================== --- haiku/trunk/src/tools/data_to_source.cpp 2007-07-14 14:16:14 UTC (rev 21601) +++ haiku/trunk/src/tools/data_to_source.cpp 2007-07-15 00:04:27 UTC (rev 21602) @@ -0,0 +1,119 @@ +/* + * Copyright 2007, Ingo Weinhold . + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include +#include +#include +#include +#include +#include + + +void +write_string(int fd, const char* data) +{ + int len = strlen(data); + if (len == 0) + return; + + ssize_t written = write(fd, data, len); + if (written < 0) { + fprintf(stderr, "Error: Failed to write to output file: %s\n", + strerror(errno)); + exit(1); + } +} + + +int +main(int argc, const char* const* argv) +{ + if (argc != 5) { + fprintf(stderr, + "Usage: %s \n", + argv[0]); + exit(1); + } + const char* dataVarName = argv[1]; + const char* sizeVarName = argv[2]; + const char* inFileName = argv[3]; + const char* outFileName = argv[4]; + + // open files + int inFD = open(inFileName, O_RDONLY); + if (inFD < 0) { + fprintf(stderr, "Error: Failed to open input file \"%s\": %s\n", + inFileName, strerror(errno)); + exit(1); + } + + int outFD = open(outFileName, O_WRONLY | O_CREAT | O_TRUNC, + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + if (outFD < 0) { + fprintf(stderr, "Error: Failed to open output file \"%s\": %s\n", + outFileName, strerror(errno)); + exit(1); + } + + const int kCharsPerLine = 15; + const int kBufferSize = 16 * 1024; + unsigned char buffer[kBufferSize]; + char lineBuffer[128]; + + sprintf(lineBuffer, "unsigned char %s[] = {\n", dataVarName); + write_string(outFD, lineBuffer); + + off_t dataSize = 0; + off_t offset = 0; + char* lineBufferEnd = lineBuffer; + *lineBufferEnd = '\0'; + while (true) { + // read a buffer + ssize_t bytesRead = read(inFD, buffer, kBufferSize); + if (bytesRead < 0) { + fprintf(stderr, "Error: Failed to read from input file: %s\n", + strerror(errno)); + exit(1); + } + if (bytesRead == 0) + break; + + dataSize += bytesRead; + + // write lines + for (int i = 0; i < bytesRead; i++, offset++) { + if (offset % kCharsPerLine == 0) { + if (offset > 0) { + // line is full -- flush it + strcpy(lineBufferEnd, ",\n"); + write_string(outFD, lineBuffer); + lineBufferEnd = lineBuffer; + *lineBufferEnd = '\0'; + } + + sprintf(lineBufferEnd, "\t%u", (unsigned)buffer[i]); + } else + sprintf(lineBufferEnd, ", %u", (unsigned)buffer[i]); + + lineBufferEnd += strlen(lineBufferEnd); + } + } + + // flush the line buffer + if (lineBufferEnd != lineBuffer) { + strcpy(lineBufferEnd, ",\n"); + write_string(outFD, lineBuffer); + } + + // close the braces and write the size variable + sprintf(lineBuffer, "};\nlong long %s = %lldLL;\n", sizeVarName, + dataSize); + write_string(outFD, lineBuffer); + + close(inFD); + close(outFD); + + return 0; +} From bonefish at mail.berlios.de Sun Jul 15 02:13:16 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 15 Jul 2007 02:13:16 +0200 Subject: [Haiku-commits] r21603 - in haiku/trunk/src/add-ons/kernel/drivers/disk/virtual: . remote_disk Message-ID: <200707150013.l6F0DGEE032348@sheep.berlios.de> Author: bonefish Date: 2007-07-15 02:13:14 +0200 (Sun, 15 Jul 2007) New Revision: 21603 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21603&view=rev Added: haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/ haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/Jamfile haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.cpp haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.h haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/remote_disk.cpp Log: Kernel driver my home-brewn remote disk protocol. I actually intended to remove it completely, but I had no luck with the NBD driver. :-/ Added: haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/Jamfile 2007-07-15 00:04:27 UTC (rev 21602) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/Jamfile 2007-07-15 00:13:14 UTC (rev 21603) @@ -0,0 +1,12 @@ +SubDir HAIKU_TOP src add-ons kernel drivers disk virtual remote_disk ; + +UsePrivateHeaders kernel ; +UseArchHeaders $(TARGET_ARCH) ; +UsePrivateHeaders [ FDirName kernel boot platform $(TARGET_BOOT_PLATFORM) ] ; + # TODO: Ugly! + +KernelAddon remote_disk : + remote_disk.cpp + + RemoteDisk.cpp +; Copied: haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.cpp (from rev 21590, haiku/trunk/src/system/boot/loader/net/RemoteDisk.cpp) =================================================================== --- haiku/trunk/src/system/boot/loader/net/RemoteDisk.cpp 2007-07-09 21:41:44 UTC (rev 21590) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.cpp 2007-07-15 00:13:14 UTC (rev 21603) @@ -0,0 +1,404 @@ +/* + * Copyright 2005-2007, Ingo Weinhold . + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include "RemoteDisk.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include // for IS_USER_ADDRESS() + + +//#define TRACE_REMOTE_DISK +#ifdef TRACE_REMOTE_DISK +# define TRACE(x) dprintf x +#else +# define TRACE(x) do {} while (false) +#endif + + +static const bigtime_t kReceiveTimeout = 30000LL; +static const bigtime_t kRequestTimeout = 100000LL; + +#if __BYTE_ORDER == __LITTLE_ENDIAN + +static inline +uint64_t swap_uint64(uint64_t data) +{ + return ((data & 0xff) << 56) + | ((data & 0xff00) << 40) + | ((data & 0xff0000) << 24) + | ((data & 0xff000000) << 8) + | ((data >> 8) & 0xff000000) + | ((data >> 24) & 0xff0000) + | ((data >> 40) & 0xff00) + | ((data >> 56) & 0xff); +} + +#define host_to_net64(data) swap_uint64(data) +#define net_to_host64(data) swap_uint64(data) + +#endif + +#if __BYTE_ORDER == __BIG_ENDIAN +#define host_to_net64(data) (data) +#define net_to_host64(data) (data) +#endif + +#undef htonll +#undef ntohll +#define htonll(data) host_to_net64(data) +#define ntohll(data) net_to_host64(data) + + +enum { + BUFFER_SIZE = 2048 +}; + + +// constructor +RemoteDisk::RemoteDisk() + : fImageSize(0), + fRequestID(0), + fSocket(-1), + fPacket(NULL), + fPacketSize(0) +{ +} + + +// destructor +RemoteDisk::~RemoteDisk() +{ + if (fSocket >= 0) + close(fSocket); + + free(fPacket); +} + + +// Init +status_t +RemoteDisk::Init(uint32 serverAddress, uint16 serverPort, off_t imageSize) +{ + status_t error = _Init(); + if (error != B_OK) + return error; + + fServerAddress.sin_family = AF_INET; + fServerAddress.sin_port = htons(serverPort); + fServerAddress.sin_addr.s_addr = htonl(serverAddress); + + fImageSize = imageSize; + + return B_OK; +} + + +// FindAnyRemoteDisk +status_t +RemoteDisk::FindAnyRemoteDisk() +{ + status_t error = _Init(); + if (error != B_OK) + return error; + + // prepare request + remote_disk_header request; + request.command = REMOTE_DISK_HELLO_REQUEST; + + // init server address to broadcast + fServerAddress.sin_family = AF_INET; + fServerAddress.sin_port = htons(REMOTE_DISK_SERVER_PORT); + fServerAddress.sin_addr.s_addr = htonl(INADDR_BROADCAST); + + // set SO_BROADCAST on socket + int soBroadcastValue = 1; + if (fSocketModule->setsockopt(fSocket, SOL_SOCKET, SO_BROADCAST, + &soBroadcastValue, sizeof(soBroadcastValue)) < 0) { + dprintf("RemoteDisk::Init(): Failed to set SO_BROADCAST on socket: " + "%s\n", strerror(errno)); + } + + // send request + sockaddr_in serverAddress; + error = _SendRequest(&request, sizeof(request), REMOTE_DISK_HELLO_REPLY, + &serverAddress); + if (error != B_OK) { + dprintf("RemoteDisk::FindAnyRemoteDisk(): Got no server reply.\n"); + return error; + } + remote_disk_header* reply = (remote_disk_header*)fPacket; + + // unset SO_BROADCAST on socket + soBroadcastValue = 0; + if (fSocketModule->setsockopt(fSocket, SOL_SOCKET, SO_BROADCAST, + &soBroadcastValue, sizeof(soBroadcastValue)) < 0) { + dprintf("RemoteDisk::Init(): Failed to unset SO_BROADCAST on socket: " + "%s\n", strerror(errno)); + } + + // init server address and size + fServerAddress = serverAddress; + fServerAddress.sin_port = reply->port; + + fImageSize = ntohll(reply->offset); + + return B_OK; +} + + +// ReadAt +ssize_t +RemoteDisk::ReadAt(off_t pos, void *_buffer, size_t bufferSize) +{ + if (fSocket < 0) + return B_NO_INIT; + + uint8 *buffer = (uint8*)_buffer; + if (!buffer || pos < 0) + return B_BAD_VALUE; + + if (bufferSize == 0) + return 0; + + // Check whether the current packet already contains the beginning of the + // data to read. + ssize_t bytesRead = _ReadFromPacket(pos, buffer, bufferSize); + if (bytesRead < 0) + return bytesRead; + + // If there still remains something to be read, we need to get it from the + // server. + status_t error = B_OK; + while (bufferSize > 0) { + // prepare request + remote_disk_header request; + request.offset = htonll(pos); + uint32 toRead = min_c(bufferSize, REMOTE_DISK_BLOCK_SIZE); + request.size = htons(toRead); + request.command = REMOTE_DISK_READ_REQUEST; + + // send request + error = _SendRequest(&request, sizeof(request), REMOTE_DISK_READ_REPLY); + if (error != B_OK) + break; + + // check for errors + int16 packetSize = ntohs(((remote_disk_header*)fPacket)->size); + if (packetSize < 0) { + if (packetSize == REMOTE_DISK_IO_ERROR) + error = B_IO_ERROR; + else if (packetSize == REMOTE_DISK_BAD_REQUEST) + error = B_BAD_VALUE; + fPacketSize = 0; + break; + } + + // read from the packet + size_t packetBytesRead = _ReadFromPacket(pos, buffer, bufferSize); + if (packetBytesRead <= 0) { + if (packetBytesRead < 0) + error = packetBytesRead; + break; + } + bytesRead += packetBytesRead; + } + + // only return an error, when we were not able to read anything at all + return (bytesRead == 0 ? error : bytesRead); +} + + +// WriteAt +ssize_t +RemoteDisk::WriteAt(off_t pos, const void *buffer, size_t bufferSize) +{ + // TODO: Implement! + return B_PERMISSION_DENIED; +} + + +// _Init +status_t +RemoteDisk::_Init() +{ + // get the socket module + status_t error = get_module(B_SOCKET_MODULE_NAME, + (module_info**)&fSocketModule); + if (error != B_OK) { + dprintf("RemoteDisk::Init(): Failed to load socket module: %s\n", + strerror(error)); + return error; + } + + // open a control socket for playing with the stack + fSocket = fSocketModule->socket(AF_INET, SOCK_DGRAM, 0); + if (fSocket < 0) { + dprintf("RemoteDisk::Init(): Failed to open socket: %s\n", + strerror(errno)); + return errno; + } + + // bind socket + fSocketAddress.sin_family = AF_INET; + fSocketAddress.sin_port = 0; + fSocketAddress.sin_addr.s_addr = INADDR_ANY; + if (fSocketModule->bind(fSocket, (sockaddr*)&fSocketAddress, + sizeof(fSocketAddress)) < 0) { + dprintf("RemoteDisk::Init(): Failed to bind socket: %s\n", + strerror(errno)); + return errno; + } + + // get the port + socklen_t addrSize = sizeof(fSocketAddress); + if (fSocketModule->getsockname(fSocket, (sockaddr*)&fSocketAddress, + &addrSize) < 0) { + dprintf("RemoteDisk::Init(): Failed to get socket address: %s\n", + strerror(errno)); + return errno; + } + + // set receive timeout + timeval timeout; + timeout.tv_sec = time_t(kReceiveTimeout / 1000000LL); + timeout.tv_usec = suseconds_t(kReceiveTimeout % 1000000LL); + if (fSocketModule->setsockopt(fSocket, SOL_SOCKET, SO_RCVTIMEO, &timeout, + sizeof(timeout)) < 0) { + dprintf("RemoteDisk::Init(): Failed to set socket receive timeout: " + "%s\n", strerror(errno)); + return errno; + } + + // allocate buffer + fPacket = malloc(BUFFER_SIZE); + if (!fPacket) + return B_NO_MEMORY; + + return B_OK; +} + + +// _ReadFromPacket +ssize_t +RemoteDisk::_ReadFromPacket(off_t& pos, uint8*& buffer, size_t& bufferSize) +{ + if (fPacketSize == 0) + return 0; + + // check whether the cached packet is indeed a read reply + remote_disk_header* header = (remote_disk_header*)fPacket; + if (header->command != REMOTE_DISK_READ_REPLY) + return 0; + + uint64 packetOffset = ntohll(header->offset); + uint32 packetSize = ntohs(header->size); + if (packetOffset > (uint64)pos || packetOffset + packetSize <= (uint64)pos) + return 0; + + // we have something to copy + size_t toCopy = size_t(packetOffset + packetSize - (uint64)pos); + if (toCopy > bufferSize) + toCopy = bufferSize; + + if (IS_USER_ADDRESS(buffer)) { + status_t error = user_memcpy(buffer, + header->data + (pos - packetOffset), toCopy); + if (error != B_OK) + return error; + } else + memcpy(buffer, header->data + (pos - packetOffset), toCopy); + + pos += toCopy; + buffer += toCopy; + bufferSize -= toCopy; + return toCopy; +} + + +// _SendRequest +status_t +RemoteDisk::_SendRequest(remote_disk_header* request, size_t size, + uint8 expectedReply, sockaddr_in* peerAddress) +{ + request->request_id = fRequestID++; + request->port = fSocketAddress.sin_port; + + // try sending the request 3 times at most + for (int i = 0; i < 3; i++) { + // send request +//bool debug = false; +//{ +//thread_info threadInfo; +//get_thread_info(find_thread(NULL), &threadInfo); +////debug = (strcmp(threadInfo.name, "AddOnMonitor") == 0); +//debug = (find_thread(NULL) >= 60); +//if (debug) { +////panic("RemoteDisk::_SendRequest(): AddOnMonitor\n"); +//TRACE(("[%ld: %s] RemoteDisk::_SendRequest(): sendto(%d, %p, %lu, 0, %p, %lu)\n", +//find_thread(NULL), threadInfo.name, fSocket, request, size, (sockaddr*)&fServerAddress, sizeof(fServerAddress))); +//} +//} + ssize_t bytesSent = fSocketModule->sendto(fSocket, request, size, + 0, (sockaddr*)&fServerAddress, sizeof(fServerAddress)); + if (bytesSent < 0) + return errno; + if (bytesSent != (ssize_t)size) { + dprintf("RemoteDisk::_SendRequest(): sent less bytes than desired"); + return B_ERROR; + } + + // receive reply + bigtime_t timeout = system_time() + kRequestTimeout; + do { + fPacketSize = 0; + socklen_t addrSize = sizeof(sockaddr_in); +//if (debug) { +//TRACE(("[%ld] RemoteDisk::_SendRequest(): recvfrom(%d, %p, %u, 0, %p, %p)\n", +//find_thread(NULL), fSocket, fPacket, BUFFER_SIZE, (sockaddr*)&peerAddress, (peerAddress ? &addrSize : 0))); +//} + ssize_t bytesReceived = fSocketModule->recvfrom(fSocket, + fPacket, BUFFER_SIZE, 0, (sockaddr*)peerAddress, + (peerAddress ? &addrSize : 0)); + if (bytesReceived < 0) { +//if (debug) { +//TRACE(("[%ld] RemoteDisk::_SendRequest(): recvfrom() failed: %s\n", find_thread(NULL), strerror(errno))); +//} + status_t error = errno; + if (error != B_TIMED_OUT && error != B_WOULD_BLOCK) + return error; + continue; + } + + // got something; check, if it is looks good + if (bytesReceived >= (ssize_t)sizeof(remote_disk_header)) { + remote_disk_header* reply = (remote_disk_header*)fPacket; + if (reply->request_id == request->request_id + && reply->command == expectedReply) { + fPacketSize = bytesReceived; +//if (debug) { +//TRACE(("[%ld] RemoteDisk::_SendRequest(): done: packet size: %ld\n", find_thread(NULL), bytesReceived)); +//} + return B_OK; + } + } + } while (timeout > system_time()); + } + + // no reply + return B_ERROR; +} Copied: haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.h (from rev 21590, haiku/trunk/headers/private/kernel/boot/net/RemoteDisk.h) =================================================================== --- haiku/trunk/headers/private/kernel/boot/net/RemoteDisk.h 2007-07-09 21:41:44 UTC (rev 21590) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.h 2007-07-15 00:13:14 UTC (rev 21603) @@ -0,0 +1,65 @@ +/* + * Copyright 2005-2007, Ingo Weinhold . + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#ifndef _BOOT_REMOTE_DISK_H +#define _BOOT_REMOTE_DISK_H + +#include + +#include + +#include + +#include + + +class RemoteDisk { +public: + RemoteDisk(); + ~RemoteDisk(); + + status_t Init(uint32 serverAddress, uint16 serverPort, + off_t imageSize); + + status_t FindAnyRemoteDisk(); + + ssize_t ReadAt(off_t pos, void *buffer, + size_t bufferSize); + ssize_t WriteAt(off_t pos, const void *buffer, + size_t bufferSize); + + off_t Size() const + { return fImageSize; } + + bool IsReadOnly() const + { return true; } // TODO:... + +// uint32 ServerIPAddress() const +// { return fServerAddress; } +// uint16 ServerPort() const +// { return fServerPort; } + +private: + status_t _Init(); + + ssize_t _ReadFromPacket(off_t& pos, uint8*& buffer, + size_t& bufferSize); + + status_t _SendRequest(remote_disk_header *request, + size_t size, uint8 expectedReply, + sockaddr_in* peerAddress = NULL); + +private: + socket_module_info* fSocketModule; + sockaddr_in fSocketAddress; + sockaddr_in fServerAddress; + off_t fImageSize; + uint64 fRequestID; + int fSocket; + void* fPacket; + int32 fPacketSize; +}; + +#endif // _BOOT_REMOTE_DISK_H Added: haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/remote_disk.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/remote_disk.cpp 2007-07-15 00:04:27 UTC (rev 21602) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/remote_disk.cpp 2007-07-15 00:13:14 UTC (rev 21603) @@ -0,0 +1,379 @@ +/* + * Copyright 2007, Ingo Weinhold . + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include + +#include +#include + +#include +#include +#include + +#include "RemoteDisk.h" + + +//#define TRACE_REMOTE_DISK +#ifdef TRACE_REMOTE_DISK +# define TRACE(x) dprintf x +#else +# define TRACE(x) do {} while (false) +#endif + + +const bigtime_t kInitRetryDelay = 10 * 1000000LL; // 10 s + +enum { + MAX_REMOTE_DISKS = 1 +}; + + +struct RemoteDiskDevice : recursive_lock { + RemoteDisk* remoteDisk; + bigtime_t lastInitRetryTime; + + RemoteDiskDevice() + : remoteDisk(NULL), + lastInitRetryTime(-1) + { + sem = -1; + } + + ~RemoteDiskDevice() + { + delete remoteDisk; + Uninit(); + } + + status_t Init() + { + return recursive_lock_init(this, "remote disk device"); + } + + void Uninit() + { + recursive_lock_destroy(this); + } + + status_t LazyInitDisk() + { + if (remoteDisk) + return B_OK; + + // don't try to init, if the last attempt wasn't long enough ago + if (lastInitRetryTime >= 0 + && system_time() < lastInitRetryTime + kInitRetryDelay) { + return B_ERROR; + } + + // create the object + remoteDisk = new(nothrow) RemoteDisk; + if (!remoteDisk) { + lastInitRetryTime = system_time(); + return B_NO_MEMORY; + } + + // find a server + TRACE(("remote_disk: FindAnyRemoteDisk()\n")); + status_t error = remoteDisk->FindAnyRemoteDisk(); + if (error != B_OK) { + delete remoteDisk; + remoteDisk = NULL; + lastInitRetryTime = system_time(); + return B_NO_MEMORY; + } + + return B_OK; + } + + void GetGeometry(device_geometry* geometry, bool bios) + { + // TODO: Respect "bios" argument! + geometry->bytes_per_sector = REMOTE_DISK_BLOCK_SIZE; + geometry->sectors_per_track = 1; + geometry->cylinder_count = remoteDisk->Size() / REMOTE_DISK_BLOCK_SIZE; + geometry->head_count = 1; + geometry->device_type = B_DISK; + geometry->removable = true; + geometry->read_only = remoteDisk->IsReadOnly(); + geometry->write_once = false; + } +}; + +typedef RecursiveLocker DeviceLocker; + + +static const char* kPublishedNames[] = { + "disk/virtual/remote_disk/0/raw", +// "misc/remote_disk_control", + NULL +}; + +static RemoteDiskDevice* sDevices; + + +// #pragma mark - internal functions + + +// device_for_name +static RemoteDiskDevice* +device_for_name(const char* name) +{ + for (int i = 0; i < MAX_REMOTE_DISKS; i++) { + if (strcmp(name, kPublishedNames[i]) == 0) + return sDevices + i; + } + return NULL; +} + + +// #pragma mark - data device hooks + + +static status_t +remote_disk_open(const char* name, uint32 flags, void** cookie) +{ + RemoteDiskDevice* device = device_for_name(name); + TRACE(("remote_disk_open(\"%s\") -> %p\n", name, device)); + if (!device) + return B_BAD_VALUE; + + DeviceLocker locker(device); + status_t error = device->LazyInitDisk(); + if (error != B_OK) + return error; + + *cookie = device; + + return B_OK; +} + + +static status_t +remote_disk_close(void* cookie) +{ + TRACE(("remote_disk_close(%p)\n", cookie)); + + // nothing to do + return B_OK; +} + + +static status_t +remote_disk_read(void* cookie, off_t position, void* buffer, size_t* numBytes) +{ + TRACE(("remote_disk_read(%p, %lld, %p, %lu)\n", cookie, position, buffer, + *numBytes)); + + RemoteDiskDevice* device = (RemoteDiskDevice*)cookie; + DeviceLocker locker(device); + + ssize_t bytesRead = device->remoteDisk->ReadAt(position, buffer, *numBytes); + if (bytesRead < 0) { + *numBytes = 0; +TRACE(("remote_disk_read() failed: %s\n", strerror(bytesRead))); + return bytesRead; + } + + *numBytes = bytesRead; +TRACE(("remote_disk_read() done: %ld\n", bytesRead)); + return B_OK; +} + + +static status_t +remote_disk_write(void* cookie, off_t position, const void* buffer, + size_t* numBytes) +{ + TRACE(("remote_disk_write(%p, %lld, %p, %lu)\n", cookie, position, buffer, + *numBytes)); + + RemoteDiskDevice* device = (RemoteDiskDevice*)cookie; + DeviceLocker locker(device); + + ssize_t bytesWritten = device->remoteDisk->WriteAt(position, buffer, + *numBytes); + if (bytesWritten < 0) { + *numBytes = 0; + return bytesWritten; + } + + *numBytes = bytesWritten; + return B_OK; +} + + +static status_t +remote_disk_control(void* cookie, uint32 op, void* arg, size_t len) +{ + TRACE(("remote_disk_control(%p, %lu, %p, %lu)\n", cookie, op, arg, len)); + + RemoteDiskDevice* device = (RemoteDiskDevice*)cookie; + DeviceLocker locker(device); + + // used data device + switch (op) { + case B_GET_DEVICE_SIZE: + TRACE(("remote_disk: B_GET_DEVICE_SIZE\n")); + *(size_t*)arg = device->remoteDisk->Size(); + return B_OK; + + case B_SET_NONBLOCKING_IO: + TRACE(("remote_disk: B_SET_NONBLOCKING_IO\n")); + return B_OK; + + case B_SET_BLOCKING_IO: + TRACE(("remote_disk: B_SET_BLOCKING_IO\n")); + return B_OK; + + case B_GET_READ_STATUS: + TRACE(("remote_disk: B_GET_READ_STATUS\n")); + *(bool*)arg = true; + return B_OK; + + case B_GET_WRITE_STATUS: + TRACE(("remote_disk: B_GET_WRITE_STATUS\n")); + *(bool*)arg = true; + return B_OK; + + case B_GET_ICON: + { + TRACE(("remote_disk: B_GET_ICON\n")); + return B_BAD_VALUE; + } + + case B_GET_GEOMETRY: + TRACE(("remote_disk: B_GET_GEOMETRY\n")); + device->GetGeometry((device_geometry*)arg, false); + return B_OK; + + case B_GET_BIOS_GEOMETRY: + { + TRACE(("remote_disk: B_GET_BIOS_GEOMETRY\n")); + device->GetGeometry((device_geometry*)arg, true); + return B_OK; + } + + case B_GET_MEDIA_STATUS: + TRACE(("remote_disk: B_GET_MEDIA_STATUS\n")); + *(status_t*)arg = B_NO_ERROR; + return B_OK; + + case B_SET_UNINTERRUPTABLE_IO: + TRACE(("remote_disk: B_SET_UNINTERRUPTABLE_IO\n")); + return B_OK; + + case B_SET_INTERRUPTABLE_IO: + TRACE(("remote_disk: B_SET_INTERRUPTABLE_IO\n")); + return B_OK; + + case B_FLUSH_DRIVE_CACHE: + TRACE(("remote_disk: B_FLUSH_DRIVE_CACHE\n")); + return B_OK; + + case B_GET_BIOS_DRIVE_ID: + TRACE(("remote_disk: B_GET_BIOS_DRIVE_ID\n")); + *(uint8*)arg = 0xF8; + return B_OK; + + case B_GET_DRIVER_FOR_DEVICE: + case B_SET_DEVICE_SIZE: + case B_SET_PARTITION: + case B_FORMAT_DEVICE: + case B_EJECT_DEVICE: + case B_LOAD_MEDIA: + case B_GET_NEXT_OPEN_DEVICE: + TRACE(("remote_disk: another ioctl: %lx (%lu)\n", op, op)); + return B_BAD_VALUE; + + default: + TRACE(("remote_disk: unknown ioctl: %lx (%lu)\n", op, op)); + return B_BAD_VALUE; + } +} + + +static status_t +remote_disk_free(void* cookie) +{ + TRACE(("remote_disk_free(%p)\n", cookie)); + + // nothing to do + return B_OK; +} + + +static device_hooks sDataDeviceHooks = { + remote_disk_open, + remote_disk_close, + remote_disk_free, + remote_disk_control, + remote_disk_read, + remote_disk_write +}; + + +// #pragma mark - public API + + +int32 api_version = B_CUR_DRIVER_API_VERSION; + + +status_t +init_hardware(void) +{ + TRACE(("remote_disk: init_hardware()\n")); + + return B_OK; +} + + +status_t +init_driver(void) +{ + TRACE(("remote_disk: init_driver()\n")); + + sDevices = new(nothrow) RemoteDiskDevice[MAX_REMOTE_DISKS]; + if (!sDevices) + return B_NO_MEMORY; + + status_t error = B_OK; + for (int i = 0; error == B_OK && i < MAX_REMOTE_DISKS; i++) + error = sDevices[i].Init(); + + if (error != B_OK) { + delete[] sDevices; + sDevices = NULL; + return error; + } + + return B_OK; +} + + +void +uninit_driver(void) +{ + TRACE(("remote_disk: uninit_driver()\n")); + + delete[] sDevices; +} + + +const char** +publish_devices(void) +{ + TRACE(("remote_disk: publish_devices()\n")); + return kPublishedNames; +} + + +device_hooks* +find_device(const char* name) +{ + TRACE(("remote_disk: find_device(%s)\n", name)); + return &sDataDeviceHooks; +} + From bonefish at mail.berlios.de Sun Jul 15 02:16:01 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 15 Jul 2007 02:16:01 +0200 Subject: [Haiku-commits] r21604 - haiku/trunk/build/jam Message-ID: <200707150016.l6F0G1hU000354@sheep.berlios.de> Author: bonefish Date: 2007-07-15 02:15:54 +0200 (Sun, 15 Jul 2007) New Revision: 21604 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21604&view=rev Modified: haiku/trunk/build/jam/NetBootArchive Log: * Removed stuff not strictly necessary for the net boot (ps2 bus manager, some drivers). * Commented out nbd for the time being and added remote_disk. * Consequent use of boot links. Modified: haiku/trunk/build/jam/NetBootArchive =================================================================== --- haiku/trunk/build/jam/NetBootArchive 2007-07-15 00:13:14 UTC (rev 21603) +++ haiku/trunk/build/jam/NetBootArchive 2007-07-15 00:15:54 UTC (rev 21604) @@ -23,7 +23,7 @@ via-rhine wb840 net_stack vlance $(GPL_ONLY)bcm440x $(GPL_ONLY)bcm570x ; -BEOS_ADD_ONS_BUS_MANAGERS = pci $(X86_ONLY)ps2 $(X86_ONLY)isa ide scsi +BEOS_ADD_ONS_BUS_MANAGERS = pci $(X86_ONLY)isa ide scsi config_manager $(X86_ONLY)agp ; BEOS_ADD_ONS_FILE_SYSTEMS = bfs cdda dos googlefs iso9660 nfs ; @@ -49,10 +49,9 @@ } # drivers -AddDriversToNetBootArchive : console dprintf $(X86_ONLY)keyboard - null random tty zero ; AddDriversToNetBootArchive disk scsi : scsi_cd scsi_dsk ; -AddDriversToNetBootArchive disk virtual : nbd ; +#AddDriversToNetBootArchive disk virtual : nbd ; +AddDriversToNetBootArchive disk virtual : remote_disk ; AddDriversToNetBootArchive net : $(BEOS_ADD_ONS_DRIVERS_NET) ; # kernel @@ -66,13 +65,6 @@ AddFilesToNetBootArchive home config settings kernel drivers : $(driverSettingsFiles) ; -# boot module links -#AddBootModuleSymlinksToNetBootArchive config_manager bfs block_io fast_log -# generic_ide_pci $(X86_ONLY)isa ide ide_adapter $(X86_ONLY)ide_isa intel -# locked_pool $(PPC_ONLY)openpic pci scsi scsi_cd scsi_dsk scsi_periph -# ahci silicon_image_3112 -#; - # add-ons AddFilesToNetBootArchive beos system add-ons kernel network : stack socket ; @@ -85,7 +77,26 @@ AddFilesToNetBootArchive beos system add-ons kernel network protocols : $(BEOS_NETWORK_PROTOCOLS) ; +# boot module links +AddBootModuleSymlinksToNetBootArchive + $(BEOS_ADD_ONS_BUS_MANAGERS) + ahci generic_ide_pci $(X86_ONLY)ide_isa silicon_image_3112 + $(BEOS_ADD_ONS_FILE_SYSTEMS) + block_io fast_log ide_adapter locked_pool mpu401 scsi_periph + intel session + $(PPC_ONLY)openpic + $(X86_ONLY)generic_x86 +# nbd + remote_disk + $(BEOS_ADD_ONS_DRIVERS_NET) + stack socket + $(BEOS_NETWORK_DEVICES) + $(BEOS_NETWORK_DATALINK_PROTOCOLS) + $(BEOS_NETWORK_PPP) + $(BEOS_NETWORK_PROTOCOLS) +; + #pragma mark - Build The Archive # archive target From bonefish at mail.berlios.de Sun Jul 15 02:32:38 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 15 Jul 2007 02:32:38 +0200 Subject: [Haiku-commits] r21605 - in haiku/trunk: headers/private/kernel/util src/system/kernel/messaging Message-ID: <200707150032.l6F0WcMw002058@sheep.berlios.de> Author: bonefish Date: 2007-07-15 02:32:37 +0200 (Sun, 15 Jul 2007) New Revision: 21605 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21605&view=rev Modified: haiku/trunk/headers/private/kernel/util/KMessage.h haiku/trunk/src/system/kernel/messaging/KMessage.cpp Log: * Made header includable by C code. In this case a KMessage structure with the same size as the class is defined. * The SetTo() methods do now accept an unspecified (negative) bufferSize in case of being told to initialize from the given buffer. * Added handy Get*() methods returning a field element value or a supplied default value, if the field element doesn't exist. * Added also handy Set*() methods setting the value of first element of a field, i.e. adding it, if it didn't exist before, otherwise replacing the old value. Only for fixed size types. * Moved _FindType() inline template method into the header. * Made the source file fit for use in the boot loader. If the macro KMESSAGE_CONTAINER_ONLY is defined, the message sending/receiving part is omitted. Modified: haiku/trunk/headers/private/kernel/util/KMessage.h =================================================================== --- haiku/trunk/headers/private/kernel/util/KMessage.h 2007-07-15 00:15:54 UTC (rev 21604) +++ haiku/trunk/headers/private/kernel/util/KMessage.h 2007-07-15 00:32:37 UTC (rev 21605) @@ -11,6 +11,10 @@ #include #include + +#ifdef __cplusplus + + class BMessage; namespace BPrivate { @@ -36,7 +40,7 @@ status_t SetTo(uint32 what, uint32 flags = 0); status_t SetTo(void *buffer, int32 bufferSize, uint32 what, uint32 flags = 0); - status_t SetTo(const void *buffer, int32 bufferSize); + status_t SetTo(const void *buffer, int32 bufferSize = -1); void Unset(); void SetWhat(uint32 what); @@ -82,6 +86,33 @@ inline status_t FindString(const char *name, int32 index, const char **value) const; + inline bool GetBool(const char* name, bool defaultValue) const; + inline bool GetBool(const char* name, int32 index, bool defaultValue) const; + inline int8 GetInt8(const char* name, int8 defaultValue) const; + inline int8 GetInt8(const char* name, int32 index, int8 defaultValue) const; + inline int16 GetInt16(const char* name, int16 defaultValue) const; + inline int16 GetInt16(const char* name, int32 index, + int16 defaultValue) const; + inline int32 GetInt32(const char* name, int32 defaultValue) const; + inline int32 GetInt32(const char* name, int32 index, + int32 defaultValue) const; + inline int64 GetInt64(const char* name, int64 defaultValue) const; + inline int64 GetInt64(const char* name, int32 index, + int64 defaultValue) const; + inline const char* GetString(const char* name, + const char* defaultValue) const; + inline const char* GetString(const char* name, int32 index, + const char* defaultValue) const; + + // fixed size fields only + status_t SetData(const char* name, type_code type, const void* data, + int32 numBytes); + inline status_t SetBool(const char* name, bool value); + inline status_t SetInt8(const char* name, int8 value); + inline status_t SetInt16(const char* name, int16 value); + inline status_t SetInt32(const char* name, int32 value); + inline status_t SetInt64(const char* name, int64 value); + // message delivery team_id Sender() const; int32 TargetToken() const; @@ -129,7 +160,7 @@ status_t _AddFieldData(KMessageField *field, const void *data, int32 elementSize, int32 elementCount); - status_t _InitFromBuffer(); + status_t _InitFromBuffer(bool sizeFromBuffer); void _InitBuffer(uint32 what); void _CheckBuffer(); // debugging only @@ -139,6 +170,8 @@ int32 _CapacityFor(int32 size); template inline status_t _FindType(const char* name, type_code type, int32 index, T *value) const; + template inline T _GetType(const char* name, type_code type, + int32 index, const T& defaultValue) const; Header fHeader; // pointed to by fBuffer, if nothing is // allocated @@ -185,9 +218,10 @@ using BPrivate::KMessage; using BPrivate::KMessageField; -// #pragma mark - -// inline functions +// #pragma mark - inline functions + + // AddBool inline status_t @@ -238,8 +272,30 @@ return AddData(name, B_STRING_TYPE, value, strlen(value) + 1, false); } + // #pragma mark - + +// _FindType +template +inline status_t +KMessage::_FindType(const char* name, type_code type, int32 index, + T *value) const +{ + const void *data; + int32 size; + status_t error = FindData(name, type, index, &data, &size); + if (error != B_OK) + return error; + + if (size != sizeof(T)) + return B_BAD_DATA; + + *value = *(T*)data; + + return B_OK; +} + // FindBool inline status_t @@ -337,4 +393,184 @@ return FindData(name, B_STRING_TYPE, index, (const void**)value, &size); } + +// _GetType +template +inline T +KMessage::_GetType(const char* name, type_code type, int32 index, + const T& defaultValue) const +{ + T value; + if (_FindType(name, type, index, &value) == B_OK) + return value; + return defaultValue; +} + + +// GetBool +inline bool +KMessage::GetBool(const char* name, bool defaultValue) const +{ + return _GetType(name, B_BOOL_TYPE, 0, defaultValue); +} + + +// GetBool +inline bool +KMessage::GetBool(const char* name, int32 index, bool defaultValue) const +{ + return _GetType(name, B_BOOL_TYPE, index, defaultValue); +} + +// GetInt8 +inline int8 +KMessage::GetInt8(const char* name, int8 defaultValue) const +{ + return _GetType(name, B_INT8_TYPE, 0, defaultValue); +} + + +// GetInt8 +inline int8 +KMessage::GetInt8(const char* name, int32 index, int8 defaultValue) const +{ + return _GetType(name, B_INT8_TYPE, index, defaultValue); +} + + +// GetInt16 +inline int16 +KMessage::GetInt16(const char* name, int16 defaultValue) const +{ + return _GetType(name, B_INT16_TYPE, 0, defaultValue); +} + + +// GetInt16 +inline int16 +KMessage::GetInt16(const char* name, int32 index, int16 defaultValue) const +{ + return _GetType(name, B_INT16_TYPE, index, defaultValue); +} + + +// GetInt32 +inline int32 +KMessage::GetInt32(const char* name, int32 defaultValue) const +{ + return _GetType(name, B_INT32_TYPE, 0, defaultValue); +} + + +// GetInt32 +inline int32 +KMessage::GetInt32(const char* name, int32 index, int32 defaultValue) const +{ + return _GetType(name, B_INT32_TYPE, index, defaultValue); +} + + +// GetInt64 +inline int64 +KMessage::GetInt64(const char* name, int64 defaultValue) const +{ + return _GetType(name, B_INT64_TYPE, 0, defaultValue); +} + + +// GetInt64 +inline int64 +KMessage::GetInt64(const char* name, int32 index, int64 defaultValue) const +{ + return _GetType(name, B_INT64_TYPE, index, defaultValue); +} + + +// GetString +inline const char* +KMessage::GetString(const char* name, int32 index, + const char* defaultValue) const +{ + // don't use _GetType() here, since it checks field size == sizeof(T) + int32 size; + const char* value; + if (FindData(name, B_STRING_TYPE, index, (const void**)&value, &size) + == B_OK) { + return value; + } + return defaultValue; +} + + +// GetString +inline const char* +KMessage::GetString(const char* name, const char* defaultValue) const +{ + return GetString(name, 0, defaultValue); +} + + +// SetBool +inline status_t +KMessage::SetBool(const char* name, bool value) +{ + return SetData(name, B_BOOL_TYPE, &value, sizeof(bool)); +} + + +// SetInt8 +inline status_t +KMessage::SetInt8(const char* name, int8 value) +{ + return SetData(name, B_INT8_TYPE, &value, sizeof(int8)); +} + + +// SetInt16 +inline status_t +KMessage::SetInt16(const char* name, int16 value) +{ + return SetData(name, B_INT16_TYPE, &value, sizeof(int16)); +} + + +// SetInt32 +inline status_t +KMessage::SetInt32(const char* name, int32 value) +{ + return SetData(name, B_INT32_TYPE, &value, sizeof(int32)); +} + + +// SetInt64 +inline status_t +KMessage::SetInt64(const char* name, int64 value) +{ + return SetData(name, B_INT64_TYPE, &value, sizeof(int64)); +} + + +#else // !__cplusplus + + +typedef struct KMessage { + struct Header { + uint32 magic; + int32 size; + uint32 what; + team_id sender; + int32 targetToken; + port_id replyPort; + int32 replyToken; + } fHeader; + void* fBuffer; + int32 fBufferCapacity; + uint32 fFlags; + int32 fLastFieldOffset; +} KMessage; + + +#endif // !__cplusplus + + #endif // KMESSAGE_H Modified: haiku/trunk/src/system/kernel/messaging/KMessage.cpp =================================================================== --- haiku/trunk/src/system/kernel/messaging/KMessage.cpp 2007-07-15 00:15:54 UTC (rev 21604) +++ haiku/trunk/src/system/kernel/messaging/KMessage.cpp 2007-07-15 00:32:37 UTC (rev 21605) @@ -1,8 +1,10 @@ /* - * Copyright 2005, Ingo Weinhold, bonefish at users.sf.net. All rights reserved. - * Distributed under the terms of the MIT License. + * Copyright 2005-2007, Ingo Weinhold, bonefish at users.sf.net. + * All rights reserved. Distributed under the terms of the MIT License. */ +#include "KMessage.h" + #include #include @@ -10,8 +12,14 @@ #include #include -#include "KMessage.h" +#if defined(_BOOT_MODE) +# include +#else +# include +#endif +using std::nothrow; + // TODO: Add a field index using a hash map, so that lookup improves to O(1) // (is now O(n)). @@ -141,21 +149,33 @@ KMessage::SetTo(void *buffer, int32 bufferSize, uint32 what, uint32 flags) { Unset(); - if (!buffer || bufferSize < (int)sizeof(Header)) + + if (!buffer) return B_BAD_VALUE; + + if (bufferSize < 0) { + if (!(flags & KMESSAGE_INIT_FROM_BUFFER)) + return B_BAD_VALUE; + } else if (bufferSize < (int)sizeof(Header)) + return B_BAD_VALUE; + // if read-only, we need to init from the buffer, too if (flags & KMESSAGE_READ_ONLY && !(flags & KMESSAGE_INIT_FROM_BUFFER)) return B_BAD_VALUE; + fBuffer = buffer; fBufferCapacity = bufferSize; fFlags = flags; + status_t error = B_OK; if (flags & KMESSAGE_INIT_FROM_BUFFER) - error = _InitFromBuffer(); + error = _InitFromBuffer(bufferSize < 0); else _InitBuffer(what); + if (error != B_OK) Unset(); + return error; } @@ -325,6 +345,42 @@ return _AddFieldData(&field, data, elementSize, elementCount); } + +// SetData +status_t +KMessage::SetData(const char* name, type_code type, const void* data, + int32 numBytes) +{ + if (fBuffer != &fHeader && (fFlags & KMESSAGE_READ_ONLY)) + return B_NOT_ALLOWED; + + KMessageField field; + + if (FindField(name, &field) == B_OK) { + // field already known + if (field.TypeCode() != type || !field.HasFixedElementSize() + || field.ElementSize() != numBytes) { + return B_BAD_VALUE; + } + + // if it has an element, just replace its value + if (field.CountElements() > 0) { + const void* element = field.ElementAt(0); + memcpy(const_cast(element), data, numBytes); + return B_OK; + } + } else { + // no such field yet -- add it + status_t error = _AddField(name, type, numBytes, &field); + if (error != B_OK) + return error; + } + + // we've got an empty field -- add the element + return _AddFieldData(&field, data, numBytes, 1); +} + + // FindData status_t KMessage::FindData(const char *name, type_code type, const void **data, @@ -380,6 +436,9 @@ return _Header()->replyToken; } + +#ifndef KMESSAGE_CONTAINER_ONLY + // SendTo status_t KMessage::SendTo(port_id targetPort, int32 targetToken, port_id replyPort, @@ -512,6 +571,9 @@ KMESSAGE_OWNS_BUFFER | KMESSAGE_INIT_FROM_BUFFER); } +#endif // !KMESSAGE_CONTAINER_ONLY + + // _Header KMessage::Header * KMessage::_Header() const @@ -631,18 +693,24 @@ // _InitFromBuffer status_t -KMessage::_InitFromBuffer() +KMessage::_InitFromBuffer(bool sizeFromBuffer) { - if (!fBuffer || fBufferCapacity < (int)sizeof(Header) - || _Align(fBuffer) != fBuffer) { + if (!fBuffer || _Align(fBuffer) != fBuffer) return B_BAD_DATA; - } + Header *header = _Header(); + + if (sizeFromBuffer) + fBufferCapacity = header->size; + + if (fBufferCapacity < (int)sizeof(Header)) + return B_BAD_DATA; + // check header - Header *header = _Header(); if (header->magic != kMessageHeaderMagic) return B_BAD_DATA; if (header->size < (int)sizeof(Header) || header->size > fBufferCapacity) return B_BAD_DATA; + // check the fields FieldHeader *fieldHeader = NULL; uint8 *data = (uint8*)_FirstFieldHeader(); @@ -721,7 +789,7 @@ KMessage::_CheckBuffer() { int32 lastFieldOffset = fLastFieldOffset; - if (_InitFromBuffer() != B_OK) { + if (_InitFromBuffer(false) != B_OK) { PANIC("internal data mangled"); } if (fLastFieldOffset != lastFieldOffset) { @@ -779,25 +847,7 @@ * kMessageReallocChunkSize; } -// _FindType -template -inline -status_t -KMessage::_FindType(const char* name, type_code type, int32 index, - T *value) const -{ - const void *data; - int32 size; - status_t error = FindData(name, type, index, &data, &size); - if (error != B_OK) - return error; - if (size != sizeof(T)) - return B_BAD_DATA; - *value = *(T*)data; - return B_OK; -} - // #pragma mark - // constructor From bonefish at mail.berlios.de Sun Jul 15 02:34:18 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 15 Jul 2007 02:34:18 +0200 Subject: [Haiku-commits] r21606 - in haiku/trunk: headers/private/kernel/fs src/system/kernel/fs Message-ID: <200707150034.l6F0YI24002191@sheep.berlios.de> Author: bonefish Date: 2007-07-15 02:34:17 +0200 (Sun, 15 Jul 2007) New Revision: 21606 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21606&view=rev Modified: haiku/trunk/headers/private/kernel/fs/KPath.h haiku/trunk/src/system/kernel/fs/KPath.cpp Log: Added RemoveLeaf() leaf method. Very handy for recursive directory iteration code using a single KPath object. Modified: haiku/trunk/headers/private/kernel/fs/KPath.h =================================================================== --- haiku/trunk/headers/private/kernel/fs/KPath.h 2007-07-15 00:32:37 UTC (rev 21605) +++ haiku/trunk/headers/private/kernel/fs/KPath.h 2007-07-15 00:34:17 UTC (rev 21606) @@ -35,6 +35,8 @@ const char *Leaf() const; status_t ReplaceLeaf(const char *newLeaf); + bool RemoveLeaf(); + // returns false, if nothing could be removed anymore status_t Append(const char *toAppend, bool isComponent = true); Modified: haiku/trunk/src/system/kernel/fs/KPath.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/KPath.cpp 2007-07-15 00:32:37 UTC (rev 21605) +++ haiku/trunk/src/system/kernel/fs/KPath.cpp 2007-07-15 00:34:17 UTC (rev 21606) @@ -202,6 +202,24 @@ } +bool +KPath::RemoveLeaf() +{ + // get the leaf -- bail out, if not initialized or only the "/" is left + const char *leaf = Leaf(); + if (!leaf || leaf == fBuffer) + return false; + + // chop off the leaf + int32 leafIndex = leaf - fBuffer; + fBuffer[leafIndex] = '\0'; + fPathLength = leafIndex; + _ChopTrailingSlashes(); + + return true; +} + + status_t KPath::Append(const char *component, bool isComponent) { From bonefish at mail.berlios.de Sun Jul 15 02:35:10 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 15 Jul 2007 02:35:10 +0200 Subject: [Haiku-commits] r21607 - haiku/trunk/headers/private/kernel/arch Message-ID: <200707150035.l6F0ZAFL002244@sheep.berlios.de> Author: bonefish Date: 2007-07-15 02:35:10 +0200 (Sun, 15 Jul 2007) New Revision: 21607 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21607&view=rev Modified: haiku/trunk/headers/private/kernel/arch/thread.h Log: Never include anything in an extern "C" block. Modified: haiku/trunk/headers/private/kernel/arch/thread.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/thread.h 2007-07-15 00:34:17 UTC (rev 21606) +++ haiku/trunk/headers/private/kernel/arch/thread.h 2007-07-15 00:35:10 UTC (rev 21607) @@ -41,11 +41,11 @@ void arch_store_fork_frame(struct arch_fork_arg *arg); void arch_restore_fork_frame(struct arch_fork_arg *arg); -// for any inline overrides -#include - #ifdef __cplusplus } #endif +// for any inline overrides +#include + #endif /* KERNEL_ARCH_THREAD_H */ From bonefish at mail.berlios.de Sun Jul 15 02:45:20 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 15 Jul 2007 02:45:20 +0200 Subject: [Haiku-commits] r21608 - haiku/trunk/src/system/boot/loader/file_systems/tarfs Message-ID: <200707150045.l6F0jKB7002890@sheep.berlios.de> Author: bonefish Date: 2007-07-15 02:45:10 +0200 (Sun, 15 Jul 2007) New Revision: 21608 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21608&view=rev Modified: haiku/trunk/src/system/boot/loader/file_systems/tarfs/tarfs.cpp Log: * Reduced the region allocated for the uncompressed data to 16 MB. With 32 MB the kernel's VM initialization code would run into trouble. Accessing freshly mapped memory in the generic page mapper would result in a page fault. To be investigated. * Apparently in the boot loader the file systems are responsible for resolving symbolic links (instead of the VFS). We do that now. Modified: haiku/trunk/src/system/boot/loader/file_systems/tarfs/tarfs.cpp =================================================================== --- haiku/trunk/src/system/boot/loader/file_systems/tarfs/tarfs.cpp 2007-07-15 00:35:10 UTC (rev 21607) +++ haiku/trunk/src/system/boot/loader/file_systems/tarfs/tarfs.cpp 2007-07-15 00:45:10 UTC (rev 21608) @@ -34,7 +34,7 @@ static const uint32 kFloppyArchiveOffset = 192 * 1024; // at 192 kB -static const size_t kTarRegionSize = 32 * 1024 * 1024; // 32 MB +static const size_t kTarRegionSize = 16 * 1024 * 1024; // 16 MB namespace TarFS { @@ -143,6 +143,8 @@ virtual off_t Size() const; virtual ino_t Inode() const; + const char* LinkPath() const { return fHeader->linkname; } + virtual ::Node *ToNode() { return this; } private: @@ -367,15 +369,29 @@ ::Node * -TarFS::Directory::Lookup(const char *name, bool /*traverseLinks*/) +TarFS::Directory::Lookup(const char *name, bool traverseLinks) { - if (TarFS::Entry *entry = LookupEntry(name)) { - entry->ToNode()->Acquire(); - // our entries are not supposed to be deleted after use - return entry->ToNode(); + TarFS::Entry *entry = LookupEntry(name); + if (!entry) + return NULL; + + Node* node = entry->ToNode(); + + if (traverseLinks) { + if (S_ISLNK(node->Type())) { + Symlink* symlink = static_cast(node); + int fd = open_from(this, symlink->LinkPath(), O_RDONLY); + if (fd >= 0) { + node = get_node_from(fd); + close(fd); + } + } } - return NULL; + if (node) + node->Acquire(); + + return node; } @@ -536,22 +552,7 @@ ssize_t TarFS::Symlink::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize) { - TRACE(("tarfs: symlink read at %Ld, %lu bytes, fSize = %Ld\n", pos, - bufferSize, fSize)); - - if (pos < 0 || !buffer) - return B_BAD_VALUE; - - if (pos >= fSize || bufferSize == 0) - return 0; - - size_t toRead = fSize - pos; - if (toRead > bufferSize) - toRead = bufferSize; - - memcpy(buffer, fHeader->linkname + pos, toRead); - - return toRead; + return B_NOT_ALLOWED; } From bonefish at mail.berlios.de Sun Jul 15 02:49:05 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 15 Jul 2007 02:49:05 +0200 Subject: [Haiku-commits] r21609 - haiku/trunk/src/add-ons/kernel/network/protocols/udp Message-ID: <200707150049.l6F0n52d003089@sheep.berlios.de> Author: bonefish Date: 2007-07-15 02:49:04 +0200 (Sun, 15 Jul 2007) New Revision: 21609 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21609&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/protocols/udp/udp.cpp Log: Use the AutoLocker defined by the super class. Modified: haiku/trunk/src/add-ons/kernel/network/protocols/udp/udp.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/udp/udp.cpp 2007-07-15 00:45:10 UTC (rev 21608) +++ haiku/trunk/src/add-ons/kernel/network/protocols/udp/udp.cpp 2007-07-15 00:49:04 UTC (rev 21609) @@ -815,7 +815,7 @@ { TRACE_EP("Open()"); - BenaphoreLocker _(fLock); + AutoLocker _(fLock); status_t status = ProtocolSocket::Open(); if (status < B_OK) From bonefish at mail.berlios.de Sun Jul 15 02:54:21 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 15 Jul 2007 02:54:21 +0200 Subject: [Haiku-commits] r21610 - haiku/trunk/src/system/boot/platform/bios_ia32 Message-ID: <200707150054.l6F0sLaP003332@sheep.berlios.de> Author: bonefish Date: 2007-07-15 02:54:16 +0200 (Sun, 15 Jul 2007) New Revision: 21610 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21610&view=rev Modified: haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp Log: Clear out/initialize IDT and GDT using their virtual addresses after they have been mapped. The previous method relied on their physical pages living in the identity mapped region, which they wouldn't, when the boot loader allocated enough memory before. Modified: haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp 2007-07-15 00:49:04 UTC (rev 21609) +++ haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp 2007-07-15 00:54:16 UTC (rev 21610) @@ -428,15 +428,16 @@ TRACE(("idt at %p\n", idt)); + // map the idt into virtual space + gKernelArgs.arch_args.vir_idt = (uint32)get_next_virtual_page(); + map_page(gKernelArgs.arch_args.vir_idt, (uint32)idt, kDefaultPageFlags); + // clear it out + uint32* virtualIDT = (uint32*)gKernelArgs.arch_args.vir_idt; for (int32 i = 0; i < IDT_LIMIT / 4; i++) { - idt[i] = 0; + virtualIDT[i] = 0; } - // map the idt into virtual space - gKernelArgs.arch_args.vir_idt = (uint32)get_next_virtual_page(); - map_page(gKernelArgs.arch_args.vir_idt, (uint32)idt, kDefaultPageFlags); - // load the idt idtDescriptor.limit = IDT_LIMIT - 1; idtDescriptor.base = (uint32 *)gKernelArgs.arch_args.vir_idt; @@ -458,25 +459,34 @@ TRACE(("gdt at %p\n", gdt)); + // map the gdt into virtual space + gKernelArgs.arch_args.vir_gdt = (uint32)get_next_virtual_page(); + map_page(gKernelArgs.arch_args.vir_gdt, (uint32)gdt, kDefaultPageFlags); + // put standard segment descriptors in it - clear_segment_descriptor(&gdt[0]); - set_segment_descriptor(&gdt[1], 0, 0xffffffff, DT_CODE_READABLE, DPL_KERNEL); - // seg 0x08 - kernel 4GB code - set_segment_descriptor(&gdt[2], 0, 0xffffffff, DT_DATA_WRITEABLE, DPL_KERNEL); - // seg 0x10 - kernel 4GB data + segment_descriptor* virtualGDT + = (segment_descriptor*)gKernelArgs.arch_args.vir_gdt; + clear_segment_descriptor(&virtualGDT[0]); - set_segment_descriptor(&gdt[3], 0, 0xffffffff, DT_CODE_READABLE, DPL_USER); - // seg 0x1b - ring 3 user 4GB code - set_segment_descriptor(&gdt[4], 0, 0xffffffff, DT_DATA_WRITEABLE, DPL_USER); - // seg 0x23 - ring 3 user 4GB data + // seg 0x08 - kernel 4GB code + set_segment_descriptor(&virtualGDT[1], 0, 0xffffffff, DT_CODE_READABLE, + DPL_KERNEL); - // gdt[5] and above will be filled later by the kernel + // seg 0x10 - kernel 4GB data + set_segment_descriptor(&virtualGDT[2], 0, 0xffffffff, DT_DATA_WRITEABLE, + DPL_KERNEL); + + // seg 0x1b - ring 3 user 4GB code + set_segment_descriptor(&virtualGDT[3], 0, 0xffffffff, DT_CODE_READABLE, + DPL_USER); + + // seg 0x23 - ring 3 user 4GB data + set_segment_descriptor(&virtualGDT[4], 0, 0xffffffff, DT_DATA_WRITEABLE, + DPL_USER); + + // virtualGDT[5] and above will be filled later by the kernel // to contain the TSS descriptors, and for TLS (one for every CPU) - // map the gdt into virtual space - gKernelArgs.arch_args.vir_gdt = (uint32)get_next_virtual_page(); - map_page(gKernelArgs.arch_args.vir_gdt, (uint32)gdt, kDefaultPageFlags); - // load the GDT gdtDescriptor.limit = GDT_LIMIT - 1; gdtDescriptor.base = (uint32 *)gKernelArgs.arch_args.vir_gdt; From bonefish at mail.berlios.de Sun Jul 15 04:10:20 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 15 Jul 2007 04:10:20 +0200 Subject: [Haiku-commits] r21611 - in haiku/trunk: headers/private/kernel/boot headers/private/kernel/boot/platform/bios_ia32 headers/private/kernel/fs src/system/boot/loader src/system/boot/platform/bios_ia32 src/system/boot/platform/pxe_ia32 src/system/kernel src/system/kernel/fs Message-ID: <200707150210.l6F2AKsu006420@sheep.berlios.de> Author: bonefish Date: 2007-07-15 04:10:15 +0200 (Sun, 15 Jul 2007) New Revision: 21611 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21611&view=rev Added: haiku/trunk/src/system/kernel/fs/vfs_boot.h haiku/trunk/src/system/kernel/fs/vfs_net_boot.cpp haiku/trunk/src/system/kernel/fs/vfs_net_boot.h Modified: haiku/trunk/headers/private/kernel/boot/disk_identifier.h haiku/trunk/headers/private/kernel/boot/elf.h haiku/trunk/headers/private/kernel/boot/kernel_args.h haiku/trunk/headers/private/kernel/boot/platform/bios_ia32/platform_kernel_args.h haiku/trunk/headers/private/kernel/boot/vfs.h haiku/trunk/headers/private/kernel/fs/devfs.h haiku/trunk/src/system/boot/loader/Jamfile haiku/trunk/src/system/boot/loader/loader.cpp haiku/trunk/src/system/boot/loader/main.cpp haiku/trunk/src/system/boot/loader/menu.cpp haiku/trunk/src/system/boot/loader/partitions.cpp haiku/trunk/src/system/boot/loader/vfs.cpp haiku/trunk/src/system/boot/platform/bios_ia32/devices.cpp haiku/trunk/src/system/boot/platform/pxe_ia32/Jamfile haiku/trunk/src/system/boot/platform/pxe_ia32/devices.cpp haiku/trunk/src/system/boot/platform/pxe_ia32/network.cpp haiku/trunk/src/system/boot/platform/pxe_ia32/network.h haiku/trunk/src/system/boot/platform/pxe_ia32/pxe_stage2.S haiku/trunk/src/system/boot/platform/pxe_ia32/pxe_undi.h haiku/trunk/src/system/kernel/fs/Jamfile haiku/trunk/src/system/kernel/fs/devfs.cpp haiku/trunk/src/system/kernel/fs/vfs_boot.cpp haiku/trunk/src/system/kernel/main.c haiku/trunk/src/system/kernel/module.cpp Log: [Sorry, couldn't split this one up any further.] * Images preloaded by the boot loader had to be modules to be of any use to the kernel. Extended the mechanism so that any images not accepted by the module code would later be tried to be added as drivers by the devfs. This is a little hacky ATM, since the devfs manages the drivers using a hash map keyed by the drivers inode ID, which those drivers obviously don't have. * The devfs emulates read_pages() using read(), if the device driver doesn't implement the former (all old-style drivers), thus making it possible to BFS, which uses the file cache which in turn requires read_pages(), on the device. write_pages() emulation is still missing. * Replaced the kernel_args::boot_disk structure by a KMessage, which can more flexibly be extended and deals more gracefully with arbitrarily-size data. The disk_identifier structure still exists, though. It is added as message field in cases where needed (non net boot). Moved the boot_drive_number field of the bios_ia32 platform specific args into the message. * Made the stage 1 PXE boot loader superfluous. Moved the relevant initialization code into the stage 2 loader, which can now be loaded directly via PXE. * The PXE boot loader does now download a boot tgz archive via TFTP. It does no longer use the RemoteDisk protocol (it could actually be removed from the boot loader). It also parses the DHCP options in the DHCPACK packet provided by PXE and extracts the root path to be mounted by the kernel. * Reorganized the boot volume search in the kernel (vfs_boot.cpp) and added support for network boot. In this case the net stack is initialized and the network interface the boot loader used is brought up and configured. Since NBD and RemoteDisk are our only options for net boot (and those aren't really configurable dynamically) ATM, the the boot device is found automatically by the disk device manager. Booting via PXE does work to some degree now. The most grievous problem is that loading certain drivers or kernel modules (or related activity) causes a reboot (likely a triple fault, though one wonders where our double fault handler is on vacation). Namely the keyboard and mouse input server add-ons need to be deactivated as well as the media server. A smaller problem is the net server, which apparently tries to (re-)configure the network interface we're using to boot, which obviously doesn't work out that well. So, if all this stuff is disabled Haiku does fully boot, when using the RemoteDisk protocol (not being able to use keyboard or mouse doesn't make this a particular fascinating experience, though ;-)). I had no luck with NBD -- it seemed to have protocol problems with the servers I tried. Modified: haiku/trunk/headers/private/kernel/boot/disk_identifier.h =================================================================== --- haiku/trunk/headers/private/kernel/boot/disk_identifier.h 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/headers/private/kernel/boot/disk_identifier.h 2007-07-15 02:10:15 UTC (rev 21611) @@ -23,7 +23,6 @@ USB_DEVICE, FIREWIRE_DEVICE, FIBRE_DEVICE, - NETWORK_DEVICE, }; #define NUM_DISK_CHECK_SUMS 5 @@ -63,11 +62,6 @@ uint64 wwd; } fibre; struct { - uint32 client_ip; - uint32 server_ip; - uint16 server_port; - } network; - struct { off_t size; struct { off_t offset; Modified: haiku/trunk/headers/private/kernel/boot/elf.h =================================================================== --- haiku/trunk/headers/private/kernel/boot/elf.h 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/headers/private/kernel/boot/elf.h 2007-07-15 02:10:15 UTC (rev 21611) @@ -35,6 +35,8 @@ ino_t inode; image_id id; // the ID field will be filled out in the kernel + bool is_module; + // set by the module initialization code }; #ifdef __cplusplus Modified: haiku/trunk/headers/private/kernel/boot/kernel_args.h =================================================================== --- haiku/trunk/headers/private/kernel/boot/kernel_args.h 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/headers/private/kernel/boot/kernel_args.h 2007-07-15 02:10:15 UTC (rev 21611) @@ -18,10 +18,27 @@ #include #include +#include #define CURRENT_KERNEL_ARGS_VERSION 1 -#define MAX_KERNEL_ARGS_RANGE 16 +#define MAX_KERNEL_ARGS_RANGE 32 +// names of common boot_volume fields +#define BOOT_METHOD "boot method" +#define BOOT_VOLUME_USER_SELECTED "user selected" +#define BOOT_VOLUME_BOOTED_FROM_IMAGE "booted from image" +#define BOOT_VOLUME_PARTITION_OFFSET "partition offset" +#define BOOT_VOLUME_DISK_IDENTIFIER "disk identifier" + +// boot methods +enum { + BOOT_METHOD_HARD_DISK = 0, + BOOT_METHOD_CD = 1, + BOOT_METHOD_NET = 2, + + BOOT_METHOD_DEFAULT = BOOT_METHOD_HARD_DISK +}; + typedef struct kernel_args { uint32 kernel_args_size; uint32 version; @@ -41,14 +58,7 @@ uint32 num_cpus; addr_range cpu_kstack[MAX_BOOT_CPUS]; - struct { - disk_identifier identifier; - off_t partition_offset; - bool user_selected; - bool booted_from_image; - bool booted_from_network; - bool cd; - } boot_disk; + KMessage boot_volume; struct driver_settings_file *driver_settings; Modified: haiku/trunk/headers/private/kernel/boot/platform/bios_ia32/platform_kernel_args.h =================================================================== --- haiku/trunk/headers/private/kernel/boot/platform/bios_ia32/platform_kernel_args.h 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/headers/private/kernel/boot/platform/bios_ia32/platform_kernel_args.h 2007-07-15 02:10:15 UTC (rev 21611) @@ -25,7 +25,6 @@ typedef struct { uint16 serial_base_ports[MAX_SERIAL_PORTS]; - uint16 boot_drive_number; bios_drive *drives; // this does not contain the boot drive apm_info apm; Modified: haiku/trunk/headers/private/kernel/boot/vfs.h =================================================================== --- haiku/trunk/headers/private/kernel/boot/vfs.h 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/headers/private/kernel/boot/vfs.h 2007-07-15 02:10:15 UTC (rev 21611) @@ -73,6 +73,26 @@ virtual ssize_t Write(const void *buffer, size_t bufferSize); }; + +class MemoryDisk : public Node { + public: + MemoryDisk(const uint8* data, size_t size, const char* name); + + virtual ssize_t ReadAt(void* cookie, off_t pos, void* buffer, + size_t bufferSize); + virtual ssize_t WriteAt(void* cookie, off_t pos, const void* buffer, + size_t bufferSize); + + virtual off_t Size() const; + virtual status_t GetName(char *nameBuffer, size_t bufferSize) const; + + private: + const uint8* fData; + size_t fSize; + char fName[64]; +}; + + /* function prototypes */ extern status_t vfs_init(stage2_args *args); Modified: haiku/trunk/headers/private/kernel/fs/devfs.h =================================================================== --- haiku/trunk/headers/private/kernel/fs/devfs.h 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/headers/private/kernel/fs/devfs.h 2007-07-15 02:10:15 UTC (rev 21611) @@ -16,6 +16,8 @@ extern "C" { #endif +void devfs_add_preloaded_drivers(struct kernel_args* args); + status_t devfs_add_driver(const char *path); status_t devfs_unpublish_file_device(const char *path); Modified: haiku/trunk/src/system/boot/loader/Jamfile =================================================================== --- haiku/trunk/src/system/boot/loader/Jamfile 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/src/system/boot/loader/Jamfile 2007-07-15 02:10:15 UTC (rev 21611) @@ -22,8 +22,10 @@ BOOT_SUPPORT_FILE_SYSTEM_BFS BOOT_SUPPORT_FILE_SYSTEM_AMIGA_FFS BOOT_SUPPORT_FILE_SYSTEM_TARFS - ; + KMESSAGE_CONTAINER_ONLY + ; + defines = [ FDefines $(defines) ] ; SubDirCcFlags $(defines) -Wall -Wno-multichar ; SubDirC++Flags $(defines) -Wall -Wno-multichar -fno-rtti ; @@ -46,8 +48,9 @@ driver_settings.c # utils + kernel_cpp.cpp + KMessage.cpp list.c - kernel_cpp.cpp : -fno-pic ; @@ -69,6 +72,9 @@ SEARCH on [ FGristFiles kernel_cpp.cpp list.c ] = [ FDirName $(HAIKU_TOP) src system kernel util ] ; +SEARCH on [ FGristFiles KMessage.cpp ] + = [ FDirName $(HAIKU_TOP) src system kernel messaging ] ; + SEARCH on [ FGristFiles driver_settings.c ] = [ FDirName $(HAIKU_TOP) src system libroot os ] ; Modified: haiku/trunk/src/system/boot/loader/loader.cpp =================================================================== --- haiku/trunk/src/system/boot/loader/loader.cpp 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/src/system/boot/loader/loader.cpp 2007-07-15 02:10:15 UTC (rev 21611) @@ -193,7 +193,8 @@ // and now load all partitioning and file system modules // needed to identify the boot volume - if (!gKernelArgs.boot_disk.booted_from_image) { + if (!gKernelArgs.boot_volume.GetBool(BOOT_VOLUME_BOOTED_FROM_IMAGE, + false)) { // iterate over the mounted volumes and load their file system Partition *partition; if (gRoot->GetPartitionFor(volume, &partition) == B_OK) { Modified: haiku/trunk/src/system/boot/loader/main.cpp =================================================================== --- haiku/trunk/src/system/boot/loader/main.cpp 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/src/system/boot/loader/main.cpp 2007-07-15 02:10:15 UTC (rev 21611) @@ -35,6 +35,9 @@ TRACE(("boot(): heap initialized...\n")); + // construct boot_volume KMessage explicitely + new(&gKernelArgs.boot_volume) KMessage; + platform_init_video(); // the main platform dependent initialisation @@ -107,6 +110,20 @@ gKernelArgs.kernel_args_size = sizeof(kernel_args); gKernelArgs.version = CURRENT_KERNEL_ARGS_VERSION; + // clone the boot_volume KMessage into kernel accessible memory + // note, that we need to 4 byte align the buffer and thus allocate + // 3 more bytes + KMessage& bootVolume = gKernelArgs.boot_volume; + void* buffer = kernel_args_malloc(bootVolume.ContentSize() + 3); + if (!buffer) { + panic("Could not allocate memory for the boot volume kernel " + "arguments"); + } + + buffer = (void*)(((addr_t)buffer + 3) & ~(addr_t)0x3); + memcpy(buffer, bootVolume.Buffer(), bootVolume.ContentSize()); + bootVolume.SetTo(buffer, bootVolume.ContentSize()); + // ToDo: cleanup, heap_release() etc. platform_start_kernel(); } Modified: haiku/trunk/src/system/boot/loader/menu.cpp =================================================================== --- haiku/trunk/src/system/boot/loader/menu.cpp 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/src/system/boot/loader/menu.cpp 2007-07-15 02:10:15 UTC (rev 21611) @@ -360,7 +360,7 @@ bootItem->Select(true); bootItem->SetData(item->Data()); - gKernelArgs.boot_disk.user_selected = true; + gKernelArgs.boot_volume.SetBool(BOOT_VOLUME_USER_SELECTED, true); return true; } @@ -416,7 +416,7 @@ menu->AddItem(item = new(nothrow) MenuItem("Return to main menu")); item->SetType(MENU_ITEM_NO_CHOICE); - if (gKernelArgs.boot_disk.booted_from_image) + if (gKernelArgs.boot_volume.GetBool(BOOT_VOLUME_BOOTED_FROM_IMAGE, false)) menu->SetChoiceText("CD-ROM or hard drive"); return menu; Modified: haiku/trunk/src/system/boot/loader/partitions.cpp =================================================================== --- haiku/trunk/src/system/boot/loader/partitions.cpp 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/src/system/boot/loader/partitions.cpp 2007-07-15 02:10:15 UTC (rev 21611) @@ -210,8 +210,10 @@ status_t Partition::Mount(Directory **_fileSystem, bool isBootDevice) { - if (isBootDevice && gKernelArgs.boot_disk.booted_from_image) + if (isBootDevice && gKernelArgs.boot_volume.GetBool( + BOOT_VOLUME_BOOTED_FROM_IMAGE, false)) { return _Mount(&gTarFileSystemModule, _fileSystem); + } for (int32 i = 0; i < sNumFileSystemModules; i++) { status_t status = _Mount(sFileSystemModules[i], _fileSystem); @@ -233,8 +235,10 @@ // if we were not booted from the real boot device, we won't scan // the device we were booted from (which is likely to be a slow // floppy or CD) - if (isBootDevice && gKernelArgs.boot_disk.booted_from_image) + if (isBootDevice && gKernelArgs.boot_volume.GetBool( + BOOT_VOLUME_BOOTED_FROM_IMAGE, false)) { return B_ENTRY_NOT_FOUND; + } const partition_module_info *bestModule = NULL; void *bestCookie = NULL; Modified: haiku/trunk/src/system/boot/loader/vfs.cpp =================================================================== --- haiku/trunk/src/system/boot/loader/vfs.cpp 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/src/system/boot/loader/vfs.cpp 2007-07-15 02:10:15 UTC (rev 21611) @@ -198,6 +198,58 @@ // #pragma mark - +MemoryDisk::MemoryDisk(const uint8* data, size_t size, const char* name) + : Node(), + fData(data), + fSize(size) +{ + strlcpy(fName, name, sizeof(fName)); +} + + +ssize_t +MemoryDisk::ReadAt(void* cookie, off_t pos, void* buffer, size_t bufferSize) +{ + if (pos >= fSize) + return 0; + + if (pos + bufferSize > fSize) + bufferSize = fSize - pos; + + memcpy(buffer, fData + pos, bufferSize); + return bufferSize; +} + + +ssize_t +MemoryDisk::WriteAt(void* cookie, off_t pos, const void* buffer, + size_t bufferSize) +{ + return B_NOT_ALLOWED; +} + + +off_t +MemoryDisk::Size() const +{ + return fSize; +} + + +status_t +MemoryDisk::GetName(char *nameBuffer, size_t bufferSize) const +{ + if (!nameBuffer) + return B_BAD_VALUE; + + strlcpy(nameBuffer, fName, bufferSize); + return B_OK; +} + + +// #pragma mark - + + Descriptor::Descriptor(Node *node, void *cookie) : fNode(node), @@ -307,7 +359,8 @@ return status; } - gKernelArgs.boot_disk.partition_offset = partition->offset; + gKernelArgs.boot_volume.SetInt64(BOOT_VOLUME_PARTITION_OFFSET, + partition->offset); Node *device = get_node_from(partition->FD()); if (device == NULL) { Modified: haiku/trunk/src/system/boot/platform/bios_ia32/devices.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/devices.cpp 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/src/system/boot/platform/bios_ia32/devices.cpp 2007-07-15 02:10:15 UTC (rev 21611) @@ -166,7 +166,7 @@ static void check_cd_boot(BIOSDrive *drive) { - gKernelArgs.boot_disk.cd = false; + gKernelArgs.boot_volume.SetInt32(BOOT_METHOD, BOOT_METHOD_HARD_DISK); if (drive->DriveID() != 0) return; @@ -183,7 +183,8 @@ // we obviously were booted from CD! specification_packet *packet = (specification_packet *)kDataSegmentScratch; - gKernelArgs.boot_disk.cd = packet->media_type != 0; + if (packet->media_type != 0) + gKernelArgs.boot_volume.SetInt32(BOOT_METHOD, BOOT_METHOD_CD); #if 0 dprintf("got CD boot spec:\n"); @@ -756,8 +757,8 @@ } TRACE(("boot drive size: %Ld bytes\n", drive->Size())); - gKernelArgs.boot_disk.booted_from_image = gBootedFromImage; - gKernelArgs.boot_disk.booted_from_network = false; + gKernelArgs.boot_volume.SetInt32(BOOT_VOLUME_BOOTED_FROM_IMAGE, + gBootedFromImage); return B_OK; } @@ -803,8 +804,9 @@ check_cd_boot(drive); - gKernelArgs.platform_args.boot_drive_number = drive->DriveID(); - gKernelArgs.boot_disk.identifier = drive->Identifier(); + gKernelArgs.boot_volume.SetInt64("boot drive number", drive->DriveID()); + gKernelArgs.boot_volume.SetData(BOOT_VOLUME_DISK_IDENTIFIER, B_RAW_TYPE, + &drive->Identifier(), sizeof(disk_identifier)); return B_OK; } Modified: haiku/trunk/src/system/boot/platform/pxe_ia32/Jamfile =================================================================== --- haiku/trunk/src/system/boot/platform/pxe_ia32/Jamfile 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/src/system/boot/platform/pxe_ia32/Jamfile 2007-07-15 02:10:15 UTC (rev 21611) @@ -48,7 +48,7 @@ pxe_undi.cpp $(bios_ia32_src) $(bios_ia32_edid_src) - + # generic text_menu.cpp : -fno-pic Modified: haiku/trunk/src/system/boot/platform/pxe_ia32/devices.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/pxe_ia32/devices.cpp 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/src/system/boot/platform/pxe_ia32/devices.cpp 2007-07-15 02:10:15 UTC (rev 21611) @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -27,26 +28,90 @@ #endif +//extern unsigned char* gBuiltinBootArchive; +//extern long long gBuiltinBootArchiveSize; + +static TFTP sTFTP; + + status_t platform_add_boot_device(struct stage2_args *args, NodeList *devicesList) { TRACE("platform_add_boot_device\n"); - status_t error = net_stack_init(); - if (error != B_OK) - return error; + // get the boot archive containing kernel and drivers via TFTP + status_t error = sTFTP.Init(); + if (error == B_OK) { + uint8* data; + size_t size; + // The root path in the DHCP packet from the server might contain the + // name of the archive. It would come first, then separated by semicolon + // the actual root path. + const char* fileName = "haiku-netboot.tgz"; // default + char stackFileName[1024]; + const char* rootPath = sTFTP.RootPath(); + if (rootPath) { + if (char* fileNameEnd = strchr(rootPath, ';')) { + size_t len = min_c(fileNameEnd - rootPath, + (int)sizeof(stackFileName) - 1); + memcpy(stackFileName, rootPath, len); + stackFileName[len] = '\0'; + fileName = stackFileName; + } + } - // init a remote disk, if possible - RemoteDisk *remoteDisk = RemoteDisk::FindAnyRemoteDisk(); - if (!remoteDisk) { - unsigned ip = NetStack::Default()->GetEthernetInterface()->IPAddress(); - panic("PXE boot: can't find remote disk on server %u.%u.%u.%u\n", - (ip >> 24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff); - return B_ENTRY_NOT_FOUND; + // get the file + error = sTFTP.ReceiveFile(fileName, &data, &size); + if (error == B_OK) { + char name[64]; + ip_addr_t serverAddress = sTFTP.ServerIPAddress(); + snprintf(name, sizeof(name), "%lu.%lu.%lu.%lu:%s", + (serverAddress >> 24), (serverAddress >> 16) & 0xff, + (serverAddress >> 8) & 0xff, serverAddress & 0xff, fileName); + + MemoryDisk* disk = new(nothrow) MemoryDisk(data, size, name); + if (!disk) { + dprintf("platform_add_boot_device(): Out of memory!\n"); + platform_free_region(data, size); + return B_NO_MEMORY; + } + + devicesList->Add(disk); + return B_OK; + } else { + dprintf("platform_add_boot_device(): Failed to load file \"%s\" " + "via TFTP\n", fileName); + } } - devicesList->Add(remoteDisk); - return B_OK; + return B_ENTRY_NOT_FOUND; + +// // built-in boot archive? +// if (gBuiltinBootArchiveSize > 0) { +// MemoryDisk* disk = new(nothrow) MemoryDisk(gBuiltinBootArchive, +// gBuiltinBootArchiveSize); +// if (!disk) +// return B_NO_MEMORY; +// +// devicesList->Add(disk); +// return B_OK; +// } + +// error = net_stack_init(); +// if (error != B_OK) +// return error; +// +// // init a remote disk, if possible +// RemoteDisk *remoteDisk = RemoteDisk::FindAnyRemoteDisk(); +// if (!remoteDisk) { +// unsigned ip = NetStack::Default()->GetEthernetInterface()->IPAddress(); +// panic("PXE boot: can't find remote disk on server %u.%u.%u.%u\n", +// (ip >> 24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff); +// return B_ENTRY_NOT_FOUND; +// } +// +// devicesList->Add(remoteDisk); +// return B_OK; } @@ -80,22 +145,39 @@ { TRACE("platform_register_boot_device\n"); - gKernelArgs.platform_args.boot_drive_number = 0xffff; - gKernelArgs.platform_args.drives = NULL; + // get the root path -- chop off the file name of the archive we loaded + const char* rootPath = sTFTP.RootPath(); + if (rootPath) { + if (char* fileNameEnd = strchr(rootPath, ';')) + rootPath = fileNameEnd + 1; + } - RemoteDisk *rd = static_cast(device); - UNDI *undi = static_cast(NetStack::Default()->GetEthernetInterface()); + KMessage& bootVolume = gKernelArgs.boot_volume; + if (bootVolume.SetInt32(BOOT_METHOD, BOOT_METHOD_NET) != B_OK + || bootVolume.AddInt64("client MAC", + sTFTP.MACAddress().ToUInt64()) != B_OK + || bootVolume.AddInt32("client IP", sTFTP.IPAddress()) != B_OK + || bootVolume.AddInt32("server IP", sTFTP.ServerIPAddress()) != B_OK + || bootVolume.AddInt32("server port", sTFTP.ServerPort()) != B_OK + || (sTFTP.RootPath() + && bootVolume.AddString("net root path", rootPath) + != B_OK)) { + return B_NO_MEMORY; + } - gKernelArgs.boot_disk.identifier.bus_type = UNKNOWN_BUS; - gKernelArgs.boot_disk.identifier.device_type = NETWORK_DEVICE; - gKernelArgs.boot_disk.identifier.device.network.client_ip = undi->IPAddress(); - gKernelArgs.boot_disk.identifier.device.network.server_ip = rd->ServerIPAddress(); - gKernelArgs.boot_disk.identifier.device.network.server_port = rd->ServerPort(); - gKernelArgs.boot_disk.partition_offset = 0; - gKernelArgs.boot_disk.user_selected = false; - gKernelArgs.boot_disk.booted_from_image = false; - gKernelArgs.boot_disk.booted_from_network = true; - gKernelArgs.boot_disk.cd = false; +// RemoteDisk *rd = static_cast(device); +// UNDI *undi = static_cast(NetStack::Default()->GetEthernetInterface()); +// +// gKernelArgs.boot_disk.identifier.bus_type = UNKNOWN_BUS; +// gKernelArgs.boot_disk.identifier.device_type = NETWORK_DEVICE; +// gKernelArgs.boot_disk.identifier.device.network.client_ip = undi->IPAddress(); +// gKernelArgs.boot_disk.identifier.device.network.server_ip = rd->ServerIPAddress(); +// gKernelArgs.boot_disk.identifier.device.network.server_port = rd->ServerPort(); +// gKernelArgs.boot_disk.partition_offset = 0; +// gKernelArgs.boot_disk.user_selected = false; +// gKernelArgs.boot_disk.booted_from_image = false; +// gKernelArgs.boot_disk.booted_from_network = true; +// gKernelArgs.boot_disk.cd = false; return B_OK; -} +} Modified: haiku/trunk/src/system/boot/platform/pxe_ia32/network.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/pxe_ia32/network.cpp 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/src/system/boot/platform/pxe_ia32/network.cpp 2007-07-15 02:10:15 UTC (rev 21611) @@ -11,6 +11,8 @@ #include +#include + #include "network.h" #include "pxe_undi.h" @@ -49,21 +51,113 @@ #endif // !TRACE_NETWORK -UNDI::UNDI() - : fMACAddress() - , fRxFinished(true) - , fPxeData(NULL) +// #pragma mark - PXEService + + +PXEService::PXEService() + : fPxeData(NULL), + fClientIP(0), + fServerIP(0), + fRootPath(NULL) { - TRACE("UNDI::UNDI\n"); +} + +PXEService::~PXEService() +{ + free(fRootPath); +} + + +status_t +PXEService::Init() +{ + // get !PXE struct fPxeData = pxe_undi_find_data(); - if (!fPxeData) + if (!fPxeData) { panic("can't find !PXE structure"); + return B_ERROR; + } dprintf("PXE API entrypoint at %04x:%04x\n", fPxeData->EntryPointSP.seg, fPxeData->EntryPointSP.ofs); + + // get cached info + PXENV_GET_CACHED_INFO cached_info; + cached_info.PacketType = PXENV_PACKET_TYPE_CACHED_REPLY; + cached_info.BufferSize = 0; + cached_info.BufferLimit = 0; + cached_info.Buffer.seg = 0; + cached_info.Buffer.ofs = 0; + uint16 res = call_pxe_bios(fPxeData, GET_CACHED_INFO, &cached_info); + if (res != 0 || cached_info.Status != 0) { + char s[100]; + snprintf(s, sizeof(s), "Can't determine IP address! PXENV_GET_CACHED_INFO res %x, status %x\n", res, cached_info.Status); + panic(s); + return B_ERROR; + } + + char *buf = (char *)(cached_info.Buffer.seg * 16 + cached_info.Buffer.ofs); + fClientIP = ntohl(*(ip_addr_t *)(buf + 16)); + fServerIP = ntohl(*(ip_addr_t *)(buf + 20)); + fMACAddress = mac_addr_t((uint8*)(buf + 28)); + + uint8* options = (uint8*)buf + 236; + int optionsLen = int(cached_info.BufferSize) - 236; + + // check magic + if (optionsLen < 4 || options[0] != 0x63 || options[1] != 0x82 + || options[2] != 0x53 || options[3] != 0x63) { + return B_OK; + } + options += 4; + optionsLen -= 4; + + // parse DHCP options + while (optionsLen > 0) { + int option = *(options++); + optionsLen--; + + // check end or pad option + if (option == 0xff || optionsLen < 0) + break; + if (option == 0x00) + continue; + + // other options have a len field + int len = *(options++); + optionsLen--; + if (len > optionsLen) + break; + + // root path option + if (option == 17) { + dprintf("root path option: \"%.*s\"\n", len, (char*)options); + free(fRootPath); + fRootPath = (char*)malloc(len + 1); + if (!fRootPath) + return B_NO_MEMORY; + memcpy(fRootPath, options, len); + fRootPath[len] = '\0'; + } + + options += len; + optionsLen -= len; + } + + return B_OK; } +// #pragma mark - UNDI + + +UNDI::UNDI() + : fRxFinished(true) +{ + TRACE("UNDI::UNDI\n"); +} + + UNDI::~UNDI() { TRACE("UNDI::~UNDI\n"); @@ -75,33 +169,20 @@ { TRACE("UNDI::Init\n"); - PXENV_GET_CACHED_INFO cached_info; PXENV_UNDI_GET_INFORMATION get_info; PXENV_UNDI_GET_STATE get_state; PXENV_UNDI_OPEN undi_open; uint16 res; - cached_info.PacketType = PXENV_PACKET_TYPE_CACHED_REPLY; - cached_info.BufferSize = 0; - cached_info.BufferLimit = 0; - cached_info.Buffer.seg = 0; - cached_info.Buffer.ofs = 0; - res = call_pxe_bios(fPxeData, GET_CACHED_INFO, &cached_info); - if (res != 0 || cached_info.Status != 0) { - char s[100]; - snprintf(s, sizeof(s), "Can't determine IP address! PXENV_GET_CACHED_INFO res %x, status %x\n", res, cached_info.Status); - panic(s); - } + status_t error = PXEService::Init(); + if (error != B_OK) + return error; - char *buf = (char *)(cached_info.Buffer.seg * 16 + cached_info.Buffer.ofs); - ip_addr_t ipClient = ntohl(*(ip_addr_t *)(buf + 16)); - ip_addr_t ipServer = ntohl(*(ip_addr_t *)(buf + 20)); - dprintf("client-ip: %lu.%lu.%lu.%lu, server-ip: %lu.%lu.%lu.%lu\n", - (ipClient >> 24) & 0xff, (ipClient >> 16) & 0xff, (ipClient >> 8) & 0xff, ipClient & 0xff, - (ipServer >> 24) & 0xff, (ipServer >> 16) & 0xff, (ipServer >> 8) & 0xff, ipServer & 0xff); + (fClientIP >> 24) & 0xff, (fClientIP >> 16) & 0xff, (fClientIP >> 8) & 0xff, fClientIP & 0xff, + (fServerIP >> 24) & 0xff, (fServerIP >> 16) & 0xff, (fServerIP >> 8) & 0xff, fServerIP & 0xff); - SetIPAddress(ipClient); + SetIPAddress(fClientIP); undi_open.OpenFlag = 0; undi_open.PktFilter = FLTR_DIRECTED | FLTR_BRDCST | FLTR_PRMSCS; @@ -297,7 +378,160 @@ } +// #pragma mark - TFTP + +TFTP::TFTP() +{ +} + + +TFTP::~TFTP() +{ +} + + status_t +TFTP::Init() +{ + status_t error = PXEService::Init(); + if (error != B_OK) + return error; + + + + return B_OK; +} + + +uint16 +TFTP::ServerPort() const +{ + return 69; +} + + +status_t +TFTP::ReceiveFile(const char* fileName, uint8** data, size_t* size) +{ + // get file size + pxenv_tftp_get_fsize getFileSize; + getFileSize.server_ip.num = htonl(fServerIP); + getFileSize.gateway_ip.num = 0; + strlcpy(getFileSize.file_name, fileName, sizeof(getFileSize.file_name)); + + uint16 res = call_pxe_bios(fPxeData, TFTP_GET_FILE_SIZE, &getFileSize); + if (res != 0 || getFileSize.status != 0) { + dprintf("TFTP_GET_FILE_SIZE failed, res %x, status %x\n", res, + getFileSize.status); + + return B_ERROR; + } + + uint32 fileSize = getFileSize.file_size; + dprintf("size of boot archive \"%s\": %lu\n", fileName, fileSize); + + // allocate memory for the data + uint8* fileData = NULL; + if (platform_allocate_region((void**)&fileData, fileSize, + B_READ_AREA | B_WRITE_AREA, false) != B_OK) { + TRACE(("TFTP: allocating memory for file data failed\n")); + return B_NO_MEMORY; + } + + // open TFTP connection + pxenv_tftp_open openConnection; + openConnection.server_ip.num = htonl(fServerIP); + openConnection.gateway_ip.num = 0; + strlcpy(openConnection.file_name, fileName, sizeof(getFileSize.file_name)); + openConnection.port = htons(ServerPort()); + openConnection.packet_size = 1456; + + res = call_pxe_bios(fPxeData, TFTP_OPEN, &openConnection); + if (res != 0 || openConnection.status != 0) { + dprintf("TFTP_OPEN failed, res %x, status %x\n", res, + openConnection.status); + + platform_free_region(fileData, fileSize); + return B_ERROR; + } + + uint16 packetSize = openConnection.packet_size; + dprintf("successfully opened TFTP connection, packet size %u\n", + packetSize); + + // check, if the file is too big for the TFTP protocol + if (fileSize > 0xffff * (uint32)packetSize) { + dprintf("TFTP: File is too big to be transferred via TFTP\n"); + _Close(); + platform_free_region(fileData, fileSize); + return B_ERROR; + } + + // transfer the file + status_t error = B_OK; + uint32 remainingBytes = fileSize; + uint8* buffer = fileData; + while (remainingBytes > 0) { + void* scratchBuffer = (void*)0x07C00; + pxenv_tftp_read readPacket; + readPacket.buffer.seg = SEG(scratchBuffer); + readPacket.buffer.ofs = OFS(scratchBuffer); + + res = call_pxe_bios(fPxeData, TFTP_READ, &readPacket); + if (res != 0 || readPacket.status != 0) { + dprintf("TFTP_READ failed, res %x, status %x\n", res, + readPacket.status); + error = B_ERROR; + break; + } + + uint32 bytesRead = readPacket.buffer_size; + if (bytesRead > remainingBytes) { + dprintf("TFTP: Read more bytes than should be remaining!"); + error = B_ERROR; + break; + } + + memcpy(buffer, scratchBuffer, bytesRead); + buffer += bytesRead; + remainingBytes -= bytesRead; + } + + // close TFTP connection + _Close(); + + if (error == B_OK) { + dprintf("TFTP: Successfully received file\n"); + *data = fileData; + *size = fileSize; + } else { + platform_free_region(fileData, fileSize); + } + + return error; +} + +status_t +TFTP::_Close() +{ + // close TFTP connection + pxenv_tftp_close closeConnection; + uint16 res = call_pxe_bios(fPxeData, TFTP_CLOSE, &closeConnection); + if (res != 0 || closeConnection.status != 0) { + dprintf("TFTP_CLOSE failed, res %x, status %x\n", res, + closeConnection.status); + return B_ERROR; + } + + return B_OK; +} + + + +// #pragma mark - + + +status_t platform_net_stack_init() { TRACE("platform_net_stack_init\n"); Modified: haiku/trunk/src/system/boot/platform/pxe_ia32/network.h =================================================================== --- haiku/trunk/src/system/boot/platform/pxe_ia32/network.h 2007-07-15 00:54:16 UTC (rev 21610) +++ haiku/trunk/src/system/boot/platform/pxe_ia32/network.h 2007-07-15 02:10:15 UTC (rev 21611) @@ -2,7 +2,7 @@ #define _PXE_NETWORK_H /* * Copyright 2006, Marcus Overhagen . + * Copyright 2005-2007, Ingo Weinhold . * Distributed under the terms of the MIT License. */ @@ -12,7 +12,30 @@ struct PXE_STRUCT; -class UNDI : public EthernetInterface + +class PXEService { +protected: + PXEService(); + ~PXEService(); + + status_t Init(); + +public: + mac_addr_t MACAddress() const { return fMACAddress; } + ip_addr_t IPAddress() const { return fClientIP; } + ip_addr_t ServerIPAddress() const { return fServerIP; } + const char* RootPath() const { return fRootPath; } + +protected: + PXE_STRUCT* fPxeData; + ip_addr_t fClientIP; + ip_addr_t fServerIP; + mac_addr_t fMACAddress; + char* fRootPath; +}; + + +class UNDI : public EthernetInterface, public PXEService { public: UNDI(); @@ -20,7 +43,6 @@ status_t Init(); - ip_addr_t ServerIPAddress() const; virtual mac_addr_t MACAddress() const; virtual void * AllocateSendReceiveBuffer(size_t size); @@ -30,9 +52,25 @@ virtual ssize_t Receive(void *buffer, size_t size); private: - mac_addr_t fMACAddress; bool fRxFinished; PXE_STRUCT * fPxeData; }; + +class TFTP : public PXEService { +public: + TFTP(); + ~TFTP(); + + status_t Init(); + [... truncated: 1468 lines follow ...] From bonefish at mail.berlios.de Sun Jul 15 04:13:02 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 15 Jul 2007 04:13:02 +0200 Subject: [Haiku-commits] r21612 - haiku/trunk/src/add-ons/kernel/drivers/disk/virtual Message-ID: <200707150213.l6F2D2RQ006550@sheep.berlios.de> Author: bonefish Date: 2007-07-15 04:13:00 +0200 (Sun, 15 Jul 2007) New Revision: 21612 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21612&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/Jamfile Log: This one slipped. Added remote_disk driver to the build. Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/Jamfile 2007-07-15 02:10:15 UTC (rev 21611) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/Jamfile 2007-07-15 02:13:00 UTC (rev 21612) @@ -2,3 +2,4 @@ #SubInclude HAIKU_TOP src add-ons kernel drivers disk virtual fmap ; SubInclude HAIKU_TOP src add-ons kernel drivers disk virtual nbd ; +SubInclude HAIKU_TOP src add-ons kernel drivers disk virtual remote_disk ; From bonefish at mail.berlios.de Sun Jul 15 04:29:01 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 15 Jul 2007 04:29:01 +0200 Subject: [Haiku-commits] r21613 - haiku/trunk/src/system/kernel/device_manager Message-ID: <200707150229.l6F2T1BT007575@sheep.berlios.de> Author: bonefish Date: 2007-07-15 04:29:00 +0200 (Sun, 15 Jul 2007) New Revision: 21613 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21613&view=rev Modified: haiku/trunk/src/system/kernel/device_manager/probe.cpp Log: We were leaking a module reference. Modified: haiku/trunk/src/system/kernel/device_manager/probe.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/probe.cpp 2007-07-15 02:13:00 UTC (rev 21612) +++ haiku/trunk/src/system/kernel/device_manager/probe.cpp 2007-07-15 02:29:00 UTC (rev 21613) @@ -895,8 +895,10 @@ driver_module_info *info; if (get_module(name, (module_info **)&info) == B_OK) { - if (info->get_supported_paths == NULL) + if (info->get_supported_paths == NULL) { + put_module(name); continue; + } const char **busses, **devices; info->get_supported_paths(&busses, &devices); From axeld at mail.berlios.de Sun Jul 15 14:38:14 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 15 Jul 2007 14:38:14 +0200 Subject: [Haiku-commits] r21614 - haiku/trunk/src/system/kernel/fs Message-ID: <200707151238.l6FCcEmh029363@sheep.berlios.de> Author: axeld Date: 2007-07-15 14:38:13 +0200 (Sun, 15 Jul 2007) New Revision: 21614 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21614&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp Log: remove_vnode() will now return an error code if the vnode to be removed did not exist. Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-07-15 02:29:00 UTC (rev 21613) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-07-15 12:38:13 UTC (rev 21614) @@ -2631,11 +2631,11 @@ free_vnode(vnode, true); } - return B_OK; + return vnode != NULL ? B_OK : B_ENTRY_NOT_FOUND; } -extern "C" status_t +extern "C" status_t unremove_vnode(dev_t mountID, ino_t vnodeID) { struct vnode *vnode; @@ -2651,7 +2651,7 @@ } -extern "C" status_t +extern "C" status_t get_vnode_removed(dev_t mountID, ino_t vnodeID, bool* removed) { mutex_lock(&sVnodeMutex); From axeld at mail.berlios.de Sun Jul 15 15:31:03 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 15 Jul 2007 15:31:03 +0200 Subject: [Haiku-commits] r21615 - haiku/trunk/docs/user/drivers Message-ID: <200707151331.l6FDV3V6032060@sheep.berlios.de> Author: axeld Date: 2007-07-15 15:31:02 +0200 (Sun, 15 Jul 2007) New Revision: 21615 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21615&view=rev Modified: haiku/trunk/docs/user/drivers/fs_interface.dox Log: * Removed deprecated functions. * The documented the notify_*() functions - only notify_listener() was deprecated among them. * Replaced spaces with tabs - there is no reason to deviate from the standard we're using everywhere else. * Completed the docs here and there. Modified: haiku/trunk/docs/user/drivers/fs_interface.dox =================================================================== --- haiku/trunk/docs/user/drivers/fs_interface.dox 2007-07-15 12:38:13 UTC (rev 21614) +++ haiku/trunk/docs/user/drivers/fs_interface.dox 2007-07-15 13:31:02 UTC (rev 21615) @@ -1,179 +1,168 @@ -?/* +/* * Copyright 2007 Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: - * Ingo Weinhold - * Niels Sascha Reedijk + * Ingo Weinhold + * Niels Sascha Reedijk + * Axel D?rfler, axeld at pinc-software.de + * * Corresponds to: - * /trunk/headers/os/drivers/fs_interface.h rev 21568 + * /trunk/headers/os/drivers/fs_interface.h rev 21568 */ -/*! - \file fs_interface.h - \ingroup drivers - \brief Provides an interface for file system modules. - - See the \ref fs_modules "introduction to file system modules" for a guide on - how to get started with writing file system modules. -*/ - -///// Typedefs ///// - -/*! - \typedef typedef void *fs_volume - \brief Private data structure for the filesystem to store data associated - with volumes. -*/ - /*! - \typedef typedef void *fs_cookie - \brief Private data structure that is passed to the filesystem when it is - called. -*/ + \file fs_interface.h + \ingroup drivers + \brief Provides an interface for file system modules. -/*! - \typedef typedef void *fs_vnode - \brief Private data structure that is passed to the filesystem when it is - operating on vnodes. + See the \ref fs_modules "introduction to file system modules" for a guide on + how to get started with writing file system modules. */ ///// write_stat_mask ////// /*! - \enum write_stat_mask - \brief This mask is used in file_system_module_info::write_stat() to - determine which values need to be written. + \enum write_stat_mask + \brief This mask is used in file_system_module_info::write_stat() to + determine which values need to be written. */ /*! - \var write_stat_mask::FS_WRITE_STAT_MODE - \brief The mode parameter should be updated. + \var write_stat_mask::FS_WRITE_STAT_MODE + \brief The mode parameter should be updated. */ /*! - \var write_stat_mask::FS_WRITE_STAT_UID - \brief The UID field should be updated. + \var write_stat_mask::FS_WRITE_STAT_UID + \brief The UID field should be updated. */ /*! - \var write_stat_mask::FS_WRITE_STAT_GID - \brief The GID field should be updated. + \var write_stat_mask::FS_WRITE_STAT_GID + \brief The GID field should be updated. */ /*! - \var write_stat_mask::FS_WRITE_STAT_SIZE - \brief The size field should be updated. If the actual size is less than the - new provided file size, the file should be set to the new size and the - extra space should be filled with zeros. + \var write_stat_mask::FS_WRITE_STAT_SIZE + \brief The size field should be updated. If the actual size is less than the + new provided file size, the file should be set to the new size and the + extra space should be filled with zeros. */ /*! - \var write_stat_mask::FS_WRITE_STAT_ATIME - \brief The access time should be updated. + \var write_stat_mask::FS_WRITE_STAT_ATIME + \brief The access time should be updated. */ /*! - \var write_stat_mask::FS_WRITE_STAT_MTIME - \brief The 'last modified' field should be updated. + \var write_stat_mask::FS_WRITE_STAT_MTIME + \brief The 'last modified' field should be updated. */ /*! - \var write_stat_mask::FS_WRITE_STAT_CRTIME - \brief The 'creation time' should be updated. + \var write_stat_mask::FS_WRITE_STAT_CRTIME + \brief The 'creation time' should be updated. */ ///// FS_WRITE_FSINFO_NAME ///// /*! - \def FS_WRITE_FSINFO_NAME - \brief Passed to file_system_module_info::write_fs_info(). + \def FS_WRITE_FSINFO_NAME + \brief Passed to file_system_module_info::write_fs_info(). */ ///// file_io_vec ///// /*! - \struct file_io_vec - \brief Structure that describes the io vector of a file. + \struct file_io_vec + \brief Structure that describes the io vector of a file. */ /*! - \var off_t file_io_vec::offset - \brief The offset within the file. + \var off_t file_io_vec::offset + \brief The offset within the file. */ /*! - \var off_t file_io_vec::length - \brief The length of the vector. + \var off_t file_io_vec::length + \brief The length of the vector. */ ///// B_CURRENT_FS_API_VERSION ///// /*! - \def B_CURRENT_FS_API_VERSION - \brief Constant that defines the version of the filesystem API that your - filesystem conforms to. + \def B_CURRENT_FS_API_VERSION + \brief Constant that defines the version of the file system API that your + filesystem conforms to. + + The module name that exports the interface to your file system has to + end with this constant as in: + \code "file_systems/myfs" B_CURRENT_FS_API_VERSION */ ///// file_system_module_info ///// /*! - \struct file_system_module_info - \brief Kernel module interface for file systems. - - See the \ref fs_modules "introduction to file system modules" for an - introduction to writing file systems. + \struct file_system_module_info + \brief Kernel module interface for file systems. + + See the \ref fs_modules "introduction to file system modules" for an + introduction to writing file systems. */ /*! - \name Data members + \name Data members */ //! @{ /*! - \var module_info file_system_module_info::info - \brief Your module_info object which is required for all modules. + \var module_info file_system_module_info::info + \brief Your module_info object which is required for all modules. */ /*! - \var const char *file_system_module_info::pretty_name - \brief A NULL-terminated string with a 'pretty' name for you file system. + \var const char *file_system_module_info::pretty_name + \brief A NULL-terminated string with a 'pretty' name for you file system. + + Note, if a system wide disk device type constant exists for your file system, + it should equal this identifier. */ //! @} /*! - \name Scanning + \name Scanning */ //! @{ /*! - \fn float (*file_system_module_info::identify_partition)(int fd, partition_data *partition, void **cookie) - \brief Undocumented. TODO. + \fn float (*file_system_module_info::identify_partition)(int fd, partition_data *partition, void **cookie) + \brief Undocumented. TODO. */ /*! - \fn status_t (*file_system_module_info::scan_partition)(int fd, partition_data *partition, void *cookie) - \brief Undocumented. TODO. + \fn status_t (*file_system_module_info::scan_partition)(int fd, partition_data *partition, void *cookie) + \brief Undocumented. TODO. */ /*! - \fn void (*file_system_module_info::free_identify_partition_cookie)(partition_data *partition, void *cookie) - \brief Undocumented. TODO. + \fn void (*file_system_module_info::free_identify_partition_cookie)(partition_data *partition, void *cookie) + \brief Undocumented. TODO. */ /*! - \fn void (*file_system_module_info::free_partition_content_cookie)(partition_data *partition) - \brief Undocumented. TODO. + \fn void (*file_system_module_info::free_partition_content_cookie)(partition_data *partition) + \brief Undocumented. TODO. */ //! @} /*! - \name General Operations + \name General Operations */ //! @{ @@ -259,33 +248,33 @@ */ /*! - \fn status_t (*file_system_module_info::write_fs_info)(fs_volume fs, const + \fn status_t (*file_system_module_info::write_fs_info)(fs_volume fs, const struct fs_info *info, uint32 mask) - \brief Update filesystem information on the volume. - - You are requested to update certain information on the volume \a fs. The - supplied \a info contains the new values filled in for the \a mask. - Currently, the only possible mask is solely the \c FS_WRITE_FSINFO_NAME, - which asks you to update the volume name represented by the value - \c volume_name in the \c fs_info struct. - - \param fs The cookie your filesystem supplied to the volume that should be - updated. - \param info The structure that contains the new data. - \param mask The values of the \a info that need to be updated. + \brief Update filesystem information on the volume. + + You are requested to update certain information on the volume \a fs. The + supplied \a info contains the new values filled in for the \a mask. + Currently, the only possible mask is solely the \c FS_WRITE_FSINFO_NAME, + which asks you to update the volume name represented by the value + \c volume_name in the \c fs_info struct. + + \param fs The cookie your filesystem supplied to the volume that should be + updated. + \param info The structure that contains the new data. + \param mask The values of the \a info that need to be updated. \return \c B_OK if everything went fine, if not, one of the error codes. */ /*! \fn status_t (*file_system_module_info::sync)(fs_volume fs) - \brief Synchronize the cached data with the contents of the disk. - - The VFS layer sometimes wants you to synchronize any cached values with the - data on the device. - - TODO: WHEN IS THIS CALLED AND FOR WHAT PURPOSE? - - \param fs The cookie your filesystem supplied to the volume that should be + \brief Synchronize the cached data with the contents of the disk. + + The VFS layer sometimes wants you to synchronize any cached values with the + data on the device. + + TODO: WHEN IS THIS CALLED AND FOR WHAT PURPOSE? + + \param fs The cookie your filesystem supplied to the volume that should be updated. */ @@ -330,15 +319,15 @@ */ /*! - \fn status_t (*file_system_module_info::get_vnode_name)(fs_volume fs, + \fn status_t (*file_system_module_info::get_vnode_name)(fs_volume fs, fs_vnode vnode, char *buffer, size_t bufferSize) - \brief Return the file name of a vnode. - - \param fs The file system provided cookie associated with this volume. - \param vnode The file system provided cookie associated with this vnode. - \param buffer The buffer that the name can be copied into. - \param bufferSize The size of the buffer. - \retval B_OK You successfully copied the file name into the \a buffer. + \brief Return the file name of a vnode. + + \param fs The file system provided cookie associated with this volume. + \param vnode The file system provided cookie associated with this vnode. + \param buffer The buffer that the name can be copied into. + \param bufferSize The size of the buffer. + \retval B_OK You successfully copied the file name into the \a buffer. \retval "other errors" There was some error looking up or copying the name. */ @@ -399,9 +388,9 @@ /*! \fn bool (*file_system_module_info::can_page)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) - \brief Undocumented. TODO. - - TODO: In both the dos and the bfs implementations this thing simply returns + \brief Undocumented. TODO. + + TODO: In both the dos and the bfs implementations this thing simply returns false... Is there anything more to it? */ @@ -442,64 +431,64 @@ //! @{ /*! - \fn status_t (*file_system_module_info::ioctl)(fs_volume fs, fs_vnode vnode, + \fn status_t (*file_system_module_info::ioctl)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, ulong op, void *buffer, size_t length) - \brief Perform file system specific operations. - - You can implement a customized API using this call. This can be extremely - handy for debugging purposes. There are no obligatory operations for you to - implement. - - If you don't want to use this feature, you don't have to implement it. - - \param fs The file system provided cookie associated with this volume. - \param vnode The file system provided cookie associated with the vnode (if - applicable). - \param cookie The file system provided cookie associated with, for example, - an open file (if applicable). - \param op The operation code. You will have to define them yourself. - \param buffer A buffer (if applicable). - \param length The size of the buffer. + \brief Perform file system specific operations. + + You can implement a customized API using this call. This can be extremely + handy for debugging purposes. There are no obligatory operations for you to + implement. + + If you don't want to use this feature, you don't have to implement it. + + \param fs The file system provided cookie associated with this volume. + \param vnode The file system provided cookie associated with the vnode (if + applicable). + \param cookie The file system provided cookie associated with, for example, + an open file (if applicable). + \param op The operation code. You will have to define them yourself. + \param buffer A buffer (if applicable). + \param length The size of the buffer. \return You should return any of your status codes. */ /*! - \fn status_t (*file_system_module_info::set_flags)(fs_volume fs, fs_vnode + \fn status_t (*file_system_module_info::set_flags)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, int flags) - \brief Set the open mode flags for an opened file. - - This function should change the open flags for an opened file. - - \param fs The file system provided cookie associated with this volume. - \param vnode The file system provided cookie associated with the vnode. - \param cookie The file system provided cookie associated with the opened - file. - \param flags The new flags. + \brief Set the open mode flags for an opened file. + + This function should change the open flags for an opened file. + + \param fs The file system provided cookie associated with this volume. + \param vnode The file system provided cookie associated with the vnode. + \param cookie The file system provided cookie associated with the opened + file. + \param flags The new flags. \return \c B_OK if the operation succeeded, or else an error code. */ /*! \fn status_t (*file_system_module_info::select)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, uint8 event, uint32 ref, selectsync *sync) - \brief Undocumented. TODO. - + \brief Undocumented. TODO. + TODO: What should this do? */ /*! \fn status_t (*file_system_module_info::deselect)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, uint8 event, selectsync *sync) - \brief Undocumented. TODO. - + \brief Undocumented. TODO. + TODO: What should this do? */ /*! \fn status_t (*file_system_module_info::fsync)(fs_volume fs, fs_vnode vnode) - \brief Synchronize the buffers with the on disk data. - - \param fs The file system provided cookie associated with this volume. - \param vnode The file system provided cookie associated with the vnode. + \brief Synchronize the buffers with the on disk data. + + \param fs The file system provided cookie associated with this volume. + \param vnode The file system provided cookie associated with the vnode. \return \c B_OK if the operation succeeded, or else an error code. */ @@ -526,84 +515,84 @@ */ /*! - \fn status_t (*file_system_module_info::create_symlink)(fs_volume fs, + \fn status_t (*file_system_module_info::create_symlink)(fs_volume fs, fs_vnode dir, const char *name, const char *path, int mode) - \brief Create a new symbolic link. - - Your implementation should check if the user has permission to perform this - operation. - - \param fs The file system provided cookie associated with this volume. - \param dir The file system provided cookie associated with the directory - the symbolic link should be created in. - \param name The name of the new symbolic link. - \param path The path of the original inode the symbolic link should refer to. - \param mode The mode that this symbolic link should be created in. (TODO - what exactly?) + \brief Create a new symbolic link. + + Your implementation should check if the user has permission to perform this + operation. + + \param fs The file system provided cookie associated with this volume. + \param dir The file system provided cookie associated with the directory + the symbolic link should be created in. + \param name The name of the new symbolic link. + \param path The path of the original inode the symbolic link should refer to. + \param mode The mode that this symbolic link should be created in. (TODO + what exactly?) \return \c B_OK if you succeeded, or an error code if you failed. */ /*! - \fn status_t (*file_system_module_info::link)(fs_volume fs, fs_vnode dir, + \fn status_t (*file_system_module_info::link)(fs_volume fs, fs_vnode dir, const char *name, fs_vnode vnode) - \brief Create a new hard link. - - You should make sure the user has the proper permissions. - - The virtual file system will request the creation of symbolic links with - create_symlink(). - - \param fs The file system provided cookie associated with this volume. - \param dir The cookie associated to the directory where the link should be - saved. - \param name The name the link should have. - \param vnode The vnode the new link should resolve to. - \retval B_OK The hard link is properly created. - \retval B_NOT_ALLOWED The user does not have the proper permissions. - \retval "other errors" Another error occured. + \brief Create a new hard link. + + You should make sure the user has the proper permissions. + + The virtual file system will request the creation of symbolic links with + create_symlink(). + + \param fs The file system provided cookie associated with this volume. + \param dir The cookie associated to the directory where the link should be + saved. + \param name The name the link should have. + \param vnode The vnode the new link should resolve to. + \retval B_OK The hard link is properly created. + \retval B_NOT_ALLOWED The user does not have the proper permissions. + \retval "other errors" Another error occured. */ /*! - \fn status_t (*file_system_module_info::unlink)(fs_volume fs, fs_vnode dir, + \fn status_t (*file_system_module_info::unlink)(fs_volume fs, fs_vnode dir, const char *name) - \brief Remove a node or directory. - - You should make sure the user has the proper permissions. - - \param fs The file system provided cookie associated with this volume. - \param dir The parent directory of the node that should be removed. - \param name The name of the node that should be deleted. - \retval B_OK Removal succeeded. - \retval B_ENTRY_NOT_FOUND The entry does not exist. - \retval B_NOT_ALLOWED The user does not have the proper permissions. - \retval B_DIRECTORY_NOT_EMPTY The \a name refers to a directory. The virtual - file system expects directories to be emptied before they can be unlinked. + \brief Remove a node or directory. + + You should make sure the user has the proper permissions. + + \param fs The file system provided cookie associated with this volume. + \param dir The parent directory of the node that should be removed. + \param name The name of the node that should be deleted. + \retval B_OK Removal succeeded. + \retval B_ENTRY_NOT_FOUND The entry does not exist. + \retval B_NOT_ALLOWED The user does not have the proper permissions. + \retval B_DIRECTORY_NOT_EMPTY The \a name refers to a directory. The virtual + file system expects directories to be emptied before they can be unlinked. \retval "other errors" Another error occured. */ /*! - \fn status_t (*file_system_module_info::rename)(fs_volume fs, fs_vnode + \fn status_t (*file_system_module_info::rename)(fs_volume fs, fs_vnode fromDir, const char *fromName, fs_vnode toDir, const char *toName) - \brief Rename and/or relocate a vnode. - - The virtual file system merely relays the request, so make sure the user is - not changing the file name to something like '.', '..' or anything starting - with '/'. - - This also means that it if the node is a directory, that it should not be - moved into one of its own children. - - You should also make sure the user has the proper permissions. - - \param fs The file system provided cookie associated with this volume. - \param fromDir The cookie of the parent directory the vnode should be moved - from. - \param fromName The old name of the node. - \param toDir The cookie of the parent directory the vnode should be moved to. - \param toName The new name of the node. - \retval B_OK The renaming and relocating succeeded. - \retval B_BAD_VALUE One of the supplied parameters were invalid. - \retval B_NOT_ALLOWED The user does not have the proper permissions. + \brief Rename and/or relocate a vnode. + + The virtual file system merely relays the request, so make sure the user is + not changing the file name to something like '.', '..' or anything starting + with '/'. + + This also means that it if the node is a directory, that it should not be + moved into one of its own children. + + You should also make sure the user has the proper permissions. + + \param fs The file system provided cookie associated with this volume. + \param fromDir The cookie of the parent directory the vnode should be moved + from. + \param fromName The old name of the node. + \param toDir The cookie of the parent directory the vnode should be moved to. + \param toName The new name of the node. + \retval B_OK The renaming and relocating succeeded. + \retval B_BAD_VALUE One of the supplied parameters were invalid. + \retval B_NOT_ALLOWED The user does not have the proper permissions. \retval "other errors" Another error condition was encountered. */ @@ -658,20 +647,20 @@ */ /*! - \fn status_t (*file_system_module_info::write_stat)(fs_volume fs, fs_vnode + \fn status_t (*file_system_module_info::write_stat)(fs_volume fs, fs_vnode vnode, const struct stat *stat, uint32 statMask) - \brief Update the stats for a vnode. - - You should make sure that the new values are valid and that the user has the - proper permissions to update the stats. - - \param fs The file system provided cookie to the volume. - \param vnode The cookie to the vnode. - \param stat The structure with the updated values. - \param statMask One of the #write_stat_mask enumeration, which forms a mask - of which of the values in \a stat should actually be updated. - \retval B_OK The update succeeded. - \retval B_NOT_ALLOWED The user does not have the proper permissions. + \brief Update the stats for a vnode. + + You should make sure that the new values are valid and that the user has the + proper permissions to update the stats. + + \param fs The file system provided cookie to the volume. + \param vnode The cookie to the vnode. + \param stat The structure with the updated values. + \param statMask One of the #write_stat_mask enumeration, which forms a mask + of which of the values in \a stat should actually be updated. + \retval B_OK The update succeeded. + \retval B_NOT_ALLOWED The user does not have the proper permissions. \retval "other errors" Another error condition occured. */ @@ -684,30 +673,30 @@ //! @{ /*! - \fn status_t (*file_system_module_info::create)(fs_volume fs, fs_vnode dir, + \fn status_t (*file_system_module_info::create)(fs_volume fs, fs_vnode dir, const char *name, int openMode, int perms, fs_cookie *_cookie, ino_t *_newVnodeID) - \brief Create a new file. - - Your implementation shall check whether it is possible to create the node. - You will need to take the user's permissions into account. When you create - a new file, you will also have to open it. This means also checking the - permissions the user requires to open the file according to the \a mode. - See \link file_system_module_info::open() open() \endlink for the possible - values of \a mode. - - \param fs The file system provided cookie associated with this volume. - \param dir The file system provided cookie associated with the directory - where the file should appear. - \param name The name of the new file. - \param openMode The mode associated to the file. - \param perms The permissions the new file should have. - \param[out] _cookie In case of success, the you can store your file system - data for this node in this variable. - \param[out] _newVnodeID In case of success, you can store the new vnode id - in this variable. - \return You should return \c B_OK if creating the new node succeeded, and if - you put data in both \a _cookie and \a _newVnodeID. Else you should return + \brief Create a new file. + + Your implementation shall check whether it is possible to create the node. + You will need to take the user's permissions into account. When you create + a new file, you will also have to open it. This means also checking the + permissions the user requires to open the file according to the \a mode. + See \link file_system_module_info::open() open() \endlink for the possible + values of \a mode. + + \param fs The file system provided cookie associated with this volume. + \param dir The file system provided cookie associated with the directory + where the file should appear. + \param name The name of the new file. + \param openMode The mode associated to the file. + \param perms The permissions the new file should have. + \param[out] _cookie In case of success, the you can store your file system + data for this node in this variable. + \param[out] _newVnodeID In case of success, you can store the new vnode id + in this variable. + \return You should return \c B_OK if creating the new node succeeded, and if + you put data in both \a _cookie and \a _newVnodeID. Else you should return an error code. */ @@ -799,29 +788,29 @@ */ /*! - \fn status_t (*file_system_module_info::write)(fs_volume fs, fs_vnode vnode, + \fn status_t (*file_system_module_info::write)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos, const void *buffer, size_t *length) - \brief Write data to a file. - - This function should fail if - - the node is not a file, - - the cookie has not been opened for writing, - - \a pos is negative, or - - some other error occurs while trying to read the data, and no data have - been read at all. - - The number of bytes to be written is stored in the variable pointed to by - \a length. - - TODO: What to do if we were to write less than the \a length? Should this - function fail? - - \param fs The file system provided cookie associated with this volume. - \param vnode The file system provided cookie associated with the vnode. - \param cookie The file system provided cookie associated with the file. - \param pos The position to start writing. - \param buffer The buffer that contains the data that will need to be written. - \param length The length of the data that needs to be written. + \brief Write data to a file. + + This function should fail if + - the node is not a file, + - the cookie has not been opened for writing, + - \a pos is negative, or + - some other error occurs while trying to read the data, and no data have + been read at all. + + The number of bytes to be written is stored in the variable pointed to by + \a length. + + TODO: What to do if we were to write less than the \a length? Should this + function fail? + + \param fs The file system provided cookie associated with this volume. + \param vnode The file system provided cookie associated with the vnode. + \param cookie The file system provided cookie associated with the file. + \param pos The position to start writing. + \param buffer The buffer that contains the data that will need to be written. + \param length The length of the data that needs to be written. \return \c B_OK if everything went fine, another error code otherwise. */ @@ -832,45 +821,45 @@ */ /*! - \fn status_t (*file_system_module_info::create_dir)(fs_volume fs, fs_vnode + \fn status_t (*file_system_module_info::create_dir)(fs_volume fs, fs_vnode parent, const char *name, int perms, ino_t *_newVnodeID) - \brief Create a new directory. - - Your implementation should make sure that the directory actually can be - created in the \a parent directory. You will have to check if the user has - permissions to actually write to the \a parent. If not, this function should - fail (probably with \c B_NOT_ALLOWED, or in case of a read-only filesystem, - with \c B_READ_ONLY_DEVICE). If the operation succeeds, you should put the - new vnode id in \a _newVnodeID. - - \param fs The file system provided cookie associated with this volume. - \param parent The file system provided cookie associated with the parent - node. - \param name The name the new directory should have. - \param perms The permissions the new directory should have. - \param[out] _newVnodeID If creating the directory succeeds, than you should - put the new vnode id in this variable. - \return If the operation succeeds and the \a _newVnodeID is populated with - the new vnode, then you should return \c B_OK. Else you should return with + \brief Create a new directory. + + Your implementation should make sure that the directory actually can be + created in the \a parent directory. You will have to check if the user has + permissions to actually write to the \a parent. If not, this function should + fail (probably with \c B_NOT_ALLOWED, or in case of a read-only filesystem, + with \c B_READ_ONLY_DEVICE). If the operation succeeds, you should put the + new vnode id in \a _newVnodeID. + + \param fs The file system provided cookie associated with this volume. + \param parent The file system provided cookie associated with the parent + node. + \param name The name the new directory should have. + \param perms The permissions the new directory should have. + \param[out] _newVnodeID If creating the directory succeeds, than you should + put the new vnode id in this variable. + \return If the operation succeeds and the \a _newVnodeID is populated with + the new vnode, then you should return \c B_OK. Else you should return with an error code. */ /*! - \fn status_t (*file_system_module_info::remove_dir)(fs_volume fs, fs_vnode + \fn status_t (*file_system_module_info::remove_dir)(fs_volume fs, fs_vnode parent, const char *name) - \brief Remove a directory. - - You should make sure the user has the proper permissions. You should also - check that the directory is empty. - - \param fs The file system provided cookie associated with this volume. - \param parent The file system provided cookie associated with the parent - node. - \param name The \a name of the directory that needs to be removed. - \retval B_OK Operation succeeded. - \retval B_DIRECTORY_NOT_EMPTY The directory is not empty. - \retval B_ENTRY_NOT_FOUND There is no directory with this \a name. - \retval B_NOT_A_DIRECTORY The entry is not a directory. + \brief Remove a directory. + + You should make sure the user has the proper permissions. You should also + check that the directory is empty. + + \param fs The file system provided cookie associated with this volume. + \param parent The file system provided cookie associated with the parent + node. + \param name The \a name of the directory that needs to be removed. + \retval B_OK Operation succeeded. + \retval B_DIRECTORY_NOT_EMPTY The directory is not empty. + \retval B_ENTRY_NOT_FOUND There is no directory with this \a name. + \retval B_NOT_A_DIRECTORY The entry is not a directory. \retval "other errors" Other errors occured. */ @@ -987,63 +976,63 @@ //! @{ /*! - \fn status_t (*file_system_module_info::open_attr_dir)(fs_volume fs, fs_vnode + \fn status_t (*file_system_module_info::open_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie *_cookie) - \brief Open a 'directory' of attributes for a \a vnode. - - See \ref concepts "Generic Concepts" on directories and iterators. Basically, - the VFS uses the same way of traversing through attributes as it traverses - through a directory. - - \param fs The file system provided cookie to the volume. - \param vnode The vnode on which the file system wants to read the attributes. - \param[out] _cookie Pointer where the file system can store a directory - cookie if the attribute directory is succesfully opened. + \brief Open a 'directory' of attributes for a \a vnode. + + See \ref concepts "Generic Concepts" on directories and iterators. Basically, + the VFS uses the same way of traversing through attributes as it traverses + through a directory. + + \param fs The file system provided cookie to the volume. + \param vnode The vnode on which the file system wants to read the attributes. + \param[out] _cookie Pointer where the file system can store a directory + cookie if the attribute directory is succesfully opened. \return \c B_OK if everything went fine, another error code otherwise. */ /*! - \fn status_t (*file_system_module_info::close_attr_dir)(fs_volume fs, + \fn status_t (*file_system_module_info::close_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) - \brief Close a 'directory' of attributes for a \a vnode. - - Note that you should free the cookie in the free_attr_dir_cookie() call. - - \param fs The file system provided cookie to the volume. - \param vnode The vnode on which the 'directory' was opened. - \param cookie The cookie associated with this 'directory'. + \brief Close a 'directory' of attributes for a \a vnode. + + Note that you should free the cookie in the free_attr_dir_cookie() call. + + \param fs The file system provided cookie to the volume. + \param vnode The vnode on which the 'directory' was opened. + \param cookie The cookie associated with this 'directory'. \return \c B_OK if everything went fine, another error code otherwise. */ /*! - \fn status_t (*file_system_module_info::free_attr_dir_cookie)(fs_volume fs, + \fn status_t (*file_system_module_info::free_attr_dir_cookie)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) - \brief Free the \a cookie to an attribute 'directory'. - - \param fs The file system provided cookie to the volume. - \param vnode The vnode on which the 'directory' was opened. - \param cookie The cookie associated that should be freed. + \brief Free the \a cookie to an attribute 'directory'. + + \param fs The file system provided cookie to the volume. + \param vnode The vnode on which the 'directory' was opened. + \param cookie The cookie associated that should be freed. \return \c B_OK if everything went fine, another error code otherwise. */ /*! - \fn status_t (*file_system_module_info::read_attr_dir)(fs_volume fs, fs_vnode - vnode, fs_cookie cookie, struct dirent *buffer, size_t bufferSize, + \fn status_t (*file_system_module_info::read_attr_dir)(fs_volume fs, fs_vnode + vnode, fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num) - \brief Read the next one or more attribute directory entries. - - This method should perform the same tasks as read_dir(), except that the '.' + \brief Read the next one or more attribute directory entries. + + This method should perform the same tasks as read_dir(), except that the '.' and '..' entries do not have to be present. */ /*! - \fn status_t (*file_system_module_info::rewind_attr_dir)(fs_volume fs, + \fn status_t (*file_system_module_info::rewind_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) - \brief Rewind the attribute directory iterator to the first entry. - - \param fs The file system provided cookie to the volume. - \param vnode The vnode on which the 'directory' was opened. - \param cookie The cookie associated with this 'directory'. + \brief Rewind the attribute directory iterator to the first entry. + + \param fs The file system provided cookie to the volume. + \param vnode The vnode on which the 'directory' was opened. + \param cookie The cookie associated with this 'directory'. \return \c B_OK if everything went fine, another error code otherwise. */ @@ -1056,154 +1045,154 @@ //! @{ /*! - \fn status_t (*file_system_module_info::create_attr)(fs_volume fs, fs_vnode + \fn status_t (*file_system_module_info::create_attr)(fs_volume fs, fs_vnode vnode, const char *name, uint32 type, int openMode, fs_cookie *_cookie) - \brief Create a new attribute. - - If the attribute already exists, you should open it in truncated mode. - - \param fs The file system provided cookie to the volume. - \param vnode The file system provided cookie to the vnode. - \param name The name of the attribute. - \param type The \c type_code of the attribute. - \param openMode The openMode of the associated attribute. - \param[out] _cookie A pointer where you can store an associated file system - cookie. + \brief Create a new attribute. + + If the attribute already exists, you should open it in truncated mode. + + \param fs The file system provided cookie to the volume. + \param vnode The file system provided cookie to the vnode. + \param name The name of the attribute. + \param type The \c type_code of the attribute. + \param openMode The openMode of the associated attribute. + \param[out] _cookie A pointer where you can store an associated file system + cookie. \return \c B_OK if everything went fine, another error code otherwise. */ /*! - \fn status_t (*file_system_module_info::open_attr)(fs_volume fs, fs_vnode + \fn status_t (*file_system_module_info::open_attr)(fs_volume fs, fs_vnode vnode, const char *name, int openMode, fs_cookie *_cookie) - \brief Open an existing attribute. - - \param fs The file system provided cookie to the volume. - \param vnode The file system provided cookie to the vnode. - \param name The name of the attribute. - \param openMode The mode in which you want to open the attribute data. - \param[out] _cookie A pointer where you can store an associated file system - cookie. + \brief Open an existing attribute. + + \param fs The file system provided cookie to the volume. + \param vnode The file system provided cookie to the vnode. + \param name The name of the attribute. + \param openMode The mode in which you want to open the attribute data. + \param[out] _cookie A pointer where you can store an associated file system + cookie. \return \c B_OK if everything went fine, another error code otherwise. */ /*! - \fn status_t (*file_system_module_info::close_attr)(fs_volume fs, fs_vnode + \fn status_t (*file_system_module_info::close_attr)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) - \brief Close access to an attribute. - - Note that you should not delete the cookie yet, you should do that when the - VFS calls free_attr_cookie(). - - \param fs The file system provided cookie to the volume. - \param vnode The file system provided cookie to the vnode. - \param cookie The cookie you associated to this attribute. + \brief Close access to an attribute. + + Note that you should not delete the cookie yet, you should do that when the + VFS calls free_attr_cookie(). + + \param fs The file system provided cookie to the volume. + \param vnode The file system provided cookie to the vnode. + \param cookie The cookie you associated to this attribute. \return \c B_OK if everything went fine, another error code otherwise. */ /*! - \fn status_t (*file_system_module_info::free_attr_cookie)(fs_volume fs, + \fn status_t (*file_system_module_info::free_attr_cookie)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) - \brief Free the cookie of an attribute. - - The VFS calls this hook when all operations on the attribute have ceased. - - \param fs The file system provided cookie to the volume. - \param vnode The file system provided cookie to the vnode. - \param cookie The cookie to the attribute that should be freed. + \brief Free the cookie of an attribute. [... truncated: 841 lines follow ...] From korli at mail.berlios.de Sun Jul 15 19:43:04 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Sun, 15 Jul 2007 19:43:04 +0200 Subject: [Haiku-commits] r21616 - in haiku/trunk: headers/private/firewire src/bin/fwcontrol Message-ID: <200707151743.l6FHh4Tq024734@sheep.berlios.de> Author: korli Date: 2007-07-15 19:43:02 +0200 (Sun, 15 Jul 2007) New Revision: 21616 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21616&view=rev Added: haiku/trunk/headers/private/firewire/eui64.h haiku/trunk/headers/private/firewire/firewire.h haiku/trunk/headers/private/firewire/fwphyreg.h haiku/trunk/headers/private/firewire/iec13213.h haiku/trunk/headers/private/firewire/iec68113.h haiku/trunk/headers/private/firewire/queue.h haiku/trunk/src/bin/fwcontrol/Jamfile haiku/trunk/src/bin/fwcontrol/eui64.c haiku/trunk/src/bin/fwcontrol/fwcontrol.8 haiku/trunk/src/bin/fwcontrol/fwcontrol.c haiku/trunk/src/bin/fwcontrol/fwcrom.c haiku/trunk/src/bin/fwcontrol/fwdv.c haiku/trunk/src/bin/fwcontrol/fwmethods.h haiku/trunk/src/bin/fwcontrol/fwmpegts.c Log: work from JiSheng Zhang : fwcontrol with firewire headers from FreeBSD current. Thanks! clean up Added: haiku/trunk/headers/private/firewire/eui64.h =================================================================== --- haiku/trunk/headers/private/firewire/eui64.h 2007-07-15 13:31:02 UTC (rev 21615) +++ haiku/trunk/headers/private/firewire/eui64.h 2007-07-15 17:43:02 UTC (rev 21616) @@ -0,0 +1,57 @@ +/*- + * Copyright 2004 The Aerospace Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions, and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of The Aerospace Corporation may not be used to endorse or + * promote products derived from this software. + * + * THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/sys/eui64.h,v 1.2 2005/01/07 02:29:23 imp Exp $ + */ +#ifndef _SYS_EUI64_H +#define _SYS_EUI64_H + +/* + * Size of the ASCII representation of an EUI-64. + */ +#define EUI64_SIZ 24 + +/* + * The number of bytes in an EUI-64. + */ +#define EUI64_LEN 8 + +/* + * Structure of an IEEE EUI-64. + */ +struct eui64 { + u_char octet[EUI64_LEN]; +}; + +#ifndef _KERNEL +int eui64_aton(const char *, struct eui64 *); +int eui64_ntoa(const struct eui64 *, char *, size_t); +int eui64_ntohost(char *, size_t, const struct eui64 *); +int eui64_hostton(const char *, struct eui64 *); +#endif /* !_KERNEL */ + +#endif /* !_SYS_EUI64_H */ Added: haiku/trunk/headers/private/firewire/firewire.h =================================================================== --- haiku/trunk/headers/private/firewire/firewire.h 2007-07-15 13:31:02 UTC (rev 21615) +++ haiku/trunk/headers/private/firewire/firewire.h 2007-07-15 17:43:02 UTC (rev 21616) @@ -0,0 +1,437 @@ +/*- + * Copyright (c) 2003 Hidetoshi Shimokawa + * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the acknowledgement as bellow: + * + * This product includes software developed by K. Kobayashi and H. Shimokawa + * + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/sys/dev/firewire/firewire.h,v 1.21 2007/04/24 12:15:05 simokawa Exp $ + * + */ + +#ifndef _FIREWIRE_H +#define _FIREWIRE_H 1 +#ifdef __HAIKU__ +#include +#include +#endif + +#define DEV_DEF 0 +#define DEV_DV 2 + +struct fw_isochreq { + unsigned char ch:6, + tag:2; +}; + +struct fw_isobufreq { + struct fw_bufspec { + unsigned int nchunk; + unsigned int npacket; + unsigned int psize; + } tx, rx; +}; + +struct fw_addr { + uint32_t hi; + uint32_t lo; +}; + +struct fw_asybindreq { + struct fw_addr start; + unsigned long len; +}; + +struct fw_reg_req_t { + uint32_t addr; + uint32_t data; +}; + +#define MAXREC(x) (2 << (x)) +#define FWPMAX_S400 (2048 + 20) /* MAXREC plus space for control data */ +#define FWMAXQUEUE 128 + +#define FWLOCALBUS 0xffc0 + +#define FWTCODE_WREQQ 0 +#define FWTCODE_WREQB 1 +#define FWTCODE_WRES 2 +#define FWTCODE_RREQQ 4 +#define FWTCODE_RREQB 5 +#define FWTCODE_RRESQ 6 +#define FWTCODE_RRESB 7 +#define FWTCODE_CYCS 8 +#define FWTCODE_LREQ 9 +#define FWTCODE_STREAM 0xa +#define FWTCODE_LRES 0xb +#define FWTCODE_PHY 0xe + +#define FWRETRY_1 0 +#define FWRETRY_X 1 +#define FWRETRY_A 2 +#define FWRETRY_B 3 + +#define FWRCODE_COMPLETE 0 +#define FWRCODE_ER_CONFL 4 +#define FWRCODE_ER_DATA 5 +#define FWRCODE_ER_TYPE 6 +#define FWRCODE_ER_ADDR 7 + +#define FWSPD_S100 0 +#define FWSPD_S200 1 +#define FWSPD_S400 2 + +#define FWP_TL_VALID (1 << 7) + +struct fw_isohdr { + uint32_t hdr[1]; +}; + +struct fw_asyhdr { + uint32_t hdr[4]; +}; + +#if BYTE_ORDER == BIG_ENDIAN +#define BIT4x2(x,y) uint8_t x:4, y:4 +#define BIT16x2(x,y) uint32_t x:16, y:16 +#else +#define BIT4x2(x,y) uint8_t y:4, x:4 +#define BIT16x2(x,y) uint32_t y:16, x:16 +#endif + + +#if BYTE_ORDER == BIG_ENDIAN +#define COMMON_HDR(a,b,c,d) uint32_t a:16,b:8,c:4,d:4 +#define COMMON_RES(a,b,c,d) uint32_t a:16,b:4,c:4,d:8 +#else +#define COMMON_HDR(a,b,c,d) uint32_t d:4,c:4,b:8,a:16 +#define COMMON_RES(a,b,c,d) uint32_t d:8,c:4,b:4,a:16 +#endif + +struct fw_pkt { + union { + uint32_t ld[0]; + struct { + COMMON_HDR(, , tcode, ); + } common; + struct { + COMMON_HDR(len, chtag, tcode, sy); + uint32_t payload[0]; + } stream; + struct { + COMMON_HDR(dst, tlrt, tcode, pri); + BIT16x2(src, ); + } hdr; + struct { + COMMON_HDR(dst, tlrt, tcode, pri); + BIT16x2(src, dest_hi); + uint32_t dest_lo; + } rreqq; + struct { + COMMON_HDR(dst, tlrt, tcode, pri); + COMMON_RES(src, rtcode, , ); + uint32_t :32; + } wres; + struct { + COMMON_HDR(dst, tlrt, tcode, pri); + BIT16x2(src, dest_hi); + uint32_t dest_lo; + BIT16x2(len, extcode); + } rreqb; + struct { + COMMON_HDR(dst, tlrt, tcode, pri); + BIT16x2(src, dest_hi); + uint32_t dest_lo; + uint32_t data; + } wreqq; + struct { + COMMON_HDR(dst, tlrt, tcode, pri); + BIT16x2(src, dest_hi); + uint32_t dest_lo; + uint32_t data; + } cyc; + struct { + COMMON_HDR(dst, tlrt, tcode, pri); + COMMON_RES(src, rtcode, , ); + uint32_t :32; + uint32_t data; + } rresq; + struct { + COMMON_HDR(dst, tlrt, tcode, pri); + BIT16x2(src, dest_hi); + uint32_t dest_lo; + BIT16x2(len, extcode); + uint32_t payload[0]; + } wreqb; + struct { + COMMON_HDR(dst, tlrt, tcode, pri); + BIT16x2(src, dest_hi); + uint32_t dest_lo; + BIT16x2(len, extcode); + uint32_t payload[0]; + } lreq; + struct { + COMMON_HDR(dst, tlrt, tcode, pri); + COMMON_RES(src, rtcode, , ); + uint32_t :32; + BIT16x2(len, extcode); + uint32_t payload[0]; + } rresb; + struct { + COMMON_HDR(dst, tlrt, tcode, pri); + COMMON_RES(src, rtcode, , ); + uint32_t :32; + BIT16x2(len, extcode); + uint32_t payload[0]; + } lres; + } mode; +}; + +/* + * Response code (rtcode) + */ +/* The node has successfully completed the command. */ +#define RESP_CMP 0 +/* A resource conflict was detected. The request may be retried. */ +#define RESP_CONFLICT_ERROR 4 +/* Hardware error, data is unavailable. */ +#define RESP_DATA_ERROR 5 +/* A field in the request packet header was set to an unsupported or incorrect + * value, or an invalid transaction was attempted (e.g., a write to a read-only + * address). */ +#define RESP_TYPE_ERROR 6 +/* The destination offset field in the request was set to an address not + * accessible in the destination node. */ +#define RESP_ADDRESS_ERROR 7 + +/* + * Extended transaction code (extcode) + */ +#define EXTCODE_MASK_SWAP 1 +#define EXTCODE_CMP_SWAP 2 +#define EXTCODE_FETCH_ADD 3 +#define EXTCODE_LITTLE_ADD 4 +#define EXTCODE_BOUNDED_ADD 5 +#define EXTCODE_WRAP_ADD 6 + +struct fw_eui64 { + uint32_t hi, lo; +}; +#define FW_EUI64_BYTE(eui, x) \ + ((((x)<4)? \ + ((eui)->hi >> (8*(3-(x)))): \ + ((eui)->lo >> (8*(7-(x)))) \ + ) & 0xff) +#define FW_EUI64_EQUAL(x, y) \ + ((x).hi == (y).hi && (x).lo == (y).lo) + +struct fw_asyreq { + struct fw_asyreq_t{ + unsigned char sped; + unsigned int type; +#define FWASREQNODE 0 +#define FWASREQEUI 1 +#define FWASRESTL 2 +#define FWASREQSTREAM 3 + unsigned short len; + union { + struct fw_eui64 eui; + }dst; + }req; + struct fw_pkt pkt; + uint32_t data[512]; +}; + +struct fw_devinfo { + struct fw_eui64 eui; + uint16_t dst; + uint16_t status; +}; + +#define FW_MAX_DEVLST 70 +struct fw_devlstreq { + uint16_t n; + uint16_t info_len; + struct fw_devinfo dev[FW_MAX_DEVLST]; +}; + +#define FW_SELF_ID_PORT_CONNECTED_TO_CHILD 3 +#define FW_SELF_ID_PORT_CONNECTED_TO_PARENT 2 +#define FW_SELF_ID_PORT_NOT_CONNECTED 1 +#define FW_SELF_ID_PORT_NOT_EXISTS 0 +#if BYTE_ORDER == BIG_ENDIAN +union fw_self_id { + struct { + uint32_t id:2, + phy_id:6, + sequel:1, + link_active:1, + gap_count:6, + phy_speed:2, + phy_delay:2, + contender:1, + power_class:3, + port0:2, + port1:2, + port2:2, + initiated_reset:1, + more_packets:1; + } p0; + struct { + uint32_t + id:2, + phy_id:6, + sequel:1, + sequence_num:3, + :2, + porta:2, + portb:2, + portc:2, + portd:2, + porte:2, + portf:2, + portg:2, + porth:2, + :1, + more_packets:1; + } p1; +}; +#else +union fw_self_id { + struct { + uint32_t more_packets:1, + initiated_reset:1, + port2:2, + port1:2, + port0:2, + power_class:3, + contender:1, + phy_delay:2, + phy_speed:2, + gap_count:6, + link_active:1, + sequel:1, + phy_id:6, + id:2; + } p0; + struct { + uint32_t more_packets:1, + reserved1:1, + porth:2, + portg:2, + portf:2, + porte:2, + portd:2, + portc:2, + portb:2, + porta:2, + reserved2:2, + sequence_num:3, + sequel:1, + phy_id:6, + id:2; + } p1; +}; +#endif + + +struct fw_topology_map { + uint32_t crc:16, + crc_len:16; + uint32_t generation; + uint32_t self_id_count:16, + node_count:16; + union fw_self_id self_id[4*64]; +}; + +struct fw_speed_map { + uint32_t crc:16, + crc_len:16; + uint32_t generation; + uint8_t speed[64][64]; +}; + +struct fw_crom_buf { + struct fw_eui64 eui; + uint32_t len; + void *ptr; +}; + +/* + * FireWire specific system requests. + */ +#define FW_SSTBUF _IOWR('S', 86, struct fw_isobufreq) +#define FW_GSTBUF _IOWR('S', 87, struct fw_isobufreq) +#define FW_SRSTREAM _IOWR('S', 88, struct fw_isochreq) +#define FW_GRSTREAM _IOWR('S', 89, struct fw_isochreq) +#define FW_STSTREAM _IOWR('S', 90, struct fw_isochreq) +#define FW_GTSTREAM _IOWR('S', 91, struct fw_isochreq) + +#define FW_ASYREQ _IOWR('S', 92, struct fw_asyreq) +#define FW_IBUSRST _IOR('S', 1, unsigned int) +#define FW_GDEVLST _IOWR('S', 2, struct fw_devlstreq) +#define FW_SBINDADDR _IOWR('S', 3, struct fw_asybindreq) +#define FW_CBINDADDR _IOWR('S', 4, struct fw_asybindreq) +#define FW_GTPMAP _IOR('S', 5, struct fw_topology_map) +#define FW_GCROM _IOWR('S', 7, struct fw_crom_buf) + +#define FW_SDEUI64 _IOW('S', 20, struct fw_eui64) +#define FW_GDEUI64 _IOR('S', 21, struct fw_eui64) + +#define FWOHCI_RDREG _IOWR('S', 80, struct fw_reg_req_t) +#define FWOHCI_WRREG _IOWR('S', 81, struct fw_reg_req_t) +#define FWOHCI_RDPHYREG _IOWR('S', 82, struct fw_reg_req_t) +#define FWOHCI_WRPHYREG _IOWR('S', 83, struct fw_reg_req_t) + +#define DUMPDMA _IOWR('S', 82, uint32_t) + +#ifdef _KERNEL + +#define FWMAXNDMA 0x100 /* 8 bits DMA channel id. in device No. */ + +#ifndef __HAIKU__ +#if defined(__DragonFly__) || __FreeBSD_version < 500000 +#define dev2unit(x) ((minor(x) & 0xff) | (minor(x) >> 8)) +#define unit2minor(x) (((x) & 0xff) | (((x) << 8) & ~0xffff)) +#endif + +#define MAKEMINOR(f, u, s) \ + unit2minor((f) | (((u) & 0xff) << 8) | (s & 0xff)) +#define DEV2UNIT(x) ((dev2unit(x) & 0xff00) >> 8) +#define DEV2SUB(x) (dev2unit(x) & 0xff) + +#define FWMEM_FLAG 0x10000 +#define DEV_FWMEM(x) (dev2unit(x) & FWMEM_FLAG) +#endif /* __HAIKU__ */ +#endif +#ifdef __HAIKU__ +#define EX_NOINPUT 66 +#define EX_USAGE 64 +#endif /* __HAIKU__*/ +#endif Added: haiku/trunk/headers/private/firewire/fwphyreg.h =================================================================== --- haiku/trunk/headers/private/firewire/fwphyreg.h 2007-07-15 13:31:02 UTC (rev 21615) +++ haiku/trunk/headers/private/firewire/fwphyreg.h 2007-07-15 17:43:02 UTC (rev 21616) @@ -0,0 +1,168 @@ +/*- + * Copyright (C) 2003 + * Hidetoshi Shimokawa. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * + * This product includes software developed by Hidetoshi Shimokawa. + * + * 4. Neither the name of the author nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/dev/firewire/fwphyreg.h,v 1.3 2005/01/06 01:42:41 imp Exp $ + */ + +struct phyreg_base { +#if BYTE_ORDER == BIG_ENDIAN + uint8_t phy_id:6, + r:1, + cps:1; + uint8_t rhb:1, + ibr:1, + gap_count:6; + uint8_t extended:3, + num_ports:5; + uint8_t phy_speed:3, + :1, + delay:4; + uint8_t lctrl:1, + c:1, + jitter:3, + pwr_class:3; + uint8_t wdie:1, + isbr:1, + ctoi:1, + cpsi:1, + stoi:1, + pei:1, + eaa:1, + emc:1; + uint8_t legacy_spd:3, + blink:1, + bridge:2, + :2; + uint8_t page_select:3, + :1, + port_select:4; +#else + uint8_t cps:1, + r:1, + phy_id:6; + uint8_t gap_count:6, + ibr:1, + rhb:1; + uint8_t num_ports:5, + extended:3; + uint8_t delay:4, + :1, + phy_speed:3; + uint8_t pwr_class:3, + jitter:3, + c:1, + lctrl:1; + uint8_t emc:1, + eaa:1, + pei:1, + stoi:1, + cpsi:1, + ctoi:1, + isbr:1, + wdie:1; + uint8_t :2, + bridge:2, + blink:1, + legacy_spd:3; + uint8_t port_select:4, + :1, + page_select:3; +#endif +}; + +struct phyreg_page0 { +#if BYTE_ORDER == BIG_ENDIAN + uint8_t astat:2, + bstat:2, + ch:1, + con:1, + rxok:1, + dis:1; + uint8_t negotiated_speed:3, + pie:1, + fault:1, + stanby_fault:1, + disscrm:1, + b_only:1; + uint8_t dc_connected:1, + max_port_speed:3, + lpp:1, + cable_speed:3; + uint8_t connection_unreliable:1, + :3, + beta_mode:1, + :3; + uint8_t port_error; + uint8_t :5, + loop_disable:1, + in_standby:1, + hard_disable:1; + uint8_t :8; + uint8_t :8; +#else + uint8_t dis:1, + rxok:1, + con:1, + ch:1, + bstat:2, + astat:2; + uint8_t b_only:1, + disscrm:1, + stanby_fault:1, + fault:1, + pie:1, + negotiated_speed:3; + uint8_t cable_speed:3, + lpp:1, + max_port_speed:3, + dc_connected:1; + uint8_t :3, + beta_mode:1, + :3, + connection_unreliable:1; + uint8_t port_error; + uint8_t hard_disable:1, + in_standby:1, + loop_disable:1, + :5; + uint8_t :8; + uint8_t :8; +#endif +}; + +struct phyreg_page1 { + uint8_t compliance; + uint8_t :8; + uint8_t vendor_id[3]; + uint8_t product_id[3]; +}; Added: haiku/trunk/headers/private/firewire/iec13213.h =================================================================== --- haiku/trunk/headers/private/firewire/iec13213.h 2007-07-15 13:31:02 UTC (rev 21615) +++ haiku/trunk/headers/private/firewire/iec13213.h 2007-07-15 17:43:02 UTC (rev 21616) @@ -0,0 +1,251 @@ +/*- + * Copyright (c) 2003 Hidetoshi Shimokawa + * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the acknowledgement as bellow: + * + * This product includes software developed by K. Kobayashi and H. Shimokawa + * + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/sys/dev/firewire/iec13213.h,v 1.14 2005/01/06 01:42:41 imp Exp $ + * + */ + +#define STATE_CLEAR 0x0000 +#define STATE_SET 0x0004 +#define NODE_IDS 0x0008 +#define RESET_START 0x000c +#define SPLIT_TIMEOUT_HI 0x0018 +#define SPLIT_TIMEOUT_LO 0x001c +#define CYCLE_TIME 0x0200 +#define BUS_TIME 0x0204 +#define BUSY_TIMEOUT 0x0210 +#define PRIORITY_BUDGET 0x0218 +#define BUS_MGR_ID 0x021c +#define BANDWIDTH_AV 0x0220 +#define CHANNELS_AV_HI 0x0224 +#define CHANNELS_AV_LO 0x0228 +#define IP_CHANNELS 0x0234 + +#define CONF_ROM 0x0400 + +#define TOPO_MAP 0x1000 +#define SPED_MAP 0x2000 + +#define CSRTYPE_SHIFT 6 +#define CSRTYPE_MASK (3 << CSRTYPE_SHIFT) +#define CSRTYPE_I (0 << CSRTYPE_SHIFT) /* Immediate */ +#define CSRTYPE_C (1 << CSRTYPE_SHIFT) /* CSR offset */ +#define CSRTYPE_L (2 << CSRTYPE_SHIFT) /* Leaf */ +#define CSRTYPE_D (3 << CSRTYPE_SHIFT) /* Directory */ + +/* + * CSR keys + * 00 - 2F: defined by CSR architecture standards. + * 30 - 37: defined by BUS starndards + * 38 - 3F: defined by Vendor/Specifier + */ +#define CSRKEY_MASK 0x3f +#define CSRKEY_DESC 0x01 /* Descriptor */ +#define CSRKEY_BDINFO 0x02 /* Bus_Dependent_Info */ +#define CSRKEY_VENDOR 0x03 /* Vendor */ +#define CSRKEY_HW 0x04 /* Hardware_Version */ +#define CSRKEY_MODULE 0x07 /* Module */ +#define CSRKEY_NCAP 0x0c /* Node_Capabilities */ +#define CSRKEY_EUI64 0x0d /* EUI_64 */ +#define CSRKEY_UNIT 0x11 /* Unit */ +#define CSRKEY_SPEC 0x12 /* Specifier_ID */ +#define CSRKEY_VER 0x13 /* Version */ +#define CSRKEY_DINFO 0x14 /* Dependent_Info */ +#define CSRKEY_ULOC 0x15 /* Unit_Location */ +#define CSRKEY_MODEL 0x17 /* Model */ +#define CSRKEY_INST 0x18 /* Instance */ +#define CSRKEY_KEYW 0x19 /* Keyword */ +#define CSRKEY_FEAT 0x1a /* Feature */ +#define CSRKEY_EROM 0x1b /* Extended_ROM */ +#define CSRKEY_EKSID 0x1c /* Extended_Key_Specifier_ID */ +#define CSRKEY_EKEY 0x1d /* Extended_Key */ +#define CSRKEY_EDATA 0x1e /* Extended_Data */ +#define CSRKEY_MDESC 0x1f /* Modifiable_Descriptor */ +#define CSRKEY_DID 0x20 /* Directory_ID */ +#define CSRKEY_REV 0x21 /* Revision */ + +#define CSRKEY_FIRM_VER 0x3c /* Firmware version */ +#define CSRKEY_UNIT_CH 0x3a /* Unit characteristics */ +#define CSRKEY_COM_SPEC 0x38 /* Command set revision */ +#define CSRKEY_COM_SET 0x39 /* Command set */ + +#define CROM_UDIR (CSRTYPE_D | CSRKEY_UNIT) /* 0x81 Unit directory */ +#define CROM_TEXTLEAF (CSRTYPE_L | CSRKEY_DESC) /* 0x81 Text leaf */ +#define CROM_LUN (CSRTYPE_I | CSRKEY_DINFO) /* 0x14 Logical unit num. */ +#define CROM_MGM (CSRTYPE_C | CSRKEY_DINFO) /* 0x54 Management agent */ + +#define CSRVAL_VENDOR_PRIVATE 0xacde48 +#define CSRVAL_1394TA 0x00a02d +#define CSRVAL_ANSIT10 0x00609e +#define CSRVAL_IETF 0x00005e + +#define CSR_PROTAVC 0x010001 +#define CSR_PROTCAL 0x010002 +#define CSR_PROTEHS 0x010004 +#define CSR_PROTHAVI 0x010008 +#define CSR_PROTCAM104 0x000100 +#define CSR_PROTCAM120 0x000101 +#define CSR_PROTCAM130 0x000102 +#define CSR_PROTDPP 0x0a6be2 +#define CSR_PROTIICP 0x4b661f + +#define CSRVAL_T10SBP2 0x010483 +#define CSRVAL_SCSI 0x0104d8 + +struct csrreg { +#if BYTE_ORDER == BIG_ENDIAN + uint32_t key:8, + val:24; +#else + uint32_t val:24, + key:8; +#endif +}; +struct csrhdr { +#if BYTE_ORDER == BIG_ENDIAN + uint32_t info_len:8, + crc_len:8, + crc:16; +#else + uint32_t crc:16, + crc_len:8, + info_len:8; +#endif +}; +struct csrdirectory { + BIT16x2(crc_len, crc); + struct csrreg entry[0]; +}; +struct csrtext { + BIT16x2(crc_len, crc); +#if BYTE_ORDER == BIG_ENDIAN + uint32_t spec_type:8, + spec_id:24; +#else + uint32_t spec_id:24, + spec_type:8; +#endif + uint32_t lang_id; + uint32_t text[0]; +}; + +struct bus_info { +#define CSR_BUS_NAME_IEEE1394 0x31333934 + uint32_t bus_name; +#if BYTE_ORDER == BIG_ENDIAN + uint32_t irmc:1, /* iso. resource manager capable */ + cmc:1, /* cycle master capable */ + isc:1, /* iso. operation support */ + bmc:1, /* bus manager capable */ + pmc:1, /* power manager capable */ + :3, + cyc_clk_acc:8, /* 0 <= ppm <= 100 */ + max_rec:4, /* (2 << max_rec) bytes */ + :2, + max_rom:2, + generation:4, + :1, + link_spd:3; +#else + uint32_t link_spd:3, + :1, + generation:4, + max_rom:2, + :2, + max_rec:4, /* (2 << max_rec) bytes */ + cyc_clk_acc:8, /* 0 <= ppm <= 100 */ + :3, + pmc:1, /* power manager capable */ + bmc:1, /* bus manager capable */ + isc:1, /* iso. operation support */ + cmc:1, /* cycle master capable */ + irmc:1; /* iso. resource manager capable */ +#endif + struct fw_eui64 eui64; +}; +/* max_rom */ +#define MAXROM_4 0 +#define MAXROM_64 1 +#define MAXROM_1024 2 + +#define CROM_MAX_DEPTH 10 +struct crom_ptr { + struct csrdirectory *dir; + int index; +}; + +struct crom_context { + int depth; + struct crom_ptr stack[CROM_MAX_DEPTH]; +}; + +void crom_init_context(struct crom_context *, uint32_t *); +struct csrreg *crom_get(struct crom_context *); +void crom_next(struct crom_context *); +void crom_parse_text(struct crom_context *, char *, int); +uint16_t crom_crc(uint32_t *r, int); +struct csrreg *crom_search_key(struct crom_context *, uint8_t); +int crom_has_specver(uint32_t *, uint32_t, uint32_t); + +#if !defined(_KERNEL) && !defined(_BOOT) +char *crom_desc(struct crom_context *, char *, int); +#endif + +/* For CROM build */ +#if defined(_KERNEL) || defined(_BOOT) || defined(TEST) +#define CROM_MAX_CHUNK_LEN 20 +struct crom_src { + struct csrhdr hdr; + struct bus_info businfo; + STAILQ_HEAD(, crom_chunk) chunk_list; +}; + +struct crom_chunk { + STAILQ_ENTRY(crom_chunk) link; + struct crom_chunk *ref_chunk; + int ref_index; + int offset; + struct { + BIT16x2(crc_len, crc); + uint32_t buf[CROM_MAX_CHUNK_LEN]; + } data; +}; + +extern int crom_add_quad(struct crom_chunk *, uint32_t); +extern int crom_add_entry(struct crom_chunk *, int, int); +extern int crom_add_chunk(struct crom_src *src, struct crom_chunk *, + struct crom_chunk *, int); +extern int crom_add_simple_text(struct crom_src *src, struct crom_chunk *, + struct crom_chunk *, char *); +extern int crom_load(struct crom_src *, uint32_t *, int); +#endif Added: haiku/trunk/headers/private/firewire/iec68113.h =================================================================== --- haiku/trunk/headers/private/firewire/iec68113.h 2007-07-15 13:31:02 UTC (rev 21615) +++ haiku/trunk/headers/private/firewire/iec68113.h 2007-07-15 17:43:02 UTC (rev 21616) @@ -0,0 +1,127 @@ +/*- + * Copyright (c) 2003 Hidetoshi Shimokawa + * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the acknowledgement as bellow: + * + * This product includes software developed by K. Kobayashi and H. Shimokawa + * + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/sys/dev/firewire/iec68113.h,v 1.9 2005/01/06 01:42:41 imp Exp $ + * + */ + +#define DV_BROADCAST_ON (1<<30) +#define oMPR 0x900 +#define oPCR 0x904 +#define iMPR 0x980 +#define iPCR 0x984 + +struct ciphdr { +#if BYTE_ORDER == BIG_ENDIAN + uint8_t eoh0:1, /* 0 */ + form0:1, /* 0 */ + src:6; +#else + uint8_t src:6, + form0:1, /* 0 */ + eoh0:1; /* 0 */ +#endif + uint8_t len; +#if BYTE_ORDER == BIG_ENDIAN + uint8_t fn:2, + qpc:3, + sph:1, [... truncated: 3478 lines follow ...] From axeld at mail.berlios.de Sun Jul 15 20:09:44 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 15 Jul 2007 20:09:44 +0200 Subject: [Haiku-commits] r21617 - haiku/trunk/docs/user/drivers Message-ID: <200707151809.l6FI9i0f025810@sheep.berlios.de> Author: axeld Date: 2007-07-15 20:09:43 +0200 (Sun, 15 Jul 2007) New Revision: 21617 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21617&view=rev Modified: haiku/trunk/docs/user/drivers/fs_interface.dox Log: * Completed some more missing parts. * Replaced some more spaces with tabs, though still not complete. * And I forgot: the last commit also removed some garbage at the beginning of the file. Modified: haiku/trunk/docs/user/drivers/fs_interface.dox =================================================================== --- haiku/trunk/docs/user/drivers/fs_interface.dox 2007-07-15 17:43:02 UTC (rev 21616) +++ haiku/trunk/docs/user/drivers/fs_interface.dox 2007-07-15 18:09:43 UTC (rev 21617) @@ -168,114 +168,115 @@ //! @{ /*! - \fn status_t (*file_system_module_info::mount)(ino_t id, const char *device, - uint32 flags, const char *args, fs_volume *_fs, ino_t *_rootVnodeID) - \brief Mount a volume according to the specified parameters. + \fn status_t (*file_system_module_info::mount)(ino_t id, const char *device, + uint32 flags, const char *args, fs_volume *_fs, ino_t *_rootVnodeID) + \brief Mount a volume according to the specified parameters. - Invoked by the VFS when it has been requested to mount the volume. The FS is - supposed to perform whatever one-time initialization is necessary for the - volume. It is required to create a volume handle for the volume and pass it - back in \a _fs. Moreover it must invoke publish_vnode() for the root node - of the volume and pass the ID of the volume back in \a _rootVnodeID. + Invoked by the VFS when it has been requested to mount the volume. The FS is + supposed to perform whatever one-time initialization is necessary for the + volume. It is required to create a volume handle for the volume and pass it + back in \a _fs. Moreover it must invoke publish_vnode() for the root node + of the volume and pass the ID of the volume back in \a _rootVnodeID. - A disk-based FS will need to check whether \a device is not \c NULL, open - it, and analyze whether the device or image file actually represents a volume - of that FS type. + A disk-based FS will need to check whether \a device is not \c NULL, open + it, and analyze whether the device or image file actually represents a volume + of that FS type. - If mounting the volume fails for whatever reason, the hook must return an - error code other than \c B_OK. In this case all resources allocated by the - hook must be freed before returning. If and only if \c B_OK is returned, the - unmount() hook will be invoked at a later point when unmounting the volume. + If mounting the volume fails for whatever reason, the hook must return an + error code other than \c B_OK. In this case all resources allocated by the + hook must be freed before returning. If and only if \c B_OK is returned, the + unmount() hook will be invoked at a later point when unmounting the volume. - \param id The ID of the volume to be mounted. It should be saved in the FS's - volume private data (volume handle). - \param device The path to the device (or image file) representing the volume - to be mounted. Can be \c NULL. - \param flags Flags: - - \c B_MOUNT_READ_ONLY: Mount the volume read-only. - \param args Null-terminated string in driver settings format, containing FS - specific parameters. - \param _fs Pointer to a pre-allocated variable the volume handle shall be - written to. - \param _rootVnodeID Pointer to a pre-allocated variable the ID of the - volume's root directory shall be written to. - \return \c B_OK if everything went fine, another error code otherwise. + \param id The ID of the volume to be mounted. It should be saved in the FS's + volume private data (volume handle). + \param device The path to the device (or image file) representing the volume + to be mounted. Can be \c NULL. + \param flags Flags: + - \c B_MOUNT_READ_ONLY: Mount the volume read-only. + \param args Null-terminated string in driver settings format, containing FS + specific parameters. + \param _fs Pointer to a pre-allocated variable the volume handle shall be + written to. + \param _rootVnodeID Pointer to a pre-allocated variable the ID of the + volume's root directory shall be written to. + \return \c B_OK if everything went fine, another error code otherwise. */ /*! - \fn status_t (*file_system_module_info::unmount)(fs_volume fs) - \brief Unmounts the given volume. + \fn status_t (*file_system_module_info::unmount)(fs_volume fs) + \brief Unmounts the given volume. - Invoked by the VFS when it is asked to unmount the volume. The function must - free all resources associated with the mounted volume, including the volume - handle. Although the mount() hook called publish_vnode() for the root node - of the volume, unmount() must not invoke put_vnode(). + Invoked by the VFS when it is asked to unmount the volume. The function must + free all resources associated with the mounted volume, including the volume + handle. Although the mount() hook called publish_vnode() for the root node + of the volume, unmount() must not invoke put_vnode(). - \param fs The volume handle. - \return \c B_OK if everything went fine, another error code otherwise. The - error code will be ignored, though. + \param fs The volume handle. + \return \c B_OK if everything went fine, another error code otherwise. The + error code will be ignored, though. */ /*! - \fn status_t (*file_system_module_info::read_fs_info)(fs_volume fs, - struct fs_info *info) - \brief Retrieves general information about the volume. + \fn status_t (*file_system_module_info::read_fs_info)(fs_volume fs, + struct fs_info *info) + \brief Retrieves general information about the volume. - The following fields of the \c fs_info structure need to be filled in: - - \c flags: Flags applying to the volume, e.g. \c B_FS_IS_READONLY, - \c B_FS_HAS_ATTR, etc. - - \c block_size: The size of blocks the volume data are organized in. - Meaningful mainly for disk-based FSs, other FSs should use some reasonable - value for computing \c total_blocks and \c free_blocks. - - \c io_size: Preferred size of the buffers passed to read() and write(). - - \c total_blocks: Total number of blocks the volume contains. - - \c free_blocks: Number of free blocks on the volume. - - \c total_nodes: Maximal number of nodes the volume can contain. If there is - no such limitation use \c LONGLONG_MAX. - - \c free_nodes: Number of additional nodes the volume could contain. If - there is no such limitation use \c LONGLONG_MAX. - - \c device_name: The name of the device or image file containing the volume. - Non-disk-based FSs shall fill in an empty string. - - \c volume_name: The name of the volume. + The following fields of the \c fs_info structure need to be filled in: + - \c flags: Flags applying to the volume, e.g. \c B_FS_IS_READONLY, + \c B_FS_HAS_ATTR, etc. + - \c block_size: The size of blocks the volume data are organized in. + Meaningful mainly for disk-based FSs, other FSs should use some reasonable + value for computing \c total_blocks and \c free_blocks. + - \c io_size: Preferred size of the buffers passed to read() and write(). + - \c total_blocks: Total number of blocks the volume contains. + - \c free_blocks: Number of free blocks on the volume. + - \c total_nodes: Maximal number of nodes the volume can contain. If there is + no such limitation use \c LONGLONG_MAX. + - \c free_nodes: Number of additional nodes the volume could contain. If + there is no such limitation use \c LONGLONG_MAX. + - \c device_name: The name of the device or image file containing the volume. + Non-disk-based FSs shall fill in an empty string. + - \c volume_name: The name of the volume. - The other values are filled in by the VFS. + The other values are filled in by the VFS. - \param fs The volume handle. - \param info Pointer to a pre-allocated variable the FS info shall be written - to. - \return \c B_OK if everything went fine, another error code otherwise. The - error code will be ignored, though. + \param fs The volume handle. + \param info Pointer to a pre-allocated variable the FS info shall be written + to. + \return \c B_OK if everything went fine, another error code otherwise. The + error code will be ignored, though. */ /*! - \fn status_t (*file_system_module_info::write_fs_info)(fs_volume fs, const - struct fs_info *info, uint32 mask) - \brief Update filesystem information on the volume. - - You are requested to update certain information on the volume \a fs. The - supplied \a info contains the new values filled in for the \a mask. - Currently, the only possible mask is solely the \c FS_WRITE_FSINFO_NAME, - which asks you to update the volume name represented by the value - \c volume_name in the \c fs_info struct. + \fn status_t (*file_system_module_info::write_fs_info)(fs_volume fs, const + struct fs_info *info, uint32 mask) + \brief Update filesystem information on the volume. - \param fs The cookie your filesystem supplied to the volume that should be - updated. - \param info The structure that contains the new data. - \param mask The values of the \a info that need to be updated. - \return \c B_OK if everything went fine, if not, one of the error codes. + You are requested to update certain information on the volume \a fs. The + supplied \a info contains the new values filled in for the \a mask. + Currently, the only possible mask is solely the \c FS_WRITE_FSINFO_NAME, + which asks you to update the volume name represented by the value + \c volume_name in the \c fs_info struct. + + \param fs The cookie your filesystem supplied to the volume that should be + updated. + \param info The structure that contains the new data. + \param mask The values of the \a info that need to be updated. + \return \c B_OK if everything went fine, if not, one of the error codes. */ /*! - \fn status_t (*file_system_module_info::sync)(fs_volume fs) - \brief Synchronize the cached data with the contents of the disk. - - The VFS layer sometimes wants you to synchronize any cached values with the - data on the device. - - TODO: WHEN IS THIS CALLED AND FOR WHAT PURPOSE? - - \param fs The cookie your filesystem supplied to the volume that should be - updated. + \fn status_t (*file_system_module_info::sync)(fs_volume fs) + \brief Synchronize the cached data with the contents of the disk. + + The VFS layer sometimes wants you to synchronize any cached values with the + data on the device. + + This currently only happens when the POSIX sync() function is invoked, for + example via the "sync" command line tool. + + \param fs The cookie your filesystem supplied to the volume that should be + updated. */ //! @} @@ -287,381 +288,417 @@ //! @{ /*! - \fn status_t (*file_system_module_info::lookup)(fs_volume fs, fs_vnode dir, - const char *name, ino_t *_id, int *_type) - \brief Looks up the node a directory entry refers to. + \fn status_t (*file_system_module_info::lookup)(fs_volume fs, fs_vnode dir, + const char *name, ino_t *_id, int *_type) + \brief Looks up the node a directory entry refers to. - The VFS uses this hook to resolve path names to vnodes. It is used quite - often and should be implemented efficiently. + The VFS uses this hook to resolve path names to vnodes. It is used quite + often and should be implemented efficiently. - If the parameter \a dir does not specify a directory, the function shall - fail. It shall also fail, if it is a directory, but does not contain an entry - with the given name \a name. Otherwise the function shall invoke get_vnode() - for the node the entry refers to and pass back the ID and the type of the - node in \a _id and \a _type respectively. + If the parameter \a dir does not specify a directory, the function shall + fail. It shall also fail, if it is a directory, but does not contain an entry + with the given name \a name. Otherwise the function shall invoke get_vnode() + for the node the entry refers to and pass back the ID and the type of the + node in \a _id and \a _type respectively. - Note that a directory must contain the special entries \c "." and \c "..", - referring to the same directory and the parent directory respectively. - lookup() must resolve the nodes accordingly. \c ".." for the root directory - of the volume shall be resolved to the root directory itself. + Note that a directory must contain the special entries \c "." and \c "..", + referring to the same directory and the parent directory respectively. + lookup() must resolve the nodes accordingly. \c ".." for the root directory + of the volume shall be resolved to the root directory itself. - \param fs The volume handle. - \param dir The node handle of the directory. - \param name The name of the directory entry. - \param _id Pointer to a pre-allocated variable the ID of the found node - shall be written to. - \param _type Pointer to a pre-allocated variable the type of the found node - shall be written to. The type is encoded as in the \c st_mode field of a - struct stat (bitwise anded with \c S_IFMT). - \retval B_OK Everything went fine. - \retval B_ENTRY_NOT_FOUND The given directory does not contain an entry with - the given name. + \param fs The volume handle. + \param dir The node handle of the directory. + \param name The name of the directory entry. + \param _id Pointer to a pre-allocated variable the ID of the found node + shall be written to. + \param _type Pointer to a pre-allocated variable the type of the found node + shall be written to. The type is encoded as in the \c st_mode field of a + struct stat (bitwise anded with \c S_IFMT). + \retval B_OK Everything went fine. + \retval B_ENTRY_NOT_FOUND The given directory does not contain an entry with + the given name. */ /*! - \fn status_t (*file_system_module_info::get_vnode_name)(fs_volume fs, - fs_vnode vnode, char *buffer, size_t bufferSize) - \brief Return the file name of a vnode. - - \param fs The file system provided cookie associated with this volume. - \param vnode The file system provided cookie associated with this vnode. - \param buffer The buffer that the name can be copied into. - \param bufferSize The size of the buffer. - \retval B_OK You successfully copied the file name into the \a buffer. - \retval "other errors" There was some error looking up or copying the name. + \fn status_t (*file_system_module_info::get_vnode_name)(fs_volume fs, + fs_vnode vnode, char *buffer, size_t bufferSize) + \brief Return the file name of a vnode. + + Note that you don't have to implement this call if it can't be easily done; + it's completely optional. + If you don't implement it, you'll have to export a NULL pointer for this + function in the module definition. In this case, the VFS will find the name + by iterating over its parent directory. + + \param fs The file system provided cookie associated with this volume. + \param vnode The file system provided cookie associated with this vnode. + \param buffer The buffer that the name can be copied into. + \param bufferSize The size of the buffer. + \retval B_OK You successfully copied the file name into the \a buffer. + \retval "other errors" There was some error looking up or copying the name. */ /*! - \fn status_t (*file_system_module_info::get_vnode)(fs_volume fs, ino_t id, - fs_vnode *_vnode, bool reenter) - \brief Creates the private data handle to be associated with the node - referred to by \a id. + \fn status_t (*file_system_module_info::get_vnode)(fs_volume fs, ino_t id, + fs_vnode *_vnode, bool reenter) + \brief Creates the private data handle to be associated with the node + referred to by \a id. - Invoked by the VFS when it creates the vnode for the respective node. + Invoked by the VFS when it creates the vnode for the respective node. + When the VFS no longer needs the vnode in memory (for example when + memory is becoming tight), it will your file_system_module_info::put_vnode(), + or file_system_module_info::remove_vnode() in case the vnode has been + marked removed. - \param fs The volume handle. - \param id The ID of the node. - \param _vnode Pointer to a pre-allocated variable the node handle shall be - written to. - \param reenter \c true if the hook invocation has been caused by the FS - itself, e.g. by invoking ::get_vnode(). - \return \c B_OK if everything went fine, another error code otherwise. + \param fs The volume handle. + \param id The ID of the node. + \param _vnode Pointer to a pre-allocated variable the node handle shall be + written to. + \param reenter \c true if the hook invocation has been caused by the FS + itself, e.g. by invoking ::get_vnode(). + \return \c B_OK if everything went fine, another error code otherwise. */ /*! - \fn \fn status_t (*file_system_module_info::put_vnode)(fs_volume fs, - fs_vnode vnode, bool reenter) - \brief Deletes the private data handle associated with the specified node. + \fn \fn status_t (*file_system_module_info::put_vnode)(fs_volume fs, + fs_vnode vnode, bool reenter) + \brief Deletes the private data handle associated with the specified node. - Invoked by the VFS when it deletes the vnode for the respective node and the - node is not marked removed. + Invoked by the VFS when it deletes the vnode for the respective node and the + node is not marked removed. - \param fs The volume handle. - \param vnode The node handle. - \param reenter \c true if the hook invocation has been caused by the FS - itself, e.g. by invoking ::put_vnode(). - \return \c B_OK if everything went fine, another error code otherwise. + \param fs The volume handle. + \param vnode The node handle. + \param reenter \c true if the hook invocation has been caused by the FS + itself, e.g. by invoking ::put_vnode(). + \return \c B_OK if everything went fine, another error code otherwise. */ /*! - \fn status_t (*file_system_module_info::remove_vnode)(fs_volume fs, - fs_vnode vnode, bool reenter) - \brief Deletes the private data handle associated with the specified node. + \fn status_t (*file_system_module_info::remove_vnode)(fs_volume fs, + fs_vnode vnode, bool reenter) + \brief Deletes the private data handle associated with the specified node. - Invoked by the VFS when it deletes the vnode for the respective node and the - node is marked removed. + Invoked by the VFS when it deletes the vnode for the respective node and the + node has been marked removed by a call to remove_vnode(). - \param fs The volume handle. - \param vnode The node handle. - \param reenter \c true if the hook invocation has been caused by the FS - itself, e.g. by invoking ::put_vnode(). - \return \c B_OK if everything went fine, another error code otherwise. + \param fs The volume handle. + \param vnode The node handle. + \param reenter \c true if the hook invocation has been caused by the FS + itself, e.g. by invoking ::put_vnode(). + \return \c B_OK if everything went fine, another error code otherwise. */ //! @} /*! - \name VM file access + \name VM file access */ //! @{ /*! - \fn bool (*file_system_module_info::can_page)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) - \brief Undocumented. TODO. - - TODO: In both the dos and the bfs implementations this thing simply returns - false... Is there anything more to it? + \fn bool (*file_system_module_info::can_page)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) + \brief Undocumented. TODO. + + TODO: In both the dos and the bfs implementations this thing simply returns + false... Is there anything more to it? + This call might be removed in the future - it's currently unused. */ /*! - \fn status_t (*file_system_module_info::read_pages)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, - off_t pos, const iovec *vecs, size_t count, size_t *_numBytes, - bool reenter) - \brief Undocumented. TODO. + \fn status_t (*file_system_module_info::read_pages)(fs_volume fs, fs_vnode vnode, + fs_cookie cookie, off_t pos, const iovec *vecs, size_t count, + size_t *_numBytes, bool reenter) + \brief Undocumented. TODO. */ /*! - \fn status_t (*file_system_module_info::write_pages)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, - off_t pos, const iovec *vecs, size_t count, size_t *_numBytes, - bool reenter) + \fn status_t (*file_system_module_info::write_pages)(fs_volume fs, fs_vnode vnode, + fs_cookie cookie, off_t pos, const iovec *vecs, size_t count, + size_t *_numBytes, bool reenter) \brief Undocumented. TODO. */ //! @} /*! - \name Cache File Access + \name Cache File Access */ //! @{ /*! - \fn status_t (*file_system_module_info::get_file_map)(fs_volume fs, fs_vnode vnode, off_t offset, - size_t size, struct file_io_vec *vecs, size_t *_count) - \brief Undocumented. TODO. + \fn status_t (*file_system_module_info::get_file_map)(fs_volume fs, + fs_vnode vnode, off_t offset, size_t size, struct file_io_vec *vecs, + size_t *_count) + \brief Fills the \a vecs with the extents of the file data stream. + + This function is called only when you are using the file cache, but if you + use it, its implementation is mandatory. + + TODO: complete me */ //! @} /*! - \name Standard Operations + \name Standard Operations */ //! @{ /*! - \fn status_t (*file_system_module_info::ioctl)(fs_volume fs, fs_vnode vnode, - fs_cookie cookie, ulong op, void *buffer, size_t length) - \brief Perform file system specific operations. - - You can implement a customized API using this call. This can be extremely - handy for debugging purposes. There are no obligatory operations for you to - implement. - - If you don't want to use this feature, you don't have to implement it. - - \param fs The file system provided cookie associated with this volume. - \param vnode The file system provided cookie associated with the vnode (if - applicable). - \param cookie The file system provided cookie associated with, for example, - an open file (if applicable). - \param op The operation code. You will have to define them yourself. - \param buffer A buffer (if applicable). - \param length The size of the buffer. - \return You should return any of your status codes. + \fn status_t (*file_system_module_info::ioctl)(fs_volume fs, fs_vnode vnode, + fs_cookie cookie, ulong op, void *buffer, size_t length) + \brief Perform file system specific operations. + + You can implement a customized API using this call. This can be extremely + handy for debugging purposes. There are no obligatory operations for you to + implement. + + If you don't want to use this feature, you don't have to implement it. + + \param fs The file system provided cookie associated with this volume. + \param vnode The file system provided cookie associated with the vnode (if + applicable). + \param cookie The file system provided cookie associated with, for example, + an open file (if applicable). + \param op The operation code. You will have to define them yourself. + \param buffer A buffer (if applicable). + \param length The size of the buffer. + \return You should return any of your status codes. */ /*! - \fn status_t (*file_system_module_info::set_flags)(fs_volume fs, fs_vnode - vnode, fs_cookie cookie, int flags) - \brief Set the open mode flags for an opened file. - - This function should change the open flags for an opened file. - - \param fs The file system provided cookie associated with this volume. - \param vnode The file system provided cookie associated with the vnode. - \param cookie The file system provided cookie associated with the opened - file. - \param flags The new flags. - \return \c B_OK if the operation succeeded, or else an error code. + \fn status_t (*file_system_module_info::set_flags)(fs_volume fs, fs_vnode + vnode, fs_cookie cookie, int flags) + \brief Set the open mode flags for an opened file. + + This function should change the open flags for an opened file. + + \param fs The file system provided cookie associated with this volume. + \param vnode The file system provided cookie associated with the vnode. + \param cookie The file system provided cookie associated with the opened + file. + \param flags The new flags. + \return \c B_OK if the operation succeeded, or else an error code. */ /*! - \fn status_t (*file_system_module_info::select)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, - uint8 event, uint32 ref, selectsync *sync) - \brief Undocumented. TODO. - - TODO: What should this do? + \fn status_t (*file_system_module_info::select)(fs_volume fs, fs_vnode vnode, + fs_cookie cookie, uint8 event, uint32 ref, selectsync *sync) + \brief Selects the specified \a vnode with the specified \a events. + + This function is called by the VFS whenever select() or poll() is called on + a file descriptor that points to your file system. + + You have to check if the condition of the select() (ie. if there is data + available if event is B_SELECT_READ) is already satisfied, and call + notify_select_event() with the \a sync and \a ref arguments you retrieve + here. + + Additionally, when a vnode is selected this way, you have to call + notify_select_event() whenever the condition becomes true until the + vnode is deselected again via file_system_module_info::deselect(). + + This function is optional. If you don't export it, the default implementation + in the VFS will call notify_select_event() directly which will be sufficient + for most file systems. */ /*! - \fn status_t (*file_system_module_info::deselect)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, - uint8 event, selectsync *sync) - \brief Undocumented. TODO. - - TODO: What should this do? + \fn status_t (*file_system_module_info::deselect)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, + uint8 event, selectsync *sync) + \brief Deselects the specified \a vnode from a previous select() call. + + This function is called by the VFS whenever a select() or poll() function + exits that previously called file_system_module_info::select() on that + \a vnode. */ /*! - \fn status_t (*file_system_module_info::fsync)(fs_volume fs, fs_vnode vnode) - \brief Synchronize the buffers with the on disk data. - - \param fs The file system provided cookie associated with this volume. - \param vnode The file system provided cookie associated with the vnode. - \return \c B_OK if the operation succeeded, or else an error code. + \fn status_t (*file_system_module_info::fsync)(fs_volume fs, fs_vnode vnode) + \brief Synchronize the buffers with the on disk data. + + \param fs The file system provided cookie associated with this volume. + \param vnode The file system provided cookie associated with the vnode. + \return \c B_OK if the operation succeeded, or else an error code. */ /*! - \fn status_t (*file_system_module_info::read_symlink)(fs_volume fs, - fs_vnode link, char *buffer, size_t *_bufferSize) - \brief Read the value of a symbolic link. + \fn status_t (*file_system_module_info::read_symlink)(fs_volume fs, + fs_vnode link, char *buffer, size_t *_bufferSize) + \brief Read the value of a symbolic link. - If the function is successful, the string written to the buffer shall be - null-terminated and the variable \a _bufferSize points to shall be set to - the length of that string, including the terminating null character. + If the function is successful, the string written to the buffer shall be + null-terminated and the variable \a _bufferSize points to shall be set to + the length of that string, including the terminating null character. - \param fs The volume handle. - \param link The node handle. - \param buffer Pointer to a pre-allocated buffer the link value shall be - written to. - \param buffer Pointer to a pre-allocated variable containing the size of the - buffer supplied to the function. Upon successful completion the hook shall - store the number of bytes actually written into the buffer in the variable. - \retval B_OK Everything went fine. - \retval B_BAD_VALUE \a link does not identify a symbolic link. - \retval B_BUFFER_OVERFLOW The supplied buffer is not big enough to contain - the complete link value. + \param fs The volume handle. + \param link The node handle. + \param buffer Pointer to a pre-allocated buffer the link value shall be + written to. + \param buffer Pointer to a pre-allocated variable containing the size of the + buffer supplied to the function. Upon successful completion the hook shall + store the number of bytes actually written into the buffer in the variable. + \retval B_OK Everything went fine. + \retval B_BAD_VALUE \a link does not identify a symbolic link. + \retval B_BUFFER_OVERFLOW The supplied buffer is not big enough to contain + the complete link value. */ /*! - \fn status_t (*file_system_module_info::create_symlink)(fs_volume fs, - fs_vnode dir, const char *name, const char *path, int mode) - \brief Create a new symbolic link. - - Your implementation should check if the user has permission to perform this - operation. - - \param fs The file system provided cookie associated with this volume. - \param dir The file system provided cookie associated with the directory - the symbolic link should be created in. - \param name The name of the new symbolic link. - \param path The path of the original inode the symbolic link should refer to. - \param mode The mode that this symbolic link should be created in. (TODO - what exactly?) - \return \c B_OK if you succeeded, or an error code if you failed. + \fn status_t (*file_system_module_info::create_symlink)(fs_volume fs, + fs_vnode dir, const char *name, const char *path, int mode) + \brief Create a new symbolic link. + + Your implementation should check if the user has permission to perform this + operation. + + \param fs The file system provided cookie associated with this volume. + \param dir The file system provided cookie associated with the directory + the symbolic link should be created in. + \param name The name of the new symbolic link. + \param path The path of the original inode the symbolic link should refer to. + \param mode The mode that this symbolic link should be created in. (TODO + what exactly?) + \return \c B_OK if you succeeded, or an error code if you failed. */ /*! - \fn status_t (*file_system_module_info::link)(fs_volume fs, fs_vnode dir, - const char *name, fs_vnode vnode) - \brief Create a new hard link. - - You should make sure the user has the proper permissions. - - The virtual file system will request the creation of symbolic links with - create_symlink(). - - \param fs The file system provided cookie associated with this volume. - \param dir The cookie associated to the directory where the link should be - saved. - \param name The name the link should have. - \param vnode The vnode the new link should resolve to. - \retval B_OK The hard link is properly created. - \retval B_NOT_ALLOWED The user does not have the proper permissions. - \retval "other errors" Another error occured. + \fn status_t (*file_system_module_info::link)(fs_volume fs, fs_vnode dir, + const char *name, fs_vnode vnode) + \brief Create a new hard link. + + You should make sure the user has the proper permissions. + + The virtual file system will request the creation of symbolic links with + create_symlink(). + + If you don't implement this function, the VFS will return \c EROFS + when a hard link is requested. + + \param fs The file system provided cookie associated with this volume. + \param dir The cookie associated to the directory where the link should be + saved. + \param name The name the link should have. + \param vnode The vnode the new link should resolve to. + \retval B_OK The hard link is properly created. + \retval B_NOT_ALLOWED The user does not have the proper permissions. + \retval "other errors" Another error occured. */ /*! - \fn status_t (*file_system_module_info::unlink)(fs_volume fs, fs_vnode dir, - const char *name) - \brief Remove a node or directory. - - You should make sure the user has the proper permissions. - - \param fs The file system provided cookie associated with this volume. - \param dir The parent directory of the node that should be removed. - \param name The name of the node that should be deleted. - \retval B_OK Removal succeeded. - \retval B_ENTRY_NOT_FOUND The entry does not exist. - \retval B_NOT_ALLOWED The user does not have the proper permissions. - \retval B_DIRECTORY_NOT_EMPTY The \a name refers to a directory. The virtual - file system expects directories to be emptied before they can be unlinked. - \retval "other errors" Another error occured. + \fn status_t (*file_system_module_info::unlink)(fs_volume fs, fs_vnode dir, + const char *name) + \brief Remove a node or directory. + + You should make sure the user has the proper permissions. + + \param fs The file system provided cookie associated with this volume. + \param dir The parent directory of the node that should be removed. + \param name The name of the node that should be deleted. + \retval B_OK Removal succeeded. + \retval B_ENTRY_NOT_FOUND The entry does not exist. + \retval B_NOT_ALLOWED The user does not have the proper permissions. + \retval B_DIRECTORY_NOT_EMPTY The \a name refers to a directory. The virtual + file system expects directories to be emptied before they can be unlinked. + \retval "other errors" Another error occured. */ /*! - \fn status_t (*file_system_module_info::rename)(fs_volume fs, fs_vnode - fromDir, const char *fromName, fs_vnode toDir, const char *toName) - \brief Rename and/or relocate a vnode. - - The virtual file system merely relays the request, so make sure the user is - not changing the file name to something like '.', '..' or anything starting - with '/'. - - This also means that it if the node is a directory, that it should not be - moved into one of its own children. - - You should also make sure the user has the proper permissions. - - \param fs The file system provided cookie associated with this volume. - \param fromDir The cookie of the parent directory the vnode should be moved - from. - \param fromName The old name of the node. - \param toDir The cookie of the parent directory the vnode should be moved to. - \param toName The new name of the node. - \retval B_OK The renaming and relocating succeeded. - \retval B_BAD_VALUE One of the supplied parameters were invalid. - \retval B_NOT_ALLOWED The user does not have the proper permissions. - \retval "other errors" Another error condition was encountered. + \fn status_t (*file_system_module_info::rename)(fs_volume fs, fs_vnode + fromDir, const char *fromName, fs_vnode toDir, const char *toName) + \brief Rename and/or relocate a vnode. + + The virtual file system merely relays the request, so make sure the user is + not changing the file name to something like '.', '..' or anything starting + with '/'. + + This also means that it if the node is a directory, that it should not be + moved into one of its own children. + + You should also make sure the user has the proper permissions. + + \param fs The file system provided cookie associated with this volume. + \param fromDir The cookie of the parent directory the vnode should be moved + from. + \param fromName The old name of the node. + \param toDir The cookie of the parent directory the vnode should be moved to. + \param toName The new name of the node. + \retval B_OK The renaming and relocating succeeded. + \retval B_BAD_VALUE One of the supplied parameters were invalid. + \retval B_NOT_ALLOWED The user does not have the proper permissions. + \retval "other errors" Another error condition was encountered. */ /*! - \fn status_t (*file_system_module_info::access)(fs_volume fs, fs_vnode vnode, - int mode) - \brief Checks whether the current user is allowed to access the node in the - specified way. + \fn status_t (*file_system_module_info::access)(fs_volume fs, fs_vnode vnode, + int mode) + \brief Checks whether the current user is allowed to access the node in the + specified way. - \a mode is a bitwise combination of: - - \c R_OK: Read access. - - \c W_OK: Write access. - - \c X_OK: Execution. + \a mode is a bitwise combination of: + - \c R_OK: Read access. + - \c W_OK: Write access. + - \c X_OK: Execution. - If the current user does not have any of the access permissions represented - by the set bits, the function shall return \c B_NOT_ALLOWED. As a special - case, if the volume is read-only and write access is requested, - \c B_READ_ONLY_DEVICE shall be returned. If the requested access mode - complies with the user's access permissions, the function shall return - \c B_OK. + If the current user does not have any of the access permissions represented + by the set bits, the function shall return \c B_NOT_ALLOWED. As a special + case, if the volume is read-only and write access is requested, + \c B_READ_ONLY_DEVICE shall be returned. If the requested access mode + complies with the user's access permissions, the function shall return + \c B_OK. - For most FSs the permissions a user has are defined by the \c st_mode, - \c st_uid, and \c st_gid fields of the node's stat data. As a special - exception, the root user (geteuid() == 0) does always have - read and write permissions, execution permission only when at least one of - the execution permission bits are set. + For most FSs the permissions a user has are defined by the \c st_mode, + \c st_uid, and \c st_gid fields of the node's stat data. As a special + exception, the root user (geteuid() == 0) does always have + read and write permissions, execution permission only when at least one of + the execution permission bits are set. - \param fs The volume handle. - \param vnode The node handle. - \param mode The access mode mask. - \retval B_OK The user has the permissions to access the node in the requested - way. - \retval B_READ_ONLY_DEVICE The volume is read-only, but the write access has - been requested. - \retval B_NOT_ALLOWED The user does not have all permissions to access the - node in the requested way. + \param fs The volume handle. + \param vnode The node handle. + \param mode The access mode mask. + \retval B_OK The user has the permissions to access the node in the requested + way. + \retval B_READ_ONLY_DEVICE The volume is read-only, but the write access has + been requested. + \retval B_NOT_ALLOWED The user does not have all permissions to access the + node in the requested way. */ /*! - \fn status_t (*file_system_module_info::read_stat)(fs_volume fs, - fs_vnode vnode, struct stat *stat) - \brief Retrieves the stat data for a given node. + \fn status_t (*file_system_module_info::read_stat)(fs_volume fs, + fs_vnode vnode, struct stat *stat) + \brief Retrieves the stat data for a given node. - All values of the struct stat save \c st_dev, \c st_ino, \c st_rdev, - and \c st_type need to be filled in. + All values of the struct stat save \c st_dev, \c st_ino, \c st_rdev, + and \c st_type need to be filled in. - \param fs The volume handle. - \param vnode The node handle. - \param stat Pointer to a pre-allocated variable the stat data shall be - written to. - \return \c B_OK if everything went fine, another error code otherwise. + \param fs The volume handle. + \param vnode The node handle. + \param stat Pointer to a pre-allocated variable the stat data shall be + written to. + \return \c B_OK if everything went fine, another error code otherwise. */ /*! - \fn status_t (*file_system_module_info::write_stat)(fs_volume fs, fs_vnode - vnode, const struct stat *stat, uint32 statMask) - \brief Update the stats for a vnode. - - You should make sure that the new values are valid and that the user has the - proper permissions to update the stats. - - \param fs The file system provided cookie to the volume. - \param vnode The cookie to the vnode. - \param stat The structure with the updated values. - \param statMask One of the #write_stat_mask enumeration, which forms a mask - of which of the values in \a stat should actually be updated. - \retval B_OK The update succeeded. - \retval B_NOT_ALLOWED The user does not have the proper permissions. - \retval "other errors" Another error condition occured. + \fn status_t (*file_system_module_info::write_stat)(fs_volume fs, fs_vnode + vnode, const struct stat *stat, uint32 statMask) + \brief Update the stats for a vnode. + + You should make sure that the new values are valid and that the user has the + proper permissions to update the stats. + + \param fs The file system provided cookie to the volume. + \param vnode The cookie to the vnode. + \param stat The structure with the updated values. + \param statMask One of the #write_stat_mask enumeration, which forms a mask + of which of the values in \a stat should actually be updated. + \retval B_OK The update succeeded. + \retval B_NOT_ALLOWED The user does not have the proper permissions. + \retval "other errors" Another error condition occured. */ //! @} @@ -673,304 +710,304 @@ //! @{ /*! - \fn status_t (*file_system_module_info::create)(fs_volume fs, fs_vnode dir, - const char *name, int openMode, int perms, fs_cookie *_cookie, - ino_t *_newVnodeID) - \brief Create a new file. - - Your implementation shall check whether it is possible to create the node. - You will need to take the user's permissions into account. When you create - a new file, you will also have to open it. This means also checking the - permissions the user requires to open the file according to the \a mode. - See \link file_system_module_info::open() open() \endlink for the possible - values of \a mode. - - \param fs The file system provided cookie associated with this volume. - \param dir The file system provided cookie associated with the directory - where the file should appear. - \param name The name of the new file. - \param openMode The mode associated to the file. - \param perms The permissions the new file should have. - \param[out] _cookie In case of success, the you can store your file system - data for this node in this variable. - \param[out] _newVnodeID In case of success, you can store the new vnode id - in this variable. - \return You should return \c B_OK if creating the new node succeeded, and if - you put data in both \a _cookie and \a _newVnodeID. Else you should return - an error code. + \fn status_t (*file_system_module_info::create)(fs_volume fs, fs_vnode dir, + const char *name, int openMode, int perms, fs_cookie *_cookie, + ino_t *_newVnodeID) + \brief Create a new file. + + Your implementation shall check whether it is possible to create the node. + You will need to take the user's permissions into account. When you create + a new file, you will also have to open it. This means also checking the + permissions the user requires to open the file according to the \a mode. + See \link file_system_module_info::open() open() \endlink for the possible + values of \a mode. + + \param fs The file system provided cookie associated with this volume. + \param dir The file system provided cookie associated with the directory + where the file should appear. + \param name The name of the new file. + \param openMode The mode associated to the file. + \param perms The permissions the new file should have. + \param[out] _cookie In case of success, the you can store your file system + data for this node in this variable. + \param[out] _newVnodeID In case of success, you can store the new vnode id + in this variable. + \return You should return \c B_OK if creating the new node succeeded, and if + you put data in both \a _cookie and \a _newVnodeID. Else you should return + an error code. */ /*! - \fn status_t (*file_system_module_info::open)(fs_volume fs, fs_vnode vnode, - int openMode, fs_cookie *_cookie) - \brief Opens the given node. + \fn status_t (*file_system_module_info::open)(fs_volume fs, fs_vnode vnode, + int openMode, fs_cookie *_cookie) + \brief Opens the given node. - The function shall check whether it is possible to open the node according to - the mode specified by \c openMode (also considering the user's access - permissions), create a node cookie, and store it in the variable - \a _cookie points to. + The function shall check whether it is possible to open the node according to + the mode specified by \c openMode (also considering the user's access + permissions), create a node cookie, and store it in the variable + \a _cookie points to. - The open mode \a openMode is encoded in the same way as the parameter of the - POSIX function \c open(), i.e. it is either \c O_RDONLY, \c O_WRONLY, or - \c O_RDWR, bitwise or'ed with flags. The only relevant flags for this hook - are \c O_TRUNC and \c O_NONBLOCK. + The open mode \a openMode is encoded in the same way as the parameter of the + POSIX function \c open(), i.e. it is either \c O_RDONLY, \c O_WRONLY, or + \c O_RDWR, bitwise or'ed with flags. The only relevant flags for this hook + are \c O_TRUNC and \c O_NONBLOCK. - \param fs The volume handle. - \param vnode The node handle. - \param openMode The open mode. - \param _cookie Pointer to a pre-allocated variable the node cookie shall be - written to. - \return \c B_OK if everything went fine, another error code otherwise. + \param fs The volume handle. + \param vnode The node handle. + \param openMode The open mode. + \param _cookie Pointer to a pre-allocated variable the node cookie shall be + written to. + \return \c B_OK if everything went fine, another error code otherwise. */ /*! - \fn status_t (*file_system_module_info::close)(fs_volume fs, fs_vnode vnode, - fs_cookie cookie) - \brief Closes the given node cookie. + \fn status_t (*file_system_module_info::close)(fs_volume fs, fs_vnode vnode, + fs_cookie cookie) + \brief Closes the given node cookie. [... truncated: 430 lines follow ...] From niels.reedijk at gmail.com Sun Jul 15 22:16:22 2007 From: niels.reedijk at gmail.com (Niels Reedijk) Date: Sun, 15 Jul 2007 22:16:22 +0200 Subject: [Haiku-commits] r21615 - haiku/trunk/docs/user/drivers In-Reply-To: <200707151331.l6FDV3V6032060@sheep.berlios.de> References: <200707151331.l6FDV3V6032060@sheep.berlios.de> Message-ID: <507d86c0707151316m3f8b4cc2j27bc68ca64ee3096@mail.gmail.com> Hi Axel, > Modified: > haiku/trunk/docs/user/drivers/fs_interface.dox > Log: > * Removed deprecated functions. > * The documented the notify_*() functions - only notify_listener() was deprecated > among them. > * Replaced spaces with tabs - there is no reason to deviate from the standard we're > using everywhere else. > * Completed the docs here and there. Thanks for the help and additions. Unfortunately we don't use tabs in the documentation, but spaces. We could ignore that for this file though. Niels From axeld at pinc-software.de Sun Jul 15 22:40:03 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 15 Jul 2007 22:40:03 +0200 CEST Subject: [Haiku-commits] r21615 - haiku/trunk/docs/user/drivers In-Reply-To: <507d86c0707151316m3f8b4cc2j27bc68ca64ee3096@mail.gmail.com> Message-ID: <40065522041-BeMail@zon> "Niels Reedijk" wrote: > > Modified: > > haiku/trunk/docs/user/drivers/fs_interface.dox > > Log: > > * Removed deprecated functions. > > * The documented the notify_*() functions - only notify_listener() > > was deprecated > > among them. > > * Replaced spaces with tabs - there is no reason to deviate from > > the standard we're > > using everywhere else. > > * Completed the docs here and there. > Thanks for the help and additions. Unfortunately we don't use tabs in > the documentation, but spaces. We could ignore that for this file > though. I wonder why it shouldn't be possible to have one style guide project wide. There is no reason to rule out your own when there is one available. Bye, Axel. From niels.reedijk at gmail.com Sun Jul 15 23:02:24 2007 From: niels.reedijk at gmail.com (Niels Reedijk) Date: Sun, 15 Jul 2007 23:02:24 +0200 Subject: [Haiku-commits] r21615 - haiku/trunk/docs/user/drivers In-Reply-To: <40065522041-BeMail@zon> References: <507d86c0707151316m3f8b4cc2j27bc68ca64ee3096@mail.gmail.com> <40065522041-BeMail@zon> Message-ID: <507d86c0707151402h51d4c11dy36771104db23a172@mail.gmail.com> 2007/7/15, Axel D?rfler : > "Niels Reedijk" wrote: > I wonder why it shouldn't be possible to have one style guide project > wide. > There is no reason to rule out your own when there is one available. I agree, however, I was/am not familiar with the style guide, and since we are dealing with documentation (and not code) it does not seem necessary to immediately change it, especially since it would mean reformatting all the other documents. Which would be a waste of time and energy. Let me put this in other words, this won't really pose a conflict with the style guide, since most of the documentation will not be written by developers. Niels From axeld at pinc-software.de Sun Jul 15 23:51:26 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 15 Jul 2007 23:51:26 +0200 CEST Subject: [Haiku-commits] r21615 - haiku/trunk/docs/user/drivers In-Reply-To: <507d86c0707151402h51d4c11dy36771104db23a172@mail.gmail.com> Message-ID: <44348972380-BeMail@zon> "Niels Reedijk" wrote: > 2007/7/15, Axel D?rfler : > > "Niels Reedijk" wrote: > > I wonder why it shouldn't be possible to have one style guide > > project > > wide. > > There is no reason to rule out your own when there is one > > available. > I agree, however, I was/am not familiar with the style guide, and > since we are dealing with documentation (and not code) it does not > seem necessary to immediately change it, especially since it would That's a simple thing to change: http://haiku-os.org/documents/dev/haiku_coding_guidelines > mean reformatting all the other documents. Which would be a waste of > time and energy. It's not if you don't do it like I did with fs_interface.dox - you can just use a tool like indent to do the job. If you think it's a waste of time, I'd volunteer to do that job. There is only a small amount of documentation written by now - it makes sense to switch now rather than later. There is no reason for a differing style guide so it should be removed. Bye, Axel. From korli at mail.berlios.de Mon Jul 16 00:00:00 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 16 Jul 2007 00:00:00 +0200 Subject: [Haiku-commits] r21618 - in haiku/vendor/mesa/current: glu/libnurbs/interface glu/libnurbs/internals glu/libnurbs/nurbtess glu/libtess glu/libutil headers/private/internal headers/public src src/array_cache src/drivers/common src/glapi src/main src/shader src/shader/grammar src/shader/slang src/shader/slang/library src/sparc src/swrast src/swrast_setup src/tnl src/tnl_dd src/vbo src/x86 src/x86-64 Message-ID: <200707152200.l6FM009K005372@sheep.berlios.de> Author: korli Date: 2007-07-15 23:59:35 +0200 (Sun, 15 Jul 2007) New Revision: 21618 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21618&view=rev Added: haiku/vendor/mesa/current/src/main/queryobj.c haiku/vendor/mesa/current/src/main/queryobj.h haiku/vendor/mesa/current/src/main/shaders.c haiku/vendor/mesa/current/src/main/shaders.h haiku/vendor/mesa/current/src/shader/prog_debug.c haiku/vendor/mesa/current/src/shader/prog_debug.h haiku/vendor/mesa/current/src/shader/prog_execute.c haiku/vendor/mesa/current/src/shader/prog_execute.h haiku/vendor/mesa/current/src/shader/prog_instruction.c haiku/vendor/mesa/current/src/shader/prog_instruction.h haiku/vendor/mesa/current/src/shader/prog_parameter.c haiku/vendor/mesa/current/src/shader/prog_parameter.h haiku/vendor/mesa/current/src/shader/prog_print.c haiku/vendor/mesa/current/src/shader/prog_print.h haiku/vendor/mesa/current/src/shader/prog_statevars.c haiku/vendor/mesa/current/src/shader/prog_statevars.h haiku/vendor/mesa/current/src/shader/shader_api.c haiku/vendor/mesa/current/src/shader/shader_api.h haiku/vendor/mesa/current/src/shader/slang/library/slang_120_core_gc.h haiku/vendor/mesa/current/src/shader/slang/library/slang_builtin_120_common_gc.h haiku/vendor/mesa/current/src/shader/slang/library/slang_builtin_120_fragment_gc.h haiku/vendor/mesa/current/src/shader/slang/library/slang_version_syn.h haiku/vendor/mesa/current/src/shader/slang/slang_builtin.c haiku/vendor/mesa/current/src/shader/slang/slang_builtin.h haiku/vendor/mesa/current/src/shader/slang/slang_codegen.c haiku/vendor/mesa/current/src/shader/slang/slang_codegen.h haiku/vendor/mesa/current/src/shader/slang/slang_emit.c haiku/vendor/mesa/current/src/shader/slang/slang_emit.h haiku/vendor/mesa/current/src/shader/slang/slang_ir.c haiku/vendor/mesa/current/src/shader/slang/slang_ir.h haiku/vendor/mesa/current/src/shader/slang/slang_label.c haiku/vendor/mesa/current/src/shader/slang/slang_label.h haiku/vendor/mesa/current/src/shader/slang/slang_log.c haiku/vendor/mesa/current/src/shader/slang/slang_log.h haiku/vendor/mesa/current/src/shader/slang/slang_mem.c haiku/vendor/mesa/current/src/shader/slang/slang_mem.h haiku/vendor/mesa/current/src/shader/slang/slang_print.c haiku/vendor/mesa/current/src/shader/slang/slang_print.h haiku/vendor/mesa/current/src/shader/slang/slang_simplify.c haiku/vendor/mesa/current/src/shader/slang/slang_simplify.h haiku/vendor/mesa/current/src/shader/slang/slang_typeinfo.c haiku/vendor/mesa/current/src/shader/slang/slang_typeinfo.h haiku/vendor/mesa/current/src/shader/slang/slang_vartable.c haiku/vendor/mesa/current/src/shader/slang/slang_vartable.h haiku/vendor/mesa/current/src/swrast/s_fragprog.c haiku/vendor/mesa/current/src/swrast/s_fragprog.h haiku/vendor/mesa/current/src/tnl/t_draw.c haiku/vendor/mesa/current/src/vbo/ haiku/vendor/mesa/current/src/vbo/vbo.h haiku/vendor/mesa/current/src/vbo/vbo_attrib.h haiku/vendor/mesa/current/src/vbo/vbo_attrib_tmp.h haiku/vendor/mesa/current/src/vbo/vbo_context.c haiku/vendor/mesa/current/src/vbo/vbo_context.h haiku/vendor/mesa/current/src/vbo/vbo_exec.c haiku/vendor/mesa/current/src/vbo/vbo_exec.h haiku/vendor/mesa/current/src/vbo/vbo_exec_api.c haiku/vendor/mesa/current/src/vbo/vbo_exec_array.c haiku/vendor/mesa/current/src/vbo/vbo_exec_draw.c haiku/vendor/mesa/current/src/vbo/vbo_exec_eval.c haiku/vendor/mesa/current/src/vbo/vbo_rebase.c haiku/vendor/mesa/current/src/vbo/vbo_save.c haiku/vendor/mesa/current/src/vbo/vbo_save.h haiku/vendor/mesa/current/src/vbo/vbo_save_api.c haiku/vendor/mesa/current/src/vbo/vbo_save_draw.c haiku/vendor/mesa/current/src/vbo/vbo_save_loopback.c haiku/vendor/mesa/current/src/vbo/vbo_split.c haiku/vendor/mesa/current/src/vbo/vbo_split.h haiku/vendor/mesa/current/src/vbo/vbo_split_copy.c haiku/vendor/mesa/current/src/vbo/vbo_split_inplace.c Removed: haiku/vendor/mesa/current/src/array_cache/ac_context.c haiku/vendor/mesa/current/src/array_cache/ac_context.h haiku/vendor/mesa/current/src/array_cache/ac_import.c haiku/vendor/mesa/current/src/array_cache/acache.h haiku/vendor/mesa/current/src/main/occlude.c haiku/vendor/mesa/current/src/main/occlude.h haiku/vendor/mesa/current/src/shader/grammar/descrip.mms haiku/vendor/mesa/current/src/shader/grammar/sources haiku/vendor/mesa/current/src/shader/nvvertexec.c haiku/vendor/mesa/current/src/shader/nvvertexec.h haiku/vendor/mesa/current/src/shader/program_instruction.h haiku/vendor/mesa/current/src/shader/shaderobjects.c haiku/vendor/mesa/current/src/shader/shaderobjects.h haiku/vendor/mesa/current/src/shader/shaderobjects_3dlabs.c haiku/vendor/mesa/current/src/shader/shaderobjects_3dlabs.h haiku/vendor/mesa/current/src/shader/slang/descrip.mms haiku/vendor/mesa/current/src/shader/slang/library/slang_builtin_vec4_gc.h haiku/vendor/mesa/current/src/shader/slang/slang_analyse.c haiku/vendor/mesa/current/src/shader/slang/slang_analyse.h haiku/vendor/mesa/current/src/shader/slang/slang_assemble.c haiku/vendor/mesa/current/src/shader/slang/slang_assemble.h haiku/vendor/mesa/current/src/shader/slang/slang_assemble_assignment.c haiku/vendor/mesa/current/src/shader/slang/slang_assemble_assignment.h haiku/vendor/mesa/current/src/shader/slang/slang_assemble_conditional.c haiku/vendor/mesa/current/src/shader/slang/slang_assemble_conditional.h haiku/vendor/mesa/current/src/shader/slang/slang_assemble_constructor.c haiku/vendor/mesa/current/src/shader/slang/slang_assemble_constructor.h haiku/vendor/mesa/current/src/shader/slang/slang_assemble_typeinfo.c haiku/vendor/mesa/current/src/shader/slang/slang_assemble_typeinfo.h haiku/vendor/mesa/current/src/shader/slang/slang_execute.c haiku/vendor/mesa/current/src/shader/slang/slang_execute.h haiku/vendor/mesa/current/src/shader/slang/slang_execute_x86.c haiku/vendor/mesa/current/src/shader/slang/slang_export.c haiku/vendor/mesa/current/src/shader/slang/slang_export.h haiku/vendor/mesa/current/src/shader/slang/slang_library_texsample.c haiku/vendor/mesa/current/src/shader/slang/slang_library_texsample.h haiku/vendor/mesa/current/src/shader/slang/slang_mesa.h haiku/vendor/mesa/current/src/shader/slang/sources haiku/vendor/mesa/current/src/shader/slang/traverse_wrap.h haiku/vendor/mesa/current/src/swrast/s_arbshader.c haiku/vendor/mesa/current/src/swrast/s_arbshader.h haiku/vendor/mesa/current/src/swrast/s_nvfragprog.c haiku/vendor/mesa/current/src/swrast/s_nvfragprog.h haiku/vendor/mesa/current/src/tnl/t_array_api.c haiku/vendor/mesa/current/src/tnl/t_array_api.h haiku/vendor/mesa/current/src/tnl/t_array_import.c haiku/vendor/mesa/current/src/tnl/t_array_import.h haiku/vendor/mesa/current/src/tnl/t_save_api.h haiku/vendor/mesa/current/src/tnl/t_save_loopback.c haiku/vendor/mesa/current/src/tnl/t_save_playback.c haiku/vendor/mesa/current/src/tnl/t_vb_arbprogram.c haiku/vendor/mesa/current/src/tnl/t_vb_arbprogram.h haiku/vendor/mesa/current/src/tnl/t_vb_arbprogram_sse.c haiku/vendor/mesa/current/src/tnl/t_vb_arbshader.c haiku/vendor/mesa/current/src/tnl/t_vtx_api.c haiku/vendor/mesa/current/src/tnl/t_vtx_api.h haiku/vendor/mesa/current/src/tnl/t_vtx_eval.c haiku/vendor/mesa/current/src/tnl/t_vtx_exec.c haiku/vendor/mesa/current/src/tnl/t_vtx_generic.c haiku/vendor/mesa/current/src/tnl/t_vtx_x86.c haiku/vendor/mesa/current/src/tnl/t_vtx_x86_gcc.S Modified: haiku/vendor/mesa/current/glu/libnurbs/interface/bezierEval.h haiku/vendor/mesa/current/glu/libnurbs/interface/bezierPatch.cc haiku/vendor/mesa/current/glu/libnurbs/interface/bezierPatch.h haiku/vendor/mesa/current/glu/libnurbs/interface/bezierPatchMesh.cc haiku/vendor/mesa/current/glu/libnurbs/interface/bezierPatchMesh.h haiku/vendor/mesa/current/glu/libnurbs/interface/glcurveval.cc haiku/vendor/mesa/current/glu/libnurbs/interface/glimports.h haiku/vendor/mesa/current/glu/libnurbs/interface/glinterface.cc haiku/vendor/mesa/current/glu/libnurbs/interface/glrenderer.h haiku/vendor/mesa/current/glu/libnurbs/interface/incurveeval.cc haiku/vendor/mesa/current/glu/libnurbs/interface/insurfeval.cc haiku/vendor/mesa/current/glu/libnurbs/interface/mystdio.h haiku/vendor/mesa/current/glu/libnurbs/interface/mystdlib.h haiku/vendor/mesa/current/glu/libnurbs/internals/arc.h haiku/vendor/mesa/current/glu/libnurbs/internals/arcsorter.cc haiku/vendor/mesa/current/glu/libnurbs/internals/arcsorter.h haiku/vendor/mesa/current/glu/libnurbs/internals/arctess.h haiku/vendor/mesa/current/glu/libnurbs/internals/backend.cc haiku/vendor/mesa/current/glu/libnurbs/internals/backend.h haiku/vendor/mesa/current/glu/libnurbs/internals/basiccrveval.h haiku/vendor/mesa/current/glu/libnurbs/internals/basicsurfeval.h haiku/vendor/mesa/current/glu/libnurbs/internals/bezierarc.h haiku/vendor/mesa/current/glu/libnurbs/internals/bin.cc haiku/vendor/mesa/current/glu/libnurbs/internals/bin.h haiku/vendor/mesa/current/glu/libnurbs/internals/bufpool.cc haiku/vendor/mesa/current/glu/libnurbs/internals/bufpool.h haiku/vendor/mesa/current/glu/libnurbs/internals/cachingeval.cc haiku/vendor/mesa/current/glu/libnurbs/internals/cachingeval.h haiku/vendor/mesa/current/glu/libnurbs/internals/ccw.cc haiku/vendor/mesa/current/glu/libnurbs/internals/coveandtiler.h haiku/vendor/mesa/current/glu/libnurbs/internals/curve.cc haiku/vendor/mesa/current/glu/libnurbs/internals/curve.h haiku/vendor/mesa/current/glu/libnurbs/internals/curvelist.cc haiku/vendor/mesa/current/glu/libnurbs/internals/curvelist.h haiku/vendor/mesa/current/glu/libnurbs/internals/curvesub.cc haiku/vendor/mesa/current/glu/libnurbs/internals/dataTransform.cc haiku/vendor/mesa/current/glu/libnurbs/internals/dataTransform.h haiku/vendor/mesa/current/glu/libnurbs/internals/defines.h haiku/vendor/mesa/current/glu/libnurbs/internals/displaylist.cc haiku/vendor/mesa/current/glu/libnurbs/internals/displaylist.h haiku/vendor/mesa/current/glu/libnurbs/internals/displaymode.h haiku/vendor/mesa/current/glu/libnurbs/internals/flist.cc haiku/vendor/mesa/current/glu/libnurbs/internals/flist.h haiku/vendor/mesa/current/glu/libnurbs/internals/flistsorter.cc haiku/vendor/mesa/current/glu/libnurbs/internals/flistsorter.h haiku/vendor/mesa/current/glu/libnurbs/internals/gridline.h haiku/vendor/mesa/current/glu/libnurbs/internals/gridtrimvertex.h haiku/vendor/mesa/current/glu/libnurbs/internals/gridvertex.h haiku/vendor/mesa/current/glu/libnurbs/internals/hull.cc haiku/vendor/mesa/current/glu/libnurbs/internals/hull.h haiku/vendor/mesa/current/glu/libnurbs/internals/intersect.cc haiku/vendor/mesa/current/glu/libnurbs/internals/jarcloc.h haiku/vendor/mesa/current/glu/libnurbs/internals/knotvector.h haiku/vendor/mesa/current/glu/libnurbs/internals/mapdesc.cc haiku/vendor/mesa/current/glu/libnurbs/internals/mapdesc.h haiku/vendor/mesa/current/glu/libnurbs/internals/mapdescv.cc haiku/vendor/mesa/current/glu/libnurbs/internals/maplist.cc haiku/vendor/mesa/current/glu/libnurbs/internals/maplist.h haiku/vendor/mesa/current/glu/libnurbs/internals/mesher.cc haiku/vendor/mesa/current/glu/libnurbs/internals/mesher.h haiku/vendor/mesa/current/glu/libnurbs/internals/monoTriangulationBackend.cc haiku/vendor/mesa/current/glu/libnurbs/internals/monotonizer.cc haiku/vendor/mesa/current/glu/libnurbs/internals/monotonizer.h haiku/vendor/mesa/current/glu/libnurbs/internals/myassert.h haiku/vendor/mesa/current/glu/libnurbs/internals/mycode.cc haiku/vendor/mesa/current/glu/libnurbs/internals/mystring.h haiku/vendor/mesa/current/glu/libnurbs/internals/nurbsconsts.h haiku/vendor/mesa/current/glu/libnurbs/internals/nurbstess.cc haiku/vendor/mesa/current/glu/libnurbs/internals/patch.cc haiku/vendor/mesa/current/glu/libnurbs/internals/patch.h haiku/vendor/mesa/current/glu/libnurbs/internals/patchlist.cc haiku/vendor/mesa/current/glu/libnurbs/internals/patchlist.h haiku/vendor/mesa/current/glu/libnurbs/internals/pwlarc.h haiku/vendor/mesa/current/glu/libnurbs/internals/quilt.cc haiku/vendor/mesa/current/glu/libnurbs/internals/quilt.h haiku/vendor/mesa/current/glu/libnurbs/internals/reader.cc haiku/vendor/mesa/current/glu/libnurbs/internals/reader.h haiku/vendor/mesa/current/glu/libnurbs/internals/renderhints.cc haiku/vendor/mesa/current/glu/libnurbs/internals/renderhints.h haiku/vendor/mesa/current/glu/libnurbs/internals/simplemath.h haiku/vendor/mesa/current/glu/libnurbs/internals/slicer.cc haiku/vendor/mesa/current/glu/libnurbs/internals/slicer.h haiku/vendor/mesa/current/glu/libnurbs/internals/sorter.cc haiku/vendor/mesa/current/glu/libnurbs/internals/sorter.h haiku/vendor/mesa/current/glu/libnurbs/internals/splitarcs.cc haiku/vendor/mesa/current/glu/libnurbs/internals/subdivider.h haiku/vendor/mesa/current/glu/libnurbs/internals/tobezier.cc haiku/vendor/mesa/current/glu/libnurbs/internals/trimline.cc haiku/vendor/mesa/current/glu/libnurbs/internals/trimline.h haiku/vendor/mesa/current/glu/libnurbs/internals/trimregion.cc haiku/vendor/mesa/current/glu/libnurbs/internals/trimregion.h haiku/vendor/mesa/current/glu/libnurbs/internals/trimvertex.h haiku/vendor/mesa/current/glu/libnurbs/internals/trimvertpool.cc haiku/vendor/mesa/current/glu/libnurbs/internals/trimvertpool.h haiku/vendor/mesa/current/glu/libnurbs/internals/types.h haiku/vendor/mesa/current/glu/libnurbs/internals/uarray.cc haiku/vendor/mesa/current/glu/libnurbs/internals/uarray.h haiku/vendor/mesa/current/glu/libnurbs/internals/varray.cc haiku/vendor/mesa/current/glu/libnurbs/internals/varray.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/definitions.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/directedLine.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/glimports.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/gridWrap.cc haiku/vendor/mesa/current/glu/libnurbs/nurbtess/gridWrap.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/monoChain.cc haiku/vendor/mesa/current/glu/libnurbs/nurbtess/monoChain.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/monoTriangulation.cc haiku/vendor/mesa/current/glu/libnurbs/nurbtess/monoTriangulation.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/mystdio.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/mystdlib.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/partitionX.cc haiku/vendor/mesa/current/glu/libnurbs/nurbtess/partitionX.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/partitionY.cc haiku/vendor/mesa/current/glu/libnurbs/nurbtess/partitionY.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/polyDBG.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/polyUtil.cc haiku/vendor/mesa/current/glu/libnurbs/nurbtess/polyUtil.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/primitiveStream.cc haiku/vendor/mesa/current/glu/libnurbs/nurbtess/primitiveStream.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/quicksort.cc haiku/vendor/mesa/current/glu/libnurbs/nurbtess/quicksort.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/rectBlock.cc haiku/vendor/mesa/current/glu/libnurbs/nurbtess/rectBlock.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/sampleComp.cc haiku/vendor/mesa/current/glu/libnurbs/nurbtess/sampleComp.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/sampleCompBot.cc haiku/vendor/mesa/current/glu/libnurbs/nurbtess/sampleCompBot.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/sampleCompRight.cc haiku/vendor/mesa/current/glu/libnurbs/nurbtess/sampleCompRight.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/sampleCompTop.cc haiku/vendor/mesa/current/glu/libnurbs/nurbtess/sampleCompTop.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/sampleMonoPoly.cc haiku/vendor/mesa/current/glu/libnurbs/nurbtess/sampleMonoPoly.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/sampledLine.cc haiku/vendor/mesa/current/glu/libnurbs/nurbtess/sampledLine.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/searchTree.cc haiku/vendor/mesa/current/glu/libnurbs/nurbtess/searchTree.h haiku/vendor/mesa/current/glu/libnurbs/nurbtess/zlassert.h haiku/vendor/mesa/current/glu/libtess/README haiku/vendor/mesa/current/glu/libtess/alg-outline haiku/vendor/mesa/current/glu/libtess/dict-list.h haiku/vendor/mesa/current/glu/libtess/dict.c haiku/vendor/mesa/current/glu/libtess/dict.h haiku/vendor/mesa/current/glu/libtess/geom.c haiku/vendor/mesa/current/glu/libtess/memalloc.c haiku/vendor/mesa/current/glu/libtess/memalloc.h haiku/vendor/mesa/current/glu/libtess/mesh.c haiku/vendor/mesa/current/glu/libtess/mesh.h haiku/vendor/mesa/current/glu/libtess/normal.h haiku/vendor/mesa/current/glu/libtess/priorityq-heap.c haiku/vendor/mesa/current/glu/libtess/priorityq-heap.h haiku/vendor/mesa/current/glu/libtess/priorityq-sort.h haiku/vendor/mesa/current/glu/libtess/priorityq.c haiku/vendor/mesa/current/glu/libtess/priorityq.h haiku/vendor/mesa/current/glu/libtess/render.c haiku/vendor/mesa/current/glu/libtess/render.h haiku/vendor/mesa/current/glu/libtess/sweep.h haiku/vendor/mesa/current/glu/libtess/tess.h haiku/vendor/mesa/current/glu/libtess/tessmono.c haiku/vendor/mesa/current/glu/libtess/tessmono.h haiku/vendor/mesa/current/glu/libutil/error.c haiku/vendor/mesa/current/glu/libutil/glue.c haiku/vendor/mesa/current/glu/libutil/gluint.h haiku/vendor/mesa/current/glu/libutil/project.c haiku/vendor/mesa/current/glu/libutil/registry.c haiku/vendor/mesa/current/headers/private/internal/glcore.h haiku/vendor/mesa/current/headers/public/glext.h haiku/vendor/mesa/current/src/drivers/common/driverfuncs.c haiku/vendor/mesa/current/src/drivers/common/driverfuncs.h haiku/vendor/mesa/current/src/glapi/glapi.c haiku/vendor/mesa/current/src/glapi/glapitable.h haiku/vendor/mesa/current/src/glapi/glapitemp.h haiku/vendor/mesa/current/src/glapi/glprocs.h haiku/vendor/mesa/current/src/main/api_loopback.c haiku/vendor/mesa/current/src/main/api_noop.c haiku/vendor/mesa/current/src/main/arrayobj.c haiku/vendor/mesa/current/src/main/attrib.c haiku/vendor/mesa/current/src/main/bufferobj.c haiku/vendor/mesa/current/src/main/buffers.c haiku/vendor/mesa/current/src/main/colortab.c haiku/vendor/mesa/current/src/main/config.h haiku/vendor/mesa/current/src/main/context.c haiku/vendor/mesa/current/src/main/context.h haiku/vendor/mesa/current/src/main/dd.h haiku/vendor/mesa/current/src/main/dlist.c haiku/vendor/mesa/current/src/main/enable.c haiku/vendor/mesa/current/src/main/enums.c haiku/vendor/mesa/current/src/main/execmem.c haiku/vendor/mesa/current/src/main/extensions.c haiku/vendor/mesa/current/src/main/fbobject.c haiku/vendor/mesa/current/src/main/framebuffer.c haiku/vendor/mesa/current/src/main/framebuffer.h haiku/vendor/mesa/current/src/main/get.c haiku/vendor/mesa/current/src/main/getstring.c haiku/vendor/mesa/current/src/main/glheader.h haiku/vendor/mesa/current/src/main/image.c haiku/vendor/mesa/current/src/main/imports.c haiku/vendor/mesa/current/src/main/imports.h haiku/vendor/mesa/current/src/main/light.c haiku/vendor/mesa/current/src/main/light.h haiku/vendor/mesa/current/src/main/lines.c haiku/vendor/mesa/current/src/main/matrix.c haiku/vendor/mesa/current/src/main/mipmap.c haiku/vendor/mesa/current/src/main/mtypes.h haiku/vendor/mesa/current/src/main/pixel.c haiku/vendor/mesa/current/src/main/points.c haiku/vendor/mesa/current/src/main/points.h haiku/vendor/mesa/current/src/main/polygon.c haiku/vendor/mesa/current/src/main/polygon.h haiku/vendor/mesa/current/src/main/rastpos.c haiku/vendor/mesa/current/src/main/rbadaptors.c haiku/vendor/mesa/current/src/main/renderbuffer.c haiku/vendor/mesa/current/src/main/renderbuffer.h haiku/vendor/mesa/current/src/main/state.c haiku/vendor/mesa/current/src/main/stencil.c haiku/vendor/mesa/current/src/main/texcompress_fxt1.c haiku/vendor/mesa/current/src/main/texcompress_s3tc.c haiku/vendor/mesa/current/src/main/texenvprogram.c haiku/vendor/mesa/current/src/main/teximage.c haiku/vendor/mesa/current/src/main/texobj.c haiku/vendor/mesa/current/src/main/texrender.c haiku/vendor/mesa/current/src/main/texstate.c haiku/vendor/mesa/current/src/main/texstore.c haiku/vendor/mesa/current/src/main/texstore.h haiku/vendor/mesa/current/src/main/varray.c haiku/vendor/mesa/current/src/main/version.h haiku/vendor/mesa/current/src/shader/arbprogparse.c haiku/vendor/mesa/current/src/shader/arbprogram.c haiku/vendor/mesa/current/src/shader/grammar/grammar.c haiku/vendor/mesa/current/src/shader/nvfragparse.c haiku/vendor/mesa/current/src/shader/nvprogram.c haiku/vendor/mesa/current/src/shader/nvvertparse.c haiku/vendor/mesa/current/src/shader/program.c haiku/vendor/mesa/current/src/shader/program.h haiku/vendor/mesa/current/src/shader/programopt.c haiku/vendor/mesa/current/src/shader/programopt.h haiku/vendor/mesa/current/src/shader/slang/library/gc_to_bin.c haiku/vendor/mesa/current/src/shader/slang/library/slang_common_builtin_gc.h haiku/vendor/mesa/current/src/shader/slang/library/slang_core_gc.h haiku/vendor/mesa/current/src/shader/slang/library/slang_fragment_builtin_gc.h haiku/vendor/mesa/current/src/shader/slang/library/slang_shader_syn.h haiku/vendor/mesa/current/src/shader/slang/library/slang_vertex_builtin_gc.h haiku/vendor/mesa/current/src/shader/slang/slang_compile.c haiku/vendor/mesa/current/src/shader/slang/slang_compile.h haiku/vendor/mesa/current/src/shader/slang/slang_compile_function.c haiku/vendor/mesa/current/src/shader/slang/slang_compile_function.h haiku/vendor/mesa/current/src/shader/slang/slang_compile_operation.c haiku/vendor/mesa/current/src/shader/slang/slang_compile_operation.h haiku/vendor/mesa/current/src/shader/slang/slang_compile_struct.c haiku/vendor/mesa/current/src/shader/slang/slang_compile_variable.c haiku/vendor/mesa/current/src/shader/slang/slang_compile_variable.h haiku/vendor/mesa/current/src/shader/slang/slang_library_noise.c haiku/vendor/mesa/current/src/shader/slang/slang_link.c haiku/vendor/mesa/current/src/shader/slang/slang_link.h haiku/vendor/mesa/current/src/shader/slang/slang_preprocess.c haiku/vendor/mesa/current/src/shader/slang/slang_preprocess.h haiku/vendor/mesa/current/src/shader/slang/slang_storage.c haiku/vendor/mesa/current/src/shader/slang/slang_storage.h haiku/vendor/mesa/current/src/shader/slang/slang_utility.c haiku/vendor/mesa/current/src/shader/slang/slang_utility.h haiku/vendor/mesa/current/src/sparc/glapi_sparc.S haiku/vendor/mesa/current/src/swrast/s_aaline.c haiku/vendor/mesa/current/src/swrast/s_aalinetemp.h haiku/vendor/mesa/current/src/swrast/s_aatriangle.c haiku/vendor/mesa/current/src/swrast/s_aatritemp.h haiku/vendor/mesa/current/src/swrast/s_accum.c haiku/vendor/mesa/current/src/swrast/s_alpha.c haiku/vendor/mesa/current/src/swrast/s_atifragshader.c haiku/vendor/mesa/current/src/swrast/s_bitmap.c haiku/vendor/mesa/current/src/swrast/s_buffers.c haiku/vendor/mesa/current/src/swrast/s_context.c haiku/vendor/mesa/current/src/swrast/s_context.h haiku/vendor/mesa/current/src/swrast/s_copypix.c haiku/vendor/mesa/current/src/swrast/s_depth.c haiku/vendor/mesa/current/src/swrast/s_drawpix.c haiku/vendor/mesa/current/src/swrast/s_feedback.c haiku/vendor/mesa/current/src/swrast/s_fog.c haiku/vendor/mesa/current/src/swrast/s_lines.c haiku/vendor/mesa/current/src/swrast/s_linetemp.h haiku/vendor/mesa/current/src/swrast/s_logic.c haiku/vendor/mesa/current/src/swrast/s_masking.c haiku/vendor/mesa/current/src/swrast/s_points.c haiku/vendor/mesa/current/src/swrast/s_pointtemp.h haiku/vendor/mesa/current/src/swrast/s_readpix.c haiku/vendor/mesa/current/src/swrast/s_span.c haiku/vendor/mesa/current/src/swrast/s_span.h haiku/vendor/mesa/current/src/swrast/s_stencil.c haiku/vendor/mesa/current/src/swrast/s_texcombine.c haiku/vendor/mesa/current/src/swrast/s_texfilter.c haiku/vendor/mesa/current/src/swrast/s_triangle.c haiku/vendor/mesa/current/src/swrast/s_tritemp.h haiku/vendor/mesa/current/src/swrast/s_zoom.c haiku/vendor/mesa/current/src/swrast/swrast.h haiku/vendor/mesa/current/src/swrast_setup/ss_context.c haiku/vendor/mesa/current/src/swrast_setup/ss_triangle.c haiku/vendor/mesa/current/src/swrast_setup/ss_tritmp.h haiku/vendor/mesa/current/src/tnl/t_context.c haiku/vendor/mesa/current/src/tnl/t_context.h haiku/vendor/mesa/current/src/tnl/t_pipeline.c haiku/vendor/mesa/current/src/tnl/t_pipeline.h haiku/vendor/mesa/current/src/tnl/t_save_api.c haiku/vendor/mesa/current/src/tnl/t_vb_cull.c haiku/vendor/mesa/current/src/tnl/t_vb_fog.c haiku/vendor/mesa/current/src/tnl/t_vb_light.c haiku/vendor/mesa/current/src/tnl/t_vb_normals.c haiku/vendor/mesa/current/src/tnl/t_vb_points.c haiku/vendor/mesa/current/src/tnl/t_vb_program.c haiku/vendor/mesa/current/src/tnl/t_vb_render.c haiku/vendor/mesa/current/src/tnl/t_vb_rendertmp.h haiku/vendor/mesa/current/src/tnl/t_vb_texgen.c haiku/vendor/mesa/current/src/tnl/t_vb_texmat.c haiku/vendor/mesa/current/src/tnl/t_vb_vertex.c haiku/vendor/mesa/current/src/tnl/t_vp_build.c haiku/vendor/mesa/current/src/tnl/tnl.h haiku/vendor/mesa/current/src/tnl_dd/t_dd_vb.c haiku/vendor/mesa/current/src/x86-64/glapi_x86-64.S haiku/vendor/mesa/current/src/x86-64/matypes.h haiku/vendor/mesa/current/src/x86/common_x86.c haiku/vendor/mesa/current/src/x86/glapi_x86.S haiku/vendor/mesa/current/src/x86/matypes.h haiku/vendor/mesa/current/src/x86/mmx_blend.S haiku/vendor/mesa/current/src/x86/read_rgba_span_x86.S Log: updating mesa vendor with version 6.5.3 Modified: haiku/vendor/mesa/current/glu/libnurbs/interface/bezierEval.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/interface/bezierEval.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/interface/bezierEval.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -34,7 +34,7 @@ ** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ */ /* -** $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/interface/bezierEval.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ +** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/bezierEval.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #ifndef _BEZIEREVAL_H Modified: haiku/vendor/mesa/current/glu/libnurbs/interface/bezierPatch.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/interface/bezierPatch.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/interface/bezierPatch.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -34,7 +34,7 @@ ** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ */ /* -** $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/interface/bezierPatch.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $ +** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/bezierPatch.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #include "gluos.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/interface/bezierPatch.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/interface/bezierPatch.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/interface/bezierPatch.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -34,7 +34,7 @@ ** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ */ /* -** $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/interface/bezierPatch.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ +** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/bezierPatch.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #ifndef _BEZIERPATCH_H Modified: haiku/vendor/mesa/current/glu/libnurbs/interface/bezierPatchMesh.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/interface/bezierPatchMesh.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/interface/bezierPatchMesh.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -34,7 +34,7 @@ ** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ */ /* -** $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/interface/bezierPatchMesh.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $ +** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/bezierPatchMesh.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #include "gluos.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/interface/bezierPatchMesh.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/interface/bezierPatchMesh.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/interface/bezierPatchMesh.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -34,7 +34,7 @@ ** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ */ /* -** $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/interface/bezierPatchMesh.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ +** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/bezierPatchMesh.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #ifndef _BEZIERPATCHMESH_H Modified: haiku/vendor/mesa/current/glu/libnurbs/interface/glcurveval.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/interface/glcurveval.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/interface/glcurveval.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * glcurveval.c++ * * $Date: 2006/03/29 18:46:46 $ $Revision: 1.7 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/interface/glcurveval.cc,v 1.7 2006/03/29 18:46:46 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glcurveval.cc,v 1.7 2006/03/29 18:46:46 brianp Exp $ */ /* Polynomial Evaluator Interface */ Modified: haiku/vendor/mesa/current/glu/libnurbs/interface/glimports.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/interface/glimports.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/interface/glimports.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * glimports.h * * $Date: 2001/03/19 17:52:02 $ $Revision: 1.3 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/interface/glimports.h,v 1.3 2001/03/19 17:52:02 pesco Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glimports.h,v 1.3 2001/03/19 17:52:02 pesco Exp $ */ #ifndef __gluimports_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/interface/glinterface.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/interface/glinterface.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/interface/glinterface.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -34,7 +34,7 @@ ** $Date: 2001/07/16 15:46:42 $ $Revision: 1.2 $ */ /* -** $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/interface/glinterface.cc,v 1.2 2001/07/16 15:46:42 brianp Exp $ +** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glinterface.cc,v 1.2 2001/07/16 15:46:42 brianp Exp $ */ #include "gluos.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/interface/glrenderer.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/interface/glrenderer.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/interface/glrenderer.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * glrenderer.h * * $Date: 2004/02/26 14:58:11 $ $Revision: 1.4 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/interface/glrenderer.h,v 1.4 2004/02/26 14:58:11 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glrenderer.h,v 1.4 2004/02/26 14:58:11 brianp Exp $ */ #ifndef __gluglrenderer_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/interface/incurveeval.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/interface/incurveeval.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/interface/incurveeval.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -34,7 +34,7 @@ ** $Date: 2004/05/12 15:29:36 $ $Revision: 1.2 $ */ /* -** $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/interface/incurveeval.cc,v 1.2 2004/05/12 15:29:36 brianp Exp $ +** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/incurveeval.cc,v 1.2 2004/05/12 15:29:36 brianp Exp $ */ #include Modified: haiku/vendor/mesa/current/glu/libnurbs/interface/insurfeval.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/interface/insurfeval.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/interface/insurfeval.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -34,7 +34,7 @@ ** $Date: 2004/05/12 15:29:36 $ $Revision: 1.3 $ */ /* -** $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/interface/insurfeval.cc,v 1.3 2004/05/12 15:29:36 brianp Exp $ +** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/insurfeval.cc,v 1.3 2004/05/12 15:29:36 brianp Exp $ */ #include "gluos.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/interface/mystdio.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/interface/mystdio.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/interface/mystdio.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * mystdio.h * * $Date: 2006/03/14 15:08:52 $ $Revision: 1.4 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/interface/mystdio.h,v 1.4 2006/03/14 15:08:52 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/mystdio.h,v 1.4 2006/03/14 15:08:52 brianp Exp $ */ #ifndef __glumystdio_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/interface/mystdlib.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/interface/mystdlib.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/interface/mystdlib.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * mystdlib.h * * $Date: 2001/03/19 17:52:02 $ $Revision: 1.3 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/interface/mystdlib.h,v 1.3 2001/03/19 17:52:02 pesco Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/mystdlib.h,v 1.3 2001/03/19 17:52:02 pesco Exp $ */ #ifndef __glumystdlib_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/arc.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/arc.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/arc.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * arc.h * * $Date: 2001/08/07 17:34:11 $ $Revision: 1.2 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/arc.h,v 1.2 2001/08/07 17:34:11 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/arc.h,v 1.2 2001/08/07 17:34:11 brianp Exp $ */ #ifndef __gluarc_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/arcsorter.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/arcsorter.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/arcsorter.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * arcsorter.c++ * * $Date: 2006/03/14 15:08:52 $ $Revision: 1.2 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/arcsorter.cc,v 1.2 2006/03/14 15:08:52 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/arcsorter.cc,v 1.2 2006/03/14 15:08:52 brianp Exp $ */ #ifndef __gluarcsorter_c_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/arcsorter.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/arcsorter.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/arcsorter.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * arcsorter.h * * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/arcsorter.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/arcsorter.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #ifndef __gluarcsorter_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/arctess.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/arctess.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/arctess.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * arctess.h * * $Date: 2001/08/07 17:34:11 $ $Revision: 1.2 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/arctess.h,v 1.2 2001/08/07 17:34:11 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/arctess.h,v 1.2 2001/08/07 17:34:11 brianp Exp $ */ #ifndef __gluarctess_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/backend.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/backend.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/backend.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * backend.c++ * * $Date: 2004/05/12 15:29:36 $ $Revision: 1.2 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/backend.cc,v 1.2 2004/05/12 15:29:36 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/backend.cc,v 1.2 2004/05/12 15:29:36 brianp Exp $ */ /* Bezier surface backend Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/backend.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/backend.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/backend.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * backend.h * * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/backend.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/backend.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #ifndef __glubackend_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/basiccrveval.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/basiccrveval.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/basiccrveval.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * basiccurveeval.h * * $Date: 2006/03/29 18:54:00 $ $Revision: 1.2 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/basiccrveval.h,v 1.2 2006/03/29 18:54:00 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/basiccrveval.h,v 1.2 2006/03/29 18:54:00 brianp Exp $ */ #ifndef __glubasiccrveval_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/basicsurfeval.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/basicsurfeval.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/basicsurfeval.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * basicsurfeval.h * * $Date: 2006/03/29 18:54:00 $ $Revision: 1.2 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/basicsurfeval.h,v 1.2 2006/03/29 18:54:00 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/basicsurfeval.h,v 1.2 2006/03/29 18:54:00 brianp Exp $ */ #ifndef __glubasicsurfeval_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/bezierarc.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/bezierarc.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/bezierarc.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * bezierarc.h * * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/bezierarc.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/bezierarc.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #ifndef __glubezierarc_h Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/bin.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/bin.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/bin.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * bin.c++ * * $Date: 2006/03/14 15:08:52 $ $Revision: 1.3 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/bin.cc,v 1.3 2006/03/14 15:08:52 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/bin.cc,v 1.3 2006/03/14 15:08:52 brianp Exp $ */ #include "glimports.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/bin.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/bin.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/bin.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * bin.h * * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/bin.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/bin.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #ifndef __glubin_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/bufpool.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/bufpool.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/bufpool.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * bufpool.c++ * * $Date: 2004/05/12 15:29:36 $ $Revision: 1.2 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/bufpool.cc,v 1.2 2004/05/12 15:29:36 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/bufpool.cc,v 1.2 2004/05/12 15:29:36 brianp Exp $ */ #include "glimports.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/bufpool.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/bufpool.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/bufpool.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * bufpool.h * * $Date: 2006/03/29 18:46:46 $ $Revision: 1.3 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/bufpool.h,v 1.3 2006/03/29 18:46:46 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/bufpool.h,v 1.3 2006/03/29 18:46:46 brianp Exp $ */ #ifndef __glubufpool_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/cachingeval.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/cachingeval.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/cachingeval.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * cachingeval.c++ * * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/cachingeval.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/cachingeval.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #include "cachingeval.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/cachingeval.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/cachingeval.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/cachingeval.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * cachingeval.h * * $Date: 2006/03/29 18:54:00 $ $Revision: 1.2 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/cachingeval.h,v 1.2 2006/03/29 18:54:00 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/cachingeval.h,v 1.2 2006/03/29 18:54:00 brianp Exp $ */ #ifndef __glucachingval_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/ccw.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/ccw.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/ccw.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * ccw.c++ * * $Date: 2006/03/14 15:08:52 $ $Revision: 1.3 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/ccw.cc,v 1.3 2006/03/14 15:08:52 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/ccw.cc,v 1.3 2006/03/14 15:08:52 brianp Exp $ */ #include "glimports.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/coveandtiler.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/coveandtiler.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/coveandtiler.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * coveandtiler.h * * $Date: 2001/07/16 15:46:42 $ $Revision: 1.2 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/coveandtiler.h,v 1.2 2001/07/16 15:46:42 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/coveandtiler.h,v 1.2 2001/07/16 15:46:42 brianp Exp $ */ #ifndef __glucoveandtiler_h Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/curve.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/curve.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/curve.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * curve.c++ * * $Date: 2004/05/12 15:29:36 $ $Revision: 1.3 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/curve.cc,v 1.3 2004/05/12 15:29:36 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/curve.cc,v 1.3 2004/05/12 15:29:36 brianp Exp $ */ #include "glimports.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/curve.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/curve.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/curve.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * curve.h * * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/curve.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/curve.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #ifndef __glucurve_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/curvelist.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/curvelist.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/curvelist.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * curvelist.c++ * * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/curvelist.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/curvelist.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #include "glimports.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/curvelist.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/curvelist.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/curvelist.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * curvelist.h * * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/curvelist.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/curvelist.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #ifndef __glucurvelist_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/curvesub.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/curvesub.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/curvesub.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * curvesub.c++ * * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/curvesub.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/curvesub.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #include "glimports.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/dataTransform.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/dataTransform.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/dataTransform.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -34,7 +34,7 @@ ** $Date: 2005/10/28 13:09:23 $ $Revision: 1.2 $ */ /* -** $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/dataTransform.cc,v 1.2 2005/10/28 13:09:23 brianp Exp $ +** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/dataTransform.cc,v 1.2 2005/10/28 13:09:23 brianp Exp $ */ #include Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/dataTransform.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/dataTransform.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/dataTransform.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -34,7 +34,7 @@ ** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ */ /* -** $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/dataTransform.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ +** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/dataTransform.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #ifndef _DATA_TRANSFORM_H Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/defines.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/defines.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/defines.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * defines.h * * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/defines.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/defines.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #ifndef __gludefines_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/displaylist.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/displaylist.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/displaylist.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * displaylist.c++ * * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/displaylist.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/displaylist.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #include "glimports.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/displaylist.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/displaylist.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/displaylist.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * displaylist.h * * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/displaylist.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/displaylist.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #ifndef __gludisplaylist_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/displaymode.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/displaymode.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/displaymode.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -34,7 +34,7 @@ ** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ */ /* -** $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/displaymode.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ +** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/displaymode.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #ifndef __gludisplaymode_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/flist.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/flist.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/flist.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * flist.c++ * * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/flist.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/flist.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #include "glimports.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/flist.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/flist.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/flist.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * flist.h * * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/flist.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/flist.h,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #ifndef __gluflist_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/flistsorter.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/flistsorter.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/flistsorter.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * flistsorter.c++ * * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/flistsorter.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/flistsorter.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $ */ #include "glimports.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/flistsorter.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/flistsorter.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/flistsorter.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * flistsorter.h * * $Date: 2006/03/29 18:54:00 $ $Revision: 1.2 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/flistsorter.h,v 1.2 2006/03/29 18:54:00 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/flistsorter.h,v 1.2 2006/03/29 18:54:00 brianp Exp $ */ #ifndef __gluflistsorter_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/gridline.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/gridline.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/gridline.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * gridline.h * * $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/gridline.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/gridline.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ */ #ifndef __glugridline_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/gridtrimvertex.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/gridtrimvertex.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/gridtrimvertex.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * gridtrimvertex.h * * $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/gridtrimvertex.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/gridtrimvertex.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ */ #ifndef __glugridtrimvertex_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/gridvertex.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/gridvertex.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/gridvertex.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * gridvertex.h * * $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/gridvertex.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/gridvertex.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ */ #ifndef __glugridvertex_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/hull.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/hull.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/hull.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * hull.c++ * * $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/hull.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/hull.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $ */ #include "glimports.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/hull.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/hull.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/hull.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * hull.h * * $Date: 2001/08/07 17:34:11 $ $Revision: 1.2 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/hull.h,v 1.2 2001/08/07 17:34:11 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/hull.h,v 1.2 2001/08/07 17:34:11 brianp Exp $ */ #ifndef __gluhull_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/intersect.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/intersect.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/intersect.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * intersect.c++ * * $Date: 2005/10/28 13:09:23 $ $Revision: 1.3 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/intersect.cc,v 1.3 2005/10/28 13:09:23 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/intersect.cc,v 1.3 2005/10/28 13:09:23 brianp Exp $ */ #include "glimports.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/jarcloc.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/jarcloc.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/jarcloc.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * jarcloc.h * * $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/jarcloc.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/jarcloc.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ */ #ifndef __glujarcloc_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/knotvector.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/knotvector.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/knotvector.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * knotvector.h * * $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/knotvector.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/knotvector.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ */ #ifndef __gluknotvector_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/mapdesc.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/mapdesc.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/mapdesc.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * mapdesc.c++ * * $Date: 2001/11/29 16:16:55 $ $Revision: 1.2 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/mapdesc.cc,v 1.2 2001/11/29 16:16:55 kschultz Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mapdesc.cc,v 1.2 2001/11/29 16:16:55 kschultz Exp $ */ #include Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/mapdesc.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/mapdesc.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/mapdesc.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * mapdesc.h * * $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/mapdesc.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mapdesc.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ */ #ifndef __glumapdesc_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/mapdescv.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/mapdescv.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/mapdescv.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * mapdescv.c++ * * $Date: 2004/05/12 15:29:36 $ $Revision: 1.3 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/mapdescv.cc,v 1.3 2004/05/12 15:29:36 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mapdescv.cc,v 1.3 2004/05/12 15:29:36 brianp Exp $ */ #include "glimports.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/maplist.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/maplist.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/maplist.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * maplist.c++ * * $Date: 2005/10/28 13:09:23 $ $Revision: 1.2 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/maplist.cc,v 1.2 2005/10/28 13:09:23 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/maplist.cc,v 1.2 2005/10/28 13:09:23 brianp Exp $ */ #include "glimports.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/maplist.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/maplist.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/maplist.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * maplist.h * * $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/maplist.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/maplist.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ */ #ifndef __glumaplist_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/mesher.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/mesher.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/mesher.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * mesher.c++ * * $Date: 2001/11/29 16:16:55 $ $Revision: 1.3 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/mesher.cc,v 1.3 2001/11/29 16:16:55 kschultz Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mesher.cc,v 1.3 2001/11/29 16:16:55 kschultz Exp $ */ #include "glimports.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/mesher.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/mesher.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/mesher.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * mesher.h * * $Date: 2001/08/07 17:34:11 $ $Revision: 1.2 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/mesher.h,v 1.2 2001/08/07 17:34:11 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mesher.h,v 1.2 2001/08/07 17:34:11 brianp Exp $ */ #ifndef __glumesher_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/monoTriangulationBackend.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/monoTriangulationBackend.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/monoTriangulationBackend.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -34,7 +34,7 @@ ** $Date: 2005/10/28 13:09:23 $ $Revision: 1.3 $ */ /* -** $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/monoTriangulationBackend.cc,v 1.3 2005/10/28 13:09:23 brianp Exp $ +** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/monoTriangulationBackend.cc,v 1.3 2005/10/28 13:09:23 brianp Exp $ */ #include "monoTriangulation.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/monotonizer.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/monotonizer.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/monotonizer.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * monotonizer.c++ * * $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/monotonizer.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/monotonizer.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $ */ #include "glimports.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/monotonizer.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/monotonizer.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/monotonizer.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -35,7 +35,7 @@ /* * monotonizer.h * - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/monotonizer.h,v 1.2 2006/04/03 22:23:52 ajax Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/monotonizer.h,v 1.2 2006/04/03 22:23:52 ajax Exp $ */ #ifndef __glumonotonizer_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/myassert.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/myassert.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/myassert.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * myassert.h * * $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/myassert.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/myassert.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ */ #ifndef __glumyassert_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/mycode.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/mycode.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/mycode.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -34,7 +34,7 @@ ** $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $ */ /* -** $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/mycode.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $ +** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mycode.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $ */ #include "mymath.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/mystring.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/mystring.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/mystring.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * mystring.h * * $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/mystring.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mystring.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ */ #ifndef __glumystring_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/nurbsconsts.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/nurbsconsts.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/nurbsconsts.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * nurbsconsts.h * * $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/nurbsconsts.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/nurbsconsts.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ */ #ifndef __glunurbsconsts_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/nurbstess.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/nurbstess.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/nurbstess.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * nurbstess.c++ * * $Date: 2006/03/14 15:08:52 $ $Revision: 1.2 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/nurbstess.cc,v 1.2 2006/03/14 15:08:52 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/nurbstess.cc,v 1.2 2006/03/14 15:08:52 brianp Exp $ */ #include "glimports.h" Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/patch.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/patch.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/patch.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * patch.c++ * * $Date: 2006/03/14 15:08:52 $ $Revision: 1.4 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/patch.cc,v 1.4 2006/03/14 15:08:52 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/patch.cc,v 1.4 2006/03/14 15:08:52 brianp Exp $ */ #include Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/patch.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/patch.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/patch.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * patch.h * * $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/patch.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/patch.h,v 1.1 2001/03/17 00:25:41 brianp Exp $ */ #ifndef __glupatch_h_ Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/patchlist.cc =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/patchlist.cc 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/patchlist.cc 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * patchlist.c++ * * $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $ - * $Header: /cvs/mesa/Mesa/src/glu/sgi/libnurbs/internals/patchlist.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $ + * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/patchlist.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $ */ #include Modified: haiku/vendor/mesa/current/glu/libnurbs/internals/patchlist.h =================================================================== --- haiku/vendor/mesa/current/glu/libnurbs/internals/patchlist.h 2007-07-15 18:09:43 UTC (rev 21617) +++ haiku/vendor/mesa/current/glu/libnurbs/internals/patchlist.h 2007-07-15 21:59:35 UTC (rev 21618) @@ -36,7 +36,7 @@ * patchlist.h [... truncated: 57617 lines follow ...] From korli at mail.berlios.de Mon Jul 16 00:00:57 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 16 Jul 2007 00:00:57 +0200 Subject: [Haiku-commits] r21619 - haiku/vendor/mesa Message-ID: <200707152200.l6FM0v0P005542@sheep.berlios.de> Author: korli Date: 2007-07-16 00:00:57 +0200 (Mon, 16 Jul 2007) New Revision: 21619 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21619&view=rev Added: haiku/vendor/mesa/6.5.3/ Log: tagging Mesa 6.5.3 Copied: haiku/vendor/mesa/6.5.3 (from rev 21618, haiku/vendor/mesa/current) From korli at mail.berlios.de Mon Jul 16 00:13:02 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 16 Jul 2007 00:13:02 +0200 Subject: [Haiku-commits] r21620 - in haiku/vendor/mesa/current: headers/public src/glapi src/main src/shader src/shader/slang src/shader/slang/library src/swrast src/swrast_setup src/tnl src/x86 Message-ID: <200707152213.l6FMD27J006376@sheep.berlios.de> Author: korli Date: 2007-07-16 00:12:58 +0200 (Mon, 16 Jul 2007) New Revision: 21620 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21620&view=rev Added: haiku/vendor/mesa/current/src/shader/slang/library/slang_120_core.gc haiku/vendor/mesa/current/src/shader/slang/library/slang_builtin_120_common.gc haiku/vendor/mesa/current/src/shader/slang/library/slang_builtin_120_fragment.gc haiku/vendor/mesa/current/src/shader/slang/library/slang_common_builtin.gc haiku/vendor/mesa/current/src/shader/slang/library/slang_core.gc haiku/vendor/mesa/current/src/shader/slang/library/slang_fragment_builtin.gc haiku/vendor/mesa/current/src/shader/slang/library/slang_pp_directives.syn haiku/vendor/mesa/current/src/shader/slang/library/slang_pp_expression.syn haiku/vendor/mesa/current/src/shader/slang/library/slang_pp_version.syn haiku/vendor/mesa/current/src/shader/slang/library/slang_shader.syn haiku/vendor/mesa/current/src/shader/slang/library/slang_version.syn haiku/vendor/mesa/current/src/shader/slang/library/slang_vertex_builtin.gc Removed: haiku/vendor/mesa/current/src/shader/slang/library/slang_builtin_120_common_gc.h haiku/vendor/mesa/current/src/shader/slang/library/slang_builtin_120_fragment_gc.h Modified: haiku/vendor/mesa/current/headers/public/gl.h haiku/vendor/mesa/current/src/glapi/glapi.c haiku/vendor/mesa/current/src/main/attrib.c haiku/vendor/mesa/current/src/main/config.h haiku/vendor/mesa/current/src/main/context.c haiku/vendor/mesa/current/src/main/enable.c haiku/vendor/mesa/current/src/main/fbobject.c haiku/vendor/mesa/current/src/main/image.c haiku/vendor/mesa/current/src/main/imports.c haiku/vendor/mesa/current/src/main/light.c haiku/vendor/mesa/current/src/main/points.c haiku/vendor/mesa/current/src/main/teximage.c haiku/vendor/mesa/current/src/main/texobj.c haiku/vendor/mesa/current/src/main/texstate.c haiku/vendor/mesa/current/src/main/version.h haiku/vendor/mesa/current/src/shader/arbprogram.c haiku/vendor/mesa/current/src/shader/prog_execute.c haiku/vendor/mesa/current/src/shader/prog_execute.h haiku/vendor/mesa/current/src/shader/prog_statevars.c haiku/vendor/mesa/current/src/shader/shader_api.c haiku/vendor/mesa/current/src/shader/slang/library/slang_common_builtin_gc.h haiku/vendor/mesa/current/src/shader/slang/slang_codegen.c haiku/vendor/mesa/current/src/shader/slang/slang_compile.c haiku/vendor/mesa/current/src/shader/slang/slang_ir.c haiku/vendor/mesa/current/src/swrast/s_aalinetemp.h haiku/vendor/mesa/current/src/swrast/s_aatritemp.h haiku/vendor/mesa/current/src/swrast/s_feedback.c haiku/vendor/mesa/current/src/swrast/s_fragprog.c haiku/vendor/mesa/current/src/swrast/s_pointtemp.h haiku/vendor/mesa/current/src/swrast/s_span.c haiku/vendor/mesa/current/src/swrast/s_tritemp.h haiku/vendor/mesa/current/src/swrast_setup/ss_context.c haiku/vendor/mesa/current/src/tnl/t_vb_points.c haiku/vendor/mesa/current/src/tnl/t_vb_program.c haiku/vendor/mesa/current/src/tnl/t_vertex.c haiku/vendor/mesa/current/src/x86/3dnow_normal.S haiku/vendor/mesa/current/src/x86/glapi_x86.S Log: updating mesa vendor with version 7.0 Modified: haiku/vendor/mesa/current/headers/public/gl.h =================================================================== --- haiku/vendor/mesa/current/headers/public/gl.h 2007-07-15 22:00:57 UTC (rev 21619) +++ haiku/vendor/mesa/current/headers/public/gl.h 2007-07-15 22:12:58 UTC (rev 21620) @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 7.0 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), Modified: haiku/vendor/mesa/current/src/glapi/glapi.c =================================================================== --- haiku/vendor/mesa/current/src/glapi/glapi.c 2007-07-15 22:00:57 UTC (rev 21619) +++ haiku/vendor/mesa/current/src/glapi/glapi.c 2007-07-15 22:12:58 UTC (rev 21620) @@ -1028,22 +1028,24 @@ #if defined(PTHREADS) || defined(GLX_USE_TLS) /** * Perform platform-specific GL API entry-point fixups. - * - * */ static void init_glapi_relocs( void ) { -#if defined( USE_X86_ASM ) && defined( GLX_USE_TLS ) - extern void * _x86_get_dispatch(void); - const GLubyte * const get_disp = (const GLubyte *) _x86_get_dispatch; +#if defined(USE_X86_ASM) && defined(GLX_USE_TLS) && !defined(GLX_X86_READONLY_TEXT) + extern unsigned long _x86_get_dispatch(void); + char run_time_patch[] = { + 0x65, 0xa1, 0, 0, 0, 0 /* movl %gs:0,%eax */ + }; + GLuint *offset = (GLuint *) &run_time_patch[2]; /* 32-bits for x86/32 */ + const GLubyte * const get_disp = (const GLubyte *) run_time_patch; GLubyte * curr_func = (GLubyte *) gl_dispatch_functions_start; - + *offset = _x86_get_dispatch(); while ( curr_func != (GLubyte *) gl_dispatch_functions_end ) { - (void) memcpy( curr_func, get_disp, 6 ); + (void) memcpy( curr_func, get_disp, sizeof(run_time_patch)); curr_func += DISPATCH_FUNCTION_SIZE; } -#endif /* defined( USE_X86_ASM ) && defined( GLX_USE_TLS ) */ +#endif } -#endif +#endif /* defined(PTHREADS) || defined(GLX_USE_TLS) */ Modified: haiku/vendor/mesa/current/src/main/attrib.c =================================================================== --- haiku/vendor/mesa/current/src/main/attrib.c 2007-07-15 22:00:57 UTC (rev 21619) +++ haiku/vendor/mesa/current/src/main/attrib.c 2007-07-15 22:12:58 UTC (rev 21620) @@ -764,6 +764,7 @@ _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, obj->MagFilter); _mesa_TexParameterf(target, GL_TEXTURE_MIN_LOD, obj->MinLod); _mesa_TexParameterf(target, GL_TEXTURE_MAX_LOD, obj->MaxLod); + _mesa_TexParameterf(target, GL_TEXTURE_LOD_BIAS, obj->LodBias); _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, obj->BaseLevel); if (target != GL_TEXTURE_RECTANGLE_ARB) _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, obj->MaxLevel); Modified: haiku/vendor/mesa/current/src/main/config.h =================================================================== --- haiku/vendor/mesa/current/src/main/config.h 2007-07-15 22:00:57 UTC (rev 21619) +++ haiku/vendor/mesa/current/src/main/config.h 2007-07-15 22:12:58 UTC (rev 21620) @@ -5,9 +5,9 @@ /* * Mesa 3-D graphics library - * Version: 6.5.2 + * Version: 7.0 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -240,10 +240,7 @@ /** - * Bits per depth buffer value. - * - * Any reasonable value up to 31 will work. 32 doesn't work because of integer - * overflow problems in the rasterizer code. + * Bits per depth buffer value (max is 32). */ #ifndef DEFAULT_SOFTWARE_DEPTH_BITS #define DEFAULT_SOFTWARE_DEPTH_BITS 16 Modified: haiku/vendor/mesa/current/src/main/context.c =================================================================== --- haiku/vendor/mesa/current/src/main/context.c 2007-07-15 22:00:57 UTC (rev 21619) +++ haiku/vendor/mesa/current/src/main/context.c 2007-07-15 22:12:58 UTC (rev 21620) @@ -6,9 +6,9 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.0 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -1382,8 +1382,11 @@ return GL_FALSE; if (ctxvis->blueMask && ctxvis->blueMask != bufvis->blueMask) return GL_FALSE; +#if 0 + /* disabled (see bug 11161) */ if (ctxvis->depthBits && ctxvis->depthBits != bufvis->depthBits) return GL_FALSE; +#endif if (ctxvis->stencilBits && ctxvis->stencilBits != bufvis->stencilBits) return GL_FALSE; Modified: haiku/vendor/mesa/current/src/main/enable.c =================================================================== --- haiku/vendor/mesa/current/src/main/enable.c 2007-07-15 22:00:57 UTC (rev 21619) +++ haiku/vendor/mesa/current/src/main/enable.c 2007-07-15 22:12:58 UTC (rev 21620) @@ -190,7 +190,26 @@ } +/** + * Helper function to enable or disable a texture target. + */ +static GLboolean +enable_texture(GLcontext *ctx, GLboolean state, GLbitfield bit) +{ + const GLuint curr = ctx->Texture.CurrentUnit; + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; + const GLuint newenabled = (!state) + ? (texUnit->Enabled & ~bit) : (texUnit->Enabled | bit); + if (!ctx->DrawBuffer->Visual.rgbMode || texUnit->Enabled == newenabled) + return GL_FALSE; + + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->Enabled = newenabled; + return GL_TRUE; +} + + /** * Helper function to enable or disable state. * @@ -558,45 +577,21 @@ FLUSH_VERTICES(ctx, _NEW_STENCIL); ctx->Stencil.Enabled = state; break; - case GL_TEXTURE_1D: { - const GLuint curr = ctx->Texture.CurrentUnit; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; - GLuint newenabled = texUnit->Enabled & ~TEXTURE_1D_BIT; - if (state) - newenabled |= TEXTURE_1D_BIT; - if (!ctx->DrawBuffer->Visual.rgbMode - || texUnit->Enabled == newenabled) + case GL_TEXTURE_1D: + if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) { return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Enabled = newenabled; + } break; - } - case GL_TEXTURE_2D: { - const GLuint curr = ctx->Texture.CurrentUnit; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; - GLuint newenabled = texUnit->Enabled & ~TEXTURE_2D_BIT; - if (state) - newenabled |= TEXTURE_2D_BIT; - if (!ctx->DrawBuffer->Visual.rgbMode - || texUnit->Enabled == newenabled) + case GL_TEXTURE_2D: + if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) { return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Enabled = newenabled; + } break; - } - case GL_TEXTURE_3D: { - const GLuint curr = ctx->Texture.CurrentUnit; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; - GLuint newenabled = texUnit->Enabled & ~TEXTURE_3D_BIT; - if (state) - newenabled |= TEXTURE_3D_BIT; - if (!ctx->DrawBuffer->Visual.rgbMode - || texUnit->Enabled == newenabled) + case GL_TEXTURE_3D: + if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) { return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Enabled = newenabled; + } break; - } case GL_TEXTURE_GEN_Q: { GLuint unit = ctx->Texture.CurrentUnit; struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; @@ -715,18 +710,9 @@ /* GL_ARB_texture_cube_map */ case GL_TEXTURE_CUBE_MAP_ARB: - { - const GLuint curr = ctx->Texture.CurrentUnit; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; - GLuint newenabled = texUnit->Enabled & ~TEXTURE_CUBE_BIT; - CHECK_EXTENSION(ARB_texture_cube_map, cap); - if (state) - newenabled |= TEXTURE_CUBE_BIT; - if (!ctx->DrawBuffer->Visual.rgbMode - || texUnit->Enabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Enabled = newenabled; + CHECK_EXTENSION(ARB_texture_cube_map, cap); + if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) { + return; } break; @@ -879,18 +865,8 @@ /* GL_NV_texture_rectangle */ case GL_TEXTURE_RECTANGLE_NV: CHECK_EXTENSION(NV_texture_rectangle, cap); - { - const GLuint curr = ctx->Texture.CurrentUnit; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; - GLuint newenabled = texUnit->Enabled & ~TEXTURE_RECT_BIT; - CHECK_EXTENSION(NV_texture_rectangle, cap); - if (state) - newenabled |= TEXTURE_RECT_BIT; - if (!ctx->DrawBuffer->Visual.rgbMode - || texUnit->Enabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Enabled = newenabled; + if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) { + return; } break; @@ -1002,6 +978,18 @@ /** + * Helper function to determine whether a texture target is enabled. + */ +static GLboolean +is_texture_enabled(GLcontext *ctx, GLbitfield bit) +{ + const struct gl_texture_unit *const texUnit = + &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE; +} + + +/** * Return simple enable/disable state. * * \param cap state variable to query. @@ -1117,23 +1105,11 @@ case GL_STENCIL_TEST: return ctx->Stencil.Enabled; case GL_TEXTURE_1D: - { - const struct gl_texture_unit *texUnit; - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - return (texUnit->Enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE; - } + return is_texture_enabled(ctx, TEXTURE_1D_BIT); case GL_TEXTURE_2D: - { - const struct gl_texture_unit *texUnit; - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - return (texUnit->Enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE; - } + return is_texture_enabled(ctx, TEXTURE_2D_BIT); case GL_TEXTURE_3D: - { - const struct gl_texture_unit *texUnit; - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - return (texUnit->Enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE; - } + return is_texture_enabled(ctx, TEXTURE_3D_BIT); case GL_TEXTURE_GEN_Q: { const struct gl_texture_unit *texUnit; @@ -1219,11 +1195,7 @@ /* GL_ARB_texture_cube_map */ case GL_TEXTURE_CUBE_MAP_ARB: CHECK_EXTENSION(ARB_texture_cube_map); - { - const struct gl_texture_unit *texUnit; - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - return (texUnit->Enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE; - } + return is_texture_enabled(ctx, TEXTURE_CUBE_BIT); /* GL_EXT_secondary_color */ case GL_COLOR_SUM_EXT: @@ -1343,11 +1315,7 @@ /* GL_NV_texture_rectangle */ case GL_TEXTURE_RECTANGLE_NV: CHECK_EXTENSION(NV_texture_rectangle); - { - const struct gl_texture_unit *texUnit; - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - return (texUnit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE; - } + return is_texture_enabled(ctx, TEXTURE_RECT_BIT); /* GL_EXT_stencil_two_side */ case GL_STENCIL_TEST_TWO_SIDE_EXT: Modified: haiku/vendor/mesa/current/src/main/fbobject.c =================================================================== --- haiku/vendor/mesa/current/src/main/fbobject.c 2007-07-15 22:00:57 UTC (rev 21619) +++ haiku/vendor/mesa/current/src/main/fbobject.c 2007-07-15 22:12:58 UTC (rev 21620) @@ -1144,20 +1144,19 @@ * Common code called by glFramebufferTexture1D/2D/3DEXT(). */ static void -framebuffer_texture(GLuint dims, GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, +framebuffer_texture(GLcontext *ctx, const char *caller, GLenum target, + GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) { struct gl_renderbuffer_attachment *att; struct gl_texture_object *texObj = NULL; struct gl_framebuffer *fb; - GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (target != GL_FRAMEBUFFER_EXT) { _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferTexture%dDEXT(target)", dims); + "glFramebufferTexture%sEXT(target)", caller); return; } @@ -1167,83 +1166,53 @@ /* check framebuffer binding */ if (fb->Name == 0) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture%dDEXT", dims); + "glFramebufferTexture%sEXT", caller); return; } + + /* The textarget, level, and zoffset parameters are only validated if + * texture is non-zero. + */ if (texture) { - texObj = _mesa_lookup_texture(ctx, texture); - } + GLboolean err = GL_TRUE; - /* Check dimension-dependent things */ - switch (dims) { - case 1: - if (textarget != GL_TEXTURE_1D) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferTexture1DEXT(textarget)"); - return; + texObj = _mesa_lookup_texture(ctx, texture); + if (texObj != NULL) { + err = (texObj->Target == GL_TEXTURE_CUBE_MAP) + ? !IS_CUBE_FACE(textarget) + : (texObj->Target != textarget); } - if (texObj && texObj->Target != GL_TEXTURE_1D) { + + if (err) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture1DEXT(texture target mismatch)"); + "glFramebufferTexture%sEXT(texture target mismatch)", + caller); return; } - break; - case 2: - if (textarget != GL_TEXTURE_2D && - textarget != GL_TEXTURE_RECTANGLE_ARB && - !IS_CUBE_FACE(textarget)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferTexture2DEXT(textarget)"); - return; - } - if (texObj) { - if ((texObj->Target == GL_TEXTURE_2D && textarget != GL_TEXTURE_2D) || - (texObj->Target == GL_TEXTURE_RECTANGLE_ARB - && textarget != GL_TEXTURE_RECTANGLE_ARB) || - (texObj->Target == GL_TEXTURE_CUBE_MAP - && !IS_CUBE_FACE(textarget))) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture1DEXT(texture target mismatch)"); - return; - } - } - break; - case 3: - if (textarget != GL_TEXTURE_3D) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferTexture3DEXT(textarget)"); - return; - } - if (texObj && texObj->Target != GL_TEXTURE_3D) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture3DEXT(texture target mismatch)"); - return; - } - { + + if (texObj->Target == GL_TEXTURE_3D) { const GLint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1); if (zoffset < 0 || zoffset >= maxSize) { _mesa_error(ctx, GL_INVALID_VALUE, - "glFramebufferTexture3DEXT(zoffset)"); + "glFramebufferTexture%sEXT(zoffset)", + caller); return; } } - break; - default: - _mesa_problem(ctx, "Unexpected dims in error_check_framebuffer_texture"); - return; - } - if ((level < 0) || level >= _mesa_max_texture_levels(ctx, textarget)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glFramebufferTexture%dDEXT(level)", dims); - return; + if ((level < 0) || + (level >= _mesa_max_texture_levels(ctx, texObj->Target))) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glFramebufferTexture%sEXT(level)", caller); + return; + } } att = _mesa_get_attachment(ctx, fb, attachment); if (att == NULL) { _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferTexture%dDEXT(attachment)", dims); + "glFramebufferTexture%sEXT(attachment)", caller); return; } @@ -1271,9 +1240,16 @@ _mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { - const GLint zoffset = 0; - framebuffer_texture(1, target, attachment, textarget, texture, - level, zoffset); + GET_CURRENT_CONTEXT(ctx); + + if ((texture != 0) && (textarget != GL_TEXTURE_1D)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferTexture1DEXT(textarget)"); + return; + } + + framebuffer_texture(ctx, "1D", target, attachment, textarget, texture, + level, 0); } @@ -1281,9 +1257,19 @@ _mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { - const GLint zoffset = 0; - framebuffer_texture(2, target, attachment, textarget, texture, - level, zoffset); + GET_CURRENT_CONTEXT(ctx); + + if ((texture != 0) && + (textarget != GL_TEXTURE_2D) && + (textarget != GL_TEXTURE_RECTANGLE_ARB) && + (!IS_CUBE_FACE(textarget))) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferTexture2DEXT(textarget)"); + return; + } + + framebuffer_texture(ctx, "2D", target, attachment, textarget, texture, + level, 0); } @@ -1292,12 +1278,19 @@ GLenum textarget, GLuint texture, GLint level, GLint zoffset) { - framebuffer_texture(3, target, attachment, textarget, texture, + GET_CURRENT_CONTEXT(ctx); + + if ((texture != 0) && (textarget != GL_TEXTURE_3D)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferTexture3DEXT(textarget)"); + return; + } + + framebuffer_texture(ctx, "3D", target, attachment, textarget, texture, level, zoffset); } - void GLAPIENTRY _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbufferTarget, Modified: haiku/vendor/mesa/current/src/main/image.c =================================================================== --- haiku/vendor/mesa/current/src/main/image.c 2007-07-15 22:00:57 UTC (rev 21619) +++ haiku/vendor/mesa/current/src/main/image.c 2007-07-15 22:12:58 UTC (rev 21620) @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.0 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -64,27 +64,27 @@ */ static GLboolean _mesa_type_is_packed(GLenum type) - { - switch (type) { - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - case GL_UNSIGNED_SHORT_8_8_MESA: - case GL_UNSIGNED_SHORT_8_8_REV_MESA: - case GL_UNSIGNED_INT_24_8_EXT: - return GL_TRUE; - } +{ + switch (type) { + case GL_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_5_6_5_REV: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: + case GL_UNSIGNED_SHORT_8_8_MESA: + case GL_UNSIGNED_SHORT_8_8_REV_MESA: + case GL_UNSIGNED_INT_24_8_EXT: + return GL_TRUE; + } - return GL_FALSE; + return GL_FALSE; } /** @@ -103,9 +103,8 @@ static void flip_bytes( GLubyte *p, GLuint n ) { - register GLuint i, a, b; - - for (i=0;i> 8) | ((p[i] << 8) & 0xff00); } } @@ -144,9 +142,8 @@ void _mesa_swap4( GLuint *p, GLuint n ) { - register GLuint i, a, b; - - for (i=0;i> 24) | ((b >> 8) & 0xff00) @@ -4263,60 +4260,68 @@ const GLvoid *src = _mesa_image_address(dimensions, unpack, pixels, width, height, format, type, img, row, 0); - if ((type == GL_BITMAP) && (unpack->SkipPixels & 0x7)) { - GLint i; - flipBytes = GL_FALSE; - if (unpack->LsbFirst) { - GLubyte srcMask = 1 << (unpack->SkipPixels & 0x7); - GLubyte dstMask = 128; - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 128) { - srcMask = 1; - s++; - } else { - srcMask = srcMask << 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } else { - dstMask = dstMask >> 1; - } - } - } else { - GLubyte srcMask = 128 >> (unpack->SkipPixels & 0x7); - GLubyte dstMask = 128; - const GLubyte *s = src; - GLubyte *d = dst; + if ((type == GL_BITMAP) && (unpack->SkipPixels & 0x7)) { + GLint i; + flipBytes = GL_FALSE; + if (unpack->LsbFirst) { + GLubyte srcMask = 1 << (unpack->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 128) { + srcMask = 1; + s++; + } + else { + srcMask = srcMask << 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 1) { - srcMask = 128; - s++; - } else { - srcMask = srcMask >> 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } else { - dstMask = dstMask >> 1; - } - } - } - } else - _mesa_memcpy(dst, src, bytesPerRow); + } + else { + dstMask = dstMask >> 1; + } + } + } + else { + GLubyte srcMask = 128 >> (unpack->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 1) { + srcMask = 128; + s++; + } + else { + srcMask = srcMask >> 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } + else { + dstMask = dstMask >> 1; + } + } + } + } + else { + _mesa_memcpy(dst, src, bytesPerRow); + } + /* byte flipping/swapping */ if (flipBytes) { flip_bytes((GLubyte *) dst, bytesPerRow); Modified: haiku/vendor/mesa/current/src/main/imports.c =================================================================== --- haiku/vendor/mesa/current/src/main/imports.c 2007-07-15 22:00:57 UTC (rev 21619) +++ haiku/vendor/mesa/current/src/main/imports.c 2007-07-15 22:12:58 UTC (rev 21620) @@ -20,9 +20,9 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.0 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -921,14 +921,11 @@ /*@{*/ /** - * Display a warning. + * Report a warning (a recoverable error condition) to stderr if + * either DEBUG is defined or the MESA_DEBUG env var is set. * * \param ctx GL context. * \param fmtString printf() alike format string. - * - * If debugging is enabled (either at compile-time via the DEBUG macro, or - * run-time via the MESA_DEBUG environment variable), prints the warning to - * stderr via fprintf(). */ void _mesa_warning( GLcontext *ctx, const char *fmtString, ... ) @@ -951,13 +948,11 @@ } /** - * This function is called when the Mesa user has stumbled into a code - * path which may not be implemented fully or correctly. + * Report an internla implementation problem. + * Prints the message to stderr via fprintf(). * * \param ctx GL context. * \param s problem description string. - * - * Prints the message to stderr via fprintf(). */ void _mesa_problem( const GLcontext *ctx, const char *fmtString, ... ) @@ -975,18 +970,16 @@ } /** - * Display an error message. + * Record an OpenGL state error. These usually occur when the users + * passes invalid parameters to a GL function. * - * If in debug mode, print error message. - * Also, record the error code by calling _mesa_record_error(). + * If debugging is enabled (either at compile-time via the DEBUG macro, or + * run-time via the MESA_DEBUG environment variable), report the error with + * _mesa_debug(). * * \param ctx the GL context. * \param error the error value. * \param fmtString printf() style format string, followed by optional args - * - * If debugging is enabled (either at compile-time via the DEBUG macro, or - * run-time via the MESA_DEBUG environment variable), interperts the error code and - * prints the error message via _mesa_debug(). */ void _mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... ) @@ -1056,12 +1049,11 @@ } /** - * Report debug information. + * Report debug information. Print error message to stderr via fprintf(). + * No-op if DEBUG mode not enabled. * * \param ctx GL context. - * \param fmtString printf() alike format string. - * - * Prints the message to stderr via fprintf(). + * \param fmtString printf()-style format string, followed by optional args. */ void _mesa_debug( const GLcontext *ctx, const char *fmtString, ... ) Modified: haiku/vendor/mesa/current/src/main/light.c =================================================================== --- haiku/vendor/mesa/current/src/main/light.c 2007-07-15 22:00:57 UTC (rev 21619) +++ haiku/vendor/mesa/current/src/main/light.c 2007-07-15 22:12:58 UTC (rev 21620) @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.0 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -1117,6 +1117,13 @@ } light->_VP_inf_spot_attenuation = 1.0; } + else { + /* positional light w/ homogeneous coordinate, divide by W */ + GLfloat wInv = 1.0 / light->_Position[3]; + light->_Position[0] *= wInv; + light->_Position[1] *= wInv; + light->_Position[2] *= wInv; + } if (light->_Flags & LIGHT_SPOT) { if (ctx->_NeedEyeCoords) { Modified: haiku/vendor/mesa/current/src/main/points.c =================================================================== --- haiku/vendor/mesa/current/src/main/points.c 2007-07-15 22:00:57 UTC (rev 21619) +++ haiku/vendor/mesa/current/src/main/points.c 2007-07-15 22:12:58 UTC (rev 21620) @@ -5,9 +5,9 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 7.0 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -61,10 +61,6 @@ ctx->Point.MinSize, ctx->Point.MaxSize); - ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 || - ctx->Point.Params[1] != 0.0 || - ctx->Point.Params[2] != 0.0); - if (ctx->Driver.PointSize) ctx->Driver.PointSize(ctx, size); } @@ -122,6 +118,9 @@ return; FLUSH_VERTICES(ctx, _NEW_POINT); COPY_3V(ctx->Point.Params, params); + ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 || + ctx->Point.Params[1] != 0.0 || + ctx->Point.Params[2] != 0.0); } else { _mesa_error(ctx, GL_INVALID_ENUM, Modified: haiku/vendor/mesa/current/src/main/teximage.c =================================================================== --- haiku/vendor/mesa/current/src/main/teximage.c 2007-07-15 22:00:57 UTC (rev 21619) +++ haiku/vendor/mesa/current/src/main/teximage.c 2007-07-15 22:12:58 UTC (rev 21620) @@ -1300,6 +1300,20 @@ /** + * Helper function to determine whether a target supports compressed textures + */ +static GLboolean +target_can_be_compressed(GLcontext *ctx, GLenum target) +{ + return (((target == GL_TEXTURE_2D || target == GL_PROXY_TEXTURE_2D)) + || ((ctx->Extensions.ARB_texture_cube_map && + (target == GL_PROXY_TEXTURE_CUBE_MAP || + (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))))); +} + + +/** * Test the glTexImage[123]D() parameters for errors. * * \param ctx GL context. @@ -1329,8 +1343,9 @@ GLint depth, GLint border ) { const GLboolean isProxy = _mesa_is_proxy_texture(target); - GLboolean sizeOK; + GLboolean sizeOK = GL_TRUE; GLboolean colorFormat, indexFormat; + GLenum proxy_target; /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ if (level < 0 || level >= MAX_TEXTURE_LEVELS) { @@ -1365,10 +1380,9 @@ */ if (dimensions == 1) { if (target == GL_PROXY_TEXTURE_1D || target == GL_TEXTURE_1D) { - sizeOK = ctx->Driver.TestProxyTexImage(ctx, GL_PROXY_TEXTURE_1D, - level, internalFormat, - format, type, - width, 1, 1, border); + proxy_target = GL_PROXY_TEXTURE_1D; + height = 1; + width = 1; } else { _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage1D(target)" ); @@ -1376,11 +1390,9 @@ } } else if (dimensions == 2) { + depth = 1; if (target == GL_PROXY_TEXTURE_2D || target == GL_TEXTURE_2D) { - sizeOK = ctx->Driver.TestProxyTexImage(ctx, GL_PROXY_TEXTURE_2D, - level, internalFormat, - format, type, - width, height, 1, border); + proxy_target = GL_PROXY_TEXTURE_2D; } else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB || (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && @@ -1389,10 +1401,8 @@ _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)"); return GL_TRUE; } - sizeOK = (width == height) && - ctx->Driver.TestProxyTexImage(ctx, GL_PROXY_TEXTURE_CUBE_MAP_ARB, - level, internalFormat, format, type, - width, height, 1, border); + proxy_target = GL_PROXY_TEXTURE_CUBE_MAP_ARB; + sizeOK = (width == height); } else if (target == GL_PROXY_TEXTURE_RECTANGLE_NV || target == GL_TEXTURE_RECTANGLE_NV) { @@ -1400,11 +1410,7 @@ _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)"); return GL_TRUE; } - sizeOK = ctx->Driver.TestProxyTexImage(ctx, - GL_PROXY_TEXTURE_RECTANGLE_NV, - level, internalFormat, - format, type, - width, height, 1, border); + proxy_target = GL_PROXY_TEXTURE_RECTANGLE_NV; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)"); @@ -1413,10 +1419,7 @@ [... truncated: 12633 lines follow ...] From korli at mail.berlios.de Mon Jul 16 00:14:06 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 16 Jul 2007 00:14:06 +0200 Subject: [Haiku-commits] r21621 - haiku/vendor/mesa Message-ID: <200707152214.l6FME61m006425@sheep.berlios.de> Author: korli Date: 2007-07-16 00:14:06 +0200 (Mon, 16 Jul 2007) New Revision: 21621 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21621&view=rev Added: haiku/vendor/mesa/7.0/ Log: tagging Mesa 7.0 Copied: haiku/vendor/mesa/7.0 (from rev 21620, haiku/vendor/mesa/current) From korli at mail.berlios.de Mon Jul 16 00:28:51 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 16 Jul 2007 00:28:51 +0200 Subject: [Haiku-commits] r21622 - in haiku/trunk: headers/os/opengl/GL src/kits/opengl/mesa/glapi src/kits/opengl/mesa/main src/kits/opengl/mesa/shader src/kits/opengl/mesa/shader/slang src/kits/opengl/mesa/shader/slang/library src/kits/opengl/mesa/swrast src/kits/opengl/mesa/swrast_setup src/kits/opengl/mesa/tnl src/kits/opengl/mesa/x86 Message-ID: <200707152228.l6FMSpo9008668@sheep.berlios.de> Author: korli Date: 2007-07-16 00:28:49 +0200 (Mon, 16 Jul 2007) New Revision: 21622 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21622&view=rev Added: haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_120_core.gc haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_builtin_120_common.gc haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_builtin_120_fragment.gc haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_common_builtin.gc haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_core.gc haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_fragment_builtin.gc haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_pp_directives.syn haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_pp_expression.syn haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_pp_version.syn haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_shader.syn haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_version.syn haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_vertex_builtin.gc Removed: haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_builtin_120_common_gc.h haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_builtin_120_fragment_gc.h Modified: haiku/trunk/headers/os/opengl/GL/gl.h haiku/trunk/src/kits/opengl/mesa/glapi/glapi.c haiku/trunk/src/kits/opengl/mesa/main/attrib.c haiku/trunk/src/kits/opengl/mesa/main/config.h haiku/trunk/src/kits/opengl/mesa/main/context.c haiku/trunk/src/kits/opengl/mesa/main/enable.c haiku/trunk/src/kits/opengl/mesa/main/fbobject.c haiku/trunk/src/kits/opengl/mesa/main/image.c haiku/trunk/src/kits/opengl/mesa/main/imports.c haiku/trunk/src/kits/opengl/mesa/main/light.c haiku/trunk/src/kits/opengl/mesa/main/points.c haiku/trunk/src/kits/opengl/mesa/main/teximage.c haiku/trunk/src/kits/opengl/mesa/main/texobj.c haiku/trunk/src/kits/opengl/mesa/main/texstate.c haiku/trunk/src/kits/opengl/mesa/main/version.h haiku/trunk/src/kits/opengl/mesa/shader/arbprogram.c haiku/trunk/src/kits/opengl/mesa/shader/prog_execute.c haiku/trunk/src/kits/opengl/mesa/shader/prog_execute.h haiku/trunk/src/kits/opengl/mesa/shader/prog_statevars.c haiku/trunk/src/kits/opengl/mesa/shader/shader_api.c haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_common_builtin_gc.h haiku/trunk/src/kits/opengl/mesa/shader/slang/slang_codegen.c haiku/trunk/src/kits/opengl/mesa/shader/slang/slang_compile.c haiku/trunk/src/kits/opengl/mesa/shader/slang/slang_ir.c haiku/trunk/src/kits/opengl/mesa/swrast/s_aalinetemp.h haiku/trunk/src/kits/opengl/mesa/swrast/s_aatritemp.h haiku/trunk/src/kits/opengl/mesa/swrast/s_feedback.c haiku/trunk/src/kits/opengl/mesa/swrast/s_fragprog.c haiku/trunk/src/kits/opengl/mesa/swrast/s_pointtemp.h haiku/trunk/src/kits/opengl/mesa/swrast/s_span.c haiku/trunk/src/kits/opengl/mesa/swrast/s_tritemp.h haiku/trunk/src/kits/opengl/mesa/swrast_setup/ss_context.c haiku/trunk/src/kits/opengl/mesa/tnl/t_vb_points.c haiku/trunk/src/kits/opengl/mesa/tnl/t_vb_program.c haiku/trunk/src/kits/opengl/mesa/tnl/t_vertex.c haiku/trunk/src/kits/opengl/mesa/x86/3dnow_normal.S haiku/trunk/src/kits/opengl/mesa/x86/glapi_x86.S Log: updated mesa to 7.0 Modified: haiku/trunk/headers/os/opengl/GL/gl.h =================================================================== --- haiku/trunk/headers/os/opengl/GL/gl.h 2007-07-15 22:14:06 UTC (rev 21621) +++ haiku/trunk/headers/os/opengl/GL/gl.h 2007-07-15 22:28:49 UTC (rev 21622) @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 7.0 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), Modified: haiku/trunk/src/kits/opengl/mesa/glapi/glapi.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/glapi/glapi.c 2007-07-15 22:14:06 UTC (rev 21621) +++ haiku/trunk/src/kits/opengl/mesa/glapi/glapi.c 2007-07-15 22:28:49 UTC (rev 21622) @@ -1028,22 +1028,24 @@ #if defined(PTHREADS) || defined(GLX_USE_TLS) /** * Perform platform-specific GL API entry-point fixups. - * - * */ static void init_glapi_relocs( void ) { -#if defined( USE_X86_ASM ) && defined( GLX_USE_TLS ) - extern void * _x86_get_dispatch(void); - const GLubyte * const get_disp = (const GLubyte *) _x86_get_dispatch; +#if defined(USE_X86_ASM) && defined(GLX_USE_TLS) && !defined(GLX_X86_READONLY_TEXT) + extern unsigned long _x86_get_dispatch(void); + char run_time_patch[] = { + 0x65, 0xa1, 0, 0, 0, 0 /* movl %gs:0,%eax */ + }; + GLuint *offset = (GLuint *) &run_time_patch[2]; /* 32-bits for x86/32 */ + const GLubyte * const get_disp = (const GLubyte *) run_time_patch; GLubyte * curr_func = (GLubyte *) gl_dispatch_functions_start; - + *offset = _x86_get_dispatch(); while ( curr_func != (GLubyte *) gl_dispatch_functions_end ) { - (void) memcpy( curr_func, get_disp, 6 ); + (void) memcpy( curr_func, get_disp, sizeof(run_time_patch)); curr_func += DISPATCH_FUNCTION_SIZE; } -#endif /* defined( USE_X86_ASM ) && defined( GLX_USE_TLS ) */ +#endif } -#endif +#endif /* defined(PTHREADS) || defined(GLX_USE_TLS) */ Modified: haiku/trunk/src/kits/opengl/mesa/main/attrib.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/attrib.c 2007-07-15 22:14:06 UTC (rev 21621) +++ haiku/trunk/src/kits/opengl/mesa/main/attrib.c 2007-07-15 22:28:49 UTC (rev 21622) @@ -764,6 +764,7 @@ _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, obj->MagFilter); _mesa_TexParameterf(target, GL_TEXTURE_MIN_LOD, obj->MinLod); _mesa_TexParameterf(target, GL_TEXTURE_MAX_LOD, obj->MaxLod); + _mesa_TexParameterf(target, GL_TEXTURE_LOD_BIAS, obj->LodBias); _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, obj->BaseLevel); if (target != GL_TEXTURE_RECTANGLE_ARB) _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, obj->MaxLevel); Modified: haiku/trunk/src/kits/opengl/mesa/main/config.h =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/config.h 2007-07-15 22:14:06 UTC (rev 21621) +++ haiku/trunk/src/kits/opengl/mesa/main/config.h 2007-07-15 22:28:49 UTC (rev 21622) @@ -5,9 +5,9 @@ /* * Mesa 3-D graphics library - * Version: 6.5.2 + * Version: 7.0 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -240,10 +240,7 @@ /** - * Bits per depth buffer value. - * - * Any reasonable value up to 31 will work. 32 doesn't work because of integer - * overflow problems in the rasterizer code. + * Bits per depth buffer value (max is 32). */ #ifndef DEFAULT_SOFTWARE_DEPTH_BITS #define DEFAULT_SOFTWARE_DEPTH_BITS 16 Modified: haiku/trunk/src/kits/opengl/mesa/main/context.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/context.c 2007-07-15 22:14:06 UTC (rev 21621) +++ haiku/trunk/src/kits/opengl/mesa/main/context.c 2007-07-15 22:28:49 UTC (rev 21622) @@ -6,9 +6,9 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.0 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -1382,8 +1382,11 @@ return GL_FALSE; if (ctxvis->blueMask && ctxvis->blueMask != bufvis->blueMask) return GL_FALSE; +#if 0 + /* disabled (see bug 11161) */ if (ctxvis->depthBits && ctxvis->depthBits != bufvis->depthBits) return GL_FALSE; +#endif if (ctxvis->stencilBits && ctxvis->stencilBits != bufvis->stencilBits) return GL_FALSE; Modified: haiku/trunk/src/kits/opengl/mesa/main/enable.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/enable.c 2007-07-15 22:14:06 UTC (rev 21621) +++ haiku/trunk/src/kits/opengl/mesa/main/enable.c 2007-07-15 22:28:49 UTC (rev 21622) @@ -190,7 +190,26 @@ } +/** + * Helper function to enable or disable a texture target. + */ +static GLboolean +enable_texture(GLcontext *ctx, GLboolean state, GLbitfield bit) +{ + const GLuint curr = ctx->Texture.CurrentUnit; + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; + const GLuint newenabled = (!state) + ? (texUnit->Enabled & ~bit) : (texUnit->Enabled | bit); + if (!ctx->DrawBuffer->Visual.rgbMode || texUnit->Enabled == newenabled) + return GL_FALSE; + + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->Enabled = newenabled; + return GL_TRUE; +} + + /** * Helper function to enable or disable state. * @@ -558,45 +577,21 @@ FLUSH_VERTICES(ctx, _NEW_STENCIL); ctx->Stencil.Enabled = state; break; - case GL_TEXTURE_1D: { - const GLuint curr = ctx->Texture.CurrentUnit; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; - GLuint newenabled = texUnit->Enabled & ~TEXTURE_1D_BIT; - if (state) - newenabled |= TEXTURE_1D_BIT; - if (!ctx->DrawBuffer->Visual.rgbMode - || texUnit->Enabled == newenabled) + case GL_TEXTURE_1D: + if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) { return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Enabled = newenabled; + } break; - } - case GL_TEXTURE_2D: { - const GLuint curr = ctx->Texture.CurrentUnit; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; - GLuint newenabled = texUnit->Enabled & ~TEXTURE_2D_BIT; - if (state) - newenabled |= TEXTURE_2D_BIT; - if (!ctx->DrawBuffer->Visual.rgbMode - || texUnit->Enabled == newenabled) + case GL_TEXTURE_2D: + if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) { return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Enabled = newenabled; + } break; - } - case GL_TEXTURE_3D: { - const GLuint curr = ctx->Texture.CurrentUnit; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; - GLuint newenabled = texUnit->Enabled & ~TEXTURE_3D_BIT; - if (state) - newenabled |= TEXTURE_3D_BIT; - if (!ctx->DrawBuffer->Visual.rgbMode - || texUnit->Enabled == newenabled) + case GL_TEXTURE_3D: + if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) { return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Enabled = newenabled; + } break; - } case GL_TEXTURE_GEN_Q: { GLuint unit = ctx->Texture.CurrentUnit; struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; @@ -715,18 +710,9 @@ /* GL_ARB_texture_cube_map */ case GL_TEXTURE_CUBE_MAP_ARB: - { - const GLuint curr = ctx->Texture.CurrentUnit; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; - GLuint newenabled = texUnit->Enabled & ~TEXTURE_CUBE_BIT; - CHECK_EXTENSION(ARB_texture_cube_map, cap); - if (state) - newenabled |= TEXTURE_CUBE_BIT; - if (!ctx->DrawBuffer->Visual.rgbMode - || texUnit->Enabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Enabled = newenabled; + CHECK_EXTENSION(ARB_texture_cube_map, cap); + if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) { + return; } break; @@ -879,18 +865,8 @@ /* GL_NV_texture_rectangle */ case GL_TEXTURE_RECTANGLE_NV: CHECK_EXTENSION(NV_texture_rectangle, cap); - { - const GLuint curr = ctx->Texture.CurrentUnit; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; - GLuint newenabled = texUnit->Enabled & ~TEXTURE_RECT_BIT; - CHECK_EXTENSION(NV_texture_rectangle, cap); - if (state) - newenabled |= TEXTURE_RECT_BIT; - if (!ctx->DrawBuffer->Visual.rgbMode - || texUnit->Enabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Enabled = newenabled; + if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) { + return; } break; @@ -1002,6 +978,18 @@ /** + * Helper function to determine whether a texture target is enabled. + */ +static GLboolean +is_texture_enabled(GLcontext *ctx, GLbitfield bit) +{ + const struct gl_texture_unit *const texUnit = + &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE; +} + + +/** * Return simple enable/disable state. * * \param cap state variable to query. @@ -1117,23 +1105,11 @@ case GL_STENCIL_TEST: return ctx->Stencil.Enabled; case GL_TEXTURE_1D: - { - const struct gl_texture_unit *texUnit; - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - return (texUnit->Enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE; - } + return is_texture_enabled(ctx, TEXTURE_1D_BIT); case GL_TEXTURE_2D: - { - const struct gl_texture_unit *texUnit; - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - return (texUnit->Enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE; - } + return is_texture_enabled(ctx, TEXTURE_2D_BIT); case GL_TEXTURE_3D: - { - const struct gl_texture_unit *texUnit; - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - return (texUnit->Enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE; - } + return is_texture_enabled(ctx, TEXTURE_3D_BIT); case GL_TEXTURE_GEN_Q: { const struct gl_texture_unit *texUnit; @@ -1219,11 +1195,7 @@ /* GL_ARB_texture_cube_map */ case GL_TEXTURE_CUBE_MAP_ARB: CHECK_EXTENSION(ARB_texture_cube_map); - { - const struct gl_texture_unit *texUnit; - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - return (texUnit->Enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE; - } + return is_texture_enabled(ctx, TEXTURE_CUBE_BIT); /* GL_EXT_secondary_color */ case GL_COLOR_SUM_EXT: @@ -1343,11 +1315,7 @@ /* GL_NV_texture_rectangle */ case GL_TEXTURE_RECTANGLE_NV: CHECK_EXTENSION(NV_texture_rectangle); - { - const struct gl_texture_unit *texUnit; - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - return (texUnit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE; - } + return is_texture_enabled(ctx, TEXTURE_RECT_BIT); /* GL_EXT_stencil_two_side */ case GL_STENCIL_TEST_TWO_SIDE_EXT: Modified: haiku/trunk/src/kits/opengl/mesa/main/fbobject.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/fbobject.c 2007-07-15 22:14:06 UTC (rev 21621) +++ haiku/trunk/src/kits/opengl/mesa/main/fbobject.c 2007-07-15 22:28:49 UTC (rev 21622) @@ -1144,20 +1144,19 @@ * Common code called by glFramebufferTexture1D/2D/3DEXT(). */ static void -framebuffer_texture(GLuint dims, GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, +framebuffer_texture(GLcontext *ctx, const char *caller, GLenum target, + GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) { struct gl_renderbuffer_attachment *att; struct gl_texture_object *texObj = NULL; struct gl_framebuffer *fb; - GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (target != GL_FRAMEBUFFER_EXT) { _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferTexture%dDEXT(target)", dims); + "glFramebufferTexture%sEXT(target)", caller); return; } @@ -1167,83 +1166,53 @@ /* check framebuffer binding */ if (fb->Name == 0) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture%dDEXT", dims); + "glFramebufferTexture%sEXT", caller); return; } + + /* The textarget, level, and zoffset parameters are only validated if + * texture is non-zero. + */ if (texture) { - texObj = _mesa_lookup_texture(ctx, texture); - } + GLboolean err = GL_TRUE; - /* Check dimension-dependent things */ - switch (dims) { - case 1: - if (textarget != GL_TEXTURE_1D) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferTexture1DEXT(textarget)"); - return; + texObj = _mesa_lookup_texture(ctx, texture); + if (texObj != NULL) { + err = (texObj->Target == GL_TEXTURE_CUBE_MAP) + ? !IS_CUBE_FACE(textarget) + : (texObj->Target != textarget); } - if (texObj && texObj->Target != GL_TEXTURE_1D) { + + if (err) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture1DEXT(texture target mismatch)"); + "glFramebufferTexture%sEXT(texture target mismatch)", + caller); return; } - break; - case 2: - if (textarget != GL_TEXTURE_2D && - textarget != GL_TEXTURE_RECTANGLE_ARB && - !IS_CUBE_FACE(textarget)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferTexture2DEXT(textarget)"); - return; - } - if (texObj) { - if ((texObj->Target == GL_TEXTURE_2D && textarget != GL_TEXTURE_2D) || - (texObj->Target == GL_TEXTURE_RECTANGLE_ARB - && textarget != GL_TEXTURE_RECTANGLE_ARB) || - (texObj->Target == GL_TEXTURE_CUBE_MAP - && !IS_CUBE_FACE(textarget))) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture1DEXT(texture target mismatch)"); - return; - } - } - break; - case 3: - if (textarget != GL_TEXTURE_3D) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferTexture3DEXT(textarget)"); - return; - } - if (texObj && texObj->Target != GL_TEXTURE_3D) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture3DEXT(texture target mismatch)"); - return; - } - { + + if (texObj->Target == GL_TEXTURE_3D) { const GLint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1); if (zoffset < 0 || zoffset >= maxSize) { _mesa_error(ctx, GL_INVALID_VALUE, - "glFramebufferTexture3DEXT(zoffset)"); + "glFramebufferTexture%sEXT(zoffset)", + caller); return; } } - break; - default: - _mesa_problem(ctx, "Unexpected dims in error_check_framebuffer_texture"); - return; - } - if ((level < 0) || level >= _mesa_max_texture_levels(ctx, textarget)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glFramebufferTexture%dDEXT(level)", dims); - return; + if ((level < 0) || + (level >= _mesa_max_texture_levels(ctx, texObj->Target))) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glFramebufferTexture%sEXT(level)", caller); + return; + } } att = _mesa_get_attachment(ctx, fb, attachment); if (att == NULL) { _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferTexture%dDEXT(attachment)", dims); + "glFramebufferTexture%sEXT(attachment)", caller); return; } @@ -1271,9 +1240,16 @@ _mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { - const GLint zoffset = 0; - framebuffer_texture(1, target, attachment, textarget, texture, - level, zoffset); + GET_CURRENT_CONTEXT(ctx); + + if ((texture != 0) && (textarget != GL_TEXTURE_1D)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferTexture1DEXT(textarget)"); + return; + } + + framebuffer_texture(ctx, "1D", target, attachment, textarget, texture, + level, 0); } @@ -1281,9 +1257,19 @@ _mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { - const GLint zoffset = 0; - framebuffer_texture(2, target, attachment, textarget, texture, - level, zoffset); + GET_CURRENT_CONTEXT(ctx); + + if ((texture != 0) && + (textarget != GL_TEXTURE_2D) && + (textarget != GL_TEXTURE_RECTANGLE_ARB) && + (!IS_CUBE_FACE(textarget))) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferTexture2DEXT(textarget)"); + return; + } + + framebuffer_texture(ctx, "2D", target, attachment, textarget, texture, + level, 0); } @@ -1292,12 +1278,19 @@ GLenum textarget, GLuint texture, GLint level, GLint zoffset) { - framebuffer_texture(3, target, attachment, textarget, texture, + GET_CURRENT_CONTEXT(ctx); + + if ((texture != 0) && (textarget != GL_TEXTURE_3D)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferTexture3DEXT(textarget)"); + return; + } + + framebuffer_texture(ctx, "3D", target, attachment, textarget, texture, level, zoffset); } - void GLAPIENTRY _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbufferTarget, Modified: haiku/trunk/src/kits/opengl/mesa/main/image.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/image.c 2007-07-15 22:14:06 UTC (rev 21621) +++ haiku/trunk/src/kits/opengl/mesa/main/image.c 2007-07-15 22:28:49 UTC (rev 21622) @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.0 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -64,27 +64,27 @@ */ static GLboolean _mesa_type_is_packed(GLenum type) - { - switch (type) { - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - case GL_UNSIGNED_SHORT_8_8_MESA: - case GL_UNSIGNED_SHORT_8_8_REV_MESA: - case GL_UNSIGNED_INT_24_8_EXT: - return GL_TRUE; - } +{ + switch (type) { + case GL_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_5_6_5_REV: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: + case GL_UNSIGNED_SHORT_8_8_MESA: + case GL_UNSIGNED_SHORT_8_8_REV_MESA: + case GL_UNSIGNED_INT_24_8_EXT: + return GL_TRUE; + } - return GL_FALSE; + return GL_FALSE; } /** @@ -103,9 +103,8 @@ static void flip_bytes( GLubyte *p, GLuint n ) { - register GLuint i, a, b; - - for (i=0;i> 8) | ((p[i] << 8) & 0xff00); } } @@ -144,9 +142,8 @@ void _mesa_swap4( GLuint *p, GLuint n ) { - register GLuint i, a, b; - - for (i=0;i> 24) | ((b >> 8) & 0xff00) @@ -4263,60 +4260,68 @@ const GLvoid *src = _mesa_image_address(dimensions, unpack, pixels, width, height, format, type, img, row, 0); - if ((type == GL_BITMAP) && (unpack->SkipPixels & 0x7)) { - GLint i; - flipBytes = GL_FALSE; - if (unpack->LsbFirst) { - GLubyte srcMask = 1 << (unpack->SkipPixels & 0x7); - GLubyte dstMask = 128; - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 128) { - srcMask = 1; - s++; - } else { - srcMask = srcMask << 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } else { - dstMask = dstMask >> 1; - } - } - } else { - GLubyte srcMask = 128 >> (unpack->SkipPixels & 0x7); - GLubyte dstMask = 128; - const GLubyte *s = src; - GLubyte *d = dst; + if ((type == GL_BITMAP) && (unpack->SkipPixels & 0x7)) { + GLint i; + flipBytes = GL_FALSE; + if (unpack->LsbFirst) { + GLubyte srcMask = 1 << (unpack->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 128) { + srcMask = 1; + s++; + } + else { + srcMask = srcMask << 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 1) { - srcMask = 128; - s++; - } else { - srcMask = srcMask >> 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } else { - dstMask = dstMask >> 1; - } - } - } - } else - _mesa_memcpy(dst, src, bytesPerRow); + } + else { + dstMask = dstMask >> 1; + } + } + } + else { + GLubyte srcMask = 128 >> (unpack->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 1) { + srcMask = 128; + s++; + } + else { + srcMask = srcMask >> 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } + else { + dstMask = dstMask >> 1; + } + } + } + } + else { + _mesa_memcpy(dst, src, bytesPerRow); + } + /* byte flipping/swapping */ if (flipBytes) { flip_bytes((GLubyte *) dst, bytesPerRow); Modified: haiku/trunk/src/kits/opengl/mesa/main/imports.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/imports.c 2007-07-15 22:14:06 UTC (rev 21621) +++ haiku/trunk/src/kits/opengl/mesa/main/imports.c 2007-07-15 22:28:49 UTC (rev 21622) @@ -20,9 +20,9 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.0 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -921,14 +921,11 @@ /*@{*/ /** - * Display a warning. + * Report a warning (a recoverable error condition) to stderr if + * either DEBUG is defined or the MESA_DEBUG env var is set. * * \param ctx GL context. * \param fmtString printf() alike format string. - * - * If debugging is enabled (either at compile-time via the DEBUG macro, or - * run-time via the MESA_DEBUG environment variable), prints the warning to - * stderr via fprintf(). */ void _mesa_warning( GLcontext *ctx, const char *fmtString, ... ) @@ -951,13 +948,11 @@ } /** - * This function is called when the Mesa user has stumbled into a code - * path which may not be implemented fully or correctly. + * Report an internla implementation problem. + * Prints the message to stderr via fprintf(). * * \param ctx GL context. * \param s problem description string. - * - * Prints the message to stderr via fprintf(). */ void _mesa_problem( const GLcontext *ctx, const char *fmtString, ... ) @@ -975,18 +970,16 @@ } /** - * Display an error message. + * Record an OpenGL state error. These usually occur when the users + * passes invalid parameters to a GL function. * - * If in debug mode, print error message. - * Also, record the error code by calling _mesa_record_error(). + * If debugging is enabled (either at compile-time via the DEBUG macro, or + * run-time via the MESA_DEBUG environment variable), report the error with + * _mesa_debug(). * * \param ctx the GL context. * \param error the error value. * \param fmtString printf() style format string, followed by optional args - * - * If debugging is enabled (either at compile-time via the DEBUG macro, or - * run-time via the MESA_DEBUG environment variable), interperts the error code and - * prints the error message via _mesa_debug(). */ void _mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... ) @@ -1056,12 +1049,11 @@ } /** - * Report debug information. + * Report debug information. Print error message to stderr via fprintf(). + * No-op if DEBUG mode not enabled. * * \param ctx GL context. - * \param fmtString printf() alike format string. - * - * Prints the message to stderr via fprintf(). + * \param fmtString printf()-style format string, followed by optional args. */ void _mesa_debug( const GLcontext *ctx, const char *fmtString, ... ) Modified: haiku/trunk/src/kits/opengl/mesa/main/light.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/light.c 2007-07-15 22:14:06 UTC (rev 21621) +++ haiku/trunk/src/kits/opengl/mesa/main/light.c 2007-07-15 22:28:49 UTC (rev 21622) @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.0 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -1117,6 +1117,13 @@ } light->_VP_inf_spot_attenuation = 1.0; } + else { + /* positional light w/ homogeneous coordinate, divide by W */ + GLfloat wInv = 1.0 / light->_Position[3]; + light->_Position[0] *= wInv; + light->_Position[1] *= wInv; + light->_Position[2] *= wInv; + } if (light->_Flags & LIGHT_SPOT) { if (ctx->_NeedEyeCoords) { Modified: haiku/trunk/src/kits/opengl/mesa/main/points.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/points.c 2007-07-15 22:14:06 UTC (rev 21621) +++ haiku/trunk/src/kits/opengl/mesa/main/points.c 2007-07-15 22:28:49 UTC (rev 21622) @@ -5,9 +5,9 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 7.0 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -61,10 +61,6 @@ ctx->Point.MinSize, ctx->Point.MaxSize); - ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 || - ctx->Point.Params[1] != 0.0 || - ctx->Point.Params[2] != 0.0); - if (ctx->Driver.PointSize) ctx->Driver.PointSize(ctx, size); } @@ -122,6 +118,9 @@ return; FLUSH_VERTICES(ctx, _NEW_POINT); COPY_3V(ctx->Point.Params, params); + ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 || + ctx->Point.Params[1] != 0.0 || + ctx->Point.Params[2] != 0.0); } else { _mesa_error(ctx, GL_INVALID_ENUM, Modified: haiku/trunk/src/kits/opengl/mesa/main/teximage.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/teximage.c 2007-07-15 22:14:06 UTC (rev 21621) +++ haiku/trunk/src/kits/opengl/mesa/main/teximage.c 2007-07-15 22:28:49 UTC (rev 21622) @@ -1300,6 +1300,20 @@ /** + * Helper function to determine whether a target supports compressed textures + */ +static GLboolean +target_can_be_compressed(GLcontext *ctx, GLenum target) +{ + return (((target == GL_TEXTURE_2D || target == GL_PROXY_TEXTURE_2D)) + || ((ctx->Extensions.ARB_texture_cube_map && + (target == GL_PROXY_TEXTURE_CUBE_MAP || + (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))))); +} + + +/** * Test the glTexImage[123]D() parameters for errors. * * \param ctx GL context. @@ -1329,8 +1343,9 @@ GLint depth, GLint border ) { const GLboolean isProxy = _mesa_is_proxy_texture(target); - GLboolean sizeOK; + GLboolean sizeOK = GL_TRUE; GLboolean colorFormat, indexFormat; + GLenum proxy_target; /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ if (level < 0 || level >= MAX_TEXTURE_LEVELS) { @@ -1365,10 +1380,9 @@ */ if (dimensions == 1) { if (target == GL_PROXY_TEXTURE_1D || target == GL_TEXTURE_1D) { - sizeOK = ctx->Driver.TestProxyTexImage(ctx, GL_PROXY_TEXTURE_1D, - level, internalFormat, - format, type, - width, 1, 1, border); + proxy_target = GL_PROXY_TEXTURE_1D; + height = 1; + width = 1; } else { _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage1D(target)" ); @@ -1376,11 +1390,9 @@ } } else if (dimensions == 2) { + depth = 1; if (target == GL_PROXY_TEXTURE_2D || target == GL_TEXTURE_2D) { - sizeOK = ctx->Driver.TestProxyTexImage(ctx, GL_PROXY_TEXTURE_2D, - level, internalFormat, - format, type, - width, height, 1, border); + proxy_target = GL_PROXY_TEXTURE_2D; } else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB || (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && @@ -1389,10 +1401,8 @@ _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)"); return GL_TRUE; } - sizeOK = (width == height) && - ctx->Driver.TestProxyTexImage(ctx, GL_PROXY_TEXTURE_CUBE_MAP_ARB, - level, internalFormat, format, type, - width, height, 1, border); + proxy_target = GL_PROXY_TEXTURE_CUBE_MAP_ARB; + sizeOK = (width == height); } else if (target == GL_PROXY_TEXTURE_RECTANGLE_NV || target == GL_TEXTURE_RECTANGLE_NV) { @@ -1400,11 +1410,7 @@ _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)"); return GL_TRUE; } - sizeOK = ctx->Driver.TestProxyTexImage(ctx, - GL_PROXY_TEXTURE_RECTANGLE_NV, - level, internalFormat, - format, type, - width, height, 1, border); + proxy_target = GL_PROXY_TEXTURE_RECTANGLE_NV; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)"); @@ -1413,10 +1419,7 @@ [... truncated: 2994 lines follow ...] From axeld at mail.berlios.de Mon Jul 16 01:51:23 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 16 Jul 2007 01:51:23 +0200 Subject: [Haiku-commits] r21623 - haiku/trunk/src/system/kernel/fs Message-ID: <200707152351.l6FNpN2m029699@sheep.berlios.de> Author: axeld Date: 2007-07-16 01:51:21 +0200 (Mon, 16 Jul 2007) New Revision: 21623 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21623&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs_boot.cpp haiku/trunk/src/system/kernel/fs/vfs_net_boot.cpp Log: * Now checks if the BootMethod allocation succeeds. * Minor cleanup, reordered header files to go from private/local to public/global. Modified: haiku/trunk/src/system/kernel/fs/vfs_boot.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs_boot.cpp 2007-07-15 22:28:49 UTC (rev 21622) +++ haiku/trunk/src/system/kernel/fs/vfs_boot.cpp 2007-07-15 23:51:21 UTC (rev 21623) @@ -1,24 +1,16 @@ /* * Copyright 2007, Ingo Weinhold, bonefish at cs.tu-berlin.de. - * Copyright 2002-2006, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. * Distributed under the terms of the NewOS License. */ + #include "vfs_boot.h" +#include "vfs_net_boot.h" -#include - -#include -#include - -#include -#include -#include -#include - #include #include #include @@ -27,9 +19,17 @@ #include #include -#include "vfs_net_boot.h" +#include +#include +#include +#include +#include +#include +#include + + //#define TRACE_VFS #ifdef TRACE_VFS # define TRACE(x) dprintf x @@ -56,7 +56,7 @@ dev_t gBootDevice = -1; -/** No image was chosen - prefer disks with names like "Haiku", or "System" +/*! No image was chosen - prefer disks with names like "Haiku", or "System" */ int compare_image_boot(const void *_a, const void *_b) @@ -89,10 +89,10 @@ } -/** The system was booted from CD - prefer CDs over other entries. If there - * is no CD, fall back to the standard mechanism (as implemented by - * compare_image_boot(). - */ +/*! The system was booted from CD - prefer CDs over other entries. If there + is no CD, fall back to the standard mechanism (as implemented by + compare_image_boot(). +*/ static int compare_cd_boot(const void *_a, const void *_b) { @@ -110,12 +110,12 @@ } -/** Computes a check sum for the specified block. - * The check sum is the sum of all data in that block interpreted as an - * array of uint32 values. - * Note, this must use the same method as the one used in - * boot/platform/bios_ia32/devices.cpp (or similar solutions). - */ +/*! Computes a check sum for the specified block. + The check sum is the sum of all data in that block interpreted as an + array of uint32 values. + Note, this must use the same method as the one used in + boot/platform/bios_ia32/devices.cpp (or similar solutions). +*/ static uint32 compute_check_sum(KDiskDevice *device, off_t offset) { @@ -142,8 +142,9 @@ BootMethod::BootMethod(const KMessage& bootVolume, int32 method) - : fBootVolume(bootVolume), - fMethod(method) + : + fBootVolume(bootVolume), + fMethod(method) { } @@ -277,12 +278,12 @@ // #pragma mark - -/** Make the boot partition (and probably others) available. - * The partitions that are a boot candidate a put into the /a partitions - * stack. If the user selected a boot device, there is will only be one - * entry in this stack; if not, the most likely is put up first. - * The boot code should then just try them one by one. - */ +/*! Make the boot partition (and probably others) available. + The partitions that are a boot candidate a put into the /a partitions + stack. If the user selected a boot device, there is will only be one + entry in this stack; if not, the most likely is put up first. + The boot code should then just try them one by one. +*/ static status_t get_boot_partitions(kernel_args *args, PartitionStack &partitions) { @@ -355,7 +356,7 @@ break; } - status_t status = bootMethod->Init(); + status_t status = bootMethod != NULL ? bootMethod->Init() : B_NO_MEMORY; if (status != B_OK) return status; @@ -364,7 +365,8 @@ status = manager->InitialDeviceScan(); if (status != B_OK) { - dprintf("KDiskDeviceManager::InitialDeviceScan() failed: %s\n", strerror(status)); + dprintf("KDiskDeviceManager::InitialDeviceScan() failed: %s\n", + strerror(status)); return status; } Modified: haiku/trunk/src/system/kernel/fs/vfs_net_boot.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs_net_boot.cpp 2007-07-15 22:28:49 UTC (rev 21622) +++ haiku/trunk/src/system/kernel/fs/vfs_net_boot.cpp 2007-07-15 23:51:21 UTC (rev 21623) @@ -48,10 +48,10 @@ KPartition* a = *(KPartition**)_a; KPartition* b = *(KPartition**)_b; - bool aIsCD = is_net_device(a->Device()); - bool bIsCD = is_net_device(b->Device()); + bool aIsNetDevice = is_net_device(a->Device()); + bool bIsNetDevice = is_net_device(b->Device()); - int compare = (int)aIsCD - (int)bIsCD; + int compare = (int)aIsNetDevice - (int)bIsNetDevice; if (compare != 0) return compare; From bonefish at mail.berlios.de Mon Jul 16 17:06:03 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 16 Jul 2007 17:06:03 +0200 Subject: [Haiku-commits] r21624 - haiku/trunk/src/system/kernel/fs Message-ID: <200707161506.l6GF637M016913@sheep.berlios.de> Author: bonefish Date: 2007-07-16 17:06:02 +0200 (Mon, 16 Jul 2007) New Revision: 21624 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21624&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs_boot.cpp Log: The partition offset is int64, of course, not bool. Sometimes one wishes, C++ had a stricter typing. Modified: haiku/trunk/src/system/kernel/fs/vfs_boot.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs_boot.cpp 2007-07-15 23:51:21 UTC (rev 21623) +++ haiku/trunk/src/system/kernel/fs/vfs_boot.cpp 2007-07-16 15:06:02 UTC (rev 21624) @@ -243,7 +243,7 @@ if (!fBootVolume.GetBool(BOOT_VOLUME_BOOTED_FROM_IMAGE, false)) { // the simple case: we can just boot from the selected boot // device - if (partition->Offset() == fBootVolume.GetBool( + if (partition->Offset() == fBootVolume.GetInt64( BOOT_VOLUME_PARTITION_OFFSET, 0)) { foundForSure = true; return true; From korli at mail.berlios.de Mon Jul 16 20:40:33 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 16 Jul 2007 20:40:33 +0200 Subject: [Haiku-commits] r21625 - in haiku/trunk: headers/private/input src/servers/input Message-ID: <200707161840.l6GIeXep012761@sheep.berlios.de> Author: korli Date: 2007-07-16 20:40:32 +0200 (Mon, 16 Jul 2007) New Revision: 21625 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21625&view=rev Modified: haiku/trunk/headers/private/input/InputServerTypes.h haiku/trunk/src/servers/input/InputServer.cpp haiku/trunk/src/servers/input/InputServer.h Log: the keymap is now saved when key locks or key modifiers are changed this fixes bug #1282 Modified: haiku/trunk/headers/private/input/InputServerTypes.h =================================================================== --- haiku/trunk/headers/private/input/InputServerTypes.h 2007-07-16 15:06:02 UTC (rev 21624) +++ haiku/trunk/headers/private/input/InputServerTypes.h 2007-07-16 18:40:32 UTC (rev 21625) @@ -40,6 +40,7 @@ #define SYSTEM_SHUTTING_DOWN 'SSDn' #define IS_SAVE_SETTINGS 'Isst' +#define IS_SAVE_KEYMAP 'Iskp' // app_server communication #define IS_ACQUIRE_INPUT 'Iaqi' Modified: haiku/trunk/src/servers/input/InputServer.cpp =================================================================== --- haiku/trunk/src/servers/input/InputServer.cpp 2007-07-16 15:06:02 UTC (rev 21624) +++ haiku/trunk/src/servers/input/InputServer.cpp 2007-07-16 18:40:32 UTC (rev 21625) @@ -322,6 +322,13 @@ memcpy(fChars, kSystemKeyChars, fCharsSize); // TODO: why are we doing this? + return _SaveKeymap(); +} + + +status_t +InputServer::_SaveKeymap() +{ // we save this keymap to file BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) @@ -585,6 +592,10 @@ fMouseSettings.SaveSettings(); return; + case IS_SAVE_KEYMAP: + _SaveKeymap(); + return; + case B_SOME_APP_LAUNCHED: { const char *signature; @@ -738,6 +749,8 @@ // TODO: unmap the key ? + be_app_messenger.SendMessage(IS_SAVE_KEYMAP); + BMessage msg(IS_CONTROL_DEVICES); msg.AddInt32("type", B_KEYBOARD_DEVICE); msg.AddInt32("code", B_KEY_MAP_CHANGED); @@ -752,6 +765,8 @@ InputServer::HandleSetKeyboardLocks(BMessage* message, BMessage* reply) { if (message->FindInt32("locks", (int32*)&fKeys.lock_settings) == B_OK) { + be_app_messenger.SendMessage(IS_SAVE_KEYMAP); + BMessage msg(IS_CONTROL_DEVICES); msg.AddInt32("type", B_KEYBOARD_DEVICE); msg.AddInt32("code", B_KEY_LOCKS_CHANGED); Modified: haiku/trunk/src/servers/input/InputServer.h =================================================================== --- haiku/trunk/src/servers/input/InputServer.h 2007-07-16 15:06:02 UTC (rev 21624) +++ haiku/trunk/src/servers/input/InputServer.h 2007-07-16 18:40:32 UTC (rev 21625) @@ -171,6 +171,7 @@ status_t _LoadKeymap(); status_t _LoadSystemKeymap(); + status_t _SaveKeymap(); void _InitKeyboardMouseStates(); status_t _StartEventLoop(); From korli at mail.berlios.de Mon Jul 16 21:12:38 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 16 Jul 2007 21:12:38 +0200 Subject: [Haiku-commits] r21626 - haiku/trunk/src/system/boot/platform/openfirmware Message-ID: <200707161912.l6GJCcLD014700@sheep.berlios.de> Author: korli Date: 2007-07-16 21:12:37 +0200 (Mon, 16 Jul 2007) New Revision: 21626 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21626&view=rev Modified: haiku/trunk/src/system/boot/platform/openfirmware/devices.cpp Log: fixed ppc build. It was broken since r21611. Obviously it's not tested. Modified: haiku/trunk/src/system/boot/platform/openfirmware/devices.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/openfirmware/devices.cpp 2007-07-16 18:40:32 UTC (rev 21625) +++ haiku/trunk/src/system/boot/platform/openfirmware/devices.cpp 2007-07-16 19:12:37 UTC (rev 21626) @@ -187,12 +187,15 @@ status_t platform_register_boot_device(Node *device) { - disk_identifier &disk = gKernelArgs.boot_disk.identifier; + disk_identifier disk; disk.bus_type = UNKNOWN_BUS; disk.device_type = UNKNOWN_DEVICE; disk.device.unknown.size = device->Size(); + gKernelArgs.boot_volume.SetData(BOOT_VOLUME_DISK_IDENTIFIER, B_RAW_TYPE, + &disk, sizeof(disk_identifier)); + return B_OK; } From leavengood at gmail.com Mon Jul 16 21:53:49 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Mon, 16 Jul 2007 15:53:49 -0400 Subject: [Haiku-commits] r21626 - haiku/trunk/src/system/boot/platform/openfirmware In-Reply-To: <200707161912.l6GJCcLD014700@sheep.berlios.de> References: <200707161912.l6GJCcLD014700@sheep.berlios.de> Message-ID: On 7/16/07, korli at BerliOS wrote: > Log: > fixed ppc build. It was broken since r21611. Obviously it's not tested. Does anyone have a spare PPC machine that could do daily builds to ensure this port is still building? Of course that means someone would need to stay on top of that and fix problems as they are found. Not sure if you want that job though, korli. Ryan From bonefish at cs.tu-berlin.de Mon Jul 16 22:13:30 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Mon, 16 Jul 2007 22:13:30 +0200 Subject: [Haiku-commits] r21626 - haiku/trunk/src/system/boot/platform/openfirmware In-Reply-To: References: <200707161912.l6GJCcLD014700@sheep.berlios.de> Message-ID: <20070716221330.963.1@cs.tu-berlin.de> On 2007-07-16 at 21:53:49 [+0200], Ryan Leavengood wrote: > On 7/16/07, korli at BerliOS wrote: > > Log: > > fixed ppc build. It was broken since r21611. Obviously it's not tested. This part didn't work before, so there was nothing to test, anyway. :-) > Does anyone have a spare PPC machine that could do daily builds to > ensure this port is still building? You don't need a PPC machine to build for PPC. The cross-compilation works just fine. Well, or doesn't since we upgraded to binutils 2.17. CU, Ingo From leavengood at gmail.com Mon Jul 16 22:33:04 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Mon, 16 Jul 2007 16:33:04 -0400 Subject: [Haiku-commits] r21626 - haiku/trunk/src/system/boot/platform/openfirmware In-Reply-To: <20070716221330.963.1@cs.tu-berlin.de> References: <200707161912.l6GJCcLD014700@sheep.berlios.de> <20070716221330.963.1@cs.tu-berlin.de> Message-ID: On 7/16/07, Ingo Weinhold wrote: > > You don't need a PPC machine to build for PPC. The cross-compilation works > just fine. Well, or doesn't since we upgraded to binutils 2.17. Cool. Is there a way to test this in some kind of PPC VM? Is there a PPC VM? ;) Though maybe just building it is enough, hehehe. Either way I don't have much time to mess with this, so I'm not sure why I'm asking :P All my old machines are x86 anyhow... Ryan From bonefish at cs.tu-berlin.de Mon Jul 16 22:53:09 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Mon, 16 Jul 2007 22:53:09 +0200 Subject: [Haiku-commits] r21626 - haiku/trunk/src/system/boot/platform/openfirmware In-Reply-To: References: <200707161912.l6GJCcLD014700@sheep.berlios.de> <20070716221330.963.1@cs.tu-berlin.de> Message-ID: <20070716225309.3289.3@cs.tu-berlin.de> On 2007-07-16 at 22:33:04 [+0200], Ryan Leavengood wrote: > On 7/16/07, Ingo Weinhold wrote: > > > > You don't need a PPC machine to build for PPC. The cross-compilation works > > just fine. Well, or doesn't since we upgraded to binutils 2.17. > > Cool. Is there a way to test this in some kind of PPC VM? Is there a PPC > VM? ;) IIRC qemu also has support for PPC machines. But you won't get much further than initializing the kernel anyway. CU, Ingo From axeld at mail.berlios.de Mon Jul 16 23:47:15 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 16 Jul 2007 23:47:15 +0200 Subject: [Haiku-commits] r21627 - haiku/trunk/docs/user/drivers Message-ID: <200707162147.l6GLlFb0023597@sheep.berlios.de> Author: axeld Date: 2007-07-16 23:47:13 +0200 (Mon, 16 Jul 2007) New Revision: 21627 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21627&view=rev Modified: haiku/trunk/docs/user/drivers/fs_interface.dox haiku/trunk/docs/user/drivers/fs_modules.dox Log: * Spaces to tabs. * Carriage returns to simple new lines. Modified: haiku/trunk/docs/user/drivers/fs_interface.dox =================================================================== --- haiku/trunk/docs/user/drivers/fs_interface.dox 2007-07-16 19:12:37 UTC (rev 21626) +++ haiku/trunk/docs/user/drivers/fs_interface.dox 2007-07-16 21:47:13 UTC (rev 21627) @@ -1,1769 +1,1775 @@ -/* - * Copyright 2007 Haiku Inc. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Ingo Weinhold - * Niels Sascha Reedijk - * Axel D?rfler, axeld at pinc-software.de - * - * Corresponds to: - * /trunk/headers/os/drivers/fs_interface.h rev 21568 - */ - -/*! - \file fs_interface.h - \ingroup drivers - \brief Provides an interface for file system modules. - - See the \ref fs_modules "introduction to file system modules" for a guide on - how to get started with writing file system modules. -*/ - -///// write_stat_mask ////// - -/*! - \enum write_stat_mask - \brief This mask is used in file_system_module_info::write_stat() to - determine which values need to be written. -*/ - -/*! - \var write_stat_mask::FS_WRITE_STAT_MODE - \brief The mode parameter should be updated. -*/ - -/*! - \var write_stat_mask::FS_WRITE_STAT_UID - \brief The UID field should be updated. -*/ - -/*! - \var write_stat_mask::FS_WRITE_STAT_GID - \brief The GID field should be updated. -*/ - -/*! - \var write_stat_mask::FS_WRITE_STAT_SIZE - \brief The size field should be updated. If the actual size is less than the - new provided file size, the file should be set to the new size and the - extra space should be filled with zeros. -*/ - -/*! - \var write_stat_mask::FS_WRITE_STAT_ATIME - \brief The access time should be updated. -*/ - -/*! - \var write_stat_mask::FS_WRITE_STAT_MTIME - \brief The 'last modified' field should be updated. -*/ - -/*! - \var write_stat_mask::FS_WRITE_STAT_CRTIME - \brief The 'creation time' should be updated. -*/ - -///// FS_WRITE_FSINFO_NAME ///// - -/*! - \def FS_WRITE_FSINFO_NAME - \brief Passed to file_system_module_info::write_fs_info(). -*/ - -///// file_io_vec ///// - -/*! - \struct file_io_vec - \brief Structure that describes the io vector of a file. -*/ - -/*! - \var off_t file_io_vec::offset - \brief The offset within the file. -*/ - -/*! - \var off_t file_io_vec::length - \brief The length of the vector. -*/ - -///// B_CURRENT_FS_API_VERSION ///// - -/*! - \def B_CURRENT_FS_API_VERSION - \brief Constant that defines the version of the file system API that your - filesystem conforms to. - - The module name that exports the interface to your file system has to - end with this constant as in: - \code "file_systems/myfs" B_CURRENT_FS_API_VERSION -*/ - -///// file_system_module_info ///// - - -/*! - \struct file_system_module_info - \brief Kernel module interface for file systems. - - See the \ref fs_modules "introduction to file system modules" for an - introduction to writing file systems. -*/ - -/*! - \name Data members -*/ - -//! @{ - -/*! - \var module_info file_system_module_info::info - \brief Your module_info object which is required for all modules. -*/ - -/*! - \var const char *file_system_module_info::pretty_name - \brief A NULL-terminated string with a 'pretty' name for you file system. - - Note, if a system wide disk device type constant exists for your file system, - it should equal this identifier. -*/ - -//! @} - -/*! - \name Scanning -*/ - -//! @{ - -/*! - \fn float (*file_system_module_info::identify_partition)(int fd, partition_data *partition, void **cookie) - \brief Undocumented. TODO. -*/ - -/*! - \fn status_t (*file_system_module_info::scan_partition)(int fd, partition_data *partition, void *cookie) - \brief Undocumented. TODO. -*/ - -/*! - \fn void (*file_system_module_info::free_identify_partition_cookie)(partition_data *partition, void *cookie) - \brief Undocumented. TODO. -*/ - -/*! - \fn void (*file_system_module_info::free_partition_content_cookie)(partition_data *partition) - \brief Undocumented. TODO. -*/ - -//! @} - -/*! - \name General Operations -*/ - -//! @{ - -/*! - \fn status_t (*file_system_module_info::mount)(ino_t id, const char *device, - uint32 flags, const char *args, fs_volume *_fs, ino_t *_rootVnodeID) - \brief Mount a volume according to the specified parameters. - - Invoked by the VFS when it has been requested to mount the volume. The FS is - supposed to perform whatever one-time initialization is necessary for the - volume. It is required to create a volume handle for the volume and pass it - back in \a _fs. Moreover it must invoke publish_vnode() for the root node - of the volume and pass the ID of the volume back in \a _rootVnodeID. - - A disk-based FS will need to check whether \a device is not \c NULL, open - it, and analyze whether the device or image file actually represents a volume - of that FS type. - - If mounting the volume fails for whatever reason, the hook must return an - error code other than \c B_OK. In this case all resources allocated by the - hook must be freed before returning. If and only if \c B_OK is returned, the - unmount() hook will be invoked at a later point when unmounting the volume. - - \param id The ID of the volume to be mounted. It should be saved in the FS's - volume private data (volume handle). - \param device The path to the device (or image file) representing the volume - to be mounted. Can be \c NULL. - \param flags Flags: - - \c B_MOUNT_READ_ONLY: Mount the volume read-only. - \param args Null-terminated string in driver settings format, containing FS - specific parameters. - \param _fs Pointer to a pre-allocated variable the volume handle shall be - written to. - \param _rootVnodeID Pointer to a pre-allocated variable the ID of the - volume's root directory shall be written to. - \return \c B_OK if everything went fine, another error code otherwise. -*/ - -/*! - \fn status_t (*file_system_module_info::unmount)(fs_volume fs) - \brief Unmounts the given volume. - - Invoked by the VFS when it is asked to unmount the volume. The function must - free all resources associated with the mounted volume, including the volume - handle. Although the mount() hook called publish_vnode() for the root node - of the volume, unmount() must not invoke put_vnode(). - - \param fs The volume handle. - \return \c B_OK if everything went fine, another error code otherwise. The - error code will be ignored, though. -*/ - -/*! - \fn status_t (*file_system_module_info::read_fs_info)(fs_volume fs, - struct fs_info *info) - \brief Retrieves general information about the volume. - - The following fields of the \c fs_info structure need to be filled in: - - \c flags: Flags applying to the volume, e.g. \c B_FS_IS_READONLY, - \c B_FS_HAS_ATTR, etc. - - \c block_size: The size of blocks the volume data are organized in. - Meaningful mainly for disk-based FSs, other FSs should use some reasonable - value for computing \c total_blocks and \c free_blocks. - - \c io_size: Preferred size of the buffers passed to read() and write(). - - \c total_blocks: Total number of blocks the volume contains. - - \c free_blocks: Number of free blocks on the volume. - - \c total_nodes: Maximal number of nodes the volume can contain. If there is - no such limitation use \c LONGLONG_MAX. - - \c free_nodes: Number of additional nodes the volume could contain. If - there is no such limitation use \c LONGLONG_MAX. - - \c device_name: The name of the device or image file containing the volume. - Non-disk-based FSs shall fill in an empty string. - - \c volume_name: The name of the volume. - - The other values are filled in by the VFS. - - \param fs The volume handle. - \param info Pointer to a pre-allocated variable the FS info shall be written - to. - \return \c B_OK if everything went fine, another error code otherwise. The - error code will be ignored, though. -*/ - -/*! - \fn status_t (*file_system_module_info::write_fs_info)(fs_volume fs, const - struct fs_info *info, uint32 mask) - \brief Update filesystem information on the volume. - - You are requested to update certain information on the volume \a fs. The - supplied \a info contains the new values filled in for the \a mask. - Currently, the only possible mask is solely the \c FS_WRITE_FSINFO_NAME, - which asks you to update the volume name represented by the value - \c volume_name in the \c fs_info struct. - - \param fs The cookie your filesystem supplied to the volume that should be - updated. - \param info The structure that contains the new data. - \param mask The values of the \a info that need to be updated. - \return \c B_OK if everything went fine, if not, one of the error codes. -*/ - -/*! - \fn status_t (*file_system_module_info::sync)(fs_volume fs) - \brief Synchronize the cached data with the contents of the disk. - - The VFS layer sometimes wants you to synchronize any cached values with the - data on the device. - - This currently only happens when the POSIX sync() function is invoked, for - example via the "sync" command line tool. - - \param fs The cookie your filesystem supplied to the volume that should be - updated. -*/ - -//! @} - -/*! - \name VNode Operations -*/ - -//! @{ - -/*! - \fn status_t (*file_system_module_info::lookup)(fs_volume fs, fs_vnode dir, - const char *name, ino_t *_id, int *_type) - \brief Looks up the node a directory entry refers to. - - The VFS uses this hook to resolve path names to vnodes. It is used quite - often and should be implemented efficiently. - - If the parameter \a dir does not specify a directory, the function shall - fail. It shall also fail, if it is a directory, but does not contain an entry - with the given name \a name. Otherwise the function shall invoke get_vnode() - for the node the entry refers to and pass back the ID and the type of the - node in \a _id and \a _type respectively. - - Note that a directory must contain the special entries \c "." and \c "..", - referring to the same directory and the parent directory respectively. - lookup() must resolve the nodes accordingly. \c ".." for the root directory - of the volume shall be resolved to the root directory itself. - - \param fs The volume handle. - \param dir The node handle of the directory. - \param name The name of the directory entry. - \param _id Pointer to a pre-allocated variable the ID of the found node - shall be written to. - \param _type Pointer to a pre-allocated variable the type of the found node - shall be written to. The type is encoded as in the \c st_mode field of a - struct stat (bitwise anded with \c S_IFMT). - \retval B_OK Everything went fine. - \retval B_ENTRY_NOT_FOUND The given directory does not contain an entry with - the given name. -*/ - -/*! - \fn status_t (*file_system_module_info::get_vnode_name)(fs_volume fs, - fs_vnode vnode, char *buffer, size_t bufferSize) - \brief Return the file name of a vnode. - - Note that you don't have to implement this call if it can't be easily done; - it's completely optional. - If you don't implement it, you'll have to export a NULL pointer for this - function in the module definition. In this case, the VFS will find the name - by iterating over its parent directory. - - \param fs The file system provided cookie associated with this volume. - \param vnode The file system provided cookie associated with this vnode. - \param buffer The buffer that the name can be copied into. - \param bufferSize The size of the buffer. - \retval B_OK You successfully copied the file name into the \a buffer. - \retval "other errors" There was some error looking up or copying the name. -*/ - -/*! - \fn status_t (*file_system_module_info::get_vnode)(fs_volume fs, ino_t id, - fs_vnode *_vnode, bool reenter) - \brief Creates the private data handle to be associated with the node - referred to by \a id. - - Invoked by the VFS when it creates the vnode for the respective node. - When the VFS no longer needs the vnode in memory (for example when - memory is becoming tight), it will your file_system_module_info::put_vnode(), - or file_system_module_info::remove_vnode() in case the vnode has been - marked removed. - - \param fs The volume handle. - \param id The ID of the node. - \param _vnode Pointer to a pre-allocated variable the node handle shall be - written to. - \param reenter \c true if the hook invocation has been caused by the FS - itself, e.g. by invoking ::get_vnode(). - \return \c B_OK if everything went fine, another error code otherwise. -*/ - -/*! - \fn \fn status_t (*file_system_module_info::put_vnode)(fs_volume fs, - fs_vnode vnode, bool reenter) - \brief Deletes the private data handle associated with the specified node. - - Invoked by the VFS when it deletes the vnode for the respective node and the - node is not marked removed. - - \param fs The volume handle. - \param vnode The node handle. - \param reenter \c true if the hook invocation has been caused by the FS - itself, e.g. by invoking ::put_vnode(). - \return \c B_OK if everything went fine, another error code otherwise. -*/ - -/*! - \fn status_t (*file_system_module_info::remove_vnode)(fs_volume fs, - fs_vnode vnode, bool reenter) - \brief Deletes the private data handle associated with the specified node. - - Invoked by the VFS when it deletes the vnode for the respective node and the - node has been marked removed by a call to remove_vnode(). - - \param fs The volume handle. - \param vnode The node handle. - \param reenter \c true if the hook invocation has been caused by the FS - itself, e.g. by invoking ::put_vnode(). - \return \c B_OK if everything went fine, another error code otherwise. -*/ - -//! @} - -/*! - \name VM file access -*/ - -//! @{ - -/*! - \fn bool (*file_system_module_info::can_page)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) - \brief Undocumented. TODO. - - TODO: In both the dos and the bfs implementations this thing simply returns - false... Is there anything more to it? - This call might be removed in the future - it's currently unused. -*/ - -/*! - \fn status_t (*file_system_module_info::read_pages)(fs_volume fs, fs_vnode vnode, - fs_cookie cookie, off_t pos, const iovec *vecs, size_t count, - size_t *_numBytes, bool reenter) - \brief Undocumented. TODO. -*/ - -/*! - \fn status_t (*file_system_module_info::write_pages)(fs_volume fs, fs_vnode vnode, - fs_cookie cookie, off_t pos, const iovec *vecs, size_t count, - size_t *_numBytes, bool reenter) - \brief Undocumented. TODO. -*/ - -//! @} - -/*! - \name Cache File Access -*/ - -//! @{ - -/*! - \fn status_t (*file_system_module_info::get_file_map)(fs_volume fs, - fs_vnode vnode, off_t offset, size_t size, struct file_io_vec *vecs, - size_t *_count) - \brief Fills the \a vecs with the extents of the file data stream. - - This function is called only when you are using the file cache, but if you - use it, its implementation is mandatory. - - TODO: complete me -*/ - -//! @} - -/*! - \name Standard Operations -*/ - -//! @{ - -/*! - \fn status_t (*file_system_module_info::ioctl)(fs_volume fs, fs_vnode vnode, - fs_cookie cookie, ulong op, void *buffer, size_t length) - \brief Perform file system specific operations. - - You can implement a customized API using this call. This can be extremely - handy for debugging purposes. There are no obligatory operations for you to - implement. - - If you don't want to use this feature, you don't have to implement it. - - \param fs The file system provided cookie associated with this volume. - \param vnode The file system provided cookie associated with the vnode (if - applicable). - \param cookie The file system provided cookie associated with, for example, - an open file (if applicable). - \param op The operation code. You will have to define them yourself. - \param buffer A buffer (if applicable). - \param length The size of the buffer. - \return You should return any of your status codes. -*/ - -/*! - \fn status_t (*file_system_module_info::set_flags)(fs_volume fs, fs_vnode - vnode, fs_cookie cookie, int flags) - \brief Set the open mode flags for an opened file. - - This function should change the open flags for an opened file. - - \param fs The file system provided cookie associated with this volume. - \param vnode The file system provided cookie associated with the vnode. - \param cookie The file system provided cookie associated with the opened - file. - \param flags The new flags. - \return \c B_OK if the operation succeeded, or else an error code. -*/ - -/*! - \fn status_t (*file_system_module_info::select)(fs_volume fs, fs_vnode vnode, - fs_cookie cookie, uint8 event, uint32 ref, selectsync *sync) - \brief Selects the specified \a vnode with the specified \a events. - - This function is called by the VFS whenever select() or poll() is called on - a file descriptor that points to your file system. - - You have to check if the condition of the select() (ie. if there is data - available if event is B_SELECT_READ) is already satisfied, and call - notify_select_event() with the \a sync and \a ref arguments you retrieve - here. - - Additionally, when a vnode is selected this way, you have to call - notify_select_event() whenever the condition becomes true until the - vnode is deselected again via file_system_module_info::deselect(). - - This function is optional. If you don't export it, the default implementation - in the VFS will call notify_select_event() directly which will be sufficient - for most file systems. -*/ - -/*! - \fn status_t (*file_system_module_info::deselect)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, - uint8 event, selectsync *sync) - \brief Deselects the specified \a vnode from a previous select() call. - - This function is called by the VFS whenever a select() or poll() function - exits that previously called file_system_module_info::select() on that - \a vnode. -*/ - -/*! - \fn status_t (*file_system_module_info::fsync)(fs_volume fs, fs_vnode vnode) - \brief Synchronize the buffers with the on disk data. - - \param fs The file system provided cookie associated with this volume. - \param vnode The file system provided cookie associated with the vnode. - \return \c B_OK if the operation succeeded, or else an error code. -*/ - -/*! - \fn status_t (*file_system_module_info::read_symlink)(fs_volume fs, - fs_vnode link, char *buffer, size_t *_bufferSize) - \brief Read the value of a symbolic link. - - If the function is successful, the string written to the buffer shall be - null-terminated and the variable \a _bufferSize points to shall be set to - the length of that string, including the terminating null character. - - \param fs The volume handle. - \param link The node handle. - \param buffer Pointer to a pre-allocated buffer the link value shall be - written to. - \param buffer Pointer to a pre-allocated variable containing the size of the - buffer supplied to the function. Upon successful completion the hook shall - store the number of bytes actually written into the buffer in the variable. - \retval B_OK Everything went fine. - \retval B_BAD_VALUE \a link does not identify a symbolic link. - \retval B_BUFFER_OVERFLOW The supplied buffer is not big enough to contain - the complete link value. -*/ - -/*! - \fn status_t (*file_system_module_info::create_symlink)(fs_volume fs, - fs_vnode dir, const char *name, const char *path, int mode) - \brief Create a new symbolic link. - - Your implementation should check if the user has permission to perform this - operation. - - \param fs The file system provided cookie associated with this volume. - \param dir The file system provided cookie associated with the directory - the symbolic link should be created in. - \param name The name of the new symbolic link. - \param path The path of the original inode the symbolic link should refer to. - \param mode The mode that this symbolic link should be created in. (TODO - what exactly?) - \return \c B_OK if you succeeded, or an error code if you failed. -*/ - -/*! - \fn status_t (*file_system_module_info::link)(fs_volume fs, fs_vnode dir, - const char *name, fs_vnode vnode) - \brief Create a new hard link. - - You should make sure the user has the proper permissions. - - The virtual file system will request the creation of symbolic links with - create_symlink(). - - If you don't implement this function, the VFS will return \c EROFS - when a hard link is requested. - - \param fs The file system provided cookie associated with this volume. - \param dir The cookie associated to the directory where the link should be - saved. - \param name The name the link should have. - \param vnode The vnode the new link should resolve to. - \retval B_OK The hard link is properly created. - \retval B_NOT_ALLOWED The user does not have the proper permissions. - \retval "other errors" Another error occured. -*/ - -/*! - \fn status_t (*file_system_module_info::unlink)(fs_volume fs, fs_vnode dir, - const char *name) - \brief Remove a node or directory. - - You should make sure the user has the proper permissions. - - \param fs The file system provided cookie associated with this volume. - \param dir The parent directory of the node that should be removed. - \param name The name of the node that should be deleted. - \retval B_OK Removal succeeded. - \retval B_ENTRY_NOT_FOUND The entry does not exist. - \retval B_NOT_ALLOWED The user does not have the proper permissions. - \retval B_DIRECTORY_NOT_EMPTY The \a name refers to a directory. The virtual - file system expects directories to be emptied before they can be unlinked. - \retval "other errors" Another error occured. -*/ - -/*! - \fn status_t (*file_system_module_info::rename)(fs_volume fs, fs_vnode - fromDir, const char *fromName, fs_vnode toDir, const char *toName) - \brief Rename and/or relocate a vnode. - - The virtual file system merely relays the request, so make sure the user is - not changing the file name to something like '.', '..' or anything starting - with '/'. - - This also means that it if the node is a directory, that it should not be - moved into one of its own children. - - You should also make sure the user has the proper permissions. - - \param fs The file system provided cookie associated with this volume. - \param fromDir The cookie of the parent directory the vnode should be moved - from. - \param fromName The old name of the node. - \param toDir The cookie of the parent directory the vnode should be moved to. - \param toName The new name of the node. - \retval B_OK The renaming and relocating succeeded. - \retval B_BAD_VALUE One of the supplied parameters were invalid. - \retval B_NOT_ALLOWED The user does not have the proper permissions. - \retval "other errors" Another error condition was encountered. -*/ - -/*! - \fn status_t (*file_system_module_info::access)(fs_volume fs, fs_vnode vnode, - int mode) - \brief Checks whether the current user is allowed to access the node in the - specified way. - - \a mode is a bitwise combination of: - - \c R_OK: Read access. - - \c W_OK: Write access. - - \c X_OK: Execution. - - If the current user does not have any of the access permissions represented - by the set bits, the function shall return \c B_NOT_ALLOWED. As a special - case, if the volume is read-only and write access is requested, - \c B_READ_ONLY_DEVICE shall be returned. If the requested access mode - complies with the user's access permissions, the function shall return - \c B_OK. - - For most FSs the permissions a user has are defined by the \c st_mode, - \c st_uid, and \c st_gid fields of the node's stat data. As a special - exception, the root user (geteuid() == 0) does always have - read and write permissions, execution permission only when at least one of - the execution permission bits are set. - - \param fs The volume handle. - \param vnode The node handle. - \param mode The access mode mask. - \retval B_OK The user has the permissions to access the node in the requested - way. - \retval B_READ_ONLY_DEVICE The volume is read-only, but the write access has - been requested. - \retval B_NOT_ALLOWED The user does not have all permissions to access the - node in the requested way. -*/ - -/*! - \fn status_t (*file_system_module_info::read_stat)(fs_volume fs, - fs_vnode vnode, struct stat *stat) - \brief Retrieves the stat data for a given node. - - All values of the struct stat save \c st_dev, \c st_ino, \c st_rdev, - and \c st_type need to be filled in. - - \param fs The volume handle. - \param vnode The node handle. - \param stat Pointer to a pre-allocated variable the stat data shall be - written to. - \return \c B_OK if everything went fine, another error code otherwise. -*/ - -/*! - \fn status_t (*file_system_module_info::write_stat)(fs_volume fs, fs_vnode - vnode, const struct stat *stat, uint32 statMask) - \brief Update the stats for a vnode. - - You should make sure that the new values are valid and that the user has the - proper permissions to update the stats. - - \param fs The file system provided cookie to the volume. - \param vnode The cookie to the vnode. - \param stat The structure with the updated values. - \param statMask One of the #write_stat_mask enumeration, which forms a mask - of which of the values in \a stat should actually be updated. - \retval B_OK The update succeeded. - \retval B_NOT_ALLOWED The user does not have the proper permissions. - \retval "other errors" Another error condition occured. -*/ - -//! @} - -/*! - \name File Operations -*/ - -//! @{ - -/*! - \fn status_t (*file_system_module_info::create)(fs_volume fs, fs_vnode dir, - const char *name, int openMode, int perms, fs_cookie *_cookie, - ino_t *_newVnodeID) - \brief Create a new file. - - Your implementation shall check whether it is possible to create the node. - You will need to take the user's permissions into account. When you create - a new file, you will also have to open it. This means also checking the - permissions the user requires to open the file according to the \a mode. - See \link file_system_module_info::open() open() \endlink for the possible - values of \a mode. - - \param fs The file system provided cookie associated with this volume. - \param dir The file system provided cookie associated with the directory - where the file should appear. - \param name The name of the new file. - \param openMode The mode associated to the file. - \param perms The permissions the new file should have. - \param[out] _cookie In case of success, the you can store your file system - data for this node in this variable. - \param[out] _newVnodeID In case of success, you can store the new vnode id - in this variable. - \return You should return \c B_OK if creating the new node succeeded, and if - you put data in both \a _cookie and \a _newVnodeID. Else you should return - an error code. -*/ - -/*! - \fn status_t (*file_system_module_info::open)(fs_volume fs, fs_vnode vnode, - int openMode, fs_cookie *_cookie) - \brief Opens the given node. - - The function shall check whether it is possible to open the node according to - the mode specified by \c openMode (also considering the user's access - permissions), create a node cookie, and store it in the variable - \a _cookie points to. - - The open mode \a openMode is encoded in the same way as the parameter of the - POSIX function \c open(), i.e. it is either \c O_RDONLY, \c O_WRONLY, or - \c O_RDWR, bitwise or'ed with flags. The only relevant flags for this hook - are \c O_TRUNC and \c O_NONBLOCK. - - \param fs The volume handle. - \param vnode The node handle. - \param openMode The open mode. - \param _cookie Pointer to a pre-allocated variable the node cookie shall be - written to. - \return \c B_OK if everything went fine, another error code otherwise. -*/ - -/*! - \fn status_t (*file_system_module_info::close)(fs_volume fs, fs_vnode vnode, - fs_cookie cookie) - \brief Closes the given node cookie. - - The hook is invoked, when closing the node has been requested. At this point - other threads might still use the cookie, i.e. still execute hooks to which - the cookie has been passed. If the FS supports blocking I/O operations, this - hook should make sure to unblock all currently blocking threads performing - an operation using the cookie, and mark the cookie such that no further - threads will block using it. - - For many FSs this hook is a no-op - it's mandatory to be exported, though. - - \param fs The volume handle. - \param vnode The node handle. - \param cookie The node cookie as returned by open(). - \return \c B_OK if everything went fine, another error code otherwise. -*/ - -/*! - \fn status_t (*file_system_module_info::free_cookie)(fs_volume fs, - fs_vnode vnode, fs_cookie cookie) - \brief Frees the given node cookie. - - The hook is invoked after close(), when no other thread uses or is going to - use the cookie. All resources associated with the cookie must be freed. - - \param fs The volume handle. - \param vnode The node handle. - \param cookie The node cookie as returned by open(). - \return \c B_OK if everything went fine, another error code otherwise. -*/ - -/*! - \fn status_t (*file_system_module_info::read)(fs_volume fs, fs_vnode vnode, - fs_cookie cookie, off_t pos, void *buffer, size_t *length) - \brief Reads data from a file. - - This function should fail if - - the node is not a file, - - the cookie has not been opened for reading, - - \a pos is negative, or - - some other error occurs while trying to read the data, and no data have - been read at all. - - The number of bytes to be read is stored in the variable pointed to by - \a length. If less data is available at file position \a pos, or if \a pos - if greater than the size of the file, only as many data as available shall - be read, the function shall store the number of bytes actually read into the - variable pointed to by \a length, and return \c B_OK. - - \param fs The volume handle. - \param vnode The node handle. - \param cookie The node cookie as returned by open(). - \param pos The file position where to start reading data. - \param buffer Pointer to a pre-allocated buffer the read data shall be - written to. - \param length Pointer to a pre-allocated variable containing the size of the - buffer when invoked, and into which the size of the data actually read - shall be written. - \return \c B_OK if everything went fine, another error code otherwise. -*/ - -/*! - \fn status_t (*file_system_module_info::write)(fs_volume fs, fs_vnode vnode, - fs_cookie cookie, off_t pos, const void *buffer, size_t *length) - \brief Write data to a file. - - This function should fail if - - the node is not a file, - - the cookie has not been opened for writing, - - \a pos is negative, or - - some other error occurs while trying to read the data, and no data have - been read at all. - - The number of bytes to be written is stored in the variable pointed to by - \a length. If not all bytes could be written, that variable must be updated - to reflect the amount of actually written bytes. If an error prevented - you from writing the full amount, an appropriate error code should be - returned. - - \param fs The file system provided cookie associated with this volume. - \param vnode The file system provided cookie associated with the vnode. - \param cookie The file system provided cookie associated with the file. - \param pos The position to start writing. - \param buffer The buffer that contains the data that will need to be written. - \param length The length of the data that needs to be written. - \return \c B_OK if everything went fine, another error code otherwise. -*/ - -//! @} - -/*! - \name Directory Operations -*/ - -/*! - \fn status_t (*file_system_module_info::create_dir)(fs_volume fs, fs_vnode - parent, const char *name, int perms, ino_t *_newVnodeID) - \brief Create a new directory. - - Your implementation should make sure that the directory actually can be - created in the \a parent directory. You will have to check if the user has - permissions to actually write to the \a parent. If not, this function should - fail (probably with \c B_NOT_ALLOWED, or in case of a read-only filesystem, - with \c B_READ_ONLY_DEVICE). If the operation succeeds, you should put the - new vnode id in \a _newVnodeID. - - \param fs The file system provided cookie associated with this volume. - \param parent The file system provided cookie associated with the parent - node. - \param name The name the new directory should have. - \param perms The permissions the new directory should have. - \param[out] _newVnodeID If creating the directory succeeds, than you should - put the new vnode id in this variable. - \return If the operation succeeds and the \a _newVnodeID is populated with - the new vnode, then you should return \c B_OK. Else you should return with - an error code. -*/ - -/*! - \fn status_t (*file_system_module_info::remove_dir)(fs_volume fs, fs_vnode - parent, const char *name) - \brief Remove a directory. - - You should make sure the user has the proper permissions. You should also - check that the directory is empty. - - \param fs The file system provided cookie associated with this volume. - \param parent The file system provided cookie associated with the parent - node. - \param name The \a name of the directory that needs to be removed. - \retval B_OK Operation succeeded. - \retval B_DIRECTORY_NOT_EMPTY The directory is not empty. - \retval B_ENTRY_NOT_FOUND There is no directory with this \a name. - \retval B_NOT_A_DIRECTORY The entry is not a directory. - \retval "other errors" Other errors occured. -*/ - -/*! - \fn status_t (*file_system_module_info::open_dir)(fs_volume fs, fs_vnode vnode, - fs_cookie *_cookie) - \brief Opens the given directory node. - - If the specified node is not a directory, or if the current user does not - have the permissions to read the directory, the function shall fail. - Otherwise it shall allocate a directory cookie and store it in the variable - \a _cookie points to. A subsequent read_dir() using the cookie shall start - reading the first entry of the directory. - - \param fs The volume handle. - \param vnode The node handle. - \param _cookie Pointer to a pre-allocated variable the directory cookie shall - be written to. - \return \c B_OK if everything went fine, another error code otherwise. -*/ - -/*! - \fn status_t (*file_system_module_info::close_dir)(fs_volume fs, - fs_vnode vnode, fs_cookie cookie) - \brief Closes the given directory cookie. - - Generally the situation is similar to the one described for close(). In - practice it is a bit, though, since directory cookies are exclusively used - for directory iteration, and it normally doesn't make sense to have multiple - threads read the same directory concurrently. Furthermore reading a directory - should not block. Therefore for most FSs this hook is a no-op. - - \param fs The volume handle. - \param vnode The node handle. - \param cookie The directory cookie as returned by open_dir(). - \return \c B_OK if everything went fine, another error code otherwise. -*/ - -/*! - \fn status_t (*file_system_module_info::free_dir_cookie)(fs_volume fs, - fs_vnode vnode, fs_cookie cookie) - \brief Frees the given directory cookie. - - The hook is invoked after close_dir(), when no other thread uses or is going - to use the cookie. All resources associated with the cookie must be freed. - - \param fs The volume handle. - \param vnode The node handle. - \param cookie The directory cookie as returned by open_dir(). - \return \c B_OK if everything went fine, another error code otherwise. -*/ - -/*! - \fn status_t (*file_system_module_info::read_dir)(fs_volume fs, fs_vnode vnode, - fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num) - \brief Reads the next one or more directory entries. - - The number of entries to be read at maximum is stored in the variable \a _num - points to. - - Per read \c dirent the following fields have to be filled in: - - \c d_dev: The volume ID. - - \c d_ino: The ID of the node the entry refers to. - - \c d_name: The null-terminated name of the entry. - - \c d_reclen: The size of the \c dirent structure in bytes, starting from - the beginning of the structure, counting all bytes up to and including - the null-termination char of the name stored in \c d_name. - - If more than one entry is read, the corresponding \c dirent structures are - tightly packed, i.e. the second entry begins directly after the end of the - first one (i.e. \c d_reclen bytes after the beginning of the first one). - Most FSs read only one entry at a time though, even if more are requested. - - When the function is invoked after the end of the directory has been reached, - it shall set the variable \a _num points to to \c 0 and return \c B_OK. If - the provided buffer is too small to contain even the single next entry, - \c B_BUFFER_OVERFLOW shall be returned. It shall not fail, if at least one - entry has been read, and the buffer is just too small to hold as many entries - as requested. - - Note that a directory is expected to contain the special entries \c "." and - \c "..", referring to the same directory and the parent directory - respectively. The \c dirent structure returned for the \c ".." entry of the - volume's root directory shall refer to the root node itself. - - \param fs The volume handle. - \param vnode The node handle. - \param cookie The directory cookie as returned by open_dir(). - \param buffer Pointer to a pre-allocated buffer the directory entries shall - be written to. - \param bufferSize The size of \a buffer in bytes. - \param _num Pointer to a pre-allocated variable, when invoked, containing the - number of directory entries to be read, and into which the number of - entries actually read shall be written. - \return \c B_OK if everything went fine, another error code otherwise. -*/ [... truncated: 2934 lines follow ...] From jackburton at mail.berlios.de Tue Jul 17 09:58:38 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 17 Jul 2007 09:58:38 +0200 Subject: [Haiku-commits] r21628 - haiku/trunk/src/apps/terminal Message-ID: <200707170758.l6H7wcJq023951@sheep.berlios.de> Author: jackburton Date: 2007-07-17 09:58:37 +0200 (Tue, 17 Jul 2007) New Revision: 21628 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21628&view=rev Modified: haiku/trunk/src/apps/terminal/TermApp.cpp haiku/trunk/src/apps/terminal/TermParse.cpp haiku/trunk/src/apps/terminal/TermParse.h haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h haiku/trunk/src/apps/terminal/TermWindow.cpp haiku/trunk/src/apps/terminal/TermWindow.h haiku/trunk/src/apps/terminal/spawn.cpp haiku/trunk/src/apps/terminal/spawn.h Log: Encapsulated low level terminal stuff into a Shell class, which also supersedes spawn_shell(). Removed window parameter from TermParse. Since we already have a pointer to the view, we just call Window() on it (only used in one place, no need to save a pointer). Other cleanups. Modified: haiku/trunk/src/apps/terminal/TermApp.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-16 21:47:13 UTC (rev 21627) +++ haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-17 07:58:37 UTC (rev 21628) @@ -11,7 +11,7 @@ #include "CodeConv.h" #include "PrefHandler.h" -#include "spawn.h" +//#include "spawn.h" #include "TermBuffer.h" #include "TermWindow.h" #include "TermConst.h" @@ -25,13 +25,12 @@ #include #include -#include +//#include #include #include -#include -#include + // Globals PrefHandler *gTermPref; @@ -119,14 +118,8 @@ void TermApp::Quit() { - if (!sUsageRequested){ - int status; - - kill(-gShPid, SIGHUP); - wait(&status); - + if (!sUsageRequested) _UnregisterTerminal(); - } BApplication::Quit(); } Modified: haiku/trunk/src/apps/terminal/TermParse.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-16 21:47:13 UTC (rev 21627) +++ haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-17 07:58:37 UTC (rev 21628) @@ -47,12 +47,10 @@ #define NPARAM 10 // Max parameters -TermParse::TermParse(int fd, TermWindow *inWinObj, TermView *inViewObj, - CodeConv *inConvObj) +TermParse::TermParse(int fd, TermView *inViewObj, CodeConv *inConvObj) : fFd(fd), fViewObj(inViewObj), - fWinObj(inWinObj), fConvObj(inConvObj), fParseThread(-1), fParseSem(-1), @@ -807,7 +805,7 @@ switch (mode_char) { case '0': case '2': - fWinObj->SetTitle(string); + fViewObj->Window()->SetTitle(string); break; case '1': break; Modified: haiku/trunk/src/apps/terminal/TermParse.h =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.h 2007-07-16 21:47:13 UTC (rev 21627) +++ haiku/trunk/src/apps/terminal/TermParse.h 2007-07-17 07:58:37 UTC (rev 21628) @@ -39,14 +39,13 @@ class TermView; class CodeConv; -class TermWindow; //PtyReader buffer size. #define READ_BUF_SIZE 2048 class TermParse : public BHandler { public: - TermParse(int fd, TermWindow *inWinObj, TermView *inViewObj, CodeConv *inConvObj); + TermParse(int fd, TermView *inViewObj, CodeConv *inConvObj); ~TermParse(); status_t StartThreads(); @@ -72,7 +71,6 @@ int fFd; TermView *fViewObj; - TermWindow *fWinObj; CodeConv *fConvObj; thread_id fParseThread; Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-16 21:47:13 UTC (rev 21627) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-17 07:58:37 UTC (rev 21628) @@ -63,9 +63,9 @@ }; -TermView::TermView(BRect frame, CodeConv *inCodeConv, int fd) +TermView::TermView(BRect frame, CodeConv *inCodeConv) : BView(frame, "termview", B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS), - fTerminalFd(fd), + fShell(NULL), fFontWidth(0), fFontHeight(0), fFontAscent(0), @@ -122,6 +122,25 @@ } +status_t +TermView::AttachShell(Shell *shell) +{ + if (shell == NULL) + return B_BAD_VALUE; + + fShell = shell; + + return B_OK; +} + + +void +TermView::DetachShell() +{ + fShell = NULL; +} + + //! Get width and height for terminal font void TermView::GetFontSize(int* _width, int* _height) @@ -1010,11 +1029,7 @@ ScrollTo(0, fTop); ResizeScrBarRange(); - struct winsize ws; - ws.ws_row = fTermRows; - ws.ws_col = fTermColumns; - ioctl(fTerminalFd, TIOCSWINSZ, &ws); - kill(-gShPid, SIGWINCH); + fShell->UpdateWindowSize(fTermRows, fTermColumns); fFrameResized = 0; if (fScrRegionSet == 0) @@ -1033,11 +1048,11 @@ switch (n) { case 5: len = sprintf(sbuf,"\033[0n") ; - write(fTerminalFd, sbuf, len); + fShell->Write(sbuf, len); break ; case 6: len = sprintf(sbuf,"\033[%d;%dR", fTermRows, fTermColumns) ; - write(fTerminalFd, sbuf, len); + fShell->Write(sbuf, len); break ; default: return; @@ -1210,10 +1225,10 @@ // If bytes[0] equal intr charactor, // send signal to shell process group. - tcgetattr(fTerminalFd, &tio); + fShell->GetAttr(tio); if (*bytes == tio.c_cc[VINTR]) { if (tio.c_lflag & ISIG) - kill(-gShPid, SIGINT); + fShell->Signal(SIGINT); } // Terminal changes RET, ENTER, F1...F12, and ARROW key code. @@ -1224,24 +1239,24 @@ case B_RETURN: c = 0x0d; if (key == RETURN_KEY || key == ENTER_KEY) { - write(fTerminalFd, &c, 1); + fShell->Write(&c, 1); return; } else { - write(fTerminalFd, bytes, numBytes); + fShell->Write(bytes, numBytes); return; } break; case B_LEFT_ARROW: if (key == LEFT_ARROW_KEY) { - write(fTerminalFd, LEFT_ARROW_KEY_CODE, sizeof(LEFT_ARROW_KEY_CODE)-1); + fShell->Write(LEFT_ARROW_KEY_CODE, sizeof(LEFT_ARROW_KEY_CODE)-1); return; } break; case B_RIGHT_ARROW: if (key == RIGHT_ARROW_KEY) { - write(fTerminalFd, RIGHT_ARROW_KEY_CODE, sizeof(RIGHT_ARROW_KEY_CODE)-1); + fShell->Write(RIGHT_ARROW_KEY_CODE, sizeof(RIGHT_ARROW_KEY_CODE)-1); return; } break; @@ -1256,7 +1271,7 @@ } if (key == UP_ARROW_KEY) { - write(fTerminalFd, UP_ARROW_KEY_CODE, sizeof(UP_ARROW_KEY_CODE)-1); + fShell->Write(UP_ARROW_KEY_CODE, sizeof(UP_ARROW_KEY_CODE)-1); return; } break; @@ -1269,21 +1284,21 @@ } if (key == DOWN_ARROW_KEY) { - write(fTerminalFd, DOWN_ARROW_KEY_CODE, sizeof(DOWN_ARROW_KEY_CODE)-1); + fShell->Write(DOWN_ARROW_KEY_CODE, sizeof(DOWN_ARROW_KEY_CODE)-1); return; } break; case B_INSERT: if (key == INSERT_KEY) { - write(fTerminalFd, INSERT_KEY_CODE, sizeof(INSERT_KEY_CODE)-1); + fShell->Write(INSERT_KEY_CODE, sizeof(INSERT_KEY_CODE)-1); return; } break; case B_HOME: if (key == HOME_KEY) { - write(fTerminalFd, HOME_KEY_CODE, sizeof(HOME_KEY_CODE)-1); + fShell->Write(HOME_KEY_CODE, sizeof(HOME_KEY_CODE)-1); return; } break; @@ -1298,7 +1313,7 @@ } if (key == PAGE_UP_KEY) { - write(fTerminalFd, PAGE_UP_KEY_CODE, sizeof(PAGE_UP_KEY_CODE)-1); + fShell->Write(PAGE_UP_KEY_CODE, sizeof(PAGE_UP_KEY_CODE)-1); return; } break; @@ -1311,14 +1326,14 @@ } if (key == PAGE_DOWN_KEY) { - write(fTerminalFd, PAGE_DOWN_KEY_CODE, sizeof(PAGE_DOWN_KEY_CODE)-1); + fShell->Write(PAGE_DOWN_KEY_CODE, sizeof(PAGE_DOWN_KEY_CODE)-1); return; } break; case B_END: if (key == END_KEY) { - write(fTerminalFd, END_KEY_CODE, sizeof(END_KEY_CODE)-1); + fShell->Write(END_KEY_CODE, sizeof(END_KEY_CODE)-1); return; } break; @@ -1326,7 +1341,7 @@ case B_FUNCTION_KEY: for (c = 0; c < 12; c++) { if (key == function_keycode_table[c]) { - write(fTerminalFd, function_key_char_table[c], 5); + fShell->Write(function_key_char_table[c], 5); return; } } @@ -1341,12 +1356,12 @@ if (GetEncoding() != M_UTF8) { int cnum = fCodeConv->ConvertFromInternal(bytes, numBytes, (char *)dstbuf, GetEncoding()); - write(fTerminalFd, dstbuf, cnum); + fShell->Write(dstbuf, cnum); return; } } - write(fTerminalFd, bytes, numBytes); + fShell->Write(bytes, numBytes); } @@ -1428,7 +1443,7 @@ case MENU_CLEAR_ALL: DoClearAll(); - write(fTerminalFd, ctrl_l, 1); + fShell->Write(ctrl_l, 1); break; case MSGRUN_CURSOR: @@ -1589,10 +1604,10 @@ uchar *destBuffer = (uchar *)malloc(numBytes * 3); numBytes = fCodeConv->ConvertFromInternal((char*)text, numBytes, (char*)destBuffer, GetEncoding()); - write(fTerminalFd, destBuffer, numBytes); + fShell->Write(destBuffer, numBytes); free(destBuffer); } else { - write(fTerminalFd, text, numBytes); + fShell->Write(text, numBytes); } } Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2007-07-16 21:47:13 UTC (rev 21627) +++ haiku/trunk/src/apps/terminal/TermView.h 2007-07-17 07:58:37 UTC (rev 21628) @@ -44,7 +44,6 @@ #define CUROFF 0 #define CURON 1 -#define VIEW_THR_CODE 'vtcd' #define MOUSE_THR_CODE 'mtcd' #define RECT_BUF_SIZE 32 @@ -95,12 +94,16 @@ class BPopUpMenu; class BScrollBar; class BString; +class Shell; class TermView : public BView { public: - TermView(BRect frame, CodeConv *inCodeConv, int fd); + TermView(BRect frame, CodeConv *inCodeConv); ~TermView(); + status_t AttachShell(Shell *shell); + void DetachShell(); + void SetTermFont(const BFont *halfFont, const BFont *fullFont); void GetFontSize(int *width, int *height); BRect SetTermSize(int rows, int cols, bool flag); @@ -225,7 +228,7 @@ bool CheckSelectedRegion(const CurPos &pos); inline void Redraw(int, int, int, int); - int fTerminalFd; + Shell *fShell; // Font and Width BFont fHalfFont; Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-16 21:47:13 UTC (rev 21627) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-17 07:58:37 UTC (rev 21628) @@ -56,7 +56,7 @@ TermWindow::TermWindow(BRect frame, const char* title, const char *command) : BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE), - fPfd(-1), + fShell(NULL), fTermParse(NULL), fMenubar(NULL), fFilemenu(NULL), @@ -96,9 +96,10 @@ // Get encoding name (setenv TTYPE in spawn_shell functions) const char *encoding = longname2shortname(gTermPref->getString(PREF_TEXT_ENCODING)); - fPfd = spawn_shell(rows, cols, command, encoding); - if (fPfd < 0) - throw fPfd; + fShell = new Shell(); + status_t status = fShell->Open(rows, cols, command, encoding); + if (status < 0) + throw status; InitWindow(); } @@ -106,7 +107,9 @@ TermWindow::~TermWindow() { - close(fPfd); + fTermView->DetachShell(); + + delete fShell; delete fTermParse; delete fCodeConv; if (fPrefWindow) @@ -159,8 +162,10 @@ textframe.top = fMenubar->Bounds().bottom + 1.0; fCodeConv = new CodeConv(); - fTermView = new TermView(Bounds(), fCodeConv, fPfd); + fTermView = new TermView(Bounds(), fCodeConv); + fTermView->AttachShell(fShell); + /* * MuTerm has two views. BaseView is window base view. * TermView is character Terminal view on BaseView. It has paste @@ -214,7 +219,7 @@ // Initialize TermParse SetEncoding(longname2id(gTermPref->getString(PREF_TEXT_ENCODING))); - fTermParse = new TermParse(fPfd, this, fTermView, fCodeConv); + fTermParse = new TermParse(fShell->FD(), fTermView, fCodeConv); if (fTermParse->StartThreads() < B_OK) return; @@ -463,7 +468,7 @@ } else if (!strcmp("tty", spe.FindString("property", i))) { BMessage reply(B_REPLY); - reply.AddString("result", ttyname(fPfd)); + reply.AddString("result", fShell->TTYName()); message->SendReply(&reply); } else { BWindow::MessageReceived(message); Modified: haiku/trunk/src/apps/terminal/TermWindow.h =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-16 21:47:13 UTC (rev 21627) +++ haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-17 07:58:37 UTC (rev 21628) @@ -45,8 +45,8 @@ class CodeConv; class PrefWindow; class FindWindow; +class Shell; - class TermWindow : public BWindow { public: TermWindow(BRect frame, const char* title, const char *command); @@ -74,7 +74,7 @@ /* * data member */ - int fPfd; + Shell *fShell; TermParse *fTermParse; BMenuBar *fMenubar; BMenu *fFilemenu, *fEditmenu, *fEncodingmenu, *fHelpmenu, *fFontMenu, *fWindowSizeMenu, *fNewFontMenu; Modified: haiku/trunk/src/apps/terminal/spawn.cpp =================================================================== --- haiku/trunk/src/apps/terminal/spawn.cpp 2007-07-16 21:47:13 UTC (rev 21627) +++ haiku/trunk/src/apps/terminal/spawn.cpp 2007-07-17 07:58:37 UTC (rev 21628) @@ -30,21 +30,22 @@ */ #include -#include -#include +#include +#include +#include +#include #include -#include -#include #include #include -#include -#include +#include +#include +#include #include -#include -#include #include -#include +#include +#include + #include "TermConst.h" #include "spawn.h" #include "PrefHandler.h" @@ -53,18 +54,20 @@ /* default shell command and options. */ #define SHELL_COMMAND "/bin/sh -login" -extern char **environ; -const char *kSpawnAlertMessage = "alert --stop " "'Cannot execute \"%s\":\n" + +const static char *kSpawnAlertMessage = "alert --stop " "'Cannot execute \"%s\":\n" "\t%s\n'" "'Use Default Shell' 'Abort'"; /* - * Set environment varriable. + * Set environment variable. */ +#if !defined(__HAIKU__) || defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) -#if !defined(__HAIKU__) || defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) -int +extern char **environ; + +static int setenv(const char *var, const char *value, bool overwrite) { int envindex = 0; @@ -110,11 +113,11 @@ #define PTY_NG 1 /* pty open or set termios NG */ #define PTY_WS 2 /* pty need WINSIZE (row and col ) */ -/* global variables */ -pid_t gShPid; +static pid_t sShPid; + static status_t send_handshake_message(thread_id target, const handshake_t& handshake) { @@ -130,7 +133,7 @@ } -int +static int spawn_shell(int row, int col, const char *command, const char *coding) { signal(SIGTTOU, SIG_IGN); @@ -180,7 +183,7 @@ thread_id terminalThread = find_thread(NULL); /* Fork a child process. */ - if ((gShPid = fork()) < 0) { + if ((sShPid = fork()) < 0) { close(master); return -1; } @@ -188,7 +191,7 @@ handshake_t handshake; - if (gShPid == 0) { + if (sShPid == 0) { // Now in child process. /* @@ -443,7 +446,7 @@ handshake.row = row; handshake.col = col; handshake.status = PTY_WS; - send_handshake_message(gShPid, handshake); + send_handshake_message(sShPid, handshake); break; } } @@ -451,3 +454,116 @@ return (done > 0) ? master : -1; } + +static void +close_shell(int fd) +{ + if (fd < 0) + return; + + close(fd); + + int status; + kill(-sShPid, SIGHUP); + wait(&status); +} + + +Shell::Shell() + :fFd(-1) +{ +} + + +Shell::~Shell() +{ + Close(); +} + + +status_t +Shell::Open(int row, int col, const char *command, const char *coding) +{ + fFd = spawn_shell(row, col, command, coding); + if (fFd < 0) + return fFd; + + return B_OK; +} + + +void +Shell::Close() +{ + if (fFd >= 0) { + close_shell(fFd); + fFd = -1; + } +} + + +const char * +Shell::TTYName() const +{ + return ttyname(fFd); +} + + +ssize_t +Shell::Read(void *buffer, size_t numBytes) +{ + if (fFd < 0) + return B_NO_INIT; + + return read(fFd, buffer, numBytes); +} + + +ssize_t +Shell::Write(const void *buffer, size_t numBytes) +{ + if (fFd < 0) + return B_NO_INIT; + + return write(fFd, buffer, numBytes); +} + + +void +Shell::UpdateWindowSize(int rows, int columns) +{ + struct winsize winSize; + winSize.ws_row = rows; + winSize.ws_col = columns; + ioctl(fFd, TIOCSWINSZ, &winSize); + Signal(SIGWINCH); +} + + +void +Shell::Signal(int signal) +{ + kill(-sShPid, signal); +} + + +status_t +Shell::GetAttr(struct termios &attr) +{ + return tcgetattr(fFd, &attr); +} + + +status_t +Shell::SetAttr(struct termios &attr) +{ + return tcsetattr(fFd, TCSANOW, &attr); +} + + +int +Shell::FD() const +{ + return fFd; +} + Modified: haiku/trunk/src/apps/terminal/spawn.h =================================================================== --- haiku/trunk/src/apps/terminal/spawn.h 2007-07-16 21:47:13 UTC (rev 21627) +++ haiku/trunk/src/apps/terminal/spawn.h 2007-07-17 07:58:37 UTC (rev 21628) @@ -80,14 +80,30 @@ #define APC 0x9F #define RDEL 0xFF -/* - * Prototype: - */ -int spawn_shell (int, int, const char *, const char *); -void Setenv (const char *, const char *); +class Shell { +public: + Shell(); + ~Shell(); -extern pid_t gShPid; /* shell process ID */ + status_t Open(int row, int col, const char *command, const char *coding); + void Close(); + + const char * TTYName() const; + ssize_t Read(void *buffer, size_t numBytes); + ssize_t Write(const void *buffer, size_t numBytes); + void UpdateWindowSize(int row, int columns); + void Signal(int signal); + + status_t GetAttr(struct termios &attr); + status_t SetAttr(struct termios &attr); + + int FD() const; + +private: + int fFd; +}; + #endif /* SPAWN_H */ From jackburton at mail.berlios.de Tue Jul 17 10:04:37 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 17 Jul 2007 10:04:37 +0200 Subject: [Haiku-commits] r21629 - haiku/trunk/src/apps/terminal Message-ID: <200707170804.l6H84bAK024233@sheep.berlios.de> Author: jackburton Date: 2007-07-17 10:04:36 +0200 (Tue, 17 Jul 2007) New Revision: 21629 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21629&view=rev Added: haiku/trunk/src/apps/terminal/Shell.cpp haiku/trunk/src/apps/terminal/Shell.h Removed: haiku/trunk/src/apps/terminal/spawn.cpp haiku/trunk/src/apps/terminal/spawn.h Modified: haiku/trunk/src/apps/terminal/Jamfile haiku/trunk/src/apps/terminal/PrefWindow.cpp haiku/trunk/src/apps/terminal/TermApp.cpp haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermWindow.cpp Log: Renamed spawn.cpp/h to Shell.cpp/h and updated the other source files to take this change into account Modified: haiku/trunk/src/apps/terminal/Jamfile =================================================================== --- haiku/trunk/src/apps/terminal/Jamfile 2007-07-17 07:58:37 UTC (rev 21628) +++ haiku/trunk/src/apps/terminal/Jamfile 2007-07-17 08:04:36 UTC (rev 21629) @@ -15,7 +15,7 @@ PrefHandler.cpp PrefView.cpp PrefWindow.cpp - spawn.cpp + Shell.cpp TermApp.cpp TermBaseView.cpp TermBuffer.cpp Modified: haiku/trunk/src/apps/terminal/PrefWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/PrefWindow.cpp 2007-07-17 07:58:37 UTC (rev 21628) +++ haiku/trunk/src/apps/terminal/PrefWindow.cpp 2007-07-17 08:04:36 UTC (rev 21629) @@ -11,7 +11,7 @@ #include "PrefHandler.h" #include "PrefWindow.h" #include "PrefView.h" -#include "spawn.h" +#include "Shell.h" #include "TermConst.h" #include Copied: haiku/trunk/src/apps/terminal/Shell.cpp (from rev 21628, haiku/trunk/src/apps/terminal/spawn.cpp) =================================================================== --- haiku/trunk/src/apps/terminal/spawn.cpp 2007-07-17 07:58:37 UTC (rev 21628) +++ haiku/trunk/src/apps/terminal/Shell.cpp 2007-07-17 08:04:36 UTC (rev 21629) @@ -0,0 +1,569 @@ +/* + * Copyright (c) 2003-4 Kian Duffy + * Copyright (c) 2004 Daniel Furrer + * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files or portions + * thereof (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice + * in the binary, as well as this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "TermConst.h" +#include "Shell.h" +#include "PrefHandler.h" + +extern PrefHandler *gTermPref; + +/* default shell command and options. */ +#define SHELL_COMMAND "/bin/sh -login" + + +const static char *kSpawnAlertMessage = "alert --stop " "'Cannot execute \"%s\":\n" + "\t%s\n'" + "'Use Default Shell' 'Abort'"; + +/* + * Set environment variable. + */ +#if !defined(__HAIKU__) || defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) + +extern char **environ; + +static int +setenv(const char *var, const char *value, bool overwrite) +{ + int envindex = 0; + const int len = strlen(var); + const int val_len = strlen (value); + + while (environ[envindex] != NULL) { + if (!strncmp(environ[envindex], var, len)) { + /* found it */ + if (overwrite) { + environ[envindex] = (char *)malloc((unsigned)len + val_len + 2); + snprintf(environ[envindex], "%s=%s", var, value); + } + return 0; + } + envindex++; + } + + environ[envindex] = (char *)malloc((unsigned)len + val_len + 2); + sprintf(environ[envindex], "%s=%s", var, value); + environ[++envindex] = NULL; + return 0; +} +#endif + + +/* + * spawn_shell(): spawn child process, create pty master/slave device and + * execute SHELL program. + */ + +/* handshake interface */ +typedef struct +{ + int status; /* status of child */ + char msg[128]; /* error message */ + int row; /* terminal rows */ + int col; /* Terminal columns */ +} handshake_t; + +/* status of handshake */ +#define PTY_OK 0 /* pty open and set termios OK */ +#define PTY_NG 1 /* pty open or set termios NG */ +#define PTY_WS 2 /* pty need WINSIZE (row and col ) */ + + + +static pid_t sShPid; + + +static status_t +send_handshake_message(thread_id target, const handshake_t& handshake) +{ + return send_data(target, 0, &handshake, sizeof(handshake_t)); +} + + +static void +receive_handshake_message(handshake_t& handshake) +{ + thread_id sender; + receive_data(&sender, &handshake, sizeof(handshake_t)); +} + + +static int +spawn_shell(int row, int col, const char *command, const char *coding) +{ + signal(SIGTTOU, SIG_IGN); + + /* + * Get a pseudo-tty. We do this by cycling through files in the + * directory. The oparationg system will not allow us to open a master + * which is already in use, so we simply go until the open succeeds. + */ + char ttyName[B_PATH_NAME_LENGTH]; + int master = -1; + DIR *dir = opendir("/dev/pt/"); + if (dir != NULL) { + struct dirent *dirEntry; + while ((dirEntry = readdir(dir)) != NULL) { + // skip '.' and '..' + if (dirEntry->d_name[0] == '.') + continue; + + char ptyName[B_PATH_NAME_LENGTH]; + snprintf(ptyName, sizeof(ptyName), "/dev/pt/%s", dirEntry->d_name); + + master = open(ptyName, O_RDWR); + if (master >= 0) { + // Set the tty that corresponds to the pty we found + snprintf(ttyName, sizeof(ttyName), "/dev/tt/%s", dirEntry->d_name); + break; + } else { + // B_BUSY is a normal case + if (errno != B_BUSY) + fprintf(stderr, "could not open %s: %s\n", ptyName, strerror(errno)); + } + } + closedir(dir); + } + + if (master < 0) { + printf("didn't find any available pseudo ttys."); + return -1; + } + + /* + * Get the modes of the current terminal. We will duplicates these + * on the pseudo terminal. + */ + + thread_id terminalThread = find_thread(NULL); + + /* Fork a child process. */ + if ((sShPid = fork()) < 0) { + close(master); + return -1; + } + + + handshake_t handshake; + + if (sShPid == 0) { + // Now in child process. + + /* + * Make our controlling tty the pseudo tty. This hapens because + * we cleared our original controlling terminal above. + */ + + /* Set process session leader */ + if (setsid() < 0) { + handshake.status = PTY_NG; + snprintf(handshake.msg, sizeof(handshake.msg), + "could not set session leader."); + send_handshake_message(terminalThread, handshake); + exit(1); + } + + /* change pty owner and access mode. */ + chown(ttyName, getuid(), getgid()); + chmod(ttyName, S_IRUSR | S_IWUSR); + + /* open slave pty */ + int slave = -1; + if ((slave = open(ttyName, O_RDWR)) < 0) { + handshake.status = PTY_NG; + snprintf(handshake.msg, sizeof(handshake.msg), + "can't open tty (%s).", ttyName); + send_handshake_message(terminalThread, handshake); + exit(1); + } + + struct termios tio; + + /* get tty termios (not necessary). + * TODO: so why are we doing it ? + */ + tcgetattr(slave, &tio); + + /* set signal default */ + signal(SIGCHLD, SIG_DFL); + signal(SIGHUP, SIG_DFL); + signal(SIGQUIT, SIG_DFL); + signal(SIGTERM, SIG_DFL); + signal(SIGINT, SIG_DFL); + signal(SIGTTOU, SIG_DFL); + + /* + * Set Terminal interface. + */ + + tio.c_line = 0; + tio.c_lflag |= ECHOE; + + /* input: nl->nl, cr->nl */ + tio.c_iflag &= ~(INLCR|IGNCR); + tio.c_iflag |= ICRNL; + tio.c_iflag &= ~ISTRIP; + + /* output: cr->cr, nl in not retrun, no delays, ln->cr/ln */ + tio.c_oflag &= ~(OCRNL|ONLRET|NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY); + tio.c_oflag |= ONLCR; + tio.c_oflag |= OPOST; + + /* baud rate is 19200 (equal beterm) */ + tio.c_cflag &= ~(CBAUD); + tio.c_cflag |= B19200; + + tio.c_cflag &= ~CSIZE; + tio.c_cflag |= CS8; + tio.c_cflag |= CREAD; + + tio.c_cflag |= HUPCL; + tio.c_iflag &= ~(IGNBRK|BRKINT); + + /* + * enable signals, canonical processing (erase, kill, etc), echo. + */ + tio.c_lflag |= ISIG|ICANON|ECHO|ECHOE|ECHONL; + tio.c_lflag &= ~(ECHOK | IEXTEN); + + /* set control characters. */ + tio.c_cc[VINTR] = 'C' & 0x1f; /* '^C' */ + tio.c_cc[VQUIT] = CQUIT; /* '^\' */ + tio.c_cc[VERASE] = 0x08; /* '^H' */ + tio.c_cc[VKILL] = 'U' & 0x1f; /* '^U' */ + tio.c_cc[VEOF] = CEOF; /* '^D' */ + tio.c_cc[VEOL] = CEOL; /* '^@' */ + tio.c_cc[VMIN] = 4; + tio.c_cc[VTIME] = 0; + tio.c_cc[VEOL2] = CEOL; /* '^@' */ + tio.c_cc[VSWTCH] = CSWTCH; /* '^@' */ + tio.c_cc[VSTART] = CSTART; /* '^S' */ + tio.c_cc[VSTOP] = CSTOP; /* '^Q' */ + tio.c_cc[VSUSP] = CSUSP; /* '^@' */ + + /* + * change control tty. + */ + + dup2(slave, 0); + dup2(slave, 1); + dup2(slave, 2); + + /* close old slave fd. */ + if (slave > 2) + close(slave); + + /* + * set terminal interface. + */ + if (tcsetattr (0, TCSANOW, &tio) == -1) { + handshake.status = PTY_NG; + snprintf(handshake.msg, sizeof(handshake.msg), + "failed set terminal interface (TERMIOS)."); + send_handshake_message(terminalThread, handshake); + exit(1); + } + + /* + * set window size. + */ + + handshake.status = PTY_WS; + send_handshake_message(terminalThread, handshake); + receive_handshake_message(handshake); + + if (handshake.status != PTY_WS) { + handshake.status = PTY_NG; + snprintf(handshake.msg, sizeof(handshake.msg), + "mismatch handshake."); + send_handshake_message(terminalThread, handshake); + exit(1); + } + + struct winsize ws; + + ws.ws_row = handshake.row; + ws.ws_col = handshake.col; + + ioctl(0, TIOCSWINSZ, &ws); + + /* + * Set process group ID to process, and Terminal Process group ID + * to this process group ID (equal process ID). + */ + + pid_t processGroup = getpid(); + if (setpgid(processGroup, processGroup) < 0) { + handshake.status = PTY_NG; + snprintf(handshake.msg, sizeof(handshake.msg), + "can't set process group id."); + send_handshake_message(terminalThread, handshake); + exit(1); + } + tcsetpgrp(0, processGroup); + + /* pty open and set termios successful. */ + handshake.status = PTY_OK; + send_handshake_message(terminalThread, handshake); + + /* + * setenv TERM and TTY. + */ + setenv("TERM", "beterm", true); + setenv("TTY", ttyName, true); + setenv("TTYPE", coding, true); + + /* + * If don't set command args, exec SHELL_COMMAND. + */ + if (command == NULL) + command = SHELL_COMMAND; + + /* + * split up the arguments in the command into an artv-like structure. + */ + char commandLine[256]; + memcpy(commandLine, command, 256); + char *ptr = commandLine; + char *args[16]; + int i = 0; + while (*ptr) { + /* Skip white space */ + while ((*ptr == ' ') || (*ptr == '\t')) + *ptr++ = 0; + args[i++] = ptr; + + /* Skip over this word to next white space. */ + while ((*ptr != 0) && (*ptr != ' ') && (*ptr != '\t')) + ptr++; + } + + args[i] = NULL; + + setenv("SHELL", *args, true); + +#if 0 + /* + * Print Welcome Message. + * (But, Only print message when MuTerminal coding is UTF8.) + */ + + time_t now_time_t = time(NULL); + struct tm *now_time = localtime (&now_time_t); + int now_hour = 0; + if (now_time->tm_hour >= 5 && now_time->tm_hour < 11) { + now_hour = 0; + } else if (now_time->tm_hour >= 11 && now_time->tm_hour <= 18 ) { + now_hour = 1; + } else { + now_hour = 2; + } +#endif + execve(*args, args, environ); + + /* + * Exec failed. + */ + sleep(1); + char errorMessage[256]; + snprintf(errorMessage, sizeof(errorMessage), kSpawnAlertMessage, commandLine, strerror(errno)); + + if (system(errorMessage) == 0) + execl("/bin/sh", "/bin/sh", "-login", NULL); + + exit(1); + } + + /* + * In parent Process, Set up the input and output file pointers so + * that they can write and read the pseudo terminal. + */ + + /* + * close parent control tty. + */ + + int done = 0; + while (!done) { + receive_handshake_message(handshake); + + switch (handshake.status) { + case PTY_OK: + done = 1; + break; + + case PTY_NG: + printf("%s\n", handshake.msg); + done = -1; + break; + + case PTY_WS: + handshake.row = row; + handshake.col = col; + handshake.status = PTY_WS; + send_handshake_message(sShPid, handshake); + break; + } + } + + return (done > 0) ? master : -1; +} + + +static void +close_shell(int fd) +{ + if (fd < 0) + return; + + close(fd); + + int status; + kill(-sShPid, SIGHUP); + wait(&status); +} + + +Shell::Shell() + :fFd(-1) +{ +} + + +Shell::~Shell() +{ + Close(); +} + + +status_t +Shell::Open(int row, int col, const char *command, const char *coding) +{ + fFd = spawn_shell(row, col, command, coding); + if (fFd < 0) + return fFd; + + return B_OK; +} + + +void +Shell::Close() +{ + if (fFd >= 0) { + close_shell(fFd); + fFd = -1; + } +} + + +const char * +Shell::TTYName() const +{ + return ttyname(fFd); +} + + +ssize_t +Shell::Read(void *buffer, size_t numBytes) +{ + if (fFd < 0) + return B_NO_INIT; + + return read(fFd, buffer, numBytes); +} + + +ssize_t +Shell::Write(const void *buffer, size_t numBytes) +{ + if (fFd < 0) + return B_NO_INIT; + + return write(fFd, buffer, numBytes); +} + + +void +Shell::UpdateWindowSize(int rows, int columns) +{ + struct winsize winSize; + winSize.ws_row = rows; + winSize.ws_col = columns; + ioctl(fFd, TIOCSWINSZ, &winSize); + Signal(SIGWINCH); +} + + +void +Shell::Signal(int signal) +{ + kill(-sShPid, signal); +} + + +status_t +Shell::GetAttr(struct termios &attr) +{ + return tcgetattr(fFd, &attr); +} + + +status_t +Shell::SetAttr(struct termios &attr) +{ + return tcsetattr(fFd, TCSANOW, &attr); +} + + +int +Shell::FD() const +{ + return fFd; +} + Copied: haiku/trunk/src/apps/terminal/Shell.h (from rev 21628, haiku/trunk/src/apps/terminal/spawn.h) =================================================================== --- haiku/trunk/src/apps/terminal/spawn.h 2007-07-17 07:58:37 UTC (rev 21628) +++ haiku/trunk/src/apps/terminal/Shell.h 2007-07-17 08:04:36 UTC (rev 21629) @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2003-4 Kian Duffy + * Copyright (c) 2004 Daniel Furrer + * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files or portions + * thereof (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice + * in the binary, as well as this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#ifndef _SHELL_H +#define _SHELL_H + +#define MAXPTTYS 16 * 4 + +#ifndef CEOF +#define CEOF ('D'&037) +#endif +#ifndef CSUSP +#define CSUSP ('@'&037) +#endif +#ifndef CQUIT +#define CQUIT ('\\'&037) +#endif +#ifndef CEOL +#define CEOL 0 +#endif +#ifndef CSTOP +#define CSTOP ('Q'&037) +#endif +#ifndef CSTART +#define CSTART ('S'&037) +#endif +#ifndef CSWTCH +#define CSWTCH 0 +#endif + +/* + * ANSI emulation. + */ +#define INQ 0x05 +#define FF 0x0C /* C0, C1 control names */ +#define LS1 0x0E +#define LS0 0x0F +#define CAN 0x18 +#define SUB 0x1A +#define ESC 0x1B +#define US 0x1F +#define DEL 0x7F +#define HTS ('H'+0x40) +#define SS2 0x8E +#define SS3 0x8F +#define DCS 0x90 +#define OLDID 0x9A /* ESC Z */ +#define CSI 0x9B +#define ST 0x9C +#define OSC 0x9D +#define PM 0x9E +#define APC 0x9F +#define RDEL 0xFF + + +class Shell { +public: + Shell(); + ~Shell(); + + status_t Open(int row, int col, const char *command, const char *coding); + void Close(); + + const char * TTYName() const; + + ssize_t Read(void *buffer, size_t numBytes); + ssize_t Write(const void *buffer, size_t numBytes); + + void UpdateWindowSize(int row, int columns); + void Signal(int signal); + + status_t GetAttr(struct termios &attr); + status_t SetAttr(struct termios &attr); + + int FD() const; + +private: + int fFd; +}; + +#endif // _SHELL_H Modified: haiku/trunk/src/apps/terminal/TermApp.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-17 07:58:37 UTC (rev 21628) +++ haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-17 08:04:36 UTC (rev 21629) @@ -11,7 +11,6 @@ #include "CodeConv.h" #include "PrefHandler.h" -//#include "spawn.h" #include "TermBuffer.h" #include "TermWindow.h" #include "TermConst.h" @@ -25,7 +24,6 @@ #include #include -//#include #include #include Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-17 07:58:37 UTC (rev 21628) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-17 08:04:36 UTC (rev 21629) @@ -22,7 +22,7 @@ #include "PrefHandler.h" #include "MenuUtil.h" #include "PrefView.h" -#include "spawn.h" +#include "Shell.h" #include #include Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-17 07:58:37 UTC (rev 21628) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-17 08:04:36 UTC (rev 21629) @@ -40,7 +40,7 @@ #include "TermView.h" #include "TermWindow.h" #include "TermConst.h" -#include "spawn.h" +#include "Shell.h" // Global Preference Handler Deleted: haiku/trunk/src/apps/terminal/spawn.cpp Deleted: haiku/trunk/src/apps/terminal/spawn.h From jackburton at mail.berlios.de Tue Jul 17 11:14:46 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 17 Jul 2007 11:14:46 +0200 Subject: [Haiku-commits] r21630 - haiku/trunk/src/apps/terminal Message-ID: <200707170914.l6H9Ekg0028607@sheep.berlios.de> Author: jackburton Date: 2007-07-17 11:14:44 +0200 (Tue, 17 Jul 2007) New Revision: 21630 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21630&view=rev Modified: haiku/trunk/src/apps/terminal/AppearPrefView.cpp haiku/trunk/src/apps/terminal/ColorWindow.cpp haiku/trunk/src/apps/terminal/MenuUtil.cpp haiku/trunk/src/apps/terminal/PrefHandler.cpp haiku/trunk/src/apps/terminal/PrefHandler.h haiku/trunk/src/apps/terminal/PrefWindow.cpp haiku/trunk/src/apps/terminal/Shell.cpp haiku/trunk/src/apps/terminal/ShellPrefView.cpp haiku/trunk/src/apps/terminal/TermApp.cpp haiku/trunk/src/apps/terminal/TermBuffer.cpp haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermWindow.cpp haiku/trunk/src/apps/terminal/TermWindow.h Log: Got rid of gTermPref by adding some static methods to PrefHandler. The font size menu wasn't up to date with the current settings. Fixed. Modified: haiku/trunk/src/apps/terminal/AppearPrefView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/AppearPrefView.cpp 2007-07-17 08:04:36 UTC (rev 21629) +++ haiku/trunk/src/apps/terminal/AppearPrefView.cpp 2007-07-17 09:14:44 UTC (rev 21630) @@ -27,13 +27,13 @@ fAppearancePrefViewMessenger(messenger) { const char *color_tbl[] = { - PREF_TEXT_FORE_COLOR, - PREF_TEXT_BACK_COLOR, - PREF_CURSOR_FORE_COLOR, - PREF_CURSOR_BACK_COLOR, - PREF_SELECT_FORE_COLOR, - PREF_SELECT_BACK_COLOR, - NULL + PREF_TEXT_FORE_COLOR, + PREF_TEXT_BACK_COLOR, + PREF_CURSOR_FORE_COLOR, + PREF_CURSOR_BACK_COLOR, + PREF_SELECT_FORE_COLOR, + PREF_SELECT_BACK_COLOR, + NULL }; float fontDividerSize = StringWidth("Font:") + 8.0; @@ -42,13 +42,14 @@ BRect r(5, 5, 225, 25); BMenu *menu = _MakeFontMenu(MSG_HALF_FONT_CHANGED, - gTermPref->getString(PREF_HALF_FONT_FAMILY)); + PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY)); fFont = new BMenuField(r, "font", "Font:", menu, B_WILL_DRAW); fFont->SetDivider(fontDividerSize); AddChild(fFont); r.OffsetBy(r.Width() + 10, 0); - menu = _MakeSizeMenu(MSG_HALF_SIZE_CHANGED, 12); + menu = _MakeSizeMenu(MSG_HALF_SIZE_CHANGED, + atoi(PrefHandler::Default()->getString(PREF_HALF_FONT_SIZE))); fFontSize = new BMenuField(r, "size", "Size:", menu, B_WILL_DRAW); fFontSize->SetDivider(sizeDividerSize); AddChild(fFontSize); @@ -61,7 +62,7 @@ fColorControl = SetupBColorControl(BPoint(r.left, r.bottom + 10), B_CELLS_32x8, 6, MSG_COLOR_CHANGED); - fColorControl->SetValue(gTermPref->getRGB(PREF_TEXT_FORE_COLOR)); + fColorControl->SetValue(PrefHandler::Default()->getRGB(PREF_TEXT_FORE_COLOR)); } @@ -80,10 +81,10 @@ AppearancePrefView::Revert() { fColorField->Menu()->ItemAt(0)->SetMarked(true); - fColorControl->SetValue(gTermPref->getRGB(PREF_TEXT_FORE_COLOR)); + fColorControl->SetValue(PrefHandler::Default()->getRGB(PREF_TEXT_FORE_COLOR)); - fFont->Menu()->FindItem(gTermPref->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true); - fFontSize->Menu()->FindItem(gTermPref->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true); + fFont->Menu()->FindItem(PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true); + fFontSize->Menu()->FindItem(PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true); } @@ -105,25 +106,25 @@ switch (msg->what) { case MSG_HALF_FONT_CHANGED: - gTermPref->setString (PREF_HALF_FONT_FAMILY, + PrefHandler::Default()->setString (PREF_HALF_FONT_FAMILY, fFont->Menu()->FindMarked()->Label()); modified = true; break; case MSG_HALF_SIZE_CHANGED: - gTermPref->setString(PREF_HALF_FONT_SIZE, + PrefHandler::Default()->setString(PREF_HALF_FONT_SIZE, fFontSize->Menu()->FindMarked()->Label()); modified = true; break; case MSG_COLOR_CHANGED: - gTermPref->setRGB(fColorField->Menu()->FindMarked()->Label(), + PrefHandler::Default()->setRGB(fColorField->Menu()->FindMarked()->Label(), fColorControl->ValueAsColor()); modified = true; break; case MSG_COLOR_FIELD_CHANGED: - fColorControl->SetValue(gTermPref->getRGB( + fColorControl->SetValue(PrefHandler::Default()->getRGB( fColorField->Menu()->FindMarked()->Label())); break; Modified: haiku/trunk/src/apps/terminal/ColorWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/ColorWindow.cpp 2007-07-17 08:04:36 UTC (rev 21629) +++ haiku/trunk/src/apps/terminal/ColorWindow.cpp 2007-07-17 09:14:44 UTC (rev 21630) @@ -110,7 +110,7 @@ BColorControl* controller = new BColorControl(BPoint(10, 45), B_CELLS_32x8, 6, "Terminal Color Controller", new BMessage(MSG_COLOR_CHANGED)); icon->AddChild(controller); - controller->SetValue(gTermPref->getRGB(PREF_TEXT_FORE_COLOR)); + controller->SetValue(PrefHandler::Default()->getRGB(PREF_TEXT_FORE_COLOR)); @@ -138,14 +138,14 @@ { case MSG_COLOR_CHANGED: - gTermPref->setRGB(workspaceMenuField->Menu()->FindMarked()->Label(), + PrefHandler::Default()->setRGB(workspaceMenuField->Menu()->FindMarked()->Label(), controller->ValueAsColor()); modified = true; break; case MSG_COLOR_FIELD_CHANGED: controller->SetValue - (gTermPref->getRGB (workspaceMenuField->Menu()->FindMarked()->Label())); + (PrefHandler::Default()->getRGB (workspaceMenuField->Menu()->FindMarked()->Label())); break; Modified: haiku/trunk/src/apps/terminal/MenuUtil.cpp =================================================================== --- haiku/trunk/src/apps/terminal/MenuUtil.cpp 2007-07-17 08:04:36 UTC (rev 21629) +++ haiku/trunk/src/apps/terminal/MenuUtil.cpp 2007-07-17 09:14:44 UTC (rev 21630) @@ -19,8 +19,6 @@ #include "PrefHandler.h" #include "Coding.h" -extern PrefHandler *gTermPref; - //#define LOCALE_FILE_DIR PREF_FOLDER"menu/" BPopUpMenu * @@ -68,7 +66,7 @@ char name[B_PATH_NAME_LENGTH]; const char *locale; - locale = gTermPref->getString(PREF_GUI_LANGUAGE); + locale = PrefHandler::Default()->getString(PREF_GUI_LANGUAGE); // TODO: this effectively disables any locale support - which is okay for now sprintf(name, "%s%s", /*LOCALE_FILE_DIR*/"", locale); Modified: haiku/trunk/src/apps/terminal/PrefHandler.cpp =================================================================== --- haiku/trunk/src/apps/terminal/PrefHandler.cpp 2007-07-17 08:04:36 UTC (rev 21629) +++ haiku/trunk/src/apps/terminal/PrefHandler.cpp 2007-07-17 09:14:44 UTC (rev 21630) @@ -64,6 +64,9 @@ }; +PrefHandler *PrefHandler::sPrefHandler = NULL; + + PrefHandler::PrefHandler() : fContainer('Pref') @@ -91,6 +94,34 @@ /* static */ +PrefHandler * +PrefHandler::Default() +{ + if (sPrefHandler == NULL) + sPrefHandler = new PrefHandler(); + return sPrefHandler; +} + + +/* static */ +void +PrefHandler::DeleteDefault() +{ + delete sPrefHandler; + sPrefHandler = NULL; +} + + +/* static */ +void +PrefHandler::SetDefault(PrefHandler *prefHandler) +{ + DeleteDefault(); + sPrefHandler = prefHandler; +} + + +/* static */ status_t PrefHandler::GetDefaultPath(BPath& path) { Modified: haiku/trunk/src/apps/terminal/PrefHandler.h =================================================================== --- haiku/trunk/src/apps/terminal/PrefHandler.h 2007-07-17 08:04:36 UTC (rev 21629) +++ haiku/trunk/src/apps/terminal/PrefHandler.h 2007-07-17 09:14:44 UTC (rev 21630) @@ -61,6 +61,10 @@ PrefHandler(); ~PrefHandler(); + static PrefHandler *Default(); + static void DeleteDefault(); + static void SetDefault(PrefHandler *handler); + status_t Open(const char *name); status_t OpenText(const char *path); status_t Save(const char *name); @@ -90,6 +94,8 @@ status_t _LoadFromTextFile(const char * path); BMessage fContainer; + + static PrefHandler *sPrefHandler; }; #endif // PREF_HANDLER_H Modified: haiku/trunk/src/apps/terminal/PrefWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/PrefWindow.cpp 2007-07-17 08:04:36 UTC (rev 21629) +++ haiku/trunk/src/apps/terminal/PrefWindow.cpp 2007-07-17 09:14:44 UTC (rev 21630) @@ -24,14 +24,11 @@ #include -extern PrefHandler *gTermPref; - // Global Preference Handler - PrefWindow::PrefWindow(BMessenger messenger) : BWindow(_CenteredRect(BRect(0, 0, 350, 215)), "Terminal Settings", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_RESIZABLE|B_NOT_ZOOMABLE), - fPrefTemp(new PrefHandler(gTermPref)), + fPrefTemp(new PrefHandler(PrefHandler::Default())), fSavePanel(NULL), fDirty(false), fPrefDlgMessenger(messenger) @@ -140,7 +137,7 @@ BDirectory dir(&dirref); BPath path(&dir, filename); - gTermPref->SaveAsText(path.Path(), PREFFILE_MIMETYPE, TERM_SIGNATURE); + PrefHandler::Default()->SaveAsText(path.Path(), PREFFILE_MIMETYPE, TERM_SIGNATURE); } @@ -148,11 +145,11 @@ PrefWindow::_Save() { delete fPrefTemp; - fPrefTemp = new PrefHandler(gTermPref); + fPrefTemp = new PrefHandler(PrefHandler::Default()); BPath path; if (PrefHandler::GetDefaultPath(path) == B_OK) { - gTermPref->SaveAsText(path.Path(), PREFFILE_MIMETYPE); + PrefHandler::Default()->SaveAsText(path.Path(), PREFFILE_MIMETYPE); fDirty = false; } } @@ -161,8 +158,7 @@ void PrefWindow::_Revert() { - delete gTermPref; - gTermPref = new PrefHandler(fPrefTemp); + PrefHandler::SetDefault(new PrefHandler(fPrefTemp)); fPrefDlgMessenger.SendMessage(MSG_HALF_FONT_CHANGED); fPrefDlgMessenger.SendMessage(MSG_COLOR_CHANGED); Modified: haiku/trunk/src/apps/terminal/Shell.cpp =================================================================== --- haiku/trunk/src/apps/terminal/Shell.cpp 2007-07-17 08:04:36 UTC (rev 21629) +++ haiku/trunk/src/apps/terminal/Shell.cpp 2007-07-17 09:14:44 UTC (rev 21630) @@ -50,8 +50,6 @@ #include "Shell.h" #include "PrefHandler.h" -extern PrefHandler *gTermPref; - /* default shell command and options. */ #define SHELL_COMMAND "/bin/sh -login" Modified: haiku/trunk/src/apps/terminal/ShellPrefView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/ShellPrefView.cpp 2007-07-17 08:04:36 UTC (rev 21629) +++ haiku/trunk/src/apps/terminal/ShellPrefView.cpp 2007-07-17 09:14:44 UTC (rev 21630) @@ -25,7 +25,7 @@ #include "TTextControl.h" -extern PrefHandler *gTermPref; +extern PrefHandler *PrefHandler::Default(); ShellPrefView::ShellPrefView(BRect frame, const char *name, @@ -37,26 +37,26 @@ mCols = new TTextControl(BRect(0, 0, 160, 20), "cols", "Columns", "", new BMessage(MSG_COLS_CHANGED)); AddChild(mCols); - mCols->SetText(gTermPref->getString(PREF_COLS)); + mCols->SetText(PrefHandler::Default()->getString(PREF_COLS)); mRows = new TTextControl(BRect(0, 30, 160, 50), "rows", "Rows", "", new BMessage(MSG_ROWS_CHANGED)); AddChild(mRows); - mRows->SetText(gTermPref->getString(PREF_ROWS)); + mRows->SetText(PrefHandler::Default()->getString(PREF_ROWS)); mHistory = new TTextControl(BRect(0, 60, 160, 80), "history", "History", "", new BMessage(MSG_HISTORY_CHANGED)); AddChild(mHistory); - mHistory->SetText(gTermPref->getString(PREF_HISTORY_SIZE)); + mHistory->SetText(PrefHandler::Default()->getString(PREF_HISTORY_SIZE)); } void ShellPrefView::Revert() { - mCols->SetText(gTermPref->getString(PREF_COLS)); - mRows->SetText(gTermPref->getString(PREF_ROWS)); - mHistory->SetText(gTermPref->getString(PREF_HISTORY_SIZE)); + mCols->SetText(PrefHandler::Default()->getString(PREF_COLS)); + mRows->SetText(PrefHandler::Default()->getString(PREF_ROWS)); + mHistory->SetText(PrefHandler::Default()->getString(PREF_HISTORY_SIZE)); } @@ -66,17 +66,17 @@ BMessenger messenger(fTermWindow); if (mCols->IsModified()) { - gTermPref->setString(PREF_COLS, mCols->Text()); + PrefHandler::Default()->setString(PREF_COLS, mCols->Text()); messenger.SendMessage(MSG_COLS_CHANGED); mCols->ModifiedText(false); } if (mRows->IsModified()) { - gTermPref->setString(PREF_ROWS, mRows->Text()); + PrefHandler::Default()->setString(PREF_ROWS, mRows->Text()); messenger.SendMessage(MSG_ROWS_CHANGED); mRows->ModifiedText(false); } //if (mShell->IsModified()) - // gTermPref->setString (PREF_SHELL, mShell->Text()); + // PrefHandler::Default()->setString (PREF_SHELL, mShell->Text()); if (mHistory->IsModified()) { int size = atoi(mHistory->Text()); @@ -85,7 +85,7 @@ if (size > 1048575) mHistory->SetText("1048575"); - gTermPref->setString (PREF_HISTORY_SIZE, mHistory->Text()); + PrefHandler::Default()->setString (PREF_HISTORY_SIZE, mHistory->Text()); } } @@ -120,10 +120,10 @@ case MSG_COLS_CHANGED: size = atoi (mCols->Text()); if (size >= MAX_COLS || size < MIN_COLS) { - mCols->SetText (gTermPref->getString (PREF_COLS)); + mCols->SetText (PrefHandler::Default()->getString (PREF_COLS)); beep (); } else { - gTermPref->setString (PREF_COLS, mCols->Text()); + PrefHandler::Default()->setString (PREF_COLS, mCols->Text()); modified = true; } break; @@ -131,16 +131,16 @@ case MSG_ROWS_CHANGED: size = atoi (mRows->Text()); if (size >= MAX_COLS || size < MIN_COLS) { - mRows->SetText(gTermPref->getString(PREF_ROWS)); + mRows->SetText(PrefHandler::Default()->getString(PREF_ROWS)); beep (); } else { - gTermPref->setString(PREF_ROWS, mRows->Text()); + PrefHandler::Default()->setString(PREF_ROWS, mRows->Text()); modified = true; } break; // case MSG_SHELL_CHANGED: -// gTermPref->setString (PREF_SHELL, mShell->Text()); +// PrefHandler::Default()->setString (PREF_SHELL, mShell->Text()); // Window()->PostMessage(MSG_PREF_MODIFIED); // break; @@ -148,10 +148,10 @@ size = atoi(mHistory->Text()); if (size < 512 || size > 1048575) { - mHistory->SetText(gTermPref->getString(PREF_HISTORY_SIZE)); + mHistory->SetText(PrefHandler::Default()->getString(PREF_HISTORY_SIZE)); beep (); } else { - gTermPref->setString(PREF_HISTORY_SIZE, mHistory->Text()); + PrefHandler::Default()->setString(PREF_HISTORY_SIZE, mHistory->Text()); Window()->PostMessage(MSG_PREF_MODIFIED); } break; Modified: haiku/trunk/src/apps/terminal/TermApp.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-17 08:04:36 UTC (rev 21629) +++ haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-17 09:14:44 UTC (rev 21630) @@ -28,10 +28,6 @@ #include - -// Globals -PrefHandler *gTermPref; - static bool sUsageRequested = false; static bool sGeometryRequested = false; @@ -77,14 +73,11 @@ int l = (j * 16) + 50; fTermFrame.Set(k, l, k + 50, k + 50); - - gTermPref = new PrefHandler(); } TermApp::~TermApp() { - delete gTermPref; } @@ -198,7 +191,7 @@ // Load preference file if (argmatch(argv, argc, "-p", "--preference", 4, &value, &skip_args)) - gTermPref->Open(value); + PrefHandler::Default()->Open(value); // Set window title if (argmatch(argv ,argc, "-t", "--title", 3, &value, &skip_args)) @@ -216,8 +209,8 @@ sUsageRequested = true; PostMessage(B_QUIT_REQUESTED); } - gTermPref->setInt32(PREF_COLS, width); - gTermPref->setInt32(PREF_ROWS, height); + PrefHandler::Default()->setInt32(PREF_COLS, width); + PrefHandler::Default()->setInt32(PREF_ROWS, height); fTermFrame.Set(xpos, ypos, xpos + 50, ypos + 50); sGeometryRequested = true; @@ -268,7 +261,7 @@ BEntry ent(&ref); BPath path(&ent); - gTermPref->OpenText(path.Path()); + PrefHandler::Default()->OpenText(path.Path()); return; } @@ -288,7 +281,7 @@ if (fCommandLine.Length() > 0) command = fCommandLine.String(); else - command = gTermPref->getString(PREF_SHELL); + command = PrefHandler::Default()->getString(PREF_SHELL); try { fTermWindow = new TermWindow(frame, fWindowTitle.String(), command); Modified: haiku/trunk/src/apps/terminal/TermBuffer.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermBuffer.cpp 2007-07-17 08:04:36 UTC (rev 21629) +++ haiku/trunk/src/apps/terminal/TermBuffer.cpp 2007-07-17 09:14:44 UTC (rev 21630) @@ -90,9 +90,6 @@ #define ROW(x) (((x) + fRowOffset) % fBufferSize) -extern PrefHandler *gTermPref; - - TermBuffer::TermBuffer(int rows, int cols) { if (rows < 1) @@ -111,7 +108,7 @@ fSelStart.Set(-1,-1); fSelEnd.Set(-1,-1); - fBufferSize = gTermPref->getInt32(PREF_HISTORY_SIZE); + fBufferSize = PrefHandler::Default()->getInt32(PREF_HISTORY_SIZE); if (fBufferSize < 1000) fBufferSize = 1000; Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-17 08:04:36 UTC (rev 21629) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-17 09:14:44 UTC (rev 21630) @@ -49,8 +49,6 @@ extern int function_keycode_table[]; extern char *function_key_char_table[]; -extern PrefHandler *gTermPref; // Global Preference Handler - const static rgb_color kTermColorTable[16] = { { 0, 0, 0, 0}, {255, 0, 0, 0}, @@ -83,15 +81,15 @@ fBoldFlag(0), fUnderlineFlag(0), fBufferStartPos(-1), - fTermRows(gTermPref->getInt32(PREF_ROWS)), - fTermColumns(gTermPref->getInt32(PREF_COLS)), + fTermRows(PrefHandler::Default()->getInt32(PREF_ROWS)), + fTermColumns(PrefHandler::Default()->getInt32(PREF_COLS)), fTop(0), fTextBuffer(new (nothrow) TermBuffer(fTermRows, fTermColumns)), fCodeConv(inCodeConv), fScrollBar(NULL), fScrTop(0), fScrBot(fTermRows - 1), - fScrBufSize(gTermPref->getInt32(PREF_HISTORY_SIZE)), + fScrBufSize(PrefHandler::Default()->getInt32(PREF_HISTORY_SIZE)), fScrRegionSet(0), fMouseTracking(false), fMouseThread(-1), @@ -108,7 +106,7 @@ SetMouseCursor(); SetTermFont(be_plain_font, be_plain_font); - //SetIMAware(gTermPref->getInt32(PREF_IM_AWARE)); + //SetIMAware(PrefHandler::Default()->getInt32(PREF_IM_AWARE)); _InitMouseThread(); } @@ -179,7 +177,7 @@ void TermView::SetMouseCursor() { - if (!strcmp(gTermPref->getString(PREF_MOUSE_IMAGE), "Hand cursor")) + if (!strcmp(PrefHandler::Default()->getString(PREF_MOUSE_IMAGE), "Hand cursor")) fMouseImage = false; else fMouseImage = true; @@ -190,12 +188,12 @@ void TermView::SetTermColor() { - fTextForeColor = gTermPref->getRGB(PREF_TEXT_FORE_COLOR); - fTextBackColor = gTermPref->getRGB(PREF_TEXT_BACK_COLOR); - fSelectForeColor = gTermPref->getRGB(PREF_SELECT_FORE_COLOR); - fSelectBackColor = gTermPref->getRGB(PREF_SELECT_BACK_COLOR); - fCursorForeColor = gTermPref->getRGB(PREF_CURSOR_FORE_COLOR); - fCursorBackColor = gTermPref->getRGB(PREF_CURSOR_BACK_COLOR); + fTextForeColor = PrefHandler::Default()->getRGB(PREF_TEXT_FORE_COLOR); + fTextBackColor = PrefHandler::Default()->getRGB(PREF_TEXT_BACK_COLOR); + fSelectForeColor = PrefHandler::Default()->getRGB(PREF_SELECT_FORE_COLOR); + fSelectBackColor = PrefHandler::Default()->getRGB(PREF_SELECT_BACK_COLOR); + fCursorForeColor = PrefHandler::Default()->getRGB(PREF_CURSOR_FORE_COLOR); + fCursorBackColor = PrefHandler::Default()->getRGB(PREF_CURSOR_BACK_COLOR); SetLowColor(fTextBackColor); SetViewColor(fTextBackColor); @@ -777,7 +775,7 @@ BRect r; if (theObj->HasSelection() - && ( gTermPref->getInt32(PREF_DRAGN_COPY) + && ( PrefHandler::Default()->getInt32(PREF_DRAGN_COPY) || modifiers() & B_CONTROL_KEY)) { if (theObj->LockLooper()) { @@ -1652,7 +1650,7 @@ // If mouse pointer is avove selected Region, start Drag'n Copy. if (inPos > stPos && inPos < edPos) { - if (mod & B_CONTROL_KEY || gTermPref->getInt32(PREF_DRAGN_COPY)) { + if (mod & B_CONTROL_KEY || PrefHandler::Default()->getInt32(PREF_DRAGN_COPY)) { BPoint p; uint32 bt; do { Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-17 08:04:36 UTC (rev 21629) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-17 09:14:44 UTC (rev 21630) @@ -43,8 +43,6 @@ #include "Shell.h" -// Global Preference Handler -extern PrefHandler *gTermPref; // // help and GPL URL // @@ -82,20 +80,20 @@ fMatchCase(false), fMatchWord(false) { - int rows = gTermPref->getInt32(PREF_ROWS); + int rows = PrefHandler::Default()->getInt32(PREF_ROWS); if (rows < 1) { rows = 1; - gTermPref->setInt32(PREF_ROWS, rows); + PrefHandler::Default()->setInt32(PREF_ROWS, rows); } - int cols = gTermPref->getInt32(PREF_COLS); + int cols = PrefHandler::Default()->getInt32(PREF_COLS); if (cols < MIN_COLS) { cols = MIN_COLS; - gTermPref->setInt32(PREF_COLS, cols); + PrefHandler::Default()->setInt32(PREF_COLS, cols); } // Get encoding name (setenv TTYPE in spawn_shell functions) - const char *encoding = longname2shortname(gTermPref->getString(PREF_TEXT_ENCODING)); + const char *encoding = longname2shortname(PrefHandler::Default()->getString(PREF_TEXT_ENCODING)); fShell = new Shell(); status_t status = fShell->Open(rows, cols, command, encoding); if (status < 0) @@ -120,6 +118,8 @@ fFindPanel = NULL; } + PrefHandler::DeleteDefault(); + delete fWindowUpdate; } @@ -136,21 +136,21 @@ // Setup font. - const char *family = gTermPref->getString(PREF_HALF_FONT_FAMILY); + const char *family = PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY); BFont halfFont; halfFont.SetFamilyAndStyle(family, NULL); - float size = gTermPref->getFloat(PREF_HALF_FONT_SIZE); + float size = PrefHandler::Default()->getFloat(PREF_HALF_FONT_SIZE); if (size < 6.0f) size = 6.0f; halfFont.SetSize(size); halfFont.SetSpacing(B_FIXED_SPACING); - family = gTermPref->getString(PREF_FULL_FONT_FAMILY); + family = PrefHandler::Default()->getString(PREF_FULL_FONT_FAMILY); BFont fullFont; fullFont.SetFamilyAndStyle(family, NULL); - size = gTermPref->getFloat(PREF_FULL_FONT_SIZE); + size = PrefHandler::Default()->getFloat(PREF_FULL_FONT_SIZE); if (size < 6.0f) size = 6.0f; fullFont.SetSize(size); @@ -177,8 +177,8 @@ fTermView->SetTermFont(&halfFont, &fullFont); - BRect rect = fTermView->SetTermSize(gTermPref->getInt32(PREF_ROWS), - gTermPref->getInt32(PREF_COLS), 1); + BRect rect = fTermView->SetTermSize(PrefHandler::Default()->getInt32(PREF_ROWS), + PrefHandler::Default()->getInt32(PREF_COLS), 1); int width, height; fTermView->GetFontSize(&width, &height); @@ -186,7 +186,7 @@ MIN_COLS * height, MAX_COLS * height); fTermView->SetTermColor(); - fBaseView->SetViewColor(gTermPref->getRGB(PREF_TEXT_BACK_COLOR)); + fBaseView->SetViewColor(PrefHandler::Default()->getRGB(PREF_TEXT_BACK_COLOR)); // Add offset to baseview. rect.InsetBy(-VIEW_OFFSET, -VIEW_OFFSET); @@ -218,7 +218,7 @@ fEditmenu->SetTargetForItems(fTermView); // Initialize TermParse - SetEncoding(longname2id(gTermPref->getString(PREF_TEXT_ENCODING))); + SetEncoding(longname2id(PrefHandler::Default()->getString(PREF_TEXT_ENCODING))); fTermParse = new TermParse(fShell->FD(), fTermView, fCodeConv); if (fTermParse->StartThreads() < B_OK) return; @@ -310,7 +310,7 @@ // if (0 ==i) item->SetMarked(true); } } - fNewFontMenu->FindItem (gTermPref->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true); + fNewFontMenu->FindItem (PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true); */ fEncodingmenu = new BMenu("Font Encoding"); @@ -479,15 +479,15 @@ // Message from Preference panel. case MSG_ROWS_CHANGED: case MSG_COLS_CHANGED: { - r = fTermView->SetTermSize (gTermPref->getInt32 (PREF_ROWS), - gTermPref->getInt32 (PREF_COLS), 0); + r = fTermView->SetTermSize (PrefHandler::Default()->getInt32 (PREF_ROWS), + PrefHandler::Default()->getInt32 (PREF_COLS), 0); ResizeTo (r.Width()+ B_V_SCROLL_BAR_WIDTH + VIEW_OFFSET * 2, r.Height()+fMenubar->Bounds().Height() + VIEW_OFFSET *2); BPath path; if (PrefHandler::GetDefaultPath(path) == B_OK) - gTermPref->SaveAsText(path.Path(), PREFFILE_MIMETYPE); + PrefHandler::Default()->SaveAsText(path.Path(), PREFFILE_MIMETYPE); break; } case MSG_HALF_FONT_CHANGED: @@ -495,12 +495,12 @@ case MSG_HALF_SIZE_CHANGED: case MSG_FULL_SIZE_CHANGED: { - halfFont.SetFamilyAndStyle (gTermPref->getString(PREF_HALF_FONT_FAMILY),NULL); - halfFont.SetSize (gTermPref->getFloat(PREF_HALF_FONT_SIZE)); + halfFont.SetFamilyAndStyle (PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY),NULL); + halfFont.SetSize (PrefHandler::Default()->getFloat(PREF_HALF_FONT_SIZE)); halfFont.SetSpacing (B_FIXED_SPACING); - fullFont.SetFamilyAndStyle (gTermPref->getString(PREF_FULL_FONT_FAMILY),NULL); - fullFont.SetSize (gTermPref->getFloat(PREF_FULL_FONT_SIZE)); + fullFont.SetFamilyAndStyle (PrefHandler::Default()->getString(PREF_FULL_FONT_FAMILY),NULL); + fullFont.SetSize (PrefHandler::Default()->getFloat(PREF_FULL_FONT_SIZE)); fullFont.SetSpacing (B_FIXED_SPACING); fTermView->SetTermFont (&halfFont, &fullFont); @@ -520,36 +520,36 @@ break; } case EIGHTYTWENTYFOUR: { - gTermPref->setString(PREF_COLS, "80"); - gTermPref->setString(PREF_ROWS, "24"); + PrefHandler::Default()->setString(PREF_COLS, "80"); + PrefHandler::Default()->setString(PREF_ROWS, "24"); this->PostMessage (MSG_ROWS_CHANGED); this->PostMessage (MSG_COLS_CHANGED); break; } case EIGHTYTWENTYFIVE: { - gTermPref->setString(PREF_COLS, "80"); - gTermPref->setString(PREF_ROWS, "25"); + PrefHandler::Default()->setString(PREF_COLS, "80"); + PrefHandler::Default()->setString(PREF_ROWS, "25"); this->PostMessage (MSG_ROWS_CHANGED); this->PostMessage (MSG_COLS_CHANGED); break; } case EIGHTYFORTY: { - gTermPref->setString(PREF_COLS, "80"); - gTermPref->setString(PREF_ROWS, "40"); + PrefHandler::Default()->setString(PREF_COLS, "80"); + PrefHandler::Default()->setString(PREF_ROWS, "40"); this->PostMessage (MSG_ROWS_CHANGED); this->PostMessage (MSG_COLS_CHANGED); break; } case ONETHREETWOTWENTYFOUR: { - gTermPref->setString(PREF_COLS, "132"); - gTermPref->setString(PREF_ROWS, "24"); + PrefHandler::Default()->setString(PREF_COLS, "132"); + PrefHandler::Default()->setString(PREF_ROWS, "24"); this->PostMessage (MSG_ROWS_CHANGED); this->PostMessage (MSG_COLS_CHANGED); break; } case ONETHREETWOTWENTYFIVE: { - gTermPref->setString(PREF_COLS, "132"); - gTermPref->setString(PREF_ROWS, "25"); + PrefHandler::Default()->setString(PREF_COLS, "132"); + PrefHandler::Default()->setString(PREF_ROWS, "25"); this->PostMessage (MSG_ROWS_CHANGED); this->PostMessage (MSG_COLS_CHANGED); break; @@ -582,12 +582,12 @@ break; } case MSG_FONT_CHANGED: { - gTermPref->setString (PREF_HALF_FONT_FAMILY, fNewFontMenu->FindMarked()->Label()); + PrefHandler::Default()->setString (PREF_HALF_FONT_FAMILY, fNewFontMenu->FindMarked()->Label()); PostMessage (MSG_HALF_FONT_CHANGED); break; } case MSG_COLOR_CHANGED: { - fBaseView->SetViewColor (gTermPref->getRGB (PREF_TEXT_BACK_COLOR)); + fBaseView->SetViewColor (PrefHandler::Default()->getRGB (PREF_TEXT_BACK_COLOR)); fTermView->SetTermColor (); fBaseView->Invalidate(); fTermView->Invalidate(); @@ -596,7 +596,7 @@ case SAVE_AS_DEFAULT: { BPath path; if (PrefHandler::GetDefaultPath(path) == B_OK) - gTermPref->SaveAsText(path.Path(), PREFFILE_MIMETYPE); + PrefHandler::Default()->SaveAsText(path.Path(), PREFFILE_MIMETYPE); break; } case MENU_PAGE_SETUP: { Modified: haiku/trunk/src/apps/terminal/TermWindow.h =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-17 08:04:36 UTC (rev 21629) +++ haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-17 09:14:44 UTC (rev 21630) @@ -32,8 +32,6 @@ #define TERMWIN_H -#include "PrefHandler.h" - #include #include #include From jackburton at mail.berlios.de Tue Jul 17 11:19:03 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 17 Jul 2007 11:19:03 +0200 Subject: [Haiku-commits] r21631 - haiku/trunk/src/apps/terminal Message-ID: <200707170919.l6H9J3hm028984@sheep.berlios.de> Author: jackburton Date: 2007-07-17 11:19:02 +0200 (Tue, 17 Jul 2007) New Revision: 21631 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21631&view=rev Removed: haiku/trunk/src/apps/terminal/ToggleScrollView.cpp haiku/trunk/src/apps/terminal/ToggleScrollView.h Log: Removed unused files Deleted: haiku/trunk/src/apps/terminal/ToggleScrollView.cpp Deleted: haiku/trunk/src/apps/terminal/ToggleScrollView.h From jackburton at mail.berlios.de Tue Jul 17 11:42:35 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 17 Jul 2007 11:42:35 +0200 Subject: [Haiku-commits] r21632 - haiku/trunk/src/apps/terminal Message-ID: <200707170942.l6H9gZuH030560@sheep.berlios.de> Author: jackburton Date: 2007-07-17 11:42:34 +0200 (Tue, 17 Jul 2007) New Revision: 21632 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21632&view=rev Modified: haiku/trunk/src/apps/terminal/CodeConv.cpp haiku/trunk/src/apps/terminal/UTF8WidthTbl.c Log: Renamed a variable to fit our guidelines. Removed typedef from UTF8WidthTbl.c. Use typedef from SupportDefs.h instead Modified: haiku/trunk/src/apps/terminal/CodeConv.cpp =================================================================== --- haiku/trunk/src/apps/terminal/CodeConv.cpp 2007-07-17 09:19:02 UTC (rev 21631) +++ haiku/trunk/src/apps/terminal/CodeConv.cpp 2007-07-17 09:42:34 UTC (rev 21632) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2005, Haiku, Inc. + * Copyright (c) 2001-2007, Haiku, Inc. * Copyright (c) 2003-4 Kian Duffy * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * Distributed under the terms of the MIT license. @@ -30,7 +30,7 @@ #define BEGINS_CHAR(byte) ((byte & 0xc0) >= 0x80) -extern char utf8_width_table[]; /* define UTF8WidthTbl.c */ +extern char gUTF8WidthTable[]; // defined in UTF8WidthTbl.c CodeConv::CodeConv() @@ -51,7 +51,7 @@ ushort unicode, offset; offset = unicode = UTF8toUnicode(string); - width = utf8_width_table[unicode >> 3]; + width = gUTF8WidthTable[unicode >> 3]; offset = offset & 0x07; point = 0x80 >> offset; Modified: haiku/trunk/src/apps/terminal/UTF8WidthTbl.c =================================================================== --- haiku/trunk/src/apps/terminal/UTF8WidthTbl.c 2007-07-17 09:19:02 UTC (rev 21631) +++ haiku/trunk/src/apps/terminal/UTF8WidthTbl.c 2007-07-17 09:42:34 UTC (rev 21632) @@ -1,4 +1,5 @@ /* + * Copyright 2007 Haiku, Inc. * Copyright (c) 2003-4 Kian Duffy * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * @@ -28,9 +29,12 @@ * */ -typedef unsigned char uchar; +#ifndef __UTF8WIDTHTBL_H +#define __UTF8WIDTHTBL_H -uchar utf8_width_table[] = +#include + +uchar gUTF8WidthTable[] = { 0, 0, @@ -8224,5 +8228,7 @@ 0, 0, 0, -} -; +}; + +#endif // __UTF8WIDTHTBL_H + From jackburton at mail.berlios.de Tue Jul 17 11:50:07 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 17 Jul 2007 11:50:07 +0200 Subject: [Haiku-commits] r21633 - haiku/trunk/src/apps/terminal Message-ID: <200707170950.l6H9o7Sw031002@sheep.berlios.de> Author: jackburton Date: 2007-07-17 11:50:06 +0200 (Tue, 17 Jul 2007) New Revision: 21633 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21633&view=rev Modified: haiku/trunk/src/apps/terminal/Coding.cpp Log: fixed a warning Modified: haiku/trunk/src/apps/terminal/Coding.cpp =================================================================== --- haiku/trunk/src/apps/terminal/Coding.cpp 2007-07-17 09:42:34 UTC (rev 21632) +++ haiku/trunk/src/apps/terminal/Coding.cpp 2007-07-17 09:50:06 UTC (rev 21633) @@ -51,7 +51,7 @@ if (id == NULL) return B_BAD_VALUE; - if (i < 0 || i >= sizeof(kEncodingTable) / sizeof(etable)) + if (i < 0 || i >= (int)(sizeof(kEncodingTable) / sizeof(etable))) return B_BAD_INDEX; *id = kEncodingTable[i].id; From jackburton at mail.berlios.de Tue Jul 17 13:46:48 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 17 Jul 2007 13:46:48 +0200 Subject: [Haiku-commits] r21634 - haiku/trunk/src/add-ons/accelerants/intel_extreme Message-ID: <200707171146.l6HBkmCd021000@sheep.berlios.de> Author: jackburton Date: 2007-07-17 13:46:47 +0200 (Tue, 17 Jul 2007) New Revision: 21634 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21634&view=rev Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/accelerant.cpp Log: return errno when open() fails Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/accelerant.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/intel_extreme/accelerant.cpp 2007-07-17 09:50:06 UTC (rev 21633) +++ haiku/trunk/src/add-ons/accelerants/intel_extreme/accelerant.cpp 2007-07-17 11:46:47 UTC (rev 21634) @@ -12,6 +12,7 @@ #include "utility.h" +#include #include #include #include @@ -243,7 +244,7 @@ int fd = open(path, B_READ_WRITE); if (fd < 0) - return fd; + return errno; status_t status = init_common(fd, true); if (status != B_OK) From stippi at mail.berlios.de Tue Jul 17 21:54:39 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 17 Jul 2007 21:54:39 +0200 Subject: [Haiku-commits] r21635 - haiku/trunk/src/kits Message-ID: <200707171954.l6HJsdSe006580@sheep.berlios.de> Author: stippi Date: 2007-07-17 21:54:38 +0200 (Tue, 17 Jul 2007) New Revision: 21635 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21635&view=rev Modified: haiku/trunk/src/kits/Jamfile Log: * fixed build of libbe_haiku.so on BONE compatible hosts Modified: haiku/trunk/src/kits/Jamfile =================================================================== --- haiku/trunk/src/kits/Jamfile 2007-07-17 11:46:47 UTC (rev 21634) +++ haiku/trunk/src/kits/Jamfile 2007-07-17 19:54:38 UTC (rev 21635) @@ -74,7 +74,7 @@ libagg.a libbeadapter.so - net + $(NETWORK_LIBS) $(TARGET_LIBSTDC++) ; From mmlr at mail.berlios.de Tue Jul 17 22:00:55 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Tue, 17 Jul 2007 22:00:55 +0200 Subject: [Haiku-commits] r21636 - in haiku/trunk: headers/libs/usb src/add-ons/kernel/busses/usb src/add-ons/kernel/drivers/bus/usb src/libs/usb Message-ID: <200707172000.l6HK0t8h007075@sheep.berlios.de> Author: mmlr Date: 2007-07-17 22:00:53 +0200 (Tue, 17 Jul 2007) New Revision: 21636 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21636&view=rev Modified: haiku/trunk/headers/libs/usb/USBKit.h haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/uhci.h haiku/trunk/src/add-ons/kernel/drivers/bus/usb/usb_raw.cpp haiku/trunk/src/add-ons/kernel/drivers/bus/usb/usb_raw.h haiku/trunk/src/libs/usb/USBEndpoint.cpp Log: Patches by Salvatore Benedetto to fix changes made by me and also the underlaying problem that caused high CPU usage in the isochronous finisher thread. Also includes patches to support isochronous support through USBKit / usb_raw. Thanks! Modified: haiku/trunk/headers/libs/usb/USBKit.h =================================================================== --- haiku/trunk/headers/libs/usb/USBKit.h 2007-07-17 19:54:38 UTC (rev 21635) +++ haiku/trunk/headers/libs/usb/USBKit.h 2007-07-17 20:00:53 UTC (rev 21636) @@ -10,6 +10,7 @@ #define _USBKIT_H #include +#include #include @@ -257,7 +258,7 @@ /* The BUSBEndpoint represent a device endpoint that can be used to send or - receive data. It also alows to query endpoint characteristics like + receive data. It also allows to query endpoint characteristics like endpoint type or direction. */ class BUSBEndpoint { public: @@ -299,6 +300,10 @@ size_t length) const; ssize_t BulkTransfer(void *data, size_t length) const; + ssize_t IsochronousTransfer(void *data, + size_t length, + usb_iso_packet_descriptor *packetDescriptors, + uint32 packetCount) const; private: friend class BUSBInterface; Modified: haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp 2007-07-17 19:54:38 UTC (rev 21635) +++ haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp 2007-07-17 20:00:53 UTC (rev 21636) @@ -304,6 +304,8 @@ fStopFinishThread(false), fFirstIsochronousTransfer(NULL), fLastIsochronousTransfer(NULL), + fFinishIsochronousThread(-1), + fStopFinishIsochronousThread(false), fRootHub(NULL), fRootHubAddress(0), fPortResetChange(0) @@ -396,9 +398,18 @@ // Create the array that will keep bandwidth information fFrameBandwidth = new(std::nothrow) uint16[NUMBER_OF_FRAMES]; - // Create lists for managing isochronous transfer descriptors + // create lists for managing isochronous transfer descriptors fFirstIsochronousDescriptor = new(std::nothrow) uhci_td *[NUMBER_OF_FRAMES]; + if (!fFirstIsochronousDescriptor) { + TRACE_ERROR(("usb_uhci: cannot allocate memory\n")); + return; + } fLastIsochronousDescriptor = new(std::nothrow) uhci_td *[NUMBER_OF_FRAMES]; + if (!fLastIsochronousDescriptor) { + TRACE_ERROR(("usb_uhci: cannot allocate memory\n")); + delete [] fFirstIsochronousDescriptor; + return; + } for (int32 i = 0; i < NUMBER_OF_FRAMES; i++) { fFrameList[i] = fQueues[UHCI_INTERRUPT_QUEUE]->PhysicalAddress() @@ -426,6 +437,20 @@ return; } + // Create semaphore the isochronous finisher thread will wait for + fFinishIsochronousTransfersSem = create_sem(0, + "UHCI Isochronous Finish Transfers"); + if (fFinishIsochronousTransfersSem < B_OK) { + TRACE_ERROR(("usb_uhci: failed to create semaphore\n")); + return; + } + + // Create the isochronous finisher service thread + fFinishIsochronousThread = spawn_kernel_thread(FinishIsochronousThread, + "uhci isochronous finish thread", B_URGENT_DISPLAY_PRIORITY, + (void *)this); + resume_thread(fFinishIsochronousThread); + // Install the interrupt handler TRACE(("usb_uhci: installing interrupt handler\n")); install_io_interrupt_handler(fPCIInfo->u.h0.interrupt_line, @@ -444,8 +469,11 @@ { int32 result = 0; fStopFinishThread = true; + fStopFinishIsochronousThread = true; delete_sem(fFinishTransfersSem); + delete_sem(fFinishIsochronousTransfersSem); wait_for_thread(fFinishThread, &result); + wait_for_thread(fFinishIsochronousThread, &result); LockIsochronous(); isochronous_transfer_data *isoTransfer = fFirstIsochronousTransfer; @@ -627,7 +655,7 @@ // Set the active bit off on every descriptor in order to prevent // the controller from processing them. Then set off the is_active // field of the transfer in order to make the finisher thread skip - // the transfer. FinishIsochronousTransfers will do the rest. + // the transfer. The FinishIsochronousThread will do the rest. for (int32 i = 0; i < packetCount; i++) current->descriptors[i]->status &= ~TD_STATUS_ACTIVE; current->is_active = false; @@ -815,10 +843,6 @@ TRACE(("usb_uhci: isochronous transfer descriptor bandwdith = %d\n", bandwidth)); - // TODO: If direction is out set every descriptor data - if (!directionIn) - return B_ERROR; - // The following holds the list of transfer descriptor of the // isochronous request. It is used to quickly remove all the isochronous // descriptors from the frame list, as descriptors are not link to each @@ -841,16 +865,23 @@ isoRequest[isochronousData->packet_count - 1]->token &= ~TD_TOKEN_DATA1; isoRequest[isochronousData->packet_count - 1]->status |= TD_CONTROL_IOC; + // If direction is out set every descriptor data + if (!directionIn) { + iovec *vector = transfer->Vector(); + WriteIsochronousDescriptorChain(isoRequest, + isochronousData->packet_count, vector); + } else { + // Initialize the packet descriptors + for (uint32 i = 0; i < isochronousData->packet_count; i++) { + isochronousData->packet_descriptors[i].actual_length = 0; + isochronousData->packet_descriptors[i].status = B_NO_INIT; + } + } + TRACE(("usb_uhci: isochronous submitted size=%ld bytes, TDs=%ld, " "packetSize=%ld, restSize=%ld\n", transfer->DataLength(), isochronousData->packet_count, packetSize, restSize)); - // Initialize the packet descriptors - for (uint32 i = 0; i < isochronousData->packet_count; i++) { - isochronousData->packet_descriptors[i].actual_length = 0; - isochronousData->packet_descriptors[i].status = B_NO_INIT; - } - // Find the entry where to start inserting the first Isochronous descriptor if (isochronousData->flags & USB_ISO_ASAP || isochronousData->starting_frame_number == NULL) { @@ -911,6 +942,9 @@ currentFrame = (currentFrame + 1) % NUMBER_OF_FRAMES; } + // Wake up the isochronous finisher thread + release_sem_etc(fFinishIsochronousTransfersSem, 1, B_DO_NOT_RESCHEDULE); + return B_OK; } @@ -991,9 +1025,6 @@ if (semCount > 0) acquire_sem_etc(fFinishTransfersSem, semCount, B_RELATIVE_TIMEOUT, 0); - // give the isochronous transfers a chance - FinishIsochronousTransfers(); - if (!Lock()) continue; @@ -1155,82 +1186,102 @@ } +int32 +UHCI::FinishIsochronousThread(void *data) +{ + ((UHCI *)data)->FinishIsochronousTransfers(); + return B_OK; +} + + void UHCI::FinishIsochronousTransfers() { - if (!LockIsochronous()) - return; + /* This thread stays one position behind the controller and processes every + * isochronous descriptor. Once it finds the last isochronous descriptor + * of a transfer, it processes the entire transfer. + */ - for (uint16 frame = 0; frame < NUMBER_OF_FRAMES; frame++) { - uhci_td *current = fFirstIsochronousDescriptor[frame]; + while (!fStopFinishIsochronousThread) { + // Go to sleep if there are not isochronous transfer to process + if (acquire_sem(fFinishIsochronousTransfersSem) < B_OK) + return; - while (current) { - if (current->status & TD_STATUS_ACTIVE) { - // The transfer descriptor is still active - current = (uhci_td *)current->link_log; - continue; - } + bool transferDone = false; + uint16 currentFrame = ReadReg16(UHCI_FRNUM); + + // Process the frame list until one transfer is processed + while (!transferDone) { + // wait 1ms in order to be sure to be one position behind + // the controller + if (currentFrame == ReadReg16(UHCI_FRNUM)) + snooze(1000); - UnlinkIsochronousDescriptor(current, frame); - if (!(current->status & TD_CONTROL_IOC)) { - current = (uhci_td *)current->link_log; - continue; - } + // Process the frame till it has isochronous descriptors in it. + while (!(fFrameList[currentFrame] & FRAMELIST_NEXT_IS_QH)) { + uhci_td *current = fFirstIsochronousDescriptor[currentFrame]; + UnlinkIsochronousDescriptor(current, currentFrame); - // Process the transfer if we found the last descriptor - isochronous_transfer_data *transfer - = FindIsochronousTransfer(current); + // Process the transfer if we found the last descriptor + if (current->status & TD_CONTROL_IOC) { + isochronous_transfer_data *transfer + = FindIsochronousTransfer(current); - // The following should NEVER happen - if (!transfer) { - TRACE_ERROR(("usb_uhci: Isochronous transfer not found in" - " the finisher thread!\n")); - return; - } else if (transfer->is_active - && (current->status & TD_TOKEN_IN)) { - // Process the descriptors only if it is still active and - // belongs to an inbound transfer. If the transfer is not - // active, it means the request has been removed, so simply - // remove the descriptors. - iovec *vector = transfer->transfer->Vector(); - transfer->transfer->PrepareKernelAccess(); - ReadIsochronousDescriptorChain(transfer, vector); + // The following should NEVER happen + if (!transfer) { + TRACE_ERROR(("usb_uhci: Isochronous transfer not found" + " in the finisher thread!\n")); + return; - // Remove the transfer - if (transfer == fFirstIsochronousTransfer) { - fFirstIsochronousTransfer = transfer->link; - } else { - isochronous_transfer_data *temp - = fFirstIsochronousTransfer; - while (transfer != temp->link) - temp = temp->link; + // Process the descriptors only if it is still active and + // belongs to an inbound transfer. If the transfer is not + // active, it means the request has been removed, so simply + // remove the descriptors. + } else if (transfer->is_active + && (current->status & TD_TOKEN_IN)) { + iovec *vector = transfer->transfer->Vector(); + transfer->transfer->PrepareKernelAccess(); + ReadIsochronousDescriptorChain(transfer, vector); - if (transfer == fLastIsochronousTransfer) - fLastIsochronousTransfer = temp; - temp->link = temp->link->link; - } + // Remove the transfer + if (LockIsochronous()) { + if (transfer == fFirstIsochronousTransfer) + fFirstIsochronousTransfer = transfer->link; + else { + isochronous_transfer_data *temp + = fFirstIsochronousTransfer; + while (transfer != temp->link) + temp = temp->link; - transfer->transfer->Finished(B_OK, 0); - } else if (!transfer->is_active) - transfer->transfer->Finished(B_CANCELED, 0); + if (transfer == fLastIsochronousTransfer) + fLastIsochronousTransfer = temp; + temp->link = temp->link->link; + } - uint32 packetCount = - transfer->transfer->IsochronousData()->packet_count; - for (uint32 i = 0; i < packetCount; i++) - FreeDescriptor(transfer->descriptors[i]); + UnlockIsochronous(); + } - uint16 bandwidth = transfer->transfer->Bandwidth() / packetCount; - fFrameBandwidth[frame] += bandwidth; + transfer->transfer->Finished(B_OK, 0); - delete [] transfer->descriptors; - delete transfer->transfer; - delete transfer; + uint32 packetCount = + transfer->transfer->IsochronousData()->packet_count; + for (uint32 i = 0; i < packetCount; i++) + FreeDescriptor(transfer->descriptors[i]); - current = (uhci_td *)current->link_log; + delete [] transfer->descriptors; + delete transfer->transfer; + delete transfer; + transferDone = true; + } + } + } + + // Make sure to reset the frame bandwidth + fFrameBandwidth[currentFrame] = MAX_AVAILABLE_BANDWIDTH; + currentFrame = (currentFrame + 1) % NUMBER_OF_FRAMES; } } - UnlockIsochronous(); } @@ -1890,6 +1941,20 @@ void +UHCI::WriteIsochronousDescriptorChain(uhci_td **isoRequest, uint32 packetCount, + iovec *vector) +{ + size_t vectorOffset = 0; + for (uint32 i = 0; i < packetCount; i++) { + size_t bufferSize = isoRequest[i]->buffer_size; + memcpy((uint8 *)isoRequest[i]->buffer_log, + (uint8 *)vector->iov_base + vectorOffset, bufferSize); + vectorOffset += bufferSize; + } +} + + +void UHCI::ReadIsochronousDescriptorChain(isochronous_transfer_data *transfer, iovec *vector) { Modified: haiku/trunk/src/add-ons/kernel/busses/usb/uhci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/uhci.h 2007-07-17 19:54:38 UTC (rev 21635) +++ haiku/trunk/src/add-ons/kernel/busses/usb/uhci.h 2007-07-17 20:00:53 UTC (rev 21636) @@ -133,6 +133,7 @@ uhci_qh **_transferQueue); // Isochronous transfer functions +static int32 FinishIsochronousThread(void *data); void FinishIsochronousTransfers(); isochronous_transfer_data *FindIsochronousTransfer(uhci_td *descriptor); @@ -173,6 +174,10 @@ uint8 *lastDataToggle); size_t ReadActualLength(uhci_td *topDescriptor, uint8 *lastDataToggle); + void WriteIsochronousDescriptorChain( + uhci_td **isoRequest, + uint32 packetCount, + iovec *vector); void ReadIsochronousDescriptorChain( isochronous_transfer_data *transfer, iovec *vector); @@ -219,7 +224,10 @@ // Maintain a linked list of isochronous transfers isochronous_transfer_data *fFirstIsochronousTransfer; isochronous_transfer_data *fLastIsochronousTransfer; + sem_id fFinishIsochronousTransfersSem; + thread_id fFinishIsochronousThread; benaphore fIsochronousLock; + bool fStopFinishIsochronousThread; // Root hub UHCIRootHub *fRootHub; Modified: haiku/trunk/src/add-ons/kernel/drivers/bus/usb/usb_raw.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bus/usb/usb_raw.cpp 2007-07-17 19:54:38 UTC (rev 21635) +++ haiku/trunk/src/add-ons/kernel/drivers/bus/usb/usb_raw.cpp 2007-07-17 20:00:53 UTC (rev 21636) @@ -467,7 +467,8 @@ } case RAW_COMMAND_INTERRUPT_TRANSFER: - case RAW_COMMAND_BULK_TRANSFER: { + case RAW_COMMAND_BULK_TRANSFER: + case RAW_COMMAND_ISOCHRONOUS_TRANSFER: { const usb_configuration_info *configurationInfo = gUSBModule->get_configuration(device->device); if (!configurationInfo) { @@ -506,10 +507,16 @@ status = gUSBModule->queue_interrupt(endpointInfo->handle, command->transfer.data, command->transfer.length, usb_raw_callback, device); - } else { + } else if (op == RAW_COMMAND_BULK_TRANSFER) { status = gUSBModule->queue_bulk(endpointInfo->handle, command->transfer.data, command->transfer.length, usb_raw_callback, device); + } else { + status = gUSBModule->queue_isochronous(endpointInfo->handle, + command->isochronous.data, command->isochronous.length, + command->isochronous.packet_descriptors, + command->isochronous.packet_count, NULL, 0, + usb_raw_callback, device); } if (status < B_OK) { Modified: haiku/trunk/src/add-ons/kernel/drivers/bus/usb/usb_raw.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bus/usb/usb_raw.h 2007-07-17 19:54:38 UTC (rev 21635) +++ haiku/trunk/src/add-ons/kernel/drivers/bus/usb/usb_raw.h 2007-07-17 20:00:53 UTC (rev 21636) @@ -32,7 +32,8 @@ RAW_COMMAND_CONTROL_TRANSFER = 0x4000, RAW_COMMAND_INTERRUPT_TRANSFER, - RAW_COMMAND_BULK_TRANSFER + RAW_COMMAND_BULK_TRANSFER, + RAW_COMMAND_ISOCHRONOUS_TRANSFER } raw_command_id; @@ -127,6 +128,16 @@ void *data; size_t length; } transfer; + + struct { + status_t status; + uint32 interface; + uint32 endpoint; + void *data; + size_t length; + usb_iso_packet_descriptor *packet_descriptors; + uint32 packet_count; + } isochronous; } raw_command; Modified: haiku/trunk/src/libs/usb/USBEndpoint.cpp =================================================================== --- haiku/trunk/src/libs/usb/USBEndpoint.cpp 2007-07-17 19:54:38 UTC (rev 21635) +++ haiku/trunk/src/libs/usb/USBEndpoint.cpp 2007-07-17 20:00:53 UTC (rev 21636) @@ -189,3 +189,27 @@ return command.transfer.length; } + + +ssize_t +BUSBEndpoint::IsochronousTransfer(void *data, size_t length, + usb_iso_packet_descriptor *packetDescriptors, uint32 packetCount) const +{ + if (length > 0 && data == NULL) + return B_BAD_VALUE; + + raw_command command; + command.isochronous.interface = fInterface->Index(); + command.isochronous.endpoint = fIndex; + command.isochronous.data = data; + command.isochronous.length = length; + command.isochronous.packet_descriptors = packetDescriptors; + command.isochronous.packet_count = packetCount; + + if (ioctl(fRawFD, RAW_COMMAND_ISOCHRONOUS_TRANSFER, &command, sizeof(command)) + || command.isochronous.status != RAW_STATUS_SUCCESS) { + return B_ERROR; + } + + return command.isochronous.length; +} From stippi at mail.berlios.de Tue Jul 17 22:48:07 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 17 Jul 2007 22:48:07 +0200 Subject: [Haiku-commits] r21637 - in haiku/trunk/src: servers/app tests/servers/app Message-ID: <200707172048.l6HKm7Vj010325@sheep.berlios.de> Author: stippi Date: 2007-07-17 22:48:06 +0200 (Tue, 17 Jul 2007) New Revision: 21637 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21637&view=rev Added: haiku/trunk/src/servers/app/FontStyle.cpp haiku/trunk/src/servers/app/FontStyle.h Modified: haiku/trunk/src/servers/app/FontFamily.cpp haiku/trunk/src/servers/app/FontFamily.h haiku/trunk/src/servers/app/Jamfile haiku/trunk/src/tests/servers/app/Jamfile Log: * separated FontStyle and FontFamily into different .h/cpp, before they shared FontFamily.h/cpp (just for the reason that this is how we do it mostly everywhere) Modified: haiku/trunk/src/servers/app/FontFamily.cpp =================================================================== --- haiku/trunk/src/servers/app/FontFamily.cpp 2007-07-17 20:00:53 UTC (rev 21636) +++ haiku/trunk/src/servers/app/FontFamily.cpp 2007-07-17 20:48:06 UTC (rev 21637) @@ -11,20 +11,13 @@ #include "FontFamily.h" -#include "ServerFont.h" + #include "FontManager.h" -#include -#include FT_CACHE_H -#include - - const uint32 kInvalidFamilyFlags = ~0UL; -static BLocker sFontLock("font lock"); - static int font_score(const FontStyle* style) { @@ -55,231 +48,6 @@ /*! \brief Constructor - \param filepath path to a font file - \param face FreeType handle for the font file after it is loaded - it will be kept open until the FontStyle is destroied -*/ -FontStyle::FontStyle(node_ref& nodeRef, const char* path, FT_Face face) - : //BLocker(BString("FontStyle_").Append(face->style_name).String()), - fFreeTypeFace(face), - fName(face->style_name), - fPath(path), - fNodeRef(nodeRef), - fFamily(NULL), - fID(0), - fBounds(0, 0, 0, 0), - fFace(_TranslateStyleToFace(face->style_name)) -{ - fName.Truncate(B_FONT_STYLE_LENGTH); - // make sure this style can be found using the Be API - - fHeight.ascent = (double)face->ascender / face->units_per_EM; - fHeight.descent = (double)-face->descender / face->units_per_EM; - // FT2's descent numbers are negative. Be's is positive - - // FT2 doesn't provide a linegap, but according to the docs, we can - // calculate it because height = ascending + descending + leading - fHeight.leading = (double)(face->height - face->ascender + face->descender) - / face->units_per_EM; -} - - -FontStyle::~FontStyle() -{ - // make sure the font server is ours - if (fFamily != NULL && gFontManager->Lock()) { - gFontManager->RemoveStyle(this); - gFontManager->Unlock(); - } - - FT_Done_Face(fFreeTypeFace); -} - - -uint32 -FontStyle::Hash() const -{ - return (ID() << 16) | fFamily->ID(); -} - - -bool -FontStyle::CompareTo(Hashable& other) const -{ - // our hash values are unique (unless you have more than 65536 font families installed...) - return Hash() == other.Hash(); -} - - -bool -FontStyle::Lock() -{ - return sFontLock.Lock(); -} - - -void -FontStyle::Unlock() -{ - sFontLock.Unlock(); -} - - -void -FontStyle::GetHeight(float size, font_height& height) const -{ - height.ascent = fHeight.ascent * size; - height.descent = fHeight.descent * size; - height.leading = fHeight.leading * size; -} - - -/*! - \brief Returns the path to the style's font file - \return The style's font file path -*/ -const char* -FontStyle::Path() const -{ - return fPath.Path(); -} - - -/*! - \brief Updates the path of the font style in case the style - has been moved around. -*/ -void -FontStyle::UpdatePath(const node_ref& parentNodeRef) -{ - entry_ref ref; - ref.device = parentNodeRef.device; - ref.directory = parentNodeRef.node; - ref.set_name(fPath.Leaf()); - - fPath.SetTo(&ref); -} - - -/*! - \brief Unlike BFont::Flags() this returns the extra flags field as used - in the private part of BFont. -*/ -uint32 -FontStyle::Flags() const -{ - uint32 flags = uint32(Direction()) << B_PRIVATE_FONT_DIRECTION_SHIFT; - - if (IsFixedWidth()) - flags |= B_IS_FIXED; - if (TunedCount() > 0) - flags |= B_HAS_TUNED_FONT; - if (HasKerning()) - flags |= B_PRIVATE_FONT_HAS_KERNING; - - return flags; -} - - -/*! - \brief Updates the given face to match the one from this style - - The specified font face often doesn't match the exact face of - a style. This method will preserve the attributes of the face - that this style does not alter, and will only update the - attributes that matter to this style. - The font renderer could then emulate the other face attributes - taking this style as a base. -*/ -uint16 -FontStyle::PreservedFace(uint16 face) const -{ - // TODO: make this better - face &= ~(B_REGULAR_FACE | B_BOLD_FACE | B_ITALIC_FACE); - face |= Face(); - - return face; -} - - -status_t -FontStyle::UpdateFace(FT_Face face) -{ - if (!sFontLock.IsLocked()) { - debugger("UpdateFace() called without having locked FontStyle!"); - return B_ERROR; - } - - // we only accept the face if it hasn't change its style - - BString name = face->style_name; - name.Truncate(B_FONT_STYLE_LENGTH); - - if (name != fName) - return B_BAD_VALUE; - - FT_Done_Face(fFreeTypeFace); - fFreeTypeFace = face; - return B_OK; -} - - -/*! - \brief Converts an ASCII character to Unicode for the style - \param c An ASCII character - \return A Unicode value for the character -*/ - -// TODO: Re-enable when I understand how the FT2 Cache system changed from -// 2.1.4 to 2.1.8 -/* -int16 -FontStyle::ConvertToUnicode(uint16 c) -{ - FT_Face f; - if(FTC_Manager_LookupFace(ftmanager,(FTC_FaceID)cachedface,&f)!=0) - return 0; - - return FT_Get_Char_Index(f,c); -} -*/ - - -void -FontStyle::_SetFontFamily(FontFamily* family, uint16 id) -{ - fFamily = family; - fID = id; -} - - -uint16 -FontStyle::_TranslateStyleToFace(const char *name) const -{ - if (name == NULL) - return 0; - - BString string(name); - uint16 face = 0; - - if (string.IFindFirst("bold") >= 0) - face |= B_BOLD_FACE; - - if (string.IFindFirst("italic") >= 0 - || string.IFindFirst("oblique") >= 0) - face |= B_ITALIC_FACE; - - if (face == 0) - return B_REGULAR_FACE; - - return face; -} - - -// #pragma mark - - - -/*! - \brief Constructor \param namestr Name of the family */ FontFamily::FontFamily(const char *name, uint16 id) @@ -326,7 +94,7 @@ /*! \brief Adds the style to the family - \param face FreeType face handle used to obtain info about the font + \param style pointer to FontStyle object to be added */ bool FontFamily::AddStyle(FontStyle *style) @@ -440,7 +208,8 @@ FontStyle* FontFamily::GetStyleByID(uint16 id) const { - for (int32 i = 0; i < fStyles.CountItems(); i++) { + int32 count = fStyles.CountItems(); + for (int32 i = 0; i < count; i++) { FontStyle* style = fStyles.ItemAt(i); if (style->ID() == id) return style; @@ -456,7 +225,8 @@ // we currently only use bold/italic/regular faces face &= B_BOLD_FACE | B_ITALIC_FACE | B_REGULAR_FACE; - for (int32 i = 0; i < fStyles.CountItems(); i++) { + int32 count = fStyles.CountItems(); + for (int32 i = 0; i < count; i++) { FontStyle* style = fStyles.ItemAt(i); if (style->Face() == face) @@ -473,7 +243,8 @@ if (fFlags == kInvalidFamilyFlags) { fFlags = 0; - for (int32 i = 0; i < fStyles.CountItems(); i++) { + int32 count = fStyles.CountItems(); + for (int32 i = 0; i < count; i++) { FontStyle* style = fStyles.ItemAt(i); if (style->IsFixedWidth()) Modified: haiku/trunk/src/servers/app/FontFamily.h =================================================================== --- haiku/trunk/src/servers/app/FontFamily.h 2007-07-17 20:00:53 UTC (rev 21636) +++ haiku/trunk/src/servers/app/FontFamily.h 2007-07-17 20:48:06 UTC (rev 21637) @@ -10,178 +10,13 @@ #define FONT_FAMILY_H_ -#include -#include -#include #include -#include -#include #include -#include -#include FT_FREETYPE_H -#include "ReferenceCounting.h" -#include "HashTable.h" +#include "FontStyle.h" -struct node_ref; -class FontFamily; -class ServerFont; - -enum font_format { - FONT_TRUETYPE = 0, - FONT_TYPE_1, - FONT_OPENTYPE, - FONT_BDF, - FONT_CFF, - FONT_CID, - FONT_PCF, - FONT_PFR, - FONT_SFNT, - FONT_TYPE_42, - FONT_WINFONT, -}; - - -class FontKey : public Hashable { - public: - FontKey(uint16 familyID, uint16 styleID) - : fHash(familyID | (styleID << 16UL)) - { - } - virtual ~FontKey() {}; - - virtual uint32 Hash() const - { return fHash; } - virtual bool CompareTo(Hashable& other) const - { return fHash == other.Hash(); } - - private: - uint32 fHash; -}; - - /*! - \class FontStyle FontFamily.h - \brief Object used to represent a font style - - FontStyle objects help abstract a lot of the font engine details while - still offering plenty of information the style in question. -*/ -class FontStyle : public ReferenceCounting, public Hashable/*, public BLocker*/ { - public: - FontStyle(node_ref& nodeRef, const char* path, FT_Face face); - virtual ~FontStyle(); - - virtual uint32 Hash() const; - virtual bool CompareTo(Hashable& other) const; - - const node_ref& NodeRef() const { return fNodeRef; } - - bool Lock(); - void Unlock(); - -/*! - \fn bool FontStyle::IsFixedWidth(void) - \brief Determines whether the font's character width is fixed - \return true if fixed, false if not -*/ - bool IsFixedWidth() const - { return fFreeTypeFace->face_flags & FT_FACE_FLAG_FIXED_WIDTH; } -/*! - \fn bool FontStyle::IsScalable(void) - \brief Determines whether the font can be scaled to any size - \return true if scalable, false if not -*/ - bool IsScalable() const - { return fFreeTypeFace->face_flags & FT_FACE_FLAG_SCALABLE; } -/*! - \fn bool FontStyle::HasKerning(void) - \brief Determines whether the font has kerning information - \return true if kerning info is available, false if not -*/ - bool HasKerning() const - { return fFreeTypeFace->face_flags & FT_FACE_FLAG_KERNING; } -/*! - \fn bool FontStyle::HasTuned(void) - \brief Determines whether the font contains strikes - \return true if it has strikes included, false if not -*/ - bool HasTuned() const - { return fFreeTypeFace->num_fixed_sizes > 0; } -/*! - \fn bool FontStyle::TunedCount(void) - \brief Returns the number of strikes the style contains - \return The number of strikes the style contains -*/ - int32 TunedCount() const - { return fFreeTypeFace->num_fixed_sizes; } -/*! - \fn bool FontStyle::GlyphCount(void) - \brief Returns the number of glyphs in the style - \return The number of glyphs the style contains -*/ - uint16 GlyphCount() const - { return fFreeTypeFace->num_glyphs; } -/*! - \fn bool FontStyle::CharMapCount(void) - \brief Returns the number of character maps the style contains - \return The number of character maps the style contains -*/ - uint16 CharMapCount() const - { return fFreeTypeFace->num_charmaps; } - - const char* Name() const - { return fName.String(); } - FontFamily* Family() const - { return fFamily; } - uint16 ID() const - { return fID; } - uint32 Flags() const; - - uint16 Face() const - { return fFace; } - uint16 PreservedFace(uint16) const; - - const char* Path() const; - void UpdatePath(const node_ref& parentNodeRef); - - void GetHeight(float size, font_height &heigth) const; - font_direction Direction() const - { return B_FONT_LEFT_TO_RIGHT; } - font_file_format FileFormat() const - { return B_TRUETYPE_WINDOWS; } - - FT_Face FreeTypeFace() const - { return fFreeTypeFace; } - - status_t UpdateFace(FT_Face face); - -// TODO: Re-enable when I understand how the FT2 Cache system changed from -// 2.1.4 to 2.1.8 -// int16 ConvertToUnicode(uint16 c); - - private: - friend class FontFamily; - uint16 _TranslateStyleToFace(const char *name) const; - void _SetFontFamily(FontFamily* family, uint16 id); - - private: - FT_Face fFreeTypeFace; - BString fName; - BPath fPath; - node_ref fNodeRef; - - FontFamily* fFamily; - uint16 fID; - - BRect fBounds; - - font_height fHeight; - uint16 fFace; -}; - -/*! \class FontFamily FontFamily.h \brief Class representing a collection of similar styles @@ -189,33 +24,33 @@ Arial Roman, Arial Italic, Arial Bold, etc. */ class FontFamily { - public: - FontFamily(const char* name, uint16 id); - virtual ~FontFamily(); + public: + FontFamily(const char* name, uint16 id); + virtual ~FontFamily(); - const char* Name() const; + const char* Name() const; - bool AddStyle(FontStyle* style); - bool RemoveStyle(FontStyle* style); + bool AddStyle(FontStyle* style); + bool RemoveStyle(FontStyle* style); - FontStyle* GetStyle(const char* style) const; - FontStyle* GetStyleMatchingFace(uint16 face) const; - FontStyle* GetStyleByID(uint16 face) const; + FontStyle* GetStyle(const char* style) const; + FontStyle* GetStyleMatchingFace(uint16 face) const; + FontStyle* GetStyleByID(uint16 face) const; - uint16 ID() const - { return fID; } - uint32 Flags(); + uint16 ID() const + { return fID; } + uint32 Flags(); - bool HasStyle(const char* style) const; - int32 CountStyles() const; - FontStyle* StyleAt(int32 index) const; + bool HasStyle(const char* style) const; + int32 CountStyles() const; + FontStyle* StyleAt(int32 index) const; private: - BString fName; - BObjectList fStyles; - uint16 fID; - uint16 fNextID; - uint32 fFlags; + BString fName; + BObjectList fStyles; + uint16 fID; + uint16 fNextID; + uint32 fFlags; }; -#endif /* FONT_FAMILY_H_ */ +#endif // FONT_FAMILY_H_ Copied: haiku/trunk/src/servers/app/FontStyle.cpp (from rev 21572, haiku/trunk/src/servers/app/FontFamily.cpp) =================================================================== --- haiku/trunk/src/servers/app/FontFamily.cpp 2007-07-05 18:27:27 UTC (rev 21572) +++ haiku/trunk/src/servers/app/FontStyle.cpp 2007-07-17 20:48:06 UTC (rev 21637) @@ -0,0 +1,246 @@ +/* + * Copyright 2001-2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + * Axel D?rfler, axeld at pinc-software.de + */ + +/** Classes to represent font styles and families */ + + +#include "FontFamily.h" +#include "ServerFont.h" +#include "FontManager.h" + +#include + +#include + + +static BLocker sFontLock("font lock"); + + +/*! + \brief Constructor + \param filepath path to a font file + \param face FreeType handle for the font file after it is loaded - it will be kept open until the FontStyle is destroied +*/ +FontStyle::FontStyle(node_ref& nodeRef, const char* path, FT_Face face) + : //BLocker(BString("FontStyle_").Append(face->style_name).String()), + fFreeTypeFace(face), + fName(face->style_name), + fPath(path), + fNodeRef(nodeRef), + fFamily(NULL), + fID(0), + fBounds(0, 0, 0, 0), + fFace(_TranslateStyleToFace(face->style_name)) +{ + fName.Truncate(B_FONT_STYLE_LENGTH); + // make sure this style can be found using the Be API + + fHeight.ascent = (double)face->ascender / face->units_per_EM; + fHeight.descent = (double)-face->descender / face->units_per_EM; + // FT2's descent numbers are negative. Be's is positive + + // FT2 doesn't provide a linegap, but according to the docs, we can + // calculate it because height = ascending + descending + leading + fHeight.leading = (double)(face->height - face->ascender + face->descender) + / face->units_per_EM; +} + + +FontStyle::~FontStyle() +{ + // make sure the font server is ours + if (fFamily != NULL && gFontManager->Lock()) { + gFontManager->RemoveStyle(this); + gFontManager->Unlock(); + } + + FT_Done_Face(fFreeTypeFace); +} + + +uint32 +FontStyle::Hash() const +{ + return (ID() << 16) | fFamily->ID(); +} + + +bool +FontStyle::CompareTo(Hashable& other) const +{ + // our hash values are unique (unless you have more than 65536 font families installed...) + return Hash() == other.Hash(); +} + + +bool +FontStyle::Lock() +{ + return sFontLock.Lock(); +} + + +void +FontStyle::Unlock() +{ + sFontLock.Unlock(); +} + + +void +FontStyle::GetHeight(float size, font_height& height) const +{ + height.ascent = fHeight.ascent * size; + height.descent = fHeight.descent * size; + height.leading = fHeight.leading * size; +} + + +/*! + \brief Returns the path to the style's font file + \return The style's font file path +*/ +const char* +FontStyle::Path() const +{ + return fPath.Path(); +} + + +/*! + \brief Updates the path of the font style in case the style + has been moved around. +*/ +void +FontStyle::UpdatePath(const node_ref& parentNodeRef) +{ + entry_ref ref; + ref.device = parentNodeRef.device; + ref.directory = parentNodeRef.node; + ref.set_name(fPath.Leaf()); + + fPath.SetTo(&ref); +} + + +/*! + \brief Unlike BFont::Flags() this returns the extra flags field as used + in the private part of BFont. +*/ +uint32 +FontStyle::Flags() const +{ + uint32 flags = uint32(Direction()) << B_PRIVATE_FONT_DIRECTION_SHIFT; + + if (IsFixedWidth()) + flags |= B_IS_FIXED; + if (TunedCount() > 0) + flags |= B_HAS_TUNED_FONT; + if (HasKerning()) + flags |= B_PRIVATE_FONT_HAS_KERNING; + + return flags; +} + + +/*! + \brief Updates the given face to match the one from this style + + The specified font face often doesn't match the exact face of + a style. This method will preserve the attributes of the face + that this style does not alter, and will only update the + attributes that matter to this style. + The font renderer could then emulate the other face attributes + taking this style as a base. +*/ +uint16 +FontStyle::PreservedFace(uint16 face) const +{ + // TODO: make this better + face &= ~(B_REGULAR_FACE | B_BOLD_FACE | B_ITALIC_FACE); + face |= Face(); + + return face; +} + + +status_t +FontStyle::UpdateFace(FT_Face face) +{ + if (!sFontLock.IsLocked()) { + debugger("UpdateFace() called without having locked FontStyle!"); + return B_ERROR; + } + + // we only accept the face if it hasn't change its style + + BString name = face->style_name; + name.Truncate(B_FONT_STYLE_LENGTH); + + if (name != fName) + return B_BAD_VALUE; + + FT_Done_Face(fFreeTypeFace); + fFreeTypeFace = face; + return B_OK; +} + + +/*! + \brief Converts an ASCII character to Unicode for the style + \param c An ASCII character + \return A Unicode value for the character +*/ + +// TODO: Re-enable when I understand how the FT2 Cache system changed from +// 2.1.4 to 2.1.8 +/* +int16 +FontStyle::ConvertToUnicode(uint16 c) +{ + FT_Face f; + if(FTC_Manager_LookupFace(ftmanager,(FTC_FaceID)cachedface,&f)!=0) + return 0; + + return FT_Get_Char_Index(f,c); +} +*/ + + +void +FontStyle::_SetFontFamily(FontFamily* family, uint16 id) +{ + fFamily = family; + fID = id; +} + + +uint16 +FontStyle::_TranslateStyleToFace(const char *name) const +{ + if (name == NULL) + return 0; + + BString string(name); + uint16 face = 0; + + if (string.IFindFirst("bold") >= 0) + face |= B_BOLD_FACE; + + if (string.IFindFirst("italic") >= 0 + || string.IFindFirst("oblique") >= 0) + face |= B_ITALIC_FACE; + + if (face == 0) + return B_REGULAR_FACE; + + return face; +} + + Copied: haiku/trunk/src/servers/app/FontStyle.h (from rev 21572, haiku/trunk/src/servers/app/FontFamily.h) =================================================================== --- haiku/trunk/src/servers/app/FontFamily.h 2007-07-05 18:27:27 UTC (rev 21572) +++ haiku/trunk/src/servers/app/FontStyle.h 2007-07-17 20:48:06 UTC (rev 21637) @@ -0,0 +1,170 @@ +/* + * Copyright 2001-2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + * Axel D?rfler, axeld at pinc-software.de + */ +#ifndef FONT_STYLE_H_ +#define FONT_STYLE_H_ + + +#include +#include +#include +#include +#include +#include +#include + +#include +#include FT_FREETYPE_H +#include "ReferenceCounting.h" +#include "HashTable.h" + + +struct node_ref; +class FontFamily; +class ServerFont; + + +class FontKey : public Hashable { + public: + FontKey(uint16 familyID, uint16 styleID) + : fHash(familyID | (styleID << 16UL)) + { + } + virtual ~FontKey() {}; + + virtual uint32 Hash() const + { return fHash; } + virtual bool CompareTo(Hashable& other) const + { return fHash == other.Hash(); } + + private: + uint32 fHash; +}; + + +/*! + \class FontStyle FontStyle.h + \brief Object used to represent a font style + + FontStyle objects help abstract a lot of the font engine details while + still offering plenty of information the style in question. +*/ +class FontStyle : public ReferenceCounting, public Hashable/*, public BLocker*/ { + public: + FontStyle(node_ref& nodeRef, const char* path, FT_Face face); + virtual ~FontStyle(); + + virtual uint32 Hash() const; + virtual bool CompareTo(Hashable& other) const; + + const node_ref& NodeRef() const { return fNodeRef; } + + bool Lock(); + void Unlock(); + +/*! + \fn bool FontStyle::IsFixedWidth(void) + \brief Determines whether the font's character width is fixed + \return true if fixed, false if not +*/ + bool IsFixedWidth() const + { return fFreeTypeFace->face_flags & FT_FACE_FLAG_FIXED_WIDTH; } +/*! + \fn bool FontStyle::IsScalable(void) + \brief Determines whether the font can be scaled to any size + \return true if scalable, false if not +*/ + bool IsScalable() const + { return fFreeTypeFace->face_flags & FT_FACE_FLAG_SCALABLE; } +/*! + \fn bool FontStyle::HasKerning(void) + \brief Determines whether the font has kerning information + \return true if kerning info is available, false if not +*/ + bool HasKerning() const + { return fFreeTypeFace->face_flags & FT_FACE_FLAG_KERNING; } +/*! + \fn bool FontStyle::HasTuned(void) + \brief Determines whether the font contains strikes + \return true if it has strikes included, false if not +*/ + bool HasTuned() const + { return fFreeTypeFace->num_fixed_sizes > 0; } +/*! + \fn bool FontStyle::TunedCount(void) + \brief Returns the number of strikes the style contains + \return The number of strikes the style contains +*/ + int32 TunedCount() const + { return fFreeTypeFace->num_fixed_sizes; } +/*! + \fn bool FontStyle::GlyphCount(void) + \brief Returns the number of glyphs in the style + \return The number of glyphs the style contains +*/ + uint16 GlyphCount() const + { return fFreeTypeFace->num_glyphs; } +/*! + \fn bool FontStyle::CharMapCount(void) + \brief Returns the number of character maps the style contains + \return The number of character maps the style contains +*/ + uint16 CharMapCount() const + { return fFreeTypeFace->num_charmaps; } + + const char* Name() const + { return fName.String(); } + FontFamily* Family() const + { return fFamily; } + uint16 ID() const + { return fID; } + uint32 Flags() const; + + uint16 Face() const + { return fFace; } + uint16 PreservedFace(uint16) const; + + const char* Path() const; + void UpdatePath(const node_ref& parentNodeRef); + + void GetHeight(float size, font_height &heigth) const; + font_direction Direction() const + { return B_FONT_LEFT_TO_RIGHT; } + font_file_format FileFormat() const + { return B_TRUETYPE_WINDOWS; } + + FT_Face FreeTypeFace() const + { return fFreeTypeFace; } + + status_t UpdateFace(FT_Face face); + +// TODO: Re-enable when I understand how the FT2 Cache system changed from +// 2.1.4 to 2.1.8 +// int16 ConvertToUnicode(uint16 c); + + private: + friend class FontFamily; + uint16 _TranslateStyleToFace(const char *name) const; + void _SetFontFamily(FontFamily* family, uint16 id); + + private: + FT_Face fFreeTypeFace; + BString fName; + BPath fPath; + node_ref fNodeRef; + + FontFamily* fFamily; + uint16 fID; + + BRect fBounds; + + font_height fHeight; + uint16 fFace; +}; + +#endif // FONT_STYLE_H_ Modified: haiku/trunk/src/servers/app/Jamfile =================================================================== --- haiku/trunk/src/servers/app/Jamfile 2007-07-17 20:00:53 UTC (rev 21636) +++ haiku/trunk/src/servers/app/Jamfile 2007-07-17 20:48:06 UTC (rev 21637) @@ -4,6 +4,7 @@ UsePrivateHeaders app graphics input interface kernel shared storage ; UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing ] ; +UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing Painter ] ; UseFreeTypeHeaders ; @@ -27,6 +28,7 @@ EventStream.cpp FontFamily.cpp FontManager.cpp + FontStyle.cpp HashTable.cpp InputManager.cpp IntPoint.cpp Modified: haiku/trunk/src/tests/servers/app/Jamfile =================================================================== --- haiku/trunk/src/tests/servers/app/Jamfile 2007-07-17 20:00:53 UTC (rev 21636) +++ haiku/trunk/src/tests/servers/app/Jamfile 2007-07-17 20:48:06 UTC (rev 21637) @@ -65,6 +65,7 @@ DrawState.cpp FontFamily.cpp FontManager.cpp + FontStyle.cpp HashTable.cpp IntPoint.cpp IntRect.cpp From stippi at mail.berlios.de Tue Jul 17 22:48:54 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 17 Jul 2007 22:48:54 +0200 Subject: [Haiku-commits] r21638 - haiku/trunk/src/servers/app Message-ID: <200707172048.l6HKmsgt010402@sheep.berlios.de> Author: stippi Date: 2007-07-17 22:48:54 +0200 (Tue, 17 Jul 2007) New Revision: 21638 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21638&view=rev Modified: haiku/trunk/src/servers/app/ServerFont.h Log: * make sure that the 80 chars per line limit is not exceeded Modified: haiku/trunk/src/servers/app/ServerFont.h =================================================================== --- haiku/trunk/src/servers/app/ServerFont.h 2007-07-17 20:48:06 UTC (rev 21637) +++ haiku/trunk/src/servers/app/ServerFont.h 2007-07-17 20:48:54 UTC (rev 21638) @@ -113,7 +113,8 @@ { return fStyle->CharMapCount(); } - FT_Face GetTransformedFace(bool rotate, bool shear) const; + FT_Face GetTransformedFace(bool rotate, + bool shear) const; void PutTransformedFace(FT_Face face) const; status_t GetGlyphShapes(const char charArray[], @@ -122,8 +123,8 @@ status_t GetHasGlyphs(const char charArray[], int32 numChars, bool hasArray[]) const; - status_t GetEdges(const char charArray[], - int32 numChars, edge_info edgeArray[]) const; + status_t GetEdges(const char charArray[], int32 numChars, + edge_info edgeArray[]) const; status_t GetEscapements(const char charArray[], int32 numChars, escapement_delta delta, @@ -136,7 +137,8 @@ status_t GetBoundingBoxesAsString(const char charArray[], int32 numChars, BRect rectArray[], - bool stringEscapement, font_metric_mode mode, + bool stringEscapement, + font_metric_mode mode, escapement_delta delta); status_t GetBoundingBoxesForStrings(char *charArray[], @@ -144,7 +146,8 @@ BRect rectArray[], font_metric_mode mode, escapement_delta deltaArray[]); - float StringWidth(const char *string, int32 numChars) const; + float StringWidth(const char *string, + int32 numChars) const; bool Lock() const { return fStyle->Lock(); } void Unlock() const { fStyle->Unlock(); } From stippi at mail.berlios.de Tue Jul 17 22:52:47 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 17 Jul 2007 22:52:47 +0200 Subject: [Haiku-commits] r21639 - haiku/trunk/src/servers/app/drawing Message-ID: <200707172052.l6HKqlAc010704@sheep.berlios.de> Author: stippi Date: 2007-07-17 22:52:47 +0200 (Tue, 17 Jul 2007) New Revision: 21639 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21639&view=rev Modified: haiku/trunk/src/servers/app/drawing/PatternHandler.cpp haiku/trunk/src/servers/app/drawing/PatternHandler.h Log: * one can now specify and "offset" which will be taken into account when looking up the color in the pattern, this is needed because before, patterns were always drawn with the virtual origin in screen coordinate space, but they need to be drawn with view coordinate origin taken into account (will be implemented in a forthcomming commit) Modified: haiku/trunk/src/servers/app/drawing/PatternHandler.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/PatternHandler.cpp 2007-07-17 20:48:54 UTC (rev 21638) +++ haiku/trunk/src/servers/app/drawing/PatternHandler.cpp 2007-07-17 20:52:47 UTC (rev 21639) @@ -1,33 +1,17 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2005, Haiku, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: PatternHandler.cpp -// Author: DarkWyrm -// Stephan A?mus -// Description: Class for easy calculation and use of patterns -// -//------------------------------------------------------------------------------ -#include +/* + * Copyright (c) 2001-2007, Haiku, Inc. + * Distributed under the terms of the MIT license. + * + * Author: DarkWyrm + * Stephan A?mus + */ + #include "PatternHandler.h" +#include + +#include + const Pattern kSolidHigh(0xFFFFFFFFFFFFFFFFLL); const Pattern kSolidLow((uint64)0); const Pattern kMixedColors(0xAAAAAAAAAAAAAAAALL); @@ -44,7 +28,9 @@ PatternHandler::PatternHandler(void) : fPattern(kSolidHigh), fHighColor(kBlack), - fLowColor(kWhite) + fLowColor(kWhite), + fXOffset(0), + fYOffset(0) { } @@ -58,7 +44,9 @@ PatternHandler::PatternHandler(const int8* pat) : fPattern(pat ? Pattern(pat) : Pattern(kSolidHigh)), fHighColor(kBlack), - fLowColor(kWhite) + fLowColor(kWhite), + fXOffset(0), + fYOffset(0) { } @@ -72,7 +60,9 @@ PatternHandler::PatternHandler(const uint64& pat) : fPattern(pat), fHighColor(kBlack), - fLowColor(kWhite) + fLowColor(kWhite), + fXOffset(0), + fYOffset(0) { } @@ -86,7 +76,9 @@ PatternHandler::PatternHandler(const Pattern& pat) : fPattern(pat), fHighColor(kBlack), - fLowColor(kWhite) + fLowColor(kWhite), + fXOffset(0), + fYOffset(0) { } @@ -99,7 +91,9 @@ PatternHandler::PatternHandler(const PatternHandler& other) : fPattern(other.fPattern), fHighColor(other.fHighColor), - fLowColor(other.fLowColor) + fLowColor(other.fLowColor), + fXOffset(other.fXOffset), + fYOffset(other.fYOffset) { } @@ -115,7 +109,8 @@ This initializes to the given pattern or B_SOLID_HIGH if the pattern is NULL. */ -void PatternHandler::SetPattern(const int8* pat) +void +PatternHandler::SetPattern(const int8* pat) { if (pat) fPattern.Set(pat); @@ -127,7 +122,8 @@ \brief Sets the pattern for the handler to the one given \param pat Pattern to use. */ -void PatternHandler::SetPattern(const uint64& pat) +void +PatternHandler::SetPattern(const uint64& pat) { fPattern = pat; } @@ -136,7 +132,8 @@ \brief Sets the pattern for the handler to the one given \param pat Pattern to use. */ -void PatternHandler::SetPattern(const Pattern& pat) +void +PatternHandler::SetPattern(const Pattern& pat) { fPattern = pat; } @@ -145,7 +142,8 @@ \brief Sets the pattern for the handler to the one given \param pat R5 style pattern to use. */ -void PatternHandler::SetPattern(const pattern& pat) +void +PatternHandler::SetPattern(const pattern& pat) { fPattern = pat; } @@ -155,7 +153,8 @@ \param high High color for the handler \param low Low color for the handler */ -void PatternHandler::SetColors(const RGBColor& high, const RGBColor& low) +void +PatternHandler::SetColors(const RGBColor& high, const RGBColor& low) { fHighColor = high; fLowColor = low; @@ -165,7 +164,8 @@ \brief Set the high color for the pattern to use \param color High color for the handler */ -void PatternHandler::SetHighColor(const RGBColor& color) +void +PatternHandler::SetHighColor(const RGBColor& color) { fHighColor = color; } @@ -174,7 +174,8 @@ \brief Set the low color for the pattern to use \param color Low color for the handler */ -void PatternHandler::SetLowColor(const RGBColor& color) +void +PatternHandler::SetLowColor(const RGBColor& color) { fLowColor = color; } @@ -184,7 +185,8 @@ \param high High color for the handler \param low Low color for the handler */ -void PatternHandler::SetColors(const rgb_color& high, const rgb_color& low) +void +PatternHandler::SetColors(const rgb_color& high, const rgb_color& low) { fHighColor = high; fLowColor = low; @@ -194,7 +196,8 @@ \brief Set the high color for the pattern to use \param color High color for the handler */ -void PatternHandler::SetHighColor(const rgb_color& color) +void +PatternHandler::SetHighColor(const rgb_color& color) { fHighColor = color; } @@ -203,7 +206,8 @@ \brief Set the low color for the pattern to use \param color Low color for the handler */ -void PatternHandler::SetLowColor(const rgb_color& color) +void +PatternHandler::SetLowColor(const rgb_color& color) { fLowColor = color; } @@ -236,8 +240,21 @@ \param pt Coordinates to get the value for \return Value for the coordinates - true if high, false if low. */ -bool PatternHandler::IsHighColor(const BPoint &pt) const +bool +PatternHandler::IsHighColor(const BPoint &pt) const { return IsHighColor((int)pt.x, (int)pt.y); } +/*! + \brief Transfers the scrolling offset of a BView to affect the pattern. + \param x Positive or negative horizontal offset + \param y Positive or negative vertical offset +*/ +void +PatternHandler::SetOffsets(int32 x, int32 y) +{ + fXOffset = x & 7; + fYOffset = y & 7; +} + Modified: haiku/trunk/src/servers/app/drawing/PatternHandler.h =================================================================== --- haiku/trunk/src/servers/app/drawing/PatternHandler.h 2007-07-17 20:48:54 UTC (rev 21638) +++ haiku/trunk/src/servers/app/drawing/PatternHandler.h 2007-07-17 20:52:47 UTC (rev 21639) @@ -1,33 +1,15 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2005, Haiku, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: PatternHandler.h -// Author: DarkWyrm -// Stephan A?mus -// Description: Class for easy calculation and use of patterns -// -//------------------------------------------------------------------------------ +/* + * Copyright (c) 2001-2007, Haiku, Inc. + * Distributed under the terms of the MIT license. + * + * Author: DarkWyrm + * Stephan A?mus + */ + #ifndef PATTERNHANDLER_H #define PATTERNHANDLER_H +#include #include #include #include "RGBColor.h" @@ -146,10 +128,16 @@ { return (const pattern*)fPattern.GetInt8(); } const Pattern& GetPattern(void) const { return fPattern; } + + void SetOffsets(int32 x, int32 y); + private: Pattern fPattern; RGBColor fHighColor; RGBColor fLowColor; + + uint16 fXOffset; + uint16 fYOffset; }; /*! @@ -181,16 +169,16 @@ \param pt Coordinates to get the value for \return Value for the coordinates - true if high, false if low. */ + inline bool PatternHandler::IsHighColor(int x, int y) const { - // TODO: Does this work correctly for - // negative coordinates?!? + x -= fXOffset; + y -= fYOffset; const int8* ptr = fPattern.GetInt8(); - int32 value = ptr[y % 8] & (1 << (7 - (x % 8)) ); + int32 value = ptr[y & 7] & (1 << (7 - (x & 7)) ); - return (value == 0) ? false : true; - + return value != 0; } #endif From axeld at mail.berlios.de Wed Jul 18 01:37:42 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 18 Jul 2007 01:37:42 +0200 Subject: [Haiku-commits] r21640 - haiku/trunk/build/jam Message-ID: <200707172337.l6HNbg9d002907@sheep.berlios.de> Author: axeld Date: 2007-07-18 01:37:40 +0200 (Wed, 18 Jul 2007) New Revision: 21640 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21640&view=rev Modified: haiku/trunk/build/jam/BuildSetup haiku/trunk/build/jam/HaikuImage haiku/trunk/build/jam/ImageRules Log: Fixed update-image and update-install which were broken after the NetBootArchive changes, courtesy Ingo. Modified: haiku/trunk/build/jam/BuildSetup =================================================================== --- haiku/trunk/build/jam/BuildSetup 2007-07-17 20:52:47 UTC (rev 21639) +++ haiku/trunk/build/jam/BuildSetup 2007-07-17 23:37:40 UTC (rev 21640) @@ -11,6 +11,25 @@ # directory paths and the like. +#pragma mark - container settings + +# Haiku image +HAIKU_IMAGE_CONTAINER_NAME = haiku-image-container ; +HAIKU_CONTAINER_GRIST on $(HAIKU_IMAGE_CONTAINER_NAME) = HaikuImage ; +HAIKU_INCLUDE_IN_CONTAINER_VAR on $(HAIKU_IMAGE_CONTAINER_NAME) + = HAIKU_INCLUDE_IN_IMAGE ; +HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_IMAGE_CONTAINER_NAME) + = HAIKU_IMAGE_INSTALL_TARGETS ; + +# network boot archive +HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME = haiku-netboot-archive-container ; +HAIKU_CONTAINER_GRIST on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) + = NetBootArchive ; +# HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported +HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) + = HAIKU_NET_BOOT_ARCHIVE_INSTALL_TARGETS ; + + # analyze an optionally replace jam's target parameters HAIKU_ORIGINAL_JAM_TARGETS = $(JAM_TARGETS) ; if $(JAM_TARGETS) { @@ -724,25 +743,6 @@ } -#pragma mark - container settings - -# Haiku image -HAIKU_IMAGE_CONTAINER_NAME = haiku-image-container ; -HAIKU_CONTAINER_GRIST on $(HAIKU_IMAGE_CONTAINER_NAME) = HaikuImage ; -HAIKU_INCLUDE_IN_CONTAINER_VAR on $(HAIKU_IMAGE_CONTAINER_NAME) - = HAIKU_INCLUDE_IN_IMAGE ; -HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_IMAGE_CONTAINER_NAME) - = HAIKU_IMAGE_INSTALL_TARGETS ; - -# network boot archive -HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME = haiku-netboot-archive-container ; -HAIKU_CONTAINER_GRIST on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) - = NetBootArchive ; -# HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported -HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) - = HAIKU_NET_BOOT_ARCHIVE_INSTALL_TARGETS ; - - #pragma mark - # common stuff Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-07-17 20:52:47 UTC (rev 21639) +++ haiku/trunk/build/jam/HaikuImage 2007-07-17 23:37:40 UTC (rev 21640) @@ -415,7 +415,7 @@ AddVariableToScript $(script) : imageSize : $(HAIKU_IMAGE_SIZE) ; AddVariableToScript $(script) : addBuildCompatibilityLibDir : $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) ; -AddVariableToScript $(script) : updateOnly : $(HAIKU_IMAGE_UPDATE_ONLY) ; +AddVariableToScript $(script) : updateOnly : [ IsUpdateHaikuImageOnly ] ; AddTargetVariableToScript $(script) : bfs_shell : bfsShell ; AddTargetVariableToScript $(script) : fs_shell_command : fsShellCommand ; AddTargetVariableToScript $(script) : copyattr ; Modified: haiku/trunk/build/jam/ImageRules =================================================================== --- haiku/trunk/build/jam/ImageRules 2007-07-17 20:52:47 UTC (rev 21639) +++ haiku/trunk/build/jam/ImageRules 2007-07-17 23:37:40 UTC (rev 21640) @@ -413,6 +413,11 @@ HAIKU_CONTAINER_UPDATE_ONLY on $(HAIKU_IMAGE_CONTAINER_NAME) = $(flag) ; } +rule IsUpdateHaikuImageOnly +{ + on $(HAIKU_IMAGE_CONTAINER_NAME) return $(HAIKU_CONTAINER_UPDATE_ONLY) ; +} + rule AddDirectoryToHaikuImage directoryTokens { # AddDirectoryToHaikuImage From axeld at mail.berlios.de Wed Jul 18 01:40:41 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 18 Jul 2007 01:40:41 +0200 Subject: [Haiku-commits] r21641 - haiku/trunk/src/system/kernel Message-ID: <200707172340.l6HNefgR003150@sheep.berlios.de> Author: axeld Date: 2007-07-18 01:40:41 +0200 (Wed, 18 Jul 2007) New Revision: 21641 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21641&view=rev Modified: haiku/trunk/src/system/kernel/lock.c Log: Minor cleanup. Modified: haiku/trunk/src/system/kernel/lock.c =================================================================== --- haiku/trunk/src/system/kernel/lock.c 2007-07-17 23:37:40 UTC (rev 21640) +++ haiku/trunk/src/system/kernel/lock.c 2007-07-17 23:40:41 UTC (rev 21641) @@ -141,8 +141,10 @@ if (status < B_OK) return status; - if (me == mutex->holder) - panic("mutex_lock failure: mutex %p (sem = 0x%lx) acquired twice by thread 0x%lx\n", mutex, mutex->sem, me); + if (me == mutex->holder) { + panic("mutex_lock failure: mutex %p (sem = 0x%lx) acquired twice by" + " thread 0x%lx\n", mutex, mutex->sem, me); + } mutex->holder = me; return B_OK; @@ -158,8 +160,8 @@ return; if (me != mutex->holder) { - panic("mutex_unlock failure: thread 0x%lx is trying to release mutex %p (current holder 0x%lx)\n", - me, mutex, mutex->holder); + panic("mutex_unlock failure: thread 0x%lx is trying to release mutex %p" + " (current holder 0x%lx)\n", me, mutex, mutex->holder); } mutex->holder = -1; From axeld at mail.berlios.de Wed Jul 18 02:16:35 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 18 Jul 2007 02:16:35 +0200 Subject: [Haiku-commits] r21642 - in haiku/trunk: headers/private/kernel src/system/kernel/cache src/system/kernel/fs src/system/kernel/vm Message-ID: <200707180016.l6I0GZFL006243@sheep.berlios.de> Author: axeld Date: 2007-07-18 02:16:27 +0200 (Wed, 18 Jul 2007) New Revision: 21642 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21642&view=rev Added: haiku/trunk/src/system/kernel/vm/vm_cache.cpp Removed: haiku/trunk/src/system/kernel/vm/vm_cache.c Modified: haiku/trunk/headers/private/kernel/file_cache.h haiku/trunk/headers/private/kernel/vfs.h haiku/trunk/headers/private/kernel/vm.h haiku/trunk/headers/private/kernel/vm_cache.h haiku/trunk/headers/private/kernel/vm_types.h haiku/trunk/src/system/kernel/cache/file_cache.cpp haiku/trunk/src/system/kernel/fs/vfs.cpp haiku/trunk/src/system/kernel/vm/Jamfile haiku/trunk/src/system/kernel/vm/vm.cpp haiku/trunk/src/system/kernel/vm/vm_page.c Log: * Merged vm_cache_ref and vm_cache to a single structure (Axel & Ingo). * Renamed vm_cache.c to vm_cache.cpp Modified: haiku/trunk/headers/private/kernel/file_cache.h =================================================================== --- haiku/trunk/headers/private/kernel/file_cache.h 2007-07-17 23:40:41 UTC (rev 21641) +++ haiku/trunk/headers/private/kernel/file_cache.h 2007-07-18 00:16:27 UTC (rev 21642) @@ -37,9 +37,9 @@ extern "C" { #endif -extern void cache_node_opened(void *vnode, int32 fdType, vm_cache_ref *cache, +extern void cache_node_opened(void *vnode, int32 fdType, vm_cache *cache, dev_t mountID, ino_t parentID, ino_t vnodeID, const char *name); -extern void cache_node_closed(void *vnode, int32 fdType, vm_cache_ref *cache, +extern void cache_node_closed(void *vnode, int32 fdType, vm_cache *cache, dev_t mountID, ino_t vnodeID); extern void cache_node_launched(size_t argCount, char * const *args); extern void cache_prefetch_vnode(void *vnode, off_t offset, size_t size); Modified: haiku/trunk/headers/private/kernel/vfs.h =================================================================== --- haiku/trunk/headers/private/kernel/vfs.h 2007-07-17 23:40:41 UTC (rev 21641) +++ haiku/trunk/headers/private/kernel/vfs.h 2007-07-18 00:16:27 UTC (rev 21642) @@ -27,7 +27,7 @@ #define MAX_NODE_MONITORS 65536 struct kernel_args; -struct vm_cache_ref; +struct vm_cache; struct file_descriptor; struct selectsync; struct pollfd; @@ -91,7 +91,7 @@ const iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter); status_t vfs_write_pages(void *vnode, void *cookie, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter); -status_t vfs_get_vnode_cache(void *vnode, struct vm_cache_ref **_cache, bool allocate); +status_t vfs_get_vnode_cache(void *vnode, struct vm_cache **_cache, bool allocate); status_t vfs_get_file_map( void *_vnode, off_t offset, size_t size, struct file_io_vec *vecs, size_t *_count); status_t vfs_get_fs_node_from_path(dev_t mountID, const char *path, Modified: haiku/trunk/headers/private/kernel/vm.h =================================================================== --- haiku/trunk/headers/private/kernel/vm.h 2007-07-17 23:40:41 UTC (rev 21641) +++ haiku/trunk/headers/private/kernel/vm.h 2007-07-18 00:16:27 UTC (rev 21642) @@ -55,6 +55,8 @@ area_id vm_map_file(team_id aid, const char *name, void **address, uint32 addressSpec, addr_t size, uint32 protection, uint32 mapping, const char *path, off_t offset); +vm_cache *vm_area_get_locked_cache(vm_area *area); +void vm_area_put_locked_cache(vm_cache *cache); area_id vm_create_null_area(team_id team, const char *name, void **address, uint32 addressSpec, addr_t size); area_id vm_copy_area(team_id team, const char *name, void **_address, @@ -63,7 +65,7 @@ uint32 addressSpec, uint32 protection, uint32 mapping, area_id sourceArea); status_t vm_delete_area(team_id aid, area_id id); -status_t vm_create_vnode_cache(void *vnode, vm_cache_ref **_cacheRef); +status_t vm_create_vnode_cache(void *vnode, vm_cache **_cache); vm_area *vm_area_lookup(vm_address_space *addressSpace, addr_t address); status_t vm_set_area_memory_type(area_id id, addr_t physicalBase, uint32 type); status_t vm_get_page_mapping(team_id team, addr_t vaddr, addr_t *paddr); Modified: haiku/trunk/headers/private/kernel/vm_cache.h =================================================================== --- haiku/trunk/headers/private/kernel/vm_cache.h 2007-07-17 23:40:41 UTC (rev 21641) +++ haiku/trunk/headers/private/kernel/vm_cache.h 2007-07-18 00:16:27 UTC (rev 21642) @@ -21,19 +21,18 @@ status_t vm_cache_init(struct kernel_args *args); vm_cache *vm_cache_create(vm_store *store); -status_t vm_cache_ref_create(vm_cache *cache, bool acquireLock); -void vm_cache_acquire_ref(vm_cache_ref *cache_ref); -void vm_cache_release_ref(vm_cache_ref *cache_ref); -vm_page *vm_cache_lookup_page(vm_cache_ref *cacheRef, off_t page); -void vm_cache_insert_page(vm_cache_ref *cacheRef, vm_page *page, off_t offset); -void vm_cache_remove_page(vm_cache_ref *cacheRef, vm_page *page); -void vm_cache_remove_consumer(vm_cache_ref *cacheRef, vm_cache *consumer); -void vm_cache_add_consumer_locked(vm_cache_ref *cacheRef, vm_cache *consumer); -status_t vm_cache_write_modified(vm_cache_ref *ref, bool fsReenter); -status_t vm_cache_set_minimal_commitment_locked(vm_cache_ref *ref, off_t commitment); -status_t vm_cache_resize(vm_cache_ref *cacheRef, off_t newSize); -status_t vm_cache_insert_area_locked(vm_cache_ref *cacheRef, vm_area *area); -status_t vm_cache_remove_area(vm_cache_ref *cacheRef, vm_area *area); +void vm_cache_acquire_ref(vm_cache *cache); +void vm_cache_release_ref(vm_cache *cache); +vm_page *vm_cache_lookup_page(vm_cache *cache, off_t page); +void vm_cache_insert_page(vm_cache *cache, vm_page *page, off_t offset); +void vm_cache_remove_page(vm_cache *cache, vm_page *page); +void vm_cache_remove_consumer(vm_cache *cache, vm_cache *consumer); +void vm_cache_add_consumer_locked(vm_cache *cache, vm_cache *consumer); +status_t vm_cache_write_modified(vm_cache *cache, bool fsReenter); +status_t vm_cache_set_minimal_commitment_locked(vm_cache *cache, off_t commitment); +status_t vm_cache_resize(vm_cache *cache, off_t newSize); +status_t vm_cache_insert_area_locked(vm_cache *cache, vm_area *area); +status_t vm_cache_remove_area(vm_cache *cache, vm_area *area); #ifdef __cplusplus } Modified: haiku/trunk/headers/private/kernel/vm_types.h =================================================================== --- haiku/trunk/headers/private/kernel/vm_types.h 2007-07-17 23:40:41 UTC (rev 21641) +++ haiku/trunk/headers/private/kernel/vm_types.h 2007-07-18 00:16:27 UTC (rev 21642) @@ -125,23 +125,15 @@ CACHE_TYPE_NULL }; -// vm_cache_ref -typedef struct vm_cache_ref { - struct vm_cache *cache; +// vm_cache +typedef struct vm_cache { mutex lock; - struct vm_area *areas; - vint32 ref_count; -} vm_cache_ref; - -// vm_cache -typedef struct vm_cache { struct list_link consumer_link; struct list consumers; // list of caches that use this cache as a source vm_page *page_list; - vm_cache_ref *ref; struct vm_cache *source; struct vm_store *store; off_t virtual_base; @@ -165,7 +157,8 @@ uint16 memory_type; vint32 ref_count; - struct vm_cache_ref *cache_ref; + struct vm_cache *cache; + vint32 no_cache_change; off_t cache_offset; uint32 cache_type; vm_area_mappings mappings; Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_cache.cpp 2007-07-17 23:40:41 UTC (rev 21641) +++ haiku/trunk/src/system/kernel/cache/file_cache.cpp 2007-07-18 00:16:27 UTC (rev 21642) @@ -60,7 +60,7 @@ }; struct file_cache_ref { - vm_cache_ref *cache; + vm_cache *cache; void *vnode; void *device; void *cookie; @@ -520,7 +520,7 @@ TRACE(("read_chunk(offset = %Ld, size = %lu, pageOffset = %ld, buffer = %#lx, bufferSize = %lu\n", offset, size, pageOffset, buffer, bufferSize)); - vm_cache_ref *cache = ref->cache; + vm_cache *cache = ref->cache; iovec vecs[MAX_IO_VECS]; int32 vecCount = 0; @@ -713,9 +713,10 @@ addr_t last = (addr_t)vecs[vecCount - 1].iov_base + vecs[vecCount - 1].iov_len - B_PAGE_SIZE; - if (offset + pageOffset + bufferSize == ref->cache->cache->virtual_size) { + if (offset + pageOffset + bufferSize == ref->cache->virtual_size) { // the space in the page after this write action needs to be cleaned - memset((void *)(last + lastPageOffset), 0, B_PAGE_SIZE - lastPageOffset); + memset((void *)(last + lastPageOffset), 0, + B_PAGE_SIZE - lastPageOffset); } else if (vecCount > 1) { // the end of this write does not happen on a page boundary, so we // need to fetch the last page before we can update it @@ -842,8 +843,8 @@ panic("cache_io() called with NULL ref!\n"); file_cache_ref *ref = (file_cache_ref *)_cacheRef; - vm_cache_ref *cache = ref->cache; - off_t fileSize = cache->cache->virtual_size; + vm_cache *cache = ref->cache; + off_t fileSize = cache->virtual_size; TRACE(("cache_io(ref = %p, offset = %Ld, buffer = %p, size = %lu, %s)\n", ref, offset, (void *)buffer, *_size, doWrite ? "write" : "read")); @@ -1084,12 +1085,13 @@ extern "C" void cache_prefetch_vnode(void *vnode, off_t offset, size_t size) { - vm_cache_ref *cache; + vm_cache *cache; if (vfs_get_vnode_cache(vnode, &cache, false) != B_OK) return; - file_cache_ref *ref = (struct file_cache_ref *)((vnode_store *)cache->cache->store)->file_cache_ref; - off_t fileSize = cache->cache->virtual_size; + file_cache_ref *ref = (struct file_cache_ref *) + ((vnode_store *)cache->store)->file_cache_ref; + off_t fileSize = cache->virtual_size; if (size > fileSize) size = fileSize; @@ -1160,7 +1162,7 @@ extern "C" void -cache_node_opened(void *vnode, int32 fdType, vm_cache_ref *cache, dev_t mountID, +cache_node_opened(void *vnode, int32 fdType, vm_cache *cache, dev_t mountID, ino_t parentID, ino_t vnodeID, const char *name) { if (sCacheModule == NULL || sCacheModule->node_opened == NULL) @@ -1168,9 +1170,10 @@ off_t size = -1; if (cache != NULL) { - file_cache_ref *ref = (file_cache_ref *)((vnode_store *)cache->cache->store)->file_cache_ref; + file_cache_ref *ref = (file_cache_ref *) + ((vnode_store *)cache->store)->file_cache_ref; if (ref != NULL) - size = ref->cache->cache->virtual_size; + size = cache->virtual_size; } sCacheModule->node_opened(vnode, fdType, mountID, parentID, vnodeID, name, size); @@ -1178,7 +1181,7 @@ extern "C" void -cache_node_closed(void *vnode, int32 fdType, vm_cache_ref *cache, +cache_node_closed(void *vnode, int32 fdType, vm_cache *cache, dev_t mountID, ino_t vnodeID) { if (sCacheModule == NULL || sCacheModule->node_closed == NULL) @@ -1237,7 +1240,7 @@ if (ref == NULL) return NULL; - // TODO: delay vm_cache/vm_cache_ref creation until data is + // TODO: delay vm_cache creation until data is // requested/written for the first time? Listing lots of // files in Tracker (and elsewhere) could be slowed down. // Since the file_cache_ref itself doesn't have a lock, @@ -1255,7 +1258,8 @@ if (vfs_get_cookie_from_fd(fd, &ref->cookie) != B_OK) goto err2; - // Get the vnode for the object (note, this does not grab a reference to the node) + // Get the vnode for the object + // (note, this does not grab a reference to the node) if (vfs_lookup_vnode(mountID, vnodeID, &ref->vnode) != B_OK) goto err2; @@ -1270,8 +1274,8 @@ // we don't grab an extra reference). vfs_put_vnode(ref->vnode); - ref->cache->cache->virtual_size = size; - ((vnode_store *)ref->cache->cache->store)->file_cache_ref = ref; + ref->cache->virtual_size = size; + ((vnode_store *)ref->cache->store)->file_cache_ref = ref; return ref; err2: Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-07-17 23:40:41 UTC (rev 21641) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-07-18 00:16:27 UTC (rev 21642) @@ -65,7 +65,7 @@ struct vnode { struct vnode *next; - vm_cache_ref *cache; + vm_cache *cache; dev_t device; list_link mount_link; list_link unused_link; @@ -2415,13 +2415,14 @@ // count pages in cache size_t numPages = 0; - for (struct vm_page *page = vnode->cache->cache->page_list; + for (struct vm_page *page = vnode->cache->page_list; page != NULL; page = page->cache_next) { numPages++; } - kprintf("%p%4ld%10Ld %p %8Ld%8ld\n", vnode, vnode->device, vnode->id, vnode->cache, - (vnode->cache->cache->virtual_size + B_PAGE_SIZE - 1) / B_PAGE_SIZE, numPages); + kprintf("%p%4ld%10Ld %p %8Ld%8ld\n", vnode, vnode->device, vnode->id, + vnode->cache, (vnode->cache->virtual_size + B_PAGE_SIZE - 1) + / B_PAGE_SIZE, numPages); } hash_close(sVnodeTable, &iterator, false); @@ -3106,7 +3107,7 @@ */ extern "C" status_t -vfs_get_vnode_cache(void *_vnode, vm_cache_ref **_cache, bool allocate) +vfs_get_vnode_cache(void *_vnode, vm_cache **_cache, bool allocate) { struct vnode *vnode = (struct vnode *)_vnode; Modified: haiku/trunk/src/system/kernel/vm/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/vm/Jamfile 2007-07-17 23:40:41 UTC (rev 21641) +++ haiku/trunk/src/system/kernel/vm/Jamfile 2007-07-18 00:16:27 UTC (rev 21642) @@ -3,7 +3,7 @@ KernelMergeObject kernel_vm.o : vm.cpp vm_address_space.c - vm_cache.c + vm_cache.cpp vm_daemons.c vm_low_memory.cpp vm_page.c Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2007-07-17 23:40:41 UTC (rev 21641) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2007-07-18 00:16:27 UTC (rev 21642) @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -63,6 +64,7 @@ static hash_table *sAreaHash; static sem_id sAreaHashLock; static spinlock sMappingLock; +static mutex sAreaCacheLock; static off_t sAvailableMemory; static benaphore sAvailableMemoryLock; @@ -158,7 +160,8 @@ area->memory_type = 0; area->ref_count = 1; - area->cache_ref = NULL; + area->cache = NULL; + area->no_cache_change = 0; area->cache_offset = 0; area->address_space = addressSpace; @@ -493,30 +496,27 @@ } +//! You need to hold the lock of the cache when calling this function. static status_t -map_backing_store(vm_address_space *addressSpace, vm_cache_ref *cacheRef, +map_backing_store(vm_address_space *addressSpace, vm_cache *cache, void **_virtualAddress, off_t offset, addr_t size, uint32 addressSpec, int wiring, int protection, int mapping, vm_area **_area, const char *areaName) { - TRACE(("map_backing_store: aspace %p, cacheref %p, *vaddr %p, offset 0x%Lx, size %lu, addressSpec %ld, wiring %d, protection %d, _area %p, area_name '%s'\n", - addressSpace, cacheRef, *_virtualAddress, offset, size, addressSpec, + TRACE(("map_backing_store: aspace %p, cache %p, *vaddr %p, offset 0x%Lx, size %lu, addressSpec %ld, wiring %d, protection %d, _area %p, area_name '%s'\n", + addressSpace, cache, *_virtualAddress, offset, size, addressSpec, wiring, protection, _area, areaName)); + ASSERT_LOCKED_MUTEX(&cache->lock); vm_area *area = create_area_struct(addressSpace, areaName, wiring, protection); if (area == NULL) return B_NO_MEMORY; - mutex_lock(&cacheRef->lock); - - vm_cache *cache = cacheRef->cache; vm_store *store = cache->store; - bool unlock = true; status_t status; // if this is a private map, we need to create a new cache & store object // pair to handle the private copies of pages as they are written to if (mapping == REGION_PRIVATE_MAP) { - vm_cache_ref *newCacheRef; vm_cache *newCache; vm_store *newStore; @@ -533,31 +533,21 @@ newStore->ops->destroy(newStore); goto err1; } - status = vm_cache_ref_create(newCache, false); - if (status < B_OK) { - newStore->ops->destroy(newStore); - free(newCache); - goto err1; - } - newCacheRef = newCache->ref; + mutex_lock(&newCache->lock); newCache->type = CACHE_TYPE_RAM; newCache->temporary = 1; newCache->scan_skip = cache->scan_skip; newCache->virtual_base = offset; newCache->virtual_size = offset + size; - vm_cache_add_consumer_locked(cacheRef, newCache); + vm_cache_add_consumer_locked(cache, newCache); - mutex_unlock(&cacheRef->lock); - mutex_lock(&newCacheRef->lock); - cache = newCache; - cacheRef = newCacheRef; store = newStore; } - status = vm_cache_set_minimal_commitment_locked(cacheRef, offset + size); + status = vm_cache_set_minimal_commitment_locked(cache, offset + size); if (status != B_OK) goto err2; @@ -576,12 +566,13 @@ goto err3; // attach the cache to the area - area->cache_ref = cacheRef; + area->cache = cache; area->cache_offset = offset; // point the cache back to the area - vm_cache_insert_area_locked(cacheRef, area); - mutex_unlock(&cacheRef->lock); + vm_cache_insert_area_locked(cache, area); + if (mapping == REGION_PRIVATE_MAP) + mutex_unlock(&cache->lock); // insert the area in the global area hash table acquire_sem_etc(sAreaHashLock, WRITE_COUNT, 0 ,0); @@ -601,13 +592,10 @@ err2: if (mapping == REGION_PRIVATE_MAP) { // we created this cache, so we must delete it again - mutex_unlock(&cacheRef->lock); - vm_cache_release_ref(cacheRef); - unlock = false; + mutex_unlock(&cache->lock); + vm_cache_release_ref(cache); } err1: - if (unlock) - mutex_unlock(&cacheRef->lock); free(area->name); free(area); return status; @@ -722,7 +710,6 @@ vm_create_anonymous_area(team_id aid, const char *name, void **address, uint32 addressSpec, addr_t size, uint32 wiring, uint32 protection) { - vm_cache_ref *cacheRef; vm_area *area; vm_cache *cache; vm_store *store; @@ -804,9 +791,6 @@ status = B_NO_MEMORY; goto err2; } - status = vm_cache_ref_create(cache, false); - if (status < B_OK) - goto err3; cache->temporary = 1; cache->type = CACHE_TYPE_RAM; @@ -824,12 +808,15 @@ break; } - cacheRef = cache->ref; + mutex_lock(&cache->lock); - status = map_backing_store(addressSpace, cacheRef, address, 0, size, + status = map_backing_store(addressSpace, cache, address, 0, size, addressSpec, wiring, protection, REGION_NO_PRIVATE_MAP, &area, name); + + mutex_unlock(&cache->lock); + if (status < B_OK) { - vm_cache_release_ref(cacheRef); + vm_cache_release_ref(cache); goto err1; } @@ -842,7 +829,7 @@ case B_FULL_LOCK: { // Allocate and map all pages for this area - mutex_lock(&cacheRef->lock); + mutex_lock(&cache->lock); off_t offset = 0; for (addr_t address = area->base; address < area->base + (area->size - 1); @@ -863,11 +850,11 @@ panic("couldn't fulfill B_FULL lock!"); } - vm_cache_insert_page(cacheRef, page, offset); + vm_cache_insert_page(cache, page, offset); vm_map_page(area, page, address, protection); } - mutex_unlock(&cacheRef->lock); + mutex_unlock(&cache->lock); break; } @@ -882,7 +869,7 @@ if (!kernel_startup) panic("ALREADY_WIRED flag used outside kernel startup\n"); - mutex_lock(&cacheRef->lock); + mutex_lock(&cache->lock); map->ops->lock(map); for (addr_t virtualAddress = area->base; virtualAddress < area->base @@ -905,11 +892,11 @@ page->wired_count++; // TODO: needs to be atomic on all platforms! vm_page_set_state(page, PAGE_STATE_WIRED); - vm_cache_insert_page(cacheRef, page, offset); + vm_cache_insert_page(cache, page, offset); } map->ops->unlock(map); - mutex_unlock(&cacheRef->lock); + mutex_unlock(&cache->lock); break; } @@ -922,7 +909,7 @@ addr_t virtualAddress; off_t offset = 0; - mutex_lock(&cacheRef->lock); + mutex_lock(&cache->lock); map->ops->lock(map); for (virtualAddress = area->base; virtualAddress < area->base @@ -940,11 +927,11 @@ page->wired_count++; // TODO: needs to be atomic on all platforms! vm_page_set_state(page, PAGE_STATE_WIRED); - vm_cache_insert_page(cacheRef, page, offset); + vm_cache_insert_page(cache, page, offset); } map->ops->unlock(map); - mutex_unlock(&cacheRef->lock); + mutex_unlock(&cache->lock); break; } @@ -958,8 +945,6 @@ area->cache_type = CACHE_TYPE_RAM; return area->id; -err3: - free(cache); err2: store->ops->destroy(store); err1: @@ -985,7 +970,6 @@ vm_map_physical_memory(team_id aspaceID, const char *name, void **_address, uint32 addressSpec, addr_t size, uint32 protection, addr_t physicalAddress) { - vm_cache_ref *cacheRef; vm_area *area; vm_cache *cache; vm_store *store; @@ -1024,22 +1008,22 @@ status = B_NO_MEMORY; goto err2; } - status = vm_cache_ref_create(cache, false); - if (status < B_OK) - goto err3; // tell the page scanner to skip over this area, it's pages are special cache->scan_skip = 1; cache->type = CACHE_TYPE_DEVICE; cache->virtual_size = size; - cacheRef = cache->ref; + mutex_lock(&cache->lock); - status = map_backing_store(addressSpace, cacheRef, _address, 0, size, + status = map_backing_store(addressSpace, cache, _address, 0, size, addressSpec & ~B_MTR_MASK, B_FULL_LOCK, protection, REGION_NO_PRIVATE_MAP, &area, name); + + mutex_unlock(&cache->lock); + if (status < B_OK) - vm_cache_release_ref(cacheRef); + vm_cache_release_ref(cache); if (status >= B_OK && (addressSpec & B_MTR_MASK) != 0) { // set requested memory type @@ -1074,8 +1058,6 @@ area->cache_type = CACHE_TYPE_DEVICE; return area->id; -err3: - free(cache); err2: store->ops->destroy(store); err1: @@ -1090,7 +1072,6 @@ { vm_area *area; vm_cache *cache; - vm_cache_ref *cacheRef; vm_store *store; status_t status; @@ -1112,32 +1093,28 @@ status = B_NO_MEMORY; goto err2; } - status = vm_cache_ref_create(cache, false); - if (status < B_OK) - goto err3; // tell the page scanner to skip over this area, no pages will be mapped here cache->scan_skip = 1; cache->type = CACHE_TYPE_NULL; cache->virtual_size = size; - cacheRef = cache->ref; + mutex_lock(&cache->lock); - status = map_backing_store(addressSpace, cacheRef, address, 0, size, addressSpec, 0, + status = map_backing_store(addressSpace, cache, address, 0, size, addressSpec, 0, B_KERNEL_READ_AREA, REGION_NO_PRIVATE_MAP, &area, name); + mutex_unlock(&cache->lock); vm_put_address_space(addressSpace); if (status < B_OK) { - vm_cache_release_ref(cacheRef); + vm_cache_release_ref(cache); return status; } area->cache_type = CACHE_TYPE_NULL; return area->id; -err3: - free(cache); err2: store->ops->destroy(store); err1: @@ -1154,7 +1131,7 @@ */ status_t -vm_create_vnode_cache(void *vnode, struct vm_cache_ref **_cacheRef) +vm_create_vnode_cache(void *vnode, struct vm_cache **_cache) { status_t status; @@ -1168,18 +1145,13 @@ status = B_NO_MEMORY; goto err1; } - status = vm_cache_ref_create(cache, false); - if (status < B_OK) - goto err2; cache->type = CACHE_TYPE_VNODE; - *_cacheRef = cache->ref; + *_cache = cache; vfs_acquire_vnode(vnode); return B_OK; -err2: - free(cache); err1: store->ops->destroy(store); return status; @@ -1196,7 +1168,7 @@ size_t size, uint32 protection, uint32 mapping, const char *path, off_t offset, bool kernel) { - vm_cache_ref *cacheRef; + vm_cache *cache; vm_area *area; void *vnode; status_t status; @@ -1224,7 +1196,7 @@ goto err1; // ToDo: this only works for file systems that use the file cache - status = vfs_get_vnode_cache(vnode, &cacheRef, false); + status = vfs_get_vnode_cache(vnode, &cache, false); vfs_put_vnode(vnode); // we don't need this vnode anymore - if the above call was @@ -1233,11 +1205,16 @@ if (status < B_OK) goto err1; - status = map_backing_store(addressSpace, cacheRef, _address, + mutex_lock(&cache->lock); + + status = map_backing_store(addressSpace, cache, _address, offset, size, addressSpec, 0, protection, mapping, &area, name); + + mutex_unlock(&cache->lock); + if (status < B_OK || mapping == REGION_PRIVATE_MAP) { // map_backing_store() cannot know we no longer need the ref - vm_cache_release_ref(cacheRef); + vm_cache_release_ref(cache); } if (status < B_OK) goto err1; @@ -1297,6 +1274,36 @@ } +vm_cache * +vm_area_get_locked_cache(vm_area *area) +{ + MutexLocker locker(sAreaCacheLock); + while (true) { + vm_cache* cache = area->cache; + vm_cache_acquire_ref(cache); + locker.Unlock(); + + mutex_lock(&cache->lock); + + locker.Lock(); + if (cache == area->cache) + return cache; + + // the cache changed in the meantime + mutex_unlock(&cache->lock); + vm_cache_release_ref(cache); + } +} + + +void +vm_area_put_locked_cache(vm_cache *cache) +{ + mutex_unlock(&cache->lock); + vm_cache_release_ref(cache); +} + + area_id vm_clone_area(team_id team, const char *name, void **address, uint32 addressSpec, uint32 protection, uint32 mapping, area_id sourceID) @@ -1315,7 +1322,7 @@ return B_BAD_VALUE; } - vm_cache_acquire_ref(sourceArea->cache_ref); + vm_cache *cache = vm_area_get_locked_cache(sourceArea); // ToDo: for now, B_USER_CLONEABLE is disabled, until all drivers // have been adapted. Maybe it should be part of the kernel settings, @@ -1331,8 +1338,8 @@ if (sourceArea->cache_type == CACHE_TYPE_NULL) status = B_NOT_ALLOWED; else { - status = map_backing_store(addressSpace, sourceArea->cache_ref, - address, sourceArea->cache_offset, sourceArea->size, addressSpec, + status = map_backing_store(addressSpace, cache, address, + sourceArea->cache_offset, sourceArea->size, addressSpec, sourceArea->wiring, protection, mapping, &newArea, name); } if (status == B_OK && mapping != REGION_PRIVATE_MAP) { @@ -1340,7 +1347,7 @@ // to create a new ref, and has therefore already acquired a reference // to the source cache - but otherwise it has no idea that we need // one. - vm_cache_acquire_ref(sourceArea->cache_ref); + vm_cache_acquire_ref(cache); } if (status == B_OK && newArea->wiring == B_FULL_LOCK) { // we need to map in everything at this point @@ -1368,23 +1375,18 @@ map->ops->unlock(map); } else { // map in all pages from source - mutex_lock(&sourceArea->cache_ref->lock); - - for (vm_page *page = sourceArea->cache_ref->cache->page_list; - page != NULL; page = page->cache_next) { + for (vm_page *page = cache->page_list; page != NULL; + page = page->cache_next) { vm_map_page(newArea, page, newArea->base + ((page->cache_offset << PAGE_SHIFT) - newArea->cache_offset), protection); } - - mutex_unlock(&sourceArea->cache_ref->lock); } } if (status == B_OK) newArea->cache_type = sourceArea->cache_type; - vm_cache_release_ref(sourceArea->cache_ref); - + vm_area_put_locked_cache(cache); vm_put_area(sourceArea); vm_put_address_space(addressSpace); @@ -1509,13 +1511,13 @@ vm_unmap_pages(area, area->base, area->size); // ToDo: do that only for vnode stores - vm_cache_write_modified(area->cache_ref, false); + vm_cache_write_modified(area->cache, false); arch_vm_unset_memory_type(area); remove_area_from_address_space(addressSpace, area, aspaceLocked); - vm_cache_remove_area(area->cache_ref, area); - vm_cache_release_ref(area->cache_ref); + vm_cache_remove_area(area->cache, area); + vm_cache_release_ref(area->cache); // now we can give up the area's reference to the address space vm_put_address_space(addressSpace); @@ -1538,25 +1540,30 @@ { vm_store *store; vm_cache *upperCache, *lowerCache; - vm_cache_ref *upperCacheRef, *lowerCacheRef; - vm_translation_map *map; vm_page *page; - uint32 protection; status_t status; TRACE(("vm_copy_on_write_area(area = %p)\n", area)); - // We need to separate the vm_cache from its vm_cache_ref: the area - // and its cache_ref goes into a new layer on top of the old one. - // So the old cache gets a new cache_ref and the area a new cache. + // We need to separate the cache from its areas. The cache goes one level + // deeper and we create a new cache inbetween. - upperCacheRef = area->cache_ref; + bool noCacheChange; + do { + lowerCache = vm_area_get_locked_cache(area); + noCacheChange = false; - // we will exchange the cache_ref's cache, so we better hold its lock - mutex_lock(&upperCacheRef->lock); + for (vm_area *tempArea = lowerCache->areas; tempArea != NULL; + tempArea = tempArea->cache_next) { + if (tempArea->no_cache_change) { + noCacheChange = true; + vm_area_put_locked_cache(lowerCache); + thread_yield(); + break; + } + } + } while (noCacheChange); - lowerCache = upperCacheRef->cache; - // create an anonymous store object store = vm_store_create_anonymous_noswap(false, 0, 0); if (store == NULL) { @@ -1570,75 +1577,57 @@ goto err2; } - // we need to hold the cache_ref lock when we want to switch its cache - status = vm_cache_ref_create(lowerCache, true); - if (status < B_OK) - goto err3; + mutex_lock(&upperCache->lock); - lowerCacheRef = lowerCache->ref; - - // The area must be readable in the same way it was previously writable - protection = B_KERNEL_READ_AREA; - if (area->protection & B_READ_AREA) - protection |= B_READ_AREA; - upperCache->type = CACHE_TYPE_RAM; upperCache->temporary = 1; upperCache->scan_skip = lowerCache->scan_skip; upperCache->virtual_base = lowerCache->virtual_base; upperCache->virtual_size = lowerCache->virtual_size; - upperCache->ref = upperCacheRef; - upperCacheRef->cache = upperCache; + // transfer the lower cache areas to the upper cache + mutex_lock(&sAreaCacheLock); - // we need to manually alter the ref_count (divide it between the two) - // the lower cache_ref has only known refs, so compute them - { - int32 count = 0; - vm_cache *consumer = NULL; - while ((consumer = (vm_cache *)list_get_next_item( - &lowerCache->consumers, consumer)) != NULL) { - count++; - } + upperCache->areas = lowerCache->areas; + lowerCache->areas = NULL; - atomic_add(&lowerCacheRef->ref_count, count); - atomic_add(&upperCacheRef->ref_count, -count); + for (vm_area *tempArea = upperCache->areas; tempArea != NULL; + tempArea = tempArea->cache_next) { + tempArea->cache = upperCache; + atomic_add(&upperCache->ref_count, 1); + atomic_add(&lowerCache->ref_count, -1); } - vm_cache_add_consumer_locked(lowerCacheRef, upperCache); + mutex_unlock(&sAreaCacheLock); - // We now need to remap all pages from the area read-only, so that + vm_cache_add_consumer_locked(lowerCache, upperCache); + + // We now need to remap all pages from all of the cache's areas read-only, so that // a copy will be created on next write access - map = &area->address_space->translation_map; - map->ops->lock(map); - map->ops->unmap(map, area->base, area->base - 1 + area->size); - map->ops->flush(map); + for (vm_area *tempArea = upperCache->areas; tempArea != NULL; + tempArea = tempArea->cache_next) { +// TODO: Don't we have to lock the area's address space for accessing base, size, and protection? + // The area must be readable in the same way it was previously writable + uint32 protection = B_KERNEL_READ_AREA; + if (tempArea->protection & B_READ_AREA) + protection |= B_READ_AREA; - // TODO: does anything guarantee that we remap the same pages here? - // Shouldn't we better introduce a "change mapping"? - - for (page = lowerCache->page_list; page; page = page->cache_next) { - map->ops->map(map, area->base + (page->cache_offset << PAGE_SHIFT) - - area->cache_offset, page->physical_page_number << PAGE_SHIFT, - protection); + vm_translation_map *map = &tempArea->address_space->translation_map; + map->ops->lock(map); + map->ops->protect(map, tempArea->base, tempArea->base - 1 + tempArea->size, protection); + map->ops->unlock(map); } - map->ops->unlock(map); + vm_area_put_locked_cache(lowerCache); + vm_area_put_locked_cache(upperCache); - mutex_unlock(&lowerCacheRef->lock); - mutex_unlock(&upperCacheRef->lock); - - vm_cache_release_ref(lowerCacheRef); - return B_OK; -err3: - free(upperCache); err2: store->ops->destroy(store); err1: - mutex_unlock(&upperCacheRef->lock); + vm_area_put_locked_cache(lowerCache); return status; } @@ -1648,7 +1637,7 @@ uint32 protection, area_id sourceID) { vm_address_space *addressSpace; - vm_cache_ref *cacheRef; + vm_cache *cache; vm_area *target, *source; status_t status; bool writableCopy = (protection & (B_KERNEL_WRITE_AREA | B_WRITE_AREA)) != 0; @@ -1664,7 +1653,7 @@ return B_BAD_VALUE; addressSpace = vm_get_address_space_by_id(addressSpaceID); - cacheRef = source->cache_ref; + cache = vm_area_get_locked_cache(source); if (addressSpec == B_CLONE_ADDRESS) { [... truncated: 1486 lines follow ...] From stippi at mail.berlios.de Wed Jul 18 11:35:42 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 18 Jul 2007 11:35:42 +0200 Subject: [Haiku-commits] r21643 - in haiku/trunk/src/servers/app: . drawing drawing/Painter Message-ID: <200707180935.l6I9ZgT9018943@sheep.berlios.de> Author: stippi Date: 2007-07-18 11:35:40 +0200 (Wed, 18 Jul 2007) New Revision: 21643 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21643&view=rev Modified: haiku/trunk/src/servers/app/ServerWindow.cpp haiku/trunk/src/servers/app/ServerWindow.h haiku/trunk/src/servers/app/WindowLayer.cpp haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp haiku/trunk/src/servers/app/drawing/DrawingEngine.h haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp haiku/trunk/src/servers/app/drawing/Painter/Painter.h Log: * since every window has it's own Painter instance, the drawing state does not need to be "set" (transfered from the "current" view to the painter) for each singly drawing command. Now, painter is synchronized whenever the client changes the drawing state of the current view, or when the current view changes. * the screen offset of the current view has become part of the Painter state, in the PatternHandler. This fixes a bug in which moving or scrolling a view which used patterns for drawing, resulted in visual glitches (seams in the pattern). NOTE: this patch is a bit work in progress, most importantly, it is not complete with regards to text rendering. More specifically, the server applications and other parts of the appserver might set a font on the Painter and this might mess up the synchronization. But this happens on the Desktop's Painter instance (only?), and so it is not a problem. I did observe some drawing bugs with this patch though, so bug reports are welcome, particularily how to reproduce these bugs reliably. Modified: haiku/trunk/src/servers/app/ServerWindow.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerWindow.cpp 2007-07-18 00:16:27 UTC (rev 21642) +++ haiku/trunk/src/servers/app/ServerWindow.cpp 2007-07-18 09:35:40 UTC (rev 21643) @@ -407,7 +407,8 @@ void ServerWindow::NotifyQuitRequested() { - // NOTE: if you do something else, other than sending a port message, PLEASE lock + // NOTE: if you do something else, other than sending a port message, + // PLEASE lock STRACE(("ServerWindow %s: Quit\n", fTitle)); BMessage msg(B_QUIT_REQUESTED); @@ -435,7 +436,8 @@ void ServerWindow::NotifyZoom() { - // NOTE: if you do something else, other than sending a port message, PLEASE lock + // NOTE: if you do something else, other than sending a port message, + // PLEASE lock BMessage msg(B_ZOOM); SendMessageToClient(&msg); } @@ -465,6 +467,13 @@ } +void +ServerWindow::ResyncDrawState() +{ + _UpdateDrawState(fCurrentLayer); +} + + /*! Returns the ServerWindow's WindowLayer, if it exists and has been added to the Desktop already. @@ -1194,12 +1203,15 @@ fCurrentLayer->CurrentState()->ReadFromLink(link); // TODO: When is this used?!? fCurrentLayer->RebuildClipping(true); + _UpdateDrawState(fCurrentLayer); + break; } case AS_LAYER_SET_FONT_STATE: { DTRACE(("ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: ViewLayer name: %s\n", fTitle, fCurrentLayer->Name())); fCurrentLayer->CurrentState()->ReadFontFromLink(link); + _UpdateDrawState(fCurrentLayer); break; } case AS_LAYER_GET_STATE: @@ -1323,6 +1335,7 @@ link.Read(&y); fCurrentLayer->SetDrawingOrigin(BPoint(x, y)); + _UpdateDrawState(fCurrentLayer); break; } case AS_LAYER_GET_ORIGIN: @@ -1382,6 +1395,7 @@ uint32 flags; link.Read(&flags); fCurrentLayer->SetFlags(flags); + _UpdateDrawState(fCurrentLayer); STRACE(("ServerWindow %s: Message AS_LAYER_SET_FLAGS: ViewLayer: %s\n", Title(), fCurrentLayer->Name())); break; @@ -1411,7 +1425,9 @@ fCurrentLayer->CurrentState()->SetLineCapMode((cap_mode)lineCap); fCurrentLayer->CurrentState()->SetLineJoinMode((join_mode)lineJoin); fCurrentLayer->CurrentState()->SetMiterLimit(miterLimit); - + + _UpdateDrawState(fCurrentLayer); + break; } case AS_LAYER_GET_LINE_MODE: @@ -1430,7 +1446,8 @@ DTRACE(("ServerWindow %s: Message AS_LAYER_PUSH_STATE: ViewLayer: %s\n", Title(), fCurrentLayer->Name())); fCurrentLayer->PushState(); - + // TODO: is this necessary? + _UpdateDrawState(fCurrentLayer); break; } case AS_LAYER_POP_STATE: @@ -1438,7 +1455,7 @@ DTRACE(("ServerWindow %s: Message AS_LAYER_POP_STATE: ViewLayer: %s\n", Title(), fCurrentLayer->Name())); fCurrentLayer->PopState(); - + _UpdateDrawState(fCurrentLayer); break; } case AS_LAYER_SET_SCALE: @@ -1448,6 +1465,7 @@ link.Read(&scale); fCurrentLayer->SetScale(scale); + _UpdateDrawState(fCurrentLayer); break; } case AS_LAYER_GET_SCALE: @@ -1468,6 +1486,8 @@ link.Read(&y); fCurrentLayer->CurrentState()->SetPenLocation(BPoint(x, y)); + // TODO: is this necessary? + _UpdateDrawState(fCurrentLayer); break; } case AS_LAYER_GET_PEN_LOC: @@ -1484,8 +1504,10 @@ DTRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: ViewLayer: %s\n", Title(), fCurrentLayer->Name())); float penSize; link.Read(&penSize); + fCurrentLayer->CurrentState()->SetPenSize(penSize); - + //_UpdateDrawState(fCurrentLayer); + fWindowLayer->GetDrawingEngine()->SetPenSize(penSize); break; } case AS_LAYER_GET_PEN_SIZE: @@ -1545,7 +1567,7 @@ fCurrentLayer->CurrentState()->SetBlendingMode((source_alpha)srcAlpha, (alpha_function)alphaFunc); - + _UpdateDrawState(fCurrentLayer); break; } case AS_LAYER_GET_BLENDING_MODE: @@ -1566,7 +1588,8 @@ link.Read(&drawingMode); fCurrentLayer->CurrentState()->SetDrawingMode((drawing_mode)drawingMode); - + //_UpdateDrawState(fCurrentLayer); + fWindowLayer->GetDrawingEngine()->SetDrawingMode((drawing_mode)drawingMode); break; } case AS_LAYER_GET_DRAWING_MODE: @@ -1633,8 +1656,10 @@ { DTRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: ViewLayer: %s\n", Title(), fCurrentLayer->Name())); bool fontAliasing; - if (link.Read(&fontAliasing) == B_OK) + if (link.Read(&fontAliasing) == B_OK) { fCurrentLayer->CurrentState()->SetForceFontAliasing(fontAliasing); + _UpdateDrawState(fCurrentLayer); + } break; } case AS_LAYER_CLIP_TO_PICTURE: @@ -1782,6 +1807,8 @@ link.Read(&c, sizeof(rgb_color)); fCurrentLayer->CurrentState()->SetHighColor(RGBColor(c)); +// _UpdateDrawState(fCurrentLayer); + fWindowLayer->GetDrawingEngine()->SetHighColor(c); break; } case AS_LAYER_SET_LOW_COLOR: @@ -1792,6 +1819,8 @@ link.Read(&c, sizeof(rgb_color)); fCurrentLayer->CurrentState()->SetLowColor(RGBColor(c)); +// _UpdateDrawState(fCurrentLayer); + fWindowLayer->GetDrawingEngine()->SetLowColor(c); break; } case AS_LAYER_SET_PATTERN: @@ -1802,6 +1831,8 @@ link.Read(&pat, sizeof(pattern)); fCurrentLayer->CurrentState()->SetPattern(Pattern(pat)); +// _UpdateDrawState(fCurrentLayer); + fWindowLayer->GetDrawingEngine()->SetPattern(pat); break; } case AS_SET_FONT: @@ -1819,7 +1850,11 @@ } case AS_SYNC: { - // TODO: AS_SYNC is a no-op for now, just to get things working + // the synchronisation works by the fact that the client + // window is waiting for this reply, after having received it, + // client and server queues are in sync (earlier, the client + // may have pushed drawing commands at the server and now it + // knows they have all been carried out) fLink.StartMessage(B_OK); fLink.Flush(); break; @@ -1974,7 +2009,9 @@ } drawingEngine->LockParallelAccess(); - // TODO: avoid setting the region each time + // NOTE: the region is not copied, Painter keeps a pointer, + // that's why you need to use the clipping only for as long + // as you have it locked drawingEngine->ConstrainClippingRegion(&fCurrentDrawingRegion); switch (code) { @@ -2258,6 +2295,8 @@ fCurrentLayer->ConvertFromScreenForDrawing(&penLocation); fCurrentLayer->CurrentState()->SetPenLocation(penLocation); + // TODO: optimize with flags + _UpdateDrawState(fCurrentLayer); free(string); break; @@ -2837,29 +2876,49 @@ void ServerWindow::_SetCurrentLayer(ViewLayer* layer) { - if (fCurrentLayer != layer) { - fCurrentLayer = layer; - fCurrentDrawingRegionValid = false; + if (fCurrentLayer == layer) + return; + + fCurrentLayer = layer; + fCurrentDrawingRegionValid = false; + _UpdateDrawState(fCurrentLayer); + #if 0 #if DELAYED_BACKGROUND_CLEARING - if (fCurrentLayer && fCurrentLayer->IsBackgroundDirty() && fWindowLayer->InUpdate()) { - DrawingEngine* drawingEngine = fWindowLayer->GetDrawingEngine(); - if (drawingEngine->LockParallelAccess()) { - - fWindowLayer->GetEffectiveDrawingRegion(fCurrentLayer, fCurrentDrawingRegion); - fCurrentDrawingRegionValid = true; - BRegion dirty(fCurrentDrawingRegion); + if (fCurrentLayer && fCurrentLayer->IsBackgroundDirty() + && fWindowLayer->InUpdate()) { + DrawingEngine* drawingEngine = fWindowLayer->GetDrawingEngine(); + if (drawingEngine->LockParallelAccess()) { + + fWindowLayer->GetEffectiveDrawingRegion(fCurrentLayer, fCurrentDrawingRegion); + fCurrentDrawingRegionValid = true; + BRegion dirty(fCurrentDrawingRegion); - BRegion content; - fWindowLayer->GetContentRegion(&content); + BRegion content; + fWindowLayer->GetContentRegion(&content); - fCurrentLayer->Draw(drawingEngine, &dirty, &content, false); - - drawingEngine->UnlockParallelAccess(); - } + fCurrentLayer->Draw(drawingEngine, &dirty, &content, false); + + drawingEngine->UnlockParallelAccess(); } + } #endif #endif // 0 +} + + +void +ServerWindow::_UpdateDrawState(ViewLayer* layer) +{ + // switch the drawing state + // TODO: is it possible to scroll a view while it + // is being drawn? probably not... otherwise the + // "offsets" passed below would need to be updated again + DrawingEngine* drawingEngine = fWindowLayer->GetDrawingEngine(); + if (layer && drawingEngine) { + IntPoint p = layer->ScrollingOffset(); + p += IntPoint(layer->CurrentState()->Origin()); + drawingEngine->SetDrawState(layer->CurrentState(), p.x, p.y); } } Modified: haiku/trunk/src/servers/app/ServerWindow.h =================================================================== --- haiku/trunk/src/servers/app/ServerWindow.h 2007-07-18 00:16:27 UTC (rev 21642) +++ haiku/trunk/src/servers/app/ServerWindow.h 2007-07-18 09:35:40 UTC (rev 21643) @@ -101,6 +101,8 @@ void GetInfo(window_info& info); + void ResyncDrawState(); + private: ViewLayer* _CreateLayerTree(BPrivate::LinkReceiver &link, ViewLayer **_parent); @@ -123,6 +125,7 @@ status_t _EnableDirectWindowMode(); void _SetCurrentLayer(ViewLayer* view); + void _UpdateDrawState(ViewLayer* view); // TODO: Move me elsewhere status_t PictureToRegion(ServerPicture *picture, Modified: haiku/trunk/src/servers/app/WindowLayer.cpp =================================================================== --- haiku/trunk/src/servers/app/WindowLayer.cpp 2007-07-18 00:16:27 UTC (rev 21642) +++ haiku/trunk/src/servers/app/WindowLayer.cpp 2007-07-18 09:35:40 UTC (rev 21643) @@ -1784,6 +1784,14 @@ engine->ConstrainClippingRegion(dirtyBorderRegion); fDecorator->Draw(dirtyBorderRegion->Frame()); +// TODO: remove this once the DrawState stuff is handled +// more cleanly. The reason why this is needed is that +// when the decorator draws strings, a draw state is set +// on the Painter object, and this is were it might get +// out of sync with what the ServerWindow things is the +// current DrawState set on the Painter +fWindow->ResyncDrawState(); + engine->UnlockParallelAccess(); } fRegionPool.Recycle(dirtyBorderRegion); Modified: haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp 2007-07-18 00:16:27 UTC (rev 21642) +++ haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp 2007-07-18 09:35:40 UTC (rev 21643) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005, Haiku, Inc. + * Copyright 2001-2007, Haiku, Inc. * Distributed under the terms of the MIT License. * * Authors: @@ -182,6 +182,53 @@ void +DrawingEngine::SetDrawState(const DrawState* state, int32 xOffset, int32 yOffset) +{ + fPainter->SetDrawState(state, false, xOffset, yOffset); +} + + +void +DrawingEngine::SetHighColor(const rgb_color& color) +{ + fPainter->SetHighColor(color); +} + + +void +DrawingEngine::SetLowColor(const rgb_color& color) +{ + fPainter->SetLowColor(color); +} + + +void +DrawingEngine::SetPenSize(float size) +{ + fPainter->SetPenSize(size); +} + + +void +DrawingEngine::SetPattern(const struct pattern& pattern) +{ + // TODO: doing it like this prevents an optimization + // for font rendering (special "solid" drawing mode) + fPainter->SetPattern(pattern, false); +} + + +void +DrawingEngine::SetDrawingMode(drawing_mode mode) +{ + fPainter->SetDrawingMode(mode); +} + + +// #pragma mark - + + +void DrawingEngine::SuspendAutoSync() { CRASH_IF_NOT_LOCKED @@ -467,7 +514,7 @@ if (clipped.IsValid()) { bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); - fPainter->SetDrawState(d); +// fPainter->SetDrawState(d); fPainter->DrawBitmap(bitmap, source, dest); fGraphicsCard->Invalidate(clipped); @@ -492,7 +539,7 @@ if (clipped.IsValid()) { bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); - fPainter->SetDrawState(d); +// fPainter->SetDrawState(d); float xRadius = r.Width() / 2.0; float yRadius = r.Height() / 2.0; @@ -519,7 +566,7 @@ // TODO: figure out bounds and hide cursor depending on that fGraphicsCard->HideSoftwareCursor(); - fPainter->SetDrawState(d); +// fPainter->SetDrawState(d); BRect touched = fPainter->DrawBezier(pts, filled); fGraphicsCard->Invalidate(touched); @@ -549,7 +596,7 @@ if (clipped.IsValid()) { bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); - fPainter->SetDrawState(d); +// fPainter->SetDrawState(d); fPainter->DrawEllipse(r, filled); fGraphicsCard->Invalidate(clipped); @@ -573,7 +620,7 @@ if (bounds.IsValid()) { bool cursorTouched = fGraphicsCard->HideSoftwareCursor(bounds); - fPainter->SetDrawState(d); +// fPainter->SetDrawState(d); fPainter->DrawPolygon(ptlist, numpts, filled, closed); fGraphicsCard->Invalidate(bounds); @@ -606,10 +653,15 @@ bool cursorTouched = fGraphicsCard->HideSoftwareCursor(touched); if (!fPainter->StraightLine(start, end, color.GetColor32())) { - DrawState context; - context.SetHighColor(color); - context.SetDrawingMode(B_OP_OVER); - StrokeLine(start, end, &context); + // TODO: all this is quite expensive, but it is currently + // used only for the "gradient" decorator tab buttons + rgb_color previousColor = fPainter->HighColor(); + drawing_mode previousMode = fPainter->DrawingMode(); + fPainter->SetHighColor(color); + fPainter->SetDrawingMode(B_OP_OVER); + fPainter->StrokeLine(start, end); + fPainter->SetHighColor(previousColor); + fPainter->SetDrawingMode(previousMode); } else { fGraphicsCard->Invalidate(touched); } @@ -717,7 +769,7 @@ bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); - fPainter->SetDrawState(d); +// fPainter->SetDrawState(d); fPainter->StrokeRect(r); fGraphicsCard->Invalidate(clipped); @@ -763,7 +815,7 @@ } } if (doInSoftware) { - fPainter->SetDrawState(d); +// fPainter->SetDrawState(d); fPainter->FillRect(r); fGraphicsCard->Invalidate(r); @@ -806,7 +858,7 @@ } if (doInSoftware) { - fPainter->SetDrawState(d); +// fPainter->SetDrawState(d); BRect touched = fPainter->FillRect(r.RectAt(0)); @@ -843,7 +895,7 @@ if (clipped.IsValid()) { bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); - fPainter->SetDrawState(d); +// fPainter->SetDrawState(d); BRect touched = filled ? fPainter->FillRoundRect(r, xrad, yrad) : fPainter->StrokeRoundRect(r, xrad, yrad); @@ -865,7 +917,7 @@ // shape is drawn on screen, TODO: optimize fGraphicsCard->HideSoftwareCursor(); - fPainter->SetDrawState(d); +// fPainter->SetDrawState(d); BRect touched = fPainter->DrawShape(opCount, opList, ptCount, ptList, filled); @@ -888,7 +940,7 @@ if (clipped.IsValid()) { bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); - fPainter->SetDrawState(d); +// fPainter->SetDrawState(d); if (filled) fPainter->FillTriangle(pts[0], pts[1], pts[2]); else @@ -913,7 +965,7 @@ if (touched.IsValid()) { bool cursorTouched = fGraphicsCard->HideSoftwareCursor(touched); - fPainter->SetDrawState(context); +// fPainter->SetDrawState(context); fPainter->StrokeLine(start, end); fGraphicsCard->Invalidate(touched); @@ -954,15 +1006,7 @@ data = (const LineArrayData *)&(linedata[0]); - DrawState context; - context.SetDrawingMode(d->GetDrawingMode()); - context.SetLowColor(d->LowColor()); - context.SetHighColor(data->color); - context.SetPenSize(d->PenSize()); - // pen size is already correctly scaled - - fPainter->SetDrawState(&context); - + fPainter->SetHighColor(data->color); fPainter->StrokeLine(data->pt1, data->pt2); for (int32 i = 1; i < numLines; i++) { @@ -971,6 +1015,9 @@ fPainter->StrokeLine(data->pt1, data->pt2); } + // restore correct drawing state highcolor + fPainter->SetHighColor(d->HighColor()); + fGraphicsCard->Invalidate(touched); if (cursorTouched) fGraphicsCard->ShowSoftwareCursor(); @@ -992,6 +1039,11 @@ BPoint penLocation = pt; fPainter->SetDrawState(d, true); + // TODO: this will reset the scrolling offsets used for + // pattern drawing again, it is really necessary to change + // the whole graphics state synchronization between DrawState + // and Painter, and remove any individual SetDrawState() calls + // like here //bigtime_t now = system_time(); // TODO: BoundingBox is quite slow!! Optimizing it will be beneficial. // Cursiously, the DrawString after it is actually faster!?! Modified: haiku/trunk/src/servers/app/drawing/DrawingEngine.h =================================================================== --- haiku/trunk/src/servers/app/drawing/DrawingEngine.h 2007-07-18 00:16:27 UTC (rev 21642) +++ haiku/trunk/src/servers/app/drawing/DrawingEngine.h 2007-07-18 09:35:40 UTC (rev 21643) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005, Haiku, Inc. + * Copyright 2001-2007, Haiku, Inc. * Distributed under the terms of the MIT License. * * Authors: @@ -66,6 +66,15 @@ // will remove any clipping (drawing allowed everywhere) void ConstrainClippingRegion(const BRegion* region); + void SetDrawState(const DrawState* state, + int32 xOffset = 0, int32 yOffset = 0); + + void SetHighColor(const rgb_color& color); + void SetLowColor(const rgb_color& color); + void SetPenSize(float size); + void SetPattern(const struct pattern& pattern); + void SetDrawingMode(drawing_mode mode); + void SuspendAutoSync(); void Sync(); Modified: haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp 2007-07-18 00:16:27 UTC (rev 21642) +++ haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp 2007-07-18 09:35:40 UTC (rev 21643) @@ -1,5 +1,5 @@ /* - * Copyright 2005-2006, Stephan A?mus . All rights reserved. + * Copyright 2005-2007, Stephan A?mus . All rights reserved. * Distributed under the terms of the MIT License. * * API to the Anti-Grain Geometry based "Painter" drawing backend. Manages @@ -183,7 +183,8 @@ // SetDrawState void -Painter::SetDrawState(const DrawState* data, bool updateFont) +Painter::SetDrawState(const DrawState* data, bool updateFont, + int32 xOffset, int32 yOffset) { // NOTE: The custom clipping in "data" is ignored, because it has already been // taken into account elsewhere @@ -211,6 +212,7 @@ fAlphaSrcMode = data->AlphaSrcMode(); fAlphaFncMode = data->AlphaFncMode(); fPatternHandler->SetPattern(data->GetPattern()); + fPatternHandler->SetOffsets(xOffset, yOffset); fLineCapMode = data->LineCapMode(); fLineJoinMode = data->LineJoinMode(); fMiterLimit = data->MiterLimit(); @@ -258,6 +260,16 @@ _SetRendererColor(color); } +// SetDrawingMode +void +Painter::SetDrawingMode(drawing_mode mode) +{ + if (fDrawingMode != mode) { + fDrawingMode = mode; + _UpdateDrawingMode(); + } +} + // SetPenSize void Painter::SetPenSize(float size) Modified: haiku/trunk/src/servers/app/drawing/Painter/Painter.h =================================================================== --- haiku/trunk/src/servers/app/drawing/Painter/Painter.h 2007-07-18 00:16:27 UTC (rev 21642) +++ haiku/trunk/src/servers/app/drawing/Painter/Painter.h 2007-07-18 09:35:40 UTC (rev 21643) @@ -1,5 +1,5 @@ /* - * Copyright 2005-2006, Stephan A?mus . All rights reserved. + * Copyright 2005-2007, Stephan A?mus . All rights reserved. * Distributed under the terms of the MIT License. * * API to the Anti-Grain Geometry based "Painter" drawing backend. Manages @@ -10,6 +10,7 @@ #define PAINTER_H #include "FontManager.h" +#include "PatternHandler.h" #include "RGBColor.h" #include "ServerFont.h" @@ -26,7 +27,6 @@ class BBitmap; class BRegion; class DrawState; -class PatternHandler; class RenderingBuffer; class ServerBitmap; class ServerFont; @@ -65,13 +65,19 @@ { return fClippingRegion; } void SetDrawState(const DrawState* data, - bool updateFont = false); + bool updateFont = false, + int32 xOffset = 0, + int32 yOffset = 0); // object settings void SetHighColor(const rgb_color& color); inline void SetHighColor(uint8 r, uint8 g, uint8 b, uint8 a = 255); inline void SetHighColor(const RGBColor& color) { SetHighColor(color.GetColor32()); } + inline rgb_color HighColor() const + { return fPatternHandler-> + HighColor().GetColor32(); } + void SetLowColor(const rgb_color& color); inline void SetLowColor(uint8 r, uint8 g, uint8 b, uint8 a = 255); inline void SetLowColor(const RGBColor& color) @@ -80,6 +86,9 @@ void SetPenSize(float size); void SetPattern(const pattern& p, bool drawingText = false); + void SetDrawingMode(drawing_mode mode); + inline drawing_mode DrawingMode() const + { return fDrawingMode; } void SetPenLocation(const BPoint& location); BPoint PenLocation() const From stippi at mail.berlios.de Wed Jul 18 14:29:45 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 18 Jul 2007 14:29:45 +0200 Subject: [Haiku-commits] r21644 - haiku/trunk/src/servers/app/drawing/Painter/font_support Message-ID: <200707181229.l6ICTj5X015691@sheep.berlios.de> Author: stippi Date: 2007-07-18 14:29:44 +0200 (Wed, 18 Jul 2007) New Revision: 21644 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21644&view=rev Modified: haiku/trunk/src/servers/app/drawing/Painter/font_support/AGGTextRenderer.cpp Log: * performance optimization, getting the bounding box of a text is about 10% faster Modified: haiku/trunk/src/servers/app/drawing/Painter/font_support/AGGTextRenderer.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/Painter/font_support/AGGTextRenderer.cpp 2007-07-18 09:35:40 UTC (rev 21643) +++ haiku/trunk/src/servers/app/drawing/Painter/font_support/AGGTextRenderer.cpp 2007-07-18 12:29:44 UTC (rev 21644) @@ -177,7 +177,7 @@ // "bounds" will track the bounding box arround all glyphs that are actually drawn // it will be calculated in untransformed coordinates within the loop and then // it is transformed to the real location at the exit of the function. - BRect bounds(0.0, 0.0, -1.0, -1.0); + BRect bounds(LONG_MAX, LONG_MAX, LONG_MIN, LONG_MIN); Transformable transform(fEmbeddedTransformation); transform.TranslateBy(baseLine); @@ -249,7 +249,7 @@ // track bounding box if (glyphBounds.IsValid()) - bounds = bounds.IsValid() ? bounds | glyphBounds : glyphBounds; + bounds = bounds | glyphBounds; // render the glyph if this is not a dry run if (!dryRun) { From axeld at mail.berlios.de Wed Jul 18 14:40:39 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 18 Jul 2007 14:40:39 +0200 Subject: [Haiku-commits] r21645 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200707181240.l6ICedhd016770@sheep.berlios.de> Author: axeld Date: 2007-07-18 14:40:38 +0200 (Wed, 18 Jul 2007) New Revision: 21645 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21645&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c Log: * init_double_fault() accidently initialized the wrong TSS for the handler (the regular one, not the one intended for the double fault) since r20131. IOW double faults are now working again. * Minor cleanup. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c 2007-07-18 12:29:44 UTC (rev 21644) +++ haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c 2007-07-18 12:40:38 UTC (rev 21645) @@ -209,12 +209,13 @@ { /* set up the double fault tss */ /* TODO: Axel - fix SMP support */ - struct tss *tss = &gCPU[cpuNum].arch.tss; + struct tss *tss = &gCPU[cpuNum].arch.double_fault_tss; memset(tss, 0, sizeof(struct tss)); tss->sp0 = (uint32)sDoubleFaultStack + sizeof(sDoubleFaultStack); tss->ss0 = KERNEL_DATA_SEG; - read_cr3(tss->cr3); // copy the current cr3 to the double fault cr3 + read_cr3(tss->cr3); + // copy the current cr3 to the double fault cr3 tss->eip = (uint32)&double_fault; tss->es = KERNEL_DATA_SEG; tss->cs = KERNEL_CODE_SEG; @@ -226,12 +227,13 @@ tss->ldt_seg_selector = 0; // add TSS descriptor for this new TSS - set_tss_descriptor(&gGDT[DOUBLE_FAULT_TSS_BASE_SEGMENT + cpuNum], (addr_t)tss, sizeof(struct tss)); - -// set_tss_descriptor(&gGDT[DOUBLE_FAULT_TSS_SEGMENT + cpuNum], (addr_t)sDoubleFaultTSS[cpuNum], sizeof(struct tss)); + set_tss_descriptor(&gGDT[DOUBLE_FAULT_TSS_BASE_SEGMENT + cpuNum], + (addr_t)tss, sizeof(struct tss)); } -static void make_feature_string(cpu_ent *cpu, char *str, size_t strlen) + +static void +make_feature_string(cpu_ent *cpu, char *str, size_t strlen) { str[0] = 0; @@ -321,7 +323,9 @@ strlcat(str, "3dnow ", strlen); } -static int detect_cpu(int curr_cpu) + +static int +detect_cpu(int curr_cpu) { cpuid_info cpuid; unsigned int data[4]; @@ -414,7 +418,9 @@ return 0; } -bool x86_check_feature(uint32 feature, enum x86_feature_type type) + +bool +x86_check_feature(uint32 feature, enum x86_feature_type type) { cpu_ent *cpu = get_cpu_struct(); @@ -429,8 +435,10 @@ return (cpu->arch.feature[type] & feature) ? TRUE : FALSE; } + // #pragma mark - + status_t arch_cpu_preboot_init_percpu(kernel_args *args, int curr_cpu) { @@ -471,8 +479,8 @@ // account for the segment descriptors gGDT = (segment_descriptor *)args->arch_args.vir_gdt; - create_area("gdt", (void **)&gGDT, B_EXACT_ADDRESS, B_PAGE_SIZE, B_ALREADY_WIRED, - B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); + create_area("gdt", (void **)&gGDT, B_EXACT_ADDRESS, B_PAGE_SIZE, + B_ALREADY_WIRED, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); // currently taken out of the build, because it's not yet used (and assumes // (a fixed number of used GDT entries) @@ -480,12 +488,14 @@ // setup task-state segments for (i = 0; i < args->num_cpus; i++) { - // initialize the regular and double fault tss stored in the per-cpu structure + // initialize the regular and double fault tss stored in the per-cpu + // structure memset(&gCPU[i].arch.tss, 0, sizeof(struct tss)); gCPU[i].arch.tss.ss0 = KERNEL_DATA_SEG; // add TSS descriptor for this new TSS - set_tss_descriptor(&gGDT[TSS_BASE_SEGMENT + i], (addr_t)&gCPU[i].arch.tss, sizeof(struct tss)); + set_tss_descriptor(&gGDT[TSS_BASE_SEGMENT + i], + (addr_t)&gCPU[i].arch.tss, sizeof(struct tss)); // initialize the double fault tss init_double_fault(i); From stippi at mail.berlios.de Wed Jul 18 14:59:06 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 18 Jul 2007 14:59:06 +0200 Subject: [Haiku-commits] r21646 - in haiku/trunk/src: kits/interface servers/app servers/app/drawing/Painter tests/servers/app Message-ID: <200707181259.l6ICx6q2017849@sheep.berlios.de> Author: stippi Date: 2007-07-18 14:59:05 +0200 (Wed, 18 Jul 2007) New Revision: 21646 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21646&view=rev Added: haiku/trunk/src/servers/app/ProfileMessageSupport.cpp haiku/trunk/src/servers/app/ProfileMessageSupport.h Modified: haiku/trunk/src/kits/interface/View.cpp haiku/trunk/src/servers/app/Jamfile haiku/trunk/src/servers/app/ServerWindow.cpp haiku/trunk/src/servers/app/ViewLayer.cpp haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp haiku/trunk/src/tests/servers/app/Jamfile Log: * added ProfileMessageSupport.h/cpp to translate server message codes to a string * fixed profiling of message processsing in ServerWindow (didn't take batch processing into account) * accelerated ViewLayer::RebuildClipping() by a factor of two by avoiding BRegion::Exclude(clipping_rect) for each child, and instead building one region with all children, and excluding that. RebuildClipping() is quite a common operation and is quite slow for views with many children Modified: haiku/trunk/src/kits/interface/View.cpp =================================================================== --- haiku/trunk/src/kits/interface/View.cpp 2007-07-18 12:40:38 UTC (rev 21645) +++ haiku/trunk/src/kits/interface/View.cpp 2007-07-18 12:59:05 UTC (rev 21646) @@ -2248,15 +2248,7 @@ int32 code; if (fOwner->fLink->FlushWithReply(code) == B_OK && code == B_OK) { - int32 count; - fOwner->fLink->Read(&count); - - for (int32 i = 0; i < count; i++) { - BRect rect; - fOwner->fLink->Read(&rect); - - region->Include(rect); - } + fOwner->fLink->ReadRegion(region); fState->valid_flags |= B_VIEW_CLIP_REGION_BIT; } } @@ -2273,8 +2265,7 @@ if (region) { int32 count = region->CountRects(); fOwner->fLink->Attach(count); - for (int32 i = 0; i < count; i++) - fOwner->fLink->Attach(region->RectAtInt(i)); + fOwner->fLink->AttachRegion(*region); } else { fOwner->fLink->Attach(-1); // '-1' means that in the app_server, there won't be any 'local' @@ -3318,22 +3309,16 @@ void -BView::Invalidate(const BRegion *invalRegion) +BView::Invalidate(const BRegion* region) { - if (invalRegion == NULL || fOwner == NULL) + if (region == NULL || fOwner == NULL) return; check_lock(); - int32 count = 0; - count = const_cast(invalRegion)->CountRects(); - fOwner->fLink->StartMessage(AS_LAYER_INVALIDATE_REGION); - fOwner->fLink->Attach(count); + fOwner->fLink->AttachRegion(*region); - for (int32 i = 0; i < count; i++) - fOwner->fLink->Attach( const_cast(invalRegion)->RectAt(i)); - fOwner->fLink->Flush(); } Modified: haiku/trunk/src/servers/app/Jamfile =================================================================== --- haiku/trunk/src/servers/app/Jamfile 2007-07-18 12:40:38 UTC (rev 21645) +++ haiku/trunk/src/servers/app/Jamfile 2007-07-18 12:59:05 UTC (rev 21646) @@ -38,6 +38,7 @@ OffscreenServerWindow.cpp OffscreenWindowLayer.cpp PNGDump.cpp + ProfileMessageSupport.cpp RAMLinkMsgReader.cpp RGBColor.cpp RegionPool.cpp Added: haiku/trunk/src/servers/app/ProfileMessageSupport.cpp =================================================================== --- haiku/trunk/src/servers/app/ProfileMessageSupport.cpp 2007-07-18 12:40:38 UTC (rev 21645) +++ haiku/trunk/src/servers/app/ProfileMessageSupport.cpp 2007-07-18 12:59:05 UTC (rev 21646) @@ -0,0 +1,286 @@ +/* + * Copyright 2007: string = ""; break; Haiku: string = ""; break; Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan A?mus + */ + + +#include "ProfileMessageSupport.h" + +#include "ServerProtocol.h" + + +void +string_for_message_code(uint32 code, BString& string) +{ + string = ""; + + switch (code) { + case AS_GET_DESKTOP: string = "AS_GET_DESKTOP"; break; + case AS_REGISTER_INPUT_SERVER: string = "AS_REGISTER_INPUT_SERVER"; break; + case AS_EVENT_STREAM_CLOSED: string = "AS_EVENT_STREAM_CLOSED"; break; + + // Desktop definitions (through the ServerApp, though) + case AS_GET_WINDOW_LIST: string = "AS_GET_WINDOW_LIST"; break; + case AS_GET_WINDOW_INFO: string = "AS_GET_WINDOW_INFO"; break; + case AS_MINIMIZE_TEAM: string = "AS_MINIMIZE_TEAM"; break; + case AS_BRING_TEAM_TO_FRONT: string = "AS_BRING_TEAM_TO_FRONT"; break; + case AS_WINDOW_ACTION: string = "AS_WINDOW_ACTION"; break; + + // Application definitions + case AS_CREATE_APP: string = "AS_CREATE_APP"; break; + case AS_DELETE_APP: string = "AS_DELETE_APP"; break; + case AS_QUIT_APP: string = "AS_QUIT_APP"; break; + case AS_ACTIVATE_APP: string = "AS_ACTIVATE_APP"; break; + case AS_APP_CRASHED: string = "AS_APP_CRASHED"; break; + + case AS_CREATE_WINDOW: string = "AS_CREATE_WINDOW"; break; + case AS_CREATE_OFFSCREEN_WINDOW: string = "AS_CREATE_OFFSCREEN_WINDOW"; break; + case AS_DELETE_WINDOW: string = "AS_DELETE_WINDOW"; break; + case AS_CREATE_BITMAP: string = "AS_CREATE_BITMAP"; break; + case AS_DELETE_BITMAP: string = "AS_DELETE_BITMAP"; break; + case AS_GET_BITMAP_OVERLAY_RESTRICTIONS: string = "AS_GET_BITMAP_OVERLAY_RESTRICTIONS"; break; + + // Cursor commands + case AS_SET_CURSOR: string = "AS_SET_CURSOR"; break; + + case AS_SHOW_CURSOR: string = "AS_SHOW_CURSOR"; break; + case AS_HIDE_CURSOR: string = "AS_HIDE_CURSOR"; break; + case AS_OBSCURE_CURSOR: string = "AS_OBSCURE_CURSOR"; break; + case AS_QUERY_CURSOR_HIDDEN: string = "AS_QUERY_CURSOR_HIDDEN"; break; + + case AS_CREATE_CURSOR: string = "AS_CREATE_CURSOR"; break; + case AS_DELETE_CURSOR: string = "AS_DELETE_CURSOR"; break; + + case AS_BEGIN_RECT_TRACKING: string = "AS_BEGIN_RECT_TRACKING"; break; + case AS_END_RECT_TRACKING: string = "AS_END_RECT_TRACKING"; break; + + // Window definitions + case AS_SHOW_WINDOW: string = "AS_SHOW_WINDOW"; break; + case AS_HIDE_WINDOW: string = "AS_HIDE_WINDOW"; break; + case AS_MINIMIZE_WINDOW: string = "AS_MINIMIZE_WINDOW"; break; + case AS_QUIT_WINDOW: string = "AS_QUIT_WINDOW"; break; + case AS_SEND_BEHIND: string = "AS_SEND_BEHIND"; break; + case AS_SET_LOOK: string = "AS_SET_LOOK"; break; + case AS_SET_FEEL: string = "AS_SET_FEEL"; break; + case AS_SET_FLAGS: string = "AS_SET_FLAGS"; break; + case AS_DISABLE_UPDATES: string = "AS_DISABLE_UPDATES"; break; + case AS_ENABLE_UPDATES: string = "AS_ENABLE_UPDATES"; break; + case AS_BEGIN_UPDATE: string = "AS_BEGIN_UPDATE"; break; + case AS_END_UPDATE: string = "AS_END_UPDATE"; break; + case AS_NEEDS_UPDATE: string = "AS_NEEDS_UPDATE"; break; + case AS_SET_WINDOW_TITLE: string = "AS_SET_WINDOW_TITLE"; break; + case AS_ADD_TO_SUBSET: string = "AS_ADD_TO_SUBSET"; break; + case AS_REMOVE_FROM_SUBSET: string = "AS_REMOVE_FROM_SUBSET"; break; + case AS_SET_ALIGNMENT: string = "AS_SET_ALIGNMENT"; break; + case AS_GET_ALIGNMENT: string = "AS_GET_ALIGNMENT"; break; + case AS_GET_WORKSPACES: string = "AS_GET_WORKSPACES"; break; + case AS_SET_WORKSPACES: string = "AS_SET_WORKSPACES"; break; + case AS_WINDOW_RESIZE: string = "AS_WINDOW_RESIZE"; break; + case AS_WINDOW_MOVE: string = "AS_WINDOW_MOVE"; break; + case AS_SET_SIZE_LIMITS: string = "AS_SET_SIZE_LIMITS"; break; + case AS_ACTIVATE_WINDOW: string = "AS_ACTIVATE_WINDOW"; break; + case AS_IS_FRONT_WINDOW: string = "AS_IS_FRONT_WINDOW"; break; + + // BPicture definitions + case AS_CREATE_PICTURE: string = "AS_CREATE_PICTURE"; break; + case AS_DELETE_PICTURE: string = "AS_DELETE_PICTURE"; break; + case AS_CLONE_PICTURE: string = "AS_CLONE_PICTURE"; break; + case AS_DOWNLOAD_PICTURE: string = "AS_DOWNLOAD_PICTURE"; break; + + // Font-related server communications + case AS_SET_SYSTEM_FONT: string = "AS_SET_SYSTEM_FONT"; break; + case AS_GET_SYSTEM_FONTS: string = "AS_GET_SYSTEM_FONTS"; break; + case AS_GET_SYSTEM_DEFAULT_FONT: string = "AS_GET_SYSTEM_DEFAULT_FONT"; break; + + case AS_GET_FONT_LIST_REVISION: string = "AS_GET_FONT_LIST_REVISION"; break; + case AS_GET_FAMILY_AND_STYLES: string = "AS_GET_FAMILY_AND_STYLES"; break; + + case AS_GET_FAMILY_AND_STYLE: string = "AS_GET_FAMILY_AND_STYLE"; break; + case AS_GET_FAMILY_AND_STYLE_IDS: string = "AS_GET_FAMILY_AND_STYLE_IDS"; break; + case AS_GET_FONT_BOUNDING_BOX: string = "AS_GET_FONT_BOUNDING_BOX"; break; + case AS_GET_TUNED_COUNT: string = "AS_GET_TUNED_COUNT"; break; + case AS_GET_TUNED_INFO: string = "AS_GET_TUNED_INFO"; break; + case AS_GET_FONT_HEIGHT: string = "AS_GET_FONT_HEIGHT"; break; + case AS_GET_FONT_FILE_FORMAT: string = "AS_GET_FONT_FILE_FORMAT"; break; + case AS_GET_EXTRA_FONT_FLAGS: string = "AS_GET_EXTRA_FONT_FLAGS"; break; + + case AS_GET_STRING_WIDTHS: string = "AS_GET_STRING_WIDTHS"; break; + case AS_GET_EDGES: string = "AS_GET_EDGES"; break; + case AS_GET_ESCAPEMENTS: string = "AS_GET_ESCAPEMENTS"; break; + case AS_GET_ESCAPEMENTS_AS_FLOATS: string = "AS_GET_ESCAPEMENTS_AS_FLOATS"; break; + case AS_GET_BOUNDINGBOXES_CHARS: string = "AS_GET_BOUNDINGBOXES_CHARS"; break; + case AS_GET_BOUNDINGBOXES_STRINGS: string = "AS_GET_BOUNDINGBOXES_STRINGS"; break; + case AS_GET_HAS_GLYPHS: string = "AS_GET_HAS_GLYPHS"; break; + case AS_GET_GLYPH_SHAPES: string = "AS_GET_GLYPH_SHAPES"; break; + case AS_GET_TRUNCATED_STRINGS: string = "AS_GET_TRUNCATED_STRINGS"; break; + + // Screen methods + case AS_VALID_SCREEN_ID: string = "AS_VALID_SCREEN_ID"; break; + case AS_GET_NEXT_SCREEN_ID: string = "AS_GET_NEXT_SCREEN_ID"; break; + case AS_SCREEN_GET_MODE: string = "AS_SCREEN_GET_MODE"; break; + case AS_SCREEN_SET_MODE: string = "AS_SCREEN_SET_MODE"; break; + case AS_PROPOSE_MODE: string = "AS_PROPOSE_MODE"; break; + case AS_GET_MODE_LIST: string = "AS_GET_MODE_LIST"; break; + + case AS_GET_PIXEL_CLOCK_LIMITS: string = "AS_GET_PIXEL_CLOCK_LIMITS"; break; + case AS_GET_TIMING_CONSTRAINTS: string = "AS_GET_TIMING_CONSTRAINTS"; break; + + case AS_SCREEN_GET_COLORMAP: string = "AS_SCREEN_GET_COLORMAP"; break; + case AS_GET_DESKTOP_COLOR: string = "AS_GET_DESKTOP_COLOR"; break; + case AS_SET_DESKTOP_COLOR: string = "AS_SET_DESKTOP_COLOR"; break; + case AS_GET_SCREEN_ID_FROM_WINDOW: string = "AS_GET_SCREEN_ID_FROM_WINDOW"; break; + + case AS_READ_BITMAP: string = "AS_READ_BITMAP"; break; + + case AS_GET_RETRACE_SEMAPHORE: string = "AS_GET_RETRACE_SEMAPHORE"; break; + case AS_GET_ACCELERANT_INFO: string = "AS_GET_ACCELERANT_INFO"; break; + case AS_GET_FRAME_BUFFER_CONFIG: string = "AS_GET_FRAME_BUFFER_CONFIG"; break; + + case AS_SET_DPMS: string = "AS_SET_DPMS"; break; + case AS_GET_DPMS_STATE: string = "AS_GET_DPMS_STATE"; break; + case AS_GET_DPMS_CAPABILITIES: string = "AS_GET_DPMS_CAPABILITIES"; break; + + // Misc stuff + case AS_GET_ACCELERANT_PATH: string = "AS_GET_ACCELERANT_PATH"; break; + case AS_GET_DRIVER_PATH: string = "AS_GET_DRIVER_PATH"; break; + + // Global function call defs + case AS_SET_UI_COLORS: string = "AS_SET_UI_COLORS"; break; + case AS_SET_UI_COLOR: string = "AS_SET_UI_COLOR"; break; + case AS_SET_DECORATOR: string = "AS_SET_DECORATOR"; break; + case AS_GET_DECORATOR: string = "AS_GET_DECORATOR"; break; + case AS_R5_SET_DECORATOR: string = "AS_R5_SET_DECORATOR"; break; + case AS_COUNT_DECORATORS: string = "AS_COUNT_DECORATORS"; break; + case AS_GET_DECORATOR_NAME: string = "AS_GET_DECORATOR_NAME"; break; + + case AS_COUNT_WORKSPACES: string = "AS_COUNT_WORKSPACES"; break; + case AS_SET_WORKSPACE_COUNT: string = "AS_SET_WORKSPACE_COUNT"; break; + case AS_CURRENT_WORKSPACE: string = "AS_CURRENT_WORKSPACE"; break; + case AS_ACTIVATE_WORKSPACE: string = "AS_ACTIVATE_WORKSPACE"; break; + case AS_GET_SCROLLBAR_INFO: string = "AS_GET_SCROLLBAR_INFO"; break; + case AS_SET_SCROLLBAR_INFO: string = "AS_SET_SCROLLBAR_INFO"; break; + case AS_GET_MENU_INFO: string = "AS_GET_MENU_INFO"; break; + case AS_SET_MENU_INFO: string = "AS_SET_MENU_INFO"; break; + case AS_IDLE_TIME: string = "AS_IDLE_TIME"; break; + case AS_SET_MOUSE_MODE: string = "AS_SET_MOUSE_MODE"; break; + case AS_GET_MOUSE_MODE: string = "AS_GET_MOUSE_MODE"; break; + case AS_GET_MOUSE: string = "AS_GET_MOUSE"; break; + case AS_SET_DECORATOR_SETTINGS: string = "AS_SET_DECORATOR_SETTINGS"; break; + case AS_GET_DECORATOR_SETTINGS: string = "AS_GET_DECORATOR_SETTINGS"; break; + case AS_GET_SHOW_ALL_DRAGGERS: string = "AS_GET_SHOW_ALL_DRAGGERS"; break; + case AS_SET_SHOW_ALL_DRAGGERS: string = "AS_SET_SHOW_ALL_DRAGGERS"; break; + + // Graphics calls + case AS_SET_HIGH_COLOR: string = "AS_SET_HIGH_COLOR"; break; + case AS_SET_LOW_COLOR: string = "AS_SET_LOW_COLOR"; break; + case AS_SET_VIEW_COLOR: string = "AS_SET_VIEW_COLOR"; break; + + case AS_STROKE_ARC: string = "AS_STROKE_ARC"; break; + case AS_STROKE_BEZIER: string = "AS_STROKE_BEZIER"; break; + case AS_STROKE_ELLIPSE: string = "AS_STROKE_ELLIPSE"; break; + case AS_STROKE_LINE: string = "AS_STROKE_LINE"; break; + case AS_STROKE_LINEARRAY: string = "AS_STROKE_LINEARRAY"; break; + case AS_STROKE_POLYGON: string = "AS_STROKE_POLYGON"; break; + case AS_STROKE_RECT: string = "AS_STROKE_RECT"; break; + case AS_STROKE_ROUNDRECT: string = "AS_STROKE_ROUNDRECT"; break; + case AS_STROKE_SHAPE: string = "AS_STROKE_SHAPE"; break; + case AS_STROKE_TRIANGLE: string = "AS_STROKE_TRIANGLE"; break; + + case AS_FILL_ARC: string = "AS_FILL_ARC"; break; + case AS_FILL_BEZIER: string = "AS_FILL_BEZIER"; break; + case AS_FILL_ELLIPSE: string = "AS_FILL_ELLIPSE"; break; + case AS_FILL_POLYGON: string = "AS_FILL_POLYGON"; break; + case AS_FILL_RECT: string = "AS_FILL_RECT"; break; + case AS_FILL_REGION: string = "AS_FILL_REGION"; break; + case AS_FILL_ROUNDRECT: string = "AS_FILL_ROUNDRECT"; break; + case AS_FILL_SHAPE: string = "AS_FILL_SHAPE"; break; + case AS_FILL_TRIANGLE: string = "AS_FILL_TRIANGLE"; break; + + case AS_DRAW_STRING: string = "AS_DRAW_STRING"; break; + case AS_SET_FONT: string = "AS_SET_FONT"; break; + case AS_SET_FONT_SIZE: string = "AS_SET_FONT_SIZE"; break; + + case AS_SYNC: string = "AS_SYNC"; break; + + case AS_LAYER_CREATE: string = "AS_LAYER_CREATE"; break; + case AS_LAYER_DELETE: string = "AS_LAYER_DELETE"; break; + case AS_LAYER_CREATE_ROOT: string = "AS_LAYER_CREATE_ROOT"; break; + case AS_LAYER_SHOW: string = "AS_LAYER_SHOW"; break; + case AS_LAYER_HIDE: string = "AS_LAYER_HIDE"; break; + case AS_LAYER_MOVE: string = "AS_LAYER_MOVE"; break; + case AS_LAYER_RESIZE: string = "AS_LAYER_RESIZE"; break; + case AS_LAYER_DRAW: string = "AS_LAYER_DRAW"; break; + + // View/Layer definitions + case AS_LAYER_GET_COORD: string = "AS_LAYER_GET_COORD"; break; + case AS_LAYER_SET_FLAGS: string = "AS_LAYER_SET_FLAGS"; break; + case AS_LAYER_SET_ORIGIN: string = "AS_LAYER_SET_ORIGIN"; break; + case AS_LAYER_GET_ORIGIN: string = "AS_LAYER_GET_ORIGIN"; break; + case AS_LAYER_RESIZE_MODE: string = "AS_LAYER_RESIZE_MODE"; break; + case AS_LAYER_SET_CURSOR: string = "AS_LAYER_SET_CURSOR"; break; + case AS_LAYER_BEGIN_RECT_TRACK: string = "AS_LAYER_BEGIN_RECT_TRACK"; break; + case AS_LAYER_END_RECT_TRACK: string = "AS_LAYER_END_RECT_TRACK"; break; + case AS_LAYER_DRAG_RECT: string = "AS_LAYER_DRAG_RECT"; break; + case AS_LAYER_DRAG_IMAGE: string = "AS_LAYER_DRAG_IMAGE"; break; + case AS_LAYER_SCROLL: string = "AS_LAYER_SCROLL"; break; + case AS_LAYER_SET_LINE_MODE: string = "AS_LAYER_SET_LINE_MODE"; break; + case AS_LAYER_GET_LINE_MODE: string = "AS_LAYER_GET_LINE_MODE"; break; + case AS_LAYER_PUSH_STATE: string = "AS_LAYER_PUSH_STATE"; break; + case AS_LAYER_POP_STATE: string = "AS_LAYER_POP_STATE"; break; + case AS_LAYER_SET_SCALE: string = "AS_LAYER_SET_SCALE"; break; + case AS_LAYER_GET_SCALE: string = "AS_LAYER_GET_SCALE"; break; + case AS_LAYER_SET_DRAWING_MODE: string = "AS_LAYER_SET_DRAWING_MODE"; break; + case AS_LAYER_GET_DRAWING_MODE: string = "AS_LAYER_GET_DRAWING_MODE"; break; + case AS_LAYER_SET_BLENDING_MODE: string = "AS_LAYER_SET_BLENDING_MODE"; break; + case AS_LAYER_GET_BLENDING_MODE: string = "AS_LAYER_GET_BLENDING_MODE"; break; + case AS_LAYER_SET_PEN_LOC: string = "AS_LAYER_SET_PEN_LOC"; break; + case AS_LAYER_GET_PEN_LOC: string = "AS_LAYER_GET_PEN_LOC"; break; + case AS_LAYER_SET_PEN_SIZE: string = "AS_LAYER_SET_PEN_SIZE"; break; + case AS_LAYER_GET_PEN_SIZE: string = "AS_LAYER_GET_PEN_SIZE"; break; + case AS_LAYER_SET_HIGH_COLOR: string = "AS_LAYER_SET_HIGH_COLOR"; break; + case AS_LAYER_SET_LOW_COLOR: string = "AS_LAYER_SET_LOW_COLOR"; break; + case AS_LAYER_SET_VIEW_COLOR: string = "AS_LAYER_SET_VIEW_COLOR"; break; + case AS_LAYER_GET_HIGH_COLOR: string = "AS_LAYER_GET_HIGH_COLOR"; break; + case AS_LAYER_GET_LOW_COLOR: string = "AS_LAYER_GET_LOW_COLOR"; break; + case AS_LAYER_GET_VIEW_COLOR: string = "AS_LAYER_GET_VIEW_COLOR"; break; + case AS_LAYER_PRINT_ALIASING: string = "AS_LAYER_PRINT_ALIASING"; break; + case AS_LAYER_CLIP_TO_PICTURE: string = "AS_LAYER_CLIP_TO_PICTURE"; break; + case AS_LAYER_GET_CLIP_REGION: string = "AS_LAYER_GET_CLIP_REGION"; break; + case AS_LAYER_DRAW_BITMAP: string = "AS_LAYER_DRAW_BITMAP"; break; + case AS_LAYER_SET_EVENT_MASK: string = "AS_LAYER_SET_EVENT_MASK"; break; + case AS_LAYER_SET_MOUSE_EVENT_MASK: string = "AS_LAYER_SET_MOUSE_EVENT_MASK"; break; + + case AS_LAYER_DRAW_STRING: string = "AS_LAYER_DRAW_STRING"; break; + case AS_LAYER_SET_CLIP_REGION: string = "AS_LAYER_SET_CLIP_REGION"; break; + case AS_LAYER_LINE_ARRAY: string = "AS_LAYER_LINE_ARRAY"; break; + case AS_LAYER_BEGIN_PICTURE: string = "AS_LAYER_BEGIN_PICTURE"; break; + case AS_LAYER_APPEND_TO_PICTURE: string = "AS_LAYER_APPEND_TO_PICTURE"; break; + case AS_LAYER_END_PICTURE: string = "AS_LAYER_END_PICTURE"; break; + case AS_LAYER_COPY_BITS: string = "AS_LAYER_COPY_BITS"; break; + case AS_LAYER_DRAW_PICTURE: string = "AS_LAYER_DRAW_PICTURE"; break; + case AS_LAYER_INVALIDATE_RECT: string = "AS_LAYER_INVALIDATE_RECT"; break; + case AS_LAYER_INVALIDATE_REGION: string = "AS_LAYER_INVALIDATE_REGION"; break; + case AS_LAYER_INVERT_RECT: string = "AS_LAYER_INVERT_RECT"; break; + case AS_LAYER_MOVE_TO: string = "AS_LAYER_MOVE_TO"; break; + case AS_LAYER_RESIZE_TO: string = "AS_LAYER_RESIZE_TO"; break; + case AS_LAYER_SET_STATE: string = "AS_LAYER_SET_STATE"; break; + case AS_LAYER_SET_FONT_STATE: string = "AS_LAYER_SET_FONT_STATE"; break; + case AS_LAYER_GET_STATE: string = "AS_LAYER_GET_STATE"; break; + case AS_LAYER_SET_VIEW_BITMAP: string = "AS_LAYER_SET_VIEW_BITMAP"; break; + case AS_LAYER_SET_PATTERN: string = "AS_LAYER_SET_PATTERN"; break; + case AS_SET_CURRENT_LAYER: string = "AS_SET_CURRENT_LAYER"; break; + + // BDirectWindow codes + case AS_DIRECT_WINDOW_GET_SYNC_DATA: string = "AS_DIRECT_WINDOW_GET_SYNC_DATA"; break; + case AS_DIRECT_WINDOW_SET_FULLSCREEN: string = "AS_DIRECT_WINDOW_SET_FULLSCREEN"; break; + + default: + string << "unkown code: " << code; + break; + } +} + + Added: haiku/trunk/src/servers/app/ProfileMessageSupport.h =================================================================== --- haiku/trunk/src/servers/app/ProfileMessageSupport.h 2007-07-18 12:40:38 UTC (rev 21645) +++ haiku/trunk/src/servers/app/ProfileMessageSupport.h 2007-07-18 12:59:05 UTC (rev 21646) @@ -0,0 +1,18 @@ +/* + * Copyright 2007, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan A?mus + */ +#ifndef PROFILE_MESSAGE_SUPPORT_H +#define PROFILE_MESSAGE_SUPPORT_H + + +#include + + +void string_for_message_code(uint32 code, BString& string); + + +#endif // PROFILE_MESSAGE_SUPPORT_H Modified: haiku/trunk/src/servers/app/ServerWindow.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerWindow.cpp 2007-07-18 12:40:38 UTC (rev 21645) +++ haiku/trunk/src/servers/app/ServerWindow.cpp 2007-07-18 12:59:05 UTC (rev 21646) @@ -29,6 +29,7 @@ #include "DrawingEngine.h" #include "HWInterface.h" #include "Overlay.h" +#include "ProfileMessageSupport.h" #include "RAMLinkMsgReader.h" #include "RenderingBuffer.h" #include "ServerApp.h" @@ -58,7 +59,7 @@ //#define TRACE_SERVER_WINDOW //#define TRACE_SERVER_WINDOW_MESSAGES -//#define PROFILE_MESSAGE_LOOP +#define PROFILE_MESSAGE_LOOP #ifdef TRACE_SERVER_WINDOW @@ -76,7 +77,10 @@ #endif #ifdef PROFILE_MESSAGE_LOOP -static struct profile { int32 count; bigtime_t time; } sMessageProfile[AS_LAST_CODE]; +struct profile { int32 code; int32 count; bigtime_t time; }; +static profile sMessageProfile[AS_LAST_CODE]; +static profile sRedrawProcessingTime; +//static profile sNextMessageTime; #endif @@ -183,7 +187,21 @@ fDeathSemaphore = create_sem(0, "window death"); } +#ifdef PROFILE_MESSAGE_LOOP +static int +compare_message_profiles(const void* _a, const void* _b) +{ + profile* a = (profile*)*(void**)_a; + profile* b = (profile*)*(void**)_b; + if (a->time < b->time) + return 1; + if (a->time > b->time) + return -1; + return 0; +} +#endif + //! Tears down all connections the main app_server objects, and deletes some internals. ServerWindow::~ServerWindow() { @@ -210,13 +228,35 @@ delete_sem(fDeathSemaphore); #ifdef PROFILE_MESSAGE_LOOP + BList profiles; for (int32 i = 0; i < AS_LAST_CODE; i++) { if (sMessageProfile[i].count == 0) continue; - printf("[%ld] called %ld times, %g secs (%Ld usecs per call)\n", - i, sMessageProfile[i].count, sMessageProfile[i].time / 1000000.0, - sMessageProfile[i].time / sMessageProfile[i].count); + sMessageProfile[i].code = i; + profiles.AddItem(&sMessageProfile[i]); } + + profiles.SortItems(compare_message_profiles); + + BString codeName; + int32 count = profiles.CountItems(); + for (int32 i = 0; i < count; i++) { + profile* p = (profile*)profiles.ItemAtFast(i); + string_for_message_code(p->code, codeName); + printf("[%s] called %ld times, %g secs (%Ld usecs per call)\n", + codeName.String(), p->count, p->time / 1000000.0, + p->time / p->count); + } + if (sRedrawProcessingTime.count > 0) { + printf("average redraw processing time: %g secs, count: %ld (%lld usecs per call)\n", + sRedrawProcessingTime.time / 1000000.0, sRedrawProcessingTime.count, + sRedrawProcessingTime.time / sRedrawProcessingTime.count); + } +// if (sNextMessageTime.count > 0) { +// printf("average NextMessage() time: %g secs, count: %ld (%lld usecs per call)\n", +// sNextMessageTime.time / 1000000.0, sNextMessageTime.count, +// sNextMessageTime.time / sNextMessageTime.count); +// } #endif } @@ -1711,23 +1751,15 @@ DTRACE(("ServerWindow %s: Message AS_LAYER_GET_CLIP_REGION: ViewLayer: %s\n", Title(), fCurrentLayer->Name())); // if this ViewLayer is hidden, it is clear that its visible region is void. + fLink.StartMessage(B_OK); if (fCurrentLayer->IsHidden()) { - fLink.StartMessage(B_OK); - fLink.Attach(0L); - fLink.Flush(); + BRegion empty; + fLink.AttachRegion(empty); } else { BRegion drawingRegion = fCurrentLayer->LocalClipping(); - int32 rectCount = drawingRegion.CountRects(); - - fLink.StartMessage(B_OK); - fLink.Attach(rectCount); - - for (int32 i = 0; i < rectCount; i++) { - fLink.Attach(drawingRegion.RectAt(i)); - } - - fLink.Flush(); + fLink.AttachRegion(drawingRegion); } + fLink.Flush(); break; } @@ -1741,24 +1773,20 @@ // region for the current draw state, // but an *empty* region is actually valid! // even if it means no drawing is allowed - BRegion region; - if (status == B_OK && rectCount >= 0) { - for (int32 i = 0; i < rectCount; i++) { - clipping_rect r; - status = link.Read(&r); - if (status < B_OK) - break; - // TODO: optimize (use AttachRegion()+ReadRegion()) - region.Include(r); - } - } else - status = B_ERROR; - if (status == B_OK) { + if (status < B_OK) + break; + + if (rectCount >= 0) { + // we are supposed to set the clipping region + BRegion region; + if (link.ReadRegion(®ion) < B_OK) + break; fCurrentLayer->SetUserClipping(®ion); } else { - // passing NULL sets this states region - // to that of the previous state + // we are supposed to unset the clipping region + // passing NULL sets this states region to that + // of the previous state fCurrentLayer->SetUserClipping(NULL); } @@ -1784,18 +1812,11 @@ // NOTE: looks like this call is NOT affected by origin and scale on R5 // so this implementation is "correct" - BRegion dirty; - int32 rectCount; - BRect rect; + BRegion region; + if (link.ReadRegion(®ion) < B_OK) + break; - link.Read(&rectCount); - - for (int i = 0; i < rectCount; i++) { - link.Read(&rect); - dirty.Include(rect); - } - - fWindowLayer->InvalidateView(fCurrentLayer, dirty); + fWindowLayer->InvalidateView(fCurrentLayer, region); break; } @@ -2677,14 +2698,32 @@ lockedDesktop = true; } - if (atomic_and(&fRedrawRequested, 0) != 0) + if (atomic_and(&fRedrawRequested, 0) != 0) { +#ifdef PROFILE_MESSAGE_LOOP + bigtime_t redrawStart = system_time(); +#endif fWindowLayer->RedrawDirtyRegion(); +#ifdef PROFILE_MESSAGE_LOOP + diff = system_time() - redrawStart; + atomic_add(&sRedrawProcessingTime.count, 1); +# ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST + atomic_add64(&sRedrawProcessingTime.time, diff); +# else + sRedrawProcessingTime.time += diff; +# endif +#endif + } + + +#ifdef PROFILE_MESSAGE_LOOP + bigtime_t dispatchStart = system_time(); +#endif _DispatchMessage(code, receiver); #ifdef PROFILE_MESSAGE_LOOP if (code >= 0 && code < AS_LAST_CODE) { - diff = system_time() - start; + diff = system_time() - dispatchStart; atomic_add(&sMessageProfile[code].count, 1); #ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST atomic_add64(&sMessageProfile[code].time, diff); @@ -2702,6 +2741,7 @@ break; } + // next message status_t status = receiver.GetNextMessage(code); if (status < B_OK) { // that shouldn't happen, it's our port Modified: haiku/trunk/src/servers/app/ViewLayer.cpp =================================================================== --- haiku/trunk/src/servers/app/ViewLayer.cpp 2007-07-18 12:40:38 UTC (rev 21645) +++ haiku/trunk/src/servers/app/ViewLayer.cpp 2007-07-18 12:59:05 UTC (rev 21646) @@ -1460,13 +1460,22 @@ // the clipping spans over the bounds area fLocalClipping.Set((clipping_rect)Bounds()); - // exclude all childs from the clipping - for (ViewLayer* child = FirstChild(); child; child = child->NextSibling()) { - if (child->IsVisible()) - fLocalClipping.Exclude((clipping_rect)child->Frame()); - - if (deep) - child->RebuildClipping(deep); + if (ViewLayer* child = FirstChild()) { + BRegion* childrenRegion = fWindow->GetRegion(); + if (!childrenRegion) + return; + + // exclude all children from the clipping + for (; child; child = child->NextSibling()) { + if (child->IsVisible()) + childrenRegion->Include((clipping_rect)child->Frame()); + + if (deep) + child->RebuildClipping(deep); + } + + fLocalClipping.Exclude(childrenRegion); + fWindow->RecycleRegion(childrenRegion); } // add the user clipping in case there is one Modified: haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp 2007-07-18 12:40:38 UTC (rev 21645) +++ haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp 2007-07-18 12:59:05 UTC (rev 21646) @@ -246,6 +246,8 @@ void Painter::SetHighColor(const rgb_color& color) { + if (fPatternHandler->HighColor().GetColor32() == color) + return; fPatternHandler->SetHighColor(color); if (*(fPatternHandler->GetR5Pattern()) == B_SOLID_HIGH) _SetRendererColor(color); @@ -1254,7 +1256,6 @@ // color.green / 255.0, // color.blue / 255.0, // color.alpha / 255.0)); - } // #pragma mark - Modified: haiku/trunk/src/tests/servers/app/Jamfile =================================================================== --- haiku/trunk/src/tests/servers/app/Jamfile 2007-07-18 12:40:38 UTC (rev 21645) +++ haiku/trunk/src/tests/servers/app/Jamfile 2007-07-18 12:59:05 UTC (rev 21646) @@ -92,11 +92,12 @@ # Misc. Sources Decorator.cpp DebugInfoManager.cpp + ProfileMessageSupport.cpp + EventDispatcher.cpp + EventStream.cpp + MessageLooper.cpp PNGDump.cpp RAMLinkMsgReader.cpp - MessageLooper.cpp - EventDispatcher.cpp - EventStream.cpp # Manager Classes BitmapManager.cpp From superstippi at gmx.de Wed Jul 18 14:59:05 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Wed, 18 Jul 2007 14:59:05 +0200 Subject: [Haiku-commits] r21646 - in haiku/trunk/src: kits/interface servers/app servers/app/drawing/Painter tests/servers/app In-Reply-To: <200707181259.l6ICx6q2017849@sheep.berlios.de> References: <200707181259.l6ICx6q2017849@sheep.berlios.de> Message-ID: <20070718145905.5898.8@stippis2.1184742390.fake> > Author: stippi > Date: 2007-07-18 14:59:05 +0200 (Wed, 18 Jul 2007) New Revision: 21646 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21646&view=rev > > Added: > haiku/trunk/src/servers/app/ProfileMessageSupport.cpp > haiku/trunk/src/servers/app/ProfileMessageSupport.h > Modified: > haiku/trunk/src/kits/interface/View.cpp > haiku/trunk/src/servers/app/Jamfile > haiku/trunk/src/servers/app/ServerWindow.cpp > haiku/trunk/src/servers/app/ViewLayer.cpp > haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp > haiku/trunk/src/tests/servers/app/Jamfile > Log: > * added ProfileMessageSupport.h/cpp to translate server message codes to > a string > * fixed profiling of message processsing in ServerWindow (didn't take > batch > processing into account) > * accelerated ViewLayer::RebuildClipping() by a factor of two by avoiding > BRegion::Exclude(clipping_rect) for each child, and instead building > one region with all children, and excluding that. RebuildClipping() is > quite a common operation and is quite slow for views with many children forgot to mention: * accelerated the remaining cases where BRegions are passed between server and client by using AttachRegion() and ReadRegion() Best regards, -Stephan From stippi at mail.berlios.de Wed Jul 18 15:22:27 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 18 Jul 2007 15:22:27 +0200 Subject: [Haiku-commits] r21647 - haiku/trunk/src/servers/app Message-ID: <200707181322.l6IDMRiJ020516@sheep.berlios.de> Author: stippi Date: 2007-07-18 15:22:26 +0200 (Wed, 18 Jul 2007) New Revision: 21647 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21647&view=rev Modified: haiku/trunk/src/servers/app/ServerWindow.cpp Log: * accidentally left the profiling on in last commit Modified: haiku/trunk/src/servers/app/ServerWindow.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerWindow.cpp 2007-07-18 12:59:05 UTC (rev 21646) +++ haiku/trunk/src/servers/app/ServerWindow.cpp 2007-07-18 13:22:26 UTC (rev 21647) @@ -59,7 +59,7 @@ //#define TRACE_SERVER_WINDOW //#define TRACE_SERVER_WINDOW_MESSAGES -#define PROFILE_MESSAGE_LOOP +//#define PROFILE_MESSAGE_LOOP #ifdef TRACE_SERVER_WINDOW From stippi at mail.berlios.de Wed Jul 18 19:01:35 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 18 Jul 2007 19:01:35 +0200 Subject: [Haiku-commits] r21648 - haiku/trunk/src/servers/app Message-ID: <200707181701.l6IH1Z4b010295@sheep.berlios.de> Author: stippi Date: 2007-07-18 19:01:34 +0200 (Wed, 18 Jul 2007) New Revision: 21648 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21648&view=rev Modified: haiku/trunk/src/servers/app/ViewLayer.cpp Log: * check the overlay of the child being removed, instead of the view's own overlay (Axel please review) Modified: haiku/trunk/src/servers/app/ViewLayer.cpp =================================================================== --- haiku/trunk/src/servers/app/ViewLayer.cpp 2007-07-18 13:22:26 UTC (rev 21647) +++ haiku/trunk/src/servers/app/ViewLayer.cpp 2007-07-18 17:01:34 UTC (rev 21648) @@ -270,7 +270,7 @@ layer->fNextSibling = NULL; if (layer->IsVisible()) { - Overlay* overlay = _Overlay(); + Overlay* overlay = layer->_Overlay(); if (overlay != NULL) overlay->Hide(); From stippi at mail.berlios.de Wed Jul 18 19:02:04 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 18 Jul 2007 19:02:04 +0200 Subject: [Haiku-commits] r21649 - haiku/trunk/src/servers/app Message-ID: <200707181702.l6IH24wA010679@sheep.berlios.de> Author: stippi Date: 2007-07-18 19:02:03 +0200 (Wed, 18 Jul 2007) New Revision: 21649 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21649&view=rev Modified: haiku/trunk/src/servers/app/ServerWindow.cpp Log: * fix comment Modified: haiku/trunk/src/servers/app/ServerWindow.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerWindow.cpp 2007-07-18 17:01:34 UTC (rev 21648) +++ haiku/trunk/src/servers/app/ServerWindow.cpp 2007-07-18 17:02:03 UTC (rev 21649) @@ -1324,7 +1324,7 @@ // TODO: think about how to avoid this hack: // the parent clipping needs to be updated, it is not - // done in ResizeBy() since it would need to avoid + // done in MoveBy() since it would need to avoid // too much computations when children are resized because // follow modes if (ViewLayer* parent = fCurrentLayer->Parent()) From stippi at mail.berlios.de Wed Jul 18 19:02:45 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 18 Jul 2007 19:02:45 +0200 Subject: [Haiku-commits] r21650 - haiku/trunk/src/servers/app/drawing/Painter Message-ID: <200707181702.l6IH2jpP012139@sheep.berlios.de> Author: stippi Date: 2007-07-18 19:02:44 +0200 (Wed, 18 Jul 2007) New Revision: 21650 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21650&view=rev Modified: haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp haiku/trunk/src/servers/app/drawing/Painter/Painter.h Log: * cleanup, removed use of pointers and allocations Modified: haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp 2007-07-18 17:02:03 UTC (rev 21649) +++ haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp 2007-07-18 17:02:44 UTC (rev 21650) @@ -46,38 +46,20 @@ #include "Painter.h" -#if ALIASED_DRAWING -// in this case, we _cannot_ use the outline rasterizer. -# define USE_OUTLINE_RASTERIZER 0 -#else -// in this case, we can optionally use the outline rasterizer (faster). -// NOTE: The outline rasterizer is different from the "general purpose" -// rasterizer and can speed up the stroking of lines. It has some problems -// though, for example the butts of the lines are not anti-aliased. So we -// use the much more powerfull general purpose rasterizer, and live with the -// performance hit for now. See _StrokePath(). -// NOTE: The outline rasterizer will still be used for lines with 1 pixel width! -# define USE_OUTLINE_RASTERIZER 0 -#endif - - #define CHECK_CLIPPING if (!fValidClipping) return BRect(0, 0, -1, -1); // constructor Painter::Painter() - : fBuffer(NULL), - fPixelFormat(NULL), - fBaseRenderer(NULL), - fOutlineRenderer(NULL), - fOutlineRasterizer(NULL), - fUnpackedScanline(NULL), - fPackedScanline(NULL), - fRasterizer(NULL), - fRenderer(NULL), - fRendererBin(NULL), + : fBuffer(), + fPixelFormat(fBuffer, &fPatternHandler), + fBaseRenderer(fPixelFormat), + fUnpackedScanline(), + fPackedScanline(), + fRasterizer(), + fRenderer(fBaseRenderer), + fRendererBin(fBaseRenderer), - fLineProfile(), fPath(), fCurve(fPath), @@ -95,26 +77,25 @@ fLineJoinMode(B_MITER_JOIN), fMiterLimit(B_DEFAULT_MITER_LIMIT), - fPatternHandler(new PatternHandler()), + fPatternHandler(), fTextRenderer(AGGTextRenderer::Default()) { + fPixelFormat.SetDrawingMode(fDrawingMode, fAlphaSrcMode, fAlphaFncMode, false); + // Usually, the drawing engine will lock the font for us when // needed - unfortunately, it can't know we need it here fFont.Lock(); _UpdateFont(); fFont.Unlock(); -#if USE_OUTLINE_RASTERIZER - _UpdateLineWidth(); +#if ALIASED_DRAWING + fRasterizer.gamma(agg::gamma_threshold(0.5)); #endif } // destructor Painter::~Painter() { - _MakeEmpty(); - - delete fPatternHandler; } // #pragma mark - @@ -126,49 +107,14 @@ if (buffer && buffer->InitCheck() >= B_OK && // TODO: implement drawing on B_RGB24, B_RGB15, B_RGB16, B_CMAP8 and B_GRAY8 :-[ (buffer->ColorSpace() == B_RGBA32 || buffer->ColorSpace() == B_RGB32)) { - // clean up previous stuff - _MakeEmpty(); + fBuffer.attach((uint8*)buffer->Bits(), + buffer->Width(), buffer->Height(), buffer->BytesPerRow()); - fBuffer = new agg::rendering_buffer(); - fBuffer->attach((uint8*)buffer->Bits(), - buffer->Width(), - buffer->Height(), - buffer->BytesPerRow()); - fPixelFormat = new pixfmt(*fBuffer, fPatternHandler); - fPixelFormat->SetDrawingMode(fDrawingMode, fAlphaSrcMode, fAlphaFncMode, false); - - fBaseRenderer = new renderer_base(*fPixelFormat); - // These are the AGG renderes and rasterizes which // will be used for stroking paths -#if USE_OUTLINE_RASTERIZER -#if ALIASED_DRAWING - fOutlineRenderer = new outline_renderer_type(*fBaseRenderer); - fOutlineRasterizer = new outline_rasterizer_type(*fOutlineRenderer); -#else - fOutlineRenderer = new outline_renderer_type(*fBaseRenderer, fLineProfile); - fOutlineRasterizer = new outline_rasterizer_type(*fOutlineRenderer); - // attach our line profile to the renderer, it keeps a pointer - fOutlineRenderer->profile(fLineProfile); -#endif // ALIASED_DRAWING -#endif // USE_OUTLINE_RASTERIZER - // the renderer used for filling paths - fRenderer = new renderer_type(*fBaseRenderer); - fRasterizer = new rasterizer_type(); - fUnpackedScanline = new scanline_unpacked_type(); - fPackedScanline = new scanline_packed_type(); - -#if ALIASED_DRAWING - fRasterizer->gamma(agg::gamma_threshold(0.5)); -#endif - - // possibly needed for drawing text (if the font is - // a one bit bitmap font, which is currently not supported yet) - fRendererBin = new renderer_bin_type(*fBaseRenderer); - - _SetRendererColor(fPatternHandler->HighColor().GetColor32()); + _SetRendererColor(fPatternHandler.HighColor().GetColor32()); } } @@ -176,7 +122,6 @@ void Painter::DetachFromBuffer() { - _MakeEmpty(); } // #pragma mark - @@ -203,7 +148,7 @@ // any of these conditions means we need to use a different drawing // mode instance - bool updateDrawingMode = !(data->GetPattern() == fPatternHandler->GetPattern()) || + bool updateDrawingMode = !(data->GetPattern() == fPatternHandler.GetPattern()) || data->GetDrawingMode() != fDrawingMode || (data->GetDrawingMode() == B_OP_ALPHA && (data->AlphaSrcMode() != fAlphaSrcMode || data->AlphaFncMode() != fAlphaFncMode)); @@ -211,8 +156,8 @@ fDrawingMode = data->GetDrawingMode(); fAlphaSrcMode = data->AlphaSrcMode(); fAlphaFncMode = data->AlphaFncMode(); - fPatternHandler->SetPattern(data->GetPattern()); - fPatternHandler->SetOffsets(xOffset, yOffset); + fPatternHandler.SetPattern(data->GetPattern()); + fPatternHandler.SetOffsets(xOffset, yOffset); fLineCapMode = data->LineCapMode(); fLineJoinMode = data->LineJoinMode(); fMiterLimit = data->MiterLimit(); @@ -222,7 +167,7 @@ SetHighColor(data->HighColor().GetColor32()); SetLowColor(data->LowColor().GetColor32()); - if (updateDrawingMode || fPixelFormat->UsesOpCopyForText()) + if (updateDrawingMode || fPixelFormat.UsesOpCopyForText()) _UpdateDrawingMode(); } @@ -233,12 +178,12 @@ Painter::ConstrainClipping(const BRegion* region) { fClippingRegion = region; - fBaseRenderer->set_clipping_region(const_cast(region)); + fBaseRenderer.set_clipping_region(const_cast(region)); fValidClipping = region->Frame().IsValid(); if (fValidClipping) { clipping_rect cb = fClippingRegion->FrameInt(); - fRasterizer->clip_box(cb.left, cb.top, cb.right + 1, cb.bottom + 1); + fRasterizer.clip_box(cb.left, cb.top, cb.right + 1, cb.bottom + 1); } } @@ -246,10 +191,10 @@ void Painter::SetHighColor(const rgb_color& color) { - if (fPatternHandler->HighColor().GetColor32() == color) + if (fPatternHandler.HighColor().GetColor32() == color) return; - fPatternHandler->SetHighColor(color); - if (*(fPatternHandler->GetR5Pattern()) == B_SOLID_HIGH) + fPatternHandler.SetHighColor(color); + if (*(fPatternHandler.GetR5Pattern()) == B_SOLID_HIGH) _SetRendererColor(color); } @@ -257,8 +202,8 @@ void Painter::SetLowColor(const rgb_color& color) { - fPatternHandler->SetLowColor(color); - if (*(fPatternHandler->GetR5Pattern()) == B_SOLID_LOW) + fPatternHandler.SetLowColor(color); + if (*(fPatternHandler.GetR5Pattern()) == B_SOLID_LOW) _SetRendererColor(color); } @@ -278,11 +223,6 @@ { if (fPenSize != size) { fPenSize = size; -#if USE_OUTLINE_RASTERIZER -// NOTE: _UpdateLineWidth() updates the line profile which is quite a heavy resource! -// fortunately, we don't need it when using the general purpose rasterizer - _UpdateLineWidth(); -#endif } } @@ -290,18 +230,18 @@ void Painter::SetPattern(const pattern& p, bool drawingText) { - if (!(p == *fPatternHandler->GetR5Pattern()) || drawingText != fDrawingText) { - fPatternHandler->SetPattern(p); + if (!(p == *fPatternHandler.GetR5Pattern()) || drawingText != fDrawingText) { + fPatternHandler.SetPattern(p); fDrawingText = drawingText; _UpdateDrawingMode(fDrawingText); // update renderer color if necessary - if (fPatternHandler->IsSolidHigh()) { + if (fPatternHandler.IsSolidHigh()) { // pattern was not solid high before - _SetRendererColor(fPatternHandler->HighColor().GetColor32()); - } else if (fPatternHandler->IsSolidLow()) { + _SetRendererColor(fPatternHandler.HighColor().GetColor32()); + } else if (fPatternHandler.IsSolidLow()) { // pattern was not solid low before - _SetRendererColor(fPatternHandler->LowColor().GetColor32()); + _SetRendererColor(fPatternHandler.LowColor().GetColor32()); } } } @@ -351,12 +291,12 @@ // first, try an optimized version if (fPenSize == 1.0 && (fDrawingMode == B_OP_COPY || fDrawingMode == B_OP_OVER)) { - pattern pat = *fPatternHandler->GetR5Pattern(); + pattern pat = *fPatternHandler.GetR5Pattern(); if (pat == B_SOLID_HIGH && - StraightLine(a, b, fPatternHandler->HighColor().GetColor32())) { + StraightLine(a, b, fPatternHandler.HighColor().GetColor32())) { return _Clipped(touched); } else if (pat == B_SOLID_LOW && - StraightLine(a, b, fPatternHandler->LowColor().GetColor32())) { + StraightLine(a, b, fPatternHandler.LowColor().GetColor32())) { return _Clipped(touched); } } @@ -393,64 +333,65 @@ bool Painter::StraightLine(BPoint a, BPoint b, const rgb_color& c) const { - if (fBuffer && fValidClipping) { - if (a.x == b.x) { - // vertical - uint8* dst = fBuffer->row_ptr(0); - uint32 bpr = fBuffer->stride(); - int32 x = (int32)a.x; - dst += x * 4; - int32 y1 = (int32)min_c(a.y, b.y); - int32 y2 = (int32)max_c(a.y, b.y); - pixel32 color; - color.data8[0] = c.blue; - color.data8[1] = c.green; - color.data8[2] = c.red; - color.data8[3] = 255; - // draw a line, iterate over clipping boxes - fBaseRenderer->first_clip_box(); - do { - if (fBaseRenderer->xmin() <= x && - fBaseRenderer->xmax() >= x) { - int32 i = max_c(fBaseRenderer->ymin(), y1); - int32 end = min_c(fBaseRenderer->ymax(), y2); - uint8* handle = dst + i * bpr; - for (; i <= end; i++) { - *(uint32*)handle = color.data32; - handle += bpr; - } + if (!fValidClipping) + return false; + + if (a.x == b.x) { + // vertical + uint8* dst = fBuffer.row_ptr(0); + uint32 bpr = fBuffer.stride(); + int32 x = (int32)a.x; + dst += x * 4; + int32 y1 = (int32)min_c(a.y, b.y); + int32 y2 = (int32)max_c(a.y, b.y); + pixel32 color; + color.data8[0] = c.blue; + color.data8[1] = c.green; + color.data8[2] = c.red; + color.data8[3] = 255; + // draw a line, iterate over clipping boxes + fBaseRenderer.first_clip_box(); + do { + if (fBaseRenderer.xmin() <= x && + fBaseRenderer.xmax() >= x) { + int32 i = max_c(fBaseRenderer.ymin(), y1); + int32 end = min_c(fBaseRenderer.ymax(), y2); + uint8* handle = dst + i * bpr; + for (; i <= end; i++) { + *(uint32*)handle = color.data32; + handle += bpr; } - } while (fBaseRenderer->next_clip_box()); - - return true; - - } else if (a.y == b.y) { - // horizontal - int32 y = (int32)a.y; - uint8* dst = fBuffer->row_ptr(y); - int32 x1 = (int32)min_c(a.x, b.x); - int32 x2 = (int32)max_c(a.x, b.x); - pixel32 color; - color.data8[0] = c.blue; - color.data8[1] = c.green; - color.data8[2] = c.red; - color.data8[3] = 255; - // draw a line, iterate over clipping boxes - fBaseRenderer->first_clip_box(); - do { - if (fBaseRenderer->ymin() <= y && - fBaseRenderer->ymax() >= y) { - int32 i = max_c(fBaseRenderer->xmin(), x1); - int32 end = min_c(fBaseRenderer->xmax(), x2); - uint32* handle = (uint32*)(dst + i * 4); - for (; i <= end; i++) { - *handle++ = color.data32; - } + } + } while (fBaseRenderer.next_clip_box()); + + return true; + + } else if (a.y == b.y) { + // horizontal + int32 y = (int32)a.y; + uint8* dst = fBuffer.row_ptr(y); + int32 x1 = (int32)min_c(a.x, b.x); + int32 x2 = (int32)max_c(a.x, b.x); + pixel32 color; + color.data8[0] = c.blue; + color.data8[1] = c.green; + color.data8[2] = c.red; + color.data8[3] = 255; + // draw a line, iterate over clipping boxes + fBaseRenderer.first_clip_box(); + do { + if (fBaseRenderer.ymin() <= y && + fBaseRenderer.ymax() >= y) { + int32 i = max_c(fBaseRenderer.xmin(), x1); + int32 end = min_c(fBaseRenderer.xmax(), x2); + uint32* handle = (uint32*)(dst + i * 4); + for (; i <= end; i++) { + *handle++ = color.data32; } - } while (fBaseRenderer->next_clip_box()); - - return true; - } + } + } while (fBaseRenderer.next_clip_box()); + + return true; } return false; } @@ -594,16 +535,16 @@ // first, try an optimized version if (fPenSize == 1.0 && (fDrawingMode == B_OP_COPY || fDrawingMode == B_OP_OVER)) { - pattern p = *fPatternHandler->GetR5Pattern(); + pattern p = *fPatternHandler.GetR5Pattern(); if (p == B_SOLID_HIGH) { BRect rect(a, b); StrokeRect(rect, - fPatternHandler->HighColor().GetColor32()); + fPatternHandler.HighColor().GetColor32()); return _Clipped(rect); } else if (p == B_SOLID_LOW) { BRect rect(a, b); StrokeRect(rect, - fPatternHandler->LowColor().GetColor32()); + fPatternHandler.LowColor().GetColor32()); return _Clipped(rect); } } @@ -659,27 +600,27 @@ // first, try an optimized version if (fDrawingMode == B_OP_COPY || fDrawingMode == B_OP_OVER) { - pattern p = *fPatternHandler->GetR5Pattern(); + pattern p = *fPatternHandler.GetR5Pattern(); if (p == B_SOLID_HIGH) { BRect rect(a, b); - FillRect(rect, fPatternHandler->HighColor().GetColor32()); + FillRect(rect, fPatternHandler.HighColor().GetColor32()); return _Clipped(rect); } else if (p == B_SOLID_LOW) { BRect rect(a, b); - FillRect(rect, fPatternHandler->LowColor().GetColor32()); + FillRect(rect, fPatternHandler.LowColor().GetColor32()); return _Clipped(rect); } } if (fDrawingMode == B_OP_ALPHA && fAlphaFncMode == B_ALPHA_OVERLAY) { - pattern p = *fPatternHandler->GetR5Pattern(); + pattern p = *fPatternHandler.GetR5Pattern(); if (p == B_SOLID_HIGH) { BRect rect(a, b); - _BlendRect32(rect, fPatternHandler->HighColor().GetColor32()); + _BlendRect32(rect, fPatternHandler.HighColor().GetColor32()); return _Clipped(rect); } else if (p == B_SOLID_LOW) { - rgb_color c = fPatternHandler->LowColor().GetColor32(); + rgb_color c = fPatternHandler.LowColor().GetColor32(); if (fAlphaSrcMode == B_CONSTANT_ALPHA) - c.alpha = fPatternHandler->HighColor().GetColor32().alpha; + c.alpha = fPatternHandler.HighColor().GetColor32().alpha; BRect rect(a, b); _BlendRect32(rect, c); return _Clipped(rect); @@ -707,70 +648,69 @@ void Painter::FillRect(const BRect& r, const rgb_color& c) const { - if (fBuffer && fValidClipping) { - uint8* dst = fBuffer->row_ptr(0); - uint32 bpr = fBuffer->stride(); - int32 left = (int32)r.left; - int32 top = (int32)r.top; - int32 right = (int32)r.right; - int32 bottom = (int32)r.bottom; - // get a 32 bit pixel ready with the color - pixel32 color; - color.data8[0] = c.blue; - color.data8[1] = c.green; - color.data8[2] = c.red; - color.data8[3] = c.alpha; - // fill rects, iterate over clipping boxes - fBaseRenderer->first_clip_box(); - do { - int32 x1 = max_c(fBaseRenderer->xmin(), left); - int32 x2 = min_c(fBaseRenderer->xmax(), right); - if (x1 <= x2) { - int32 y1 = max_c(fBaseRenderer->ymin(), top); - int32 y2 = min_c(fBaseRenderer->ymax(), bottom); - uint8* offset = dst + x1 * 4; - for (; y1 <= y2; y1++) { + if (!fValidClipping) + return; + + uint8* dst = fBuffer.row_ptr(0); + uint32 bpr = fBuffer.stride(); + int32 left = (int32)r.left; + int32 top = (int32)r.top; + int32 right = (int32)r.right; + int32 bottom = (int32)r.bottom; + // get a 32 bit pixel ready with the color + pixel32 color; + color.data8[0] = c.blue; + color.data8[1] = c.green; + color.data8[2] = c.red; + color.data8[3] = c.alpha; + // fill rects, iterate over clipping boxes + fBaseRenderer.first_clip_box(); + do { + int32 x1 = max_c(fBaseRenderer.xmin(), left); + int32 x2 = min_c(fBaseRenderer.xmax(), right); + if (x1 <= x2) { + int32 y1 = max_c(fBaseRenderer.ymin(), top); + int32 y2 = min_c(fBaseRenderer.ymax(), bottom); + uint8* offset = dst + x1 * 4; + for (; y1 <= y2; y1++) { // uint32* handle = (uint32*)(offset + y1 * bpr); // for (int32 x = x1; x <= x2; x++) { // *handle++ = color.data32; // } gfxset32(offset + y1 * bpr, color.data32, (x2 - x1 + 1) * 4); - } } - } while (fBaseRenderer->next_clip_box()); - } + } + } while (fBaseRenderer.next_clip_box()); } // FillRectNoClipping void Painter::FillRectNoClipping(const BRect& r, const rgb_color& c) const { - if (fBuffer) { - int32 left = (int32)r.left; - int32 y = (int32)r.top; - int32 right = (int32)r.right; - int32 bottom = (int32)r.bottom; + int32 left = (int32)r.left; + int32 y = (int32)r.top; + int32 right = (int32)r.right; + int32 bottom = (int32)r.bottom; - uint8* dst = fBuffer->row_ptr(y); - uint32 bpr = fBuffer->stride(); + uint8* dst = fBuffer.row_ptr(y); + uint32 bpr = fBuffer.stride(); - // get a 32 bit pixel ready with the color - pixel32 color; - color.data8[0] = c.blue; - color.data8[1] = c.green; - color.data8[2] = c.red; - color.data8[3] = c.alpha; + // get a 32 bit pixel ready with the color + pixel32 color; + color.data8[0] = c.blue; + color.data8[1] = c.green; + color.data8[2] = c.red; + color.data8[3] = c.alpha; - dst += left * 4; + dst += left * 4; - for (; y <= bottom; y++) { + for (; y <= bottom; y++) { // uint32* handle = (uint32*)dst; // for (int32 x = left; x <= right; x++) { // *handle++ = color.data32; // } gfxset32(dst, color.data32, (right - left + 1) * 4); - dst += bpr; - } + dst += bpr; } } @@ -809,8 +749,8 @@ outer.rect(lt.x, lt.y, rb.x, rb.y); outer.radius(xRadius, yRadius); - fRasterizer->reset(); - fRasterizer->add_path(outer); + fRasterizer.reset(); + fRasterizer.add_path(outer); // don't add an inner hole if the "size is negative", this avoids some // defects that can be observed on R5 and could be regarded as a bug. @@ -819,19 +759,19 @@ inner.rect(lt.x + fPenSize, lt.y + fPenSize, rb.x - fPenSize, rb.y - fPenSize); inner.radius(max_c(0.0, xRadius - fPenSize), max_c(0.0, yRadius - fPenSize)); - fRasterizer->add_path(inner); + fRasterizer.add_path(inner); } // make the inner rect work as a hole - fRasterizer->filling_rule(agg::fill_even_odd); + fRasterizer.filling_rule(agg::fill_even_odd); if (fPenSize > 2) - agg::render_scanlines(*fRasterizer, *fPackedScanline, *fRenderer); + agg::render_scanlines(fRasterizer, fPackedScanline, fRenderer); else - agg::render_scanlines(*fRasterizer, *fUnpackedScanline, *fRenderer); + agg::render_scanlines(fRasterizer, fUnpackedScanline, fRenderer); // reset to default - fRasterizer->filling_rule(agg::fill_non_zero); + fRasterizer.filling_rule(agg::fill_non_zero); return _Clipped(_BoundingBox(outer)); } @@ -915,20 +855,20 @@ yRadius + inset, divisions); - fRasterizer->reset(); - fRasterizer->add_path(outer); - fRasterizer->add_path(inner); + fRasterizer.reset(); + fRasterizer.add_path(outer); + fRasterizer.add_path(inner); // make the inner ellipse work as a hole - fRasterizer->filling_rule(agg::fill_even_odd); + fRasterizer.filling_rule(agg::fill_even_odd); if (fPenSize > 4) - agg::render_scanlines(*fRasterizer, *fPackedScanline, *fRenderer); + agg::render_scanlines(fRasterizer, fPackedScanline, fRenderer); else - agg::render_scanlines(*fRasterizer, *fUnpackedScanline, *fRenderer); + agg::render_scanlines(fRasterizer, fUnpackedScanline, fRenderer); // reset to default - fRasterizer->filling_rule(agg::fill_non_zero); + fRasterizer.filling_rule(agg::fill_non_zero); return _Clipped(_BoundingBox(outer)); } @@ -1008,17 +948,16 @@ SetPattern(B_SOLID_HIGH, true); - if (fBuffer) { - bounds = fTextRenderer->RenderString(utf8String, - length, - fRenderer, - fRendererBin, - baseLine, - fClippingRegion->Frame(), - false, - &fPenLocation, - delta); - } + bounds = fTextRenderer->RenderString(utf8String, + length, + &fRenderer, + &fRendererBin, + baseLine, + fClippingRegion->Frame(), + false, + &fPenLocation, + delta); + return _Clipped(bounds); } @@ -1036,8 +975,8 @@ static BRect dummy; return fTextRenderer->RenderString(utf8String, length, - fRenderer, - fRendererBin, + &fRenderer, + &fRendererBin, baseLine, dummy, true, penLocation, delta); } @@ -1113,42 +1052,6 @@ // #pragma mark - private -// _MakeEmpty -void -Painter::_MakeEmpty() -{ - delete fBuffer; - fBuffer = NULL; - - delete fPixelFormat; - fPixelFormat = NULL; - - delete fBaseRenderer; - fBaseRenderer = NULL; - -#if USE_OUTLINE_RASTERIZER - delete fOutlineRenderer; - fOutlineRenderer = NULL; - - delete fOutlineRasterizer; - fOutlineRasterizer = NULL; -#endif - - delete fUnpackedScanline; - fUnpackedScanline = NULL; - delete fPackedScanline; - fPackedScanline = NULL; - - delete fRasterizer; - fRasterizer = NULL; - - delete fRenderer; - fRenderer = NULL; - - delete fRendererBin; - fRendererBin = NULL; -} - // _Transform void Painter::_Transform(BPoint* point, bool centerOffset) const @@ -1194,13 +1097,6 @@ fTextRenderer->SetFont(fFont); } -// _UpdateLineWidth -void -Painter::_UpdateLineWidth() -{ - fLineProfile.width(fPenSize); -} - // _UpdateDrawingMode void Painter::_UpdateDrawingMode(bool drawingText) @@ -1223,39 +1119,23 @@ // When a solid pattern is used, _SetRendererColor() // has to be called so that all internal colors in the renderes // are up to date for use by the solid drawing mode version. - fPixelFormat->SetDrawingMode(fDrawingMode, fAlphaSrcMode, - fAlphaFncMode, drawingText); + fPixelFormat.SetDrawingMode(fDrawingMode, fAlphaSrcMode, + fAlphaFncMode, drawingText); } // _SetRendererColor void Painter::_SetRendererColor(const rgb_color& color) const { -#if USE_OUTLINE_RASTERIZER - if (fOutlineRenderer) -#if ALIASED_DRAWING - fOutlineRenderer->line_color(agg::rgba(color.red / 255.0, - color.green / 255.0, - color.blue / 255.0, - color.alpha / 255.0)); -#else - fOutlineRenderer->color(agg::rgba(color.red / 255.0, - color.green / 255.0, - color.blue / 255.0, - color.alpha / 255.0)); -#endif // ALIASED_DRAWING -#endif // USE_OUTLINE_RASTERIZER - if (fRenderer) - fRenderer->color(agg::rgba(color.red / 255.0, - color.green / 255.0, - color.blue / 255.0, - color.alpha / 255.0)); + fRenderer.color(agg::rgba(color.red / 255.0, + color.green / 255.0, + color.blue / 255.0, + color.alpha / 255.0)); // TODO: bitmap fonts not yet correctly setup in AGGTextRenderer -// if (fRendererBin) -// fRendererBin->color(agg::rgba(color.red / 255.0, -// color.green / 255.0, -// color.blue / 255.0, -// color.alpha / 255.0)); +// fRendererBin.color(agg::rgba(color.red / 255.0, +// color.green / 255.0, +// color.blue / 255.0, +// color.alpha / 255.0)); } // #pragma mark - @@ -1351,7 +1231,7 @@ BRect actualBitmapRect, BRect bitmapRect, BRect viewRect) const { - if (!fBuffer || !fValidClipping + if (!fValidClipping || !bitmapRect.IsValid() || !bitmapRect.Intersects(actualBitmapRect) || !viewRect.IsValid()) { return; @@ -1474,8 +1354,8 @@ { // NOTE: this would crash if viewRect was large enough to read outside the // bitmap, so make sure this is not the case before calling this function! - uint8* dst = fBuffer->row_ptr(0); - uint32 dstBPR = fBuffer->stride(); + uint8* dst = fBuffer.row_ptr(0); + uint32 dstBPR = fBuffer.stride(); const uint8* src = srcBuffer.row_ptr(0); uint32 srcBPR = srcBuffer.stride(); @@ -1503,13 +1383,13 @@ const rgb_color* colorMap = SystemPalette(); // copy rects, iterate over clipping boxes - fBaseRenderer->first_clip_box(); + fBaseRenderer.first_clip_box(); do { - int32 x1 = max_c(fBaseRenderer->xmin(), left); - int32 x2 = min_c(fBaseRenderer->xmax(), right); + int32 x1 = max_c(fBaseRenderer.xmin(), left); + int32 x2 = min_c(fBaseRenderer.xmax(), right); if (x1 <= x2) { - int32 y1 = max_c(fBaseRenderer->ymin(), top); - int32 y2 = min_c(fBaseRenderer->ymax(), bottom); + int32 y1 = max_c(fBaseRenderer.ymin(), top); + int32 y2 = min_c(fBaseRenderer.ymax(), bottom); if (y1 <= y2) { uint8* dstHandle = dst + y1 * dstBPR + x1 * 4; const uint8* srcHandle = src + (y1 - yOffset) * srcBPR @@ -1524,7 +1404,7 @@ } } } - } while (fBaseRenderer->next_clip_box()); + } while (fBaseRenderer.next_clip_box()); } // _DrawBitmapGeneric32 @@ -1582,13 +1462,13 @@ fPath.close_polygon(); agg::conv_transform transformedPath(fPath, srcMatrix); - fRasterizer->reset(); - fRasterizer->add_path(transformedPath); + fRasterizer.reset(); + fRasterizer.add_path(transformedPath); // render the path with the bitmap as scanline fill - agg::render_scanlines_aa(*fRasterizer, - *fUnpackedScanline, - *fBaseRenderer, + agg::render_scanlines_aa(fRasterizer, + fUnpackedScanline, + fBaseRenderer, spanAllocator, spanGenerator); } @@ -1597,17 +1477,15 @@ void Painter::_InvertRect32(BRect r) const { - if (fBuffer) { - int32 width = r.IntegerWidth() + 1; - for (int32 y = (int32)r.top; y <= (int32)r.bottom; y++) { - uint8* dst = fBuffer->row_ptr(y); - dst += (int32)r.left * 4; - for (int32 i = 0; i < width; i++) { - dst[0] = 255 - dst[0]; - dst[1] = 255 - dst[1]; - dst[2] = 255 - dst[2]; - dst += 4; - } + int32 width = r.IntegerWidth() + 1; + for (int32 y = (int32)r.top; y <= (int32)r.bottom; y++) { + uint8* dst = fBuffer.row_ptr(y); + dst += (int32)r.left * 4; + for (int32 i = 0; i < width; i++) { + dst[0] = 255 - dst[0]; + dst[1] = 255 - dst[1]; + dst[2] = 255 - dst[2]; + dst += 4; } } } @@ -1616,32 +1494,33 @@ void Painter::_BlendRect32(const BRect& r, const rgb_color& c) const { - if (fBuffer && fValidClipping) { - uint8* dst = fBuffer->row_ptr(0); - uint32 bpr = fBuffer->stride(); + if (!fValidClipping) + return; - int32 left = (int32)r.left; - int32 top = (int32)r.top; - int32 right = (int32)r.right; - int32 bottom = (int32)r.bottom; + uint8* dst = fBuffer.row_ptr(0); + uint32 bpr = fBuffer.stride(); - // fill rects, iterate over clipping boxes - fBaseRenderer->first_clip_box(); - do { - int32 x1 = max_c(fBaseRenderer->xmin(), left); - int32 x2 = min_c(fBaseRenderer->xmax(), right); - if (x1 <= x2) { - int32 y1 = max_c(fBaseRenderer->ymin(), top); - int32 y2 = min_c(fBaseRenderer->ymax(), bottom); + int32 left = (int32)r.left; + int32 top = (int32)r.top; + int32 right = (int32)r.right; + int32 bottom = (int32)r.bottom; - uint8* offset = dst + x1 * 4 + y1 * bpr; - for (; y1 <= y2; y1++) { - blend_line32(offset, x2 - x1 + 1, c.red, c.green, c.blue, c.alpha); - offset += bpr; - } + // fill rects, iterate over clipping boxes + fBaseRenderer.first_clip_box(); + do { + int32 x1 = max_c(fBaseRenderer.xmin(), left); + int32 x2 = min_c(fBaseRenderer.xmax(), right); + if (x1 <= x2) { + int32 y1 = max_c(fBaseRenderer.ymin(), top); + int32 y2 = min_c(fBaseRenderer.ymax(), bottom); + + uint8* offset = dst + x1 * 4 + y1 * bpr; + for (; y1 <= y2; y1++) { + blend_line32(offset, x2 - x1 + 1, c.red, c.green, c.blue, c.alpha); + offset += bpr; } - } while (fBaseRenderer->next_clip_box()); - } + } + } while (fBaseRenderer.next_clip_box()); } // #pragma mark - @@ -1697,34 +1576,24 @@ BRect Painter::_StrokePath(VertexSource& path) const { -#if USE_OUTLINE_RASTERIZER - fOutlineRasterizer->add_path(path); -#else -// if (fPenSize > 1.0) { - agg::conv_stroke stroke(path); - stroke.width(fPenSize); + agg::conv_stroke stroke(path); + stroke.width(fPenSize); - // special case line width = 1 with square caps - // this has a couple of advantages and it looks - // like this is also the R5 behaviour. - if (fPenSize == 1.0 && fLineCapMode == B_BUTT_CAP) { - stroke.line_cap(agg::square_cap); - } else { - stroke.line_cap(agg_line_cap_mode_for(fLineCapMode)); - } - stroke.line_join(agg_line_join_mode_for(fLineJoinMode)); - stroke.miter_limit(fMiterLimit); + // special case line width = 1 with square caps + // this has a couple of advantages and it looks + // like this is also the R5 behaviour. + if (fPenSize == 1.0 && fLineCapMode == B_BUTT_CAP) { + stroke.line_cap(agg::square_cap); + } else { + stroke.line_cap(agg_line_cap_mode_for(fLineCapMode)); + } + stroke.line_join(agg_line_join_mode_for(fLineJoinMode)); + stroke.miter_limit(fMiterLimit); - fRasterizer->reset(); - fRasterizer->add_path(stroke); + fRasterizer.reset(); + fRasterizer.add_path(stroke); - agg::render_scanlines(*fRasterizer, *fPackedScanline, *fRenderer); -// } else { - // TODO: update to AGG 2.3 to get rid of the remaining problems: - // rects which are 2 or 1 pixel high/wide don't render at all. -// fOutlineRasterizer->add_path(path); -// } -#endif + agg::render_scanlines(fRasterizer, fPackedScanline, fRenderer); BRect touched = _BoundingBox(path); float penSize = ceilf(fPenSize / 2.0); @@ -1738,9 +1607,9 @@ BRect Painter::_FillPath(VertexSource& path) const { - fRasterizer->reset(); - fRasterizer->add_path(path); - agg::render_scanlines(*fRasterizer, *fPackedScanline, *fRenderer); + fRasterizer.reset(); + fRasterizer.add_path(path); + agg::render_scanlines(fRasterizer, fPackedScanline, fRenderer); return _Clipped(_BoundingBox(path)); } Modified: haiku/trunk/src/servers/app/drawing/Painter/Painter.h =================================================================== --- haiku/trunk/src/servers/app/drawing/Painter/Painter.h 2007-07-18 17:02:03 UTC (rev 21649) +++ haiku/trunk/src/servers/app/drawing/Painter/Painter.h 2007-07-18 17:02:44 UTC (rev 21650) @@ -32,24 +32,6 @@ class ServerFont; class Transformable; -// TODO: API transition: -// * most all functions should take a DrawState* context parameter instead -// of the current pattern argument, that way, each function can -// decide for itself, which pieces of information in DrawState it -// needs -> well I'm not so sure about this, there could also -// be a DrawState member in Painter fGraphicsState or something... -// * Painter itself should be made thread safe. Because no -// ServerWindow is supposed to draw outside of its clipping region, -// there is actually no reason to lock the DisplayDriver. Multiple -// threads drawing in the frame buffer at the same time is actually -// only bad if their drawing could overlap, but this is already -// prevented by the clipping regions (access to those needs to be [... truncated: 68 lines follow ...] From leavengood at mail.berlios.de Thu Jul 19 03:16:24 2007 From: leavengood at mail.berlios.de (leavengood at BerliOS) Date: Thu, 19 Jul 2007 03:16:24 +0200 Subject: [Haiku-commits] r21651 - haiku/trunk/src/preferences/joysticks Message-ID: <200707190116.l6J1GO9F000118@sheep.berlios.de> Author: leavengood Date: 2007-07-19 03:16:23 +0200 (Thu, 19 Jul 2007) New Revision: 21651 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21651&view=rev Modified: haiku/trunk/src/preferences/joysticks/JoyWin.cpp Log: Use constant for length of file suggested by Ioan Molnar. Modified: haiku/trunk/src/preferences/joysticks/JoyWin.cpp =================================================================== --- haiku/trunk/src/preferences/joysticks/JoyWin.cpp 2007-07-18 17:02:44 UTC (rev 21650) +++ haiku/trunk/src/preferences/joysticks/JoyWin.cpp 2007-07-19 01:16:23 UTC (rev 21651) @@ -132,13 +132,13 @@ /* Initialization */ status_t JoyWin::AddDevices() { - char buf[256]; + char buf[BEOS_NAME_LENGTH]; int devId = 0; MessagedItem* device; BMessage* message; BString str; - while (!fJoystick.GetDeviceName(devId, buf, 256)) { + while (!fJoystick.GetDeviceName(devId, buf, BEOS_NAME_LENGTH)) { message = new BMessage(PORT_SELECTED); message->AddString("devname", buf); // NOTE: Adding the index in the list might be useful. From leavengood at mail.berlios.de Thu Jul 19 04:06:34 2007 From: leavengood at mail.berlios.de (leavengood at BerliOS) Date: Thu, 19 Jul 2007 04:06:34 +0200 Subject: [Haiku-commits] r21652 - haiku/trunk/src/servers/app Message-ID: <200707190206.l6J26YFa002466@sheep.berlios.de> Author: leavengood Date: 2007-07-19 04:06:32 +0200 (Thu, 19 Jul 2007) New Revision: 21652 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21652&view=rev Modified: haiku/trunk/src/servers/app/ServerApp.cpp haiku/trunk/src/servers/app/ServerFont.cpp Log: When I added my BuyNow screen saver to the image and ran it, the app_server crashed. Turns out a call I use, BFont.GetBoundingBoxesForStrings was not implemented, and worse, there was bug in how the ServerApp read the parameters from the link. This was easy to fix to stop app_server from crashing, but it took me a while to figure out how to implement GetBoundingBoxesForStrings. Anyhow I implemented an initial version which works fairly well for now. I don't think the width is quite right, but it seems to match StringWidth(), so I guess it is good enough for now. Modified: haiku/trunk/src/servers/app/ServerApp.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerApp.cpp 2007-07-19 01:16:23 UTC (rev 21651) +++ haiku/trunk/src/servers/app/ServerApp.cpp 2007-07-19 02:06:32 UTC (rev 21652) @@ -1401,8 +1401,7 @@ int32 lengthArray[numStrings]; char *stringArray[numStrings]; for (int32 i = 0; i < numStrings; i++) { -// TODO: who allocates the strings?!? If the link does it then we are leaking -// everywhere else!! + // This version of ReadString allocates the strings, we free them below link.ReadString(&stringArray[i], (size_t *)&lengthArray[i]); } @@ -1982,9 +1981,9 @@ char *stringArray[numStrings]; int32 lengthArray[numStrings]; for(int32 i=0; i(&lengthArray[i]); + // This version of ReadString allocates the strings, we free them below + link.ReadString(&stringArray[i], (size_t *)&lengthArray[i]); link.Read(&deltaArray[i]); - link.ReadString(&stringArray[i]); } BRect rectArray[numStrings]; @@ -1999,7 +1998,6 @@ font.SetSpacing(spacing); font.SetFlags(flags); - // TODO implement for real if (font.GetBoundingBoxesForStrings(stringArray, lengthArray, numStrings, rectArray, mode, deltaArray) == B_OK) { fLink.StartMessage(B_OK); Modified: haiku/trunk/src/servers/app/ServerFont.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerFont.cpp 2007-07-19 01:16:23 UTC (rev 21651) +++ haiku/trunk/src/servers/app/ServerFont.cpp 2007-07-19 02:06:32 UTC (rev 21652) @@ -24,6 +24,8 @@ #include #include +#include +#include // functions needed to convert a freetype vector graphics to a BShape inline BPoint @@ -496,6 +498,7 @@ BRect rectArray[], bool stringEscapement, font_metric_mode mode, escapement_delta delta) { + // TODO: The mode is never used if (!charArray || numChars <= 0 || !rectArray) return B_BAD_DATA; @@ -519,12 +522,12 @@ + face->glyph->metrics.horiAdvance / 64.0; } - rectArray[i].left += float(face->glyph->metrics.horiBearingX) /64.0; + rectArray[i].left += float(face->glyph->metrics.horiBearingX) / 64.0; rectArray[i].right += float(face->glyph->metrics.horiBearingX + face->glyph->metrics.width) / 64.0; rectArray[i].top = -float(face->glyph->metrics.horiBearingY) / 64.0; rectArray[i].bottom = float(face->glyph->metrics.height - - face->glyph->metrics.horiBearingY) /64.0; + - face->glyph->metrics.horiBearingY) / 64.0; } PutTransformedFace(face); @@ -536,6 +539,7 @@ ServerFont::GetBoundingBoxesForStrings(char *charArray[], int32 lengthArray[], int32 numStrings, BRect rectArray[], font_metric_mode mode, escapement_delta deltaArray[]) { + // TODO: The mode is never used if (!charArray || !lengthArray|| numStrings <= 0 || !rectArray || !deltaArray) return B_BAD_DATA; @@ -544,7 +548,28 @@ return B_ERROR; for (int32 i = 0; i < numStrings; i++) { - // TODO: ... + int32 numChars = lengthArray[i]; + const char *string = charArray[i]; + escapement_delta delta = deltaArray[i]; + + rectArray[i].left = 0.0; + for (int32 j = 0; j < numChars; j++) { + uint32 charCode = UTF8ToCharCode(&string); + FT_Load_Char(face, charCode, FT_LOAD_NO_BITMAP); + + // TODO: In my testing the width doesn't seem quite right (a + // little too long), though I need to do more comparisions with BeOS + rectArray[i].right += (face->glyph->advance.x >> 6); + rectArray[i].right += is_white_space(charCode) ? delta.space : delta.nonspace; + + float top = -(face->glyph->metrics.horiBearingY >> 6); + if (top < rectArray[i].top) + rectArray[i].top = top; + float bottom = (face->glyph->metrics.height + - face->glyph->metrics.horiBearingY) >> 6; + if (bottom > rectArray[i].bottom) + rectArray[i].bottom = bottom; + } } PutTransformedFace(face); From axeld at pinc-software.de Thu Jul 19 14:18:19 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 19 Jul 2007 14:18:19 +0200 CEST Subject: [Haiku-commits] r21651 - haiku/trunk/src/preferences/joysticks In-Reply-To: <200707190116.l6J1GO9F000118@sheep.berlios.de> Message-ID: <7550092428-BeMail@zon> leavengood at BerliOS wrote: > - char buf[256]; > + char buf[BEOS_NAME_LENGTH]; Did you mean B_FILE_NAME_LENGTH by any chance? At least I am not aware that there is such a constant. Bye, Axel. From axeld at mail.berlios.de Thu Jul 19 14:52:51 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 19 Jul 2007 14:52:51 +0200 Subject: [Haiku-commits] r21653 - haiku/trunk/src/kits/tracker Message-ID: <200707191252.l6JCqpS2010473@sheep.berlios.de> Author: axeld Date: 2007-07-19 14:52:50 +0200 (Thu, 19 Jul 2007) New Revision: 21653 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21653&view=rev Modified: haiku/trunk/src/kits/tracker/AutoMounter.cpp haiku/trunk/src/kits/tracker/AutoMounter.h haiku/trunk/src/kits/tracker/Tracker.cpp haiku/trunk/src/kits/tracker/Tracker.h Log: Tracker now also restores the previously opened windows from volumes that were mounted later by the AutoMounter's initial mounting loop. Modified: haiku/trunk/src/kits/tracker/AutoMounter.cpp =================================================================== --- haiku/trunk/src/kits/tracker/AutoMounter.cpp 2007-07-19 02:06:32 UTC (rev 21652) +++ haiku/trunk/src/kits/tracker/AutoMounter.cpp 2007-07-19 12:52:50 UTC (rev 21653) @@ -82,8 +82,7 @@ fRemovableMode = kNoVolumes; } - if (PostMessage(kMsgInitialScan) != B_OK) - debug_printf("AutoMounter: OH NO!\n"); + PostMessage(kMsgInitialScan); } @@ -93,7 +92,8 @@ void -AutoMounter::_MountVolumes(mount_mode normal, mount_mode removable) +AutoMounter::_MountVolumes(mount_mode normal, mount_mode removable, + bool initialRescan) { if (normal == kNoVolumes && removable == kNoVolumes) return; @@ -145,7 +145,13 @@ return false; } - partition->Mount(); + if (partition->Mount() == B_OK) { + // notify Tracker that a new volume has been started + BMessage note(kVolumeMounted); + note.AddString("path", partition->MountedAt()); + note.AddBool("initial rescan", sInitialRescan); + be_app->PostMessage(¬e); + } return false; } @@ -445,7 +451,7 @@ { switch (message->what) { case kMsgInitialScan: - _MountVolumes(fNormalMode, fRemovableMode); + _MountVolumes(fNormalMode, fRemovableMode, true); break; case kMountVolume: @@ -466,12 +472,12 @@ _WriteSettings(); if (rescanNow) - _MountVolumes(fNormalMode, fRemovableMode); + _MountVolumes(fNormalMode, fRemovableMode, false); break; } case kMountAllNow: - _MountVolumes(kAllVolumes, kAllVolumes); + _MountVolumes(kAllVolumes, kAllVolumes, false); break; #if 0 @@ -588,6 +594,7 @@ static BMessage gSettingsMessage; static bool gSilentAutoMounter; +static bool sInitialRescan; struct OneMountFloppyParams { status_t result; @@ -652,6 +659,13 @@ return status; } + + // notify Tracker that a new volume has been started + BMessage note(kVolumeMounted); + note.AddString("path", partition->MountedAt()); + note.AddBool("initial rescan", sInitialRescan); + be_app->PostMessage(¬e); + return AutoMounterWatchNode(&nodeToWatch, B_WATCH_NAME); } @@ -965,6 +979,7 @@ if (!BootedInSafeMode()) { ReadSettings(); + sInitialRescan = true; thread_id rescan = spawn_thread(AutoMounter::InitialRescanBinder, "AutomountInitialScan", B_DISPLAY_PRIORITY, this); resume_thread(rescan); @@ -1462,6 +1477,8 @@ //+ PRINT(("restoring all volumes\n")); fList.EachMountablePartition(TryMountingRestoreOne, NULL); } + + sInitialRescan = false; } Modified: haiku/trunk/src/kits/tracker/AutoMounter.h =================================================================== --- haiku/trunk/src/kits/tracker/AutoMounter.h 2007-07-19 02:06:32 UTC (rev 21652) +++ haiku/trunk/src/kits/tracker/AutoMounter.h 2007-07-19 12:52:50 UTC (rev 21653) @@ -48,6 +48,7 @@ const uint32 kMountVolume = 'mntv'; const uint32 kMountAllNow = 'mntn'; const uint32 kSetAutomounterParams = 'pmst'; +const uint32 kVolumeMounted = 'vmtd'; #ifdef __HAIKU__ // #pragma mark - Haiku Disk Device API @@ -69,7 +70,8 @@ kRestorePreviousVolumes }; - void _MountVolumes(mount_mode normal, mount_mode removable); + void _MountVolumes(mount_mode normal, mount_mode removable, + bool initialRescan); void _MountVolume(BMessage* message); bool _ForceUnmount(const char* name, status_t error); void _ReportUnmountError(const char* name, status_t error); Modified: haiku/trunk/src/kits/tracker/Tracker.cpp =================================================================== --- haiku/trunk/src/kits/tracker/Tracker.cpp 2007-07-19 02:06:32 UTC (rev 21652) +++ haiku/trunk/src/kits/tracker/Tracker.cpp 2007-07-19 12:52:50 UTC (rev 21653) @@ -390,9 +390,9 @@ break; case kUnmountVolume: - // When the user attempts to unmount a volume from the mount - // context menu, this is where the message gets received. Save - // pose locations and forward this to the automounter + // When the user attempts to unmount a volume from the mount + // context menu, this is where the message gets received. + // Save pose locations and forward this to the automounter SaveAllPoseLocations(); fAutoMounter->PostMessage(message); break; @@ -401,17 +401,27 @@ AutomountSettingsDialog::RunAutomountSettings(fAutoMounter); break; - case kShowSplash: - { - // The AboutWindow was moved out of the Tracker in preparation - // for when we open source it. The AboutBox contains important - // credit and license issues that shouldn't be modified, and - // therefore shouldn't be open sourced. However, there is a public - // API for 3rd party apps to tell the Tracker to open the AboutBox. - run_be_about(); + case kVolumeMounted: + { + // This is sent to us by the AutoMounter whenever it mounts + // a new volume - we use it to restore the previously opened + // windows from that volume in case it has been mounted + // during the AutoMounter's initial rescan + const char* path; + bool initial; + if (message->FindBool("initial rescan", &initial) != B_OK + || message->FindString("path", &path) != B_OK + || !initial) break; - } + _OpenPreviouslyOpenedWindows(path); + break; + } + + case kShowSplash: + run_be_about(); + break; + case kAddPrinter: // show the addprinter window run_add_printer_panel(); @@ -1186,6 +1196,84 @@ void +TTracker::_OpenPreviouslyOpenedWindows(const char* pathFilter) +{ + size_t filterLength = 0; + if (pathFilter != NULL) + filterLength = strlen(pathFilter); + + BVolume bootVolume; + BVolumeRoster().GetBootVolume(&bootVolume); + BDirectory deskDir; + attr_info attrInfo; + if (FSGetDeskDir(&deskDir, bootVolume.Device()) != B_OK + || deskDir.GetAttrInfo(kAttrOpenWindows, &attrInfo) != B_OK) + return; + + char *buffer = (char *)malloc((size_t)attrInfo.size); + BMessage message; + if (deskDir.ReadAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer, + (size_t)attrInfo.size) != attrInfo.size + || message.Unflatten(buffer) != B_OK) { + free(buffer); + return; + } + + free(buffer); + + node_ref nodeRef; + deskDir.GetNodeRef(&nodeRef); + + int32 stateMessageCounter = 0; + const char *path; + for (int32 i = 0; message.FindString("paths", i, &path) == B_OK; i++) { + if (strncmp(path, pathFilter, filterLength)) + continue; + + BEntry entry(path, true); + if (entry.InitCheck() != B_OK) + continue; + + int8 flags = 0; + for (int32 j = 0; message.FindInt8(path, j, &flags) == B_OK; j++) { + Model *model = new Model(&entry); + if (model->InitCheck() == B_OK && model->IsContainer()) { + BMessage state; + bool restoreStateFromMessage = false; + if ((flags & kOpenWindowHasState) != 0 + && message.FindMessage("window state", stateMessageCounter++, + &state) == B_OK) + restoreStateFromMessage = true; + + if (restoreStateFromMessage) { + OpenContainerWindow(model, 0, kOpen, kRestoreWorkspace + | (flags & kOpenWindowMinimized ? kIsHidden : 0U) + | kRestoreDecor, false, &state); + } else { + OpenContainerWindow(model, 0, kOpen, kRestoreWorkspace + | (flags & kOpenWindowMinimized ? kIsHidden : 0U) + | kRestoreDecor); + } + } else + delete model; + } + } + + // Open disks window if needed + + if (pathFilter == NULL && TrackerSettings().ShowDisksIcon() + && message.HasBool("open_disks_window")) { + BEntry entry("/"); + Model* model = new Model(&entry); + if (model->InitCheck() == B_OK) + OpenContainerWindow(model, 0, kOpen, kRestoreWorkspace); + else + delete model; + } +} + + +void TTracker::ReadyToRun() { gStatusWindow = new BStatusWindow(); @@ -1206,14 +1294,12 @@ fTaskLoop = new StandAloneTaskLoop(true); - bool openDisksWindow = false; - // open desktop window BContainerWindow *deskWindow = NULL; - BVolume bootVol; - BVolumeRoster().GetBootVolume(&bootVol); + BVolume bootVolume; + BVolumeRoster().GetBootVolume(&bootVolume); BDirectory deskDir; - if (FSGetDeskDir(&deskDir, bootVol.Device()) == B_OK) { + if (FSGetDeskDir(&deskDir, bootVolume.Device()) == B_OK) { // create desktop BEntry entry; deskDir.GetEntry(&entry); @@ -1224,86 +1310,38 @@ AutoLock windowLock(deskWindow); deskWindow->CreatePoseView(model); deskWindow->Init(); + + if (TrackerSettings().ShowDisksIcon()) { + // create model for root of everything + BEntry entry("/"); + Model model(&entry); + if (model.InitCheck() == B_OK) { + // add the root icon to desktop window + BMessage message; + message.what = B_NODE_MONITOR; + message.AddInt32("opcode", B_ENTRY_CREATED); + message.AddInt32("device", model.NodeRef()->device); + message.AddInt64("node", model.NodeRef()->node); + message.AddInt64("directory", model.EntryRef()->directory); + message.AddString("name", model.EntryRef()->name); + deskWindow->PostMessage(&message, deskWindow->PoseView()); + } + } } else delete model; // open previously open windows - attr_info attrInfo; - if (!BootedInSafeMode() - && deskDir.GetAttrInfo(kAttrOpenWindows, &attrInfo) == B_OK) { - char *buffer = (char *)malloc((size_t)attrInfo.size); - BMessage message; - if (deskDir.ReadAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer, (size_t)attrInfo.size) - == attrInfo.size - && message.Unflatten(buffer) == B_OK) { - - node_ref nodeRef; - deskDir.GetNodeRef(&nodeRef); - - int32 stateMessageCounter = 0; - const char *path; - for (int32 outer = 0;message.FindString("paths", outer, &path) == B_OK;outer++) { - int8 flags = 0; - for (int32 inner = 0;message.FindInt8(path, inner, &flags) == B_OK;inner++) { - BEntry entry(path, true); - if (entry.InitCheck() == B_OK) { - Model *model = new Model(&entry); - if (model->InitCheck() == B_OK && model->IsContainer()) { - BMessage state; - bool restoreStateFromMessage = false; - if ((flags & kOpenWindowHasState) != 0 - && message.FindMessage("window state", stateMessageCounter++, &state) == B_OK) - restoreStateFromMessage = true; - - if (restoreStateFromMessage) - OpenContainerWindow(model, 0, kOpen, - kRestoreWorkspace | (flags & kOpenWindowMinimized ? kIsHidden : 0U) | kRestoreDecor, - false, &state); - else - OpenContainerWindow(model, 0, kOpen, - kRestoreWorkspace | (flags & kOpenWindowMinimized ? kIsHidden : 0U) | kRestoreDecor); - } else - delete model; - } - } - } - - if (message.HasBool("open_disks_window")) - openDisksWindow = true; - } - free(buffer); - } + if (!BootedInSafeMode()) + _OpenPreviouslyOpenedWindows(); } - // create model for root of everything - if (deskWindow) { - BEntry entry("/"); - Model model(&entry); - if (model.InitCheck() == B_OK) { - - if (TrackerSettings().ShowDisksIcon()) { - // add the root icon to desktop window - BMessage message; - message.what = B_NODE_MONITOR; - message.AddInt32("opcode", B_ENTRY_CREATED); - message.AddInt32("device", model.NodeRef()->device); - message.AddInt64("node", model.NodeRef()->node); - message.AddInt64("directory", model.EntryRef()->directory); - message.AddString("name", model.EntryRef()->name); - deskWindow->PostMessage(&message, deskWindow->PoseView()); - } - - if (openDisksWindow) - OpenContainerWindow(new Model(model), 0, kOpen, kRestoreWorkspace); - } - } - // kick off building the mime type list for find panels, etc. fMimeTypeList = new MimeTypeList(); - if (!BootedInSafeMode()) + if (!BootedInSafeMode()) { // kick of transient query killer DeleteTransientQueriesTask::StartUpTransientQueryCleaner(); + } } MimeTypeList * Modified: haiku/trunk/src/kits/tracker/Tracker.h =================================================================== --- haiku/trunk/src/kits/tracker/Tracker.h 2007-07-19 02:06:32 UTC (rev 21652) +++ haiku/trunk/src/kits/tracker/Tracker.h 2007-07-19 12:52:50 UTC (rev 21653) @@ -198,6 +198,7 @@ OpenSelector openSelector = kOpen, uint32 openFlags = 0, bool checkAlreadyOpen = true, const BMessage *stateMessage = NULL); // pass either a Model or a list of entries to open + void _OpenPreviouslyOpenedWindows(const char* pathFilter = NULL); void SetDefaultPrinter(const BMessage *); void EditQueries(const BMessage *); From axeld at pinc-software.de Thu Jul 19 14:54:46 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 19 Jul 2007 14:54:46 +0200 CEST Subject: [Haiku-commits] r21648 - haiku/trunk/src/servers/app In-Reply-To: <200707181701.l6IH1Z4b010295@sheep.berlios.de> Message-ID: <9737056496-BeMail@zon> stippi at BerliOS wrote: > Log: > * check the overlay of the child being removed, instead of the view's > own > overlay (Axel please review) Looks good, thanks! Bye, Axel. From bonefish at mail.berlios.de Thu Jul 19 15:16:09 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 19 Jul 2007 15:16:09 +0200 Subject: [Haiku-commits] r21654 - haiku/trunk/src/system/kernel/debug Message-ID: <200707191316.l6JDG9Ca013981@sheep.berlios.de> Author: bonefish Date: 2007-07-19 15:16:08 +0200 (Thu, 19 Jul 2007) New Revision: 21654 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21654&view=rev Modified: haiku/trunk/src/system/kernel/debug/debug.c Log: bonefish+axeld: When loading the driver settings the defaults don't override the previous variable values anymore. Modified: haiku/trunk/src/system/kernel/debug/debug.c =================================================================== --- haiku/trunk/src/system/kernel/debug/debug.c 2007-07-19 12:52:50 UTC (rev 21653) +++ haiku/trunk/src/system/kernel/debug/debug.c 2007-07-19 13:16:08 UTC (rev 21654) @@ -49,6 +49,7 @@ static bool sSerialDebugEnabled = true; static bool sSyslogOutputEnabled = true; static bool sBlueScreenEnabled = false; + // must always be false on startup static bool sDebugScreenEnabled = false; static bool sBlueScreenOutput = true; static spinlock sSpinlock = 0; @@ -719,9 +720,9 @@ handle = load_driver_settings("kernel"); if (handle != NULL) { sSerialDebugEnabled = get_driver_boolean_parameter(handle, - "serial_debug_output", true, true); + "serial_debug_output", sSerialDebugEnabled, sSerialDebugEnabled); sSyslogOutputEnabled = get_driver_boolean_parameter(handle, - "syslog_debug_output", true, true); + "syslog_debug_output", sSyslogOutputEnabled, sSyslogOutputEnabled); sBlueScreenOutput = get_driver_boolean_parameter(handle, "bluescreen", true, true); From bonefish at mail.berlios.de Thu Jul 19 15:32:33 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 19 Jul 2007 15:32:33 +0200 Subject: [Haiku-commits] r21655 - in haiku/trunk/src/system/kernel: disk_device_manager disk_device_manager/jobs fs Message-ID: <200707191332.l6JDWXSc014955@sheep.berlios.de> Author: bonefish Date: 2007-07-19 15:32:33 +0200 (Thu, 19 Jul 2007) New Revision: 21655 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21655&view=rev Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KScanPartitionJob.cpp haiku/trunk/src/system/kernel/fs/vfs_boot.cpp Log: axeld+bonefish: * Refactored RescanDiskSystems(). Pulled out a function _RescanDiskSystems() that scans for either file or partitioning systems. RescanDiskSystems(), which scanned for file systems only before, is used from the constructor as well (open_module_list() works in the early boot process since a while). * Made InitialDeviceScan() and partition scanning safe to be called a second time. We call it directly after the kernel has mounted the boot volume, now, so that additional disk systems from the boot volume have a chance to recognize previously unrecognized partitions. This is a temporary change only; later the disk device manager shall automatically find out when new disk systems/devices/whatever are available. Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-07-19 13:16:08 UTC (rev 21654) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2007-07-19 13:32:33 UTC (rev 21655) @@ -131,35 +131,8 @@ if (InitCheck() != B_OK) return; - // We are in early boot mode, so open_module_list() won't find what - // we're looking for; we need to use get_next_loaded_module_name() - // instead. + RescanDiskSystems(); - uint32 cookie = 0; - size_t partitioningPrefixLength = strlen(kPartitioningSystemPrefix); - size_t filePrefixLength = strlen(kFileSystemPrefix); - - while (true) { - KPath name; - if (name.InitCheck() != B_OK) - break; - size_t nameLength = name.BufferSize(); - if (get_next_loaded_module_name(&cookie, name.LockBuffer(), - &nameLength) != B_OK) { - break; - } - name.UnlockBuffer(); - - if (!strncmp(name.Path(), kPartitioningSystemPrefix, - partitioningPrefixLength)) { - DBG(OUT("partitioning system: %s\n", name.Path())); - _AddPartitioningSystem(name.Path()); - } else if (!strncmp(name.Path(), kFileSystemPrefix, filePrefixLength)) { - DBG(OUT("file system: %s\n", name.Path())); - _AddFileSystem(name.Path()); - } - } - DBG(OUT("number of disk systems: %ld\n", CountDiskSystems())); // TODO: Watch the disk systems and the relevant directories. } @@ -929,31 +902,53 @@ return error; } -//RescanDiskSystems +// _RescanDiskSystems status_t -KDiskDeviceManager::RescanDiskSystems() +KDiskDeviceManager::_RescanDiskSystems(bool fileSystems) { - // load file systems list - void *cookie = open_module_list(kFileSystemPrefix); - + void *cookie = open_module_list(fileSystems + ? kFileSystemPrefix : kPartitioningSystemPrefix); + if (cookie == NULL) + return B_NO_MEMORY; + while (true) { - char name[B_FILE_NAME_LENGTH]; - size_t nameLength = sizeof(name); - module_info *module; - - if (read_next_module_name(cookie, name, &nameLength) != B_OK) + KPath name; + if (name.InitCheck() != B_OK) break; - if (FindDiskSystem(name)) + size_t nameLength = name.BufferSize(); + if (read_next_module_name(cookie, name.LockBuffer(), + &nameLength) != B_OK) { + break; + } + name.UnlockBuffer(); + + if (FindDiskSystem(name.Path())) continue; - _AddFileSystem(name); - } - close_module_list(cookie); - // TODO rescan partition tree for unrecognized partitions + if (fileSystems) { + DBG(OUT("file system: %s\n", name.Path())); + _AddFileSystem(name.Path()); + } else { + DBG(OUT("partitioning system: %s\n", name.Path())); + _AddPartitioningSystem(name.Path()); + } + } + close_module_list(cookie); return B_OK; } +// RescanDiskSystems +status_t +KDiskDeviceManager::RescanDiskSystems() +{ + // rescan for partitioning and file systems + _RescanDiskSystems(false); + _RescanDiskSystems(true); + + return B_OK; +} + // _AddPartitioningSystem status_t KDiskDeviceManager::_AddPartitioningSystem(const char *name) @@ -1161,6 +1156,11 @@ int32 leafLen = strlen("/raw"); if (len <= leafLen || strcmp(path + len - leafLen, "/raw")) return B_ERROR; + if (FindDevice(path) != NULL) { + // we already know this device + return B_OK; + } + DBG(OUT(" found device: %s\n", path)); // create a KDiskDevice for it KDiskDevice *device = new(nothrow) KDiskDevice; Modified: haiku/trunk/src/system/kernel/disk_device_manager/jobs/KScanPartitionJob.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/jobs/KScanPartitionJob.cpp 2007-07-19 13:16:08 UTC (rev 21654) +++ haiku/trunk/src/system/kernel/disk_device_manager/jobs/KScanPartitionJob.cpp 2007-07-19 13:32:33 UTC (rev 21655) @@ -63,6 +63,10 @@ // the partition's device must be write-locked if (!partition) return B_BAD_VALUE; + if (partition->DiskSystem() != NULL) { + // TODO: this is more or less a hack to prevent rescanning a partition + return B_OK; + } DBG( KPath partitionPath; Modified: haiku/trunk/src/system/kernel/fs/vfs_boot.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs_boot.cpp 2007-07-19 13:16:08 UTC (rev 21654) +++ haiku/trunk/src/system/kernel/fs/vfs_boot.cpp 2007-07-19 13:32:33 UTC (rev 21655) @@ -508,5 +508,8 @@ // search for other disk systems KDiskDeviceManager *manager = KDiskDeviceManager::Default(); manager->RescanDiskSystems(); + manager->InitialDeviceScan(); + // TODO: later, the DDM should notice when there are new + // partitions/devices available } From bonefish at mail.berlios.de Thu Jul 19 15:33:41 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 19 Jul 2007 15:33:41 +0200 Subject: [Haiku-commits] r21656 - haiku/trunk/headers/private/kernel/disk_device_manager Message-ID: <200707191333.l6JDXfGH015076@sheep.berlios.de> Author: bonefish Date: 2007-07-19 15:33:41 +0200 (Thu, 19 Jul 2007) New Revision: 21656 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21656&view=rev Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h Log: Missing in the previous commit. Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h 2007-07-19 13:32:33 UTC (rev 21655) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h 2007-07-19 13:33:41 UTC (rev 21656) @@ -123,6 +123,8 @@ status_t RescanDiskSystems(); private: + status_t _RescanDiskSystems(bool fileSystems); + status_t _AddPartitioningSystem(const char *name); status_t _AddFileSystem(const char *name); status_t _AddDiskSystem(KDiskSystem *diskSystem); From bonefish at mail.berlios.de Thu Jul 19 15:34:43 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 19 Jul 2007 15:34:43 +0200 Subject: [Haiku-commits] r21657 - haiku/trunk/src/tools/remote_disk_server Message-ID: <200707191334.l6JDYh1E015215@sheep.berlios.de> Author: bonefish Date: 2007-07-19 15:34:42 +0200 (Thu, 19 Jul 2007) New Revision: 21657 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21657&view=rev Modified: haiku/trunk/src/tools/remote_disk_server/remote_disk_server.cpp Log: Fixed debug output. Modified: haiku/trunk/src/tools/remote_disk_server/remote_disk_server.cpp =================================================================== --- haiku/trunk/src/tools/remote_disk_server/remote_disk_server.cpp 2007-07-19 13:33:41 UTC (rev 21656) +++ haiku/trunk/src/tools/remote_disk_server/remote_disk_server.cpp 2007-07-19 13:34:42 UTC (rev 21657) @@ -234,7 +234,7 @@ int16_t size = ntohs(fRequest->size); int16_t result = 0; - printf("READ request: offset: %llu, %hd bytes\n", offset, size); + printf("WRITE request: offset: %llu, %hd bytes\n", offset, size); if (size < 0 || (uint32_t)size > fRequestSize - sizeof(remote_disk_header) From bonefish at mail.berlios.de Thu Jul 19 15:35:53 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 19 Jul 2007 15:35:53 +0200 Subject: [Haiku-commits] r21658 - haiku/trunk/src/system/kernel/fs Message-ID: <200707191335.l6JDZruN015347@sheep.berlios.de> Author: bonefish Date: 2007-07-19 15:35:53 +0200 (Thu, 19 Jul 2007) New Revision: 21658 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21658&view=rev Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp Log: Implemented emulating write_pages() using the write() hook. Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/devfs.cpp 2007-07-19 13:34:42 UTC (rev 21657) +++ haiku/trunk/src/system/kernel/fs/devfs.cpp 2007-07-19 13:35:53 UTC (rev 21658) @@ -1937,7 +1937,8 @@ //TRACE(("devfs_write_pages: vnode %p, vecs %p, count = %lu, pos = %Ld, size = %lu\n", vnode, vecs, count, pos, *_numBytes)); if (!S_ISCHR(vnode->stream.type) - || vnode->stream.u.dev.info->write_pages == NULL + || (vnode->stream.u.dev.info->write_pages == NULL + && vnode->stream.u.dev.info->write == NULL) || cookie == NULL) return B_NOT_ALLOWED; @@ -1946,8 +1947,37 @@ *_numBytes); } - return vnode->stream.u.dev.info->write_pages(cookie->device_cookie, pos, - vecs, count, _numBytes); + if (vnode->stream.u.dev.info->write_pages) { + return vnode->stream.u.dev.info->write_pages(cookie->device_cookie, pos, + vecs, count, _numBytes); + } + + // emulate write_pages() using write() + + status_t error = B_OK; + size_t bytesTransferred = 0; + + size_t remainingBytes = *_numBytes; + for (size_t i = 0; i < count && remainingBytes > 0; i++) { + size_t toWrite = min_c(vecs[i].iov_len, remainingBytes); + size_t length = toWrite; + + error = vnode->stream.u.dev.info->write(cookie->device_cookie, pos, + vecs[i].iov_base, &length); + if (error != B_OK) + break; + + pos += length; + bytesTransferred += length; + remainingBytes -= length; + + if (length < toWrite) + break; + } + + *_numBytes = bytesTransferred; + + return (bytesTransferred > 0 ? B_OK : error); } From bonefish at mail.berlios.de Thu Jul 19 15:38:14 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 19 Jul 2007 15:38:14 +0200 Subject: [Haiku-commits] r21659 - haiku/trunk/src/servers/syslog_daemon Message-ID: <200707191338.l6JDcE8e015510@sheep.berlios.de> Author: bonefish Date: 2007-07-19 15:38:12 +0200 (Thu, 19 Jul 2007) New Revision: 21659 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21659&view=rev Modified: haiku/trunk/src/servers/syslog_daemon/syslog_output.cpp Log: axeld: Don't print a message that couldn't be written to the syslog to stdout. Modified: haiku/trunk/src/servers/syslog_daemon/syslog_output.cpp =================================================================== --- haiku/trunk/src/servers/syslog_daemon/syslog_output.cpp 2007-07-19 13:35:53 UTC (rev 21658) +++ haiku/trunk/src/servers/syslog_daemon/syslog_output.cpp 2007-07-19 13:38:12 UTC (rev 21659) @@ -184,7 +184,7 @@ if (prepare_output() < B_OK || write_to_log(buffer, length) < B_OK) { // cannot write to syslog! - fputs(buffer, stderr); + break; } // save this message to suppress repeated messages From bonefish at mail.berlios.de Thu Jul 19 15:39:31 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 19 Jul 2007 15:39:31 +0200 Subject: [Haiku-commits] r21660 - haiku/trunk/src/add-ons/kernel/network/datalink_protocols/arp Message-ID: <200707191339.l6JDdVMe015622@sheep.berlios.de> Author: bonefish Date: 2007-07-19 15:39:30 +0200 (Thu, 19 Jul 2007) New Revision: 21660 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21660&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp Log: axeld: Calm down ARP tracing. Modified: haiku/trunk/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp 2007-07-19 13:38:12 UTC (rev 21659) +++ haiku/trunk/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp 2007-07-19 13:39:30 UTC (rev 21660) @@ -139,7 +139,7 @@ // TODO: check if this makes a good hash... #define HASH(o) ((((o) >> 24) ^ ((o) >> 16) ^ ((o) >> 8) ^ (o)) % range) -#ifdef TRACE_ARP +#if 0 in_addr_t a = entry ? entry->protocol_address : *key; dprintf("%ld.%ld.%ld.%ld: Hash: %lu\n", a >> 24, (a >> 16) & 0xff, (a >> 8) & 0xff, a & 0xff, HASH(a)); From bonefish at mail.berlios.de Thu Jul 19 15:55:57 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 19 Jul 2007 15:55:57 +0200 Subject: [Haiku-commits] r21661 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200707191355.l6JDtvKR017265@sheep.berlios.de> Author: bonefish Date: 2007-07-19 15:55:56 +0200 (Thu, 19 Jul 2007) New Revision: 21661 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21661&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_int.c Log: axeld + bonefish: Answered Travis question. We save the registers from the exception causing the double fault in the double fault iframe, since otherwise it would contain only completely unusable values. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_int.c =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_int.c 2007-07-19 13:39:30 UTC (rev 21660) +++ haiku/trunk/src/system/kernel/arch/x86/arch_int.c 2007-07-19 13:55:56 UTC (rev 21661) @@ -6,6 +6,7 @@ * Distributed under the terms of the NewOS License. */ +#include #include #include #include @@ -386,17 +387,31 @@ case 8: // Double Fault Exception (#DF) { -#if 0 - // XXX what is this supposed to do? - struct tss *tss = x86_get_main_tss(); - + // The double fault iframe contains no useful information (as + // per Intel's architecture spec). Thus we simply save the + // information from the (unhandable) exception which caused the + // double in our iframe. This will result even in useful stack + // traces. Only problem is that we trust that at least the + // TSS is still accessible. + struct tss *tss = &gCPU[smp_get_current_cpu()].arch.tss; + frame.cs = tss->cs; + frame.es = tss->es; + frame.ds = tss->ds; + frame.fs = tss->fs; + frame.gs = tss->gs; frame.eip = tss->eip; + frame.ebp = tss->ebp; frame.esp = tss->esp; + frame.eax = tss->eax; + frame.ebx = tss->ebx; + frame.ecx = tss->ecx; + frame.edx = tss->edx; + frame.esi = tss->esi; + frame.edi = tss->edi; frame.flags = tss->eflags; -#endif - panic("double fault! errorcode = 0x%lx\n", frame.error_code); + panic("double fault!\n"); break; } From bonefish at mail.berlios.de Thu Jul 19 15:58:17 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 19 Jul 2007 15:58:17 +0200 Subject: [Haiku-commits] r21662 - haiku/trunk/src/system/kernel/fs Message-ID: <200707191358.l6JDwHT0017458@sheep.berlios.de> Author: bonefish Date: 2007-07-19 15:58:17 +0200 (Thu, 19 Jul 2007) New Revision: 21662 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21662&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs_net_boot.cpp Log: Computed the netmask in net endianess. The wrong netmask caused misrouting when the net server set up the loop device, thus stopping the net boot process. Modified: haiku/trunk/src/system/kernel/fs/vfs_net_boot.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs_net_boot.cpp 2007-07-19 13:55:56 UTC (rev 21661) +++ haiku/trunk/src/system/kernel/fs/vfs_net_boot.cpp 2007-07-19 13:58:17 UTC (rev 21662) @@ -345,13 +345,13 @@ if (IN_CLASSA(net) || (ntohl(net) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET) { // class A, or loopback - netMask = IN_CLASSA_NET; + netMask = ntohl(IN_CLASSA_NET); } else if (IN_CLASSB(net)) { // class B - netMask = IN_CLASSB_NET; + netMask = ntohl(IN_CLASSB_NET); } else { // class C and rest - netMask = IN_CLASSC_NET; + netMask = ntohl(IN_CLASSC_NET); } } From bonefish at mail.berlios.de Thu Jul 19 16:03:49 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 19 Jul 2007 16:03:49 +0200 Subject: [Haiku-commits] r21663 - haiku/trunk/headers/private/kernel Message-ID: <200707191403.l6JE3nDq018061@sheep.berlios.de> Author: bonefish Date: 2007-07-19 16:03:49 +0200 (Thu, 19 Jul 2007) New Revision: 21663 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21663&view=rev Modified: haiku/trunk/headers/private/kernel/kernel.h Log: Increased kernel stack size by another page. The network boot is more stack hungry and would previously hit the stack limit and thus cause a double fault. Hopefully we'll be able to reduce the stack foot print at some time. PXE boot does now fully work. Modified: haiku/trunk/headers/private/kernel/kernel.h =================================================================== --- haiku/trunk/headers/private/kernel/kernel.h 2007-07-19 13:58:17 UTC (rev 21662) +++ haiku/trunk/headers/private/kernel/kernel.h 2007-07-19 14:03:49 UTC (rev 21663) @@ -28,9 +28,9 @@ /** Size of the kernel stack */ #ifndef DEBUG_KERNEL_STACKS -# define KERNEL_STACK_SIZE (B_PAGE_SIZE * 2) // 8 kB +# define KERNEL_STACK_SIZE (B_PAGE_SIZE * 3) // 12 kB #else -# define KERNEL_STACK_SIZE (B_PAGE_SIZE * 3) // 8 kB + one guard page +# define KERNEL_STACK_SIZE (B_PAGE_SIZE * 4) // 12 kB + one guard page #endif #define KERNEL_STACK_GUARD_PAGES 1 From bonefish at mail.berlios.de Thu Jul 19 16:11:57 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 19 Jul 2007 16:11:57 +0200 Subject: [Haiku-commits] r21664 - haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk Message-ID: <200707191411.l6JEBvxJ018695@sheep.berlios.de> Author: bonefish Date: 2007-07-19 16:11:56 +0200 (Thu, 19 Jul 2007) New Revision: 21664 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21664&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.cpp haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.h haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/remote_disk.cpp Log: axeld + bonefish: * Increased network timeouts. A single lost ARP request would cause finding the server to fail. * Consequently set the sockaddr_in::sin_len field. * Added write support. Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.cpp 2007-07-19 14:03:49 UTC (rev 21663) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.cpp 2007-07-19 14:11:56 UTC (rev 21664) @@ -30,8 +30,8 @@ #endif -static const bigtime_t kReceiveTimeout = 30000LL; -static const bigtime_t kRequestTimeout = 100000LL; +static const bigtime_t kReceiveTimeout = 2000000LL; +static const bigtime_t kRequestTimeout = 6000000LL; #if __BYTE_ORDER == __LITTLE_ENDIAN @@ -101,6 +101,7 @@ fServerAddress.sin_family = AF_INET; fServerAddress.sin_port = htons(serverPort); fServerAddress.sin_addr.s_addr = htonl(serverAddress); + fServerAddress.sin_len = sizeof(sockaddr_in); fImageSize = imageSize; @@ -124,6 +125,7 @@ fServerAddress.sin_family = AF_INET; fServerAddress.sin_port = htons(REMOTE_DISK_SERVER_PORT); fServerAddress.sin_addr.s_addr = htonl(INADDR_BROADCAST); + fServerAddress.sin_len = sizeof(sockaddr_in); // set SO_BROADCAST on socket int soBroadcastValue = 1; @@ -138,7 +140,8 @@ error = _SendRequest(&request, sizeof(request), REMOTE_DISK_HELLO_REPLY, &serverAddress); if (error != B_OK) { - dprintf("RemoteDisk::FindAnyRemoteDisk(): Got no server reply.\n"); + dprintf("RemoteDisk::FindAnyRemoteDisk(): Got no server reply: %s\n", + strerror(error)); return error; } remote_disk_header* reply = (remote_disk_header*)fPacket; @@ -225,10 +228,63 @@ // WriteAt ssize_t -RemoteDisk::WriteAt(off_t pos, const void *buffer, size_t bufferSize) +RemoteDisk::WriteAt(off_t pos, const void *_buffer, size_t bufferSize) { - // TODO: Implement! - return B_PERMISSION_DENIED; + if (fSocket < 0) + return B_NO_INIT; + + const uint8 *buffer = (const uint8*)_buffer; + if (!buffer || pos < 0) + return B_BAD_VALUE; + + if (bufferSize == 0) + return 0; + + status_t error = B_OK; + size_t bytesWritten = 0; + while (bufferSize > 0) { + // prepare request + remote_disk_header* request = (remote_disk_header*)fPacket; + request->offset = htonll(pos); + uint32 toWrite = min_c(bufferSize, REMOTE_DISK_BLOCK_SIZE); + request->size = htons(toWrite); + request->command = REMOTE_DISK_WRITE_REQUEST; + + // copy to packet buffer + if (IS_USER_ADDRESS(buffer)) { + status_t error = user_memcpy(request->data, buffer, toWrite); + if (error != B_OK) + return error; + } else + memcpy(request->data, buffer, toWrite); + + // send request + size_t requestSize = request->data + toWrite - (uint8_t*)request; + remote_disk_header reply; + int32 replySize; + error = _SendRequest(request, requestSize, REMOTE_DISK_WRITE_REPLY, + NULL, &reply, sizeof(reply), &replySize); + if (error != B_OK) + break; + + // check for errors + int16 packetSize = ntohs(reply.size); + if (packetSize < 0) { + if (packetSize == REMOTE_DISK_IO_ERROR) + error = B_IO_ERROR; + else if (packetSize == REMOTE_DISK_BAD_REQUEST) + error = B_BAD_VALUE; + break; + } + + bytesWritten += toWrite; + pos += toWrite; + buffer += toWrite; + bufferSize -= toWrite; + } + + // only return an error, when we were not able to write anything at all + return (bytesWritten == 0 ? error : bytesWritten); } @@ -257,6 +313,7 @@ fSocketAddress.sin_family = AF_INET; fSocketAddress.sin_port = 0; fSocketAddress.sin_addr.s_addr = INADDR_ANY; + fSocketAddress.sin_len = sizeof(sockaddr_in); if (fSocketModule->bind(fSocket, (sockaddr*)&fSocketAddress, sizeof(fSocketAddress)) < 0) { dprintf("RemoteDisk::Init(): Failed to bind socket: %s\n", @@ -335,49 +392,43 @@ RemoteDisk::_SendRequest(remote_disk_header* request, size_t size, uint8 expectedReply, sockaddr_in* peerAddress) { + return _SendRequest(request, size, expectedReply, peerAddress, fPacket, + BUFFER_SIZE, &fPacketSize); +} + + +status_t +RemoteDisk::_SendRequest(remote_disk_header *request, size_t size, + uint8 expectedReply, sockaddr_in* peerAddress, void* receiveBuffer, + size_t receiveBufferSize, int32* _bytesReceived) +{ request->request_id = fRequestID++; request->port = fSocketAddress.sin_port; // try sending the request 3 times at most for (int i = 0; i < 3; i++) { // send request -//bool debug = false; -//{ -//thread_info threadInfo; -//get_thread_info(find_thread(NULL), &threadInfo); -////debug = (strcmp(threadInfo.name, "AddOnMonitor") == 0); -//debug = (find_thread(NULL) >= 60); -//if (debug) { -////panic("RemoteDisk::_SendRequest(): AddOnMonitor\n"); -//TRACE(("[%ld: %s] RemoteDisk::_SendRequest(): sendto(%d, %p, %lu, 0, %p, %lu)\n", -//find_thread(NULL), threadInfo.name, fSocket, request, size, (sockaddr*)&fServerAddress, sizeof(fServerAddress))); -//} -//} ssize_t bytesSent = fSocketModule->sendto(fSocket, request, size, 0, (sockaddr*)&fServerAddress, sizeof(fServerAddress)); - if (bytesSent < 0) + if (bytesSent < 0) { + dprintf("RemoteDisk::_SendRequest(): failed to send packet: %s\n", + strerror(errno)); return errno; + } if (bytesSent != (ssize_t)size) { - dprintf("RemoteDisk::_SendRequest(): sent less bytes than desired"); + dprintf("RemoteDisk::_SendRequest(): sent less bytes than desired\n"); return B_ERROR; } // receive reply bigtime_t timeout = system_time() + kRequestTimeout; do { - fPacketSize = 0; + *_bytesReceived = 0; socklen_t addrSize = sizeof(sockaddr_in); -//if (debug) { -//TRACE(("[%ld] RemoteDisk::_SendRequest(): recvfrom(%d, %p, %u, 0, %p, %p)\n", -//find_thread(NULL), fSocket, fPacket, BUFFER_SIZE, (sockaddr*)&peerAddress, (peerAddress ? &addrSize : 0))); -//} ssize_t bytesReceived = fSocketModule->recvfrom(fSocket, - fPacket, BUFFER_SIZE, 0, (sockaddr*)peerAddress, + receiveBuffer, receiveBufferSize, 0, (sockaddr*)peerAddress, (peerAddress ? &addrSize : 0)); if (bytesReceived < 0) { -//if (debug) { -//TRACE(("[%ld] RemoteDisk::_SendRequest(): recvfrom() failed: %s\n", find_thread(NULL), strerror(errno))); -//} status_t error = errno; if (error != B_TIMED_OUT && error != B_WOULD_BLOCK) return error; @@ -386,13 +437,10 @@ // got something; check, if it is looks good if (bytesReceived >= (ssize_t)sizeof(remote_disk_header)) { - remote_disk_header* reply = (remote_disk_header*)fPacket; + remote_disk_header* reply = (remote_disk_header*)receiveBuffer; if (reply->request_id == request->request_id && reply->command == expectedReply) { - fPacketSize = bytesReceived; -//if (debug) { -//TRACE(("[%ld] RemoteDisk::_SendRequest(): done: packet size: %ld\n", find_thread(NULL), bytesReceived)); -//} + *_bytesReceived = bytesReceived; return B_OK; } } @@ -400,5 +448,5 @@ } // no reply - return B_ERROR; + return B_TIMED_OUT; } Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.h 2007-07-19 14:03:49 UTC (rev 21663) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.h 2007-07-19 14:11:56 UTC (rev 21664) @@ -34,7 +34,7 @@ { return fImageSize; } bool IsReadOnly() const - { return true; } // TODO:... + { return false; } // uint32 ServerIPAddress() const // { return fServerAddress; } @@ -50,6 +50,12 @@ status_t _SendRequest(remote_disk_header *request, size_t size, uint8 expectedReply, sockaddr_in* peerAddress = NULL); + status_t _SendRequest(remote_disk_header *request, + size_t size, uint8 expectedReply, + sockaddr_in* peerAddress, + void* receiveBuffer, + size_t receiveBufferSize, + int32* bytesReceived); private: socket_module_info* fSocketModule; Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/remote_disk.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/remote_disk.cpp 2007-07-19 14:03:49 UTC (rev 21663) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/remote_disk.cpp 2007-07-19 14:11:56 UTC (rev 21664) @@ -173,12 +173,12 @@ ssize_t bytesRead = device->remoteDisk->ReadAt(position, buffer, *numBytes); if (bytesRead < 0) { *numBytes = 0; -TRACE(("remote_disk_read() failed: %s\n", strerror(bytesRead))); + TRACE(("remote_disk_read() failed: %s\n", strerror(bytesRead))); return bytesRead; } *numBytes = bytesRead; -TRACE(("remote_disk_read() done: %ld\n", bytesRead)); + TRACE(("remote_disk_read() done: %ld\n", bytesRead)); return B_OK; } @@ -197,10 +197,12 @@ *numBytes); if (bytesWritten < 0) { *numBytes = 0; + TRACE(("remote_disk_write() failed: %s\n", strerror(bytesRead))); return bytesWritten; } *numBytes = bytesWritten; + TRACE(("remote_disk_written() done: %ld\n", bytesWritten)); return B_OK; } From leavengood at gmail.com Thu Jul 19 16:19:37 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Thu, 19 Jul 2007 10:19:37 -0400 Subject: [Haiku-commits] r21651 - haiku/trunk/src/preferences/joysticks In-Reply-To: <7550092428-BeMail@zon> References: <200707190116.l6J1GO9F000118@sheep.berlios.de> <7550092428-BeMail@zon> Message-ID: On 7/19/07, Axel D?rfler wrote: > leavengood at BerliOS wrote: > > - char buf[256]; > > + char buf[BEOS_NAME_LENGTH]; > > Did you mean B_FILE_NAME_LENGTH by any chance? > At least I am not aware that there is such a constant. Hmmm, Haiku built fine for me (on Linux) with that patch, so maybe there is such a constant? In searching the WebSVN I couldn't find it in any obvious places though. But if it is the same size as B_OS_NAME_LENGTH (32), then it probably should be changed to something bigger since the old constant was 256. Of course 256 was probably overkill. Regards, Ryan From stippi at mail.berlios.de Thu Jul 19 19:06:35 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 19 Jul 2007 19:06:35 +0200 Subject: [Haiku-commits] r21665 - in haiku/trunk: headers/os/interface src/kits/app src/kits/game src/kits/interface src/servers/app Message-ID: <200707191706.l6JH6ZIu009486@sheep.berlios.de> Author: stippi Date: 2007-07-19 19:06:28 +0200 (Thu, 19 Jul 2007) New Revision: 21665 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21665&view=rev Modified: haiku/trunk/headers/os/interface/Region.h haiku/trunk/src/kits/app/LinkReceiver.cpp haiku/trunk/src/kits/app/ServerLink.cpp haiku/trunk/src/kits/game/DirectWindow.cpp haiku/trunk/src/kits/interface/Region.cpp haiku/trunk/src/kits/interface/RegionSupport.cpp haiku/trunk/src/servers/app/ServerWindow.cpp haiku/trunk/src/servers/app/ViewLayer.cpp haiku/trunk/src/servers/app/WorkspacesLayer.cpp Log: * complete reimplementation of BRegion and it's backend I "ported" the region implementation from XOrg to work on BRegion data. This resulted in pretty much the same code structure as before, with RegionSupport.cpp containing the messy details. Only now it _is_ really messy from a code beauty point of view. I didn't exactly feel like cleaning it up right now... but I guess I will have to. So what does this mean - our BRegion implementation was very slow (no offense!), and on top of that it scaled very badly with more and more rects. The new implementation seems to be on par with the very fast R5 implementation and the data looks exactly the same too. BRegion is very performance critical for the app_server, and I cannot wait to try this on my slow computer... Some changes are noteworthy: The right and bottom coordinates of BRegion internal data are now exclusive! I inherited that from the XOrg implementation and didn't feel like changing the code, seeing it is probably tested quite well. The conversion is handled transparently. Secondly, constructing a BRegion with just one rect is not invoking malloc anymore for the member data, this makes it much more efficient to use temporary BRegions with just one rect, both externally and internally in the BRegion implementation. Modified: haiku/trunk/headers/os/interface/Region.h =================================================================== --- haiku/trunk/headers/os/interface/Region.h 2007-07-19 14:11:56 UTC (rev 21664) +++ haiku/trunk/headers/os/interface/Region.h 2007-07-19 17:06:28 UTC (rev 21665) @@ -1,13 +1,7 @@ -/******************************************************************************* -/ -/ File: Region.h -/ -/ Description: BRegion represents an area that's composed of individual -/ rectangles. -/ -/ Copyright 1992-98, Be Incorporated, All Rights Reserved -/ -*******************************************************************************/ +/* + * Copyright 2007, Haiku. All rights reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _REGION_H #define _REGION_H @@ -30,57 +24,70 @@ } clipping_rect; -/*----- BRegion class --------------------------------------------*/ - class BRegion { -public: - BRegion(); - BRegion(const BRegion ®ion); - BRegion(const BRect rect); -virtual ~BRegion(); + public: + BRegion(); + BRegion(const BRegion& region); + BRegion(const BRect rect); + virtual ~BRegion(); - BRegion &operator=(const BRegion &from); + BRegion &operator=(const BRegion &from); - BRect Frame() const; -clipping_rect FrameInt() const; - BRect RectAt(int32 index); -clipping_rect RectAtInt(int32 index); - int32 CountRects(); - void Set(BRect newBounds); - void Set(clipping_rect newBounds); - bool Intersects(BRect r) const; - bool Intersects(clipping_rect r) const; - bool Contains(BPoint pt) const; - bool Contains(int32 x, int32 y); - void PrintToStream() const; - void OffsetBy(int32 dh, int32 dv); - void MakeEmpty(); - void Include(BRect r); - void Include(clipping_rect r); - void Include(const BRegion*); - void Exclude(BRect r); - void Exclude(clipping_rect r); - void Exclude(const BRegion*); - void IntersectWith(const BRegion*); + void Set(BRect newBounds); + void Set(clipping_rect newBounds); -/*----- Private or reserved -----------------------------------------*/ - class Support; + BRect Frame() const; + clipping_rect FrameInt() const; -private: - friend class BView; + BRect RectAt(int32 index) /*const*/; + clipping_rect RectAtInt(int32 index) /*const*/; + + int32 CountRects() /*const*/; + + bool Intersects(BRect rect) const; + bool Intersects(clipping_rect rect) const; + + bool Contains(BPoint point) const; + bool Contains(int32 x, int32 y) /*const*/; + + void PrintToStream() const; + + void OffsetBy(int32 x, int32 y); + + void MakeEmpty(); + + void Include(BRect rect); + void Include(clipping_rect rect); + void Include(const BRegion*); + + void Exclude(BRect r); + void Exclude(clipping_rect r); + void Exclude(const BRegion* region); + + void IntersectWith(const BRegion* region); + + private: friend class BDirectWindow; - friend class Support; friend class BPrivate::ServerLink; friend class BPrivate::LinkReceiver; - void _AddRect(clipping_rect r); - void set_size(long new_size); + class Support; + friend class Support; -private: - long count; - long data_size; - clipping_rect bound; - clipping_rect *data; + private: + BRegion(const clipping_rect& rect); + + void _AdoptRegionData(BRegion& region); + bool _SetSize(long newSize); + + clipping_rect _Convert(const BRect& rect) const; + clipping_rect _ConvertToInternal(const BRect& rect) const; + + private: + long fCount; + long fDataSize; + clipping_rect fBounds; + clipping_rect* fData; }; -#endif /* _REGION_H */ +#endif // _REGION_H Modified: haiku/trunk/src/kits/app/LinkReceiver.cpp =================================================================== --- haiku/trunk/src/kits/app/LinkReceiver.cpp 2007-07-19 14:11:56 UTC (rev 21664) +++ haiku/trunk/src/kits/app/LinkReceiver.cpp 2007-07-19 17:06:28 UTC (rev 21665) @@ -402,12 +402,16 @@ status_t LinkReceiver::ReadRegion(BRegion* region) { - status_t status = Read(®ion->count, sizeof(int32)); + status_t status = Read(®ion->fCount, sizeof(int32)); if (status >= B_OK) - status = Read(®ion->bound, sizeof(clipping_rect)); + status = Read(®ion->fBounds, sizeof(clipping_rect)); if (status >= B_OK) { - region->set_size(region->count); - status = Read(region->data, region->count * sizeof(clipping_rect)); + if (!region->_SetSize(region->fCount)) + status = B_NO_MEMORY; + else { + status = Read(region->fData, + region->fCount * sizeof(clipping_rect)); + } if (status < B_OK) region->MakeEmpty(); } Modified: haiku/trunk/src/kits/app/ServerLink.cpp =================================================================== --- haiku/trunk/src/kits/app/ServerLink.cpp 2007-07-19 14:11:56 UTC (rev 21664) +++ haiku/trunk/src/kits/app/ServerLink.cpp 2007-07-19 17:06:28 UTC (rev 21665) @@ -34,19 +34,22 @@ status_t ServerLink::ReadRegion(BRegion *region) { - fReceiver->Read(®ion->count, sizeof(long)); - fReceiver->Read(®ion->bound, sizeof(clipping_rect)); - region->set_size(region->count + 1); - return fReceiver->Read(region->data, region->count * sizeof(clipping_rect)); + fReceiver->Read(®ion->fCount, sizeof(long)); + fReceiver->Read(®ion->fBounds, sizeof(clipping_rect)); + if (!region->_SetSize(region->fCount)) + return B_NO_MEMORY; + return fReceiver->Read(region->fData, + region->fCount * sizeof(clipping_rect)); } status_t ServerLink::AttachRegion(const BRegion ®ion) { - fSender->Attach(®ion.count, sizeof(long)); - fSender->Attach(®ion.bound, sizeof(clipping_rect)); - return fSender->Attach(region.data, region.count * sizeof(clipping_rect)); + fSender->Attach(®ion.fCount, sizeof(long)); + fSender->Attach(®ion.fBounds, sizeof(clipping_rect)); + return fSender->Attach(region.fData, + region.fCount * sizeof(clipping_rect)); } Modified: haiku/trunk/src/kits/game/DirectWindow.cpp =================================================================== --- haiku/trunk/src/kits/game/DirectWindow.cpp 2007-07-19 14:11:56 UTC (rev 21664) +++ haiku/trunk/src/kits/game/DirectWindow.cpp 2007-07-19 17:06:28 UTC (rev 21665) @@ -303,11 +303,14 @@ // Otherwise, we would need to call BRegion::Include(clipping_rect) // for every clipping_rect in our clip_list, and that would be much // more overkill than this (tested ). - region->set_size(fBufferDesc->clip_list_count); - region->count = fBufferDesc->clip_list_count; - region->bound = fBufferDesc->clip_bounds; + if (!region->_SetSize(fBufferDesc->clip_list_count)) { + UnlockDirect(); + return B_NO_MEMORY; + } + region->fCount = fBufferDesc->clip_list_count; + region->fBounds = fBufferDesc->clip_bounds; for (uint32 c = 0; c < fBufferDesc->clip_list_count; c++) - region->data[c] = fBufferDesc->clip_list[c]; + region->fData[c] = fBufferDesc->clip_list[c]; // adjust bounds by the given origin point region->OffsetBy(-originX, -originY); Modified: haiku/trunk/src/kits/interface/Region.cpp =================================================================== --- haiku/trunk/src/kits/interface/Region.cpp 2007-07-19 14:11:56 UTC (rev 21664) +++ haiku/trunk/src/kits/interface/Region.cpp 2007-07-19 17:06:28 UTC (rev 21665) @@ -1,90 +1,50 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2003-2005, Haiku, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: Region.cpp -// Author: Stefano Ceccherini (burton666 at libero.it) -// Description: Region class consisting of multiple rectangles -// -//------------------------------------------------------------------------------ +/* + * Copyright 2003-2007, Haiku. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stefano Ceccherini (burton666 at libero.it) + * Stephan A?mus + */ -// Notes: As now, memory is always allocated and never freed (except on destruction, -// or sometimes when a copy is made). -// This let us be a bit faster since we don't do many reallocations. -// But that means that even an empty region could "waste" much space, if it contained -// many rects before being emptied. -// I.E: a region which contains 24 rects allocates more than 24 * 4 * sizeof(int32) -// = 96 * sizeof(int32) bytes. If we call MakeEmpty(), that region will contain no rects, -// but it will still keep the allocated memory. -// This shouldnt' be an issue, since usually BRegions are just used for calculations, -// and don't last so long. -// Anyway, we can change that behaviour if we want, but BeOS's BRegion seems to behave exactly -// like this. -#include -#include +#include +#include +#include + #include -#include -#include -#include +#include "clipping.h" +#include "RegionSupport.h" -const static int32 kInitialDataSize = 8; +const static int32 kDataBlockSize = 8; /*! \brief Initializes a region. The region will have no rects, - and its bound will be invalid. + and its fBounds will be invalid. */ BRegion::BRegion() - : - data_size(0), - data(NULL) + : fCount(0) + , fDataSize(0) + , fBounds((clipping_rect){ 0, 0, 0, 0 }) + , fData(NULL) { - data = (clipping_rect *)malloc(kInitialDataSize * sizeof(clipping_rect)); - if (data != NULL) - data_size = kInitialDataSize; - - Support::ZeroRegion(*this); + _SetSize(kDataBlockSize); } /*! \brief Initializes a region to be a copy of another. \param region The region to copy. */ -BRegion::BRegion(const BRegion ®ion) - : - data_size(0), - data(NULL) +BRegion::BRegion(const BRegion& region) + : fCount(0) + , fDataSize(0) + , fBounds((clipping_rect){ 0, 0, 0, 0 }) + , fData(NULL) { - const int32 size = region.data_size > 0 ? region.data_size : 1; - - data = (clipping_rect *)malloc(size * sizeof(clipping_rect)); - if (data != NULL) { - data_size = size; - bound = region.bound; - count = region.count; - memcpy(data, region.data, count * sizeof(clipping_rect)); - } else - Support::ZeroRegion(*this); + *this = region; } @@ -92,34 +52,106 @@ \param rect The BRect to set the region to. */ BRegion::BRegion(const BRect rect) - : - data_size(0), - data(NULL) + : fCount(0) + , fDataSize(1) + , fBounds((clipping_rect){ 0, 0, 0, 0 }) + , fData(&fBounds) { - data = (clipping_rect *)malloc(kInitialDataSize * sizeof(clipping_rect)); - if (data != NULL) { - data_size = kInitialDataSize; - Set(rect); - } else - Support::ZeroRegion(*this); + if (!rect.IsValid()) + return; + + fBounds = _ConvertToInternal(rect); + fCount = 1; } +// NOTE: private constructor +/*! \brief Initializes a region to contain a clipping_rect. + \param rect The BRect to set the region to. +*/ +BRegion::BRegion(const clipping_rect& rect) + : fCount(1) + , fDataSize(1) + , fBounds(rect) + , fData(&fBounds) +{ +} + /*! \brief Frees the allocated memory. */ BRegion::~BRegion() { - free(data); + if (fData != &fBounds) + free(fData); } +// #pragma mark - + + +/*! \brief Modifies the region to be a copy of the given BRegion. + \param region the BRegion to copy. + \return This function always returns \c *this. +*/ +BRegion & +BRegion::operator=(const BRegion ®ion) +{ + if (®ion == this) + return *this; + + // handle reallocation if we're too small to contain + // the other region + if (_SetSize(region.fDataSize)) { + memcpy(fData, region.fData, region.fCount * sizeof(clipping_rect)); + + fBounds = region.fBounds; + fCount = region.fCount; + } + + return *this; +} + + +/*! \brief Set the region to contain just the given BRect. + \param newBounds A BRect. +*/ +void +BRegion::Set(BRect newBounds) +{ + Set(_Convert(newBounds)); +} + + +/*! \brief Set the region to contain just the given clipping_rect. + \param newBounds A clipping_rect. +*/ +void +BRegion::Set(clipping_rect newBounds) +{ + _SetSize(1); + + if (valid_rect(newBounds) && fData) { + fCount = 1; + // cheap convert to internal rect format + newBounds.right++; + newBounds.bottom++; + fData[0] = fBounds = newBounds; + } else + MakeEmpty(); +} + + +// #pragma mark - + + /*! \brief Returns the bounds of the region. \return A BRect which represents the bounds of the region. */ BRect BRegion::Frame() const { - return to_BRect(bound); + return BRect(fBounds.left, fBounds.top, + fBounds.right - 1, fBounds.bottom - 1); } @@ -129,7 +161,8 @@ clipping_rect BRegion::FrameInt() const { - return bound; + return (clipping_rect){ fBounds.left, fBounds.top, + fBounds.right - 1, fBounds.bottom - 1 }; } @@ -139,12 +172,15 @@ otherwise, it returns an invalid BRect. */ BRect -BRegion::RectAt(int32 index) +BRegion::RectAt(int32 index) /*const*/ { - if (index >= 0 && index < count) - return to_BRect(data[index]); + if (index >= 0 && index < fCount) { + const clipping_rect& r = fData[index]; + return BRect(r.left, r.top, r.right - 1, r.bottom - 1); + } - return BRect(); //An invalid BRect + return BRect(); + // an invalid BRect } @@ -154,13 +190,15 @@ otherwise, it returns an invalid clipping_rect. */ clipping_rect -BRegion::RectAtInt(int32 index) +BRegion::RectAtInt(int32 index) /*const*/ { - if (index >= 0 && index < count) - return data[index]; + if (index >= 0 && index < fCount) { + const clipping_rect& r = fData[index]; + return (clipping_rect){ r.left, r.top, r.right - 1, r.bottom - 1 }; + } - clipping_rect rect = { 1, 1, 0, 0 }; - return rect; + return (clipping_rect){ 1, 1, 0, 0 }; + // an invalid clipping_rect } @@ -168,39 +206,15 @@ \return An int32 which is the total number of rects in the region. */ int32 -BRegion::CountRects() +BRegion::CountRects() /*const*/ { - return count; + return fCount; } -/*! \brief Set the region to contain just the given BRect. - \param newBounds A BRect. -*/ -void -BRegion::Set(BRect newBounds) -{ - Set(to_clipping_rect(newBounds)); -} +// #pragma mark - -/*! \brief Set the region to contain just the given clipping_rect. - \param newBounds A clipping_rect. -*/ -void -BRegion::Set(clipping_rect newBounds) -{ - ASSERT(data_size > 0); - - if (valid_rect(newBounds)) { - count = 1; - data[0] = newBounds; - bound = newBounds; - } else - Support::ZeroRegion(*this); -} - - /*! \brief Check if the region has any area in common with the given BRect. \param rect The BRect to check the region against to. \return \ctrue if the region has any area in common with the BRect, \cfalse if not. @@ -208,7 +222,7 @@ bool BRegion::Intersects(BRect rect) const { - return Intersects(to_clipping_rect(rect)); + return Intersects(_Convert(rect)); } @@ -219,15 +233,13 @@ bool BRegion::Intersects(clipping_rect rect) const { - if (!rects_intersect(rect, bound)) - return false; + // cheap convert to internal rect format + rect.right ++; + rect.bottom ++; - for (long c = 0; c < count; c++) { - if (rects_intersect(data[c], rect)) - return true; - } - - return false; + int result = Support::XRectInRegion(this, rect); + + return result > Support::RectangleOut; } @@ -236,18 +248,9 @@ \return \ctrue if the region contains the BPoint, \cfalse if not. */ bool -BRegion::Contains(BPoint pt) const +BRegion::Contains(BPoint point) const { - // If the point doesn't lie within the region's bounds, - // don't even try it against the region's rects. - if (!point_in(bound, pt)) - return false; - - for (long c = 0; c < count; c++) { - if (point_in(data[c], pt)) - return true; - } - return false; + return Support::XPointInRegion(this, (int)point.x, (int)point.y); } @@ -257,17 +260,9 @@ \return \ctrue if the region contains the point, \cfalse if not. */ bool -BRegion::Contains(int32 x, int32 y) +BRegion::Contains(int32 x, int32 y) /*const*/ { - // see above - if (!point_in(bound, x, y)) - return false; - - for (long c = 0; c < count; c++) { - if (point_in(data[c], x, y)) - return true; - } - return false; + return Support::XPointInRegion(this, x, y); } @@ -277,30 +272,35 @@ BRegion::PrintToStream() const { Frame().PrintToStream(); - - for (long c = 0; c < count; c++) { - clipping_rect *rect = &data[c]; - printf("data = BRect(l:%ld.0, t:%ld.0, r:%ld.0, b:%ld.0)\n", - rect->left, rect->top, rect->right, rect->bottom); - } + + for (long i = 0; i < fCount; i++) { + clipping_rect *rect = &fData[i]; + printf("data[%ld] = BRect(l:%ld.0, t:%ld.0, r:%ld.0, b:%ld.0)\n", + i, rect->left, rect->top, rect->right - 1, rect->bottom - 1); + } } +// #pragma mark - + + /*! \brief Offsets all region's rects, and bounds by the given values. \param dh The horizontal offset. \param dv The vertical offset. */ void -BRegion::OffsetBy(int32 dh, int32 dv) +BRegion::OffsetBy(int32 x, int32 y) { - if (dh == 0 && dv == 0) + if (x == 0 && y == 0) return; - if (count > 0) { - for (long c = 0; c < count; c++) - offset_rect(data[c], dh, dv); + if (fCount > 0) { + if (fData != &fBounds) { + for (long i = 0; i < fCount; i++) + offset_rect(fData[i], x, y); + } - offset_rect(bound, dh, dv); + offset_rect(fBounds, x, y); } } @@ -310,17 +310,21 @@ void BRegion::MakeEmpty() { - Support::ZeroRegion(*this); + fBounds= (clipping_rect){ 0, 0, 0, 0 }; + fCount = 0; } +// #pragma mark - + + /*! \brief Modifies the region, so that it includes the given BRect. \param rect The BRect to be included by the region. */ void BRegion::Include(BRect rect) { - Include(to_clipping_rect(rect)); + Include(_Convert(rect)); } @@ -330,13 +334,17 @@ void BRegion::Include(clipping_rect rect) { - BRegion region; - BRegion newRegion; + // convert to internal rect format + rect.right ++; + rect.bottom ++; - region.Set(rect); - - Support::OrRegion(*this, region, newRegion); - Support::CopyRegion(newRegion, *this); + // use private clipping_rect constructor which avoids malloc() + BRegion t(rect); + + BRegion result; + Support::XUnionRegion(this, &t, &result); + + _AdoptRegionData(result); } @@ -344,22 +352,25 @@ \param region The region to be included. */ void -BRegion::Include(const BRegion *region) +BRegion::Include(const BRegion* region) { - BRegion newRegion; - - Support::OrRegion(*this, *region, newRegion); - Support::CopyRegion(newRegion, *this); + BRegion result; + Support::XUnionRegion(this, region, &result); + + _AdoptRegionData(result); } +// #pragma mark - + + /*! \brief Modifies the region, excluding the area represented by the given BRect. \param rect The BRect to be excluded. */ void BRegion::Exclude(BRect rect) { - Exclude(to_clipping_rect(rect)); + Exclude(_Convert(rect)); } @@ -369,152 +380,125 @@ void BRegion::Exclude(clipping_rect rect) { - BRegion region; - BRegion newRegion; - - region.Set(rect); + // convert to internal rect format + rect.right ++; + rect.bottom ++; - Support::SubRegion(*this, region, newRegion); - Support::CopyRegion(newRegion, *this); + // use private clipping_rect constructor which avoids malloc() + BRegion t(rect); + + BRegion result; + Support::XSubtractRegion(this, &t, &result); + + _AdoptRegionData(result); } -/*! \brief Modifies the region, excluding the area contained in the given BRegion. +/*! \brief Modifies the region, excluding the area contained in the given + BRegion. \param region The BRegion to be excluded. */ void -BRegion::Exclude(const BRegion *region) +BRegion::Exclude(const BRegion* region) { - BRegion newRegion; - - Support::SubRegion(*this, *region, newRegion); - Support::CopyRegion(newRegion, *this); + BRegion result; + Support::XSubtractRegion(this, region, &result); + + _AdoptRegionData(result); } -/*! \brief Modifies the region, so that it will contain just the area in common with the given BRegion. +// #pragma mark - + + +/*! \brief Modifies the region, so that it will contain just the area + in common with the given BRegion. \param region the BRegion to intersect to. */ void -BRegion::IntersectWith(const BRegion *region) +BRegion::IntersectWith(const BRegion* region) { - BRegion newRegion; - - Support::AndRegion(*this, *region, newRegion); - Support::CopyRegion(newRegion, *this); + BRegion result; + Support::XIntersectRegion(this, region, &result); + + _AdoptRegionData(result); } -/*! \brief Modifies the region to be a copy of the given BRegion. - \param region the BRegion to copy. - \return This function always returns \c *this. +// #pragma mark - + + +/*! \brief Takes over the data of a region and marks that region empty. + \param region The region to adopt the data from. */ -BRegion & -BRegion::operator=(const BRegion ®ion) +void +BRegion::_AdoptRegionData(BRegion& region) { - if (®ion != this) { - bound = region.bound; - count = region.count; + fCount = region.fCount; + fDataSize = region.fDataSize; + fBounds = region.fBounds; + if (fData != &fBounds) + free(fData); + if (region.fData != ®ion.fBounds) + fData = region.fData; + else + fData = &fBounds; - // handle reallocation if we're too small to contain - // the other region - set_size(region.data_size); - - // TODO: what is this supposed to do?? - if (data_size <= 0) - data_size = 1; - - if (data) - memcpy(data, region.data, count * sizeof(clipping_rect)); - } - - return *this; + // NOTE: MakeEmpty() is not called since _AdoptRegionData is only + // called with internally allocated regions, so they don't need to + // be left in a valid state. + region.fData = NULL; +// region.MakeEmpty(); } -/*! \brief Adds a rect to the region. - \param rect The clipping_rect to be added. - - Adds the given rect to the region, merging it with another already contained in the region, - if possible. Recalculate the region's bounds if needed. +/*! \brief Reallocate the memory in the region. + \param newSize The amount of rectangles that the region should be + able to hold. */ -void -BRegion::_AddRect(clipping_rect rect) +bool +BRegion::_SetSize(long newSize) { - ASSERT(count >= 0); - ASSERT(data_size >= 0); - ASSERT(valid_rect(rect)); + // we never shrink the size + newSize = max_c(fDataSize, newSize); + if (newSize == fDataSize) + return true; - // Should we just reallocate the memory and - // copy the rect ? - bool addRect = true; - - if (count > 0) { - // Wait! We could merge the rect with one of the - // existing rectangles, if it's adiacent. - // We just check it against the last rectangle, since - // we are keeping them sorted by their "top" coordinates. - long last = count - 1; - if (rect.left == data[last].left && rect.right == data[last].right - && rect.top == data[last].bottom + 1) { - - data[last].bottom = rect.bottom; - addRect = false; - - } else if (rect.top == data[last].top && rect.bottom == data[last].bottom) { - if (rect.left == data[last].right + 1) { + // align newSize to multiple of kDataBlockSize + newSize = ((newSize + kDataBlockSize - 1) / kDataBlockSize) * kDataBlockSize; - data[last].right = rect.right; - addRect = false; - - } else if (rect.right == data[last].left - 1) { - - data[last].left = rect.left; - addRect = false; - } - } - } - - // We weren't lucky.... just add the rect as a new one - if (addRect) { - if (data_size <= count) - set_size(count + 16); - - data[count] = rect; - - count++; + if (newSize > 0) { + if (fData == &fBounds) { + fData = (clipping_rect*)malloc(newSize * sizeof(clipping_rect)); + fData[0] = fBounds; + } else if (fData) + fData = (clipping_rect*)realloc(fData, newSize * sizeof(clipping_rect)); + else + fData = (clipping_rect*)malloc(newSize * sizeof(clipping_rect)); } - // Recalculate bounds - if (rect.top < bound.top) - bound.top = rect.top; + if (!fData || newSize <= 0) { + fDataSize = 0; + MakeEmpty(); + return false; + } - if (rect.left < bound.left) - bound.left = rect.left; - - if (rect.right > bound.right) - bound.right = rect.right; - - if (rect.bottom > bound.bottom) - bound.bottom = rect.bottom; + fDataSize = newSize; + return true; } +clipping_rect +BRegion::_Convert(const BRect& rect) const +{ + return (clipping_rect){ (int)floorf(rect.left), (int)floorf(rect.top), + (int)ceilf(rect.right), (int)ceilf(rect.bottom) }; +} -/*! \brief Reallocate the memory in the region. - \param new_size The amount of rectangles that the region could contain. -*/ -void -BRegion::set_size(long new_size) + +clipping_rect +BRegion::_ConvertToInternal(const BRect& rect) const { - if (new_size <= 0) - new_size = data_size + 16; - - data = (clipping_rect *)realloc(data, new_size * sizeof(clipping_rect)); - - if (data == NULL) - debugger("BRegion::set_size realloc error\n"); - - data_size = new_size; - - ASSERT(count <= data_size); + return (clipping_rect){ (int)floorf(rect.left), (int)floorf(rect.top), + (int)ceilf(rect.right) + 1, (int)ceilf(rect.bottom) + 1 }; } + Modified: haiku/trunk/src/kits/interface/RegionSupport.cpp =================================================================== --- haiku/trunk/src/kits/interface/RegionSupport.cpp 2007-07-19 14:11:56 UTC (rev 21664) +++ haiku/trunk/src/kits/interface/RegionSupport.cpp 2007-07-19 17:06:28 UTC (rev 21665) @@ -1,920 +1,1643 @@ [... truncated: 2475 lines follow ...] From stippi at mail.berlios.de Thu Jul 19 19:17:00 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 19 Jul 2007 19:17:00 +0200 Subject: [Haiku-commits] r21666 - in haiku/trunk: headers/os/interface src/kits/game src/kits/interface Message-ID: <200707191717.l6JHH0IT025209@sheep.berlios.de> Author: stippi Date: 2007-07-19 19:16:54 +0200 (Thu, 19 Jul 2007) New Revision: 21666 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21666&view=rev Modified: haiku/trunk/headers/os/interface/Region.h haiku/trunk/src/kits/game/DirectWindow.cpp haiku/trunk/src/kits/interface/Region.cpp Log: * just realized a bug already when reading over the commit log... Modified: haiku/trunk/headers/os/interface/Region.h =================================================================== --- haiku/trunk/headers/os/interface/Region.h 2007-07-19 17:06:28 UTC (rev 21665) +++ haiku/trunk/headers/os/interface/Region.h 2007-07-19 17:16:54 UTC (rev 21666) @@ -82,6 +82,8 @@ clipping_rect _Convert(const BRect& rect) const; clipping_rect _ConvertToInternal(const BRect& rect) const; + clipping_rect _ConvertToInternal( + const clipping_rect& rect) const; private: long fCount; Modified: haiku/trunk/src/kits/game/DirectWindow.cpp =================================================================== --- haiku/trunk/src/kits/game/DirectWindow.cpp 2007-07-19 17:06:28 UTC (rev 21665) +++ haiku/trunk/src/kits/game/DirectWindow.cpp 2007-07-19 17:16:54 UTC (rev 21666) @@ -307,10 +307,12 @@ UnlockDirect(); return B_NO_MEMORY; } - region->fCount = fBufferDesc->clip_list_count; - region->fBounds = fBufferDesc->clip_bounds; - for (uint32 c = 0; c < fBufferDesc->clip_list_count; c++) - region->fData[c] = fBufferDesc->clip_list[c]; + region->fCount = fBufferDesc->clip_list_count; + region->fBounds = region->_ConvertToInternal(fBufferDesc->clip_bounds); + for (uint32 c = 0; c < fBufferDesc->clip_list_count; c++) { + region->fData[c] = region->_ConvertToInternal( + fBufferDesc->clip_list[c]); + } // adjust bounds by the given origin point region->OffsetBy(-originX, -originY); Modified: haiku/trunk/src/kits/interface/Region.cpp =================================================================== --- haiku/trunk/src/kits/interface/Region.cpp 2007-07-19 17:06:28 UTC (rev 21665) +++ haiku/trunk/src/kits/interface/Region.cpp 2007-07-19 17:16:54 UTC (rev 21666) @@ -502,3 +502,11 @@ (int)ceilf(rect.right) + 1, (int)ceilf(rect.bottom) + 1 }; } + +clipping_rect +BRegion::_ConvertToInternal(const clipping_rect& rect) const +{ + return (clipping_rect){ rect.left, rect.top, + rect.right + 1, rect.bottom + 1 }; +} + From stippi at mail.berlios.de Thu Jul 19 19:22:54 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 19 Jul 2007 19:22:54 +0200 Subject: [Haiku-commits] r21667 - haiku/trunk/headers/private/interface Message-ID: <200707191722.l6JHMsMs011638@sheep.berlios.de> Author: stippi Date: 2007-07-19 19:22:53 +0200 (Thu, 19 Jul 2007) New Revision: 21667 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21667&view=rev Modified: haiku/trunk/headers/private/interface/RegionSupport.h Log: * fix the build, forgot to commit this... Modified: haiku/trunk/headers/private/interface/RegionSupport.h =================================================================== --- haiku/trunk/headers/private/interface/RegionSupport.h 2007-07-19 17:16:54 UTC (rev 21666) +++ haiku/trunk/headers/private/interface/RegionSupport.h 2007-07-19 17:22:53 UTC (rev 21667) @@ -1,43 +1,152 @@ -// This file is distributed under the OpenBeOS license +/* $Xorg: region.h,v 1.4 2001/02/09 02:03:40 xorgcvs Exp $ */ +/************************************************************************ +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +************************************************************************/ + #ifndef __REGION_SUPPORT_H #define __REGION_SUPPORT_H #include class BRegion::Support { -public: - static void ZeroRegion(BRegion ®ion); - static void ClearRegion(BRegion ®ion); - static void CopyRegion(const BRegion &source, BRegion &dest); - static void AndRegion(const BRegion &first, const BRegion &second, BRegion &dest); - static void OrRegion(const BRegion &first, const BRegion &second, BRegion &dest); - static void SubRegion(const BRegion &first, const BRegion &second, BRegion &dest); + public: + static int XUnionRegion(const BRegion* reg1, + const BRegion* reg2, BRegion* newReg); -private: - static void CleanupRegion(BRegion ®ion); - static void CleanupRegionVertical(BRegion ®ion); - static void CleanupRegionHorizontal(BRegion ®ion); - - static void SortRects(clipping_rect *rects, long count); - static void SortTrans(long *lptr1, long *lptr2, long count); - - static void CopyRegionMore(const BRegion &, BRegion &, long); - - static void AndRegionComplex(const BRegion &, const BRegion &, BRegion &); - static void AndRegion1ToN(const BRegion &, const BRegion &, BRegion &); + static int XIntersectRegion(const BRegion* reg1, + const BRegion* reg2, BRegion* newReg); - static void AppendRegion(const BRegion &, const BRegion &, BRegion &); - - static void OrRegionComplex(const BRegion &, const BRegion &, BRegion &); - static void OrRegion1ToN(const BRegion &, const BRegion &, BRegion &); - static void OrRegionNoX(const BRegion &, const BRegion &, BRegion &); - static void ROr(long, long, const BRegion &, const BRegion &, - BRegion &, long *, long *); + static int XSubtractRegion(const BRegion* regM, + const BRegion* regS, BRegion* regD); - static void SubRegionComplex(const BRegion &, const BRegion &, BRegion &); - static void RSub(long, long, const BRegion &, const BRegion &, - BRegion &, long *, long *); + static int XXorRegion(const BRegion* sra, + const BRegion* srb, BRegion* dr); + + static int XPointInRegion(const BRegion* region, + int x, int y); + + enum { + RectangleOut = 0, + RectanglePart = 1, + RectangleIn = 2 + }; + + static int XRectInRegion(const BRegion* region, + const clipping_rect& rect); + + private: + static BRegion* CreateRegion(); + static void DestroyRegion(BRegion* r); + + static void XOffsetRegion(BRegion* pRegion, int x, int y); + + static void miSetExtents(BRegion* pReg); + static int miIntersectO(BRegion* pReg, + clipping_rect* r1, clipping_rect* r1End, + clipping_rect* r2, clipping_rect* r2End, + int top, int bottom); + static void miRegionCopy(BRegion* dstrgn, const BRegion* rgn); + static int miCoalesce(BRegion* pReg, + int prevStart, int curStart); + static int miUnionNonO(BRegion* pReg, clipping_rect* r, + clipping_rect* rEnd, int top, int bottom); + static int miUnionO(BRegion* pReg, + clipping_rect* r1, clipping_rect* r1End, + clipping_rect* r2, clipping_rect* r2End, + int top, int bottom); + static int miSubtractO(BRegion* pReg, + clipping_rect* r1, clipping_rect* r1End, + clipping_rect* r2, clipping_rect* r2End, + int top, int bottom); + static int miSubtractNonO1(BRegion* pReg, + clipping_rect* r, clipping_rect* rEnd, + int top, int bottom); + + + + typedef int (*overlapProcp)( + BRegion* pReg, + clipping_rect* r1, + clipping_rect* r1End, + register clipping_rect* r2, + clipping_rect* r2End, + int top, + int bottom); + + typedef int (*nonOverlapProcp)( + BRegion* pReg, + clipping_rect* r, + clipping_rect* rEnd, + int top, + int bottom); + + static void miRegionOp(BRegion* newReg, + const BRegion* reg1, const BRegion* reg2, + int (*overlapFunc)( + register BRegion* pReg, + register clipping_rect* r1, + clipping_rect* r1End, + register clipping_rect* r2, + clipping_rect* r2End, + int top, + int bottom), + int (*nonOverlap1Func)( + register BRegion* pReg, + register clipping_rect* r, + clipping_rect* rEnd, + register int top, + register int bottom), + + int (*nonOverlap2Func)( + register BRegion* pReg, + register clipping_rect* r, + clipping_rect* rEnd, + register int top, + register int bottom)); + }; #endif // __REGION_SUPPORT_H From superstippi at gmx.de Thu Jul 19 19:45:07 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 19 Jul 2007 19:45:07 +0200 Subject: [Haiku-commits] broken build In-Reply-To: <200707092141.l69LfiBF007257@sheep.berlios.de> References: <200707092141.l69LfiBF007257@sheep.berlios.de> Message-ID: <20070719194507.8532.1@stippis.WG> Hi guys, C++ generated/objects/haiku/x86/release/kits/tracker/AutoMounter.o /Data/home/projects/develop/ThirdParty/Haiku/src/kits/tracker/AutoMounter.cpp: In method `bool BPrivate::AutoMounter::_MountVolumes(BPrivate::AutoMounter::mount_mode, BPrivate::AutoMounter::mount_mode, bool)::InitialMountVisitor::Visit(BPartition *, long int)': /Data/home/projects/develop/ThirdParty/Haiku/src/kits/tracker/AutoMounter.cpp: 151: no matching function for call to `BPartition::MountedAt ()' /Data/home/projects/develop/ThirdParty/Haiku/src/kits/tracker/AutoMounter.cpp: 152: `sInitialRescan' undeclared (first use this function) /Data/home/projects/develop/ThirdParty/Haiku/src/kits/tracker/AutoMounter.cpp: 152: (Each undeclared identifier is reported only once /Data/home/projects/develop/ThirdParty/Haiku/src/kits/tracker/AutoMounter.cpp: 152: for each function it appears in.) something seems to be missing... :-) Best regards, -Stephan From axeld at mail.berlios.de Thu Jul 19 20:14:39 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 19 Jul 2007 20:14:39 +0200 Subject: [Haiku-commits] r21668 - haiku/trunk/src/kits/tracker Message-ID: <200707191814.l6JIEdLL020246@sheep.berlios.de> Author: axeld Date: 2007-07-19 20:14:38 +0200 (Thu, 19 Jul 2007) New Revision: 21668 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21668&view=rev Modified: haiku/trunk/src/kits/tracker/AutoMounter.cpp Log: The AutoMounter now also compiles for Haiku again, sorry! Modified: haiku/trunk/src/kits/tracker/AutoMounter.cpp =================================================================== --- haiku/trunk/src/kits/tracker/AutoMounter.cpp 2007-07-19 17:22:53 UTC (rev 21667) +++ haiku/trunk/src/kits/tracker/AutoMounter.cpp 2007-07-19 18:14:38 UTC (rev 21668) @@ -101,10 +101,11 @@ class InitialMountVisitor : public BDiskDeviceVisitor { public: InitialMountVisitor(mount_mode normalMode, mount_mode removableMode, - BMessage& previous) + bool initialRescan, BMessage& previous) : fNormalMode(normalMode), fRemovableMode(removableMode), + fInitialRescan(initialRescan), fPrevious(previous) { } @@ -145,11 +146,13 @@ return false; } - if (partition->Mount() == B_OK) { + BPath path; + if (partition->Mount() == B_OK + && partition->GetMountPoint(&path) == B_OK) { // notify Tracker that a new volume has been started BMessage note(kVolumeMounted); - note.AddString("path", partition->MountedAt()); - note.AddBool("initial rescan", sInitialRescan); + note.AddString("path", path.Path()); + note.AddBool("initial rescan", fInitialRescan); be_app->PostMessage(¬e); } return false; @@ -158,8 +161,9 @@ private: mount_mode fNormalMode; mount_mode fRemovableMode; + bool fInitialRescan; BMessage& fPrevious; - } visitor(normal, removable, fSettings); + } visitor(normal, removable, initialRescan, fSettings); BDiskDeviceList devices; status_t status = devices.Fetch(); From axeld at pinc-software.de Thu Jul 19 20:15:32 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 19 Jul 2007 20:15:32 +0200 CEST Subject: [Haiku-commits] broken build In-Reply-To: <20070719194507.8532.1@stippis.WG> Message-ID: <1056511923-BeMail@zon> Stephan Assmus wrote: > something seems to be missing... :-) Thanks! It was a stupid copy&paste bug - I somehow thought Haiku could use the same version of that code, and only tried to compile it for BeOS... It's fixed in r21668. Bye, Axel. From superstippi at gmx.de Thu Jul 19 20:23:26 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 19 Jul 2007 20:23:26 +0200 Subject: [Haiku-commits] broken build In-Reply-To: <1056511923-BeMail@zon> References: <1056511923-BeMail@zon> Message-ID: <20070719202326.14725.2@stippis2.1184824032.fake> Axel D?rfler wrote (2007-07-19, 20:15:32 [+0200]): > Stephan Assmus wrote: > > something seems to be missing... :-) > > Thanks! It was a stupid copy&paste bug - I somehow thought Haiku could > use the same version of that code, and only tried to compile it for > BeOS... > It's fixed in r21668. No worries. It was a good excuse to start cooking some food... :-) Best regards, -Stephan From bonefish at mail.berlios.de Thu Jul 19 23:43:22 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 19 Jul 2007 23:43:22 +0200 Subject: [Haiku-commits] r21669 - haiku/trunk/src/system/kernel/cache Message-ID: <200707192143.l6JLhMAX032492@sheep.berlios.de> Author: bonefish Date: 2007-07-19 23:43:22 +0200 (Thu, 19 Jul 2007) New Revision: 21669 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21669&view=rev Modified: haiku/trunk/src/system/kernel/cache/block_cache.cpp Log: More informative output. Modified: haiku/trunk/src/system/kernel/cache/block_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/block_cache.cpp 2007-07-19 18:14:38 UTC (rev 21668) +++ haiku/trunk/src/system/kernel/cache/block_cache.cpp 2007-07-19 21:43:22 UTC (rev 21669) @@ -552,11 +552,13 @@ if (*_allocated && readBlock) { int32 blockSize = cache->block_size; - if (read_pos(cache->fd, blockNumber * blockSize, block->current_data, - blockSize) < blockSize) { + ssize_t bytesRead = read_pos(cache->fd, blockNumber * blockSize, + block->current_data, blockSize); + if (bytesRead < blockSize) { hash_remove(cache->hash, block); cache->FreeBlock(block); - FATAL(("could not read block %Ld\n", blockNumber)); + FATAL(("could not read block %Ld: bytesRead: %ld, error: %s\n", + blockNumber, bytesRead, strerror(errno))); return NULL; } } From bonefish at mail.berlios.de Thu Jul 19 23:46:19 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 19 Jul 2007 23:46:19 +0200 Subject: [Haiku-commits] r21670 - haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk Message-ID: <200707192146.l6JLkJqv032595@sheep.berlios.de> Author: bonefish Date: 2007-07-19 23:46:19 +0200 (Thu, 19 Jul 2007) New Revision: 21670 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21670&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.cpp Log: * Fine-tuned timeouts. * Also eat B_INTERRUPTED on sendto()/recvfrom(). The net stack is interruptable in principle, but our disk device operations shouldn't. Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.cpp 2007-07-19 21:43:22 UTC (rev 21669) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/virtual/remote_disk/RemoteDisk.cpp 2007-07-19 21:46:19 UTC (rev 21670) @@ -30,8 +30,9 @@ #endif -static const bigtime_t kReceiveTimeout = 2000000LL; -static const bigtime_t kRequestTimeout = 6000000LL; +static const int kMaxRequestResendCount = 5; +static const bigtime_t kReceiveTimeout = 800000LL; +static const bigtime_t kRequestTimeout = 5000000LL; #if __BYTE_ORDER == __LITTLE_ENDIAN @@ -405,18 +406,23 @@ request->request_id = fRequestID++; request->port = fSocketAddress.sin_port; - // try sending the request 3 times at most - for (int i = 0; i < 3; i++) { + // try sending the request kMaxRequestResendCount times at most + for (int i = 0; i < kMaxRequestResendCount; i++) { // send request - ssize_t bytesSent = fSocketModule->sendto(fSocket, request, size, - 0, (sockaddr*)&fServerAddress, sizeof(fServerAddress)); + ssize_t bytesSent; + do { + bytesSent = fSocketModule->sendto(fSocket, request, size, + 0, (sockaddr*)&fServerAddress, sizeof(fServerAddress)); + } while (bytesSent < 0 && errno == B_INTERRUPTED); + if (bytesSent < 0) { dprintf("RemoteDisk::_SendRequest(): failed to send packet: %s\n", strerror(errno)); return errno; } if (bytesSent != (ssize_t)size) { - dprintf("RemoteDisk::_SendRequest(): sent less bytes than desired\n"); + dprintf("RemoteDisk::_SendRequest(): sent less bytes than " + "desired\n"); return B_ERROR; } @@ -430,8 +436,12 @@ (peerAddress ? &addrSize : 0)); if (bytesReceived < 0) { status_t error = errno; - if (error != B_TIMED_OUT && error != B_WOULD_BLOCK) + if (error != B_TIMED_OUT && error != B_WOULD_BLOCK + && error != B_INTERRUPTED) { + dprintf("RemoteDisk::_SendRequest(): recvfrom() failed: " + "%s\n", strerror(error)); return error; + } continue; } From bonefish at mail.berlios.de Thu Jul 19 23:55:06 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 19 Jul 2007 23:55:06 +0200 Subject: [Haiku-commits] r21671 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200707192155.l6JLt600000122@sheep.berlios.de> Author: bonefish Date: 2007-07-19 23:55:05 +0200 (Thu, 19 Jul 2007) New Revision: 21671 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21671&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp Log: axeld + bonefish: Fixed off-by-one error in the b+ tree code splitting a node, which could result in a read beyond the block bounds thus causing a page fault. Was nicely reproducible when unzipping big archives. Now bug #1003 seems to be fixed for real. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp 2007-07-19 21:46:19 UTC (rev 21670) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp 2007-07-19 21:55:05 UTC (rev 21671) @@ -1189,8 +1189,12 @@ // move the keys in the old node: the order is important here, // because we don't want to overwrite any contents - keys = keyIndex <= skip ? out : keyIndex - skip; + keys = keyIndex <= skip ? out - 1 : keyIndex - skip; keyIndex -= skip; + in = out - keyIndex - 1; + // Note: keyIndex and in will contain invalid values when the new key + // went to the other node. But in this case bytes and bytesAfter are + // 0 and subsequently we never use keyIndex and in. if (bytesBefore) memmove(inKeys, inKeys + total, bytesBefore); @@ -1201,8 +1205,8 @@ if (bytesBefore) memmove(outKeyLengths, inKeyLengths + skip, keys * sizeof(uint16)); - in = out - keyIndex - 1; if (bytesAfter) { + // if byteAfter is > 0, keyIndex is larger than skip memmove(outKeyLengths + keyIndex + 1, inKeyLengths + skip + keyIndex, in * sizeof(uint16)); } From umccullough at gmail.com Fri Jul 20 00:04:24 2007 From: umccullough at gmail.com (Urias McCullough) Date: Thu, 19 Jul 2007 15:04:24 -0700 Subject: [Haiku-commits] r21671 - haiku/trunk/src/add-ons/kernel/file_systems/bfs In-Reply-To: <200707192155.l6JLt600000122@sheep.berlios.de> References: <200707192155.l6JLt600000122@sheep.berlios.de> Message-ID: <1e80d8750707191504p7ffb77cdj2527ef7558a89b90@mail.gmail.com> On 7/19/07, bonefish at BerliOS wrote: > Author: bonefish > Date: 2007-07-19 23:55:05 +0200 (Thu, 19 Jul 2007) > New Revision: 21671 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21671&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp > Log: > axeld + bonefish: > Fixed off-by-one error in the b+ tree code splitting a node, which could > result in a read beyond the block bounds thus causing a page fault. Was > nicely reproducible when unzipping big archives. Now bug #1003 seems to > be fixed for real. YAY! Nice one guys! From bonefish at mail.berlios.de Fri Jul 20 00:52:27 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 20 Jul 2007 00:52:27 +0200 Subject: [Haiku-commits] r21672 - in haiku/trunk: headers/private/kernel src/system/kernel/vm Message-ID: <200707192252.l6JMqR0S032626@sheep.berlios.de> Author: bonefish Date: 2007-07-20 00:52:23 +0200 (Fri, 20 Jul 2007) New Revision: 21672 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21672&view=rev Modified: haiku/trunk/headers/private/kernel/vm_types.h haiku/trunk/src/system/kernel/vm/vm.cpp haiku/trunk/src/system/kernel/vm/vm_cache.cpp haiku/trunk/src/system/kernel/vm/vm_page.c Log: axeld + bonefish: * More conditional debug code (wrt page transitions between caches). * Replaced debugger command cache_chain by a nicer cache_tree. * While handling a soft fault: When we temporarily unlock a cache, it can theoretically become busy. One such occurrence is now handled properly, two more panic() ATM, though should be fixed. * When merging caches, we do now always replace a dummy page in the upper cache, not only when the concurrent page fault is a read fault. This prevents a page from the lower (to be discarded) cache from still remaining mapped (causing a panic). * When merging caches and replacing a dummy page, we were trying to remove the dummy page from the wrong cache (causing a panic). The Haiku kernel seems now to run shockingly stable. ATM, we have more than two hours uptime of a system booted and running over network. We didn't manage to get it down by fully building Pe, downloading, unzipping, and playing with various stuff. Someone should finally fix all those app server drawing bugs, though (hint, hint! ;-)). Modified: haiku/trunk/headers/private/kernel/vm_types.h =================================================================== --- haiku/trunk/headers/private/kernel/vm_types.h 2007-07-19 21:55:05 UTC (rev 21671) +++ haiku/trunk/headers/private/kernel/vm_types.h 2007-07-19 22:52:23 UTC (rev 21672) @@ -21,6 +21,9 @@ // be in. //#define DEBUG_PAGE_QUEUE 1 +// Enables extra debug fields in the vm_page used to track page transitions +// between caches. +//#define DEBUG_PAGE_CACHE_TRANSITIONS 1 #ifdef __cplusplus struct vm_page_mapping; @@ -92,6 +95,11 @@ void* queue; #endif + #ifdef DEBUG_PAGE_CACHE_TRANSITIONS + uint32 debug_flags; + struct vm_page *collided_page; + #endif + uint8 type : 2; uint8 state : 3; uint8 busy_reading : 1; Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2007-07-19 21:55:05 UTC (rev 21671) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2007-07-19 22:52:23 UTC (rev 21672) @@ -2195,8 +2195,29 @@ } +static void +dump_cache_tree_recursively(vm_cache* cache, int level, + vm_cache* highlightCache) +{ + // print this cache + for (int i = 0; i < level; i++) + kprintf(" "); + if (cache == highlightCache) + kprintf("%p <--\n", cache); + else + kprintf("%p\n", cache); + + // recursively print its consumers + vm_cache* consumer = NULL; + while ((consumer = (vm_cache *)list_get_next_item(&cache->consumers, + consumer)) != NULL) { + dump_cache_tree_recursively(consumer, level + 1, highlightCache); + } +} + + static int -dump_cache_chain(int argc, char **argv) +dump_cache_tree(int argc, char **argv) { if (argc < 2 || strlen(argv[1]) < 2 || argv[1][0] != '0' @@ -2210,11 +2231,14 @@ return 0; vm_cache *cache = (vm_cache *)address; - while (cache != NULL) { - dprintf("%p\n", cache); - cache = cache->source; - } + vm_cache *root = cache; + // find the root cache (the transitive source) + while (root->source != NULL) + root = root->source; + + dump_cache_tree_recursively(root, 0, cache); + return 0; } @@ -2914,7 +2938,7 @@ add_debugger_command("areas", &dump_area_list, "Dump a list of all areas"); add_debugger_command("area", &dump_area, "Dump info about a particular area"); add_debugger_command("cache", &dump_cache, "Dump vm_cache"); - add_debugger_command("cache_chain", &dump_cache_chain, "Dump vm_cache chain"); + add_debugger_command("cache_tree", &dump_cache_tree, "Dump vm_cache tree"); add_debugger_command("avail", &dump_available_memory, "Dump available memory"); add_debugger_command("dl", &display_mem, "dump memory long words (64-bit)"); add_debugger_command("dw", &display_mem, "dump memory words (32-bit)"); @@ -3197,8 +3221,22 @@ // page must be busy // ToDo: don't wait forever! mutex_unlock(&cache->lock); - snooze(20000); + thread_yield(); mutex_lock(&cache->lock); + + if (cache->busy) { + // The cache became busy, which means, it is about to be + // removed by vm_cache_remove_consumer(). We start again with + // the top cache. + mutex_unlock(&cache->lock); + vm_cache_release_ref(cache); + + cache = topCache; + lastCache = cache; + + vm_cache_acquire_ref(cache); + mutex_lock(&cache->lock); + } } if (page != NULL && page != &dummyPage) @@ -3267,6 +3305,9 @@ // upwards, too, we try this cache again mutex_unlock(&cache->lock); mutex_lock(&cache->lock); + if (cache->busy) + panic("fault_find_page(): cache became busy: %p\n", cache); + // TODO: Don't panic()! lastCache = NULL; continue; } else if (status < B_OK) @@ -3288,6 +3329,9 @@ // top most cache may have direct write access. vm_cache_acquire_ref(cache); mutex_lock(&cache->lock); + if (cache->busy) + panic("fault_find_page(): 2. cache became busy: %p\n", cache); + // TOOD: Don't panic()! } // release the reference of the last vm_cache we still have from the loop above @@ -3324,12 +3368,29 @@ // Insert the new page into our cache, and replace it with the dummy page if necessary // if we inserted a dummy page into this cache, we have to remove it now - if (dummyPage.state == PAGE_STATE_BUSY && dummyPage.cache == cache) + if (dummyPage.state == PAGE_STATE_BUSY && dummyPage.cache == cache) { +#ifdef DEBUG_PAGE_CACHE_TRANSITIONS + page->debug_flags = dummyPage.debug_flags | 0x8; + if (dummyPage.collided_page != NULL) { + dummyPage.collided_page->collided_page = page; + page->collided_page = dummyPage.collided_page; + } +#endif // DEBUG_PAGE_CACHE_TRANSITIONS + fault_remove_dummy_page(dummyPage, true); + } vm_cache_insert_page(cache, page, cacheOffset); if (dummyPage.state == PAGE_STATE_BUSY) { +#ifdef DEBUG_PAGE_CACHE_TRANSITIONS + page->debug_flags = dummyPage.debug_flags | 0x10; + if (dummyPage.collided_page != NULL) { + dummyPage.collided_page->collided_page = page; + page->collided_page = dummyPage.collided_page; + } +#endif // DEBUG_PAGE_CACHE_TRANSITIONS + // we had inserted the dummy cache in another cache, so let's remove it from there fault_remove_dummy_page(dummyPage, false); } @@ -3502,6 +3563,10 @@ dummyPage.type = PAGE_TYPE_DUMMY; dummyPage.busy_writing = isWrite; dummyPage.wired_count = 0; +#ifdef DEBUG_PAGE_CACHE_TRANSITIONS + dummyPage.debug_flags = 0; + dummyPage.collided_page = NULL; +#endif // DEBUG_PAGE_CACHE_TRANSITIONS vm_cache *copiedPageSource = NULL; vm_cache *pageSource; Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2007-07-19 21:55:05 UTC (rev 21671) +++ haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2007-07-19 22:52:23 UTC (rev 21672) @@ -314,8 +314,10 @@ TRACE(("vm_cache_remove_page: cache %p, page %p\n", cache, page)); ASSERT_LOCKED_MUTEX(&cache->lock); - if (page->cache != cache) - panic("remove page from %p: page cache is set to %p\n", cache, page->cache); + if (page->cache != cache) { + panic("remove page %p from cache %p: page cache is set to %p\n", page, + cache, page->cache); + } state = disable_interrupts(); acquire_spinlock(&sPageCacheTableLock); @@ -478,6 +480,8 @@ || list_is_empty(&cache->consumers) || cache->consumers.link.next != cache->consumers.link.prev || consumer != list_get_first_item(&cache->consumers)) { + dprintf("vm_cache_remove_consumer(): cache %p was modified; " + "not merging it\n"); merge = false; cache->busy = false; mutex_unlock(&consumer->lock); @@ -512,18 +516,29 @@ vm_cache_insert_page(consumer, page, (off_t)page->cache_offset << PAGE_SHIFT); } else if (consumerPage->state == PAGE_STATE_BUSY - && consumerPage->type == PAGE_TYPE_DUMMY - && !consumerPage->busy_writing) { + && consumerPage->type == PAGE_TYPE_DUMMY) { // the page is currently busy taking a read fault - IOW, // vm_soft_fault() has mapped our page so we can just // move it up //dprintf("%ld: merged busy page %p, cache %p, offset %ld\n", find_thread(NULL), page, cacheRef->cache, page->cache_offset); - vm_cache_remove_page(cache, consumerPage); + vm_cache_remove_page(consumer, consumerPage); consumerPage->state = PAGE_STATE_INACTIVE; vm_cache_remove_page(cache, page); vm_cache_insert_page(consumer, page, (off_t)page->cache_offset << PAGE_SHIFT); +#ifdef DEBUG_PAGE_CACHE_TRANSITIONS + } else { + page->debug_flags = 0; + if (consumerPage->state == PAGE_STATE_BUSY) + page->debug_flags |= 0x1; + if (consumerPage->type == PAGE_TYPE_DUMMY) + page->debug_flags |= 0x2; + if (!consumerPage->busy_writing) + page->debug_flags |= 0x4; + page->collided_page = consumerPage; + consumerPage->collided_page = page; +#endif // DEBUG_PAGE_CACHE_TRANSITIONS } #if 0 else if (consumer->virtual_base == 0x11000) Modified: haiku/trunk/src/system/kernel/vm/vm_page.c =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_page.c 2007-07-19 21:55:05 UTC (rev 21671) +++ haiku/trunk/src/system/kernel/vm/vm_page.c 2007-07-19 22:52:23 UTC (rev 21672) @@ -269,8 +269,12 @@ kprintf("wired_count: %u\n", page->wired_count); kprintf("usage_count: %u\n", page->usage_count); #ifdef DEBUG_PAGE_QUEUE - kprintf("queue: %p\n", page->queue); + kprintf("queue: %p\n", page->queue); #endif + #ifdef DEBUG_PAGE_CACHE_TRANSITIONS + kprintf("debug_flags: 0x%lx\n", page->debug_flags); + kprintf("collided page: %p\n", page->collided_page); + #endif // DEBUG_PAGE_CACHE_TRANSITIONS kprintf("area mappings:\n"); mapping = page->mappings; @@ -831,6 +835,10 @@ #ifdef DEBUG_PAGE_QUEUE sPages[i].queue = NULL; #endif + #ifdef DEBUG_PAGE_CACHE_TRANSITIONS + sPages[i].debug_flags = 0; + sPages[i].collided_page = NULL; + #endif // DEBUG_PAGE_CACHE_TRANSITIONS enqueue_page(&page_free_queue, &sPages[i]); } From axeld at mail.berlios.de Fri Jul 20 02:31:50 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 20 Jul 2007 02:31:50 +0200 Subject: [Haiku-commits] r21673 - haiku/trunk/src/preferences/joysticks Message-ID: <200707200031.l6K0VoGn024176@sheep.berlios.de> Author: axeld Date: 2007-07-20 02:31:48 +0200 (Fri, 20 Jul 2007) New Revision: 21673 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21673&view=rev Modified: haiku/trunk/src/preferences/joysticks/JoyWin.cpp Log: * Fixed Haiku build over here (no such thing as BEOS_NAME_LENGTH defined here) * Did anyone see the coding style violations in this file??? :-) Modified: haiku/trunk/src/preferences/joysticks/JoyWin.cpp =================================================================== --- haiku/trunk/src/preferences/joysticks/JoyWin.cpp 2007-07-19 22:52:23 UTC (rev 21672) +++ haiku/trunk/src/preferences/joysticks/JoyWin.cpp 2007-07-20 00:31:48 UTC (rev 21673) @@ -130,21 +130,22 @@ /* Initialization */ -status_t JoyWin::AddDevices() +status_t +JoyWin::AddDevices() { - char buf[BEOS_NAME_LENGTH]; + char name[B_FILE_NAME_LENGTH]; int devId = 0; MessagedItem* device; - BMessage* message; - BString str; + BMessage* message; + BString str; - while (!fJoystick.GetDeviceName(devId, buf, BEOS_NAME_LENGTH)) { + while (!fJoystick.GetDeviceName(devId, name, sizeof(name))) { message = new BMessage(PORT_SELECTED); - message->AddString("devname", buf); + message->AddString("devname", name); // NOTE: Adding the index in the list might be useful. // TODO: Change it with leaf path - str.SetTo(buf); + str.SetTo(name); //str = str.Remove(0, str.FindLast('/') ); device = new MessagedItem(str.String(), message); From leavengood at gmail.com Fri Jul 20 03:36:44 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Thu, 19 Jul 2007 21:36:44 -0400 Subject: [Haiku-commits] r21673 - haiku/trunk/src/preferences/joysticks In-Reply-To: <200707200031.l6K0VoGn024176@sheep.berlios.de> References: <200707200031.l6K0VoGn024176@sheep.berlios.de> Message-ID: On 7/19/07, axeld at BerliOS wrote: > Author: axeld > Date: 2007-07-20 02:31:48 +0200 (Fri, 20 Jul 2007) > New Revision: 21673 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21673&view=rev > > Modified: > haiku/trunk/src/preferences/joysticks/JoyWin.cpp > Log: > * Fixed Haiku build over here (no such thing as BEOS_NAME_LENGTH defined here) Sorry about that, I was about to fix this but you beat me to it :) > * Did anyone see the coding style violations in this file??? :-) I fixed some things in the Joystick prefs code before checking it in, but I didn't totally clean it up. I don't think it is finished yet anyhow. As you may recall the code is from Oliver Ruiz Dorantes. I'll bug him about following the coding style more closely. Ryan From stefano.ceccherini at gmail.com Fri Jul 20 08:17:00 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Fri, 20 Jul 2007 08:17:00 +0200 Subject: [Haiku-commits] r21665 - in haiku/trunk: headers/os/interface src/kits/app src/kits/game src/kits/interface src/servers/app In-Reply-To: <200707191706.l6JH6ZIu009486@sheep.berlios.de> References: <200707191706.l6JH6ZIu009486@sheep.berlios.de> Message-ID: <894b9700707192317u48f5767x6e5abf7355bbadcc@mail.gmail.com> 2007/7/19, stippi at BerliOS : > Author: stippi > Date: 2007-07-19 19:06:28 +0200 (Thu, 19 Jul 2007) > New Revision: 21665 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21665&view=rev > BRegion::BRegion() > - : > - data_size(0), > - data(NULL) > + : fCount(0) > + , fDataSize(0) > + , fBounds((clipping_rect){ 0, 0, 0, 0 }) Stephan, is this change intended ? An empty region used to have its bound rectangle set to some invalid values. This way, instead, this kind of check: "region.Bounds().IsValid()" will return true on an empty region. BTW nice change. Actually I had the same idea some time ago (port the code from XOrg), I just hadn't the chance to do that :) From superstippi at gmx.de Fri Jul 20 08:55:54 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Fri, 20 Jul 2007 08:55:54 +0200 Subject: [Haiku-commits] r21665 - in haiku/trunk: headers/os/interface src/kits/app src/kits/game src/kits/interface src/servers/app In-Reply-To: <894b9700707192317u48f5767x6e5abf7355bbadcc@mail.gmail.com> References: <200707191706.l6JH6ZIu009486@sheep.berlios.de> <894b9700707192317u48f5767x6e5abf7355bbadcc@mail.gmail.com> Message-ID: <20070720085554.1147.2@stippis2.1184912382.fake> Stefano Ceccherini wrote (2007-07-20, 08:17:00 [+0200]): > 2007/7/19, stippi at BerliOS : > > Author: stippi > > Date: 2007-07-19 19:06:28 +0200 (Thu, 19 Jul 2007) New Revision: 21665 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21665&view=rev > > > BRegion::BRegion() > > - : > > - data_size(0), > > - data(NULL) > > + : fCount(0) > > + , fDataSize(0) > > + , fBounds((clipping_rect){ 0, 0, 0, 0 }) > > > Stephan, is this change intended ? > An empty region used to have its bound rectangle set to some invalid > values. This way, instead, this kind of check: > "region.Bounds().IsValid()" will return true on an empty region. Yes it is intended. The internal coordinates are now "exclusive" for right and bottom. Whenever the BRegion is asked to hand out rects, it decrements the right and bottom coordinates. This is how the XOrg code works, and I didn't feel like changing it and introducing lots of +/-1 bugs. :-) > BTW nice change. Actually I had the same idea some time ago (port the > code from XOrg), I just hadn't the chance to do that :) I made a little test application that allowed me to draw regions. I could watch and time four different implementations synchronized. For everything I did, the XOrg implementation was just a tiny bit slower than Dano BRegion, while our original implementation was between 5 and 16 times slower. And I only messured including/excluding a single rect from a complicated region. My change to avoid malloc for single-rect regions finally made the XOrg code perform exactly like Dano BRegion. Your in-progress implementation was in the comparisson as well, but it wasn't complete enough. Since I didn't/don't understand the actual algorithms involved, I simply went with the existing XOrg implementation. The porting itself wasn't that hard luckily, since it works with the same data structure. So basically a find+replace job. The only problems were some memory corruption bugs, since the XOrg code did unexpected reallocations at places and could leave object in an invalid state, which wasn't a problem with the original code, only when suddenly working with the same data from two sides. Best regards, -Stephan From korli at users.berlios.de Fri Jul 20 10:26:07 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Fri, 20 Jul 2007 10:26:07 +0200 Subject: [Haiku-commits] r21672 - in haiku/trunk: headers/private/kernel src/system/kernel/vm In-Reply-To: <200707192252.l6JMqR0S032626@sheep.berlios.de> References: <200707192252.l6JMqR0S032626@sheep.berlios.de> Message-ID: > The Haiku kernel seems now to run shockingly stable. ATM, we have more > than two hours uptime of a system booted and running over network. We > didn't manage to get it down by fully building Pe, downloading, unzipping, > and playing with various stuff. Someone should finally fix all those app > server drawing bugs, though (hint, hint! ;-)). > Congratulations !! J?r?me From kaoutsis at sch.gr Fri Jul 20 12:18:33 2007 From: kaoutsis at sch.gr (Kaoutsis) Date: Fri, 20 Jul 2007 13:18:33 +0300 EEST Subject: [Haiku-commits] =?utf-8?q?r21672_-_in_haiku/trunk=3A_headers/priv?= =?utf-8?q?ate/kernel_src/system/kernel/vm?= In-Reply-To: <200707192252.l6JMqR0S032626@sheep.berlios.de> Message-ID: <7494915912-BeMail@zoidberg> bonefish at BerliOS> Author: bonefish > Date: 2007-07-20 00:52:23 +0200 (Fri, 20 Jul 2007) > New Revision: 21672 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21672&view=rev > > Modified: > haiku/trunk/headers/private/kernel/vm_types.h > haiku/trunk/src/system/kernel/vm/vm.cpp > haiku/trunk/src/system/kernel/vm/vm_cache.cpp > haiku/trunk/src/system/kernel/vm/vm_page.c > Log: > axeld + bonefish: > * More conditional debug code (wrt page transitions between caches). > * Replaced debugger command cache_chain by a nicer cache_tree. > * While handling a soft fault: When we temporarily unlock a cache, it > can theoretically become busy. One such occurrence is now handled > properly, two more panic() ATM, though should be fixed. > * When merging caches, we do now always replace a dummy page in the > upper cache, not only when the concurrent page fault is a read > fault. > This prevents a page from the lower (to be discarded) cache from > still > remaining mapped (causing a panic). > * When merging caches and replacing a dummy page, we were trying to > remove the dummy page from the wrong cache (causing a panic). > > The Haiku kernel seems now to run shockingly stable. ATM, we have > more > than two hours uptime of a system booted and running over network. We > didn't manage to get it down by fully building Pe, downloading, > unzipping, > and playing with various stuff. Someone should finally fix all those > app > server drawing bugs, though (hint, hint! ;-)). > Great job guys. My congratulations also! bye, Vasilis From axeld at mail.berlios.de Fri Jul 20 12:45:09 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 20 Jul 2007 12:45:09 +0200 Subject: [Haiku-commits] r21674 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200707201045.l6KAj9iI027119@sheep.berlios.de> Author: axeld Date: 2007-07-20 12:45:04 +0200 (Fri, 20 Jul 2007) New Revision: 21674 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21674&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp Log: The AttributeIterator was returning the size of the attribute data rather than the length of the attribute name in GetNext() for attributes that are actual inodes. Found by Robert Szeleney, thanks! Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2007-07-20 00:31:48 UTC (rev 21673) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2007-07-20 10:45:04 UTC (rev 21674) @@ -2536,7 +2536,7 @@ Inode *attribute; if ((status = vnode.Get(&attribute)) == B_OK) { *_type = attribute->Type(); - *_length = attribute->Size(); + *_length = length; *_id = id; } From stippi at mail.berlios.de Fri Jul 20 13:16:06 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Fri, 20 Jul 2007 13:16:06 +0200 Subject: [Haiku-commits] r21675 - haiku/trunk/src/apps/aboutsystem Message-ID: <200707201116.l6KBG68G021576@sheep.berlios.de> Author: stippi Date: 2007-07-20 13:16:04 +0200 (Fri, 20 Jul 2007) New Revision: 21675 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21675&view=rev Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp Log: * added copyright for BRegion backend implementation Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp =================================================================== --- haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2007-07-20 10:45:04 UTC (rev 21674) +++ haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2007-07-20 11:16:04 UTC (rev 21675) @@ -529,6 +529,15 @@ "Copyright " B_UTF8_COPYRIGHT " 1997 Be Inc.\n" "Copyright " B_UTF8_COPYRIGHT " 1999 Jake Hamby. \n\n"); + // OpenGroup & DEC (BRegion backend) copyright + fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); + fCreditsView->Insert("BRegion backend (XFree86)\n"); + fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); + fCreditsView->Insert( + "Copyright " B_UTF8_COPYRIGHT " 1987, 1988, 1998 The Open Group.\n" + "Copyright " B_UTF8_COPYRIGHT " 1987, 1988 Digital Equipment Corporation, Maynard, Massachusetts.\n" + "All rights reserved.\n\n"); + // Konatu font fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); fCreditsView->Insert("Konatu font\n"); From superstippi at gmx.de Sat Jul 21 15:16:48 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Sat, 21 Jul 2007 15:16:48 +0200 Subject: [Haiku-commits] r21665 - in haiku/trunk: headers/os/interface src/kits/app src/kits/game src/kits/interface src/servers/app In-Reply-To: <894b9700707192317u48f5767x6e5abf7355bbadcc@mail.gmail.com> References: <200707191706.l6JH6ZIu009486@sheep.berlios.de> <894b9700707192317u48f5767x6e5abf7355bbadcc@mail.gmail.com> Message-ID: <20070721151648.6294.1@stippis2.1185019387.fake> Hi Stefano, Stefano Ceccherini wrote (2007-07-20, 08:17:00 [+0200]): > BTW nice change. Actually I had the same idea some time ago (port the > code from XOrg), I just hadn't the chance to do that :) I have done some more testing with intersecting large, complicated regions. It turns out that the new XOrg based implementation can be up to 20% faster than the Dano BRegion implementation, and easily 20 times faster than the old Haiku implementation. The memory consumption of the old imlementation was also quite bad, I cannot even test beyond 2 regions with more than 10000 rects each on a machine with 1 gig of memory. So kudos to the XOrg guys... :-) Best regards, -Stephan From stippi at mail.berlios.de Sat Jul 21 18:06:22 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 21 Jul 2007 18:06:22 +0200 Subject: [Haiku-commits] r21676 - haiku/trunk/src/servers/app/drawing/Painter Message-ID: <200707211606.l6LG6MgV025961@sheep.berlios.de> Author: stippi Date: 2007-07-21 18:06:22 +0200 (Sat, 21 Jul 2007) New Revision: 21676 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21676&view=rev Modified: haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp Log: * fix some issues with line placement, now it should be as close to R5 as possible without unacceptable overhead. Modified: haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp 2007-07-20 11:16:04 UTC (rev 21675) +++ haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp 2007-07-21 16:06:22 UTC (rev 21676) @@ -289,8 +289,9 @@ } // first, try an optimized version - if (fPenSize == 1.0 && - (fDrawingMode == B_OP_COPY || fDrawingMode == B_OP_OVER)) { + if (fPenSize == 1.0 + && (fDrawingMode == B_OP_COPY || fDrawingMode == B_OP_OVER)) { + pattern pat = *fPatternHandler.GetR5Pattern(); if (pat == B_SOLID_HIGH && StraightLine(a, b, fPatternHandler.HighColor().GetColor32())) { @@ -305,19 +306,59 @@ if (a == b) { // special case dots - fPath.move_to(a.x, a.y); - fPath.line_to(a.x + 1, a.y); - fPath.line_to(a.x + 1, a.y + 1); - fPath.line_to(a.x, a.y + 1); + if (fPenSize == 1.0 && !fSubpixelPrecise) { + if (fClippingRegion->Contains(a)) { + agg::rgba8 dummyColor; + fPixelFormat.blend_pixel(a.x, a.y, dummyColor, 255); + } + } else { + fPath.move_to(a.x, a.y); + fPath.line_to(a.x + 1, a.y); + fPath.line_to(a.x + 1, a.y + 1); + fPath.line_to(a.x, a.y + 1); - touched = _FillPath(fPath); + touched = _FillPath(fPath); + } } else { // do the pixel center offset here - if (!fSubpixelPrecise && fmodf(fPenSize, 2.0) != 0.0) { - a.x += 0.5; - a.y += 0.5; - b.x += 0.5; - b.y += 0.5; + // tweak ends to "include" the pixel at the index, + // we need to do this in order to produce results like R5, + // where coordinates were inclusive + if (!fSubpixelPrecise) { + bool centerOnLine = fmodf(fPenSize, 2.0) != 0.0; + if (a.x == b.x) { + // shift to pixel center vertically + if (centerOnLine) { + a.x += 0.5; + b.x += 0.5; + } + // extend on bottom end + if (a.y < b.y) + b.y++; + else + a.y++; + } else if (a.y == b.y) { + if (centerOnLine) { + // shift to pixel center horizontally + a.y += 0.5; + b.y += 0.5; + } + // extend on right end + if (a.x < b.x) + b.x++; + else + a.x++; + } else { + // do this regardless of pensize + if (a.x < b.x) + b.x++; + else + a.x++; + if (a.y < b.y) + b.y++; + else + a.y++; + } } fPath.move_to(a.x, a.y); @@ -1053,14 +1094,14 @@ // #pragma mark - private // _Transform -void +inline void Painter::_Transform(BPoint* point, bool centerOffset) const { // rounding if (!fSubpixelPrecise) { // TODO: validate usage of floor() for values < 0 - point->x = floorf(point->x); - point->y = floorf(point->y); + point->x = (int32)point->x; + point->y = (int32)point->y; } // this code is supposed to move coordinates to the center of pixels, // as AGG considers (0,0) to be the "upper left corner" of a pixel, @@ -1072,7 +1113,7 @@ } // _Transform -BPoint +inline BPoint Painter::_Transform(const BPoint& point, bool centerOffset) const { BPoint ret = point; @@ -1579,14 +1620,7 @@ agg::conv_stroke stroke(path); stroke.width(fPenSize); - // special case line width = 1 with square caps - // this has a couple of advantages and it looks - // like this is also the R5 behaviour. - if (fPenSize == 1.0 && fLineCapMode == B_BUTT_CAP) { - stroke.line_cap(agg::square_cap); - } else { - stroke.line_cap(agg_line_cap_mode_for(fLineCapMode)); - } + stroke.line_cap(agg_line_cap_mode_for(fLineCapMode)); stroke.line_join(agg_line_join_mode_for(fLineJoinMode)); stroke.miter_limit(fMiterLimit); From jackburton at mail.berlios.de Sat Jul 21 21:11:42 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sat, 21 Jul 2007 21:11:42 +0200 Subject: [Haiku-commits] r21677 - haiku/trunk/src/apps/terminal Message-ID: <200707211911.l6LJBgP6016525@sheep.berlios.de> Author: jackburton Date: 2007-07-21 21:11:41 +0200 (Sat, 21 Jul 2007) New Revision: 21677 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21677&view=rev Modified: haiku/trunk/src/apps/terminal/Coding.h haiku/trunk/src/apps/terminal/Shell.cpp haiku/trunk/src/apps/terminal/Shell.h haiku/trunk/src/apps/terminal/TermWindow.cpp haiku/trunk/src/apps/terminal/TermWindow.h Log: Minor cleanup, Updated some copyrights Modified: haiku/trunk/src/apps/terminal/Coding.h =================================================================== --- haiku/trunk/src/apps/terminal/Coding.h 2007-07-21 16:06:22 UTC (rev 21676) +++ haiku/trunk/src/apps/terminal/Coding.h 2007-07-21 19:11:41 UTC (rev 21677) @@ -83,7 +83,7 @@ }; -status_t get_nth_encoding(int i, int *op); +status_t get_nth_encoding(int i, int *id); int longname2id(const char *longname); const char * longname2shortname(const char *longname); @@ -93,5 +93,4 @@ void SetEncoding(int encoding); int GetEncoding(); - #endif /* _CODING_H_ */ Modified: haiku/trunk/src/apps/terminal/Shell.cpp =================================================================== --- haiku/trunk/src/apps/terminal/Shell.cpp 2007-07-21 16:06:22 UTC (rev 21676) +++ haiku/trunk/src/apps/terminal/Shell.cpp 2007-07-21 19:11:41 UTC (rev 21677) @@ -1,4 +1,5 @@ /* + * Copyright 2007 Haiku, inc. * Copyright (c) 2003-4 Kian Duffy * Copyright (c) 2004 Daniel Furrer * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. @@ -54,10 +55,6 @@ #define SHELL_COMMAND "/bin/sh -login" -const static char *kSpawnAlertMessage = "alert --stop " "'Cannot execute \"%s\":\n" - "\t%s\n'" - "'Use Default Shell' 'Abort'"; - /* * Set environment variable. */ @@ -92,11 +89,6 @@ #endif -/* - * spawn_shell(): spawn child process, create pty master/slave device and - * execute SHELL program. - */ - /* handshake interface */ typedef struct { @@ -112,10 +104,111 @@ #define PTY_WS 2 /* pty need WINSIZE (row and col ) */ - static pid_t sShPid; +Shell::Shell() + :fFd(-1) +{ +} + + +Shell::~Shell() +{ + Close(); +} + + +status_t +Shell::Open(int row, int col, const char *command, const char *coding) +{ + if (fFd >= 0) + return B_ERROR; + + return _Spawn(row, col, command, coding); +} + + +void +Shell::Close() +{ + if (fFd >= 0) { + close(fFd); + kill(-sShPid, SIGHUP); + int status; + wait(&status); + fFd = -1; + } +} + + +const char * +Shell::TTYName() const +{ + return ttyname(fFd); +} + + +ssize_t +Shell::Read(void *buffer, size_t numBytes) +{ + if (fFd < 0) + return B_NO_INIT; + + return read(fFd, buffer, numBytes); +} + + +ssize_t +Shell::Write(const void *buffer, size_t numBytes) +{ + if (fFd < 0) + return B_NO_INIT; + + return write(fFd, buffer, numBytes); +} + + +void +Shell::UpdateWindowSize(int rows, int columns) +{ + struct winsize winSize; + winSize.ws_row = rows; + winSize.ws_col = columns; + ioctl(fFd, TIOCSWINSZ, &winSize); + Signal(SIGWINCH); +} + + +void +Shell::Signal(int signal) +{ + kill(-sShPid, signal); +} + + +status_t +Shell::GetAttr(struct termios &attr) +{ + return tcgetattr(fFd, &attr); +} + + +status_t +Shell::SetAttr(struct termios &attr) +{ + return tcsetattr(fFd, TCSANOW, &attr); +} + + +int +Shell::FD() const +{ + return fFd; +} + + +// private static status_t send_handshake_message(thread_id target, const handshake_t& handshake) { @@ -131,14 +224,14 @@ } -static int -spawn_shell(int row, int col, const char *command, const char *coding) +status_t +Shell::_Spawn(int row, int col, const char *command, const char *coding) { signal(SIGTTOU, SIG_IGN); /* * Get a pseudo-tty. We do this by cycling through files in the - * directory. The oparationg system will not allow us to open a master + * directory. The operationg system will not allow us to open a master * which is already in use, so we simply go until the open succeeds. */ char ttyName[B_PATH_NAME_LENGTH]; @@ -170,27 +263,27 @@ if (master < 0) { printf("didn't find any available pseudo ttys."); - return -1; + return B_ERROR; } - /* - * Get the modes of the current terminal. We will duplicates these - * on the pseudo terminal. - */ + /* + * Get the modes of the current terminal. We will duplicates these + * on the pseudo terminal. + */ thread_id terminalThread = find_thread(NULL); /* Fork a child process. */ if ((sShPid = fork()) < 0) { close(master); - return -1; + return B_ERROR; } handshake_t handshake; if (sShPid == 0) { - // Now in child process. + // Now in child process. /* * Make our controlling tty the pseudo tty. This hapens because @@ -408,8 +501,12 @@ * Exec failed. */ sleep(1); + const char *spawnAlertMessage = "alert --stop " + "'Cannot execute \"%s\":\n" + "\t%s\n'" + "'Use Default Shell' 'Abort'"; char errorMessage[256]; - snprintf(errorMessage, sizeof(errorMessage), kSpawnAlertMessage, commandLine, strerror(errno)); + snprintf(errorMessage, sizeof(errorMessage), spawnAlertMessage, commandLine, strerror(errno)); if (system(errorMessage) == 0) execl("/bin/sh", "/bin/sh", "-login", NULL); @@ -449,119 +546,11 @@ } } - return (done > 0) ? master : -1; -} + if (done <= 0) + return B_ERROR; + fFd = master; -static void -close_shell(int fd) -{ - if (fd < 0) - return; - - close(fd); - - int status; - kill(-sShPid, SIGHUP); - wait(&status); -} - - -Shell::Shell() - :fFd(-1) -{ -} - - -Shell::~Shell() -{ - Close(); -} - - -status_t -Shell::Open(int row, int col, const char *command, const char *coding) -{ - fFd = spawn_shell(row, col, command, coding); - if (fFd < 0) - return fFd; - return B_OK; } - -void -Shell::Close() -{ - if (fFd >= 0) { - close_shell(fFd); - fFd = -1; - } -} - - -const char * -Shell::TTYName() const -{ - return ttyname(fFd); -} - - -ssize_t -Shell::Read(void *buffer, size_t numBytes) -{ - if (fFd < 0) - return B_NO_INIT; - - return read(fFd, buffer, numBytes); -} - - -ssize_t -Shell::Write(const void *buffer, size_t numBytes) -{ - if (fFd < 0) - return B_NO_INIT; - - return write(fFd, buffer, numBytes); -} - - -void -Shell::UpdateWindowSize(int rows, int columns) -{ - struct winsize winSize; - winSize.ws_row = rows; - winSize.ws_col = columns; - ioctl(fFd, TIOCSWINSZ, &winSize); - Signal(SIGWINCH); -} - - -void -Shell::Signal(int signal) -{ - kill(-sShPid, signal); -} - - -status_t -Shell::GetAttr(struct termios &attr) -{ - return tcgetattr(fFd, &attr); -} - - -status_t -Shell::SetAttr(struct termios &attr) -{ - return tcsetattr(fFd, TCSANOW, &attr); -} - - -int -Shell::FD() const -{ - return fFd; -} - Modified: haiku/trunk/src/apps/terminal/Shell.h =================================================================== --- haiku/trunk/src/apps/terminal/Shell.h 2007-07-21 16:06:22 UTC (rev 21676) +++ haiku/trunk/src/apps/terminal/Shell.h 2007-07-21 19:11:41 UTC (rev 21677) @@ -103,7 +103,9 @@ int FD() const; private: - int fFd; + int fFd; + + status_t _Spawn(int row, int col, const char *command, const char *coding); }; #endif // _SHELL_H Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-21 16:06:22 UTC (rev 21676) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-21 19:11:41 UTC (rev 21677) @@ -1,4 +1,5 @@ /* + * Copyright 2007 Haiku, Inc. * Copyright (c) 2003-2004 Kian Duffy * Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * Copyright (c) 2004 Daniel Furrer @@ -10,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -20,7 +22,6 @@ #include #include -#include #include #include #include @@ -33,7 +34,6 @@ #include "PrefWindow.h" #include "PrefView.h" #include "PrefHandler.h" -#include "TermApp.h" #include "TermBaseView.h" #include "TermBuffer.h" #include "TermParse.h" @@ -171,7 +171,7 @@ * TermView is character Terminal view on BaseView. It has paste * on BaseView shift as VIEW_OFFSET. */ - fBaseView = new TermBaseView(textframe, fTermView); + //fBaseView = new TermBaseView(textframe, fTermView); // Initialize TermView. (font, size and color) @@ -186,7 +186,7 @@ MIN_COLS * height, MAX_COLS * height); fTermView->SetTermColor(); - fBaseView->SetViewColor(PrefHandler::Default()->getRGB(PREF_TEXT_BACK_COLOR)); + //fBaseView->SetViewColor(PrefHandler::Default()->getRGB(PREF_TEXT_BACK_COLOR)); // Add offset to baseview. rect.InsetBy(-VIEW_OFFSET, -VIEW_OFFSET); @@ -196,9 +196,9 @@ ResizeTo(rect.Width()+ B_V_SCROLL_BAR_WIDTH, rect.Height() + fMenubar->Bounds().Height()); - fBaseView->ResizeTo(rect.Width(), rect.Height()); - fBaseView->AddChild(fTermView); - fTermView->MoveBy(VIEW_OFFSET, VIEW_OFFSET); + //fBaseView->ResizeTo(rect.Width(), rect.Height()); + //fBaseView->AddChild(fTermView); + //fTermView->MoveBy(VIEW_OFFSET, VIEW_OFFSET); // Make Scroll Bar. @@ -212,7 +212,8 @@ fTermView->SetScrollBar(scrollBar); AddChild(scrollBar); - AddChild(fBaseView); + //AddChild(fBaseView); + AddChild(fTermView); // Set fEditmenu's target to fTermView. (Oh!...) fEditmenu->SetTargetForItems(fTermView); @@ -223,14 +224,6 @@ if (fTermParse->StartThreads() < B_OK) return; - // Set Coding. - - // Init find parameters - fMatchCase = false; - fMatchWord = false; - fFindSelection = false; - fForwardSearch = false; - // Initialize MessageRunner. fWindowUpdate = new BMessageRunner(BMessenger(this), new BMessage (MSGRUN_WINDOW), 500000); @@ -238,7 +231,7 @@ void -TermWindow::MenusBeginning(void) +TermWindow::MenusBeginning() { // Syncronize Encode Menu Pop-up menu and Preference. (fEncodingmenu->FindItem(id2longname(GetEncoding())))->SetMarked(true); @@ -247,7 +240,7 @@ void -TermWindow::SetupMenu(void) +TermWindow::SetupMenu() { PrefHandler menuText; @@ -561,8 +554,8 @@ BScreen screen(this); fTermView->ScrollBar()->Hide(); fMenubar->Hide(); - fBaseView->MoveTo(0,0); - fBaseView->ResizeBy(B_V_SCROLL_BAR_WIDTH, mbHeight); + fTermView->MoveTo(0,0); + fTermView->ResizeBy(B_V_SCROLL_BAR_WIDTH, mbHeight); fSavedLook = Look(); // done before ResizeTo to work around a Dano bug (not erasing the decor) SetLook(B_NO_BORDER_WINDOW_LOOK); @@ -574,8 +567,8 @@ fTermView->ScrollBar()->Show(); ResizeTo(fSavedFrame.Width(), fSavedFrame.Height()); MoveTo(fSavedFrame.left, fSavedFrame.top); - fBaseView->ResizeBy(-B_V_SCROLL_BAR_WIDTH, -mbHeight); - fBaseView->MoveTo(0,mbHeight); + fTermView->ResizeBy(-B_V_SCROLL_BAR_WIDTH, -mbHeight); + fTermView->MoveTo(0,mbHeight); SetLook(fSavedLook); fSavedFrame = BRect(0,0,-1,-1); } @@ -587,9 +580,9 @@ break; } case MSG_COLOR_CHANGED: { - fBaseView->SetViewColor (PrefHandler::Default()->getRGB (PREF_TEXT_BACK_COLOR)); - fTermView->SetTermColor (); - fBaseView->Invalidate(); + //fBaseView->SetViewColor (PrefHandler::Default()->getRGB (PREF_TEXT_BACK_COLOR)); + fTermView->SetTermColor(); + //fBaseView->Invalidate(); fTermView->Invalidate(); break; } Modified: haiku/trunk/src/apps/terminal/TermWindow.h =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-21 16:06:22 UTC (rev 21676) +++ haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-21 19:11:41 UTC (rev 21677) @@ -28,72 +28,74 @@ * THE SOFTWARE. * */ -#ifndef TERMWIN_H -#define TERMWIN_H +#ifndef __TERMWINDOW_H +#define __TERMWINDOW_H - -#include +#include #include -#include -#include -class BFont; -class TermView; -class TermParse; +class BMenu; +class BMenuBar; +class BMessageRunner; class CodeConv; +class FindWindow; class PrefWindow; -class FindWindow; class Shell; +class TermParse; +class TermView; class TermWindow : public BWindow { - public: - TermWindow(BRect frame, const char* title, const char *command); - virtual ~TermWindow(); +public: + TermWindow(BRect frame, const char* title, const char *command); + virtual ~TermWindow(); - void TermWinActivate(); + void TermWinActivate(); - protected: - virtual void MessageReceived(BMessage *message); - virtual void WindowActivated(bool); - virtual void MenusBeginning(void); - virtual bool QuitRequested(); +protected: + virtual void MessageReceived(BMessage *message); + virtual void WindowActivated(bool); + virtual void MenusBeginning(); + virtual bool QuitRequested(); - status_t GetSupportedSuites(BMessage *msg); - BHandler* ResolveSpecifier(BMessage *msg, int32 index, - BMessage *specifier, int32 form, - const char *property); + status_t GetSupportedSuites(BMessage *msg); + BHandler* ResolveSpecifier(BMessage *msg, int32 index, + BMessage *specifier, int32 form, + const char *property); - private: - void InitWindow(); - void SetupMenu(); - status_t DoPageSetup(); - void DoPrint(); +private: + void InitWindow(); + void SetupMenu(); + status_t DoPageSetup(); + void DoPrint(); - /* - * data member - */ - Shell *fShell; - TermParse *fTermParse; - BMenuBar *fMenubar; - BMenu *fFilemenu, *fEditmenu, *fEncodingmenu, *fHelpmenu, *fFontMenu, *fWindowSizeMenu, *fNewFontMenu; - TermView *fTermView; - BView *fBaseView; - CodeConv *fCodeConv; - BMessage *fPrintSettings; - PrefWindow *fPrefWindow; - FindWindow *fFindPanel; - BMessageRunner *fWindowUpdate; - - BRect fSavedFrame; - window_look fSavedLook; - //Saved search parameters - BString fFindString; - BMenuItem *fFindForwardMenuItem; - BMenuItem *fFindBackwardMenuItem; - bool fFindSelection; - bool fForwardSearch; - bool fMatchCase; - bool fMatchWord; + Shell *fShell; + TermParse *fTermParse; + BMenuBar *fMenubar; + BMenu *fFilemenu, + *fEditmenu, + *fEncodingmenu, + *fHelpmenu, + *fFontMenu, + *fWindowSizeMenu, + *fNewFontMenu; + TermView *fTermView; + BView *fBaseView; + CodeConv *fCodeConv; + BMessage *fPrintSettings; + PrefWindow *fPrefWindow; + FindWindow *fFindPanel; + BMessageRunner *fWindowUpdate; + BRect fSavedFrame; + window_look fSavedLook; + + //Saved search parameters + BString fFindString; + BMenuItem *fFindForwardMenuItem; + BMenuItem *fFindBackwardMenuItem; + bool fFindSelection; + bool fForwardSearch; + bool fMatchCase; + bool fMatchWord; }; -#endif // TERMWIN_H +#endif // __TERMWINDOW_H From jackburton at mail.berlios.de Sat Jul 21 21:22:54 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sat, 21 Jul 2007 21:22:54 +0200 Subject: [Haiku-commits] r21678 - haiku/trunk/src/apps/terminal Message-ID: <200707211922.l6LJMsID017159@sheep.berlios.de> Author: jackburton Date: 2007-07-21 21:22:53 +0200 (Sat, 21 Jul 2007) New Revision: 21678 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21678&view=rev Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp Log: Sorry, the previous commit also contained broken WIP stuff. Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-21 19:11:41 UTC (rev 21677) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-21 19:22:53 UTC (rev 21678) @@ -171,7 +171,7 @@ * TermView is character Terminal view on BaseView. It has paste * on BaseView shift as VIEW_OFFSET. */ - //fBaseView = new TermBaseView(textframe, fTermView); + fBaseView = new TermBaseView(textframe, fTermView); // Initialize TermView. (font, size and color) @@ -186,7 +186,7 @@ MIN_COLS * height, MAX_COLS * height); fTermView->SetTermColor(); - //fBaseView->SetViewColor(PrefHandler::Default()->getRGB(PREF_TEXT_BACK_COLOR)); + fBaseView->SetViewColor(PrefHandler::Default()->getRGB(PREF_TEXT_BACK_COLOR)); // Add offset to baseview. rect.InsetBy(-VIEW_OFFSET, -VIEW_OFFSET); @@ -196,9 +196,9 @@ ResizeTo(rect.Width()+ B_V_SCROLL_BAR_WIDTH, rect.Height() + fMenubar->Bounds().Height()); - //fBaseView->ResizeTo(rect.Width(), rect.Height()); - //fBaseView->AddChild(fTermView); - //fTermView->MoveBy(VIEW_OFFSET, VIEW_OFFSET); + fBaseView->ResizeTo(rect.Width(), rect.Height()); + fBaseView->AddChild(fTermView); + fTermView->MoveBy(VIEW_OFFSET, VIEW_OFFSET); // Make Scroll Bar. @@ -212,9 +212,8 @@ fTermView->SetScrollBar(scrollBar); AddChild(scrollBar); - //AddChild(fBaseView); - AddChild(fTermView); - + AddChild(fBaseView); + // Set fEditmenu's target to fTermView. (Oh!...) fEditmenu->SetTargetForItems(fTermView); @@ -554,8 +553,8 @@ BScreen screen(this); fTermView->ScrollBar()->Hide(); fMenubar->Hide(); - fTermView->MoveTo(0,0); - fTermView->ResizeBy(B_V_SCROLL_BAR_WIDTH, mbHeight); + fBaseView->MoveTo(0,0); + fBaseView->ResizeBy(B_V_SCROLL_BAR_WIDTH, mbHeight); fSavedLook = Look(); // done before ResizeTo to work around a Dano bug (not erasing the decor) SetLook(B_NO_BORDER_WINDOW_LOOK); @@ -567,8 +566,8 @@ fTermView->ScrollBar()->Show(); ResizeTo(fSavedFrame.Width(), fSavedFrame.Height()); MoveTo(fSavedFrame.left, fSavedFrame.top); - fTermView->ResizeBy(-B_V_SCROLL_BAR_WIDTH, -mbHeight); - fTermView->MoveTo(0,mbHeight); + fBaseView->ResizeBy(-B_V_SCROLL_BAR_WIDTH, -mbHeight); + fBaseView->MoveTo(0,mbHeight); SetLook(fSavedLook); fSavedFrame = BRect(0,0,-1,-1); } @@ -580,9 +579,9 @@ break; } case MSG_COLOR_CHANGED: { - //fBaseView->SetViewColor (PrefHandler::Default()->getRGB (PREF_TEXT_BACK_COLOR)); + fBaseView->SetViewColor (PrefHandler::Default()->getRGB (PREF_TEXT_BACK_COLOR)); fTermView->SetTermColor(); - //fBaseView->Invalidate(); + fBaseView->Invalidate(); fTermView->Invalidate(); break; } From jackburton at mail.berlios.de Sat Jul 21 21:56:56 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sat, 21 Jul 2007 21:56:56 +0200 Subject: [Haiku-commits] r21679 - haiku/trunk/src/apps/terminal Message-ID: <200707211956.l6LJuuVX018550@sheep.berlios.de> Author: jackburton Date: 2007-07-21 21:56:55 +0200 (Sat, 21 Jul 2007) New Revision: 21679 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21679&view=rev Removed: haiku/trunk/src/apps/terminal/TermBaseView.cpp haiku/trunk/src/apps/terminal/TermBaseView.h Modified: haiku/trunk/src/apps/terminal/Jamfile haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermWindow.cpp haiku/trunk/src/apps/terminal/TermWindow.h Log: Got rid of TermBaseView Modified: haiku/trunk/src/apps/terminal/Jamfile =================================================================== --- haiku/trunk/src/apps/terminal/Jamfile 2007-07-21 19:22:53 UTC (rev 21678) +++ haiku/trunk/src/apps/terminal/Jamfile 2007-07-21 19:56:55 UTC (rev 21679) @@ -17,7 +17,6 @@ PrefWindow.cpp Shell.cpp TermApp.cpp - TermBaseView.cpp TermBuffer.cpp TermParse.cpp TermView.cpp Deleted: haiku/trunk/src/apps/terminal/TermBaseView.cpp Deleted: haiku/trunk/src/apps/terminal/TermBaseView.h Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-21 19:22:53 UTC (rev 21678) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-21 19:56:55 UTC (rev 21679) @@ -62,7 +62,7 @@ TermView::TermView(BRect frame, CodeConv *inCodeConv) - : BView(frame, "termview", B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS), + : BView(frame, "termview", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS), fShell(NULL), fFontWidth(0), fFontHeight(0), Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-21 19:22:53 UTC (rev 21678) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-21 19:56:55 UTC (rev 21679) @@ -34,7 +34,6 @@ #include "PrefWindow.h" #include "PrefView.h" #include "PrefHandler.h" -#include "TermBaseView.h" #include "TermBuffer.h" #include "TermParse.h" #include "TermView.h" @@ -65,7 +64,6 @@ fWindowSizeMenu(NULL), fNewFontMenu(NULL), fTermView(NULL), - fBaseView(NULL), fCodeConv(NULL), fPrintSettings(NULL), fPrefWindow(NULL), @@ -162,17 +160,10 @@ textframe.top = fMenubar->Bounds().bottom + 1.0; fCodeConv = new CodeConv(); - fTermView = new TermView(Bounds(), fCodeConv); + fTermView = new TermView(textframe, fCodeConv); fTermView->AttachShell(fShell); - /* - * MuTerm has two views. BaseView is window base view. - * TermView is character Terminal view on BaseView. It has paste - * on BaseView shift as VIEW_OFFSET. - */ - fBaseView = new TermBaseView(textframe, fTermView); - // Initialize TermView. (font, size and color) fTermView->SetTermFont(&halfFont, &fullFont); @@ -186,20 +177,16 @@ MIN_COLS * height, MAX_COLS * height); fTermView->SetTermColor(); - fBaseView->SetViewColor(PrefHandler::Default()->getRGB(PREF_TEXT_BACK_COLOR)); - + // Add offset to baseview. rect.InsetBy(-VIEW_OFFSET, -VIEW_OFFSET); // Resize Window - ResizeTo(rect.Width()+ B_V_SCROLL_BAR_WIDTH, rect.Height() + fMenubar->Bounds().Height()); - fBaseView->ResizeTo(rect.Width(), rect.Height()); - fBaseView->AddChild(fTermView); - fTermView->MoveBy(VIEW_OFFSET, VIEW_OFFSET); - + fTermView->ResizeTo(rect.Width(), rect.Height()); + // Make Scroll Bar. BRect scrollRect(0, 0, B_V_SCROLL_BAR_WIDTH, @@ -212,9 +199,8 @@ fTermView->SetScrollBar(scrollBar); AddChild(scrollBar); - AddChild(fBaseView); - - // Set fEditmenu's target to fTermView. (Oh!...) + AddChild(fTermView); + fEditmenu->SetTargetForItems(fTermView); // Initialize TermParse @@ -553,8 +539,8 @@ BScreen screen(this); fTermView->ScrollBar()->Hide(); fMenubar->Hide(); - fBaseView->MoveTo(0,0); - fBaseView->ResizeBy(B_V_SCROLL_BAR_WIDTH, mbHeight); + //fTermView->MoveTo(0,0); + fTermView->ResizeBy(B_V_SCROLL_BAR_WIDTH, mbHeight); fSavedLook = Look(); // done before ResizeTo to work around a Dano bug (not erasing the decor) SetLook(B_NO_BORDER_WINDOW_LOOK); @@ -566,8 +552,8 @@ fTermView->ScrollBar()->Show(); ResizeTo(fSavedFrame.Width(), fSavedFrame.Height()); MoveTo(fSavedFrame.left, fSavedFrame.top); - fBaseView->ResizeBy(-B_V_SCROLL_BAR_WIDTH, -mbHeight); - fBaseView->MoveTo(0,mbHeight); + fTermView->ResizeBy(-B_V_SCROLL_BAR_WIDTH, -mbHeight); + //fTermView->MoveTo(0,mbHeight); SetLook(fSavedLook); fSavedFrame = BRect(0,0,-1,-1); } @@ -579,9 +565,7 @@ break; } case MSG_COLOR_CHANGED: { - fBaseView->SetViewColor (PrefHandler::Default()->getRGB (PREF_TEXT_BACK_COLOR)); fTermView->SetTermColor(); - fBaseView->Invalidate(); fTermView->Invalidate(); break; } Modified: haiku/trunk/src/apps/terminal/TermWindow.h =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-21 19:22:53 UTC (rev 21678) +++ haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-21 19:56:55 UTC (rev 21679) @@ -79,7 +79,6 @@ *fWindowSizeMenu, *fNewFontMenu; TermView *fTermView; - BView *fBaseView; CodeConv *fCodeConv; BMessage *fPrintSettings; PrefWindow *fPrefWindow; From jackburton at mail.berlios.de Sat Jul 21 22:50:08 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sat, 21 Jul 2007 22:50:08 +0200 Subject: [Haiku-commits] r21680 - haiku/trunk/src/apps/terminal Message-ID: <200707212050.l6LKo86a021234@sheep.berlios.de> Author: jackburton Date: 2007-07-21 22:50:06 +0200 (Sat, 21 Jul 2007) New Revision: 21680 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21680&view=rev Modified: haiku/trunk/src/apps/terminal/CodeConv.cpp haiku/trunk/src/apps/terminal/CodeConv.h haiku/trunk/src/apps/terminal/Shell.cpp haiku/trunk/src/apps/terminal/Shell.h haiku/trunk/src/apps/terminal/TermParse.cpp haiku/trunk/src/apps/terminal/TermParse.h haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h haiku/trunk/src/apps/terminal/TermWindow.cpp haiku/trunk/src/apps/terminal/TermWindow.h Log: Made all CodeConv methods static, since there was no point for them to be nonstatic. Moved TermParse under Shell, Removed some parameters passing around from TermWindow/TermView/TermParse. Now TermParse threads are started when the shell is attached to a TermView. Might still be improved. Modified: haiku/trunk/src/apps/terminal/CodeConv.cpp =================================================================== --- haiku/trunk/src/apps/terminal/CodeConv.cpp 2007-07-21 19:56:55 UTC (rev 21679) +++ haiku/trunk/src/apps/terminal/CodeConv.cpp 2007-07-21 20:50:06 UTC (rev 21680) @@ -33,17 +33,8 @@ extern char gUTF8WidthTable[]; // defined in UTF8WidthTbl.c -CodeConv::CodeConv() -{ -} - - -CodeConv::~CodeConv() -{ -} - - //! get font width in coding. +/* static */ int32 CodeConv::UTF8GetFontWidth(const char *string) { @@ -61,6 +52,7 @@ //! Convert internal coding from src coding. +/* static */ int32 CodeConv::ConvertFromInternal(const char *src, int32 srclen, char *dst, int coding) { @@ -92,6 +84,7 @@ //! Convert internal coding to src coding. +/* static */ int32 CodeConv::ConvertToInternal(const char *src, int32 srclen, char *dst, int coding) { @@ -131,6 +124,7 @@ } +/* static */ unsigned short CodeConv::UTF8toUnicode(const char *utf8) { @@ -157,6 +151,7 @@ } +/* static */ void CodeConv::euc_to_sjis(uchar *buf) { Modified: haiku/trunk/src/apps/terminal/CodeConv.h =================================================================== --- haiku/trunk/src/apps/terminal/CodeConv.h 2007-07-21 19:56:55 UTC (rev 21679) +++ haiku/trunk/src/apps/terminal/CodeConv.h 2007-07-21 20:50:06 UTC (rev 21680) @@ -13,23 +13,17 @@ class CodeConv { public: - CodeConv(); - ~CodeConv(); + static int32 UTF8GetFontWidth(const char *string); - int32 UTF8GetFontWidth(const char *string); - /* internal(UTF8) -> coding */ - int32 ConvertFromInternal(const char *src, int32 bytes, char *dst, int coding); + static int32 ConvertFromInternal(const char *src, int32 bytes, char *dst, int coding); /* coding -> internal(UTF8) */ - int32 ConvertToInternal(const char *src, int32 bytes, char *dst, int coding); + static int32 ConvertToInternal(const char *src, int32 bytes, char *dst, int coding); private: - void euc_to_sjis(uchar *buf); - - unsigned short UTF8toUnicode(const char *utf8); - - int fNowCoding; + static void euc_to_sjis(uchar *buf); + static unsigned short UTF8toUnicode(const char *utf8); }; #endif /* CODECONV_H */ Modified: haiku/trunk/src/apps/terminal/Shell.cpp =================================================================== --- haiku/trunk/src/apps/terminal/Shell.cpp 2007-07-21 19:56:55 UTC (rev 21679) +++ haiku/trunk/src/apps/terminal/Shell.cpp 2007-07-21 20:50:06 UTC (rev 21680) @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,8 @@ #include #include "TermConst.h" +#include "TermParse.h" +#include "TermView.h" #include "Shell.h" #include "PrefHandler.h" @@ -108,7 +111,10 @@ Shell::Shell() - :fFd(-1) + : + fFd(-1), + fTermParse(NULL), + fAttached(false) { } @@ -125,13 +131,25 @@ if (fFd >= 0) return B_ERROR; - return _Spawn(row, col, command, coding); + status_t status = _Spawn(row, col, command, coding); + if (status < B_OK) + return status; + + fTermParse = new (std::nothrow) TermParse(fFd); + if (fTermParse == NULL) { + Close(); + return B_NO_MEMORY; + } + + return B_OK; } void Shell::Close() { + delete fTermParse; + if (fFd >= 0) { close(fFd); kill(-sShPid, SIGHUP); @@ -208,6 +226,30 @@ } +void +Shell::ViewAttached(TermView *view) +{ + if (fAttached) + return; + + status_t status = fTermParse->StartThreads(view); + if (status < B_OK) { + // TODO: What can we do here ? + fprintf(stderr, "Shell:ViewAttached():" + " cannot start parser threads: %s", + strerror(status)); + } +} + + +void +Shell::ViewDetached() +{ + if (fAttached) + fTermParse->StopThreads(); +} + + // private static status_t send_handshake_message(thread_id target, const handshake_t& handshake) Modified: haiku/trunk/src/apps/terminal/Shell.h =================================================================== --- haiku/trunk/src/apps/terminal/Shell.h 2007-07-21 19:56:55 UTC (rev 21679) +++ haiku/trunk/src/apps/terminal/Shell.h 2007-07-21 20:50:06 UTC (rev 21680) @@ -81,10 +81,13 @@ #define RDEL 0xFF +// TODO: Maybe merge TermParse and Shell classes ? +class TermParse; +class TermView; class Shell { public: Shell(); - ~Shell(); + virtual ~Shell(); status_t Open(int row, int col, const char *command, const char *coding); void Close(); @@ -101,9 +104,14 @@ status_t SetAttr(struct termios &attr); int FD() const; + + virtual void ViewAttached(TermView *view); + virtual void ViewDetached(); private: - int fFd; + int fFd; + TermParse *fTermParse; + bool fAttached; status_t _Spawn(int row, int col, const char *command, const char *coding); }; Modified: haiku/trunk/src/apps/terminal/TermParse.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-21 19:56:55 UTC (rev 21679) +++ haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-21 20:50:06 UTC (rev 21680) @@ -47,11 +47,10 @@ #define NPARAM 10 // Max parameters -TermParse::TermParse(int fd, TermView *inViewObj, CodeConv *inConvObj) +TermParse::TermParse(int fd) : fFd(fd), - fViewObj(inViewObj), - fConvObj(inConvObj), + fViewObj(NULL), fParseThread(-1), fParseSem(-1), fReaderThread(-1), @@ -67,23 +66,15 @@ TermParse::~TermParse() { - fQuitting = true; - - delete_sem(fReaderSem); - delete_sem(fReaderLocker); - - //suspend_thread(fReaderThread); - // TODO: interrupt read() - doesn't work for whatever reason - - status_t dummy; - wait_for_thread(fReaderThread, &dummy); - wait_for_thread(fParseThread, &dummy); + StopThreads(); } status_t -TermParse::StartThreads() +TermParse::StartThreads(TermView *view) { + fViewObj = view; + status_t status = InitPtyReader(); if (status < B_OK) @@ -99,6 +90,27 @@ } +status_t +TermParse::StopThreads() +{ + fQuitting = true; + + delete_sem(fReaderSem); + delete_sem(fReaderLocker); + + //suspend_thread(fReaderThread); + // TODO: interrupt read() - doesn't work for whatever reason + + status_t dummy; + wait_for_thread(fReaderThread, &dummy); + wait_for_thread(fParseThread, &dummy); + + fViewObj = NULL; + + return B_OK; +} + + //! Get data from pty device. int32 TermParse::PtyReader() @@ -241,10 +253,7 @@ int top, bot; int cs96; uchar curess = 0; - - TermView *viewObj = fViewObj; - CodeConv *convObj = fConvObj; - + uchar cbuf[4], dstbuf[4]; uchar *ptr; @@ -305,7 +314,7 @@ cbuf[0] = c; cbuf[1] = '\0'; width = HALF_WIDTH; - viewObj->PutChar(cbuf, attr, width); + fViewObj->PutChar(cbuf, attr, width); break; case CASE_PRINT_GR: @@ -346,11 +355,11 @@ } if (now_coding != M_ISO_2022_JP) - convObj->ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, now_coding); + CodeConv::ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, now_coding); else - convObj->ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, M_EUC_JP); + CodeConv::ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, M_EUC_JP); - viewObj->PutChar(dstbuf, attr, width); + fViewObj->PutChar(dstbuf, attr, width); break; case CASE_PRINT_CS96: @@ -359,33 +368,33 @@ cbuf[1] |= 0x80; cbuf[2] = 0; width = 2; - convObj->ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, M_EUC_JP); - viewObj->PutChar(dstbuf, attr, width); + CodeConv::ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, M_EUC_JP); + fViewObj->PutChar(dstbuf, attr, width); break; case CASE_LF: - viewObj->PutLF(); + fViewObj->PutLF(); break; case CASE_CR: - viewObj->PutCR(); + fViewObj->PutCR(); break; case CASE_SJIS_KANA: cbuf[0] = (uchar)c; cbuf[1] = '\0'; - convObj->ConvertToInternal((char*)cbuf, 1, (char*)dstbuf, now_coding); + CodeConv::ConvertToInternal((char*)cbuf, 1, (char*)dstbuf, now_coding); width = 1; - viewObj->PutChar(dstbuf, attr, width); + fViewObj->PutChar(dstbuf, attr, width); break; case CASE_SJIS_INSTRING: cbuf[0] = (uchar)c; GetReaderBuf(cbuf[1]); cbuf[2] = '\0'; - convObj->ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, now_coding); + CodeConv::ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, now_coding); width = 2; - viewObj->PutChar(dstbuf, attr, width); + fViewObj->PutChar(dstbuf, attr, width); break; case CASE_UTF8_2BYTE: @@ -395,8 +404,8 @@ break; cbuf[1] = (uchar)c; cbuf[2] = '\0'; - width = convObj->UTF8GetFontWidth((char*)cbuf); - viewObj->PutChar(cbuf, attr, width); + width = CodeConv::UTF8GetFontWidth((char*)cbuf); + fViewObj->PutChar(cbuf, attr, width); break; case CASE_UTF8_3BYTE: @@ -411,8 +420,8 @@ break; cbuf[2] = c; cbuf[3] = '\0'; - width = convObj->UTF8GetFontWidth((char*)cbuf); - viewObj->PutChar (cbuf, attr, width); + width = CodeConv::UTF8GetFontWidth((char*)cbuf); + fViewObj->PutChar (cbuf, attr, width); break; case CASE_MBCS: @@ -444,13 +453,13 @@ break; case CASE_BS: - viewObj->MoveCurLeft(1); + fViewObj->MoveCurLeft(1); break; case CASE_TAB: - tmp = viewObj->GetCurX(); + tmp = fViewObj->GetCurX(); tmp %= 8; - viewObj->MoveCurRight(8 - tmp); + fViewObj->MoveCurRight(8 - tmp); break; case CASE_ESC: @@ -510,7 +519,7 @@ /* ICH */ if ((row = param[0]) < 1) row = 1; - viewObj->InsertSpace(row); + fViewObj->InsertSpace(row); parsestate = groundtable; break; @@ -518,7 +527,7 @@ /* CUU */ if ((row = param[0]) < 1) row = 1; - viewObj->MoveCurUp(row); + fViewObj->MoveCurUp(row); parsestate = groundtable; break; @@ -526,7 +535,7 @@ /* CUD */ if ((row = param[0]) < 1) row = 1; - viewObj->MoveCurDown(row); + fViewObj->MoveCurDown(row); parsestate = groundtable; break; @@ -534,7 +543,7 @@ /* CUF */ if ((row = param[0]) < 1) row = 1; - viewObj->MoveCurRight(row); + fViewObj->MoveCurRight(row); parsestate = groundtable; break; @@ -542,7 +551,7 @@ /* CUB */ if ((row = param[0]) < 1) row = 1; - viewObj->MoveCurLeft(row); + fViewObj->MoveCurLeft(row); parsestate = groundtable; break; @@ -553,7 +562,7 @@ if (nparam < 2 || (col = param[1]) < 1) col = 1; - viewObj->SetCurPos(col - 1, row - 1 ); + fViewObj->SetCurPos(col - 1, row - 1 ); parsestate = groundtable; break; @@ -562,15 +571,15 @@ switch (param[0]) { case DEFAULT: case 0: - viewObj->EraseBelow(); + fViewObj->EraseBelow(); break; case 1: break; case 2: - viewObj->SetCurPos(0, 0); - viewObj->EraseBelow(); + fViewObj->SetCurPos(0, 0); + fViewObj->EraseBelow(); break; } parsestate = groundtable; @@ -578,7 +587,7 @@ case CASE_EL: // delete line /* EL */ - viewObj->DeleteColumns(); + fViewObj->DeleteColumns(); parsestate = groundtable; break; @@ -586,7 +595,7 @@ /* IL */ if ((row = param[0]) < 1) row = 1; - viewObj->PutNL(row); + fViewObj->PutNL(row); parsestate = groundtable; break; @@ -594,7 +603,7 @@ /* DL */ if ((row = param[0]) < 1) row = 1; - viewObj->DeleteLine(row); + fViewObj->DeleteLine(row); parsestate = groundtable; break; @@ -602,19 +611,19 @@ /* DCH */ if ((row = param[0]) < 1) row = 1; - viewObj->DeleteChar(row); + fViewObj->DeleteChar(row); parsestate = groundtable; break; case CASE_SET: /* SET */ - viewObj->SetInsertMode(MODE_INSERT); + fViewObj->SetInsertMode(MODE_INSERT); parsestate = groundtable; break; case CASE_RST: /* RST */ - viewObj->SetInsertMode(MODE_OVER); + fViewObj->SetInsertMode(MODE_OVER); parsestate = groundtable; break; @@ -681,7 +690,7 @@ case CASE_CPR: // Q & D hack by Y.Hayakawa (hida at sawada.riec.tohoku.ac.jp) // 21-JUL-99 - viewObj->DeviceStatusReport(param[0]); + fViewObj->DeviceStatusReport(param[0]); parsestate = groundtable; break; @@ -700,7 +709,7 @@ bot--; if (bot > top) - viewObj->SetScrollRegion(top, bot); + fViewObj->SetScrollRegion(top, bot); parsestate = groundtable; break; @@ -737,13 +746,13 @@ case CASE_DECSC: /* DECSC */ - viewObj->SaveCursor(); + fViewObj->SaveCursor(); parsestate = groundtable; break; case CASE_DECRC: /* DECRC */ - viewObj->RestoreCursor(); + fViewObj->RestoreCursor(); parsestate = groundtable; break; @@ -755,7 +764,7 @@ case CASE_RI: /* RI */ - viewObj->ScrollRegion(-1, -1, SCRDOWN, 1); + fViewObj->ScrollRegion(-1, -1, SCRDOWN, 1); parsestate = groundtable; break; Modified: haiku/trunk/src/apps/terminal/TermParse.h =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.h 2007-07-21 19:56:55 UTC (rev 21679) +++ haiku/trunk/src/apps/terminal/TermParse.h 2007-07-21 20:50:06 UTC (rev 21680) @@ -34,21 +34,20 @@ #include "TermConst.h" #include +#include #include - -class TermView; -class CodeConv; - //PtyReader buffer size. #define READ_BUF_SIZE 2048 +class TermView; class TermParse : public BHandler { public: - TermParse(int fd, TermView *inViewObj, CodeConv *inConvObj); + TermParse(int fd); ~TermParse(); - status_t StartThreads(); + status_t StartThreads(TermView *view); + status_t StopThreads(); private: // Initialize TermParse and PtyReader thread. @@ -71,7 +70,6 @@ int fFd; TermView *fViewObj; - CodeConv *fConvObj; thread_id fParseThread; sem_id fParseSem; Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-21 19:56:55 UTC (rev 21679) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-21 20:50:06 UTC (rev 21680) @@ -61,7 +61,7 @@ }; -TermView::TermView(BRect frame, CodeConv *inCodeConv) +TermView::TermView(BRect frame) : BView(frame, "termview", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS), fShell(NULL), fFontWidth(0), @@ -85,7 +85,6 @@ fTermColumns(PrefHandler::Default()->getInt32(PREF_COLS)), fTop(0), fTextBuffer(new (nothrow) TermBuffer(fTermRows, fTermColumns)), - fCodeConv(inCodeConv), fScrollBar(NULL), fScrTop(0), fScrBot(fTermRows - 1), @@ -127,7 +126,8 @@ return B_BAD_VALUE; fShell = shell; - + fShell->ViewAttached(this); + return B_OK; } @@ -135,6 +135,7 @@ void TermView::DetachShell() { + fShell->ViewDetached(); fShell = NULL; } @@ -1352,7 +1353,7 @@ // input multibyte character if (GetEncoding() != M_UTF8) { - int cnum = fCodeConv->ConvertFromInternal(bytes, numBytes, + int cnum = CodeConv::ConvertFromInternal(bytes, numBytes, (char *)dstbuf, GetEncoding()); fShell->Write(dstbuf, cnum); return; @@ -1600,7 +1601,7 @@ { if (GetEncoding() != M_UTF8) { uchar *destBuffer = (uchar *)malloc(numBytes * 3); - numBytes = fCodeConv->ConvertFromInternal((char*)text, numBytes, + numBytes = CodeConv::ConvertFromInternal((char*)text, numBytes, (char*)destBuffer, GetEncoding()); fShell->Write(destBuffer, numBytes); free(destBuffer); Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2007-07-21 19:56:55 UTC (rev 21679) +++ haiku/trunk/src/apps/terminal/TermView.h 2007-07-21 20:50:06 UTC (rev 21680) @@ -90,7 +90,6 @@ }; class TermBuffer; -class CodeConv; class BPopUpMenu; class BScrollBar; class BString; @@ -98,7 +97,7 @@ class TermView : public BView { public: - TermView(BRect frame, CodeConv *inCodeConv); + TermView(BRect frame); ~TermView(); status_t AttachShell(Shell *shell); @@ -282,7 +281,6 @@ // Object pointer. TermBuffer *fTextBuffer; - CodeConv *fCodeConv; BScrollBar *fScrollBar; // Offscreen Bitmap and View. Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-21 19:56:55 UTC (rev 21679) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-21 20:50:06 UTC (rev 21680) @@ -27,7 +27,7 @@ #include #include -#include "CodeConv.h" +#include "Coding.h" #include "ColorWindow.h" #include "MenuUtil.h" #include "FindWindow.h" @@ -54,7 +54,6 @@ TermWindow::TermWindow(BRect frame, const char* title, const char *command) : BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE), fShell(NULL), - fTermParse(NULL), fMenubar(NULL), fFilemenu(NULL), fEditmenu(NULL), @@ -64,7 +63,6 @@ fWindowSizeMenu(NULL), fNewFontMenu(NULL), fTermView(NULL), - fCodeConv(NULL), fPrintSettings(NULL), fPrefWindow(NULL), fFindPanel(NULL), @@ -106,8 +104,6 @@ fTermView->DetachShell(); delete fShell; - delete fTermParse; - delete fCodeConv; if (fPrefWindow) fPrefWindow->PostMessage(B_QUIT_REQUESTED); @@ -159,13 +155,11 @@ BRect textframe = Bounds(); textframe.top = fMenubar->Bounds().bottom + 1.0; - fCodeConv = new CodeConv(); - fTermView = new TermView(textframe, fCodeConv); + fTermView = new TermView(textframe); fTermView->AttachShell(fShell); // Initialize TermView. (font, size and color) - fTermView->SetTermFont(&halfFont, &fullFont); BRect rect = fTermView->SetTermSize(PrefHandler::Default()->getInt32(PREF_ROWS), @@ -205,9 +199,6 @@ // Initialize TermParse SetEncoding(longname2id(PrefHandler::Default()->getString(PREF_TEXT_ENCODING))); - fTermParse = new TermParse(fShell->FD(), fTermView, fCodeConv); - if (fTermParse->StartThreads() < B_OK) - return; // Initialize MessageRunner. fWindowUpdate = new BMessageRunner(BMessenger(this), Modified: haiku/trunk/src/apps/terminal/TermWindow.h =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-21 19:56:55 UTC (rev 21679) +++ haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-21 20:50:06 UTC (rev 21680) @@ -37,7 +37,6 @@ class BMenu; class BMenuBar; class BMessageRunner; -class CodeConv; class FindWindow; class PrefWindow; class Shell; @@ -79,7 +78,6 @@ *fWindowSizeMenu, *fNewFontMenu; TermView *fTermView; - CodeConv *fCodeConv; BMessage *fPrintSettings; PrefWindow *fPrefWindow; FindWindow *fFindPanel; From niels.reedijk at gmail.com Sun Jul 22 11:55:33 2007 From: niels.reedijk at gmail.com (Niels Reedijk) Date: Sun, 22 Jul 2007 11:55:33 +0200 Subject: [Haiku-commits] r21615 - haiku/trunk/docs/user/drivers In-Reply-To: <44348972380-BeMail@zon> References: <507d86c0707151402h51d4c11dy36771104db23a172@mail.gmail.com> <44348972380-BeMail@zon> Message-ID: <507d86c0707220255i6ea3e430ub0b37401bd51bb25@mail.gmail.com> Hi Axel, 2007/7/15, Axel D?rfler : > "Niels Reedijk" wrote: > > 2007/7/15, Axel D?rfler : > > > "Niels Reedijk" wrote: > > > I wonder why it shouldn't be possible to have one style guide > > > project > > > wide. > > > There is no reason to rule out your own when there is one > > > available. > > I agree, however, I was/am not familiar with the style guide, and > > since we are dealing with documentation (and not code) it does not > > seem necessary to immediately change it, especially since it would > > That's a simple thing to change: > http://haiku-os.org/documents/dev/haiku_coding_guidelines The name of the document says it all. They are coding guidelines, not documentation guidelines. I do like consistency, but just not for the sake of it. Now the point is that I do like tabs, and if no one objects to the change on the haiku-doc list, I will gladly update the API Documentation Guidelines: http://factory.haiku-os.org/documentation/Haiku_Book_doxygen/html/apidoc.html Niels From jackburton at mail.berlios.de Sun Jul 22 15:26:17 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sun, 22 Jul 2007 15:26:17 +0200 Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal Message-ID: <200707221326.l6MDQH9D021200@sheep.berlios.de> Author: jackburton Date: 2007-07-22 15:26:17 +0200 (Sun, 22 Jul 2007) New Revision: 21681 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21681&view=rev Modified: haiku/trunk/src/apps/terminal/CodeConv.cpp haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h haiku/trunk/src/apps/terminal/TermWindow.cpp haiku/trunk/src/apps/terminal/TermWindow.h Log: Fixed a bug where Terminal couldn't set itself to fullscreen the first time. Some minor cleanups. Modified: haiku/trunk/src/apps/terminal/CodeConv.cpp =================================================================== --- haiku/trunk/src/apps/terminal/CodeConv.cpp 2007-07-21 20:50:06 UTC (rev 21680) +++ haiku/trunk/src/apps/terminal/CodeConv.cpp 2007-07-22 13:26:17 UTC (rev 21681) @@ -38,15 +38,12 @@ int32 CodeConv::UTF8GetFontWidth(const char *string) { - uchar width, point; - ushort unicode, offset; + ushort unicode = UTF8toUnicode(string); + uchar width = gUTF8WidthTable[unicode >> 3]; + ushort offset = unicode & 0x07; - offset = unicode = UTF8toUnicode(string); - width = gUTF8WidthTable[unicode >> 3]; - offset = offset & 0x07; + uchar point = 0x80 >> offset; - point = 0x80 >> offset; - return (width & point) > 0 ? 2 : 1; } @@ -72,6 +69,9 @@ convert_from_utf8(theCoding, (char *)src, &srclen, (char *)dst, &dstlen, &state, '?'); + // TODO: Apart from this particular case, looks like we could use the + // system api for code conversion... check if this (which looks a lot like a workaround) + // applies to haiku, and if not, get rid of this class and just use the system api directly. if (coding == M_ISO_2022_JP && state != 0) { const char *end_of_jis = "(B"; strncpy((char *)dst + dstlen, end_of_jis, 3); Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-21 20:50:06 UTC (rev 21680) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-22 13:26:17 UTC (rev 21681) @@ -61,7 +61,7 @@ }; -TermView::TermView(BRect frame) +TermView::TermView(BRect frame, const char *command) : BView(frame, "termview", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS), fShell(NULL), fFontWidth(0), @@ -107,13 +107,28 @@ SetTermFont(be_plain_font, be_plain_font); //SetIMAware(PrefHandler::Default()->getInt32(PREF_IM_AWARE)); + // Get encoding name (setenv TTYPE in spawn_shell functions) + const char *encoding = longname2shortname(PrefHandler::Default()->getString(PREF_TEXT_ENCODING)); + fShell = new Shell(); + status_t status = fShell->Open(fTermRows, fTermColumns, command, encoding); + if (status < B_OK) + throw status; + + status = AttachShell(fShell); + if (status < B_OK) + throw status; + _InitMouseThread(); } TermView::~TermView() { + DetachShell(); + delete fTextBuffer; + delete fShell; + fQuitting = true; kill_thread(fMouseThread); } @@ -140,6 +155,16 @@ } +const char * +TermView::TerminalName() const +{ + if (fShell == NULL) + return NULL; + + return fShell->TTYName(); +} + + //! Get width and height for terminal font void TermView::GetFontSize(int* _width, int* _height) @@ -1030,7 +1055,7 @@ fShell->UpdateWindowSize(fTermRows, fTermColumns); - fFrameResized = 0; + fFrameResized = false; if (fScrRegionSet == 0) fScrBot = fTermRows - 1; } @@ -1381,7 +1406,7 @@ fTermRows = rows; fTermColumns = cols; - fFrameResized = 1; + fFrameResized = true; } Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2007-07-21 20:50:06 UTC (rev 21680) +++ haiku/trunk/src/apps/terminal/TermView.h 2007-07-22 13:26:17 UTC (rev 21681) @@ -89,20 +89,22 @@ 0x00, 0x10, }; -class TermBuffer; + class BPopUpMenu; class BScrollBar; class BString; class Shell; - +class TermBuffer; class TermView : public BView { public: - TermView(BRect frame); + TermView(BRect frame, const char *command); ~TermView(); status_t AttachShell(Shell *shell); void DetachShell(); + const char *TerminalName() const; + void SetTermFont(const BFont *halfFont, const BFont *fullFont); void GetFontSize(int *width, int *height); BRect SetTermSize(int rows, int cols, bool flag); Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-21 20:50:06 UTC (rev 21680) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-22 13:26:17 UTC (rev 21681) @@ -39,7 +39,6 @@ #include "TermView.h" #include "TermWindow.h" #include "TermConst.h" -#include "Shell.h" // @@ -53,7 +52,6 @@ TermWindow::TermWindow(BRect frame, const char* title, const char *command) : BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE), - fShell(NULL), fMenubar(NULL), fFilemenu(NULL), fEditmenu(NULL), @@ -67,7 +65,7 @@ fPrefWindow(NULL), fFindPanel(NULL), fWindowUpdate(NULL), - fSavedFrame(0, 0, 0, 0), + fSavedFrame(0, 0, -1, -1), fFindString(""), fFindForwardMenuItem(NULL), fFindBackwardMenuItem(NULL), @@ -76,34 +74,12 @@ fMatchCase(false), fMatchWord(false) { - int rows = PrefHandler::Default()->getInt32(PREF_ROWS); - if (rows < 1) { - rows = 1; - PrefHandler::Default()->setInt32(PREF_ROWS, rows); - } - - int cols = PrefHandler::Default()->getInt32(PREF_COLS); - if (cols < MIN_COLS) { - cols = MIN_COLS; - PrefHandler::Default()->setInt32(PREF_COLS, cols); - } - - // Get encoding name (setenv TTYPE in spawn_shell functions) - const char *encoding = longname2shortname(PrefHandler::Default()->getString(PREF_TEXT_ENCODING)); - fShell = new Shell(); - status_t status = fShell->Open(rows, cols, command, encoding); - if (status < 0) - throw status; - - InitWindow(); + _InitWindow(command); } TermWindow::~TermWindow() { - fTermView->DetachShell(); - - delete fShell; if (fPrefWindow) fPrefWindow->PostMessage(B_QUIT_REQUESTED); @@ -123,10 +99,10 @@ /** Initialize Window object. */ void -TermWindow::InitWindow() +TermWindow::_InitWindow(const char *command) { // make menu bar - SetupMenu(); + _SetupMenu(); // Setup font. @@ -155,10 +131,8 @@ BRect textframe = Bounds(); textframe.top = fMenubar->Bounds().bottom + 1.0; - fTermView = new TermView(textframe); + fTermView = new TermView(textframe, command); - fTermView->AttachShell(fShell); - // Initialize TermView. (font, size and color) fTermView->SetTermFont(&halfFont, &fullFont); @@ -216,7 +190,7 @@ void -TermWindow::SetupMenu() +TermWindow::_SetupMenu() { PrefHandler menuText; @@ -437,7 +411,7 @@ } else if (!strcmp("tty", spe.FindString("property", i))) { BMessage reply(B_REPLY); - reply.AddString("result", fShell->TTYName()); + reply.AddString("result", fTermView->TerminalName()); message->SendReply(&reply); } else { BWindow::MessageReceived(message); @@ -486,7 +460,7 @@ r.Height()+fMenubar->Bounds().Height() + VIEW_OFFSET * 2); fTermView->Invalidate(); - break; + break; } case EIGHTYTWENTYFOUR: { PrefHandler::Default()->setString(PREF_COLS, "80"); @@ -530,7 +504,6 @@ BScreen screen(this); fTermView->ScrollBar()->Hide(); fMenubar->Hide(); - //fTermView->MoveTo(0,0); fTermView->ResizeBy(B_V_SCROLL_BAR_WIDTH, mbHeight); fSavedLook = Look(); // done before ResizeTo to work around a Dano bug (not erasing the decor) @@ -544,7 +517,6 @@ ResizeTo(fSavedFrame.Width(), fSavedFrame.Height()); MoveTo(fSavedFrame.left, fSavedFrame.top); fTermView->ResizeBy(-B_V_SCROLL_BAR_WIDTH, -mbHeight); - //fTermView->MoveTo(0,mbHeight); SetLook(fSavedLook); fSavedFrame = BRect(0,0,-1,-1); } @@ -552,7 +524,7 @@ } case MSG_FONT_CHANGED: { PrefHandler::Default()->setString (PREF_HALF_FONT_FAMILY, fNewFontMenu->FindMarked()->Label()); - PostMessage (MSG_HALF_FONT_CHANGED); + PostMessage(MSG_HALF_FONT_CHANGED); break; } case MSG_COLOR_CHANGED: { @@ -567,15 +539,15 @@ break; } case MENU_PAGE_SETUP: { - DoPageSetup (); + _DoPageSetup(); break; } case MENU_PRINT: { - DoPrint (); + _DoPrint(); break; } case MSGRUN_WINDOW: { - fTermView->UpdateSIGWINCH (); + fTermView->UpdateSIGWINCH(); break; } case B_ABOUT_REQUESTED: { @@ -668,7 +640,7 @@ status_t -TermWindow::DoPageSetup() +TermWindow::_DoPageSetup() { BPrintJob job("PageSetup"); @@ -683,9 +655,9 @@ void -TermWindow::DoPrint() +TermWindow::_DoPrint() { - if (!fPrintSettings || (DoPageSetup() != B_NO_ERROR)) { + if (!fPrintSettings || (_DoPageSetup() != B_OK)) { (new BAlert("Cancel", "Print cancelled.", "OK"))->Go(); return; } Modified: haiku/trunk/src/apps/terminal/TermWindow.h =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-21 20:50:06 UTC (rev 21680) +++ haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-22 13:26:17 UTC (rev 21681) @@ -39,8 +39,6 @@ class BMessageRunner; class FindWindow; class PrefWindow; -class Shell; -class TermParse; class TermView; class TermWindow : public BWindow { @@ -62,13 +60,11 @@ const char *property); private: - void InitWindow(); - void SetupMenu(); - status_t DoPageSetup(); - void DoPrint(); + void _InitWindow(const char *command); + void _SetupMenu(); + status_t _DoPageSetup(); + void _DoPrint(); - Shell *fShell; - TermParse *fTermParse; BMenuBar *fMenubar; BMenu *fFilemenu, *fEditmenu, From stefano.ceccherini at gmail.com Sun Jul 22 15:27:41 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Sun, 22 Jul 2007 15:27:41 +0200 Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal In-Reply-To: <200707221326.l6MDQH9D021200@sheep.berlios.de> References: <200707221326.l6MDQH9D021200@sheep.berlios.de> Message-ID: <894b9700707220627g7d3689f6xfaf9478767e75f63@mail.gmail.com> 2007/7/22, jackburton at BerliOS : > Author: jackburton > Date: 2007-07-22 15:26:17 +0200 (Sun, 22 Jul 2007) > New Revision: 21681 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21681&view=rev > > Modified: > haiku/trunk/src/apps/terminal/CodeConv.cpp > haiku/trunk/src/apps/terminal/TermView.cpp > haiku/trunk/src/apps/terminal/TermView.h > haiku/trunk/src/apps/terminal/TermWindow.cpp > haiku/trunk/src/apps/terminal/TermWindow.h > Log: > Fixed a bug where Terminal couldn't set itself to fullscreen the first > time. Some minor cleanups. > Forgot to write in the commit message: Moved opening the shell to TermView. Now TermWindow doesn't know about Shell anymore. From stippi at mail.berlios.de Sun Jul 22 15:34:55 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 22 Jul 2007 15:34:55 +0200 Subject: [Haiku-commits] r21682 - haiku/trunk/src/servers/app Message-ID: <200707221334.l6MDYtOS021770@sheep.berlios.de> Author: stippi Date: 2007-07-22 15:34:54 +0200 (Sun, 22 Jul 2007) New Revision: 21682 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21682&view=rev Modified: haiku/trunk/src/servers/app/Decorator.cpp haiku/trunk/src/servers/app/Decorator.h Log: * removed unused function Modified: haiku/trunk/src/servers/app/Decorator.cpp =================================================================== --- haiku/trunk/src/servers/app/Decorator.cpp 2007-07-22 13:26:17 UTC (rev 21681) +++ haiku/trunk/src/servers/app/Decorator.cpp 2007-07-22 13:34:54 UTC (rev 21682) @@ -496,26 +496,7 @@ \param width Maximum number of pixels the title can be \return the number of characters that will fit in the given width */ -int32 -Decorator::_ClipTitle(float width) -{ - // TODO: eventually, use ServerFont::TruncateString() - // when it exists (if it doesn't already) - if (fDrawingEngine) { - int32 strlength = fTitle.CountChars(); - float pixwidth=fDrawingEngine->StringWidth(fTitle.String(),strlength,&fDrawState); - while (strlength >= 0) { - if (pixwidth < width) - return strlength; - - strlength--; - pixwidth=fDrawingEngine->StringWidth(fTitle.String(), strlength, &fDrawState); - } - } - return 0; -} - //! Function for calculating layout for the decorator void Decorator::_DoLayout() Modified: haiku/trunk/src/servers/app/Decorator.h =================================================================== --- haiku/trunk/src/servers/app/Decorator.h 2007-07-22 13:26:17 UTC (rev 21681) +++ haiku/trunk/src/servers/app/Decorator.h 2007-07-22 13:34:54 UTC (rev 21682) @@ -119,12 +119,6 @@ RGBColor UIColor(color_which which); protected: - int32 _ClipTitle(float width); - - /*! - \brief Returns the number of characters in the title - \return The title character count - */ int32 _TitleWidth() const { return fTitle.CountChars(); } From revol at free.fr Sun Jul 22 19:09:35 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 22 Jul 2007 19:09:35 +0200 CEST Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal In-Reply-To: <894b9700707220627g7d3689f6xfaf9478767e75f63@mail.gmail.com> Message-ID: <648424625-BeMail@laptop> > Forgot to write in the commit message: > Moved opening the shell to TermView. Now TermWindow doesn't know > about > Shell anymore. It would be nice to be able to replicate Terminal someday... to for ex embed it in an IDE. Seems it's going the good way at least. Fran?ois. From stippi at mail.berlios.de Sun Jul 22 21:29:57 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 22 Jul 2007 21:29:57 +0200 Subject: [Haiku-commits] r21683 - haiku/trunk/src/kits/interface Message-ID: <200707221929.l6MJTvFO021422@sheep.berlios.de> Author: stippi Date: 2007-07-22 21:29:56 +0200 (Sun, 22 Jul 2007) New Revision: 21683 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21683&view=rev Modified: haiku/trunk/src/kits/interface/PictureDataWriter.cpp Log: * rearranged includes Modified: haiku/trunk/src/kits/interface/PictureDataWriter.cpp =================================================================== --- haiku/trunk/src/kits/interface/PictureDataWriter.cpp 2007-07-22 13:34:54 UTC (rev 21682) +++ haiku/trunk/src/kits/interface/PictureDataWriter.cpp 2007-07-22 19:29:56 UTC (rev 21683) @@ -6,15 +6,16 @@ * Stefano Ceccherini (burton666 at libero.it) */ +#include + +#include + #include #include #include -#include #include -#include - #define THROW_ERROR(error) throw (status_t)(error) PictureDataWriter::PictureDataWriter() From stippi at mail.berlios.de Sun Jul 22 21:33:08 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 22 Jul 2007 21:33:08 +0200 Subject: [Haiku-commits] r21684 - haiku/trunk/src/kits/interface Message-ID: <200707221933.l6MJX8cA021585@sheep.berlios.de> Author: stippi Date: 2007-07-22 21:33:08 +0200 (Sun, 22 Jul 2007) New Revision: 21684 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21684&view=rev Modified: haiku/trunk/src/kits/interface/Region.cpp Log: * small correction in error handling code path Modified: haiku/trunk/src/kits/interface/Region.cpp =================================================================== --- haiku/trunk/src/kits/interface/Region.cpp 2007-07-22 19:29:56 UTC (rev 21683) +++ haiku/trunk/src/kits/interface/Region.cpp 2007-07-22 19:33:08 UTC (rev 21684) @@ -475,9 +475,14 @@ fData = (clipping_rect*)realloc(fData, newSize * sizeof(clipping_rect)); else fData = (clipping_rect*)malloc(newSize * sizeof(clipping_rect)); + } else { + // just an empty region, but no error + MakeEmpty(); + return true; } - if (!fData || newSize <= 0) { + if (!fData) { + // allocation actually failed fDataSize = 0; MakeEmpty(); return false; From stippi at mail.berlios.de Sun Jul 22 21:48:29 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 22 Jul 2007 21:48:29 +0200 Subject: [Haiku-commits] r21685 - in haiku/trunk: headers/private/app src/servers/app src/servers/app/drawing src/servers/app/drawing/Painter src/servers/app/drawing/Painter/font_support Message-ID: <200707221948.l6MJmTUv022230@sheep.berlios.de> Author: stippi Date: 2007-07-22 21:48:27 +0200 (Sun, 22 Jul 2007) New Revision: 21685 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21685&view=rev Modified: haiku/trunk/headers/private/app/ServerProtocol.h haiku/trunk/src/servers/app/DefaultDecorator.cpp haiku/trunk/src/servers/app/ProfileMessageSupport.cpp haiku/trunk/src/servers/app/RGBColor.h haiku/trunk/src/servers/app/ServerApp.cpp haiku/trunk/src/servers/app/ServerFont.cpp haiku/trunk/src/servers/app/ServerPicture.cpp haiku/trunk/src/servers/app/ServerWindow.cpp haiku/trunk/src/servers/app/ViewLayer.cpp haiku/trunk/src/servers/app/WindowLayer.h haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp haiku/trunk/src/servers/app/drawing/DrawingEngine.h haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp haiku/trunk/src/servers/app/drawing/Painter/Painter.h haiku/trunk/src/servers/app/drawing/Painter/font_support/AGGTextRenderer.cpp haiku/trunk/src/servers/app/drawing/Painter/font_support/AGGTextRenderer.h Log: * completed my changes to DrawState handling, the current DrawingState of the active ViewLayer is now always mirrored in the Painter instance of a ServerWindow, so that it doesn't need to be synced on every drawing command, this was previously incomplete for font handling * removed the DrawState parameter from all the DrawingEngine functions * adjusted ServerWindow and ServerPicture accordingly * made sure that string related functions used by non-drawing related parts (ServerApp, Decorator) don't interfere with the current drawing state * moved AS_SYNC handling from _DispatchViewMessage to _DispatchMessage, it is actually a window message and doesn't require fCurrentLayer to be valid * fixed bug #1300, fCurrentLayer was not updated when a ViewLayer was deleted by client request which happened to be fCurrentLayer (I am now handling it so that the parent becomes the current layer, could be wrong) * AGGTextRenderer is no longer using it's own scanline, which should save a few bytes RAM, the Painter already had such an object * StringWidth() in AGGTextRenderer is now taking the escapement_delta into account * Painter::StrokeLine() doesn't need to check the clipping as much, since that is already done in DrawingEngine * if a ServerWindow message is not handled because fCurrentLayer is NULL, a reply is sent in case the messages needs it (client window could freeze otherwise, waiting for the reply for ever) * removed unused AS_SET_FONT and AS_SET_FONT_SIZE * added automatic RGBColor -> rgb_color conversion to RGBColor.h * minor cleanup for 80 char/line limit Modified: haiku/trunk/headers/private/app/ServerProtocol.h =================================================================== --- haiku/trunk/headers/private/app/ServerProtocol.h 2007-07-22 19:33:08 UTC (rev 21684) +++ haiku/trunk/headers/private/app/ServerProtocol.h 2007-07-22 19:48:27 UTC (rev 21685) @@ -212,8 +212,6 @@ AS_FILL_TRIANGLE, AS_DRAW_STRING, - AS_SET_FONT, - AS_SET_FONT_SIZE, AS_SYNC, Modified: haiku/trunk/src/servers/app/DefaultDecorator.cpp =================================================================== --- haiku/trunk/src/servers/app/DefaultDecorator.cpp 2007-07-22 19:33:08 UTC (rev 21684) +++ haiku/trunk/src/servers/app/DefaultDecorator.cpp 2007-07-22 19:48:27 UTC (rev 21685) @@ -639,8 +639,9 @@ fMinTabSize += offset + size; // fMaxTabSize contains fMinWidth + the width required for the title - fMaxTabSize = fDrawingEngine ? ceilf(fDrawingEngine->StringWidth(Title(), strlen(Title()), - &fDrawState)) : 0.0; + fMaxTabSize = fDrawingEngine ? + ceilf(fDrawingEngine->StringWidth(Title(), strlen(Title()), + fDrawState.Font())) : 0.0; if (fMaxTabSize > 0.0) fMaxTabSize += fTextOffset; fMaxTabSize += fMinTabSize; @@ -967,8 +968,9 @@ { STRACE(("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom)); - fDrawState.SetHighColor(fTextColor); - fDrawState.SetLowColor(fTabColor); + fDrawingEngine->SetHighColor(fTextColor.GetColor32()); + fDrawingEngine->SetLowColor(fTabColor.GetColor32()); + fDrawingEngine->SetFont(fDrawState.Font()); // figure out position of text font_height fontHeight; @@ -987,7 +989,8 @@ : fTabRect.bottom - fTextOffset; } - fDrawingEngine->DrawString(fTruncatedTitle.String(), fTruncatedTitleLength, titlePos, &fDrawState); + fDrawingEngine->DrawString(fTruncatedTitle.String(), fTruncatedTitleLength, + titlePos); } // _DrawZoom Modified: haiku/trunk/src/servers/app/ProfileMessageSupport.cpp =================================================================== --- haiku/trunk/src/servers/app/ProfileMessageSupport.cpp 2007-07-22 19:33:08 UTC (rev 21684) +++ haiku/trunk/src/servers/app/ProfileMessageSupport.cpp 2007-07-22 19:48:27 UTC (rev 21685) @@ -200,8 +200,6 @@ case AS_FILL_TRIANGLE: string = "AS_FILL_TRIANGLE"; break; case AS_DRAW_STRING: string = "AS_DRAW_STRING"; break; - case AS_SET_FONT: string = "AS_SET_FONT"; break; - case AS_SET_FONT_SIZE: string = "AS_SET_FONT_SIZE"; break; case AS_SYNC: string = "AS_SYNC"; break; Modified: haiku/trunk/src/servers/app/RGBColor.h =================================================================== --- haiku/trunk/src/servers/app/RGBColor.h 2007-07-22 19:33:08 UTC (rev 21684) +++ haiku/trunk/src/servers/app/RGBColor.h 2007-07-22 19:48:27 UTC (rev 21685) @@ -53,6 +53,10 @@ bool operator==(const RGBColor& color) const; bool operator!=(const rgb_color& color) const; bool operator!=(const RGBColor& color) const; + + // conversion to rgb_color + operator rgb_color() const + { return fColor32; } bool IsTransparentMagic() const; Modified: haiku/trunk/src/servers/app/ServerApp.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerApp.cpp 2007-07-22 19:33:08 UTC (rev 21684) +++ haiku/trunk/src/servers/app/ServerApp.cpp 2007-07-22 19:48:27 UTC (rev 21685) @@ -1401,7 +1401,8 @@ int32 lengthArray[numStrings]; char *stringArray[numStrings]; for (int32 i = 0; i < numStrings; i++) { - // This version of ReadString allocates the strings, we free them below + // This version of ReadString allocates the strings, we free + // them below link.ReadString(&stringArray[i], (size_t *)&lengthArray[i]); } @@ -1415,13 +1416,14 @@ if (!stringArray[i] || lengthArray[i] <= 0) widthArray[i] = 0.0; else { - widthArray[i] = fDesktop->GetDrawingEngine()->StringWidth(stringArray[i], lengthArray[i], font); - // NOTE: The line below will return the exact same thing. However, - // the line above uses the AGG rendering backend, for which glyph caching - // actually works. It is about 20 times faster! - // TODO: I've disabled the AGG version for now, as it produces a dead lock - // (font use), that I am currently too lazy to investigate... -// widthArray[i] = font.StringWidth(stringArray[i], lengthArray[i]); + widthArray[i] = fDesktop->GetDrawingEngine()-> + StringWidth(stringArray[i], lengthArray[i], font); + // NOTE: The line below will return the exact same thing. + // However, the line above uses the AGG rendering backend, + // for which glyph caching actually works. It is about + // 20 times faster! +// widthArray[i] = font.StringWidth(stringArray[i], +// lengthArray[i]); } } Modified: haiku/trunk/src/servers/app/ServerFont.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerFont.cpp 2007-07-22 19:33:08 UTC (rev 21684) +++ haiku/trunk/src/servers/app/ServerFont.cpp 2007-07-22 19:48:27 UTC (rev 21685) @@ -339,6 +339,7 @@ FT_Set_Transform(face, &smatrix, NULL); } + // fStyle will be unlocked in PutTransformedFace() return face; } @@ -433,7 +434,8 @@ status_t ServerFont::GetEscapements(const char charArray[], int32 numChars, - escapement_delta delta, BPoint escapementArray[], BPoint offsetArray[]) const + escapement_delta delta, BPoint escapementArray[], + BPoint offsetArray[]) const { if (!charArray || numChars <= 0 || !escapementArray) return B_BAD_DATA; Modified: haiku/trunk/src/servers/app/ServerPicture.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerPicture.cpp 2007-07-22 19:33:08 UTC (rev 21684) +++ haiku/trunk/src/servers/app/ServerPicture.cpp 2007-07-22 19:48:27 UTC (rev 21685) @@ -131,7 +131,7 @@ } view->Window()->GetDrawingEngine()->DrawShape(frame, opCount, opList, ptCount, ptList, - view->CurrentState(), filled); + filled); } } @@ -182,7 +182,7 @@ { view->ConvertToScreenForDrawing(&start); view->ConvertToScreenForDrawing(&end); - view->Window()->GetDrawingEngine()->StrokeLine(start, end, view->CurrentState()); + view->Window()->GetDrawingEngine()->StrokeLine(start, end); } @@ -190,7 +190,7 @@ stroke_rect(ViewLayer *view, BRect rect) { view->ConvertToScreenForDrawing(&rect); - view->Window()->GetDrawingEngine()->StrokeRect(rect, view->CurrentState()); + view->Window()->GetDrawingEngine()->StrokeRect(rect); } @@ -198,7 +198,7 @@ fill_rect(ViewLayer *view, BRect rect) { view->ConvertToScreenForDrawing(&rect); - view->Window()->GetDrawingEngine()->FillRect(rect, view->CurrentState()); + view->Window()->GetDrawingEngine()->FillRect(rect); } @@ -206,7 +206,8 @@ stroke_round_rect(ViewLayer *view, BRect rect, BPoint radii) { view->ConvertToScreenForDrawing(&rect); - view->Window()->GetDrawingEngine()->DrawRoundRect(rect, radii.x, radii.y, view->CurrentState(), false); + view->Window()->GetDrawingEngine()->DrawRoundRect(rect, radii.x, radii.y, + false); } @@ -214,7 +215,8 @@ fill_round_rect(ViewLayer *view, BRect rect, BPoint radii) { view->ConvertToScreenForDrawing(&rect); - view->Window()->GetDrawingEngine()->DrawRoundRect(rect, radii.x, radii.y, view->CurrentState(), true); + view->Window()->GetDrawingEngine()->DrawRoundRect(rect, radii.x, radii.y, + true); } @@ -224,7 +226,7 @@ BPoint points[4]; view->ConvertToScreenForDrawing(points, viewPoints, 4); - view->Window()->GetDrawingEngine()->DrawBezier(points, view->CurrentState(), false); + view->Window()->GetDrawingEngine()->DrawBezier(points, false); } @@ -234,7 +236,7 @@ BPoint points[4]; view->ConvertToScreenForDrawing(points, viewPoints, 4); - view->Window()->GetDrawingEngine()->DrawBezier(points, view->CurrentState(), true); + view->Window()->GetDrawingEngine()->DrawBezier(points, true); } @@ -245,7 +247,7 @@ BRect rect(center.x - radii.x, center.y - radii.y, center.x + radii.x, center.y + radii.y); view->ConvertToScreenForDrawing(&rect); - view->Window()->GetDrawingEngine()->DrawArc(rect, startTheta, arcTheta, view->CurrentState(), false); + view->Window()->GetDrawingEngine()->DrawArc(rect, startTheta, arcTheta, false); } @@ -256,7 +258,7 @@ BRect rect(center.x - radii.x, center.y - radii.y, center.x + radii.x, center.y + radii.y); view->ConvertToScreenForDrawing(&rect); - view->Window()->GetDrawingEngine()->DrawArc(rect, startTheta, arcTheta, view->CurrentState(), true); + view->Window()->GetDrawingEngine()->DrawArc(rect, startTheta, arcTheta, true); } @@ -266,7 +268,7 @@ BRect rect(center.x - radii.x, center.y - radii.y, center.x + radii.x, center.y + radii.y); view->ConvertToScreenForDrawing(&rect); - view->Window()->GetDrawingEngine()->DrawEllipse(rect, view->CurrentState(), false); + view->Window()->GetDrawingEngine()->DrawEllipse(rect, false); } @@ -276,7 +278,7 @@ BRect rect(center.x - radii.x, center.y - radii.y, center.x + radii.x, center.y + radii.y); view->ConvertToScreenForDrawing(&rect); - view->Window()->GetDrawingEngine()->DrawEllipse(rect, view->CurrentState(), true); + view->Window()->GetDrawingEngine()->DrawEllipse(rect, true); } @@ -295,9 +297,8 @@ BRect polyFrame; get_polygon_frame(points, numPoints, &polyFrame); - view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame, - view->CurrentState(), false, - isClosed && numPoints > 2); + view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame, + false, isClosed && numPoints > 2); } else { // avoid constructor/destructor calls by using malloc instead of new [] BPoint *points = (BPoint *)malloc(numPoints * sizeof(BPoint)); @@ -310,8 +311,7 @@ get_polygon_frame(points, numPoints, &polyFrame); view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame, - view->CurrentState(), false, - isClosed && numPoints > 2); + false, isClosed && numPoints > 2); free(points); } } @@ -333,7 +333,7 @@ get_polygon_frame(points, numPoints, &polyFrame); view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame, - view->CurrentState(), true, true); + true, true); } else { // avoid constructor/destructor calls by using malloc instead of new [] BPoint *points = (BPoint *)malloc(numPoints * sizeof(BPoint)); @@ -346,7 +346,7 @@ get_polygon_frame(points, numPoints, &polyFrame); view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame, - view->CurrentState(), true, true); + true, true); free(points); } } @@ -373,13 +373,14 @@ static void -draw_string(ViewLayer *view, const char *string, float deltaSpace, float deltaNonSpace) +draw_string(ViewLayer *view, const char *string, float deltaSpace, + float deltaNonSpace) { BPoint location = view->CurrentState()->PenLocation(); escapement_delta delta = {deltaSpace, deltaNonSpace }; view->ConvertToScreenForDrawing(&location); - view->Window()->GetDrawingEngine()->DrawString(string, strlen(string), location, - view->CurrentState(), &delta); + view->Window()->GetDrawingEngine()->DrawString(string, strlen(string), + location, &delta); // TODO: Update pen location ? } @@ -399,7 +400,7 @@ view->ConvertToScreenForDrawing(&dest); - view->Window()->GetDrawingEngine()->DrawBitmap(&bitmap, src, dest, view->CurrentState()); + view->Window()->GetDrawingEngine()->DrawBitmap(&bitmap, src, dest); } @@ -434,6 +435,11 @@ pop_state(ViewLayer *view) { view->PopState(); + + IntPoint p = view->ScrollingOffset(); + p += IntPoint(view->CurrentState()->Origin()); + view->Window()->GetDrawingEngine()->SetDrawState( + view->CurrentState(), p.x, p.y); } @@ -476,6 +482,12 @@ set_pen_location(ViewLayer *view, BPoint pt) { view->CurrentState()->SetPenLocation(pt); + + // TODO: faster version + IntPoint p = view->ScrollingOffset(); + p += IntPoint(view->CurrentState()->Origin()); + view->Window()->GetDrawingEngine()->SetDrawState( + view->CurrentState(), p.x, p.y); } @@ -483,6 +495,7 @@ set_drawing_mode(ViewLayer *view, drawing_mode mode) { view->CurrentState()->SetDrawingMode(mode); + view->Window()->GetDrawingEngine()->SetDrawingMode(mode); } @@ -493,6 +506,7 @@ state->SetLineCapMode(capMode); state->SetLineJoinMode(joinMode); state->SetMiterLimit(miterLimit); + view->Window()->GetDrawingEngine()->SetStrokeMode(capMode, joinMode, miterLimit); } @@ -500,6 +514,7 @@ set_pen_size(ViewLayer *view, float size) { view->CurrentState()->SetPenSize(size); + view->Window()->GetDrawingEngine()->SetPenSize(size); } @@ -507,6 +522,7 @@ set_fore_color(ViewLayer *view, rgb_color color) { view->CurrentState()->SetHighColor(RGBColor(color)); + view->Window()->GetDrawingEngine()->SetHighColor(color); } @@ -514,13 +530,15 @@ set_back_color(ViewLayer *view, rgb_color color) { view->CurrentState()->SetLowColor(RGBColor(color)); + view->Window()->GetDrawingEngine()->SetLowColor(color); } static void set_stipple_pattern(ViewLayer *view, pattern p) { - printf("SetStipplePattern\n"); + view->CurrentState()->SetPattern(Pattern(p)); + view->Window()->GetDrawingEngine()->SetPattern(p); } @@ -558,13 +576,17 @@ ServerFont font; font.SetSize(size); view->CurrentState()->SetFont(font, B_FONT_SIZE); + view->Window()->GetDrawingEngine()->SetFont(view->CurrentState()->Font()); } static void set_font_rotate(ViewLayer *view, float rotation) { - printf("SetFontRotate(%.2f)\n", rotation); + ServerFont font; + font.SetRotation(rotation); + view->CurrentState()->SetFont(font, B_FONT_ROTATION); + view->Window()->GetDrawingEngine()->SetFont(view->CurrentState()->Font()); } Modified: haiku/trunk/src/servers/app/ServerWindow.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerWindow.cpp 2007-07-22 19:33:08 UTC (rev 21684) +++ haiku/trunk/src/servers/app/ServerWindow.cpp 2007-07-22 19:48:27 UTC (rev 21685) @@ -1034,6 +1034,16 @@ // at the fRedrawRequested member variable in _MessageLooper(). break; + case AS_SYNC: + // the synchronisation works by the fact that the client + // window is waiting for this reply, after having received it, + // client and server queues are in sync (earlier, the client + // may have pushed drawing commands at the server and now it + // knows they have all been carried out) + fLink.StartMessage(B_OK); + fLink.Flush(); + break; + case AS_BEGIN_UPDATE: DTRACE(("ServerWindowo %s: AS_BEGIN_UPDATE\n", Title())); fWindowLayer->BeginUpdate(fLink); @@ -1161,7 +1171,15 @@ // and take appropriate actions, then checking for fCurrentLayer->CurrentState() // is unnecessary if (fCurrentLayer == NULL || fCurrentLayer->CurrentState() == NULL) { - printf("ServerWindow %s received unexpected code - message offset %ld before top_view attached.\n", Title(), code - B_OK); + BString codeName; + string_for_message_code(code, codeName); + printf("ServerWindow %s received unexpected code - " + "message '%s' before top_view attached.\n", + Title(), codeName.String()); + if (link.NeedsReply()) { + fLink.StartMessage(B_ERROR); + fLink.Flush(); + } return; } @@ -1231,8 +1249,10 @@ fDesktop->EventDispatcher().RemoveListener(EventTarget(), token); } + if (fCurrentLayer == view) + _SetCurrentLayer(parent); delete view; - } + } // else we don't delete the root view } break; } @@ -1251,7 +1271,9 @@ { DTRACE(("ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: ViewLayer name: %s\n", fTitle, fCurrentLayer->Name())); fCurrentLayer->CurrentState()->ReadFontFromLink(link); - _UpdateDrawState(fCurrentLayer); +// _UpdateDrawState(fCurrentLayer); + fWindowLayer->GetDrawingEngine()->SetFont( + fCurrentLayer->CurrentState()->Font()); break; } case AS_LAYER_GET_STATE: @@ -1466,7 +1488,9 @@ fCurrentLayer->CurrentState()->SetLineJoinMode((join_mode)lineJoin); fCurrentLayer->CurrentState()->SetMiterLimit(miterLimit); - _UpdateDrawState(fCurrentLayer); + fWindowLayer->GetDrawingEngine()->SetStrokeMode((cap_mode)lineCap, + (join_mode)lineJoin, miterLimit); +// _UpdateDrawState(fCurrentLayer); break; } @@ -1606,8 +1630,10 @@ link.Read(&alphaFunc); fCurrentLayer->CurrentState()->SetBlendingMode((source_alpha)srcAlpha, - (alpha_function)alphaFunc); - _UpdateDrawState(fCurrentLayer); + (alpha_function)alphaFunc); + //_UpdateDrawState(fCurrentLayer); + fWindowLayer->GetDrawingEngine()->SetBlendingMode((source_alpha)srcAlpha, + (alpha_function)alphaFunc); break; } case AS_LAYER_GET_BLENDING_MODE: @@ -1856,30 +1882,6 @@ fWindowLayer->GetDrawingEngine()->SetPattern(pat); break; } - case AS_SET_FONT: - { - DTRACE(("ServerWindow %s: Message AS_SET_FONT\n", Title())); - // TODO: Implement AS_SET_FONT? - // Confusing!! But it works already! - break; - } - case AS_SET_FONT_SIZE: - { - DTRACE(("ServerWindow %s: Message AS_SET_FONT_SIZE\n", Title())); - // TODO: Implement AS_SET_FONT_SIZE? - break; - } - case AS_SYNC: - { - // the synchronisation works by the fact that the client - // window is waiting for this reply, after having received it, - // client and server queues are in sync (earlier, the client - // may have pushed drawing commands at the server and now it - // knows they have all been carried out) - fLink.StartMessage(B_OK); - fLink.Flush(); - break; - } case AS_LAYER_DRAG_IMAGE: { // TODO: flesh out AS_LAYER_DRAG_IMAGE @@ -2052,7 +2054,7 @@ BPoint penPos = p2; fCurrentLayer->ConvertToScreenForDrawing(&p1); fCurrentLayer->ConvertToScreenForDrawing(&p2); - drawingEngine->StrokeLine(p1, p2, fCurrentLayer->CurrentState()); + drawingEngine->StrokeLine(p1, p2); // We update the pen here because many DrawingEngine calls which do not update the // pen position actually call StrokeLine @@ -2086,7 +2088,7 @@ BRect rect(left,top,right,bottom); fCurrentLayer->ConvertToScreenForDrawing(&rect); - drawingEngine->StrokeRect(rect, fCurrentLayer->CurrentState()); + drawingEngine->StrokeRect(rect); break; } case AS_FILL_RECT: @@ -2097,7 +2099,7 @@ link.Read(&rect); fCurrentLayer->ConvertToScreenForDrawing(&rect); - drawingEngine->FillRect(rect, fCurrentLayer->CurrentState()); + drawingEngine->FillRect(rect); break; } case AS_LAYER_DRAW_BITMAP: @@ -2114,7 +2116,7 @@ if (bitmap) { fCurrentLayer->ConvertToScreenForDrawing(&dstRect); - drawingEngine->DrawBitmap(bitmap, srcRect, dstRect, fCurrentLayer->CurrentState()); + drawingEngine->DrawBitmap(bitmap, srcRect, dstRect); } break; @@ -2132,8 +2134,7 @@ link.Read(&span); fCurrentLayer->ConvertToScreenForDrawing(&r); - drawingEngine->DrawArc(r, angle, span, fCurrentLayer->CurrentState(), - code == AS_FILL_ARC); + drawingEngine->DrawArc(r, angle, span, code == AS_FILL_ARC); break; } case AS_STROKE_BEZIER: @@ -2147,8 +2148,7 @@ fCurrentLayer->ConvertToScreenForDrawing(&pts[i]); } - drawingEngine->DrawBezier(pts, fCurrentLayer->CurrentState(), - code == AS_FILL_BEZIER); + drawingEngine->DrawBezier(pts, code == AS_FILL_BEZIER); break; } case AS_STROKE_ELLIPSE: @@ -2160,7 +2160,7 @@ link.Read(&rect); fCurrentLayer->ConvertToScreenForDrawing(&rect); - drawingEngine->DrawEllipse(rect, fCurrentLayer->CurrentState(), code == AS_FILL_ELLIPSE); + drawingEngine->DrawEllipse(rect, code == AS_FILL_ELLIPSE); break; } case AS_STROKE_ROUNDRECT: @@ -2175,7 +2175,7 @@ link.Read(&yrad); fCurrentLayer->ConvertToScreenForDrawing(&rect); - drawingEngine->DrawRoundRect(rect, xrad, yrad, fCurrentLayer->CurrentState(), code == AS_FILL_ROUNDRECT); + drawingEngine->DrawRoundRect(rect, xrad, yrad, code == AS_FILL_ROUNDRECT); break; } case AS_STROKE_TRIANGLE: @@ -2194,7 +2194,7 @@ link.Read(&rect); fCurrentLayer->ConvertToScreenForDrawing(&rect); - drawingEngine->DrawTriangle(pts, rect, fCurrentLayer->CurrentState(), code == AS_FILL_TRIANGLE); + drawingEngine->DrawTriangle(pts, rect, code == AS_FILL_TRIANGLE); break; } case AS_STROKE_POLYGON: @@ -2218,8 +2218,7 @@ fCurrentLayer->ConvertToScreenForDrawing(&polyFrame); drawingEngine->DrawPolygon(pointList, pointCount, polyFrame, - fCurrentLayer->CurrentState(), code == AS_FILL_POLYGON, - isClosed && pointCount > 2); + code == AS_FILL_POLYGON, isClosed && pointCount > 2); } delete[] pointList; break; @@ -2246,7 +2245,7 @@ fCurrentLayer->ConvertToScreenForDrawing(&ptList[i]); drawingEngine->DrawShape(shapeFrame, opCount, opList, ptCount, ptList, - fCurrentLayer->CurrentState(), code == AS_FILL_SHAPE); + code == AS_FILL_SHAPE); } delete[] opList; @@ -2262,7 +2261,7 @@ break; fCurrentLayer->ConvertToScreenForDrawing(®ion); - drawingEngine->FillRegion(region, fCurrentLayer->CurrentState()); + drawingEngine->FillRegion(region); break; } @@ -2292,8 +2291,7 @@ fCurrentLayer->ConvertToScreenForDrawing(&index->pt1); fCurrentLayer->ConvertToScreenForDrawing(&index->pt2); } - drawingEngine->StrokeLineArray(lineCount, lineData, - fCurrentLayer->CurrentState()); + drawingEngine->StrokeLineArray(lineCount, lineData); } break; } @@ -2311,11 +2309,12 @@ link.ReadString(&string); fCurrentLayer->ConvertToScreenForDrawing(&location); - BPoint penLocation = drawingEngine->DrawString(string, length, location, - fCurrentLayer->CurrentState(), &delta); + BPoint penLocation = drawingEngine->DrawString(string, length, + location, &delta); fCurrentLayer->ConvertFromScreenForDrawing(&penLocation); fCurrentLayer->CurrentState()->SetPenLocation(penLocation); + // pen location has changed, update DrawingEngine // TODO: optimize with flags _UpdateDrawState(fCurrentLayer); Modified: haiku/trunk/src/servers/app/ViewLayer.cpp =================================================================== --- haiku/trunk/src/servers/app/ViewLayer.cpp 2007-07-22 19:33:08 UTC (rev 21684) +++ haiku/trunk/src/servers/app/ViewLayer.cpp 2007-07-22 19:48:27 UTC (rev 21685) @@ -1212,16 +1212,14 @@ if (rect.IsValid()/* && drawingEngine->Lock()*/) { drawingEngine->ConstrainClippingRegion(redraw); - DrawState defaultDrawState; - if (fBitmapOptions & B_TILE_BITMAP) { // tile across entire view float start = rect.left; while (rect.top < redraw->Frame().bottom) { while (rect.left < redraw->Frame().right) { - drawingEngine->DrawBitmap(fViewBitmap, fBitmapSource, - rect, &defaultDrawState); + drawingEngine->DrawBitmap(fViewBitmap, + fBitmapSource, rect); rect.OffsetBy(rect.Width() + 1, 0.0); } rect.OffsetBy(start - rect.left, rect.Height() + 1); @@ -1233,7 +1231,7 @@ while (rect.left < redraw->Frame().right) { drawingEngine->DrawBitmap(fViewBitmap, fBitmapSource, - rect, &defaultDrawState); + rect); rect.OffsetBy(rect.Width() + 1, 0.0); } // remove horizontal stripe from clipping @@ -1245,7 +1243,7 @@ while (rect.top < redraw->Frame().bottom) { drawingEngine->DrawBitmap(fViewBitmap, fBitmapSource, - rect, &defaultDrawState); + rect); rect.OffsetBy(0.0, rect.Height() + 1); } // remove vertical stripe from clipping @@ -1256,7 +1254,7 @@ // no tiling at all drawingEngine->DrawBitmap(fViewBitmap, fBitmapSource, - rect, &defaultDrawState); + rect); redraw->Exclude(rect); } Modified: haiku/trunk/src/servers/app/WindowLayer.h =================================================================== --- haiku/trunk/src/servers/app/WindowLayer.h 2007-07-22 19:33:08 UTC (rev 21684) +++ haiku/trunk/src/servers/app/WindowLayer.h 2007-07-22 19:48:27 UTC (rev 21685) @@ -84,7 +84,6 @@ ViewLayer* TopLayer() const { return fTopLayer; } // TODO: only used for WorkspacesLayer, can go away if we do // this differently one day - ViewLayer* ViewAt(const BPoint& where); virtual bool IsOffscreenWindow() const { return false; } Modified: haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp 2007-07-22 19:33:08 UTC (rev 21684) +++ haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp 2007-07-22 19:48:27 UTC (rev 21685) @@ -13,6 +13,7 @@ #include #include +#include "AGGTextRenderer.h" #include "DrawState.h" #include "Painter.h" #include "PNGDump.h" @@ -46,10 +47,10 @@ // extend_by_stroke_width static inline void -extend_by_stroke_width(BRect& rect, const DrawState* context) +extend_by_stroke_width(BRect& rect, float penSize) { // "- 0.5" because if stroke width == 1, we don't need to extend - float inset = -ceilf(context->PenSize() / 2.0 - 0.5); + float inset = -ceilf(penSize / 2.0 - 0.5); rect.InsetBy(inset, inset); } @@ -184,7 +185,7 @@ void DrawingEngine::SetDrawState(const DrawState* state, int32 xOffset, int32 yOffset) { - fPainter->SetDrawState(state, false, xOffset, yOffset); + fPainter->SetDrawState(state, true, xOffset, yOffset); } @@ -210,10 +211,23 @@ void +DrawingEngine::SetStrokeMode(cap_mode lineCap, join_mode joinMode, + float miterLimit) +{ + fPainter->SetStrokeMode(lineCap, joinMode, miterLimit); +} + + +void +DrawingEngine::SetBlendingMode(source_alpha srcAlpha, alpha_function alphaFunc) +{ + fPainter->SetBlendingMode(srcAlpha, alphaFunc); +} + + +void DrawingEngine::SetPattern(const struct pattern& pattern) { - // TODO: doing it like this prevents an optimization - // for font rendering (special "solid" drawing mode) fPainter->SetPattern(pattern, false); } @@ -225,6 +239,13 @@ } +void +DrawingEngine::SetFont(const ServerFont& font) +{ + fPainter->SetFont(font); +} + + // #pragma mark - @@ -505,8 +526,7 @@ // DrawBitmap void DrawingEngine::DrawBitmap(ServerBitmap *bitmap, - const BRect &source, const BRect &dest, - const DrawState *d) + const BRect &source, const BRect &dest) { CRASH_IF_NOT_LOCKED @@ -514,7 +534,6 @@ if (clipped.IsValid()) { bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); -// fPainter->SetDrawState(d); fPainter->DrawBitmap(bitmap, source, dest); fGraphicsCard->Invalidate(clipped); @@ -526,21 +545,18 @@ // DrawArc void DrawingEngine::DrawArc(BRect r, const float &angle, - const float &span, const DrawState *d, - bool filled) + const float &span, bool filled) { CRASH_IF_NOT_LOCKED make_rect_valid(r); BRect clipped(r); if (!filled) - extend_by_stroke_width(clipped, d); + extend_by_stroke_width(clipped, fPainter->PenSize()); clipped = fPainter->ClipRect(r); if (clipped.IsValid()) { bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); -// fPainter->SetDrawState(d); - float xRadius = r.Width() / 2.0; float yRadius = r.Height() / 2.0; BPoint center(r.left + xRadius, @@ -559,14 +575,13 @@ // DrawBezier void -DrawingEngine::DrawBezier(BPoint *pts, const DrawState *d, bool filled) +DrawingEngine::DrawBezier(BPoint *pts, bool filled) { CRASH_IF_NOT_LOCKED // TODO: figure out bounds and hide cursor depending on that fGraphicsCard->HideSoftwareCursor(); -// fPainter->SetDrawState(d); BRect touched = fPainter->DrawBezier(pts, filled); fGraphicsCard->Invalidate(touched); @@ -575,7 +590,7 @@ // DrawEllipse void -DrawingEngine::DrawEllipse(BRect r, const DrawState *d, bool filled) +DrawingEngine::DrawEllipse(BRect r, bool filled) { CRASH_IF_NOT_LOCKED @@ -584,7 +599,7 @@ fPainter->AlignEllipseRect(&clipped, filled); if (!filled) - extend_by_stroke_width(clipped, d); + extend_by_stroke_width(clipped, fPainter->PenSize()); clipped.left = floorf(clipped.left); clipped.top = floorf(clipped.top); @@ -596,7 +611,6 @@ if (clipped.IsValid()) { bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); -// fPainter->SetDrawState(d); fPainter->DrawEllipse(r, filled); fGraphicsCard->Invalidate(clipped); @@ -608,19 +622,17 @@ // DrawPolygon void DrawingEngine::DrawPolygon(BPoint* ptlist, int32 numpts, - BRect bounds, const DrawState* d, - bool filled, bool closed) + BRect bounds, bool filled, bool closed) { CRASH_IF_NOT_LOCKED make_rect_valid(bounds); if (!filled) - extend_by_stroke_width(bounds, d); + extend_by_stroke_width(bounds, fPainter->PenSize()); bounds = fPainter->ClipRect(bounds); if (bounds.IsValid()) { bool cursorTouched = fGraphicsCard->HideSoftwareCursor(bounds); -// fPainter->SetDrawState(d); fPainter->DrawPolygon(ptlist, numpts, filled, closed); fGraphicsCard->Invalidate(bounds); @@ -756,20 +768,19 @@ // #pragma mark - DrawState void -DrawingEngine::StrokeRect(BRect r, const DrawState *d) +DrawingEngine::StrokeRect(BRect r) { CRASH_IF_NOT_LOCKED // support invalid rects make_rect_valid(r); BRect clipped(r); - extend_by_stroke_width(clipped, d); + extend_by_stroke_width(clipped, fPainter->PenSize()); clipped = fPainter->ClipRect(clipped); if (clipped.IsValid()) { bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); -// fPainter->SetDrawState(d); fPainter->StrokeRect(r); fGraphicsCard->Invalidate(clipped); @@ -780,7 +791,7 @@ void -DrawingEngine::FillRect(BRect r, const DrawState *d) +DrawingEngine::FillRect(BRect r) { CRASH_IF_NOT_LOCKED @@ -794,20 +805,20 @@ // try hardware optimized version first // if the rect is large enough if ((fAvailableHWAccleration & HW_ACC_FILL_REGION) != 0) { - if (d->GetPattern() == B_SOLID_HIGH - && (d->GetDrawingMode() == B_OP_COPY - || d->GetDrawingMode() == B_OP_OVER)) { + if (fPainter->Pattern() == B_SOLID_HIGH + && (fPainter->DrawingMode() == B_OP_COPY + || fPainter->DrawingMode() == B_OP_OVER)) { BRegion region(r); region.IntersectWith(fPainter->ClippingRegion()); - fGraphicsCard->FillRegion(region, d->HighColor(), + fGraphicsCard->FillRegion(region, fPainter->HighColor(), fSuspendSyncLevel == 0 || cursorTouched); doInSoftware = false; - } else if (d->GetPattern() == B_SOLID_LOW - && d->GetDrawingMode() == B_OP_COPY) { + } else if (fPainter->Pattern() == B_SOLID_LOW + && fPainter->DrawingMode() == B_OP_COPY) { BRegion region(r); region.IntersectWith(fPainter->ClippingRegion()); - fGraphicsCard->FillRegion(region, d->LowColor(), + fGraphicsCard->FillRegion(region, fPainter->LowColor(), fSuspendSyncLevel == 0 || cursorTouched); doInSoftware = false; @@ -815,7 +826,6 @@ } } if (doInSoftware) { -// fPainter->SetDrawState(d); fPainter->FillRect(r); fGraphicsCard->Invalidate(r); @@ -828,7 +838,7 @@ void -DrawingEngine::FillRegion(BRegion& r, const DrawState *d) +DrawingEngine::FillRegion(BRegion& r) { CRASH_IF_NOT_LOCKED @@ -839,18 +849,18 @@ bool doInSoftware = true; // try hardware optimized version first if ((fAvailableHWAccleration & HW_ACC_FILL_REGION) != 0) { - if (d->GetPattern() == B_SOLID_HIGH - && (d->GetDrawingMode() == B_OP_COPY - || d->GetDrawingMode() == B_OP_OVER)) { + if (fPainter->Pattern() == B_SOLID_HIGH [... truncated: 702 lines follow ...] From stippi at mail.berlios.de Sun Jul 22 22:04:15 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 22 Jul 2007 22:04:15 +0200 Subject: [Haiku-commits] r21686 - haiku/trunk/src/servers/app/drawing/Painter Message-ID: <200707222004.l6MK4Ff4022782@sheep.berlios.de> Author: stippi Date: 2007-07-22 22:04:14 +0200 (Sun, 22 Jul 2007) New Revision: 21686 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21686&view=rev Modified: haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp Log: * last commit broke rendering dots (though it should have been just more work and no visual change... don't know why) -> fixed Modified: haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp 2007-07-22 19:48:27 UTC (rev 21685) +++ haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp 2007-07-22 20:04:14 UTC (rev 21686) @@ -292,10 +292,12 @@ && (fDrawingMode == B_OP_COPY || fDrawingMode == B_OP_OVER)) { pattern pat = *fPatternHandler.GetR5Pattern(); - if (pat == B_SOLID_HIGH && - StraightLine(a, b, fPatternHandler.HighColor().GetColor32())) { - } else if (pat == B_SOLID_LOW && - StraightLine(a, b, fPatternHandler.LowColor().GetColor32())) { + if (pat == B_SOLID_HIGH + && StraightLine(a, b, fPatternHandler.HighColor().GetColor32())) { + return; + } else if (pat == B_SOLID_LOW + && StraightLine(a, b, fPatternHandler.LowColor().GetColor32())) { + return; } } From axeld at pinc-software.de Mon Jul 23 00:08:47 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Mon, 23 Jul 2007 00:08:47 +0200 CEST Subject: [Haiku-commits] r21683 - haiku/trunk/src/kits/interface In-Reply-To: <200707221929.l6MJTvFO021422@sheep.berlios.de> Message-ID: <5681249001-BeMail@zon> stippi at BerliOS wrote: > Log: > * rearranged includes > > Modified: haiku/trunk/src/kits/interface/PictureDataWriter.cpp > =================================================================== > --- haiku/trunk/src/kits/interface/PictureDataWriter.cpp 2007-07-22 > 13:34:54 UTC (rev 21682) > +++ haiku/trunk/src/kits/interface/PictureDataWriter.cpp 2007-07-22 > 19:29:56 UTC (rev 21683) > @@ -6,15 +6,16 @@ > * Stefano Ceccherini (burton666 at libero.it) > */ > > +#include > + > +#include > + > #include > #include > #include > > -#include > #include > > -#include I notice your preferred way of arranging includes at least differs from mine, but probably we'll all have different ones. Maybe it's a good idea to find a common way on how to do that, and add that to our coding style? For the record, this is how I do it: put the most private/specific header first, and the most public/generic header last. Ie. local headers first, Be API is less generic than the POSIX API, etc. Within those blocks, I order the included headers alphabetically. This has the added benefit that most headers are tested if they are self-contained automatically (but at least that one thing we seem to have in common, anyway :-)). Bye, Axel. From axeld at mail.berlios.de Mon Jul 23 01:50:34 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 23 Jul 2007 01:50:34 +0200 Subject: [Haiku-commits] r21687 - haiku/trunk/src/servers/app Message-ID: <200707222350.l6MNoYZL015527@sheep.berlios.de> Author: axeld Date: 2007-07-23 01:50:34 +0200 (Mon, 23 Jul 2007) New Revision: 21687 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21687&view=rev Modified: haiku/trunk/src/servers/app/ClientMemoryAllocator.cpp Log: My ClientMemoryAllocator implementation wasn't complete and badly leaked memory. It now at least frees all memory when the object is deleted. Reported by Jonas - thanks! Modified: haiku/trunk/src/servers/app/ClientMemoryAllocator.cpp =================================================================== --- haiku/trunk/src/servers/app/ClientMemoryAllocator.cpp 2007-07-22 20:04:14 UTC (rev 21686) +++ haiku/trunk/src/servers/app/ClientMemoryAllocator.cpp 2007-07-22 23:50:34 UTC (rev 21687) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -42,6 +42,24 @@ ClientMemoryAllocator::~ClientMemoryAllocator() { + // delete all areas and chunks/blocks that are still allocated + + while (true) { + struct block* block = fFreeBlocks.RemoveHead(); + if (block == NULL) + break; + + free(block); + } + + while (true) { + struct chunk* chunk = fChunks.RemoveHead(); + if (chunk == NULL) + break; + + delete_area(chunk->area); + free(chunk); + } } From axeld at mail.berlios.de Mon Jul 23 02:52:10 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 23 Jul 2007 02:52:10 +0200 Subject: [Haiku-commits] r21689 - haiku/trunk/src/system/kernel/vm Message-ID: <200707230052.l6N0qAKQ020621@sheep.berlios.de> Author: axeld Date: 2007-07-23 02:52:07 +0200 (Mon, 23 Jul 2007) New Revision: 21689 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21689&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp Log: Fixed debug output. Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2007-07-23 00:15:45 UTC (rev 21688) +++ haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2007-07-23 00:52:07 UTC (rev 21689) @@ -481,7 +481,7 @@ || cache->consumers.link.next != cache->consumers.link.prev || consumer != list_get_first_item(&cache->consumers)) { dprintf("vm_cache_remove_consumer(): cache %p was modified; " - "not merging it\n"); + "not merging it\n", cache); merge = false; cache->busy = false; mutex_unlock(&consumer->lock); From axeld at pinc-software.de Mon Jul 23 02:46:10 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Mon, 23 Jul 2007 02:46:10 +0200 CEST Subject: [Haiku-commits] =?iso-8859-15?q?r21685_-_in_haiku/trunk=3A_header?= =?iso-8859-15?q?s/private/app_src/servers/app_src/servers/app/drawing_src?= =?iso-8859-15?q?/servers/app/drawing/Painter_src/servers/app/drawing/Pain?= =?iso-8859-15?q?ter/font=5Fsupport?= In-Reply-To: <200707221948.l6MJmTUv022230@sheep.berlios.de> Message-ID: <15124470411-BeMail@zon> stippi at BerliOS wrote: > * fixed bug #1300, fCurrentLayer was not updated when a ViewLayer was > deleted by client request which happened to be fCurrentLayer (I am > now > handling it so that the parent becomes the current layer, could be > wrong) That depends on whatever we do client side - which is nothing - so it doesn't matter in the end; the client should always set a new current layer when it removed the former one. It's a bit strange that this bug existed at all, methinks, especially because moving the Deskbar around worked fine previously... (which doesn't mean the server shouldn't handle it gracefully) Could be some bug in the client, too - after all, it does something with a view that already got removed. Bye, Axel. From axeld at mail.berlios.de Mon Jul 23 02:57:46 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 23 Jul 2007 02:57:46 +0200 Subject: [Haiku-commits] r21690 - haiku/trunk/headers/build Message-ID: <200707230057.l6N0vkmE021051@sheep.berlios.de> Author: axeld Date: 2007-07-23 02:57:45 +0200 (Mon, 23 Jul 2007) New Revision: 21690 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21690&view=rev Modified: haiku/trunk/headers/build/HaikuBuildCompatibility.h Log: * Added a small intro to what this file is about. * Added a socklen_t typedef. Modified: haiku/trunk/headers/build/HaikuBuildCompatibility.h =================================================================== --- haiku/trunk/headers/build/HaikuBuildCompatibility.h 2007-07-23 00:52:07 UTC (rev 21689) +++ haiku/trunk/headers/build/HaikuBuildCompatibility.h 2007-07-23 00:57:45 UTC (rev 21690) @@ -1,6 +1,14 @@ #ifndef HAIKU_BUILD_COMPATIBILITY_H #define HAIKU_BUILD_COMPATIBILITY_H +/*! + This header is automatically included in all Haiku applications + that are built for BeOS. + It will make BeOS a bit more Haiku compatible, and slightly more + POSIX compatible, too. It is supposed to keep the BeOS compatibility + kludges in our source files at a minimum. +*/ + #include #include @@ -16,6 +24,8 @@ typedef unsigned long haiku_build_addr_t; #define addr_t haiku_build_addr_t +typedef int socklen_t; + #ifndef DEFFILEMODE # define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) #endif From axeld at mail.berlios.de Mon Jul 23 02:59:31 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 23 Jul 2007 02:59:31 +0200 Subject: [Haiku-commits] r21691 - haiku/trunk/headers/private/kernel Message-ID: <200707230059.l6N0xVAp021213@sheep.berlios.de> Author: axeld Date: 2007-07-23 02:59:30 +0200 (Mon, 23 Jul 2007) New Revision: 21691 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21691&view=rev Modified: haiku/trunk/headers/private/kernel/debug.h Log: Unconditionally enable all ASSERTs in the kernel for now; should obviously be turned off for non-development releases later :-) Modified: haiku/trunk/headers/private/kernel/debug.h =================================================================== --- haiku/trunk/headers/private/kernel/debug.h 2007-07-23 00:57:45 UTC (rev 21690) +++ haiku/trunk/headers/private/kernel/debug.h 2007-07-23 00:59:30 UTC (rev 21691) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006, Axel D?rfler, axeld at pinc-software.de + * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de * Distributed under the terms of the Haiku License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -11,7 +11,7 @@ #include -//#define DEBUG 1 +#define KDEBUG 1 #if DEBUG /* From axeld at mail.berlios.de Mon Jul 23 02:15:45 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 23 Jul 2007 02:15:45 +0200 Subject: [Haiku-commits] r21688 - haiku/trunk/src/tools/remote_disk_server Message-ID: <200707230015.l6N0FjdD018070@sheep.berlios.de> Author: axeld Date: 2007-07-23 02:15:45 +0200 (Mon, 23 Jul 2007) New Revision: 21688 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21688&view=rev Modified: haiku/trunk/src/tools/remote_disk_server/Jamfile haiku/trunk/src/tools/remote_disk_server/remote_disk_server.cpp Log: * Fixed build under BeOS/Dano (only tried the latter, though). * Does anybody know why HaikuBuildCompatibility.h is not included for tools when compiled on BeOS/Dano? Modified: haiku/trunk/src/tools/remote_disk_server/Jamfile =================================================================== --- haiku/trunk/src/tools/remote_disk_server/Jamfile 2007-07-22 23:50:34 UTC (rev 21687) +++ haiku/trunk/src/tools/remote_disk_server/Jamfile 2007-07-23 00:15:45 UTC (rev 21688) @@ -4,5 +4,5 @@ BuildPlatformMain remote_disk_server : remote_disk_server.cpp - : $(HOST_LIBSUPC++) + : $(HOST_LIBSUPC++) $(NETWORK_LIBS) ; Modified: haiku/trunk/src/tools/remote_disk_server/remote_disk_server.cpp =================================================================== --- haiku/trunk/src/tools/remote_disk_server/remote_disk_server.cpp 2007-07-22 23:50:34 UTC (rev 21687) +++ haiku/trunk/src/tools/remote_disk_server/remote_disk_server.cpp 2007-07-23 00:15:45 UTC (rev 21688) @@ -1,5 +1,5 @@ /* - * Copyright 2005, Ingo Weinhold . + * Copyright 2005-2007, Ingo Weinhold . * All rights reserved. Distributed under the terms of the MIT License. */ @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -17,7 +16,14 @@ #include +#if defined(__BEOS__) && !defined(__HAIKU__) +# include +typedef int socklen_t; +#else +# include +#endif + #if __BYTE_ORDER == __LITTLE_ENDIAN static inline From stefano.ceccherini at gmail.com Mon Jul 23 08:40:15 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 23 Jul 2007 08:40:15 +0200 Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal In-Reply-To: <648424625-BeMail@laptop> References: <894b9700707220627g7d3689f6xfaf9478767e75f63@mail.gmail.com> <648424625-BeMail@laptop> Message-ID: <894b9700707222340g28952f94ufc128b0910fdbd2d@mail.gmail.com> 2007/7/22, Fran?ois Revol : > It would be nice to be able to replicate Terminal someday... to for ex > embed it in an IDE. Seems it's going the good way at least. Yeah, that' s one thing I'd like to see too. The other thing is tabbed terminal, which I've been asked by a friend. If someone is against this, I'll leave the code disabled. Of course, IF I manage to implement it. From axeld at pinc-software.de Mon Jul 23 10:30:56 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Mon, 23 Jul 2007 10:30:56 +0200 CEST Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal In-Reply-To: <894b9700707222340g28952f94ufc128b0910fdbd2d@mail.gmail.com> Message-ID: <2885141308-BeMail@zon> "Stefano Ceccherini" wrote: > 2007/7/22, Fran?ois Revol : > > It would be nice to be able to replicate Terminal someday... to for > > ex > > embed it in an IDE. Seems it's going the good way at least. > Yeah, that' s one thing I'd like to see too. The other thing is > tabbed > terminal, which I've been asked by a friend. If someone is against > this, I'll leave the code disabled. Of course, IF I manage to > implement it. As long as it's optional, I don't think anyone will object (optional in the sense that it doesn't steal any screen estate if you're not using it). Bye, Axel. From stefano.ceccherini at gmail.com Mon Jul 23 11:04:34 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 23 Jul 2007 11:04:34 +0200 Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal In-Reply-To: <2885141308-BeMail@zon> References: <894b9700707222340g28952f94ufc128b0910fdbd2d@mail.gmail.com> <2885141308-BeMail@zon> Message-ID: <894b9700707230204k376ff865ibc27822e8caf54cd@mail.gmail.com> 2007/7/23, Axel D?rfler : > As long as it's optional, I don't think anyone will object (optional in > the sense that it doesn't steal any screen estate if you're not using > it). Of course not. I'd hate that :) From superstippi at gmx.de Mon Jul 23 15:32:30 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Mon, 23 Jul 2007 15:32:30 +0200 Subject: [Haiku-commits] r21683 - haiku/trunk/src/kits/interface In-Reply-To: <5681249001-BeMail@zon> References: <5681249001-BeMail@zon> Message-ID: <20070723153230.699.1@stippis2.1185197340.fake> Hi Axel, > I notice your preferred way of arranging includes at least differs from > mine, but probably we'll all have different ones. > Maybe it's a good idea to find a common way on how to do that, and add > that to our coding style? > > For the record, this is how I do it: put the most private/specific header > first, and the most public/generic header last. Ie. local headers first, > Be API is less generic than the POSIX API, etc. Within those blocks, I > order the included headers alphabetically. > > This has the added benefit that most headers are tested if they are > self-contained automatically (but at least that one thing we seem to have > in common, anyway :-)). Yeah, I can do it like that from now on. It was an old change I came across, I don't know why I made it back then, but I guess it was because of a non-selfcontained header. Best regards, -Stephan From superstippi at gmx.de Mon Jul 23 15:38:39 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Mon, 23 Jul 2007 15:38:39 +0200 Subject: [Haiku-commits] r21685 - in haiku/trunk: headers/private/app src/servers/app src/servers/app/drawing src/servers/app/drawing/Painter src/servers/app/drawing/Painter/font_support In-Reply-To: <15124470411-BeMail@zon> References: <15124470411-BeMail@zon> Message-ID: <20070723153839.730.2@stippis2.1185197340.fake> Axel D?rfler wrote (2007-07-23, 02:46:10 [+0200]): > stippi at BerliOS wrote: > > * fixed bug #1300, fCurrentLayer was not updated when a ViewLayer was > > deleted by client request which happened to be fCurrentLayer (I am > > now > > handling it so that the parent becomes the current layer, could be > > wrong) > > That depends on whatever we do client side - which is nothing - so it > doesn't matter in the end; the client should always set a new current > layer when it removed the former one. > It's a bit strange that this bug existed at all, methinks, especially > because moving the Deskbar around worked fine previously... (which > doesn't mean the server shouldn't handle it gracefully) Could be some bug > in the client, too - after all, it does something with a view that > already got removed. No, it wasn't like that. The bug got exposed after my first round of changes to the DrawState handling, in which I needed to reset the correct Painter state after the WindowLayer has drawn itself with the decorator. At that point, fCurrentLayer was used, appearently when it still pointed to a removed ViewLayer in case of DeskBar. The client didn't actually use the ViewLayer, it was just that the pointer was stale when the ServerWindow tried to use it by itself, without client request, when trying to restore the graphics state. The other bug was AS_SYNC being handled as a view message, which got exposed when I set fCurrentLayer to NULL after removing a view (then it wasn't handled anymore). It seems like ServerWindow thinks fCurrentLayer being NULL means no views have been attached at all yet, and that's why I used the parent ViewLayer, so that I didn't have to mess with this too much. I do seem to remember that it used to be like that too, before I got to code much on the app_server. Best regards, -Stephan From laplace at mail.berlios.de Mon Jul 23 18:23:44 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Mon, 23 Jul 2007 18:23:44 +0200 Subject: [Haiku-commits] r21692 - haiku/trunk/src/preferences/print Message-ID: <200707231623.l6NGNiEc029847@sheep.berlios.de> Author: laplace Date: 2007-07-23 18:23:43 +0200 (Mon, 23 Jul 2007) New Revision: 21692 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21692&view=rev Modified: haiku/trunk/src/preferences/print/Printers.rdef Log: Updated copyright year Modified: haiku/trunk/src/preferences/print/Printers.rdef =================================================================== --- haiku/trunk/src/preferences/print/Printers.rdef 2007-07-23 00:59:30 UTC (rev 21691) +++ haiku/trunk/src/preferences/print/Printers.rdef 2007-07-23 16:23:43 UTC (rev 21692) @@ -15,7 +15,7 @@ internal = 0, short_info = "Printers", - long_info = "Printers ?2001-2006 Haiku" + long_info = "Printers ?2001-2007 Haiku" }; #ifdef HAIKU_TARGET_PLATFORM_HAIKU From laplace at mail.berlios.de Mon Jul 23 20:10:13 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Mon, 23 Jul 2007 20:10:13 +0200 Subject: [Haiku-commits] r21693 - haiku/trunk/src/preferences/print Message-ID: <200707231810.l6NIADeN018058@sheep.berlios.de> Author: laplace Date: 2007-07-23 20:10:13 +0200 (Mon, 23 Jul 2007) New Revision: 21693 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21693&view=rev Modified: haiku/trunk/src/preferences/print/PrinterListView.cpp haiku/trunk/src/preferences/print/Printers.rdef Log: Fixed issue #1313 (2 kind of printer icons). For the selected printer the Printers preflet icon was used. For not selected printer the Printer filetype icon is used. The change of the Printers preflet icon to the vector format changed its appearance, so the two did not match anymore. Using the Printers preflet icon for the selected printer is a sub-optimal solution. Now the selected printer icon is created at runtime. A check mark bitmap is drawn over the "not selected" printer icon. Someone feel free to create a version in vector format of that bitmap. Modified: haiku/trunk/src/preferences/print/PrinterListView.cpp =================================================================== --- haiku/trunk/src/preferences/print/PrinterListView.cpp 2007-07-23 16:23:43 UTC (rev 21692) +++ haiku/trunk/src/preferences/print/PrinterListView.cpp 2007-07-23 18:10:13 UTC (rev 21693) @@ -215,9 +215,36 @@ } if (sSelectedIcon == NULL) { - sSelectedIcon = new BBitmap(BRect(0,0,B_LARGE_ICON-1,B_LARGE_ICON-1), B_CMAP8); - BMimeType type(PRNT_SIGNATURE_TYPE); - type.GetIcon(sSelectedIcon, B_LARGE_ICON); + BBitmap *checkMark = LoadBitmap("check_mark_icon", 'BBMP'); + if (checkMark == NULL) { + BAlert *alert = new BAlert("Error", + "Fatal error: Check mark icon could not be loaded from resources!", + "Bye"); + alert->Go(); + exit(1); + } + + // draw check mark at bottom left over printer icon + sSelectedIcon = new BBitmap(sIcon->Bounds(), B_RGBA32, true); + if (!sSelectedIcon->IsValid()) { + BAlert *alert = new BAlert("Error", + "Fatal error: Bitmap could not be created for selected printer icon!", + "Bye"); + alert->Go(); + exit(1); + } + BView *view = new BView(sIcon->Bounds(), "offscreen", B_FOLLOW_ALL, B_WILL_DRAW); + float y = sIcon->Bounds().Height() - checkMark->Bounds().Height(); + sSelectedIcon->Lock(); + sSelectedIcon->AddChild(view); + view->DrawBitmap(sIcon); + view->SetDrawingMode(B_OP_ALPHA); + view->DrawBitmap(checkMark, BPoint(0, y)); + view->Sync(); + view->RemoveSelf(); + sSelectedIcon->Unlock(); + delete view; + delete checkMark; } // Get Name of printer Modified: haiku/trunk/src/preferences/print/Printers.rdef =================================================================== --- haiku/trunk/src/preferences/print/Printers.rdef 2007-07-23 16:23:43 UTC (rev 21692) +++ haiku/trunk/src/preferences/print/Printers.rdef 2007-07-23 18:10:13 UTC (rev 21693) @@ -102,6 +102,55 @@ resource(1, "BEOS:FILE_TYPES") message; +resource(102, "check_mark_icon") #'BBMP' archive BBitmap { + "_frame" = rect { 0.00000, 0.00000, 15.0000, 19.0000 }, + "_cspace" = 8200, + "_bmflags" = 1, + "_rowbytes" = 64, + "_data" = array { + $"FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"FFFFFF00FFFFFF00FFFFFF00FFFFFF00000000FF000000FFFFFFFF00FFFFFF00" + $"FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"FFFFFF00FFFFFF00FFFFFF00000000FF6666FFFF6666FFFF000000FFFFFFFF00" + $"FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"FFFFFF00FFFFFF00FFFFFF00000000FFCBCBFFFF6666FFFF6666FFFF000000FF" + $"FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"FFFFFF00FFFFFF00000000FF0000E4FF0000E4FFCBCBFFFF6666FFFF000000FF" + $"FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"FFFFFF00FFFFFF00000000FF0000E4FF000080FF000080FF000000FFFFFFFF00" + $"FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"FFFFFF00000000FF0000E4FF0000CBFF000098FF000080FF000000FFFFFFFF00" + $"FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"FFFFFF00000000FF0000E4FF000080FF000080FF000000FFFFFFFF00FFFFFF00" + $"FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"000000FF0000E4FF0000CBFF000098FF000080FF000000FFFFFFFF00FFFFFF00" + $"FFFFFF00FFFFFF00000000FF000000FF000000FFFFFFFF00FFFFFF00FFFFFF00" + $"000000FF0000E4FF000080FF000080FF000000FFFFFFFF00FFFFFF00FFFFFF00" + $"FFFFFF00000000FF6666FFFF6666FFFF6666FFFF000000FFFFFFFF00000000FF" + $"0000E4FF0000CBFF000098FF000080FF000000FFFFFFFF00FFFFFF00FFFFFF00" + $"000000FF6666FFFF6666FFFF6666FFFFCBCBFFFF000000FFFFFFFF00000000FF" + $"0000E4FF000080FF000080FF000000FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"000000FF0000E4FF0000CBFFCBCBFFFF6666FFFF6666FFFF000000FF0000E4FF" + $"0000CBFF000098FF000080FF000000FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"FFFFFF00000000FF0000E4FF0000CBFFCBCBFFFF6666FFFF0000E4FF0000CBFF" + $"000098FF000080FF000000FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"FFFFFF00000000FF0000E4FF0000CBFFCBCBFFFF6666FFFF0000E4FF0000CBFF" + $"000098FF000080FF000000FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"FFFFFF00FFFFFF00000000FF0000E4FF0000CBFF0000E4FF0000E4FF000080FF" + $"000080FF000000FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"FFFFFF00FFFFFF00000000FF0000E4FF0000CBFF0000E4FF0000E4FF000080FF" + $"000080FF000000FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"FFFFFF00FFFFFF00FFFFFF00000000FF0000E4FF0000CBFF000098FF000080FF" + $"000000FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"FFFFFF00FFFFFF00FFFFFF00000000FF0000E4FF0000CBFF000098FF000080FF" + $"000000FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"FFFFFF00FFFFFF00FFFFFF00FFFFFF00000000FF0000E4FF000080FF000000FF" + $"FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00" + $"FFFFFF00FFFFFF00FFFFFF00FFFFFF00000000FF000000FF000000FFFFFFFF00" + $"FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00" + } +}; + resource(0, "init_icon") #'bits' array { $"424D369000000000000036000000280000004000000090000000010020000000" $"000000900000130B0000130B00000000000000000000808080FFFFFFFFFFFFFF" From leavengood at gmail.com Mon Jul 23 21:16:36 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Mon, 23 Jul 2007 15:16:36 -0400 Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal In-Reply-To: <894b9700707222340g28952f94ufc128b0910fdbd2d@mail.gmail.com> References: <894b9700707220627g7d3689f6xfaf9478767e75f63@mail.gmail.com> <648424625-BeMail@laptop> <894b9700707222340g28952f94ufc128b0910fdbd2d@mail.gmail.com> Message-ID: On 7/23/07, Stefano Ceccherini wrote: > > Yeah, that' s one thing I'd like to see too. The other thing is tabbed > terminal, which I've been asked by a friend. If someone is against > this, I'll leave the code disabled. Of course, IF I manage to > implement it. I was thinking a tabbed terminal would be nice too, since I've gotten used to that with the GNOME Terminal. I also like the tabs in gEdit, which got me to thinking that maybe StyledEdit could have tabs too. But is a single window with multiple tabs somehow against the "BeOS philosophy"? Though I suppose it is our job to update that philosophy since many parts of it may be dated. I for one need a web browser with tabs, and plan to add that in the browser I'll be writing. Ryan From nielx at mail.berlios.de Tue Jul 24 00:41:59 2007 From: nielx at mail.berlios.de (nielx at BerliOS) Date: Tue, 24 Jul 2007 00:41:59 +0200 Subject: [Haiku-commits] r21694 - haiku/trunk/docs/user/drivers Message-ID: <200707232241.l6NMfxX3023678@sheep.berlios.de> Author: nielx Date: 2007-07-24 00:41:58 +0200 (Tue, 24 Jul 2007) New Revision: 21694 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21694&view=rev Modified: haiku/trunk/docs/user/drivers/fs_interface.dox Log: Fix a mistake. \code should always be closed by \endcode, else doxygen will stop parsing (even if a documentation block ends). Modified: haiku/trunk/docs/user/drivers/fs_interface.dox =================================================================== --- haiku/trunk/docs/user/drivers/fs_interface.dox 2007-07-23 18:10:13 UTC (rev 21693) +++ haiku/trunk/docs/user/drivers/fs_interface.dox 2007-07-23 22:41:58 UTC (rev 21694) @@ -5,7 +5,7 @@ * Authors: * Ingo Weinhold * Niels Sascha Reedijk - * Axel D?rfler, axeld at pinc-software.de + * Axel D?rfler * * Corresponds to: * /trunk/headers/os/drivers/fs_interface.h rev 21568 @@ -98,7 +98,7 @@ The module name that exports the interface to your file system has to end with this constant as in: - \code "file_systems/myfs" B_CURRENT_FS_API_VERSION + \code "file_systems/myfs" B_CURRENT_FS_API_VERSION \endcode */ ///// file_system_module_info ///// From jonas at kirilla.com Tue Jul 24 13:45:21 2007 From: jonas at kirilla.com (Jonas =?iso-8859-1?q?Sundstr=F6m?=) Date: Tue, 24 Jul 2007 13:45:21 +0200 CEST Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal In-Reply-To: Message-ID: <2065069285-BeMail@kirilla> "Ryan Leavengood" wrote: > On 7/23/07, Stefano Ceccherini wrote: > > > > Yeah, that' s one thing I'd like to see too. The other thing is > > tabbed > > terminal, which I've been asked by a friend. If someone is against > > this, I'll leave the code disabled. Of course, IF I manage to > > implement it. > > I was thinking a tabbed terminal would be nice too, since I've gotten > used to that with the GNOME Terminal. I also like the tabs in gEdit, > which got me to thinking that maybe StyledEdit could have tabs too. > But is a single window with multiple tabs somehow against the "BeOS > philosophy"? Though I suppose it is our job to update that philosophy > since many parts of it may be dated. > > I for one need a web browser with tabs, and plan to add that in the > browser I'll be writing. Tabs (or sub-windows) can only be switched between within the application itself and are not available to system-wide window management like that of Alt-Tab (the switcher) or Deskbar. Tabbed browsing works in FireFox, I suppose, but what does it provide that the system doesn't already provide? Why would we want to increase this divide (app-context vs system-context) by having applications effectively hide extra windows? Even with system-standard tab-management keyboard shortcuts it's hardly a step forward, IMO. /Jonas. From axeld at pinc-software.de Tue Jul 24 13:46:47 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 24 Jul 2007 13:46:47 +0200 CEST Subject: [Haiku-commits] r21694 - haiku/trunk/docs/user/drivers In-Reply-To: <200707232241.l6NMfxX3023678@sheep.berlios.de> Message-ID: <10305494915-BeMail@ibm> nielx at BerliOS wrote: > Log: > Fix a mistake. \code should always be closed by \endcode, else > doxygen will stop > parsing (even if a documentation block ends). Thanks! Bye, Axel. From jackburton at mail.berlios.de Tue Jul 24 14:18:25 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 24 Jul 2007 14:18:25 +0200 Subject: [Haiku-commits] r21695 - haiku/trunk/src/apps/terminal Message-ID: <200707241218.l6OCIP5q003421@sheep.berlios.de> Author: jackburton Date: 2007-07-24 14:18:24 +0200 (Tue, 24 Jul 2007) New Revision: 21695 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21695&view=rev Modified: haiku/trunk/src/apps/terminal/PrefView.cpp haiku/trunk/src/apps/terminal/Shell.cpp haiku/trunk/src/apps/terminal/Shell.h haiku/trunk/src/apps/terminal/TermConst.h haiku/trunk/src/apps/terminal/TermParse.cpp haiku/trunk/src/apps/terminal/TermParse.h haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h haiku/trunk/src/apps/terminal/TermWindow.cpp Log: Moved cursor blinking functionality from TermParse into TermView (and from a BMessageRunner into Pulse()). Removed more unused stuff. Moved around some constants and definitions. Many style changes. Sorry, I know the two should be separated, but I had already done so many changes... Modified: haiku/trunk/src/apps/terminal/PrefView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/PrefView.cpp 2007-07-23 22:41:58 UTC (rev 21694) +++ haiku/trunk/src/apps/terminal/PrefView.cpp 2007-07-24 12:18:24 UTC (rev 21695) @@ -1,4 +1,5 @@ /* + * Copyright 2007 Haiku * Copyright (c) 2003-4 Kian Duffy * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * @@ -28,35 +29,23 @@ * */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "PrefView.h" #include "PrefHandler.h" #include "TermConst.h" -#include "PrefView.h" #include "TTextControl.h" -/************************************************************************ - * - * PUBLIC MEMBER FUNCTIONS. - * - ***********************************************************************/ +#include +#include +#include + //////////////////////////////////////////////////////////////////////////// // PrefView () // Constructor. //////////////////////////////////////////////////////////////////////////// -PrefView::PrefView (BRect frame, const char *name) - :BView (frame, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW) +PrefView::PrefView(BRect frame, const char *name) + :BView(frame, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fLabel.SetTo(name); @@ -73,18 +62,18 @@ const char * -PrefView::ViewLabel (void) const +PrefView::ViewLabel() const { - return fLabel.String(); + return fLabel.String(); } //////////////////////////////////////////////////////////////////////////// // CanApply() -// Determines whether view can respont Apply command or not. +// Determines whether view can reply to Apply command or not. //////////////////////////////////////////////////////////////////////////// bool -PrefView::CanApply () +PrefView::CanApply() { return true; } @@ -115,10 +104,10 @@ // Make BColorControl. ////////////////////////////////////////////////////////////////////////////// BColorControl * -PrefView::SetupBColorControl(BPoint p, color_control_layout layout, float cell_size, ulong msg) +PrefView::SetupBColorControl(BPoint point, color_control_layout layout, float cellSize, ulong message) { - BColorControl *col = new BColorControl( p, layout, cell_size, "", new BMessage(msg)); - AddChild(col); - return col; + BColorControl *control = new BColorControl(point, layout, cellSize, "", new BMessage(message)); + AddChild(control); + return control; } Modified: haiku/trunk/src/apps/terminal/Shell.cpp =================================================================== --- haiku/trunk/src/apps/terminal/Shell.cpp 2007-07-23 22:41:58 UTC (rev 21694) +++ haiku/trunk/src/apps/terminal/Shell.cpp 2007-07-24 12:18:24 UTC (rev 21695) @@ -107,12 +107,10 @@ #define PTY_WS 2 /* pty need WINSIZE (row and col ) */ -static pid_t sShPid; - - Shell::Shell() : fFd(-1), + fProcessID(-1), fTermParse(NULL), fAttached(false) { @@ -152,7 +150,8 @@ if (fFd >= 0) { close(fFd); - kill(-sShPid, SIGHUP); + kill(-fProcessID, SIGHUP); + fProcessID = -1; int status; wait(&status); fFd = -1; @@ -187,21 +186,21 @@ } -void +status_t Shell::UpdateWindowSize(int rows, int columns) { struct winsize winSize; winSize.ws_row = rows; winSize.ws_col = columns; ioctl(fFd, TIOCSWINSZ, &winSize); - Signal(SIGWINCH); + return Signal(SIGWINCH); } -void +status_t Shell::Signal(int signal) { - kill(-sShPid, signal); + return send_signal(-fProcessID, signal); } @@ -316,7 +315,7 @@ thread_id terminalThread = find_thread(NULL); /* Fork a child process. */ - if ((sShPid = fork()) < 0) { + if ((fProcessID = fork()) < 0) { close(master); return B_ERROR; } @@ -324,7 +323,7 @@ handshake_t handshake; - if (sShPid == 0) { + if (fProcessID == 0) { // Now in child process. /* @@ -583,7 +582,7 @@ handshake.row = row; handshake.col = col; handshake.status = PTY_WS; - send_handshake_message(sShPid, handshake); + send_handshake_message(fProcessID, handshake); break; } } Modified: haiku/trunk/src/apps/terminal/Shell.h =================================================================== --- haiku/trunk/src/apps/terminal/Shell.h 2007-07-23 22:41:58 UTC (rev 21694) +++ haiku/trunk/src/apps/terminal/Shell.h 2007-07-24 12:18:24 UTC (rev 21695) @@ -97,8 +97,8 @@ ssize_t Read(void *buffer, size_t numBytes); ssize_t Write(const void *buffer, size_t numBytes); - void UpdateWindowSize(int row, int columns); - void Signal(int signal); + status_t UpdateWindowSize(int row, int columns); + status_t Signal(int signal); status_t GetAttr(struct termios &attr); status_t SetAttr(struct termios &attr); @@ -110,6 +110,7 @@ private: int fFd; + pid_t fProcessID; TermParse *fTermParse; bool fAttached; Modified: haiku/trunk/src/apps/terminal/TermConst.h =================================================================== --- haiku/trunk/src/apps/terminal/TermConst.h 2007-07-23 22:41:58 UTC (rev 21694) +++ haiku/trunk/src/apps/terminal/TermConst.h 2007-07-24 12:18:24 UTC (rev 21695) @@ -40,6 +40,9 @@ // Message constants for menu items +#include + + // Menu Message const uint32 MENU_SWITCH_TERM = 'MSWT'; const uint32 MENU_NEW_TERM = 'MNTE'; @@ -59,7 +62,6 @@ const uint32 M_GET_DEVICE_NUM = 'Mgdn'; // Message Runner -const uint32 MSGRUN_CURSOR = 'Rcur'; const uint32 MSGRUN_WINDOW = 'Rwin'; // Preference Message @@ -144,14 +146,6 @@ #define MODE_OVER 0 #define MODE_INSERT 1 -const float VIEW_OFFSET = 3; - -#define CURSOR_RECT \ - BRect r (fFontWidth * fCurPos.x, \ - fFontHeight * fCurPos.y + fTop, \ - fFontWidth * (fCurPos.x + 1) - 1, \ - fFontHeight * fCurPos.y + fTop + fCursorHeight - 1) - // Define TermBuffer internal code #define NO_CHAR 0x00 #define A_CHAR 0x01 @@ -186,8 +180,5 @@ #define FORECOLORED(x) ((x) << 3) #define BACKCOLORED(x) ((x) << 0) -// TypeDefs -typedef unsigned short ushort; - #endif // TERMCONST_H_INCLUDED Modified: haiku/trunk/src/apps/terminal/TermParse.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-23 22:41:58 UTC (rev 21694) +++ haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-24 12:18:24 UTC (rev 21695) @@ -4,6 +4,13 @@ * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * Distributed under the terms of the MIT license. */ +#include "TermParse.h" + +#include "CodeConv.h" +#include "TermConst.h" +#include "TermView.h" +#include "VTparse.h" + #include #include #include @@ -13,13 +20,7 @@ #include #include #include -#include -#include "TermParse.h" -#include "TermView.h" -#include "VTparse.h" -#include "TermConst.h" -#include "CodeConv.h" ////////////////////////////////////////////////////////////////////////////// // EscParse ... Escape sequence parse and character encoding. @@ -50,16 +51,14 @@ TermParse::TermParse(int fd) : fFd(fd), - fViewObj(NULL), fParseThread(-1), - fParseSem(-1), fReaderThread(-1), fReaderSem(-1), fReaderLocker(-1), - fCursorUpdate(NULL), - fParser_p(0), + fBufferPosition(0), fLockFlag(0), - fQuitting(false) + fView(NULL), + fQuitting(true) { } @@ -73,16 +72,27 @@ status_t TermParse::StartThreads(TermView *view) { - fViewObj = view; + if (fView != NULL) + return B_ERROR; + fQuitting = false; + fView = view; + status_t status = InitPtyReader(); - if (status < B_OK) + if (status < B_OK) { + fView = NULL; return status; + } status = InitTermParse(); if (status < B_OK) { - //AbortPtyReader(); + delete_sem(fReaderSem); + delete_sem(fReaderLocker); + fQuitting = true; + status_t dummy; + wait_for_thread(fReaderThread, &dummy); + fView = NULL; return status; } @@ -93,20 +103,27 @@ status_t TermParse::StopThreads() { + if (fView == NULL) + return B_ERROR; + fQuitting = true; delete_sem(fReaderSem); + fReaderSem = -1; delete_sem(fReaderLocker); + fReaderSem = -1; //suspend_thread(fReaderThread); // TODO: interrupt read() - doesn't work for whatever reason status_t dummy; - wait_for_thread(fReaderThread, &dummy); + wait_for_thread(fReaderThread, &dummy); + fReaderThread = -1; wait_for_thread(fParseThread, &dummy); - - fViewObj = NULL; + fReaderThread = -1; + fView = NULL; + return B_OK; } @@ -118,7 +135,7 @@ uint read_p = 0; while (!fQuitting) { // If Pty Buffer nearly full, snooze this thread, and continue. - if ((read_p - fParser_p) > READ_BUF_SIZE - 16) { + if ((read_p - fBufferPosition) > READ_BUF_SIZE - 16) { fLockFlag = READ_BUF_SIZE / 2; status_t status; do { @@ -130,7 +147,7 @@ // Read PTY uchar buf[READ_BUF_SIZE]; - int nread = read(fFd, buf, READ_BUF_SIZE - (read_p - fParser_p)); + int nread = read(fFd, buf, READ_BUF_SIZE - (read_p - fBufferPosition)); if (nread <= 0) { be_app->PostMessage(B_QUIT_REQUESTED); exit_thread(B_ERROR); @@ -142,10 +159,10 @@ int mod = read_p % READ_BUF_SIZE; if (nread >= left) { - memcpy(fReadBuf + mod, buf, left); - memcpy(fReadBuf, buf + left, nread - left); + memcpy(fReadBuffer + mod, buf, left); + memcpy(fReadBuffer, buf + left, nread - left); } else - memcpy(fReadBuf + mod, buf, nread); + memcpy(fReadBuffer + mod, buf, nread); read_p += nread; @@ -168,12 +185,11 @@ } while (status == B_INTERRUPTED); if (status == B_TIMED_OUT) { - fViewObj->ScrollAtCursor(); - fViewObj->UpdateLine(); + fView->ScrollAtCursor(); + fView->UpdateLine(); // Reset cursor blinking time and turn on cursor blinking. - fCursorUpdate->SetInterval (1000000); - fViewObj->SetCurDraw (CURON); + fView->SetCurDraw(CURON); // wait new input from pty. do { @@ -186,15 +202,15 @@ } else return status; - c = fReadBuf[fParser_p % READ_BUF_SIZE]; - fParser_p++; + c = fReadBuffer[fBufferPosition % READ_BUF_SIZE]; + fBufferPosition++; // If PtyReader thread locked, decrement counter and unlock thread. if (fLockFlag != 0) { if (--fLockFlag == 0) release_sem(fReaderLocker); } - fViewObj->SetCurDraw(CUROFF); + fView->SetCurDraw(CUROFF); return B_OK; } @@ -206,10 +222,6 @@ if (fParseThread >= 0) return B_ERROR; // we might want to return B_OK instead ? - BMessage cursor(MSGRUN_CURSOR); - fCursorUpdate = new BMessageRunner(BMessenger(fViewObj), - &cursor, 1000000); - fParseThread = spawn_thread(_escparse_thread, "EscParse", B_DISPLAY_PRIORITY, this); @@ -314,7 +326,7 @@ cbuf[0] = c; cbuf[1] = '\0'; width = HALF_WIDTH; - fViewObj->PutChar(cbuf, attr, width); + fView->PutChar(cbuf, attr, width); break; case CASE_PRINT_GR: @@ -359,7 +371,7 @@ else CodeConv::ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, M_EUC_JP); - fViewObj->PutChar(dstbuf, attr, width); + fView->PutChar(dstbuf, attr, width); break; case CASE_PRINT_CS96: @@ -369,15 +381,15 @@ cbuf[2] = 0; width = 2; CodeConv::ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, M_EUC_JP); - fViewObj->PutChar(dstbuf, attr, width); + fView->PutChar(dstbuf, attr, width); break; case CASE_LF: - fViewObj->PutLF(); + fView->PutLF(); break; case CASE_CR: - fViewObj->PutCR(); + fView->PutCR(); break; case CASE_SJIS_KANA: @@ -385,7 +397,7 @@ cbuf[1] = '\0'; CodeConv::ConvertToInternal((char*)cbuf, 1, (char*)dstbuf, now_coding); width = 1; - fViewObj->PutChar(dstbuf, attr, width); + fView->PutChar(dstbuf, attr, width); break; case CASE_SJIS_INSTRING: @@ -394,7 +406,7 @@ cbuf[2] = '\0'; CodeConv::ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, now_coding); width = 2; - fViewObj->PutChar(dstbuf, attr, width); + fView->PutChar(dstbuf, attr, width); break; case CASE_UTF8_2BYTE: @@ -405,7 +417,7 @@ cbuf[1] = (uchar)c; cbuf[2] = '\0'; width = CodeConv::UTF8GetFontWidth((char*)cbuf); - fViewObj->PutChar(cbuf, attr, width); + fView->PutChar(cbuf, attr, width); break; case CASE_UTF8_3BYTE: @@ -421,7 +433,7 @@ cbuf[2] = c; cbuf[3] = '\0'; width = CodeConv::UTF8GetFontWidth((char*)cbuf); - fViewObj->PutChar (cbuf, attr, width); + fView->PutChar (cbuf, attr, width); break; case CASE_MBCS: @@ -453,13 +465,13 @@ break; case CASE_BS: - fViewObj->MoveCurLeft(1); + fView->MoveCurLeft(1); break; case CASE_TAB: - tmp = fViewObj->GetCurX(); + tmp = fView->GetCurX(); tmp %= 8; - fViewObj->MoveCurRight(8 - tmp); + fView->MoveCurRight(8 - tmp); break; case CASE_ESC: @@ -519,7 +531,7 @@ /* ICH */ if ((row = param[0]) < 1) row = 1; - fViewObj->InsertSpace(row); + fView->InsertSpace(row); parsestate = groundtable; break; @@ -527,7 +539,7 @@ /* CUU */ if ((row = param[0]) < 1) row = 1; - fViewObj->MoveCurUp(row); + fView->MoveCurUp(row); parsestate = groundtable; break; @@ -535,7 +547,7 @@ /* CUD */ if ((row = param[0]) < 1) row = 1; - fViewObj->MoveCurDown(row); + fView->MoveCurDown(row); parsestate = groundtable; break; @@ -543,7 +555,7 @@ /* CUF */ if ((row = param[0]) < 1) row = 1; - fViewObj->MoveCurRight(row); + fView->MoveCurRight(row); parsestate = groundtable; break; @@ -551,7 +563,7 @@ /* CUB */ if ((row = param[0]) < 1) row = 1; - fViewObj->MoveCurLeft(row); + fView->MoveCurLeft(row); parsestate = groundtable; break; @@ -562,7 +574,7 @@ if (nparam < 2 || (col = param[1]) < 1) col = 1; - fViewObj->SetCurPos(col - 1, row - 1 ); + fView->SetCurPos(col - 1, row - 1 ); parsestate = groundtable; break; @@ -571,15 +583,15 @@ switch (param[0]) { case DEFAULT: case 0: - fViewObj->EraseBelow(); + fView->EraseBelow(); break; case 1: break; case 2: - fViewObj->SetCurPos(0, 0); - fViewObj->EraseBelow(); + fView->SetCurPos(0, 0); + fView->EraseBelow(); break; } parsestate = groundtable; @@ -587,7 +599,7 @@ case CASE_EL: // delete line /* EL */ - fViewObj->DeleteColumns(); + fView->DeleteColumns(); parsestate = groundtable; break; @@ -595,7 +607,7 @@ /* IL */ if ((row = param[0]) < 1) row = 1; - fViewObj->PutNL(row); + fView->PutNL(row); parsestate = groundtable; break; @@ -603,7 +615,7 @@ /* DL */ if ((row = param[0]) < 1) row = 1; - fViewObj->DeleteLine(row); + fView->DeleteLine(row); parsestate = groundtable; break; @@ -611,19 +623,19 @@ /* DCH */ if ((row = param[0]) < 1) row = 1; - fViewObj->DeleteChar(row); + fView->DeleteChar(row); parsestate = groundtable; break; case CASE_SET: /* SET */ - fViewObj->SetInsertMode(MODE_INSERT); + fView->SetInsertMode(MODE_INSERT); parsestate = groundtable; break; case CASE_RST: /* RST */ - fViewObj->SetInsertMode(MODE_OVER); + fView->SetInsertMode(MODE_OVER); parsestate = groundtable; break; @@ -690,7 +702,7 @@ case CASE_CPR: // Q & D hack by Y.Hayakawa (hida at sawada.riec.tohoku.ac.jp) // 21-JUL-99 - fViewObj->DeviceStatusReport(param[0]); + fView->DeviceStatusReport(param[0]); parsestate = groundtable; break; @@ -709,7 +721,7 @@ bot--; if (bot > top) - fViewObj->SetScrollRegion(top, bot); + fView->SetScrollRegion(top, bot); parsestate = groundtable; break; @@ -746,13 +758,13 @@ case CASE_DECSC: /* DECSC */ - fViewObj->SaveCursor(); + fView->SaveCursor(); parsestate = groundtable; break; case CASE_DECRC: /* DECRC */ - fViewObj->RestoreCursor(); + fView->RestoreCursor(); parsestate = groundtable; break; @@ -764,7 +776,7 @@ case CASE_RI: /* RI */ - fViewObj->ScrollRegion(-1, -1, SCRDOWN, 1); + fView->ScrollRegion(-1, -1, SCRDOWN, 1); parsestate = groundtable; break; @@ -814,7 +826,7 @@ switch (mode_char) { case '0': case '2': - fViewObj->Window()->SetTitle(string); + fView->Window()->SetTitle(string); break; case '1': break; Modified: haiku/trunk/src/apps/terminal/TermParse.h =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.h 2007-07-23 22:41:58 UTC (rev 21694) +++ haiku/trunk/src/apps/terminal/TermParse.h 2007-07-24 12:18:24 UTC (rev 21695) @@ -33,10 +33,10 @@ #include "TermConst.h" -#include #include -#include +#include + //PtyReader buffer size. #define READ_BUF_SIZE 2048 @@ -54,10 +54,6 @@ status_t InitTermParse(); status_t InitPtyReader(); - // Delete TermParse and PtyReader thread. - status_t AbortTermParse(); - status_t AbortPtyReader(); - int32 EscParse(); int32 PtyReader(); @@ -69,23 +65,19 @@ int fFd; - TermView *fViewObj; - thread_id fParseThread; - sem_id fParseSem; - thread_id fReaderThread; sem_id fReaderSem; sem_id fReaderLocker; - BMessageRunner *fCursorUpdate; + uint fBufferPosition; + uchar fReadBuffer[READ_BUF_SIZE]; + + int fLockFlag; - uint fParser_p; /* EscParse reading buffer pointer */ - int fLockFlag; /* PtyReader lock flag */ - - bool fQuitting; + TermView *fView; - uchar fReadBuf[READ_BUF_SIZE]; /* Reading buffer */ + bool fQuitting; }; #endif // TERMPARSE_H Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-23 22:41:58 UTC (rev 21694) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-24 12:18:24 UTC (rev 21695) @@ -12,17 +12,17 @@ #include "TermView.h" -#include "TermWindow.h" -#include "TermApp.h" -#include "TermParse.h" -#include "TermBuffer.h" #include "CodeConv.h" -#include "VTkeymap.h" -#include "TermConst.h" +#include "MenuUtil.h" #include "PrefHandler.h" -#include "MenuUtil.h" #include "PrefView.h" #include "Shell.h" +#include "TermApp.h" +#include "TermBuffer.h" +#include "TermConst.h" +#include "TermParse.h" +#include "TermWindow.h" +#include "VTkeymap.h" #include #include @@ -61,8 +61,54 @@ }; +const unsigned char M_ADD_CURSOR[] = { + 16, // Size + 1, // Color depth + 0, // Hot spot y + 1, // Hot spot x + + // Cursor image + 0x70, 0x00, + 0x48, 0x00, + 0x48, 0x00, + 0x27, 0xc0, + 0x24, 0xb8, + 0x12, 0x54, + 0x10, 0x02, + 0x78, 0x02, + 0x98, 0x02, + 0x84, 0x02, + 0x60, 0x02, + 0x18, 0x12, + 0x04, 0x10, + 0x02, 0x7c, + 0x00, 0x10, + 0x00, 0x10, + // Mask image + 0x70, 0x00, + 0x78, 0x00, + 0x78, 0x00, + 0x3f, 0xc0, + 0x3f, 0xf8, + 0x1f, 0xfc, + 0x1f, 0xfe, + 0x7f, 0xfe, + 0xff, 0xfe, + 0xff, 0xfe, + 0x7f, 0xfe, + 0x1f, 0xfe, + 0x07, 0xfc, + 0x03, 0xfc, + 0x00, 0x10, + 0x00, 0x10, +}; + + + +#define MOUSE_THR_CODE 'mtcd' + TermView::TermView(BRect frame, const char *command) - : BView(frame, "termview", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS), + : BView(frame, "termview", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED), fShell(NULL), fFontWidth(0), fFontHeight(0), @@ -72,6 +118,7 @@ fScrollUpCount(0), fScrollBarRange(0), fFrameResized(false), + fLastCursorTime(0), fCursorDrawFlag(CURON), fCursorStatus(CURON), fCursorBlinkingFlag(CURON), @@ -379,9 +426,9 @@ int x2 = end.x; int y2 = end.y; - // Send Draw Rectangle data to Draw Engine thread. Redraw(x1, y1 + fTop / fFontHeight, x2, y2 + fTop / fFontHeight); + return 0; } @@ -442,8 +489,7 @@ Redraw(0, start.y + 1, fTermColumns - 1, end.y - 1); } - Redraw(0, end.y, - end.x, end.y); + Redraw(0, end.y, end.x, end.y); } return 0; @@ -624,18 +670,18 @@ } +// TODO: Cleanup the next 3 functions!!! void TermView::DrawCursor() { - CURSOR_RECT; + BRect rect(fFontWidth * fCurPos.x, fFontHeight * fCurPos.y + fTop, + fFontWidth * (fCurPos.x + 1) - 1, fFontHeight * fCurPos.y + fTop + fCursorHeight - 1); + uchar buf[4]; ushort attr; int top = fTop / fFontHeight; - int m_flag = false; - - m_flag = CheckSelectedRegion(CurPos(fCurPos.x, - fCurPos.y + fTop / fFontHeight)); + bool m_flag = CheckSelectedRegion(CurPos(fCurPos.x, fCurPos.y + fTop / fFontHeight)); if (fTextBuffer->GetChar(fCurPos.y + top, fCurPos.x, buf, &attr) == A_CHAR) { int width; if (IS_WIDTH(attr)) @@ -652,7 +698,7 @@ else SetHighColor(fCursorBackColor); - FillRect(r); + FillRect(rect); } Sync(); @@ -671,6 +717,7 @@ DrawCursor(); fCursorStatus = fCursorStatus == CURON ? CUROFF : CURON; + fLastCursorTime = system_time(); } } @@ -1107,10 +1154,20 @@ SetFont(&fHalfFont); MakeFocus(true); fScrollBar->SetSteps(fFontHeight, fFontHeight * fTermRows); + + Window()->SetPulseRate(1000000); } void +TermView::Pulse() +{ + //if (system_time() > fLastCursorTime + 1000000) + BlinkCursor(); +} + + +void TermView::Draw(BRect updateRect) { if (IsPrinting()) { @@ -1470,9 +1527,6 @@ fShell->Write(ctrl_l, 1); break; - case MSGRUN_CURSOR: - BlinkCursor(); - break; // case B_INPUT_METHOD_EVENT: // { Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2007-07-23 22:41:58 UTC (rev 21694) +++ haiku/trunk/src/apps/terminal/TermView.h 2007-07-24 12:18:24 UTC (rev 21695) @@ -36,295 +36,247 @@ #include "TermConst.h" #include "TermWindow.h" -#include +#include #include -#include +#include /* Cursor Blinking flag */ #define CUROFF 0 #define CURON 1 -#define MOUSE_THR_CODE 'mtcd' -#define RECT_BUF_SIZE 32 - -const unsigned char M_ADD_CURSOR [] = { - 16, // Size - 1, // Color depth - 0, // Hot spot y - 1, // Hot spot x - - // Cursor image - 0x70, 0x00, - 0x48, 0x00, - 0x48, 0x00, - 0x27, 0xc0, - 0x24, 0xb8, - 0x12, 0x54, - 0x10, 0x02, - 0x78, 0x02, - 0x98, 0x02, - 0x84, 0x02, - 0x60, 0x02, - 0x18, 0x12, - 0x04, 0x10, - 0x02, 0x7c, - 0x00, 0x10, - 0x00, 0x10, - // Mask image - 0x70, 0x00, - 0x78, 0x00, - 0x78, 0x00, - 0x3f, 0xc0, - 0x3f, 0xf8, - 0x1f, 0xfc, [... truncated: 476 lines follow ...] From leavengood at gmail.com Tue Jul 24 15:52:54 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Tue, 24 Jul 2007 09:52:54 -0400 Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal In-Reply-To: <2065069285-BeMail@kirilla> References: <2065069285-BeMail@kirilla> Message-ID: On 7/24/07, Jonas Sundstr?m wrote: > > Tabbed browsing works in FireFox, I suppose, but what does it > provide that the system doesn't already provide? Why would we > want to increase this divide (app-context vs system-context) > by having applications effectively hide extra windows? Several reasons: 1) I like having a lot of different web sites open at once in my browser. I frequently open links on a given site in several new tabs and then read them in order as I get time. I suspect other people tend to do this too. I find it easier to manage this as tabs rather than a bunch of new windows. 2) I don't like manually managing lots of windows in general, but especially when doing something like in 1. 3) When browsing I don't tend to switch contexts into other applications as much, and I find it easier just to look up at my tabs when choosing what site to read next. On BeOS or Haiku I would be really annoyed having to click in the deskbar entry for the browser to get the window list to switch to another web site. I also tend to not use and dislike "windows" menus within applications. 4) Having windows plus tabs allows two levels of organization. I use this for browsers and for terminals. For example right now on my Ubuntu box at home I have one terminal with several tabs for development, then a separate terminal window for console IRC, then another one on another workspace with rtorrent running. I also really like having all my IM conversations together in a tabbed window in GAIM. 5) Tabs allow spatial organization and I feel I develop a certain muscle memory for where certain sites are in the tab layout of a browser. For example I usually put Gmail in the first tab. If I want to check my mail I can get there pretty fast. The organization of windows or applications on deskbar or other taskbar type systems is not as good. > Even with system-standard tab-management keyboard shortcuts > it's hardly a step forward, IMO. I disagree. Plus Ctrl-Tab or whatever shortcut is used for switching tabs isn't much worse than Alt-Tab. Ryan From krishnaakishore at gmail.com Tue Jul 24 17:51:00 2007 From: krishnaakishore at gmail.com (krishnaakishore at gmail.com) Date: Tue, 24 Jul 2007 21:21:00 +0530 Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal In-Reply-To: References: <2065069285-BeMail@kirilla> Message-ID: I completely agree. Its basically the "two levels of organisation" that helps. You tend to group all /similar/ tasks in tabs in a single window. So you switch windows for a /dissimilar/ group of tasks and switch tabs for /similar/ group of tasks. KK On 7/24/07, Ryan Leavengood wrote: > On 7/24/07, Jonas Sundstr?m wrote: > > > > Tabbed browsing works in FireFox, I suppose, but what does it > > provide that the system doesn't already provide? Why would we > > want to increase this divide (app-context vs system-context) > > by having applications effectively hide extra windows? > > Several reasons: > > 1) I like having a lot of different web sites open at once in my > browser. I frequently open links on a given site in several new tabs > and then read them in order as I get time. I suspect other people tend > to do this too. I find it easier to manage this as tabs rather than a > bunch of new windows. > > 2) I don't like manually managing lots of windows in general, but > especially when doing something like in 1. > > 3) When browsing I don't tend to switch contexts into other > applications as much, and I find it easier just to look up at my tabs > when choosing what site to read next. On BeOS or Haiku I would be > really annoyed having to click in the deskbar entry for the browser to > get the window list to switch to another web site. I also tend to not > use and dislike "windows" menus within applications. > > 4) Having windows plus tabs allows two levels of organization. I use > this for browsers and for terminals. For example right now on my > Ubuntu box at home I have one terminal with several tabs for > development, then a separate terminal window for console IRC, then > another one on another workspace with rtorrent running. I also really > like having all my IM conversations together in a tabbed window in > GAIM. > > 5) Tabs allow spatial organization and I feel I develop a certain > muscle memory for where certain sites are in the tab layout of a > browser. For example I usually put Gmail in the first tab. If I want > to check my mail I can get there pretty fast. The organization of > windows or applications on deskbar or other taskbar type systems is > not as good. > > > Even with system-standard tab-management keyboard shortcuts > > it's hardly a step forward, IMO. > > I disagree. Plus Ctrl-Tab or whatever shortcut is used for switching > tabs isn't much worse than Alt-Tab. > > Ryan > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > From superstippi at gmx.de Tue Jul 24 18:52:52 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Tue, 24 Jul 2007 18:52:52 +0200 Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal In-Reply-To: References: <2065069285-BeMail@kirilla> Message-ID: <20070724185252.5372.2@mallmedia0003.1185267452.fake> Ryan Leavengood wrote (2007-07-24, 15:52:54 [+0200]): > On 7/24/07, Jonas Sundstr?m wrote: > > > > Tabbed browsing works in FireFox, I suppose, but what does it provide > > that the system doesn't already provide? Why would we want to increase > > this divide (app-context vs system-context) by having applications > > effectively hide extra windows? > > Several reasons: > [8<] Completely agree too. Tabbed interfaces for multi-document apps have become more and more common, because they are quite a good approach. Since the apps in question could still have multiple windows open, each possibly with it's own set of tabs, I think both concepts can coexist. There only needs to be consistency with regards to opening new document behaviour. Ie, wether to open in existing window, new tab, or new window. Depending on what initiated opening the new doc. Either internal or external. For example, internal could default to new tab, while external could default to new window. Best regards, -Stephan From fekdahl at gmail.com Tue Jul 24 19:08:06 2007 From: fekdahl at gmail.com (Fredrik Ekdahl) Date: Tue, 24 Jul 2007 19:08:06 +0200 Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal In-Reply-To: <20070724185252.5372.2@mallmedia0003.1185267452.fake> References: <20070724185252.5372.2@mallmedia0003.1185267452.fake> Message-ID: <200707241908.06856.fekdahl@gmail.com> On Tuesday 24 July 2007 18.52.52 Stephan Assmus wrote: > it's own set of tabs, I think both concepts can coexist. There only needs > to be consistency with regards to opening new document behaviour. Ie, > wether to open in existing window, new tab, or new window. Depending on > what initiated opening the new doc. Either internal or external. For > example, internal could default to new tab, while external could default to > new window. Or left mouse button to open in new/current window (depending on the situation) and middle mouse button to open in a new tab, ie. the Firefox way of doing it. At least that works for hyperlinks. I'm not sure how this would be done from Tracker where you double-click to open. Double-clicking with the middle button is probably not a good idea... Another really handy feature is closing the tabs with the middle mouse button, which has the advantage that you don't have to aim at a tiny [X] or right click at the tab and select close, but can hit the whole tab area. /Fredrik Ekdahl From jonas at kirilla.com Tue Jul 24 19:24:36 2007 From: jonas at kirilla.com (Jonas =?iso-8859-1?q?Sundstr=F6m?=) Date: Tue, 24 Jul 2007 19:24:36 +0200 CEST Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal In-Reply-To: Message-ID: <5516040391-BeMail@kirilla> > On 7/24/07, Ryan Leavengood wrote: > > On 7/24/07, Jonas Sundstr?m wrote: > > > > > > Tabbed browsing works in FireFox, I suppose, but what does it > > > provide that the system doesn't already provide? Why would we > > > want to increase this divide (app-context vs system-context) > > > by having applications effectively hide extra windows? > > > > Several reasons: > > > > 1) I like having a lot of different web sites open at once > > in my browser. I use tabs too, to load new windows ahead of time, pre-caching. But not because I think tabs are better than windows. I could just as well use windows, if they wouldn't -cover- the current window. I believe tabs are a suboptimal fix for bad window management. > > 2) I don't like manually managing lots of windows in general, > > but especially when doing something like in 1. I think something else is missing from window management. I don't think tabs is the solution, but of course, it may not be an unreversible disaster to add it to the mix. > > 3) When browsing I don't tend to switch contexts into > > other applications as much, Me too. > > and I find it easier just to look up at my tabs when > > choosing what site to read next. If FireFox would allow opening windows in the background (or something similarly non-intrusive) and Deskbar still would not be an okay choice, then Deskbar needs to be improved. > > On BeOS or Haiku I would be really annoyed having to click > > in the deskbar entry for the browser to get the window list > > to switch to another web site. Deskbar's window entries can (or should) be as clear and present as any FireFox tabs are, thanks to the "Application Expanders". (Can we rename /unname this please?) Deskbar should allow resizing to show longer application and window names, and it should never be covered by an application, or cover an application itself. (Zoom should respect Deskbar.) > > I also tend to not use and dislike "windows" menus > > within applications. Me too. > > > > 4) Having windows plus tabs allows two levels of > > organization. See reply to Krishna below. ... > > 5) Tabs allow spatial organization and I feel I develop a > > certain muscle memory The order of Deskbar entries would be the same as your tabs unless you've set it to sort by name. I know it's not exactly the same as fixed locations, but it's not like you keep the set of tabs open, all of them, each in the exact same spot for the entire session, right? I usually close them as I read them, starting from either the first or the last, sometimes randomly. I can't really use the initial tab order memory. ... > > The organization of windows or applications on deskbar or > > other taskbar type systems is not as good. Tabs may have been created as a multiplatform feature, or possibly to work around bad task bars, like that of Windows. (Another aspect is that the window/page title and adress field is at the top of the browser window, whereas Window's task bar is at the bottom of the screen. A bad layout that doesn't reflect the hierarchy. A ribbon-like(?) layout would be better with the apps on the first level, at the top of the screen, windows (tabs) on the next level and then window contents.) > > > Even with system-standard tab-management keyboard > > > shortcuts it's hardly a step forward, IMO. > > > > I disagree. Plus Ctrl-Tab or whatever shortcut is used for > > switching tabs isn't much worse than Alt-Tab. krishnaakishore at gmail.com wrote: > I completely agree. Its basically the "two levels of organisation" > that helps. You tend to group all /similar/ tasks in tabs in a single > window. So you switch windows for a /dissimilar/ group of tasks and > switch tabs for /similar/ group of tasks. We've already got two levels, sort of, in Deskbar, and in the switcher (alt-tab), a list of running applications, with sublists of windows. In -window tabs add a conceptual third level, I think. We've also got workspaces, for similar tasks, should you want to group them that way. Well, I don't know. Perhaps it's not the end of the world to have tabs. /Jonas. From superstippi at gmx.de Tue Jul 24 20:02:52 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Tue, 24 Jul 2007 20:02:52 +0200 Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal In-Reply-To: <5516040391-BeMail@kirilla> References: <5516040391-BeMail@kirilla> Message-ID: <20070724200252.8058.6@mallmedia0003.1185267452.fake> Jonas Sundstr?m wrote (2007-07-24, 19:24:36 [+0200]): > Well, I don't know. Perhaps it's not the end of the world to have tabs. On the other hand, you make some valid points too. Something to keep in mind at least. You made me have second thoughts. I guess it's the spatial versus non-spatial debate again, and windows are more spacial. I just had the idea, that Deskbar could expand the "Application Expander" automatically for active application. Best regards, -Stephan From darkwyrm at earthlink.net Tue Jul 24 21:17:22 2007 From: darkwyrm at earthlink.net (DarkWyrm) Date: Tue, 24 Jul 2007 15:17:22 -0400 Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal In-Reply-To: <20070724200252.8058.6@mallmedia0003.1185267452.fake> References: <5516040391-BeMail@kirilla> <20070724200252.8058.6@mallmedia0003.1185267452.fake> Message-ID: <46A65042.6040203@earthlink.net> Stephan Assmus wrote: > Jonas Sundstr?m wrote (2007-07-24, 19:24:36 [+0200]): >> Well, I don't know. Perhaps it's not the end of the world to have tabs. > > On the other hand, you make some valid points too. Something to keep in > mind at least. You made me have second thoughts. I guess it's the spatial > versus non-spatial debate again, and windows are more spacial. I just had > the idea, that Deskbar could expand the "Application Expander" > automatically for active application. I don't personally like using the Application Expander, but that is a nice idea for those who do. :) --Jon From darkwyrm at earthlink.net Tue Jul 24 21:27:35 2007 From: darkwyrm at earthlink.net (DarkWyrm) Date: Tue, 24 Jul 2007 15:27:35 -0400 Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal In-Reply-To: <5516040391-BeMail@kirilla> References: <5516040391-BeMail@kirilla> Message-ID: <46A652A7.5000809@earthlink.net> > I use tabs too, to load new windows ahead of time, pre-caching. > But not because I think tabs are better than windows. I could just > as well use windows, if they wouldn't -cover- the current window. > > I believe tabs are a suboptimal fix for bad window management. The nice thing about tabs in certain situations is that it reduces window management, but you don't have to use them. Tabs in FireFox are second nature to me, but I don't use them at all in GNOME's Terminal app. Like other paradigms, they can't be used everywhere, but they are wonderful when used for the right applications. >>> 2) I don't like manually managing lots of windows in general, >>> but especially when doing something like in 1. > > I think something else is missing from window management. > I don't think tabs is the solution, but of course, it may not be an > unreversible disaster to add it to the mix. Agreed. >>> and I find it easier just to look up at my tabs when >>> choosing what site to read next. > > If FireFox would allow opening windows in the background > (or something similarly non-intrusive) and Deskbar still would > not be an okay choice, then Deskbar needs to be improved. Definitely. If you haven't seen my RFC for R2's 3D Desktop revisions, I'd certainly be interested in your thoughts on my proposed changes to the Deskbar. > Deskbar's window entries can (or should) be as clear and present as any > FireFox tabs are, thanks to the "Application Expanders". (Can we rename > /unname this please?) Window Groups? --Jon From korli at mail.berlios.de Tue Jul 24 21:34:31 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 24 Jul 2007 21:34:31 +0200 Subject: [Haiku-commits] r21696 - in haiku/trunk/src/add-ons/kernel/drivers/audio: ac97/auich ac97/auvia echo emuxki Message-ID: <200707241934.l6OJYVAb020092@sheep.berlios.de> Author: korli Date: 2007-07-24 21:34:30 +0200 (Tue, 24 Jul 2007) New Revision: 21696 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21696&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/multi.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/multi.c haiku/trunk/src/add-ons/kernel/drivers/audio/echo/multi.cpp haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/multi.c Log: should fix bug #1328, how could this be not noticed until now ... Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/multi.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/multi.c 2007-07-24 12:18:24 UTC (rev 21695) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/multi.c 2007-07-24 19:34:30 UTC (rev 21696) @@ -1090,6 +1090,9 @@ while(!LIST_EMPTY(&card->streams)) { auich_stream_delete(LIST_FIRST(&card->streams)); } + + card->pstream = NULL; + card->rstream = NULL; return B_OK; } Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/multi.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/multi.c 2007-07-24 12:18:24 UTC (rev 21695) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/multi.c 2007-07-24 19:34:30 UTC (rev 21696) @@ -381,7 +381,7 @@ } multi->control_count = index; - PRINT(("multi->control_count %u\n", multi->control_count)); + PRINT(("multi->control_count %lu\n", multi->control_count)); return B_OK; } @@ -393,7 +393,7 @@ for(i=0; iitem_count; i++) { id = MMVI->values[i].id - EMU_MULTI_CONTROL_FIRSTID; if(id < 0 || id >= card->multi.control_count) { - PRINT(("auvia_get_mix : invalid control id requested : %i\n", id)); + PRINT(("auvia_get_mix : invalid control id requested : %li\n", id)); continue; } control = &card->multi.controls[id]; @@ -432,7 +432,7 @@ for(i=0; iitem_count; i++) { id = MMVI->values[i].id - EMU_MULTI_CONTROL_FIRSTID; if(id < 0 || id >= card->multi.control_count) { - PRINT(("auvia_set_mix : invalid control id requested : %i\n", id)); + PRINT(("auvia_set_mix : invalid control id requested : %li\n", id)); continue; } control = &card->multi.controls[id]; @@ -442,7 +442,7 @@ if(i+1item_count) { id = MMVI->values[i + 1].id - EMU_MULTI_CONTROL_FIRSTID; if(id < 0 || id >= card->multi.control_count) { - PRINT(("auvia_set_mix : invalid control id requested : %i\n", id)); + PRINT(("auvia_set_mix : invalid control id requested : %li\n", id)); } else { control2 = &card->multi.controls[id]; if(control2->mix_control.master != control->mix_control.id) @@ -1098,6 +1098,9 @@ while(!LIST_EMPTY(&card->streams)) { auvia_stream_delete(LIST_FIRST(&card->streams)); } + + card->pstream = NULL; + card->rstream = NULL; return B_OK; } Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/echo/multi.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/echo/multi.cpp 2007-07-24 12:18:24 UTC (rev 21695) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/echo/multi.cpp 2007-07-24 19:34:30 UTC (rev 21696) @@ -992,6 +992,9 @@ while(!LIST_EMPTY(&card->streams)) { echo_stream_delete(LIST_FIRST(&card->streams)); } + + card->pstream = NULL; + card->rstream = NULL; return B_OK; } Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/multi.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/multi.c 2007-07-24 12:18:24 UTC (rev 21695) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/multi.c 2007-07-24 19:34:30 UTC (rev 21696) @@ -1262,6 +1262,11 @@ while(!LIST_EMPTY(&card->streams)) { emuxki_stream_delete(LIST_FIRST(&card->streams)); } + + card->pstream = NULL; + card->pstream2 = NULL; + card->rstream = NULL; + card->rstream2 = NULL; return B_OK; } From bonefish at mail.berlios.de Wed Jul 25 00:28:11 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 25 Jul 2007 00:28:11 +0200 Subject: [Haiku-commits] r21697 - haiku/trunk/src/add-ons/kernel/partitioning_systems/intel Message-ID: <200707242228.l6OMSBsF029797@sheep.berlios.de> Author: bonefish Date: 2007-07-25 00:27:57 +0200 (Wed, 25 Jul 2007) New Revision: 21697 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21697&view=rev Added: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.cpp haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.h haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapWriter.cpp haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapWriter.h Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/Jamfile haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.h haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapParser.h haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp Log: Write support for the Intel partitioning system module. Courtesy of Tomas Kucera. Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/Jamfile 2007-07-24 19:34:30 UTC (rev 21696) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/Jamfile 2007-07-24 22:27:57 UTC (rev 21697) @@ -7,16 +7,20 @@ KernelAddon intel : intel.cpp + PartitionLocker.cpp PartitionMap.cpp PartitionMapParser.cpp + PartitionMapWriter.cpp ; # Also build a userland version # ToDo: it's probably not a good idea to build them into the same directory #Addon intel : # intel.cpp +# PartitionLocker.cpp # PartitionMap.cpp # PartitionMapParser.cpp +# PartitionMapWriter.cpp #; #LinkAgainst intel : Added: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.cpp 2007-07-24 19:34:30 UTC (rev 21696) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.cpp 2007-07-24 22:27:57 UTC (rev 21697) @@ -0,0 +1,73 @@ +/* + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Tomas Kucera, kucerat at centrum.cz + */ + +#include "PartitionLocker.h" + +// #pragma mark - PartitionLocker + +// constructor +PartitionLocker::PartitionLocker(partition_id partitionID) + : device_(NULL), + partitionID_(partitionID) +{ +} + +// destructor +PartitionLocker::~PartitionLocker() +{ +} + +// IsLocked +bool +PartitionLocker::IsLocked() const +{ + return device_; +} + +// PartitionId +partition_id +PartitionLocker::PartitionId() const +{ + return partitionID_; +} + + +// #pragma mark - PartitionReadLocker + + +// constructor +PartitionReadLocker::PartitionReadLocker(partition_id partitionID) + : PartitionLocker(partitionID) +{ + device_ = read_lock_disk_device(partitionID); +} + +// destructor +PartitionReadLocker::~PartitionReadLocker() +{ + if (IsLocked()) + read_unlock_disk_device(PartitionId()); +} + + +// #pragma mark - PartitionWriteLocker + + +// constructor +PartitionWriteLocker::PartitionWriteLocker(partition_id partitionID) + : PartitionLocker(partitionID) +{ + device_ = write_lock_disk_device(partitionID); +} + +// destructor +PartitionWriteLocker::~PartitionWriteLocker() +{ + if (IsLocked()) + write_unlock_disk_device(PartitionId()); +} Added: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.h =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.h 2007-07-24 19:34:30 UTC (rev 21696) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.h 2007-07-24 22:27:57 UTC (rev 21697) @@ -0,0 +1,58 @@ +/* + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Tomas Kucera, kucerat at centrum.cz + */ + +/*! + \file PartitionLocker.h + \ingroup intel_module + \brief Structures for easy locking and automatic unlocking partitions. + */ + +#ifndef _PARTITION_LOCKER_H +#define _PARTITION_LOCKER_H + +#include + +class PartitionLocker { +public: + PartitionLocker(partition_id partitionID); + virtual ~PartitionLocker(); + bool IsLocked() const; + partition_id PartitionId() const; +protected: + const disk_device_data *device_; +private: + partition_id partitionID_; +}; + +/*! + \brief Structure which locks given partition for reading. + + When this structure is going to be destroyed, it automatically unlocks + that partition. +*/ + +class PartitionReadLocker : public PartitionLocker { +public: + PartitionReadLocker(partition_id partitionID); + virtual ~PartitionReadLocker(); +}; + +/*! + \brief Structure which locks given partition for writing. + + When this structure is going to be destroyed, it automatically unlocks + that partition. +*/ + +class PartitionWriteLocker : public PartitionLocker { +public: + PartitionWriteLocker(partition_id partitionID); + virtual ~PartitionWriteLocker(); +}; + +#endif // _PARTITION_LOCKER_H \ No newline at end of file Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp 2007-07-24 19:34:30 UTC (rev 21696) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp 2007-07-24 22:27:57 UTC (rev 21697) @@ -79,12 +79,28 @@ { 0xa8, "MacOS X" }, { 0xa9, "NetBSD" }, { 0xab, "MacOS X boot" }, + { 0xaf, "MacOS X HFS" }, { 0xbe, "Solaris 8 boot" }, { 0xeb, /*"BeOS"*/ BFS_NAME }, { 0, NULL } }; +static const struct partition_type kPartitionContentTypes[] = { +#ifndef _USER_MODE + { 0x01, kPartitionTypeFAT12 }, + { 0x0c, kPartitionTypeFAT32 }, + { 0x0f, kPartitionTypeIntelExtended }, + { 0x83, kPartitionTypeEXT2 }, + { 0x83, kPartitionTypeEXT3 }, + { 0x83, kPartitionTypeReiser }, + { 0xaf, kPartitionTypeHFS }, + { 0xaf, kPartitionTypeHFSPlus }, + { 0xeb, kPartitionTypeBFS }, +#endif + { 0, NULL } +}; + // partition_type_string static const char * partition_type_string(uint8 type) @@ -111,6 +127,7 @@ } + static int cmp_partition_offset(const void *p1, const void *p2) { @@ -161,6 +178,67 @@ } +// #pragma mark - PartitionType + + +// constructor +PartitionType::PartitionType() + : type_(0), + valid_(false) +{ +} + +// SetType +void +PartitionType::SetType(uint8 type) +{ + type_ = type; + valid_ = partition_type_string(type); +} + +// SetType +void +PartitionType::SetType(const char *type_name) +{ + for (int32 i = 0; kPartitionTypes[i].name ; i++) { + if (!strcmp(type_name, kPartitionTypes[i].name)) { + type_ = kPartitionTypes[i].type; + valid_ = true; + return; + } + } + valid_ = false; +} + +// SetContentType +void +PartitionType::SetContentType(const char *content_type) +{ + for (int32 i = 0; kPartitionContentTypes[i].name ; i++) { + if (!strcmp(content_type, kPartitionContentTypes[i].name)) { + type_ = kPartitionContentTypes[i].type; + valid_ = true; + return; + } + } + valid_ = false; +} + +// FindNext +void +PartitionType::FindNext() +{ + for (int32 i = 0; kPartitionTypes[i].name; i++) { + if (type_ < kPartitionTypes[i].type) { + type_ = kPartitionTypes[i].type; + valid_ = true; + return; + } + } + valid_ = false; +} + + // #pragma mark - Partition @@ -212,7 +290,20 @@ fActive = false; } +// GetPartitionDescriptor +void +Partition::GetPartitionDescriptor(partition_descriptor *descriptor, + off_t baseOffset, int32 blockSize) const +{ + descriptor->start = (fOffset - baseOffset) / blockSize; + descriptor->size = fSize / blockSize; + descriptor->type = fType; + descriptor->active = fActive ? 0x80 : 0x00; + descriptor->begin.Unset(); + descriptor->end.Unset(); +} + #ifdef _BOOT_MODE void Partition::AdjustSize(off_t sessionSize) @@ -303,6 +394,7 @@ { if (partition) { partition->SetPrimaryPartition(this); + partition->SetPrevious(fTail); if (fTail) { fTail->SetNext(partition); fTail = partition; @@ -313,7 +405,31 @@ } } +// RemoveLogicalPartition +void +PrimaryPartition::RemoveLogicalPartition(LogicalPartition *partition) +{ + if (!partition || partition->GetPrimaryPartition() != this) + return; + LogicalPartition *prev = partition->Previous(); + LogicalPartition *next = partition->Next(); + if (prev) + prev->SetNext(next); + else + fHead = next; + if (next) + next->SetPrevious(prev); + else + fTail = prev; + fLogicalPartitionCount--; + + partition->SetNext(NULL); + partition->SetPrevious(NULL); + partition->SetPrimaryPartition(NULL); +} + + // #pragma mark - LogicalPartition @@ -321,7 +437,8 @@ LogicalPartition::LogicalPartition() : Partition(), fPrimary(NULL), - fNext(NULL) + fNext(NULL), + fPrevious(NULL) { } @@ -331,7 +448,8 @@ PrimaryPartition *primary) : Partition(), fPrimary(NULL), - fNext(NULL) + fNext(NULL), + fPrevious(NULL) { SetTo(descriptor, ptsOffset, blockSize, primary); } @@ -357,6 +475,7 @@ { fPrimary = NULL; fNext = NULL; + fPrevious = NULL; Partition::Unset(); } Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.h =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.h 2007-07-24 19:34:30 UTC (rev 21696) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.h 2007-07-24 22:27:57 UTC (rev 21697) @@ -8,6 +8,7 @@ /*! \file PartitionMap.h + \ingroup intel_module \brief Definitions for "intel" style partitions and interface definitions for related classes. */ @@ -45,12 +46,22 @@ return (type == 0x05 || type == 0x0f || type == 0x85); } +// fill_buffer +static inline +void +fill_buffer(char *buffer, uint32 length, char ch) +{ + for (uint32 i = 0; i < length; i++) + buffer[i] = ch; +} + void get_partition_type_string(uint8 type, char *buffer); // chs struct chs { uint8 cylinder; uint16 head_sector; // head[15:10], sector[9:0] + void Unset() { cylinder = 0; head_sector = 0; } } _PACKED; // partition_descriptor @@ -71,6 +82,7 @@ char pad1[446]; partition_descriptor table[4]; uint16 signature; + void clear_code_area() { fill_buffer(pad1, 446, '\0'); } } _PACKED; static const uint16 kPartitionTableSectorSignature = 0xaa55; @@ -79,6 +91,68 @@ class PrimaryPartition; class LogicalPartition; +// PartitionType +/*! + \brief Class for validating partition types. + + To this class we can set partition type and then we can check whether + this type is valid, empty or if it represents extended partition. + We can also retrieve the name of that partition type or find next + supported type. +*/ +class PartitionType { +public: + PartitionType(); + + /*! + \brief Sets the \a type via its ID. + \param type ID of the partition type, it is in the range [0..255]. + */ + void SetType(uint8 type); + /*! + \brief Sets the type via its string name. + \param type_name Name of the partition type. + */ + void SetType(const char *type_name); + /*! + \brief Converts content type to the partition type that fits best. + \param content_type Name of the content type, it is standardized by system. + */ + void SetContentType(const char *content_type); + + /*! + \brief Check whether the current type is valid. + */ + bool IsValid() const { return valid_; } + /*! + \brief Check whether the current type describes empty type. + */ + bool IsEmpty() const { return is_empty_type(type_); } + /*! + \brief Check whether the current type describes extended partition type. + */ + bool IsExtended() const { return is_extended_type(type_); } + + /*! + \brief Returns ID of the current type. + */ + uint8 Type() const { return type_; } + /*! + \brief Finds next supported partition. + */ + void FindNext(); + /*! + \brief Returns string name of the current type. + \param buffer Buffer where the name is stored, has to be allocated with + sufficient length. + */ + void GetTypeString(char *buffer) const + { get_partition_type_string(type_, buffer); } +private: + uint8 type_; + bool valid_; +}; + // Partition class Partition { public: @@ -100,6 +174,8 @@ bool Active() const { return fActive; } void GetTypeString(char *buffer) const { get_partition_type_string(fType, buffer); } + void GetPartitionDescriptor(partition_descriptor *descriptor, + off_t baseOffset, int32 blockSize) const; void SetPTSOffset(off_t offset) { fPTSOffset = offset; } void SetOffset(off_t offset) { fOffset = offset; } @@ -135,6 +211,7 @@ int32 CountLogicalPartitions() const { return fLogicalPartitionCount; } LogicalPartition *LogicalPartitionAt(int32 index) const; void AddLogicalPartition(LogicalPartition *partition); + void RemoveLogicalPartition(LogicalPartition *partition); private: LogicalPartition *fHead; @@ -159,9 +236,13 @@ void SetNext(LogicalPartition *next) { fNext = next; } LogicalPartition *Next() const { return fNext; } + void SetPrevious(LogicalPartition *previous) { fPrevious = previous; } + LogicalPartition *Previous() const { return fPrevious; } + private: PrimaryPartition *fPrimary; LogicalPartition *fNext; + LogicalPartition *fPrevious; }; // PartitionMap Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapParser.h =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapParser.h 2007-07-24 19:34:30 UTC (rev 21696) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapParser.h 2007-07-24 22:27:57 UTC (rev 21697) @@ -5,6 +5,15 @@ * Authors: * Ingo Weinhold, bonefish at cs.tu-berlin.de */ + +/*! + \file PartitionMapParser.h + \brief Implementation of disk parser for "intel" style partitions. + + Parser reads primary and logical partitions from the disk (according to + Master Boot and Extended Boot Records) and fills \c PartitionMap structure + with partition representation. +*/ #ifndef PARTITION_MAP_PARSER_H #define PARTITION_MAP_PARSER_H Added: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapWriter.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapWriter.cpp 2007-07-24 19:34:30 UTC (rev 21696) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapWriter.cpp 2007-07-24 22:27:57 UTC (rev 21697) @@ -0,0 +1,262 @@ +/* + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Tomas Kucera, kucerat at centrum.cz + */ + +#ifndef _USER_MODE +# include +#endif + +#include +#include +#include +#include + +#include + +#include "PartitionMap.h" +#include "PartitionMapWriter.h" + +#define TRACE_ENABLED + +#ifdef TRACE_ENABLED +# ifdef _USER_MODE +# define TRACE(x) printf x +# else +# define TRACE(x) dprintf x +# endif +#endif + +using std::nothrow; + +// constructor +PartitionMapWriter::PartitionMapWriter(int deviceFD, off_t sessionOffset, + off_t sessionSize, int32 blockSize) + : fDeviceFD(deviceFD), + fSessionOffset(sessionOffset), + fSessionSize(sessionSize), + fBlockSize(blockSize), + fPTS(NULL), + fMap(NULL) +{ +} + +// destructor +PartitionMapWriter::~PartitionMapWriter() +{ +} + +// WriteMBR +status_t +PartitionMapWriter::WriteMBR(uint8 *block, const PartitionMap *map) +{ + status_t error = (map ? B_OK : B_BAD_VALUE); + if (error == B_OK) { + fMap = map; + if (block) { + partition_table_sector *pts + = (partition_table_sector*)block; + error = _WritePrimary(pts); + if (error == B_OK) + error = _WritePTS(0, pts); + } else { + partition_table_sector pts; + error = _ReadPTS(0, &pts); + if (error == B_OK) { + error = _WritePrimary(&pts); + if (error == B_OK) + error = _WritePTS(0, &pts); + } + } + + fMap = NULL; + } + return error; +} + +// WriteLogical +status_t +PartitionMapWriter::WriteLogical(uint8 *block, const LogicalPartition *partition) +{ + status_t error = (partition ? B_OK : B_BAD_VALUE); + if (error == B_OK) { + if (block) { + partition_table_sector *pts + = (partition_table_sector*)block; + error = _WriteExtended(pts, partition, partition->Next()); + if (error == B_OK) + error = _WritePTS(partition->PTSOffset(), pts); + } else { + partition_table_sector pts; + error = _ReadPTS(partition->PTSOffset(), &pts); + if (error == B_OK) { + error = _WriteExtended(&pts, partition, partition->Next()); + if (error == B_OK) + error = _WritePTS(partition->PTSOffset(), &pts); + } + } + } + return error; +} + +// WriteExtendedHead +status_t +PartitionMapWriter::WriteExtendedHead(uint8 *block, + const LogicalPartition *first_partition) +{ + LogicalPartition partition; + if (first_partition) + partition.SetPrimaryPartition(first_partition->GetPrimaryPartition()); + status_t error = B_OK; + if (block) { + partition_table_sector *pts + = (partition_table_sector*)block; + error = _WriteExtended(pts, &partition, first_partition); + if (error == B_OK) + error = _WritePTS(0, pts); + } else { + partition_table_sector pts; + error = _ReadPTS(0, &pts); + if (error == B_OK) { + error = _WriteExtended(&pts, &partition, first_partition); + if (error == B_OK) + error = _WritePTS(0, &pts); + } + } + return error; +} + +// _WritePrimary +status_t +PartitionMapWriter::_WritePrimary(partition_table_sector *pts) +{ + if (pts == NULL) + return B_BAD_VALUE; + + // write the signature + pts->signature = kPartitionTableSectorSignature; + + // write the table + for (int32 i = 0; i < 4; i++) { + partition_descriptor *descriptor = &pts->table[i]; + const PrimaryPartition *partition = fMap->PrimaryPartitionAt(i); + + // ignore, if location is bad + if (!partition->CheckLocation(fSessionSize, fBlockSize)) { + TRACE(("intel: _WritePrimary(): partition %ld: bad location, " + "ignoring\n", i)); + return B_BAD_DATA; + } + + partition->GetPartitionDescriptor(descriptor, 0, fBlockSize); + } + + return B_OK; +} + +// _WriteExtended +status_t +PartitionMapWriter::_WriteExtended(partition_table_sector *pts, + const LogicalPartition *partition, + const LogicalPartition *next) +{ + if (!pts || !partition) + return B_BAD_VALUE; + + // write the signature + pts->signature = kPartitionTableSectorSignature; + + // check the partition's location + if (!partition->CheckLocation(fSessionSize, fBlockSize)) { + TRACE(("intel: _WriteExtended(): Invalid partition " + "location: pts: %lld, offset: %lld, size: %lld, fSessionSize: %lld\n", + partition->PTSOffset(), partition->Offset(), + partition->Size(), fSessionSize)); + return B_BAD_DATA; + } + + // write the table + partition_descriptor *descriptor = &(pts->table[0]); + partition->GetPartitionDescriptor(descriptor, partition->PTSOffset(), fBlockSize); + + // setting offset and size of the next partition in the linked list + descriptor = &(pts->table[1]); + LogicalPartition extended; + if (next) { + extended.SetPTSOffset(partition->PTSOffset()); + extended.SetOffset(next->PTSOffset()); + extended.SetSize(next->Size() + next->Offset() - next->PTSOffset()); + extended.SetType(partition->GetPrimaryPartition()->Type()); + extended.GetPartitionDescriptor(descriptor, 0, fBlockSize); + extended.Unset(); + } else + extended.GetPartitionDescriptor(descriptor, 0, fBlockSize); + + // last two descriptors are empty + for (int32 i = 2; i < 4; i++) { + descriptor = &(pts->table[i]); + extended.GetPartitionDescriptor(descriptor, 0, fBlockSize); + } + + return B_OK; +} + +// _ReadPTS +status_t +PartitionMapWriter::_ReadPTS(off_t offset, partition_table_sector *pts) +// reads the sector from the disk +{ + status_t error = B_OK; + if (!pts) + pts = fPTS; + int32 toRead = sizeof(partition_table_sector); + // check the offset + if (offset < 0 || offset + toRead > fSessionSize) { + error = B_BAD_VALUE; + TRACE(("intel: _ReadPTS(): bad offset: %Ld\n", offset)); + // read + } else if (read_pos(fDeviceFD, fSessionOffset + offset, pts, toRead) + != toRead) { +#ifndef _BOOT_MODE + error = errno; + if (error == B_OK) + error = B_IO_ERROR; +#else + error = B_IO_ERROR; +#endif + TRACE(("intel: _ReadPTS(): reading the PTS failed: %lx\n", error)); + } + return error; +} + +// _WritePTS +status_t +PartitionMapWriter::_WritePTS(off_t offset, const partition_table_sector *pts) +// writes the sector to the disk +{ + status_t error = B_OK; + if (!pts) + pts = fPTS; + int32 toWrite = sizeof(partition_table_sector); + // check the offset + if (offset < 0 || offset + toWrite > fSessionSize) { + error = B_BAD_VALUE; + TRACE(("intel: _WritePTS(): bad offset: %Ld\n", offset)); + // write + } else if (write_pos(fDeviceFD, fSessionOffset + offset, pts, toWrite) + != toWrite) { +#ifndef _BOOT_MODE + error = errno; + if (error == B_OK) + error = B_IO_ERROR; +#else + error = B_IO_ERROR; +#endif + TRACE(("intel: _WritePTS(): writing the PTS failed: %lx\n", error)); + } + return error; +} + Added: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapWriter.h =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapWriter.h 2007-07-24 19:34:30 UTC (rev 21696) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapWriter.h 2007-07-24 22:27:57 UTC (rev 21697) @@ -0,0 +1,98 @@ +/* + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Tomas Kucera, kucerat at centrum.cz + */ + +/*! + \file PartitionMapWriter.h + \ingroup intel_module + \brief Implementation of disk writer for "intel" style partitions. + + Writer can write \b Master \b Boot \b Record or \b Extended \b Boot \b Records + to the disk according to partitions defined in \c PartitionMap structure. +*/ + + +#ifndef PARTITION_MAP_WRITER_H +#define PARTITION_MAP_WRITER_H + + +#include + + +class PartitionMap; +class LogicalPartition; +struct partition_table_sector; + +/*! + \brief Writer for "Intel" style partitions. + + This class serves for writing \a primary and \a logical \a partitions to disk. +*/ +class PartitionMapWriter { + public: + /*! + \brief Creates the writer. + + \param deviceFD File descriptor. + \param sessionOffset Disk offset of the partition with partitioning system. + \param sessionSize Size of the partition with partitioning system. + \param blockSize Size of the sector on given disk. + */ + PartitionMapWriter(int deviceFD, off_t sessionOffset, off_t sessionSize, + int32 blockSize); + ~PartitionMapWriter(); + + /*! + \brief Writes Master Boot Record to the first sector of the disk. + + If a \a block is not specified, the sector is firstly read from the disk + and after changing relevant items it is written back to the disk. + This allows to keep code area in MBR intact. + \param block Pointer to \c partition_table_sector. + \param map Pointer to the PartitionMap structure describing disk partitions. + */ + status_t WriteMBR(uint8 *block, const PartitionMap *map); + /*! + \brief Writes Partition Table Sector of the logical \a partition to the disk. + + This function ensures that the connection of the following linked list of logical + partitions will be correct. It do nothing with the connection of previous logical + partitions (call this function on previous logical partition to ensure it). + \param block Pointer to \c partition_table_sector. + \param partition Pointer to the logical partition. + */ + status_t WriteLogical(uint8 *block, const LogicalPartition *partition); + /*! + \brief Writes Extended Boot Record to the first sector of Extended Partition. + + Writes the head of linked list describing logical partitions. + + If the \a first_partition is not specified, it only initializes EBR and the linked + list contains no logical partitions. + \param block Pointer to \c partition_table_sector. + \param first_partition Pointer to the first logical partition. + */ + status_t WriteExtendedHead(uint8 *block, const LogicalPartition *first_partition); + + private: + status_t _WritePrimary(partition_table_sector *pts); + status_t _WriteExtended(partition_table_sector *pts, + const LogicalPartition *partition, + const LogicalPartition *next); + status_t _ReadPTS(off_t offset, partition_table_sector *pts = NULL); + status_t _WritePTS(off_t offset, const partition_table_sector *pts = NULL); + + private: + int fDeviceFD; + off_t fSessionOffset; + off_t fSessionSize; + int32 fBlockSize; + partition_table_sector *fPTS; // while writing + const PartitionMap *fMap; +}; + +#endif // PARTITION_MAP_WRITER_H Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp 2007-07-24 19:34:30 UTC (rev 21696) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp 2007-07-24 22:27:57 UTC (rev 21697) @@ -1,9 +1,10 @@ /* - * Copyright 2003-2006, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: * Ingo Weinhold, bonefish at cs.tu-berlin.de + * Tomas Kucera, kucerat at centrum.cz */ /*! @@ -32,12 +33,19 @@ #endif #include +#include "PartitionLocker.h" #include "PartitionMap.h" #include "PartitionMapParser.h" +#include "PartitionMapWriter.h" //#define TRACE(x) ; #define TRACE(x) dprintf x + +// this macro is just for testing purpose +// keep it undefined, if you are not testing !!! +// #define TESTING_INTEL_MODULE + // module names #define INTEL_PARTITION_MODULE_NAME "partitioning_systems/intel/map/v1" #define INTEL_EXTENDED_PARTITION_MODULE_NAME "partitioning_systems/intel/extended/v1" @@ -62,32 +70,119 @@ }; -// intel partition map module +#ifndef _BOOT_MODE +// Maximal size of move buffer (in sectors). +static const int32 MAX_MOVE_BUFFER = 2 * 1024 * 4; + +// for logical partitions in Intel Extended Partition +// Count of free sectors after Partition Table Sector (at logical partition). +static const uint32 FREE_SEKTORS_AFTER_PTS = 0; +// Count of free sectors after Master Boot Record. +static const uint32 FREE_SEKTORS_AFTER_MBR = 0; +// size of logical partition header in blocks +static const uint32 PTS_OFFSET = FREE_SEKTORS_AFTER_PTS + 1; +static const uint32 MBR_OFFSET = FREE_SEKTORS_AFTER_MBR + 1; + + +typedef partitionable_space_data PartitionPosition; + +typedef void (*fc_get_sibling_partitions)(partition_data *partition, + partition_data *child, off_t child_offset, partition_data **prec, + partition_data **follow, off_t *prec_offset, off_t *prec_size, + off_t *follow_offset, off_t *follow_size); + +typedef int32 (*fc_fill_partitionable_spaces_buffer)(partition_data *partition, + PartitionPosition *p_positions); + + +#endif //_BOOT_MODE + + + + +////////////////////////////////////////// +// Intel Partition Map Module // +////////////////////////////////////////// + + + + + // module static status_t pm_std_ops(int32 op, ...); // scanning static float pm_identify_partition(int fd, partition_data *partition, - void **cookie); + void **cookie); static status_t pm_scan_partition(int fd, partition_data *partition, - void *cookie); + void *cookie); static void pm_free_identify_partition_cookie(partition_data *partition, - void *cookie); + void *cookie); static void pm_free_partition_cookie(partition_data *partition); [... truncated: 2919 lines follow ...] From jackburton at mail.berlios.de Wed Jul 25 11:50:35 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Wed, 25 Jul 2007 11:50:35 +0200 Subject: [Haiku-commits] r21698 - haiku/trunk/src/apps/terminal Message-ID: <200707250950.l6P9oZIN006854@sheep.berlios.de> Author: jackburton Date: 2007-07-25 11:50:34 +0200 (Wed, 25 Jul 2007) New Revision: 21698 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21698&view=rev Modified: haiku/trunk/src/apps/terminal/ShellPrefView.cpp haiku/trunk/src/apps/terminal/TermApp.cpp haiku/trunk/src/apps/terminal/TermApp.h haiku/trunk/src/apps/terminal/TermConst.h haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h haiku/trunk/src/apps/terminal/TermWindow.cpp haiku/trunk/src/apps/terminal/TermWindow.h Log: Moved all TermView initializing code into TermView itself. Before you couldn't just rely on its constructor to fully initialize the object, since the code was scattered around, mostly into TermWindow. Added a commented out TermWindow constructor which only creates and adds a TermView object to the view hierarchy, which now works. Removed weird TermWindowActivate method, use WindowActivated instead. TermApp can now keep a pointer to a BWindow instead of TermWindow, since it doesn't do anything special with it. TermView::SetTermFont() now can filter the font attributes (it uses B_FIXED_SPACING, I'm not sure it's needed but it doesn't hurt). Usual cleanups. Modified: haiku/trunk/src/apps/terminal/ShellPrefView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/ShellPrefView.cpp 2007-07-24 22:27:57 UTC (rev 21697) +++ haiku/trunk/src/apps/terminal/ShellPrefView.cpp 2007-07-25 09:50:34 UTC (rev 21698) @@ -25,9 +25,7 @@ #include "TTextControl.h" -extern PrefHandler *PrefHandler::Default(); - ShellPrefView::ShellPrefView(BRect frame, const char *name, TermWindow *window) : PrefView(frame, name) Modified: haiku/trunk/src/apps/terminal/TermApp.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-24 22:27:57 UTC (rev 21697) +++ haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-25 09:50:34 UTC (rev 21698) @@ -146,7 +146,7 @@ break; case MSG_ACTIVATE_TERM: - fTermWindow->TermWinActivate(); + fTermWindow->Activate(); break; case MSG_TERM_IS_MINIMIZE: Modified: haiku/trunk/src/apps/terminal/TermApp.h =================================================================== --- haiku/trunk/src/apps/terminal/TermApp.h 2007-07-24 22:27:57 UTC (rev 21697) +++ haiku/trunk/src/apps/terminal/TermApp.h 2007-07-25 09:50:34 UTC (rev 21698) @@ -35,11 +35,8 @@ #include #include - -class TermWindow; -class TermParse; class BRect; - +class BWindow; class TermApp : public BApplication { public: TermApp(); @@ -71,7 +68,7 @@ BString fWindowTitle; int32 fWindowNumber; - TermWindow* fTermWindow; + BWindow* fTermWindow; BRect fTermFrame; BString fCommandLine; }; Modified: haiku/trunk/src/apps/terminal/TermConst.h =================================================================== --- haiku/trunk/src/apps/terminal/TermConst.h 2007-07-24 22:27:57 UTC (rev 21697) +++ haiku/trunk/src/apps/terminal/TermConst.h 2007-07-25 09:50:34 UTC (rev 21698) @@ -61,8 +61,6 @@ const uint32 M_GET_DEVICE_NUM = 'Mgdn'; -// Message Runner -const uint32 MSGRUN_WINDOW = 'Rwin'; // Preference Message const ulong PSET__COLS = 'pcol'; Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-24 22:27:57 UTC (rev 21697) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-25 09:50:34 UTC (rev 21698) @@ -17,18 +17,19 @@ #include "PrefHandler.h" #include "PrefView.h" #include "Shell.h" -#include "TermApp.h" #include "TermBuffer.h" #include "TermConst.h" #include "TermParse.h" -#include "TermWindow.h" #include "VTkeymap.h" +#include #include #include #include #include #include +#include +#include #include #include #include @@ -107,6 +108,9 @@ #define MOUSE_THR_CODE 'mtcd' +const static uint32 kUpdateSigWinch = 'Rwin'; + + TermView::TermView(BRect frame, const char *command) : BView(frame, "termview", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED), fShell(NULL), @@ -151,13 +155,16 @@ SetMouseCursor(); - SetTermFont(be_plain_font, be_plain_font); + SetTermFont(be_plain_font, be_plain_font); + SetTermColor(); + //SetIMAware(PrefHandler::Default()->getInt32(PREF_IM_AWARE)); - // Get encoding name (setenv TTYPE in spawn_shell functions) - const char *encoding = longname2shortname(PrefHandler::Default()->getString(PREF_TEXT_ENCODING)); + const char *encoding = PrefHandler::Default()->getString(PREF_TEXT_ENCODING); + SetEncoding(longname2id(encoding)); + fShell = new Shell(); - status_t status = fShell->Open(fTermRows, fTermColumns, command, encoding); + status_t status = fShell->Open(fTermRows, fTermColumns, command, longname2shortname(encoding)); if (status < B_OK) throw status; @@ -165,6 +172,8 @@ if (status < B_OK) throw status; + SetTermSize(fTermColumns, fTermRows, false); + _InitMouseThread(); } @@ -181,6 +190,16 @@ } +void +TermView::GetPreferredSize(float *width, float *height) +{ + if (width) + *width = fTermColumns * fFontWidth; + if (height) + *height = fTermRows * fFontHeight; +} + + status_t TermView::AttachShell(Shell *shell) { @@ -240,7 +259,7 @@ if (resize) ResizeTo(fTermColumns * fFontWidth - 1, fTermRows * fFontHeight -1); - Invalidate(Frame()); + Invalidate(); return rect; } @@ -283,6 +302,9 @@ fHalfFont = halfFont; fFullFont = fullFont; + _FixFontAttributes(fHalfFont); + _FixFontAttributes(fFullFont); + // calculate half font's max width // Not Bounding, check only A-Z(For case of fHalfFont is KanjiFont. ) for (int c = 0x20 ; c <= 0x7e; c++){ @@ -929,8 +951,7 @@ } // Scroll check - if (theObj->LockLooper()) { - + if (theObj->fScrollBar != NULL && theObj->LockLooper()) { // Get now scroll point theObj->fScrollBar->GetRange(&scr_start, &scr_end); scr_pos = theObj->fScrollBar->Value(); @@ -1039,10 +1060,11 @@ void TermView::ResizeScrBarRange() { - float viewheight, start_pos; + if (fScrollBar == NULL) + return; - viewheight = fTermRows * fFontHeight; - start_pos = fTop -(fScrBufSize - fTermRows *2) * fFontHeight; + float viewheight = fTermRows * fFontHeight; + float start_pos = fTop -(fScrBufSize - fTermRows *2) * fFontHeight; if (start_pos > 0) { fScrollBar->SetRange(start_pos, viewheight + fTop - fFontHeight); @@ -1153,13 +1175,25 @@ { SetFont(&fHalfFont); MakeFocus(true); - fScrollBar->SetSteps(fFontHeight, fFontHeight * fTermRows); + if (fScrollBar) + fScrollBar->SetSteps(fFontHeight, fFontHeight * fTermRows); + BMessage message(kUpdateSigWinch); + fWinchRunner = new (std::nothrow) BMessageRunner(BMessenger(this), &message, 500000); + Window()->SetPulseRate(1000000); } void +TermView::DetachedFromWindow() +{ + delete fWinchRunner; + fWinchRunner = NULL; +} + + +void TermView::Pulse() { //if (system_time() > fLastCursorTime + 1000000) @@ -1293,11 +1327,7 @@ void TermView::KeyDown(const char *bytes, int32 numBytes) { - char c; - struct termios tio; int32 key, mod; - - uchar dstbuf[1024]; Looper()->CurrentMessage()->FindInt32("modifiers", &mod); Looper()->CurrentMessage()->FindInt32("key", &key); @@ -1306,6 +1336,7 @@ // If bytes[0] equal intr charactor, // send signal to shell process group. + struct termios tio; fShell->GetAttr(tio); if (*bytes == tio.c_cc[VINTR]) { if (tio.c_lflag & ISIG) @@ -1315,31 +1346,19 @@ // Terminal changes RET, ENTER, F1...F12, and ARROW key code. if (numBytes == 1) { - switch (*bytes) { case B_RETURN: - c = 0x0d; - if (key == RETURN_KEY || key == ENTER_KEY) { - fShell->Write(&c, 1); - return; - } else { - fShell->Write(bytes, numBytes); - return; - } + { + char c = 0x0d; + fShell->Write(&c, 1); break; - + } case B_LEFT_ARROW: - if (key == LEFT_ARROW_KEY) { - fShell->Write(LEFT_ARROW_KEY_CODE, sizeof(LEFT_ARROW_KEY_CODE)-1); - return; - } + fShell->Write(LEFT_ARROW_KEY_CODE, sizeof(LEFT_ARROW_KEY_CODE)-1); break; case B_RIGHT_ARROW: - if (key == RIGHT_ARROW_KEY) { - fShell->Write(RIGHT_ARROW_KEY_CODE, sizeof(RIGHT_ARROW_KEY_CODE)-1); - return; - } + fShell->Write(RIGHT_ARROW_KEY_CODE, sizeof(RIGHT_ARROW_KEY_CODE)-1); break; case B_UP_ARROW: @@ -1351,10 +1370,7 @@ return; } - if (key == UP_ARROW_KEY) { - fShell->Write(UP_ARROW_KEY_CODE, sizeof(UP_ARROW_KEY_CODE)-1); - return; - } + fShell->Write(UP_ARROW_KEY_CODE, sizeof(UP_ARROW_KEY_CODE)-1); break; case B_DOWN_ARROW: @@ -1364,24 +1380,15 @@ return; } - if (key == DOWN_ARROW_KEY) { - fShell->Write(DOWN_ARROW_KEY_CODE, sizeof(DOWN_ARROW_KEY_CODE)-1); - return; - } + fShell->Write(DOWN_ARROW_KEY_CODE, sizeof(DOWN_ARROW_KEY_CODE)-1); break; case B_INSERT: - if (key == INSERT_KEY) { - fShell->Write(INSERT_KEY_CODE, sizeof(INSERT_KEY_CODE)-1); - return; - } + fShell->Write(INSERT_KEY_CODE, sizeof(INSERT_KEY_CODE)-1); break; case B_HOME: - if (key == HOME_KEY) { - fShell->Write(HOME_KEY_CODE, sizeof(HOME_KEY_CODE)-1); - return; - } + fShell->Write(HOME_KEY_CODE, sizeof(HOME_KEY_CODE)-1); break; case B_PAGE_UP: @@ -1393,10 +1400,7 @@ return; } - if (key == PAGE_UP_KEY) { - fShell->Write(PAGE_UP_KEY_CODE, sizeof(PAGE_UP_KEY_CODE)-1); - return; - } + fShell->Write(PAGE_UP_KEY_CODE, sizeof(PAGE_UP_KEY_CODE)-1); break; case B_PAGE_DOWN: @@ -1406,21 +1410,15 @@ return; } - if (key == PAGE_DOWN_KEY) { - fShell->Write(PAGE_DOWN_KEY_CODE, sizeof(PAGE_DOWN_KEY_CODE)-1); - return; - } + fShell->Write(PAGE_DOWN_KEY_CODE, sizeof(PAGE_DOWN_KEY_CODE)-1); break; case B_END: - if (key == END_KEY) { - fShell->Write(END_KEY_CODE, sizeof(END_KEY_CODE)-1); - return; - } + fShell->Write(END_KEY_CODE, sizeof(END_KEY_CODE)-1); break; case B_FUNCTION_KEY: - for (c = 0; c < 12; c++) { + for (int32 c = 0; c < 12; c++) { if (key == function_keycode_table[c]) { fShell->Write(function_key_char_table[c], 5); return; @@ -1429,33 +1427,31 @@ break; default: + fShell->Write(bytes, numBytes); break; } } else { // input multibyte character - if (GetEncoding() != M_UTF8) { + uchar dstbuf[1024]; int cnum = CodeConv::ConvertFromInternal(bytes, numBytes, (char *)dstbuf, GetEncoding()); fShell->Write(dstbuf, cnum); - return; } } - - fShell->Write(bytes, numBytes); } void TermView::FrameResized(float width, float height) { - const int cols =((int)width + 1) / fFontWidth; - const int rows =((int)height + 1) / fFontHeight; + const int cols = ((int)width + 1) / fFontWidth; + const int rows = ((int)height + 1) / fFontHeight; int offset = 0; if (rows < fCurPos.y + 1) { - fTop +=(fCurPos.y + 1 - rows) * fFontHeight; + fTop += (fCurPos.y + 1 - rows) * fFontHeight; offset = fCurPos.y + 1 - rows; fCurPos.y = rows - 1; } @@ -1464,6 +1460,9 @@ fTermColumns = cols; fFrameResized = true; + + // TODO: Fix this + Invalidate(); } @@ -1550,6 +1549,9 @@ // break; // } // } + case kUpdateSigWinch: + UpdateSIGWINCH(); + break; default: BView::MessageReceived(msg); break; @@ -1666,9 +1668,11 @@ // reset cursor pos SetCurPos(0, 0); - - fScrollBar->SetRange(0, 0); - fScrollBar->SetProportion(1); + + if (fScrollBar) { + fScrollBar->SetRange(0, 0); + fScrollBar->SetProportion(1); + } } @@ -2223,3 +2227,12 @@ } } + +/* static */ +void +TermView::_FixFontAttributes(BFont &font) +{ + font.SetSpacing(B_FIXED_SPACING); +} + + Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2007-07-24 22:27:57 UTC (rev 21697) +++ haiku/trunk/src/apps/terminal/TermView.h 2007-07-25 09:50:34 UTC (rev 21698) @@ -44,6 +44,7 @@ #define CUROFF 0 #define CURON 1 +class BMessageRunner; class BPopUpMenu; class BScrollBar; class BString; @@ -54,6 +55,8 @@ TermView(BRect frame, const char *command); ~TermView(); + virtual void GetPreferredSize(float *width, float *height); + status_t AttachShell(Shell *shell); void DetachShell(); @@ -61,8 +64,10 @@ void SetTermFont(const BFont *halfFont, const BFont *fullFont); void GetFontSize(int *width, int *height); + BRect SetTermSize(int rows, int cols, bool flag); void SetTermColor(); + void SetMouseCursor(); // void SetIMAware (bool); void SetScrollBar(BScrollBar *scrbar); @@ -124,6 +129,7 @@ protected: virtual void AttachedToWindow(); + virtual void DetachedFromWindow(); virtual void Pulse(); virtual void Draw(BRect updateRect); virtual void WindowActivated(bool active); @@ -180,8 +186,12 @@ bool CheckSelectedRegion(const CurPos &pos); inline void Redraw(int, int, int, int); + static void _FixFontAttributes(BFont &font); + Shell *fShell; + BMessageRunner *fWinchRunner; + // Font and Width BFont fHalfFont; BFont fFullFont; Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-24 22:27:57 UTC (rev 21697) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-25 09:50:34 UTC (rev 21698) @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -52,7 +51,17 @@ const static float kViewOffset = 3; +#if 0 +TermWindow::TermWindow(BRect frame, const char* title, const char *command) + : + BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE) +{ + fTermView = new TermView(Bounds(), command); + AddChild(fTermView); +} +#else + TermWindow::TermWindow(BRect frame, const char* title, const char *command) : BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE), fMenubar(NULL), @@ -67,7 +76,6 @@ fPrintSettings(NULL), fPrefWindow(NULL), fFindPanel(NULL), - fWindowUpdate(NULL), fSavedFrame(0, 0, -1, -1), fFindString(""), fFindForwardMenuItem(NULL), @@ -79,8 +87,8 @@ { _InitWindow(command); } +#endif - TermWindow::~TermWindow() { if (fPrefWindow) @@ -92,8 +100,6 @@ } PrefHandler::DeleteDefault(); - - delete fWindowUpdate; } @@ -117,8 +123,7 @@ if (size < 6.0f) size = 6.0f; halfFont.SetSize(size); - halfFont.SetSpacing(B_FIXED_SPACING); - + family = PrefHandler::Default()->getString(PREF_FULL_FONT_FAMILY); BFont fullFont; @@ -146,8 +151,6 @@ fTermView->GetFontSize(&width, &height); SetSizeLimits(MIN_COLS * width, MAX_COLS * width, MIN_COLS * height, MAX_COLS * height); - - fTermView->SetTermColor(); // Add offset to baseview. rect.InsetBy(-kViewOffset, -kViewOffset); @@ -173,13 +176,6 @@ AddChild(fTermView); fEditmenu->SetTargetForItems(fTermView); - - // Initialize TermParse - SetEncoding(longname2id(PrefHandler::Default()->getString(PREF_TEXT_ENCODING))); - - // Initialize MessageRunner. - fWindowUpdate = new BMessageRunner(BMessenger(this), - new BMessage (MSGRUN_WINDOW), 500000); } @@ -429,7 +425,7 @@ PrefHandler::Default()->getInt32 (PREF_COLS), 0); ResizeTo (r.Width()+ B_V_SCROLL_BAR_WIDTH + kViewOffset * 2, - r.Height()+fMenubar->Bounds().Height() + kViewOffset *2); + r.Height()+fMenubar->Bounds().Height() + kViewOffset *2); BPath path; if (PrefHandler::GetDefaultPath(path) == B_OK) @@ -468,36 +464,31 @@ case EIGHTYTWENTYFOUR: { PrefHandler::Default()->setString(PREF_COLS, "80"); PrefHandler::Default()->setString(PREF_ROWS, "24"); - this->PostMessage (MSG_ROWS_CHANGED); - this->PostMessage (MSG_COLS_CHANGED); + PostMessage (MSG_COLS_CHANGED); break; } case EIGHTYTWENTYFIVE: { PrefHandler::Default()->setString(PREF_COLS, "80"); PrefHandler::Default()->setString(PREF_ROWS, "25"); - this->PostMessage (MSG_ROWS_CHANGED); - this->PostMessage (MSG_COLS_CHANGED); + PostMessage (MSG_COLS_CHANGED); break; } case EIGHTYFORTY: { PrefHandler::Default()->setString(PREF_COLS, "80"); PrefHandler::Default()->setString(PREF_ROWS, "40"); - this->PostMessage (MSG_ROWS_CHANGED); - this->PostMessage (MSG_COLS_CHANGED); + PostMessage (MSG_COLS_CHANGED); break; } case ONETHREETWOTWENTYFOUR: { PrefHandler::Default()->setString(PREF_COLS, "132"); PrefHandler::Default()->setString(PREF_ROWS, "24"); - this->PostMessage (MSG_ROWS_CHANGED); - this->PostMessage (MSG_COLS_CHANGED); + PostMessage (MSG_COLS_CHANGED); break; } case ONETHREETWOTWENTYFIVE: { PrefHandler::Default()->setString(PREF_COLS, "132"); PrefHandler::Default()->setString(PREF_ROWS, "25"); - this->PostMessage (MSG_ROWS_CHANGED); - this->PostMessage (MSG_COLS_CHANGED); + PostMessage (MSG_COLS_CHANGED); break; } case FULLSCREEN: { @@ -549,10 +540,7 @@ _DoPrint(); break; } - case MSGRUN_WINDOW: { - fTermView->UpdateSIGWINCH(); - break; - } + case B_ABOUT_REQUESTED: { be_app->PostMessage(B_ABOUT_REQUESTED); break; @@ -563,30 +551,11 @@ } } } -//////////////////////////////////////////////////////////////////////////// -// WindowActivated (bool) -// Dispatch Mesasge. -//////////////////////////////////////////////////////////////////////////// -void -TermWindow::WindowActivated(bool) -{ -} - -bool -TermWindow::QuitRequested() -{ - be_app->PostMessage(B_QUIT_REQUESTED); - return true; -} - - void -TermWindow::TermWinActivate() +TermWindow::WindowActivated(bool) { - Activate(); - #ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST if (focus_follows_mouse()) { BPoint aMouseLoc = Frame().LeftTop(); @@ -597,6 +566,14 @@ } +bool +TermWindow::QuitRequested() +{ + be_app->PostMessage(B_QUIT_REQUESTED); + return true; +} + + status_t TermWindow::GetSupportedSuites(BMessage *msg) { Modified: haiku/trunk/src/apps/terminal/TermWindow.h =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-24 22:27:57 UTC (rev 21697) +++ haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-25 09:50:34 UTC (rev 21698) @@ -36,7 +36,6 @@ class BMenu; class BMenuBar; -class BMessageRunner; class FindWindow; class PrefWindow; class TermView; @@ -46,8 +45,6 @@ TermWindow(BRect frame, const char* title, const char *command); virtual ~TermWindow(); - void TermWinActivate(); - protected: virtual void MessageReceived(BMessage *message); virtual void WindowActivated(bool); @@ -77,7 +74,6 @@ BMessage *fPrintSettings; PrefWindow *fPrefWindow; FindWindow *fFindPanel; - BMessageRunner *fWindowUpdate; BRect fSavedFrame; window_look fSavedLook; From jackburton at mail.berlios.de Wed Jul 25 12:16:18 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Wed, 25 Jul 2007 12:16:18 +0200 Subject: [Haiku-commits] r21699 - haiku/trunk/src/apps/terminal Message-ID: <200707251016.l6PAGI4R009618@sheep.berlios.de> Author: jackburton Date: 2007-07-25 12:16:18 +0200 (Wed, 25 Jul 2007) New Revision: 21699 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21699&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h Log: Had switched rows and columns in SetTermSize() call inside TermView's constructor. Made UpdateSIGWINCH() private and renamed it to _UpdateSIGWINCH(). Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-25 09:50:34 UTC (rev 21698) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-25 10:16:18 UTC (rev 21699) @@ -155,7 +155,7 @@ SetMouseCursor(); - SetTermFont(be_plain_font, be_plain_font); + SetTermFont(be_fixed_font, be_fixed_font); SetTermColor(); //SetIMAware(PrefHandler::Default()->getInt32(PREF_IM_AWARE)); @@ -172,7 +172,7 @@ if (status < B_OK) throw status; - SetTermSize(fTermColumns, fTermRows, false); + SetTermSize(fTermRows, fTermColumns, false); _InitMouseThread(); } @@ -1114,7 +1114,7 @@ //! Handler for SIGWINCH void -TermView::UpdateSIGWINCH() +TermView::_UpdateSIGWINCH() { if (fFrameResized) { if (HasSelection()) @@ -1550,7 +1550,7 @@ // } // } case kUpdateSigWinch: - UpdateSIGWINCH(); + _UpdateSIGWINCH(); break; default: BView::MessageReceived(msg); Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2007-07-25 09:50:34 UTC (rev 21698) +++ haiku/trunk/src/apps/terminal/TermView.h 2007-07-25 10:16:18 UTC (rev 21699) @@ -117,7 +117,6 @@ void ScrollAtCursor(); // Other - void UpdateSIGWINCH(); void DeviceStatusReport(int); void UpdateLine(); void ScrollScreen(); @@ -186,6 +185,7 @@ bool CheckSelectedRegion(const CurPos &pos); inline void Redraw(int, int, int, int); + void _UpdateSIGWINCH(); static void _FixFontAttributes(BFont &font); Shell *fShell; From jackburton at mail.berlios.de Wed Jul 25 13:31:18 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Wed, 25 Jul 2007 13:31:18 +0200 Subject: [Haiku-commits] r21700 - haiku/trunk/src/apps/terminal Message-ID: <200707251131.l6PBVIVH028428@sheep.berlios.de> Author: jackburton Date: 2007-07-25 13:31:17 +0200 (Wed, 25 Jul 2007) New Revision: 21700 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21700&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h haiku/trunk/src/apps/terminal/TermWindow.cpp haiku/trunk/src/apps/terminal/TermWindow.h Log: Removed more unused stuff. Cleanups. Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-25 10:16:18 UTC (rev 21699) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-25 11:31:17 UTC (rev 21700) @@ -128,9 +128,8 @@ fCursorBlinkingFlag(CURON), fCursorRedrawFlag(CURON), fCursorHeight(0), - fInverseFlag(0), - fBoldFlag(0), - fUnderlineFlag(0), + fCurPos(0, 0), + fCurStack(0, 0), fBufferStartPos(-1), fTermRows(PrefHandler::Default()->getInt32(PREF_ROWS)), fTermColumns(PrefHandler::Default()->getInt32(PREF_COLS)), @@ -141,20 +140,23 @@ fScrBot(fTermRows - 1), fScrBufSize(PrefHandler::Default()->getInt32(PREF_HISTORY_SIZE)), fScrRegionSet(0), + fMouseImage(false), + fPreviousMousePoint(0, 0), + fSelStart(-1, -1), + fSelEnd(-1, -1), fMouseTracking(false), fMouseThread(-1), fQuitting(false), - fIMflag(false) -{ - // Reset cursor - fCurPos.Set(0, 0); - fCurStack.Set(0, 0); - fPreviousMousePoint.Set(0, 0); - fSelStart.Set(-1, -1); - fSelEnd.Set(-1, -1); + fIMflag(false) +{ + _InitObject(command); +} - SetMouseCursor(); +void +TermView::_InitObject(const char *command) +{ + SetMouseCursor(); SetTermFont(be_fixed_font, be_fixed_font); SetTermColor(); @@ -468,11 +470,9 @@ } if (start.y == end.y) { - Redraw(start.x, start.y, - end.x, end.y); + Redraw(start.x, start.y, end.x, end.y); } else { - Redraw(start.x, start.y, - fTermColumns, start.y); + Redraw(start.x, start.y, fTermColumns, start.y); if (end.y - start.y > 0) Redraw(0, start.y + 1, fTermColumns, end.y - 1); @@ -501,15 +501,12 @@ end.y += top; if (start.y == end.y) { - Redraw(start.x, start.y, - end.x, end.y); + Redraw(start.x, start.y, end.x, end.y); } else { - Redraw(start.x, start.y, - fTermColumns - 1, start.y); + Redraw(start.x, start.y, fTermColumns - 1, start.y); if (end.y - start.y > 0) { - Redraw(0, start.y + 1, - fTermColumns - 1, end.y - 1); + Redraw(0, start.y + 1, fTermColumns - 1, end.y - 1); } Redraw(0, end.y, end.x, end.y); } Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2007-07-25 10:16:18 UTC (rev 21699) +++ haiku/trunk/src/apps/terminal/TermView.h 2007-07-25 11:31:17 UTC (rev 21700) @@ -140,6 +140,8 @@ virtual void MessageReceived(BMessage* message); private: + void _InitObject(const char *command); + static int32 MouseTracking(void *); status_t _InitMouseThread(void); @@ -221,14 +223,8 @@ bool fCursorStatus; bool fCursorBlinkingFlag; bool fCursorRedrawFlag; - int fCursorHeight; - // terminal text attribute flag. - bool fInverseFlag; - bool fBoldFlag; - bool fUnderlineFlag; - // Cursor position. CurPos fCurPos; CurPos fCurStack; @@ -247,11 +243,6 @@ TermBuffer *fTextBuffer; BScrollBar *fScrollBar; - // Offscreen Bitmap and View. - - BRect fSrcRect; - BRect fDstRect; - // Color and Attribute. rgb_color fTextForeColor, fTextBackColor; @@ -285,7 +276,6 @@ BString fIMString; bool fIMflag; BMessenger fIMMessenger; - int32 fImCodeState; }; Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-25 10:16:18 UTC (rev 21699) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-25 11:31:17 UTC (rev 21700) @@ -58,12 +58,17 @@ { fTermView = new TermView(Bounds(), command); AddChild(fTermView); + + float width, height; + fTermView->GetPreferredSize(&width, &height); + ResizeTo(width, height); } #else TermWindow::TermWindow(BRect frame, const char* title, const char *command) : BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE), + fTermView(NULL), fMenubar(NULL), fFilemenu(NULL), fEditmenu(NULL), @@ -72,7 +77,6 @@ fFontMenu(NULL), fWindowSizeMenu(NULL), fNewFontMenu(NULL), - fTermView(NULL), fPrintSettings(NULL), fPrefWindow(NULL), fFindPanel(NULL), @@ -87,8 +91,8 @@ { _InitWindow(command); } -#endif + TermWindow::~TermWindow() { if (fPrefWindow) @@ -145,7 +149,7 @@ fTermView->SetTermFont(&halfFont, &fullFont); BRect rect = fTermView->SetTermSize(PrefHandler::Default()->getInt32(PREF_ROWS), - PrefHandler::Default()->getInt32(PREF_COLS), 1); + PrefHandler::Default()->getInt32(PREF_COLS), true); int width, height; fTermView->GetFontSize(&width, &height); @@ -677,4 +681,5 @@ job.CommitJob(); } +#endif Modified: haiku/trunk/src/apps/terminal/TermWindow.h =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-25 10:16:18 UTC (rev 21699) +++ haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-25 11:31:17 UTC (rev 21700) @@ -34,6 +34,7 @@ #include #include + class BMenu; class BMenuBar; class FindWindow; @@ -62,6 +63,7 @@ status_t _DoPageSetup(); void _DoPrint(); + TermView *fTermView; BMenuBar *fMenubar; BMenu *fFilemenu, *fEditmenu, @@ -70,7 +72,7 @@ *fFontMenu, *fWindowSizeMenu, *fNewFontMenu; - TermView *fTermView; + BMessage *fPrintSettings; PrefWindow *fPrefWindow; FindWindow *fFindPanel; From revol at free.fr Wed Jul 25 22:28:39 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Wed, 25 Jul 2007 22:28:39 +0200 CEST Subject: [Haiku-commits] r21698 - haiku/trunk/src/apps/terminal In-Reply-To: <200707250950.l6P9oZIN006854@sheep.berlios.de> Message-ID: <1480145763-BeMail@laptop> > instead. TermApp can now keep a pointer to a BWindow instead of > TermWindow, since it doesn't do anything special with it. Ah, that's good for replicants :)) Fran?ois. From marcusoverhagen at mail.berlios.de Thu Jul 26 00:10:57 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Thu, 26 Jul 2007 00:10:57 +0200 Subject: [Haiku-commits] r21701 - in haiku/trunk/src/system/libroot/posix: sys unistd Message-ID: <200707252210.l6PMAvqh018809@sheep.berlios.de> Author: marcusoverhagen Date: 2007-07-26 00:10:56 +0200 (Thu, 26 Jul 2007) New Revision: 21701 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21701&view=rev Modified: haiku/trunk/src/system/libroot/posix/sys/uio.c haiku/trunk/src/system/libroot/posix/unistd/read.c haiku/trunk/src/system/libroot/posix/unistd/write.c Log: Check the pos parameter before calling into kernel. This does prevent the unwanted side effect of reading or writing at the current file pointer position when the functions are called with a -1 position. It's save to do this check in user space, because calling the _kern_* function with -1 pos has the same effect as calling the normal read/write posix functions. Modified: haiku/trunk/src/system/libroot/posix/sys/uio.c =================================================================== --- haiku/trunk/src/system/libroot/posix/sys/uio.c 2007-07-25 11:31:17 UTC (rev 21700) +++ haiku/trunk/src/system/libroot/posix/sys/uio.c 2007-07-25 22:10:56 UTC (rev 21701) @@ -30,7 +30,12 @@ ssize_t readv_pos(int fd, off_t pos, const struct iovec *vecs, size_t count) { - ssize_t bytes = _kern_readv(fd, pos, vecs, count); + ssize_t bytes; + if (pos < 0) { + errno = B_BAD_VALUE; + return -1; + } + bytes = _kern_readv(fd, pos, vecs, count); RETURN_AND_SET_ERRNO(bytes); } @@ -48,7 +53,12 @@ ssize_t writev_pos(int fd, off_t pos, const struct iovec *vecs, size_t count) { - ssize_t bytes = _kern_writev(fd, pos, vecs, count); + ssize_t bytes; + if (pos < 0) { + errno = B_BAD_VALUE; + return -1; + } + bytes = _kern_writev(fd, pos, vecs, count); RETURN_AND_SET_ERRNO(bytes); } Modified: haiku/trunk/src/system/libroot/posix/unistd/read.c =================================================================== --- haiku/trunk/src/system/libroot/posix/unistd/read.c 2007-07-25 11:31:17 UTC (rev 21700) +++ haiku/trunk/src/system/libroot/posix/unistd/read.c 2007-07-25 22:10:56 UTC (rev 21701) @@ -34,7 +34,12 @@ ssize_t read_pos(int fd, off_t pos, void *buffer, size_t bufferSize) { - ssize_t status = _kern_read(fd, pos, buffer, bufferSize); + ssize_t status; + if (pos < 0) { + errno = B_BAD_VALUE; + return -1; + } + status = _kern_read(fd, pos, buffer, bufferSize); RETURN_AND_SET_ERRNO(status); } @@ -43,7 +48,12 @@ ssize_t pread(int fd, void *buffer, size_t bufferSize, off_t pos) { - ssize_t status = _kern_read(fd, pos, buffer, bufferSize); + ssize_t status; + if (pos < 0) { + errno = B_BAD_VALUE; + return -1; + } + status = _kern_read(fd, pos, buffer, bufferSize); RETURN_AND_SET_ERRNO(status); } Modified: haiku/trunk/src/system/libroot/posix/unistd/write.c =================================================================== --- haiku/trunk/src/system/libroot/posix/unistd/write.c 2007-07-25 11:31:17 UTC (rev 21700) +++ haiku/trunk/src/system/libroot/posix/unistd/write.c 2007-07-25 22:10:56 UTC (rev 21701) @@ -32,7 +32,12 @@ ssize_t write_pos(int fd, off_t pos, const void *buffer, size_t bufferSize) { - int status = _kern_write(fd, pos, buffer, bufferSize); + ssize_t status; + if (pos < 0) { + errno = B_BAD_VALUE; + return -1; + } + status = _kern_write(fd, pos, buffer, bufferSize); RETURN_AND_SET_ERRNO(status); } @@ -41,7 +46,12 @@ ssize_t pwrite(int fd, const void *buffer, size_t bufferSize, off_t pos) { - int status = _kern_write(fd, pos, buffer, bufferSize); + ssize_t status; + if (pos < 0) { + errno = B_BAD_VALUE; + return -1; + } + status = _kern_write(fd, pos, buffer, bufferSize); RETURN_AND_SET_ERRNO(status); } From marcusoverhagen at mail.berlios.de Thu Jul 26 00:31:00 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Thu, 26 Jul 2007 00:31:00 +0200 Subject: [Haiku-commits] r21702 - haiku/trunk/src/system/kernel/fs Message-ID: <200707252231.l6PMV0Bq021141@sheep.berlios.de> Author: marcusoverhagen Date: 2007-07-26 00:30:59 +0200 (Thu, 26 Jul 2007) New Revision: 21702 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21702&view=rev Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp Log: Make partition access saver. attempts to read or write outside of a partition now fail with B_BAD_VALUE. It's also no longer possible to overwrite the begin of a partition by specifying a negative position, as negative positions are no longer translated into 0. Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/devfs.cpp 2007-07-25 22:10:56 UTC (rev 21701) +++ haiku/trunk/src/system/kernel/fs/devfs.cpp 2007-07-25 22:30:59 UTC (rev 21702) @@ -671,14 +671,9 @@ translate_partition_access(devfs_partition *partition, off_t &offset, size_t &size) { - if (offset < 0) - offset = 0; + ASSERT(offset >= 0); + ASSERT(offset < partition->info.size); - if (offset > partition->info.size) { - size = 0; - return; - } - size = min_c(size, partition->info.size - offset); offset += partition->info.offset; } @@ -1472,9 +1467,16 @@ if (!S_ISCHR(vnode->stream.type)) return B_BAD_VALUE; - if (vnode->stream.u.dev.partition) - translate_partition_access(vnode->stream.u.dev.partition, pos, *_length); + if (pos < 0) + return B_BAD_VALUE; + if (vnode->stream.u.dev.partition) { + if (pos >= vnode->stream.u.dev.partition->info.size) + return B_BAD_VALUE; + translate_partition_access(vnode->stream.u.dev.partition, pos, + *_length); + } + if (*_length == 0) return B_OK; @@ -1507,9 +1509,16 @@ if (!S_ISCHR(vnode->stream.type)) return B_BAD_VALUE; - if (vnode->stream.u.dev.partition) - translate_partition_access(vnode->stream.u.dev.partition, pos, *_length); + if (pos < 0) + return B_BAD_VALUE; + if (vnode->stream.u.dev.partition) { + if (pos >= vnode->stream.u.dev.partition->info.size) + return B_BAD_VALUE; + translate_partition_access(vnode->stream.u.dev.partition, pos, + *_length); + } + if (*_length == 0) return B_OK; @@ -1888,7 +1897,12 @@ || cookie == NULL) return B_NOT_ALLOWED; + if (pos < 0) + return B_BAD_VALUE; + if (vnode->stream.u.dev.partition) { + if (pos >= vnode->stream.u.dev.partition->info.size) + return B_BAD_VALUE; translate_partition_access(vnode->stream.u.dev.partition, pos, *_numBytes); } @@ -1942,7 +1956,12 @@ || cookie == NULL) return B_NOT_ALLOWED; + if (pos < 0) + return B_BAD_VALUE; + if (vnode->stream.u.dev.partition) { + if (pos >= vnode->stream.u.dev.partition->info.size) + return B_BAD_VALUE; translate_partition_access(vnode->stream.u.dev.partition, pos, *_numBytes); } From phoudoin at mail.berlios.de Thu Jul 26 01:44:01 2007 From: phoudoin at mail.berlios.de (phoudoin at BerliOS) Date: Thu, 26 Jul 2007 01:44:01 +0200 Subject: [Haiku-commits] r21703 - haiku/trunk/headers/os/drivers Message-ID: <200707252344.l6PNi10p005775@sheep.berlios.de> Author: phoudoin Date: 2007-07-26 01:44:00 +0200 (Thu, 26 Jul 2007) New Revision: 21703 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21703&view=rev Modified: haiku/trunk/headers/os/drivers/dpc.h Log: DPC module interface is not binary compatible with Be's own DPC. Make our DPC named differently to avoid this confusion. Detected while testing our ACPI (which needs our DPC) under R5... Modified: haiku/trunk/headers/os/drivers/dpc.h =================================================================== --- haiku/trunk/headers/os/drivers/dpc.h 2007-07-25 22:30:59 UTC (rev 21702) +++ haiku/trunk/headers/os/drivers/dpc.h 2007-07-25 23:44:00 UTC (rev 21703) @@ -12,7 +12,7 @@ extern "C" { #endif -#define B_DPC_MODULE_NAME "generic/dpc/v1" +#define B_DPC_MODULE_NAME "generic/dpc/haiku/v1" typedef void (*dpc_func) (void *arg); From stefano.ceccherini at gmail.com Thu Jul 26 08:24:33 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Thu, 26 Jul 2007 08:24:33 +0200 Subject: [Haiku-commits] r21703 - haiku/trunk/headers/os/drivers In-Reply-To: <200707252344.l6PNi10p005775@sheep.berlios.de> References: <200707252344.l6PNi10p005775@sheep.berlios.de> Message-ID: <894b9700707252324s37d1c227hee6a3da96b1e9749@mail.gmail.com> 2007/7/26, phoudoin at BerliOS : > -#define B_DPC_MODULE_NAME "generic/dpc/v1" > +#define B_DPC_MODULE_NAME "generic/dpc/haiku/v1" > why not "generic/dpc/v2" ? :) At least, it seems weird to add haiku to the name, since we dont' do that in any other module. From axeld at pinc-software.de Thu Jul 26 11:17:07 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 26 Jul 2007 11:17:07 +0200 CEST Subject: [Haiku-commits] r21703 - haiku/trunk/headers/os/drivers In-Reply-To: <894b9700707252324s37d1c227hee6a3da96b1e9749@mail.gmail.com> Message-ID: <1524990631-BeMail@ibm> "Stefano Ceccherini" wrote: > 2007/7/26, phoudoin at BerliOS : > > -#define B_DPC_MODULE_NAME "generic/dpc/v1" > > +#define B_DPC_MODULE_NAME "generic/dpc/haiku/v1" > why not "generic/dpc/v2" ? :) > At least, it seems weird to add haiku to the name, since we dont' do > that in any other module. Just wanted to write the same thing :-) And what part is not compatible, anyway - can we change that, or do we provide more/other features? Bye, Axel. From stefano.ceccherini at gmail.com Thu Jul 26 16:02:39 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Thu, 26 Jul 2007 16:02:39 +0200 Subject: [Haiku-commits] r21698 - haiku/trunk/src/apps/terminal In-Reply-To: <1480145763-BeMail@laptop> References: <200707250950.l6P9oZIN006854@sheep.berlios.de> <1480145763-BeMail@laptop> Message-ID: <894b9700707260702o12df98c7tdfd8a6cca3048f55@mail.gmail.com> 2007/7/25, Fran?ois Revol : > > instead. TermApp can now keep a pointer to a BWindow instead of > > TermWindow, since it doesn't do anything special with it. > > Ah, that's good for replicants :)) > Yeah. Feel lucky to try ? :) From jackburton at mail.berlios.de Thu Jul 26 16:52:24 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 26 Jul 2007 16:52:24 +0200 Subject: [Haiku-commits] r21704 - haiku/trunk/src/apps/terminal Message-ID: <200707261452.l6QEqOFD021645@sheep.berlios.de> Author: jackburton Date: 2007-07-26 16:52:24 +0200 (Thu, 26 Jul 2007) New Revision: 21704 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21704&view=rev Modified: haiku/trunk/src/apps/terminal/CodeConv.cpp haiku/trunk/src/apps/terminal/Coding.cpp haiku/trunk/src/apps/terminal/Coding.h haiku/trunk/src/apps/terminal/MenuUtil.cpp haiku/trunk/src/apps/terminal/MenuUtil.h haiku/trunk/src/apps/terminal/TermParse.cpp haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h haiku/trunk/src/apps/terminal/TermWindow.cpp Log: Encoding is now a property of TermView. Changed a lot of code to fix the problems caused by this change. MakeEncodingMenu doesn't mark the current encoding anymore, it was already done in TermWindow::MenusBeginning(). Removed custom enums for encodings, just use the ones provided in UTF8.h. I'm more and more convinced we should drop the custom conversion routines and use the system ones. Modified: haiku/trunk/src/apps/terminal/CodeConv.cpp =================================================================== --- haiku/trunk/src/apps/terminal/CodeConv.cpp 2007-07-25 23:44:00 UTC (rev 21703) +++ haiku/trunk/src/apps/terminal/CodeConv.cpp 2007-07-26 14:52:24 UTC (rev 21704) @@ -22,7 +22,7 @@ ************************************************************************/ -#include +#include #include #include "CodeConv.h" @@ -62,17 +62,15 @@ return srclen; } - int theCoding = coding_translation_table[coding]; - int32 dstlen = srclen * 256; long state = 0; - convert_from_utf8(theCoding, (char *)src, &srclen, + convert_from_utf8(coding, (char *)src, &srclen, (char *)dst, &dstlen, &state, '?'); // TODO: Apart from this particular case, looks like we could use the // system api for code conversion... check if this (which looks a lot like a workaround) // applies to haiku, and if not, get rid of this class and just use the system api directly. - if (coding == M_ISO_2022_JP && state != 0) { + if (coding == B_EUC_CONVERSION && state != 0) { const char *end_of_jis = "(B"; strncpy((char *)dst + dstlen, end_of_jis, 3); dstlen += 3; @@ -113,10 +111,9 @@ #endif #endif - int theCoding = coding_translation_table[coding]; int32 dstlen = 4; long state = 0; - convert_to_utf8(theCoding, (char *)src, &srclen, + convert_to_utf8(coding, (char *)src, &srclen, (char *)dst, &dstlen, &state, '?'); dst[dstlen] = '\0'; Modified: haiku/trunk/src/apps/terminal/Coding.cpp =================================================================== --- haiku/trunk/src/apps/terminal/Coding.cpp 2007-07-25 23:44:00 UTC (rev 21703) +++ haiku/trunk/src/apps/terminal/Coding.cpp 2007-07-26 14:52:24 UTC (rev 21704) @@ -15,22 +15,23 @@ const static etable kEncodingTable[] = { {"UTF-8", "UTF8", 'U', M_UTF8}, - {"ISO-8859-1", "8859-1", '1', M_ISO_8859_1}, - {"ISO-8859-2", "8859-2", '2', M_ISO_8859_2}, - {"ISO-8859-3", "8859-3", '3', M_ISO_8859_3}, - {"ISO-8859-4", "8859-4", '4', M_ISO_8859_4}, - {"ISO-8859-5", "8859-5", '5', M_ISO_8859_5}, - {"ISO-8859-6", "8859-6", '6', M_ISO_8859_6}, - {"ISO-8859-7", "8859-7", '7', M_ISO_8859_7}, - {"ISO-8859-8", "8859-8", '8', M_ISO_8859_8}, - {"ISO-8859-9", "8859-9", '9', M_ISO_8859_9}, - {"ISO-8859-10", "8859-10", '0', M_ISO_8859_10}, - {"MacRoman", "MacRoman",'M', M_MAC_ROMAN}, - {"JIS", "JIS", 'J', M_ISO_2022_JP}, - {"Shift-JIS", "SJIS", 'S', M_SJIS}, - {"EUC-jp", "EUCJ", 'E', M_EUC_JP}, - {"EUC-kr", "EUCK", 'K', M_EUC_KR}, + {"ISO-8859-1", "8859-1", '1', B_ISO1_CONVERSION}, + {"ISO-8859-2", "8859-2", '2', B_ISO2_CONVERSION}, + {"ISO-8859-3", "8859-3", '3', B_ISO3_CONVERSION}, + {"ISO-8859-4", "8859-4", '4', B_ISO4_CONVERSION}, + {"ISO-8859-5", "8859-5", '5', B_ISO5_CONVERSION}, + {"ISO-8859-6", "8859-6", '6', B_ISO6_CONVERSION}, + {"ISO-8859-7", "8859-7", '7', B_ISO7_CONVERSION}, + {"ISO-8859-8", "8859-8", '8', B_ISO8_CONVERSION}, + {"ISO-8859-9", "8859-9", '9', B_ISO9_CONVERSION}, + {"ISO-8859-10", "8859-10", '0', B_ISO10_CONVERSION}, + {"MacRoman", "MacRoman",'M', B_MAC_ROMAN_CONVERSION}, + {"JIS", "JIS", 'J', B_JIS_CONVERSION}, + {"Shift-JIS", "SJIS", 'S', B_SJIS_CONVERSION}, + {"EUC-jp", "EUCJ", 'E', B_EUC_CONVERSION}, + {"EUC-kr", "EUCK", 'K', B_EUC_KR_CONVERSION}, + /* Not Implement. {"EUC-tw", "EUCT", "T", M_EUC_TW}, {"Big5", "Big5", 'B', M_BIG5}, @@ -42,16 +43,14 @@ }; -static int sCurrentEncoding = M_UTF8; - status_t get_nth_encoding(int i, int *id) { if (id == NULL) return B_BAD_VALUE; - if (i < 0 || i >= (int)(sizeof(kEncodingTable) / sizeof(etable))) + if (i < 0 || i >= (int)(sizeof(kEncodingTable) / sizeof(etable)) - 1) return B_BAD_INDEX; *id = kEncodingTable[i].id; @@ -97,27 +96,23 @@ const char * id2longname(int id) { - return kEncodingTable[id].name; + const etable *p = kEncodingTable; + while (p->name) { + if (id == p->id) + return p->name; + p++; + } } const char id2shortcut(int id) { - return kEncodingTable[id].shortcut; + const etable *p = kEncodingTable; + while (p->name) { + if (id == p->id) + return p->shortcut; + p++; + } } - -void -SetEncoding(int encoding) -{ - sCurrentEncoding = encoding; -} - - -int -GetEncoding() -{ - return sCurrentEncoding; -} - Modified: haiku/trunk/src/apps/terminal/Coding.h =================================================================== --- haiku/trunk/src/apps/terminal/Coding.h 2007-07-25 23:44:00 UTC (rev 21703) +++ haiku/trunk/src/apps/terminal/Coding.h 2007-07-26 14:52:24 UTC (rev 21704) @@ -32,57 +32,11 @@ #ifndef _CODING__H_ #define _CODING__H_ +#include #include -enum { - M_UTF8, /* UTF-8 */ - M_ISO_8859_1, /* ISO-8859 */ - M_ISO_8859_2, - M_ISO_8859_3, - M_ISO_8859_4, - M_ISO_8859_5, - M_ISO_8859_6, - M_ISO_8859_7, - M_ISO_8859_8, - M_ISO_8859_9, - M_ISO_8859_10, +#define M_UTF8 (uint32)(-1) - M_MAC_ROMAN, /* Macintosh Roman */ - - M_ISO_2022_JP, - M_SJIS, /* Japanese */ - M_EUC_JP, - M_EUC_KR - - // M_EUC_TW, /* Chinese */ - // M_BIG5, - // M_ISO_2022_CN, - - // M_EUC_KR, /* Koeran */ - // M_ISO_2022_KR, - -}; - -const uint32 coding_translation_table[] = { - 0, - B_ISO1_CONVERSION, /* ISO 8859-1 */ - B_ISO2_CONVERSION, /* ISO 8859-2 */ - B_ISO3_CONVERSION, /* ISO 8859-3 */ - B_ISO4_CONVERSION, /* ISO 8859-4 */ - B_ISO5_CONVERSION, /* ISO 8859-5 */ - B_ISO6_CONVERSION, /* ISO 8859-6 */ - B_ISO7_CONVERSION, /* ISO 8859-7 */ - B_ISO8_CONVERSION, /* ISO 8859-8 */ - B_ISO9_CONVERSION, /* ISO 8859-9 */ - B_ISO10_CONVERSION, /* ISO 8859-10 */ - B_MAC_ROMAN_CONVERSION, /* Macintosh Roman */ - B_JIS_CONVERSION, /* JIS X 0208-1990 */ - B_SJIS_CONVERSION, /* Shift-JIS */ - B_EUC_CONVERSION, /* EUC Packed Japanese */ - B_EUC_KR_CONVERSION /* EUC Korean */ -}; - - status_t get_nth_encoding(int i, int *id); int longname2id(const char *longname); @@ -90,7 +44,5 @@ const char * id2longname(int op); const char id2shortcut(int op); -void SetEncoding(int encoding); -int GetEncoding(); #endif /* _CODING_H_ */ Modified: haiku/trunk/src/apps/terminal/MenuUtil.cpp =================================================================== --- haiku/trunk/src/apps/terminal/MenuUtil.cpp 2007-07-25 23:44:00 UTC (rev 21703) +++ haiku/trunk/src/apps/terminal/MenuUtil.cpp 2007-07-26 14:52:24 UTC (rev 21704) @@ -41,7 +41,7 @@ void -MakeEncodingMenu(BMenu *eMenu, int marked, bool flag) +MakeEncodingMenu(BMenu *eMenu, bool flag) { int encoding; int i = 0; @@ -53,9 +53,6 @@ else eMenu->AddItem(new BMenuItem(id2longname(encoding), msg)); - if (i == marked) - eMenu->ItemAt(i)->SetMarked(true); - i++; } } Modified: haiku/trunk/src/apps/terminal/MenuUtil.h =================================================================== --- haiku/trunk/src/apps/terminal/MenuUtil.h 2007-07-25 23:44:00 UTC (rev 21703) +++ haiku/trunk/src/apps/terminal/MenuUtil.h 2007-07-26 14:52:24 UTC (rev 21704) @@ -20,7 +20,7 @@ BPopUpMenu * MakeMenu(ulong msg, const char **items, const char *defaultItemName); -void MakeEncodingMenu(BMenu *eMenu, int coding, bool flag); +void MakeEncodingMenu(BMenu *eMenu, bool flag); void LoadLocaleFile (PrefHandler *); Modified: haiku/trunk/src/apps/terminal/TermParse.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-25 23:44:00 UTC (rev 21703) +++ haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-26 14:52:24 UTC (rev 21704) @@ -288,37 +288,38 @@ if (GetReaderBuf(c) < B_OK) break; - if (now_coding != GetEncoding()) { + if (now_coding != fView->Encoding()) { /* * Change coding, change parse table. */ - switch (GetEncoding()) { - case M_UTF8: - groundtable = utf8_groundtable; - break; - case M_ISO_8859_1: - case M_ISO_8859_2: - case M_ISO_8859_3: - case M_ISO_8859_4: - case M_ISO_8859_5: - case M_ISO_8859_6: - case M_ISO_8859_7: - case M_ISO_8859_8: - case M_ISO_8859_9: - case M_ISO_8859_10: + switch (fView->Encoding()) { + case B_ISO1_CONVERSION: + case B_ISO2_CONVERSION: + case B_ISO3_CONVERSION: + case B_ISO4_CONVERSION: + case B_ISO5_CONVERSION: + case B_ISO6_CONVERSION: + case B_ISO7_CONVERSION: + case B_ISO8_CONVERSION: + case B_ISO9_CONVERSION: + case B_ISO10_CONVERSION: groundtable = iso8859_groundtable; break; - case M_SJIS: + case B_SJIS_CONVERSION: groundtable = sjis_groundtable; break; - case M_EUC_JP: - case M_EUC_KR: - case M_ISO_2022_JP: + case B_EUC_CONVERSION: + case B_EUC_KR_CONVERSION: + case B_JIS_CONVERSION: groundtable = iso8859_groundtable; break; + case M_UTF8: + default: + groundtable = utf8_groundtable; + break; } parsestate = groundtable; - now_coding = GetEncoding(); + now_coding = fView->Encoding(); } switch (parsestate[c]) { @@ -332,8 +333,8 @@ case CASE_PRINT_GR: /* case iso8859 gr character, or euc */ ptr = cbuf; - if (now_coding == M_EUC_JP || now_coding == M_EUC_KR - || now_coding == M_ISO_2022_JP) { + if (now_coding == B_EUC_CONVERSION || now_coding == B_EUC_KR_CONVERSION + || now_coding == B_JIS_CONVERSION) { switch (parsestate[curess]) { case CASE_SS2: /* JIS X 0201 */ *ptr++ = curess; @@ -366,10 +367,10 @@ width = 1; } - if (now_coding != M_ISO_2022_JP) + if (now_coding != B_JIS_CONVERSION) CodeConv::ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, now_coding); else - CodeConv::ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, M_EUC_JP); + CodeConv::ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, B_EUC_CONVERSION); fView->PutChar(dstbuf, attr, width); break; @@ -380,7 +381,7 @@ cbuf[1] |= 0x80; cbuf[2] = 0; width = 2; - CodeConv::ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, M_EUC_JP); + CodeConv::ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, B_EUC_CONVERSION); fView->PutChar(dstbuf, attr, width); break; Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-25 23:44:00 UTC (rev 21703) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-26 14:52:24 UTC (rev 21704) @@ -133,6 +133,7 @@ fBufferStartPos(-1), fTermRows(PrefHandler::Default()->getInt32(PREF_ROWS)), fTermColumns(PrefHandler::Default()->getInt32(PREF_COLS)), + fEncoding(M_UTF8), fTop(0), fTextBuffer(new (nothrow) TermBuffer(fTermRows, fTermColumns)), fScrollBar(NULL), @@ -294,6 +295,20 @@ } +int +TermView::Encoding() const +{ + return fEncoding; +} + + +void +TermView::SetEncoding(int encoding) +{ + fEncoding = encoding; +} + + //! Sets half and full fonts for terminal void TermView::SetTermFont(const BFont *halfFont, const BFont *fullFont) @@ -1429,10 +1444,10 @@ } } else { // input multibyte character - if (GetEncoding() != M_UTF8) { + if (fEncoding != M_UTF8) { uchar dstbuf[1024]; int cnum = CodeConv::ConvertFromInternal(bytes, numBytes, - (char *)dstbuf, GetEncoding()); + (char *)dstbuf, fEncoding); fShell->Write(dstbuf, cnum); } } @@ -1679,10 +1694,10 @@ void TermView::WritePTY(const uchar *text, int numBytes) { - if (GetEncoding() != M_UTF8) { + if (fEncoding != M_UTF8) { uchar *destBuffer = (uchar *)malloc(numBytes * 3); numBytes = CodeConv::ConvertFromInternal((char*)text, numBytes, - (char*)destBuffer, GetEncoding()); + (char*)destBuffer, fEncoding); fShell->Write(destBuffer, numBytes); free(destBuffer); } else { @@ -1839,12 +1854,14 @@ if (fTextBuffer->GetChar(start.y, start.x, buf, &attr) == IN_STRING) { start.x--; - if (start.x < 0) start.x = 0; + if (start.x < 0) + start.x = 0; } if (fTextBuffer->GetChar(end.y, end.x, buf, &attr) == IN_STRING) { end.x++; - if (end.x >= fTermColumns) end.x = fTermColumns; + if (end.x >= fTermColumns) + end.x = fTermColumns; } fSelStart = start; Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2007-07-25 23:44:00 UTC (rev 21703) +++ haiku/trunk/src/apps/terminal/TermView.h 2007-07-26 14:52:24 UTC (rev 21704) @@ -68,6 +68,9 @@ BRect SetTermSize(int rows, int cols, bool flag); void SetTermColor(); + int Encoding() const; + void SetEncoding(int encoding); + void SetMouseCursor(); // void SetIMAware (bool); void SetScrollBar(BScrollBar *scrbar); @@ -235,6 +238,8 @@ int fTermRows; int fTermColumns; + int fEncoding; + // Terminal view pointer. int fTop; Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-25 23:44:00 UTC (rev 21703) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-26 14:52:24 UTC (rev 21704) @@ -144,6 +144,7 @@ textframe.top = fMenubar->Bounds().bottom + 1.0; fTermView = new TermView(textframe, command); + fTermView->SetEncoding(longname2id(PrefHandler::Default()->getString(PREF_TEXT_ENCODING))); // Initialize TermView. (font, size and color) fTermView->SetTermFont(&halfFont, &fullFont); @@ -187,7 +188,9 @@ TermWindow::MenusBeginning() { // Syncronize Encode Menu Pop-up menu and Preference. - (fEncodingmenu->FindItem(id2longname(GetEncoding())))->SetMarked(true); + BMenuItem *item = fEncodingmenu->FindItem(id2longname(fTermView->Encoding())); + if (item != NULL) + item->SetMarked(true); BWindow::MenusBeginning(); } @@ -261,7 +264,7 @@ fEncodingmenu = new BMenu("Font Encoding"); fEncodingmenu->SetRadioMode(true); - MakeEncodingMenu(fEncodingmenu, GetEncoding(), true); + MakeEncodingMenu(fEncodingmenu, true); fHelpmenu->AddItem(fWindowSizeMenu); fHelpmenu->AddItem(fEncodingmenu); // fHelpmenu->AddItem(fNewFontMenu); @@ -382,7 +385,7 @@ case MENU_ENCODING: { message->FindInt32 ("op", &coding_id); - SetEncoding(coding_id); + fTermView->SetEncoding(coding_id); break; } // Extended B_SET_PROPERTY. Dispatch this message, @@ -393,7 +396,7 @@ message->GetCurrentSpecifier(&i, &spe); if (!strcmp("encode", spe.FindString("property", i))){ message->FindInt32 ("data", &coding_id); - SetEncoding (coding_id); + fTermView->SetEncoding (coding_id); message->SendReply(B_REPLY); } else { @@ -409,7 +412,7 @@ message->GetCurrentSpecifier(&i, &spe); if (!strcmp("encode", spe.FindString("property", i))){ BMessage reply(B_REPLY); - reply.AddInt32("result", GetEncoding()); + reply.AddInt32("result", fTermView->Encoding()); message->SendReply(&reply); } else if (!strcmp("tty", spe.FindString("property", i))) { From jackburton at mail.berlios.de Thu Jul 26 17:07:16 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 26 Jul 2007 17:07:16 +0200 Subject: [Haiku-commits] r21705 - haiku/trunk/src/apps/terminal Message-ID: <200707261507.l6QF7Gbr022846@sheep.berlios.de> Author: jackburton Date: 2007-07-26 17:07:16 +0200 (Thu, 26 Jul 2007) New Revision: 21705 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21705&view=rev Modified: haiku/trunk/src/apps/terminal/Coding.cpp haiku/trunk/src/apps/terminal/Coding.h haiku/trunk/src/apps/terminal/TermBuffer.cpp haiku/trunk/src/apps/terminal/TermBuffer.h haiku/trunk/src/apps/terminal/TermConst.h haiku/trunk/src/apps/terminal/TermWindow.cpp Log: Fixed warnings, rearranged some headers. Modified: haiku/trunk/src/apps/terminal/Coding.cpp =================================================================== --- haiku/trunk/src/apps/terminal/Coding.cpp 2007-07-26 14:52:24 UTC (rev 21704) +++ haiku/trunk/src/apps/terminal/Coding.cpp 2007-07-26 15:07:16 UTC (rev 21705) @@ -5,7 +5,7 @@ const char *name; // long name for menu item. const char *shortname; // short name (use for command-line etc.) const char shortcut; // short cut key code - const uint32 id; // encoding id + const int32 id; // encoding id }; @@ -32,7 +32,7 @@ {"EUC-kr", "EUCK", 'K', B_EUC_KR_CONVERSION}, - /* Not Implement. + /* Not Implemented. {"EUC-tw", "EUCT", "T", M_EUC_TW}, {"Big5", "Big5", 'B', M_BIG5}, {"ISO-2022-cn", "ISOC", 'C', M_ISO_2022_CN}, @@ -102,6 +102,8 @@ return p->name; p++; } + + return kEncodingTable[0].name; } @@ -114,5 +116,6 @@ return p->shortcut; p++; } + return kEncodingTable[0].shortcut; } Modified: haiku/trunk/src/apps/terminal/Coding.h =================================================================== --- haiku/trunk/src/apps/terminal/Coding.h 2007-07-26 14:52:24 UTC (rev 21704) +++ haiku/trunk/src/apps/terminal/Coding.h 2007-07-26 15:07:16 UTC (rev 21705) @@ -35,7 +35,7 @@ #include #include -#define M_UTF8 (uint32)(-1) +#define M_UTF8 (-1) status_t get_nth_encoding(int i, int *id); Modified: haiku/trunk/src/apps/terminal/TermBuffer.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermBuffer.cpp 2007-07-26 14:52:24 UTC (rev 21704) +++ haiku/trunk/src/apps/terminal/TermBuffer.cpp 2007-07-26 15:07:16 UTC (rev 21705) @@ -73,18 +73,19 @@ ************************************************************************/ +#include "TermBuffer.h" + +#include "CurPos.h" +#include "PrefHandler.h" +#include "TermConst.h" + #include #include #include -#include +#include #include -#include -#include "TermBuffer.h" -#include "TermConst.h" -#include "CurPos.h" -#include "PrefHandler.h" #define ARRAY_SIZE 512 #define ROW(x) (((x) + fRowOffset) % fBufferSize) @@ -223,12 +224,10 @@ void TermBuffer::WriteChar(const CurPos &pos, const uchar *u, ushort attr) { - term_buffer *ptr; - const int row = pos.y; const int col = pos.x; - ptr = (fBuffer[ROW(row)] + col); + term_buffer *ptr = (fBuffer[ROW(row)] + col); memcpy ((char *)ptr->code, u, 4); if (IS_WIDTH(attr)) Modified: haiku/trunk/src/apps/terminal/TermBuffer.h =================================================================== --- haiku/trunk/src/apps/terminal/TermBuffer.h 2007-07-26 14:52:24 UTC (rev 21704) +++ haiku/trunk/src/apps/terminal/TermBuffer.h 2007-07-26 15:07:16 UTC (rev 21705) @@ -35,10 +35,7 @@ #include "CurPos.h" -#define MIN_COLS 10 -#define MAX_COLS 256 - struct term_buffer { uchar code[4]; Modified: haiku/trunk/src/apps/terminal/TermConst.h =================================================================== --- haiku/trunk/src/apps/terminal/TermConst.h 2007-07-26 14:52:24 UTC (rev 21704) +++ haiku/trunk/src/apps/terminal/TermConst.h 2007-07-26 15:07:16 UTC (rev 21705) @@ -140,6 +140,9 @@ SCRDOWN }; +#define MIN_COLS 10 +#define MAX_COLS 256 + // Insert mode flag #define MODE_OVER 0 #define MODE_INSERT 1 Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-26 14:52:24 UTC (rev 21704) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-26 15:07:16 UTC (rev 21705) @@ -6,6 +6,19 @@ * * Distributed unter the terms of the MIT license. */ + +#include "TermWindow.h" + +#include "Coding.h" +#include "ColorWindow.h" +#include "MenuUtil.h" +#include "FindWindow.h" +#include "PrefWindow.h" +#include "PrefView.h" +#include "PrefHandler.h" +#include "TermConst.h" +#include "TermView.h" + #include #include #include @@ -22,24 +35,9 @@ #include #include -#include -#include -#include +#include +#include -#include "Coding.h" -#include "ColorWindow.h" -#include "MenuUtil.h" -#include "FindWindow.h" -#include "PrefWindow.h" -#include "PrefView.h" -#include "PrefHandler.h" -#include "TermBuffer.h" -#include "TermParse.h" -#include "TermView.h" -#include "TermWindow.h" -#include "TermConst.h" - - // // help and GPL URL // From jackburton at mail.berlios.de Thu Jul 26 17:22:22 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 26 Jul 2007 17:22:22 +0200 Subject: [Haiku-commits] r21706 - haiku/trunk/src/apps/terminal Message-ID: <200707261522.l6QFMMXB023832@sheep.berlios.de> Author: jackburton Date: 2007-07-26 17:22:21 +0200 (Thu, 26 Jul 2007) New Revision: 21706 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21706&view=rev Modified: haiku/trunk/src/apps/terminal/Shell.cpp haiku/trunk/src/apps/terminal/Shell.h haiku/trunk/src/apps/terminal/TermView.cpp Log: More headers cleanup Modified: haiku/trunk/src/apps/terminal/Shell.cpp =================================================================== --- haiku/trunk/src/apps/terminal/Shell.cpp 2007-07-26 15:07:16 UTC (rev 21705) +++ haiku/trunk/src/apps/terminal/Shell.cpp 2007-07-26 15:22:21 UTC (rev 21706) @@ -30,6 +30,14 @@ * */ + +#include "Shell.h" + +#include "TermConst.h" +#include "TermParse.h" + +#include + #include #include #include @@ -46,14 +54,54 @@ #include #include -#include +#define MAXPTTYS 16 * 4 -#include "TermConst.h" -#include "TermParse.h" -#include "TermView.h" -#include "Shell.h" -#include "PrefHandler.h" +#ifndef CEOF +#define CEOF ('D'&037) +#endif +#ifndef CSUSP +#define CSUSP ('@'&037) +#endif +#ifndef CQUIT +#define CQUIT ('\\'&037) +#endif +#ifndef CEOL +#define CEOL 0 +#endif +#ifndef CSTOP +#define CSTOP ('Q'&037) +#endif +#ifndef CSTART +#define CSTART ('S'&037) +#endif +#ifndef CSWTCH +#define CSWTCH 0 +#endif +/* + * ANSI emulation. + */ +#define INQ 0x05 +#define FF 0x0C /* C0, C1 control names */ +#define LS1 0x0E +#define LS0 0x0F +#define CAN 0x18 +#define SUB 0x1A +#define ESC 0x1B +#define US 0x1F +#define DEL 0x7F +#define HTS ('H'+0x40) +#define SS2 0x8E +#define SS3 0x8F +#define DCS 0x90 +#define OLDID 0x9A /* ESC Z */ +#define CSI 0x9B +#define ST 0x9C +#define OSC 0x9D +#define PM 0x9E +#define APC 0x9F +#define RDEL 0xFF + /* default shell command and options. */ #define SHELL_COMMAND "/bin/sh -login" Modified: haiku/trunk/src/apps/terminal/Shell.h =================================================================== --- haiku/trunk/src/apps/terminal/Shell.h 2007-07-26 15:07:16 UTC (rev 21705) +++ haiku/trunk/src/apps/terminal/Shell.h 2007-07-26 15:22:21 UTC (rev 21706) @@ -1,4 +1,5 @@ /* + * Copyright 2007 Haiku, Inc. * Copyright (c) 2003-4 Kian Duffy * Copyright (c) 2004 Daniel Furrer * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. @@ -32,55 +33,8 @@ #ifndef _SHELL_H #define _SHELL_H -#define MAXPTTYS 16 * 4 +#include -#ifndef CEOF -#define CEOF ('D'&037) -#endif -#ifndef CSUSP -#define CSUSP ('@'&037) -#endif -#ifndef CQUIT -#define CQUIT ('\\'&037) -#endif -#ifndef CEOL -#define CEOL 0 -#endif -#ifndef CSTOP -#define CSTOP ('Q'&037) -#endif -#ifndef CSTART -#define CSTART ('S'&037) -#endif -#ifndef CSWTCH -#define CSWTCH 0 -#endif - -/* - * ANSI emulation. - */ -#define INQ 0x05 -#define FF 0x0C /* C0, C1 control names */ -#define LS1 0x0E -#define LS0 0x0F -#define CAN 0x18 -#define SUB 0x1A -#define ESC 0x1B -#define US 0x1F -#define DEL 0x7F -#define HTS ('H'+0x40) -#define SS2 0x8E -#define SS3 0x8F -#define DCS 0x90 -#define OLDID 0x9A /* ESC Z */ -#define CSI 0x9B -#define ST 0x9C -#define OSC 0x9D -#define PM 0x9E -#define APC 0x9F -#define RDEL 0xFF - - // TODO: Maybe merge TermParse and Shell classes ? class TermParse; class TermView; Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-26 15:07:16 UTC (rev 21705) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-26 15:22:21 UTC (rev 21706) @@ -19,7 +19,6 @@ #include "Shell.h" #include "TermBuffer.h" #include "TermConst.h" -#include "TermParse.h" #include "VTkeymap.h" #include From axeld at pinc-software.de Thu Jul 26 15:26:11 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 26 Jul 2007 15:26:11 +0200 CEST Subject: [Haiku-commits] r21683 - haiku/trunk/src/kits/interface In-Reply-To: <20070723153230.699.1@stippis2.1185197340.fake> Message-ID: <4610970578-BeMail@ibm> Stephan Assmus wrote: > > Maybe it's a good idea to find a common way on how to do that, and > > add > > that to our coding style? > > > > For the record, this is how I do it: put the most private/specific > > header > > first, and the most public/generic header last. Ie. local headers > > first, > > Be API is less generic than the POSIX API, etc. Within those > > blocks, I > > order the included headers alphabetically. > > > > This has the added benefit that most headers are tested if they are > > self-contained automatically (but at least that one thing we seem > > to have > > in common, anyway :-)). > Yeah, I can do it like that from now on. It was an old change I came > across, I don't know why I made it back then, but I guess it was > because of > a non-selfcontained header. Any other opinions WRT how I do it? Would anybody object to put something like that in the coding style guide? And if so, why? :-) Bye, Axel. From axeld at pinc-software.de Thu Jul 26 14:37:48 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 26 Jul 2007 14:37:48 +0200 CEST Subject: [Haiku-commits] r21681 - haiku/trunk/src/apps/terminal In-Reply-To: <2065069285-BeMail@kirilla> Message-ID: <1707772773-BeMail@ibm> "Jonas Sundstr?m" wrote: > Even with system-standard tab-management keyboard shortcuts > it's hardly a step forward, IMO. I guess we could come up with more ways to improve their integration with the rest of the system some time later. Ie. have them visible from the Deskbar/Switcher as well, for example. Bye, Axel. From axeld at pinc-software.de Thu Jul 26 17:53:24 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 26 Jul 2007 17:53:24 +0200 CEST Subject: [Haiku-commits] r21704 - haiku/trunk/src/apps/terminal In-Reply-To: <200707261452.l6QEqOFD021645@sheep.berlios.de> Message-ID: <1694699313-BeMail@ibm> jackburton at BerliOS wrote: > Removed custom enums for encodings, just use the ones provided in > UTF8.h. > I'm more and more convinced we should drop the custom conversion > routines > and use the system ones. Definitely! I think the original creator just didn't find the encodings they needed in libtextencoding.so - we can easily change that, though. Bye, Axel. From leavengood at gmail.com Thu Jul 26 18:17:54 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Thu, 26 Jul 2007 12:17:54 -0400 Subject: [Haiku-commits] r21683 - haiku/trunk/src/kits/interface In-Reply-To: <4610970578-BeMail@ibm> References: <20070723153230.699.1@stippis2.1185197340.fake> <4610970578-BeMail@ibm> Message-ID: On 7/26/07, Axel D?rfler wrote: > > Would anybody object to put something like that in the coding style > guide? And if so, why? :-) I think the more specific the guidelines are, the better. In fact, if I ever run into anything I feel is ambiguous I'll probably ask about it and have you add that too. I recall having a feeling like this before, but I can't remember exactly what it was. Actually I was reading through the guidelines just now and I think this needs more detail: "Use AutoLock, etc. for all locking and other resource acquisition, don't use Lock() and Unlock() on a BLocker directly. Don't use BAutolock, use the AutoLock template instead." How does one use the AutoLock template? Maybe it is obvious, but I feel it is better to be explicit. Also in the copyright section: "In case everything is copyrighted to "Haiku Inc." and authors are listed in lexicographic order by last name." Aren't names in order of contribution date? Also Jonas posted a comment to the guidelines about prefixing private methods with _underscore. This should be added too. Then that comment can probably be deleted. Regards, Ryan From bonefish at cs.tu-berlin.de Thu Jul 26 20:28:20 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Thu, 26 Jul 2007 20:28:20 +0200 Subject: [Haiku-commits] r21683 - haiku/trunk/src/kits/interface In-Reply-To: <4610970578-BeMail@ibm> References: <4610970578-BeMail@ibm> Message-ID: <20070726202820.2429.3@cs.tu-berlin.de> On 2007-07-26 at 15:26:11 [+0200], Axel D?rfler wrote: > Stephan Assmus wrote: > > > Maybe it's a good idea to find a common way on how to do that, and > > > add > > > that to our coding style? > > > > > > For the record, this is how I do it: put the most private/specific > > > header > > > first, and the most public/generic header last. Ie. local headers > > > first, > > > Be API is less generic than the POSIX API, etc. Within those > > > blocks, I > > > order the included headers alphabetically. > > > > > > This has the added benefit that most headers are tested if they are > > > self-contained automatically (but at least that one thing we seem > > > to have > > > in common, anyway :-)). > > Yeah, I can do it like that from now on. It was an old change I came > > across, I don't know why I made it back then, but I guess it was > > because of > > a non-selfcontained header. > > Any other opinions WRT how I do it? > Would anybody object to put something like that in the coding style > guide? And if so, why? :-) Since you ask: I order the headers almost exactly the other way around: First the header corresponding to the source file for the self-containment check, then standard C headers, standard C++ headers, public Haiku headers, private Haiku headers, local headers. I find the generic -> specific order more natural than the other way around, as it looks somehow weird, to include , , and friends last. CU, Ingo From bonefish at cs.tu-berlin.de Thu Jul 26 21:04:28 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Thu, 26 Jul 2007 21:04:28 +0200 Subject: [Haiku-commits] r21683 - haiku/trunk/src/kits/interface In-Reply-To: References: <20070723153230.699.1@stippis2.1185197340.fake> <4610970578-BeMail@ibm> Message-ID: <20070726210428.2501.4@cs.tu-berlin.de> On 2007-07-26 at 18:17:54 [+0200], Ryan Leavengood wrote: > On 7/26/07, Axel D?rfler wrote: > > > > Would anybody object to put something like that in the coding style > > guide? And if so, why? :-) > > I think the more specific the guidelines are, the better. In fact, if > I ever run into anything I feel is ambiguous I'll probably ask about > it and have you add that too. I recall having a feeling like this > before, but I can't remember exactly what it was. > > Actually I was reading through the guidelines just now and I think > this needs more detail: > > "Use AutoLock, etc. for all locking and other resource acquisition, > don't use Lock() and Unlock() on a BLocker directly. Don't use > BAutolock, use the AutoLock template instead." Actually the thing is called AutoLocker (headers/private/shared/AutoLocker.h). > How does one use the AutoLock template? Maybe it is obvious, but I > feel it is better to be explicit. It's used pretty much like the BAutolock class, save that you have to explicitely specify the class of the object you want to lock. E.g.: BLooper* looper = ...; ... AutoLocker locker(looper); Like BAutolock it also features an IsLocked() method to check whether locking really was successful. It has a lot of additional features though. First of all the constructor is this: inline AutoLocker(Lockable *lockable, bool alreadyLocked = false, bool lockIfNotLocked = true); "alreadyLocked" allows to take over an existing lock, e.g.: looper->Lock(); AutoLocker locker(looper, true); "lockIfNotLocked" specifies whether the constructor shall lock the object or leave it unlocked initially. This is a more obscure use which can make sense in combination with the Lock() and Unlock() methods. AutoLocker locker(fooContainer, false, false); Foo* foo = NULL; for (...) { ... // fooContainer shall only be locked for the lookup locker.Lock(); foo = ...; if (foo) break; locker.Unlock(); ... } // ... when a foo has been found, fooContainer needs to remain locked ... More often one has to generally keep a lock, but unlock for a short time, e.g. to wait for something to happen. The SetTo() method is similar to the constructor. A previous lock is released before setting the new one. Unset() unlocks and "forgets" the lockable object (i.e. a subsequent Lock() is a no-op). Detach() does not unlock but also "forgets" the object, that is, it allows to explicitely keep a lock acquired by the AutoLocker. Furthermore we have operators for assignment from the lockable object and a bool() cast operator, which allows for: if (AutoLocker locker = looper) { ... } Being roughly equivalent to: { AutoLocker locker(looper); if (locker.IsLocked()) { ... } } AutoLocker is not only parameterized by the object type to lock, but also by the locking strategy. There are already locking strategies for read and write locking (AutoLocker{Read,Write}Locking) which invoke {Read,Write}Lock()/{Read,Write}Unlock() on the object. And there are instantiations for the kernel locking primitives (headers/private/kernel/util/AutoLock.h), namely MutexLocker, RecursiveLocker, BenaphoreLocker. CU, Ingo From philippe.houdoin at free.fr Thu Jul 26 23:47:32 2007 From: philippe.houdoin at free.fr (Philippe Houdoin) Date: Thu, 26 Jul 2007 23:47:32 +0200 Subject: [Haiku-commits] r21703 - haiku/trunk/headers/os/drivers Message-ID: <1185486452.46a916746a40b@imp.free.fr> Axel said: > "Stefano Ceccherini" wrote: > >> 2007/7/26, phoudoin at BerliOS : >>> -#define B_DPC_MODULE_NAME "generic/dpc/v1" >>> +#define B_DPC_MODULE_NAME "generic/dpc/haiku/v1" >> >> why not "generic/dpc/v2" ? :) >> At least, it seems weird to add haiku to the name, since we dont' do >> that in any other module. > > Just wanted to write the same thing :-) > And what part is not compatible, anyway - can we change that, or do we > provide more/other features? I Agree, as I don't like it either. The only purpose is that the BeOS R5 kernel module loader wont confuse our DPC with its own anymore, notably used by USB and FireWire stacks. Our DPC is not binary compatible with R5 one, whose interface is not documented. But both provide very similar features. Bring up from v1 to v2 without any interface change doesn't made sense to me. Anyway, currently it's only used by the ACPI subsystem, and as I tried to make it available for non-haiku targets, I'm concerned about two duplicated "generic/dpc/v1" modules on users system. Should I make it binary compatible (3 functions exported, should be easy to reverse engineering their prototypes)? - Philippe From zooey at hirschkaefer.de Fri Jul 27 00:09:44 2007 From: zooey at hirschkaefer.de (Oliver Tappe) Date: Fri, 27 Jul 2007 00:09:44 +0200 Subject: [Haiku-commits] r21683 - haiku/trunk/src/kits/interface In-Reply-To: <20070726202820.2429.3@cs.tu-berlin.de> References: <4610970578-BeMail@ibm> <20070726202820.2429.3@cs.tu-berlin.de> Message-ID: <20070727000944.1304.5@bee.hirschkaefer.site> Hi, On 2007-07-26 at 20:28:20 [+0200], Ingo Weinhold wrote: > > On 2007-07-26 at 15:26:11 [+0200], Axel D?rfler > wrote: [ ... ] > > Any other opinions WRT how I do it? > > Would anybody object to put something like that in the coding style > > guide? And if so, why? :-) > > Since you ask: I order the headers almost exactly the other way around: > First the header corresponding to the source file for the self-containment > check, then standard C headers, standard C++ headers, public Haiku headers, > private Haiku headers, local headers. I find the generic -> specific order > more natural than the other way around, as it looks somehow weird, to > include , , and friends last. I agree with Ingo and I'd like to add that specifying the headers ordered from most specific to less specific (as suggested by Axel) has the risk that some of the more obscure system header may overrule a define made in a local header. Not very likely, I know, but still not nice should it ever happen ... cheers, Oliver From marcusoverhagen at arcor.de Fri Jul 27 00:33:58 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Fri, 27 Jul 2007 00:33:58 +0200 (CEST) Subject: [Haiku-commits] r21683 - haiku/trunk/src/kits/interface In-Reply-To: <20070726202820.2429.3@cs.tu-berlin.de> References: <20070726202820.2429.3@cs.tu-berlin.de> <4610970578-BeMail@ibm> Message-ID: <251287.1185489238557.JavaMail.ngmail@webmail18> Ingo Weinhold wrote: > > Would anybody object to put something like that in the coding style > > guide? And if so, why? :-) > > Since you ask: I order the headers almost exactly the other way around: > First the header corresponding to the source file for the self-containment > check, then standard C headers, standard C++ headers, public Haiku headers, > > private Haiku headers, local headers. I find the generic -> specific order > more natural than the other way around, as it looks somehow weird, to > include , , and friends last. I do agree with Ingo, and I always do it that way, too. Marcus Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 34,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From jonas at kirilla.com Fri Jul 27 00:48:46 2007 From: jonas at kirilla.com (Jonas =?iso-8859-1?q?Sundstr=F6m?=) Date: Fri, 27 Jul 2007 00:48:46 +0200 CEST Subject: [Haiku-commits] r21683 - haiku/trunk/src/kits/interface In-Reply-To: <20070726202820.2429.3@cs.tu-berlin.de> Message-ID: <2819344644-BeMail@kirilla> Ingo Weinhold wrote: ... > I find the generic -> specific order more natural Me too, FWIW. /Jonas. From bonefish at mail.berlios.de Fri Jul 27 00:54:33 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 27 Jul 2007 00:54:33 +0200 Subject: [Haiku-commits] r21707 - haiku/trunk/src/tools/resattr Message-ID: <200707262254.l6QMsXEM005236@sheep.berlios.de> Author: bonefish Date: 2007-07-27 00:54:32 +0200 (Fri, 27 Jul 2007) New Revision: 21707 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21707&view=rev Modified: haiku/trunk/src/tools/resattr/resattr.cpp Log: Be stricter in case of errors in loops. We do always fully fail now, if an error occurs. Modified: haiku/trunk/src/tools/resattr/resattr.cpp =================================================================== --- haiku/trunk/src/tools/resattr/resattr.cpp 2007-07-26 15:22:21 UTC (rev 21706) +++ haiku/trunk/src/tools/resattr/resattr.cpp 2007-07-26 22:54:32 UTC (rev 21707) @@ -100,7 +100,7 @@ // should not happen fprintf(stderr, "Failed to get resource `%s', type: %lx, id: %ld " "from input file `%s'\n", name, type, id, inFileName); - continue; + exit(1); } // construct a name, if the resource doesn't have one @@ -134,7 +134,7 @@ if (error != B_OK) { fprintf(stderr, "Failed to get info for attribute `%s' of input " "file `%s': %s\n", name, inFileName, strerror(error)); - continue; + exit(1); } // read attribute @@ -145,7 +145,7 @@ fprintf(stderr, "Failed to read attribute `%s' of input " "file `%s': %s\n", name, inFileName, strerror(bytesRead)); delete[] data; - continue; + exit(1); } // find unique ID @@ -202,7 +202,7 @@ if (error != B_OK) { fprintf(stderr, "Failed to open input file `%s': %s\n", inputFiles[i], strerror(error)); - continue; + exit(1); } // open resources @@ -211,7 +211,7 @@ if (error != B_OK) { fprintf(stderr, "Failed to read resources of input file `%s': %s\n", inputFiles[i], strerror(error)); - continue; + exit(1); } // add the attributes @@ -253,7 +253,7 @@ if (error != B_OK) { fprintf(stderr, "Failed to open input file `%s': %s\n", inputFiles[i], strerror(error)); - continue; + exit(1); } // add the resources From bonefish at mail.berlios.de Fri Jul 27 01:08:06 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 27 Jul 2007 01:08:06 +0200 Subject: [Haiku-commits] r21708 - haiku/trunk/build/jam Message-ID: <200707262308.l6QN86fj024409@sheep.berlios.de> Author: bonefish Date: 2007-07-27 01:08:05 +0200 (Fri, 27 Jul 2007) New Revision: 21708 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21708&view=rev Modified: haiku/trunk/build/jam/BeOSRules Log: * ResComp can now deal with multiple input files at once. * Added ResAttr rule, which converts resource (or rdef) files to a file with attributes. Modified: haiku/trunk/build/jam/BeOSRules =================================================================== --- haiku/trunk/build/jam/BeOSRules 2007-07-26 22:54:32 UTC (rev 21707) +++ haiku/trunk/build/jam/BeOSRules 2007-07-26 23:08:05 UTC (rev 21708) @@ -216,10 +216,46 @@ ResComp1 $(1) : rc $(2) ; } -# Note: We pipe the file into the preprocessor, since *.rdef files are -# considered linker scripts. +# Note: We pipe the input files into the preprocessor, since *.rdef files are +# considered linker scripts, and thus we can use preprocessor features. actions ResComp1 { $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) - cat $(2[2]) | $(CC) -E $(CCDEFS) $(HDRS) - | egrep -v '^#' | $(2[1]) $(RCHDRS) --auto-names -o $(1) - + cat $(2[2-]) | $(CC) -E $(CCDEFS) $(HDRS) - | egrep -v '^#' | $(2[1]) $(RCHDRS) --auto-names -o $(1) - } + +rule ResAttr attributeFile : _resourceFiles +{ + # ResAttr : ; + # + # and must be gristed. + # can also be .rdef files -- they will be compiled first in + # this case. + + local resourceFiles ; + local resourceFile ; + for resourceFile in $(_resourceFiles) { + # if the specified resource file is an .rdef file, we compile it first + if $(resourceFile:S) = ".rdef" { + local rdefFile = $(resourceFile) ; + resourceFile = $(rdefFile:S=.rsrc) ; + ResComp $(resourceFile) : $(rdefFile) ; + } else { + SEARCH on $(resourceFile) += $(SEARCH_SOURCE) ; + } + + resourceFiles += $(resourceFile) ; + } + + MakeLocateArch $(attributeFile) ; + Depends $(attributeFile) : $(resourceFiles) resattr ; + LocalClean clean : $(attributeFile) ; + ResAttr1 $(attributeFile) : resattr $(resourceFiles) ; +} + +actions ResAttr1 +{ + $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) + rm -f $(1) + $(2[1]) -o $(1) $(2[2-]) +} From bonefish at mail.berlios.de Fri Jul 27 01:09:19 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 27 Jul 2007 01:09:19 +0200 Subject: [Haiku-commits] r21709 - haiku/trunk Message-ID: <200707262309.l6QN9J8l026165@sheep.berlios.de> Author: bonefish Date: 2007-07-27 01:09:18 +0200 (Fri, 27 Jul 2007) New Revision: 21709 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21709&view=rev Modified: haiku/trunk/Jamfile Log: Reset the correct subdir environment before doing the final stuff (haiku image, netboot archive, etc). Modified: haiku/trunk/Jamfile =================================================================== --- haiku/trunk/Jamfile 2007-07-26 23:08:05 UTC (rev 21708) +++ haiku/trunk/Jamfile 2007-07-26 23:09:18 UTC (rev 21709) @@ -142,6 +142,9 @@ SubInclude HAIKU_TOP src ; } +# reset subdir +SubDir HAIKU_TOP ; + # specify the Haiku image and network boot archive contents include [ FDirName $(HAIKU_BUILD_RULES_DIR) HaikuImage ] ; include [ FDirName $(HAIKU_BUILD_RULES_DIR) NetBootArchive ] ; From bonefish at mail.berlios.de Fri Jul 27 01:11:18 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 27 Jul 2007 01:11:18 +0200 Subject: [Haiku-commits] r21710 - haiku/trunk/src/tools/fs_shell Message-ID: <200707262311.l6QNBIm4028048@sheep.berlios.de> Author: bonefish Date: 2007-07-27 01:11:16 +0200 (Fri, 27 Jul 2007) New Revision: 21710 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21710&view=rev Modified: haiku/trunk/src/tools/fs_shell/command_cp.cpp Log: Added switch "-a" to the FS shell's cp command. It turns on "attribute only" mode, in which only the attributes from the source files are copied to the (existing) target file. Modified: haiku/trunk/src/tools/fs_shell/command_cp.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/command_cp.cpp 2007-07-26 23:09:18 UTC (rev 21709) +++ haiku/trunk/src/tools/fs_shell/command_cp.cpp 2007-07-26 23:11:16 UTC (rev 21710) @@ -36,12 +36,14 @@ struct Options { Options() - : dereference(true), + : attributesOnly(false), + dereference(true), force(false), recursive(false) { } + bool attributesOnly; bool dereference; bool force; bool recursive; @@ -1200,6 +1202,8 @@ for (int i = 1; arg[i]; i++) { switch (arg[i]) { + case 'a': + options.attributesOnly = true; case 'd': options.dereference = false; break; @@ -1239,7 +1243,11 @@ NodeDeleter targetDeleter(targetNode); targetExists = true; - if (targetNode->IsDirectory()) { + if (options.attributesOnly) { + // That's how it should be; we don't care whether the target is + // a directory or not. We append the attributes to that node in + // either case. + } else if (targetNode->IsDirectory()) { targetIsDir = true; } else { if (sourceCount > 1) { @@ -1249,7 +1257,12 @@ } } } else { - if (sourceCount > 1) { + if (options.attributesOnly) { + fprintf(stderr, "Error: Failed to open target `%s' (it must exist " + "in attributes only mode): `%s'\n", target, + fssh_strerror(error)); + return error; + } else if (sourceCount > 1) { fprintf(stderr, "Error: Failed to open destination directory `%s':" " `%s'\n", target, fssh_strerror(error)); return error; @@ -1264,12 +1277,42 @@ } MemoryDeleter copyBufferDeleter(sCopyBuffer); + // open the target node for attributes only mode + NodeDeleter targetDeleter; + if (options.attributesOnly) { + error = targetDomain->Open(target, FSSH_O_WRONLY, targetNode); + if (error != FSSH_B_OK) { + fprintf(stderr, "Error: Failed to open target `%s' for writing: " + "`%s'\n", target, fssh_strerror(error)); + return error; + } + + targetDeleter.SetTo(targetNode); + } + // the copy loop for (int i = 0; i < sourceCount; i++) { const char *source = sources[i]; FSDomain *sourceDomain = get_file_domain(source, source); DomainDeleter sourceDomainDeleter(sourceDomain); - if (targetExists && targetIsDir) { + if (options.attributesOnly) { + // 0. copy attributes only + // open the source node + Node *sourceNode; + error = sourceDomain->Open(source, + FSSH_O_RDONLY | (options.dereference ? 0 : FSSH_O_NOTRAVERSE), + sourceNode); + if (error != FSSH_B_OK) { + fprintf(stderr, "Error: Failed to open `%s': %s.\n", source, + fssh_strerror(error)); + return error; + } + NodeDeleter sourceDeleter(sourceNode); + + // copy the attributes + error = copy_attributes(source, sourceNode, target, targetNode); + + } else if (targetExists && targetIsDir) { // 1. target exists: // 1.1. target is a dir: // get the source leaf name From bonefish at mail.berlios.de Fri Jul 27 01:20:58 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 27 Jul 2007 01:20:58 +0200 Subject: [Haiku-commits] r21711 - in haiku/trunk: build/jam build/scripts data Message-ID: <200707262320.l6QNKwS7020727@sheep.berlios.de> Author: bonefish Date: 2007-07-27 01:20:58 +0200 (Fri, 27 Jul 2007) New Revision: 21711 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21711&view=rev Added: haiku/trunk/data/image_directories/ Modified: haiku/trunk/build/jam/ImageRules haiku/trunk/build/scripts/build_haiku_image Log: * Added second parameter to AddDirectoryToHaikuImage, a list of resource (or rdef) files which will be converted to attributes and added to the installed directory. Adjusted build_haiku_image script accordingly. * Added directory data/image_directories, which is where the resource files for the directories attributes shall be stored. As naming convention I suggest using the target directory path with slashes replaced by hyphens, e.g. home-config-bin.rdef for home/config/bin. Modified: haiku/trunk/build/jam/ImageRules =================================================================== --- haiku/trunk/build/jam/ImageRules 2007-07-26 23:11:16 UTC (rev 21710) +++ haiku/trunk/build/jam/ImageRules 2007-07-26 23:20:58 UTC (rev 21711) @@ -108,6 +108,7 @@ if ! [ on $(directory) return $(__is_on_image) ] { HAIKU_INSTALL_DIRECTORIES on $(container) += $(directory) ; __is_on_image on $(directory) = true ; + DIRECTORY_TOKENS on $(directory) = $(directoryTokens) ; NotFile $(directory) ; # mark the parent dir as not to be created @@ -298,20 +299,48 @@ LOCATE on $(scriptBody) = [ on $(script) return $(LOCATE) ] ; Depends $(scriptBody) : $(initScript) ; Depends $(script) : $(scriptBody) ; - + + # collect the directories to create local dirsToCreate ; + local directories = [ on $(container) return $(HAIKU_INSTALL_DIRECTORIES) ] ; local dir ; - for dir in [ on $(container) return $(HAIKU_INSTALL_DIRECTORIES) ] { + for dir in $(directories) { if ! [ on $(dir) return $(DONT_CREATE) ] { dirsToCreate += $(dir) ; } } - Depends $(scriptBody) : $(dirsToCreate) ; # If the image shall only be updated, we don't create directories. if $(dirsToCreate) && ! [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ] { + Depends $(scriptBody) : $(dirsToCreate) ; CreateContainerMakeDirectoriesScript1 $(scriptBody) : $(dirsToCreate) ; + + # For directories with attributes, we convert those the specified + # resource files to files with attributes and add commands to the script + # adding the attributes to the directories. + for dir in $(directories) { + local resourceFiles = [ on $(dir) return $(ATTRIBUTE_FILES) ] ; + if $(resourceFiles) { + local dirTokens = [ on $(dir) return $(DIRECTORY_TOKENS) ] ; + + # translate resources file to file with attributes + local attributeFile = $(script)-attributes-$(dirTokens:J=-) ; + ResAttr $(attributeFile) : $(resourceFiles) ; + + # use a unique dummy target for this file, on which we + # can define the TARGET_DIR variable + local dummyTarget = $(script)-attributes-dummy-$(dir:G=) ; + NotFile $(dummyTarget) ; + TARGET_DIR on $(dummyTarget) = $(dir:G=) ; + + Depends $(dummyTarget) : $(initScript) $(attributeFile) ; + Depends $(script) : $(dummyTarget) ; + + AppendToContainerMakeDirectoriesScriptAttributes $(dummyTarget) + : $(initScript) $(attributeFile) ; + } + } } } @@ -320,6 +349,12 @@ echo \$mkdir -p "\"\${tPrefix}$(2:G=)\"" >> $(1) } +actions AppendToContainerMakeDirectoriesScriptAttributes +{ + echo \$copyAttrs "\"\${sPrefix}$(2[2])\"" \ + "\"\${tPrefix}$(TARGET_DIR)\"" >> $(2[1]) +} + rule CreateContainerCopyFilesScript container : script { MakeLocate $(script) : $(HAIKU_OUTPUT_DIR) ; @@ -418,12 +453,20 @@ on $(HAIKU_IMAGE_CONTAINER_NAME) return $(HAIKU_CONTAINER_UPDATE_ONLY) ; } -rule AddDirectoryToHaikuImage directoryTokens +rule AddDirectoryToHaikuImage directoryTokens : attributeFiles { # AddDirectoryToHaikuImage - return [ AddDirectoryToContainer $(HAIKU_IMAGE_CONTAINER_NAME) + local dir = [ AddDirectoryToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(directoryTokens) ] ; + + if $(attributeFiles) { + SEARCH on $(attributeFiles) + += [ FDirName $(HAIKU_TOP) data image_directories ] ; + ATTRIBUTE_FILES on $(dir) += $(attributeFiles) ; + } + + return $(dir) ; } rule AddFilesToHaikuImage directory : targets : destName Modified: haiku/trunk/build/scripts/build_haiku_image =================================================================== --- haiku/trunk/build/scripts/build_haiku_image 2007-07-26 23:11:16 UTC (rev 21710) +++ haiku/trunk/build/scripts/build_haiku_image 2007-07-26 23:20:58 UTC (rev 21711) @@ -34,6 +34,7 @@ cd="$fsShellCommand cd" scd="$fsShellCommand cd" cp="$fsShellCommand cp" + copyAttrs="$fsShellCommand cp -a" ln="$fsShellCommand ln" mkdir="$fsShellCommand mkdir" rm="$fsShellCommand rm" @@ -45,6 +46,7 @@ cd=cd scd=: cp="$copyattr -d" + copyAttrs="$copyattr" ln=ln mkdir=mkdir rm=rm From axeld at pinc-software.de Fri Jul 27 02:59:21 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Fri, 27 Jul 2007 02:59:21 +0200 CEST Subject: [Haiku-commits] r21683 - haiku/trunk/src/kits/interface In-Reply-To: <20070727000944.1304.5@bee.hirschkaefer.site> Message-ID: <1835521515-BeMail@ibm> Oliver Tappe wrote: > On 2007-07-26 at 20:28:20 [+0200], Ingo Weinhold > > wrote: > > Since you ask: I order the headers almost exactly the other way > > around: > > First the header corresponding to the source file for the self- > > containment > > check, then standard C headers, standard C++ headers, public Haiku > > headers, > > private Haiku headers, local headers. The only complaint I would have about that is that by putting the most specific header up first, you break the logic of the rest; ie. you create a special case. Also, always going from specific to generic has the advantage that you'll likely test more headers for self-containment this way. > > I find the generic -> specific order > > more natural than the other way around, as it looks somehow weird, > > to > > include , , and friends last. > I agree with Ingo and I'd like to add that specifying the headers > ordered > from most specific to less specific (as suggested by Axel) has the > risk that > some of the more obscure system header may overrule a define made in > a local > header. Not very likely, I know, but still not nice should it ever > happen ... Overrule?? Whatever you mean by that, it would probably not work in the other direction either, nor would GCC swallow it, right? :-) But since so many others seem to share your opinion, I guess we should follow the masses here instead of good old logic, snief :) Bye, Axel. From axeld at mail.berlios.de Fri Jul 27 03:34:15 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 27 Jul 2007 03:34:15 +0200 Subject: [Haiku-commits] r21712 - haiku/trunk/src/system/kernel Message-ID: <200707270134.l6R1YFkx030404@sheep.berlios.de> Author: axeld Date: 2007-07-27 03:34:14 +0200 (Fri, 27 Jul 2007) New Revision: 21712 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21712&view=rev Modified: haiku/trunk/src/system/kernel/port.c Log: read_port[_etc]() now allows the msgCode pointer parameter to be NULL - as on BeOS. Modified: haiku/trunk/src/system/kernel/port.c =================================================================== --- haiku/trunk/src/system/kernel/port.c 2007-07-26 23:20:58 UTC (rev 21711) +++ haiku/trunk/src/system/kernel/port.c 2007-07-27 01:34:14 UTC (rev 21712) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001, Mark-Jan Bastian. All rights reserved. @@ -927,8 +927,7 @@ if (!sPortsActive || id < 0) return B_BAD_PORT_ID; - if (_msgCode == NULL - || (msgBuffer == NULL && bufferSize > 0) + if ((msgBuffer == NULL && bufferSize > 0) || timeout < 0) return B_BAD_VALUE; @@ -998,7 +997,8 @@ size = min(bufferSize, msg->size); // copy message - *_msgCode = msg->code; + if (_msgCode != NULL) + *_msgCode = msg->code; if (size > 0) { if (userCopy) { if ((status = cbuf_user_memcpy_from_chain(msgBuffer, msg->buffer_chain, 0, size) < B_OK)) { @@ -1318,20 +1318,22 @@ size_t bufferSize, uint32 flags, bigtime_t timeout) { int32 messageCode; - ssize_t status; + ssize_t bytesRead; - if (userCode == NULL || (userBuffer == NULL && bufferSize != 0)) + if (userBuffer == NULL && bufferSize != 0) return B_BAD_VALUE; - if (!IS_USER_ADDRESS(userCode) || (userBuffer != NULL && !IS_USER_ADDRESS(userBuffer))) + if ((userCode != NULL && !IS_USER_ADDRESS(userCode)) + || (userBuffer != NULL && !IS_USER_ADDRESS(userBuffer))) return B_BAD_ADDRESS; - status = read_port_etc(port, &messageCode, userBuffer, bufferSize, - flags | PORT_FLAG_USE_USER_MEMCPY | B_CAN_INTERRUPT, timeout); + bytesRead = read_port_etc(port, &messageCode, userBuffer, bufferSize, + flags | PORT_FLAG_USE_USER_MEMCPY | B_CAN_INTERRUPT, timeout); - if (status >= 0 && user_memcpy(userCode, &messageCode, sizeof(int32)) < B_OK) + if (bytesRead >= 0 && userCode != NULL + && user_memcpy(userCode, &messageCode, sizeof(int32)) < B_OK) return B_BAD_ADDRESS; - return status; + return bytesRead; } From axeld at mail.berlios.de Fri Jul 27 04:12:25 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 27 Jul 2007 04:12:25 +0200 Subject: [Haiku-commits] r21713 - haiku/trunk/src/kits/tracker Message-ID: <200707270212.l6R2CPu9031717@sheep.berlios.de> Author: axeld Date: 2007-07-27 04:12:23 +0200 (Fri, 27 Jul 2007) New Revision: 21713 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21713&view=rev Modified: haiku/trunk/src/kits/tracker/ContainerWindow.cpp Log: The "Delete" item in the Trash is not really needed - but was pretty close to "Restore"; I've removed it for safety. Modified: haiku/trunk/src/kits/tracker/ContainerWindow.cpp =================================================================== --- haiku/trunk/src/kits/tracker/ContainerWindow.cpp 2007-07-27 01:34:14 UTC (rev 21712) +++ haiku/trunk/src/kits/tracker/ContainerWindow.cpp 2007-07-27 02:12:23 UTC (rev 21713) @@ -1829,7 +1829,6 @@ menu->AddItem(new BMenuItem("Edit Name", new BMessage(kEditItem), 'E')); if (IsTrash() || InTrash()) { - menu->AddItem(new BMenuItem("Delete", new BMessage(kDelete))); menu->AddItem(new BMenuItem("Restore", new BMessage(kRestoreFromTrash))); if (IsTrash()) { // add as first item in menu From axeld at mail.berlios.de Fri Jul 27 04:15:41 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 27 Jul 2007 04:15:41 +0200 Subject: [Haiku-commits] r21714 - haiku/trunk/src/system/kernel/vm Message-ID: <200707270215.l6R2Ffik032035@sheep.berlios.de> Author: axeld Date: 2007-07-27 04:15:39 +0200 (Fri, 27 Jul 2007) New Revision: 21714 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21714&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm.cpp Log: Minor cleanup in comments. Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2007-07-27 02:12:23 UTC (rev 21713) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2007-07-27 02:15:39 UTC (rev 21714) @@ -3338,7 +3338,7 @@ if (lastCache != NULL) vm_cache_release_ref(lastCache); } else { - // we still own a reference to the cacheRef + // we still own a reference to the cache } *_pageCache = cache; @@ -3348,7 +3348,7 @@ /*! Returns the page that should be mapped into the area that got the fault. - It returns the owner of the page in \a sourceRef - it keeps a reference + It returns the owner of the page in \a sourceCache - it keeps a reference to it, and has also locked it on exit. */ static inline vm_page * From axeld at mail.berlios.de Fri Jul 27 04:32:23 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 27 Jul 2007 04:32:23 +0200 Subject: [Haiku-commits] r21715 - in haiku/trunk: headers/private/kernel headers/private/libroot src/kits src/kits/tracker src/system/kernel src/system/kernel/messaging src/system/kernel/util src/system/libroot src/system/libroot/os src/system/libroot/posix/stdlib src/system/runtime_loader Message-ID: <200707270232.l6R2WNkh032763@sheep.berlios.de> Author: axeld Date: 2007-07-27 04:32:19 +0200 (Fri, 27 Jul 2007) New Revision: 21715 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21715&view=rev Modified: haiku/trunk/headers/private/kernel/syscalls.h haiku/trunk/headers/private/kernel/team.h haiku/trunk/headers/private/kernel/user_runtime.h haiku/trunk/headers/private/libroot/libroot_private.h haiku/trunk/src/kits/Jamfile haiku/trunk/src/kits/tracker/FSUtils.cpp haiku/trunk/src/system/kernel/messaging/Jamfile haiku/trunk/src/system/kernel/messaging/KMessage.cpp haiku/trunk/src/system/kernel/team.c haiku/trunk/src/system/kernel/util/kernel_cpp.cpp haiku/trunk/src/system/libroot/libroot_init.c haiku/trunk/src/system/libroot/os/image.c haiku/trunk/src/system/libroot/posix/stdlib/env.c haiku/trunk/src/system/runtime_loader/Jamfile haiku/trunk/src/system/runtime_loader/elf.cpp haiku/trunk/src/system/runtime_loader/heap.cpp haiku/trunk/src/system/runtime_loader/runtime_loader.c haiku/trunk/src/system/runtime_loader/runtime_loader_private.h haiku/trunk/src/system/runtime_loader/utility.cpp Log: * Added a mechanism to retrieve a BMessage with eventual error descriptions for _kern_load_image(). * Added KMessage to the runtime_loader (a bit hacky, though) - it will use it to deliver the above mentioned functionality. * load_dependencies() did return the wrong status code in case a library was missing; now it returns B_MISSING_LIBRARY. * load_dependencies() will now try to load all dependencies when a report message is requested; therefore, all missing libraries are listed. * Renamed uspace_program_args to user_space_program_args. * The kernel filled in various members of the user_space_program_args structure unsafely, ie. was not using user_memcpy(). * Renamed some local variables in team.c to better fit our style guide (ie. uargs to userArgs). * Changed Tracker to use the new _kern_load_image() variant on Haiku to retrieve and report all missing libraries. This fixes bug #1324. * Adapted kernel_cpp.cpp to the runtime loader as well; the latter will now compile with _LOADER_MODE defined. Modified: haiku/trunk/headers/private/kernel/syscalls.h =================================================================== --- haiku/trunk/headers/private/kernel/syscalls.h 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/headers/private/kernel/syscalls.h 2007-07-27 02:32:19 UTC (rev 21715) @@ -1,5 +1,5 @@ /* - * Copyright 2004-2006, Haiku Inc. All rights reserved. + * Copyright 2004-2007, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _KERNEL_SYSCALLS_H @@ -73,7 +73,7 @@ extern thread_id _kern_load_image(int32 argCount, const char **args, int32 envCount, const char **envp, int32 priority, - uint32 flags); + uint32 flags, port_id errorPort, uint32 errorToken); extern void _kern_exit_team(status_t returnValue); extern status_t _kern_kill_team(team_id team); extern team_id _kern_get_current_team(); Modified: haiku/trunk/headers/private/kernel/team.h =================================================================== --- haiku/trunk/headers/private/kernel/team.h 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/headers/private/kernel/team.h 2007-07-27 02:32:19 UTC (rev 21715) @@ -6,7 +6,6 @@ #define _TEAM_H -#include #include @@ -15,37 +14,44 @@ #endif status_t team_init(struct kernel_args *args); -team_id team_create_team(const char *path, const char *name, char **args, int argc, - char **envp, int envc, int priority); +team_id team_create_team(const char *path, const char *name, char **args, + int argc, char **envp, int envc, int priority); status_t wait_for_team(team_id id, status_t *returnCode); void team_remove_team(struct team *team, struct process_group **_freeGroup); void team_delete_team(struct team *team); -struct process_group *team_get_process_group_locked(struct process_session *session, pid_t id); +struct process_group *team_get_process_group_locked( + struct process_session *session, pid_t id); void team_delete_process_group(struct process_group *group); struct team *team_get_kernel_team(void); team_id team_get_kernel_team_id(void); team_id team_get_current_team_id(void); -status_t team_get_address_space(team_id id, struct vm_address_space **_addressSpace); +status_t team_get_address_space(team_id id, + struct vm_address_space **_addressSpace); char **user_team_get_arguments(void); int user_team_get_arg_count(void); status_t team_get_death_entry(struct team *team, thread_id child, - struct death_entry *death, struct death_entry **_freeDeath); + struct death_entry *death, struct death_entry **_freeDeath); bool team_is_valid(team_id id); struct team *team_get_team_struct_locked(team_id id); int32 team_max_teams(void); int32 team_used_teams(void); -status_t start_watching_team(team_id team, void (*hook)(team_id, void *), void *data); -status_t stop_watching_team(team_id team, void (*hook)(team_id, void *), void *data); +status_t start_watching_team(team_id team, void (*hook)(team_id, void *), + void *data); +status_t stop_watching_team(team_id team, void (*hook)(team_id, void *), + void *data); // used in syscalls.c thread_id _user_load_image(int32 argCount, const char **args, int32 envCount, - const char **envp, int32 priority, uint32 flags); + const char **env, int32 priority, uint32 flags, + port_id errorPort, uint32 errorToken); status_t _user_wait_for_team(team_id id, status_t *_returnCode); void _user_exit_team(status_t returnValue); status_t _user_kill_team(thread_id thread); -thread_id _user_wait_for_child(thread_id child, uint32 flags, int32 *_reason, status_t *_returnCode); -status_t _user_exec(const char *path, int32 argc, char * const *argv, int32 envCount, char * const *environment); +thread_id _user_wait_for_child(thread_id child, uint32 flags, int32 *_reason, + status_t *_returnCode); +status_t _user_exec(const char *path, int32 argc, char * const *argv, + int32 envCount, char * const *environment); thread_id _user_fork(void); team_id _user_get_current_team(void); pid_t _user_process_info(pid_t process, int32 which); @@ -54,10 +60,11 @@ status_t _user_get_team_info(team_id id, team_info *info); status_t _user_get_next_team_info(int32 *cookie, team_info *info); -status_t _user_get_team_usage_info(team_id team, int32 who, team_usage_info *info, size_t size); +status_t _user_get_team_usage_info(team_id team, int32 who, + team_usage_info *info, size_t size); #ifdef __cplusplus } #endif -#endif /* _TIME_H */ +#endif /* _TEAM_H */ Modified: haiku/trunk/headers/private/kernel/user_runtime.h =================================================================== --- haiku/trunk/headers/private/kernel/user_runtime.h 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/headers/private/kernel/user_runtime.h 2007-07-27 02:32:19 UTC (rev 21715) @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2003-2007, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2002, Manuel J. Petit. All rights reserved. @@ -15,13 +15,15 @@ #define MAGIC_APP_NAME "_APP_" -struct uspace_program_args { - char program_name[B_OS_NAME_LENGTH]; - char program_path[B_PATH_NAME_LENGTH]; - int argc; - int envc; - char **argv; - char **envp; +struct user_space_program_args { + char program_name[B_OS_NAME_LENGTH]; + char program_path[B_PATH_NAME_LENGTH]; + port_id error_port; + uint32 error_token; + int arg_count; + int env_count; + char **args; + char **env; }; struct rld_export { @@ -37,7 +39,7 @@ status_t (*get_next_image_dependency)(image_id id, uint32 *cookie, const char **_name); - const struct uspace_program_args *program_args; + const struct user_space_program_args *program_args; }; extern struct rld_export *__gRuntimeLoader; Modified: haiku/trunk/headers/private/libroot/libroot_private.h =================================================================== --- haiku/trunk/headers/private/libroot/libroot_private.h 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/headers/private/libroot/libroot_private.h 2007-07-27 02:32:19 UTC (rev 21715) @@ -1,5 +1,5 @@ /* - * Copyright 2004-2006, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2004-2007, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ #ifndef LIBROOT_PRIVATE_H @@ -10,7 +10,7 @@ #include -struct uspace_program_args; +struct user_space_program_args; struct real_time_data; extern char _single_threaded; @@ -26,7 +26,7 @@ status_t __get_next_image_dependency(image_id id, uint32 *cookie, const char **_name); status_t __test_executable(const char *path, char *invoker); -void __init_env(const struct uspace_program_args *args); +void __init_env(const struct user_space_program_args *args); void __init_heap(void); void __init_time(void); Modified: haiku/trunk/src/kits/Jamfile =================================================================== --- haiku/trunk/src/kits/Jamfile 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/src/kits/Jamfile 2007-07-27 02:32:19 UTC (rev 21715) @@ -17,8 +17,8 @@ SubDirC++Flags $(defines) ; } -UsePrivateHeaders [ FDirName kernel util ] ; # For KMessage.h -UsePrivateHeaders syslog_daemon ; # For syslog.cpp +UsePrivateHeaders [ FDirName kernel ] # For KMessage.h +UsePrivateHeaders syslog_daemon ; # For syslog.cpp # Build our libbe.so Modified: haiku/trunk/src/kits/tracker/FSUtils.cpp =================================================================== --- haiku/trunk/src/kits/tracker/FSUtils.cpp 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/src/kits/tracker/FSUtils.cpp 2007-07-27 02:32:19 UTC (rev 21715) @@ -2890,12 +2890,19 @@ } extern "C" char** environ; + +#ifdef __HAIKU__ +extern "C" status_t _kern_load_image(int32 argCount, const char **args, + int32 envCount, const char **env, int32 priority, uint32 flags, + port_id errorPort, uint32 errorToken); +#else extern "C" -#if !B_BEOS_VERSION_DANO +# if !B_BEOS_VERSION_DANO _IMPEXP_ROOT -#endif +# endif status_t _kload_image_etc_(int argc, char **argv, char **envp, char *buf, int bufsize); +#endif static status_t @@ -2903,17 +2910,74 @@ { BPath path; BEntry appEntry(app, true); + status_t result = appEntry.GetPath(&path); - if (result != B_OK) return result; - + char *argv[2] = { const_cast(path.Path()), 0}; #ifdef __HAIKU__ - // ToDo: do this correctly! - result = load_image(1, (const char **)argv, (const char **)environ); - details.SetTo("ToDo: this is missing from Haiku"); + port_id errorPort = create_port(1, "Tracker loader error"); + + // count environment variables + uint32 envCount = 0; + while (environ[envCount] != NULL) + envCount++; + + result = _kern_load_image(1, (const char **)argv, envCount, + (const char **)environ, B_NORMAL_PRIORITY, B_WAIT_TILL_LOADED, + errorPort, 0); + if (result == B_OK) { + // we weren't supposed to be able to start the application... + return B_ERROR; + } + + // read error message from port and construct details string + + ssize_t bufferSize; + + do { + bufferSize = port_buffer_size_etc(errorPort, B_RELATIVE_TIMEOUT, 0); + } while (bufferSize == B_INTERRUPTED); + + if (bufferSize <= B_OK) { + delete_port(errorPort); + return bufferSize; + } + + uint8 *buffer = (uint8 *)malloc(bufferSize); + if (buffer == NULL) { + delete_port(errorPort); + return B_NO_MEMORY; + } + + bufferSize = read_port_etc(errorPort, NULL, buffer, bufferSize, + B_RELATIVE_TIMEOUT, 0); + delete_port(errorPort); + + if (bufferSize < B_OK) { + free(buffer); + return bufferSize; + } + + BMessage message; + result = message.Unflatten((const char *)buffer); + free(buffer); + + if (result != B_OK) + return result; + + message.PrintToStream(); + const char* library; + for (int32 i = 0; message.FindString("missing library", i, + &library) == B_OK; i++) { + if (i > 0) + details += ", "; + details += library; + } + + return B_OK; #else result = _kload_image_etc_(1, argv, environ, details.LockBuffer(1024), 1024); details.UnlockBuffer(); @@ -3048,7 +3112,7 @@ alertString << "Could not open \"" << documentRef.name << "\" "; if (openedDocuments) alertString << "with application \"" << app.name << "\" "; - alertString << "(Missing library: " << loaderErrorString << "). \n"; + alertString << "(Missing libraries: " << loaderErrorString << "). \n"; alternative = kFindAlternativeStr; } else { alertString << "Could not open \"" << documentRef.name Modified: haiku/trunk/src/system/kernel/messaging/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/messaging/Jamfile 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/src/system/kernel/messaging/Jamfile 2007-07-27 02:32:19 UTC (rev 21715) @@ -3,7 +3,6 @@ UsePrivateHeaders [ FDirName kernel ] ; #UsePrivateHeaders [ FDirName kernel disk_device_manager ] ; #UsePrivateHeaders [ FDirName kernel fs ] ; -UsePrivateHeaders [ FDirName kernel util ] ; # for UsePrivateHeaders shared ; UseHeaders [ FDirName $(HAIKU_TOP) src system kernel disk_device_manager ] ; # for "Locker.h" Modified: haiku/trunk/src/system/kernel/messaging/KMessage.cpp =================================================================== --- haiku/trunk/src/system/kernel/messaging/KMessage.cpp 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/src/system/kernel/messaging/KMessage.cpp 2007-07-27 02:32:19 UTC (rev 21715) @@ -3,7 +3,7 @@ * All rights reserved. Distributed under the terms of the MIT License. */ -#include "KMessage.h" +#include #include #include @@ -12,7 +12,7 @@ #include #include -#if defined(_BOOT_MODE) +#if defined(_BOOT_MODE) || defined(_LOADER_MODE) # include #else # include @@ -32,6 +32,21 @@ # endif #endif +#ifdef _LOADER_MODE +# include + +# define KMESSAGE_NO_RECEIVE + +# define create_port(capacity, name) _kern_create_port(capacity, name) +# define delete_port(port) _kern_delete_port(port) +# define write_port(port, code, buffer, bufferSize) \ + _kern_write_port_etc(port, code, buffer, bufferSize, 0, 0) +# define write_port_etc(port, code, buffer, bufferSize, flags, timeout) \ + _kern_write_port_etc(port, code, buffer, bufferSize, flags, timeout) +# define set_port_owner(port, team) _kern_set_port_owner(port, team) +# define _get_port_info(port, info, size) _kern_get_port_info(port, info) +#endif + static const int32 kMessageReallocChunkSize = 64; // kMessageHeaderMagic @@ -546,6 +561,9 @@ status_t KMessage::ReceiveFrom(port_id fromPort, bigtime_t timeout) { +#ifdef KMESSAGE_NO_RECEIVE + return B_NOT_SUPPORTED; +#else // get the port buffer size ssize_t size; if (timeout < 0) @@ -569,6 +587,7 @@ // init the message return SetTo(buffer, size, 0, KMESSAGE_OWNS_BUFFER | KMESSAGE_INIT_FROM_BUFFER); +#endif // !KMESSAGE_NO_RECEIVE } #endif // !KMESSAGE_CONTAINER_ONLY @@ -804,6 +823,7 @@ { if (fBuffer != &fHeader && (fFlags & KMESSAGE_READ_ONLY)) return B_NOT_ALLOWED; + int32 offset = ContentSize(); if (alignAddress) offset = _Align(offset); Modified: haiku/trunk/src/system/kernel/team.c =================================================================== --- haiku/trunk/src/system/kernel/team.c 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/src/system/kernel/team.c 2007-07-27 02:32:19 UTC (rev 21715) @@ -50,6 +50,8 @@ char **args; uint32 env_count; char **env; + port_id error_port; + uint32 error_token; }; struct fork_arg { @@ -610,7 +612,7 @@ for (count = 0; count < argc; count++) size += strlen(args[count]) + 1; - return size + (argc + 1) * sizeof(char *) + sizeof(struct uspace_program_args); + return size + (argc + 1) * sizeof(char *) + sizeof(struct user_space_program_args); } @@ -626,7 +628,7 @@ static status_t create_team_arg(struct team_arg **_teamArg, int32 argCount, char * const *args, - int32 envCount, char * const *env, bool kernel) + int32 envCount, char * const *env, port_id port, uint32 token, bool kernel) { status_t status; char **argsCopy; @@ -652,6 +654,8 @@ teamArg->args = argsCopy; teamArg->env_count = envCount; teamArg->env = envCopy; + teamArg->error_port = port; + teamArg->error_token = token; *_teamArg = teamArg; return B_OK; @@ -669,10 +673,10 @@ addr_t entry; char ustack_name[128]; uint32 sizeLeft; - char **uargs; - char **uenv; - char *udest; - struct uspace_program_args *uspa; + char **userArgs; + char **userEnv; + char *userDest; + struct user_space_program_args *programArgs; uint32 argCount, envCount, i; t = thread_get_current_thread(); @@ -717,32 +721,32 @@ argCount = teamArgs->arg_count; envCount = teamArgs->env_count; - uspa = (struct uspace_program_args *)(t->user_stack_base + t->user_stack_size - + TLS_SIZE + ENV_SIZE); - uargs = (char **)(uspa + 1); - udest = (char *)(uargs + argCount + 1); + programArgs = (struct user_space_program_args *)(t->user_stack_base + + t->user_stack_size + TLS_SIZE + ENV_SIZE); + userArgs = (char **)(programArgs + 1); + userDest = (char *)(userArgs + argCount + 1); - TRACE(("addr: stack base = 0x%lx, uargs = %p, udest = %p, sizeLeft = %lu\n", - t->user_stack_base, uargs, udest, sizeLeft)); + TRACE(("addr: stack base = 0x%lx, userArgs = %p, userDest = %p, sizeLeft = %lu\n", + t->user_stack_base, userArgs, userDest, sizeLeft)); - sizeLeft = t->user_stack_base + sizeLeft - (addr_t)udest; + sizeLeft = t->user_stack_base + sizeLeft - (addr_t)userDest; for (i = 0; i < argCount; i++) { - ssize_t length = user_strlcpy(udest, teamArgs->args[i], sizeLeft); + ssize_t length = user_strlcpy(userDest, teamArgs->args[i], sizeLeft); if (length < B_OK) { argCount = 0; break; } - uargs[i] = udest; - udest += ++length; + userArgs[i] = userDest; + userDest += ++length; sizeLeft -= length; } - uargs[argCount] = NULL; + userArgs[argCount] = NULL; - uenv = (char **)(t->user_stack_base + t->user_stack_size + TLS_SIZE); + userEnv = (char **)(t->user_stack_base + t->user_stack_size + TLS_SIZE); sizeLeft = ENV_SIZE; - udest = (char *)uenv + ENV_SIZE - 1; + userDest = (char *)userEnv + ENV_SIZE - 1; // the environment variables are copied from back to front TRACE(("team_create_thread_start: envc: %ld, env: %p\n", @@ -750,29 +754,37 @@ for (i = 0; i < envCount; i++) { ssize_t length = strlen(teamArgs->env[i]) + 1; - udest -= length; - if (udest < (char *)&uenv[envCount]) { + userDest -= length; + if (userDest < (char *)&userEnv[envCount]) { envCount = i; break; } - uenv[i] = udest; + userEnv[i] = userDest; - if (user_memcpy(udest, teamArgs->env[i], length) < B_OK) { + if (user_memcpy(userDest, teamArgs->env[i], length) < B_OK) { envCount = 0; break; } sizeLeft -= length; } - uenv[envCount] = NULL; + userEnv[envCount] = NULL; path = teamArgs->args[0]; - user_memcpy(uspa->program_path, path, sizeof(uspa->program_path)); - uspa->argc = argCount; - uspa->argv = uargs; - uspa->envc = envCount; - uspa->envp = uenv; + if (user_memcpy(programArgs->program_path, path, + sizeof(programArgs->program_path)) < B_OK + || user_memcpy(&programArgs->arg_count, &argCount, sizeof(int32)) < B_OK + || user_memcpy(&programArgs->args, &userArgs, sizeof(char **)) < B_OK + || user_memcpy(&programArgs->env_count, &envCount, sizeof(int32)) < B_OK + || user_memcpy(&programArgs->env, &userEnv, sizeof(char **)) < B_OK + || user_memcpy(&programArgs->error_port, &teamArgs->error_port, + sizeof(port_id)) < B_OK + || user_memcpy(&programArgs->error_token, &teamArgs->error_token, + sizeof(uint32)) < B_OK) { + // the team deletion process will clean this mess + return B_BAD_ADDRESS; + } TRACE(("team_create_thread_start: loading elf binary '%s'\n", path)); @@ -801,7 +813,7 @@ team->state = TEAM_STATE_NORMAL; // jump to the entry point in user space - return arch_thread_enter_userspace(t, entry, uspa, NULL); + return arch_thread_enter_userspace(t, entry, programArgs, NULL); // only returns in case of error } @@ -811,8 +823,9 @@ */ static thread_id -load_image_etc(int32 argCount, char * const *args, int32 envCount, char * const *env, - int32 priority, uint32 flags, bool kernel) +load_image_etc(int32 argCount, char * const *args, int32 envCount, + char * const *env, int32 priority, uint32 flags, + port_id errorPort, uint32 errorToken, bool kernel) { struct process_group *group; struct team *team, *parent; @@ -853,7 +866,8 @@ RELEASE_TEAM_LOCK(); restore_interrupts(state); - status = create_team_arg(&teamArgs, argCount, args, envCount, env, kernel); + status = create_team_arg(&teamArgs, argCount, args, envCount, env, + errorPort, errorToken, kernel); if (status != B_OK) goto err1; @@ -879,8 +893,8 @@ // Create a kernel thread, but under the context of the new team // The new thread will take over ownership of teamArgs - thread = spawn_kernel_thread_etc(team_create_thread_start, threadName, B_NORMAL_PRIORITY, - teamArgs, team->id, team->id); + thread = spawn_kernel_thread_etc(team_create_thread_start, threadName, + B_NORMAL_PRIORITY, teamArgs, team->id, team->id); if (thread < 0) { status = thread; goto err4; @@ -1007,9 +1021,8 @@ if (status != B_OK) return status; - // ToDo: maybe we should make sure upfront that the target path is an app? - - status = create_team_arg(&teamArgs, argCount, args, envCount, env, false); + status = create_team_arg(&teamArgs, argCount, args, envCount, env, + -1, 0, false); if (status != B_OK) return status; @@ -1857,7 +1870,8 @@ envCount++; return load_image_etc(argCount, (char * const *)args, envCount, - (char * const *)env, B_NORMAL_PRIORITY, B_WAIT_TILL_LOADED, true); + (char * const *)env, B_NORMAL_PRIORITY, B_WAIT_TILL_LOADED, + -1, 0, true); } @@ -2393,7 +2407,8 @@ team_id _user_load_image(int32 argCount, const char **userArgs, int32 envCount, - const char **userEnv, int32 priority, uint32 flags) + const char **userEnv, int32 priority, uint32 flags, port_id errorPort, + uint32 errorToken) { TRACE(("_user_load_image_etc: argc = %ld\n", argCount)); @@ -2404,7 +2419,8 @@ return B_BAD_ADDRESS; return load_image_etc(argCount, (char * const *)userArgs, - envCount, (char * const *)userEnv, priority, flags, false); + envCount, (char * const *)userEnv, priority, flags, errorPort, + errorToken, false); } Modified: haiku/trunk/src/system/kernel/util/kernel_cpp.cpp =================================================================== --- haiku/trunk/src/system/kernel/util/kernel_cpp.cpp 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/src/system/kernel/util/kernel_cpp.cpp 2007-07-27 02:32:19 UTC (rev 21715) @@ -1,17 +1,31 @@ -/* cpp - C++ in the kernel -** -** Initial version by Axel D?rfler, axeld at pinc-software.de -** This file may be used under the terms of the OpenBeOS License. -*/ +/* + * Copyright 2003-2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel D?rfler, axeld at pinc-software.de. + * Ingo Weinhold, bonefish at users.sf.net. + */ +//! C++ in the kernel + + #include "util/kernel_cpp.h" #ifdef _BOOT_MODE # include -#elif defined(_KERNEL_MODE) +#else # include +# include #endif +#ifdef _LOADER_MODE +# define panic printf +# define dprintf printf +# define kernel_debugger printf +#endif + + // Always define the symbols needed when not linking against libgcc.a -- // we simply override them. @@ -39,10 +53,8 @@ #endif // full C++ support in the kernel -#if defined(_KERNEL_MODE) && !defined(_BOOT_MODE) +#if (defined(_KERNEL_MODE) || defined(_LOADER_MODE)) && !defined(_BOOT_MODE) -#include - FILE *stderr = NULL; extern "C" Modified: haiku/trunk/src/system/libroot/libroot_init.c =================================================================== --- haiku/trunk/src/system/libroot/libroot_init.c 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/src/system/libroot/libroot_init.c 2007-07-27 02:32:19 UTC (rev 21715) @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2003-2007, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -37,7 +37,7 @@ void initialize_before(image_id imageID) { - char *programPath = __gRuntimeLoader->program_args->argv[0]; + char *programPath = __gRuntimeLoader->program_args->args[0]; if (programPath) { if ((__progname = strrchr(programPath, '/')) == NULL) __progname = programPath; @@ -45,8 +45,8 @@ __progname++; } - __libc_argc = __gRuntimeLoader->program_args->argc; - __libc_argv = __gRuntimeLoader->program_args->argv; + __libc_argc = __gRuntimeLoader->program_args->arg_count; + __libc_argv = __gRuntimeLoader->program_args->args; __init_time(); __init_fork(); Modified: haiku/trunk/src/system/libroot/os/image.c =================================================================== --- haiku/trunk/src/system/libroot/os/image.c 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/src/system/libroot/os/image.c 2007-07-27 02:32:19 UTC (rev 21715) @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2003-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -44,7 +44,7 @@ envCount++; thread = _kern_load_image(argCount, args, envCount, environ, - B_NORMAL_PRIORITY, B_WAIT_TILL_LOADED); + B_NORMAL_PRIORITY, B_WAIT_TILL_LOADED, -1, 0); free(newArgs); return thread; Modified: haiku/trunk/src/system/libroot/posix/stdlib/env.c =================================================================== --- haiku/trunk/src/system/libroot/posix/stdlib/env.c 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/src/system/libroot/posix/stdlib/env.c 2007-07-27 02:32:19 UTC (rev 21715) @@ -1,5 +1,5 @@ /* - * Copyright 2004-2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2004-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -148,12 +148,12 @@ void -__init_env(const struct uspace_program_args *args) +__init_env(const struct user_space_program_args *args) { // Following POSIX, there is no need to make any of the // environment functions thread-safe - but we do it anyway sEnvLock = create_sem(1, "env lock"); - environ = args->envp; + environ = args->env; atfork(environ_fork_hook); } Modified: haiku/trunk/src/system/runtime_loader/Jamfile =================================================================== --- haiku/trunk/src/system/runtime_loader/Jamfile 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/src/system/runtime_loader/Jamfile 2007-07-27 02:32:19 UTC (rev 21715) @@ -9,11 +9,15 @@ SubDirC++Flags -fno-builtin -fno-exceptions ; # default to BeOS style symbol resolution -DEFINES += BEOS_STYLE_SYMBOLS_RESOLUTION ; +DEFINES += BEOS_STYLE_SYMBOLS_RESOLUTION + _LOADER_MODE +; # needed for "runtime_loader" only StaticLibrary libruntime_loader.a : kernel_vsprintf.c + kernel_cpp.cpp + KMessage.cpp : syscalls.o sem.o @@ -54,8 +58,12 @@ [ FGristFiles kernel_vsprintf.o ] ; +SEARCH on [ FGristFiles kernel_cpp.cpp ] + = [ FDirName $(HAIKU_TOP) src system kernel util ] ; SEARCH on [ FGristFiles kernel_vsprintf.c ] = [ FDirName $(HAIKU_TOP) src system kernel lib ] ; +SEARCH on [ FGristFiles KMessage.cpp ] + = [ FDirName $(HAIKU_TOP) src system kernel messaging ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) arch $(TARGET_ARCH) ] ; Modified: haiku/trunk/src/system/runtime_loader/elf.cpp =================================================================== --- haiku/trunk/src/system/runtime_loader/elf.cpp 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/src/system/runtime_loader/elf.cpp 2007-07-27 02:32:19 UTC (rev 21715) @@ -76,6 +76,7 @@ static image_queue_t sDisposableImages = {0, 0}; static uint32 sLoadedImageCount = 0; static image_t *sProgramImage; +static KMessage sErrorMessage; #ifdef BEOS_STYLE_SYMBOLS_RESOLUTION static bool sResolveSymbolsBeOSStyle = true; @@ -1096,8 +1097,8 @@ load_dependencies(image_t *image) { struct Elf32_Dyn *d = (struct Elf32_Dyn *)image->dynamic_ptr; - int neededOffset; - status_t status; + bool reportErrors = gProgramArgs->error_port >= 0; + status_t status = B_OK; uint32 i, j; const char *rpath; @@ -1121,15 +1122,30 @@ for (i = 0, j = 0; d[i].d_tag != DT_NULL; i++) { switch (d[i].d_tag) { case DT_NEEDED: - neededOffset = d[i].d_un.d_val; + { + int32 neededOffset = d[i].d_un.d_val; + const char *name = STRING(image, neededOffset); - status = load_container(STRING(image, neededOffset), - B_LIBRARY_IMAGE, rpath, &image->needed[j]); - if (status < B_OK) - return status; + status_t loadStatus = load_container(name, B_LIBRARY_IMAGE, + rpath, &image->needed[j]); + if (loadStatus < B_OK) { + status = loadStatus; + // correct error code in case the file could not been found + if (status == B_ENTRY_NOT_FOUND) { + status = B_MISSING_LIBRARY; + if (reportErrors) + sErrorMessage.AddString("missing library", name); + } + + // Collect all missing libraries in case we report back + if (!reportErrors) + return status; + } + j += 1; break; + } default: // ignore any other tag @@ -1137,6 +1153,9 @@ } } + if (status < B_OK) + return status; + if (j != image->num_needed) { FATAL("Internal error at load_dependencies()"); return B_ERROR; @@ -1255,8 +1274,7 @@ } -// #pragma mark - -// Exported functions (to libroot.so) +// #pragma mark - libroot.so exported functions image_id @@ -1271,11 +1289,8 @@ TRACE(("rld: load %s\n", path)); status = load_container(path, B_APP_IMAGE, NULL, &sProgramImage); - if (status < B_OK) { - _kern_loading_app_failed(status); - rld_unlock(); - return status; - } + if (status < B_OK) + goto err; for (image = sLoadedImages.head; image != NULL; image = image->next) { status = load_dependencies(image); @@ -1322,9 +1337,16 @@ return sProgramImage->id; err: + delete_image(sProgramImage); + + if (gProgramArgs->error_port >= 0) { + sErrorMessage.AddInt32("error", status); + sErrorMessage.SendTo(gProgramArgs->error_port, gProgramArgs->error_token, + -1, 0, 0, find_thread(NULL)); + } _kern_loading_app_failed(status); - delete_image(sProgramImage); rld_unlock(); + return status; } @@ -1563,7 +1585,7 @@ } -// #pragma mark - +// #pragma mark - runtime_loader private exports /** Read and verify the ELF header */ @@ -1627,4 +1649,13 @@ area->loaded_images = &sLoadedImages; } + + // initialize error message if needed + if (gProgramArgs->error_port >= 0) { + void *buffer = malloc(1024); + if (buffer == NULL) + return; + + sErrorMessage.SetTo(buffer, 1024, 'Rler'); + } } Modified: haiku/trunk/src/system/runtime_loader/heap.cpp =================================================================== --- haiku/trunk/src/system/runtime_loader/heap.cpp 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/src/system/runtime_loader/heap.cpp 2007-07-27 02:32:19 UTC (rev 21715) @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2003-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -237,6 +237,14 @@ void * +realloc(void *buffer, size_t newSize) +{ + // not implemented + return NULL; +} + + +void * malloc(size_t size) { if (size == 0) Modified: haiku/trunk/src/system/runtime_loader/runtime_loader.c =================================================================== --- haiku/trunk/src/system/runtime_loader/runtime_loader.c 2007-07-27 02:15:39 UTC (rev 21714) +++ haiku/trunk/src/system/runtime_loader/runtime_loader.c 2007-07-27 02:32:19 UTC (rev 21715) @@ -26,7 +26,7 @@ #endif -struct uspace_program_args *gProgramArgs; +struct user_space_program_args *gProgramArgs; static const char * @@ -254,12 +254,12 @@ } -/** Tests if there is an executable file at the provided path. It will - * also test if the file has a valid ELF header or is a shell script. - * Even if the runtime loader does not need to be able to deal with - * both types, the caller will give scripts a proper treatment. - */ - +/*! + Tests if there is an executable file at the provided path. It will + also test if the file has a valid ELF header or is a shell script. + Even if the runtime loader does not need to be able to deal with + both types, the caller will give scripts a proper treatment. +*/ status_t test_executable(const char *name, uid_t user, gid_t group, char *invoker) { @@ -339,17 +339,17 @@ } -/** This is the main entry point of the runtime loader as - * specified by its ld-script. - */ - +/*! [... truncated: 92 lines follow ...] From axeld at mail.berlios.de Fri Jul 27 04:47:23 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 27 Jul 2007 04:47:23 +0200 Subject: [Haiku-commits] r21716 - haiku/trunk/src/kits/tracker Message-ID: <200707270247.l6R2lN5q000946@sheep.berlios.de> Author: axeld Date: 2007-07-27 04:47:22 +0200 (Fri, 27 Jul 2007) New Revision: 21716 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21716&view=rev Modified: haiku/trunk/src/kits/tracker/FSUtils.cpp Log: Forgot to remove some debug output. Modified: haiku/trunk/src/kits/tracker/FSUtils.cpp =================================================================== --- haiku/trunk/src/kits/tracker/FSUtils.cpp 2007-07-27 02:32:19 UTC (rev 21715) +++ haiku/trunk/src/kits/tracker/FSUtils.cpp 2007-07-27 02:47:22 UTC (rev 21716) @@ -2968,7 +2968,6 @@ if (result != B_OK) return result; - message.PrintToStream(); const char* library; for (int32 i = 0; message.FindString("missing library", i, &library) == B_OK; i++) { From bonefish at mail.berlios.de Fri Jul 27 04:48:20 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 27 Jul 2007 04:48:20 +0200 Subject: [Haiku-commits] r21717 - haiku/trunk/src/add-ons/kernel/partitioning_systems/intel Message-ID: <200707270248.l6R2mKEN001086@sheep.berlios.de> Author: bonefish Date: 2007-07-27 04:48:18 +0200 (Fri, 27 Jul 2007) New Revision: 21717 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21717&view=rev Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.cpp haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.h haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.h haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapWriter.cpp haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapWriter.h haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp Log: * Style cleanup. * Moved method documentation from headers to source files. * Removed test code. * Added TODOs where I spotted problems. Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.cpp 2007-07-27 02:47:22 UTC (rev 21716) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.cpp 2007-07-27 02:48:18 UTC (rev 21717) @@ -12,8 +12,8 @@ // constructor PartitionLocker::PartitionLocker(partition_id partitionID) - : device_(NULL), - partitionID_(partitionID) + : fDevice(NULL), + fPartitionID(partitionID) { } @@ -26,14 +26,14 @@ bool PartitionLocker::IsLocked() const { - return device_; + return fDevice; } // PartitionId partition_id PartitionLocker::PartitionId() const { - return partitionID_; + return fPartitionID; } @@ -44,7 +44,7 @@ PartitionReadLocker::PartitionReadLocker(partition_id partitionID) : PartitionLocker(partitionID) { - device_ = read_lock_disk_device(partitionID); + fDevice = read_lock_disk_device(partitionID); } // destructor @@ -62,7 +62,7 @@ PartitionWriteLocker::PartitionWriteLocker(partition_id partitionID) : PartitionLocker(partitionID) { - device_ = write_lock_disk_device(partitionID); + fDevice = write_lock_disk_device(partitionID); } // destructor Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.h =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.h 2007-07-27 02:47:22 UTC (rev 21716) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.h 2007-07-27 02:48:18 UTC (rev 21717) @@ -17,42 +17,47 @@ #include + class PartitionLocker { public: PartitionLocker(partition_id partitionID); - virtual ~PartitionLocker(); + ~PartitionLocker(); + bool IsLocked() const; partition_id PartitionId() const; + protected: - const disk_device_data *device_; + const disk_device_data *fDevice; + private: - partition_id partitionID_; + partition_id fPartitionID; }; + /*! \brief Structure which locks given partition for reading. When this structure is going to be destroyed, it automatically unlocks that partition. */ - class PartitionReadLocker : public PartitionLocker { public: PartitionReadLocker(partition_id partitionID); - virtual ~PartitionReadLocker(); + ~PartitionReadLocker(); }; + /*! \brief Structure which locks given partition for writing. When this structure is going to be destroyed, it automatically unlocks that partition. */ - class PartitionWriteLocker : public PartitionLocker { public: PartitionWriteLocker(partition_id partitionID); - virtual ~PartitionWriteLocker(); + ~PartitionWriteLocker(); }; -#endif // _PARTITION_LOCKER_H \ No newline at end of file + +#endif // _PARTITION_LOCKER_H Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp 2007-07-27 02:47:22 UTC (rev 21716) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp 2007-07-27 02:48:18 UTC (rev 21717) @@ -183,62 +183,105 @@ // constructor PartitionType::PartitionType() - : type_(0), - valid_(false) + : fType(0), + fValid(false) { } // SetType +/*! + \brief Sets the \a type via its ID. + \param type ID of the partition type, it is in the range [0..255]. +*/ void PartitionType::SetType(uint8 type) { - type_ = type; - valid_ = partition_type_string(type); + fType = type; + fValid = partition_type_string(type); } // SetType +/*! + \brief Sets the type via its string name. + \param typeName Name of the partition type. +*/ void -PartitionType::SetType(const char *type_name) +PartitionType::SetType(const char *typeName) { for (int32 i = 0; kPartitionTypes[i].name ; i++) { - if (!strcmp(type_name, kPartitionTypes[i].name)) { - type_ = kPartitionTypes[i].type; - valid_ = true; + if (!strcmp(typeName, kPartitionTypes[i].name)) { + fType = kPartitionTypes[i].type; + fValid = true; return; } } - valid_ = false; + fValid = false; } // SetContentType +/*! + \brief Converts content type to the partition type that fits best. + \param content_type Name of the content type, it is standardized by system. +*/ void -PartitionType::SetContentType(const char *content_type) +PartitionType::SetContentType(const char *contentType) { for (int32 i = 0; kPartitionContentTypes[i].name ; i++) { - if (!strcmp(content_type, kPartitionContentTypes[i].name)) { - type_ = kPartitionContentTypes[i].type; - valid_ = true; + if (!strcmp(contentType, kPartitionContentTypes[i].name)) { + fType = kPartitionContentTypes[i].type; + fValid = true; return; } } - valid_ = false; + fValid = false; } // FindNext +/*! + \brief Finds next supported partition. +*/ void PartitionType::FindNext() { for (int32 i = 0; kPartitionTypes[i].name; i++) { - if (type_ < kPartitionTypes[i].type) { - type_ = kPartitionTypes[i].type; - valid_ = true; + if (fType < kPartitionTypes[i].type) { + fType = kPartitionTypes[i].type; + fValid = true; return; } } - valid_ = false; + fValid = false; } +/*! + \fn bool PartitionType::IsValid() const + \brief Check whether the current type is valid. +*/ + +/*! + \fn bool PartitionType::IsEmpty() const + \brief Check whether the current type describes empty type. +*/ + +/*! + \fn bool PartitionType::IsExtended() const + \brief Check whether the current type describes extended partition type. +*/ + +/*! + \fn uint8 PartitionType::Type() const + \brief Returns ID of the current type. +*/ + +/*! + \fn void PartitionType::GetTypeString(char *buffer) const + \brief Returns string name of the current type. + \param buffer Buffer where the name is stored, has to be allocated with + sufficient length. +*/ + + // #pragma mark - Partition Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.h =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.h 2007-07-27 02:47:22 UTC (rev 21716) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.h 2007-07-27 02:48:18 UTC (rev 21717) @@ -31,24 +31,21 @@ // is_empty_type -static inline -bool +static inline bool is_empty_type(uint8 type) { return (type == 0x00); } // is_extended_type -static inline -bool +static inline bool is_extended_type(uint8 type) { return (type == 0x05 || type == 0x0f || type == 0x85); } // fill_buffer -static inline -void +static inline void fill_buffer(char *buffer, uint32 length, char ch) { for (uint32 i = 0; i < length; i++) @@ -104,53 +101,21 @@ public: PartitionType(); - /*! - \brief Sets the \a type via its ID. - \param type ID of the partition type, it is in the range [0..255]. - */ void SetType(uint8 type); - /*! - \brief Sets the type via its string name. - \param type_name Name of the partition type. - */ - void SetType(const char *type_name); - /*! - \brief Converts content type to the partition type that fits best. - \param content_type Name of the content type, it is standardized by system. - */ - void SetContentType(const char *content_type); + void SetType(const char *typeName); + void SetContentType(const char *contentType); - /*! - \brief Check whether the current type is valid. - */ - bool IsValid() const { return valid_; } - /*! - \brief Check whether the current type describes empty type. - */ - bool IsEmpty() const { return is_empty_type(type_); } - /*! - \brief Check whether the current type describes extended partition type. - */ - bool IsExtended() const { return is_extended_type(type_); } + bool IsValid() const { return fValid; } + bool IsEmpty() const { return is_empty_type(fType); } + bool IsExtended() const { return is_extended_type(fType); } - /*! - \brief Returns ID of the current type. - */ - uint8 Type() const { return type_; } - /*! - \brief Finds next supported partition. - */ + uint8 Type() const { return fType; } void FindNext(); - /*! - \brief Returns string name of the current type. - \param buffer Buffer where the name is stored, has to be allocated with - sufficient length. - */ void GetTypeString(char *buffer) const - { get_partition_type_string(type_, buffer); } + { get_partition_type_string(fType, buffer); } private: - uint8 type_; - bool valid_; + uint8 fType; + bool fValid; }; // Partition @@ -158,10 +123,10 @@ public: Partition(); Partition(const partition_descriptor *descriptor, off_t ptsOffset, - off_t baseOffset, int32 blockSize); + off_t baseOffset, int32 blockSize); void SetTo(const partition_descriptor *descriptor, off_t ptsOffset, - off_t baseOffset, int32 blockSize); + off_t baseOffset, int32 blockSize); void Unset(); bool IsEmpty() const { return is_empty_type(fType); } @@ -201,10 +166,10 @@ public: PrimaryPartition(); PrimaryPartition(const partition_descriptor *descriptor, off_t ptsOffset, - int32 blockSize); + int32 blockSize); void SetTo(const partition_descriptor *descriptor, off_t ptsOffset, - int32 blockSize); + int32 blockSize); void Unset(); // only if extended @@ -224,10 +189,10 @@ public: LogicalPartition(); LogicalPartition(const partition_descriptor *descriptor, off_t ptsOffset, - int32 blockSize, PrimaryPartition *primary); + int32 blockSize, PrimaryPartition *primary); void SetTo(const partition_descriptor *descriptor, off_t ptsOffset, - int32 blockSize, PrimaryPartition *primary); + int32 blockSize, PrimaryPartition *primary); void Unset(); void SetPrimaryPartition(PrimaryPartition *primary) { fPrimary = primary; } Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapWriter.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapWriter.cpp 2007-07-27 02:47:22 UTC (rev 21716) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapWriter.cpp 2007-07-27 02:48:18 UTC (rev 21717) @@ -33,8 +33,16 @@ using std::nothrow; // constructor +/*! + \brief Creates the writer. + + \param deviceFD File descriptor. + \param sessionOffset Disk offset of the partition with partitioning system. + \param sessionSize Size of the partition with partitioning system. + \param blockSize Size of the sector on given disk. +*/ PartitionMapWriter::PartitionMapWriter(int deviceFD, off_t sessionOffset, - off_t sessionSize, int32 blockSize) + off_t sessionSize, int32 blockSize) : fDeviceFD(deviceFD), fSessionOffset(sessionOffset), fSessionSize(sessionSize), @@ -50,6 +58,15 @@ } // WriteMBR +/*! + \brief Writes Master Boot Record to the first sector of the disk. + + If a \a block is not specified, the sector is firstly read from the disk + and after changing relevant items it is written back to the disk. + This allows to keep code area in MBR intact. + \param block Pointer to \c partition_table_sector. + \param map Pointer to the PartitionMap structure describing disk partitions. +*/ status_t PartitionMapWriter::WriteMBR(uint8 *block, const PartitionMap *map) { @@ -78,8 +95,21 @@ } // WriteLogical +/*! + \brief Writes Partition Table Sector of the logical \a partition to the + disk. + + This function ensures that the connection of the following linked list + of logical partitions will be correct. It do nothing with the connection of + previous logical partitions (call this function on previous logical + partition to ensure it). + + \param block Pointer to \c partition_table_sector. + \param partition Pointer to the logical partition. +*/ status_t -PartitionMapWriter::WriteLogical(uint8 *block, const LogicalPartition *partition) +PartitionMapWriter::WriteLogical(uint8 *block, + const LogicalPartition *partition) { status_t error = (partition ? B_OK : B_BAD_VALUE); if (error == B_OK) { @@ -103,9 +133,21 @@ } // WriteExtendedHead +/*! + \brief Writes Extended Boot Record to the first sector of Extended + Partition. + + Writes the head of linked list describing logical partitions. + + If the \a first_partition is not specified, it only initializes EBR and the + linked list contains no logical partitions. + + \param block Pointer to \c partition_table_sector. + \param first_partition Pointer to the first logical partition. +*/ status_t PartitionMapWriter::WriteExtendedHead(uint8 *block, - const LogicalPartition *first_partition) + const LogicalPartition *first_partition) { LogicalPartition partition; if (first_partition) @@ -160,8 +202,7 @@ // _WriteExtended status_t PartitionMapWriter::_WriteExtended(partition_table_sector *pts, - const LogicalPartition *partition, - const LogicalPartition *next) + const LogicalPartition *partition, const LogicalPartition *next) { if (!pts || !partition) return B_BAD_VALUE; @@ -172,7 +213,8 @@ // check the partition's location if (!partition->CheckLocation(fSessionSize, fBlockSize)) { TRACE(("intel: _WriteExtended(): Invalid partition " - "location: pts: %lld, offset: %lld, size: %lld, fSessionSize: %lld\n", + "location: pts: %lld, offset: %lld, size: %lld, " + "fSessionSize: %lld\n", partition->PTSOffset(), partition->Offset(), partition->Size(), fSessionSize)); return B_BAD_DATA; @@ -180,7 +222,8 @@ // write the table partition_descriptor *descriptor = &(pts->table[0]); - partition->GetPartitionDescriptor(descriptor, partition->PTSOffset(), fBlockSize); + partition->GetPartitionDescriptor(descriptor, partition->PTSOffset(), + fBlockSize); // setting offset and size of the next partition in the linked list descriptor = &(pts->table[1]); @@ -205,9 +248,10 @@ } // _ReadPTS +/*! \brief Reads the sector from the disk. +*/ status_t PartitionMapWriter::_ReadPTS(off_t offset, partition_table_sector *pts) -// reads the sector from the disk { status_t error = B_OK; if (!pts) @@ -233,9 +277,10 @@ } // _WritePTS +/*! \brief Writes the sector to the disk. +*/ status_t PartitionMapWriter::_WritePTS(off_t offset, const partition_table_sector *pts) -// writes the sector to the disk { status_t error = B_OK; if (!pts) Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapWriter.h =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapWriter.h 2007-07-27 02:47:22 UTC (rev 21716) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMapWriter.h 2007-07-27 02:48:18 UTC (rev 21717) @@ -11,8 +11,9 @@ \ingroup intel_module \brief Implementation of disk writer for "intel" style partitions. - Writer can write \b Master \b Boot \b Record or \b Extended \b Boot \b Records - to the disk according to partitions defined in \c PartitionMap structure. + Writer can write \b Master \b Boot \b Record or \b Extended \b Boot + \b Records to the disk according to partitions defined in \c PartitionMap + structure. */ @@ -33,66 +34,30 @@ This class serves for writing \a primary and \a logical \a partitions to disk. */ class PartitionMapWriter { - public: - /*! - \brief Creates the writer. +public: + PartitionMapWriter(int deviceFD, off_t sessionOffset, off_t sessionSize, + int32 blockSize); + ~PartitionMapWriter(); - \param deviceFD File descriptor. - \param sessionOffset Disk offset of the partition with partitioning system. - \param sessionSize Size of the partition with partitioning system. - \param blockSize Size of the sector on given disk. - */ - PartitionMapWriter(int deviceFD, off_t sessionOffset, off_t sessionSize, - int32 blockSize); - ~PartitionMapWriter(); + status_t WriteMBR(uint8 *block, const PartitionMap *map); + status_t WriteLogical(uint8 *block, const LogicalPartition *partition); + status_t WriteExtendedHead(uint8 *block, + const LogicalPartition *first_partition); - /*! - \brief Writes Master Boot Record to the first sector of the disk. +private: + status_t _WritePrimary(partition_table_sector *pts); + status_t _WriteExtended(partition_table_sector *pts, + const LogicalPartition *partition, const LogicalPartition *next); + status_t _ReadPTS(off_t offset, partition_table_sector *pts = NULL); + status_t _WritePTS(off_t offset, const partition_table_sector *pts = NULL); - If a \a block is not specified, the sector is firstly read from the disk - and after changing relevant items it is written back to the disk. - This allows to keep code area in MBR intact. - \param block Pointer to \c partition_table_sector. - \param map Pointer to the PartitionMap structure describing disk partitions. - */ - status_t WriteMBR(uint8 *block, const PartitionMap *map); - /*! - \brief Writes Partition Table Sector of the logical \a partition to the disk. - - This function ensures that the connection of the following linked list of logical - partitions will be correct. It do nothing with the connection of previous logical - partitions (call this function on previous logical partition to ensure it). - \param block Pointer to \c partition_table_sector. - \param partition Pointer to the logical partition. - */ - status_t WriteLogical(uint8 *block, const LogicalPartition *partition); - /*! - \brief Writes Extended Boot Record to the first sector of Extended Partition. - - Writes the head of linked list describing logical partitions. - - If the \a first_partition is not specified, it only initializes EBR and the linked - list contains no logical partitions. - \param block Pointer to \c partition_table_sector. - \param first_partition Pointer to the first logical partition. - */ - status_t WriteExtendedHead(uint8 *block, const LogicalPartition *first_partition); - - private: - status_t _WritePrimary(partition_table_sector *pts); - status_t _WriteExtended(partition_table_sector *pts, - const LogicalPartition *partition, - const LogicalPartition *next); - status_t _ReadPTS(off_t offset, partition_table_sector *pts = NULL); - status_t _WritePTS(off_t offset, const partition_table_sector *pts = NULL); - - private: - int fDeviceFD; - off_t fSessionOffset; - off_t fSessionSize; - int32 fBlockSize; - partition_table_sector *fPTS; // while writing - const PartitionMap *fMap; +private: + int fDeviceFD; + off_t fSessionOffset; + off_t fSessionSize; + int32 fBlockSize; + partition_table_sector *fPTS; // while writing + const PartitionMap *fMap; }; #endif // PARTITION_MAP_WRITER_H Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp 2007-07-27 02:47:22 UTC (rev 21716) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp 2007-07-27 02:48:18 UTC (rev 21717) @@ -41,11 +41,6 @@ //#define TRACE(x) ; #define TRACE(x) dprintf x - -// this macro is just for testing purpose -// keep it undefined, if you are not testing !!! -// #define TESTING_INTEL_MODULE - // module names #define INTEL_PARTITION_MODULE_NAME "partitioning_systems/intel/map/v1" #define INTEL_EXTENDED_PARTITION_MODULE_NAME "partitioning_systems/intel/extended/v1" @@ -77,38 +72,31 @@ // for logical partitions in Intel Extended Partition // Count of free sectors after Partition Table Sector (at logical partition). -static const uint32 FREE_SEKTORS_AFTER_PTS = 0; +static const uint32 FREE_SECTORS_AFTER_PTS = 0; // Count of free sectors after Master Boot Record. -static const uint32 FREE_SEKTORS_AFTER_MBR = 0; +static const uint32 FREE_SECTORS_AFTER_MBR = 0; // size of logical partition header in blocks -static const uint32 PTS_OFFSET = FREE_SEKTORS_AFTER_PTS + 1; -static const uint32 MBR_OFFSET = FREE_SEKTORS_AFTER_MBR + 1; +static const uint32 PTS_OFFSET = FREE_SECTORS_AFTER_PTS + 1; +static const uint32 MBR_OFFSET = FREE_SECTORS_AFTER_MBR + 1; typedef partitionable_space_data PartitionPosition; typedef void (*fc_get_sibling_partitions)(partition_data *partition, - partition_data *child, off_t child_offset, partition_data **prec, + partition_data *child, off_t childOffset, partition_data **prec, partition_data **follow, off_t *prec_offset, off_t *prec_size, off_t *follow_offset, off_t *follow_size); typedef int32 (*fc_fill_partitionable_spaces_buffer)(partition_data *partition, - PartitionPosition *p_positions); + PartitionPosition *positions); -#endif //_BOOT_MODE +#endif //!_BOOT_MODE +// #pragma mark - Intel Partition Map Module -////////////////////////////////////////// -// Intel Partition Map Module // -////////////////////////////////////////// - - - - - // module static status_t pm_std_ops(int32 op, ...); @@ -262,18 +250,9 @@ }; +// #pragma mark - Intel Extended Partition Module - - -/////////////////////////////////////////////// -// Intel Extended Partition Module // -/////////////////////////////////////////////// - - - - - // module static status_t ep_std_ops(int32 op, ...); @@ -420,7 +399,7 @@ ep_initialize, // initialize ep_create_child, // create_child ep_delete_child, // delete_child -#else +#else // _BOOT_MODE NULL #endif // _BOOT_MODE }; @@ -437,22 +416,11 @@ #endif +// #pragma mark - Intel Partition Map Module - - - -////////////////////////////////////////// -// Intel Partition Map Module // -////////////////////////////////////////// - - - - - // pm_std_ops -static -status_t +static status_t pm_std_ops(int32 op, ...) { TRACE(("intel: pm_std_ops(0x%lx)\n", op)); @@ -466,8 +434,7 @@ // pm_identify_partition -static -float +static float pm_identify_partition(int fd, partition_data *partition, void **cookie) { // check parameters @@ -487,7 +454,7 @@ uint32 blockSize = partition->block_size; if (blockSize < sizeof(partition_table_sector)) { TRACE(("intel: read_partition_map: bad block size: %ld, should be " - ">= %ld\n", blockSize, sizeof(partition_table_sector))); + ">= %ld\n", blockSize, sizeof(partition_table_sector))); return -1; } @@ -511,8 +478,7 @@ } // pm_scan_partition -static -status_t +static status_t pm_scan_partition(int fd, partition_data *partition, void *cookie) { // check parameters @@ -583,8 +549,7 @@ } // pm_free_identify_partition_cookie -static -void +static void pm_free_identify_partition_cookie(partition_data */*partition*/, void *cookie) { if (cookie) { @@ -595,8 +560,7 @@ } // pm_free_partition_cookie -static -void +static void pm_free_partition_cookie(partition_data *partition) { // called for the primary partitions: the PrimaryPartition is allocated @@ -606,8 +570,7 @@ } // pm_free_partition_content_cookie -static -void +static void pm_free_partition_content_cookie(partition_data *partition) { if (partition && partition->content_cookie) { @@ -619,158 +582,137 @@ #ifndef _BOOT_MODE +// #pragma mark - Intel Partition Map - support functions - -///////////////////////////////////////////// -// Intel Partition Map - support functions // -///////////////////////////////////////////// - - - - // pm_supports_resizing -static -bool +static bool pm_supports_resizing(partition_data *partition) { TRACE(("intel: pm_supports_resizing(%ld: %lld, %lld, %ld, %s)\n", - partition->id, partition->offset, partition->size, - partition->block_size, partition->content_type)); + partition->id, partition->offset, partition->size, + partition->block_size, partition->content_type)); return (partition && partition->content_type - && !strcmp(partition->content_type, kPartitionTypeIntel)); + && !strcmp(partition->content_type, kPartitionTypeIntel)); } // pm_supports_resizing_child -static -bool +static bool pm_supports_resizing_child(partition_data *partition, partition_data *child) { TRACE(("intel: pm_supports_resizing_child(%ld: %lld, %lld, %ld, %s)\n", - partition->id, partition->offset, partition->size, - partition->block_size, partition->content_type)); + partition->id, partition->offset, partition->size, + partition->block_size, partition->content_type)); return (partition && child && partition->content_type && !strcmp(partition->content_type, kPartitionTypeIntel)); } // pm_supports_moving -static -bool +static bool pm_supports_moving(partition_data *partition, bool *isNoOp) { TRACE(("intel: pm_supports_moving(%ld: %lld, %lld, %ld, %s)\n", - partition->id, partition->offset, partition->size, - partition->block_size, partition->content_type)); + partition->id, partition->offset, partition->size, + partition->block_size, partition->content_type)); *isNoOp = true; return (partition && partition->content_type - && !strcmp(partition->content_type, kPartitionTypeIntel)); + && !strcmp(partition->content_type, kPartitionTypeIntel)); } // pm_supports_moving_child -static -bool +static bool pm_supports_moving_child(partition_data *partition, partition_data *child) { TRACE(("intel: pm_supports_moving_child(%ld: %lld, %lld, %ld, %s)\n", - partition->id, partition->offset, partition->size, - partition->block_size, partition->content_type)); + partition->id, partition->offset, partition->size, + partition->block_size, partition->content_type)); return (partition && child && partition->content_type - && !strcmp(partition->content_type, kPartitionTypeIntel)); + && !strcmp(partition->content_type, kPartitionTypeIntel)); } // pm_supports_setting_name -static -bool +static bool pm_supports_setting_name(partition_data *partition) { return false; } // pm_supports_setting_content_name -static -bool +static bool pm_supports_setting_content_name(partition_data *partition) { return false; } // pm_supports_setting_type -static -bool +static bool pm_supports_setting_type(partition_data *partition) { TRACE(("intel: pm_supports_setting_type(%ld: %lld, %lld, %ld)\n", - partition->id, partition->offset, partition->size, - partition->block_size)); + partition->id, partition->offset, partition->size, + partition->block_size)); // partition should be child of "Intel Partition Map" partition_data *parent; return (partition - && (parent = get_parent_partition(partition->id)) - && parent->content_type - && !strcmp(parent->content_type, kPartitionTypeIntel) - ); + && (parent = get_parent_partition(partition->id)) + && parent->content_type + && !strcmp(parent->content_type, kPartitionTypeIntel)); } // pm_supports_initializing -static -bool +static bool pm_supports_initializing(partition_data *partition) { TRACE(("intel: pm_supports_initializing(%ld: %lld, %lld, %ld, %s, %d, %d)\n", - partition->id, partition->offset, partition->size, - partition->block_size, partition->content_type, - partition->child_count == 0, - partition->content_cookie == NULL)); + partition->id, partition->offset, partition->size, + partition->block_size, partition->content_type, + partition->child_count == 0, + partition->content_cookie == NULL)); return (partition - && !partition->content_type - && partition->child_count == 0 - && partition->content_cookie == NULL - ); + && !partition->content_type + && partition->child_count == 0 + && partition->content_cookie == NULL); } // pm_supports_creating_child -static -bool +static bool pm_supports_creating_child(partition_data *partition) { - TRACE(("intel: pm_supports_creating_child(%ld: %lld, %lld, %ld, %s, %d)\n", - partition->id, partition->offset, partition->size, - partition->block_size, partition->content_type, - partition->child_count)); + TRACE(("intel: pm_supports_creating_child(%ld: %lld, %lld, %ld, %s, %ld)\n", + partition->id, partition->offset, partition->size, + partition->block_size, partition->content_type, + partition->child_count)); int32 count_spaces = 0; return (partition && partition->content_type - && !strcmp(partition->content_type, kPartitionTypeIntel) - && partition->child_count < 4 - // free space check - && pm_get_partitionable_spaces(partition, NULL, 0, - &count_spaces) == B_OK - && count_spaces - ); + && !strcmp(partition->content_type, kPartitionTypeIntel) + && partition->child_count < 4 + // free space check + && pm_get_partitionable_spaces(partition, NULL, 0, &count_spaces) + == B_OK + && count_spaces); } // pm_supports_deleting_child -static -bool +static bool pm_supports_deleting_child(partition_data *partition, partition_data *child) { TRACE(("intel: pm_supports_deleting_child(%ld: %lld, %lld, %ld, %s)\n", - partition->id, partition->offset, partition->size, - partition->block_size, partition->content_type)); + partition->id, partition->offset, partition->size, + partition->block_size, partition->content_type)); return (partition && child && partition->content_type - && !strcmp(partition->content_type, kPartitionTypeIntel)); + && !strcmp(partition->content_type, kPartitionTypeIntel)); } // pm_is_sub_system_for -static -bool [... truncated: 2280 lines follow ...] From umccullough at gmail.com Fri Jul 27 10:20:37 2007 From: umccullough at gmail.com (Urias McCullough) Date: Fri, 27 Jul 2007 01:20:37 -0700 Subject: [Haiku-commits] r21715 - in haiku/trunk: headers/private/kernel headers/private/libroot src/kits src/kits/tracker src/system/kernel src/system/kernel/messaging src/system/kernel/util src/system/libroot src/system/libroot/os src/system/libroot/pos Message-ID: <1e80d8750707270120r29b09fe0p8cb50f40d8011440@mail.gmail.com> On 7/26/07, axeld at BerliOS wrote: > Author: axeld > Date: 2007-07-27 04:32:19 +0200 (Fri, 27 Jul 2007) > New Revision: 21715 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21715&view=rev > > Modified: > haiku/trunk/headers/private/kernel/syscalls.h I think the change to syscalls.h broke the build - strace fails currently for me complaining about too few arguments on _kern_load_image() From axeld at mail.berlios.de Fri Jul 27 11:40:27 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 27 Jul 2007 11:40:27 +0200 Subject: [Haiku-commits] r21718 - haiku/trunk/src/bin/strace Message-ID: <200707270940.l6R9eRh2006027@sheep.berlios.de> Author: axeld Date: 2007-07-27 11:40:26 +0200 (Fri, 27 Jul 2007) New Revision: 21718 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21718&view=rev Modified: haiku/trunk/src/bin/strace/strace.cpp Log: Forgot to include strace in the huge commit that changed the _kern_load_image() signature, sorry! Modified: haiku/trunk/src/bin/strace/strace.cpp =================================================================== --- haiku/trunk/src/bin/strace/strace.cpp 2007-07-27 02:48:18 UTC (rev 21717) +++ haiku/trunk/src/bin/strace/strace.cpp 2007-07-27 09:40:26 UTC (rev 21718) @@ -1,5 +1,5 @@ /* - * Copyright 2005, Ingo Weinhold, bonefish at users.sf.net. + * Copyright 2005-2007, Ingo Weinhold, bonefish at users.sf.net. * Distributed under the terms of the MIT License. */ @@ -194,7 +194,7 @@ // load the program error = _kern_load_image(argCount, mutableArgs, envCount, (const char**)environ, B_NORMAL_PRIORITY, - (traceLoading ? 0 : B_WAIT_TILL_LOADED)); + (traceLoading ? 0 : B_WAIT_TILL_LOADED), -1, 0); delete[] mutableArgs; From axeld at pinc-software.de Fri Jul 27 11:41:45 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Fri, 27 Jul 2007 11:41:45 +0200 CEST Subject: [Haiku-commits] =?iso-8859-15?q?r21715_-_in_haiku/trunk=3A_header?= =?iso-8859-15?q?s/private/kernel_headers/private/libroot_src/kits_src/kit?= =?iso-8859-15?q?s/tracker_src/system/kernel_src/system/kernel/messaging_s?= =?iso-8859-15?q?rc/system/kernel/util_src/system/libroot_src/system/libro?= =?iso-8859-15?q?ot/os__src/system/libroot/pos?= In-Reply-To: <1e80d8750707270120r29b09fe0p8cb50f40d8011440@mail.gmail.com> Message-ID: <571567316-BeMail@ibm> "Urias McCullough" wrote: > On 7/26/07, axeld at BerliOS wrote: > > Modified: > > haiku/trunk/headers/private/kernel/syscalls.h > I think the change to syscalls.h broke the build - strace fails > currently for me complaining about too few arguments on > _kern_load_image() Thanks for the note! I forgot to commit my changes to strace, sorry! Bye, Axel. From zooey at hirschkaefer.de Fri Jul 27 12:11:27 2007 From: zooey at hirschkaefer.de (Oliver Tappe) Date: Fri, 27 Jul 2007 12:11:27 +0200 Subject: [Haiku-commits] r21683 - haiku/trunk/src/kits/interface In-Reply-To: <1835521515-BeMail@ibm> References: <1835521515-BeMail@ibm> Message-ID: <20070727121127.479.2@bee.hirschkaefer.site> On 2007-07-27 at 02:59:21 [+0200], Axel D?rfler wrote: > Oliver Tappe wrote: [ ... ] > > I agree with Ingo and I'd like to add that specifying the headers > > ordered > > from most specific to less specific (as suggested by Axel) has the > > risk that > > some of the more obscure system header may overrule a define made in > > a local > > header. Not very likely, I know, but still not nice should it ever > > happen ... > > Overrule?? Whatever you mean by that, it would probably not work in the > other direction either, nor would GCC swallow it, right? :-) Well, just for the record, I meant stuff like this: #undef SOMETHING #define SOMETHING SOME_OTHER_MACRO which would of course be swallowed by gcc. cheers, Oliver From axeld at pinc-software.de Fri Jul 27 13:07:27 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Fri, 27 Jul 2007 13:07:27 +0200 CEST Subject: [Haiku-commits] r21683 - haiku/trunk/src/kits/interface In-Reply-To: <20070727121127.479.2@bee.hirschkaefer.site> Message-ID: <5713871135-BeMail@ibm> Oliver Tappe wrote: > > Overrule?? Whatever you mean by that, it would probably not work in > > the > > other direction either, nor would GCC swallow it, right? :-) > Well, just for the record, I meant stuff like this: > > #undef SOMETHING > #define SOMETHING SOME_OTHER_MACRO > > which would of course be swallowed by gcc. Ah okay, but those need a special header order anyway; ie. you need to take care of that, even though it's probably indeed less of a problem when going from generic to specific headers. Bye, Axel. From bonefish at cs.tu-berlin.de Fri Jul 27 14:09:51 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Fri, 27 Jul 2007 14:09:51 +0200 Subject: [Haiku-commits] r21715 - in haiku/trunk: headers/private/kernel headers/private/libroot src/kits src/kits/tracker src/system/kernel src/system/kernel/messaging src/system/kernel/util src/system/libroot src/system/libroot/os src/system/libroot/posix/stdlib src/system/runtime_loader In-Reply-To: <200707270232.l6R2WNkh032763@sheep.berlios.de> References: <200707270232.l6R2WNkh032763@sheep.berlios.de> Message-ID: <20070727140951.794.1@cs.tu-berlin.de> On 2007-07-27 at 04:32:23 [+0200], axeld at BerliOS wrote: > Author: axeld > Date: 2007-07-27 04:32:19 +0200 (Fri, 27 Jul 2007) > New Revision: 21715 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21715&view=rev > > Modified: > haiku/trunk/headers/private/kernel/syscalls.h > haiku/trunk/headers/private/kernel/team.h > haiku/trunk/headers/private/kernel/user_runtime.h > haiku/trunk/headers/private/libroot/libroot_private.h > haiku/trunk/src/kits/Jamfile > haiku/trunk/src/kits/tracker/FSUtils.cpp > haiku/trunk/src/system/kernel/messaging/Jamfile > haiku/trunk/src/system/kernel/messaging/KMessage.cpp > haiku/trunk/src/system/kernel/team.c > haiku/trunk/src/system/kernel/util/kernel_cpp.cpp > haiku/trunk/src/system/libroot/libroot_init.c > haiku/trunk/src/system/libroot/os/image.c > haiku/trunk/src/system/libroot/posix/stdlib/env.c > haiku/trunk/src/system/runtime_loader/Jamfile > haiku/trunk/src/system/runtime_loader/elf.cpp > haiku/trunk/src/system/runtime_loader/heap.cpp > haiku/trunk/src/system/runtime_loader/runtime_loader.c > haiku/trunk/src/system/runtime_loader/runtime_loader_private.h > haiku/trunk/src/system/runtime_loader/utility.cpp > Log: > * Added a mechanism to retrieve a BMessage with eventual error descriptions > for _kern_load_image(). > * Added KMessage to the runtime_loader (a bit hacky, though) - it will use > it to deliver the above mentioned functionality. Hacky indeed. Did anything speak against just defining the required *_port() symbols in the loader? Or probably even better, use KMessage in KMESSAGE_CONTAINER_ONLY mode and send it yourself (maybe add a KMessage::SetDeliveryInfo()). > * load_dependencies() did return the wrong status code in case a library > was missing; now it returns B_MISSING_LIBRARY. > * load_dependencies() will now try to load all dependencies when a report > message is requested; therefore, all missing libraries are listed. > * Renamed uspace_program_args to user_space_program_args. > * The kernel filled in various members of the user_space_program_args > structure > unsafely, ie. was not using user_memcpy(). > * Renamed some local variables in team.c to better fit our style guide (ie. > uargs to userArgs). > * Changed Tracker to use the new _kern_load_image() variant on Haiku to > retrieve > and report all missing libraries. This fixes bug #1324. Am I the only one who's not overly happy with the Tracker (i.e. a more or less normal app) using syscalls directly? It smells like the BRoster::Launch() methods should have an additional BMessage* errorMessage parameter. CU, Ingo From bonefish at mail.berlios.de Fri Jul 27 14:12:38 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 27 Jul 2007 14:12:38 +0200 Subject: [Haiku-commits] r21719 - in haiku/trunk: headers/os/drivers headers/private/kernel/disk_device_manager src/system/kernel/disk_device_manager src/system/kernel/disk_device_manager/jobs Message-ID: <200707271212.l6RCCcxm001509@sheep.berlios.de> Author: bonefish Date: 2007-07-27 14:12:35 +0200 (Fri, 27 Jul 2007) New Revision: 21719 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21719&view=rev Modified: haiku/trunk/headers/os/drivers/disk_device_manager.h haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceJob.h haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h haiku/trunk/headers/private/kernel/disk_device_manager/KFileSystem.h haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h haiku/trunk/headers/private/kernel/disk_device_manager/KPartitioningSystem.h haiku/trunk/headers/private/kernel/disk_device_manager/KPhysicalPartition.h haiku/trunk/headers/private/kernel/disk_device_manager/KShadowPartition.h haiku/trunk/src/system/kernel/disk_device_manager/Jamfile haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJobFactory.cpp haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KCreateChildJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KCreateChildJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KDefragmentJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KDefragmentJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KDeleteChildJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KDeleteChildJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KInitializeJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KInitializeJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KMoveJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KMoveJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KRepairJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KRepairJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KResizeJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KScanPartitionJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KScanPartitionJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetParametersJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetParametersJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KUninitializeJob.h Log: Addition of write support to the disk device manager. Courtesy of Tomas Kucera and Jan Matejek. Modified: haiku/trunk/headers/os/drivers/disk_device_manager.h =================================================================== --- haiku/trunk/headers/os/drivers/disk_device_manager.h 2007-07-27 09:40:26 UTC (rev 21718) +++ haiku/trunk/headers/os/drivers/disk_device_manager.h 2007-07-27 12:12:35 UTC (rev 21719) @@ -14,9 +14,11 @@ extern "C" { #endif -// C API partition representation -// Fields marked [sys] are set by the system and are not to be changed by -// the disk system modules. +/** \brief C API partition representation + * + * Fields marked [sys] are set by the system and are not to be changed by + * the disk system modules. + */ typedef struct partition_data { partition_id id; // [sys] off_t offset; Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceJob.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceJob.h 2007-07-27 09:40:26 UTC (rev 21718) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceJob.h 2007-07-27 12:12:35 UTC (rev 21719) @@ -4,6 +4,7 @@ #define _K_DISK_DEVICE_JOB_H #include "disk_device_manager.h" +#include struct user_disk_device_job_info; @@ -12,19 +13,41 @@ class KDiskDeviceJobQueue; +/** + * Represents some action executed on the disk device. + * + * - + */ class KDiskDeviceJob { public: + /** + * Creates a new job + * + * \param type actual type of the job (see DiskDeviceDefs.h for details) + * \param partitionID the partition/device on which the action should be executed + * \param scopeID partition/device which is the highest in the hierarchy (i.e. closest + * to the root) that can be affected by the action + * - every descendant of this partition is marked busy and all ancestors are marked descendant- + busy + */ KDiskDeviceJob(uint32 type, partition_id partitionID, partition_id scopeID = -1); virtual ~KDiskDeviceJob(); + /** + * Unique identification of the job + */ disk_job_id ID() const; void SetJobQueue(KDiskDeviceJobQueue *queue); KDiskDeviceJobQueue *JobQueue() const; + /** + * Gets actual type of the action + */ uint32 Type() const; + void SetStatus(uint32 status); uint32 Status() const; @@ -54,9 +77,25 @@ // triggers a notification float Progress() const; + status_t GetInfo(user_disk_device_job_info *info); status_t GetProgressInfo(disk_device_job_progress_info *info); + /** + * Do the actual work of the job. + * + * - is supposed to be implemented in descendants + * - doesn't have any parameter - every operation needs different ones -> they're passed + * to the constructor + * - the implementations will + * - check the parameters given in constructor (e.g. if given partition exists...) + * - check whether the partition has needed disk system (its own or parent - depends + * on the operation) + * - using the disk system, validate the operation for given params + * - finally execute the action + * + * \return B_OK when everything went OK, some error otherwise + */ virtual status_t Do() = 0; private: @@ -76,6 +115,29 @@ float fProgress; static disk_job_id fNextID; + +private: + /** + * Visitor which checks if every descendant of given partition is busy or descendant-busy + */ + struct IsNotBusyVisitor : KPartitionVisitor { + virtual bool VisitPre(KPartition * partition); + }; + IsNotBusyVisitor fNotBusyVisitor; + +protected: + //some stuff useful for all descendants + + /** + * Checks if there's any descendant which is not busy/descendant-busy. + * + * - the condition of busy descendant is common for many disk device operations -> + * many jobs can use this + * + * \param partition the root of checked subtree of the whole partition hieararchy + */ + bool isPartitionNotBusy( KPartition * partition ); + }; } // namespace DiskDevice Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h 2007-07-27 09:40:26 UTC (rev 21718) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h 2007-07-27 12:12:35 UTC (rev 21719) @@ -13,6 +13,7 @@ class KDiskDeviceJob; class KPartition; +/// \brief Common ancestor for disk system add-on wrappers class KDiskSystem { public: KDiskSystem(const char *name); Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KFileSystem.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KFileSystem.h 2007-07-27 09:40:26 UTC (rev 21718) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KFileSystem.h 2007-07-27 12:12:35 UTC (rev 21719) @@ -13,6 +13,7 @@ namespace BPrivate { namespace DiskDevice { +/// \brief Wrapper for the C interface of a filesystem add-on. class KFileSystem : public KDiskSystem { public: KFileSystem(const char *name); Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h 2007-07-27 09:40:26 UTC (rev 21718) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h 2007-07-27 12:12:35 UTC (rev 21719) @@ -21,6 +21,7 @@ class KPhysicalPartition; class KShadowPartition; +/// \brief Class representing a single partition. class KPartition { public: KPartition(partition_id id = -1); Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KPartitioningSystem.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KPartitioningSystem.h 2007-07-27 09:40:26 UTC (rev 21718) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KPartitioningSystem.h 2007-07-27 12:12:35 UTC (rev 21719) @@ -10,6 +10,11 @@ namespace BPrivate { namespace DiskDevice { +/** + * \brief Wrapper for the C interface of a partitioning system add-on. + * + * See \ref ddm_modules.h for better description of the interface. + */ class KPartitioningSystem : public KDiskSystem { public: KPartitioningSystem(const char *name); @@ -19,7 +24,9 @@ // Scanning + /// Try to identify a given partition virtual float Identify(KPartition *partition, void **cookie); + /// Scan the partition virtual status_t Scan(KPartition *partition, void *cookie); virtual void FreeIdentifyCookie(KPartition *partition, void *cookie); virtual void FreeCookie(KPartition *partition); @@ -27,88 +34,132 @@ // Querying + /// Check whether the add-on supports repairing this partition. virtual bool SupportsRepairing(KPartition *partition, bool checkOnly, bool *whileMounted); + /// Check whether the add-on supports resizing this partition. virtual bool SupportsResizing(KPartition *partition, bool *whileMounted); + /// Check whether the add-on supports resizing children of this partition. virtual bool SupportsResizingChild(KPartition *child); + /// Check whether the add-on supports moving this partition. virtual bool SupportsMoving(KPartition *partition, bool *isNoOp); + /// Check whether the add-on supports moving children of this partition. virtual bool SupportsMovingChild(KPartition *child); + /// Check whether the add-on supports setting name of this partition. virtual bool SupportsSettingName(KPartition *partition); + /// Check whether the add-on supports setting name to content of this partition. virtual bool SupportsSettingContentName(KPartition *partition, bool *whileMounted); + /// Check whether the add-on supports setting type of this partition. virtual bool SupportsSettingType(KPartition *partition); + /// Check whether the add-on supports setting parameters of this partition. virtual bool SupportsSettingParameters(KPartition *partition); + /// Check whether the add-on supports setting parameters to content of this partition. virtual bool SupportsSettingContentParameters(KPartition *partition, bool *whileMounted); + /// Check whether the add-on supports initializing this partition. virtual bool SupportsInitializing(KPartition *partition); + /// Check whether the add-on supports initializing a child of this partition. virtual bool SupportsInitializingChild(KPartition *child, const char *diskSystem); + /// Check whether the add-on supports creating children of this partition. virtual bool SupportsCreatingChild(KPartition *partition); + /// Check whether the add-on supports deleting children of this partition. virtual bool SupportsDeletingChild(KPartition *child); + /// Check whether the add-on is a subsystem for a given partition. virtual bool IsSubSystemFor(KPartition *partition); + /// Validates parameters for resizing a partition virtual bool ValidateResize(KPartition *partition, off_t *size); + /// Validates parameters for resizing a child partition virtual bool ValidateResizeChild(KPartition *child, off_t *size); + /// Validates parameters for moving a partition virtual bool ValidateMove(KPartition *partition, off_t *start); + /// Validates parameters for moving a child partition virtual bool ValidateMoveChild(KPartition *child, off_t *start); + /// Validates parameters for setting name of a partition virtual bool ValidateSetName(KPartition *partition, char *name); + /// Validates parameters for setting name to content of a partition virtual bool ValidateSetContentName(KPartition *partition, char *name); + /// Validates parameters for setting type of a partition virtual bool ValidateSetType(KPartition *partition, const char *type); + /// Validates parameters for setting parameters of a partition virtual bool ValidateSetParameters(KPartition *partition, const char *parameters); + /// Validates parameters for setting parameters to content of a partition virtual bool ValidateSetContentParameters(KPartition *parameters, const char *parameters); + /// Validates parameters for initializing a partition virtual bool ValidateInitialize(KPartition *partition, char *name, const char *parameters); + /// Validates parameters for creating child of a partition virtual bool ValidateCreateChild(KPartition *partition, off_t *start, off_t *size, const char *type, const char *parameters, int32 *index); + /// Counts partitionable spaces on a partition virtual int32 CountPartitionableSpaces(KPartition *partition); + /// Retrieves a list of partitionable spaces on a partition virtual status_t GetPartitionableSpaces(KPartition *partition, partitionable_space_data *buffer, int32 count, int32 *actualCount = NULL); + /// Iterates through supported partition types virtual status_t GetNextSupportedType(KPartition *partition, int32 *cookie, char *type); + /// Translates the "pretty" content type to an internal type virtual status_t GetTypeForContentType(const char *contentType, char *type); // Shadow partition modification + /// Calls for additional modifications when shadow partition is changed virtual status_t ShadowPartitionChanged(KPartition *partition, uint32 operation); // Writing + /// Repairs a partition virtual status_t Repair(KPartition *partition, bool checkOnly, KDiskDeviceJob *job); + /// Resizes a partition virtual status_t Resize(KPartition *partition, off_t size, KDiskDeviceJob *job); + /// Resizes child of a partition virtual status_t ResizeChild(KPartition *child, off_t size, KDiskDeviceJob *job); + /// Moves a partition virtual status_t Move(KPartition *partition, off_t offset, KDiskDeviceJob *job); + /// Moves child of a partition virtual status_t MoveChild(KPartition *child, off_t offset, KDiskDeviceJob *job); + /// Sets name to a partition virtual status_t SetName(KPartition *partition, char *name, KDiskDeviceJob *job); + /// Sets name to content of a partition virtual status_t SetContentName(KPartition *partition, char *name, KDiskDeviceJob *job); + /// Sets type of a partition virtual status_t SetType(KPartition *partition, char *type, KDiskDeviceJob *job); + /// Sets parameters of a partition virtual status_t SetParameters(KPartition *partition, const char *parameters, KDiskDeviceJob *job); + /// Sets parameters to content of a partition virtual status_t SetContentParameters(KPartition *partition, const char *parameters, KDiskDeviceJob *job); + /// Creates a child partition virtual status_t CreateChild(KPartition *partition, off_t offset, off_t size, const char *type, const char *parameters, KDiskDeviceJob *job, KPartition **child = NULL, partition_id childID = -1); + /// Deletes a child partition virtual status_t DeleteChild(KPartition *child, KDiskDeviceJob *job); + /// Initializes a partition with this partitioning system virtual status_t Initialize(KPartition *partition, const char *name, const char *parameters, KDiskDeviceJob *job); Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KPhysicalPartition.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KPhysicalPartition.h 2007-07-27 09:40:26 UTC (rev 21718) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KPhysicalPartition.h 2007-07-27 12:12:35 UTC (rev 21719) @@ -12,6 +12,7 @@ class KDiskSystem; class KShadowPartition; +/// \brief Class representing an existing partition. class KPhysicalPartition : public KPartition { public: KPhysicalPartition(partition_id id = -1); Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KShadowPartition.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KShadowPartition.h 2007-07-27 09:40:26 UTC (rev 21718) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KShadowPartition.h 2007-07-27 12:12:35 UTC (rev 21719) @@ -11,6 +11,9 @@ class KPhysicalPartition; +/// \brief Class representing a shadow of an existing partition. +/// +/// See \ref path_kernel_structures for more information. class KShadowPartition : public KPartition, private KPartitionListener { public: KShadowPartition(KPhysicalPartition *physicalPartition); Modified: haiku/trunk/src/system/kernel/disk_device_manager/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/Jamfile 2007-07-27 09:40:26 UTC (rev 21718) +++ haiku/trunk/src/system/kernel/disk_device_manager/Jamfile 2007-07-27 12:12:35 UTC (rev 21719) @@ -42,7 +42,9 @@ KRepairJob.cpp KResizeJob.cpp KScanPartitionJob.cpp + KSetNameJob.cpp KSetParametersJob.cpp + KSetTypeJob.cpp KUninitializeJob.cpp # utilities Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJob.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJob.cpp 2007-07-27 09:40:26 UTC (rev 21718) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJob.cpp 2007-07-27 12:12:35 UTC (rev 21719) @@ -243,3 +243,17 @@ // fNextID disk_job_id KDiskDeviceJob::fNextID = 0; + +// IsNotBusyVisitor +bool KDiskDeviceJob::IsNotBusyVisitor::VisitPre( KPartition * partition ) { + return !(partition->IsBusy() || partition->IsDescendantBusy()); +} + + +bool KDiskDeviceJob::isPartitionNotBusy( KPartition * partition ) { + if( !partition ) { + return false; + } + + return partition->VisitEachDescendant(&fNotBusyVisitor); +} Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJobFactory.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJobFactory.cpp 2007-07-27 09:40:26 UTC (rev 21718) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJobFactory.cpp 2007-07-27 12:12:35 UTC (rev 21719) @@ -10,8 +10,18 @@ #include "KDiskDeviceJob.h" #include "KDiskDeviceJobFactory.h" + +#include "KCreateChildJob.h" +#include "KDefragmentJob.h" +#include "KDeleteChildJob.h" +#include "KInitializeJob.h" +#include "KMoveJob.h" +#include "KRepairJob.h" #include "KResizeJob.h" #include "KScanPartitionJob.h" +#include "KSetNameJob.h" +#include "KSetParametersJob.h" +#include "KSetTypeJob.h" #include "KUninitializeJob.h" using namespace std; @@ -30,8 +40,7 @@ KDiskDeviceJob * KDiskDeviceJobFactory::CreateDefragmentJob(partition_id partitionID) { - // not implemented - return NULL; + return new(nothrow) KDefragmentJob(partitionID); } @@ -39,8 +48,7 @@ KDiskDeviceJobFactory::CreateRepairJob(partition_id partitionID, bool checkOnly) { - // not implemented - return NULL; + return new(nothrow) KRepairJob(partitionID, checkOnly); } @@ -56,8 +64,8 @@ KDiskDeviceJobFactory::CreateMoveJob(partition_id parentID, partition_id partitionID, off_t offset, const partition_id *contentsToMove, int32 contentsToMoveCount) { - // not implemented - return NULL; + // TODO: this is wierd, what in hell are contentsToMove etc? + return new(nothrow) KMoveJob(parentID, partitionID, offset); } @@ -65,8 +73,7 @@ KDiskDeviceJobFactory::CreateSetNameJob(partition_id parentID, partition_id partitionID, const char *name) { - // not implemented - return NULL; + return new(nothrow) KSetNameJob(parentID, partitionID, name, 0); } @@ -74,8 +81,7 @@ KDiskDeviceJobFactory::CreateSetContentNameJob(partition_id partitionID, const char *name) { - // not implemented - return NULL; + return new(nothrow) KSetNameJob(0, partitionID, 0, name); } @@ -83,8 +89,7 @@ KDiskDeviceJobFactory::CreateSetTypeJob(partition_id parentID, partition_id partitionID, const char *type) { - // not implemented - return NULL; + return new(nothrow) KSetTypeJob(parentID, partitionID, type); } @@ -92,8 +97,7 @@ KDiskDeviceJobFactory::CreateSetParametersJob(partition_id parentID, partition_id partitionID, const char *parameters) { - // not implemented - return NULL; + return new(nothrow) KSetParametersJob(parentID, partitionID, parameters, 0); } @@ -101,8 +105,7 @@ KDiskDeviceJobFactory::CreateSetContentParametersJob(partition_id partitionID, const char *parameters) { - // not implemented - return NULL; + return new(nothrow) KSetParametersJob(0, partitionID, 0, parameters); } @@ -110,8 +113,7 @@ KDiskDeviceJobFactory::CreateInitializeJob(partition_id partitionID, disk_system_id diskSystemID, const char *name, const char *parameters) { - // not implemented - return NULL; + return new(nothrow) KInitializeJob(partitionID, diskSystemID, name, parameters); } @@ -127,8 +129,7 @@ partition_id childID, off_t offset, off_t size, const char *type, const char *parameters) { - // not implemented - return NULL; + return new(nothrow) KCreateChildJob(partitionID, childID, offset, size, type, parameters); } @@ -136,8 +137,7 @@ KDiskDeviceJobFactory::CreateDeleteChildJob(partition_id parentID, partition_id partitionID) { - // not implemented - return NULL; + return new(nothrow) KDeleteChildJob(parentID, partitionID); } Modified: haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp 2007-07-27 09:40:26 UTC (rev 21718) +++ haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp 2007-07-27 12:12:35 UTC (rev 21719) @@ -1,4 +1,7 @@ -// KPartitioningSystem.cpp +/** \file KPartitioningSystem.cpp + * + * \brief Implementation of \ref KPartitioningSystem class + */ #include #include @@ -499,17 +502,17 @@ return B_ENTRY_NOT_FOUND; // lock partition and open partition device KDiskDeviceManager *manager = KDiskDeviceManager::Default(); - KPartition *_partition = manager->ReadLockPartition(partition->ID()); + KPartition *_partition = manager->WriteLockPartition(partition->ID()); if (!_partition) return B_ERROR; int fd = -1; { PartitionRegistrar registrar(_partition, true); PartitionRegistrar deviceRegistrar(_partition->Device(), true); - DeviceReadLocker locker(_partition->Device(), true); + DeviceWriteLocker locker(_partition->Device(), true); if (partition != _partition) return B_ERROR; - status_t result = partition->Open(O_RDONLY, &fd); + status_t result = partition->Open(O_RDWR, &fd); if (result != B_OK) return result; } @@ -526,25 +529,24 @@ KDiskDeviceJob *job) { // check parameters - if (!child || !job || size < 0) + if (!child || !job || !child->Parent() || size < 0) return B_BAD_VALUE; if (!fModule->resize_child) return B_ENTRY_NOT_FOUND; // lock partition and open (parent) partition device KDiskDeviceManager *manager = KDiskDeviceManager::Default(); - KPartition *_partition = manager->ReadLockPartition(child->ID()); + KPartition *_partition = manager->WriteLockPartition(child->ID()); + KPartition *_parent = manager->WriteLockPartition(child->Parent()->ID()); if (!_partition) return B_ERROR; int fd = -1; { PartitionRegistrar registrar(_partition, true); PartitionRegistrar deviceRegistrar(_partition->Device(), true); - DeviceReadLocker locker(_partition->Device(), true); + DeviceWriteLocker locker(_partition->Device(), true); if (child != _partition) return B_ERROR; - if (!child->Parent()) - return B_BAD_VALUE; - status_t result = child->Parent()->Open(O_RDONLY, &fd); + status_t result = child->Parent()->Open(O_RDWR, &fd); if (result != B_OK) return result; } @@ -560,8 +562,32 @@ KPartitioningSystem::Move(KPartition *partition, off_t offset, KDiskDeviceJob *job) { - // to be implemented - return B_ERROR; + // check parameters + if (!partition || !job) + return B_BAD_VALUE; + if (!fModule->move) + return B_ENTRY_NOT_FOUND; + // lock partition and open partition device + KDiskDeviceManager *manager = KDiskDeviceManager::Default(); + KPartition *_partition = manager->WriteLockPartition(partition->ID()); + if (!_partition) + return B_ERROR; + int fd = -1; + { + PartitionRegistrar registrar(_partition, true); + PartitionRegistrar deviceRegistrar(_partition->Device(), true); + DeviceWriteLocker locker(_partition->Device(), true); + if (partition != _partition) + return B_ERROR; + status_t result = partition->Open(O_RDWR, &fd); + if (result != B_OK) + return result; + } + // let the module do its job + status_t result = fModule->move(fd, partition->ID(), offset, job->ID()); + // cleanup and return + close(fd); + return result; } // MoveChild @@ -569,8 +595,33 @@ KPartitioningSystem::MoveChild(KPartition *child, off_t offset, KDiskDeviceJob *job) { - // to be implemented - return B_ERROR; + // check parameters + if (!child || !job || !child->Parent()) + return B_BAD_VALUE; + if (!fModule->move_child) + return B_ENTRY_NOT_FOUND; + // lock partition and open (parent) partition device + KDiskDeviceManager *manager = KDiskDeviceManager::Default(); + KPartition *_partition = manager->WriteLockPartition(child->ID()); + KPartition *_parent = manager->WriteLockPartition(child->Parent()->ID()); + if (!_partition) + return B_ERROR; + int fd = -1; + { + PartitionRegistrar registrar(_partition, true); + PartitionRegistrar deviceRegistrar(_partition->Device(), true); + DeviceWriteLocker locker(_partition->Device(), true); + if (child != _partition) + return B_ERROR; + status_t result = child->Parent()->Open(O_RDWR, &fd); + if (result != B_OK) + return result; + } + // let the module do its job + status_t result = fModule->move_child(fd, child->Parent()->ID(), child->ID(), offset, job->ID()); + // cleanup and return + close(fd); + return result; } // SetName @@ -578,8 +629,32 @@ KPartitioningSystem::SetName(KPartition *partition, char *name, KDiskDeviceJob *job) { - // to be implemented - return B_ERROR; + // check parameters + if (!partition || !job || !name) + return B_BAD_VALUE; + if (!fModule->set_name) + return B_ENTRY_NOT_FOUND; + // lock partition and open partition device + KDiskDeviceManager *manager = KDiskDeviceManager::Default(); + KPartition *_partition = manager->WriteLockPartition(partition->ID()); + if (!_partition) + return B_ERROR; + int fd = -1; + { + PartitionRegistrar registrar(_partition, true); + PartitionRegistrar deviceRegistrar(_partition->Device(), true); + DeviceWriteLocker locker(_partition->Device(), true); + if (partition != _partition) + return B_ERROR; + status_t result = partition->Open(O_RDWR, &fd); + if (result != B_OK) + return result; + } + // let the module do its job + status_t result = fModule->set_name(fd, partition->ID(), name, job->ID()); + // cleanup and return + close(fd); + return result; } // SetContentName @@ -587,8 +662,32 @@ KPartitioningSystem::SetContentName(KPartition *partition, char *name, KDiskDeviceJob *job) { - // to be implemented - return B_ERROR; + // check parameters + if (!partition || !job || !name) + return B_BAD_VALUE; + if (!fModule->set_content_name) + return B_ENTRY_NOT_FOUND; + // lock partition and open partition device + KDiskDeviceManager *manager = KDiskDeviceManager::Default(); + KPartition *_partition = manager->WriteLockPartition(partition->ID()); + if (!_partition) + return B_ERROR; + int fd = -1; + { + PartitionRegistrar registrar(_partition, true); + PartitionRegistrar deviceRegistrar(_partition->Device(), true); + DeviceWriteLocker locker(_partition->Device(), true); + if (partition != _partition) + return B_ERROR; + status_t result = partition->Open(O_RDWR, &fd); + if (result != B_OK) + return result; + } + // let the module do its job + status_t result = fModule->set_content_name(fd, partition->ID(), name, job->ID()); + // cleanup and return + close(fd); + return result; } // SetType @@ -596,8 +695,32 @@ KPartitioningSystem::SetType(KPartition *partition, char *type, KDiskDeviceJob *job) { - // to be implemented - return B_ERROR; + // check parameters + if (!partition || !job || !type) + return B_BAD_VALUE; + if (!fModule->set_type) + return B_ENTRY_NOT_FOUND; + // lock partition and open partition device + KDiskDeviceManager *manager = KDiskDeviceManager::Default(); + KPartition *_partition = manager->WriteLockPartition(partition->ID()); + if (!_partition) + return B_ERROR; + int fd = -1; + { + PartitionRegistrar registrar(_partition, true); + PartitionRegistrar deviceRegistrar(_partition->Device(), true); + DeviceWriteLocker locker(_partition->Device(), true); + if (partition != _partition) + return B_ERROR; + status_t result = partition->Open(O_RDWR, &fd); + if (result != B_OK) + return result; + } + // let the module do its job + status_t result = fModule->set_type(fd, partition->ID(), type, job->ID()); + // cleanup and return + close(fd); + return result; } // SetParameters @@ -605,8 +728,32 @@ KPartitioningSystem::SetParameters(KPartition *partition, const char *parameters, KDiskDeviceJob *job) { - // to be implemented - return B_ERROR; + // check parameters + if (!partition || !job || !parameters) + return B_BAD_VALUE; + if (!fModule->set_parameters) + return B_ENTRY_NOT_FOUND; + // lock partition and open partition device + KDiskDeviceManager *manager = KDiskDeviceManager::Default(); + KPartition *_partition = manager->WriteLockPartition(partition->ID()); + if (!_partition) + return B_ERROR; + int fd = -1; + { + PartitionRegistrar registrar(_partition, true); + PartitionRegistrar deviceRegistrar(_partition->Device(), true); + DeviceWriteLocker locker(_partition->Device(), true); + if (partition != _partition) + return B_ERROR; + status_t result = partition->Open(O_RDWR, &fd); + if (result != B_OK) + return result; + } + // let the module do its job + status_t result = fModule->set_parameters(fd, partition->ID(), parameters, job->ID()); + // cleanup and return + close(fd); + return result; } // SetContentParameters @@ -615,8 +762,32 @@ const char *parameters, KDiskDeviceJob *job) { - // to be implemented - return B_ERROR; + // check parameters + if (!partition || !job || !parameters) + return B_BAD_VALUE; + if (!fModule->set_content_parameters) + return B_ENTRY_NOT_FOUND; + // lock partition and open partition device + KDiskDeviceManager *manager = KDiskDeviceManager::Default(); + KPartition *_partition = manager->WriteLockPartition(partition->ID()); + if (!_partition) + return B_ERROR; + int fd = -1; + { + PartitionRegistrar registrar(_partition, true); + PartitionRegistrar deviceRegistrar(_partition->Device(), true); + DeviceWriteLocker locker(_partition->Device(), true); + if (partition != _partition) + return B_ERROR; + status_t result = partition->Open(O_RDWR, &fd); + if (result != B_OK) + return result; + } + // let the module do its job + status_t result = fModule->set_content_parameters(fd, partition->ID(), parameters, job->ID()); + // cleanup and return + close(fd); + return result; } // Initialize @@ -624,8 +795,32 @@ KPartitioningSystem::Initialize(KPartition *partition, const char *name, const char *parameters, KDiskDeviceJob *job) { - // to be implemented - return B_ERROR; + // check parameters + if (!partition || !job || !name /*|| !parameters*/) + return B_BAD_VALUE; + if (!fModule->initialize) + return B_ENTRY_NOT_FOUND; + // lock partition and open partition device + KDiskDeviceManager *manager = KDiskDeviceManager::Default(); + KPartition *_partition = manager->WriteLockPartition(partition->ID()); + if (!_partition) + return B_ERROR; + int fd = -1; + { + PartitionRegistrar registrar(_partition, true); + PartitionRegistrar deviceRegistrar(_partition->Device(), true); + DeviceWriteLocker locker(_partition->Device(), true); + if (partition != _partition) + return B_ERROR; + status_t result = partition->Open(O_RDWR, &fd); + if (result != B_OK) + return result; + } + // let the module do its job + status_t result = fModule->initialize(fd, partition->ID(), name, parameters, job->ID()); + // cleanup and return + close(fd); + return result; } // CreateChild @@ -635,8 +830,37 @@ const char *parameters, KDiskDeviceJob *job, KPartition **child, partition_id childID) { - // to be implemented - return B_ERROR; + // check parameters + if (!partition || !job || !type /*|| !parameters*/ || !child) + return B_BAD_VALUE; + if (!fModule->create_child) + return B_ENTRY_NOT_FOUND; + // lock partition and open partition device + KDiskDeviceManager *manager = KDiskDeviceManager::Default(); + KPartition *_partition = manager->WriteLockPartition(partition->ID()); + if (!_partition) + return B_ERROR; + int fd = -1; + { + PartitionRegistrar registrar(_partition, true); + PartitionRegistrar deviceRegistrar(_partition->Device(), true); + DeviceWriteLocker locker(_partition->Device(), true); + if (partition != _partition) + return B_ERROR; + status_t result = partition->Open(O_RDWR, &fd); + if (result != B_OK) + return result; + } + // let the module do its job + status_t result = fModule->create_child(fd, partition->ID(), offset, size, + type, parameters, job->ID(), &childID); + + // find and return the child + *child = manager->FindPartition(childID, false); + + // cleanup and return + close(fd); + return result; } // DeleteChild Modified: haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp 2007-07-27 09:40:26 UTC (rev 21718) +++ haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp 2007-07-27 12:12:35 UTC (rev 21719) @@ -1,4 +1,7 @@ -// ddm_userland_interface.cpp +/** \file ddm_userland_interface.cpp + * + * \brief Interface for userspace calls. + */ #include @@ -721,7 +724,7 @@ int32 changeCounter, const char *_diskSystemName) { - if (_diskSystemName) + if (!_diskSystemName) return false; char diskSystemName[B_DISK_SYSTEM_NAME_LENGTH]; status_t error = ddm_strlcpy(diskSystemName, _diskSystemName, B_DISK_SYSTEM_NAME_LENGTH); @@ -969,10 +972,10 @@ error = validate_initialize_partition(partition, changeCounter, diskSystemName, name, parameters); } - if (!error) - error = ddm_strlcpy(_name, name, B_DISK_DEVICE_NAME_LENGTH); + if (!error) + error = ddm_strlcpy(name, _name, B_DISK_DEVICE_NAME_LENGTH); free(parameters); - return error; + return error; } // _user_validate_create_child_partition @@ -1548,6 +1551,7 @@ } if (!error) { partition->Changed(B_PARTITION_CHANGED_CONTENT_PARAMETERS); + partition->Changed(B_PARTITION_CHANGED_INITIALIZATION); // implicit content disk system changes error = partition->DiskSystem()->ShadowPartitionChanged( partition, B_PARTITION_INITIALIZE); Modified: haiku/trunk/src/system/kernel/disk_device_manager/jobs/KCreateChildJob.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/jobs/KCreateChildJob.cpp 2007-07-27 09:40:26 UTC (rev 21718) +++ haiku/trunk/src/system/kernel/disk_device_manager/jobs/KCreateChildJob.cpp 2007-07-27 12:12:35 UTC (rev 21719) @@ -1,3 +1,114 @@ // KCreateChildJob.cpp #include "KCreateChildJob.h" + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ddm_operation_validation.h" + + + +KCreateChildJob::KCreateChildJob(partition_id partition, partition_id child, off_t offset, + off_t size, const char *type, const char *parameters) + : KDiskDeviceJob( B_DISK_DEVICE_JOB_CREATE, partition, partition ), + fChildID( child ), fOffset( offset ), fSize( size ), + fType ( !type ? NULL : strcpy ( new char[strlen(type)+1], type ) ), + fParameters( !parameters ? NULL : strcpy( new char[strlen(parameters)+1], parameters ) ) +{ + SetDescription( "creating child of the partition" ); +} + +KCreateChildJob::~KCreateChildJob() {} + +/** [... truncated: 1047 lines follow ...] From bonefish at mail.berlios.de Fri Jul 27 17:37:24 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 27 Jul 2007 17:37:24 +0200 Subject: [Haiku-commits] r21720 - haiku/trunk/src/system/kernel/disk_device_manager/jobs Message-ID: <200707271537.l6RFbOZh013397@sheep.berlios.de> Author: bonefish Date: 2007-07-27 17:37:23 +0200 (Fri, 27 Jul 2007) New Revision: 21720 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21720&view=rev Added: haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetNameJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetNameJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetTypeJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetTypeJob.h Log: Missed those in the previous commit. Added: haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetNameJob.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetNameJob.cpp 2007-07-27 12:12:35 UTC (rev 21719) +++ haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetNameJob.cpp 2007-07-27 15:37:23 UTC (rev 21720) @@ -0,0 +1,135 @@ + +#include "KSetNameJob.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "ddm_operation_validation.h" + + +KSetNameJob::KSetNameJob(partition_id parentID, partition_id partitionID, const char * name, + const char * contentName) + : KDiskDeviceJob(B_DISK_DEVICE_JOB_SET_NAME, partitionID, parentID), + fName( !name ? NULL : strcpy( new char[strlen(name)+1], name ) ), + fContentName( !contentName ? NULL : strcpy( new char[strlen(contentName)+1], contentName ) ) +{ + SetDescription( "setting name for the partition or its content" ); +} + + +KSetNameJob::~KSetNameJob() +{ + delete[] fName; + delete[] fContentName; +} + + +status_t KSetNameJob::Do() { + KDiskDeviceManager * manager = KDiskDeviceManager::Default(); + + KPartition * partition = manager->WriteLockPartition( PartitionID() ); + if( partition ) { + if( !fName && !fContentName ) { + SetErrorMessage( "No name to set." ); + return B_BAD_VALUE; + } + + PartitionRegistrar registrar(partition, true); + PartitionRegistrar deviceRegistrar(partition->Device(), true); + + //TODO is lock necessary? + DeviceWriteLocker locker(partition->Device(), true); + + //basic checks + + // all descendants should be marked busy/descendant busy + if ( isPartitionNotBusy( partition ) ) { + SetErrorMessage("Can't set name for non-busy partition!"); + return B_ERROR; + } + + if( fName ) { + //set name of the partition + + //setting name of this partition -> via our parent disk system + if( !partition->ParentDiskSystem() ) { + SetErrorMessage( "Partition has no parent disk system!" ); + return B_BAD_VALUE; + } + + //TODO mayebe give copy of name + status_t validation_result = validate_set_partition_name( + partition, partition->ChangeCounter(), + fName, false); + + if( validation_result != B_OK) { + SetErrorMessage( "Validation of setting partition name failed!" ); + return validation_result; + } + + //everything OK, let's do the job + KDiskSystem * parentDiskSystem = partition->ParentDiskSystem(); + + DiskSystemLoader loader(parentDiskSystem); + + locker.Unlock(); + + status_t set_name_result = parentDiskSystem->SetName(partition, fName, this); + + if( set_name_result != B_OK ) { + SetErrorMessage( "Setting name of the partition failed!" ); + } + return set_name_result; + + } + + if( fContentName ) { + //set name of the contents + + //setting name of our contents -> via our disk system + if( !partition->DiskSystem() ) { + SetErrorMessage( "Partition has no disk system!"); + return B_BAD_VALUE; + } + + status_t validation_result = validate_set_partition_content_name( + partition, partition->ChangeCounter(), + fContentName, false); + + if( validation_result != B_OK ) { + SetErrorMessage( "Validation of setting partition content name failed!" ); + return validation_result; + } + + //everything OK, let's do the job + + KDiskSystem * diskSystem = partition->DiskSystem(); + DiskSystemLoader loader( diskSystem ); + + locker.Unlock(); + + status_t set_cont_name_result = diskSystem->SetContentName( + partition, fContentName, this); + + if( set_cont_name_result != B_OK ) { + SetErrorMessage( "Setting name of the partition's content failed!" ); + } + return set_cont_name_result; + + } + + + } else { + SetErrorMessage( "Couldn't find partition!" ); + return B_ENTRY_NOT_FOUND; + } + + +} Added: haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetNameJob.h =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetNameJob.h 2007-07-27 12:12:35 UTC (rev 21719) +++ haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetNameJob.h 2007-07-27 15:37:23 UTC (rev 21720) @@ -0,0 +1,47 @@ +#ifndef _K_DISK_DEVICE_SET_NAME_JOB_H +#define _K_DISK_DEVICE_SET_NAME_JOB_H + +#include + +namespace BPrivate { + +namespace DiskDevice { + +/** + * Sets the name for partition/device and/or its content + * + * - can set both name and content name for the partition - but + * it's possible to create it with only one of these name parameters and so + * set only one of the names + */ +class KSetNameJob : public KDiskDeviceJob +{ +public: + /** + * Creates the job. + * + * + * \param partitionID the partition/device whose name should be set + * \param name the new name for \c partitionID + * \param contentName the new name for the content of \c partitionID + */ + KSetNameJob(partition_id parentID, partition_id partitionID, const char * name, + const char * contentName); + + virtual ~KSetNameJob(); + + virtual status_t Do(); + +private: + char * fName, *fContentName; + + +}; + +} + +} + +using BPrivate::DiskDevice::KSetNameJob; + +#endif Added: haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetTypeJob.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetTypeJob.cpp 2007-07-27 12:12:35 UTC (rev 21719) +++ haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetTypeJob.cpp 2007-07-27 15:37:23 UTC (rev 21720) @@ -0,0 +1,89 @@ +// +// C++ Implementation: KSetTypeJob +// +// Description: +// +// +// Author: , (C) 2007 +// +// Copyright: See COPYING file that comes with this distribution +// +// + + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "KSetTypeJob.h" +#include "ddm_operation_validation.h" + +KSetTypeJob::KSetTypeJob(partition_id parentID, partition_id partitionID, const char *type) + : KDiskDeviceJob(B_DISK_DEVICE_JOB_SET_TYPE, partitionID, parentID), + fType( !type ? NULL : strcpy( new char[strlen(type)+1], type ) ) +{ + SetDescription( "setting partition type" ); +} + + +KSetTypeJob::~KSetTypeJob(){} + +status_t KSetTypeJob::Do() { + KDiskDeviceManager * manager = KDiskDeviceManager::Default(); + + KPartition * partition = manager->WriteLockPartition( PartitionID() ); + + if( partition ) { + PartitionRegistrar registrar(partition, true); + PartitionRegistrar deviceRegistrar(partition->Device(), true); + + //TODO is lock necessary? + DeviceWriteLocker locker(partition->Device(), true); + + //basic checks + if( !partition->ParentDiskSystem() ) { + SetErrorMessage( "Partition has no parent disk system!" ); + return B_BAD_VALUE; + } + + if( !fType ) { + SetErrorMessage( "No type to set!" ); + return B_BAD_VALUE; + } + + status_t validation_result = validate_set_partition_type( + partition, partition->ChangeCounter(), + fType, false); + + if( validation_result != B_OK ) { + SetErrorMessage( "Validation of setting partition type failed!" ); + return validation_result; + } + + //everything OK, let's do the job + KDiskSystem * parentDiskSystem = partition->ParentDiskSystem(); + DiskSystemLoader loader( parentDiskSystem ); + + status_t set_type_result = parentDiskSystem->SetType( partition, fType, this ); + + if( set_type_result != B_OK ) { + SetErrorMessage( "Setting partition type failed!" ); + return set_type_result; + } + + return B_OK; + + } else { + SetErrorMessage( "Couldn't find partition!" ); + return B_ENTRY_NOT_FOUND; + } + +} Added: haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetTypeJob.h =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetTypeJob.h 2007-07-27 12:12:35 UTC (rev 21719) +++ haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetTypeJob.h 2007-07-27 15:37:23 UTC (rev 21720) @@ -0,0 +1,50 @@ +// +// C++ Interface: KSetTypeJob +// +// Description: +// +// +// Author: , (C) 2007 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef _K_DISK_DEVICE_SET_TYPE_JOB_H +#define _K_DISK_DEVICE_SET_TYPE_JOB_H + +#include + +namespace BPrivate { + +namespace DiskDevice { + +/** + * Sets type of the device/partition + */ +class KSetTypeJob : public KDiskDeviceJob +{ +public: + /** + * Creates the job. + * + * \param partitionID the partition whose type should be set + * \param type the new type for the partition + */ + KSetTypeJob(partition_id parentID, partition_id partitionID, const char *type); + + virtual ~KSetTypeJob(); + + virtual status_t Do(); + +private: + char * fType; + +}; + +} + +} + +using BPrivate::DiskDevice::KSetTypeJob; + +#endif From bonefish at mail.berlios.de Fri Jul 27 18:32:58 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 27 Jul 2007 18:32:58 +0200 Subject: [Haiku-commits] r21721 - in haiku/trunk: headers/private/kernel/disk_device_manager src/system/kernel/disk_device_manager src/system/kernel/disk_device_manager/jobs Message-ID: <200707271632.l6RGWwMN021110@sheep.berlios.de> Author: bonefish Date: 2007-07-27 18:32:47 +0200 (Fri, 27 Jul 2007) New Revision: 21721 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21721&view=rev Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceJob.h haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h haiku/trunk/headers/private/kernel/disk_device_manager/KFileSystem.h haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h haiku/trunk/headers/private/kernel/disk_device_manager/KPartitioningSystem.h haiku/trunk/headers/private/kernel/disk_device_manager/KPhysicalPartition.h haiku/trunk/headers/private/kernel/disk_device_manager/KShadowPartition.h haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJobFactory.cpp haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp haiku/trunk/src/system/kernel/disk_device_manager/ddm_userland_interface.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KCreateChildJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KCreateChildJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KDefragmentJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KDefragmentJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KDeleteChildJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KDeleteChildJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KInitializeJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KInitializeJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KMoveJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KMoveJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KRepairJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KRepairJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KResizeJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KResizeJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KScanPartitionJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KScanPartitionJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetNameJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetNameJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetParametersJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetParametersJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetTypeJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KSetTypeJob.h haiku/trunk/src/system/kernel/disk_device_manager/jobs/KUninitializeJob.cpp haiku/trunk/src/system/kernel/disk_device_manager/jobs/KUninitializeJob.h Log: * Style cleanup. * Moved method documentation from headers to source files. * Fixed small problems (memory leaks, unsafe string duplication,...). * Added TODOs where I spotted problems. Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceJob.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceJob.h 2007-07-27 15:37:23 UTC (rev 21720) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KDiskDeviceJob.h 2007-07-27 16:32:47 UTC (rev 21721) @@ -1,5 +1,11 @@ -// KDiskDeviceJob.h - +/* + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold + * Lubos Kulic + */ #ifndef _K_DISK_DEVICE_JOB_H #define _K_DISK_DEVICE_JOB_H @@ -15,38 +21,19 @@ /** * Represents some action executed on the disk device. - * - * - */ class KDiskDeviceJob { public: - /** - * Creates a new job - * - * \param type actual type of the job (see DiskDeviceDefs.h for details) - * \param partitionID the partition/device on which the action should be executed - * \param scopeID partition/device which is the highest in the hierarchy (i.e. closest - * to the root) that can be affected by the action - * - every descendant of this partition is marked busy and all ancestors are marked descendant- - busy - */ KDiskDeviceJob(uint32 type, partition_id partitionID, partition_id scopeID = -1); virtual ~KDiskDeviceJob(); - /** - * Unique identification of the job - */ disk_job_id ID() const; void SetJobQueue(KDiskDeviceJobQueue *queue); KDiskDeviceJobQueue *JobQueue() const; - /** - * Gets actual type of the action - */ uint32 Type() const; - void SetStatus(uint32 status); uint32 Status() const; @@ -81,21 +68,6 @@ status_t GetInfo(user_disk_device_job_info *info); status_t GetProgressInfo(disk_device_job_progress_info *info); - /** - * Do the actual work of the job. - * - * - is supposed to be implemented in descendants - * - doesn't have any parameter - every operation needs different ones -> they're passed - * to the constructor - * - the implementations will - * - check the parameters given in constructor (e.g. if given partition exists...) - * - check whether the partition has needed disk system (its own or parent - depends - * on the operation) - * - using the disk system, validate the operation for given params - * - finally execute the action - * - * \return B_OK when everything went OK, some error otherwise - */ virtual status_t Do() = 0; private: @@ -116,27 +88,10 @@ static disk_job_id fNextID; -private: - /** - * Visitor which checks if every descendant of given partition is busy or descendant-busy - */ - struct IsNotBusyVisitor : KPartitionVisitor { - virtual bool VisitPre(KPartition * partition); - }; - IsNotBusyVisitor fNotBusyVisitor; - protected: - //some stuff useful for all descendants + // some stuff useful for all descendants - /** - * Checks if there's any descendant which is not busy/descendant-busy. - * - * - the condition of busy descendant is common for many disk device operations -> - * many jobs can use this - * - * \param partition the root of checked subtree of the whole partition hieararchy - */ - bool isPartitionNotBusy( KPartition * partition ); + bool IsPartitionNotBusy(KPartition* partition); }; Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h 2007-07-27 15:37:23 UTC (rev 21720) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h 2007-07-27 16:32:47 UTC (rev 21721) @@ -1,5 +1,10 @@ -// KDiskSystem.h - +/* + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold + */ #ifndef _K_DISK_DEVICE_SYSTEM_H #define _K_DISK_DEVICE_SYSTEM_H @@ -13,7 +18,7 @@ class KDiskDeviceJob; class KPartition; -/// \brief Common ancestor for disk system add-on wrappers +//! \brief Common ancestor for disk system add-on wrappers class KDiskSystem { public: KDiskSystem(const char *name); Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KFileSystem.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KFileSystem.h 2007-07-27 15:37:23 UTC (rev 21720) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KFileSystem.h 2007-07-27 16:32:47 UTC (rev 21721) @@ -1,8 +1,13 @@ -// KFileSystem.h -// -// KFileSystem implements the KDiskSystem interface for file systems. -// It works with the FS API. - +/* + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold + * + * KFileSystem implements the KDiskSystem interface for file systems. + * It works with the FS API. + */ #ifndef _K_FILE_DISK_DEVICE_SYSTEM_H #define _K_FILE_DISK_DEVICE_SYSTEM_H @@ -13,7 +18,7 @@ namespace BPrivate { namespace DiskDevice { -/// \brief Wrapper for the C interface of a filesystem add-on. +//! \brief Wrapper for the C interface of a filesystem add-on. class KFileSystem : public KDiskSystem { public: KFileSystem(const char *name); Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h 2007-07-27 15:37:23 UTC (rev 21720) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h 2007-07-27 16:32:47 UTC (rev 21721) @@ -1,5 +1,10 @@ -// KPartition.h - +/* + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold + */ #ifndef _K_DISK_DEVICE_PARTITION_H #define _K_DISK_DEVICE_PARTITION_H @@ -21,7 +26,7 @@ class KPhysicalPartition; class KShadowPartition; -/// \brief Class representing a single partition. +//! \brief Class representing a single partition. class KPartition { public: KPartition(partition_id id = -1); Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KPartitioningSystem.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KPartitioningSystem.h 2007-07-27 15:37:23 UTC (rev 21720) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KPartitioningSystem.h 2007-07-27 16:32:47 UTC (rev 21721) @@ -1,5 +1,10 @@ -// KPartitioningSystem.h - +/* + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold + */ #ifndef _K_PARTITIONING_DISK_DEVICE_SYSTEM_H #define _K_PARTITIONING_DISK_DEVICE_SYSTEM_H @@ -24,9 +29,9 @@ // Scanning - /// Try to identify a given partition + //! Try to identify a given partition virtual float Identify(KPartition *partition, void **cookie); - /// Scan the partition + //! Scan the partition virtual status_t Scan(KPartition *partition, void *cookie); virtual void FreeIdentifyCookie(KPartition *partition, void *cookie); virtual void FreeCookie(KPartition *partition); @@ -34,132 +39,132 @@ // Querying - /// Check whether the add-on supports repairing this partition. + //! Check whether the add-on supports repairing this partition. virtual bool SupportsRepairing(KPartition *partition, bool checkOnly, bool *whileMounted); - /// Check whether the add-on supports resizing this partition. + //! Check whether the add-on supports resizing this partition. virtual bool SupportsResizing(KPartition *partition, bool *whileMounted); - /// Check whether the add-on supports resizing children of this partition. + //! Check whether the add-on supports resizing children of this partition. virtual bool SupportsResizingChild(KPartition *child); - /// Check whether the add-on supports moving this partition. + //! Check whether the add-on supports moving this partition. virtual bool SupportsMoving(KPartition *partition, bool *isNoOp); - /// Check whether the add-on supports moving children of this partition. + //! Check whether the add-on supports moving children of this partition. virtual bool SupportsMovingChild(KPartition *child); - /// Check whether the add-on supports setting name of this partition. + //! Check whether the add-on supports setting name of this partition. virtual bool SupportsSettingName(KPartition *partition); - /// Check whether the add-on supports setting name to content of this partition. + //! Check whether the add-on supports setting name to content of this partition. virtual bool SupportsSettingContentName(KPartition *partition, bool *whileMounted); - /// Check whether the add-on supports setting type of this partition. + //! Check whether the add-on supports setting type of this partition. virtual bool SupportsSettingType(KPartition *partition); - /// Check whether the add-on supports setting parameters of this partition. + //! Check whether the add-on supports setting parameters of this partition. virtual bool SupportsSettingParameters(KPartition *partition); - /// Check whether the add-on supports setting parameters to content of this partition. + //! Check whether the add-on supports setting parameters to content of this partition. virtual bool SupportsSettingContentParameters(KPartition *partition, bool *whileMounted); - /// Check whether the add-on supports initializing this partition. + //! Check whether the add-on supports initializing this partition. virtual bool SupportsInitializing(KPartition *partition); - /// Check whether the add-on supports initializing a child of this partition. + //! Check whether the add-on supports initializing a child of this partition. virtual bool SupportsInitializingChild(KPartition *child, const char *diskSystem); - /// Check whether the add-on supports creating children of this partition. + //! Check whether the add-on supports creating children of this partition. virtual bool SupportsCreatingChild(KPartition *partition); - /// Check whether the add-on supports deleting children of this partition. + //! Check whether the add-on supports deleting children of this partition. virtual bool SupportsDeletingChild(KPartition *child); - /// Check whether the add-on is a subsystem for a given partition. + //! Check whether the add-on is a subsystem for a given partition. virtual bool IsSubSystemFor(KPartition *partition); - /// Validates parameters for resizing a partition + //! Validates parameters for resizing a partition virtual bool ValidateResize(KPartition *partition, off_t *size); - /// Validates parameters for resizing a child partition + //! Validates parameters for resizing a child partition virtual bool ValidateResizeChild(KPartition *child, off_t *size); - /// Validates parameters for moving a partition + //! Validates parameters for moving a partition virtual bool ValidateMove(KPartition *partition, off_t *start); - /// Validates parameters for moving a child partition + //! Validates parameters for moving a child partition virtual bool ValidateMoveChild(KPartition *child, off_t *start); - /// Validates parameters for setting name of a partition + //! Validates parameters for setting name of a partition virtual bool ValidateSetName(KPartition *partition, char *name); - /// Validates parameters for setting name to content of a partition + //! Validates parameters for setting name to content of a partition virtual bool ValidateSetContentName(KPartition *partition, char *name); - /// Validates parameters for setting type of a partition + //! Validates parameters for setting type of a partition virtual bool ValidateSetType(KPartition *partition, const char *type); - /// Validates parameters for setting parameters of a partition + //! Validates parameters for setting parameters of a partition virtual bool ValidateSetParameters(KPartition *partition, const char *parameters); - /// Validates parameters for setting parameters to content of a partition + //! Validates parameters for setting parameters to content of a partition virtual bool ValidateSetContentParameters(KPartition *parameters, const char *parameters); - /// Validates parameters for initializing a partition + //! Validates parameters for initializing a partition virtual bool ValidateInitialize(KPartition *partition, char *name, const char *parameters); - /// Validates parameters for creating child of a partition + //! Validates parameters for creating child of a partition virtual bool ValidateCreateChild(KPartition *partition, off_t *start, off_t *size, const char *type, const char *parameters, int32 *index); - /// Counts partitionable spaces on a partition + //! Counts partitionable spaces on a partition virtual int32 CountPartitionableSpaces(KPartition *partition); - /// Retrieves a list of partitionable spaces on a partition + //! Retrieves a list of partitionable spaces on a partition virtual status_t GetPartitionableSpaces(KPartition *partition, partitionable_space_data *buffer, int32 count, int32 *actualCount = NULL); - /// Iterates through supported partition types + //! Iterates through supported partition types virtual status_t GetNextSupportedType(KPartition *partition, int32 *cookie, char *type); - /// Translates the "pretty" content type to an internal type + //! Translates the "pretty" content type to an internal type virtual status_t GetTypeForContentType(const char *contentType, char *type); // Shadow partition modification - /// Calls for additional modifications when shadow partition is changed + //! Calls for additional modifications when shadow partition is changed virtual status_t ShadowPartitionChanged(KPartition *partition, uint32 operation); // Writing - /// Repairs a partition + //! Repairs a partition virtual status_t Repair(KPartition *partition, bool checkOnly, KDiskDeviceJob *job); - /// Resizes a partition + //! Resizes a partition virtual status_t Resize(KPartition *partition, off_t size, KDiskDeviceJob *job); - /// Resizes child of a partition + //! Resizes child of a partition virtual status_t ResizeChild(KPartition *child, off_t size, KDiskDeviceJob *job); - /// Moves a partition + //! Moves a partition virtual status_t Move(KPartition *partition, off_t offset, KDiskDeviceJob *job); - /// Moves child of a partition + //! Moves child of a partition virtual status_t MoveChild(KPartition *child, off_t offset, KDiskDeviceJob *job); - /// Sets name to a partition + //! Sets name of a partition virtual status_t SetName(KPartition *partition, char *name, KDiskDeviceJob *job); - /// Sets name to content of a partition + //! Sets name of the content of a partition virtual status_t SetContentName(KPartition *partition, char *name, KDiskDeviceJob *job); - /// Sets type of a partition + //! Sets type of a partition virtual status_t SetType(KPartition *partition, char *type, KDiskDeviceJob *job); - /// Sets parameters of a partition + //! Sets parameters of a partition virtual status_t SetParameters(KPartition *partition, const char *parameters, KDiskDeviceJob *job); - /// Sets parameters to content of a partition + //! Sets parameters to content of a partition virtual status_t SetContentParameters(KPartition *partition, const char *parameters, KDiskDeviceJob *job); - /// Creates a child partition + //! Creates a child partition virtual status_t CreateChild(KPartition *partition, off_t offset, off_t size, const char *type, const char *parameters, KDiskDeviceJob *job, KPartition **child = NULL, partition_id childID = -1); - /// Deletes a child partition + //! Deletes a child partition virtual status_t DeleteChild(KPartition *child, KDiskDeviceJob *job); - /// Initializes a partition with this partitioning system + //! Initializes a partition with this partitioning system virtual status_t Initialize(KPartition *partition, const char *name, const char *parameters, KDiskDeviceJob *job); Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KPhysicalPartition.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KPhysicalPartition.h 2007-07-27 15:37:23 UTC (rev 21720) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KPhysicalPartition.h 2007-07-27 16:32:47 UTC (rev 21721) @@ -1,5 +1,10 @@ -// KPartition.h - +/* + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold + */ #ifndef _K_DISK_DEVICE_PHYSICAL_PARTITION_H #define _K_DISK_DEVICE_PHYSICAL_PARTITION_H @@ -12,7 +17,7 @@ class KDiskSystem; class KShadowPartition; -/// \brief Class representing an existing partition. +//! \brief Class representing an existing partition. class KPhysicalPartition : public KPartition { public: KPhysicalPartition(partition_id id = -1); Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KShadowPartition.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KShadowPartition.h 2007-07-27 15:37:23 UTC (rev 21720) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KShadowPartition.h 2007-07-27 16:32:47 UTC (rev 21721) @@ -1,5 +1,10 @@ -// KPartition.h - +/* + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold + */ #ifndef _K_DISK_DEVICE_SHADOW_PARTITION_H #define _K_DISK_DEVICE_SHADOW_PARTITION_H @@ -11,9 +16,10 @@ class KPhysicalPartition; -/// \brief Class representing a shadow of an existing partition. -/// -/// See \ref path_kernel_structures for more information. +/*! \brief Class representing a shadow of an existing partition. + + See \ref path_kernel_structures for more information. +*/ class KShadowPartition : public KPartition, private KPartitionListener { public: KShadowPartition(KPhysicalPartition *physicalPartition); Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJob.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJob.cpp 2007-07-27 15:37:23 UTC (rev 21720) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJob.cpp 2007-07-27 16:32:47 UTC (rev 21721) @@ -1,4 +1,11 @@ -// KDiskDeviceJob.cpp +/* + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold + * Lubos Kulic + */ #include @@ -14,8 +21,19 @@ #define OUT dprintf // constructor +/** + Creates a new job + + \param type actual type of the job (see DiskDeviceDefs.h for details) + \param partitionID the partition/device on which the action should be + executed + \param scopeID partition/device which is the highest in the hierarchy (i.e. + closest to the root) that can be affected by the action - every + descendant of this partition is marked busy and all ancestors are marked + descendant-busy +*/ KDiskDeviceJob::KDiskDeviceJob(uint32 type, partition_id partitionID, - partition_id scopeID) + partition_id scopeID) : fID(_NextID()), fJobQueue(NULL), fType(type), @@ -233,6 +251,23 @@ return B_OK; } +/** \fn status_t KDiskDevice::Do() + Do the actual work of the job. + + - is supposed to be implemented in descendants + - doesn't have any parameter - every operation needs different ones + -> they're passed to the constructor + - the implementations will + - check the parameters given in constructor (e.g. if given partition + exists...) + - check whether the partition has needed disk system (its own or + parent - depends on the operation) + - using the disk system, validate the operation for given params + - finally execute the action + + \return B_OK when everything went OK, some error otherwise +*/ + // _NextID disk_job_id KDiskDeviceJob::_NextID() @@ -244,16 +279,29 @@ disk_job_id KDiskDeviceJob::fNextID = 0; -// IsNotBusyVisitor -bool KDiskDeviceJob::IsNotBusyVisitor::VisitPre( KPartition * partition ) { - return !(partition->IsBusy() || partition->IsDescendantBusy()); -} +/** + Checks if there's any descendant which is not busy/descendant-busy. + - the condition of busy descendant is common for many disk device operations -> + many jobs can use this -bool KDiskDeviceJob::isPartitionNotBusy( KPartition * partition ) { + \param partition the root of checked subtree of the whole partition + hierarchy +*/ +bool +KDiskDeviceJob::IsPartitionNotBusy(KPartition* partition) +{ if( !partition ) { return false; } + + struct IsNotBusyVisitor : KPartitionVisitor { + virtual bool VisitPre(KPartition* partition) + { + return !(partition->IsBusy() || partition->IsDescendantBusy()); + } + }; + IsNotBusyVisitor notBusyVisitor; - return partition->VisitEachDescendant(&fNotBusyVisitor); + return partition->VisitEachDescendant(¬BusyVisitor); } Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJobFactory.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJobFactory.cpp 2007-07-27 15:37:23 UTC (rev 21720) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceJobFactory.cpp 2007-07-27 16:32:47 UTC (rev 21721) @@ -1,11 +1,12 @@ /* - * Copyright 2004-2006, Haiku, Inc. All rights reserved. - * Copyright 2003-2004, Ingo Weinhold, bonefish at cs.tu-berlin.de. All rights reserved. + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. * - * Distributed under the terms of the MIT License. + * Authors: + * Ingo Weinhold + * Lubos Kulic */ - #include #include "KDiskDeviceJob.h" @@ -24,6 +25,7 @@ #include "KSetTypeJob.h" #include "KUninitializeJob.h" + using namespace std; @@ -61,8 +63,9 @@ KDiskDeviceJob * -KDiskDeviceJobFactory::CreateMoveJob(partition_id parentID, partition_id partitionID, - off_t offset, const partition_id *contentsToMove, int32 contentsToMoveCount) +KDiskDeviceJobFactory::CreateMoveJob(partition_id parentID, + partition_id partitionID, off_t offset, const partition_id *contentsToMove, + int32 contentsToMoveCount) { // TODO: this is wierd, what in hell are contentsToMove etc? return new(nothrow) KMoveJob(parentID, partitionID, offset); @@ -113,7 +116,8 @@ KDiskDeviceJobFactory::CreateInitializeJob(partition_id partitionID, disk_system_id diskSystemID, const char *name, const char *parameters) { - return new(nothrow) KInitializeJob(partitionID, diskSystemID, name, parameters); + return new(nothrow) KInitializeJob(partitionID, diskSystemID, name, + parameters); } @@ -129,7 +133,8 @@ partition_id childID, off_t offset, off_t size, const char *type, const char *parameters) { - return new(nothrow) KCreateChildJob(partitionID, childID, offset, size, type, parameters); + return new(nothrow) KCreateChildJob(partitionID, childID, offset, size, + type, parameters); } Modified: haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp 2007-07-27 15:37:23 UTC (rev 21720) +++ haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp 2007-07-27 16:32:47 UTC (rev 21721) @@ -1,3 +1,12 @@ +/* + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold + * Lubos Kulic + */ + /** \file KPartitioningSystem.cpp * * \brief Implementation of \ref KPartitioningSystem class @@ -15,6 +24,7 @@ #include #include + // constructor KPartitioningSystem::KPartitioningSystem(const char *name) : KDiskSystem(name), @@ -44,6 +54,7 @@ } // Identify +//! Try to identify a given partition float KPartitioningSystem::Identify(KPartition *partition, void **cookie) { @@ -53,12 +64,13 @@ if (partition->Open(O_RDONLY, &fd) != B_OK) return -1; float result = fModule->identify_partition(fd, partition->PartitionData(), - cookie); + cookie); close(fd); return result; } // Scan +//! Scan the partition status_t KPartitioningSystem::Scan(KPartition *partition, void *cookie) { @@ -80,7 +92,7 @@ if (!partition || !fModule || !fModule->free_identify_partition_cookie) return; fModule->free_identify_partition_cookie(partition->PartitionData(), - cookie); + cookie); } // FreeCookie @@ -108,9 +120,10 @@ } // SupportsRepairing +//! Check whether the add-on supports repairing this partition. bool KPartitioningSystem::SupportsRepairing(KPartition *partition, bool checkOnly, - bool *whileMounted) + bool *whileMounted) { bool _whileMounted = false; if (!whileMounted) @@ -126,9 +139,9 @@ } // SupportsResizing +//! Check whether the add-on supports resizing this partition. bool -KPartitioningSystem::SupportsResizing(KPartition *partition, - bool *whileMounted) +KPartitioningSystem::SupportsResizing(KPartition *partition, bool *whileMounted) { bool _whileMounted = false; if (!whileMounted) @@ -143,17 +156,18 @@ } // SupportsResizingChild +//! Check whether the add-on supports resizing children of this partition. bool KPartitioningSystem::SupportsResizingChild(KPartition *child) { return (child && child->Parent() && child->ParentDiskSystem() == this - && fModule && fModule->supports_resizing_child - && fModule->supports_resizing_child( - child->Parent()->PartitionData(), - child->PartitionData())); + && fModule && fModule->supports_resizing_child + && fModule->supports_resizing_child(child->Parent()->PartitionData(), + child->PartitionData())); } // SupportsMoving +//! Check whether the add-on supports moving this partition. bool KPartitioningSystem::SupportsMoving(KPartition *partition, bool *isNoOp) { @@ -168,28 +182,33 @@ } // SupportsMovingChild +//! Check whether the add-on supports moving children of this partition. bool KPartitioningSystem::SupportsMovingChild(KPartition *child) { return (child && child->Parent() && child->ParentDiskSystem() != this - && fModule && fModule->supports_moving_child - && fModule->supports_moving_child(child->Parent()->PartitionData(), - child->PartitionData())); + && fModule && fModule->supports_moving_child + && fModule->supports_moving_child(child->Parent()->PartitionData(), + child->PartitionData())); } // SupportsSettingName +//! Check whether the add-on supports setting name of this partition. bool KPartitioningSystem::SupportsSettingName(KPartition *partition) { return (partition && partition->ParentDiskSystem() == this - && fModule && fModule->supports_setting_name - && fModule->supports_setting_name(partition->PartitionData())); + && fModule && fModule->supports_setting_name + && fModule->supports_setting_name(partition->PartitionData())); } // SupportsSettingContentName +/*! Check whether the add-on supports setting name of the content of this + partition. +*/ bool KPartitioningSystem::SupportsSettingContentName(KPartition *partition, - bool *whileMounted) + bool *whileMounted) { bool _whileMounted = false; if (!whileMounted) @@ -205,28 +224,32 @@ } // SupportsSettingType +//! Check whether the add-on supports setting type of this partition. bool KPartitioningSystem::SupportsSettingType(KPartition *partition) { return (partition && partition->ParentDiskSystem() == this - && fModule && fModule->supports_setting_type - && fModule->supports_setting_type(partition->PartitionData())); + && fModule && fModule->supports_setting_type + && fModule->supports_setting_type(partition->PartitionData())); } // SupportsSettingParameters +//! Check whether the add-on supports setting parameters of this partition. bool KPartitioningSystem::SupportsSettingParameters(KPartition *partition) { return (partition && partition->ParentDiskSystem() == this - && fModule && fModule->supports_setting_parameters - && fModule->supports_setting_parameters( - partition->PartitionData())); + && fModule && fModule->supports_setting_parameters + && fModule->supports_setting_parameters(partition->PartitionData())); } // SupportsSettingContentParameters +/*! Check whether the add-on supports setting parameters of the content of this + partition. +*/ bool KPartitioningSystem::SupportsSettingContentParameters(KPartition *partition, - bool *whileMounted) + bool *whileMounted) { bool _whileMounted = false; if (!whileMounted) @@ -242,135 +265,149 @@ } // SupportsInitializing +//! Check whether the add-on supports initializing this partition. bool KPartitioningSystem::SupportsInitializing(KPartition *partition) { return (partition && fModule && fModule->supports_initializing - && fModule->supports_initializing(partition->PartitionData())); + && fModule->supports_initializing(partition->PartitionData())); } // SupportsInitializingChild +//! Check whether the add-on supports initializing a child of this partition. bool KPartitioningSystem::SupportsInitializingChild(KPartition *child, - const char *diskSystem) + const char *diskSystem) { return (child && child->ParentDiskSystem() == this && diskSystem - && fModule && fModule->supports_initializing_child - && fModule->supports_initializing_child(child->PartitionData(), - diskSystem)); + && fModule && fModule->supports_initializing_child + && fModule->supports_initializing_child(child->PartitionData(), + diskSystem)); } // SupportsCreatingChild +//! Check whether the add-on supports creating children of this partition. bool KPartitioningSystem::SupportsCreatingChild(KPartition *partition) { return (partition && partition->DiskSystem() == this - && fModule && fModule->supports_creating_child - && fModule->supports_creating_child(partition->PartitionData())); + && fModule && fModule->supports_creating_child + && fModule->supports_creating_child(partition->PartitionData())); } // SupportsDeletingChild +//! Check whether the add-on supports deleting children of this partition. bool KPartitioningSystem::SupportsDeletingChild(KPartition *child) { return (child && child->Parent() && child->ParentDiskSystem() == this - && fModule && fModule->supports_deleting_child - && fModule->supports_deleting_child( - child->Parent()->PartitionData(), child->PartitionData())); + && fModule && fModule->supports_deleting_child + && fModule->supports_deleting_child(child->Parent()->PartitionData(), + child->PartitionData())); } // IsSubSystemFor +//! Check whether the add-on is a subsystem for a given partition. bool KPartitioningSystem::IsSubSystemFor(KPartition *partition) { return (partition && fModule && fModule->is_sub_system_for - && fModule->is_sub_system_for(partition->PartitionData())); + && fModule->is_sub_system_for(partition->PartitionData())); } // ValidateResize +//! Validates parameters for resizing a partition bool KPartitioningSystem::ValidateResize(KPartition *partition, off_t *size) { return (partition && size && partition->DiskSystem() == this && fModule - && fModule->validate_resize - && fModule->validate_resize(partition->PartitionData(), size)); + && fModule->validate_resize + && fModule->validate_resize(partition->PartitionData(), size)); } // ValidateResizeChild +//! Validates parameters for resizing a child partition bool KPartitioningSystem::ValidateResizeChild(KPartition *child, off_t *size) { return (child && size && child->Parent() - && child->ParentDiskSystem() == this && fModule - && fModule->validate_resize_child - && fModule->validate_resize_child(child->Parent()->PartitionData(), - child->PartitionData(), size)); + && child->ParentDiskSystem() == this && fModule + && fModule->validate_resize_child + && fModule->validate_resize_child(child->Parent()->PartitionData(), + child->PartitionData(), size)); } // ValidateMove +//! Validates parameters for moving a partition bool KPartitioningSystem::ValidateMove(KPartition *partition, off_t *start) { return (partition && start && partition->DiskSystem() == this && fModule - && fModule->validate_move - && fModule->validate_move(partition->PartitionData(), start)); + && fModule->validate_move + && fModule->validate_move(partition->PartitionData(), start)); } // ValidateMoveChild +//! Validates parameters for moving a child partition bool KPartitioningSystem::ValidateMoveChild(KPartition *child, off_t *start) { return (child && start && child->Parent() - && child->ParentDiskSystem() == this && fModule - && fModule->validate_move_child - && fModule->validate_move_child(child->Parent()->PartitionData(), - child->PartitionData(), start)); + && child->ParentDiskSystem() == this && fModule + && fModule->validate_move_child + && fModule->validate_move_child(child->Parent()->PartitionData(), + child->PartitionData(), start)); } // ValidateSetName +//! Validates parameters for setting name of a partition bool KPartitioningSystem::ValidateSetName(KPartition *partition, char *name) { return (partition && name && partition->Parent() - && partition->ParentDiskSystem() == this && fModule - && fModule->validate_set_name - && fModule->validate_set_name(partition->PartitionData(), name)); + && partition->ParentDiskSystem() == this && fModule + && fModule->validate_set_name + && fModule->validate_set_name(partition->PartitionData(), name)); } // ValidateSetContentName +//! Validates parameters for setting name of the content of a partition bool KPartitioningSystem::ValidateSetContentName(KPartition *partition, char *name) { return (partition && name && partition->DiskSystem() == this - && fModule && fModule->validate_set_content_name - && fModule->validate_set_content_name(partition->PartitionData(), - name)); + && fModule && fModule->validate_set_content_name + && fModule->validate_set_content_name(partition->PartitionData(), + name)); } // ValidateSetType +//! Validates parameters for setting type of a partition bool KPartitioningSystem::ValidateSetType(KPartition *partition, const char *type) { return (partition && type && partition->ParentDiskSystem() == this - && fModule && fModule->validate_set_type - && fModule->validate_set_type(partition->PartitionData(), type)); + && fModule && fModule->validate_set_type + && fModule->validate_set_type(partition->PartitionData(), type)); } // ValidateSetParameters +//! Validates parameters for setting parameters of a partition bool KPartitioningSystem::ValidateSetParameters(KPartition *partition, - const char *parameters) + const char *parameters) { return (partition && partition->ParentDiskSystem() == this - && fModule && fModule->validate_set_parameters - && fModule->validate_set_parameters(partition->PartitionData(), - parameters)); + && fModule && fModule->validate_set_parameters + && fModule->validate_set_parameters(partition->PartitionData(), + parameters)); } // ValidateSetContentParameters +//! Validates parameters for setting parameters of the content of a partition bool KPartitioningSystem::ValidateSetContentParameters(KPartition *partition, - const char *parameters) + const char *parameters) { return (partition && partition->DiskSystem() == this && fModule && fModule->validate_set_content_parameters @@ -379,33 +416,34 @@ } // ValidateInitialize +//! Validates parameters for initializing a partition bool KPartitioningSystem::ValidateInitialize(KPartition *partition, char *name, [... truncated: 2648 lines follow ...] From bonefish at mail.berlios.de Fri Jul 27 19:05:46 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 27 Jul 2007 19:05:46 +0200 Subject: [Haiku-commits] r21722 - haiku/trunk/src/kits/storage Message-ID: <200707271705.l6RH5kAT028735@sheep.berlios.de> Author: bonefish Date: 2007-07-27 19:05:45 +0200 (Fri, 27 Jul 2007) New Revision: 21722 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21722&view=rev Modified: haiku/trunk/src/kits/storage/DiskDevice.cpp Log: Some documentation. Courtesy of Jan Matejek. Modified: haiku/trunk/src/kits/storage/DiskDevice.cpp =================================================================== --- haiku/trunk/src/kits/storage/DiskDevice.cpp 2007-07-27 16:32:47 UTC (rev 21721) +++ haiku/trunk/src/kits/storage/DiskDevice.cpp 2007-07-27 17:05:45 UTC (rev 21722) @@ -41,6 +41,7 @@ */ BDiskDevice::~BDiskDevice() { + CancelModifications(); } // HasMedia @@ -179,6 +180,14 @@ } // PrepareModifications +/*! \brief Initializes the partition hierarchy for modifications. + * + * Subsequent modifications are performed on so-called \a shadow structure + * and not written to device until \ref CommitModifications is called. + * + * \note This call locks the device. You need to call \ref CommitModifications + * or \ref CancelModifications to unlock it. + */ status_t BDiskDevice::PrepareModifications() { @@ -202,6 +211,12 @@ } // CommitModifications +/*! \brief Commits modifications to device. + * + * Creates a set of jobs that perform all the changes done after + * \ref PrepareModifications. The changes are then written to device. + * Unlocks the device for further use. + */ status_t BDiskDevice::CommitModifications(bool synchronously, BMessenger progressMessenger, @@ -223,6 +238,10 @@ } // CancelModifications +/*! \brief Cancels all modifications performed on the device. + * + * Nothing is written on the device and it is unlocked for further use. + */ status_t BDiskDevice::CancelModifications() { From jackburton at mail.berlios.de Fri Jul 27 23:23:39 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Fri, 27 Jul 2007 23:23:39 +0200 Subject: [Haiku-commits] r21723 - haiku/trunk/src/apps/terminal Message-ID: <200707272123.l6RLNdFe013173@sheep.berlios.de> Author: jackburton Date: 2007-07-27 23:23:32 +0200 (Fri, 27 Jul 2007) New Revision: 21723 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21723&view=rev Added: haiku/trunk/src/apps/terminal/SmartTabView.cpp haiku/trunk/src/apps/terminal/SmartTabView.h Modified: haiku/trunk/src/apps/terminal/Jamfile haiku/trunk/src/apps/terminal/Shell.cpp haiku/trunk/src/apps/terminal/Shell.h haiku/trunk/src/apps/terminal/TermBuffer.cpp haiku/trunk/src/apps/terminal/TermBuffer.h haiku/trunk/src/apps/terminal/TermParse.cpp haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h haiku/trunk/src/apps/terminal/TermWindow.cpp haiku/trunk/src/apps/terminal/TermWindow.h Log: More work towards a tabbed terminal. Actually it already somewhat works (code not enabled, though). Moved scripting from TermWindow to TermView. Added a SmartTabView which (for now) only resizes the child views to fit their size. Usual cleanups. Modified: haiku/trunk/src/apps/terminal/Jamfile =================================================================== --- haiku/trunk/src/apps/terminal/Jamfile 2007-07-27 17:05:45 UTC (rev 21722) +++ haiku/trunk/src/apps/terminal/Jamfile 2007-07-27 21:23:32 UTC (rev 21723) @@ -16,6 +16,7 @@ PrefView.cpp PrefWindow.cpp Shell.cpp + SmartTabView.cpp TermApp.cpp TermBuffer.cpp TermParse.cpp Modified: haiku/trunk/src/apps/terminal/Shell.cpp =================================================================== --- haiku/trunk/src/apps/terminal/Shell.cpp 2007-07-27 17:05:45 UTC (rev 21722) +++ haiku/trunk/src/apps/terminal/Shell.cpp 2007-07-27 21:23:32 UTC (rev 21723) @@ -172,12 +172,12 @@ status_t -Shell::Open(int row, int col, const char *command, const char *coding) +Shell::Open(int row, int col, const char *command, const char *encoding) { if (fFd >= 0) return B_ERROR; - status_t status = _Spawn(row, col, command, coding); + status_t status = _Spawn(row, col, command, encoding); if (status < B_OK) return status; @@ -314,7 +314,7 @@ status_t -Shell::_Spawn(int row, int col, const char *command, const char *coding) +Shell::_Spawn(int row, int col, const char *command, const char *encoding) { signal(SIGTTOU, SIG_IGN); @@ -536,7 +536,7 @@ */ setenv("TERM", "beterm", true); setenv("TTY", ttyName, true); - setenv("TTYPE", coding, true); + setenv("TTYPE", encoding, true); /* * If don't set command args, exec SHELL_COMMAND. Modified: haiku/trunk/src/apps/terminal/Shell.h =================================================================== --- haiku/trunk/src/apps/terminal/Shell.h 2007-07-27 17:05:45 UTC (rev 21722) +++ haiku/trunk/src/apps/terminal/Shell.h 2007-07-27 21:23:32 UTC (rev 21723) @@ -3,33 +3,13 @@ * Copyright (c) 2003-4 Kian Duffy * Copyright (c) 2004 Daniel Furrer * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files or portions - * thereof (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice - * in the binary, as well as this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with - * the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * + * Distributed under the terms of the MIT License. + * Authors: + * Stefano Ceccherini + * Kian Duffy + * Kazuho Okui + * Takashi Murai */ - #ifndef _SHELL_H #define _SHELL_H Added: haiku/trunk/src/apps/terminal/SmartTabView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/SmartTabView.cpp 2007-07-27 17:05:45 UTC (rev 21722) +++ haiku/trunk/src/apps/terminal/SmartTabView.cpp 2007-07-27 21:23:32 UTC (rev 21723) @@ -0,0 +1,35 @@ +/* + * Copyright 2007, Haiku. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stefano Ceccherini (burton666 at libero.it) + */ + +#include "SmartTabView.h" + +SmartTabView::SmartTabView(BRect frame, const char *name, button_width width, + uint32 resizingMode, uint32 flags) + : + BTabView(frame, name, width, resizingMode, flags) +{ +} + + +SmartTabView::~SmartTabView() +{ +} + + +void +SmartTabView::Select(int32 index) +{ + BTabView::Select(index); + BTab *tab = TabAt(Selection()); + if (tab != NULL) { + BView *view = tab->View(); + if (view != NULL) + view->ResizeTo(Bounds().Width(), Bounds().Height()); + } +} + Added: haiku/trunk/src/apps/terminal/SmartTabView.h =================================================================== --- haiku/trunk/src/apps/terminal/SmartTabView.h 2007-07-27 17:05:45 UTC (rev 21722) +++ haiku/trunk/src/apps/terminal/SmartTabView.h 2007-07-27 21:23:32 UTC (rev 21723) @@ -0,0 +1,28 @@ +/* + * Copyright 2007, Haiku. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stefano Ceccherini (burton666 at libero.it) + */ + +#ifndef __SMARTTABVIEW_H +#define __SMARTTABVIEW_H + +#include + +class SmartTabView : public BTabView { +public: + SmartTabView(BRect frame, const char *name, + button_width width = B_WIDTH_AS_USUAL, + uint32 resizingMode = B_FOLLOW_ALL, + uint32 flags = B_FULL_UPDATE_ON_RESIZE | + B_WILL_DRAW | B_NAVIGABLE_JUMP | + B_FRAME_EVENTS | B_NAVIGABLE); + virtual ~SmartTabView(); + virtual void Select(int32 tab); + +}; + +#endif // __SMARTTABVIEW_H + Modified: haiku/trunk/src/apps/terminal/TermBuffer.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermBuffer.cpp 2007-07-27 17:05:45 UTC (rev 21722) +++ haiku/trunk/src/apps/terminal/TermBuffer.cpp 2007-07-27 21:23:32 UTC (rev 21723) @@ -87,11 +87,10 @@ #include -#define ARRAY_SIZE 512 #define ROW(x) (((x) + fRowOffset) % fBufferSize) -TermBuffer::TermBuffer(int rows, int cols) +TermBuffer::TermBuffer(int rows, int cols, int bufferSize) { if (rows < 1) rows = 1; @@ -109,7 +108,7 @@ fSelStart.Set(-1,-1); fSelEnd.Set(-1,-1); - fBufferSize = PrefHandler::Default()->getInt32(PREF_HISTORY_SIZE); + fBufferSize = bufferSize; if (fBufferSize < 1000) fBufferSize = 1000; Modified: haiku/trunk/src/apps/terminal/TermBuffer.h =================================================================== --- haiku/trunk/src/apps/terminal/TermBuffer.h 2007-07-27 17:05:45 UTC (rev 21722) +++ haiku/trunk/src/apps/terminal/TermBuffer.h 2007-07-27 21:23:32 UTC (rev 21723) @@ -30,10 +30,10 @@ #ifndef _TERMBUFFER_H #define _TERMBUFFER_H -#include +#include "CurPos.h" #include "TermConst.h" -#include "CurPos.h" +#include struct term_buffer @@ -49,7 +49,7 @@ class TermBuffer { public: - TermBuffer(int row, int col); + TermBuffer(int row, int col, int bufferSize = 1000); ~TermBuffer(); // Modified: haiku/trunk/src/apps/terminal/TermParse.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-27 17:05:45 UTC (rev 21722) +++ haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-27 21:23:32 UTC (rev 21723) @@ -20,6 +20,7 @@ #include #include #include +#include ////////////////////////////////////////////////////////////////////////////// Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-27 17:05:45 UTC (rev 21722) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-27 21:23:32 UTC (rev 21723) @@ -31,9 +31,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -134,7 +136,7 @@ fTermColumns(PrefHandler::Default()->getInt32(PREF_COLS)), fEncoding(M_UTF8), fTop(0), - fTextBuffer(new (nothrow) TermBuffer(fTermRows, fTermColumns)), + fTextBuffer(NULL), fScrollBar(NULL), fScrTop(0), fScrBot(fTermRows - 1), @@ -156,17 +158,17 @@ void TermView::_InitObject(const char *command) { + fTextBuffer = new TermBuffer(fTermRows, fTermColumns, fScrBufSize); + SetMouseCursor(); SetTermFont(be_fixed_font, be_fixed_font); SetTermColor(); //SetIMAware(PrefHandler::Default()->getInt32(PREF_IM_AWARE)); - const char *encoding = PrefHandler::Default()->getString(PREF_TEXT_ENCODING); - SetEncoding(longname2id(encoding)); - fShell = new Shell(); - status_t status = fShell->Open(fTermRows, fTermColumns, command, longname2shortname(encoding)); + status_t status = fShell->Open(fTermRows, fTermColumns, + command, longname2shortname(id2longname(fEncoding))); if (status < B_OK) throw status; @@ -1531,7 +1533,41 @@ case B_SELECT_ALL: DoSelectAll(); break; + + case B_SET_PROPERTY: { + int32 i; + int32 encodingID; + BMessage spe; + msg->GetCurrentSpecifier(&i, &spe); + if (!strcmp("encoding", spe.FindString("property", i))){ + msg->FindInt32 ("data", &encodingID); + SetEncoding(encodingID); + msg->SendReply(B_REPLY); + } else { + BView::MessageReceived(msg); + } + break; + } + case B_GET_PROPERTY: { + int32 i; + BMessage spe; + msg->GetCurrentSpecifier(&i, &spe); + if (!strcmp("encoding", spe.FindString("property", i))){ + BMessage reply(B_REPLY); + reply.AddInt32("result", Encoding()); + msg->SendReply(&reply); + } + else if (!strcmp("tty", spe.FindString("property", i))) { + BMessage reply(B_REPLY); + reply.AddString("result", TerminalName()); + msg->SendReply(&reply); + } else { + BView::MessageReceived(msg); + } + break; + } + case MENU_CLEAR_ALL: DoClearAll(); fShell->Write(ctrl_l, 1); @@ -1570,6 +1606,46 @@ } +status_t +TermView::GetSupportedSuites(BMessage *message) +{ + static property_info propList[] = { + { "encoding", + {B_GET_PROPERTY, 0}, + {B_DIRECT_SPECIFIER, 0}, + "get muterminal encoding"}, + { "encoding", + {B_SET_PROPERTY, 0}, + {B_DIRECT_SPECIFIER, 0}, + "set muterminal encoding"}, + { "tty", + {B_GET_PROPERTY, 0}, + {B_DIRECT_SPECIFIER, 0}, + "get tty_name."}, + { 0 } + + }; + + message->AddString("suites", "suite/vnd.naan-termview"); + BPropertyInfo propInfo(propList); + message->AddFlat("messages", &propInfo); + return BView::GetSupportedSuites(message); +} + + +BHandler* +TermView::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier, + int32 form, const char *property) +{ + if (((strcmp(property, "encode") == 0) + && ((msg->what == B_SET_PROPERTY) || (msg->what == B_GET_PROPERTY))) + || ((strcmp(property, "tty") == 0) && (msg->what == B_GET_PROPERTY))) + return this; + + return BView::ResolveSpecifier(msg, index, specifier, form, property); +} + + //! Gets dropped file full path and display it at cursor position. void TermView::DoFileDrop(entry_ref &ref) Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2007-07-27 17:05:45 UTC (rev 21722) +++ haiku/trunk/src/apps/terminal/TermView.h 2007-07-27 21:23:32 UTC (rev 21723) @@ -33,8 +33,6 @@ #include "CurPos.h" -#include "TermConst.h" -#include "TermWindow.h" #include #include @@ -52,7 +50,7 @@ class TermBuffer; class TermView : public BView { public: - TermView(BRect frame, const char *command); + TermView(BRect frame, const char *command = NULL); ~TermView(); virtual void GetPreferredSize(float *width, float *height); @@ -142,6 +140,11 @@ virtual void FrameResized(float width, float height); virtual void MessageReceived(BMessage* message); + virtual status_t GetSupportedSuites(BMessage *msg); + virtual BHandler* ResolveSpecifier(BMessage *msg, int32 index, + BMessage *specifier, int32 form, + const char *property); + private: void _InitObject(const char *command); Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-27 17:05:45 UTC (rev 21722) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-27 21:23:32 UTC (rev 21723) @@ -16,6 +16,7 @@ #include "PrefWindow.h" #include "PrefView.h" #include "PrefHandler.h" +#include "SmartTabView.h" #include "TermConst.h" #include "TermView.h" @@ -26,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -52,14 +52,14 @@ #if 0 TermWindow::TermWindow(BRect frame, const char* title, const char *command) : - BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE) + BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE), + fTabView(NULL) { - fTermView = new TermView(Bounds(), command); - AddChild(fTermView); - - float width, height; - fTermView->GetPreferredSize(&width, &height); - ResizeTo(width, height); + fTabView = new SmartTabView(Bounds(), "Tab view"); + AddChild(fTabView); + + _NewTab(command); + _NewTab(NULL); } #else @@ -386,43 +386,7 @@ fTermView->SetEncoding(coding_id); break; } - // Extended B_SET_PROPERTY. Dispatch this message, - // Set coding ID. - case B_SET_PROPERTY: { - int32 i; - BMessage spe; - message->GetCurrentSpecifier(&i, &spe); - if (!strcmp("encode", spe.FindString("property", i))){ - message->FindInt32 ("data", &coding_id); - fTermView->SetEncoding (coding_id); - - message->SendReply(B_REPLY); - } else { - BWindow::MessageReceived(message); - } - break; - } - - // Extended B_GET_PROPERTY. Dispatch this message, reply now coding ID. - case B_GET_PROPERTY: { - int32 i; - BMessage spe; - message->GetCurrentSpecifier(&i, &spe); - if (!strcmp("encode", spe.FindString("property", i))){ - BMessage reply(B_REPLY); - reply.AddInt32("result", fTermView->Encoding()); - message->SendReply(&reply); - } - else if (!strcmp("tty", spe.FindString("property", i))) { - BMessage reply(B_REPLY); - reply.AddString("result", fTermView->TerminalName()); - message->SendReply(&reply); - } else { - BWindow::MessageReceived(message); - } - break; - } - + // Message from Preference panel. case MSG_ROWS_CHANGED: case MSG_COLS_CHANGED: { @@ -580,51 +544,6 @@ status_t -TermWindow::GetSupportedSuites(BMessage *msg) -{ - static property_info propList[] = { - { "encode", - {B_GET_PROPERTY, 0}, - {B_DIRECT_SPECIFIER, 0}, - "get muterminal encode"}, - { "encode", - {B_SET_PROPERTY, 0}, - {B_DIRECT_SPECIFIER, 0}, - "set muterminal encode"}, - { "tty", - {B_GET_PROPERTY, 0}, - {B_DIRECT_SPECIFIER, 0}, - "get tty_name."}, - { 0 } - - }; - - msg->AddString("suites", "suite/vnd.naan-termwindow"); - BPropertyInfo propInfo(propList); - msg->AddFlat("messages", &propInfo); - return BWindow::GetSupportedSuites(msg); -} - - -//////////////////////////////////////////////////////////////////////////// -// ResolveSpecifier -// -//////////////////////////////////////////////////////////////////////////// -BHandler* -TermWindow::ResolveSpecifier(BMessage *msg, int32 index, - BMessage *specifier, int32 form, - const char *property) -{ - if (((strcmp(property, "encode") == 0) - && ((msg->what == B_SET_PROPERTY) || (msg->what == B_GET_PROPERTY))) - || ((strcmp(property, "tty") == 0) && (msg->what == B_GET_PROPERTY))) - return this; - - return BWindow::ResolveSpecifier(msg, index, specifier, form, property); -} - - -status_t TermWindow::_DoPageSetup() { BPrintJob job("PageSetup"); @@ -684,3 +603,12 @@ } #endif +void +TermWindow::_NewTab(const char *command) +{ + TermView *view = new TermView(Bounds(), command); + fTabView->AddTab(view); +} + + + Modified: haiku/trunk/src/apps/terminal/TermWindow.h =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-27 17:05:45 UTC (rev 21722) +++ haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-27 21:23:32 UTC (rev 21723) @@ -40,7 +40,7 @@ class FindWindow; class PrefWindow; class TermView; - +class SmartTabView; class TermWindow : public BWindow { public: TermWindow(BRect frame, const char* title, const char *command); @@ -52,17 +52,15 @@ virtual void MenusBeginning(); virtual bool QuitRequested(); - status_t GetSupportedSuites(BMessage *msg); - BHandler* ResolveSpecifier(BMessage *msg, int32 index, - BMessage *specifier, int32 form, - const char *property); private: void _InitWindow(const char *command); void _SetupMenu(); status_t _DoPageSetup(); void _DoPrint(); - + void _NewTab(const char *command); + + SmartTabView *fTabView; TermView *fTermView; BMenuBar *fMenubar; BMenu *fFilemenu, From jackburton at mail.berlios.de Fri Jul 27 23:43:25 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Fri, 27 Jul 2007 23:43:25 +0200 Subject: [Haiku-commits] r21724 - haiku/trunk/src/apps/terminal Message-ID: <200707272143.l6RLhPxf014586@sheep.berlios.de> Author: jackburton Date: 2007-07-27 23:43:24 +0200 (Fri, 27 Jul 2007) New Revision: 21724 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21724&view=rev Modified: haiku/trunk/src/apps/terminal/TermApp.cpp haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h haiku/trunk/src/apps/terminal/TermWindow.cpp Log: Removed weird code in TermWindow::WindowActivated. Added basic Archive(), Instantiate(), and unarchiving constructor. Modified: haiku/trunk/src/apps/terminal/TermApp.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-27 21:23:32 UTC (rev 21723) +++ haiku/trunk/src/apps/terminal/TermApp.cpp 2007-07-27 21:43:24 UTC (rev 21724) @@ -11,7 +11,6 @@ #include "CodeConv.h" #include "PrefHandler.h" -#include "TermBuffer.h" #include "TermWindow.h" #include "TermConst.h" Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-27 21:23:32 UTC (rev 21723) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-27 21:43:24 UTC (rev 21724) @@ -155,6 +155,13 @@ } +TermView::TermView(BMessage *archive) + : + BView(archive) +{ +} + + void TermView::_InitObject(const char *command) { @@ -194,6 +201,23 @@ } +/* static */ +BArchivable * +TermView::Instantiate(BMessage* data) +{ + if (validate_instantiation(data, "TermView")) + return new TermView(data); + return NULL; +} + + +status_t +TermView::Archive(BMessage* data, bool deep) const +{ + return BView::Archive(data, deep); +} + + void TermView::GetPreferredSize(float *width, float *height) { Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2007-07-27 21:23:32 UTC (rev 21723) +++ haiku/trunk/src/apps/terminal/TermView.h 2007-07-27 21:43:24 UTC (rev 21724) @@ -51,8 +51,11 @@ class TermView : public BView { public: TermView(BRect frame, const char *command = NULL); + TermView(BMessage *archive); ~TermView(); + static BArchivable* Instantiate(BMessage* data); + virtual status_t Archive(BMessage* data, bool deep = true) const; virtual void GetPreferredSize(float *width, float *height); status_t AttachShell(Shell *shell); Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-27 21:23:32 UTC (rev 21723) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-27 21:43:24 UTC (rev 21724) @@ -523,15 +523,9 @@ void -TermWindow::WindowActivated(bool) +TermWindow::WindowActivated(bool activated) { -#ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST - if (focus_follows_mouse()) { - BPoint aMouseLoc = Frame().LeftTop(); - set_mouse_position(int32(aMouseLoc.x + 16), int32(aMouseLoc.y + 2)); - be_app->SetCursor(B_HAND_CURSOR); - } -#endif + BWindow::WindowActivated(activated); } From jackburton at mail.berlios.de Fri Jul 27 23:56:48 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Fri, 27 Jul 2007 23:56:48 +0200 Subject: [Haiku-commits] r21725 - haiku/trunk/src/apps/terminal Message-ID: <200707272156.l6RLulnU015005@sheep.berlios.de> Author: jackburton Date: 2007-07-27 23:56:47 +0200 (Fri, 27 Jul 2007) New Revision: 21725 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21725&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp Log: Implemented Archive() and unarchiving constructor. TermView won't work as a replicant, though, until I remove the preference code from it. Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-27 21:43:24 UTC (rev 21724) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-27 21:56:47 UTC (rev 21725) @@ -157,8 +157,53 @@ TermView::TermView(BMessage *archive) : - BView(archive) + BView(archive), + fShell(NULL), + fFontWidth(0), + fFontHeight(0), + fFontAscent(0), + fUpdateFlag(false), + fInsertModeFlag(MODE_OVER), + fScrollUpCount(0), + fScrollBarRange(0), + fFrameResized(false), + fLastCursorTime(0), + fCursorDrawFlag(CURON), + fCursorStatus(CURON), + fCursorBlinkingFlag(CURON), + fCursorRedrawFlag(CURON), + fCursorHeight(0), + fCurPos(0, 0), + fCurStack(0, 0), + fBufferStartPos(-1), + fTermRows(25), + fTermColumns(80), + fEncoding(M_UTF8), + fTop(0), + fTextBuffer(NULL), + fScrollBar(NULL), + fScrTop(0), + fScrBot(fTermRows - 1), + fScrBufSize(1000), + fScrRegionSet(0), + fMouseImage(false), + fPreviousMousePoint(0, 0), + fSelStart(-1, -1), + fSelEnd(-1, -1), + fMouseTracking(false), + fMouseThread(-1), + fQuitting(false), + fIMflag(false) { + if (archive->FindInt32("encoding", (int32 *)&fEncoding) < B_OK) + fEncoding = M_UTF8; + if (archive->FindInt32("columns", (int32 *)&fTermColumns) < B_OK) + fTermColumns = 80; + if (archive->FindInt32("rows", (int32 *)&fTermRows) < B_OK) + fTermRows = 25; + + // TODO: Retrieve command from archive + _InitObject(NULL); } @@ -214,7 +259,18 @@ status_t TermView::Archive(BMessage* data, bool deep) const { - return BView::Archive(data, deep); + status_t status = BView::Archive(data, deep); + if (status < B_OK) + return status; + status = data->AddInt32("encoding", (int32)fEncoding); + if (status < B_OK) + return status; + status = data->AddInt32("columns", (int32)fTermColumns); + if (status < B_OK) + return status; + status = data->AddInt32("rows", (int32)fTermRows); + + return status; } From laplace at mail.berlios.de Sat Jul 28 08:15:01 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Sat, 28 Jul 2007 08:15:01 +0200 Subject: [Haiku-commits] r21726 - haiku/trunk/src/servers/print Message-ID: <200707280615.l6S6F1nr003137@sheep.berlios.de> Author: laplace Date: 2007-07-28 08:15:01 +0200 (Sat, 28 Jul 2007) New Revision: 21726 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21726&view=rev Modified: haiku/trunk/src/servers/print/print_server.rdef Log: Updated copyright year. Modified: haiku/trunk/src/servers/print/print_server.rdef =================================================================== --- haiku/trunk/src/servers/print/print_server.rdef 2007-07-27 21:56:47 UTC (rev 21725) +++ haiku/trunk/src/servers/print/print_server.rdef 2007-07-28 06:15:01 UTC (rev 21726) @@ -10,7 +10,7 @@ internal = 0, short_info = "print_server", - long_info = "print_server ?2001-2006 Haiku" + long_info = "print_server ?2001-2007 Haiku" }; resource app_flags B_EXCLUSIVE_LAUNCH | B_BACKGROUND_APP; From laplace at mail.berlios.de Sat Jul 28 09:17:24 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Sat, 28 Jul 2007 09:17:24 +0200 Subject: [Haiku-commits] r21727 - in haiku/trunk: build/jam data/image_directories Message-ID: <200707280717.l6S7HO6N006923@sheep.berlios.de> Author: laplace Date: 2007-07-28 09:17:23 +0200 (Sat, 28 Jul 2007) New Revision: 21727 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21727&view=rev Added: haiku/trunk/data/image_directories/home-config-settings-printers-preview.rdef haiku/trunk/data/image_directories/home-config-settings-printers-save-as-pdf.rdef Modified: haiku/trunk/build/jam/HaikuImage Log: Added "default" printers to image (Preview and Save as PDF). Thank you Ingo, for providing the necessary build infrastructure! Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-07-28 06:15:01 UTC (rev 21726) +++ haiku/trunk/build/jam/HaikuImage 2007-07-28 07:17:23 UTC (rev 21727) @@ -385,7 +385,14 @@ #optional AddFilesToHaikuImage optional beos system add-ons input_server methods : canna ; +# printers +AddDirectoryToHaikuImage home config settings printers Preview + : home-config-settings-printers-preview.rdef ; +AddDirectoryToHaikuImage home config settings printers "Save-as-PDF" + : home-config-settings-printers-save-as-pdf.rdef ; + + #pragma mark - Build The Image # Set image name and directory defaults and locate the image. Added: haiku/trunk/data/image_directories/home-config-settings-printers-preview.rdef =================================================================== --- haiku/trunk/data/image_directories/home-config-settings-printers-preview.rdef 2007-07-28 06:15:01 UTC (rev 21726) +++ haiku/trunk/data/image_directories/home-config-settings-printers-preview.rdef 2007-07-28 07:17:23 UTC (rev 21727) @@ -0,0 +1,9 @@ + +resource(0, "BEOS:TYPE") #'MIMS' "application/x-vnd.Be.printer"; + +resource(1, "Printer Name") "Preview"; +resource(2, "Driver Name") "Preview"; +resource(3, "transport") ""; +resource(4, "transport_address") ""; +resource(5, "connection") "Local"; +resource(6, "state") "free"; Added: haiku/trunk/data/image_directories/home-config-settings-printers-save-as-pdf.rdef =================================================================== --- haiku/trunk/data/image_directories/home-config-settings-printers-save-as-pdf.rdef 2007-07-28 06:15:01 UTC (rev 21726) +++ haiku/trunk/data/image_directories/home-config-settings-printers-save-as-pdf.rdef 2007-07-28 07:17:23 UTC (rev 21727) @@ -0,0 +1,9 @@ + +resource(0, "BEOS:TYPE") #'MIMS' "application/x-vnd.Be.printer"; + +resource(1, "Printer Name") "Save as PDF"; +resource(2, "Driver Name") "PDF Writer"; +resource(3, "transport") "Print To File"; +resource(4, "transport_address") ""; +resource(5, "connection") "Local"; +resource(6, "state") "free"; From jackburton at mail.berlios.de Sat Jul 28 16:49:40 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sat, 28 Jul 2007 16:49:40 +0200 Subject: [Haiku-commits] r21728 - haiku/trunk/src/apps/terminal Message-ID: <200707281449.l6SEneOD012112@sheep.berlios.de> Author: jackburton Date: 2007-07-28 16:49:39 +0200 (Sat, 28 Jul 2007) New Revision: 21728 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21728&view=rev Modified: haiku/trunk/src/apps/terminal/PrefHandler.cpp haiku/trunk/src/apps/terminal/Shell.cpp haiku/trunk/src/apps/terminal/TermBuffer.cpp haiku/trunk/src/apps/terminal/TermConst.h haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h haiku/trunk/src/apps/terminal/TermWindow.cpp haiku/trunk/src/apps/terminal/TermWindow.h Log: TermView and the classes used by it now don't know about PrefHandler anymore, but have methods to set the needed options. Various cleanups. Modified: haiku/trunk/src/apps/terminal/PrefHandler.cpp =================================================================== --- haiku/trunk/src/apps/terminal/PrefHandler.cpp 2007-07-28 07:17:23 UTC (rev 21727) +++ haiku/trunk/src/apps/terminal/PrefHandler.cpp 2007-07-28 14:49:39 UTC (rev 21728) @@ -55,9 +55,6 @@ { PREF_TEXT_ENCODING, "UTF-8" }, - { PREF_MOUSE_IMAGE, "Hand cursor"}, - { PREF_DRAGN_COPY, "0"}, - { PREF_GUI_LANGUAGE, "English"}, { PREF_IM_AWARE, "0"}, { NULL, NULL}, Modified: haiku/trunk/src/apps/terminal/Shell.cpp =================================================================== --- haiku/trunk/src/apps/terminal/Shell.cpp 2007-07-28 07:17:23 UTC (rev 21727) +++ haiku/trunk/src/apps/terminal/Shell.cpp 2007-07-28 14:49:39 UTC (rev 21728) @@ -4,33 +4,10 @@ * Copyright (c) 2004 Daniel Furrer * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files or portions - * thereof (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, subject - * to the following conditions: + * Distributed under the terms of the MIT license. * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice - * in the binary, as well as this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with - * the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * */ - #include "Shell.h" #include "TermConst.h" Modified: haiku/trunk/src/apps/terminal/TermBuffer.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermBuffer.cpp 2007-07-28 07:17:23 UTC (rev 21727) +++ haiku/trunk/src/apps/terminal/TermBuffer.cpp 2007-07-28 14:49:39 UTC (rev 21728) @@ -76,7 +76,6 @@ #include "TermBuffer.h" #include "CurPos.h" -#include "PrefHandler.h" #include "TermConst.h" #include Modified: haiku/trunk/src/apps/terminal/TermConst.h =================================================================== --- haiku/trunk/src/apps/terminal/TermConst.h 2007-07-28 07:17:23 UTC (rev 21727) +++ haiku/trunk/src/apps/terminal/TermConst.h 2007-07-28 14:49:39 UTC (rev 21728) @@ -103,13 +103,11 @@ const char* const PREF_IM_FORE_COLOR = "IM Foreground Color"; const char* const PREF_IM_BACK_COLOR = "IM Background Color"; const char* const PREF_IM_SELECT_COLOR = "IM Selection Color"; -const char* const PREF_DRAGN_COPY = "Drag'n Copy"; const char* const PREF_HISTORY_SIZE = "Histry Size"; const char* const PREF_CURSOR_BLINKING = "Cursor Blinking rate"; const char* const PREF_IM_AWARE = "Input Method Aware"; -const char* const PREF_MOUSE_IMAGE = "Cursor Image"; const char* const PREF_COLS = "Cols"; const char* const PREF_ROWS = "Rows"; Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-28 07:17:23 UTC (rev 21727) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-28 14:49:39 UTC (rev 21728) @@ -5,6 +5,7 @@ * All rights reserved. Distributed under the terms of the MIT license. * * Authors: + * Stefano Ceccherini * Kian Duffy, myob at users.sourceforge.net * Y.Hayakawa, hida at sawada.riec.tohoku.ac.jp */ @@ -13,8 +14,6 @@ #include "TermView.h" #include "CodeConv.h" -#include "MenuUtil.h" -#include "PrefHandler.h" #include "PrefView.h" #include "Shell.h" #include "TermBuffer.h" @@ -108,11 +107,16 @@ #define MOUSE_THR_CODE 'mtcd' +#define ROWS_DEFAULT 25 +#define COLUMNS_DEFAULT 80 const static uint32 kUpdateSigWinch = 'Rwin'; +const static rgb_color kBlackColor = { 0, 0, 0, 255 }; +const static rgb_color kWhiteColor = { 255, 255, 255, 255 }; -TermView::TermView(BRect frame, const char *command) + +TermView::TermView(BRect frame, const char *command, int32 historySize) : BView(frame, "termview", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED), fShell(NULL), fFontWidth(0), @@ -132,17 +136,22 @@ fCurPos(0, 0), fCurStack(0, 0), fBufferStartPos(-1), - fTermRows(PrefHandler::Default()->getInt32(PREF_ROWS)), - fTermColumns(PrefHandler::Default()->getInt32(PREF_COLS)), + fTermRows(ROWS_DEFAULT), + fTermColumns(COLUMNS_DEFAULT), fEncoding(M_UTF8), fTop(0), fTextBuffer(NULL), fScrollBar(NULL), + fTextForeColor(kBlackColor), + fTextBackColor(kWhiteColor), + fCursorForeColor(kWhiteColor), + fCursorBackColor(kBlackColor), + fSelectForeColor(kWhiteColor), + fSelectBackColor(kBlackColor), fScrTop(0), fScrBot(fTermRows - 1), - fScrBufSize(PrefHandler::Default()->getInt32(PREF_HISTORY_SIZE)), + fScrBufSize(historySize), fScrRegionSet(0), - fMouseImage(false), fPreviousMousePoint(0, 0), fSelStart(-1, -1), fSelEnd(-1, -1), @@ -176,17 +185,22 @@ fCurPos(0, 0), fCurStack(0, 0), fBufferStartPos(-1), - fTermRows(25), - fTermColumns(80), + fTermRows(ROWS_DEFAULT), + fTermColumns(COLUMNS_DEFAULT), fEncoding(M_UTF8), fTop(0), fTextBuffer(NULL), fScrollBar(NULL), + fTextForeColor(kBlackColor), + fTextBackColor(kWhiteColor), + fCursorForeColor(kWhiteColor), + fCursorBackColor(kBlackColor), + fSelectForeColor(kWhiteColor), + fSelectBackColor(kBlackColor), fScrTop(0), fScrBot(fTermRows - 1), fScrBufSize(1000), fScrRegionSet(0), - fMouseImage(false), fPreviousMousePoint(0, 0), fSelStart(-1, -1), fSelEnd(-1, -1), @@ -202,7 +216,7 @@ if (archive->FindInt32("rows", (int32 *)&fTermRows) < B_OK) fTermRows = 25; - // TODO: Retrieve command from archive + // TODO: Retrieve command, colors, history size, etc. from archive _InitObject(NULL); } @@ -212,11 +226,9 @@ { fTextBuffer = new TermBuffer(fTermRows, fTermColumns, fScrBufSize); - SetMouseCursor(); SetTermFont(be_fixed_font, be_fixed_font); - SetTermColor(); - //SetIMAware(PrefHandler::Default()->getInt32(PREF_IM_AWARE)); + //SetIMAware(false); fShell = new Shell(); status_t status = fShell->Open(fTermRows, fTermColumns, @@ -349,30 +361,30 @@ } -//! Sets the mouse cursor image void -TermView::SetMouseCursor() +TermView::SetTextColor(rgb_color fore, rgb_color back) { - if (!strcmp(PrefHandler::Default()->getString(PREF_MOUSE_IMAGE), "Hand cursor")) - fMouseImage = false; - else - fMouseImage = true; + fTextForeColor = fore; + fTextBackColor = back; + + SetLowColor(fTextBackColor); + SetViewColor(fTextBackColor); } -//! Sets colors for the terminal void -TermView::SetTermColor() +TermView::SetSelectColor(rgb_color fore, rgb_color back) { - fTextForeColor = PrefHandler::Default()->getRGB(PREF_TEXT_FORE_COLOR); - fTextBackColor = PrefHandler::Default()->getRGB(PREF_TEXT_BACK_COLOR); - fSelectForeColor = PrefHandler::Default()->getRGB(PREF_SELECT_FORE_COLOR); - fSelectBackColor = PrefHandler::Default()->getRGB(PREF_SELECT_BACK_COLOR); - fCursorForeColor = PrefHandler::Default()->getRGB(PREF_CURSOR_FORE_COLOR); - fCursorBackColor = PrefHandler::Default()->getRGB(PREF_CURSOR_BACK_COLOR); + fSelectForeColor = fore; + fSelectBackColor = back; +} - SetLowColor(fTextBackColor); - SetViewColor(fTextBackColor); + +void +TermView::SetCursorColor(rgb_color fore, rgb_color back) +{ + fCursorForeColor = fore; + fCursorBackColor = back; } @@ -386,6 +398,9 @@ void TermView::SetEncoding(int encoding) { + // TODO: Shell::_Spawn() sets the "TTYPE" environment variable using + // the string value of encoding. But when this function is called and + // the encoding changes, the new value is never passed to Shell. fEncoding = encoding; } @@ -963,8 +978,7 @@ BRect r; if (theObj->HasSelection() - && ( PrefHandler::Default()->getInt32(PREF_DRAGN_COPY) - || modifiers() & B_CONTROL_KEY)) { + && (modifiers() & B_CONTROL_KEY)) { if (theObj->LockLooper()) { theObj->GetMouse(&stpoint, &button); @@ -1411,9 +1425,6 @@ if (active == false) { // DoIMConfirm(); } - - if (active && fMouseImage) - be_app->SetCursor(B_I_BEAM_CURSOR); } @@ -1901,7 +1912,7 @@ // If mouse pointer is avove selected Region, start Drag'n Copy. if (inPos > stPos && inPos < edPos) { - if (mod & B_CONTROL_KEY || PrefHandler::Default()->getInt32(PREF_DRAGN_COPY)) { + if (mod & B_CONTROL_KEY) { BPoint p; uint32 bt; do { @@ -1984,14 +1995,9 @@ } void -TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *) +TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message) { - if (fMouseImage && Window()->IsActive()) { - if (transit == B_ENTERED_VIEW) - be_app->SetCursor(B_I_BEAM_CURSOR); - if (transit == B_EXITED_VIEW) - be_app->SetCursor(B_HAND_CURSOR); - } + BView::MouseMoved(where, transit, message); } Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2007-07-28 07:17:23 UTC (rev 21727) +++ haiku/trunk/src/apps/terminal/TermView.h 2007-07-28 14:49:39 UTC (rev 21728) @@ -3,31 +3,12 @@ * Copyright (c) 2003-4 Kian Duffy * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files or portions - * thereof (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice - * in the binary, as well as this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with - * the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * + * Distributed under the terms of the MIT license. + * Authors: + * Stefano Ceccherini + * Kian Duffy, myob at users.sourceforge.net */ + #ifndef TERMVIEW_H #define TERMVIEW_H @@ -50,7 +31,7 @@ class TermBuffer; class TermView : public BView { public: - TermView(BRect frame, const char *command = NULL); + TermView(BRect frame, const char *command = NULL, int32 historySize = 1000); TermView(BMessage *archive); ~TermView(); @@ -67,12 +48,13 @@ void GetFontSize(int *width, int *height); BRect SetTermSize(int rows, int cols, bool flag); - void SetTermColor(); + void SetTextColor(rgb_color fore, rgb_color back); + void SetSelectColor(rgb_color fore, rgb_color back); + void SetCursorColor(rgb_color fore, rgb_color back); int Encoding() const; void SetEncoding(int encoding); - void SetMouseCursor(); // void SetIMAware (bool); void SetScrollBar(BScrollBar *scrbar); BScrollBar *ScrollBar() const { return fScrollBar; }; @@ -84,9 +66,9 @@ void PutNL(int num); void SetInsertMode(int flag); void InsertSpace(int num); - int TermDraw(const CurPos &start, const CurPos &end); - int TermDrawRegion(CurPos start, CurPos end); - int TermDrawSelectedRegion(CurPos start, CurPos end); + int TermDraw(const CurPos &start, const CurPos &end); + int TermDrawRegion(CurPos start, CurPos end); + int TermDrawSelectedRegion(CurPos start, CurPos end); // Delete Charactor void EraseBelow(); void DeleteChar(int num); @@ -259,16 +241,13 @@ rgb_color fTextForeColor, fTextBackColor; rgb_color fCursorForeColor, fCursorBackColor; rgb_color fSelectForeColor, fSelectBackColor; - uchar fTermAttr; - + // Scroll Region int fScrTop; int fScrBot; - int fScrBufSize; + int32 fScrBufSize; bool fScrRegionSet; - bool fMouseImage; - BPoint fPreviousMousePoint; // view selection Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-28 07:17:23 UTC (rev 21727) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-28 14:49:39 UTC (rev 21728) @@ -1,10 +1,10 @@ /* * Copyright 2007 Haiku, Inc. + * Copyright (c) 2004 Daniel Furrer * Copyright (c) 2003-2004 Kian Duffy * Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. - * Copyright (c) 2004 Daniel Furrer * - * Distributed unter the terms of the MIT license. + * Distributed under the terms of the MIT license. */ #include "TermWindow.h" @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -53,7 +54,27 @@ TermWindow::TermWindow(BRect frame, const char* title, const char *command) : BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE), - fTabView(NULL) + fTabView(NULL), + fTermView(NULL), + fMenubar(NULL), + fFilemenu(NULL), + fEditmenu(NULL), + fEncodingmenu(NULL), + fHelpmenu(NULL), + fFontMenu(NULL), + fWindowSizeMenu(NULL), + fNewFontMenu(NULL), + fPrintSettings(NULL), + fPrefWindow(NULL), + fFindPanel(NULL), + fSavedFrame(0, 0, -1, -1), + fFindString(""), + fFindForwardMenuItem(NULL), + fFindBackwardMenuItem(NULL), + fFindSelection(false), + fForwardSearch(false), + fMatchCase(false), + fMatchWord(false) { fTabView = new SmartTabView(Bounds(), "Tab view"); AddChild(fTabView); @@ -61,11 +82,12 @@ _NewTab(command); _NewTab(NULL); } +#endif -#else TermWindow::TermWindow(BRect frame, const char* title, const char *command) : BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE), + fTabView(NULL), fTermView(NULL), fMenubar(NULL), fFilemenu(NULL), @@ -147,8 +169,9 @@ // Initialize TermView. (font, size and color) fTermView->SetTermFont(&halfFont, &fullFont); + _SetTermColors(); BRect rect = fTermView->SetTermSize(PrefHandler::Default()->getInt32(PREF_ROWS), - PrefHandler::Default()->getInt32(PREF_COLS), true); + PrefHandler::Default()->getInt32(PREF_COLS), true); int width, height; fTermView->GetFontSize(&width, &height); @@ -491,7 +514,7 @@ break; } case MSG_COLOR_CHANGED: { - fTermView->SetTermColor(); + _SetTermColors(); fTermView->Invalidate(); break; } @@ -537,6 +560,20 @@ } +void +TermWindow::_SetTermColors() +{ + fTermView->SetTextColor(PrefHandler::Default()->getRGB(PREF_TEXT_FORE_COLOR), + PrefHandler::Default()->getRGB(PREF_TEXT_BACK_COLOR)); + + fTermView->SetSelectColor(PrefHandler::Default()->getRGB(PREF_SELECT_FORE_COLOR), + PrefHandler::Default()->getRGB(PREF_SELECT_BACK_COLOR)); + + fTermView->SetCursorColor(PrefHandler::Default()->getRGB(PREF_CURSOR_FORE_COLOR), + PrefHandler::Default()->getRGB(PREF_CURSOR_BACK_COLOR)); +} + + status_t TermWindow::_DoPageSetup() { @@ -595,8 +632,8 @@ job.CommitJob(); } -#endif + void TermWindow::_NewTab(const char *command) { Modified: haiku/trunk/src/apps/terminal/TermWindow.h =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-28 07:17:23 UTC (rev 21727) +++ haiku/trunk/src/apps/terminal/TermWindow.h 2007-07-28 14:49:39 UTC (rev 21728) @@ -54,6 +54,7 @@ private: + void _SetTermColors(); void _InitWindow(const char *command); void _SetupMenu(); status_t _DoPageSetup(); From bonefish at mail.berlios.de Sat Jul 28 16:56:02 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 28 Jul 2007 16:56:02 +0200 Subject: [Haiku-commits] r21729 - in haiku/trunk: headers/private/storage src/kits/storage Message-ID: <200707281456.l6SEu2t4012562@sheep.berlios.de> Author: bonefish Date: 2007-07-28 16:56:02 +0200 (Sat, 28 Jul 2007) New Revision: 21729 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21729&view=rev Modified: haiku/trunk/headers/private/storage/DiskSystem.h haiku/trunk/src/kits/storage/DiskSystem.cpp Log: Added copy constructor and assignment operator. Modified: haiku/trunk/headers/private/storage/DiskSystem.h =================================================================== --- haiku/trunk/headers/private/storage/DiskSystem.h 2007-07-28 14:49:39 UTC (rev 21728) +++ haiku/trunk/headers/private/storage/DiskSystem.h 2007-07-28 14:56:02 UTC (rev 21729) @@ -15,6 +15,7 @@ class BDiskSystem { public: BDiskSystem(); + BDiskSystem(const BDiskSystem& other); ~BDiskSystem(); status_t InitCheck() const; @@ -47,6 +48,8 @@ bool IsFileSystem() const; bool IsSubSystemFor(BPartition *parent) const; + BDiskSystem& operator=(const BDiskSystem& other); + private: status_t _SetTo(disk_system_id id); status_t _SetTo(user_disk_system_info *info); Modified: haiku/trunk/src/kits/storage/DiskSystem.cpp =================================================================== --- haiku/trunk/src/kits/storage/DiskSystem.cpp 2007-07-28 14:49:39 UTC (rev 21728) +++ haiku/trunk/src/kits/storage/DiskSystem.cpp 2007-07-28 14:56:02 UTC (rev 21729) @@ -18,6 +18,15 @@ { } +// copy constructor +BDiskSystem::BDiskSystem(const BDiskSystem& other) + : fID(other.fID), + fName(other.fName), + fPrettyName(other.fPrettyName), + fFlags(other.fFlags) +{ +} + // destructor BDiskSystem::~BDiskSystem() { @@ -267,6 +276,18 @@ parent->_ChangeCounter())); } +// = +BDiskSystem& +BDiskSystem::operator=(const BDiskSystem& other) +{ + fID = other.fID; + fName = other.fName; + fPrettyName = other.fPrettyName; + fFlags = other.fFlags; + + return *this; +} + // _SetTo status_t BDiskSystem::_SetTo(disk_system_id id) From bonefish at mail.berlios.de Sat Jul 28 16:57:12 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 28 Jul 2007 16:57:12 +0200 Subject: [Haiku-commits] r21730 - in haiku/trunk/src/tests/apps: . partitioner Message-ID: <200707281457.l6SEvCwg012627@sheep.berlios.de> Author: bonefish Date: 2007-07-28 16:57:12 +0200 (Sat, 28 Jul 2007) New Revision: 21730 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21730&view=rev Added: haiku/trunk/src/tests/apps/partitioner/ haiku/trunk/src/tests/apps/partitioner/Jamfile haiku/trunk/src/tests/apps/partitioner/Partitioner.cpp Modified: haiku/trunk/src/tests/apps/Jamfile Log: Beginnings of a little test partitioning tool. Modified: haiku/trunk/src/tests/apps/Jamfile =================================================================== --- haiku/trunk/src/tests/apps/Jamfile 2007-07-28 14:56:02 UTC (rev 21729) +++ haiku/trunk/src/tests/apps/Jamfile 2007-07-28 14:57:12 UTC (rev 21730) @@ -1,5 +1,7 @@ SubDir HAIKU_TOP src tests apps ; -SubInclude HAIKU_TOP src tests apps miniterminal ; SubInclude HAIKU_TOP src tests apps fake_app_server ; SubInclude HAIKU_TOP src tests apps installer ; +SubInclude HAIKU_TOP src tests apps miniterminal ; +SubInclude HAIKU_TOP src tests apps partitioner ; + Added: haiku/trunk/src/tests/apps/partitioner/Jamfile =================================================================== --- haiku/trunk/src/tests/apps/partitioner/Jamfile 2007-07-28 14:56:02 UTC (rev 21729) +++ haiku/trunk/src/tests/apps/partitioner/Jamfile 2007-07-28 14:57:12 UTC (rev 21730) @@ -0,0 +1,10 @@ +SubDir HAIKU_TOP src tests apps partitioner ; + +UsePrivateHeaders shared ; +UsePrivateHeaders storage ; + +SimpleTest Partitioner : + Partitioner.cpp + + : be +; Added: haiku/trunk/src/tests/apps/partitioner/Partitioner.cpp =================================================================== --- haiku/trunk/src/tests/apps/partitioner/Partitioner.cpp 2007-07-28 14:56:02 UTC (rev 21729) +++ haiku/trunk/src/tests/apps/partitioner/Partitioner.cpp 2007-07-28 14:57:12 UTC (rev 21730) @@ -0,0 +1,661 @@ +/* + * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + + +extern "C" const char* __progname; +static const char* kProgramName = __progname; + +static const char* kUsage = +"Usage: %s \n" +"\n" +"Options:\n" +" -h, --help - print this help text\n" +; + + +static void +print_usage(bool error) +{ + fprintf(error ? stderr : stdout, kUsage, kProgramName); +} + + +static void +print_usage_and_exit(bool error) +{ + print_usage(error); + exit(error ? 1 : 0); +} + + +static void +get_size_string(off_t _size, BString& string) +{ + const char* suffixes[] = { + "", "K", "M", "G", "T", NULL + }; + + double size = _size; + int index = 0; + while (size > 1024 && suffixes[index + 1]) { + size /= 1024; + index++; + } + + char buffer[128]; + snprintf(buffer, sizeof(buffer), "%.2f%s", size, suffixes[index]); + + string = buffer; +} + + +// PrintLongVisitor +class PrintLongVisitor : public BDiskDeviceVisitor { +public: + virtual bool Visit(BDiskDevice *device) + { + BPath path; + status_t error = device->GetPath(&path); + const char *pathString = NULL; + if (error == B_OK) + pathString = path.Path(); + else + pathString = strerror(error); + printf("device %ld: \"%s\"\n", device->ID(), pathString); + printf(" has media: %d\n", device->HasMedia()); + printf(" removable: %d\n", device->IsRemovableMedia()); + printf(" read only: %d\n", device->IsReadOnlyMedia()); + printf(" write once: %d\n", device->IsWriteOnceMedia()); + printf(" ---\n"); + Visit(device, 0); + return false; + } + + virtual bool Visit(BPartition *partition, int32 level) + { + char prefix[128]; + sprintf(prefix, "%*s", 2 * (int)level, ""); + if (level > 0) { + BPath path; + status_t error = partition->GetPath(&path); + const char *pathString = NULL; + if (error == B_OK) + pathString = path.Path(); + else + pathString = strerror(error); + printf("%spartition %ld: \"%s\"\n", prefix, partition->ID(), + pathString); + } + printf("%s offset: %lld\n", prefix, partition->Offset()); + printf("%s size: %lld\n", prefix, partition->Size()); + printf("%s block size: %lu\n", prefix, partition->BlockSize()); + printf("%s index: %ld\n", prefix, partition->Index()); + printf("%s status: %lu\n", prefix, partition->Status()); + printf("%s file system: %d\n", prefix, + partition->ContainsFileSystem()); + printf("%s part. system: %d\n", prefix, + partition->ContainsPartitioningSystem()); + printf("%s device: %d\n", prefix, partition->IsDevice()); + printf("%s read only: %d\n", prefix, partition->IsReadOnly()); + printf("%s mounted: %d\n", prefix, partition->IsMounted()); + printf("%s flags: %lx\n", prefix, partition->Flags()); + printf("%s name: `%s'\n", prefix, partition->Name()); + printf("%s content name: \"%s\"\n", prefix, + partition->ContentName()); + printf("%s type: \"%s\"\n", prefix, partition->Type()); + printf("%s content type: \"%s\"\n", prefix, + partition->ContentType()); + // volume, icon,... + return false; + } +}; + + +static void +print_partition_table_header() +{ + printf(" Index Start Size Content Type " + "Content Name\n"); + printf("--------------------------------------------------------------" + "------------\n"); +} + + +static void +print_partition(BPartition* partition, int level, int index) +{ + BString offset, size; + get_size_string(partition->Offset(), offset); + get_size_string(partition->Size(), size); + + printf("%*s%02d%*s %8s %8s %26.26s %16.16s\n", 2 * level, "", + index, + 2 * max_c(3 - level, 0), "", + offset.String(), size.String(), + (partition->ContentType() ? partition->ContentType() : "-"), + (partition->ContentName() ? partition->ContentName() : "")); +} + + +// PrintShortVisitor +class PrintShortVisitor : public BDiskDeviceVisitor { +public: + virtual bool Visit(BDiskDevice* device) + { + fIndex = 0; + + // get path + BPath path; + status_t error = device->GetPath(&path); + const char *pathString = NULL; + if (error == B_OK) + pathString = path.Path(); + else + pathString = strerror(error); + + // check media present; if so which read/write abilities + const char* media; + const char* readWrite; + if (device->HasMedia()) { + if (device->IsRemovableMedia()) { + media = "removable media"; + } else { + media = "fixed media"; + } + + if (device->IsReadOnlyMedia()) { + if (device->IsWriteOnceMedia()) + readWrite = ", write once"; + else + readWrite = ", read-only"; + } else + readWrite = ", read/write"; + } else { + media = "no media"; + readWrite = ""; + } + + printf("\ndevice %ld: \"%s\": %s%s\n\n", device->ID(), pathString, + media, readWrite); + print_partition_table_header(); + + Visit(device, 0); + return false; + } + + virtual bool Visit(BPartition* partition, int32 level) + { + print_partition(partition, level, fIndex++); + return false; + } + +private: + int fIndex; +}; + + +// FindPartitionByIndexVisitor +class FindPartitionByIndexVisitor : public BDiskDeviceVisitor { +public: + FindPartitionByIndexVisitor(int index) + : fIndex(index) + { + } + + virtual bool Visit(BDiskDevice *device) + { + return Visit(device, 0); + } + + virtual bool Visit(BPartition *partition, int32 level) + { + return (fIndex-- == 0); + } + +private: + int fIndex; +}; + + +// Partitioner +class Partitioner { +public: + Partitioner(BDiskDevice* device) + : fDevice(device), + fPrepared(false) + { + } + + void Run() + { + // prepare device modifications + if (fDevice->IsReadOnly()) { + printf("Device is read-only. Can't change anything.\n"); + } else { + status_t error = fDevice->PrepareModifications(); + fPrepared = (error == B_OK); + if (error != B_OK) { + printf("Error: Failed to prepare device for modifications: " + "%s\n", strerror(error)); + } + } + + // main input loop + while (true) { + BString line; + if (!_ReadLine("> ", line)) + return; + + if (line == "") { + // do nothing + } else if (line == "h" || line == "help") { + _PrintHelp(); + } else if (line == "i") { + _InitializePartition(); + } else if (line == "l") { + _PrintPartitionsShort(); + } else if (line == "ll") { + _PrintPartitionsLong(); + } else if (line == "n") { + _NewPartition(); + } else if (line == "q" || line == "quit") { + return; + } else if (line == "w") { + _WriteChanges(); + } else { + printf("Invalid command \"%s\", type \"help\" for help\n", + line.String()); + } + } + } + +private: + void _PrintHelp() + { + printf("Valid commands:\n" + " h, help - prints this help text\n" + " i - initialize a partition\n" + " l - lists the device's partitions recursively\n" + " ll - lists the device's partitions recursively, long " + "format\n" + " l - create a new child partition\n" + " q, quit - quits the program, changes are discarded\n" + " w - write changes to disk\n"); + } + + void _PrintPartitionsShort() + { + PrintShortVisitor visitor; + fDevice->VisitEachDescendant(&visitor); + } + + void _PrintPartitionsLong() + { + PrintLongVisitor visitor; + fDevice->VisitEachDescendant(&visitor); + } + + void _InitializePartition() + { + if (!fPrepared) { + if (fDevice->IsReadOnly()) + printf("Device is read-only!\n"); + else + printf("Sorry, not prepared for modifications!\n"); + return; + } + + // get the partition + int32 partitionIndex; + BPartition* partition = NULL; + if (!_SelectPartition("partition index [-1 to abort]: ", partition, + partitionIndex)) { + return; + } + + printf("\nselected partition:\n\n"); + print_partition_table_header(); + print_partition(partition, 0, partitionIndex); + + // get available disk systems + BObjectList diskSystems(20, true); + BDiskDeviceRoster roster; + { + BDiskSystem diskSystem; + while (roster.GetNextDiskSystem(&diskSystem) == B_OK) { + if (partition->CanInitialize(diskSystem.Name())) + diskSystems.AddItem(new BDiskSystem(diskSystem)); + } + } + + if (diskSystems.IsEmpty()) { + printf("There are no disk systems, that can initialize this " + "partition.\n"); + return; + } + + // print the available disk systems + printf("\ndisk systems that can initialize the selected partition:\n"); + for (int32 i = 0; BDiskSystem* diskSystem = diskSystems.ItemAt(i); i++) + printf("%2ld %s\n", i, diskSystem->Name()); + + printf("\n"); + + // get the disk system + BDiskSystem* diskSystem = NULL; + int64 diskSystemIndex; + do { + _ReadNumber("disk system index [-1 to abort]: ", diskSystemIndex); + if (diskSystemIndex < 0) + return; + + diskSystem = diskSystems.ItemAt(diskSystemIndex); + if (!diskSystem) + printf("invalid index\n"); + } while (!diskSystem); + + BString name; + BString parameters; + while (true) { + // let the user enter name and parameters +// TODO: Obviously we should be able to check whether the disk system supports +// naming at all. + if (!_ReadLine("partition name: ", name) + || !_ReadLine("partition parameters: ", parameters)) { + return; + } + + // validate parameters + char validatedName[B_OS_NAME_LENGTH]; + strlcpy(validatedName, name.String(), sizeof(validatedName)); + if (partition->ValidateInitialize(diskSystem->Name(), validatedName, + parameters.String()) != B_OK) { + printf("Validation of the given values failed. Sorry, can't " + "continue."); + return; + } + + // did the disk system change the name? + if (name == validatedName) { + printf("Everything looks dandy.\n"); + } else { + printf("The disk system adjusted the file name to \"%s\".\n", + validatedName); + name = validatedName; + } + + // let the user decide whether to continue, change parameters, or + // abort + bool changeParameters = false; + while (true) { + BString line; + _ReadLine("Everything looks dandy. [c]ontinue, change " + "[p]arameters, or [a]bort? ", line); + if (line == "a") + return; + if (line == "p") { + changeParameters = true; + break; + } + if (line == "c") + break; + + printf("invalid input\n"); + } + + if (!changeParameters) + break; + } + + // initialize + status_t error = partition->Initialize(diskSystem->Name(), + name.String(), parameters.String()); + if (error != B_OK) + printf("Initialization failed: %s\n", strerror(error)); + } + + void _NewPartition() + { + if (!fPrepared) { + if (fDevice->IsReadOnly()) + printf("Device is read-only!\n"); + else + printf("Sorry, not prepared for modifications!\n"); + return; + } + + // get the parent partition + BPartition* partition = NULL; + int32 partitionIndex; + if (!_SelectPartition("parent partition index [-1 to abort]: ", + partition, partitionIndex)) { + return; + } + + printf("\nselected partition:\n\n"); + print_partition_table_header(); + print_partition(partition, 0, partitionIndex); + + if (!partition->ContainsPartitioningSystem()) { + printf("The selected partition does not contain a partitioning " + "system.\n"); + return; + } + + // get the disk system + BDiskSystem diskSystem; + status_t error = partition->GetDiskSystem(&diskSystem); + if (error != B_OK) { + printf("Failed to get disk system for partition: %s\n", + strerror(error)); + return; + } + + // get supported types + BObjectList supportedTypes(20, true); + char typeBuffer[B_OS_NAME_LENGTH]; + int32 cookie = 0; + while (diskSystem.GetNextSupportedType(partition, &cookie, typeBuffer) + == B_OK) { + supportedTypes.AddItem(new BString(typeBuffer)); + } + + if (supportedTypes.IsEmpty()) { + printf("The partitioning system is not able to create any " + "child partition (no supported types).\n"); + return; + } + + // get partitioning info + BPartitioningInfo partitioningInfo; + error = partition->GetPartitioningInfo(&partitioningInfo); + if (error != B_OK) { + printf("Failed to get partitioning info for partition: %s\n", + strerror(error)); + return; + } + + int32 spacesCount = partitioningInfo.CountPartitionableSpaces(); + if (spacesCount == 0) { + printf("There's no space on the partition where a child partition " + "could be created\n"); + return; + } + + // list partitionable spaces + printf("Unused regions where the new partition could be created:\n"); + for (int32 i = 0; i < spacesCount; i++) { + off_t _offset; + off_t _size; + partitioningInfo.GetPartitionableSpaceAt(i, &_offset, &_size); + BString offset, size; + get_size_string(_offset, offset); + get_size_string(_size, size); + printf("%2ld start: %8s, size: %8s", i, offset.String(), + size.String()); + } + + // TODO:... + } + + void _WriteChanges() + { + if (!fPrepared || !fDevice->IsModified()) { + printf("No changes have been made!\n"); + return; + } + + printf("Writing changes to disk. This can take a while...\n"); + + // commit + status_t error = fDevice->CommitModifications(); + if (error == B_OK) { + printf("All changes have been written successfully!\n"); + } else { + printf("Failed to write all changes: %s\n", strerror(error)); + } + + // prepare again + error = fDevice->PrepareModifications(); + fPrepared = (error == B_OK); + if (error != B_OK) { + printf("Error: Failed to prepare device for modifications: " + "%s\n", strerror(error)); + } + } + + bool _SelectPartition(const char* prompt, BPartition*& partition, + int32& _partitionIndex) + { + // if the disk device has no children, we select it without asking + if (fDevice->CountChildren() == 0) { + partition = fDevice; + return true; + } + + // otherwise let the user select + partition = NULL; + int64 partitionIndex; + while (true) { + _ReadNumber(prompt, partitionIndex); + if (partitionIndex < 0) + return false; + + FindPartitionByIndexVisitor visitor(partitionIndex); + partition = fDevice->VisitEachDescendant(&visitor); + if (partition) { + _partitionIndex = partitionIndex; + return true; + } + + printf("invalid partition index\n"); + } + } + + bool _ReadLine(const char* prompt, BString& _line) + { + // prompt + printf(prompt); + fflush(stdout); + + // read line + char line[256]; + if (!fgets(line, sizeof(line), stdin)) + return false; + + // remove trailing '\n' + if (char* trailingNL = strchr(line, '\n')) + *trailingNL = '\0'; + + _line = line; + return true; + } + + bool _ReadNumber(const char* prompt, int64& number) + { + while (true) { + BString line; + if (!_ReadLine(prompt, line)) + return false; + + char buffer[256]; + if (sscanf(line.String(), "%lld%s", &number, buffer) == 1) + return true; + + printf("invalid input\n"); + } + } + +private: + BDiskDevice* fDevice; + bool fPrepared; +}; + + +int +main(int argc, const char* const* argv) +{ + // parse arguments + int argi = 1; + for (; argi < argc; argi++) { + const char* arg = argv[argi]; + if (arg[0] == '-') { + if (arg[1] == '-') { + // a double '-' option + if (strcmp(arg, "--help") == 0) { + print_usage_and_exit(false); + } else + print_usage_and_exit(true); + } else { + // single '-' options + for (int i = 1; arg[i] != '\0'; i++) { + switch (arg[i]) { + case 'h': + print_usage_and_exit(false); + default: + print_usage_and_exit(true); + } + } + } + } else + break; + } + + // only the device path should remain + if (argi != argc - 1) + print_usage_and_exit(true); + const char* devicePath = argv[argi]; + + // get the disk device + BDiskDeviceRoster roster; + BDiskDevice device; + status_t error = roster.GetDeviceForPath(devicePath, &device); + if (error != B_OK) { + fprintf(stderr, "Error: Failed to get disk device for path \"%s\": " + "%s\n", devicePath, strerror(error)); + } + + Partitioner partitioner(&device); + partitioner.Run(); + + return 0; +} From marcusoverhagen at mail.berlios.de Sun Jul 29 00:36:09 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sun, 29 Jul 2007 00:36:09 +0200 Subject: [Haiku-commits] r21731 - haiku/trunk/src/system/kernel/util Message-ID: <200707282236.l6SMa96H031270@sheep.berlios.de> Author: marcusoverhagen Date: 2007-07-29 00:36:02 +0200 (Sun, 29 Jul 2007) New Revision: 21731 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21731&view=rev Modified: haiku/trunk/src/system/kernel/util/kernel_cpp.cpp Log: Build fix for GCC 4 Modified: haiku/trunk/src/system/kernel/util/kernel_cpp.cpp =================================================================== --- haiku/trunk/src/system/kernel/util/kernel_cpp.cpp 2007-07-28 14:57:12 UTC (rev 21730) +++ haiku/trunk/src/system/kernel/util/kernel_cpp.cpp 2007-07-28 22:36:02 UTC (rev 21731) @@ -31,7 +31,11 @@ // ... it doesn't seem to work with this symbol at least. #ifndef USING_LIBGCC +# if __GNUC__ >= 3 +const std::nothrow_t std::nothrow = {}; +# else const nothrow_t std::nothrow = {}; +# endif #endif #if __GNUC__ == 2 @@ -92,6 +96,7 @@ return 0; } +#ifndef _LOADER_MODE extern "C" int printf(const char *format, ...) @@ -100,6 +105,7 @@ dprintf("printf(`%s',...)\n", format); return 0; } +#endif extern "C" int From marcusoverhagen at mail.berlios.de Sun Jul 29 02:24:57 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sun, 29 Jul 2007 02:24:57 +0200 Subject: [Haiku-commits] r21732 - haiku/trunk/src/system/kernel Message-ID: <200707290024.l6T0Ovhx009249@sheep.berlios.de> Author: marcusoverhagen Date: 2007-07-29 02:24:54 +0200 (Sun, 29 Jul 2007) New Revision: 21732 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21732&view=rev Modified: haiku/trunk/src/system/kernel/thread.c Log: kernel debugger support for suspending a thread Modified: haiku/trunk/src/system/kernel/thread.c =================================================================== --- haiku/trunk/src/system/kernel/thread.c 2007-07-28 22:36:02 UTC (rev 21731) +++ haiku/trunk/src/system/kernel/thread.c 2007-07-29 00:24:54 UTC (rev 21732) @@ -528,6 +528,38 @@ } +static int +make_thread_suspended(int argc, char **argv) +{ + struct thread *thread; + struct hash_iterator i; + int32 id; + + if (argc != 2) { + kprintf("usage: suspend [thread-id]\n"); + return 0; + } + + id = strtoul(argv[1], NULL, 0); + + hash_open(sThreadHash, &i); + + while ((thread = hash_next(sThreadHash, &i)) != NULL) { + if (thread->id != id) + continue; + + thread->state = thread->next_state = B_THREAD_SUSPENDED; + kprintf("thread 0x%lx suspended\n", thread->id); + break; + } + if (!thread) + kprintf("thread 0x%lx not found\n", thread->id); + + hash_close(sThreadHash, &i, false); + return 0; +} + + static const char * state_to_text(struct thread *thread, int32 state) { @@ -1537,6 +1569,7 @@ add_debugger_command("next_all", &dump_next_thread_in_all_list, "dump the next thread in the global list of the last thread viewed"); add_debugger_command("next_team", &dump_next_thread_in_team, "dump the next thread in the team of the last thread viewed"); add_debugger_command("unreal", &make_thread_unreal, "set realtime priority threads to normal priority"); + add_debugger_command("suspend", &make_thread_suspended, "suspend a thread"); return B_OK; } From marcusoverhagen at mail.berlios.de Sun Jul 29 02:51:38 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sun, 29 Jul 2007 02:51:38 +0200 Subject: [Haiku-commits] r21733 - haiku/trunk/src/system/kernel/messaging Message-ID: <200707290051.l6T0pcPX011431@sheep.berlios.de> Author: marcusoverhagen Date: 2007-07-29 02:51:36 +0200 (Sun, 29 Jul 2007) New Revision: 21733 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21733&view=rev Modified: haiku/trunk/src/system/kernel/messaging/Jamfile Log: build fix (rebuidling MessagingService.o wasn't possible after this jamfile was changed in r21715) Modified: haiku/trunk/src/system/kernel/messaging/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/messaging/Jamfile 2007-07-29 00:24:54 UTC (rev 21732) +++ haiku/trunk/src/system/kernel/messaging/Jamfile 2007-07-29 00:51:36 UTC (rev 21733) @@ -1,6 +1,7 @@ SubDir HAIKU_TOP src system kernel messaging ; UsePrivateHeaders [ FDirName kernel ] ; +UsePrivateHeaders [ FDirName kernel util ] ; #UsePrivateHeaders [ FDirName kernel disk_device_manager ] ; #UsePrivateHeaders [ FDirName kernel fs ] ; UsePrivateHeaders shared ; From marcusoverhagen at mail.berlios.de Sun Jul 29 03:06:37 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sun, 29 Jul 2007 03:06:37 +0200 Subject: [Haiku-commits] r21734 - haiku/trunk/src/system/kernel Message-ID: <200707290106.l6T16biD012488@sheep.berlios.de> Author: marcusoverhagen Date: 2007-07-29 03:06:36 +0200 (Sun, 29 Jul 2007) New Revision: 21734 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21734&view=rev Modified: haiku/trunk/src/system/kernel/thread.c Log: Added "suspend", "resume" and "drop" commands to kernel debugger. It's now possible to debug amok-running user threads by suspending or resuming them, as well as dropping them into the userland-debugger from inside kdl. Modified: haiku/trunk/src/system/kernel/thread.c =================================================================== --- haiku/trunk/src/system/kernel/thread.c 2007-07-29 00:51:36 UTC (rev 21733) +++ haiku/trunk/src/system/kernel/thread.c 2007-07-29 01:06:36 UTC (rev 21734) @@ -535,12 +535,15 @@ struct hash_iterator i; int32 id; - if (argc != 2) { + if (argc > 2) { kprintf("usage: suspend [thread-id]\n"); return 0; } - id = strtoul(argv[1], NULL, 0); + if (argc == 1) + id = thread_get_current_thread()->id; + else + id = strtoul(argv[1], NULL, 0); hash_open(sThreadHash, &i); @@ -549,17 +552,80 @@ continue; thread->state = thread->next_state = B_THREAD_SUSPENDED; - kprintf("thread 0x%lx suspended\n", thread->id); + kprintf("thread 0x%lx suspended\n", id); break; } if (!thread) - kprintf("thread 0x%lx not found\n", thread->id); + kprintf("thread 0x%lx not found\n", id); hash_close(sThreadHash, &i, false); return 0; } +static int +make_thread_resumed(int argc, char **argv) +{ + struct thread *thread; + struct hash_iterator i; + int32 id; + + if (argc != 2) { + kprintf("usage: resume \n"); + return 0; + } + + // force user to enter a thread id, as using + // the current thread is usually not intended + id = strtoul(argv[1], NULL, 0); + + hash_open(sThreadHash, &i); + + while ((thread = hash_next(sThreadHash, &i)) != NULL) { + if (thread->id != id) + continue; + + if (thread->state == B_THREAD_SUSPENDED) { + thread->state = thread->next_state = B_THREAD_READY; + scheduler_enqueue_in_run_queue(thread); + kprintf("thread 0x%lx resumed\n", thread->id); + } + break; + } + if (!thread) + kprintf("thread 0x%lx not found\n", id); + + hash_close(sThreadHash, &i, false); + return 0; +} + + +static int +drop_into_debugger(int argc, char **argv) +{ + status_t err; + int32 id; + + if (argc > 2) { + kprintf("usage: drop [thread-id]\n"); + return 0; + } + + if (argc == 1) + id = thread_get_current_thread()->id; + else + id = strtoul(argv[1], NULL, 0); + + err = _user_debug_thread(id); + if (err) + kprintf("drop failed\n"); + else + kprintf("thread 0x%lx dropped into user debugger\n", id); + + return 0; +} + + static const char * state_to_text(struct thread *thread, int32 state) { @@ -1570,6 +1636,8 @@ add_debugger_command("next_team", &dump_next_thread_in_team, "dump the next thread in the team of the last thread viewed"); add_debugger_command("unreal", &make_thread_unreal, "set realtime priority threads to normal priority"); add_debugger_command("suspend", &make_thread_suspended, "suspend a thread"); + add_debugger_command("resume", &make_thread_resumed, "resume a thread"); + add_debugger_command("drop", &drop_into_debugger, "drop a thread into the user-debugger"); return B_OK; } From bonefish at mail.berlios.de Sun Jul 29 03:09:41 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 29 Jul 2007 03:09:41 +0200 Subject: [Haiku-commits] r21735 - haiku/trunk/src/add-ons/kernel/drivers/tty Message-ID: <200707290109.l6T19fIw012641@sheep.berlios.de> Author: bonefish Date: 2007-07-29 03:09:39 +0200 (Sun, 29 Jul 2007) New Revision: 21735 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21735&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/driver.cpp haiku/trunk/src/add-ons/kernel/drivers/tty/line_buffer.cpp haiku/trunk/src/add-ons/kernel/drivers/tty/line_buffer.h haiku/trunk/src/add-ons/kernel/drivers/tty/master.cpp haiku/trunk/src/add-ons/kernel/drivers/tty/slave.cpp haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h Log: * Moved members pgrp_id, termios, window_size from the tty structure to the new structure tty_settings of which there's only one instance per master/slave tty pair. Previously the existence of two instances of those members caused several kinds of problems, e.g. the Terminal setting the window size on the master and CLI programs readings the unchanged values from the slave. E.g. less correctly adjusts the display when the Terminal size changes, now. * Reorganized writing to a TTY. We do no longer handle writes to master and slave the same way. Writes to the master are "input" and need to be processed differently from writes to the slave ("output"). Before, both were processed first as output then as input, which caused incorrect behavior. E.g. CRs were not echoed correctly. * Added canonical ERASE (backspace) and KILL (clear line) processing. Couldn't really see it work. glibc's fgets() seems to read single chars, so that we never have anything in the line buffer. * Added handling for EOF. Works well with Be's Terminal, ours seems to write an ESC sequence instead of the EOF char (Ctrl-D), though. * Extended output processing support (ECHOE, ECHOK, ECHONL, OCRNL, ONLRET, OLCUC). * Writes use user_memcpy() now. Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/driver.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/tty/driver.cpp 2007-07-29 01:06:36 UTC (rev 21734) +++ haiku/trunk/src/add-ons/kernel/drivers/tty/driver.cpp 2007-07-29 01:09:39 UTC (rev 21735) @@ -102,8 +102,9 @@ if (++digit > 15) digit = 0, letter++; - reset_tty(&gMasterTTYs[i], i); - reset_tty(&gSlaveTTYs[i], i); + reset_tty(&gMasterTTYs[i], i, true); + reset_tty(&gSlaveTTYs[i], i, false); + reset_tty_settings(&gTTYSettings[i], i); if (!sDeviceNames[i] || !sDeviceNames[i + kNumTTYs]) { uninit_driver(); Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/line_buffer.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/tty/line_buffer.cpp 2007-07-29 01:06:36 UTC (rev 21734) +++ haiku/trunk/src/add-ons/kernel/drivers/tty/line_buffer.cpp 2007-07-29 01:09:39 UTC (rev 21735) @@ -57,7 +57,8 @@ ssize_t -line_buffer_user_read(struct line_buffer &buffer, char *data, size_t length) +line_buffer_user_read(struct line_buffer &buffer, char *data, size_t length, + char eof, bool* hitEOF) { size_t available = buffer.in; @@ -67,6 +68,19 @@ if (length == 0) return 0; + // check for EOF, if the caller asked us to + if (hitEOF) { + *hitEOF = false; + for (size_t i = 0; i < available; i++) { + char c = buffer.buffer[(buffer.first + i) % buffer.size]; + if (c == eof) { + *hitEOF = true; + length = i; + break; + } + } + } + ssize_t bytesRead = length; if (buffer.first + length < buffer.size) { @@ -88,6 +102,12 @@ buffer.in -= bytesRead; } + // dispose of EOF char + if (hitEOF && *hitEOF) { + buffer.first = (buffer.first + 1) % buffer.size; + buffer.in--; + } + return bytesRead; } @@ -116,3 +136,14 @@ } #endif + + +bool +line_buffer_tail_getc(struct line_buffer &buffer, char *c) +{ + if (buffer.in == 0) + return false; + + *c = buffer.buffer[(buffer.first + --buffer.in) % buffer.size]; + return true; +} Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/line_buffer.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/tty/line_buffer.h 2007-07-29 01:06:36 UTC (rev 21734) +++ haiku/trunk/src/add-ons/kernel/drivers/tty/line_buffer.h 2007-07-29 01:09:39 UTC (rev 21735) @@ -21,9 +21,11 @@ status_t clear_line_buffer(struct line_buffer &buffer); int32 line_buffer_readable(struct line_buffer &buffer); int32 line_buffer_writable(struct line_buffer &buffer); -ssize_t line_buffer_user_read(struct line_buffer &buffer, char *data, size_t length); +ssize_t line_buffer_user_read(struct line_buffer &buffer, char *data, + size_t length, char eof = 0, bool* hitEOF = NULL); status_t line_buffer_getc(struct line_buffer &buffer, char *_c); status_t line_buffer_putc(struct line_buffer &buffer, char c); status_t line_buffer_ungetc(struct line_buffer &buffer, char *c); +bool line_buffer_tail_getc(struct line_buffer &buffer, char *c); #endif /* LINE_BUFFER_H */ Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/master.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/tty/master.cpp 2007-07-29 01:06:36 UTC (rev 21734) +++ haiku/trunk/src/add-ons/kernel/drivers/tty/master.cpp 2007-07-29 01:09:39 UTC (rev 21735) @@ -173,7 +173,7 @@ TRACE(("master_write: cookie %p, offset %Ld, buffer %p, length %lu\n", _cookie, offset, buffer, *_length)); - status_t result = tty_write_to_tty(cookie, buffer, _length, true); + status_t result = tty_write_to_tty_master(cookie, buffer, _length); TRACE(("master_write done: cookie %p, result: %lx, length %lu\n", _cookie, result, *_length)); Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/slave.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/tty/slave.cpp 2007-07-29 01:06:36 UTC (rev 21734) +++ haiku/trunk/src/add-ons/kernel/drivers/tty/slave.cpp 2007-07-29 01:09:39 UTC (rev 21735) @@ -146,7 +146,7 @@ TRACE(("slave_write: cookie %p, offset %Ld, buffer %p, length %lu\n", _cookie, offset, buffer, *_length)); - status_t result = tty_write_to_tty(cookie, buffer, _length, false); + status_t result = tty_write_to_tty_slave(cookie, buffer, _length); TRACE(("slave_write done: cookie %p, result %lx, length %lu\n", _cookie, result, *_length)); Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp 2007-07-29 01:06:36 UTC (rev 21734) +++ haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp 2007-07-29 01:09:39 UTC (rev 21735) @@ -1,4 +1,5 @@ /* + * Copyright 2007, Ingo Weinhold, bonefish at cs.tu-berlin.de. All rights reserved. * Copyright 2004-2006, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -8,11 +9,13 @@ // tailored for pseudo-TTYs. Have a look at Be's TTY includes (drivers/tty/*) -#include -#include +#include #include #include +#include +#include + #include "SemaphorePool.h" #include "tty_private.h" @@ -45,13 +48,13 @@ operations are done at a certain point when closing a cookie (cf. tty_close_cookie() and TTYReference). - tty::lock: Guards the access to tty::{input_buffer,termios,window_size, - pgrp_id}. Moreover when held guarantees that tty::open_count won't drop - to zero (both gGlobalTTYLock and tty::lock must be held to decrement - it). A tty and the tty connected to it (master and slave) share the same - lock. tty::lock is only valid when tty::open_count is > 0. So before - accessing tty::lock, it must be made sure that it is still valid. Given - a tty_cookie, TTYReference can be used to do that, or otherwise + tty::lock: Guards the access to tty::{input_buffer,settings::{termios, + window_size,pgrp_id}}. Moreover when held guarantees that tty::open_count + won't drop to zero (both gGlobalTTYLock and tty::lock must be held to + decrement it). A tty and the tty connected to it (master and slave) share + the same lock. tty::lock is only valid when tty::open_count is > 0. So + before accessing tty::lock, it must be made sure that it is still valid. + Given a tty_cookie, TTYReference can be used to do that, or otherwise gGlobalTTYLock can be acquired and tty::open_count be checked. gTTYRequestLock: Guards access to tty::{reader,writer}_queue (most @@ -79,6 +82,9 @@ */ +tty_settings gTTYSettings[kNumTTYs]; + + static void tty_notify_select_event(struct tty *tty, uint8 event); static void tty_notify_if_available(struct tty *tty, struct tty *otherTTY, bool notifySelect); @@ -252,6 +258,7 @@ first->Notify(bytesAvailable); } + void RequestQueue::NotifyError(status_t error) { @@ -263,6 +270,7 @@ } } + void RequestQueue::NotifyError(tty_cookie *cookie, status_t error) { @@ -369,7 +377,7 @@ // check, if already done if (fError == B_OK - && (!fRequests[0].WasNotified() || !fRequests[0].WasNotified())) { + && (!fRequests[0].WasNotified() || !fRequests[1].WasNotified())) { // not yet done // set the semaphore @@ -478,7 +486,8 @@ // tty_close_cookie() pseudo request). // get the echo mode - fEcho = (fTarget->termios.c_lflag & ECHO) != 0; + fEcho = (fSource->is_master + && fSource->settings->termios.c_lflag & ECHO) != 0; // enqueue ourselves in the respective request queues RecursiveLocker locker(gTTYRequestLock); @@ -542,7 +551,7 @@ return B_OK; } - // We are not the first in queue or currently there's nothing to read: + // We are not the first in queue or currently there's no space to write: // bail out, if we shall not block. if (dontBlock) return B_WOULD_BLOCK; @@ -665,7 +674,7 @@ } -void +static void reset_termios(struct termios &termios) { memset(&termios, 0, sizeof(struct termios)); @@ -682,6 +691,8 @@ termios.c_cc[VERASE] = CTRL('H'); termios.c_cc[VKILL] = CTRL('U'); termios.c_cc[VEOF] = CTRL('D'); + termios.c_cc[VEOL] = '\0'; + termios.c_cc[VEOL2] = '\0'; termios.c_cc[VSTART] = CTRL('S'); termios.c_cc[VSTOP] = CTRL('Q'); termios.c_cc[VSUSP] = CTRL('Z'); @@ -689,25 +700,33 @@ void -reset_tty(struct tty *tty, int32 index) +reset_tty_settings(tty_settings *settings, int32 index) { - reset_termios(tty->termios); + reset_termios(settings->termios); - tty->open_count = 0; - tty->index = index; - tty->lock = NULL; - - tty->pgrp_id = 0; + settings->pgrp_id = 0; // this value prevents any signal of being sent // some initial window size - the TTY in question should set these values - tty->window_size.ws_col = 80; - tty->window_size.ws_row = 25; - tty->window_size.ws_xpixel = tty->window_size.ws_col * 8; - tty->window_size.ws_ypixel = tty->window_size.ws_row * 8; + settings->window_size.ws_col = 80; + settings->window_size.ws_row = 25; + settings->window_size.ws_xpixel = settings->window_size.ws_col * 8; + settings->window_size.ws_ypixel = settings->window_size.ws_row * 8; } +void +reset_tty(struct tty *tty, int32 index, bool isMaster) +{ + tty->open_count = 0; + tty->index = index; + tty->lock = NULL; + tty->settings = &gTTYSettings[index]; + tty->is_master = isMaster; + tty->pending_eof = 0; +} + + status_t tty_output_getc(struct tty *tty, int *_c) { @@ -719,64 +738,76 @@ * Depending on the termios flags set, signals may be sent, the input * character changed or removed, etc. */ - static void tty_input_putc_locked(struct tty *tty, int c) { - tcflag_t flags = tty->termios.c_iflag; - // process signals if needed - if ((tty->termios.c_lflag & ISIG) != 0) { + if ((tty->settings->termios.c_lflag & ISIG) != 0) { // enable signals, process INTR, QUIT, and SUSP int signal = -1; - if (c == tty->termios.c_cc[VINTR]) + if (c == tty->settings->termios.c_cc[VINTR]) signal = SIGINT; - else if (c == tty->termios.c_cc[VQUIT]) + else if (c == tty->settings->termios.c_cc[VQUIT]) signal = SIGQUIT; - else if (c == tty->termios.c_cc[VSUSP]) + else if (c == tty->settings->termios.c_cc[VSUSP]) // ToDo: what to do here? signal = -1; // do we need to deliver a signal? if (signal != -1) { // we may have to flush the input buffer - if ((tty->termios.c_lflag & NOFLSH) == 0) + if ((tty->settings->termios.c_lflag & NOFLSH) == 0) clear_line_buffer(tty->input_buffer); - if (tty->pgrp_id != 0) - send_signal(-tty->pgrp_id, signal); + if (tty->settings->pgrp_id != 0) + send_signal(-tty->settings->pgrp_id, signal); return; } } // process special canonical input characters - if ((tty->termios.c_lflag & ICANON) != 0) { + if ((tty->settings->termios.c_lflag & ICANON) != 0) { // canonical mode, process ERASE and KILL - if (c == tty->termios.c_cc[VERASE]) { - // ToDo: erase one character + cc_t* controlChars = tty->settings->termios.c_cc; + + if (c == controlChars[VERASE]) { + // erase one character + char lastChar; + if (line_buffer_tail_getc(tty->input_buffer, &lastChar)) { + if (lastChar == controlChars[VEOF] + || lastChar == controlChars[VEOL] + || lastChar == '\n' || lastChar == '\r') { + // EOF or end of line -- put it back + line_buffer_putc(tty->input_buffer, lastChar); + } + } return; - } else if (c == tty->termios.c_cc[VKILL]) { - // ToDo: erase line + } else if (c == controlChars[VKILL]) { + // erase line + char lastChar; + while (line_buffer_tail_getc(tty->input_buffer, &lastChar)) { + if (lastChar == controlChars[VEOF] + || lastChar == controlChars[VEOL] + || lastChar == '\n' || lastChar == '\r') { + // EOF or end of line -- put it back + line_buffer_putc(tty->input_buffer, lastChar); + break; + } + } return; + } else if (c == controlChars[VEOF]) { + // we still write the EOF to the stream -- tty_input_read() needs + // to recognize it + tty->pending_eof++; } } - // character conversions + // Input character conversions have already been done. What reaches this + // point can directly be written to the line buffer. - if (c == '\n' && (flags & INLCR) != 0) { - // map NL to CR - c = '\r'; - } else if (c == '\r') { - if (flags & IGNCR) // ignore CR - return; - if (flags & ICRNL) // map CR to NL - c = '\n'; - } if (flags & ISTRIP) // strip the highest bit - c &= 0x7f; - line_buffer_putc(tty->input_buffer, c); } @@ -1033,6 +1064,130 @@ } +/*! + \brief Performs input character conversion and writes the result to + \a buffer. + \param tty The master tty. + \param c The input character. + \param buffer The buffer to which to write the converted character. + \param _bytesNeeded The number of bytes needed in the target tty's + line buffer. + \return \c true, if the character shall be processed further, \c false, if + it shall be skipped. +*/ +static bool +process_input_char(struct tty* tty, char c, char* buffer, + size_t* _bytesNeeded) +{ + tcflag_t flags = tty->settings->termios.c_iflag; + + // signals + if (tty->settings->termios.c_lflag & ISIG) { + if (c == tty->settings->termios.c_cc[VINTR] + || c == tty->settings->termios.c_cc[VQUIT] + || c == tty->settings->termios.c_cc[VSUSP]) { + *buffer = c; + *_bytesNeeded = 0; + return true; + } + } + + // canonical input characters + if (tty->settings->termios.c_lflag & ICANON) { + if (c == tty->settings->termios.c_cc[VERASE] + || c == tty->settings->termios.c_cc[VKILL]) { + *buffer = c; + *_bytesNeeded = 0; + return true; + } + } + + // convert chars + if (c == '\r') { + if (flags & IGNCR) // ignore CR + return false; + if (flags & ICRNL) // CR -> NL + c = '\n'; + } else if (c == '\n') { + if (flags & INLCR) // NL -> CR + c = '\r'; + } else if (flags & ISTRIP) // strip of eighth bit + c &= 0x7f; + + *buffer = c; + *_bytesNeeded = 1; + return true; +} + +/*! + \brief Performs output character conversion and writes the result to + \a buffer. + \param tty The master tty. + \param c The output character. + \param buffer The buffer to which to write the converted character(s). + \param _bytesWritten The number of bytes written to the output buffer + (max 3). + \param echoed \c true if the output char to be processed has been echoed + from the input. +*/ +static void +process_output_char(struct tty* tty, char c, char* buffer, + size_t *_bytesWritten, bool echoed) +{ + tcflag_t flags = tty->settings->termios.c_oflag; + + if (flags & OPOST) { + if (echoed && c == tty->settings->termios.c_cc[VERASE]) { + if (tty->settings->termios.c_lflag & ECHOE) { + // ERASE -> ERASE SPACE ERASE + buffer[0] = tty->settings->termios.c_cc[VERASE]; + buffer[1] = ' '; + buffer[2] = tty->settings->termios.c_cc[VERASE]; + *_bytesWritten = 3; + return; + } + } else if (echoed && c == tty->settings->termios.c_cc[VKILL]) { + if (!(tty->settings->termios.c_lflag & ECHOK)) { + // don't echo KILL + *_bytesWritten = 0; + return; + } + } else if (echoed && c == tty->settings->termios.c_cc[VEOF]) { + // don't echo EOF + *_bytesWritten = 0; + return; + } else if (c == '\n') { + if (echoed && !(tty->settings->termios.c_lflag & ECHONL)) { + // don't echo NL + *_bytesWritten = 0; + return; + } + if (flags & ONLCR) { // NL -> CR-NL + buffer[0] = '\r'; + buffer[1] = '\n'; + *_bytesWritten = 2; + return; + } + } else if (c == '\r') { + if (flags & OCRNL) { // CR -> NL + c = '\n'; + } else if (flags & ONLRET) { // NL also does RET, ignore CR + *_bytesWritten = 0; + return; + } else if (flags & ONOCR) { // don't output CR at column 0 + // TODO: We can't decide that here. + } + } else { + if (flags & OLCUC) // lower case -> upper case + c = toupper(c); + } + } + + *buffer = c; + *_bytesWritten = 1; +} + + // #pragma mark - // device functions @@ -1096,44 +1251,54 @@ case TCGETA: TRACE(("tty: get attributes\n")); - return user_memcpy(buffer, &tty->termios, sizeof(struct termios)); + return user_memcpy(buffer, &tty->settings->termios, + sizeof(struct termios)); case TCSETA: case TCSETAW: case TCSETAF: - TRACE(("tty: set attributes (iflag = %lx, oflag = %lx, cflag = %lx, lflag = %lx)\n", - tty->termios.c_iflag, tty->termios.c_oflag, tty->termios.c_cflag, tty->termios.c_lflag)); + TRACE(("tty: set attributes (iflag = %lx, oflag = %lx, " + "cflag = %lx, lflag = %lx)\n", tty->settings->termios.c_iflag, + tty->settings->termios.c_oflag, tty->settings->termios.c_cflag, + tty->settings->termios.c_lflag)); - return user_memcpy(&tty->termios, buffer, sizeof(struct termios)); + return user_memcpy(&tty->settings->termios, buffer, + sizeof(struct termios)); /* get and set process group ID */ case TIOCGPGRP: TRACE(("tty: get pgrp_id\n")); - return user_memcpy(buffer, &tty->pgrp_id, sizeof(pid_t)); + return user_memcpy(buffer, &tty->settings->pgrp_id, sizeof(pid_t)); case TIOCSPGRP: case 'pgid': TRACE(("tty: set pgrp_id\n")); - return user_memcpy(&tty->pgrp_id, buffer, sizeof(pid_t)); + return user_memcpy(&tty->settings->pgrp_id, buffer, sizeof(pid_t)); /* get and set window size */ case TIOCGWINSZ: TRACE(("tty: set window size\n")); - return user_memcpy(buffer, &tty->window_size, sizeof(struct winsize)); + return user_memcpy(buffer, &tty->settings->window_size, + sizeof(struct winsize)); case TIOCSWINSZ: { - uint16 oldColumns = tty->window_size.ws_col, oldRows = tty->window_size.ws_row; + uint16 oldColumns = tty->settings->window_size.ws_col; + uint16 oldRows = tty->settings->window_size.ws_row; TRACE(("tty: set window size\n")); - if (user_memcpy(&tty->window_size, buffer, sizeof(struct winsize)) < B_OK) + if (user_memcpy(&tty->settings->window_size, buffer, + sizeof(struct winsize)) < B_OK) { return B_BAD_ADDRESS; + } // send a signal only if the window size has changed - if ((oldColumns != tty->window_size.ws_col || oldRows != tty->window_size.ws_row) - && tty->pgrp_id != 0) - send_signal(-tty->pgrp_id, SIGWINCH); + if ((oldColumns != tty->settings->window_size.ws_col + || oldRows != tty->settings->window_size.ws_row) + && tty->settings->pgrp_id != 0) { + send_signal(-tty->settings->pgrp_id, SIGWINCH); + } return B_OK; } @@ -1172,14 +1337,21 @@ return status; } - // ToDo: add support for ICANON mode + bool _hitEOF = false; + bool* hitEOF = (tty->pending_eof > 0 ? &_hitEOF : NULL); bytesRead = line_buffer_user_read(tty->input_buffer, (char *)buffer, - length); + length, tty->settings->termios.c_cc[VEOF], hitEOF); if (bytesRead < B_OK) { *_length = 0; return bytesRead; } + + // we hit an EOF char -- bail out, whatever amount of data we have + if (hitEOF && *hitEOF) { + tty->pending_eof--; + break; + } } *_length = bytesRead; @@ -1187,13 +1359,12 @@ } -status_t -tty_write_to_tty(tty_cookie *sourceCookie, const void *buffer, size_t *_length, - bool sourceIsMaster) +static status_t +tty_write_to_tty_master_unsafe(tty_cookie *sourceCookie, const char *data, + size_t *_length) { struct tty *source = sourceCookie->tty; struct tty *target = sourceCookie->other_tty; - const char *data = (const char *)buffer; size_t length = *_length; size_t bytesWritten = 0; uint32 mode = sourceCookie->open_mode; @@ -1213,72 +1384,172 @@ if (target->open_count <= 0) return B_FILE_ERROR; - bool echo = (target->termios.c_lflag & ECHO) != 0; - // Confusingly enough, we need to echo when the target's ECHO flag is - // set. That's because our target is supposed to echo back at us, not - // to itself. + bool echo = (source->settings->termios.c_lflag & ECHO) != 0; - TRACE(("tty_write_to_tty(source = %p, target = %p, length = %lu, %s%s)\n", source, target, length, - sourceIsMaster ? "master" : "slave", echo ? ", echo mode" : "")); + TRACE(("tty_write_to_tty_master(source = %p, target = %p, " + "length = %lu%s)\n", source, target, length, + (echo ? ", echo mode" : ""))); - // ToDo: "buffer" is not yet copied or accessed in a safe way! + status_t status = locker.AcquireWriter(dontBlock, 0); + if (status != B_OK) { + *_length = 0; + return status; + } + size_t writable = locker.AvailableBytes(); - size_t bytesNeeded = 1; - while (bytesWritten < length) { - status_t status = locker.AcquireWriter(dontBlock, bytesNeeded); - if (status != B_OK) { - *_length = bytesWritten; - return status; + // fetch next char and do input processing + char c; + size_t bytesNeeded; + if (!process_input_char(source, *data, &c, &bytesNeeded)) { + // input char shall be skipped + data++; + bytesWritten++; + continue; } - bytesNeeded = 1; // reset + // If in echo mode, we do the output conversion and need to update + // the needed bytes count. + char echoBuffer[3]; + size_t echoBytes; + if (echo) { + process_output_char(source, c, echoBuffer, &echoBytes, true); + if (echoBytes > bytesNeeded) + bytesNeeded = echoBytes; + } - size_t writable = locker.AvailableBytes(); - if (writable == 0) { - // should never happen + // If there's not enough space to write what we have, we need to wait + // until it is available. + if (writable < bytesNeeded) { + status = locker.AcquireWriter(dontBlock, bytesNeeded); + if (status != B_OK) { + *_length = bytesWritten; + return status; + } + + writable = locker.AvailableBytes(); + + // We need to restart the loop, since the termios flags might have + // changed in the meantime (while we've unlocked the tty). Note, + // that we don't re-get "echo" -- maybe we should. continue; } - while (writable > 0 && bytesWritten < length) { - char c = data[0]; + // write the bytes + tty_input_putc_locked(target, c); - if (c == '\n' && (source->termios.c_oflag & (OPOST | ONLCR)) == OPOST | ONLCR) { - // post-process output and transfrom '\n' to '\r\n' + if (echo) { + for (size_t i = 0; i < echoBytes; i++) + line_buffer_putc(source->input_buffer, echoBuffer[i]); + } - // If we can't write both '\r' and '\n', we won't write either, - // or we would write the '\r' again. - if (writable < 2) { - // try acquiring the writer again, when enough space is available - bytesNeeded = 2; - writable = 0; - // make sure we're breaking out of this loop - continue; - } + writable -= bytesNeeded; + data++; + bytesWritten++; + } -#if 1 - // ToDo: this doesn't fix the bug that is responsible for the doubled shell prompt - // and it's all wrong, too - but it cures the symptoms, and that's good enough - // for now :) - // Apparently, the shell reads only single bytes and handles both, '\r' and '\n' - // as a newline. - if (!sourceIsMaster) -#endif - tty_input_putc_locked(target, '\r'); - if (echo) - tty_input_putc_locked(source, '\r'); + return B_OK; +} - if (--writable == 0) - continue; + +status_t +tty_write_to_tty_master(tty_cookie *sourceCookie, const void *_buffer, + size_t *_length) +{ + const char* buffer = (const char*)_buffer; + size_t bytesRemaining = *_length; + *_length = 0; + + while (bytesRemaining > 0) { + // copy data to stack + char safeBuffer[256]; + size_t toWrite = min_c(sizeof(safeBuffer), bytesRemaining); + status_t error = user_memcpy(safeBuffer, buffer, toWrite); + if (error != B_OK) + return error; + + // write them + size_t written = toWrite; + error = tty_write_to_tty_master_unsafe(sourceCookie, safeBuffer, + &written); + if (error != B_OK) + return error; + + buffer += written; + bytesRemaining -= written; + *_length += written; + + if (written < toWrite) + return B_OK; + } + + return B_OK; +} + + +static status_t +tty_write_to_tty_slave_unsafe(tty_cookie *sourceCookie, const char *data, + size_t *_length) +{ + struct tty *target = sourceCookie->other_tty; + size_t length = *_length; + size_t bytesWritten = 0; + uint32 mode = sourceCookie->open_mode; + bool dontBlock = (mode & O_NONBLOCK) != 0; + + // bail out, if source is already closed + TTYReference sourceTTYReference(sourceCookie); + if (!sourceTTYReference.IsLocked()) + return B_FILE_ERROR; + + if (length == 0) + return B_OK; + + WriterLocker locker(sourceCookie); + + // if the target is not open, fail now + if (target->open_count <= 0) + return B_FILE_ERROR; + + TRACE(("tty_write_to_tty_slave(source = %p, target = %p, length = %lu)\n", + sourceCookie->tty, target, length)); + + status_t status = locker.AcquireWriter(dontBlock, 0); + if (status != B_OK) { + *_length = 0; + return status; + } + size_t writable = locker.AvailableBytes(); + + while (bytesWritten < length) { + // fetch next char and do output processing + char buffer[3]; + size_t bytesNeeded; + process_output_char(target, *data, buffer, &bytesNeeded, false); + + // If there's not enough space to write what we have, we need to wait + // until it is available. + if (writable < bytesNeeded) { + status = locker.AcquireWriter(dontBlock, bytesNeeded); + if (status != B_OK) { + *_length = bytesWritten; + return status; } - tty_input_putc_locked(target, c); - if (echo) - tty_input_putc_locked(source, c); + writable = locker.AvailableBytes(); - data++; - bytesWritten++; + // We need to restart the loop, since the termios flags might have + // changed in the meantime (while we've unlocked the tty). + continue; } + + // write the bytes + for (size_t i = 0; i < bytesNeeded; i++) + tty_input_putc_locked(target, buffer[i]); + + writable -= bytesNeeded; + data++; + bytesWritten++; } return B_OK; @@ -1286,6 +1557,41 @@ status_t +tty_write_to_tty_slave(tty_cookie *sourceCookie, const void *_buffer, + size_t *_length) +{ + const char* buffer = (const char*)_buffer; + size_t bytesRemaining = *_length; + *_length = 0; + + while (bytesRemaining > 0) { + // copy data to stack + char safeBuffer[256]; + size_t toWrite = min_c(sizeof(safeBuffer), bytesRemaining); + status_t error = user_memcpy(safeBuffer, buffer, toWrite); + if (error != B_OK) + return error; + + // write them + size_t written = toWrite; + error = tty_write_to_tty_slave_unsafe(sourceCookie, safeBuffer, + &written); + if (error != B_OK) + return error; + + buffer += written; + bytesRemaining -= written; + *_length += written; + + if (written < toWrite) + return B_OK; + } + + return B_OK; +} + + +status_t tty_select(tty_cookie *cookie, uint8 event, uint32 ref, selectsync *sync) { struct tty *tty = cookie->tty; @@ -1346,9 +1652,10 @@ break; } - // In case the other TTY echos, we have to check, whether we can + // In case input is echoed, we have to check, whether we can // currently can write to our TTY as well. - bool echo = (otherTTY->termios.c_lflag & ECHO); + bool echo = (tty->is_master + && tty->settings->termios.c_lflag & ECHO); if (otherTTY->writer_queue.IsEmpty() && line_buffer_writable(otherTTY->input_buffer) > 0) { Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h 2007-07-29 01:06:36 UTC (rev 21734) +++ haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h 2007-07-29 01:09:39 UTC (rev 21735) @@ -118,24 +118,31 @@ typedef DoublyLinkedList TTYCookieList; +struct tty_settings { + pid_t pgrp_id; + struct termios termios; + struct winsize window_size; +}; + struct tty { int32 open_count; int32 index; - struct mutex *lock; + struct mutex* lock; + tty_settings* settings; RequestQueue reader_queue; RequestQueue writer_queue; TTYCookieList cookies; - pid_t pgrp_id; line_buffer input_buffer; tty_service_func service_func; - struct termios termios; - struct winsize window_size; + uint32 pending_eof; + bool is_master; }; static const uint32 kNumTTYs = 64; extern tty gMasterTTYs[kNumTTYs]; extern tty gSlaveTTYs[kNumTTYs]; +extern tty_settings gTTYSettings[kNumTTYs]; extern device_hooks gMasterTTYHooks; extern device_hooks gSlaveTTYHooks; @@ -149,13 +156,16 @@ // functions available for master/slave TTYs extern int32 get_tty_index(const char *name); -extern void reset_tty(struct tty *tty, int32 index); +extern void reset_tty(struct tty *tty, int32 index, bool isMaster); +extern void reset_tty_settings(tty_settings *settings, int32 index); //extern status_t tty_input_putc(struct tty *tty, int c); extern status_t tty_input_read(tty_cookie *cookie, void *buffer, size_t *_length); extern status_t tty_output_getc(struct tty *tty, int *_c); -extern status_t tty_write_to_tty(tty_cookie *sourceCookie, const void *buffer, - size_t *_length, bool sourceIsMaster); +extern status_t tty_write_to_tty_master(tty_cookie *sourceCookie, + const void *buffer, size_t *_length); +extern status_t tty_write_to_tty_slave(tty_cookie *sourceCookie, + const void *buffer, size_t *_length); extern status_t init_tty_cookie(tty_cookie *cookie, struct tty *tty, struct tty *otherTTY, uint32 openMode); From marcusoverhagen at mail.berlios.de Sun Jul 29 03:31:02 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sun, 29 Jul 2007 03:31:02 +0200 Subject: [Haiku-commits] r21736 - haiku/trunk/src/system/kernel Message-ID: <200707290131.l6T1V2O4013904@sheep.berlios.de> Author: marcusoverhagen Date: 2007-07-29 03:30:59 +0200 (Sun, 29 Jul 2007) New Revision: 21736 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21736&view=rev Modified: haiku/trunk/src/system/kernel/thread.c Log: Allow thread priority setting from inside kdl. Right now, a single priority 12 thread can make the whole GUI appear frozen. Modified: haiku/trunk/src/system/kernel/thread.c =================================================================== --- haiku/trunk/src/system/kernel/thread.c 2007-07-29 01:09:39 UTC (rev 21735) +++ haiku/trunk/src/system/kernel/thread.c 2007-07-29 01:30:59 UTC (rev 21736) @@ -529,6 +529,47 @@ static int +set_thread_prio(int argc, char **argv) +{ + struct thread *thread; + struct hash_iterator i; + int32 id; + int32 prio; + + if (argc > 3 || argc < 2) { + kprintf("usage: priority [thread-id]\n"); + return 0; + } + + prio = strtoul(argv[1], NULL, 0); + if (prio > B_MAX_PRIORITY) + prio = B_MAX_PRIORITY; + if (prio < B_MIN_PRIORITY) + prio = B_MIN_PRIORITY; + + if (argc > 2) + id = strtoul(argv[2], NULL, 0); + else + id = thread_get_current_thread()->id; + + hash_open(sThreadHash, &i); + + while ((thread = hash_next(sThreadHash, &i)) != NULL) { + if (thread->id != id) + continue; + thread->priority = thread->next_priority = prio; + kprintf("thread 0x%lx set to priority %ld\n", id, prio); + break; + } + if (!thread) + kprintf("thread 0x%lx not found\n", id); + + hash_close(sThreadHash, &i, false); + return 0; +} + + +static int make_thread_suspended(int argc, char **argv) { struct thread *thread; @@ -1638,6 +1679,7 @@ add_debugger_command("suspend", &make_thread_suspended, "suspend a thread"); add_debugger_command("resume", &make_thread_resumed, "resume a thread"); add_debugger_command("drop", &drop_into_debugger, "drop a thread into the user-debugger"); + add_debugger_command("priority", &set_thread_prio, "set a thread priority"); return B_OK; } From laplace at mail.berlios.de Sun Jul 29 10:59:46 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Sun, 29 Jul 2007 10:59:46 +0200 Subject: [Haiku-commits] r21737 - haiku/trunk/src/kits/interface Message-ID: <200707290859.l6T8xkjW014874@sheep.berlios.de> Author: laplace Date: 2007-07-29 10:59:46 +0200 (Sun, 29 Jul 2007) New Revision: 21737 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21737&view=rev Modified: haiku/trunk/src/kits/interface/PrintJob.cpp Log: Do not overwrite current printer name. Name should be provided by print_server already. Modified: haiku/trunk/src/kits/interface/PrintJob.cpp =================================================================== --- haiku/trunk/src/kits/interface/PrintJob.cpp 2007-07-29 01:30:59 UTC (rev 21736) +++ haiku/trunk/src/kits/interface/PrintJob.cpp 2007-07-29 08:59:46 UTC (rev 21737) @@ -412,8 +412,8 @@ } // add printer settings message - fSetupMessage->RemoveName(PSRV_FIELD_CURRENT_PRINTER); - fSetupMessage->AddString(PSRV_FIELD_CURRENT_PRINTER, printer); + if (!fSetupMessage->HasString(PSRV_FIELD_CURRENT_PRINTER)) + fSetupMessage->AddString(PSRV_FIELD_CURRENT_PRINTER, printer); AddSetupSpec(); // prepare page header From laplace at mail.berlios.de Sun Jul 29 11:03:25 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Sun, 29 Jul 2007 11:03:25 +0200 Subject: [Haiku-commits] r21738 - haiku/trunk/src/servers/print Message-ID: <200707290903.l6T93PMP015152@sheep.berlios.de> Author: laplace Date: 2007-07-29 11:03:25 +0200 (Sun, 29 Jul 2007) New Revision: 21738 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21738&view=rev Modified: haiku/trunk/src/servers/print/Printer.cpp Log: Search printer spool folder by name stored in attribute 'Printer Name'. Modified: haiku/trunk/src/servers/print/Printer.cpp =================================================================== --- haiku/trunk/src/servers/print/Printer.cpp 2007-07-29 08:59:46 UTC (rev 21737) +++ haiku/trunk/src/servers/print/Printer.cpp 2007-07-29 09:03:25 UTC (rev 21738) @@ -463,20 +463,33 @@ // Try to move job to another printer folder. // // Parameters: -// name - the printer folder name. +// name - the printer name. // // Returns: // true if successful. // --------------------------------------------------------------- bool Printer::MoveJob(const BString& name) { - BPath file(&fJob->EntryRef()); BPath path; - file.GetParent(&path); - path.Append(".."); path.Append(name.String()); - BDirectory dir(path.Path()); - BEntry entry(&fJob->EntryRef()); - // try to move job file to proper directory - return entry.MoveTo(&dir) == B_OK; + if (::find_directory(B_USER_PRINTERS_DIRECTORY, &path) != B_OK) + return false; + + // search printer folder with given name + BDirectory printersFolder(path.Path()); + BEntry printerEntry; + while (printersFolder.GetNextEntry(&printerEntry) == B_OK) { + BNode printerNode(&printerEntry); + BString printerName; + if (printerNode.ReadAttrString(PSRV_PRINTER_ATTR_PRT_NAME, &printerName) != B_OK) + continue; + if (name != printerName) + continue; + + BEntry jobEntry(&fJob->EntryRef()); + BDirectory printerDirectory(&printerEntry); + return jobEntry.MoveTo(&printerDirectory) == B_OK; + // try to move job file to proper directory + } + return false; } // --------------------------------------------------------------- From axeld at mail.berlios.de Sun Jul 29 23:12:25 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 29 Jul 2007 23:12:25 +0200 Subject: [Haiku-commits] r21739 - haiku/trunk/src/apps/cdplayer Message-ID: <200707292112.l6TLCP1B027062@sheep.berlios.de> Author: axeld Date: 2007-07-29 23:12:21 +0200 (Sun, 29 Jul 2007) New Revision: 21739 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21739&view=rev Modified: haiku/trunk/src/apps/cdplayer/ButtonBitmaps.h haiku/trunk/src/apps/cdplayer/CDAudioDevice.cpp haiku/trunk/src/apps/cdplayer/CDAudioDevice.h haiku/trunk/src/apps/cdplayer/CDDBSupport.cpp haiku/trunk/src/apps/cdplayer/CDDBSupport.h haiku/trunk/src/apps/cdplayer/CDPlayer.cpp haiku/trunk/src/apps/cdplayer/CDPlayer.h Log: Patch by Vasilis Kaoutsis: * Fixed several missing incorrect initializations from fYear. * Style cleanup. Modified: haiku/trunk/src/apps/cdplayer/ButtonBitmaps.h =================================================================== --- haiku/trunk/src/apps/cdplayer/ButtonBitmaps.h 2007-07-29 09:03:25 UTC (rev 21738) +++ haiku/trunk/src/apps/cdplayer/ButtonBitmaps.h 2007-07-29 21:12:21 UTC (rev 21739) @@ -15,6 +15,7 @@ #ifndef BUTTON_BITMAPS_H #define BUTTON_BITMAPS_H +#include // #pragma mark play Modified: haiku/trunk/src/apps/cdplayer/CDAudioDevice.cpp =================================================================== --- haiku/trunk/src/apps/cdplayer/CDAudioDevice.cpp 2007-07-29 09:03:25 UTC (rev 21738) +++ haiku/trunk/src/apps/cdplayer/CDAudioDevice.cpp 2007-07-29 21:12:21 UTC (rev 21739) @@ -1,127 +1,163 @@ /* - * Copyright (c) 2006-2007, Haiku, Inc. + * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT license. * * Author: - * DarkWyrm + * DarkWyrm, bpmagic at columbus.rr.com */ + + #include "CDAudioDevice.h" +#include "scsi.h" -#include -#include -#include -#include -#include #include #include #include #include +#include + #include -#include "scsi.h" +#include +#include +#include +#include -cdaudio_data::cdaudio_data(const int32 &id, const int32 &count, - const int32 &disclength) - : disc_id(id), - track_count(count), - length(disclength) +struct ConvertedToc { + int32 min; + int32 sec; + int32 frame; +}; + + +static int32 +cddb_sum(int n) { + char buf[12]; + int32 ret = 0; + + sprintf(buf, "%u", n); + for (const char *p = buf; *p != '\0'; p++) + ret += (*p - '0'); + return ret; } -cdaudio_data::cdaudio_data(const cdaudio_data &from) - : disc_id(from.disc_id), - track_count(from.track_count), - length(from.length) +// #pragma mark - + + +CDAudioData::CDAudioData(const int32 &id, const int32 &count, const int32 &discLength) + : + fDiscId(id), + fTrackCount(count), + fLength(discLength) { } -cdaudio_data & -cdaudio_data::operator=(const cdaudio_data &from) +CDAudioData::CDAudioData(const CDAudioData &from) + : + fDiscId(from.fDiscId), + fTrackCount(from.fTrackCount), + fLength(from.fLength) { - disc_id = from.disc_id; - track_count = from.track_count; - length = from.length; - frame_offsets = from.frame_offsets; +} + + +CDAudioData & +CDAudioData::operator=(const CDAudioData &from) +{ + fDiscId = from.fDiscId; + fTrackCount = from.fTrackCount; + fLength = from.fLength; + fFrameOffsets = from.fFrameOffsets; return *this; } -cdaudio_time::cdaudio_time(const int32 min,const int32 &sec) - : minutes(min), - seconds(sec) +// #pragma mark - + + +CDAudioTime::CDAudioTime(const int32 min,const int32 &sec) + : + fMinutes(min), + fSeconds(sec) { } -cdaudio_time::cdaudio_time(const cdaudio_time &from) - : minutes(from.minutes), - seconds(from.seconds) +CDAudioTime::CDAudioTime(const CDAudioTime &from) + : + fMinutes(from.fMinutes), + fSeconds(from.fSeconds) { } -cdaudio_time & -cdaudio_time::operator=(const cdaudio_time &from) +CDAudioTime & +CDAudioTime::operator=(const CDAudioTime &from) { - minutes = from.minutes; - seconds = from.seconds; + fMinutes = from.fMinutes; + fSeconds = from.fSeconds; return *this; } -cdaudio_time -cdaudio_time::operator+(const cdaudio_time &from) +CDAudioTime +CDAudioTime::operator+(const CDAudioTime &from) { - cdaudio_time time; - - time.minutes = minutes + from.minutes; - time.seconds = seconds + from.seconds; - - while (time.seconds > 59) { - time.minutes++; - time.seconds-=60; + CDAudioTime time; + + time.fMinutes = fMinutes + from.fMinutes; + time.fSeconds = fSeconds + from.fSeconds; + + while (time.fSeconds > 59) { + time.fMinutes++; + time.fSeconds -= 60; } return time; } -cdaudio_time -cdaudio_time::operator-(const cdaudio_time &from) +CDAudioTime +CDAudioTime::operator-(const CDAudioTime &from) { - cdaudio_time time; - - int32 tsec = ((minutes * 60) + seconds) - ((from.minutes * 60) + from.seconds); + CDAudioTime time; + + int32 tsec = ((fMinutes * 60) + fSeconds) - ((from.fMinutes * 60) + from.fSeconds); if (tsec < 0) { - time.minutes = 0; - time.seconds = 0; + time.fMinutes = 0; + time.fSeconds = 0; return time; } - - time.minutes = tsec / 60; - time.seconds = tsec % 60; - + + time.fMinutes = tsec / 60; + time.fSeconds = tsec % 60; + return time; } -CDAudioDevice::CDAudioDevice(void) +// #pragma mark - + + +CDAudioDevice::CDAudioDevice() { - FindDrives("/dev/disk"); + _FindDrives("/dev/disk"); if (CountDrives() > 0) SetDrive(0); } -CDAudioDevice::~CDAudioDevice(void) +CDAudioDevice::~CDAudioDevice() { for (int32 i = 0; i < fDriveList.CountItems(); i++) delete (BString*) fDriveList.ItemAt(i); } -// This plays only one track - the track specified + +//! This plays only one track - the track specified bool CDAudioDevice::Play(const int16 &track) { @@ -130,7 +166,7 @@ ioctl(fFileHandle, B_LOAD_MEDIA, 0, 0); return false; } - + scsi_play_track playtrack; playtrack.start_track = track; @@ -149,7 +185,7 @@ bool -CDAudioDevice::Pause(void) +CDAudioDevice::Pause() { status_t result = ioctl(fFileHandle, B_SCSI_PAUSE_AUDIO); if (result != B_OK) { @@ -161,7 +197,7 @@ bool -CDAudioDevice::Resume(void) +CDAudioDevice::Resume() { CDState state = GetState(); if (state == kNoCD) { @@ -172,7 +208,7 @@ if (state == kStopped) return Play(0); } - + status_t result = ioctl(fFileHandle, B_SCSI_RESUME_AUDIO); if (result != B_OK) { printf("Couldn't resume track: %s\n", strerror(errno)); @@ -183,7 +219,7 @@ bool -CDAudioDevice::Stop(void) +CDAudioDevice::Stop() { status_t result = ioctl(fFileHandle, B_SCSI_STOP_AUDIO); if (result != B_OK) { @@ -194,20 +230,19 @@ } -// open or close the CD tray +//! Open or close the CD tray bool -CDAudioDevice::Eject(void) +CDAudioDevice::Eject() { status_t media_status = B_DEV_NO_MEDIA; - + // get the status first ioctl(fFileHandle, B_GET_MEDIA_STATUS, &media_status, sizeof(media_status)); - + // if door open, load the media, else eject the CD status_t result = ioctl(fFileHandle, - media_status == B_DEV_DOOR_OPEN ? - B_LOAD_MEDIA : B_EJECT_DEVICE); - + media_status == B_DEV_DOOR_OPEN ? B_LOAD_MEDIA : B_EJECT_DEVICE); + if (result != B_OK) { printf("Couldn't eject CD: %s\n", strerror(errno)); return false; @@ -217,7 +252,7 @@ bool -CDAudioDevice::StartFastFwd(void) +CDAudioDevice::StartFastFwd() { scsi_scan scan; scan.direction = 1; @@ -232,7 +267,7 @@ bool -CDAudioDevice::StopFastFwd(void) +CDAudioDevice::StopFastFwd() { scsi_scan scan; scan.direction = 0; @@ -247,7 +282,7 @@ bool -CDAudioDevice::StartRewind(void) +CDAudioDevice::StartRewind() { scsi_scan scan; scan.direction = -1; @@ -262,7 +297,7 @@ bool -CDAudioDevice::StopRewind(void) +CDAudioDevice::StopRewind() { scsi_scan scan; scan.direction = 0; @@ -280,12 +315,12 @@ CDAudioDevice::SetVolume(uint8 value) { scsi_volume vol; - + // change only port0's volume - vol.flags=2; - vol.port0_volume=value; - - status_t result = ioctl(fFileHandle,B_SCSI_SET_VOLUME,&vol); + vol.flags = 2; + vol.port0_volume = value; + + status_t result = ioctl(fFileHandle, B_SCSI_SET_VOLUME, &vol); if (result != B_OK) { printf("Couldn't set volume: %s\n", strerror(errno)); return false; @@ -295,7 +330,7 @@ uint8 -CDAudioDevice::GetVolume(void) +CDAudioDevice::GetVolume() { scsi_volume vol; ioctl(fFileHandle, B_SCSI_GET_VOLUME, &vol); @@ -303,13 +338,13 @@ } -// check the current CD play state +//! Check the current CD play state CDState -CDAudioDevice::GetState(void) +CDAudioDevice::GetState() { scsi_position pos; status_t media_status = B_DEV_NO_MEDIA; - + ioctl(fFileHandle, B_GET_MEDIA_STATUS, &media_status, sizeof(media_status)); if (media_status != B_OK) return kNoCD; @@ -328,26 +363,26 @@ int16 -CDAudioDevice::CountTracks(void) +CDAudioDevice::CountTracks() { scsi_toc toc; status_t result = ioctl(fFileHandle, B_SCSI_GET_TOC, &toc); - + if (result != B_OK) return -1; - + return toc.toc_data[3]; } -// Get the 0-based index of the current track +//! Get the 0-based index of the current track int16 -CDAudioDevice::GetTrack(void) +CDAudioDevice::GetTrack() { scsi_position pos; status_t media_status = B_DEV_NO_MEDIA; - + ioctl(fFileHandle, B_GET_MEDIA_STATUS, &media_status, sizeof(media_status)); if (media_status != B_OK) return -1; @@ -355,7 +390,7 @@ status_t result = ioctl(fFileHandle, B_SCSI_GET_POSITION, &pos); if (result != B_OK) return -1; - + if (!pos.position[1] || pos.position[1] >= 0x13 || (pos.position[1] == 0x12 && !pos.position[6])) return 0; @@ -365,7 +400,7 @@ uint8 -CDAudioDevice::CountDrives(void) +CDAudioDevice::CountDrives() { return fDriveList.CountItems(); } @@ -375,10 +410,10 @@ CDAudioDevice::SetDrive(const int32 &drive) { BString *path = (BString*) fDriveList.ItemAt(drive); - + if (!path) return false; - + int device = open(path->String(), O_RDONLY); if (device >= 0) { fFileHandle = device; @@ -392,63 +427,62 @@ const char * -CDAudioDevice::GetDrivePath(void) const +CDAudioDevice::GetDrivePath() const { if (!fDrivePath) return NULL; - + return fDrivePath->String(); } int32 -CDAudioDevice::FindDrives(const char *path) +CDAudioDevice::_FindDrives(const char *path) { BDirectory dir(path); - + if (dir.InitCheck() != B_OK) return B_ERROR; dir.Rewind(); - + BEntry entry; while (dir.GetNextEntry(&entry) >= 0) { BPath path; const char *name; entry_ref e; - + if (entry.GetPath(&path) != B_OK) continue; - + name = path.Path(); if (entry.GetRef(&e) != B_OK) continue; - + if (entry.IsDirectory()) { // ignore floppy -- it is not silent if (strcmp(e.name, "floppy") == 0) continue; - else - if (strcmp(e.name, "ata") == 0) + else if (strcmp(e.name, "ata") == 0) continue; - + // Note that if we check for the count here, we could // just search for one drive. However, we want to find *all* drives // that are available, so we keep searching even if we've found one - FindDrives(name); - + _FindDrives(name); + } else { int devfd; device_geometry g; - + // ignore partitions if (strcmp(e.name, "raw") != 0) continue; - + devfd = open(name, O_RDONLY); if (devfd < 0) continue; - + if (ioctl(devfd, B_GET_GEOMETRY, &g, sizeof(g)) >= 0) { if (g.device_type == B_CD) fDriveList.AddItem(new BString(name)); @@ -461,124 +495,104 @@ bool -CDAudioDevice::GetTime(cdaudio_time &track, cdaudio_time &disc) +CDAudioDevice::GetTime(CDAudioTime &track, CDAudioTime &disc) { scsi_position pos; - + // Sanity check status_t media_status = B_DEV_NO_MEDIA; ioctl(fFileHandle, B_GET_MEDIA_STATUS, &media_status, sizeof(media_status)); if (media_status != B_OK) return false; - + status_t result = ioctl(fFileHandle, B_SCSI_GET_POSITION, &pos); - + if (result != B_OK) return false; - + if ((!pos.position[1]) || (pos.position[1] >= 0x13) || ((pos.position[1] == 0x12) && (!pos.position[6]))) { // This indicates that we have a CD, but we are stopped. return false; } - - disc.minutes = pos.position[9]; - disc.seconds = pos.position[10]; - track.minutes = pos.position[13]; - track.seconds = pos.position[14]; + + disc.SetMinutes(pos.position[9]); + disc.SetSeconds(pos.position[10]); + track.SetMinutes(pos.position[13]); + track.SetSeconds(pos.position[14]); return true; } bool -CDAudioDevice::GetTimeForTrack(const int16 &index, cdaudio_time &track) +CDAudioDevice::GetTimeForTrack(const int16 &index, CDAudioTime &track) { scsi_toc toc; status_t result = ioctl(fFileHandle, B_SCSI_GET_TOC, &toc); - + if (result != B_OK) return false; - + int16 trackcount = toc.toc_data[3] - toc.toc_data[2] + 1; - + if (index < 1 || index > trackcount) return false; - + TrackDescriptor *desc = (TrackDescriptor*)&(toc.toc_data[4]); - + int32 tracktime = (desc[index].min * 60) + desc[index].sec; + + tracktime -= (desc[index - 1].min * 60) + desc[index - 1].sec; + track.SetMinutes(tracktime / 60); + track.SetSeconds(tracktime % 60); - tracktime -= (desc[index-1].min * 60) + desc[index-1].sec; - track.minutes = tracktime / 60; - track.seconds = tracktime % 60; - return true; } bool -CDAudioDevice::GetTimeForDisc(cdaudio_time &disc) +CDAudioDevice::GetTimeForDisc(CDAudioTime &disc) { scsi_toc toc; status_t result = ioctl(fFileHandle, B_SCSI_GET_TOC, &toc); - + if (result != B_OK) return false; - + int16 trackcount = toc.toc_data[3] - toc.toc_data[2] + 1; TrackDescriptor *desc = (TrackDescriptor*)&(toc.toc_data[4]); - - disc.minutes = desc[trackcount].min; - disc.seconds = desc[trackcount].sec; - - return true; -} + disc.SetMinutes(desc[trackcount].min); + disc.SetSeconds(desc[trackcount].sec); -struct ConvertedToc { - int32 min; - int32 sec; - int32 frame; -}; - - -static int32 -cddb_sum(int n) -{ - char buf[12]; - int32 ret = 0; - - sprintf(buf, "%u", n); - for (const char *p = buf; *p != '\0'; p++) - ret += (*p - '0'); - return ret; + return true; } int32 -CDAudioDevice::GetDiscID(void) +CDAudioDevice::GetDiscID() { // Read the disc scsi_toc toc; status_t result = ioctl(fFileHandle, B_SCSI_GET_TOC, &toc); - + if (result != B_OK) return -1; - - + + int32 id, numTracks; BString frameOffsetsString; - + ConvertedToc tocData[100]; // figure out the disc ID for (int index = 0; index < 100; index++) { - tocData[index].min = toc.toc_data[9 + 8*index]; - tocData[index].sec = toc.toc_data[10 + 8*index]; - tocData[index].frame = toc.toc_data[11 + 8*index]; + tocData[index].min = toc.toc_data[9 + 8 * index]; + tocData[index].sec = toc.toc_data[10 + 8 * index]; + tocData[index].frame = toc.toc_data[11 + 8 * index]; } numTracks = toc.toc_data[3] - toc.toc_data[2] + 1; - + int32 sum1 = 0; int32 sum2 = 0; for (int index = 0; index < numTracks; index++) { @@ -589,7 +603,7 @@ (tocData[index].min * 60 + tocData[index].sec); } id = ((sum1 % 0xff) << 24) + (sum2 << 8) + numTracks; - + return id; } @@ -599,19 +613,18 @@ { scsi_toc toc; status_t result = ioctl(fFileHandle, B_SCSI_GET_TOC, &toc); - + if (result != B_OK) return false; - + TrackDescriptor *trackindex = (TrackDescriptor*) &(toc.toc_data[4]); if (track > toc.toc_data[3]) return false; - + // At least under R5, the SCSI CD drive has each legitimate audio track // have a value of 0x10. Data tracks have a value of 0x14; if (trackindex[track].adr_control & 4) return true; - + return false; } - Modified: haiku/trunk/src/apps/cdplayer/CDAudioDevice.h =================================================================== --- haiku/trunk/src/apps/cdplayer/CDAudioDevice.h 2007-07-29 09:03:25 UTC (rev 21738) +++ haiku/trunk/src/apps/cdplayer/CDAudioDevice.h 2007-07-29 21:12:21 UTC (rev 21739) @@ -1,27 +1,28 @@ /* - * Copyright (c) 2006-2007, Haiku, Inc. + * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT license. * * Author: - * DarkWyrm + * DarkWyrm, bpmagic at columbus.rr.com */ #ifndef CDAUDIODEVICE_H #define CDAUDIODEVICE_H +#include +#include #include -#include -#include + // The SCSI table of contents consists of a 4-byte header followed by 100 track // descriptors, which are each 8 bytes. We don't really need the first 5 bytes // of the track descriptor, so we'll just ignore them. All we really want is the -// length of each track, which happen to be the last 3 bytes of the descriptor. +// fLength of each track, which happen to be the last 3 bytes of the descriptor. typedef struct { uint8 reserved; uint8 adr_control; // bytes 0-3 are control, 4-7 are ADR uint8 track_number; uint8 reserved2; - + uint8 reserved3; uint8 min; uint8 sec; @@ -29,7 +30,7 @@ } TrackDescriptor; enum CDState { - kNoCD=0, + kNoCD = 0, kStopped, kPaused, kPlaying, @@ -38,79 +39,104 @@ kInit }; -class cdaudio_time -{ -public: - cdaudio_time(const int32 min=-1,const int32 &sec=-1); - cdaudio_time(const cdaudio_time &from); - cdaudio_time &operator=(const cdaudio_time &from); - cdaudio_time operator+(const cdaudio_time &from); - cdaudio_time operator-(const cdaudio_time &from); - - int32 minutes; - int32 seconds; + +class CDAudioTime { + public: + CDAudioTime(const int32 min = -1, const int32 &sec = -1); + CDAudioTime(const CDAudioTime &from); + CDAudioTime &operator=(const CDAudioTime &from); + CDAudioTime operator+(const CDAudioTime &from); + CDAudioTime operator-(const CDAudioTime &from); + + void SetMinutes(const int32& minutes) + { + fMinutes = minutes; + } + + void SetSeconds(const int32& seconds) + { + fSeconds = seconds; + } + + int32 GetMinutes() const + { + return fMinutes; + } + + int32 GetSeconds() const + { + return fSeconds; + } + + private: + int32 fMinutes; + int32 fSeconds; }; -class cdaudio_data -{ -public: - cdaudio_data(const int32 &id = -1, const int32 &count = -1, - const int32 &disclength = -1); - cdaudio_data(const cdaudio_data &from); - cdaudio_data &operator=(const cdaudio_data &from); - - int32 disc_id; - int32 track_count; - int32 length; - - BString frame_offsets; + +class CDAudioData { + public: + CDAudioData(const int32 &id = -1, const int32 &count = -1, + const int32 &discLength = -1); + CDAudioData(const CDAudioData &from); + CDAudioData &operator=(const CDAudioData &from); + + private: + int32 fDiscId; + int32 fTrackCount; + int32 fLength; + BString fFrameOffsets; }; -class CDAudioDevice -{ -public: - CDAudioDevice(void); - ~CDAudioDevice(void); - - bool Play(const int16 &track); - bool Pause(void); - bool Resume(void); - bool Stop(void); - bool Eject(void); - - bool StartFastFwd(void); - bool StopFastFwd(void); - - bool StartRewind(void); - bool StopRewind(void); - - bool SetVolume(uint8 value); - uint8 GetVolume(void); - - CDState GetState(void); - - int16 CountTracks(void); - int16 GetTrack(void); - - uint8 CountDrives(void); - bool SetDrive(const int32 &drive); - const char * GetDrivePath(void) const; - int32 GetDrive(void) const { return fDriveIndex; } - - bool GetTime(cdaudio_time &track, cdaudio_time &disc); - bool GetTimeForTrack(const int16 &index, cdaudio_time &track); - bool GetTimeForDisc(cdaudio_time &disc); - int32 GetDiscID(void); - - bool IsDataTrack(const int16 &track); - -private: - int32 FindDrives(const char *path); - - int fFileHandle; - BString * fDrivePath; - BList fDriveList; - int32 fDriveIndex; + +class CDAudioDevice { + public: + CDAudioDevice(); + ~CDAudioDevice(); + + bool Play(const int16 &track); + bool Pause(); + bool Resume(); + bool Stop(); + bool Eject(); + + bool StartFastFwd(); + bool StopFastFwd(); + + bool StartRewind(); + bool StopRewind(); + + bool SetVolume(uint8 value); + uint8 GetVolume(); + + CDState GetState(); + + int16 CountTracks(); + int16 GetTrack(); + + uint8 CountDrives(); + bool SetDrive(const int32 &drive); + const char* GetDrivePath() const; + + int32 GetDrive() const + { + return fDriveIndex; + } + + bool GetTime(CDAudioTime &track, CDAudioTime &disc); + bool GetTimeForTrack(const int16 &index, CDAudioTime &track); + bool GetTimeForDisc(CDAudioTime &disc); + int32 GetDiscID(); + + bool IsDataTrack(const int16 &track); + + private: + int32 _FindDrives(const char *path); + + int fFileHandle; + BString* fDrivePath; + BList fDriveList; + int32 fDriveIndex; }; -#endif +#endif // CDAUDIODEVICE_H Modified: haiku/trunk/src/apps/cdplayer/CDDBSupport.cpp =================================================================== --- haiku/trunk/src/apps/cdplayer/CDDBSupport.cpp 2007-07-29 09:03:25 UTC (rev 21738) +++ haiku/trunk/src/apps/cdplayer/CDDBSupport.cpp 2007-07-29 21:12:21 UTC (rev 21739) @@ -6,28 +6,29 @@ #include "CDDBSupport.h" +#include #include -#include #include #include #include #include +#include +#include #include -#include #include #include +#include #include #include #include -#include #include #include #include #include #include -#include + //#define DEBUG_CDDB #ifdef DEBUG_CDDB @@ -44,67 +45,108 @@ // length of each track, which happen to be the last 3 bytes of the descriptor. typedef struct TrackRecord { int8 unused[5]; - + int8 min; int8 sec; int8 frame; }; [... truncated: 2745 lines follow ...] From axeld at pinc-software.de Sun Jul 29 16:15:05 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 29 Jul 2007 16:15:05 +0200 CEST Subject: [Haiku-commits] r21715 - in haiku/trunk: headers/private/kernel headers/private/libroot src/kits src/kits/tracker src/system/kernel src/system/kernel/messaging src/system/kernel/util src/system/libroot src/system/libroot/os src/system/libroot/posix/stdlib src/system/runtime_loader In-Reply-To: <20070727140951.794.1@cs.tu-berlin.de> Message-ID: <563285263-BeMail@ibm> Ingo Weinhold wrote: > Hacky indeed. Did anything speak against just defining the required * > _port() I knew you'd like it :-) > symbols in the loader? Or probably even better, use KMessage in > KMESSAGE_CONTAINER_ONLY mode and send it yourself (maybe add a > KMessage::SetDeliveryInfo()). That seems to be a good idea! > > * Changed Tracker to use the new _kern_load_image() variant on > > Haiku to > > retrieve and report all missing libraries. This fixes bug #1324. > Am I the only one who's not overly happy with the Tracker (i.e. a > more or > less normal app) using syscalls directly? It smells like the > BRoster::Launch() methods should have an additional BMessage* > errorMessage > parameter. No, you're not - I just wanted to have a quick and dirty solution that mirrored how BeOS does it. It would be much cleaner to introduce a public 'what' constant, have an additional BRoster::Launch() variant, and have Tracker collect those messages in its main app - it would just need to get to the info which application was tried to be launched, at what it's parameters were (ie. the document that Tracker tried to open). It looks like the runtime loader could easily add fields for this information to the message, though. Bye, Axel. From axeld at pinc-software.de Sun Jul 29 16:50:51 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 29 Jul 2007 16:50:51 +0200 CEST Subject: [Haiku-commits] r21683 - haiku/trunk/src/kits/interface In-Reply-To: Message-ID: <2709470940-BeMail@ibm> "Ryan Leavengood" wrote: > On 7/26/07, Axel D?rfler wrote: > > Would anybody object to put something like that in the coding style > > guide? And if so, why? :-) [...] > Also in the copyright section: > > "In case everything is copyrighted to "Haiku Inc." and authors are > listed in lexicographic order by last name." > > Aren't names in order of contribution date? Indeed, I don't know who changed that, at least I'm pretty sure it used to say differently. In any case, it should be reverted to the contribution date. > Also Jonas posted a comment to the guidelines about prefixing private > methods with _underscore. This should be added too. Then that comment > can probably be deleted. Sounds good. There are lots of other cases where there is something missing in the guideline, and I hope we'll able to corner them in the future :-) Bye, Axel. From axeld at pinc-software.de Sun Jul 29 17:49:19 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 29 Jul 2007 17:49:19 +0200 CEST Subject: [Haiku-commits] r21651 - haiku/trunk/src/preferences/joysticks In-Reply-To: Message-ID: <6217435340-BeMail@ibm> "Ryan Leavengood" wrote: > On 7/19/07, Axel D?rfler wrote: > > leavengood at BerliOS wrote: > > > - char buf[256]; > > > + char buf[BEOS_NAME_LENGTH]; > > Did you mean B_FILE_NAME_LENGTH by any chance? > > At least I am not aware that there is such a constant. > Hmmm, Haiku built fine for me (on Linux) with that patch, so maybe > there is such a constant? At least I couldn't compile Joysticks here anymore :-) > In searching the WebSVN I couldn't find it in any obvious places > though. But if it is the same size as B_OS_NAME_LENGTH (32), then it > probably should be changed to something bigger since the old constant > was 256. Of course 256 was probably overkill. No, absolutely not - since you get a file path in return, actually B_PATH_NAME_LENGTH (1024) would be appropriate. However, in BeOS, the device path is limited in several places to 256 bytes - so B_FILE_NAME_LENGTH is a perfect fit for now. Bye, Axel. From axeld at mail.berlios.de Sun Jul 29 23:36:50 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 29 Jul 2007 23:36:50 +0200 Subject: [Haiku-commits] r21740 - in haiku/trunk: headers/private/kernel/util src/system/kernel/messaging src/system/runtime_loader Message-ID: <200707292136.l6TLaoc6028433@sheep.berlios.de> Author: axeld Date: 2007-07-29 23:36:49 +0200 (Sun, 29 Jul 2007) New Revision: 21740 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21740&view=rev Modified: haiku/trunk/headers/private/kernel/util/KMessage.h haiku/trunk/src/system/kernel/messaging/KMessage.cpp haiku/trunk/src/system/runtime_loader/Jamfile haiku/trunk/src/system/runtime_loader/elf.cpp Log: * Followed Ingo's suggestion and send the message manually in the runtime loader; therefore, we could remove the ugly defines from KMessage again, and compile it with KMESSAGE_CONTAINER_ONLY. * Added KMessage::SetDeliveryInfo() to be able to send messages with a correct header. * Fixed a bug in KMessage::SendTo() that would not send the senderTeam when passing a negative value for the parameter, but override it when passing in a valid value. Modified: haiku/trunk/headers/private/kernel/util/KMessage.h =================================================================== --- haiku/trunk/headers/private/kernel/util/KMessage.h 2007-07-29 21:12:21 UTC (rev 21739) +++ haiku/trunk/headers/private/kernel/util/KMessage.h 2007-07-29 21:36:49 UTC (rev 21740) @@ -1,8 +1,7 @@ /* - * Copyright 2005, Ingo Weinhold, bonefish at users.sf.net. All rights reserved. + * Copyright 2005-2007, Ingo Weinhold, bonefish at users.sf.net. All rights reserved. * Distributed under the terms of the MIT License. */ - #ifndef KMESSAGE_H #define KMESSAGE_H @@ -119,6 +118,9 @@ port_id ReplyPort() const; int32 ReplyToken() const; + void SetDeliveryInfo(int32 targetToken, port_id replyPort, + int32 replyToken, team_id senderTeam); + status_t SendTo(port_id targetPort, int32 targetToken = -1, port_id replyPort = -1, int32 replyToken = -1, bigtime_t timeout = -1, team_id senderTeam = -1); Modified: haiku/trunk/src/system/kernel/messaging/KMessage.cpp =================================================================== --- haiku/trunk/src/system/kernel/messaging/KMessage.cpp 2007-07-29 21:12:21 UTC (rev 21739) +++ haiku/trunk/src/system/kernel/messaging/KMessage.cpp 2007-07-29 21:36:49 UTC (rev 21740) @@ -32,21 +32,6 @@ # endif #endif -#ifdef _LOADER_MODE -# include - -# define KMESSAGE_NO_RECEIVE - -# define create_port(capacity, name) _kern_create_port(capacity, name) -# define delete_port(port) _kern_delete_port(port) -# define write_port(port, code, buffer, bufferSize) \ - _kern_write_port_etc(port, code, buffer, bufferSize, 0, 0) -# define write_port_etc(port, code, buffer, bufferSize, flags, timeout) \ - _kern_write_port_etc(port, code, buffer, bufferSize, flags, timeout) -# define set_port_owner(port, team) _kern_set_port_owner(port, team) -# define _get_port_info(port, info, size) _kern_get_port_info(port, info) -#endif - static const int32 kMessageReallocChunkSize = 64; // kMessageHeaderMagic @@ -451,6 +436,18 @@ return _Header()->replyToken; } +// SetDeliveryInfo +void +KMessage::SetDeliveryInfo(int32 targetToken, port_id replyPort, + int32 replyToken, team_id senderTeam) +{ + Header* header = _Header(); + header->sender = senderTeam; + header->targetToken = targetToken; + header->replyPort = replyPort; + header->replyToken = replyToken; + header->sender = senderTeam; +} #ifndef KMESSAGE_CONTAINER_ONLY @@ -459,23 +456,22 @@ KMessage::SendTo(port_id targetPort, int32 targetToken, port_id replyPort, int32 replyToken, bigtime_t timeout, team_id senderTeam) { - // set the deliver info - Header* header = _Header(); - header->sender = senderTeam; - header->targetToken = targetToken; - header->replyPort = replyPort; - header->replyToken = replyToken; // get the sender team - if (senderTeam >= 0) { + if (senderTeam < 0) { thread_info info; status_t error = get_thread_info(find_thread(NULL), &info); if (error != B_OK) return error; - header->sender = info.team; + + senderTeam = info.team; } + + SetDeliveryInfo(targetToken, replyPort, replyToken, senderTeam); + // send the message if (timeout < 0) return write_port(targetPort, 'KMSG', fBuffer, ContentSize()); + return write_port_etc(targetPort, 'KMSG', fBuffer, ContentSize(), B_RELATIVE_TIMEOUT, timeout); } @@ -561,9 +557,6 @@ status_t KMessage::ReceiveFrom(port_id fromPort, bigtime_t timeout) { -#ifdef KMESSAGE_NO_RECEIVE - return B_NOT_SUPPORTED; -#else // get the port buffer size ssize_t size; if (timeout < 0) @@ -587,7 +580,6 @@ // init the message return SetTo(buffer, size, 0, KMESSAGE_OWNS_BUFFER | KMESSAGE_INIT_FROM_BUFFER); -#endif // !KMESSAGE_NO_RECEIVE } #endif // !KMESSAGE_CONTAINER_ONLY Modified: haiku/trunk/src/system/runtime_loader/Jamfile =================================================================== --- haiku/trunk/src/system/runtime_loader/Jamfile 2007-07-29 21:12:21 UTC (rev 21739) +++ haiku/trunk/src/system/runtime_loader/Jamfile 2007-07-29 21:36:49 UTC (rev 21740) @@ -10,6 +10,7 @@ # default to BeOS style symbol resolution DEFINES += BEOS_STYLE_SYMBOLS_RESOLUTION + KMESSAGE_CONTAINER_ONLY _LOADER_MODE ; Modified: haiku/trunk/src/system/runtime_loader/elf.cpp =================================================================== --- haiku/trunk/src/system/runtime_loader/elf.cpp 2007-07-29 21:12:21 UTC (rev 21739) +++ haiku/trunk/src/system/runtime_loader/elf.cpp 2007-07-29 21:36:49 UTC (rev 21740) @@ -183,6 +183,13 @@ } +static inline bool +report_errors() +{ + return gProgramArgs->error_port >= 0; +} + + static image_t * find_image_in_queue(image_queue_t *queue, const char *name, bool isPath, uint32 typeMask) @@ -1097,7 +1104,7 @@ load_dependencies(image_t *image) { struct Elf32_Dyn *d = (struct Elf32_Dyn *)image->dynamic_ptr; - bool reportErrors = gProgramArgs->error_port >= 0; + bool reportErrors = report_errors(); status_t status = B_OK; uint32 i, j; const char *rpath; @@ -1339,10 +1346,14 @@ err: delete_image(sProgramImage); - if (gProgramArgs->error_port >= 0) { + if (report_errors()) { + // send error message sErrorMessage.AddInt32("error", status); - sErrorMessage.SendTo(gProgramArgs->error_port, gProgramArgs->error_token, - -1, 0, 0, find_thread(NULL)); + sErrorMessage.SetDeliveryInfo(gProgramArgs->error_token, + -1, 0, find_thread(NULL)); + + _kern_write_port_etc(gProgramArgs->error_port, 'KMSG', + sErrorMessage.Buffer(), sErrorMessage.ContentSize(), 0, 0); } _kern_loading_app_failed(status); rld_unlock(); @@ -1651,7 +1662,7 @@ } // initialize error message if needed - if (gProgramArgs->error_port >= 0) { + if (report_errors()) { void *buffer = malloc(1024); if (buffer == NULL) return; From mmlr at mail.berlios.de Sun Jul 29 23:46:11 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 29 Jul 2007 23:46:11 +0200 Subject: [Haiku-commits] r21741 - haiku/trunk/src/add-ons/kernel/bus_managers/usb Message-ID: <200707292146.l6TLkBUY029262@sheep.berlios.de> Author: mmlr Date: 2007-07-29 23:46:10 +0200 (Sun, 29 Jul 2007) New Revision: 21741 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21741&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp Log: Initialize the endpoints of all interfaces of the configuration to be set. Fixes stuff that needs more than one interface at the same time (ACM modems for example). Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp 2007-07-29 21:36:49 UTC (rev 21740) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp 2007-07-29 21:46:10 UTC (rev 21741) @@ -330,41 +330,43 @@ fCurrentConfiguration = &fConfigurations[index]; // Initialize all the endpoints that are now active - usb_interface_info *interfaceInfo = fCurrentConfiguration->interface[0].active; - for (size_t i = 0; i < interfaceInfo->endpoint_count; i++) { - usb_endpoint_info *endpoint = &interfaceInfo->endpoint[i]; - Pipe *pipe = NULL; + for (size_t j = 0; j < fCurrentConfiguration->interface_count; j++) { + usb_interface_info *interfaceInfo = fCurrentConfiguration->interface[j].active; + for (size_t i = 0; i < interfaceInfo->endpoint_count; i++) { + usb_endpoint_info *endpoint = &interfaceInfo->endpoint[i]; + Pipe *pipe = NULL; - switch (endpoint->descr->attributes & 0x03) { - case 0x00: /* Control Endpoint */ - pipe = new(std::nothrow) ControlPipe(this, fDeviceAddress, - endpoint->descr->endpoint_address & 0x0f, fSpeed, - endpoint->descr->max_packet_size); - break; + switch (endpoint->descr->attributes & 0x03) { + case 0x00: /* Control Endpoint */ + pipe = new(std::nothrow) ControlPipe(this, fDeviceAddress, + endpoint->descr->endpoint_address & 0x0f, fSpeed, + endpoint->descr->max_packet_size); + break; - case 0x01: /* Isochronous Endpoint */ - pipe = new(std::nothrow) IsochronousPipe(this, fDeviceAddress, - endpoint->descr->endpoint_address & 0x0f, - (endpoint->descr->endpoint_address & 0x80) > 0 ? Pipe::In : Pipe::Out, - fSpeed, endpoint->descr->max_packet_size); - break; + case 0x01: /* Isochronous Endpoint */ + pipe = new(std::nothrow) IsochronousPipe(this, fDeviceAddress, + endpoint->descr->endpoint_address & 0x0f, + (endpoint->descr->endpoint_address & 0x80) > 0 ? Pipe::In : Pipe::Out, + fSpeed, endpoint->descr->max_packet_size); + break; - case 0x02: /* Bulk Endpoint */ - pipe = new(std::nothrow) BulkPipe(this, fDeviceAddress, - endpoint->descr->endpoint_address & 0x0f, - (endpoint->descr->endpoint_address & 0x80) > 0 ? Pipe::In : Pipe::Out, - fSpeed, endpoint->descr->max_packet_size); - break; + case 0x02: /* Bulk Endpoint */ + pipe = new(std::nothrow) BulkPipe(this, fDeviceAddress, + endpoint->descr->endpoint_address & 0x0f, + (endpoint->descr->endpoint_address & 0x80) > 0 ? Pipe::In : Pipe::Out, + fSpeed, endpoint->descr->max_packet_size); + break; - case 0x03: /* Interrupt Endpoint */ - pipe = new(std::nothrow) InterruptPipe(this, fDeviceAddress, - endpoint->descr->endpoint_address & 0x0f, - (endpoint->descr->endpoint_address & 0x80) > 0 ? Pipe::In : Pipe::Out, - fSpeed, endpoint->descr->max_packet_size); - break; + case 0x03: /* Interrupt Endpoint */ + pipe = new(std::nothrow) InterruptPipe(this, fDeviceAddress, + endpoint->descr->endpoint_address & 0x0f, + (endpoint->descr->endpoint_address & 0x80) > 0 ? Pipe::In : Pipe::Out, + fSpeed, endpoint->descr->max_packet_size); + break; + } + + endpoint->handle = pipe->USBID(); } - - endpoint->handle = pipe->USBID(); } // Wait some for the configuration being finished @@ -400,11 +402,13 @@ if (!fCurrentConfiguration) return B_OK; - usb_interface_info *interfaceInfo = fCurrentConfiguration->interface[0].active; - for (size_t i = 0; i < interfaceInfo->endpoint_count; i++) { - usb_endpoint_info *endpoint = &interfaceInfo->endpoint[i]; - delete (Pipe *)GetStack()->GetObject(endpoint->handle); - endpoint->handle = 0; + for (size_t j = 0; j < fCurrentConfiguration->interface_count; j++) { + usb_interface_info *interfaceInfo = fCurrentConfiguration->interface[j].active; + for (size_t i = 0; i < interfaceInfo->endpoint_count; i++) { + usb_endpoint_info *endpoint = &interfaceInfo->endpoint[i]; + delete (Pipe *)GetStack()->GetObject(endpoint->handle); + endpoint->handle = 0; + } } fCurrentConfiguration = NULL; From jackburton at mail.berlios.de Mon Jul 30 10:59:13 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 30 Jul 2007 10:59:13 +0200 Subject: [Haiku-commits] r21742 - haiku/trunk/src/apps/terminal Message-ID: <200707300859.l6U8xD9M002578@sheep.berlios.de> Author: jackburton Date: 2007-07-30 10:59:12 +0200 (Mon, 30 Jul 2007) New Revision: 21742 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21742&view=rev Modified: haiku/trunk/src/apps/terminal/SmartTabView.cpp haiku/trunk/src/apps/terminal/SmartTabView.h haiku/trunk/src/apps/terminal/TermParse.cpp haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h haiku/trunk/src/apps/terminal/TermWindow.cpp Log: Don't use exceptions in TermView constructor, as it would cause problems with instantiation. Note that if an error occurs in the constructor, we're pretty much screwed. Made some TermView functions private. Some small cleanup, and some WIP code. Modified: haiku/trunk/src/apps/terminal/SmartTabView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/SmartTabView.cpp 2007-07-29 21:46:10 UTC (rev 21741) +++ haiku/trunk/src/apps/terminal/SmartTabView.cpp 2007-07-30 08:59:12 UTC (rev 21742) @@ -32,4 +32,39 @@ view->ResizeTo(Bounds().Width(), Bounds().Height()); } } + +/* +void +SmartTabView::AddTab(BView *target, BTab *tab) +{ + if (target == NULL) + return; + + if (CountTabs() == 1) { + + } + AddTab(target, tab); +} + + +BTab * +SmartTabView::RemoveTab(int32 index) +{ + BTab *oldTab = RemoveTab(index); + if (CountTabs() == 1) { + + } + return oldTab; +} + + +BRect +SmartTabView::DrawTabs() +{ + //if (CountTabs() > 1) + return BTabView::DrawTabs(); + //return BRect(0, 0, -1, -1); +} +*/ + Modified: haiku/trunk/src/apps/terminal/SmartTabView.h =================================================================== --- haiku/trunk/src/apps/terminal/SmartTabView.h 2007-07-29 21:46:10 UTC (rev 21741) +++ haiku/trunk/src/apps/terminal/SmartTabView.h 2007-07-30 08:59:12 UTC (rev 21742) @@ -20,7 +20,11 @@ B_WILL_DRAW | B_NAVIGABLE_JUMP | B_FRAME_EVENTS | B_NAVIGABLE); virtual ~SmartTabView(); - virtual void Select(int32 tab); + virtual void Select(int32 tab); + /* + virtual void AddTab(BView *target, BTab *tab = NULL); + virtual BTab* RemoveTab(int32 index); + virtual BRect DrawTabs();*/ }; Modified: haiku/trunk/src/apps/terminal/TermParse.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-29 21:46:10 UTC (rev 21741) +++ haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-30 08:59:12 UTC (rev 21742) @@ -435,7 +435,7 @@ cbuf[2] = c; cbuf[3] = '\0'; width = CodeConv::UTF8GetFontWidth((char*)cbuf); - fView->PutChar (cbuf, attr, width); + fView->PutChar(cbuf, attr, width); break; case CASE_MBCS: Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-29 21:46:10 UTC (rev 21741) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-30 08:59:12 UTC (rev 21742) @@ -44,8 +44,6 @@ #include -using std::nothrow; - // defined VTKeyTbl.c extern int function_keycode_table[]; extern char *function_key_char_table[]; @@ -209,6 +207,7 @@ fQuitting(false), fIMflag(false) { + printf("TermView(BMessage *)\n"); if (archive->FindInt32("encoding", (int32 *)&fEncoding) < B_OK) fEncoding = M_UTF8; if (archive->FindInt32("columns", (int32 *)&fTermColumns) < B_OK) @@ -217,32 +216,38 @@ fTermRows = 25; // TODO: Retrieve command, colors, history size, etc. from archive - _InitObject(NULL); + printf("_InitObject() returned %s\n", strerror(_InitObject(NULL))); } -void +status_t TermView::_InitObject(const char *command) { - fTextBuffer = new TermBuffer(fTermRows, fTermColumns, fScrBufSize); + SetTermFont(be_fixed_font, be_fixed_font); - SetTermFont(be_fixed_font, be_fixed_font); + fTextBuffer = new (std::nothrow) TermBuffer(fTermRows, fTermColumns, fScrBufSize); + if (fTextBuffer == NULL) + return B_NO_MEMORY; + + fShell = new (std::nothrow) Shell(); + if (fShell == NULL) + return B_NO_MEMORY; - //SetIMAware(false); - - fShell = new Shell(); status_t status = fShell->Open(fTermRows, fTermColumns, command, longname2shortname(id2longname(fEncoding))); if (status < B_OK) - throw status; + return status; status = AttachShell(fShell); if (status < B_OK) - throw status; + return status; SetTermSize(fTermRows, fTermColumns, false); + //SetIMAware(false); _InitMouseThread(); + + return B_OK; } @@ -262,8 +267,11 @@ BArchivable * TermView::Instantiate(BMessage* data) { + printf("TermView::Instantiate()\n"); if (validate_instantiation(data, "TermView")) - return new TermView(data); + return new (std::nothrow) TermView(data); + + printf("Returned NULL\n"); return NULL; } @@ -271,17 +279,15 @@ status_t TermView::Archive(BMessage* data, bool deep) const { + printf("TermView::Archive()\n"); status_t status = BView::Archive(data, deep); - if (status < B_OK) - return status; - status = data->AddInt32("encoding", (int32)fEncoding); - if (status < B_OK) - return status; - status = data->AddInt32("columns", (int32)fTermColumns); - if (status < B_OK) - return status; - status = data->AddInt32("rows", (int32)fTermRows); - + if (status == B_OK) + status = data->AddInt32("encoding", (int32)fEncoding); + if (status == B_OK) + status = data->AddInt32("columns", (int32)fTermColumns); + if (status == B_OK) + status = data->AddInt32("rows", (int32)fTermRows); + printf("Archive() returned %s\n", strerror(status)); return status; } @@ -1438,7 +1444,7 @@ if (fIMflag) return; - // If bytes[0] equal intr charactor, + // If bytes[0] equal intr character, // send signal to shell process group. struct termios tio; fShell->GetAttr(tio); @@ -1448,9 +1454,8 @@ } // Terminal changes RET, ENTER, F1...F12, and ARROW key code. - if (numBytes == 1) { - switch (*bytes) { + switch (bytes[0]) { case B_RETURN: { char c = 0x0d; @@ -1537,10 +1542,11 @@ } else { // input multibyte character if (fEncoding != M_UTF8) { - uchar dstbuf[1024]; + uchar destBuffer[1024]; int cnum = CodeConv::ConvertFromInternal(bytes, numBytes, - (char *)dstbuf, fEncoding); - fShell->Write(dstbuf, cnum); + (char *)destBuffer, fEncoding); + fShell->Write(destBuffer, cnum); + destBuffer[cnum] = 0; } } } Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2007-07-29 21:46:10 UTC (rev 21741) +++ haiku/trunk/src/apps/terminal/TermView.h 2007-07-30 08:59:12 UTC (rev 21742) @@ -66,9 +66,7 @@ void PutNL(int num); void SetInsertMode(int flag); void InsertSpace(int num); - int TermDraw(const CurPos &start, const CurPos &end); - int TermDrawRegion(CurPos start, CurPos end); - int TermDrawSelectedRegion(CurPos start, CurPos end); + // Delete Charactor void EraseBelow(); void DeleteChar(int num); @@ -131,12 +129,16 @@ const char *property); private: - void _InitObject(const char *command); + status_t _InitObject(const char *command); static int32 MouseTracking(void *); status_t _InitMouseThread(void); void DrawLines(int , int, ushort, uchar *, int, int, int, BView *); + int TermDraw(const CurPos &start, const CurPos &end); + int TermDrawRegion(CurPos start, CurPos end); + int TermDrawSelectedRegion(CurPos start, CurPos end); + void DoPrint(BRect updateRect); void ResizeScrBarRange (void); void DoFileDrop(entry_ref &ref); @@ -147,7 +149,7 @@ void DoSelectAll(); void DoClearAll(); - void WritePTY (const uchar *text, int num_byteses); + void WritePTY(const uchar *text, int num_byteses); // Comunicate Input Method // void DoIMStart (BMessage* message); Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-29 21:46:10 UTC (rev 21741) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-30 08:59:12 UTC (rev 21742) @@ -50,7 +50,7 @@ const static float kViewOffset = 3; -#if 0 +/* TermWindow::TermWindow(BRect frame, const char* title, const char *command) : BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE), @@ -76,13 +76,22 @@ fMatchCase(false), fMatchWord(false) { + fTabView = new SmartTabView(Bounds(), "Tab view"); AddChild(fTabView); _NewTab(command); _NewTab(NULL); + + BView *view = new TermView(Bounds()); + AddChild(view); + BRect draggerFrame(0, 0, 16, 16); + draggerFrame.OffsetTo(Bounds().RightBottom() - BPoint(16, 16)); + BDragger *dragger = new BDragger(draggerFrame, view, B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM, B_WILL_DRAW); + + view->AddChild(dragger); } -#endif +*/ TermWindow::TermWindow(BRect frame, const char* title, const char *command) From stefano.ceccherini at gmail.com Mon Jul 30 11:48:02 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 30 Jul 2007 11:48:02 +0200 Subject: [Haiku-commits] r21742 - haiku/trunk/src/apps/terminal In-Reply-To: <200707300859.l6U8xD9M002578@sheep.berlios.de> References: <200707300859.l6U8xD9M002578@sheep.berlios.de> Message-ID: <894b9700707300248i10209d05l952ed4923e3eea19@mail.gmail.com> 2007/7/30, jackburton at BerliOS : > Log: > Don't use exceptions in TermView constructor, as it would cause problems > with instantiation. Could we add a try {} catch block in BShelf, where it uses instantiate_object(), to handle those constructors which throw an exception ? From jackburton at mail.berlios.de Mon Jul 30 11:59:17 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 30 Jul 2007 11:59:17 +0200 Subject: [Haiku-commits] r21743 - haiku/trunk/src/apps/terminal Message-ID: <200707300959.l6U9xHER006147@sheep.berlios.de> Author: jackburton Date: 2007-07-30 11:59:17 +0200 (Mon, 30 Jul 2007) New Revision: 21743 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21743&view=rev Modified: haiku/trunk/src/apps/terminal/TermParse.cpp haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h haiku/trunk/src/apps/terminal/TermWindow.cpp Log: Added a TermView::NotifyQuit() method, used in TermParse, so it doesn't mess with be_app anymore. Renamed TermView private methods to have an underscore prefix. Modified: haiku/trunk/src/apps/terminal/TermParse.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-30 08:59:12 UTC (rev 21742) +++ haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-30 09:59:17 UTC (rev 21743) @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -150,7 +149,8 @@ uchar buf[READ_BUF_SIZE]; int nread = read(fFd, buf, READ_BUF_SIZE - (read_p - fBufferPosition)); if (nread <= 0) { - be_app->PostMessage(B_QUIT_REQUESTED); + // TODO: errno ? (Jerome ?) :) + fView->NotifyQuit(nread); exit_thread(B_ERROR); } Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-30 08:59:12 UTC (rev 21742) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-30 09:59:17 UTC (rev 21743) @@ -14,7 +14,6 @@ #include "TermView.h" #include "CodeConv.h" -#include "PrefView.h" #include "Shell.h" #include "TermBuffer.h" #include "TermConst.h" @@ -545,7 +544,7 @@ UpdateLine(); fTextBuffer->InsertSpace(fCurPos, num); - TermDraw(fCurPos, CurPos(fTermColumns - 1, fCurPos.y)); + _TermDraw(fCurPos, CurPos(fTermColumns - 1, fCurPos.y)); } @@ -560,14 +559,14 @@ //! Draw region inline int -TermView::TermDraw(const CurPos &start, const CurPos &end) +TermView::_TermDraw(const CurPos &start, const CurPos &end) { int x1 = start.x; int y1 = start.y; int x2 = end.x; int y2 = end.y; - Redraw(x1, y1 + fTop / fFontHeight, + _Redraw(x1, y1 + fTop / fFontHeight, x2, y2 + fTop / fFontHeight); return 0; @@ -576,7 +575,7 @@ //! Draw region int -TermView::TermDrawSelectedRegion(CurPos start, CurPos end) +TermView::_TermDrawSelectedRegion(CurPos start, CurPos end) { CurPos inPos; @@ -587,14 +586,14 @@ } if (start.y == end.y) { - Redraw(start.x, start.y, end.x, end.y); + _Redraw(start.x, start.y, end.x, end.y); } else { - Redraw(start.x, start.y, fTermColumns, start.y); + _Redraw(start.x, start.y, fTermColumns, start.y); if (end.y - start.y > 0) - Redraw(0, start.y + 1, fTermColumns, end.y - 1); + _Redraw(0, start.y + 1, fTermColumns, end.y - 1); - Redraw(0, end.y, end.x, end.y); + _Redraw(0, end.y, end.x, end.y); } return 0; @@ -603,7 +602,7 @@ //! Draw region int -TermView::TermDrawRegion(CurPos start, CurPos end) +TermView::_TermDrawRegion(CurPos start, CurPos end) { CurPos inPos; int top = fTop / fFontHeight; @@ -618,14 +617,14 @@ end.y += top; if (start.y == end.y) { - Redraw(start.x, start.y, end.x, end.y); + _Redraw(start.x, start.y, end.x, end.y); } else { - Redraw(start.x, start.y, fTermColumns - 1, start.y); + _Redraw(start.x, start.y, fTermColumns - 1, start.y); if (end.y - start.y > 0) { - Redraw(0, start.y + 1, fTermColumns - 1, end.y - 1); + _Redraw(0, start.y + 1, fTermColumns - 1, end.y - 1); } - Redraw(0, end.y, end.x, end.y); + _Redraw(0, end.y, end.x, end.y); } return 0; @@ -639,9 +638,9 @@ UpdateLine(); fTextBuffer->EraseBelow(fCurPos); - TermDraw(fCurPos, CurPos(fTermColumns - 1, fCurPos.y)); + _TermDraw(fCurPos, CurPos(fTermColumns - 1, fCurPos.y)); if (fCurPos.y != fTermRows - 1) - TermDraw(CurPos(0, fCurPos.y + 1), CurPos(fTermColumns - 1, fTermRows - 1)); + _TermDraw(CurPos(0, fCurPos.y + 1), CurPos(fTermColumns - 1, fTermRows - 1)); } @@ -652,7 +651,7 @@ UpdateLine(); fTextBuffer->DeleteChar(fCurPos, num); - TermDraw(fCurPos, CurPos(fTermColumns - 1, fCurPos.y)); + _TermDraw(fCurPos, CurPos(fTermColumns - 1, fCurPos.y)); } @@ -663,7 +662,7 @@ UpdateLine(); fTextBuffer->DeleteChar(fCurPos, fTermColumns - fCurPos.x); - TermDraw(fCurPos, CurPos(fTermColumns - 1, fCurPos.y)); + _TermDraw(fCurPos, CurPos(fTermColumns - 1, fCurPos.y)); } @@ -817,7 +816,7 @@ ushort attr; int top = fTop / fFontHeight; - bool m_flag = CheckSelectedRegion(CurPos(fCurPos.x, fCurPos.y + fTop / fFontHeight)); + bool m_flag = _CheckSelectedRegion(CurPos(fCurPos.x, fCurPos.y + fTop / fFontHeight)); if (fTextBuffer->GetChar(fCurPos.y + top, fCurPos.x, buf, &attr) == A_CHAR) { int width; if (IS_WIDTH(attr)) @@ -825,7 +824,7 @@ else width = 1; - DrawLines(fCurPos.x * fFontWidth, + _DrawLines(fCurPos.x * fFontWidth, fCurPos.y * fFontHeight + fTop, attr, buf, width, m_flag, true, this); } else { @@ -848,7 +847,7 @@ && fCursorBlinkingFlag == CURON && Window()->IsActive()) { if (fCursorStatus == CURON) - TermDraw(fCurPos, fCurPos); + _TermDraw(fCurPos, fCurPos); else DrawCursor(); @@ -864,7 +863,7 @@ { if (flag == CUROFF) { if (fCursorStatus == CURON) - TermDraw(fCurPos, fCurPos); + _TermDraw(fCurPos, fCurPos); fCursorStatus = CUROFF; fCursorDrawFlag = CUROFF; @@ -909,7 +908,7 @@ bot = fScrBot; fTextBuffer->ScrollRegion(top, bot , dir ,num); - TermDraw(CurPos(0, top), CurPos(fTermColumns - 1, bot)); + _TermDraw(CurPos(0, top), CurPos(fTermColumns - 1, bot)); } @@ -941,7 +940,7 @@ TermView::ScrollAtCursor() { if (LockLooper()) { - ResizeScrBarRange(); + _ResizeScrBarRange(); fScrollUpCount = 0; ScrollTo(0, fTop); UnlockLooper(); @@ -954,7 +953,7 @@ { // spawn Mouse Tracking thread. if (fMouseThread < 0) { - fMouseThread = spawn_thread(MouseTracking, "MouseTracking", + fMouseThread = spawn_thread(_MouseTrackingEntryFunction, "MouseTracking", B_NORMAL_PRIORITY,this); } else return B_BAD_THREAD_ID; @@ -963,9 +962,17 @@ } +/* static */ +int32 +TermView::_MouseTrackingEntryFunction(void *data) +{ + return static_cast(data)->_MouseTracking(); +} + + //! Thread for tracking mouse. int32 -TermView::MouseTracking(void *data) +TermView::_MouseTracking() { int32 code, selected = false; uint32 button; @@ -974,130 +981,126 @@ BPoint stpoint, edpoint; float scr_start, scr_end, scr_pos; - TermView *theObj =(TermView *)data; - - while(!theObj->fQuitting) { - - if (1) { -#ifdef CHANGE_CURSOR_IMAGE - if (!has_data(find_thread(NULL))) { - BRect r; - - if (theObj->HasSelection() - && (modifiers() & B_CONTROL_KEY)) { - - if (theObj->LockLooper()) { - theObj->GetMouse(&stpoint, &button); - r = theObj->Bounds(); - theObj->UnlockLooper(); - } - if (r.Contains(stpoint)) { - CurPos tmppos = theObj->BPointToCurPos(stpoint); - if (theObj->fSelStart > theObj->fSelEnd) { - stpos = theObj->fSelEnd; - edpos = theObj->fSelStart; - } else { - stpos = theObj->fSelStart; - edpos = theObj->fSelEnd; + while(!fQuitting) { + if (1) { + #ifdef CHANGE_CURSOR_IMAGE + if (!has_data(find_thread(NULL))) { + BRect r; + + if (_HasSelection() + && (modifiers() & B_CONTROL_KEY)) { + + if (LockLooper()) { + GetMouse(&stpoint, &button); + r = Bounds(); + UnlockLooper(); } - - if (tmppos > stpos && tmppos < edpos) - be_app->SetCursor(M_ADD_CURSOR); - else - be_app->SetCursor(B_HAND_CURSOR); + if (r.Contains(stpoint)) { + CurPos tmppos = _BPointToCurPos(stpoint); + if (fSelStart > fSelEnd) { + stpos = fSelEnd; + edpos = fSelStart; + } else { + stpos = fSelStart; + edpos = fSelEnd; + } + + if (tmppos > stpos && tmppos < edpos) + be_app->SetCursor(M_ADD_CURSOR); + else + be_app->SetCursor(B_HAND_CURSOR); + } } + snooze(50 * 1000); + continue; + } else { +#endif + code = receive_data(&sender,(void *)&stpoint, sizeof(BPoint)); } - snooze(50 * 1000); - continue; - } else { -#endif - code = receive_data(&sender,(void *)&stpoint, sizeof(BPoint)); - } - if (code != MOUSE_THR_CODE) - continue; + if (code != MOUSE_THR_CODE) + continue; - selected = theObj->HasSelection(); - edpoint.Set(-1, -1); - - stpos = theObj->BPointToCurPos(stpoint); - - do { + selected = _HasSelection(); + edpoint.Set(-1, -1); - snooze(40 * 1000); + stpos = _BPointToCurPos(stpoint); - if (theObj->LockLooper()) { - theObj->GetMouse(&edpoint, &button); - theObj->UnlockLooper(); - } - - edpos = theObj->BPointToCurPos(edpoint); - if (edpos.y < 0) - continue; + do { + + snooze(40 * 1000); + + if (LockLooper()) { + GetMouse(&edpoint, &button); + UnlockLooper(); + } + + edpos = _BPointToCurPos(edpoint); + if (edpos.y < 0) + continue; - if (stpoint == edpoint) { - continue; - } else { - if (!selected) { - theObj->Select(stpos, edpos); - selected = true; - } else { - - // Align cursor point to text. - if (stpos == edpos) + if (stpoint == edpoint) { continue; - - if (edpos > stpos) { - edpoint.x -= theObj->fFontWidth / 2; - edpos = theObj->BPointToCurPos(edpoint); - //edpos.x--; - if (edpos.x < 0) - edpos.x = 0; - } - else - if (edpos < stpos) { - edpoint.x += theObj->fFontWidth / 2; - edpos = theObj->BPointToCurPos(edpoint); - //edpos.x++; - if (edpos.x > theObj->fTermColumns) - edpos.x = theObj->fTermColumns; - } - - // Scroll check - if (theObj->fScrollBar != NULL && theObj->LockLooper()) { - // Get now scroll point - theObj->fScrollBar->GetRange(&scr_start, &scr_end); - scr_pos = theObj->fScrollBar->Value(); + } else { + if (!selected) { + _Select(stpos, edpos); + selected = true; + } else { - if (edpoint.y < theObj->Bounds().LeftTop().y ) - - // mouse point left of window - if (scr_pos != scr_start) - theObj->ScrollTo(0, edpoint.y); + // Align cursor point to text. + if (stpos == edpos) + continue; - if (edpoint.y > theObj->Bounds().LeftBottom().y) { + if (edpos > stpos) { + edpoint.x -= fFontWidth / 2; + edpos = _BPointToCurPos(edpoint); + //edpos.x--; + if (edpos.x < 0) + edpos.x = 0; + } + else + if (edpos < stpos) { + edpoint.x += fFontWidth / 2; + edpos = _BPointToCurPos(edpoint); + //edpos.x++; + if (edpos.x > fTermColumns) + edpos.x = fTermColumns; + } - // mouse point left of window - if (scr_pos != scr_end) - theObj->ScrollTo(0, edpoint.y); + // Scroll check + if (fScrollBar != NULL && LockLooper()) { + // Get now scroll point + fScrollBar->GetRange(&scr_start, &scr_end); + scr_pos = fScrollBar->Value(); + + if (edpoint.y < Bounds().LeftTop().y ) + + // mouse point left of window + if (scr_pos != scr_start) + ScrollTo(0, edpoint.y); + + if (edpoint.y > Bounds().LeftBottom().y) { + + // mouse point left of window + if (scr_pos != scr_end) + ScrollTo(0, edpoint.y); + } + UnlockLooper(); + } + _ResizeSelectRegion(edpos); } - theObj->UnlockLooper(); } - theObj->ResizeSelectRegion(edpos); - } - } - } while(button); - theObj->fMouseTracking = false; + } while(button); + fMouseTracking = false; } - exit_thread(B_OK); return 0; } //! Draw character on offscreen bitmap. void -TermView::DrawLines(int x1, int y1, ushort attr, uchar *buf, +TermView::_DrawLines(int x1, int y1, ushort attr, uchar *buf, int width, int mouse, int cursor, BView *inView) { int x2, y2; @@ -1171,7 +1174,7 @@ //! Resize scroll bar range and knob size. void -TermView::ResizeScrBarRange() +TermView::_ResizeScrBarRange() { if (fScrollBar == NULL) return; @@ -1198,7 +1201,7 @@ if (fScrollUpCount > fTermRows ) { if (LockLooper()) { - ResizeScrBarRange(); + _ResizeScrBarRange(); fScrollBarRange += fScrollUpCount; fScrollUpCount = 0; ScrollTo(0, fTop); @@ -1214,7 +1217,7 @@ { if (fScrollUpCount){ if (LockLooper()) { - ResizeScrBarRange(); + _ResizeScrBarRange(); fScrollBarRange += fScrollUpCount; fScrollUpCount = 0; @@ -1230,10 +1233,10 @@ TermView::_UpdateSIGWINCH() { if (fFrameResized) { - if (HasSelection()) - TermDrawSelectedRegion(fSelStart, fSelEnd); + if (_HasSelection()) + _TermDrawSelectedRegion(fSelStart, fSelEnd); ScrollTo(0, fTop); - ResizeScrBarRange(); + _ResizeScrBarRange(); fShell->UpdateWindowSize(fTermRows, fTermColumns); @@ -1272,10 +1275,10 @@ { if (fUpdateFlag == true) { if (fInsertModeFlag == MODE_INSERT) { - TermDraw(CurPos(fBufferStartPos, fCurPos.y), + _TermDraw(CurPos(fBufferStartPos, fCurPos.y), CurPos(fTermColumns - 1, fCurPos.y)); } else { - TermDraw(CurPos(fBufferStartPos, fCurPos.y), + _TermDraw(CurPos(fBufferStartPos, fCurPos.y), CurPos(fCurPos.x - 1, fCurPos.y)); } fUpdateFlag = false; @@ -1318,7 +1321,7 @@ TermView::Draw(BRect updateRect) { if (IsPrinting()) { - DoPrint(updateRect); + _DoPrint(updateRect); return; } @@ -1350,7 +1353,7 @@ for (i = k; i <= x2;) { count = fTextBuffer->GetString(j, i, x2, buf, &attr); - m_flag = CheckSelectedRegion(CurPos(i, j)); + m_flag = _CheckSelectedRegion(CurPos(i, j)); if (count < 0) { if (m_flag) { @@ -1366,7 +1369,7 @@ continue; } - DrawLines(fFontWidth * i, fFontHeight * j, + _DrawLines(fFontWidth * i, fFontHeight * j, attr, buf, count, m_flag, false, this); i += count; if (i >= fTermColumns) @@ -1382,7 +1385,7 @@ void -TermView::DoPrint(BRect updateRect) +TermView::_DoPrint(BRect updateRect) { ushort attr; uchar buf[256]; @@ -1417,7 +1420,7 @@ continue; } - DrawLines(fFontWidth * i, fFontHeight * j, + _DrawLines(fFontWidth * i, fFontHeight * j, attr, buf, count, false, false, this); i += count; } @@ -1587,11 +1590,11 @@ { int32 i = 0; if (msg->FindRef("refs", i++, &ref) == B_OK) { - DoFileDrop(ref); + _DoFileDrop(ref); while (msg->FindRef("refs", i++, &ref) == B_OK) { - WritePTY((const uchar*)" ", 1); - DoFileDrop(ref); + _WritePTY((const uchar*)" ", 1); + _DoFileDrop(ref); } } else BView::MessageReceived(msg); @@ -1610,25 +1613,25 @@ if (sts != B_OK) break; - WritePTY((uchar *)text, numBytes); + _WritePTY((uchar *)text, numBytes); } break; } case B_COPY: - DoCopy(); + _DoCopy(); break; case B_PASTE: { int32 code; if (msg->FindInt32("index", &code) == B_OK) - DoPaste(); + _DoPaste(); break; } case B_SELECT_ALL: - DoSelectAll(); + _DoSelectAll(); break; case B_SET_PROPERTY: { @@ -1666,7 +1669,7 @@ } case MENU_CLEAR_ALL: - DoClearAll(); + _DoClearAll(); fShell->Write(ctrl_l, 1); break; @@ -1745,22 +1748,22 @@ //! Gets dropped file full path and display it at cursor position. void -TermView::DoFileDrop(entry_ref &ref) +TermView::_DoFileDrop(entry_ref &ref) { BEntry ent(&ref); BPath path(&ent); BString string(path.Path()); string.CharacterEscape(" ~`#$&*()\\|[]{};'\"<>?!",'\\'); - WritePTY((const uchar *)string.String(), string.Length()); + _WritePTY((const uchar *)string.String(), string.Length()); } //! Copy selected text to Clipboard. void -TermView::DoCopy() +TermView::_DoCopy() { - if (!HasSelection()) + if (!_HasSelection()) return; BString copyStr; @@ -1782,13 +1785,13 @@ // R5's Terminal app displays. We want to mimic the behavior, so we will // no longer do the deselection // if (!fMouseTracking) -// DeSelect(); +// _DeSelect(); } //! Paste clipboard text at cursor position. void -TermView::DoPaste() +TermView::_DoPaste() { if (be_clipboard->Lock()) { BMessage *clipMsg = be_clipboard->Data(); @@ -1798,7 +1801,7 @@ (const void **)&text, &numBytes) == B_OK ) { // Clipboard text doesn't attached EOF? text[numBytes] = '\0'; - WritePTY((uchar *)text, numBytes); + _WritePTY((uchar *)text, numBytes); } be_clipboard->Unlock(); @@ -1808,7 +1811,7 @@ //! Select all displayed text and text /in buffer. void -TermView::DoSelectAll(void) +TermView::_DoSelectAll(void) { CurPos start, end; int screen_top; @@ -1829,14 +1832,14 @@ end.y = fCurPos.y + screen_top; - Select(start, end); + _Select(start, end); } // Clear display and text buffer, then moves Cursorr at home position. void -TermView::DoClearAll(void) +TermView::_DoClearAll(void) { - DeSelect(); + _DeSelect(); fTextBuffer->Clear(); fTop = 0; @@ -1864,7 +1867,7 @@ encoding to UTF8 before writing PTY. */ void -TermView::WritePTY(const uchar *text, int numBytes) +TermView::_WritePTY(const uchar *text, int numBytes) { if (fEncoding != M_UTF8) { uchar *destBuffer = (uchar *)malloc(numBytes * 3); @@ -1886,14 +1889,14 @@ // paste button if ((buttons & (B_SECONDARY_MOUSE_BUTTON | B_TERTIARY_MOUSE_BUTTON)) != 0) { - if (HasSelection()) { + if (_HasSelection()) { // copy text from region BString copy; fTextBuffer->GetStringFromRegion(copy, fSelStart, fSelEnd); - WritePTY((uchar *)copy.String(), copy.Length()); + _WritePTY((uchar *)copy.String(), copy.Length()); } else { // copy text from clipboard. - DoPaste(); + _DoPaste(); } return; } @@ -1904,7 +1907,7 @@ Window()->CurrentMessage()->FindInt32("modifiers", &mod); Window()->CurrentMessage()->FindInt32("clicks", &clicks); - if (HasSelection()) { + if (_HasSelection()) { CurPos inPos, stPos, edPos; if (fSelStart < fSelEnd) { stPos = fSelStart; @@ -1914,7 +1917,7 @@ edPos = fSelStart; } - inPos = BPointToCurPos(where); + inPos = _BPointToCurPos(where); // If mouse pointer is avove selected Region, start Drag'n Copy. if (inPos > stPos && inPos < edPos) { @@ -1925,7 +1928,7 @@ GetMouse(&p, &bt); if (bt == 0) { - DeSelect(); + _DeSelect(); return; } @@ -1940,8 +1943,8 @@ BMessage msg(B_MIME_TYPE); msg.AddData("text/plain", B_MIME_TYPE, copyStr.String(), copyStr.Length()); - BPoint st = CurPosToBPoint(stPos); - BPoint ed = CurPosToBPoint(edPos); + BPoint st = _CurPosToBPoint(stPos); + BPoint ed = _CurPosToBPoint(edPos); BRect r; if (stPos.y == edPos.y) { @@ -1970,9 +1973,9 @@ fPreviousMousePoint = where; if (mod & B_SHIFT_KEY) - AddSelectRegion(BPointToCurPos(where)); + _AddSelectRegion(_BPointToCurPos(where)); else - DeSelect(); + _DeSelect(); // If clicks larger than 3, reset mouse click counter. @@ -1987,11 +1990,11 @@ break; case 2: - SelectWord(where, mod); + _SelectWord(where, mod); break; case 3: - SelectLine(where, mod); + _SelectLine(where, mod); break; } return; @@ -2009,7 +2012,7 @@ // Select a range of text void -TermView::Select(CurPos start, CurPos end) +TermView::_Select(CurPos start, CurPos end) { uchar buf[4]; ushort attr; @@ -2035,18 +2038,19 @@ fSelEnd = end; fTextBuffer->Select(fSelStart, fSelEnd); - TermDrawSelectedRegion(fSelStart, fSelEnd); + _TermDrawSelectedRegion(fSelStart, fSelEnd); } + // Add select region(shift + mouse click) void -TermView::AddSelectRegion(CurPos pos) +TermView::_AddSelectRegion(CurPos pos) { uchar buf[4]; ushort attr; CurPos start, end, inPos; - if (!HasSelection()) + if (!_HasSelection()) return; // error check, and if mouse point to a plase full width character, @@ -2113,12 +2117,13 @@ } fTextBuffer->Select(fSelStart, fSelEnd); - TermDrawSelectedRegion(inPos, fSelEnd); + _TermDrawSelectedRegion(inPos, fSelEnd); } + // Resize select region (mouse drag) void -TermView::ResizeSelectRegion(CurPos pos) +TermView::_ResizeSelectRegion(CurPos pos) { CurPos inPos; uchar buf[4]; @@ -2149,17 +2154,17 @@ fSelEnd = pos; fTextBuffer->Select(fSelStart, pos); - TermDrawSelectedRegion(inPos, pos); + _TermDrawSelectedRegion(inPos, pos); } // DeSelect a range of text void -TermView::DeSelect(void) +TermView::_DeSelect(void) { CurPos start, end; - if (!HasSelection()) + if (!_HasSelection()) return; fTextBuffer->DeSelect(); @@ -2170,24 +2175,24 @@ fSelStart.Set(-1, -1); fSelEnd.Set(-1, -1); - TermDrawSelectedRegion(start, end); + _TermDrawSelectedRegion(start, end); } bool -TermView::HasSelection() const +TermView::_HasSelection() const { return fSelStart != fSelEnd; } void -TermView::SelectWord(BPoint where, int mod) +TermView::_SelectWord(BPoint where, int mod) { CurPos start, end, pos; bool flag; - pos = BPointToCurPos(where); + pos = _BPointToCurPos(where); flag = fTextBuffer->FindWord(pos, &start, &end); fTextBuffer->Select(start, end); @@ -2196,28 +2201,29 @@ if (flag) { if (start < fSelStart) - AddSelectRegion(start); + _AddSelectRegion(start); else if (end > fSelEnd) - AddSelectRegion(end); + _AddSelectRegion(end); } else - AddSelectRegion(pos); + _AddSelectRegion(pos); } else { - DeSelect(); + _DeSelect(); if (flag) - Select(start, end); + _Select(start, end); } } + void -TermView::SelectLine(BPoint where, int mod) +TermView::_SelectLine(BPoint where, int mod) { CurPos start, end, pos; - pos = BPointToCurPos(where); + pos = _BPointToCurPos(where); if (mod & B_SHIFT_KEY) { @@ -2225,32 +2231,35 @@ end = CurPos(fTermColumns - 1, pos.y); if (start < fSelStart) - AddSelectRegion(start); + _AddSelectRegion(start); else if (end > fSelEnd) - AddSelectRegion(end); + _AddSelectRegion(end); } else { - DeSelect(); - Select(CurPos(0, pos.y), CurPos(fTermColumns - 1, pos.y)); + _DeSelect(); + _Select(CurPos(0, pos.y), CurPos(fTermColumns - 1, pos.y)); } } + // Convert View visible area corrdination to cursor position. CurPos -TermView::BPointToCurPos(const BPoint &p) +TermView::_BPointToCurPos(const BPoint &p) { return CurPos(p.x / fFontWidth, p.y / fFontHeight); } + // Convert cursor position to view coordination. BPoint -TermView::CurPosToBPoint(const CurPos &pos) +TermView::_CurPosToBPoint(const CurPos &pos) { return BPoint(fFontWidth * pos.x, pos.y * fFontHeight + fTop); } + bool -TermView::CheckSelectedRegion(const CurPos &pos) +TermView::_CheckSelectedRegion(const CurPos &pos) { CurPos start, end; @@ -2292,6 +2301,7 @@ *height = fTop + fTermRows * fFontHeight; } + // Sets terninal rows and cols. void TermView::GetFontInfo(int *width, int *height) @@ -2300,6 +2310,7 @@ *height = fFontHeight; } + // Find a string, and select it if found bool TermView::Find(const BString &str, bool forwardSearch, bool matchCase, bool matchWord) @@ -2380,8 +2391,8 @@ selectionend.y = (result + str.Length() - 1) / fTermColumns; selectionend.x = (result + str.Length() - 1) % fTermColumns; //Update the contents of the view - DeSelect(); - Select(selectionstart, selectionend); + _DeSelect(); + _Select(selectionstart, selectionend); return true; } @@ -2395,9 +2406,16 @@ } +void +TermView::NotifyQuit(int32 reason) +{ + // TODO: If we are a replicant, we can't just quit the BWindow, no?. + Window()->PostMessage(B_QUIT_REQUESTED); +} + inline void -TermView::Redraw(int x1, int y1, int x2, int y2) [... truncated: 150 lines follow ...] From jackburton at mail.berlios.de Mon Jul 30 12:26:25 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 30 Jul 2007 12:26:25 +0200 Subject: [Haiku-commits] r21744 - haiku/trunk/src/kits/interface Message-ID: <200707301026.l6UAQPAt009518@sheep.berlios.de> Author: jackburton Date: 2007-07-30 12:26:24 +0200 (Mon, 30 Jul 2007) New Revision: 21744 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21744&view=rev Modified: haiku/trunk/src/kits/interface/ZombieReplicantView.cpp Log: Initialize the string, so we don't get garbage in case of problems in getting the name. Modified: haiku/trunk/src/kits/interface/ZombieReplicantView.cpp =================================================================== --- haiku/trunk/src/kits/interface/ZombieReplicantView.cpp 2007-07-30 09:59:17 UTC (rev 21743) +++ haiku/trunk/src/kits/interface/ZombieReplicantView.cpp 2007-07-30 10:26:24 UTC (rev 21744) @@ -43,8 +43,7 @@ case B_ABOUT_REQUESTED: { const char *addOn = NULL; - char description[B_MIME_TYPE_LENGTH]; - + char description[B_MIME_TYPE_LENGTH] = { '\0' }; if (fArchive->FindString("add_on", &addOn) == B_OK) { BMimeType type(addOn); type.GetShortDescription(description); From korli at users.berlios.de Mon Jul 30 12:55:14 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Mon, 30 Jul 2007 12:55:14 +0200 Subject: [Haiku-commits] r21744 - haiku/trunk/src/kits/interface In-Reply-To: <200707301026.l6UAQPAt009518@sheep.berlios.de> References: <200707301026.l6UAQPAt009518@sheep.berlios.de> Message-ID: 2007/7/30, jackburton at BerliOS : > - char description[B_MIME_TYPE_LENGTH]; > - > + char description[B_MIME_TYPE_LENGTH] = { '\0' }; > if (fArchive->FindString("add_on", &addOn) == B_OK) { Would this be clearer ? char description[B_MIME_TYPE_LENGTH] = ""; Bye, J?r?me From korli at users.berlios.de Mon Jul 30 12:59:02 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Mon, 30 Jul 2007 12:59:02 +0200 Subject: [Haiku-commits] r21743 - haiku/trunk/src/apps/terminal In-Reply-To: <200707300959.l6U9xHER006147@sheep.berlios.de> References: <200707300959.l6U9xHER006147@sheep.berlios.de> Message-ID: 2007/7/30, jackburton at BerliOS : > int nread = read(fFd, buf, READ_BUF_SIZE - (read_p - fBufferPosition)); > if (nread <= 0) { > - be_app->PostMessage(B_QUIT_REQUESTED); > + // TODO: errno ? (Jerome ?) :) > + fView->NotifyQuit(nread); > exit_thread(B_ERROR); > } In fact, errno is set by read(). See : http://svn.berlios.de/viewcvs/haiku/haiku/trunk/src/system/libroot/posix/unistd/read.c?rev=21701&view=markup Bye, J?r?me From stefano.ceccherini at gmail.com Mon Jul 30 13:37:24 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 30 Jul 2007 13:37:24 +0200 Subject: [Haiku-commits] r21744 - haiku/trunk/src/kits/interface In-Reply-To: References: <200707301026.l6UAQPAt009518@sheep.berlios.de> Message-ID: <894b9700707300437n401e4ef8l5208af5a7f6dc3b8@mail.gmail.com> 2007/7/30, J?r?me Duval : > 2007/7/30, jackburton at BerliOS : > > - char description[B_MIME_TYPE_LENGTH]; > > - > > + char description[B_MIME_TYPE_LENGTH] = { '\0' }; > > if (fArchive->FindString("add_on", &addOn) == B_OK) { > > Would this be clearer ? > > char description[B_MIME_TYPE_LENGTH] = ""; Yeah, probably. I also thought about initializing it to some useful value... like "unknown", so that the error string looks like "Can't create the "unknown" replicant... etc.". Thoughts ? From stefano.ceccherini at gmail.com Mon Jul 30 13:37:48 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 30 Jul 2007 13:37:48 +0200 Subject: [Haiku-commits] r21743 - haiku/trunk/src/apps/terminal In-Reply-To: References: <200707300959.l6U9xHER006147@sheep.berlios.de> Message-ID: <894b9700707300437o7782c19co4a53da90d4f10af@mail.gmail.com> 2007/7/30, J?r?me Duval : > In fact, errno is set by read(). See : > Ok, I'll return errno, then. Thank you. From jackburton at mail.berlios.de Mon Jul 30 13:48:36 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 30 Jul 2007 13:48:36 +0200 Subject: [Haiku-commits] r21745 - haiku/trunk/src/apps/terminal Message-ID: <200707301148.l6UBmaDD028534@sheep.berlios.de> Author: jackburton Date: 2007-07-30 13:48:35 +0200 (Mon, 30 Jul 2007) New Revision: 21745 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21745&view=rev Modified: haiku/trunk/src/apps/terminal/TermParse.cpp haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermWindow.cpp Log: Add the add_on field in TermView::Archive(). This way instantiating a replicant works (thank you Marc). Return errno instead of the return value of read() (thank you Jerome). Terminal now can be instantiated as a replicant, although input doesn't work :((. Modified: haiku/trunk/src/apps/terminal/TermParse.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-30 10:26:24 UTC (rev 21744) +++ haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-30 11:48:35 UTC (rev 21745) @@ -149,9 +149,8 @@ uchar buf[READ_BUF_SIZE]; int nread = read(fFd, buf, READ_BUF_SIZE - (read_p - fBufferPosition)); if (nread <= 0) { - // TODO: errno ? (Jerome ?) :) - fView->NotifyQuit(nread); - exit_thread(B_ERROR); + fView->NotifyQuit(errno); + exit_thread(errno); } // Copy read string to PtyBuffer. Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-30 10:26:24 UTC (rev 21744) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-30 11:48:35 UTC (rev 21745) @@ -206,7 +206,6 @@ fQuitting(false), fIMflag(false) { - printf("TermView(BMessage *)\n"); if (archive->FindInt32("encoding", (int32 *)&fEncoding) < B_OK) fEncoding = M_UTF8; if (archive->FindInt32("columns", (int32 *)&fTermColumns) < B_OK) @@ -215,7 +214,7 @@ fTermRows = 25; // TODO: Retrieve command, colors, history size, etc. from archive - printf("_InitObject() returned %s\n", strerror(_InitObject(NULL))); + _InitObject(NULL); } @@ -266,11 +265,9 @@ BArchivable * TermView::Instantiate(BMessage* data) { - printf("TermView::Instantiate()\n"); if (validate_instantiation(data, "TermView")) return new (std::nothrow) TermView(data); - printf("Returned NULL\n"); return NULL; } @@ -278,15 +275,16 @@ status_t TermView::Archive(BMessage* data, bool deep) const { - printf("TermView::Archive()\n"); status_t status = BView::Archive(data, deep); if (status == B_OK) + status = data->AddString("add_on", TERM_SIGNATURE); + if (status == B_OK) status = data->AddInt32("encoding", (int32)fEncoding); if (status == B_OK) status = data->AddInt32("columns", (int32)fTermColumns); if (status == B_OK) status = data->AddInt32("rows", (int32)fTermRows); - printf("Archive() returned %s\n", strerror(status)); + return status; } Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-30 10:26:24 UTC (rev 21744) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-07-30 11:48:35 UTC (rev 21745) @@ -50,10 +50,8 @@ const static float kViewOffset = 3; -#if 0 TermWindow::TermWindow(BRect frame, const char* title, const char *command) - : - BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE), + : BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE), fTabView(NULL), fTermView(NULL), fMenubar(NULL), @@ -76,53 +74,18 @@ fMatchCase(false), fMatchWord(false) { + _InitWindow(command); + /*BView *view = new TermView(Bounds()); - fTabView = new SmartTabView(Bounds(), "Tab view"); - AddChild(fTabView); - - _NewTab(command); - _NewTab(NULL); - fTabView->Select(0); -/* - BView *view = new TermView(Bounds()); AddChild(view); - BRect _WritePTYdraggerFrame(0, 0, 16, 16); + BRect draggerFrame(0, 0, 16, 16); draggerFrame.OffsetTo(Bounds().RightBottom() - BPoint(16, 16)); BDragger *dragger = new BDragger(draggerFrame, view, B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM, B_WILL_DRAW); view->AddChild(dragger);*/ } -#endif -TermWindow::TermWindow(BRect frame, const char* title, const char *command) - : BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE), - fTabView(NULL), - fTermView(NULL), - fMenubar(NULL), - fFilemenu(NULL), - fEditmenu(NULL), - fEncodingmenu(NULL), - fHelpmenu(NULL), - fFontMenu(NULL), - fWindowSizeMenu(NULL), - fNewFontMenu(NULL), - fPrintSettings(NULL), - fPrefWindow(NULL), - fFindPanel(NULL), - fSavedFrame(0, 0, -1, -1), - fFindString(""), - fFindForwardMenuItem(NULL), - fFindBackwardMenuItem(NULL), - fFindSelection(false), - fForwardSearch(false), - fMatchCase(false), - fMatchWord(false) -{ - _InitWindow(command); -} - - TermWindow::~TermWindow() { if (fPrefWindow) From axeld at mail.berlios.de Mon Jul 30 13:54:11 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 30 Jul 2007 13:54:11 +0200 Subject: [Haiku-commits] r21746 - haiku/trunk/src/system/kernel/vm Message-ID: <200707301154.l6UBsBrX028996@sheep.berlios.de> Author: axeld Date: 2007-07-30 13:54:11 +0200 (Mon, 30 Jul 2007) New Revision: 21746 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21746&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm.cpp Log: area_for() in the kernel can now also find user areas in case you are coming from a user team. Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2007-07-30 11:48:35 UTC (rev 21745) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2007-07-30 11:54:11 UTC (rev 21746) @@ -4073,7 +4073,17 @@ area_id area_for(void *address) { - return vm_area_for(vm_kernel_address_space_id(), (addr_t)address); + team_id space; + + if (IS_USER_ADDRESS(address)) { + // we try the user team address space, if any + space = vm_current_user_address_space_id(); + if (space < B_OK) + return space; + } else + space = vm_kernel_address_space_id(); + + return vm_area_for(space, (addr_t)address); } From marcusoverhagen at arcor.de Mon Jul 30 14:08:07 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Mon, 30 Jul 2007 14:08:07 +0200 (CEST) Subject: [Haiku-commits] r21745 - haiku/trunk/src/apps/terminal In-Reply-To: <200707301148.l6UBmaDD028534@sheep.berlios.de> References: <200707301148.l6UBmaDD028534@sheep.berlios.de> Message-ID: <11236219.1185797287367.JavaMail.ngmail@webmail16> jackburton at BerliOS wrote: > uchar buf[READ_BUF_SIZE]; > int nread = read(fFd, buf, READ_BUF_SIZE - (read_p - fBufferPosition)); > if (nread <= 0) { > + fView->NotifyQuit(errno); > + exit_thread(errno); > } This doesn't work. NotifyQuit can/might change errno. You need to retrieve and cache the errno value directly after read failed, before any other posix functions (like a printf inside NotifyQuit) are executed. if (nread <= 0) { status_t err = errno; fView->NotifyQuit(err); exit_thread(err); } BTW, I don't like the exit_thread very much. Isn't there a cleaner way? regards Marcus Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 34,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From stefano.ceccherini at gmail.com Mon Jul 30 14:10:58 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 30 Jul 2007 14:10:58 +0200 Subject: [Haiku-commits] r21745 - haiku/trunk/src/apps/terminal In-Reply-To: <11236219.1185797287367.JavaMail.ngmail@webmail16> References: <200707301148.l6UBmaDD028534@sheep.berlios.de> <11236219.1185797287367.JavaMail.ngmail@webmail16> Message-ID: <894b9700707300510k743af8bds8ab2a6406c959d3c@mail.gmail.com> 2007/7/30, Marcus Overhagen : > This doesn't work. NotifyQuit can/might change errno. > You need to retrieve and cache the errno value directly after read failed, > before any other posix functions (like a printf inside NotifyQuit) are executed. Ok, I see. Thank you. > if (nread <= 0) { > status_t err = errno; > fView->NotifyQuit(err); > exit_thread(err); > } > > > BTW, I don't like the exit_thread very much. Isn't there a cleaner way? I'll try to rework it to avoid the exit_thread(). From stefano.ceccherini at gmail.com Mon Jul 30 14:12:15 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 30 Jul 2007 14:12:15 +0200 Subject: [Haiku-commits] r21745 - haiku/trunk/src/apps/terminal In-Reply-To: <894b9700707300510k743af8bds8ab2a6406c959d3c@mail.gmail.com> References: <200707301148.l6UBmaDD028534@sheep.berlios.de> <11236219.1185797287367.JavaMail.ngmail@webmail16> <894b9700707300510k743af8bds8ab2a6406c959d3c@mail.gmail.com> Message-ID: <894b9700707300512t7d0f53b4l978d7024fd0ce222@mail.gmail.com> 2007/7/30, Stefano Ceccherini : > > > > BTW, I don't like the exit_thread very much. Isn't there a cleaner way? > > I'll try to rework it to avoid the exit_thread(). > But anyway, I guess in case the read fails that thread can't do anything useful anymore. From jackburton at mail.berlios.de Mon Jul 30 14:19:21 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 30 Jul 2007 14:19:21 +0200 Subject: [Haiku-commits] r21747 - haiku/trunk/src/apps/terminal Message-ID: <200707301219.l6UCJLM7030591@sheep.berlios.de> Author: jackburton Date: 2007-07-30 14:19:20 +0200 (Mon, 30 Jul 2007) New Revision: 21747 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21747&view=rev Modified: haiku/trunk/src/apps/terminal/TermParse.cpp haiku/trunk/src/apps/terminal/TermView.cpp Log: on MouseDown(), TermView becomes the focus view (like BTextView does). Now input works also with a replicanted Terminal, although I have to click on it twice(!?!?). Don't call exit_thread() anymore in TermParse::PtyReader(). Hope this is correct. (feel free to beat me on this). Modified: haiku/trunk/src/apps/terminal/TermParse.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-30 11:54:11 UTC (rev 21746) +++ haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-30 12:19:20 UTC (rev 21747) @@ -149,8 +149,11 @@ uchar buf[READ_BUF_SIZE]; int nread = read(fFd, buf, READ_BUF_SIZE - (read_p - fBufferPosition)); if (nread <= 0) { - fView->NotifyQuit(errno); - exit_thread(errno); + fView->NotifyQuit(errno); + // on the next iteration, fQuitting will probably be true, + // or the semaphore acquisition will fail, so this thread will + // be killed anyway. + continue; } // Copy read string to PtyBuffer. Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-30 11:54:11 UTC (rev 21746) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-30 12:19:20 UTC (rev 21747) @@ -213,8 +213,11 @@ if (archive->FindInt32("rows", (int32 *)&fTermRows) < B_OK) fTermRows = 25; - // TODO: Retrieve command, colors, history size, etc. from archive - _InitObject(NULL); + const char *command = NULL; + archive->FindString("command", &command); + + // TODO: Retrieve colors, history size, etc. from archive + _InitObject(command); } @@ -1882,6 +1885,11 @@ void TermView::MouseDown(BPoint where) { + // TODO: Get rid of the extra thread for mouse tracking, + // and implement it using something like BTextView uses. + if (!IsFocus()) + MakeFocus(); + int32 buttons; Window()->CurrentMessage()->FindInt32("buttons", &buttons); From stefano.ceccherini at gmail.com Mon Jul 30 14:29:01 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 30 Jul 2007 14:29:01 +0200 Subject: [Haiku-commits] r21747 - haiku/trunk/src/apps/terminal In-Reply-To: <200707301219.l6UCJLM7030591@sheep.berlios.de> References: <200707301219.l6UCJLM7030591@sheep.berlios.de> Message-ID: <894b9700707300529t20a7261bl77713b61602d5f9d@mail.gmail.com> 2007/7/30, jackburton at BerliOS : > Author: jackburton > Date: 2007-07-30 14:19:20 +0200 (Mon, 30 Jul 2007) > New Revision: 21747 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21747&view=rev > > Modified: > haiku/trunk/src/apps/terminal/TermParse.cpp > haiku/trunk/src/apps/terminal/TermView.cpp > Log: > on MouseDown(), TermView becomes the focus view (like BTextView does). > Now input works also with a replicanted Terminal, although I have to > click on it twice(!?!?). Don't call exit_thread() anymore in > TermParse::PtyReader(). Hope this is correct. (feel free to beat me on > this). By the way... say hello to the replicant Terminal :) http://burton666.neoni.net/workspace/upload/shots/terminal.png It's not yet really usable (since an "exit" will forward the signal to the hosting app, not really cool :P), but works more or less. From mmlr at mail.berlios.de Mon Jul 30 14:54:21 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Mon, 30 Jul 2007 14:54:21 +0200 Subject: [Haiku-commits] r21748 - haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid Message-ID: <200707301254.l6UCsLo5000740@sheep.berlios.de> Author: mmlr Date: 2007-07-30 14:54:20 +0200 (Mon, 30 Jul 2007) New Revision: 21748 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21748&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.c haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.h Log: Use a flag to cancel issuing new transfers instead of relying on a B_CANCELED. This should ensure that the hid driver does not use the device after the remove hook completes. Untested... Modified: haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.c 2007-07-30 12:19:20 UTC (rev 21747) +++ haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.c 2007-07-30 12:54:20 UTC (rev 21748) @@ -339,6 +339,7 @@ device->open = 0; device->open_fds = NULL; device->active = true; + device->unplugged = false; device->insns = NULL; device->num_insns = 0; device->flags = 0; @@ -584,7 +585,7 @@ hid_device_info *device = cookie; status_t status; - if (device == NULL) + if (device == NULL || device->unplugged) return; acquire_sem(device->sem_lock); @@ -849,6 +850,8 @@ assert (cookie != NULL); DPRINTF_INFO((MY_ID "device_removed(%s)\n", device->name)); + + device->unplugged = true; usb->cancel_queued_transfers (device->ept->handle); remove_device_info(device); Modified: haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.h 2007-07-30 12:19:20 UTC (rev 21747) +++ haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.h 2007-07-30 12:54:20 UTC (rev 21748) @@ -68,6 +68,7 @@ struct ring_buffer *rbuf; bool active; + bool unplugged; int open; struct driver_cookie *open_fds; From jackburton at mail.berlios.de Mon Jul 30 14:56:23 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 30 Jul 2007 14:56:23 +0200 Subject: [Haiku-commits] r21749 - haiku/trunk/src/kits/interface Message-ID: <200707301256.l6UCuNn2000922@sheep.berlios.de> Author: jackburton Date: 2007-07-30 14:56:22 +0200 (Mon, 30 Jul 2007) New Revision: 21749 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21749&view=rev Modified: haiku/trunk/src/kits/interface/ZombieReplicantView.cpp Log: Better error messages Modified: haiku/trunk/src/kits/interface/ZombieReplicantView.cpp =================================================================== --- haiku/trunk/src/kits/interface/ZombieReplicantView.cpp 2007-07-30 12:54:20 UTC (rev 21748) +++ haiku/trunk/src/kits/interface/ZombieReplicantView.cpp 2007-07-30 12:56:22 UTC (rev 21749) @@ -43,17 +43,21 @@ case B_ABOUT_REQUESTED: { const char *addOn = NULL; - char description[B_MIME_TYPE_LENGTH] = { '\0' }; + char error[1024]; if (fArchive->FindString("add_on", &addOn) == B_OK) { + char description[B_MIME_TYPE_LENGTH] = ""; BMimeType type(addOn); type.GetShortDescription(description); + snprintf(error, sizeof(error), + "Cannot create the replicant for \"%s\". (%s)", + description, strerror(fError)); + } else { + snprintf(error, sizeof(error), + "Cannot locate the application for the replicant. " + "No application signature supplied. (%s)", strerror(fError)); } - char error[1024]; - snprintf(error, sizeof(error), - "Can't create the \"%s\" replicant because the library is in the Trash. (%s)", - description, strerror(fError)); - + BAlert *alert = new (std::nothrow) BAlert("Error", error, "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); if (alert != NULL) From axeld at pinc-software.de Mon Jul 30 15:08:56 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Mon, 30 Jul 2007 15:08:56 +0200 CEST Subject: [Haiku-commits] r21744 - haiku/trunk/src/kits/interface In-Reply-To: <894b9700707300437n401e4ef8l5208af5a7f6dc3b8@mail.gmail.com> Message-ID: <9798877027-BeMail@ibm> "Stefano Ceccherini" wrote: > Yeah, probably. I also thought about initializing it to some useful > value... like "unknown", so that the error string looks like "Can't > create the "unknown" replicant... etc.". Thoughts ? "unknown" is not really helpful - isn't there some better way? Bye, Axel. From stefano.ceccherini at gmail.com Mon Jul 30 15:11:33 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 30 Jul 2007 15:11:33 +0200 Subject: [Haiku-commits] r21744 - haiku/trunk/src/kits/interface In-Reply-To: <9798877027-BeMail@ibm> References: <894b9700707300437n401e4ef8l5208af5a7f6dc3b8@mail.gmail.com> <9798877027-BeMail@ibm> Message-ID: <894b9700707300611w5deec70dj3949df175b665bab@mail.gmail.com> 2007/7/30, Axel D?rfler : > "Stefano Ceccherini" wrote: > > Yeah, probably. I also thought about initializing it to some useful > > value... like "unknown", so that the error string looks like "Can't > > create the "unknown" replicant... etc.". Thoughts ? > > "unknown" is not really helpful - isn't there some better way? > I changed the errors in my last commit to that file. Now it says clearly it cannot find the application to instantiate the replicant, because no signature has been supplied (as it was in my case, where I didn't put the signature of Terminal as the add_on field of the message). From axeld at pinc-software.de Mon Jul 30 15:22:35 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Mon, 30 Jul 2007 15:22:35 +0200 CEST Subject: [Haiku-commits] r21745 - haiku/trunk/src/apps/terminal In-Reply-To: <894b9700707300512t7d0f53b4l978d7024fd0ce222@mail.gmail.com> Message-ID: <10617023265-BeMail@ibm> "Stefano Ceccherini" wrote: > 2007/7/30, Stefano Ceccherini : > > > BTW, I don't like the exit_thread very much. Isn't there a > > > cleaner way? > > I'll try to rework it to avoid the exit_thread(). > But anyway, I guess in case the read fails that thread can't do > anything useful anymore. I'm also not sure what should be so bad about exit_thread() - or didn't you spawn that thread yourself before? Bye, Axel. From axeld at pinc-software.de Mon Jul 30 15:11:36 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Mon, 30 Jul 2007 15:11:36 +0200 CEST Subject: [Haiku-commits] r21742 - haiku/trunk/src/apps/terminal In-Reply-To: <894b9700707300248i10209d05l952ed4923e3eea19@mail.gmail.com> Message-ID: <9958527058-BeMail@ibm> "Stefano Ceccherini" wrote: > 2007/7/30, jackburton at BerliOS : > > Log: > > Don't use exceptions in TermView constructor, as it would cause > > problems > > with instantiation. > Could we add a try {} catch block in BShelf, where it uses > instantiate_object(), to handle those constructors which throw an > exception ? That definitely sounds like a good idea. Bye, Axel. From stefano.ceccherini at gmail.com Mon Jul 30 15:28:43 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 30 Jul 2007 15:28:43 +0200 Subject: [Haiku-commits] r21742 - haiku/trunk/src/apps/terminal In-Reply-To: <9958527058-BeMail@ibm> References: <894b9700707300248i10209d05l952ed4923e3eea19@mail.gmail.com> <9958527058-BeMail@ibm> Message-ID: <894b9700707300628g72db26ecia9f9a72b7c2d94db@mail.gmail.com> 2007/7/30, Axel D?rfler : > That definitely sounds like a good idea. I'll do that. From jackburton at mail.berlios.de Mon Jul 30 16:21:42 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 30 Jul 2007 16:21:42 +0200 Subject: [Haiku-commits] r21750 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200707301421.l6UELgGJ006650@sheep.berlios.de> Author: jackburton Date: 2007-07-30 16:21:41 +0200 (Mon, 30 Jul 2007) New Revision: 21750 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21750&view=rev Modified: haiku/trunk/headers/os/interface/Shelf.h haiku/trunk/src/kits/interface/Shelf.cpp Log: Added a wrapper method to instantiate_object(), where we catch any possible exception thrown from the constructor called by the function itself, for safety. Modified: haiku/trunk/headers/os/interface/Shelf.h =================================================================== --- haiku/trunk/headers/os/interface/Shelf.h 2007-07-30 12:56:22 UTC (rev 21749) +++ haiku/trunk/headers/os/interface/Shelf.h 2007-07-30 14:21:41 UTC (rev 21750) @@ -99,6 +99,8 @@ status_t _AddReplicant(BMessage* data, BPoint* location, uint32 uniqueID); status_t _GetProperty(BMessage* message, BMessage* reply); + + static BArchivable* _InstantiateObject(BMessage *archive, image_id *image); private: BView* fContainerView; Modified: haiku/trunk/src/kits/interface/Shelf.cpp =================================================================== --- haiku/trunk/src/kits/interface/Shelf.cpp 2007-07-30 12:56:22 UTC (rev 21749) +++ haiku/trunk/src/kits/interface/Shelf.cpp 2007-07-30 14:21:41 UTC (rev 21750) @@ -1140,7 +1140,7 @@ // Instantiate the object, if this fails we have a zombie image_id image; - BArchivable *archivable = instantiate_object(data, &image); + BArchivable *archivable = _InstantiateObject(data, &image); if (archivable) { BView *view = dynamic_cast(archivable); BPoint point; @@ -1157,7 +1157,7 @@ if (data->FindMessage("__widget", &widget) == B_OK) { image_id draggerImage = B_ERROR; replicant = view; - dragger = dynamic_cast(instantiate_object(&widget, &draggerImage)); + dragger = dynamic_cast(_InstantiateObject(&widget, &draggerImage)); if (dragger != NULL) { // Replicant is either a sibling or unknown dragger->_SetViewToDrag(replicant); @@ -1325,3 +1325,19 @@ return err; } + + +/* static */ +BArchivable * +BShelf::_InstantiateObject(BMessage *archive, image_id *image) +{ + // Stay on the safe side. The constructor called by instantiate_object + // could throw an exception, which we catch here. Otherwise our calling app + // could die without notice. + try { + return instantiate_object(archive, image); + } catch (...) { + return NULL; + } +} + From jackburton at mail.berlios.de Mon Jul 30 17:05:04 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 30 Jul 2007 17:05:04 +0200 Subject: [Haiku-commits] r21751 - haiku/trunk/src/apps/terminal Message-ID: <200707301505.l6UF54YK009288@sheep.berlios.de> Author: jackburton Date: 2007-07-30 17:05:04 +0200 (Mon, 30 Jul 2007) New Revision: 21751 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21751&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp Log: More or less reverted TermView::KeyDown() to r21695. Fixes bug #1340. Thanks to Ingo & Korli for the help. Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-30 14:21:41 UTC (rev 21750) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-30 15:05:04 UTC (rev 21751) @@ -1432,6 +1432,7 @@ void TermView::WindowActivated(bool active) { + BView::WindowActivated(active); if (active == false) { // DoIMConfirm(); } @@ -1457,35 +1458,49 @@ fShell->Signal(SIGINT); } - // Terminal changes RET, ENTER, F1...F12, and ARROW key code. + // Terminal filters RET, ENTER, F1...F12, and ARROW key code. + // TODO: Cleanup if (numBytes == 1) { - switch (bytes[0]) { + switch (*bytes) { case B_RETURN: - { - char c = 0x0d; - fShell->Write(&c, 1); + if (key == RETURN_KEY || key == ENTER_KEY) { + char c = 0x0d; + fShell->Write(&c, 1); + return; + } else { + fShell->Write(bytes, numBytes); + return; + } break; - } + case B_LEFT_ARROW: - fShell->Write(LEFT_ARROW_KEY_CODE, sizeof(LEFT_ARROW_KEY_CODE)-1); + if (key == LEFT_ARROW_KEY) { + fShell->Write(LEFT_ARROW_KEY_CODE, sizeof(LEFT_ARROW_KEY_CODE) - 1); + return; + } break; case B_RIGHT_ARROW: - fShell->Write(RIGHT_ARROW_KEY_CODE, sizeof(RIGHT_ARROW_KEY_CODE)-1); + if (key == RIGHT_ARROW_KEY) { + fShell->Write(RIGHT_ARROW_KEY_CODE, sizeof(RIGHT_ARROW_KEY_CODE) - 1); + return; + } break; case B_UP_ARROW: if (mod & B_SHIFT_KEY) { - if (Bounds().top <= 0) - return; - ScrollBy(0, -fFontHeight); - Window()->UpdateIfNeeded(); + if (Bounds().top > 0) { + ScrollBy(0, -fFontHeight); + Window()->UpdateIfNeeded(); + } return; } - - fShell->Write(UP_ARROW_KEY_CODE, sizeof(UP_ARROW_KEY_CODE)-1); + if (key == UP_ARROW_KEY) { + fShell->Write(UP_ARROW_KEY_CODE, sizeof(UP_ARROW_KEY_CODE) - 1); + return; + } break; - + case B_DOWN_ARROW: if (mod & B_SHIFT_KEY) { ScrollBy(0, fFontHeight); @@ -1493,27 +1508,45 @@ return; } - fShell->Write(DOWN_ARROW_KEY_CODE, sizeof(DOWN_ARROW_KEY_CODE)-1); + if (key == DOWN_ARROW_KEY) { + fShell->Write(DOWN_ARROW_KEY_CODE, sizeof(DOWN_ARROW_KEY_CODE) - 1); + return; + } break; case B_INSERT: - fShell->Write(INSERT_KEY_CODE, sizeof(INSERT_KEY_CODE)-1); + if (key == INSERT_KEY) { + fShell->Write(INSERT_KEY_CODE, sizeof(INSERT_KEY_CODE) - 1); + return; + } break; case B_HOME: - fShell->Write(HOME_KEY_CODE, sizeof(HOME_KEY_CODE)-1); + if (key == HOME_KEY) { + fShell->Write(HOME_KEY_CODE, sizeof(HOME_KEY_CODE) - 1); + return; + } break; + case B_END: + if (key == END_KEY) { + fShell->Write(END_KEY_CODE, sizeof(END_KEY_CODE) - 1); + return; + } + break; + case B_PAGE_UP: if (mod & B_SHIFT_KEY) { - if (Bounds().top <= 0) - return; - ScrollBy(0, -fFontHeight * fTermRows ); - Window()->UpdateIfNeeded(); + if (Bounds().top > 0) { + ScrollBy(0, -fFontHeight * fTermRows ); + Window()->UpdateIfNeeded(); + } return; } - - fShell->Write(PAGE_UP_KEY_CODE, sizeof(PAGE_UP_KEY_CODE)-1); + if (key == PAGE_UP_KEY) { + fShell->Write(PAGE_UP_KEY_CODE, sizeof(PAGE_UP_KEY_CODE) - 1); + return; + } break; case B_PAGE_DOWN: @@ -1522,37 +1555,37 @@ Window()->UpdateIfNeeded(); return; } - - fShell->Write(PAGE_DOWN_KEY_CODE, sizeof(PAGE_DOWN_KEY_CODE)-1); + + if (key == PAGE_DOWN_KEY) { + fShell->Write(PAGE_DOWN_KEY_CODE, sizeof(PAGE_DOWN_KEY_CODE) - 1); + return; + } break; - case B_END: - fShell->Write(END_KEY_CODE, sizeof(END_KEY_CODE)-1); - break; - case B_FUNCTION_KEY: - for (int32 c = 0; c < 12; c++) { - if (key == function_keycode_table[c]) { - fShell->Write(function_key_char_table[c], 5); + // TODO: Why not just fShell->Write(key) ? + for (int32 i = 0; i < 12; i++) { + if (key == function_keycode_table[i]) { + fShell->Write(function_key_char_table[i], 5); return; } } break; - default: - fShell->Write(bytes, numBytes); break; } } else { // input multibyte character if (fEncoding != M_UTF8) { - uchar destBuffer[1024]; + char destBuffer[16]; int cnum = CodeConv::ConvertFromInternal(bytes, numBytes, (char *)destBuffer, fEncoding); fShell->Write(destBuffer, cnum); - destBuffer[cnum] = 0; + return; } } + + fShell->Write(bytes, numBytes); } From jackburton at mail.berlios.de Mon Jul 30 17:22:38 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 30 Jul 2007 17:22:38 +0200 Subject: [Haiku-commits] r21752 - haiku/trunk/src/apps/terminal Message-ID: <200707301522.l6UFMcoJ010263@sheep.berlios.de> Author: jackburton Date: 2007-07-30 17:22:37 +0200 (Mon, 30 Jul 2007) New Revision: 21752 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21752&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h Log: Implemented B_ABOUT_REQUESTED in TermView, for the replicant version. Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-30 15:05:04 UTC (rev 21751) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-07-30 15:22:37 UTC (rev 21752) @@ -20,7 +20,7 @@ #include "VTkeymap.h" #include -#include +#include #include #include #include @@ -1620,6 +1620,11 @@ char *ctrl_l = " "; switch (msg->what){ + case B_ABOUT_REQUESTED: + // (replicant) about box requested + _AboutRequested(); + break; + case B_SIMPLE_DATA: { int32 i = 0; @@ -2473,4 +2478,17 @@ font.SetSpacing(B_FIXED_SPACING); } - + +void +TermView::_AboutRequested() +{ + BAlert *alert = new (std::nothrow) BAlert("about", + "Terminal\n" + "\twritten by Kazuho Okui and Takashi Murai\n" + "\tupdated by Kian Duffy and others\n\n" + "\tCopyright " B_UTF8_COPYRIGHT "2003-2007, Haiku.\n", "Ok"); + if (alert != NULL) + alert->Go(); +} + + Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2007-07-30 15:05:04 UTC (rev 21751) +++ haiku/trunk/src/apps/terminal/TermView.h 2007-07-30 15:22:37 UTC (rev 21752) @@ -23,6 +23,7 @@ #define CUROFF 0 #define CURON 1 + class BMessageRunner; class BPopUpMenu; class BScrollBar; @@ -133,11 +134,15 @@ private: status_t _InitObject(const char *command); status_t _InitMouseThread(void); + + void _AboutRequested(); + void _DrawLines(int , int, ushort, uchar *, int, int, int, BView *); int _TermDraw(const CurPos &start, const CurPos &end); int _TermDrawRegion(CurPos start, CurPos end); int _TermDrawSelectedRegion(CurPos start, CurPos end); - + inline void _Redraw(int, int, int, int); + void _DoPrint(BRect updateRect); void _ResizeScrBarRange (void); void _DoFileDrop(entry_ref &ref); @@ -177,11 +182,12 @@ BPoint _CurPosToBPoint(const CurPos &pos); bool _CheckSelectedRegion(const CurPos &pos); - inline void _Redraw(int, int, int, int); + void _UpdateSIGWINCH(); + static void _FixFontAttributes(BFont &font); - + static int32 _MouseTrackingEntryFunction(void *); int32 _MouseTracking(); From marcusoverhagen at arcor.de Mon Jul 30 16:18:42 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Mon, 30 Jul 2007 16:18:42 +0200 (CEST) Subject: [Haiku-commits] r21745 - haiku/trunk/src/apps/terminal Message-ID: <9873335.1185805122688.JavaMail.ngmail@webmail16> Axel D?rfler wrote: > "Stefano Ceccherini" wrote: > > 2007/7/30, Stefano Ceccherini : > > > > BTW, I don't like the exit_thread very much. Isn't there a > > > > cleaner way? > > > I'll try to rework it to avoid the exit_thread(). > > But anyway, I guess in case the read fails that thread can't do > > anything useful anymore. > I'm also not sure what should be so bad about exit_thread() - or didn't > you spawn that thread yourself before? Using exit_thread() isn't wrong per se. But it usually indicates a strange design. Please note that I didn't say "you have to remove it". I hadn't even looked at the full sourcecode, I just hoped there would be a cleaner way than terminating a thread somewhere in the middle. However, the comment added to the new code doesn't make me feel confident that it's cleaner now. While I looked at it, I noticed the code contains still a few errors: 1) delete_sem(fReaderSem); fReaderSem = -1; delete_sem(fReaderLocker); fReaderSem = -1; note: looks like a copy+paste error 2) wait_for_thread(fReaderThread, &dummy); fReaderThread = -1; wait_for_thread(fParseThread, &dummy); fReaderThread = -1; note: looks like a copy+paste error 3) fReaderThread = -1; return B_OK; note: the variable is later used to wait on the thread, exit_thread is not needed here 4) thread_id TermParse::InitPtyReader() { note: this function doesn't return a thread_id 5) return resume_thread(fReaderThread); note: either don't check the return value (I prefer that one), or cleanup if it failes 6) return resume_thread(fParseThread); note: either don't check the return value (I prefer that one), or cleanup if it failes 7) fParseThread = -1; exit_thread(B_OK); return B_OK; note: the variable is later used to wait on the thread, exit_thread is not needed here regards Marcus Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 34,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From laplace at mail.berlios.de Mon Jul 30 19:41:07 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Mon, 30 Jul 2007 19:41:07 +0200 Subject: [Haiku-commits] r21753 - haiku/trunk/src/servers/print Message-ID: <200707301741.l6UHf7VP002325@sheep.berlios.de> Author: laplace Date: 2007-07-30 19:41:06 +0200 (Mon, 30 Jul 2007) New Revision: 21753 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21753&view=rev Modified: haiku/trunk/src/servers/print/Printer.cpp Log: Undo last change (Search spool folder by name stored in attribute 'Printer Name'). In other parts of the print_server we had assumed that printer spool directory name = printer name. So the change broke some things. Modified: haiku/trunk/src/servers/print/Printer.cpp =================================================================== --- haiku/trunk/src/servers/print/Printer.cpp 2007-07-30 15:22:37 UTC (rev 21752) +++ haiku/trunk/src/servers/print/Printer.cpp 2007-07-30 17:41:06 UTC (rev 21753) @@ -463,33 +463,20 @@ // Try to move job to another printer folder. // // Parameters: -// name - the printer name. +// name - the printer folder name. // // Returns: // true if successful. // --------------------------------------------------------------- bool Printer::MoveJob(const BString& name) { + BPath file(&fJob->EntryRef()); BPath path; - if (::find_directory(B_USER_PRINTERS_DIRECTORY, &path) != B_OK) - return false; - - // search printer folder with given name - BDirectory printersFolder(path.Path()); - BEntry printerEntry; - while (printersFolder.GetNextEntry(&printerEntry) == B_OK) { - BNode printerNode(&printerEntry); - BString printerName; - if (printerNode.ReadAttrString(PSRV_PRINTER_ATTR_PRT_NAME, &printerName) != B_OK) - continue; - if (name != printerName) - continue; - - BEntry jobEntry(&fJob->EntryRef()); - BDirectory printerDirectory(&printerEntry); - return jobEntry.MoveTo(&printerDirectory) == B_OK; - // try to move job file to proper directory - } - return false; + file.GetParent(&path); + path.Append(".."); path.Append(name.String()); + BDirectory dir(path.Path()); + BEntry entry(&fJob->EntryRef()); + // try to move job file to proper directory + return entry.MoveTo(&dir) == B_OK; } // --------------------------------------------------------------- From laplace at mail.berlios.de Mon Jul 30 20:19:56 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Mon, 30 Jul 2007 20:19:56 +0200 Subject: [Haiku-commits] r21754 - haiku/trunk/src/kits/interface Message-ID: <200707301819.l6UIJu9U004047@sheep.berlios.de> Author: laplace Date: 2007-07-30 20:19:56 +0200 (Mon, 30 Jul 2007) New Revision: 21754 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21754&view=rev Modified: haiku/trunk/src/kits/interface/PrintJob.cpp Log: Added sanity check to public method. Set offset to first page in header. Modified: haiku/trunk/src/kits/interface/PrintJob.cpp =================================================================== --- haiku/trunk/src/kits/interface/PrintJob.cpp 2007-07-30 17:41:06 UTC (rev 21753) +++ haiku/trunk/src/kits/interface/PrintJob.cpp 2007-07-30 18:19:56 UTC (rev 21754) @@ -525,6 +525,9 @@ void BPrintJob::DrawView(BView *view, BRect rect, BPoint where) { + if (fSpoolFile == NULL) + return; + if (view == NULL) return; @@ -718,6 +721,10 @@ // write page header fCurrentPageHeaderOffset = fSpoolFile->Position(); fSpoolFile->Write(fCurrentPageHeader, sizeof(*fCurrentPageHeader)); + + if (fPageNumber == 1) + fCurrentHeader.first_page = fCurrentPageHeaderOffset; + fPageNumber ++; } @@ -727,8 +734,6 @@ { fSpoolFile->Seek(0, SEEK_SET); fCurrentHeader.page_count = fPageNumber; - // TODO set first_page correctly - // fCurrentHeader.first_page = 0; fSpoolFile->Write(&fCurrentHeader, sizeof(fCurrentHeader));} From laplace at mail.berlios.de Mon Jul 30 20:31:22 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Mon, 30 Jul 2007 20:31:22 +0200 Subject: [Haiku-commits] r21755 - haiku/trunk/src/add-ons/print/shared Message-ID: <200707301831.l6UIVMWZ004774@sheep.berlios.de> Author: laplace Date: 2007-07-30 20:31:21 +0200 (Mon, 30 Jul 2007) New Revision: 21755 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21755&view=rev Modified: haiku/trunk/src/add-ons/print/shared/PrintTransport.cpp Log: The Haiku 'Save File Dialog' returns NULL in case of cancelation contrary to BeOS R5. Now NULL is check too. Fixes issue #1068. Modified: haiku/trunk/src/add-ons/print/shared/PrintTransport.cpp =================================================================== --- haiku/trunk/src/add-ons/print/shared/PrintTransport.cpp 2007-07-30 18:19:56 UTC (rev 21754) +++ haiku/trunk/src/add-ons/print/shared/PrintTransport.cpp 2007-07-30 18:31:21 UTC (rev 21755) @@ -129,5 +129,5 @@ // The BeOS "Print To File" transport add-on returns a non-NULL BDataIO * // even after user filepanel cancellation! BFile* file = dynamic_cast(fDataIO); - return file != NULL && file->InitCheck() != B_OK; + return fDataIO == NULL || file != NULL && file->InitCheck() != B_OK; } From korli at mail.berlios.de Mon Jul 30 20:43:32 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 30 Jul 2007 20:43:32 +0200 Subject: [Haiku-commits] r21756 - in haiku/trunk: build/jam src/preferences/keymap Message-ID: <200707301843.l6UIhWGb006946@sheep.berlios.de> Author: korli Date: 2007-07-30 20:43:32 +0200 (Mon, 30 Jul 2007) New Revision: 21756 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21756&view=rev Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/src/preferences/keymap/Keymap.cpp Log: only add libglut.so on x86 added keymap symlinks Finnish, Brazilian, Croatian Keymap preferences app wasn't able to load symlinked keymaps Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-07-30 18:31:21 UTC (rev 21755) +++ haiku/trunk/build/jam/HaikuImage 2007-07-30 18:43:32 UTC (rev 21756) @@ -174,7 +174,9 @@ AddSymlinkToHaikuImage beos system lib : libnetwork.so : libnetapi.so ; AddSymlinkToHaikuImage beos system lib : libnetwork.so : libbnetapi.so ; # libGL.so have GLUT built-in +if $(TARGET_ARCH) = x86 { AddSymlinkToHaikuImage beos system lib : $(X86_ONLY)libGL.so : libglut.so ; +} # servers AddFilesToHaikuImage beos system servers : $(BEOS_SYSTEM_SERVERS) ; @@ -306,6 +308,9 @@ : *.keymap ] ; keymapFiles = $(keymapFiles:BG=keymap) ; AddFilesToHaikuImage beos etc Keymap : $(keymapFiles) ; +AddSymlinkToHaikuImage beos etc Keymap : Swedish : Finnish ; +AddSymlinkToHaikuImage beos etc Keymap : Slovene : Croatian ; +AddSymlinkToHaikuImage beos etc Keymap : US-International : Brazilian ; local timezones = [ FTimeZoneBinaries $(HAIKU_TIME_ZONE_SOURCES) : : true ] ; for timezone in $(timezones) { Modified: haiku/trunk/src/preferences/keymap/Keymap.cpp =================================================================== --- haiku/trunk/src/preferences/keymap/Keymap.cpp 2007-07-30 18:31:21 UTC (rev 21755) +++ haiku/trunk/src/preferences/keymap/Keymap.cpp 2007-07-30 18:43:32 UTC (rev 21756) @@ -86,21 +86,28 @@ Keymap::Load(entry_ref &ref) { status_t err; + BEntry entry(&ref, true); + if ((err = entry.InitCheck()) != B_OK) { + fprintf(stderr, "error loading keymap: %s\n", strerror(err)); + return err; + } - BFile file(&ref, B_READ_ONLY); + BFile file(&entry, B_READ_ONLY); if ((err = file.InitCheck()) != B_OK) { - printf("error %s\n", strerror(err)); + fprintf(stderr, "error loading keymap: %s\n", strerror(err)); return err; } - if (file.Read(&fKeys, sizeof(fKeys)) < (ssize_t)sizeof(fKeys)) { + if ((err = file.Read(&fKeys, sizeof(fKeys))) < (ssize_t)sizeof(fKeys)) { + fprintf(stderr, "error reading keymap keys: %s\n", strerror(err)); return B_BAD_VALUE; } for (uint32 i=0; i Author: korli Date: 2007-07-30 21:57:50 +0200 (Mon, 30 Jul 2007) New Revision: 21757 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21757&view=rev Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp Log: fixed ppc build: replaced a cast to float with a multiplication as the cast requires __floatdisf from libgcc the other solution would have been to link against libgcc.a. please comment. Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp 2007-07-30 18:43:32 UTC (rev 21756) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp 2007-07-30 19:57:50 UTC (rev 21757) @@ -1542,7 +1542,7 @@ return error; fromOffset += buffer_size; toOffset += buffer_size; - update_disk_device_job_progress(job, (float)i / cycleCount); + update_disk_device_job_progress(job, i * 1.0 / cycleCount); } if (remainingSize) error = move_block(fd, fromOffset, toOffset, buffer, remainingSize); From korli at mail.berlios.de Mon Jul 30 22:59:53 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 30 Jul 2007 22:59:53 +0200 Subject: [Haiku-commits] r21758 - haiku/trunk/src/add-ons/media/media-add-ons/multi_audio Message-ID: <200707302059.l6UKxrgg016157@sheep.berlios.de> Author: korli Date: 2007-07-30 22:59:52 +0200 (Mon, 30 Jul 2007) New Revision: 21758 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21758&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp Log: now checks buffer_cycle field for playback and record clean up Modified: haiku/trunk/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp 2007-07-30 19:57:50 UTC (rev 21757) +++ haiku/trunk/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp 2007-07-30 20:59:52 UTC (rev 21758) @@ -1241,7 +1241,7 @@ } for(uint32 i=0; i < (*ioSize/sizeof(float)); i++) { - PRINT(("B_CONTINUOUS_PARAMETER value[%i] : %f\n", i, ((float*)value)[i])); + PRINT(("GetParameterValue B_CONTINUOUS_PARAMETER value[%i] : %f\n", i, ((float*)value)[i])); } } else if(parameter->Type() == BParameter::B_DISCRETE_PARAMETER) { @@ -1254,7 +1254,7 @@ *ioSize = sizeof(int32); for(uint32 i=0; i < (*ioSize/sizeof(int32)); i++) { - PRINT(("B_DISCRETE_PARAMETER value[%i] : %i\n", i, ((int32*)value)[i])); + PRINT(("GetParameterValue B_DISCRETE_PARAMETER value[%i] : %i\n", i, ((int32*)value)[i])); } } @@ -1284,7 +1284,7 @@ if(parameter->Type() == BParameter::B_CONTINUOUS_PARAMETER) { for(uint32 i=0; i < (size/sizeof(float)); i++) { - PRINT(("B_CONTINUOUS_PARAMETER value[%i] : %f\n", i, ((float*)value)[i])); + PRINT(("SetParameterValue B_CONTINUOUS_PARAMETER value[%i] : %f\n", i, ((float*)value)[i])); } MMVI.item_count = 1; MMV[0].id = id; @@ -1298,7 +1298,7 @@ } else if(parameter->Type() == BParameter::B_DISCRETE_PARAMETER) { for(uint32 i=0; i < (size/sizeof(int32)); i++) { - PRINT(("B_DISCRETE_PARAMETER value[%i] : %i\n", i, ((int32*)value)[i])); + PRINT(("SetParameterValue B_DISCRETE_PARAMETER value[%i] : %i\n", i, ((int32*)value)[i])); } BDiscreteParameter *dparameter = (BDiscreteParameter*) parameter; @@ -1445,10 +1445,12 @@ MultiAudioNode::RunThread() { CALLED(); - multi_buffer_info MBI;//, oldMBI; + multi_buffer_info MBI; MBI.info_size = sizeof(MBI); MBI._reserved_0 = 0; MBI._reserved_1 = 2; + MBI.playback_buffer_cycle = 0; + MBI.record_buffer_cycle = 0; while ( 1 ) { //acquire buffer if any @@ -1456,8 +1458,6 @@ return B_OK; } - //oldMBI = MBI; - //send buffer fDevice->DoBufferExchange(&MBI); @@ -1471,11 +1471,13 @@ for(int32 i=0; ifChannelId) + if ((MBI._reserved_0 == input->fChannelId) + && MBI.playback_buffer_cycle >= 0 + && MBI.playback_buffer_cycle < fDevice->MBL.return_playback_buffers && (input->fOldMBI.playback_buffer_cycle != MBI.playback_buffer_cycle - || fDevice->MBL.return_playback_buffers == 1) + || fDevice->MBL.return_playback_buffers == 1) && (input->fInput.source != media_source::null - || input->fChannelId == 0)) { + || input->fChannelId == 0)) { //PRINT(("playback_buffer_cycle ok input : %i %d\n", i, MBI.playback_buffer_cycle)); @@ -1491,8 +1493,6 @@ input->fOldMBI = MBI; if(input->fBuffer!=NULL) { - /*memcpy( fDevice->MBL.playback_buffers[input->fBufferCycle][input->fChannelId].base, - input->fBuffer->Data(), input->fBuffer->SizeUsed() );*/ FillNextBuffer(*input, input->fBuffer); input->fBuffer->Recycle(); input->fBuffer = NULL; @@ -1516,7 +1516,9 @@ // make sure we're both started *and* connected before delivering a buffer if ((RunState() == BMediaEventLooper::B_STARTED) && (output->fOutput.destination != media_destination::null)) { - if((MBI._reserved_1 == output->fChannelId) + if ((MBI._reserved_1 == output->fChannelId) + && MBI.record_buffer_cycle >= 0 + && MBI.record_buffer_cycle < fDevice->MBL.return_record_buffers && (output->fOldMBI.record_buffer_cycle != MBI.record_buffer_cycle || fDevice->MBL.return_record_buffers == 1)) { //PRINT(("record_buffer_cycle ok\n")); From korli at mail.berlios.de Mon Jul 30 23:53:02 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 30 Jul 2007 23:53:02 +0200 Subject: [Haiku-commits] r21759 - haiku/trunk/src/preferences/media Message-ID: <200707302153.l6ULr2Nk019477@sheep.berlios.de> Author: korli Date: 2007-07-30 23:53:01 +0200 (Mon, 30 Jul 2007) New Revision: 21759 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21759&view=rev Modified: haiku/trunk/src/preferences/media/MediaViews.cpp haiku/trunk/src/preferences/media/MediaViews.h Log: selecting the current default input or the current default output doesn't change the setting anymore, and doesn't ask to restart the media server Modified: haiku/trunk/src/preferences/media/MediaViews.cpp =================================================================== --- haiku/trunk/src/preferences/media/MediaViews.cpp 2007-07-30 20:59:52 UTC (rev 21758) +++ haiku/trunk/src/preferences/media/MediaViews.cpp 2007-07-30 21:53:01 UTC (rev 21759) @@ -231,6 +231,16 @@ } + +status_t +SettingsItem::Invoke(BMessage *message) +{ + if (IsMarked()) + return B_OK; + return BMenuItem::Invoke(message); +} + + Settings2Item::Settings2Item(dormant_node_info *info, media_input *input, BMessage *message, char shortcut, uint32 modifiers) : BMenuItem(input->name, message, shortcut, modifiers), @@ -240,8 +250,18 @@ } + Settings2Item::~Settings2Item() { delete fInput; } + +status_t +Settings2Item::Invoke(BMessage *message) +{ + if (IsMarked()) + return B_OK; + return BMenuItem::Invoke(message); +} + Modified: haiku/trunk/src/preferences/media/MediaViews.h =================================================================== --- haiku/trunk/src/preferences/media/MediaViews.h 2007-07-30 20:59:52 UTC (rev 21758) +++ haiku/trunk/src/preferences/media/MediaViews.h 2007-07-30 21:53:01 UTC (rev 21759) @@ -41,6 +41,7 @@ SettingsItem(dormant_node_info *info, BMessage *message, char shortcut = 0, uint32 modifiers = 0); dormant_node_info *fInfo; + virtual status_t Invoke(BMessage *message = NULL); }; class Settings2Item : public BMenuItem @@ -48,7 +49,8 @@ public: Settings2Item(dormant_node_info *info, media_input *input, BMessage *message, char shortcut = 0, uint32 modifiers = 0); - ~Settings2Item(); + virtual ~Settings2Item(); + virtual status_t Invoke(BMessage *message = NULL); dormant_node_info *fInfo; media_input *fInput; }; From korli at mail.berlios.de Tue Jul 31 01:35:02 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 31 Jul 2007 01:35:02 +0200 Subject: [Haiku-commits] r21760 - in haiku/trunk/src/add-ons/kernel/drivers/audio/ac97: . es1370 Message-ID: <200707302335.l6UNZ2Iq007963@sheep.berlios.de> Author: korli Date: 2007-07-31 01:35:00 +0200 (Tue, 31 Jul 2007) New Revision: 21760 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21760&view=rev Added: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/Jamfile haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/ac97.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/ac97.h haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/config.h haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/debug.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/debug.h haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/es1370.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/es1370.h haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/es1370.settings haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/es1370reg.h haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/io.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/io.h haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/multi.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/multi.h haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/queue.h haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/util.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/util.h Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/Jamfile Log: ES1370 audio driver for QEmu, first version. Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/Jamfile 2007-07-30 21:53:01 UTC (rev 21759) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/Jamfile 2007-07-30 23:35:00 UTC (rev 21760) @@ -2,5 +2,6 @@ SubInclude HAIKU_TOP src add-ons kernel drivers audio ac97 auich ; SubInclude HAIKU_TOP src add-ons kernel drivers audio ac97 auvia ; +SubInclude HAIKU_TOP src add-ons kernel drivers audio ac97 es1370 ; SubInclude HAIKU_TOP src add-ons kernel drivers audio ac97 ich ; # SubInclude HAIKU_TOP src add-ons kernel drivers audio ac97 ichaudio ; Added: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/Jamfile 2007-07-30 21:53:01 UTC (rev 21759) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/Jamfile 2007-07-30 23:35:00 UTC (rev 21760) @@ -0,0 +1,14 @@ +SubDir HAIKU_TOP src add-ons kernel drivers audio ac97 es1370 ; + +SetSubDirSupportedPlatformsBeOSCompatible ; + +UsePrivateHeaders media ; + +KernelAddon es1370 : + debug.c + es1370.c + io.c + multi.c + util.c +; + Added: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/ac97.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/ac97.c 2007-07-30 21:53:01 UTC (rev 21759) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/ac97.c 2007-07-30 23:35:00 UTC (rev 21760) @@ -0,0 +1,296 @@ +/* + * Auich BeOS Driver for Intel Southbridge audio + * + * Copyright (c) 2003, Jerome Duval (jerome.duval at free.fr) + * + * Original code : BeOS Driver for Intel ICH AC'97 Link interface + * Copyright (c) 2002, Marcus Overhagen + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include +#include "ac97.h" + +#define REVERSE_EAMP_POLARITY 0 + +#include "debug.h" +#include "io.h" + +#define B_UTF8_REGISTERED "\xC2\xAE" + +const char * stereo_enhancement_technique[] = +{ + "No 3D Stereo Enhancement", + "Analog Devices", + "Creative Technology", + "National Semiconductor", + "Yamaha", + "BBE Sound", + "Crystal Semiconductor", + "Qsound Labs", + "Spatializer Audio Laboratories", + "SRS Labs", + "Platform Tech", + "AKM Semiconductor", + "Aureal", + "Aztech Labs", + "Binaura", + "ESS Technology", + "Harman International", + "Nvidea", + "Philips", + "Texas Instruments", + "VLSI Technology", + "TriTech", + "Realtek", + "Samsung", + "Wolfson Microelectronics", + "Delta Integration", + "SigmaTel", + "KS Waves", + "Rockwell", + "Unknown (29)", + "Unknown (30)", + "Unknown (31)" +}; + +typedef void (* codec_init)(device_config *); +typedef void (* codec_amp_enable)(device_config *, bool); + +typedef struct codec_ops_tag +{ + codec_init init; + codec_amp_enable amp_enable; +} codec_ops; + +typedef struct codec_table_tag +{ + uint32 id; + uint32 mask; + codec_ops *ops; + const char *info; +} codec_table; + +void default_init(device_config *); +void ad1886_init(device_config *); + +void default_amp_enable(device_config *, bool); +void cs4299_amp_enable(device_config *, bool); + +codec_ops default_ops = { default_init, default_amp_enable }; +codec_ops ad1886_ops = { ad1886_init, default_amp_enable }; +codec_ops cs4299_ops = { default_init, cs4299_amp_enable }; + +codec_table codecs[] = +{ + /* Vendor ID and description imported from FreeBSD src/sys/dev/sound/pcm/ac97.c */ + { 0x414b4d00, 0xffffffff, &default_ops, "Asahi Kasei AK4540" }, + { 0x414b4d01, 0xffffffff, &default_ops, "Asahi Kasei AK4542" }, + { 0x414b4d02, 0xffffffff, &default_ops, "Asahi Kasei AK4543" }, + { 0x43525900, 0xffffffff, &default_ops, "Cirrus Logic CS4297" }, + { 0x43525903, 0xffffffff, &default_ops, "Cirrus Logic CS4297" }, + { 0x43525913, 0xffffffff, &default_ops, "Cirrus Logic CS4297A" }, + { 0x43525914, 0xffffffff, &default_ops, "Cirrus Logic CS4297B" }, + { 0x43525923, 0xffffffff, &default_ops, "Cirrus Logic CS4294C" }, + { 0x4352592b, 0xffffffff, &default_ops, "Cirrus Logic CS4298C" }, + { 0x43525931, 0xffffffff, &cs4299_ops, "Cirrus Logic CS4299A" }, + { 0x43525933, 0xffffffff, &cs4299_ops, "Cirrus Logic CS4299C" }, + { 0x43525934, 0xffffffff, &cs4299_ops, "Cirrus Logic CS4299D" }, + { 0x43525941, 0xffffffff, &default_ops, "Cirrus Logic CS4201A" }, + { 0x43525951, 0xffffffff, &default_ops, "Cirrus Logic CS4205A" }, + { 0x43525961, 0xffffffff, &default_ops, "Cirrus Logic CS4291A" }, + { 0x45838308, 0xffffffff, &default_ops, "ESS Technology ES1921" }, + { 0x49434511, 0xffffffff, &default_ops, "ICEnsemble ICE1232" }, + { 0x4e534331, 0xffffffff, &default_ops, "National Semiconductor LM4549" }, + { 0x83847600, 0xffffffff, &default_ops, "SigmaTel STAC9700/9783/9784" }, + { 0x83847604, 0xffffffff, &default_ops, "SigmaTel STAC9701/9703/9704/9705" }, + { 0x83847605, 0xffffffff, &default_ops, "SigmaTel STAC9704" }, + { 0x83847608, 0xffffffff, &default_ops, "SigmaTel STAC9708/9711" }, + { 0x83847609, 0xffffffff, &default_ops, "SigmaTel STAC9721/9723" }, + { 0x83847644, 0xffffffff, &default_ops, "SigmaTel STAC9744" }, + { 0x83847656, 0xffffffff, &default_ops, "SigmaTel STAC9756/9757" }, + { 0x53494c22, 0xffffffff, &default_ops, "Silicon Laboratory Si3036" }, + { 0x53494c23, 0xffffffff, &default_ops, "Silicon Laboratory Si3038" }, + { 0x54524103, 0xffffffff, &default_ops, "TriTech TR?????" }, + { 0x54524106, 0xffffffff, &default_ops, "TriTech TR28026" }, + { 0x54524108, 0xffffffff, &default_ops, "TriTech TR28028" }, + { 0x54524123, 0xffffffff, &default_ops, "TriTech TR28602" }, + { 0x574d4c00, 0xffffffff, &default_ops, "Wolfson WM9701A" }, + { 0x574d4c03, 0xffffffff, &default_ops, "Wolfson WM9703/9704" }, + { 0x574d4c04, 0xffffffff, &default_ops, "Wolfson WM9704 (quad)" }, + /* Assembled from datasheets: */ + { 0x41445303, 0xffffffff, &default_ops, "Analog Devices AD1819B SoundPort"B_UTF8_REGISTERED }, + { 0x41445340, 0xffffffff, &default_ops, "Analog Devices AD1881 SoundMAX"B_UTF8_REGISTERED }, + { 0x41445348, 0xffffffff, &default_ops, "Analog Devices AD1881A SoundMAX"B_UTF8_REGISTERED }, + { 0x41445360, 0xffffffff, &default_ops, "Analog Devices AD1885 SoundMAX"B_UTF8_REGISTERED }, + { 0x41445361, 0xffffffff, &ad1886_ops, "Analog Devices AD1886 SoundMAX"B_UTF8_REGISTERED }, + { 0x41445362, 0xffffffff, &default_ops, "Analog Devices AD1887 SoundMAX"B_UTF8_REGISTERED }, + { 0x41445363, 0xffffffff, &default_ops, "Analog Devices AD1886A SoundMAX"B_UTF8_REGISTERED }, + { 0x41445371, 0xffffffff, &default_ops, "Analog Devices AD1981A SoundMAX"B_UTF8_REGISTERED }, + { 0x41445372, 0xffffffff, &default_ops, "Analog Devices AD1981A SoundMAX"B_UTF8_REGISTERED }, + { 0x414c4320, 0xfffffff0, &default_ops, "Avance Logic (Realtek) ALC100/ALC100P, RL5383/RL5522" }, + { 0x414c4730, 0xffffffff, &default_ops, "Avance Logic (Realtek) ALC101" }, +#if 0 + { 0x414c4710, 0xffffffff, &default_ops, "Avance Logic (Realtek) ALC200/ALC200A" }, /* datasheet says id2 = 4710 */ + { 0x414c4710, 0xffffffff, &default_ops, "Avance Logic (Realtek) ALC201/ALC201A" }, /* 4710 or 4720 */ + { 0x414c4720, 0xffffffff, &default_ops, "Avance Logic (Realtek) ALC650" }, /* datasheet says id2 = 4720 */ +#else + { 0x414c4710, 0xffffffff, &default_ops, "Avance Logic (Realtek) ALC200/ALC200A or ALC201/ALC201A" }, + { 0x414c4720, 0xffffffff, &default_ops, "Avance Logic (Realtek) ALC650 or ALC201/ALC201A" }, +#endif + { 0x414c4740, 0xffffffff, &default_ops, "Avance Logic (Realtek) ALC202/ALC202A" }, + /* Vendors only: */ + { 0x41445300, 0xffffff00, &default_ops, "Analog Devices" }, + { 0x414b4d00, 0xffffff00, &default_ops, "Asahi Kasei" }, + { 0x414c4700, 0xffffff00, &default_ops, "Avance Logic (Realtek)" }, + { 0x43525900, 0xffffff00, &default_ops, "Cirrus Logic" }, + { 0x45838300, 0xffffff00, &default_ops, "ESS Technology" }, + { 0x49434500, 0xffffff00, &default_ops, "ICEnsemble" }, + { 0x4e534300, 0xffffff00, &default_ops, "National Semiconductor" }, + { 0x83847600, 0xffffff00, &default_ops, "SigmaTel" }, + { 0x53494c00, 0xffffff00, &default_ops, "Silicon Laboratory" }, + { 0x54524100, 0xffffff00, &default_ops, "TriTech" }, + { 0x574d4c00, 0xffffff00, &default_ops, "Wolfson" }, + { 0x00000000, 0x00000000, &default_ops, "Unknown" } /* must be last one, matches every codec */ +}; + +static codec_table * +find_codec_table(uint32 codecid) +{ + codec_table *codec; + for (codec = codecs; codec->id; codec++) + if ((codec->id & codec->mask) == (codecid & codec->mask)) + break; + return codec; +} + +const char * +ac97_get_3d_stereo_enhancement(device_config *config) +{ + uint16 data; + data = auich_codec_read(config, AC97_RESET); + data = (data >> 10) & 31; + return stereo_enhancement_technique[data]; +} + +const char * +ac97_get_vendor_id_description(device_config *config) +{ + uint32 id = ac97_get_vendor_id(config); + codec_table *codec = find_codec_table(id); + char f = (id >> 24) & 0xff; + char s = (id >> 16) & 0xff; + char t = (id >> 8) & 0xff; + if (f == 0) f = '?'; + if (s == 0) s = '?'; + if (t == 0) t = '?'; + LOG(("codec %c%c%c %u\n",f,s,t,id & 0xff)); + LOG(("info: %s\n",codec->info)); + return codec->info; +} + +uint32 +ac97_get_vendor_id(device_config *config) +{ + uint16 data1; + uint16 data2; + data1 = auich_codec_read(config, AC97_VENDOR_ID1); + data2 = auich_codec_read(config, AC97_VENDOR_ID2); + return (((uint32)data1) << 16) | data2; +} + +void +ac97_amp_enable(device_config *config, bool yesno) +{ + codec_table *codec; + LOG(("ac97_amp_enable\n")); + codec = find_codec_table(ac97_get_vendor_id(config)); + codec->ops->amp_enable(config, yesno); +} + +void +ac97_init(device_config *config) +{ + codec_table *codec; + LOG(("ac97_init\n")); + codec = find_codec_table(ac97_get_vendor_id(config)); + codec->ops->init(config); + + auich_codec_write(config, AC97_EXTENDED_AUDIO_STATUS, + auich_codec_read(config, AC97_EXTENDED_AUDIO_STATUS) | 1); + +} + +void default_init(device_config *config) +{ + LOG(("default_init\n")); +} + +void ad1886_init(device_config *config) +{ + LOG(("ad1886_init\n")); + auich_codec_write(config, 0x72, 0x0010); +} + +void default_amp_enable(device_config *config, bool yesno) +{ + LOG(("default_amp_enable\n")); + LOG(("powerdown register was = %#04x\n",auich_codec_read(config, AC97_POWERDOWN))); + #if REVERSE_EAMP_POLARITY + yesno = !yesno; + LOG(("using reverse eamp polarity\n")); + #endif + if (yesno) + auich_codec_write(config, AC97_POWERDOWN, auich_codec_read(config, AC97_POWERDOWN) & ~0x8000); /* switch on (low active) */ + else + auich_codec_write(config, AC97_POWERDOWN, auich_codec_read(config, AC97_POWERDOWN) | 0x8000); /* switch off */ + LOG(("powerdown register is = %#04x\n", auich_codec_read(config, AC97_POWERDOWN))); +} + +void cs4299_amp_enable(device_config *config, bool yesno) +{ + LOG(("cs4299_amp_enable\n")); + if (yesno) + auich_codec_write(config, 0x68, 0x8004); + else + auich_codec_write(config, 0x68, 0); +} + +const ac97_source_info source_info[] = { + { "Recording", B_MIX_GAIN|B_MIX_MUTE|B_MIX_STEREO|B_MIX_RECORDMUX, 100, AC97_RECORD_GAIN, 0x8000, 4, 0, 1, 0, 0.0, 22.5, 1.5 }, + { "Master", B_MIX_GAIN|B_MIX_MUTE|B_MIX_STEREO, 101, AC97_MASTER_VOLUME, 0x8000, 5, 0, 1, 1,-46.5, 0.0, 1.5 }, + //{ "Bass/Treble", B_MIX_GAIN|B_MIX_STEREO, 102, AC97_MASTER_TONE, 0x0f0f, 4, 0, 1, 1,-12.0, 10.5, 1.5 }, + //{ "Aux Out", B_MIX_GAIN|B_MIX_MUTE|B_MIX_STEREO, 103, AC97_AUX_OUT_VOLUME, 0x8000, 5, 0, 1, 1,-46.5, 0.0, 1.5 }, + { "PCM Out", B_MIX_GAIN|B_MIX_MUTE|B_MIX_STEREO, 104, AC97_PCM_OUT_VOLUME, 0x8808, 5, 0, 1, 1,-34.5, 12.0, 1.5 }, + { "CD", B_MIX_GAIN|B_MIX_MUTE|B_MIX_STEREO, 105, AC97_CD_VOLUME, 0x8808, 5, 0, 1, 1,-34.5, 12.0, 1.5 }, + { "Aux In", B_MIX_GAIN|B_MIX_MUTE|B_MIX_STEREO, 106, AC97_AUX_IN_VOLUME, 0x8808, 5, 0, 1, 1,-34.5, 12.0, 1.5 }, + { "TAD", B_MIX_GAIN|B_MIX_MUTE|B_MIX_MONO, 107, AC97_PHONE_VOLUME, 0x8008, 5, 0, 1, 1,-34.5, 12.0, 1.5 }, + { "Mic", B_MIX_GAIN|B_MIX_MUTE|B_MIX_MONO|B_MIX_MICBOOST, 108, AC97_MIC_VOLUME, 0x8008, 5, 0, 1, 1,-34.5, 12.0, 1.5 }, + { "Line In", B_MIX_GAIN|B_MIX_MUTE|B_MIX_STEREO, 109, AC97_LINE_IN_VOLUME, 0x8808, 5, 0, 1, 1,-34.5, 12.0, 1.5 }, + //{ "Center/Lfe", B_MIX_GAIN|B_MIX_MUTE|B_MIX_STEREO, 111, AC97_CENTER_LFE_VOLUME, 0x8080, 5, 0, 1, 1,-46.5, 0.0, 1.5 }, + { "Center/Lfe" /* should be "Surround" but no */, B_MIX_GAIN|B_MIX_MUTE|B_MIX_STEREO, 110, AC97_SURROUND_VOLUME, 0x8080, 5, 0, 1, 1,-46.5, 0.0, 1.5 } +}; + +const int32 source_info_size = (sizeof(source_info)/sizeof(source_info[0])); Added: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/ac97.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/ac97.h 2007-07-30 21:53:01 UTC (rev 21759) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/ac97.h 2007-07-30 23:35:00 UTC (rev 21760) @@ -0,0 +1,107 @@ +/* + * Auich BeOS Driver for Intel Southbridge audio + * + * Copyright (c) 2003, Jerome Duval (jerome.duval at free.fr) + * + * Original code : BeOS Driver for Intel ICH AC'97 Link interface + * Copyright (c) 2002, Marcus Overhagen + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _AC97_H_ +#define _AC97_H_ + +#include "config.h" + +enum AC97_REGISTER { + AC97_RESET = 0x00, + AC97_MASTER_VOLUME = 0x02, + AC97_AUX_OUT_VOLUME = 0x04, + AC97_MONO_VOLUME = 0x06, + AC97_MASTER_TONE = 0x08, + AC97_PC_BEEP_VOLUME = 0x0A, + AC97_PHONE_VOLUME = 0x0C, + AC97_MIC_VOLUME = 0x0E, + AC97_LINE_IN_VOLUME = 0x10, + AC97_CD_VOLUME = 0x12, + AC97_VIDEO_VOLUME = 0x14, + AC97_AUX_IN_VOLUME = 0x16, + AC97_PCM_OUT_VOLUME = 0x18, + AC97_RECORD_SELECT = 0x1A, + AC97_RECORD_GAIN = 0x1C, + AC97_RECORD_GAIN_MIC = 0x1E, + AC97_GENERAL_PURPOSE = 0x20, + AC97_3D_CONTROL = 0x22, + AC97_PAGING = 0x24, + AC97_POWERDOWN = 0x26, + AC97_EXTENDED_AUDIO_ID = 0x28, + AC97_EXTENDED_AUDIO_STATUS = 0x2A, + AC97_PCM_FRONT_DAC_RATE = 0x2C, + AC97_PCM_SURR_DAC_RATE = 0x2E, + AC97_PCM_LFE_DAC_RATE = 0x30, + AC97_PCM_LR_ADC_RATE = 0x32, + AC97_MIC_ADC_RATE = 0x34, + AC97_CENTER_LFE_VOLUME = 0x36, + AC97_SURROUND_VOLUME = 0x38, + AC97_SPDIF_CONTROL = 0x3A, + AC97_VENDOR_ID1 = 0x7C, + AC97_VENDOR_ID2 = 0x7E +}; + +const char * ac97_get_3d_stereo_enhancement(device_config *config); +const char * ac97_get_vendor_id_description(device_config *config); +uint32 ac97_get_vendor_id(device_config *config); +void ac97_init(device_config *config); + +void ac97_amp_enable(device_config *config, bool yesno); + +typedef enum { + B_MIX_GAIN = 1 << 0, + B_MIX_MUTE = 1 << 1, + B_MIX_MONO = 1 << 2, + B_MIX_STEREO = 1 << 3, + B_MIX_MUX = 1 << 4, + B_MIX_MICBOOST = 1 << 5, + B_MIX_RECORDMUX = 1 << 6 +} ac97_mixer_type; + +typedef struct _ac97_source_info { + const char *name; + ac97_mixer_type type; + + int32 id; + uint8 reg; + uint16 default_value; + uint8 bits:3; + uint8 ofs:4; + uint8 mute:1; + uint8 polarity:1; // max_gain -> 0 + float min_gain; + float max_gain; + float granularity; +} ac97_source_info; + +extern const ac97_source_info source_info[]; +extern const int32 source_info_size; + +#endif Added: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/config.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/config.h 2007-07-30 21:53:01 UTC (rev 21759) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/config.h 2007-07-30 23:35:00 UTC (rev 21760) @@ -0,0 +1,24 @@ +/* + * ES1370 Haiku Driver for ES1370 audio + * + * Copyright 2002-2007, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Marcus Overhagen, marcus at overhagen.de + * Jerome Duval, jerome.duval at free.fr + */ +#ifndef _CONFIG_H_ +#define _CONFIG_H_ + +#define NUM_CARDS 3 +#define DEVNAME 32 + +typedef struct +{ + uint32 base; + uint32 irq; + uint32 type; +} device_config; + +#endif Added: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/debug.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/debug.c 2007-07-30 21:53:01 UTC (rev 21759) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/debug.c 2007-07-30 23:35:00 UTC (rev 21760) @@ -0,0 +1,76 @@ +/* + * ES1370 Haiku Driver for ES1370 audio + * + * Copyright 2002-2007, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Marcus Overhagen, marcus at overhagen.de + * Jerome Duval, jerome.duval at free.fr + */ +#include +#include +#include +#include +#include +#include +#include "debug.h" +#include "es1370.h" + +#if DEBUG > 0 +static const char * logfile="/boot/home/es1370.log"; +static sem_id loglock; +#endif + +void debug_printf(const char *text,...); +void log_printf(const char *text,...); +void log_create(void); + +void debug_printf(const char *text,...) +{ + char buf[1024]; + va_list ap; + + va_start(ap,text); + vsprintf(buf,text,ap); + va_end(ap); + + dprintf(DRIVER_NAME ": %s",buf); +} + +void log_create() +{ +#if DEBUG > 0 + int fd = open(logfile, O_WRONLY | O_CREAT | O_TRUNC, 0666); + const char *text = DRIVER_NAME ", " VERSION "\n"; + loglock = create_sem(1,"logfile sem"); + write(fd,text,strlen(text)); + close(fd); +#endif +} + +void log_printf(const char *text,...) +{ +#if DEBUG > 0 + int fd; + char buf[1024]; + va_list ap; + + va_start(ap,text); + vsprintf(buf,text,ap); + va_end(ap); + + dprintf(DRIVER_NAME ": %s",buf); + + acquire_sem(loglock); + fd = open(logfile, O_WRONLY | O_APPEND); + write(fd,buf,strlen(buf)); + close(fd); + release_sem(loglock); + + #if DEBUG > 1 + snooze(150000); + #endif +#endif +} + Added: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/debug.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/debug.h 2007-07-30 21:53:01 UTC (rev 21759) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/debug.h 2007-07-30 23:35:00 UTC (rev 21760) @@ -0,0 +1,51 @@ +/* + * ES1370 Haiku Driver for ES1370 audio + * + * Copyright 2002-2007, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Marcus Overhagen, marcus at overhagen.de + * Jerome Duval, jerome.duval at free.fr + */ + +#ifndef _DEBUG_H_ +#define _DEBUG_H_ + +/* + * PRINT() executes dprintf if DEBUG = 0 (disabled), or expands to LOG() when DEBUG > 0 + * TRACE() executes dprintf if DEBUG > 0 + * LOG() executes dprintf and writes to the logfile if DEBUG > 0 + */ + +/* DEBUG == 0, no debugging, PRINT writes to syslog + * DEBUG == 1, TRACE & LOG, PRINT + * DEBUG == 2, TRACE & LOG, PRINT with snooze() + */ +#ifndef DEBUG + #define DEBUG 1 +#endif + +#undef PRINT +#undef TRACE +#undef ASSERT + +#if DEBUG > 0 + #define PRINT(a) log_printf a + #define TRACE(a) debug_printf a + #define LOG(a) log_printf a + #define LOG_CREATE() log_create() + #define ASSERT(a) if (a) {} else LOG(("ASSERT failed! file = %s, line = %d\n",__FILE__,__LINE__)) + void log_create(); + void log_printf(const char *text,...); + void debug_printf(const char *text,...); +#else + void debug_printf(const char *text,...); + #define PRINT(a) debug_printf a + #define TRACE(a) ((void)(0)) + #define ASSERT(a) ((void)(0)) + #define LOG(a) ((void)(0)) + #define LOG_CREATE() +#endif + +#endif Added: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/es1370.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/es1370.c 2007-07-30 21:53:01 UTC (rev 21759) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/es1370.c 2007-07-30 23:35:00 UTC (rev 21760) @@ -0,0 +1,613 @@ +/* + * ES1370 Haiku Driver for ES1370 audio + * + * Copyright 2002-2007, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Jerome Duval, jerome.duval at free.fr + */ + +#include +#include +#include +#include +#include +#include +#include "es1370.h" +#include "debug.h" +#include "config.h" +#include "util.h" +#include "io.h" +#include +#include +#include + +status_t init_hardware(void); +status_t init_driver(void); +void uninit_driver(void); +const char ** publish_devices(void); +device_hooks * find_device(const char *); +status_t es1370_init(es1370_dev * card); + +static char pci_name[] = B_PCI_MODULE_NAME; +pci_module_info *pci; + +int32 num_cards; +es1370_dev cards[NUM_CARDS]; +int32 num_names; +char * names[NUM_CARDS*20+1]; + +extern device_hooks multi_hooks; + +es1370_settings current_settings = { + 44100, // sample rate + 512, // buffer frames + 2, // buffer count +}; + + +/* es1370 Memory management */ + +static es1370_mem * +es1370_mem_new(es1370_dev *card, size_t size) +{ + es1370_mem *mem; + + if ((mem = malloc(sizeof(*mem))) == NULL) + return (NULL); + + mem->area = alloc_mem(&mem->phy_base, &mem->log_base, size, "es1370 buffer"); + mem->size = size; + if (mem->area < B_OK) { + free(mem); + return NULL; + } + return mem; +} + +static void +es1370_mem_delete(es1370_mem *mem) +{ + if(mem->area > B_OK) + delete_area(mem->area); + free(mem); +} + +static void * +es1370_mem_alloc(es1370_dev *card, size_t size) +{ + es1370_mem *mem; + + mem = es1370_mem_new(card, size); + if (mem == NULL) + return (NULL); + + LIST_INSERT_HEAD(&(card->mems), mem, next); + + return mem; +} + +static void +es1370_mem_free(es1370_dev *card, void *ptr) +{ + es1370_mem *mem; + + LIST_FOREACH(mem, &card->mems, next) { + if (mem->log_base != ptr) + continue; + LIST_REMOVE(mem, next); + + es1370_mem_delete(mem); + break; + } +} + +/* es1370 stream functions */ + +status_t +es1370_stream_set_audioparms(es1370_stream *stream, uint8 channels, + uint8 b16, uint32 sample_rate) +{ + uint8 sample_size, frame_size; + LOG(("es1370_stream_set_audioparms\n")); + + if ((stream->channels == channels) && + (stream->b16 == b16) && + (stream->sample_rate == sample_rate)) + return B_OK; + + if(stream->buffer) + es1370_mem_free(stream->card, stream->buffer->log_base); + + stream->b16 = b16; + stream->sample_rate = sample_rate; + stream->channels = channels; + + sample_size = stream->b16 + 1; + frame_size = sample_size * stream->channels; + + stream->buffer = es1370_mem_alloc(stream->card, stream->bufframes * frame_size * stream->bufcount); + + stream->trigblk = 0; /* This shouldn't be needed */ + stream->blkmod = stream->bufcount; + stream->blksize = stream->bufframes * frame_size; + + return B_OK; +} + +status_t +es1370_stream_commit_parms(es1370_stream *stream) +{ + uint8 sample_size, frame_size; + uint32 ctrl; + es1370_dev *card = stream->card; + LOG(("es1370_stream_commit_parms\n")); + + ctrl = es1370_reg_read_32(&card->config, ES1370_REG_CONTROL) & ~CTRL_PCLKDIV; + ctrl |= DAC2_SRTODIV((uint16)stream->sample_rate) << CTRL_SH_PCLKDIV; + es1370_reg_write_32(&card->config, ES1370_REG_CONTROL, ctrl); + + sample_size = stream->b16 + 1; + frame_size = sample_size * stream->channels; + + if (stream->use & ES1370_USE_RECORD) { + es1370_reg_write_32(&card->config, ES1370_REG_MEMPAGE, 0xd); + es1370_reg_write_32(&card->config, ES1370_REG_ADC_FRAMEADR & 0xff, (uint32)stream->buffer->phy_base); + es1370_reg_write_32(&card->config, ES1370_REG_ADC_FRAMECNT & 0xff, ((stream->blksize * stream->bufcount) >> 2) - 1); + es1370_reg_write_32(&card->config, ES1370_REG_ADC_SCOUNT & 0xff, stream->bufframes - 1); + } else { + es1370_reg_write_32(&card->config, ES1370_REG_MEMPAGE, 0xc); + es1370_reg_write_32(&card->config, ES1370_REG_DAC2_FRAMEADR & 0xff, (uint32)stream->buffer->phy_base); + es1370_reg_write_32(&card->config, ES1370_REG_DAC2_FRAMECNT & 0xff, ((stream->blksize * stream->bufcount) >> 2) - 1); + es1370_reg_write_32(&card->config, ES1370_REG_DAC2_SCOUNT & 0xff, stream->bufframes - 1); + LOG(("es1370_stream_commit_parms %ld %ld\n", ((stream->blksize * stream->bufcount) >> 2) - 1, (stream->blksize / frame_size) - 1)); + } + + return B_OK; +} + +status_t +es1370_stream_get_nth_buffer(es1370_stream *stream, uint8 chan, uint8 buf, + char** buffer, size_t *stride) +{ + uint8 sample_size, frame_size; + LOG(("es1370_stream_get_nth_buffer\n")); + + sample_size = stream->b16 + 1; + frame_size = sample_size * stream->channels; + + *buffer = stream->buffer->log_base + (buf * stream->bufframes * frame_size) + + chan * sample_size; + *stride = frame_size; + + return B_OK; +} + +static uint32 +es1370_stream_curaddr(es1370_stream *stream) +{ + es1370_dev *card = stream->card; + uint32 reg = 0, cnt = 0; + if (stream->use & ES1370_USE_RECORD) { + reg = ES1370_REG_ADC_FRAMECNT; + } else { + reg = ES1370_REG_DAC2_FRAMECNT; + } + es1370_reg_write_32(&card->config, ES1370_REG_MEMPAGE, reg >> 8); + cnt = es1370_reg_read_32(&card->config, reg & 0xff) >> 16; + //TRACE(("stream_curaddr %lx\n", (cnt << 2) / stream->blksize)); + return (cnt << 2) / stream->blksize; +} + +void +es1370_stream_start(es1370_stream *stream, void (*inth) (void *), void *inthparam) +{ + uint32 sctrl = 0, ctrl = 0; + es1370_dev *card = stream->card; + LOG(("es1370_stream_start\n")); + + stream->inth = inth; + stream->inthparam = inthparam; + + stream->state |= ES1370_STATE_STARTED; + + sctrl = es1370_reg_read_32(&card->config, ES1370_REG_SERIAL_CONTROL); + ctrl = es1370_reg_read_32(&card->config, ES1370_REG_CONTROL); + + if (stream->use & ES1370_USE_RECORD) { + sctrl &= ~(SCTRL_R1SEB | SCTRL_R1SMB); + if (stream->b16) + sctrl |= SCTRL_R1SEB; + if (stream->channels == 2) + sctrl |= SCTRL_R1SMB; + es1370_reg_write_32(&card->config, ES1370_REG_SERIAL_CONTROL, sctrl & ~SCTRL_R1INTEN); + es1370_reg_write_32(&card->config, ES1370_REG_SERIAL_CONTROL, sctrl | SCTRL_R1INTEN); + + ctrl |= CTRL_ADC_EN; + } else { + sctrl &= ~(SCTRL_P2SEB | SCTRL_P2SMB | 0x003f0000); + if (stream->b16) + sctrl |= SCTRL_P2SEB; + if (stream->channels == 2) + sctrl |= SCTRL_P2SMB; + sctrl |= (stream->b16 + 1) << SCTRL_SH_P2ENDINC; + es1370_reg_write_32(&card->config, ES1370_REG_SERIAL_CONTROL, sctrl & ~SCTRL_P2INTEN); + es1370_reg_write_32(&card->config, ES1370_REG_SERIAL_CONTROL, sctrl | SCTRL_P2INTEN); + + ctrl |= CTRL_DAC2_EN; + } + + es1370_reg_write_32(&card->config, ES1370_REG_SERIAL_CONTROL, sctrl); + es1370_reg_write_32(&card->config, ES1370_REG_CONTROL, ctrl); + +#ifdef DEBUG + //dump_hardware_regs(&stream->card->config); +#endif +} + +void +es1370_stream_halt(es1370_stream *stream) +{ + uint32 ctrl; + es1370_dev *card = stream->card; + LOG(("es1370_stream_halt\n")); + + stream->state &= ~ES1370_STATE_STARTED; + + ctrl = es1370_reg_read_32(&card->config, ES1370_REG_CONTROL); + if (stream->use & ES1370_USE_RECORD) + ctrl &= ~CTRL_ADC_EN; + else + ctrl &= ~CTRL_DAC2_EN; + es1370_reg_write_32(&card->config, ES1370_REG_CONTROL, ctrl); +} + +es1370_stream * +es1370_stream_new(es1370_dev *card, uint8 use, uint32 bufframes, uint8 bufcount) +{ + es1370_stream *stream; + cpu_status status; + LOG(("es1370_stream_new\n")); + + stream = malloc(sizeof(es1370_stream)); + if (stream == NULL) + return (NULL); + stream->card = card; + stream->use = use; + stream->state = !ES1370_STATE_STARTED; + stream->b16 = 0; + stream->sample_rate = 0; + stream->channels = 0; + stream->bufframes = bufframes; + stream->bufcount = bufcount; + stream->inth = NULL; + stream->inthparam = NULL; + stream->buffer = NULL; + stream->blksize = 0; + stream->trigblk = 0; + stream->blkmod = 0; + + stream->buffer_cycle = 0; + stream->frames_count = 0; + stream->real_time = 0; + stream->update_needed = false; + + status = lock(); + LIST_INSERT_HEAD((&card->streams), stream, next); + unlock(status); + + return stream; +} + +void +es1370_stream_delete(es1370_stream *stream) +{ + cpu_status status; + int32 i; + LOG(("es1370_stream_delete\n")); + + es1370_stream_halt(stream); + + if(stream->buffer) + es1370_mem_free(stream->card, stream->buffer->log_base); + + status = lock(); + LIST_REMOVE(stream, next); + unlock(status); + + free(stream); +} + +/* es1370 interrupt */ + +static int32 +es1370_int(void *arg) +{ + es1370_dev *card = arg; + bool gotone = false; + uint32 curblk; + es1370_stream *stream = NULL; + uint32 sta, sctrl; + + // TRACE(("es1370_int(%p)\n", card)); + + sta = es1370_reg_read_32(&card->config, ES1370_REG_STATUS); + if (sta & card->interrupt_mask) { + + //TRACE(("interrupt !! %x\n", sta)); + sctrl = es1370_reg_read_32(&card->config, ES1370_REG_SERIAL_CONTROL); + + LIST_FOREACH(stream, &card->streams, next) { + if (stream->use & ES1370_USE_RECORD) { + if ((sta & STAT_ADC) == 0) + continue; + es1370_reg_write_32(&card->config, ES1370_REG_SERIAL_CONTROL, sctrl & ~SCTRL_R1INTEN); + es1370_reg_write_32(&card->config, ES1370_REG_SERIAL_CONTROL, sctrl | SCTRL_R1INTEN); + } else { + if ((sta & STAT_DAC2) == 0) + continue; + es1370_reg_write_32(&card->config, ES1370_REG_SERIAL_CONTROL, sctrl & ~SCTRL_P2INTEN); + es1370_reg_write_32(&card->config, ES1370_REG_SERIAL_CONTROL, sctrl | SCTRL_P2INTEN); + } + + curblk = es1370_stream_curaddr(stream); + // TRACE(("INTR at trigblk %lu, stream->trigblk %lu\n", curblk, stream->trigblk)); + if (curblk == stream->trigblk) { + stream->trigblk++; + stream->trigblk = stream->trigblk % stream->blkmod; + if (stream->inth) + stream->inth(stream->inthparam); + } + gotone = true; + } + } else { + //TRACE(("interrupt masked %x, ", card->interrupt_mask)); + //TRACE(("sta %x\n", sta)); + } + + if (gotone) + return B_INVOKE_SCHEDULER; + + //TRACE(("Got unhandled interrupt\n")); + return B_UNHANDLED_INTERRUPT; +} + + +/* es1370 driver functions */ + + [... truncated: 2363 lines follow ...] From axeld at pinc-software.de Tue Jul 31 03:12:56 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 31 Jul 2007 03:12:56 +0200 CEST Subject: [Haiku-commits] r21759 - haiku/trunk/src/preferences/media In-Reply-To: <200707302153.l6ULr2Nk019477@sheep.berlios.de> Message-ID: <42021331972-BeMail@ibm> korli at BerliOS wrote: > Log: > selecting the current default input or the current default output > doesn't change > the setting anymore, and doesn't ask to restart the media server I thought we wouldn't need to restart the media server for this anyway? Bye, Axel. From umccullough at gmail.com Tue Jul 31 03:25:34 2007 From: umccullough at gmail.com (Urias McCullough) Date: Mon, 30 Jul 2007 18:25:34 -0700 Subject: [Haiku-commits] r21760 - in haiku/trunk/src/add-ons/kernel/drivers/audio/ac97: . es1370 In-Reply-To: <200707302335.l6UNZ2Iq007963@sheep.berlios.de> References: <200707302335.l6UNZ2Iq007963@sheep.berlios.de> Message-ID: <1e80d8750707301825j50c1cceal9b70e5dca6f993ca@mail.gmail.com> On 7/30/07, korli at BerliOS wrote: > Author: korli > Date: 2007-07-31 01:35:00 +0200 (Tue, 31 Jul 2007) > New Revision: 21760 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21760&view=rev > > Added: > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/ > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/Jamfile > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/ac97.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/ac97.h > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/config.h > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/debug.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/debug.h > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/es1370.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/es1370.h > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/es1370.settings > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/es1370reg.h > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/io.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/io.h > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/multi.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/multi.h > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/queue.h > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/util.h > Modified: > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/Jamfile > Log: > ES1370 audio driver for QEmu, first version. Nice! - has this been tested in VMWare yet? you should be able to set sound.virtualDev=es1370 in the .vmx file to enable it... I think I'll test this out tonight :D From bonefish at cs.tu-berlin.de Tue Jul 31 03:47:33 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Tue, 31 Jul 2007 03:47:33 +0200 (MEST) Subject: [Haiku-commits] r21757 - haiku/trunk/src/add-ons/kernel/partitioning_systems/intel In-Reply-To: <200707301957.l6UJvpuE011879@sheep.berlios.de> References: <200707301957.l6UJvpuE011879@sheep.berlios.de> Message-ID: On Mon, 30 Jul 2007, korli at BerliOS wrote: > Author: korli > Date: 2007-07-30 21:57:50 +0200 (Mon, 30 Jul 2007) > New Revision: 21757 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21757&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp > Log: > fixed ppc build: replaced a cast to float with a multiplication as the cast requires __floatdisf from libgcc > the other solution would have been to link against libgcc.a. please comment. > > > Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp > =================================================================== > --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp 2007-07-30 18:43:32 UTC (rev 21756) > +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp 2007-07-30 19:57:50 UTC (rev 21757) > @@ -1542,7 +1542,7 @@ > return error; > fromOffset += buffer_size; > toOffset += buffer_size; > - update_disk_device_job_progress(job, (float)i / cycleCount); > + update_disk_device_job_progress(job, i * 1.0 / cycleCount); Isn't that pretty much equivalent to casting to double? CU, Ingo From bonefish at mail.berlios.de Tue Jul 31 03:54:25 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 31 Jul 2007 03:54:25 +0200 Subject: [Haiku-commits] r21761 - haiku/trunk/build/jam Message-ID: <200707310154.l6V1sPpf017017@sheep.berlios.de> Author: bonefish Date: 2007-07-31 03:54:24 +0200 (Tue, 31 Jul 2007) New Revision: 21761 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21761&view=rev Modified: haiku/trunk/build/jam/BeOSRules Log: Made the ResComp and ResAttr actions spaces-in-file-names-proof. AddDirectoryToHaikuImage with attributes does also work for directory names with spaces now. Modified: haiku/trunk/build/jam/BeOSRules =================================================================== --- haiku/trunk/build/jam/BeOSRules 2007-07-30 23:35:00 UTC (rev 21760) +++ haiku/trunk/build/jam/BeOSRules 2007-07-31 01:54:24 UTC (rev 21761) @@ -221,7 +221,7 @@ actions ResComp1 { $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) - cat $(2[2-]) | $(CC) -E $(CCDEFS) $(HDRS) - | egrep -v '^#' | $(2[1]) $(RCHDRS) --auto-names -o $(1) - + cat "$(2[2-])" | $(CC) -E $(CCDEFS) $(HDRS) - | egrep -v '^#' | $(2[1]) $(RCHDRS) --auto-names -o "$(1)" - } rule ResAttr attributeFile : _resourceFiles @@ -257,5 +257,5 @@ { $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) rm -f $(1) - $(2[1]) -o $(1) $(2[2-]) + $(2[1]) -o "$(1)" "$(2[2-])" } From umccullough at gmail.com Tue Jul 31 03:55:43 2007 From: umccullough at gmail.com (Urias McCullough) Date: Mon, 30 Jul 2007 18:55:43 -0700 Subject: [Haiku-commits] r21760 - in haiku/trunk/src/add-ons/kernel/drivers/audio/ac97: . es1370 In-Reply-To: <1e80d8750707301825j50c1cceal9b70e5dca6f993ca@mail.gmail.com> References: <200707302335.l6UNZ2Iq007963@sheep.berlios.de> <1e80d8750707301825j50c1cceal9b70e5dca6f993ca@mail.gmail.com> Message-ID: <1e80d8750707301855v47e8d0dak2917f3d9fb013fc7@mail.gmail.com> On 7/30/07, Urias McCullough wrote: > Nice! - has this been tested in VMWare yet? you should be able to set > sound.virtualDev=es1370 in the .vmx file to enable it... Appears I am wrong, it's actually: sound.virtualDev= "es1371" Will that be supported by the same driver? From axeld at pinc-software.de Tue Jul 31 04:00:47 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 31 Jul 2007 04:00:47 +0200 CEST Subject: [Haiku-commits] r21745 - haiku/trunk/src/apps/terminal In-Reply-To: <10617023265-BeMail@ibm> Message-ID: <44892564808-BeMail@ibm> "Axel D?rfler" wrote: > "Stefano Ceccherini" wrote: > > 2007/7/30, Stefano Ceccherini : > > > > BTW, I don't like the exit_thread very much. Isn't there a > > > > cleaner way? > > > I'll try to rework it to avoid the exit_thread(). > > But anyway, I guess in case the read fails that thread can't do > > anything useful anymore. > I'm also not sure what should be so bad about exit_thread() - or > didn't > you spawn that thread yourself before? BTW as Ingo quickly reminded me, there is one bad thing about this function: it doesn't unwind the stack, so any destructors waiting there won't be called. Bye, Axel. From geist at foobox.com Tue Jul 31 06:58:21 2007 From: geist at foobox.com (Travis Geiselbrecht) Date: Mon, 30 Jul 2007 21:58:21 -0700 Subject: [Haiku-commits] r21757 - haiku/trunk/src/add-ons/kernel/partitioning_systems/intel In-Reply-To: <200707301957.l6UJvpuE011879@sheep.berlios.de> References: <200707301957.l6UJvpuE011879@sheep.berlios.de> Message-ID: On Jul 30, 2007, at 12:57 PM, korli at BerliOS wrote: > Author: korli > Date: 2007-07-30 21:57:50 +0200 (Mon, 30 Jul 2007) > New Revision: 21757 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21757&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp > Log: > fixed ppc build: replaced a cast to float with a multiplication as > the cast requires __floatdisf from libgcc > the other solution would have been to link against libgcc.a. please > comment. > Every binary should *always* link against libgcc.a, don't rely on any routine being in the kernel, since it wont be unless the kernel uses the same routine. Travis From stefano.ceccherini at gmail.com Tue Jul 31 08:38:40 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Tue, 31 Jul 2007 08:38:40 +0200 Subject: [Haiku-commits] r21745 - haiku/trunk/src/apps/terminal In-Reply-To: <9873335.1185805122688.JavaMail.ngmail@webmail16> References: <9873335.1185805122688.JavaMail.ngmail@webmail16> Message-ID: <894b9700707302338l7ec0301bue9361bfde6f4befb@mail.gmail.com> 2007/7/30, Marcus Overhagen : > Axel D?rfler wrote: > > While I looked at it, I noticed the code contains still a few errors: > Thanks for the notes, I'll fix those problems in my next commit. From korli at users.berlios.de Tue Jul 31 09:44:57 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Tue, 31 Jul 2007 09:44:57 +0200 Subject: [Haiku-commits] r21759 - haiku/trunk/src/preferences/media In-Reply-To: <42021331972-BeMail@ibm> References: <200707302153.l6ULr2Nk019477@sheep.berlios.de> <42021331972-BeMail@ibm> Message-ID: 2007/7/31, Axel D?rfler : > korli at BerliOS wrote: > > Log: > > selecting the current default input or the current default output > > doesn't change > > the setting anymore, and doesn't ask to restart the media server > > I thought we wouldn't need to restart the media server for this anyway? > This was the target but unless something changed, it needs to be restarted. We could set up this for R1, anyway media kit needs some more tweaking before :) Bye, J?r?me From korli at users.berlios.de Tue Jul 31 09:47:05 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Tue, 31 Jul 2007 09:47:05 +0200 Subject: [Haiku-commits] r21760 - in haiku/trunk/src/add-ons/kernel/drivers/audio/ac97: . es1370 In-Reply-To: <1e80d8750707301855v47e8d0dak2917f3d9fb013fc7@mail.gmail.com> References: <200707302335.l6UNZ2Iq007963@sheep.berlios.de> <1e80d8750707301825j50c1cceal9b70e5dca6f993ca@mail.gmail.com> <1e80d8750707301855v47e8d0dak2917f3d9fb013fc7@mail.gmail.com> Message-ID: 2007/7/31, Urias McCullough : > On 7/30/07, Urias McCullough wrote: > > Nice! - has this been tested in VMWare yet? you should be able to set > > sound.virtualDev=es1370 in the .vmx file to enable it... > > Appears I am wrong, it's actually: > > sound.virtualDev= "es1371" > > Will that be supported by the same driver? It's not at the moment. I was like you hoping for es1370. Work is surely needed to support es1371. Bye, J?r?me From korli at users.berlios.de Tue Jul 31 09:50:11 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Tue, 31 Jul 2007 09:50:11 +0200 Subject: [Haiku-commits] r21757 - haiku/trunk/src/add-ons/kernel/partitioning_systems/intel In-Reply-To: References: <200707301957.l6UJvpuE011879@sheep.berlios.de> Message-ID: 2007/7/31, Ingo Weinhold : > > fromOffset += buffer_size; > > toOffset += buffer_size; > > - update_disk_device_job_progress(job, (float)i / cycleCount); > > + update_disk_device_job_progress(job, i * 1.0 / cycleCount); > > Isn't that pretty much equivalent to casting to double? > Maybe the kernel doesn't use cast to double anywhere ? Could we link every kernel addon against libgcc.a ? Bye, J?r?me From stefano.ceccherini at gmail.com Tue Jul 31 11:24:33 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Tue, 31 Jul 2007 11:24:33 +0200 Subject: [Haiku-commits] r21745 - haiku/trunk/src/apps/terminal In-Reply-To: <9873335.1185805122688.JavaMail.ngmail@webmail16> References: <9873335.1185805122688.JavaMail.ngmail@webmail16> Message-ID: <894b9700707310224qc19b1c8u1b3fbd495777cd0c@mail.gmail.com> 2007/7/30, Marcus Overhagen : > Using exit_thread() isn't wrong per se. But it usually indicates a strange > design. Please note that I didn't say "you have to remove it". I hadn't even > looked at the full sourcecode, I just hoped there would be a cleaner way > than terminating a thread somewhere in the middle. Oh, for the record, the design is indeed strange (not just there). I have cleaned it up a bit, but it probably needs more changes. From bonefish at cs.tu-berlin.de Tue Jul 31 13:02:36 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Tue, 31 Jul 2007 13:02:36 +0200 (MEST) Subject: [Haiku-commits] r21757 - haiku/trunk/src/add-ons/kernel/partitioning_systems/intel In-Reply-To: References: <200707301957.l6UJvpuE011879@sheep.berlios.de> Message-ID: On Tue, 31 Jul 2007, J?r?me Duval wrote: > 2007/7/31, Ingo Weinhold : >>> fromOffset += buffer_size; >>> toOffset += buffer_size; >>> - update_disk_device_job_progress(job, (float)i / cycleCount); >>> + update_disk_device_job_progress(job, i * 1.0 / cycleCount); >> >> Isn't that pretty much equivalent to casting to double? >> > > Maybe the kernel doesn't use cast to double anywhere ? I meant your change. Since the compiler should be clever enough to recognize that multiplying with 1 is a no-op, all that's left is the promotion to double (instead of the previous cast to float). > Could we link > every kernel addon against libgcc.a ? We could. That will increase the size of the kernel modules, of course. CU, Ingo From korli at users.berlios.de Tue Jul 31 13:25:02 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Tue, 31 Jul 2007 13:25:02 +0200 Subject: [Haiku-commits] r21757 - haiku/trunk/src/add-ons/kernel/partitioning_systems/intel In-Reply-To: References: <200707301957.l6UJvpuE011879@sheep.berlios.de> Message-ID: 2007/7/31, Ingo Weinhold : > I meant your change. Since the compiler should be clever enough to > recognize that multiplying with 1 is a no-op, all that's left is the > promotion to double (instead of the previous cast to float). The compiler must use the op multiply with float, which is different from cast to float. > > > Could we link > > every kernel addon against libgcc.a ? > > We could. That will increase the size of the kernel modules, of course. > Even if they link to libgcc after kernel.so ? Bye, J?r?me From jackburton at mail.berlios.de Tue Jul 31 14:53:17 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 31 Jul 2007 14:53:17 +0200 Subject: [Haiku-commits] r21762 - haiku/trunk/src/apps/terminal Message-ID: <200707311253.l6VCrHXC027016@sheep.berlios.de> Author: jackburton Date: 2007-07-31 14:53:16 +0200 (Tue, 31 Jul 2007) New Revision: 21762 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21762&view=rev Modified: haiku/trunk/src/apps/terminal/TermParse.cpp haiku/trunk/src/apps/terminal/TermParse.h Log: cleaned up a bit thread creation and deletion Modified: haiku/trunk/src/apps/terminal/TermParse.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-31 01:54:24 UTC (rev 21761) +++ haiku/trunk/src/apps/terminal/TermParse.cpp 2007-07-31 12:53:16 UTC (rev 21762) @@ -79,7 +79,6 @@ fView = view; status_t status = InitPtyReader(); - if (status < B_OK) { fView = NULL; return status; @@ -87,11 +86,7 @@ status = InitTermParse(); if (status < B_OK) { - delete_sem(fReaderSem); - delete_sem(fReaderLocker); - fQuitting = true; - status_t dummy; - wait_for_thread(fReaderThread, &dummy); + StopPtyReader(); fView = NULL; return status; } @@ -108,19 +103,11 @@ fQuitting = true; - delete_sem(fReaderSem); - fReaderSem = -1; - delete_sem(fReaderLocker); - fReaderSem = -1; - //suspend_thread(fReaderThread); // TODO: interrupt read() - doesn't work for whatever reason - status_t dummy; - wait_for_thread(fReaderThread, &dummy); - fReaderThread = -1; - wait_for_thread(fParseThread, &dummy); - fReaderThread = -1; + StopPtyReader(); + StopTermParse(); fView = NULL; @@ -128,56 +115,6 @@ } -//! Get data from pty device. -int32 -TermParse::PtyReader() -{ - uint read_p = 0; - while (!fQuitting) { - // If Pty Buffer nearly full, snooze this thread, and continue. - if ((read_p - fBufferPosition) > READ_BUF_SIZE - 16) { - fLockFlag = READ_BUF_SIZE / 2; - status_t status; - do { - status = acquire_sem(fReaderLocker); - } while (status == B_INTERRUPTED); - if (status < B_OK) - return status; - } - - // Read PTY - uchar buf[READ_BUF_SIZE]; - int nread = read(fFd, buf, READ_BUF_SIZE - (read_p - fBufferPosition)); - if (nread <= 0) { - fView->NotifyQuit(errno); - // on the next iteration, fQuitting will probably be true, - // or the semaphore acquisition will fail, so this thread will - // be killed anyway. - continue; - } - - // Copy read string to PtyBuffer. - - int left = READ_BUF_SIZE - (read_p % READ_BUF_SIZE); - int mod = read_p % READ_BUF_SIZE; - - if (nread >= left) { - memcpy(fReadBuffer + mod, buf, left); - memcpy(fReadBuffer, buf + left, nread - left); - } else - memcpy(fReadBuffer + mod, buf, nread); - - read_p += nread; - - // Release semaphore. Number of semaphore counter is nread. - release_sem_etc(fReaderSem, nread, 0); - } - - fReaderThread = -1; - return B_OK; -} - - //! Get char from pty reader buffer. status_t TermParse::GetReaderBuf(uchar &c) @@ -228,12 +165,14 @@ fParseThread = spawn_thread(_escparse_thread, "EscParse", B_DISPLAY_PRIORITY, this); - return resume_thread(fParseThread); + resume_thread(fParseThread); + + return B_OK; } //! Initialize and spawn PtyReader thread. -thread_id +status_t TermParse::InitPtyReader() { if (fReaderThread >= 0) @@ -246,6 +185,7 @@ fReaderLocker = create_sem(0, "pty_locker_sem"); if (fReaderLocker < 0) { delete_sem(fReaderSem); + fReaderSem = -1; return fReaderLocker; } @@ -253,15 +193,99 @@ B_NORMAL_PRIORITY, this); if (fReaderThread < 0) { delete_sem(fReaderSem); + fReaderSem = -1; delete_sem(fReaderLocker); + fReaderLocker = -1; return fReaderThread; } - return resume_thread(fReaderThread); + resume_thread(fReaderThread); + + return B_OK; } +void +TermParse::StopTermParse() +{ + if (fParseThread >= 0) { + status_t dummy; + wait_for_thread(fParseThread, &dummy); + fParseThread = -1; + } +} + + +void +TermParse::StopPtyReader() +{ + if (fReaderSem >= 0) { + delete_sem(fReaderSem); + fReaderSem = -1; + } + if (fReaderLocker >= 0) { + delete_sem(fReaderLocker); + fReaderLocker = -1; + } + + if (fReaderThread >= 0) { + status_t dummy; + wait_for_thread(fReaderThread, &dummy); + fReaderThread = -1; + } +} + + +//! Get data from pty device. int32 +TermParse::PtyReader() +{ + uint read_p = 0; + while (!fQuitting) { + // If Pty Buffer nearly full, snooze this thread, and continue. + if ((read_p - fBufferPosition) > READ_BUF_SIZE - 16) { + fLockFlag = READ_BUF_SIZE / 2; + status_t status; + do { + status = acquire_sem(fReaderLocker); + } while (status == B_INTERRUPTED); + if (status < B_OK) + return status; + } + + // Read PTY + uchar buf[READ_BUF_SIZE]; + int nread = read(fFd, buf, READ_BUF_SIZE - (read_p - fBufferPosition)); + if (nread <= 0) { + fView->NotifyQuit(errno); + // on the next iteration, fQuitting will probably be true, + // or the semaphore acquisition will fail, so this thread will + // be killed anyway. + continue; + } + + // Copy read string to PtyBuffer. + + int left = READ_BUF_SIZE - (read_p % READ_BUF_SIZE); + int mod = read_p % READ_BUF_SIZE; + + if (nread >= left) { + memcpy(fReadBuffer + mod, buf, left); + memcpy(fReadBuffer, buf + left, nread - left); + } else + memcpy(fReadBuffer + mod, buf, nread); + + read_p += nread; + + // Release semaphore. Number of semaphore counter is nread. + release_sem_etc(fReaderSem, nread, 0); + } + + return B_OK; +} + + +int32 TermParse::EscParse() { int tmp; @@ -877,8 +901,7 @@ break; } } - fParseThread = -1; - exit_thread(B_OK); + return B_OK; } Modified: haiku/trunk/src/apps/terminal/TermParse.h =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.h 2007-07-31 01:54:24 UTC (rev 21761) +++ haiku/trunk/src/apps/terminal/TermParse.h 2007-07-31 12:53:16 UTC (rev 21762) @@ -54,6 +54,9 @@ status_t InitTermParse(); status_t InitPtyReader(); + void StopTermParse(); + void StopPtyReader(); + int32 EscParse(); int32 PtyReader(); From axeld at mail.berlios.de Tue Jul 31 17:04:27 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 31 Jul 2007 17:04:27 +0200 Subject: [Haiku-commits] r21763 - haiku/trunk/src/apps/mail Message-ID: <200707311504.l6VF4Rsk005054@sheep.berlios.de> Author: axeld Date: 2007-07-31 17:04:26 +0200 (Tue, 31 Jul 2007) New Revision: 21763 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21763&view=rev Modified: haiku/trunk/src/apps/mail/Mail.cpp Log: Renovated the about window a bit. Modified: haiku/trunk/src/apps/mail/Mail.cpp =================================================================== --- haiku/trunk/src/apps/mail/Mail.cpp 2007-07-31 12:53:16 UTC (rev 21762) +++ haiku/trunk/src/apps/mail/Mail.cpp 2007-07-31 15:04:26 UTC (rev 21763) @@ -46,16 +46,17 @@ #include #include +#include #include +#include #include #include #include #include #include #include +#include #include -#include -#include #include #include @@ -291,11 +292,21 @@ void TMailApp::AboutRequested() { - (new BAlert("", - "Mail\nBy Robert Polic\n\n" - "Enhanced by Axel D?rfler and the Dr. Zoidberg crew\n\n" - "Compiled on " __DATE__ " at " __TIME__ ".", - "OK"))->Go(); + BAlert *alert = new BAlert("about", "Mail\n\n" + "written by Robert Polic\n" + "enhanced by the Dr. Zoidberg crew\n\n" + "Copyright 2007, Haiku.\n", "Ok"); + BTextView *view = alert->TextView(); + BFont font; + + view->SetStylable(true); + + view->GetFont(&font); + font.SetSize(font.Size() + 7.0f); + font.SetFace(B_BOLD_FACE); + view->SetFontAndColor(0, 4, &font); + + alert->Go(); } From axeld at mail.berlios.de Tue Jul 31 17:12:51 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 31 Jul 2007 17:12:51 +0200 Subject: [Haiku-commits] r21764 - haiku/trunk/src/kits/mail Message-ID: <200707311512.l6VFCpHB005679@sheep.berlios.de> Author: axeld Date: 2007-07-31 17:12:50 +0200 (Tue, 31 Jul 2007) New Revision: 21764 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21764&view=rev Modified: haiku/trunk/src/kits/mail/MailMessage.cpp Log: Fixed the date string to comply to RFC 2822 - apparently, the timezone must not be given as a string anymore (it's deprecated). That at least allows mmlr's internet provider to recognize mails as valid mails rather than spam. Modified: haiku/trunk/src/kits/mail/MailMessage.cpp =================================================================== --- haiku/trunk/src/kits/mail/MailMessage.cpp 2007-07-31 15:04:26 UTC (rev 21763) +++ haiku/trunk/src/kits/mail/MailMessage.cpp 2007-07-31 15:12:50 UTC (rev 21764) @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001-2004 Dr. Zoidberg Enterprises. All rights reserved. * Copyright 2007, Haiku Inc. All Rights Reserved. * @@ -105,14 +105,16 @@ } -status_t BEmailMessage::InitCheck() const +status_t +BEmailMessage::InitCheck() const { return _status; } BEmailMessage * -BEmailMessage::ReplyMessage(mail_reply_to_mode replyTo, bool accountFromMail, const char *quoteStyle) +BEmailMessage::ReplyMessage(mail_reply_to_mode replyTo, bool accountFromMail, + const char *quoteStyle) { BEmailMessage *to_return = new BEmailMessage; @@ -181,8 +183,10 @@ BString header = "------ Forwarded Message: ------\n"; header << "To: " << To() << '\n'; header << "From: " << From() << '\n'; - if (CC() != NULL) - header << "CC: " << CC() << '\n'; // Can use CC rather than "Cc" since display only. + if (CC() != NULL) { + // Can use CC rather than "Cc" since display only. + header << "CC: " << CC() << '\n'; + } header << "Subject: " << Subject() << '\n'; header << "Date: " << Date() << "\n\n"; if (_text_body != NULL) @@ -524,11 +528,16 @@ return NULL; } -int32 BEmailMessage::CountComponents() const { + +int32 +BEmailMessage::CountComponents() const +{ return _num_components; } -void BEmailMessage::Attach(entry_ref *ref, bool includeAttributes) + +void +BEmailMessage::Attach(entry_ref *ref, bool includeAttributes) { if (includeAttributes) AddComponent(new BAttributedMailAttachment(ref)); @@ -536,7 +545,10 @@ AddComponent(new BSimpleMailAttachment(ref)); } -bool BEmailMessage::IsComponentAttachment(int32 i) { + +bool +BEmailMessage::IsComponentAttachment(int32 i) +{ if ((i >= _num_components) || (_num_components == 0)) return false; @@ -553,7 +565,10 @@ return component->IsAttachment(); } -void BEmailMessage::SetBodyTextTo(const char *text) { + +void +BEmailMessage::SetBodyTextTo(const char *text) +{ if (_text_body == NULL) { _text_body = new BTextMailComponent; AddComponent(_text_body); @@ -563,7 +578,8 @@ } -BTextMailComponent *BEmailMessage::Body() +BTextMailComponent * +BEmailMessage::Body() { if (_text_body == NULL) _text_body = RetrieveTextBody(_body); @@ -572,7 +588,9 @@ } -const char *BEmailMessage::BodyText() { +const char * +BEmailMessage::BodyText() +{ if (Body() == NULL) return NULL; @@ -580,7 +598,9 @@ } -status_t BEmailMessage::SetBody(BTextMailComponent *body) { +status_t +BEmailMessage::SetBody(BTextMailComponent *body) +{ if (_text_body != NULL) { return B_ERROR; // removing doesn't exist for now @@ -594,20 +614,21 @@ } -BTextMailComponent *BEmailMessage::RetrieveTextBody(BMailComponent *component) +BTextMailComponent * +BEmailMessage::RetrieveTextBody(BMailComponent *component) { BTextMailComponent *body = dynamic_cast(component); if (body != NULL) return body; - BMIMEMultipartMailContainer *container = dynamic_cast(component); + BMIMEMultipartMailContainer *container + = dynamic_cast(component); if (container != NULL) { for (int32 i = 0; i < container->CountComponents(); i++) { if ((component = container->GetComponent(i)) == NULL) continue; - switch (component->ComponentType()) - { + switch (component->ComponentType()) { case B_MAIL_PLAIN_TEXT_BODY: // AttributedAttachment returns the MIME type of its contents, so // we have to use dynamic_cast here @@ -691,8 +712,10 @@ // Do real rendering - if (From() == NULL) - SendViaAccount(_chain_id); //-----Set the from string + if (From() == NULL) { + // set the "From:" string + SendViaAccount(_chain_id); + } BList recipientList; get_address_list(recipientList, To(), extract_address); @@ -717,16 +740,20 @@ struct tm tm; localtime_r(&creationTime, &tm); - strftime(date, 128, "%a, %d %b %Y %H:%M:%S",&tm); + size_t length = strftime(date, sizeof(date), + "%a, %d %b %Y %H:%M:%S", &tm); // GMT offsets are full hours, yes, but you never know :-) - if (tm.tm_gmtoff) - sprintf(date + strlen(date)," %+03d%02d",tm.tm_gmtoff / 3600,(tm.tm_gmtoff / 60) % 60); + if (tm.tm_gmtoff) { +#ifndef HAIKU_TARGET_PLATFORM_BEOS + snprintf(date + length, sizeof(date) - length, " %+03d%02d", + tm.tm_gmtoff / 3600, (tm.tm_gmtoff / 60) % 60); +#else + sprintf(date + length, " %+03d%02d", + tm.tm_gmtoff / 3600, (tm.tm_gmtoff / 60) % 60); +#endif + } - uint32 length = strlen(date); - if (length < sizeof(date) - 5) - strftime(date + length, length - sizeof(date), " %Z", &tm); - SetHeaderField("Date", date); } From axeld at mail.berlios.de Tue Jul 31 18:00:32 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 31 Jul 2007 18:00:32 +0200 Subject: [Haiku-commits] r21765 - haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3 Message-ID: <200707311600.l6VG0Wxg013045@sheep.berlios.de> Author: axeld Date: 2007-07-31 18:00:26 +0200 (Tue, 31 Jul 2007) New Revision: 21765 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21765&view=rev Modified: haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.h Log: * Fixed dumb uses of select() with a hardcoded number of file descriptors. * Decreased the timeout from 60 to 30 seconds; somehow it seems it waits more than just once this time in case something fails over here. * Cleaned up the messy SSL patch. * Made the whole thing a bit more compliant to our coding style. * Got rid of the useless pop3_error() macro. * Fixed error reporting in ReceiveLine(). Modified: haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp =================================================================== --- haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp 2007-07-31 15:12:50 UTC (rev 21764) +++ haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp 2007-07-31 16:00:26 UTC (rev 21765) @@ -1,8 +1,12 @@ -/* POP3Protocol - implementation of the POP3 protocol -** -** Copyright 2001-2002 Dr. Zoidberg Enterprises. All rights reserved. -*/ +/* + * Copyright 2001-2002 Dr. Zoidberg Enterprises. All rights reserved. + * Copyright 2007, Haiku Inc. All Rights Reserved. + * + * Distributed under the terms of the MIT License. + */ +//! POP3Protocol - implementation of the POP3 protocol + #include #include #include @@ -35,19 +39,18 @@ #include "pop3.h" -#define POP3_RETRIEVAL_TIMEOUT 60000000 +#define POP3_RETRIEVAL_TIMEOUT 30000000 #define CRLF "\r\n" -#define pop3_error(string) runner->ShowError(string) POP3Protocol::POP3Protocol(BMessage *settings, BMailChainRunner *status) : SimpleMailProtocol(settings,status), fNumMessages(-1), fMailDropSize(0) { - #ifdef USESSL - use_ssl = (settings->FindInt32("flavor") == 1); - #endif +#ifdef USESSL + fUseSSL = (settings->FindInt32("flavor") == 1); +#endif Init(); } @@ -55,25 +58,23 @@ POP3Protocol::~POP3Protocol() { #ifdef USESSL - if( (use_ssl && ssl) || !use_ssl) - SendCommand("QUIT" CRLF); -#else + if (!fUseSSL || fSSL) +#endif SendCommand("QUIT" CRLF); -#endif #ifdef USESSL - if(use_ssl) { - if(ssl) - SSL_shutdown(ssl); - if(ctx) - SSL_CTX_free(ctx); + if (fUseSSL) { + if (fSSL) + SSL_shutdown(fSSL); + if (fSSLContext) + SSL_CTX_free(fSSLContext); } #endif #ifndef HAIKU_TARGET_PLATFORM_BEOS - close(conn); + close(fSocket); #else - closesocket(conn); + closesocket(fSocket); #endif } @@ -81,14 +82,16 @@ status_t POP3Protocol::Open(const char *server, int port, int) { - runner->ReportProgress(0,0,MDR_DIALECT_CHOICE ("Connecting to POP3 Server...","POP3???????????...")); + runner->ReportProgress(0, 0, MDR_DIALECT_CHOICE("Connecting to POP3 Server...", + "POP3???????????...")); - if (port <= 0) - #ifdef USESSL - port = use_ssl ? 995 : 110; - #else - port = 110; - #endif + if (port <= 0) { +#ifdef USESSL + port = fUseSSL ? 995 : 110; +#else + port = 110; +#endif + } fLog = ""; @@ -106,74 +109,73 @@ if (hostIP == 0) { error_msg << MDR_DIALECT_CHOICE (": Connection refused or host not found",": ??????????????????????"); - pop3_error(error_msg.String()); + runner->ShowError(error_msg.String()); return B_NAME_NOT_FOUND; } #ifndef HAIKU_TARGET_PLATFORM_BEOS - conn = socket(AF_INET, SOCK_STREAM, 0); + fSocket = socket(AF_INET, SOCK_STREAM, 0); #else - conn = socket(AF_INET, 2, 0); + fSocket = socket(AF_INET, 2, 0); #endif - if (conn >= 0) { + if (fSocket >= 0) { struct sockaddr_in saAddr; memset(&saAddr, 0, sizeof(saAddr)); - saAddr.sin_family = AF_INET; - saAddr.sin_port = htons(port); + saAddr.sin_family = AF_INET; + saAddr.sin_port = htons(port); saAddr.sin_addr.s_addr = hostIP; - int result = connect(conn, (struct sockaddr *) &saAddr, sizeof(saAddr)); + int result = connect(fSocket, (struct sockaddr *) &saAddr, sizeof(saAddr)); if (result < 0) { #ifndef HAIKU_TARGET_PLATFORM_BEOS - close(conn); + close(fSocket); #else - closesocket(conn); + closesocket(fSocket); #endif - conn = -1; + fSocket = -1; error_msg << ": " << strerror(errno); - pop3_error(error_msg.String()); + runner->ShowError(error_msg.String()); return errno; } } else { error_msg << ": Could not allocate socket."; - pop3_error(error_msg.String()); + runner->ShowError(error_msg.String()); return B_ERROR; } - #ifdef USESSL - if (use_ssl) { +#ifdef USESSL + if (fUseSSL) { SSL_library_init(); - SSL_load_error_strings(); - RAND_seed(this,sizeof(POP3Protocol)); - /*--- Because we're an add-on loaded at an unpredictable time, all - the memory addresses and things contained in ourself are - esssentially random. */ - - ctx = SSL_CTX_new(SSLv23_method()); - ssl = SSL_new(ctx); - sbio=BIO_new_socket(conn,BIO_NOCLOSE); - SSL_set_bio(ssl,sbio,sbio); - - if (SSL_connect(ssl) <= 0) { - BString error; - error << "Could not connect to POP3 server " << settings->FindString("server"); + SSL_load_error_strings(); + RAND_seed(this,sizeof(POP3Protocol)); + /*--- Because we're an add-on loaded at an unpredictable time, all + the memory addresses and things contained in ourself are + esssentially random. */ + + fSSLContext = SSL_CTX_new(SSLv23_method()); + fSSL = SSL_new(fSSLContext); + fSSLBio = BIO_new_socket(fSocket, BIO_NOCLOSE); + SSL_set_bio(fSSL, fSSLBio, fSSLBio); + + if (SSL_connect(fSSL) <= 0) { + BString error; + error << "Could not connect to POP3 server " + << settings->FindString("server"); if (port != 995) error << ":" << port; error << ". (SSL Connection Error)"; runner->ShowError(error.String()); - SSL_CTX_free(ctx); - #ifndef HAIKU_TARGET_PLATFORM_BEOS - close(conn); - #else - closesocket(conn); - #endif + SSL_CTX_free(fSSLContext); +#ifndef HAIKU_TARGET_PLATFORM_BEOS + close(fSocket); +#else + closesocket(fSocket); +#endif runner->Stop(true); return B_ERROR; - } } - - #endif +#endif BString line; status_t err; @@ -186,47 +188,48 @@ if (err < 0) { #ifndef HAIKU_TARGET_PLATFORM_BEOS - close(conn); + close(fSocket); #else - closesocket(conn); + closesocket(fSocket); #endif - conn = -1; + fSocket = -1; error_msg << ": " << strerror(err); - pop3_error(error_msg.String()); - + runner->ShowError(error_msg.String()); return B_ERROR; } if (strncmp(line.String(), "+OK", 3) != 0) { - error_msg << MDR_DIALECT_CHOICE (". The server said:\n","???????????\n") << line.String(); - pop3_error(error_msg.String()); - + error_msg << MDR_DIALECT_CHOICE(". The server said:\n", + "???????????\n") << line.String(); + runner->ShowError(error_msg.String()); return B_ERROR; } fLog = line; - return B_OK; } -status_t POP3Protocol::Login(const char *uid, const char *password, int method) +status_t +POP3Protocol::Login(const char *uid, const char *password, int method) { status_t err; BString error_msg; - error_msg << MDR_DIALECT_CHOICE ("Error while authenticating user ","?????????????????? ") << uid; + error_msg << MDR_DIALECT_CHOICE("Error while authenticating user ", + "?????????????????? ") << uid; if (method == 1) { //APOP int32 index = fLog.FindFirst("<"); if(index != B_ERROR) { - runner->ReportProgress(0,0,MDR_DIALECT_CHOICE ("Sending APOP authentication...","APOP????????...")); + runner->ReportProgress(0, 0, MDR_DIALECT_CHOICE( + "Sending APOP authentication...", "APOP????????...")); int32 end = fLog.FindFirst(">",index); BString timestamp(""); - fLog.CopyInto(timestamp,index,end-index+1); + fLog.CopyInto(timestamp, index, end - index + 1); timestamp += password; char md5sum[33]; - MD5Digest((unsigned char*)timestamp.String(),md5sum); + MD5Digest((unsigned char*)timestamp.String(), md5sum); BString cmd = "APOP "; cmd += uid; cmd += " "; @@ -235,20 +238,22 @@ err = SendCommand(cmd.String()); if (err != B_OK) { - error_msg << MDR_DIALECT_CHOICE (". The server said:\n","???????????\n") << fLog; - pop3_error(error_msg.String()); - + error_msg << MDR_DIALECT_CHOICE(". The server said:\n", + "???????????\n") << fLog; + runner->ShowError(error_msg.String()); return err; } return B_OK; } else { - error_msg << MDR_DIALECT_CHOICE (": The server does not support APOP.","????APOP???????????"); - pop3_error(error_msg.String()); + error_msg << MDR_DIALECT_CHOICE(": The server does not support APOP.", + "????APOP???????????"); + runner->ShowError(error_msg.String()); return B_NOT_ALLOWED; } } - runner->ReportProgress(0,0,MDR_DIALECT_CHOICE ("Sending username...","????ID???...")); + runner->ReportProgress(0, 0, MDR_DIALECT_CHOICE("Sending username...", + "????ID???...")); BString cmd = "USER "; cmd += uid; @@ -256,22 +261,23 @@ err = SendCommand(cmd.String()); if (err != B_OK) { - error_msg << MDR_DIALECT_CHOICE (". The server said:\n","???????????\n") << fLog; - pop3_error(error_msg.String()); - + error_msg << MDR_DIALECT_CHOICE(". The server said:\n", + "???????????\n") << fLog; + runner->ShowError(error_msg.String()); return err; } - runner->ReportProgress(0,0,MDR_DIALECT_CHOICE ("Sending password...","????????...")); + runner->ReportProgress(0, 0, MDR_DIALECT_CHOICE("Sending password...", + "????????...")); cmd = "PASS "; cmd += password; cmd += CRLF; err = SendCommand(cmd.String()); if (err != B_OK) { - error_msg << MDR_DIALECT_CHOICE (". The server said:\n","???????????\n") << fLog; - pop3_error(error_msg.String()); - + error_msg << MDR_DIALECT_CHOICE(". The server said:\n", + "???????????\n") << fLog; + runner->ShowError(error_msg.String()); return err; } @@ -279,15 +285,17 @@ } -status_t POP3Protocol::Stat() +status_t +POP3Protocol::Stat() { - runner->ReportProgress(0,0,MDR_DIALECT_CHOICE ("Getting mailbox size...","???????????????????...")); + runner->ReportProgress(0, 0, MDR_DIALECT_CHOICE("Getting mailbox size...", + "???????????????????...")); if (SendCommand("STAT" CRLF) < B_OK) return B_ERROR; int32 messages,dropSize; - if (sscanf(fLog.String(),"+OK %ld %ld",&messages,&dropSize) < 2) + if (sscanf(fLog.String(), "+OK %ld %ld", &messages, &dropSize) < 2) return B_ERROR; fNumMessages = messages; @@ -297,7 +305,8 @@ } -int32 POP3Protocol::Messages() +int32 +POP3Protocol::Messages() { if (fNumMessages < 0) Stat(); @@ -306,7 +315,8 @@ } -size_t POP3Protocol::MailDropSize() +size_t +POP3Protocol::MailDropSize() { if (fNumMessages < 0) Stat(); @@ -315,7 +325,8 @@ } -status_t POP3Protocol::Retrieve(int32 message, BPositionIO *write_to) +status_t +POP3Protocol::Retrieve(int32 message, BPositionIO *write_to) { status_t returnCode; BString cmd; @@ -339,7 +350,8 @@ } -status_t POP3Protocol::GetHeader(int32 message, BPositionIO *write_to) +status_t +POP3Protocol::GetHeader(int32 message, BPositionIO *write_to) { BString cmd; cmd << "TOP " << message + 1 << " 0" << CRLF; @@ -347,7 +359,8 @@ } -status_t POP3Protocol::RetrieveInternal(const char *command, int32 message, +status_t +POP3Protocol::RetrieveInternal(const char *command, int32 message, BPositionIO *write_to, bool post_progress) { const int bufSize = 1024 * 30; @@ -375,26 +388,22 @@ return B_ERROR; struct timeval tv; - struct fd_set fds; + tv.tv_sec = POP3_RETRIEVAL_TIMEOUT / 1000000; + tv.tv_usec = POP3_RETRIEVAL_TIMEOUT % 1000000; - tv.tv_sec = long(POP3_RETRIEVAL_TIMEOUT / 1e6); - tv.tv_usec = long(POP3_RETRIEVAL_TIMEOUT-(tv.tv_sec * 1e6)); - - /* Initialize (clear) the socket mask. */ - FD_ZERO(&fds); - - /* Set the socket in the mask. */ - FD_SET(conn, &fds); - + struct fd_set readSet; + FD_ZERO(&readSet); + FD_SET(fSocket, &readSet); + while (cont) { - int result = 0; + int result = 0; - #ifdef USESSL - if ((use_ssl) && (SSL_pending(ssl))) - result = 1; - else - #endif - result = select(32, &fds, NULL, NULL, &tv); +#ifdef USESSL + if (fUseSSL && SSL_pending(fSSL)) + result = 1; + else +#endif + result = select(fSocket + 1, &readSet, NULL, NULL, &tv); if (result == 0) { // No data available, even after waiting a minute. fLog = "POP3 timeout - no data received after a long wait."; @@ -403,21 +412,22 @@ } if (amountToReceive > bufSize - 1 - amountInBuffer) amountToReceive = bufSize - 1 - amountInBuffer; - #ifdef USESSL - if (use_ssl) - amountReceived = SSL_read(ssl,buf + amountInBuffer, amountToReceive); - else - #endif - amountReceived = recv(conn,buf + amountInBuffer, amountToReceive,0); - +#ifdef USESSL + if (fUseSSL) { + amountReceived = SSL_read(fSSL, buf + amountInBuffer, + amountToReceive); + } else +#endif + amountReceived = recv(fSocket, buf + amountInBuffer, amountToReceive, 0); if (amountReceived < 0) { fLog = strerror(errno); return errno; } if (amountReceived == 0) { fLog = "POP3 data supposedly ready to receive but not received!"; - return B_ERROR; // Shouldn't happen, but... + return B_ERROR; } + amountToReceive = bufSize - 1; // For next time, read a full buffer. amountInBuffer += amountReceived; buf[amountInBuffer] = 0; // NUL stops tests past the end of buffer. @@ -490,12 +500,16 @@ } -status_t POP3Protocol::UniqueIDs() { +status_t +POP3Protocol::UniqueIDs() +{ status_t ret = B_OK; - runner->ReportProgress(0,0,MDR_DIALECT_CHOICE ("Getting UniqueIDs...","???ID????...")); + runner->ReportProgress(0, 0, MDR_DIALECT_CHOICE("Getting UniqueIDs...", + "???ID????...")); ret = SendCommand("UIDL" CRLF); - if (ret != B_OK) return ret; + if (ret != B_OK) + return ret; BString result; int32 uid_offset; @@ -508,7 +522,7 @@ unique_ids->AddItem(result.String()); } - if (SendCommand("LIST"CRLF) != B_OK) + if (SendCommand("LIST" CRLF) != B_OK) return B_ERROR; int32 b; @@ -521,73 +535,73 @@ b = atol(&(result.String()[b])); else b = 0; - sizes.AddItem((void *)(b)); + fSizes.AddItem((void *)(b)); } return ret; } -void POP3Protocol::Delete(int32 num) { +void +POP3Protocol::Delete(int32 num) +{ BString cmd = "DELE "; cmd << (num+1) << CRLF; if (SendCommand(cmd.String()) != B_OK) { // Error } - #if DEBUG - puts(fLog.String()); - #endif +#if DEBUG + puts(fLog.String()); +#endif } -size_t POP3Protocol::MessageSize(int32 index) { - return (size_t)(sizes.ItemAt(index)); +size_t +POP3Protocol::MessageSize(int32 index) +{ + return (size_t)fSizes.ItemAt(index); } int32 POP3Protocol::ReceiveLine(BString &line) { - int32 len = 0, rcv; - int8 c = 0; + int32 len = 0; bool flag = false; line = ""; - + struct timeval tv; - struct fd_set fds; + tv.tv_sec = POP3_RETRIEVAL_TIMEOUT / 1000000; + tv.tv_usec = POP3_RETRIEVAL_TIMEOUT % 1000000; - tv.tv_sec = long(POP3_RETRIEVAL_TIMEOUT / 1e6); - tv.tv_usec = long(POP3_RETRIEVAL_TIMEOUT-(tv.tv_sec * 1e6)); - - /* Initialize (clear) the socket mask. */ - FD_ZERO(&fds); - - /* Set the socket in the mask. */ - FD_SET(conn, &fds); - int result = -1; - #ifdef USESSL - if ((use_ssl) && (SSL_pending(ssl))) - result = 1; - else - #endif - result = select(32, &fds, NULL, NULL, &tv); - - if (result < 0) - return B_TIMEOUT; - + struct fd_set readSet; + FD_ZERO(&readSet); + FD_SET(fSocket, &readSet); + + int result; +#ifdef USESSL + if (fUseSSL && SSL_pending(fSSL)) + result = 1; + else +#endif + result = select(fSocket + 1, &readSet, NULL, NULL, &tv); + if (result > 0) { - while (true) { // Hope there's an end of line out there else this gets stuck. - #ifdef USESSL - if (use_ssl) - rcv = SSL_read(ssl,&c,1); + while (true) { + // Hope there's an end of line out there else this gets stuck. + int32 bytesReceived; + uint8 c = 0; +#ifdef USESSL + if (fUseSSL) + bytesReceived = SSL_read(fSSL, (char*)&c, 1); else - #endif - rcv = recv(conn, &c, 1, 0); - if (rcv < 0) - return errno; //--An error! - //putchar(c); - if ((c == '\n') || (rcv == 0 /* EOF */)) +#endif + bytesReceived = recv(fSocket, &c, 1, 0); + if (bytesReceived < 0) + return errno; + + if (c == '\n' || bytesReceived == 0 /* EOF */) break; if (c == '\r') { @@ -603,68 +617,72 @@ } } } else { - fLog = "POP3 socket timeout."; + status_t error = errno; + fLog = "POP3 "; + fLog << strerror(error) << "."; + runner->Stop(true); + return error; } + return len; } + status_t - POP3Protocol::SendCommand(const char *cmd) { - if (conn < 0 || conn > FD_SETSIZE) + if (fSocket < 0 || fSocket > FD_SETSIZE) return B_FILE_ERROR; + //printf(cmd); // Flush any accumulated garbage data before we send our command, so we // don't misinterrpret responses from previous commands (that got left over // due to bugs) as being from this command. struct timeval tv; - tv.tv_sec = long(1000 / 1e6); - tv.tv_usec = long(1000-(tv.tv_sec * 1e6)); /* very short timeout, hangs with 0 in R5 */ + tv.tv_sec = 0; + tv.tv_usec = 1000; + /* very short timeout, hangs with 0 in R5 */ - struct fd_set fds; + struct fd_set readSet; + FD_ZERO(&readSet); + FD_SET(fSocket, &readSet); + int result; +#ifdef USESSL + if (fUseSSL && SSL_pending(fSSL)) + result = 1; + else +#endif + result = select(fSocket + 1, &readSet, NULL, NULL, &tv); - /* Initialize (clear) the socket mask. */ - FD_ZERO(&fds); - - /* Set the socket in the mask. */ - FD_SET(conn, &fds); - int result; - #ifdef USESSL - if ((use_ssl) && (SSL_pending(ssl))) - result = 1; - else - #endif - result = select(32, &fds, NULL, NULL, &tv); - if (result > 0) { int amountReceived; char tempString [1025]; - #ifdef USESSL - if (use_ssl) - amountReceived = SSL_read(ssl,tempString, sizeof (tempString) - 1); - else - #endif - amountReceived = recv (conn,tempString, sizeof (tempString) - 1,0); +#ifdef USESSL + if (fUseSSL) + amountReceived = SSL_read(fSSL, tempString, sizeof(tempString) - 1); + else +#endif + amountReceived = recv(fSocket, tempString, sizeof(tempString) - 1, 0); if (amountReceived < 0) return errno; + tempString [amountReceived] = 0; printf ("POP3Protocol::SendCommand Bug! Had to flush %d bytes: %s\n", amountReceived, tempString); //if (amountReceived == 0) // break; } + #ifdef USESSL - if (use_ssl) { - SSL_write(ssl,cmd,::strlen(cmd)); - //SSL_write(ssl,"\r\n",2); + if (fUseSSL) { + SSL_write(fSSL, cmd,::strlen(cmd)); } else #endif - if (send(conn, cmd, ::strlen(cmd), 0) < 0) { + if (send(fSocket, cmd, ::strlen(cmd), 0) < 0) { fLog = strerror(errno); - printf ("POP3Protocol::SendCommand Send \"%s\" failed, code %d: %s\n", + printf("POP3Protocol::SendCommand Send \"%s\" failed, code %d: %s\n", cmd, errno, fLog.String()); return errno; } @@ -685,7 +703,9 @@ } else { printf("POP3Protocol::SendCommand \"%s\" got nonsense message " "from server: %s\n", cmd, fLog.String()); - err = B_BAD_VALUE; //-------If it's not +OK, and it's not -ERR, then what the heck is it? Presume an error + err = B_BAD_VALUE; + // If it's not +OK, and it's not -ERR, then what the heck + // is it? Presume an error break; } } @@ -693,51 +713,59 @@ } -void POP3Protocol::MD5Digest (unsigned char *in,char *ascii_digest) +void +POP3Protocol::MD5Digest(unsigned char *in, char *asciiDigest) { - unsigned char digest[16]; + unsigned char digest[16]; - #ifdef USESSL - MD5(in, ::strlen((char*)in),digest); - #else +#ifdef USESSL + MD5(in, ::strlen((char*)in), digest); +#else MD5_CTX context; - MD5Init(&context); + MD5Init(&context); MD5Update(&context, in, ::strlen((char*)in)); MD5Final(digest, &context); - #endif +#endif - for (int i = 0; i < 16; i++) - sprintf(ascii_digest+2*i, "%02x", digest[i]); + for (int i = 0; i < 16; i++) { + sprintf(asciiDigest + 2 * i, "%02x", digest[i]); + } return; } -BMailFilter *instantiate_mailfilter(BMessage *settings, BMailChainRunner *runner) +// #pragma mark - + + +BMailFilter * +instantiate_mailfilter(BMessage *settings, BMailChainRunner *runner) { return new POP3Protocol(settings,runner); } -BView* instantiate_config_panel(BMessage *settings,BMessage *) +BView* +instantiate_config_panel(BMessage *settings, BMessage *) { - BMailProtocolConfigView *view = new BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_USERNAME | B_MAIL_PROTOCOL_HAS_AUTH_METHODS | B_MAIL_PROTOCOL_HAS_PASSWORD | B_MAIL_PROTOCOL_HAS_HOSTNAME | B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER - #if USESSL - | B_MAIL_PROTOCOL_HAS_FLAVORS); - #else + BMailProtocolConfigView *view = new BMailProtocolConfigView( + B_MAIL_PROTOCOL_HAS_USERNAME | B_MAIL_PROTOCOL_HAS_AUTH_METHODS + | B_MAIL_PROTOCOL_HAS_PASSWORD | B_MAIL_PROTOCOL_HAS_HOSTNAME + | B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER +#if USESSL + | B_MAIL_PROTOCOL_HAS_FLAVORS +#endif ); - #endif view->AddAuthMethod("Plain Text"); view->AddAuthMethod("APOP"); - #if USESSL - view->AddFlavor("No Encryption"); - view->AddFlavor("SSL"); - #endif +#if USESSL + view->AddFlavor("No Encryption"); + view->AddFlavor("SSL"); +#endif view->SetTo(settings); - return view; } Modified: haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.h =================================================================== --- haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.h 2007-07-31 15:12:50 UTC (rev 21764) +++ haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.h 2007-07-31 16:00:26 UTC (rev 21765) @@ -27,26 +27,27 @@ size_t MailDropSize(void); protected: - status_t RetrieveInternal(const char *command,int32 message, BPositionIO *write_to, bool show_progress); - + status_t RetrieveInternal(const char *command, int32 message, + BPositionIO *writeTo, bool showProgress); + int32 ReceiveLine(BString &line); status_t SendCommand(const char* cmd); - void MD5Digest (unsigned char *in, char *out); // MD5 Digest - + void MD5Digest(unsigned char *in, char *out); + private: - int conn; + int fSocket; BString fLog; int32 fNumMessages; size_t fMailDropSize; - BList sizes; - - #ifdef USESSL - SSL_CTX *ctx; - SSL *ssl; - BIO *sbio; - - bool use_ssl; - #endif + BList fSizes; + +#ifdef USESSL + SSL_CTX* fSSLContext; + SSL* fSSL; + BIO* fSSLBio; + + bool fUseSSL; +#endif }; #endif /* ZOIDBERG_POP3_H */ From axeld at mail.berlios.de Tue Jul 31 18:14:59 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 31 Jul 2007 18:14:59 +0200 Subject: [Haiku-commits] r21766 - in haiku/trunk: headers/private/kernel/util src/add-ons/kernel/network/protocols/ipv4 src/add-ons/kernel/network/protocols/tcp src/add-ons/kernel/network/protocols/udp src/system/kernel/slab Message-ID: <200707311614.l6VGExcm014365@sheep.berlios.de> Author: axeld Date: 2007-07-31 18:14:58 +0200 (Tue, 31 Jul 2007) New Revision: 21766 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21766&view=rev Modified: haiku/trunk/headers/private/kernel/util/MultiHashTable.h haiku/trunk/headers/private/kernel/util/OpenHashTable.h haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/multicast.h haiku/trunk/src/add-ons/kernel/network/protocols/tcp/EndpointManager.cpp haiku/trunk/src/add-ons/kernel/network/protocols/tcp/EndpointManager.h haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h haiku/trunk/src/add-ons/kernel/network/protocols/udp/udp.cpp haiku/trunk/src/system/kernel/slab/Slab.cpp Log: axeld+bonefish: Got rid of the ParentType in the HashTableDefinition; it doesn't really belong there. Modified: haiku/trunk/headers/private/kernel/util/MultiHashTable.h =================================================================== --- haiku/trunk/headers/private/kernel/util/MultiHashTable.h 2007-07-31 16:00:26 UTC (rev 21765) +++ haiku/trunk/headers/private/kernel/util/MultiHashTable.h 2007-07-31 16:14:58 UTC (rev 21766) @@ -5,15 +5,15 @@ * Authors: * Hugo Santos, hugosantos at gmail.com */ +#ifndef _KERNEL_UTIL_MULTI_HASH_TABLE_H +#define _KERNEL_UTIL_MULTI_HASH_TABLE_H -#ifndef _MULTI_HASH_TABLE_H_ -#define _MULTI_HASH_TABLE_H_ - #include #include #include + // MultiHashTable is a container which acts a bit like multimap<> // but with hash table semantics. @@ -34,9 +34,9 @@ MultiHashTable(size_t initialSize = HashTable::kMinimumSize) : HashTable(initialSize) {} - MultiHashTable(typename Definition::ParentType *parent, + MultiHashTable(const Definition& definition, size_t initialSize = HashTable::kMinimumSize) - : HashTable(parent, initialSize) {} + : HashTable(definition, initialSize) {} status_t InitCheck() const { return HashTable::InitCheck(); } @@ -174,4 +174,4 @@ } }; -#endif +#endif // _KERNEL_UTIL_MULTI_HASH_TABLE_H Modified: haiku/trunk/headers/private/kernel/util/OpenHashTable.h =================================================================== --- haiku/trunk/headers/private/kernel/util/OpenHashTable.h 2007-07-31 16:00:26 UTC (rev 21765) +++ haiku/trunk/headers/private/kernel/util/OpenHashTable.h 2007-07-31 16:14:58 UTC (rev 21766) @@ -5,37 +5,38 @@ * Authors: * Hugo Santos, hugosantos at gmail.com */ +#ifndef _KERNEL_UTIL_OPEN_HASH_TABLE_H +#define _KERNEL_UTIL_OPEN_HASH_TABLE_H -#ifndef _OPEN_HASH_TABLE_H_ -#define _OPEN_HASH_TABLE_H_ - #include #include -// the Definition template must have four methods: `HashKey', `Hash', -// `Compare' and `GetLink;. It must also define several types as shown in the -// following example: -// -// struct Foo : HashTableLink { -// int bar; -// -// HashTableLink otherLink; -// }; -// -// struct HashTableDefinition { -// typedef void ParentType; -// typedef int KeyType; -// typedef Foo ValueType; -// -// HashTableDefinition(void *parent) {} -// -// size_t HashKey(int key) const { return key >> 1; } -// size_t Hash(Foo *value) const { return HashKey(value->bar); } -// bool Compare(int key, Foo *value) const { return value->bar == key; } -// HashTableLink *GetLink(Foo *value) const { return value; } -// }; +/*! + The Definition template must have four methods: `HashKey', `Hash', + `Compare' and `GetLink;. It must also define several types as shown in the + following example: + + struct Foo : HashTableLink { + int bar; + + HashTableLink otherLink; + }; + + struct HashTableDefinition { + typedef int KeyType; + typedef Foo ValueType; + + HashTableDefinition(const HashTableDefinition&) {} + + size_t HashKey(int key) const { return key >> 1; } + size_t Hash(Foo *value) const { return HashKey(value->bar); } + bool Compare(int key, Foo *value) const { return value->bar == key; } + HashTableLink *GetLink(Foo *value) const { return value; } + }; +*/ + template struct HashTableLink { Type *fNext; @@ -59,15 +60,22 @@ // 50 / 256 = 19.53125% OpenHashTable(size_t initialSize = kMinimumSize) - : fTableSize(0), fItemCount(0), fTable(NULL) + : + fTableSize(0), + fItemCount(0), + fTable(NULL) { if (initialSize > 0) _Resize(initialSize); } - OpenHashTable(typename Definition::ParentType *parent, - size_t initialSize = kMinimumSize) - : fDefinition(parent), fTableSize(0), fItemCount(0), fTable(NULL) + OpenHashTable(const Definition& definition, + size_t initialSize = kMinimumSize) + : + fDefinition(definition), + fTableSize(0), + fItemCount(0), + fTable(NULL) { if (initialSize > 0) _Resize(initialSize); @@ -273,4 +281,4 @@ ValueType **fTable; }; -#endif +#endif // _KERNEL_UTIL_OPEN_HASH_TABLE_H Modified: haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp 2007-07-31 16:00:26 UTC (rev 21765) +++ haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp 2007-07-31 16:14:58 UTC (rev 21766) @@ -131,7 +131,6 @@ typedef MulticastFilter IPv4MulticastFilter; struct MulticastStateHash { - typedef void ParentType; typedef std::pair KeyType; typedef IPv4GroupInterface ValueType; Modified: haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/multicast.h =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/multicast.h 2007-07-31 16:00:26 UTC (rev 21765) +++ haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/multicast.h 2007-07-31 16:14:58 UTC (rev 21766) @@ -5,10 +5,10 @@ * Authors: * Hugo Santos, hugosantos at gmail.com */ - #ifndef _PRIVATE_MULTICAST_H_ #define _PRIVATE_MULTICAST_H_ + #include #include @@ -18,6 +18,7 @@ #include + struct net_buffer; struct net_protocol; @@ -164,7 +165,6 @@ bool FilterAccepts(net_buffer *buffer) const; struct HashDefinition { - typedef void ParentType; typedef std::pair KeyType; typedef ThisType ValueType; Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/EndpointManager.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/EndpointManager.cpp 2007-07-31 16:00:26 UTC (rev 21765) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/EndpointManager.cpp 2007-07-31 16:14:58 UTC (rev 21766) @@ -4,6 +4,7 @@ * * Authors: * Axel D?rfler, axeld at pinc-software.de + * Hugo Santos, hugosantos at gmail.com */ @@ -30,8 +31,12 @@ ConnectionHashDefinition::ConnectionHashDefinition(EndpointManager *manager) - : fManager(manager) {} + : + fManager(manager) +{ +} + size_t ConnectionHashDefinition::HashKey(const KeyType &key) const { Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/EndpointManager.h =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/EndpointManager.h 2007-07-31 16:00:26 UTC (rev 21765) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/EndpointManager.h 2007-07-31 16:14:58 UTC (rev 21766) @@ -1,13 +1,15 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: * Axel D?rfler, axeld at pinc-software.de + * Hugo Santos, hugosantos at gmail.com */ #ifndef ENDPOINT_MANAGER_H #define ENDPOINT_MANAGER_H + #include "tcp.h" #include @@ -27,12 +29,16 @@ struct ConnectionHashDefinition { public: - typedef EndpointManager ParentType; typedef std::pair KeyType; typedef TCPEndpoint ValueType; ConnectionHashDefinition(EndpointManager *manager); + ConnectionHashDefinition(const ConnectionHashDefinition& definition) + : fManager(definition.fManager) + { + } + size_t HashKey(const KeyType &key) const; size_t Hash(TCPEndpoint *endpoint) const; bool Compare(const KeyType &key, TCPEndpoint *endpoint) const; @@ -45,7 +51,6 @@ class EndpointHashDefinition { public: - typedef EndpointManager ParentType; typedef uint16 KeyType; typedef TCPEndpoint ValueType; Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h 2007-07-31 16:00:26 UTC (rev 21765) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h 2007-07-31 16:14:58 UTC (rev 21766) @@ -1,10 +1,11 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: * Andrew Galante, haiku.galante at gmail.com * Axel D?rfler, axeld at pinc-software.de + * Hugo Santos, hugosantos at gmail.com */ #ifndef TCP_ENDPOINT_H #define TCP_ENDPOINT_H @@ -14,7 +15,6 @@ #include "EndpointManager.h" #include "tcp.h" - #include #include #include Modified: haiku/trunk/src/add-ons/kernel/network/protocols/udp/udp.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/udp/udp.cpp 2007-07-31 16:00:26 UTC (rev 21765) +++ haiku/trunk/src/add-ons/kernel/network/protocols/udp/udp.cpp 2007-07-31 16:14:58 UTC (rev 21766) @@ -115,8 +115,10 @@ typedef std::pair KeyType; typedef UdpEndpoint ValueType; - UdpHashDefinition(net_address_module_info *parent) - : module(parent) {} + UdpHashDefinition(net_address_module_info *_module) + : module(_module) {} + UdpHashDefinition(const UdpHashDefinition& definition) + : module(definition.module) {} size_t HashKey(const KeyType &key) const { Modified: haiku/trunk/src/system/kernel/slab/Slab.cpp =================================================================== --- haiku/trunk/src/system/kernel/slab/Slab.cpp 2007-07-31 16:00:26 UTC (rev 21765) +++ haiku/trunk/src/system/kernel/slab/Slab.cpp 2007-07-31 16:14:58 UTC (rev 21766) @@ -112,6 +112,7 @@ typedef Link ValueType; Definition(HashedObjectCache *_parent) : parent(_parent) {} + Definition(const Definition& definition) : parent(definition.parent) {} size_t HashKey(const void *key) const { From axeld at mail.berlios.de Tue Jul 31 18:20:38 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 31 Jul 2007 18:20:38 +0200 Subject: [Haiku-commits] r21767 - in haiku/trunk: headers/private/shared src/kits/support src/servers/registrar Message-ID: <200707311620.l6VGKcJG014930@sheep.berlios.de> Author: axeld Date: 2007-07-31 18:20:37 +0200 (Tue, 31 Jul 2007) New Revision: 21767 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21767&view=rev Added: haiku/trunk/headers/private/shared/Referenceable.h haiku/trunk/src/kits/support/Referenceable.cpp Removed: haiku/trunk/src/servers/registrar/Referenceable.cpp haiku/trunk/src/servers/registrar/Referenceable.h Modified: haiku/trunk/headers/private/shared/AutoDeleter.h haiku/trunk/src/kits/support/Jamfile haiku/trunk/src/servers/registrar/Jamfile Log: * Moved Referenceable.cpp to src/kits/support (private libbe API), and its header to private/shared. * Made AddReference() and CountReferences() inlines. * The registrar is now using the private Referenceable version in libbe.so. * Minor cleanup. Modified: haiku/trunk/headers/private/shared/AutoDeleter.h =================================================================== --- haiku/trunk/headers/private/shared/AutoDeleter.h 2007-07-31 16:14:58 UTC (rev 21766) +++ haiku/trunk/headers/private/shared/AutoDeleter.h 2007-07-31 16:20:37 UTC (rev 21767) @@ -1,35 +1,16 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2002, OpenBeOS -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: AutoDeleter.h -// Author(s): Ingo Weinhold (bonefish at users.sf.net) -// Description: Scope-based automatic deletion of objects/arrays. -// ObjectDeleter - deletes an object -// ArrayDeleter - deletes an array -// MemoryDeleter - free()s malloc()ed memory -//------------------------------------------------------------------------------ - +/* + * Copyright 2001-2007, Ingo Weinhold, bonefish at users.sf.net. All rights reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _AUTO_DELETER_H #define _AUTO_DELETER_H +/*! Scope-based automatic deletion of objects/arrays. + ObjectDeleter - deletes an object + ArrayDeleter - deletes an array + MemoryDeleter - free()s malloc()ed memory +*/ + #include namespace BPrivate { Copied: haiku/trunk/headers/private/shared/Referenceable.h (from rev 21739, haiku/trunk/headers/private/userlandfs/shared/Referencable.h) =================================================================== --- haiku/trunk/headers/private/userlandfs/shared/Referencable.h 2007-07-29 21:12:21 UTC (rev 21739) +++ haiku/trunk/headers/private/shared/Referenceable.h 2007-07-31 16:20:37 UTC (rev 21767) @@ -0,0 +1,122 @@ +/* + * Copyright 2004-2007, Ingo Weinhold, bonefish at users.sf.net. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _REFERENCEABLE_H +#define _REFERENCEABLE_H + + +#include + + +namespace BPrivate { + +class Referenceable { +public: + Referenceable( + bool deleteWhenUnreferenced = true); + virtual ~Referenceable(); + + void AddReference() + { atomic_add(&fReferenceCount, 1); } + + bool RemoveReference(); // returns true after last + + int32 CountReferences() const + { return fReferenceCount; } + +protected: + vint32 fReferenceCount; + bool fDeleteWhenUnreferenced; +}; + +// Reference +template +class Reference { +public: + Reference() + : fObject(NULL) + { + } + + Reference(Type* object, bool alreadyHasReference = false) + : fObject(NULL) + { + SetTo(object, alreadyHasReference); + } + + Reference(const Reference& other) + : fObject(NULL) + { + SetTo(other.fObject); + } + + ~Reference() + { + Unset(); + } + + void SetTo(Type* object, bool alreadyHasReference = false) + { + Unset(); + fObject = object; + if (fObject && !alreadyHasReference) + fObject->AddReference(); + } + + void Unset() + { + if (fObject) { + fObject->RemoveReference(); + fObject = NULL; + } + } + + Type* Get() const + { + return fObject; + } + + Type* Detach() + { + Type* object = fObject; + fObject = NULL; + return object; + } + + Type& operator*() const + { + return *fObject; + } + + Type* operator->() const + { + return fObject; + } + + Reference& operator=(const Reference& other) + { + SetTo(other.fObject); + return *this; + } + + bool operator==(const Reference& other) const + { + return (fObject == other.fObject); + } + + bool operator!=(const Reference& other) const + { + return (fObject != other.fObject); + } + +private: + Type* fObject; +}; + +} // namespace BPrivate + +using BPrivate::Referenceable; +using BPrivate::Reference; + +#endif // _REFERENCEABLE_H Modified: haiku/trunk/src/kits/support/Jamfile =================================================================== --- haiku/trunk/src/kits/support/Jamfile 2007-07-31 16:14:58 UTC (rev 21766) +++ haiku/trunk/src/kits/support/Jamfile 2007-07-31 16:20:37 UTC (rev 21767) @@ -22,6 +22,7 @@ List.cpp Locker.cpp PointerList.cpp + Referenceable.cpp StopWatch.cpp String.cpp # StreamIO.cpp Copied: haiku/trunk/src/kits/support/Referenceable.cpp (from rev 21739, haiku/trunk/src/servers/registrar/Referenceable.cpp) =================================================================== --- haiku/trunk/src/servers/registrar/Referenceable.cpp 2007-07-29 21:12:21 UTC (rev 21739) +++ haiku/trunk/src/kits/support/Referenceable.cpp 2007-07-31 16:20:37 UTC (rev 21767) @@ -0,0 +1,30 @@ +/* + * Copyright 2005-2007, Ingo Weinhold, bonefish at users.sf.net. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include + + +// constructor +Referenceable::Referenceable(bool deleteWhenUnreferenced) + : fReferenceCount(1), + fDeleteWhenUnreferenced(deleteWhenUnreferenced) +{ +} + +// destructor +Referenceable::~Referenceable() +{ +} + +// RemoveReference +bool +Referenceable::RemoveReference() +{ + bool unreferenced = (atomic_add(&fReferenceCount, -1) == 1); + if (fDeleteWhenUnreferenced && unreferenced) + delete this; + return unreferenced; +} Modified: haiku/trunk/src/servers/registrar/Jamfile =================================================================== --- haiku/trunk/src/servers/registrar/Jamfile 2007-07-31 16:14:58 UTC (rev 21766) +++ haiku/trunk/src/servers/registrar/Jamfile 2007-07-31 16:20:37 UTC (rev 21767) @@ -25,7 +25,6 @@ PriorityMessageQueue.cpp RecentApps.cpp RecentEntries.cpp - Referenceable.cpp Registrar.cpp RosterAppInfo.cpp RosterSettingsCharStream.cpp Deleted: haiku/trunk/src/servers/registrar/Referenceable.cpp Deleted: haiku/trunk/src/servers/registrar/Referenceable.h From axeld at mail.berlios.de Tue Jul 31 18:23:41 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 31 Jul 2007 18:23:41 +0200 Subject: [Haiku-commits] r21768 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/kernel/lib Message-ID: <200707311623.l6VGNfiA015122@sheep.berlios.de> Author: axeld Date: 2007-07-31 18:23:40 +0200 (Tue, 31 Jul 2007) New Revision: 21768 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21768&view=rev Added: haiku/trunk/headers/private/kernel/Notifications.h haiku/trunk/src/system/kernel/Notifications.cpp Modified: haiku/trunk/src/system/kernel/lib/Jamfile haiku/trunk/src/system/kernel/main.c Log: bonefish+axeld: Implemented a robust notification framework for the kernel. Will be used for node monitoring and other stuff, too (like the Registrar or the VM low memory handler). Added: haiku/trunk/headers/private/kernel/Notifications.h =================================================================== --- haiku/trunk/headers/private/kernel/Notifications.h 2007-07-31 16:20:37 UTC (rev 21767) +++ haiku/trunk/headers/private/kernel/Notifications.h 2007-07-31 16:23:40 UTC (rev 21768) @@ -0,0 +1,196 @@ +/* + * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel D?rfler, axeld at pinc-software.de + * Ingo Weinhold, bonefish at cs.tu-berlin.de + */ +#ifndef _KERNEL_NOTIFICATIONS_H +#define _KERNEL_NOTIFICATIONS_H + + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + + +#ifdef __cplusplus + +class NotificationService; + +class NotificationListener + : public DoublyLinkedListLinkImpl { + public: + virtual ~NotificationListener(); + + virtual void EventOccured(NotificationService& service, + const KMessage* event); + virtual void AllListenersNotified(); +}; + +class UserMessagingMessageSender { + public: + UserMessagingMessageSender(); + + void SendMessage(const KMessage* message, port_id port, int32 token); + void FlushMessage(); + + private: + enum { + MAX_MESSAGING_TARGET_COUNT = 16, + }; + + const KMessage* fMessage; + messaging_target fTargets[MAX_MESSAGING_TARGET_COUNT]; + int32 fTargetCount; +}; + +class UserMessagingListener : public NotificationListener { + public: + UserMessagingListener(UserMessagingMessageSender& sender, port_id port, + int32 token); + virtual ~UserMessagingListener(); + + virtual void EventOccured(NotificationService& service, + const KMessage* event); + virtual void AllListenersNotified(); + + port_id Port() { return fPort; } + int32 Token() { return fToken; } + + private: + UserMessagingMessageSender& fSender; + port_id fPort; + int32 fToken; +}; + +class NotificationListenerUpdater { + public: + enum update_action { + UPDATED, + SKIP, + DELETE, + REMOVE + }; + + NotificationListenerUpdater(const KMessage* eventSpecifier); + virtual ~NotificationListenerUpdater(); + + virtual status_t UpdateListener(NotificationListener& listener, + enum update_action& action); + + virtual status_t CreateListener(NotificationListener** _listener); + + virtual void SetEventSpecifier(const KMessage* eventSpecifier); + const KMessage* EventSpecifier() const { return fEventSpecifier; } + + protected: + const KMessage* fEventSpecifier; +}; + +class UserMessagingListenerUpdater : public NotificationListenerUpdater { + public: + UserMessagingListenerUpdater(const KMessage* eventSpecifier, port_id port, + int32 token); + + virtual status_t UpdateListener(NotificationListener& listener, + enum update_action& action); + + protected: + virtual status_t UpdateListener(UserMessagingListener& listener, + enum update_action& action) = 0; + + port_id fPort; + int32 fToken; +}; + +class NotificationService : public Referenceable { + public: + virtual ~NotificationService() = 0; + + virtual status_t AddListener(const KMessage* eventSpecifier, + NotificationListener& listener) = 0; + virtual status_t RemoveListener(const KMessage* eventSpecifier, + NotificationListener& listener) = 0; + virtual status_t UpdateListener(NotificationListenerUpdater& updater) = 0; + + virtual const char* Name() = 0; + HashTableLink& Link() { return fLink; } + + private: + HashTableLink fLink; +}; + +class NotificationManager { + public: + static NotificationManager& Manager(); + static status_t CreateManager(); + + status_t RegisterService(NotificationService& service); + void UnregisterService(NotificationService& service); + + NotificationService* GetService(const char* name); + void PutService(NotificationService* service); + + status_t AddListener(const char* service, uint32 eventMask, + NotificationListener& listener); + status_t AddListener(const char* service, + const KMessage* eventSpecifier, NotificationListener& listener); + + status_t RemoveListener(const char* service, uint32 eventMask, + NotificationListener& listener); + status_t RemoveListener(const char* service, + const KMessage* eventSpecifier, NotificationListener& listener); + + status_t UpdateListener(const char* service, + NotificationListenerUpdater& updater); + + private: + NotificationManager(); + ~NotificationManager(); + + status_t _Init(); + NotificationService* _ServiceFor(const char* name); + + struct HashDefinition { + typedef const char* KeyType; + typedef NotificationService ValueType; + + size_t HashKey(const char* key) const + { return hash_hash_string(key); } + size_t Hash(NotificationService *service) const + { return hash_hash_string(service->Name()); } + bool Compare(const char* key, NotificationService* service) const + { return !strcmp(key, service->Name()); } + HashTableLink* GetLink( + NotificationService* service) const + { return &service->Link(); } + }; + + static NotificationManager sManager; + + mutex fLock; + typedef OpenHashTable ServiceHash; + ServiceHash fServiceHash; +}; + +extern "C" { + +#endif // __cplusplus + +void notifications_init(void); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // _KERNEL_NOTIFICATIONS_H Added: haiku/trunk/src/system/kernel/Notifications.cpp =================================================================== --- haiku/trunk/src/system/kernel/Notifications.cpp 2007-07-31 16:20:37 UTC (rev 21767) +++ haiku/trunk/src/system/kernel/Notifications.cpp 2007-07-31 16:23:40 UTC (rev 21768) @@ -0,0 +1,344 @@ +/* + * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel D?rfler, axeld at pinc-software.de + * Ingo Weinhold, bonefish at cs.tu-berlin.de + */ + + +#include + + +NotificationManager NotificationManager::sManager; + + +// #pragma mark - UserMessagingListener + + +NotificationListener::~NotificationListener() +{ +} + + +void +NotificationListener::EventOccured(NotificationService& service, + const KMessage* event) +{ +} + + +void +NotificationListener::AllListenersNotified() +{ +} + + +// #pragma mark - UserMessagingMessageSender + + +UserMessagingMessageSender::UserMessagingMessageSender() + : + fMessage(NULL), + fTargetCount(0) +{ +} + + +void +UserMessagingMessageSender::SendMessage(const KMessage* message, port_id port, + int32 token) +{ + if (message != fMessage && fMessage != NULL + || fTargetCount == MAX_MESSAGING_TARGET_COUNT) { + FlushMessage(); + } + + fMessage = message; + fTargets[fTargetCount].port = port; + fTargets[fTargetCount].token = token; + fTargetCount++; +} + + +void +UserMessagingMessageSender::FlushMessage() +{ + if (fMessage != NULL && fTargetCount > 0) { + send_message(fMessage->Buffer(), fMessage->ContentSize(), + fTargets, fTargetCount); + } + + fMessage = NULL; + fTargetCount = 0; +} + + +// #pragma mark - UserMessagingListener + + +UserMessagingListener::UserMessagingListener(UserMessagingMessageSender& sender, + port_id port, int32 token) + : + fSender(sender), + fPort(port), + fToken(token) +{ +} + + +UserMessagingListener::~UserMessagingListener() +{ +} + + +void +UserMessagingListener::EventOccured(NotificationService& service, + const KMessage* event) +{ + fSender.SendMessage(event, fPort, fToken); +} + + +void +UserMessagingListener::AllListenersNotified() +{ + fSender.FlushMessage(); +} + + +// #pragma mark - NotificationListenerUpdater + + +NotificationListenerUpdater::NotificationListenerUpdater( + const KMessage* eventSpecifier) + : fEventSpecifier(eventSpecifier) +{ +} + + +NotificationListenerUpdater::~NotificationListenerUpdater() +{ +} + + +status_t +NotificationListenerUpdater::UpdateListener(NotificationListener& listener, + enum update_action& action) +{ + action = SKIP; + return B_OK; +} + + +status_t +NotificationListenerUpdater::CreateListener(NotificationListener** _listener) +{ + return B_ERROR; +} + + +void +NotificationListenerUpdater::SetEventSpecifier(const KMessage* eventSpecifier) +{ + fEventSpecifier = eventSpecifier; +} + + +// #pragma mark - NotificationListenerUpdater + + +UserMessagingListenerUpdater::UserMessagingListenerUpdater( + const KMessage* eventSpecifier, port_id port, int32 token) + : + NotificationListenerUpdater(eventSpecifier), + fPort(port), + fToken(token) +{ +} + + +status_t +UserMessagingListenerUpdater::UpdateListener(NotificationListener& _listener, + enum update_action& action) +{ + UserMessagingListener* listener + = dynamic_cast(&_listener); + if (listener != NULL && listener->Port() == fPort + && listener->Token() == fToken) { + return UpdateListener(*listener, action); + } + + action = SKIP; + return B_OK; +} + + +// #pragma mark - NotificationManager + +#if 0 +NotificationService::~NotificationService() +{ +} +#endif + + +// #pragma mark - NotificationManager + + +/*static*/ NotificationManager& +NotificationManager::Manager() +{ + return sManager; +} + + +/*static*/ status_t +NotificationManager::CreateManager() +{ + new(&sManager) NotificationManager; + return sManager._Init(); +} + + +NotificationManager::NotificationManager() +{ +} + + +NotificationManager::~NotificationManager() +{ +} + + +status_t +NotificationManager::_Init() +{ + status_t status = mutex_init(&fLock, "notification manager"); + if (status < B_OK) + return status; + + return fServiceHash.InitCheck(); +} + + +NotificationService* +NotificationManager::_ServiceFor(const char* name) +{ + return fServiceHash.Lookup(name); +} + + +status_t +NotificationManager::RegisterService(NotificationService& service) +{ + MutexLocker _(fLock); + + if (_ServiceFor(service.Name())) + return B_NAME_IN_USE; + + status_t status = fServiceHash.Insert(&service); + if (status == B_OK) + service.AddReference(); + + return status; +} + + +void +NotificationManager::UnregisterService(NotificationService& service) +{ + MutexLocker _(fLock); + fServiceHash.Remove(&service); + service.RemoveReference(); +} + + +status_t +NotificationManager::AddListener(const char* serviceName, + uint32 eventMask, NotificationListener& listener) +{ + char buffer[96]; + KMessage specifier; + specifier.SetTo(buffer, sizeof(buffer), 0); + specifier.AddInt32("event mask", eventMask); + + return AddListener(serviceName, &specifier, listener); +} + + +status_t +NotificationManager::AddListener(const char* serviceName, + const KMessage* eventSpecifier, NotificationListener& listener) +{ + MutexLocker locker(fLock); + NotificationService* service = _ServiceFor(serviceName); + if (service == NULL) + return B_NAME_NOT_FOUND; + + Reference reference(service); + locker.Unlock(); + + return service->AddListener(eventSpecifier, listener); +} + + +status_t +NotificationManager::RemoveListener(const char* serviceName, uint32 eventMask, + NotificationListener& listener) +{ + char buffer[96]; + KMessage specifier; + specifier.SetTo(buffer, sizeof(buffer), 0); + specifier.AddInt32("event mask", eventMask); + + return RemoveListener(serviceName, &specifier, listener); +} + + +status_t +NotificationManager::RemoveListener(const char* serviceName, + const KMessage* eventSpecifier, NotificationListener& listener) +{ + MutexLocker locker(fLock); + NotificationService* service = _ServiceFor(serviceName); + if (service == NULL) + return B_NAME_NOT_FOUND; + + Reference reference(service); + locker.Unlock(); + + return service->RemoveListener(eventSpecifier, listener); +} + + +status_t +NotificationManager::UpdateListener(const char* serviceName, + NotificationListenerUpdater& updater) +{ + MutexLocker locker(fLock); + NotificationService* service = _ServiceFor(serviceName); + if (service == NULL) + return B_NAME_NOT_FOUND; + + Reference reference(service); + locker.Unlock(); + + return service->UpdateListener(updater); +} + + +// #pragma mark - + + +extern "C" void +notifications_init(void) +{ + status_t status = NotificationManager::CreateDefault(); + if (status < B_OK) { + panic("Creating the notification manager failed: %s\n", + strerror(status)); + } +} + Modified: haiku/trunk/src/system/kernel/lib/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/lib/Jamfile 2007-07-31 16:20:37 UTC (rev 21767) +++ haiku/trunk/src/system/kernel/lib/Jamfile 2007-07-31 16:23:40 UTC (rev 21768) @@ -132,3 +132,13 @@ : $(TARGET_KERNEL_PIC_CCFLAGS) ; + +UsePrivateHeaders shared ; + +SEARCH_SOURCE = [ FDirName $(HAIKU_TOP) src kits support ] ; + +KernelMergeObject kernel_misc.o : + Referenceable.cpp + + : $(TARGET_KERNEL_PIC_CCFLAGS) +; Modified: haiku/trunk/src/system/kernel/main.c =================================================================== --- haiku/trunk/src/system/kernel/main.c 2007-07-31 16:20:37 UTC (rev 21767) +++ haiku/trunk/src/system/kernel/main.c 2007-07-31 16:23:40 UTC (rev 21768) @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -156,6 +157,8 @@ elf_init(&sKernelArgs); TRACE("init scheduler\n"); scheduler_init(); + TRACE("init notification services\n"); + notifications_init(); TRACE("init VFS\n"); vfs_init(&sKernelArgs); From laplace at mail.berlios.de Tue Jul 31 18:36:29 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Tue, 31 Jul 2007 18:36:29 +0200 Subject: [Haiku-commits] r21769 - haiku/trunk/build/jam Message-ID: <200707311636.l6VGaTht025982@sheep.berlios.de> Author: laplace Date: 2007-07-31 18:36:28 +0200 (Tue, 31 Jul 2007) New Revision: 21769 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21769&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: Renamed printer spool folder to 'Save as PDF'. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-07-31 16:23:40 UTC (rev 21768) +++ haiku/trunk/build/jam/HaikuImage 2007-07-31 16:36:28 UTC (rev 21769) @@ -393,7 +393,7 @@ # printers AddDirectoryToHaikuImage home config settings printers Preview : home-config-settings-printers-preview.rdef ; -AddDirectoryToHaikuImage home config settings printers "Save-as-PDF" +AddDirectoryToHaikuImage home config settings printers "Save as PDF" : home-config-settings-printers-save-as-pdf.rdef ; From laplace at mail.berlios.de Tue Jul 31 18:39:03 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Tue, 31 Jul 2007 18:39:03 +0200 Subject: [Haiku-commits] r21770 - haiku/trunk/src/add-ons/print/transports/print_to_file Message-ID: <200707311639.l6VGd3GX030087@sheep.berlios.de> Author: laplace Date: 2007-07-31 18:38:48 +0200 (Tue, 31 Jul 2007) New Revision: 21770 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21770&view=rev Modified: haiku/trunk/src/add-ons/print/transports/print_to_file/FileSelector.cpp Log: Avoid memory access to deleted object. Modified: haiku/trunk/src/add-ons/print/transports/print_to_file/FileSelector.cpp =================================================================== --- haiku/trunk/src/add-ons/print/transports/print_to_file/FileSelector.cpp 2007-07-31 16:36:28 UTC (rev 21769) +++ haiku/trunk/src/add-ons/print/transports/print_to_file/FileSelector.cpp 2007-07-31 16:38:48 UTC (rev 21770) @@ -109,13 +109,16 @@ PostMessage(START_MSG); acquire_sem(m_exit_sem); - if ( m_result == B_OK && ref) - m_result = m_entry.GetRef(ref); + // cache result to avoid memory access of deleted window object + // after Quit(). + status_t result = m_result; + if ( result == B_OK && ref) + result = m_entry.GetRef(ref); Lock(); Quit(); - return m_result; + return result; } From laplace at mail.berlios.de Tue Jul 31 18:40:16 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Tue, 31 Jul 2007 18:40:16 +0200 Subject: [Haiku-commits] r21771 - haiku/trunk/src/add-ons/print/transports/print_to_file Message-ID: <200707311640.l6VGeGeV031461@sheep.berlios.de> Author: laplace Date: 2007-07-31 18:40:15 +0200 (Tue, 31 Jul 2007) New Revision: 21771 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21771&view=rev Modified: haiku/trunk/src/add-ons/print/transports/print_to_file/print_transport.cpp Log: * return invalid BFile on cancellation for backwards compatibility with BeOS R5. * style changes. Modified: haiku/trunk/src/add-ons/print/transports/print_to_file/print_transport.cpp =================================================================== --- haiku/trunk/src/add-ons/print/transports/print_to_file/print_transport.cpp 2007-07-31 16:38:48 UTC (rev 21770) +++ haiku/trunk/src/add-ons/print/transports/print_to_file/print_transport.cpp 2007-07-31 16:40:15 UTC (rev 21771) @@ -36,90 +36,78 @@ #include "FileSelector.h" -static BList * g_files_list = NULL; -static uint32 g_nb_files = 0; +static BList * gFiles = NULL; status_t AddFile(BFile * file); status_t RemoveFile(); +static const int32 kStatusOk = 'okok'; +static const int32 kStatusCancel = 'canc'; + extern "C" _EXPORT void exit_transport() { - printf("exit_transport\n"); RemoveFile(); } -extern "C" _EXPORT BDataIO * init_transport - ( - BMessage * msg - ) -{ - BFile * file; - FileSelector * selector; - entry_ref ref; - - printf("init_transport\n"); +extern "C" _EXPORT BDataIO * init_transport(BMessage * msg) +{ + FileSelector * selector = new FileSelector(); + entry_ref ref; + if (selector->Go(&ref) != B_OK) { + // dialog cancelled + if (msg) + msg->what = kStatusCancel; + + // for backwards compatibility with BeOS R5 return an invalid BFile + BFile *file = new BFile(); + AddFile(file); + return file; + } - selector = new FileSelector(); - if (selector->Go(&ref) != B_OK) - return NULL; - - file = new BFile(&ref, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); + BFile *file = new BFile(&ref, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); if ( file->InitCheck() != B_OK ) { - if (msg) - msg->what = 'canc'; // Indicates user cancel the panel... - delete file; - return NULL; - }; + // invalid file selected + if (msg) + msg->what = kStatusCancel; + AddFile(file); + return file; + } - AddFile(file); - - BPath path; - path.SetTo(&ref); - if (msg) { // Print transport add-ons should set to 'okok' the message on success - msg->what = 'okok'; - msg->AddString("path", path.Path()); // Add path of new choosen file to transport message + msg->what = kStatusOk; + + BPath path; + path.SetTo(&ref); + msg->AddString("path", path.Path()); } + AddFile(file); return file; } status_t AddFile(BFile * file) { - if (!file) + if (file == NULL) return B_ERROR; - if (!g_files_list) - { - g_files_list = new BList(); - g_nb_files = 0; - }; + if (gFiles == NULL) + gFiles = new BList(); - g_files_list->AddItem(file); - g_nb_files++; + gFiles->AddItem(file); - printf("AddFile: %ld file transport(s) instanciated\n", g_nb_files); - return B_OK; } status_t RemoveFile() { - void * file; - int32 i; - - g_nb_files--; - - printf("RemoveFile: %ld file transport(s) still instanciated\n", g_nb_files); - - if (g_nb_files) + if (gFiles == NULL) return B_OK; - printf("RemoveFile: deleting files list...\n"); - - for (i = 0; (file = g_files_list->ItemAt(i)); i++) - delete (BFile*)file; + int32 n = gFiles->CountItems(); + for (int32 i = 0; i < n; i++) + delete (BFile*)gFiles->ItemAt(i); - delete g_files_list; + delete gFiles; + gFiles = NULL; return B_OK; } From axeld at mail.berlios.de Tue Jul 31 18:41:16 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 31 Jul 2007 18:41:16 +0200 Subject: [Haiku-commits] r21772 - haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3 Message-ID: <200707311641.l6VGfGpu000173@sheep.berlios.de> Author: axeld Date: 2007-07-31 18:41:06 +0200 (Tue, 31 Jul 2007) New Revision: 21772 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21772&view=rev Modified: haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp Log: I have no idea why it would be a good idea to call ReceiveLine() 200000 times if it didn't deliver a line back, but I've changed it such that it only does this for R5. I've enlarged the timeout back to 60 seconds, as I guess that could have been the culprit. Tested here, and it at least still works. Modified: haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp =================================================================== --- haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp 2007-07-31 16:40:15 UTC (rev 21771) +++ haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp 2007-07-31 16:41:06 UTC (rev 21772) @@ -39,7 +39,7 @@ #include "pop3.h" -#define POP3_RETRIEVAL_TIMEOUT 30000000 +#define POP3_RETRIEVAL_TIMEOUT 60000000 #define CRLF "\r\n" @@ -95,25 +95,28 @@ fLog = ""; - //-----Prime the error message + // Prime the error message BString error_msg; - error_msg << MDR_DIALECT_CHOICE ("Error while connecting to server ","?????????????????? ") << server; + error_msg << MDR_DIALECT_CHOICE("Error while connecting to server ", + "?????????????????? ") << server; if (port != 110) error_msg << ":" << port; - - uint32 hostIP = inet_addr(server); // first see if we can parse it as a numeric address - if ((hostIP == 0)||(hostIP == (uint32)-1)) { + + uint32 hostIP = inet_addr(server); + // first see if we can parse it as a numeric address + if (hostIP == 0 || hostIP == ~0UL) { struct hostent * he = gethostbyname(server); hostIP = he ? *((uint32*)he->h_addr) : 0; } if (hostIP == 0) { - error_msg << MDR_DIALECT_CHOICE (": Connection refused or host not found",": ??????????????????????"); + error_msg << MDR_DIALECT_CHOICE(": Connection refused or host not found", + ": ??????????????????????"); runner->ShowError(error_msg.String()); return B_NAME_NOT_FOUND; } - + #ifndef HAIKU_TARGET_PLATFORM_BEOS fSocket = socket(AF_INET, SOCK_STREAM, 0); #else @@ -179,12 +182,16 @@ BString line; status_t err; +#ifndef HAIKU_TARGET_PLATFORM_BEOS + err = ReceiveLine(line); +#else int32 tries = 200000; // no endless loop here while ((err = ReceiveLine(line)) == 0) { if (tries-- < 0) return B_ERROR; } +#endif if (err < 0) { #ifndef HAIKU_TARGET_PLATFORM_BEOS From axeld at mail.berlios.de Tue Jul 31 19:17:59 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 31 Jul 2007 19:17:59 +0200 Subject: [Haiku-commits] r21773 - in haiku/trunk: headers/private/kernel src/system/kernel Message-ID: <200707311717.l6VHHx3J009641@sheep.berlios.de> Author: axeld Date: 2007-07-31 19:17:51 +0200 (Tue, 31 Jul 2007) New Revision: 21773 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21773&view=rev Modified: haiku/trunk/headers/private/kernel/Notifications.h haiku/trunk/src/system/kernel/Jamfile haiku/trunk/src/system/kernel/Notifications.cpp Log: Ahem... build fix. Forgot that there were some last minute changes that shouldn't have been part of the commit... Modified: haiku/trunk/headers/private/kernel/Notifications.h =================================================================== --- haiku/trunk/headers/private/kernel/Notifications.h 2007-07-31 16:41:06 UTC (rev 21772) +++ haiku/trunk/headers/private/kernel/Notifications.h 2007-07-31 17:17:51 UTC (rev 21773) @@ -12,19 +12,21 @@ #include +#include +#include +#include + + +#ifdef __cplusplus + #include -#include -#include #include #include -#include #include #include -#ifdef __cplusplus - class NotificationService; class NotificationListener Modified: haiku/trunk/src/system/kernel/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/Jamfile 2007-07-31 16:41:06 UTC (rev 21772) +++ haiku/trunk/src/system/kernel/Jamfile 2007-07-31 17:17:51 UTC (rev 21773) @@ -10,6 +10,8 @@ SubDirC++Flags $(defines) ; } +UsePrivateHeaders shared ; + AddResources kernel_$(TARGET_ARCH) : kernel.rdef ; KernelMergeObject kernel_core.o : @@ -24,6 +26,7 @@ lock.c main.c module.cpp + Notifications.cpp port.c real_time_clock.c scheduler.cpp @@ -68,11 +71,12 @@ linkhack.so - # kernel libroot parts + # kernel parts borrowed from libroot and others kernel_os_main.o kernel_os_arch_$(TARGET_ARCH).o kernel_posix.o kernel_posix_arch_$(TARGET_ARCH).o + kernel_misc.o $(HAIKU_STATIC_LIBSUPC++) Modified: haiku/trunk/src/system/kernel/Notifications.cpp =================================================================== --- haiku/trunk/src/system/kernel/Notifications.cpp 2007-07-31 16:41:06 UTC (rev 21772) +++ haiku/trunk/src/system/kernel/Notifications.cpp 2007-07-31 17:17:51 UTC (rev 21773) @@ -335,7 +335,7 @@ extern "C" void notifications_init(void) { - status_t status = NotificationManager::CreateDefault(); + status_t status = NotificationManager::CreateManager(); if (status < B_OK) { panic("Creating the notification manager failed: %s\n", strerror(status)); From axeld at mail.berlios.de Tue Jul 31 19:20:39 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 31 Jul 2007 19:20:39 +0200 Subject: [Haiku-commits] r21774 - haiku/trunk/src/add-ons/accelerants/common Message-ID: <200707311720.l6VHKdFG014448@sheep.berlios.de> Author: axeld Date: 2007-07-31 19:20:34 +0200 (Tue, 31 Jul 2007) New Revision: 21774 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21774&view=rev Modified: haiku/trunk/src/add-ons/accelerants/common/ddc.c haiku/trunk/src/add-ons/accelerants/common/ddc_int.h haiku/trunk/src/add-ons/accelerants/common/decode_edid.c haiku/trunk/src/add-ons/accelerants/common/dump_edid.c haiku/trunk/src/add-ons/accelerants/common/i2c.c Log: Patch by Vasilis Kaoutsis - thanks!: * Fixed some warnings. * Style cleanup. Modified: haiku/trunk/src/add-ons/accelerants/common/ddc.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/common/ddc.c 2007-07-31 17:17:51 UTC (rev 21773) +++ haiku/trunk/src/add-ons/accelerants/common/ddc.c 2007-07-31 17:20:34 UTC (rev 21774) @@ -1,89 +1,103 @@ /* - Copyright (c) 2003, Thomas Kurschel + * Copyright 2003, Thomas Kurschel. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ - Part of DDC driver - +/*! + Part of DDC driver Main DDC communication */ -#include -#include -#include + #include "ddc_int.h" #include "ddc.h" - #include "i2c.h" -// number of retries to read ddc data +#include +#include + +#include + + #define READ_RETRIES 4 + // number of retries to read ddc data -// verify checksum of ddc data -// (some monitors have a broken checksum - bad luck for them) -static status_t verify_checksum( const uint8 *data, size_t len ) +#if 0 +/*! Verify checksum of ddc data + (some monitors have a broken checksum - bad luck for them) +*/ +static status_t +verify_checksum(const uint8 *data, size_t len) { - int i; + uint32 index; uint8 sum = 0; uint8 all_or = 0; - for( i = 0; i < len; ++i, ++data ) { + for (index = 0; index < len; ++index, ++data) { sum += *data; all_or |= *data; } - if( all_or == 0 ) { - SHOW_ERROR0( 2, "DDC information contains zeros only" ); + if (all_or == 0) { + SHOW_ERROR0(2, "DDC information contains zeros only"); return B_ERROR; } - if( sum != 0 ) { - SHOW_ERROR0( 2, "Checksum error of DDC information" ); + if (sum != 0) { + SHOW_ERROR0(2, "Checksum error of DDC information"); return B_IO_ERROR; } return B_OK; } +#endif -// read ddc2 data from monitor -static status_t ddc2_read( const i2c_bus *bus, int start, uint8 *buffer, size_t len ) + +//! Read ddc2 data from monitor +static status_t +ddc2_read(const i2c_bus *bus, int start, uint8 *buffer, size_t len) { uint8 write_buffer[2]; i2c_timing timing; int i; - status_t res; + status_t res = B_OK; write_buffer[0] = start & 0xff; write_buffer[1] = (start >> 8) & 0xff; - i2c_get100k_timing( &timing ); - + i2c_get100k_timing(&timing); + timing.start_timeout = 550; timing.byte_timeout = 2200; timing.bit_timeout = 40; timing.ack_start_timeout = 40; timing.ack_timeout = 40; - - for( i = 0; i < READ_RETRIES; ++i ) { - res = i2c_send_receive( bus, &timing, + + for (i = 0; i < READ_RETRIES; ++i) { + res = i2c_send_receive(bus, &timing, 0xa0, write_buffer, start < 0x100 ? 1 : 2, - buffer, len ); + buffer, len); // don't verify checksum - it's often broken - if( res == B_OK /*&& verify_checksum( buffer, len ) == B_OK*/ ) + if (res == B_OK /*&& verify_checksum( buffer, len ) == B_OK*/) break; - + res = B_ERROR; } - + return res; } -// reading VDIF has not been tested. -// it seems that almost noone supports VDIF which makes testing hard, -// but what's the point anyway? +/*! + Reading VDIF has not been tested. + it seems that almost noone supports VDIF which makes testing hard, + but what's the point anyway? +*/ #if 0 -static status_t ddc2_read_vdif( const i2c_bus *bus, int start, - void **vdif, size_t *vdif_len ) +static status_t +ddc2_read_vdif(const i2c_bus *bus, int start, + void **vdif, size_t *vdif_len) { status_t res; uint8 *data, *cur_data; @@ -93,21 +107,21 @@ *vdif = NULL; *vdif_len = 0; - res = ddc2_read( bus, start, buffer, 64 ); - SHOW_INFO( 2, "%x", buffer[0] ); - if( res != B_OK || buffer[0] == 0 ) + res = ddc2_read(bus, start, buffer, 64); + SHOW_INFO(2, "%x", buffer[0]); + if (res != B_OK || buffer[0] == 0) return B_OK; - + // each block is 63 bytes plus 1 checksum long // we strip the checksum but store data directly into // buffer, so we need an extra byte for checksum of the last block - data = malloc( buffer[0] * 63 + 1 ); - if( data == NULL ) + data = malloc(buffer[0] * 63 + 1); + if (data == NULL) return B_NO_MEMORY; - + cur_data = data; - for( i = 0; i < buffer[0]; ++i ) { - ddc2_read( bus, start + i * 64, cur_data, 64 ); + for (i = 0; i < buffer[0]; ++i) { + ddc2_read(bus, start + i * 64, cur_data, 64); // strip checksum byte cur_data += 63; } @@ -118,29 +132,31 @@ } #endif -// read EDID and VDIF from monitor via ddc2 -status_t ddc2_read_edid1( const i2c_bus *bus, edid1_info *edid, - void **vdif, size_t *vdif_len ) + +//! Read EDID and VDIF from monitor via ddc2 +status_t +ddc2_read_edid1(const i2c_bus *bus, edid1_info *edid, + void **vdif, size_t *vdif_len) { status_t res; edid1_raw raw; - res = ddc2_read( bus, 0, (uint8 *)&raw, sizeof( raw )); - if( res != B_OK ) + res = ddc2_read(bus, 0, (uint8 *)&raw, sizeof(raw)); + if (res != B_OK) return res; - - edid_decode( edid, &raw ); - + + edid_decode(edid, &raw); + *vdif = NULL; *vdif_len = 0; // skip vdif as long as it's not tested #if 0 - res = ddc2_read_vdif( bus, sizeof( raw ) * (edid->num_sections + 1), - vdif, vdif_len ); - if( res != B_OK ) + res = ddc2_read_vdif(bus, sizeof(raw) * (edid->num_sections + 1), + vdif, vdif_len); + if (res != B_OK) return res; #endif - + return B_OK; } Modified: haiku/trunk/src/add-ons/accelerants/common/ddc_int.h =================================================================== --- haiku/trunk/src/add-ons/accelerants/common/ddc_int.h 2007-07-31 17:17:51 UTC (rev 21773) +++ haiku/trunk/src/add-ons/accelerants/common/ddc_int.h 2007-07-31 17:20:34 UTC (rev 21774) @@ -1,14 +1,20 @@ /* - Copyright (c) 2003, Thomas Kurschel + * Copyright 2003, Thomas Kurschel. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef DDC_INT_H +#define DDC_INT_H - Part of DDC driver - +/*! + Part of DDC driver Internal header */ -// no dprintf in user space, but if you know the trick ;) -void _sPrintf(const char *format, ...); + +void _sPrintf(const char *format, ...); + // no dprintf in user space, but if you know the trick ;) + //bool set_dprintf_enabled(bool); /* returns old enable flag */ #define dprintf _sPrintf @@ -21,3 +27,5 @@ #define DEBUG_MSG_PREFIX "DDC " #include "debug_ext.h" + +#endif // DDC_INT_H Modified: haiku/trunk/src/add-ons/accelerants/common/decode_edid.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/common/decode_edid.c 2007-07-31 17:17:51 UTC (rev 21773) +++ haiku/trunk/src/add-ons/accelerants/common/decode_edid.c 2007-07-31 17:20:34 UTC (rev 21774) @@ -1,8 +1,9 @@ /* - * Copyright (c) 2003, Thomas Kurschel. All Rights Reserved. + * Copyright 2003, Thomas Kurschel. All Rights Reserved. * Distributed under the terms of the MIT License. */ + /*! Part of DDC driver @@ -16,6 +17,7 @@ #include "edid.h" #include + #include @@ -89,12 +91,15 @@ case 0: timing->v_size = timing->h_size; break; + case 1: timing->v_size = timing->h_size * 3 / 4; break; + case 2: timing->v_size = timing->h_size * 4 / 5; break; + case 3: timing->v_size = timing->h_size * 9 / 16; break; @@ -120,7 +125,7 @@ static void -decode_detailed_timing( edid1_detailed_timing *timing, +decode_detailed_timing(edid1_detailed_timing *timing, const edid1_detailed_timing_raw *raw) { timing->pixel_clock = raw->pixel_clock; @@ -168,7 +173,7 @@ static void -decode_detailed_monitor( edid1_detailed_monitor *monitor, +decode_detailed_monitor(edid1_detailed_monitor *monitor, const edid1_detailed_monitor_raw *raw, bool enableExtra) { int i, j; @@ -191,21 +196,26 @@ copy_str( monitor->data.serial_number, raw->extra.data.serial_number, EDID1_EXTRA_STRING_LEN ); break; + case edid1_ascii_data: copy_str( monitor->data.ascii_data, raw->extra.data.ascii_data, EDID1_EXTRA_STRING_LEN ); break; + case edid1_monitor_ranges: monitor->data.monitor_range = raw->extra.data.monitor_range; break; + case edid1_monitor_name: copy_str( monitor->data.monitor_name, raw->extra.data.monitor_name, EDID1_EXTRA_STRING_LEN ); break; + case edid1_add_colour_pointer: decode_whitepoint( monitor->data.whitepoint, &raw->extra.data.whitepoint ); break; + case edid1_add_std_timing: for (j = 0; j < EDID1_NUM_EXTRA_STD_TIMING; ++j) { decode_std_timing(&monitor->data.std_timing[j], @@ -224,7 +234,7 @@ // #pragma mark - -//! main function to decode edid data +//! Main function to decode edid data void edid_decode(edid1_info *edid, const edid1_raw *raw) { Modified: haiku/trunk/src/add-ons/accelerants/common/dump_edid.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/common/dump_edid.c 2007-07-31 17:17:51 UTC (rev 21773) +++ haiku/trunk/src/add-ons/accelerants/common/dump_edid.c 2007-07-31 17:20:34 UTC (rev 21774) @@ -3,11 +3,13 @@ * Distributed under the terms of the MIT License. */ + /*! Part of DDC driver Dumps EDID content */ + #include "edid.h" #if !defined(_KERNEL_MODE) && !defined(_BOOT_MODE) # include "ddc_int.h" @@ -91,10 +93,13 @@ case edid1_serial_number: dprintf("Serial Number: %s\n", monitor->data.serial_number); break; + case edid1_ascii_data: dprintf(" %s\n", monitor->data.serial_number); break; - case edid1_monitor_ranges: { + + case edid1_monitor_ranges: + { edid1_monitor_range monitor_range = monitor->data.monitor_range; dprintf("Horizontal frequency range = %d..%d kHz\n", @@ -104,10 +109,13 @@ dprintf("Maximum pixel clock = %d MHz\n", (uint16)monitor_range.max_clock * 10); break; } + case edid1_monitor_name: dprintf("Monitor Name: %s\n", monitor->data.serial_number); break; - case edid1_add_colour_pointer: { + + case edid1_add_colour_pointer: + { for (j = 0; j < EDID1_NUM_EXTRA_WHITEPOINTS; ++j) { edid1_whitepoint *whitepoint = &monitor->data.whitepoint[j]; @@ -122,7 +130,9 @@ } break; } - case edid1_add_std_timing: { + + case edid1_add_std_timing: + { for (j = 0; j < EDID1_NUM_EXTRA_STD_TIMING; ++j) { edid1_std_timing *timing = &monitor->data.std_timing[j]; @@ -135,9 +145,11 @@ } break; } - case edid1_is_detailed_timing: { + + case edid1_is_detailed_timing: + { edid1_detailed_timing *timing = &monitor->data.detailed_timing; - + dprintf("Additional Video Mode:\n"); dprintf("clock=%f MHz\n", timing->pixel_clock / 100.0); dprintf("h: (%d, %d, %d, %d)\n", Modified: haiku/trunk/src/add-ons/accelerants/common/i2c.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/common/i2c.c 2007-07-31 17:17:51 UTC (rev 21773) +++ haiku/trunk/src/add-ons/accelerants/common/i2c.c 2007-07-31 17:20:34 UTC (rev 21774) @@ -1,215 +1,227 @@ /* - Copyright (c) 2003, Thomas Kurschel + * Copyright 2003, Thomas Kurschel. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ - Part of DDC driver - +/*! + Part of DDC driver I2C protocoll */ -#include -#include - +#include "ddc_int.h" #include "i2c.h" -#include "ddc_int.h" +#include +#include -// there's no spin in user space, but we need it to wait a couple -// of microseconds only -// (in this case, snooze has much too much overhead) -void spin( bigtime_t delay ) +/*! + There's no spin in user space, but we need it to wait a couple + of microseconds only + (in this case, snooze has much too much overhead) +*/ +void +spin(bigtime_t delay) { bigtime_t start_time = system_time(); - while( system_time() - start_time < delay ) + while (system_time() - start_time < delay) ; } -// wait until slave releases clock signal ("clock stretching") -static status_t wait_for_clk( const i2c_bus *bus, const i2c_timing *timing, - bigtime_t timeout ) +//! Wait until slave releases clock signal ("clock stretching") +static status_t +wait_for_clk(const i2c_bus *bus, const i2c_timing *timing, + bigtime_t timeout) { bigtime_t start_time; // wait for clock signal to raise - spin( timing->r ); + spin(timing->r); start_time = system_time(); - - while( 1 ) { + + while (1) { int clk, data; - bus->get_signals( bus->cookie, &clk, &data ); - if( clk != 0 ) + bus->get_signals(bus->cookie, &clk, &data); + if (clk != 0) return B_OK; - - if( system_time() - start_time > timeout ) + + if (system_time() - start_time > timeout) return B_TIMEOUT; - - spin( timing->r ); + + spin(timing->r); } } -// send start or repeated start condition -static status_t send_start_condition( const i2c_bus *bus, const i2c_timing *timing ) +//! Send start or repeated start condition +static status_t +send_start_condition(const i2c_bus *bus, const i2c_timing *timing) { status_t res; - - bus->set_signals( bus->cookie, 1, 1 ); - - res = wait_for_clk( bus, timing, timing->start_timeout ); - if( res != B_OK ) { - SHOW_FLOW0( 3, "Timeout sending start condition" ); + + bus->set_signals(bus->cookie, 1, 1); + + res = wait_for_clk(bus, timing, timing->start_timeout); + if (res != B_OK) { + SHOW_FLOW0(3, "Timeout sending start condition"); return res; } - - spin( timing->su_sta ); - bus->set_signals( bus->cookie, 1, 0 ); - spin( timing->hd_sta ); - bus->set_signals( bus->cookie, 0, 0 ); - spin( timing->f ); - + + spin(timing->su_sta); + bus->set_signals(bus->cookie, 1, 0); + spin(timing->hd_sta); + bus->set_signals(bus->cookie, 0, 0); + spin(timing->f); + return B_OK; } -// send stop condition -static status_t send_stop_condition( const i2c_bus *bus, const i2c_timing *timing ) +//! Send stop condition +static status_t +send_stop_condition(const i2c_bus *bus, const i2c_timing *timing) { status_t res; - - bus->set_signals( bus->cookie, 0, 0 ); - spin( timing->r ); - bus->set_signals( bus->cookie, 1, 0 ); - + + bus->set_signals(bus->cookie, 0, 0); + spin(timing->r); + bus->set_signals(bus->cookie, 1, 0); + // a slave may wait for us, so let elapse the acknowledge timeout // to make the slave release bus control - res = wait_for_clk( bus, timing, timing->ack_timeout ); - if( res != B_OK ) { - SHOW_FLOW0( 3, "Timeout sending stop condition" ); + res = wait_for_clk(bus, timing, timing->ack_timeout); + if (res != B_OK) { + SHOW_FLOW0(3, "Timeout sending stop condition"); return res; } - spin( timing->su_sto ); - bus->set_signals( bus->cookie, 1, 1 ); - spin( timing->buf ); - - SHOW_FLOW0( 3, "" ); - + spin(timing->su_sto); + bus->set_signals(bus->cookie, 1, 1); + spin(timing->buf); + + SHOW_FLOW0(3, ""); + return B_OK; } -// send one bit -static status_t send_bit( const i2c_bus *bus, const i2c_timing *timing, bool bit, int timeout ) +//! Send one bit +static status_t +send_bit(const i2c_bus *bus, const i2c_timing *timing, bool bit, int timeout) { status_t res; - + //SHOW_FLOW( 3, "%d", bit & 1 ); - - bus->set_signals( bus->cookie, 0, bit & 1 ); - spin( timing->su_dat ); - bus->set_signals( bus->cookie, 1, bit & 1 ); - - res = wait_for_clk( bus, timing, timeout ); - if( res != B_OK ) { - SHOW_FLOW0( 3, "Timeout when sending next bit" ); + + bus->set_signals(bus->cookie, 0, bit & 1); + spin(timing->su_dat); + bus->set_signals(bus->cookie, 1, bit & 1); + + res = wait_for_clk(bus, timing, timeout); + if (res != B_OK) { + SHOW_FLOW0(3, "Timeout when sending next bit"); return res; } - - spin( timing->high ); - bus->set_signals( bus->cookie, 0, bit & 1 ); - spin( timing->f + timing->low ); + spin(timing->high); + bus->set_signals(bus->cookie, 0, bit & 1); + spin(timing->f + timing->low); + return B_OK; } -// send acknowledge and wait for reply -static status_t send_acknowledge( const i2c_bus *bus, const i2c_timing *timing ) +//! Send acknowledge and wait for reply +static status_t +send_acknowledge(const i2c_bus *bus, const i2c_timing *timing) { status_t res; bigtime_t start_time; - + // release data so slave can modify it - bus->set_signals( bus->cookie, 0, 1 ); - spin( timing->su_dat ); - bus->set_signals( bus->cookie, 1, 1 ); - - res = wait_for_clk( bus, timing, timing->ack_start_timeout ); - if( res != B_OK ) { - SHOW_FLOW0( 3, "Timeout when sending acknowledge" ); + bus->set_signals(bus->cookie, 0, 1); + spin(timing->su_dat); + bus->set_signals(bus->cookie, 1, 1); + + res = wait_for_clk(bus, timing, timing->ack_start_timeout); + if (res != B_OK) { + SHOW_FLOW0(3, "Timeout when sending acknowledge"); return res; } // data and clock is high, now wait for slave to pull data low // (according to spec, this can happen any time once clock is high) start_time = system_time(); - - while( 1 ) { + + while (1) { int clk, data; - - bus->get_signals( bus->cookie, &clk, &data ); - - if( data == 0 ) + + bus->get_signals(bus->cookie, &clk, &data); + + if (data == 0) break; - - if( system_time() - start_time > timing->ack_timeout ) { - SHOW_FLOW0( 3, "Slave didn't acknowledge byte" ); + + if (system_time() - start_time > timing->ack_timeout) { + SHOW_FLOW0(3, "Slave didn't acknowledge byte"); return B_TIMEOUT; } - - spin( timing->r ); + + spin(timing->r); } - - SHOW_FLOW0( 4, "Success!" ); - + + SHOW_FLOW0(4, "Success!"); + // make sure we've waited at least t_high - spin( timing->high ); + spin(timing->high); - bus->set_signals( bus->cookie, 0, 1 ); - spin( timing->f + timing->low ); + bus->set_signals(bus->cookie, 0, 1); + spin(timing->f + timing->low); return B_OK; } -// send byte and wait for acknowledge if is true -static status_t send_byte( const i2c_bus *bus, const i2c_timing *timing, - uint8 byte, bool acknowledge ) +//! Send byte and wait for acknowledge if is true +static status_t +send_byte(const i2c_bus *bus, const i2c_timing *timing, + uint8 byte, bool acknowledge) { int i; - + SHOW_FLOW( 3, "%x ", byte ); - for( i = 7; i >= 0; --i ) { + for (i = 7; i >= 0; --i) { status_t res; - - res = send_bit( bus, timing, byte >> i, - i == 7 ? timing->byte_timeout : timing->bit_timeout ); - if( res != B_OK ) + + res = send_bit(bus, timing, byte >> i, + i == 7 ? timing->byte_timeout : timing->bit_timeout); + if (res != B_OK) return res; } - if( acknowledge ) - return send_acknowledge( bus, timing ); + if (acknowledge) + return send_acknowledge(bus, timing); else return B_OK; } -// send slave address, obeying 10-bit addresses and general call addresses -static status_t send_slave_address( const i2c_bus *bus, - const i2c_timing *timing, int slave_address, bool is_write ) + +//! Send slave address, obeying 10-bit addresses and general call addresses +static status_t +send_slave_address( const i2c_bus *bus, const i2c_timing *timing, + int slave_address, bool is_write ) { status_t res; - res = send_byte( bus, timing, (slave_address & 0xfe) | !is_write, true ); - if( res != B_OK ) + res = send_byte(bus, timing, (slave_address & 0xfe) | !is_write, true); + if (res != B_OK) return res; - + // there are the following special cases if the first byte looks like: // - 0000 0000 - general call address (second byte with address follows) // - 0000 0001 - start byte @@ -221,154 +233,166 @@ // - 1111 0xxx - 10 bit address (second byte contains remaining 8 bits) // the lsb is 0 for write and 1 for read (except for general call address) - if( (slave_address & 0xff) != 0 && - (slave_address & 0xf8) != 0xf0 ) + if ((slave_address & 0xff) != 0 && (slave_address & 0xf8) != 0xf0) return B_OK; - // send second byte if required - return send_byte( bus, timing, slave_address >> 8, true ); + return send_byte(bus, timing, slave_address >> 8, true); + // send second byte if required } -// receive one bit -static status_t receive_bit( const i2c_bus *bus, const i2c_timing *timing, - bool *bit, int timeout ) +//! Receive one bit +static status_t +receive_bit(const i2c_bus *bus, const i2c_timing *timing, + bool *bit, int timeout) { status_t res; int clk, data; - // release clock - bus->set_signals( bus->cookie, 1, 1 ); + bus->set_signals(bus->cookie, 1, 1); + // release clock // wait for slave to raise clock - res = wait_for_clk( bus, timing, timeout ); - if( res != B_OK ) { - SHOW_FLOW0( 3, "Timeout waiting for bit sent by slave" ); + res = wait_for_clk(bus, timing, timeout); + if (res != B_OK) { + SHOW_FLOW0(3, "Timeout waiting for bit sent by slave"); return res; } - - // sample data - bus->get_signals( bus->cookie, &clk, &data ); - // leave clock high for minimal time - spin( timing->high ); - // pull clock low so slave waits for us before next bit - bus->set_signals( bus->cookie, 0, 1 ); - // let it settle and leave it low for minimal time - // to make sure slave has finished bit transmission too - spin( timing->f + timing->low); + bus->get_signals(bus->cookie, &clk, &data); + // sample data + + spin(timing->high); + // leave clock high for minimal time + + bus->set_signals(bus->cookie, 0, 1); + // pull clock low so slave waits for us before next bit + + spin(timing->f + timing->low); + // let it settle and leave it low for minimal time + // to make sure slave has finished bit transmission too + *bit = data; return B_OK; } -// receive byte -// send positive acknowledge afterwards if is true, else send negative one -static status_t receive_byte( const i2c_bus *bus, const i2c_timing *timing, - uint8 *res_byte, bool acknowledge ) + +/*! receive byte + Send positive acknowledge afterwards if is true, + else send negative one +*/ +static status_t +receive_byte(const i2c_bus *bus, const i2c_timing *timing, + uint8 *res_byte, bool acknowledge) { uint8 byte = 0; int i; - + // pull clock low to let slave wait for us - bus->set_signals( bus->cookie, 0, 1 ); + bus->set_signals(bus->cookie, 0, 1); - for( i = 7; i >= 0; --i ) { + for (i = 7; i >= 0; --i) { status_t res; bool bit; - - res = receive_bit( bus, timing, &bit, - i == 7 ? timing->byte_timeout : timing->bit_timeout ); - if( res != B_OK ) + + res = receive_bit(bus, timing, &bit, + i == 7 ? timing->byte_timeout : timing->bit_timeout); + if (res != B_OK) return res; - + byte = (byte << 1) | bit; } - + //SHOW_FLOW( 3, "%x ", byte ); - + *res_byte = byte; - - return send_bit( bus, timing, acknowledge ? 0 : 1, timing->bit_timeout ); + + return send_bit(bus, timing, acknowledge ? 0 : 1, timing->bit_timeout); } -// send multiple bytes -static status_t send_bytes( const i2c_bus *bus, const i2c_timing *timing, - const uint8 *write_buffer, ssize_t write_len ) + +//! Send multiple bytes +static status_t +send_bytes(const i2c_bus *bus, const i2c_timing *timing, + const uint8 *write_buffer, ssize_t write_len) { SHOW_FLOW( 3, "len=%ld", write_len ); - - for( ; write_len > 0; --write_len, ++write_buffer ) { + + for (; write_len > 0; --write_len, ++write_buffer) { status_t res; - - res = send_byte( bus, timing, *write_buffer, true ); - if( res != B_OK ) + + res = send_byte(bus, timing, *write_buffer, true); + if (res != B_OK) return res; } - + return B_OK; } -// receive multiple bytes -static status_t receive_bytes( const i2c_bus *bus, const i2c_timing *timing, - uint8 *read_buffer, ssize_t read_len ) + +//! Receive multiple bytes +static status_t +receive_bytes(const i2c_bus *bus, const i2c_timing *timing, + uint8 *read_buffer, ssize_t read_len) { - SHOW_FLOW( 3, "len=%ld", read_len ); - - for( ; read_len > 0; --read_len, ++read_buffer ) { + SHOW_FLOW(3, "len=%ld", read_len); + + for (; read_len > 0; --read_len, ++read_buffer) { status_t res; - - res = receive_byte( bus, timing, read_buffer, read_len > 1 ); - if( res != B_OK ) + + res = receive_byte(bus, timing, read_buffer, read_len > 1); + if (res != B_OK) return res; } - + return B_OK; } -// combined i2c send+receive format -status_t i2c_send_receive( const i2c_bus *bus, const i2c_timing *timing, - int slave_address, - const uint8 *write_buffer, size_t write_len, - uint8 *read_buffer, size_t read_len ) + +//! Combined i2c send+receive format +status_t +i2c_send_receive(const i2c_bus *bus, const i2c_timing *timing, + int slave_address, const uint8 *write_buffer, size_t write_len, + uint8 *read_buffer, size_t read_len) { status_t res; - - res = send_start_condition( bus, timing ); - if( res != B_OK ) + + res = send_start_condition(bus, timing); + if (res != B_OK) return res; - - res = send_slave_address( bus, timing, slave_address, true ); - if( res != B_OK ) + + res = send_slave_address(bus, timing, slave_address, true); + if (res != B_OK) goto err; - - res = send_bytes( bus, timing, write_buffer, write_len ); - if( res != B_OK ) + + res = send_bytes(bus, timing, write_buffer, write_len); + if (res != B_OK) goto err; - - res = send_start_condition( bus, timing ); - if( res != B_OK ) + + res = send_start_condition(bus, timing); + if (res != B_OK) return res; - - res = send_slave_address( bus, timing, slave_address, false ); - if( res != B_OK ) + + res = send_slave_address(bus, timing, slave_address, false); + if (res != B_OK) goto err; - - res = receive_bytes( bus, timing, read_buffer, read_len ); - if( res != B_OK ) + + res = receive_bytes(bus, timing, read_buffer, read_len); + if (res != B_OK) goto err; [... truncated: 54 lines follow ...] From axeld at pinc-software.de Tue Jul 31 19:39:53 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 31 Jul 2007 19:39:53 +0200 Subject: [Haiku-commits] r21744 & r21747 In-Reply-To: <894b9700707300611w5deec70dj3949df175b665bab@mail.gmail.com> Message-ID: <27800973279-BeMail@ibm> "Stefano Ceccherini" wrote: > 2007/7/30, Axel D?rfler : > > "Stefano Ceccherini" wrote: > > > Yeah, probably. I also thought about initializing it to some > > > useful > > > value... like "unknown", so that the error string looks like > > > "Can't > > > create the "unknown" replicant... etc.". Thoughts ? > > "unknown" is not really helpful - isn't there some better way? > I changed the errors in my last commit to that file. > Now it says clearly it cannot find the application to instantiate the > replicant, because no signature has been supplied (as it was in my > case, where I didn't put the signature of Terminal as the add_on > field > of the message). Great, thanks! > By the way... say hello to the replicant Terminal :) > http://burton666.neoni.net/workspace/upload/shots/terminal.png > > It's not yet really usable (since an "exit" will forward the signal > to > the hosting app, not really cool :P), but works more or less. Pretty nice :-) Bye, Axel. From korli at mail.berlios.de Tue Jul 31 22:15:25 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 31 Jul 2007 22:15:25 +0200 Subject: [Haiku-commits] r21775 - in haiku/trunk: headers/private/firewire src/add-ons/kernel/drivers/bus src/add-ons/kernel/drivers/bus/firewire Message-ID: <200707312015.l6VKFP7q014413@sheep.berlios.de> Author: korli Date: 2007-07-31 22:15:25 +0200 (Tue, 31 Jul 2007) New Revision: 21775 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21775&view=rev Added: haiku/trunk/headers/private/firewire/firewire_module.h haiku/trunk/headers/private/firewire/firewirereg.h haiku/trunk/headers/private/firewire/fwdma.h haiku/trunk/src/add-ons/kernel/drivers/bus/firewire/Jamfile haiku/trunk/src/add-ons/kernel/drivers/bus/firewire/fw_raw.c Modified: haiku/trunk/src/add-ons/kernel/drivers/bus/Jamfile Log: work from JiSheng Zhang : fw_raw with firewire headers from FreeBSD current. Thanks! clean up Added: haiku/trunk/headers/private/firewire/firewire_module.h =================================================================== --- haiku/trunk/headers/private/firewire/firewire_module.h 2007-07-31 17:20:34 UTC (rev 21774) +++ haiku/trunk/headers/private/firewire/firewire_module.h 2007-07-31 20:15:25 UTC (rev 21775) @@ -0,0 +1,67 @@ +/* Kernel driver for firewire + * + * Copyright (C) 2007 JiSheng Zhang . All rights reserved + * Distributed under the terms of the MIT license. + */ +#ifndef _FW_MODULE_H +#define _FW_MODULE_H + +#include +#include +#include + +#include "firewire.h" +#include "firewirereg.h" + + +#define FIREWIRE_MODULE_NAME "bus_managers/firewire/v1" +#define MAX_CARDS 4 +struct fw_module_info{ + + bus_manager_info binfo; + + struct fw_device * (*fw_noderesolve_nodeid)(struct firewire_comm *fc, int dst); + + struct fw_device * (*fw_noderesolve_eui64)(struct firewire_comm *fc, struct fw_eui64 *eui); + + int (*fw_asyreq)(struct firewire_comm *fc, int sub, struct fw_xfer *xfer); + + void (*fw_xferwake)(struct fw_xfer *xfer); + int (*fw_xferwait)(struct fw_xfer *xfer); + + struct fw_bind * (*fw_bindlookup)(struct firewire_comm *fc, uint16_t dest_hi, uint32_t dest_lo); + + int (*fw_bindadd)(struct firewire_comm *fc, struct fw_bind *fwb); + + int (*fw_bindremove)(struct firewire_comm *fc, struct fw_bind *fwb); + + int (*fw_xferlist_add)(struct fw_xferlist *q, + int slen, int rlen, int n, + struct firewire_comm *fc, void *sc, void (*hand)(struct fw_xfer *)); + + void (*fw_xferlist_remove)(struct fw_xferlist *q); + + struct fw_xfer * (*fw_xfer_alloc)(); + + struct fw_xfer * (*fw_xfer_alloc_buf)(int send_len, int recv_len); + + void (*fw_xfer_done)(struct fw_xfer *xfer); + + void (*fw_xfer_unload)(struct fw_xfer* xfer); + + void (*fw_xfer_free_buf)( struct fw_xfer* xfer); + + void (*fw_xfer_free)( struct fw_xfer* xfer); + + void (*fw_asy_callback_free)(struct fw_xfer *xfer); + + int (*fw_open_isodma)(struct firewire_comm *fc, int tx); + + int (*get_handle)(int socket, struct firewire_softc *handle); + + struct fwdma_alloc_multi * (*fwdma_malloc_multiseg)(int alignment, + int esize, int n); + + void (*fwdma_free_multiseg)(struct fwdma_alloc_multi *); +}; +#endif Added: haiku/trunk/headers/private/firewire/firewirereg.h =================================================================== --- haiku/trunk/headers/private/firewire/firewirereg.h 2007-07-31 17:20:34 UTC (rev 21774) +++ haiku/trunk/headers/private/firewire/firewirereg.h 2007-07-31 20:15:25 UTC (rev 21775) @@ -0,0 +1,391 @@ +/*- + * Copyright (c) 2003 Hidetoshi Shimokawa + * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the acknowledgement as bellow: + * + * This product includes software developed by K. Kobayashi and H. Shimokawa + * + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/sys/dev/firewire/firewirereg.h,v 1.49 2007/07/15 13:20:48 simokawa Exp $ + * + */ +#ifndef _FIREWIREREG_H +#define _FIREWIREREG_H +#ifndef __HAIKU__ +#ifdef __DragonFly__ +typedef d_thread_t fw_proc; +#include +#elif __FreeBSD_version >= 500000 +typedef struct thread fw_proc; +#include +#else +typedef struct proc fw_proc; +#include +#endif +#endif/*__HAIKU__*/ + +#include + +#ifndef __HAIKU__ +#include +#include +#define splfw splimp +#else +#define splfw disable_interrupts +#define splx restore_interrupts +#endif + +STAILQ_HEAD(fw_xferlist, fw_xfer); + +struct fw_device{ + uint16_t dst; + struct fw_eui64 eui; + uint8_t speed; + uint8_t maxrec; + uint8_t nport; + uint8_t power; +#define CSRROMOFF 0x400 +#define CSRROMSIZE 0x400 + int rommax; /* offset from 0xffff f000 0000 */ + uint32_t csrrom[CSRROMSIZE/4]; + int rcnt; + struct firewire_comm *fc; + uint32_t status; +#define FWDEVINIT 1 +#define FWDEVATTACHED 2 +#define FWDEVINVAL 3 + STAILQ_ENTRY(fw_device) link; +}; + +struct firewire_softc { +#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 + struct cdev *dev; +#endif + struct firewire_comm *fc; +}; + +#define FW_MAX_DMACH 0x20 +#define FW_MAX_DEVCH FW_MAX_DMACH +#define FW_XFERTIMEOUT 1 + +struct firewire_dev_comm { +#ifndef __HAIKU__ + device_t dev; +#endif + struct firewire_comm *fc; + void (*post_busreset) (void *); + void (*post_explore) (void *); +}; + +struct tcode_info { + u_char hdr_len; /* IEEE1394 header length */ + u_char flag; +#define FWTI_REQ (1 << 0) +#define FWTI_RES (1 << 1) +#define FWTI_TLABEL (1 << 2) +#define FWTI_BLOCK_STR (1 << 3) +#define FWTI_BLOCK_ASY (1 << 4) + u_char valid_res; +}; + +#ifdef __HAIKU__ +struct crom_src_buf { + struct crom_src src; + struct crom_chunk root; + struct crom_chunk vendor; + struct crom_chunk hw; +}; +#endif //move from firewire.c to firewirereg.h + +struct firewire_comm{ +#ifndef __HAIKU__ + device_t dev; + device_t bdev; +#endif + uint16_t busid:10, + nodeid:6; + u_int mode; + u_int nport; + u_int speed; + u_int maxrec; + u_int irm; + u_int max_node; + u_int max_hop; +#define FWPHYASYST (1 << 0) + uint32_t status; +#define FWBUSDETACH (-2) +#define FWBUSNOTREADY (-1) +#define FWBUSRESET 0 +#define FWBUSINIT 1 +#define FWBUSCYMELECT 2 +#define FWBUSMGRELECT 3 +#define FWBUSMGRDONE 4 +#define FWBUSEXPLORE 5 +#define FWBUSPHYCONF 6 +#define FWBUSEXPDONE 7 +#define FWBUSCOMPLETION 10 + int nisodma; + struct fw_eui64 eui; + struct fw_xferq + *arq, *atq, *ars, *ats, *it[FW_MAX_DMACH],*ir[FW_MAX_DMACH]; + struct fw_xferlist tlabels[0x40]; + u_char last_tlabel[0x40]; + STAILQ_HEAD(, fw_bind) binds; + STAILQ_HEAD(, fw_device) devices; + u_int sid_cnt; +#define CSRSIZE 0x4000 + uint32_t csr_arc[CSRSIZE/4]; +#define CROMSIZE 0x400 + uint32_t *config_rom; + struct crom_src_buf *crom_src_buf; + struct crom_src *crom_src; + struct crom_chunk *crom_root; + struct fw_topology_map *topology_map; + struct fw_speed_map *speed_map; +#ifndef __HAIKU__ + struct callout busprobe_callout; + struct callout bmr_callout; + struct callout timeout_callout; +#else + //timer_id busprobe_callout; + //timer_id bmr_callout; + //timer_id timeout_callout; +#endif + //struct task task_timeout; + uint32_t (*cyctimer) (struct firewire_comm *); + void (*ibr) (struct firewire_comm *); + uint32_t (*set_bmr) (struct firewire_comm *, uint32_t); +#ifndef __HAIKU__ + int (*ioctl) (struct cdev *, u_long, caddr_t, int, fw_proc *); +#else + int (*ioctl) (void *cookie, uint32 cmd, void *arg, size_t len); +#endif + int (*irx_enable) (struct firewire_comm *, int); + int (*irx_disable) (struct firewire_comm *, int); + int (*itx_enable) (struct firewire_comm *, int); + int (*itx_disable) (struct firewire_comm *, int); + void (*timeout) (void *); + void (*poll) (struct firewire_comm *, int, int); + void (*set_intr) (struct firewire_comm *, int); + void (*irx_post) (struct firewire_comm *, uint32_t *); + void (*itx_post) (struct firewire_comm *, uint32_t *); + struct tcode_info *tcode; +#ifndef __HAIKU__ + bus_dma_tag_t dmat; + struct mtx mtx; + struct mtx wait_lock; +#else + sem_id mtx; + sem_id wait_lock; +#endif +// struct taskqueue *taskqueue;//to be completed +#ifndef __HAIKU__ + struct proc *probe_thread; +#else + thread_id probe_thread; +#endif +}; +#define CSRARC(sc, offset) ((sc)->csr_arc[(offset)/4]) + +#ifndef __HAIKU__ +#define FW_GMTX(fc) (&(fc)->mtx) +#define FW_GLOCK(fc) mtx_lock(FW_GMTX(fc)) +#define FW_GUNLOCK(fc) mtx_unlock(FW_GMTX(fc)) +#define FW_GLOCK_ASSERT(fc) mtx_assert(FW_GMTX(fc), MA_OWNED) +#endif +#define FW_GMTX(fc) ((fc)->mtx) +#define FW_GLOCK(fc) acquire_sem_etc(FW_GMTX(fc), 1, B_CAN_INTERRUPT | B_TIMEOUT, 0) +#define FW_GUNLOCK(fc) release_sem(FW_GMTX(fc)) +#define FW_GLOCK_ASSERT(fc) + +struct fw_xferq { + int flag; +#define FWXFERQ_CHTAGMASK 0xff +#define FWXFERQ_RUNNING (1 << 8) +#define FWXFERQ_STREAM (1 << 9) + +#define FWXFERQ_BULK (1 << 11) +#define FWXFERQ_MODEMASK (7 << 10) + +#define FWXFERQ_EXTBUF (1 << 13) +#define FWXFERQ_OPEN (1 << 14) + +#define FWXFERQ_HANDLER (1 << 16) +#define FWXFERQ_WAKEUP (1 << 17) + void (*start) (struct firewire_comm*); + int dmach; + struct fw_xferlist q; + u_int queued; + u_int maxq; + u_int psize; + struct fwdma_alloc_multi *buf; + u_int bnchunk; + u_int bnpacket; + struct fw_bulkxfer *bulkxfer; + STAILQ_HEAD(, fw_bulkxfer) stvalid; + STAILQ_HEAD(, fw_bulkxfer) stfree; + STAILQ_HEAD(, fw_bulkxfer) stdma; + struct fw_bulkxfer *stproc; +// struct selinfo rsel; + spinlock Spinlock; + sem_id Sem; + caddr_t sc; + void (*hand) (struct fw_xferq *); +}; + +struct fw_bulkxfer{ + int poffset; +// struct mbuf *mbuf;//to be completed + STAILQ_ENTRY(fw_bulkxfer) link; + caddr_t start; + caddr_t end; + int resp; +}; + +struct fw_bind{ + u_int64_t start; + u_int64_t end; + struct fw_xferlist xferlist; + STAILQ_ENTRY(fw_bind) fclist; + STAILQ_ENTRY(fw_bind) chlist; + void *sc; +}; + +struct fw_xfer{ + caddr_t sc; + struct firewire_comm *fc; + struct fw_xferq *q; +// struct timeval tv;//to be completed + int8_t resp; +#define FWXF_INIT 0x00 +#define FWXF_INQ 0x01 +#define FWXF_START 0x02 +#define FWXF_SENT 0x04 +#define FWXF_SENTERR 0x08 +#define FWXF_BUSY 0x10 +#define FWXF_RCVD 0x20 + +#define FWXF_WAKE 0x80 + uint8_t flag; + int8_t tl; + void (*hand) (struct fw_xfer *); + struct { + struct fw_pkt hdr; + uint32_t *payload; + uint16_t pay_len; + uint8_t spd; + } send, recv; +// struct mbuf *mbuf;//to be completed + STAILQ_ENTRY(fw_xfer) link; + STAILQ_ENTRY(fw_xfer) tlabel; + struct malloc_type *malloc; +}; + +struct fw_rcv_buf { + struct firewire_comm *fc; + struct fw_xfer *xfer; + struct iovec *vec; + u_int nvec; + uint8_t spd; +}; +#ifndef __HAIKU__ +void fw_sidrcv (struct firewire_comm *, uint32_t *, u_int); +void fw_rcv (struct fw_rcv_buf *); +void fw_xfer_unload ( struct fw_xfer*); +void fw_xfer_free_buf ( struct fw_xfer*); +void fw_xfer_free ( struct fw_xfer*); +struct fw_xfer *fw_xfer_alloc (struct malloc_type *); +struct fw_xfer *fw_xfer_alloc_buf (struct malloc_type *, int, int); +void fw_init (struct firewire_comm *); +int fw_tbuf_update (struct firewire_comm *, int, int); +int fw_rbuf_update (struct firewire_comm *, int, int); +int fw_bindadd (struct firewire_comm *, struct fw_bind *); +int fw_bindremove (struct firewire_comm *, struct fw_bind *); +int fw_xferlist_add (struct fw_xferlist *, struct malloc_type *, int, int, int, + struct firewire_comm *, void *, void (*)(struct fw_xfer *)); +void fw_xferlist_remove (struct fw_xferlist *); +int fw_asyreq (struct firewire_comm *, int, struct fw_xfer*); +void fw_busreset (struct firewire_comm *, uint32_t); +uint16_t fw_crc16 (uint32_t *, uint32_t); +void fw_xfer_timeout (void *); +void fw_xfer_done (struct fw_xfer *); +void fw_xferwake (struct fw_xfer *); +int fw_xferwait (struct fw_xfer *); +void fw_asy_callback_free (struct fw_xfer *); +struct fw_device *fw_noderesolve_nodeid (struct firewire_comm *, int); +struct fw_device *fw_noderesolve_eui64 (struct firewire_comm *, struct fw_eui64 *); +struct fw_bind *fw_bindlookup (struct firewire_comm *, uint16_t, uint32_t); +void fw_drain_txq (struct firewire_comm *); +int fwdev_makedev (struct firewire_softc *); +int fwdev_destroydev (struct firewire_softc *); +void fwdev_clone (void *, struct ucred *, char *, int, struct cdev **); +int fw_open_isodma(struct firewire_comm *, int); +#endif +extern int firewire_debug; +#ifndef __HAIKU__ +extern devclass_t firewire_devclass; +#endif +extern int firewire_phydma_enable; + +#ifndef __HAIKU__ +#ifdef __DragonFly__ +#define FWPRI PCATCH +#else +#define FWPRI ((PZERO+8)|PCATCH) +#endif + +#if defined(__DragonFly__) || __FreeBSD_version < 500000 +#define CALLOUT_INIT(x) callout_init(x) +#else +#define CALLOUT_INIT(x) callout_init(x, 1 /* mpsafe */) +#endif + +#if defined(__DragonFly__) || __FreeBSD_version < 500000 +/* compatibility shim for 4.X */ +#define bio buf +#define bio_bcount b_bcount +#define bio_cmd b_flags +#define bio_count b_count +#define bio_data b_data +#define bio_dev b_dev +#define bio_error b_error +#define bio_flags b_flags +#define bio_offset b_offset +#define bio_resid b_resid +#define BIO_ERROR B_ERROR +#define BIO_READ B_READ +#define BIO_WRITE B_WRITE +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif + +MALLOC_DECLARE(M_FW); +MALLOC_DECLARE(M_FWXFER); +#endif /*__HAIKU__*/ + +#endif Added: haiku/trunk/headers/private/firewire/fwdma.h =================================================================== --- haiku/trunk/headers/private/firewire/fwdma.h 2007-07-31 17:20:34 UTC (rev 21774) +++ haiku/trunk/headers/private/firewire/fwdma.h 2007-07-31 20:15:25 UTC (rev 21775) @@ -0,0 +1,130 @@ +/*- + * Copyright (C) 2003 + * Hidetoshi Shimokawa. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * + * This product includes software developed by Hidetoshi Shimokawa. + * + * 4. Neither the name of the author nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/dev/firewire/fwdma.h,v 1.3 2005/01/06 01:42:41 imp Exp $ + */ +#ifndef _FWDMA_H +#define _FWDMA_H + +#ifndef howmany +#define howmany(x, y) (((x)+((y)-1))/(y)) // x/y??? +#endif +#define rounddown(x, y) (((x)/(y))*(y)) // ?x??y?????? +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ // ?x??y????? +#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ +#define powerof2(x) ((((x)-1)&(x))==0) // ???2??? + +typedef uint32_t bus_addr_t; +typedef uint32_t bus_size_t; + +struct fwdma_alloc { +// bus_dma_tag_t dma_tag; +// bus_dmamap_t dma_map; + area_id BufArea; + void * v_addr; + bus_addr_t bus_addr; +}; + +struct fwdma_seg { +// bus_dmamap_t dma_map; + + void * v_addr; + bus_addr_t bus_addr; +}; + +struct fwdma_alloc_multi { + bus_size_t ssize; + bus_size_t esize; + int nseg; +// bus_dma_tag_t dma_tag; + area_id BufArea; + + struct fwdma_seg seg[0]; +}; + +static __inline void * +fwdma_v_addr(struct fwdma_alloc_multi *am, int index) +{ + bus_size_t ssize = am->ssize; + int offset = am->esize * index; + + return ((caddr_t)am->seg[offset / ssize].v_addr + (offset % ssize)); +} + +static __inline bus_addr_t +fwdma_bus_addr(struct fwdma_alloc_multi *am, int index) +{ + bus_size_t ssize = am->ssize; + int offset = am->esize * index; + + return (am->seg[offset / ssize].bus_addr + (offset % ssize)); +} +#ifndef __HAIKU__ +static __inline void +fwdma_sync(struct fwdma_alloc *dma, bus_dmasync_op_t op) +{ + bus_dmamap_sync(dma->dma_tag, dma->dma_map, op); +} + +static __inline void +fwdma_sync_multiseg(struct fwdma_alloc_multi *am, + int start, int end, bus_dmasync_op_t op) +{ + struct fwdma_seg *seg, *eseg; + + seg = &am->seg[am->esize * start / am->ssize]; + eseg = &am->seg[am->esize * end / am->ssize]; + for (; seg <= eseg; seg ++) + bus_dmamap_sync(am->dma_tag, seg->dma_map, op); +} + +static __inline void +fwdma_sync_multiseg_all(struct fwdma_alloc_multi *am, bus_dmasync_op_t op) +{ + struct fwdma_seg *seg; + int i; + + seg = &am->seg[0]; + for (i = 0; i < am->nseg; i++, seg++) + bus_dmamap_sync(am->dma_tag, seg->dma_map, op); +} + +void *fwdma_malloc(int, bus_size_t, struct fwdma_alloc *, int); +void fwdma_free(struct fwdma_alloc *); +void *fwdma_malloc_size(bus_dma_tag_t, bus_dmamap_t *, bus_size_t, bus_addr_t *, int); +void fwdma_free_size(bus_dma_tag_t, bus_dmamap_t, void *, bus_size_t); +struct fwdma_alloc_multi *fwdma_malloc_multiseg(struct firewire_comm *, + int, int, int, int); +#endif /*__HAIKU__*/ + +#endif /* _FWDMA_H*/ Modified: haiku/trunk/src/add-ons/kernel/drivers/bus/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bus/Jamfile 2007-07-31 17:20:34 UTC (rev 21774) +++ haiku/trunk/src/add-ons/kernel/drivers/bus/Jamfile 2007-07-31 20:15:25 UTC (rev 21775) @@ -1,5 +1,6 @@ SubDir HAIKU_TOP src add-ons kernel drivers bus ; +SubInclude HAIKU_TOP src add-ons kernel drivers bus firewire ; SubInclude HAIKU_TOP src add-ons kernel drivers bus pcmcia ; SubInclude HAIKU_TOP src add-ons kernel drivers bus scsi ; SubInclude HAIKU_TOP src add-ons kernel drivers bus usb ; Added: haiku/trunk/src/add-ons/kernel/drivers/bus/firewire/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bus/firewire/Jamfile 2007-07-31 17:20:34 UTC (rev 21774) +++ haiku/trunk/src/