In Progress

convert simple perl tools to compilable c code for linux systems

small and simple perl tool need to be migrated to executables binaries, 'make'able c++ code should do it, mainly to be run on linux type OS...

perl version attached

perl piece:

----------------------------------------------------------------------

#!/usr/bin/perl

use strict;

use Socket;

my $me = $0;

my $input = $ARGV[0];

if ($me =~ /ip2int/) {

my $ipnumber = ip2num( "$input" );

if ( $ipnumber ) {

print "$ipnumber\n";

}

} elsif ($me =~ /int2ip/) {

my $ip = num2ip( $input );

if ( $ip ) {

print "$ip\n";

}

} elsif ($me =~ /mac2int/) {

my $num = mac2num( "$input" );

if ( $num ) {

print "$num\n";

}

} elsif ($me =~ /int2mac/) {

my $mac = num2mac( "$input" );

if ( $mac ) {

print "$mac\n";

}

}

sub ip2num {

return unpack 'N', inet_aton(shift);

}

sub num2ip {

return inet_ntoa( pack 'N', shift );

}

sub mac2num {

my $mac_hex = shift;

$mac_hex =~ s/://g;

$mac_hex = substr(('0'x12).$mac_hex, -12);

my @mac_bytes = unpack("A2"x6, $mac_hex);

my $mac_num = 0;

foreach (@mac_bytes) {

$mac_num = $mac_num * (2**8) + hex($_);

}

return $mac_num;

}

sub num2mac {

my $mac_num = shift;

my @mac_bytes;

for (1..6) {

unshift(@mac_bytes, sprintf("%02x", $mac_num % (2**8)));

$mac_num = int($mac_num / (2**8));

}

return join(':', @mac_bytes);

}

----------------------------------------------------------------------

Skills: C++ Programming, Perl

See more: linux convert perl, systems programming, sprintf c programming, socket programming c#, programming tools, programming on linux, programming for mac, programming for linux, print pack, perl socket programming, mac tools, hex programming, c# socket programming, c socket programming, c# programming tools, c programming sprintf, c programming on mac, c programming mac, code for programming, socket programming c, programming perl, c++ code, c code, perl convert code, piece code

About the Employer:
( 1 review ) herndon, United States

Project ID: #4414069

Awarded to:

damirmarkovic

I have a lot of experience with C coding and Perl scripting. If the price is ok, you can have bulletproof code in a day. Let me know if you have any questions.

$60 USD in 1 day
(36 Reviews)
4.6

6 freelancers are bidding on average $90 for this job

idleswell

Hello, I have ~30 years experience in both Perl and C/C++. I see what each step of your script is doing I will be able to translate this from Perl to C++ for you. A IDLER

$93 USD in 3 days
(96 Reviews)
5.6
honeypotant

Dear Sir. I'm very interested in your job post involving these skills. I am just LinuxOS/Network expert and have 7 years experience. I have consistently delivered projects on time and under budget, which has earn More

$412 USD in 4 days
(7 Reviews)
4.5
hddh

I can do it.

$80 USD in 2 days
(10 Reviews)
3.5
zkutch

Hello. More 20 years programming experiense.

$100 USD in 1 day
(1 Review)
2.1
vkoder

Hi i can do this

$99 USD in 3 days
(2 Reviews)
1.5
krvenkat

Hi, I can do it, Please check your PM.

$110 USD in 2 days
(0 Reviews)
0.0