Wednesday, July 24, 2013

Lightspeed Systems: iOS Mobile App Developer

LOCATION: Bakersfield, CA; Portland, OR; Austin, TX

URL: Enjoy iOS development and want to join a small team where you can play a pivotal role in popular apps that will change the future of education? We want to talk with you.

Lightspeed Systems is already one of the largest education software providers in the market, and now we want to push the envelope in our mobile space. We have apps for iPhone and iPad in the app store, but they are only the first step in a much larger vision we are working to achieve.

Saturday, July 6, 2013

In My Mailbox #25

What's In My MailboxFor Review:All These Things I've Done By Gabrielle Zevin (//)I was very shocked to find a red box in my mailbox. It was from Macmillan. Curious I open it to find red confetti, bag of chocolate cover expresso, and a note from the publicist and underneath all of that was Gabrielle Zevin's new novel All these things I've done. Which btw, judging from the first 100 pages, will definitely be a hit. It comes out this September 2011 :) Thank you very much Ksenia Winnicki.What did you guys get in your mailbox this week? BTW if you haven't already figure it out. In my Mailbox was started by .Yours Truly, - Full Post

ARC (Monday) GIVE AWAY MONDAY:ARC of The Gathering By Kelley Armstrong

So I have been thinking of starting this new thing on my blog. Every Monday or maybe every other Monday (I am not quite sure yet)(Or maybe every once a month on a Monday) I am going to give away book(s) or swag to one lucky winner. I am calling this Give Away Monday. So to start off this new idea I am going to be giving away an Advance Readers Copy (ARC) of The Gathering by Kelley Armstrong.I had been originally given 2 copies of The Gathering from the Publishers. However I have never given the second copy away.  So I thought I would do so now.This giveaway is not international!! It is only open to Canadians and Americans. Sorry :( !!! Must be following both my twitter and blog (GFC or Linky) to enter!!-The Winner will be notify immediately after the contest closes (next Monday). If I get no reply from the winner in 48 hours I will pick a new winner =D - Full Post

The Most Famous Bottle Design, Forever?

Coca-Cola settled on its famous contour bottle design almost 100 years ago, in 1916, after several years of trials with other far less distinctive shapes (at least under today’s standards):
Federal trademark the first use date to be July 8, 1916. The description of the contour bottle design mark in 1960 was: “The trademark consists of the distinctively shaped contour, or confirmation, and design of the bottle as shown”:

The silhouette or outline of the contour bottle design stands alone as a even without words:
The negative image or silhouette of the contour bottle design is also as a trademark:

 
 
 
 
 
 
 
 
 
 
 
 
And, now the outline or partial image of the contour bottle design shape even finds itself in multiple other federally-registered formats for the Coca-Cola brand:




 

 
Do these examples make it the most famous that no one is talking about — when they’re talking about ? Sorry, .
Will there ever be a more iconic bottle design or ? Sorry, Pepsi, .
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
The beauty in the design to , of course, lies in the fact that the shape can be owned as a trademark, forever . . . . - Full Post

Happiness is a Federally-Registered Mark

It should be no surprise that the famous Coca-Cola brand name is federally-registered. One of the many significant is the USPTO’s obligation to refuse registration of third party marks that are likely to confuse — most importantly, without the prompting or involvement of the prior trademark registrant.
No doubt Coca-Cola will be popping a top and opening a little happiness when it learns that it won’t have to spend the time or effort to formally oppose an  by ”Harvey W. Wiley, d/b/a We The People” (apparently located in Chattanooga, Tennessee).
The application seeks to register COCA COLA, without a hyphen (as if that makes a difference), for “Colas; Non-alcoholic beverages, namely, carbonated beverages.” Last Friday, the USPTO promptly delivered to Mr. Wiley both barrels of sticky syrup in a and registration refusal. It should be safe to trust that this application will never proceed to publication, but it should leave us all wondering what on earth the Applicant is thinking.
Perhaps the whole trademark filing is a hoax, since it appears “Harvey W. Wiley” is a known historical pioneer consumer activist, . Moreover, Applicant Harvey can’t seem to make up his mind on his actual name, as as the “Owner” – ”Harvey W. Harvey,” then he signed as “General Partner” – ”Harvey Wiley,” a few months later in a to disclaim exclusive rights in the term COLA.
This is truly bizarre behavior. You’d think the $275 governmental filing fee would act as a sufficient deterrent for utterly wasting the time of USPTO Examining Attorneys, but apparently not for this Harvey.
And now, for , to quote an entirely different Harvey.
Thankfully for Coca-Cola, its portfolio of federally-registered Coca-Cola marks should avoid its need to waste any time on this one, with special thanks to the USPTO, of course. - Full Post

Inspiration for a Non-Traditional Trademark?

What an honor it was to be part of the conference at HOW Design Live, last week in San Francisco, thanks again for the opportunity Andrew!
The is Method’s visually stunning Ocean Plastic Dish and Hand soap container, shown to the left, and discussed this way:
“The more ocean plastic we’re able to reuse means less demand for virgin materials and a cleaner planet. We may never be able to return the ocean to its pristine state, but we can raise awareness of the importance of using the plastic that’s already here. The ocean plastic in this packaging was hand-collected on the beaches of Hawaii by method employees and local Hawaiian volunteer groups. The unique gray color is a departure from method’s usual bright pops of color.”
“The gray color is what resulted naturally after the plastic chopping, washing and pelletizing process and our creative direction was inspired by its organic feel. The inspiration for the ridges along the side of the bottle came from a sea urchin.”
Happily, no or here to explain the unique look, shape, and features of this product container, so there is serious potential for inherently distinctive , although I could find no pending applications filed by Method, (with no ridges).
I love the choice and use of the word “inspiration” to explain the designed ridges on the bottle — in my opinion, it is very nicely suggestive (not descriptive) of the ocean plastic material making up the container, by adopting a creative interpretation of an important and protective feature of sea urchins in the package design.
Although the color of the container is probably not subject to trademark protection because it is apparently the natural result of the manufacturing process, the look, , and shape of the container have great potential, since those features haven’t been verbally saddled with the “” or ““ functional baggage that others unfortunately have stumbled in using to explain their product or container features.
Last, it was a distinct pleasure to present again with guest blogger Aaron Keller of Capsule on the topic of The Intersection of Design and the Law. As always, it was a lot of fun, so if you’d like a private showing of that discussion, please let us know, we’ll consider taking it on the road again, for the right crowd. - Full Post

Get to Know Mr. C, But Where Are His Eyes?

Earlier this year and I had a chance to learn about Procter & Gamble’s creative efforts in bringing Mr. Clean to life at the in Chicago.
Little did we know at the time, that a might be in the works, and that there could be reason for an addition to the  here on DuetsBlog.
The only brand truncation visible on the Mr. Clean billboard (currently posted in the Twin Cities metro area) shows some non-verbal brand elements — the bald head with bushy white eyebrows:
To see any evidence of the brand truncation for the verbal element, one needs to visit the website noted in the ad to view Mr. C: .

 
 
There you also will be reminded of the other non-verbal brand elements missing from the billboard that I would think are key to any recognition of the Mr. Clean character, if no words are to be used: White t-shirt, folded arms, toothless smile, and sparkling left earring:
 
Turns out, to see Mr. Clean’s piercing blue eyes in a static representation of the non-verbal brand, I had to visit the USPTO website. Procter & Gamble, surprisingly doesn’t appear to have sought any federally-registered rights for the Mr. Clean character or any of his distinctive visual elements, at least separate and apart from the words Mr. Clean.
The Procter & Gamble marks that do appear on the USPTO database , include only these two composite marks:

 
Question for our designer friends and marketing types: Why do you suppose the billboard hides Mr. Clean’s eyes, and the YouTube banner does too?
When a lie detector test is not handy, isn’t the “look me in the eye” test the best surrogate? If so, what does that say about brand authenticity and transparency, or am I reading way too much into the missing eyeballs?
As attractive as the billboard is, I was surprised to see only 221, 587 views of the video it promoted, especially since the only call to action in the ad is to “see his opic story” at YouTube.com/MrClean.
Marketing types, does this look like the making of a successful ad campaign to you? If not, do you think showing Mr. C’s eyeballs may have attracted a few more of others’ eyeballs?
It seems a bit light on the engagement side to me (although it certainly caught my attention, albeit as someone who doesn’t make purchasing decisions like these), so what do you think? - Full Post

PrePrint: QoS Analysis for Web Service Compositions with Complex Structures

- Full Post

PrePrint: Confucius: A Tool Supporting Collaborative Scientific Workflow Composition

- Full Post

PrePrint: Cost and Accuracy Aware Scientific Workflow Composition for Service-Oriented Environments

- Full Post

PrePrint: QoS-Aware Dynamic Composition of Web Services using Numerical Temporal Planning

- Full Post

PrePrint: Proxy Provable Data Possession in Public Clouds

- Full Post

PrePrint: Automating Cloud Services Lifecycle through Semantic Technologies

- Full Post

PrePrint: Towards Complex Event Aware Services as Part of SOA

- Full Post

PrePrint: Towards Efficient Virtual Appliance Delivery with Minimal Manageable Virtual Appliances

- Full Post

PrePrint: Privacy-Enhanced Web Service Composition

- Full Post

PrePrint: Power-Aware Cloud Metering

- Full Post

PrePrint: Introducing Replaceability into Web Service Composition

- Full Post

PrePrint: Application Portability in Cloud Computing: An Abstraction Driven Perspective

- Full Post

PrePrint: Service Identification in Inter-Organizational Process Design

- Full Post

PrePrint: A Chemistry-Inspired Workflow Management System for a Decentralized Workflow Execution

- Full Post

PrePrint: Instant Recommendation for Web Services Composition

- Full Post

PrePrint: Simulating Service-oriented Systems: A Survey and the Services-Aware Simulation Framework

- Full Post

PrePrint: A Methodology for Evolving E-contracts Using Templates

- Full Post

PrePrint: Robust Dynamic Service Composition in Sensor Networks

- Full Post

PrePrint: SanGA: A Self-Adaptive Network-Aware Approach to Service Composition

- Full Post

PrePrint: A Framework for Consumer-Centric SLA Management of Cloud-Hosted Databases

- Full Post

PrePrint: Where Should We Fix This Bug?: A Two-phase Recommendation Model

- Full Post

PrePrint: Usability through Software Design

- Full Post

World Environment Day, 5 June 1999

- Full Post

Enormous undertakings need enormous prayer

- Full Post

Committee chairs need prayer

- Full Post

When you pray . . .

- Full Post

75 Attend Perkins Luncheon

Approximately 75 leaders attended a March 27 luncheon at Spruce Hill Christian School at 42nd and Baltimore. CCDA-Philly Fundraising Chair Seth Cohen's original vision was to have 10-12 leaders come and meet John Perkins. This grew just a little bit. Praise God!! Pray for CCDA-Philly's need to raise $30,000 for conference expenses. Give thanks for the pledges received, so far, from Tenth and Woodland Presbyterian Churches. Pray about your own church offering $500, $1000 or more. If you or your church would like to make a contribution email . - Full Post

Financial Times Ranks S&C Among Most Innovative U.S. Law Firms

S&C was recognized as one of the top 15 most innovative law firms in the United States in the 2012 U.S. Innovative Lawyers Report, published by the Financial Times on November 29. Mr. Shenker was also identified as one of the top 10 agents of change. S&C received commendations in the corporate category for the multidisciplinary advice it provided in Frank McCourt’s divorce, as well as for its role in the development of a complex holding company structure that enabled Chile’s LAN Airlines to merge with Brazil’s TAM. The Firm was named a standout in the energy category for its role in the $8.5 billion financing structure for Asia Pacific Liquefied Natural Gas in Queensland, Australia. Mr. Shenker was recognized as “one of the rare lawyers who can turn his hand to many legal disciplines,” as evidenced by his role in the different facets surrounding McCourt’s divorce.  - Full Post

S&C Deals Recognized at FinanceAsia's 2012 Achievement Awards for Australia and New Zealand

S&C was recognized in seven categories in FinanceAsia's 2012 Achievement Awards for Australia and New Zealand, including:Issuer of the Year     • Leighton Holdings Best IPO     • SCA Property Group’s spin-off from Woolworths Best M&A Deal     • Foxtel’s acquisition of Austar Best International Bond Deal     • Sydney Airport’s bond offering Best Project Finance Deal     • Australia Pacific LNG Most Innovative Deal     • Commonwealth Bank of Australia covered bond offering Best New Zealand Deal     • Fonterra Shareholders’ Fund IPOThe awards will be presented at a dinner on February 5 at the Park Hyatt in Sydney. - Full Post

Visualizing Data via Project Descry…and the MIX Thing!

This year’s MIX page contains several cool projects and experiments that you can play with. One of my favorites is Project Descry – an attempt at visualizing data in interesting ways:
Best of all, the to all of the projects is provided. Since I am a Deep Zoom kind of person (until after MIX when I can tell you what else I’ve been working on!), you should definitely check out :

This is a Deep Zoom-based pixel representation of all the crazy things that go on in a typical web development environment. If you have ever been curious to know how to create Deep Zoom overlays where non-image content is overlaid over key parts of a Deep Zoom image, check out the source code for this project!
Mix-ing it up 09 Style Speaking of MIX, I and a will be at MIX either presenting or causing general mayhem…or both! If you will be in attendance, feel free to drop by and say Hi.
Cheers! Kirupa - Full Post

Programming in C- Display inputted integers in english

Please read this whole post before commenting. I am new to programming in C. The problem I have is from Kochan's "Programming in C," Chapter 6, Exercise 6. The problem states that I need to take user input (some integer) and display it in english. Ex. User inputs "123", output should be "one two three." This next part is important: I can NOT use arrays. At this point in the book I do NOT know how to use arrays. Sorry if that comes across as snarky, the last two forums I posted on insisted I use them. I will, believe me, but not right now. Here is the code I have so far to display input greater than 9 in english:

if (number > 9) {
while (temp >= 1 ) {
temp = temp / 10;
++counter;
}
for (i = 1; i <= (counter - 1); i++) {
digit = number / pow(10, (counter - i));
if (digit == 9) {
printf ("nine ");
}
else if (digit == 8) {
printf ("eight ");
}
else if (digit == 7) {
printf ("seven ");
}
else if (digit == 6) {
printf ("six ");
}
else if (digit == 5) {
printf ("five ");
}
else if (digit == 4) {
printf ("four ");
}
else if (digit == 3) {
printf ("three ");
}
else if (digit == 2) {
printf ("two ");
}
else if (digit == 1) {
printf ("one ");
}
x = 1;
for (x = 1; x <= counter - i; x++) {
ten = ten * 10;
}
number = number % ten;
}
}
digit = number;
if (digit > 0 && digit < 10) {
if (digit == 9) {
printf ("nine ");
}
else if (digit == 8) {
printf ("eight ");
}
else if (digit == 7) {
printf ("seven ");
}
else if (digit == 6) {
printf ("six ");
}
else if (digit == 5) {
printf ("five ");
}
else if (digit == 4) {
printf ("four ");
}
else if (digit == 3) {
printf ("three ");
}
else if (digit == 2) {
printf ("two ");
}
else if (digit == 1) {
printf ("one ");
}
}


NOTES: I will use switch statements later, for now please forgive my use of "if." int temp = int number. int number is the user input. int counter and int digit = 0 at declaration. int ten = 1 at declaration.

The output I am getting currently, no matter what the input is, is the first two digits displayed in english and nothing else. What is wrong with the logic in my code?

SPECIAL NOTES: I know the code is not pretty. I repeat, I cannot use arrays and I am new to programming in C, I have been learning it for 7 hours now. I am not assuming anyone here is mean to newbies, but on the last forum I posted on, the only reply was from someone who wanted to tell me my code was garbage and not even worth reviewing. If you feel the need to do this, please email me at frohanyo@hotmail.com, and do not post here. Thanks for any help in advance! - Full Post

while loop and fscanf

**I am trying to read the records from and to a CSV file in C. Of course i want to stop when I have read all the records. If I use a for loop it works perfect except I have to know how many records there are. if I change to a while loop it only reads one record. I read many of your great examples and tried different things. I have tried !=EOF and == all number from 1 to 10. It still only reads one line. Can you give me a suggestion please. (please don't tell me to give up C programing altogether)
This code works and reads/writes the data just fine:
**

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
FILE *in_file = fopen("c:\\cstuff\\texttext.csv", "r");
FILE *out_file = fopen("c:\\cstuff\\outtext.csv", "a");
int z =0;
char one[30];
char two[30];
char three[30];
for (z = 1; z < 15; z++)
/*while(fscanf(in_file,"%[^,]",one)=2);*/
{
fscanf(in_file,"%[^,]",one);
fscanf(in_file,"%*c %[^,]",two);
fscanf(in_file,"%*c %s\n",three);
/*z++; /*Increment z for line numbers*/
/*fscanf(in_file,"%[^,] %*c %[^,] %*c %s\n",one, two, three);*/
/* put the data back in another file with the line number*/
fprintf(out_file,"%i,",z); /* put the count first followed by a comma*/
fprintf(out_file,"%s,",one); /*put the first variable followed by a comma*/
fprintf(out_file,"%s,",two); /*put the second variable followed by a comma*/
fprintf(out_file,"%s\n",three); /*put the third variable position to next line*/
} /*end while/for loop */
/* close the files */
fclose(in_file);
fclose(out_file);
return 0;
}


if I comment out the for loop and put in a while loop it will only read one record.
This is the code that only reads one record:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
FILE *in_file = fopen("c:\\cstuff\\texttext.csv", "r");
FILE *out_file = fopen("c:\\cstuff\\outtext.csv", "a");
int z =0;
char one[30];
char two[30];
char three[30];
/*for (z = 1; z < 15; z++)*/
while(fscanf(in_file,"%[^,]",one)==1);
{
/*fscanf(in_file,"%[^,]",one);*/
fscanf(in_file,"%*c %[^,]",two);
fscanf(in_file,"%*c %s\n",three);
z++; /*Increment z for line numbers*/
/*fscanf(in_file,"%[^,] %*c %[^,] %*c %s\n",one, two, three);*/
/* put the data back in another file with the line number*/
fprintf(out_file,"%i,",z); /* put the count first followed by a comma*/
fprintf(out_file,"%s,",one); /*put the first variable followed by a comma*/
fprintf(out_file,"%s,",two); /*put the second variable followed by a comma*/
fprintf(out_file,"%s\n",three); /*put the third variable position to next line*/
} /*end while/for loop */
/* close the files */
fclose(in_file);
fclose(out_file);
return 0;
}


the data looks like this:
first,bfirst,cfirst
second,bsecond,csecond
third,bthird,cthird
fourth,bfourth,cfourth
fifth,bfifth,cfifth
sixth,bsixth,csixth
seventh,bseventh,cseventh
eighth,beighth,ceighth
ninth,bninth,cninth
tenth,btenth,ctenth
eleventh,beleventh,celeventh
twelveth,btwelveth,ctwelveth
thirteenth,bthirteenth,cthirteenth
fourteenth,bfourteenth,cfourteenth - Full Post

mini market project

The mini-supermarket already has a list of product names and their corresponding
type (soap, oil, milk, cheese, etc….) included in it initially.
The user menu displays the following operations:
(Hint: Use the function gets to read an array of characters including spaces)
- Insert a product (name, type)
- Display products of (selected) type, i.e. the user select a type and display all
products’ names in this type
- Search product by name (if exist, display its name, and its type)“linear search
- display all products, their names and corresponding type, as they had enterd. - Full Post

sending image through sockets

im trying to send image from one system to another(client server model),it works fine when i use loopback ip address(same machine as both client and server) but when trying to send to another system,the gimp doesnt recognize the image and displays an error after receiving the image... - Full Post

problem with open function in c

hi.
i have problem with following code:
when i give address directly it works correct but when i get address from command line, it does n't work.

int main(int argc, char** argv)
{
int size;
int fd,fd2;
char buf[10000],buf2[10000],FileAdd[10000];

size = read(fd2,buf2,10000);
//char *FileAdd = malloc(size);
strcpy(FileAdd,buf2);
if ((fd= open(FileAdd, O_RDONLY)) < 0)
{
perror("unable to open.");
exit(1);
}
read(fd, buf, 10000);
puts(buf);

int filedesc = open("writer.txt", O_WRONLY | O_APPEND);
if (filedesc < 0)
{
return -1;
}
if (write(filedesc, buf, strlen(buf)) != strlen(buf)) {
write(2, buf, strlen(buf));
return -1;
}

return 0;
}
- Full Post

recv function doesn't work in c

hi.
i create a server and client and i have a text based connection between them.
firstly client sends a message to server and client gets the answer but after that client sends another message to server and when client wants to get the message, it shows empty message.
important part of client and server code is as below:

//client code
write(2,"print file name : ",18);
nread2=read(0,FileName,8);

write(2,FileName,nread2);
if(send(sock , FileName , 8 , 0) < 0){perror("error happened");}
//puts("\ndata has been sent.");
if((SizeOfText=recv(sock,buffer2,1000,O_NONBLOCK)) < 0)
{
write(2,"\nerror\n",7);
break;
}
write(2,buffer2,SizeOfText);
int filedesc = open(FileName, O_WRONLY | O_CREAT | O_TRUNC , S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (filedesc < 0)
{
return -1;
}
if (write(filedesc, buffer2, SizeOfText) != SizeOfText)
{
write(2, buffer2, SizeOfText);
return -1;
}
//server code
if ((fd=open(client_message, O_RDONLY)) < 0)
{
perror("unable to open.");
exit(1);
}
int size = read(fd, buf, 10000);
write(2,buf,size);
if(send(socket_desc,buf,size,0) < 0){perror("error");}
- Full Post

Storing via asprintf and reading back via isprintf?

We have a packet capture function which is as below. The issue now each of the hex value of packet I read and concat into a char *hex2Value using this code below. I would like to know is this the most efficienct method to concat all into one single string ? Secondly now this one long string I want to reach each 2 value into isprint function to print the readable character how best to do this?

char *hex2Value="";
while(*p) {
//printf("\n\nstr: %s\n", p);
asprintf(&hexValue,"%s%02x",hex2Value,p);
//asprintf(&hexValue,"%s%02x",hexValue,p);

p++;
}








void dummyProcesssPacket(const struct pfring_pkthdr *h,
const u_char *p, const u_char *user_bytes) {
long threadId = (long)user_bytes;
printf("\nIN Dummy\n");
numPkts[threadId]++, numBytes[threadId] += h->len+24 /* 8 Preamble + 4 CRC + 12 IFG */;

#ifdef ENABLE_BPF
if (userspace_bpf && bpf_filter(filter.bf_insns, p, h->caplen, h->len) == 0)
return; /* rejected */

numPktsFiltered[threadId]++;
#endif

if(touch_payload) {
volatile int __attribute__ ((unused)) i;

i = p[12] + p[13];
}

if(verbose) {
printf("\nverbose :");
struct ether_header *ehdr;
char buf1[32], buf2[32];
struct ip *ip;
int s;
uint usec;
uint nsec=0;


int i=0;
int j=0,line=0,packSize=h->caplen;
char *hexValue="";
while(j<packSize/16)
{
printf("%06x: ",line++);
for(i=0;i<16;i++)
{
printf("%02x ",p[j*16+i]);
asprintf(&hexValue,"%s%02x",hexValue,p[j*16+i]);
}
printf(" |");
/*for(i=0;i<16;i++)
{
if(isprint(p[j*16+i]))
printf("%c",p[j*16+i]);
else
printf(".");
}*/
printf("|\n");
j++;
}
printf("\nTotal hex value is %s",hexValue);




if(h->ts.tv_sec == 0) {
memset((void*)&h->extended_hdr.parsed_pkt, 0, sizeof(struct pkt_parsing_info));
pfring_parse_pkt((u_char*)p, (struct pfring_pkthdr*)h, 5, 1, 1);
}

s = (h->ts.tv_sec + thiszone) % 86400;

if(h->extended_hdr.timestamp_ns) {
if (pd->dna.dna_dev.mem_info.device_model != intel_igb_82580 /* other than intel_igb_82580 */)
s = ((h->extended_hdr.timestamp_ns / 1000000000) + thiszone) % 86400;
/* "else" intel_igb_82580 has 40 bit ts, using gettimeofday seconds:
* be careful with drifts mixing sys time and hw timestamp */
usec = (h->extended_hdr.timestamp_ns / 1000) % 1000000;
nsec = h->extended_hdr.timestamp_ns % 1000;
} else {
usec = h->ts.tv_usec;
}

printf("%02d:%02d:%02d.%06u%03u ",
s / 3600, (s % 3600) / 60, s % 60,
usec, nsec);

ehdr = (struct ether_header *) p;
printf("\n\nBefore Extexted :%d",use_extended_pkt_header);
if(use_extended_pkt_header) {
printf("\nafter USE EXE");
printf("%s[if_index=%d]",
h->extended_hdr.rx_direction ? "[RX]" : "[TX]",
h->extended_hdr.if_index);

printf("[%s -> %s] ",
etheraddr_string(h->extended_hdr.parsed_pkt.smac, buf1),
etheraddr_string(h->extended_hdr.parsed_pkt.dmac, buf2));

if(h->extended_hdr.parsed_pkt.offset.vlan_offset)
printf("[vlan %u] ", h->extended_hdr.parsed_pkt.vlan_id);

if (h->extended_hdr.parsed_pkt.eth_type == 0x0800 /* IPv4*/ || h->extended_hdr.parsed_pkt.eth_type == 0x86DD /* IPv6*/) {

if(h->extended_hdr.parsed_pkt.eth_type == 0x0800 /* IPv4*/ ) {
printf("[IPv4][%s:%d ", intoa(h->extended_hdr.parsed_pkt.ipv4_src), h->extended_hdr.parsed_pkt.l4_src_port);
printf("-> %s:%d] ", intoa(h->extended_hdr.parsed_pkt.ipv4_dst), h->extended_hdr.parsed_pkt.l4_dst_port);




char sql_lite[1500];
int lastID = mysql_insert_id(conn);
printf("\n\n\nLAT IS %d",lastID);
char *hexValue="";
while(p) {
printf("\n\nstr: %s\n", p);
asprintf(&hexValue,"%s%02x",hexValue,p);
p++;
}
//printf("\n\n char size : p size %lu ",sizeof(p));
sprintf(sql_lite, "insert into tblPL1 values ('%d','%s','%s')",'2013-05-11 20:20:20',p[0]);
puts(sql_lite);
//error = sqlite3_exec(conn, sql_lite, 0, 0, 0);




} else {
printf("[IPv6][%s:%d ", in6toa(h->extended_hdr.parsed_pkt.ipv6_src), h->extended_hdr.parsed_pkt.l4_src_port);
printf("-> %s:%d] ", in6toa(h->extended_hdr.parsed_pkt.ipv6_dst), h->extended_hdr.parsed_pkt.l4_dst_port);
}

printf("[l3_proto=%s]", proto2str(h->extended_hdr.parsed_pkt.l3_proto));

if(h->extended_hdr.parsed_pkt.tunnel.tunnel_id != NO_TUNNEL_ID) {
printf("[TEID=0x%08X][tunneled_proto=%s]",
h->extended_hdr.parsed_pkt.tunnel.tunnel_id,
proto2str(h->extended_hdr.parsed_pkt.tunnel.tunneled_proto));

if(h->extended_hdr.parsed_pkt.eth_type == 0x0800 /* IPv4*/ ) {
printf("[IPv4][%s:%d ",
intoa(h->extended_hdr.parsed_pkt.tunnel.tunneled_ip_src.v4),
h->extended_hdr.parsed_pkt.tunnel.tunneled_l4_src_port);
printf("-> %s:%d] ",
intoa(h->extended_hdr.parsed_pkt.tunnel.tunneled_ip_dst.v4),
h->extended_hdr.parsed_pkt.tunnel.tunneled_l4_dst_port);
} else {
printf("[IPv6][%s:%d ",
in6toa(h->extended_hdr.parsed_pkt.tunnel.tunneled_ip_src.v6),
h->extended_hdr.parsed_pkt.tunnel.tunneled_l4_src_port);
printf("-> %s:%d] ",
in6toa(h->extended_hdr.parsed_pkt.tunnel.tunneled_ip_dst.v6),
h->extended_hdr.parsed_pkt.tunnel.tunneled_l4_dst_port);
}
}

printf("[hash=%u][tos=%d][tcp_seq_num=%u]",
h->extended_hdr.pkt_hash,
h->extended_hdr.parsed_pkt.ipv4_tos,
h->extended_hdr.parsed_pkt.tcp.seq_num);

} else {
if(h->extended_hdr.parsed_pkt.eth_type == 0x0806 /* ARP */)
printf("[ARP]");
else
printf("[eth_type=0x%04X]", h->extended_hdr.parsed_pkt.eth_type);
}

printf(" [caplen=%d][len=%d][parsed_header_len=%d][eth_offset=%d][l3_offset=%d][l4_offset=%d][payload_offset=%d]\n",
h->caplen, h->len, h->extended_hdr.parsed_header_len,
h->extended_hdr.parsed_pkt.offset.eth_offset,
h->extended_hdr.parsed_pkt.offset.l3_offset,
h->extended_hdr.parsed_pkt.offset.l4_offset,
h->extended_hdr.parsed_pkt.offset.payload_offset);

} else {
printf("[%s -> %s][eth_type=0x%04X][caplen=%d][len=%d] (use -m for details)\n",
etheraddr_string(ehdr->ether_shost, buf1),
etheraddr_string(ehdr->ether_dhost, buf2),
ntohs(ehdr->ether_type),
h->caplen, h->len);
}
}

if(verbose == 2) {
int i;

for(i = 0; i < h->caplen; i++)
printf("%02X ", p[i]);
printf("\n");
}

if(unlikely(add_drop_rule)) {
if(h->ts.tv_sec == 0)
pfring_parse_pkt((u_char*)p, (struct pfring_pkthdr*)h, 4, 0, 1);

drop_packet_rule(h);
}
}
- Full Post

Deleting an element from a struct array

I'm working on a struct array and I need to dynamically delete elements from the struct. I have the added dynamically but I've run into some issues with deleting. I've researched different methods and tried a few. I found that one from here works, in that it will delete the entry but then using the view function won't print out the new array and crashes. I think it needs to be sorted but when I add my sort function it crashes before returning to the menu. The other method I tried also deleted the element through the index value but when viewed just outputted a bunch a symbols. Here's what I have. I commented out the 2nd method I used to see if that one in the end is easier to modify to work. Any help in the right direction would be beneficial.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h> /* not required for unix */
#include <sys/stat.h> /* stat */

struct person {
char firstname[12];
char lastname[12];
char birthdate[11];
};

void view(struct person *p, int max);
void swap(struct person *a, struct person *b);
void psort(struct person *p, int hi);

int add(struct person *p, int max); /* prompt for first, last, and bd (in main) */
int del(struct person *p, int max); /* prompt for index value (in main) */

int main(void)
{
struct stat st;
char choice;
FILE *f;
char filename[80] = "p19.db";
int i, n, max=5, size, done = 0;

struct person *p, *t;

struct person porig[5] = {{"Jack","Smith","1993-05-05"},{"Julie","Allen","1992-05-09"},
{"Cori","Murdock","1990-05-11"},{"Suzi","Hall","1980-04-30"},
{"Sami","Sundance","1972-05-05"} };

char menu[] = "(v)iew (+)add (-)del (?)search (a)ge (s)ave (q)uit ? ";

f = fopen(filename,"wb"); /* write binary file */
fwrite(porig,sizeof(struct person),max,f);
fclose(f);

if( stat(filename,&st)==0 )
{
if (st.st_mode & S_IFREG )
{
int i;
f = fopen(filename,"rb"); /* read binary file */
size = st.st_size;
t = p = (struct person *) malloc(size);
if ( fread(p,1,size,f)==size )
{
max = size/(sizeof(struct person));
//printf("BEFORE sort()\n");
//view(p,max);
//psort(p,max); /* test psort() */
//printf("AFTER sort()\n");
//view(p,max);
//free(p);
}
else
printf("Error in reading %s\n", filename);
}
else
printf("%s is not a regular file\n",filename);
}
else
printf("Unable to open %s\n", filename);

while ( !done )
{
printf("%s", menu);
scanf("%s", &choice);
switch(choice)
{
case 'v': view(p,max); break;
case '+':
//struct person *t = p;
p = add(p,max);
if ( p==t )
;
else
max = max + 1;
break;
case '-':
p = del(p,i);
if(p==t)
{
;
}
else
{
max = max - 1;
}
//psort(p,max);
break;
case 'q': done = 1; break;
default: printf("Invalid choice.\n");
}
}
printf("Done.\n");



getchar();
getchar(); /* system pause hack */
return 0;
}
void view(struct person *p, int max)
{
int i=0;
struct person *t = p;
for(i=0;i<max;i++,t++)
printf("[%d]%13s%13s%11s\n", i, t->firstname, t->lastname, t->birthdate);
}
void swap(struct person *a, struct person *b)
{
struct person tempa = *a;
*a = *b;
*b = tempa;
}
int indexOfMin(struct person *p, int hi)
{
int i, mindex = 0;
for(i=1;i<hi;i++)
{
if ( strcmp((p+i)->lastname,(p+mindex)->lastname )< 0 )
mindex = i;
else
;
}
return mindex;
}
void psort(struct person *p, int hi)
{
int i;
struct person *t = p;
for(i=0;i<hi-1;i++,t++) {
swap(t,t+indexOfMin(t,hi-i));
}
}
int add(struct person *p, int max)
{
int i;
struct person *t = NULL, *t0 = NULL, *p0 = p;
t = t0 = (struct person*)malloc(sizeof(struct person)*(max+1));

if ( t!=NULL )
{
for(i=0;i<max;i++)
*t++ = *p++;
printf("Enter a firstname, lastname and birthday (yyyy-mm-dd): ");
if ( scanf("%s%s%s", &t->firstname, &t->lastname, &t->birthdate)==3)
{
if ( p0==NULL )
;
else
free(p0);
p = t0;
}
else
p = p0;
}
else
fprintf(stderr,"Error, unable to malloc\n");
return add;
}
int del(struct person *p, int max)
{
int i = 0;
char deleteFirstname[12]; // Temp string to compare to existing array
char deleteLastname[12]; //temp string
char nullStr[11] = {"\0"}; // empty string to remove birthdate
printf("\nEnter firstname: ");
scanf("%s", deleteFirstname); //place into temp string
printf("Enter lastname: ");
scanf("%s", deleteLastname); //place into temp string
for (i = 0; i < max; i++)
{
if (strcmp(deleteFirstname, p[i].firstname) == 0) //compare deleteName to p.firstname
{
for (i = 0; i< max; i++)
{
if (strcmp(deleteLastname, p[i].lastname) == 0) //If deleteSurname matches p.lastname
{
strcpy(p[i].firstname, nullStr); //Put null into firstname
strcpy(p[i].lastname, nullStr); //Null into lastname
strcpy(p[i].birthdate, nullStr); //Null into birthdate
printf("Person removed from array.\n");
i--;
}
}
}
else printf("Invalid entry--try again.\n");
}


//int i, a;
//printf("Enter index value: ");
//scanf("%d", &i);
//if (i >= max+1)
//{
//printf("Deletion not possible.\n");
//}
//else
//{
//for ( a = i - 1 ; a < max - 1 ; a++ )
//p[a] = p[a+1];
//}
return del;

}
- Full Post

how to copy string array dynamically

hey guys I need help with this I have no idea how to work this out please help me with like atleast the starting coding i am trying to google too but i cannot find any info on this.

"char * copyString( const char * s );
copyString returns a dynamically allocated copy of the arg string.
For instance, if s were “CAT”, then copyString allocated a 4-byte array, sets that array to “CAT”, and returns the address of the first element of the dynamically allocated array. As usual, deallocation is the caller’s responsibility."

this is the function that i am suppose to have please can some one point me in the right direction.
thank you - Full Post

scanf help

Hi,
I am trying to write a program which read a certain input in a particular format and then gives an ouput. I wrote a code to read the file. Input is something like this.
X 20 60 80 90
X 78 98 97 96
X 34 35 43 23
Y 76 87 34
Y 65 76 72
Z 13 70 39
So my reading function read the input and then it counts the number lines with X and Y. Now, when I wrote two different funcions to read X and Y lines. When I am finished reading the X lines, I go to read Y lines. The code skips the first Y line, because it has already read it without realising that it is a Y line, and then it read the next line while skipping the first Y line. Can I avoid that?

I use scanf to read the first character and then it is true I used scanf in a while loop to read the rest of the numbers and I store those numbers in an array.

As I know that it has already read the next character, can I test it if the character is Y? Because the input may not contain the Y line.

Thanks. - Full Post

Programming in C

(i)Write a function in C Programming Language, isEven(), that takes an
integer value as argument and returns 1 if the latter is even, otherwise
returns 0 (zero).

(ii)The function isEven() is saved to the file 'usefulfunctions.h'. You are
required to write a C program that allows the user to enter integer
numbers. To end we use 0 (zero) as the last number. Your program
should make use of the isEven() function from 'usefulfunctions.h' and print
the odd numbers on screen.

I am having difficuty to answer the second part. I can not even start it. Help? - Full Post

network programming

i want to write a sever application.my sever have some service to client. some of the answer of my server is long(transfer file) and some of them is short(list of online client).
when server transferring file to a client , other client request to get online client list. i want first job pause and answer the second then return first job.

and my server code is below:
what should i do?!

int runServer(char* pathDir, int portNum)
{
int tcp_socket,maxSelect,activity,newSocket;
struct sockaddr_in server_addr;
int server_addr_length;

tcp_socket = socket(AF_INET,SOCK_STREAM,0); // IPV4 , TCP , IP
if ( tcp_socket==-1 )
{
char handle_error[] = "socket not created so application terminate, please run again.";
write(1,handle_error,strlen(handle_error));
return -1;
}
int opt=TRUE;
if(setsockopt(tcp_socket,SOL_SOCKET,SO_REUSEADDR,(char*)&opt,sizeof(opt))<0)
{
char handle_error ="ERROR: problem in set socket option occurred\n";
write(1,handle_error,strlen(handle_error));
}
server_addr.sin_family = AF_INET; // family address ipv4
server_addr.sin_port= htons(portNum); // port number
server_addr.sin_addr.s_addr = INADDR_ANY; // recieve message from all address

int mybind = bind(tcp_socket,(struct sockaddr*)&server_addr,sizeof(server_addr));
if(mybind==-1)
{
char handle_error[] = " ERROR in binding\n";
write(1,handle_error,strlen(handle_error));
return 0;
}
listen(tcp_socket,MAX_USER);
while(TRUE)
{
FD_ZERO(&readfd);//clear the socket set
FD_SET(tcp_socket,&readfd);//add socket
maxSelect=tcp_socket;

// add child socket
int k;
for(k=0;k<MAX_USER;k++)
{

if(clientList[k].isThere==1)
{
FD_SET(clientList[k].userIdNumber,&readfd);
if(clientList[k].userIdNumber>maxSelect)
maxSelect=clientList[k].userIdNumber;
}
}
activity= select(maxSelect+1,&readfd,NULL,NULL,NULL);

if(FD_ISSET(tcp_socket,&readfd)) //request for connecting
{
function that answer conection request;
}
int y;
for(y=0;y<MAX_USER;y++)
{
find who request and answer to him
}
}
}
- Full Post

Caesar Cipher

I am doing code for CAESAR CIPHER. I need to built a histogram or frequency distribution for the output. I thought that finding out the frequency of the ASCII code, then print the frequency with * by using loop. But my code din't have array, can't do ++freq[c[i]].
I have no idea. Anyone can help?

#include <stdio.h>
#include <iostream.h>
void encrypt(int shift);

int main()
{
int shift;
int decOrEnc;

printf("Enter shift amount (1-25): ");
scanf("%d", &shift);

if (shift < 0)
{
printf("Bad Input.");
return 0;
}

printf("Type 1 to Encrypt or 0 to Decrypt: ");
scanf("%d", &decOrEnc);

if (decOrEnc != 0 && decOrEnc !=1)
{
printf("Bad Input.");
return 0;
}
while(getchar() != '\n');
if (decOrEnc == 1)
encrypt(shift);
else
{
shift = -1 * shift;
encrypt(shift);
}
getchar();
}

void encrypt(int shift)
{
char ch;
printf("Please Enter Your ID : ");
ch = getchar();
while(ch != '\n')
{
if (ch == ' ')
putchar(ch);
else
{
if(shift == 1)
putchar(ch + shift);
else
putchar(ch - shift);
}
ch = getchar();
}

{
unsigned int c;
while (1)
{
printf("\n" );
c = getchar();
printf("%c - %d", c, c );
}
}
/* int freq[100]={0};
for(int i=0; i<127; i++)
{
++freq[c[i]];
}*/
system("pause");
putchar(ch);

}
- Full Post

c programing of numbers,

this is my code, when even i run it it tells me that the number is even while it is odd.

#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int value;

/* To read a number and say wheither it is even or odd*/
printf("Please enter any number \n");
scanf("%u", &value);


if (value/2 != 0)
printf("the number is Even \n");
else
printf("the number is Odd \n ");
printf("The value is %u \n",value*10);

return 0;
}


please help me out in getting the code to work in the right way that i want it to. - Full Post