Newbie question with puts/gets

I'm having trouble getting put and gets to work. Right now I do an insert into the DB (returns 0) with data in the data.data fields and then when I get it I always get empty space. I was hoping that someone might be able to help. Here is the two snippets of code that I'm using:
int
insert_data(DHT_DBS my_dbs, Message *msg)
    DBT key, data;
    char myData[(u_int32_t)strlen(msg->payload)];
    char myKey[41];
    memcpy(&myData,(msg->payload), (u_int32_t)strlen(msg->payload));
    memcpy(&myKey,(msg->dest.keystr), 41);
    printf("in insert\n");
    /* Zero out the DBTs */
    memset(&key, 0, sizeof(DBT));
    memset(&data, 0, sizeof(DBT));
    key.data = msg->dest.keystr;
    data.data = msg->payload;
    data.size = (u_int32_t)strlen(msg->payload);
    /* Put the data into the database */
    int val = 0;
    val = my_dbs.dht->put(my_dbs.dht, 0, &key, &data, 0);
    printf("after put %d\n", val);
    return 0;
void get_data(DHT_DBS * my_dbs, Message *msg)
    DBT key, data;
    char myData[200];
    int ret;
    /* Initialize our DBTs. */
    memset(&key, 0, sizeof(DBT));
    memset(&data, 0, sizeof(DBT));
    memset(&myData,0,200);
    key.data = msg->dest.keystr;
    key.size = sizeof(Key);
    data.data = &myData;
    data.flags = DB_DBT_USERMEM;
    ret = my_dbs->dht->put(my_dbs->dht,NULL, &key, &data, 0);
    if (ret) {
        printf("No records found for '%s'\n", msg->dest.keystr);
    else
        printf("Record found\n");
        printf("Found: %s\n", myData);
        // if we did find what they were looking for, send a get_response message to the source
        // we may need to add another object to the message struct
}I'm just trying to test this. my main simply calls the following after I define the variables and open the data bases:
insert_data(mydb,m);
get_data(&mydb, m);Now the interesting thing is it does find the key that I inserted with insert_data. However, the data stored with the key is always "" and not the characters that it should be. I'm just wondering if I'm doing something wrong. Any tips would be appreciated.

Alright I'm back to a different problem now.
int
insert_data(DHT_DBS my_dbs, Message *msg)
    DBT key, data;
    char myData[(u_int32_t)strlen(msg->payload)];
    char myKey[41];
    memcpy(&myData,(msg->payload), (u_int32_t)strlen(msg->payload));
    memcpy(&myKey,(msg->dest.keystr), 41);
    printf("in insert\n");
    /* Zero out the DBTs */
    memset(&key, 0, sizeof(DBT));
    memset(&data, 0, sizeof(DBT));
    key.data = msg->dest.keystr;
    data.data = msg->payload;
    data.size = (u_int32_t)strlen(msg->payload);
    /* Put the data into the database */
    int val = 0;
    val = my_dbs.dht->put(my_dbs.dht, 0, &key, &data, 0);
    printf("after put %d\n", val);
    return 0;
void get_data(DHT_DBS * my_dbs, Message *msg)
    DBT key, data;
    char myData[200];
    int ret;
    /* Initialize our DBTs. */
    memset(&key, 0, sizeof(DBT));
    memset(&data, 0, sizeof(DBT));
    memset(&myData,0,200);
    key.data = msg->dest.keystr;
    key.size = sizeof(Key);
    data.data = &myData;
    data.flags = DB_DBT_USERMEM;
    ret = my_dbs->dht->get(my_dbs->dht,NULL, &key, &data, 0);
    if (ret) {
        printf("No records found for '%s'\n", msg->dest.keystr);
    else
        printf("Record found\n");
        printf("Found: %s\n", myData);
        // if we did find what they were looking for, send a get_response message to the source
        // we may need to add another object to the message struct
}I corrected that to reflect the get, but now the put doesnt' seem to be working. I thought I followed getting_started example pretty closely. Ret is -30989 when it attempts the get but the put returns 0.

