473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can anyone please outline whatz happening in this code .

11
Hi Mates, Can u please tell me whats happpenning in those. Please tell what ever u got. Outline the functinaliy in normal words. i am new to C++. I need to write SWIG wrapper which checks this C++ Code in perl.

Please tell , what ever u understood .

Thanks in advance


Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include "stdafx.h"
  3. #include "client.h"
  4. using namespace std;
  5.  
  6. int main(int argc, char* argv[])
  7. {
  8.     char szKey[48];
  9.     Key k;
  10.     Block *b;
  11.     int total;
  12.     TransferResult ret;
  13.     //printf("%d", argc);
  14.     if ((argc == 8) || (argc == 9))
  15.     {
  16.         str_to_key(argv[2], k);
  17.         if (strcmp(argv[1],"-put") == 0)
  18.         {
  19.             total = HEADER_SIZE(Block) + atoi(argv[3]);
  20.             b = (Block *) MALLOC(void, total);
  21.             b->size = atoi(argv[3]);
  22.             memcpy(b->data, argv[4], b->size);
  23.         }
  24.     }
  25.     else
  26.     {
  27.         cout << "Usage:" << endl;
  28.         cout << "    FakeFEClient.exe -p <key> <value>" << endl;
  29.         cout << "    FakeFEClient.exe -g <key>" << endl;
  30.         return 0;
  31.     }
  32.  
  33.  
  34.     try {
  35.  
  36.         Client *c;
  37.  
  38.         if (strcmp(argv[1],"-get") == 0)
  39.             c = new Client(argv[5], atoi(argv[7]));
  40.         else
  41.             c = new Client(argv[6], atoi(argv[8]));
  42.  
  43.  
  44.         key_to_str(k, szKey, sizeof(szKey));
  45.  
  46.  
  47.         if (strcmp(argv[1],"-put") == 0)
  48.         {
  49.             ret = c->PutBlock(k, b,10000);
  50.             if (ret == TR_Processed)
  51.             {
  52.                 cout << "Put operation successful";
  53.             }
  54.             else
  55.             {
  56.                 cout << "Put operation failed";
  57.             }
  58.             free(b);
  59.         }
  60.  
  61.         if (strcmp(argv[1],"-get") == 0)
  62.         {
  63.             byte block_buf[BLOCK_BUF_LIMIT];
  64.             Block* block = (Block*)block_buf;
  65.             block->size = atoi(argv[3]);
  66.             ret = c->GetBlock(k, block, 1000);
  67.             if (ret != TR_Processed)
  68.             {
  69.                 cout << "Get operation failed";
  70.                 return 1;
  71.             }
  72.             block->data[block->size]='\0';
  73.             printf("%s",block->data);
  74.         }
  75.  
  76.  
  77.     }
  78.     catch (NetworkException e)
  79.     {
  80.         std::cout << "Network exception raised" << std::endl;
  81.     }
  82.     catch (...)
  83.     {
  84.         std::cout << "Exception raised" << std::endl; 
  85.     }
  86.  
  87.     return 0;
  88. }
  89.  
  90.  
Nov 13 '08 #1
1 1376
weaknessforcats
9,208 Expert Mod 8TB
The person who wrote this is also new to C++ because the code is largely C.

I would suggest you locate the author and ask what the code does.

I could help if you had a specific question but not when what you ask is really not a question at all but is a request for a consultation.
Nov 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Xavier Noria | last post by:
A Google search here for folding Python code in Emacs pointed to outline.el, but when I try to use some *-hide-* commands I get "Wrong type argument: stringp, nil". The header of the file has no...
10
by: Agent Mulder | last post by:
I feel the need for an outline specifier to facilitate java-style programming.
20
by: Chris Bradbury | last post by:
Hi, I'm posting in this forum for the first time so if I break any conventions or protocols I'm sorry. I've attached this style: *:focus { outline: none } to a page but it doesn't remove...
5
by: Felix Collins | last post by:
Hi, I'm not a regexp expert and had a bit of trouble with the following search. I have an "outline number" system like 1 1.2 1.2.3 1.3
4
by: John | last post by:
I have a function declaration that gives an error while compiling. Can anyone help me figure this one out? inline void create(const std::vector< myclass >& plist, std::vector< myclass...
2
by: NotYetaNurd | last post by:
please try the following float F1=1.0f; float F2=1.0f; string testString = " "+ ((F1-F2)>0)?"test1":"test2"; //throws error while compilation and
1
by: John Doe | last post by:
I collapse an outline block, then copy it, then paste it. In my experience, the outline block always expands after the paste. Is their a way to modify the editor's behavior so that an outline block...
13
by: deko | last post by:
I. A. B. II. A. 1) 2) B. C.
4
by: mattehz | last post by:
Hey there, I am trying to upload old source files and came across these errors: Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_html.php on line 59...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.