Similar Messages

  • Newbie question with Netbeans: How do I get a component in a panel

    I've made a class called PatternComponent that extends JComponent which draws some patterns and stuff that I specify. I've been using a very basic GUI that I threw together in eclipse, but I need to clean it up and I've decided that NetBeans is more apt for the job.
    I've figured out how to get my buttons to work, but I can't find how to add my PatternComponent to the panel I want to stick it in.

    This is not a Netbeans forum.

  • Newbie question: Can't get equal object widths

    I have two rectangle paths in my document. I don't remember exactly how I created them but as far as I can tell, they are very alike, same fill, no stroke. They are two vertical sides of a rectangular border around the perimiter of my doc.
    I would like to change the widths to be identical. Width/height proportion constraints are off. I enter the width of one object in the width field of the other, and the width changes but to some unpredictable number. I can put in a new number again and the width changes to something new but not what I want. I have tried to use different units, same result. I have no problem changing the heights of the corresponding horizontal paths to be the numbers I want.
    There is one visible difference between the paths: When the troubling path is selected, the blue outline around it is wider than on the other paths.
    I ended up throwing away the trouble path and copying the good one as a work-around. But I'd like to know what's going on, I assume I'm missing something basic.
    Hope somebody can help.

    With the rectangle tool (hotkey: M)
    Hold [Alt] and click where you want your rectangle to be centered. A window will appear with the height and width options.
    If it's all symmetrical, I would then use the Reflect tool, or Rotate tool to make a copy, where I wanted. With either tool, hold [Alt] and click the point you wish to rotate around. Check the preview box to make sure you have the right outcome, and then select the Copy option to finalize.
    If you are selecting one rectangle at a time and entering the new width into the Transform Panel, I am unsure what is happening.
    (Note: Instead of increasing the width, in the transform panel, by replacing 128 px with 256 px ▬ you have the option to add to the original number,
    so it would look like this: 128+128 px [it also works for decreasing, with subtraction])
    To select and scale two objects, in place, at the same time:
    Object→ Transform→ Transform each

  • Newbie question: Can't get 100% black

    I have created text. When it prints, I am getting 4 color plates. I filled with foreground color that is 100% black. What am I missing? Thanks for any help.
    Photoshop 9.0.2; Mac OS 10.4.8; System: PowerPC G5

    In CMYK, you can render black 2 ways: as "rich black" (made up of all four plates), or "black-only" (made up of black ink only.)
    When you say you created the text with "foreground color... 100% black", that probably means you used Photoshop's default colors - black and white. If you open the color picker and look at how the default black is made, you'll see that it's a combination of C, M, Y and K.
    If you are creating the file in CMYK mode, you can open the color picker, enter 0/0/0/100 in the CMYK fields, and fill your type or shape. You'll have 100% black and no other colors.
    If you're creating your file in RGB, you're SOL. When you convert to CMYK, all black will be converted to rich black using the CMYK build as defined by the CMYK profile to which you're converting. In that case, you would have to go back into the CMYK file and manually fix all the elements that are supposed to be black-only.
    It's a rather nasty can of worms. This is one of the things that keeps an RGB workflow from being accepted universally by the prepress community. There are tools available (Alwan, etc.) that will preserve black-only elements as the file gets converted from RGB to CMYK, but they are not widely used yet.
    (ed. - Peter, It looks like we cross-posted...)

  • Newbe Question: How to get the Workflow Name to a WS* number?

    Hi All
    Just a short question:
    I have a whole bunch of WS9*** numbers and now I am supposed to find the corresponding WorkFlows in a system (from a business perspective). The problem is that I have no clue on how to do this as I am reale new to WorkFlows.
    Is there anybody who can help me out?
    Thanks,
    Regards,
    Minima

    Hello,
    If you have access to PFTC_DIS, choose "Workflow template" for Task type and do a list of values on the Task field (which has the WS* number, but without the WS). This will give you the full list.
    If you don't have access to PFTC_DIS, but do have access to SE16 or SE12, look in table
    HRS1000 where OTYPE = WS and LANGU = EN.
    regards
    Rick Bakker
    Hanabi Technology
    Edited by: Rick Bakker on Dec 15, 2008 12:58 PM

  • Newbie question, need to get started!

    I haven't used Garageband before and can't seem to get past square one! I bought a First Act usb guitar cord to record guitar, when I plugged it in Garageband seemed to recognize it, and it looks like I'm getting a signal and can see the waves when I record, but I can't hear anything. Is there something special I have to do to actually hear what I'm playing through my iMac?

    xSlamx wrote:
    hear what I'm playing through my iMac?
    http://www.bulletsandbones.com/GB/GBFAQ.html#usecomputersspeakers
    (Let the page FULLY load. The link to your answer is at the top of your screen)
    (btw, you should use a more descriptive subject line)

  • Newbies question with iPhone 4 sync

    I have installed itune 10 and using Win 7. I hope that some kind soul can advise on how to get my iphone to sync, D/L  and able to listen to the music transferred or D/L. Thanks

    Just attach your iPhone to your computer, open up iTunes if he doesn't automatically, and if it is the first time you use that iPhone (new bought or restored), iTunes will walk your through the setup.
    Any way, iTunes will auto-detect the iPhone, the iPhone will appear in the sidebar, click it to set sync settings like which music, video, apps and so on to sync.

  • Installed new hard drive in imac and i get folder with question mark, put in OS install disk and it does nothing? All I have is wireless key board and mouse, is this a factor?

    Installed new hard drive in imac and i get folder with question mark, put in OS install disk and it does nothing? All I have is wireless key board and mouse, is this an issue?

    Other than put disc in you don't give much info about what you've done. With the install disc inserted restart your Mac while holding the C key, that should start it up from the install disc. Should also work fine with a wireless Apple keyboard.

  • Hi all new here. Newb question...can this be done with flash?

    Hi everyone hoping you can help a newb like me out. Thanks in advance for your time. I am trying to make a video exactly like this.
    http://www.youtube.com/watch?v=UbMOTNI8tcE
    I know in the video it implies he uses a light control thing but I think he is really just animating the cartoon. I just want to animate a "line cartoon" like this one. Can I do this in flash? Its not for a website just like a movie type thing. I have access to pretty much all the other adobe software at my school so if I need to use a different program I can do that. Just looking for someone to point me in the right direction and maybe give some tips on how to go about it. Thanks.

    open flash and you'll see a timeline with frames (that are all empty when you start).  draw something on the stage.  that will be in frame 1.  right click on frame 10 and click insert keyframe.  your drawing will be in frame 10 now.  double click your drawing to select all of it, move your mouse off and then over the select drawing and then drag it to the right and release.  right click between frame 1 and frame 10 and click motion tween.  test your movie.
    now start playing with flash to see what you can do.  you're not going to learn how to create your animation by asking questions.
    you can get help getting started but you now have enough info to get started.  you can get more help if and when you encounter problems.

  • Stuck on ask a question page. cant get anything I can work with

    I had a page with bookmarks then it all disappeared and now all I have is a page titled at top --- Ask a Question Firefox Support/Mozilla Firefox. there is nothing on the page I can work or remove . I can see the page I want but cannot get to It.

    DITTO to what aehplh4423 posted 3 months ago on this thread.
    as follows:
    "stuck on ask a question page. cant get anything I can work with
    I had a page with bookmarks then it all disappeared and now all I have is a page titled at top --- Ask a Question Firefox Support/Mozilla Firefox. there is nothing on the page I can work or remove . I can see the page I want but cannot get to It. "
    WHAT'S UP FIREFOX?????????
    If you don't have an answer, then how do I get back to my previous version of Firefox with my home page and bookmarks? Or do we just need to go back to Explorer or Google Chrome?

  • Starting fluxbox-newbie question

    :? I currently have kde running on my system. I installed fluxbox using pacman. 
         How do I start fluxbox? I couldn't even find it, so I su to root, type fluxbox, and get
         an error message saying that another window system is already running! (kde)
        A  typical newbie question, but I don't know how to start fluxbox. I think I want to
        replace kde with fluxbox, so should I just uninstall kde?? 
                                                           Thanks -- Larry

    lmellen wrote:
    :?  scottro -- This is .xinitrc.
    #!/bin/sh
    # ~/.xinitrc
    # Executed by startx (run your window manager from here)
    exec wmaker
    # exec startkde
    # exec icewm
    # exec blackbox
    exec fluxbox
    The only thing I uncommented was" exec fluxbox". I'm still getting kde at start up.
    I have kdm listed in a start up daemon in rc.conf. is this the problem?
                         thanks for the reply -- Larry
    if you comment out exec wmaker and then put a ! in front of the kdm daemon you should boot to a console at which point you login then type startx. you may also have to change your init level but i dunno i haven't used a graphical login manager for a very long time.

  • Yes i keep ashing the same question i keep getting the same answer and it is not resolving the problem

    YES I KEEP ASKING THE SAME QUESTION I KEEP GETTING THE SAME ANSWER AND IT IS NOT RESOLVING THE PROBLEM AND CHAT KEEPS SENDING ME BACK TO THE FORUMS THEY SAY THEIR EXPERTS WILL BE ABLE TO RESOLVE THE PROBLEM BUT IT IS NOT RESOLVED YET I KEEP GETTING THE SAME ANSWER FROM FORUM EXPERTS WELL THAT IS NOT WORKING I NEED A SOLUTION THAT WILL WORK I PAID FOR THIS AND I WANT TO USE IT BUT I CANNOT
    TRYING TO ACTIVATE A trial version of photoshop elements 7.0 disc worked till in the middle got an erroe fur and animalskin file missing checked dvd and it had a scratch so 3 times i downloaded a trial version of photoshop elements 7.0 from adobe.com but when try to activate get invalid serial number the website said have your serial number ready to activate which i do because i am getting it right from the dvd case it is registered i am signed in and chat just keeps telling me it is too old try the forums which i have many times with no resolution but they mark it as assumed resolved premeir elements 7.0 from the same dvd case is on why can't i activate trial version of photoshop elements 7.0 my computer crashed and i had to restore then i am now trying to put the programs
    maybe i can buy or exchange the dvd of photoshop elements 7.0 without because my serial number is good so i maybe just need a new disc being this disc is scratched i've got 40 to 50 hours into this 1 trial version of photoshop elements 7.0 more than i have in the whole computer restore and all the other programs i have restored have windows xp service pack 3 or 3.5 and net framework 4.0 and all the important and required updates i also have an open case which i am getting no where either case #213952591 which i responded to within 4 days as not resolved but i am still getting no help activating this trial version of photoshop elements 7.0
    24 Views
    Tags:

    YES I KEEP ASKING THE SAME QUESTION I KEEP GETTING THE SAME ANSWER AND IT IS NOT RESOLVING THE PROBLEM AND CHAT KEEPS SENDING ME BACK TO THE FORUMS THEY SAY THEIR EXPERTS WILL BE ABLE TO RESOLVE THE PROBLEM BUT IT IS NOT RESOLVED YET I KEEP GETTING THE SAME ANSWER FROM FORUM EXPERTS WELL THAT IS NOT WORKING I NEED A SOLUTION THAT WILL WORK I PAID FOR THIS AND I WANT TO USE IT BUT I CANNOT
    TRYING TO ACTIVATE A trial version of photoshop elements 7.0 disc worked till in the middle got an erroe fur and animalskin file missing checked dvd and it had a scratch so 3 times i downloaded a trial version of photoshop elements 7.0 from adobe.com but when try to activate get invalid serial number the website said have your serial number ready to activate which i do because i am getting it right from the dvd case it is registered i am signed in and chat just keeps telling me it is too old try the forums which i have many times with no resolution but they mark it as assumed resolved premeir elements 7.0 from the same dvd case is on why can't i activate trial version of photoshop elements 7.0 my computer crashed and i had to restore then i am now trying to put the programs
    maybe i can buy or exchange the dvd of photoshop elements 7.0 without because my serial number is good so i maybe just need a new disc being this disc is scratched i've got 40 to 50 hours into this 1 trial version of photoshop elements 7.0 more than i have in the whole computer restore and all the other programs i have restored have windows xp service pack 3 or 3.5 and net framework 4.0 and all the important and required updates i also have an open case which i am getting no where either case #213952591 which i responded to within 4 days as not resolved but i am still getting no help activating this trial version of photoshop elements 7.0
    24 Views
    Tags:

  • Domain name settings - Newbie question

    Sorry for a newbie question!
    I am already pointing a domain name to web hosting for email account. Now, I need an application server to run ERP software and Oracle, and installing Solaris and Oracle need a domain name.
    If I point my domain name to the server, how do I receive emails from web hosting???
    Install an email server to the application server instead? What can I do if I want the same domain name? Any option?

    Setting up a mailserver and making sure it doesn't suddenly turn into a spambox is not something you do with the use of a few commands. I suggest to dive into the Solaris admin guide on docs.sun.com and read up on e-mail and network services.
    If that is asking too much of your time you'll be better off getting your ISP to handle all this for you.

  • Newbie Question:  How much computer do I need?

    Newbie Question:
    I would like to use MainStage 3 in a live performance environment to play bars, parties, etc.  I'm not looping, using it to playback recordings, processing outboard equipment or vocal processing.  I want to stop carrying Rolands, Nords, Korgs, etc and get to a controller and a rack with a Mac Mini in it.
    I tested a download of Mainstage 3 on my home Mac Mini (late 2012, 3.5 Ghz i5, 4GB RAM, 500GB drive) and it seemed to run fairly well.  $30 well invested so I trekked forward... I purchased a Mac Mini (late 2009,  2.52GHz Core 2 Duo, 6GB RAM, 128GB SSD) for $200.  I started to do more elaborate keyboard setups to see how the CPU would hold up.  It typically runs from 30% to 50% of capacity (CPU and Memory)  It actually boots and runs better than the i5.  I hear the occasion gitch, but it actually seems to be getting better in time (or I'm rock and roll deaf.
    I got a rack, an Airport Express, a Radial USB interface and a Nektar Panorama P6.  It's starting to get expensive, but I'm emboldened by the actual quality for the sound and the flexibility of arranging for live performance.  What used to take me two and three keyboards to play, I can now fit on one performance patch.
    OK, now the question... am I at the limits of this little Core 2 Duo?  Should I upgrade the i5 with more RAM and a bigger SSD and use that?  Should I get a new(er) i7 and bite the $1,500 bullet for the additional RAM and SSD?
    I see that most of you are running pretty nice Macbook Pros with i7 and lots of everything.  My needs are modest; am I OK? 
    BTW, I want to run a Mac Mini in a box because I don't want to carry a laptop out in the open.  If I was doing bigger shows I wouldn't care but I play some rowdy bars and constantly have folks hanging off me while I'm playing.  It's fun, but hard on gear.  If you can't drop it or dip it in beer, it won't last long where I work.
    Matt Donnelly

    Rule of thumb: newer and faster is better. But, depending the complexity of your needs you may be OK with an older Mac. Some glitches that happen in a live performance are due to loss of communication with USB or Firewire inputs, so make sure they're secure. I recently upgraded from a 2010 Mac Mini 2.6 dual core with 16 GB RAM, which was used live for nearly four years, to the latest Mac Mini 3.0 i7 with 16 GB RAM and a 500 GB SSD. I was getting an occasional stuck note with the older one. The new one is rock solid. Some of my patches may have up to a dozen channel strips mapped to three keyboards. The Mini is mounted in a rack next to a MOTU Ultralite Hybrid. It is a good idea to map a panic button on your keyboard to controller # 123(all notes off). Also, you might want to invest in a battery backup power supply(APC, Cyberpower, etc.-$40-$60) to protect your Mac against power loss, which can damage you hard drive.

  • Newbie question - XML version, searching by artist

    Probably quite a common problems - apologies for newbie questions.
    I've changed the URL of my MP3s in my XML to a new location and refreshed my feed. Is there a way of seeing what version of the XML iTunes is using? (it takes around 24 housr to refresh, right?)
    Also, when I'm searching for my podcast by author it's not coming up (<channel><itunes:author>) - is there a reason for this or a way to get it to show up when people search for the artist, other than doubling it in the title? (This works by the way, but I'd prefer not to!)
    Thanks.

    you can do it in just one loop, going through all the image
    tags in index_content and for each tag fill the values of all four
    arrays
    for (i...) {
    get the appropriate child of index_content
    first_array[ i ] = value of first tag
    second_array[ i ] = value of second tag
    no need for multiple loops.
    flash has functionality for xml files, but it helps to write
    a little wrapper around it, to simplify programming, especially if
    you work with xml a lot.. I wrote my for work, so I can't show it
    to you, but it's not very complicated to do

Maybe you are looking for

  • Frame XSLT processing screws graphics mappings

    Hi, We have encountered strange behavior in FM 8. Our XML has element for graphics with attribute set that matches 100% to frame graphic properties, like: image position="below" href="graphic.jpg" etc.. rw-rules maps position to position property and

  • Safari, won't display any windows??

    Hi all, Just went to use Safari only to discover it won't display any windows, of any kind. I've tried 'new window', 'new tab', 'open location/file' and it even won't open the 'Preferences' window!? It seems to be creating them as I can see them in t

  • Is it possible to have a user interface in a stand alone application without having LV

    Hi! I want to know if it's possible to build a stand-alone application in order to avoid purchasing LV and at the same time having a user interface to display data? I really want to know what are the advantages of the stand-alone applications and wha

  • IPhoto crashes after update using OS X 10.8

    Using  Mountain lion OS X 10.8. I recently updated to the new iPhoto 9.4 and after updating iPhoto to 9.4 it keeps crashing. I've read prior discussions and those answers seemed not to work.  I pasted below the error message. Please help.  Thank you!

  • 10.5.5 Initial backup is taking DAYS (!!) over firewire 400

    I ran into an issue where I had to erase my Time Machine backups on my external FW400 OWC Neptune backup drive. Not a big deal as I also use Superduper for bootable backups. so last week I tried doing a new initial backup and it's taking days literal