Wednesday 30 November 2011

Giving permission for file creation in SuSe

Giving permission for file creation in SuSe

Hi,

I have created a user using useradd xxx and chaged the passwd xxx. I am able to successfully log into xxx , but when i am trying to create a file its displaying " Permission denied"

Please help me how to give the rights to user xxx

Thanks in advance!

-Sumanta

Networking issues

Networking issues

Hi guys,

First post here :)

Okay, we are having network issues on 3 of our production servers (Running Oracle)

We are getting a lot of dropped connections and users are complaining of losing connection to Oracle. Our 1 application servers network service also randomly stop/hangs.

We have confirmed with our network team that they don't pick up any dropped packets on the switches. We tried switching the mezzanine cards which didn't work. We increased the buffer on the network. We made configurations to the bnx2 drivers as well.

All 3 servers are running Red hat 5.3 (Tikanga)

Thanks in advance

How to secure TMP folder?

How to secure TMP folder?

Hi

I want to secure tmp folder and want to stop any execution there.

Please guide me for that

Thanks

Issue opening Ubuntu Software Center

Issue opening Ubuntu Software Center

Hello,

this is my first time posting so I apologize if this has been addressed previously. I searched to see if there was anything related but I could not find anything.

I have installed Ubuntu 11.10 on VirtualBox and everything was going fine. Then I went to open the Software Center. First, nothing came up but in the top left corner it said "Ubuntu Software Center" as if the program were open. Then, I started getting this strange thing when I opened the Software Center after a few tries (see attached picture). Any idea what may be happening here?
Attachment 3941

ffserver cannot open ffserver.conf file

ffserver cannot open ffserver.conf file

Hello, I use ffserver & ffmpeg in order to generate a live stream (recorded by a webcam).

I use an embedded processor (SH7724), busybox version 2010.09, kernel 2.6.39.3.

the command I issue is and its output are attached in file (sorry, forum does not allow me to specify it in here).


--> It seems for me that ffserver does NOT open the conf file, hence webcam.ffm file is NOT opened.

I've tried to move the conf file to some other path or to change its name, but it wouldn't help.
I've also tried to remove the "-f /etc/ffserver.conf" (default location is anyway /etc/ffserver.conf), but it also wouldn't help.

--> As far as I can tell the problem is that ffserver does NOT care about its conf file

Do you have any idea? I'm lost....

Thanks

Code:

The ffserver.conf file is:
==================
Port 8090
# bind to all IPs aliased or not
BindAddress 0.0.0.0
# max number of simultaneous clients
MaxClients 4
# max bandwidth per-client (kb/s)
MaxBandwidth 10000
CustomLog -
# Suppress that if you want to launch ffserver as a daemon.
NoDaemon

<Stream status.html>
Format status
# Only allow local people to get the status
#ACL allow localhost
#ACL allow 192.168.0.0 192.168.255.255
</Stream>

<Feed webcam.ffm>
File /tmp/webcam.ffm
FileMaxSize 5M
</Feed>

# FLV output - good for streaming
<Stream webcam.flv>
# the source feed
Feed webcam.ffm
# the output stream format - FLV = FLash Video
Format flv
VideoCodec flv
# this must match the ffmpeg -r argument
VideoFrameRate 24
# generally leave this is a large number
VideoBufferSize 50 #Aviv: changed from 20000
# another quality tweak
VideoBitRate 100
# quality ranges - 1-31 (1 = best, 31 = worst)
VideoQMin 5
VideoQMax 10
VideoSize qvga
# this sets how many seconds in past to start
PreRoll 0
# wecams don't have audio
Noaudio
</Stream>

# ASF output - for windows media player
<Stream webcam.asf>
# the source feed
Feed webcam.ffm
# the output stream format - ASF
Format asf
VideoCodec msmpeg4
# this must match the ffmpeg -r argument
VideoFrameRate 24
# generally leave this is a large number
VideoBufferSize 80000
# another quality tweak
VideoBitRate 200
# quality ranges - 1-31 (1 = best, 31 = worst)
VideoQMin 1
VideoQMax 10
VideoSize 640x480
# this sets how many seconds in past to start
PreRoll 0
# wecams don't have audio
Noaudio
</Stream>

<Stream webcam.mjpeg>
Feed webcam.ffm
Format mpjpeg
VideoSize qvga
VideoFrameRate 24
VideoIntraOnly
# Noaudio
Strict -1
</Stream>

Aix servers Monitoring

Aix servers Monitoring

Hi All,

I installed nagios ,plugins and nrpe in zlinux servers .And also I installed nrpe and plugins in xlinux and AIX servers.Is it possible to monitor the AIX anb xlinux servers from zlinux servers?

Thanks
ravi

Need to find my "C" drive on bricked Windows machine...

Need to find my "C" drive on bricked Windows machine...

Backstory: My Windows 7 is bricked. I have two SSDs on the machine: the "C" drive with my OS, antivirus, etc... and a "P" drive for programs. On top of that I have four HDDs set up in a RAID 10 for data.

My problem is either related to a virus or to AVG-- it's the AVGIDSEH.sys stall upon start-up issue for those familiar. Basically Windows stalls on startup and eventually reboots... and on and on.

I saw that one person beat this issue by running Slax from a USB and then renaming a couple of specific AVG files, then rebooting, starting in safe mode and uninstalling AVG all together. So, having tried several other approaches, I made a bootable USB for Slax, and I'm FINALLY looking at something. Progress!

Now the trick is this-- I can see the former "P" drive and that's it. I can't see the RAID drive, which didn't surprise me. But I can't see the former "C" drive either.

Can somebody please take this Linux newbie by the hand and tell me how to figure out the source location of my "C" drive and then how to mount that so I can see it in Slax?

Secondary to that-- is there any way to get to the files on my RAID? Unfortunately I have an important work file on there that I need to get to asap.

My little head is pounding from all of this-- I'm barely staying afloat. Any help would be so appreciated. Thanks!

searching for open source progams

searching for open source progams

I'm looking for an open source program and I thought this would be a good place to ask since I used Linux for a while and always received good advice.
I am looking for a newspaper template where I can basically plug in my own headlines and text into already pre fabricated boxes. Photos would be a plus. Something simple that I can use to create a realistic looking weekly newspaper and export as PDF. Nothing that requires the use of gimp. Not sure if such a thing exists so thanks for any help.

Any Hope for Monoprice USB Wifi Devices? (Ralink, Realtek)

Any Hope for Monoprice USB Wifi Devices? (Ralink, Realtek)

I have 3 Monoprice 802.11n USB adapters that I got as a side effect of another transaction. For all 3 devices, the packaging declares Linux as a supported OS on both the front and back, as do the paper instruction manual and CD, but after numerous sessions trying to get them working, none of the 3 is useful. I've tried with Debian 6, several live distros, and periodically with Debian testing weekly ISOs, in a room with ~2 meters clear line of sight separation.

Monoprice product #5333 was sold as being Ralink 3070 based
Monoprice product #6147 was sold as being Realtek RTL8191SU based
Monoprice product #6148 was sold as being Realtek RTL8188SU based

The 5333 (148f:3070) seems to load its firmware successfully and responds to iwconfig/ifconfig/iwlist/iw as you'd expect, but fails in various ways: sometimes simply failing to associate, but usually establishing a successful connection and then dropping it within a few minutes. Logs vary with each version of distro and kernel, for example "No probe response from AP" or "disassociating by local choice (reason=3)". Sometimes data transfer begins with a surge for a second or 2, but then stalls for minutes at a time until the connection drops.

I experienced what others have noticed, that the USB-ID changes for the Realtek devices. Initially the 6147 was 0bda:8172 and the 6148 was 0bda:8171, but now both identify as 0bda:8192
Both Realtek devices will not even load firmware, so there's not much to test with them.

kern.log says
rtl819xU:EEPROM ID is invalid(is 0x0(should be 0x8129)

Also,
usb 4-2: not running at top speed; connect to a high speed hub
(mass storage devices as well as the 5333 do connect at high speed)

I've tried various workarounds for the firmware problem (including following instructions on the net for modifying udev rules), but haven't found one that works.

Other than the USB-ID, is there a way to determine what chip is actually being used in each device? Why would the ID change?

If anyone knows how to get these devices working with Debian (and hopefully other Free systems), I'd appreciate your advice.

BTW, the 2 Realteks have wps buttons: Do these function with Linux drivers?

Thanks.

Increase Linux kernel computation speed

Increase Linux kernel computation speed

Hi to all
I attend to make special kernel build made only for one purpose: to compute mathematical problems faster.
Please ,can someone verify that is correct optimization I can made in kernel

- Try BFS, for a low end machine it might be better for multi-core tasks. []The kernel patch homepage of Con Kolivas
Or
- Build a custom kernel and set:
Always use Transparent Huge Pages
Disable paravirtualization
100 HZ
No Forced Preemption
SLAB
Pick optimizations for your cpu type


Of course any other idea or link is highly welcome

Wow, gourmet coffee, it's good, smells great

Wow, gourmet coffee, it's good, smells great

mmmmmmmmmmmmmmmmmmmmm

converting mp3s

converting mp3s

I'm looking for a script that can find all the mp3s within a folder and all it's sub-directories that either have a bit rate greater than 192kb/s or are vbr, convert them to 192kb/s, and in the case of the vbr ones, remove the bigger of the two. If possible it would be really be nice if I could retain the id3v2 tags as well, as it would save some work afterwords.

I don't care what you use to make it work, as long as it's relitively easy to find and compile. I'm currently using arch linux if that makes any difference.

Using Linux with a virtual machine

Using Linux with a virtual machine

How do i install Linux for a virtual machine to use? I would like to keep Windows as my only "official" OS but be able to run Linux from within the VM.

Basic Knoppix 6.2 questions

Basic Knoppix 6.2 questions

I have a Knoppix 6.2 LiveCD that boots up fine on a Windows XP home machine sp2.

It then gives me menus where I can mount a hard-drive or partition, no problem there, it lists all of the computer's volumes and allows me to choose which volume I want to look at in File Manager.

Two problems occur next:
1) It complains about which charset to use - there's an error, perhaps it doesn't know my volumes are of a certain type, naturally, they are NTFS.

2) Then when I choose to skip rather than cancel or whatever, I am able to browse my directories quite well, and there are 10 commands at the bottom but the commands always give an error - should I use a number, a letter, or the whole word?

Anyone know what I am talking about?

Getting this error when trying to install a game.

Getting this error when trying to install a game.

I'm trying to install a game and get this error: I'm running Ubuntu 11.10 and running intel pent 2.8 ghz x 2 64 bit.

The setup program seems to have failed on x86_64/unknown


Detecting libc...
Detected: os=Linux, arch=x86_64, libc=unknown



Thanks in advance for any help.

ou8it

Apply changes to all subfoldersand their contents - sudo konqueror

Apply changes to all subfoldersand their contents - sudo konqueror

I am attempting to use konqueror to navigate and reset permissions for team group folders.
On the permissions dialogue window the bottom checkbox remains unavailable even though I opened konqueror using sudo.
Is there a way to set my user to have the privilege of applying the permissions recursively using konqueror? See attached screen shot. Thanks in advance.

Attachment 3938
Attached Images

Writing and reading from a serial port

Writing and reading from a serial port

Hello,

I am working on a project that will basically write some data to 8250 serial port (/dev/ttyS0) and then read back the same data. My understanding is if I write something, it will stored in a buffer and then if I read back, I should be able to read what I just wrote. However, I am having issues where I can write successfully to a serial port but when I check for # of bytes available in the input buffer, it returns 0. So basically, my write does not flush. Can you tell me where the problem..? Here is my code snippet.

#include <termios.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/signal.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <stdlib.h>
#include <sys/ioctl.h>

int main()
{
int fd, res, sen;
int i;
struct termios oldtio, newtio;
char buf[] = "hello";
int bytes, total;

fd = open("/dev/ttyS0",O_RDWR | O_NONBLOCK | O_SYNC);

if (fd < 0) { perror("error"); return EXIT_FAILURE; }

fcntl( fd, F_SETFL, O_NONBLOCK );

newtio.c_cflag = CLOCAL | CREAD;

newtio.c_iflag = IGNPAR | ICRNL;
newtio.c_oflag = 0;

newtio.c_lflag = ICANON;
newtio.c_cc[VMIN] = 0;

newtio.c_cc[VTIME] = 10;

tcflush(fd, TCIFLUSH);

tcsetattr( fd, TCSANOW, &newtio );

sen = write( fd, buf, sizeof(buf) );


printf("No. of bytes written = %d\n", sen);

tcsetattr(fd, TCSAFLUSH, &newtio);

total =ioctl(fd, FIONREAD, &bytes);

printf("No. of bytes in the input buffer = %d\n", total);


return 0;

}

Any help will be highly appreciated.

Thanks,
Nick

running a stopped process

running a stopped process

i m trying to implement a scheduler in C. I need to insert a forked process into a queue and make it exec for 1 quantum say and then push it back in queue. Allocate another quantum l8r.. how do i do this??
What r the different calls supported in the header unistd.h

How to DNAT with iptables

How to DNAT with iptables

When x.x.x.x makes a request on port 80 to y.y.y.y I would like the request to be redirected to z.z.z.z:80. I'm trying to do this with iptables under CentOS 6. It might be worth mentioning that to prove the concept x.x.x.x and y.y.y.y are currently in the same local network but later I'll be trying to do this over a VPN with x.x.x.x one side of the VPN and y.y.y.y on the other. z.z.z.z is an external ip.

Before creating any rules, when I go to y.y.y.y:80 from x.x.x.x I can connect to the http server running on y.y.y.y.

I think I've established that I need to create a DNAT rule. I've done this as follows:
Code:

iptables -t nat -A PREROUTING -p tcp -s x.x.x.x -d y.y.y.y --dport 80 -j DNAT --to-destination z.z.z.z:80
When trying to connect to y.y.y.y the connection times out. I realised ip forwarding was disabled, so issued:
Code:

echo 1 > /proc/sys/net/ipv4/ip_forward
This then stops the timeout but still doesn't connect to the http server on z.z.z.z.

Someone suggested that I need to create an SNAT rule because x.x.x.x and y.y.y.y are currently on the same network. I'm not sure if I've done this correctly or not:
Code:

iptables -A POSTROUTING -t nat -s x.x.x.0/24 -o eth0 -j SNAT --to-source x.x.x.x
If anyone has a suggestion on how I can get this working I'd really appreciate their help.

Thanks,

James

Video problems running Fedora 15

Video problems running Fedora 15

I decided it was time to move from Windows XP and installed Fedora 15 on my Dell Inspiron 6000 laptop. However, I am now getting a blank screen on 'switch on' which can be resolved after a hard reset and the computer hangs if left untouched for longer than 1hour.
Any suggestions would be much appreciated. :p

SSL ldap pasword change

SSL ldap pasword change

Quick question does anyone know how an enduser would change their password in ldap using ssl instead of kerberos?

Thanks
grimm08

What distro do I need to do this?

What distro do I need to do this?

Hi I wonder if anyone can point me in the right direction as to what distro would be suitable for my needs.

I would like a live usb or cd distro that enables me to fully customise the over all look.
Password login that erases the stick if someone tries to login and fails 3 times.
Web browser
On stick storage space
Small database for contacts with notes.
Fully transferable over a range of systems.

Is there anything out there that does this or would give me the means to create this?

Many thanks.

recovery mode and password

recovery mode and password

Dual boot (2HDD) Ubuntu and XP. Ubuntu is on its own hard drive. I can access regular account with no problem. Password works as it's supposed to.

If I try recovery mode, at the end it asks for username and password. However, it will not accept what I use for regular access and set up the Ubuntu account with. Just sits there at the prompt and says incorrect.

What is it looking for? Windows has never had a password, so it can't be that.

This happened with 10.10 and now 11.04. Do you have to set up a Ubuntu one account for a general password? I never have as I want nothing to do with cloud storage. I do not share if I don't have total control. In fact, I want to delete Ubuntu One.

Thanks

Virtual Box Screen Size & cursor Problem

Virtual Box Screen Size & cursor Problem

Hi Guys !

I have installed Virtual Box(latest version) in Ubuntu 10.04 as (Host) where - WinXP & Cent OS are guests.

After installing the guest additions I am unable to get the full screen window size in Cent OS. I want the exact screen size of 1280x800 which is not available as option in centos-system-preferences-display. Suppose if i select the given higher resolutions, it will be small or very high where i'll have to scroll to get to see the whole desktop screen. Also there is NO /etc/X11/xorg.conf file in centos. In win Xp the screen is absolutely fine.

- How to get the right window size(just maximized size) from centos(guest) in Ubuntu (host). Do i have make changes in centos display files or Ubuntu-Vbox file?

- Also my mouse cursor is not synchronized in centos guest & ubuntu. where as in WinXp(guest) - Ubuntu (host) i am not having any problems as such. How to fix this?

Thanks in advance !

How to provide SSH Linux Users less privileiges ?

How to provide SSH Linux Users less privileiges ?

Hi All

Can you help me on this thing, here is my scenario..

we had a linux system(server),
1) where had created ssh users in order to access the linux system.
2) we had edited the sudoers file such that that SSH users will get same privileges as the user gets.
3) now the problem descriptions is how can we provide less restrictions to the SSH users created , so that the dont get root privileges, how can we configure linux system in order to provide less restricitions


Regards
Rakesh

Hi everybody!

Hi everybody!

Hi everybody!
I'm not a newbie of Unix, but definetely not an expert.
I hope to learn how to solve problems that occurs thanks to your help, in order to be able to else someone help in the future!!!

OS Inhibition

OS Inhibition

Hi everybody,
I have a real big problem to solve...
Is possible, with RedHat enterprise 6.0, to run a C/C++ routine or program ensuring that no other processes (also kernel processes) stop its execution?

p.s. I can't recompile the kernel for this purpose.

Please help me if you can!

Missing the separate debug info file

Missing the separate debug info file

Hi all,
i have some doubt in this topic
i have read that , it is due to
Quote:

that the problem was that the appropriate "-debug" packages for the shared libraries were not installed and suggested that the absence of specific information as to which libraries were missing was a bug.
when i try to debug my pgm
Code:


Starting program: /home/shamjs/source/olupxtest

warning: Missing the separate debug info file: /usr/lib/debug/.build-id/ac/2eeb206486bb7315d6ac4cd64de0cb50838ff6.debug

warning: Missing the separate debug info file: /usr/lib/debug/.build-id/e3/3448de964a5ca97b70edbdcea227c6ea5d3657.debug

[Thread debugging using libthread_db enabled]
[New process 17475]
Enter the result level(0 - 5): 5
Calculate outliers ? (0, 1): 0
Do pretreatments? (0, 1): 1
Enter the file name: Scenario1
Enter the Model name: CaseB-WP
[New Thread -1208432944 (LWP 17475)]
[Switching to Thread -1208432944 (LWP 17475)]

Breakpoint 1, main () at olupxtest.cpp:376
376            nError = olxGetAvailableModels(pred, sfileName, "", &nmodcount, &pointer);
(gdb) step
377            if(nError == OK)
(gdb) n
388            nError = olpSelectProjectFile(pred, sfileName, smodelName, "");
(gdb)
terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_S_construct NULL not valid

Program received signal SIGABRT, Aborted.
0x00110402 in __kernel_vsyscall ()

1>my question is that,whther it(warnings) cause any any problem to my program

2>im not able to use step during debugging ,as you can see i have applied break point at line 376 ,and then im trying to step into the olxGetAvailableModels function,but unfortunately stepping is not happening........(whether its because i got those warnings?)

what can be done........
waiting for your reply.......

Clustering using VMware images

Clustering using VMware images

Hi
I would like to understand the basics, setup of a cluster. I have a powerful machine in i7, 6 gb ddr3 Ram. I was thinking why not clone a same ubuntu vmware image as 4-5 ones, start them up together and work as a cluster. But my thoughts couldn't be converted as actions as I don' t know anything about clustering, how to make 1 system know the other, how to attach static IP, or what cluster software is free/easiest to maintain.

I am thinking of installing multi-partitioned database server in either DB2 or Oracle and use 1 other system in my home network as application server and want to play around.

Please link me to any articles/cluster software that are free/easy, and how to make 1 system know the other 1? meaning how to even mount 1 vmware image in another etc.

Thanks
Arun

How to Convert DVD/Video to Nokia N9, iPhone 4S, HTC Android

How to Convert DVD/Video to Nokia N9, iPhone 4S, HTC Android

How to Convert DVD/Video to Nokia N9, iPhone 4S, HTC Android and other devices.

Nokia N9
Nokia has announced the first MeeGo-based smartphone - Nokia N9. It will be available in three colors—black, cyan, and magenta—with 16GB and 64GB storage. But Nokia has already stated that is has largely abandoned Meego in favor of Microsoft's Windows Phone operating system. Still, the N9 is shaping up to be a pretty impressive device, and boasts some interesting design choices. The most intriguing feature on the Nokia N9 is a gesture called swipe. There is no home key on the phone—when you're in an application, swiping from the edge of the display will pull up your home screen. There will be three different home screen views, designed to focus on apps, notifications, and switching between activities.
The Nokia N9 features a 3.9-incled AMOLED screen made from scratch-resistant curved glass. According to Nokia, the N9's polycarbonate body enables improved antenna performance, which may result in better reception, better voice quality, and fewer dropped calls.
The Nokia N9 allows you to easily share images and videos between devices by touching them together. There's an 8-megapixel autofocus camera with a wide-angle lens and HD-quality video capture. And it will also feature free turn-by-turn driving and walking navigation with voice guidance in Maps and a new dedicated Drive app.
iPhone 4S
Familiar and yet new, the iPhone 4S may not look different from the outside, but inside it's a very different beast. With its fifth generation smartphone, Apple is keen to show that the devil is truly in the details: the iPhone 4S is wickedly fast, fiendishly well equipped and ruthlessly threatening to its mobile rivals. Can this really be your intelligent personal assistant, your multimedia hub and your window onto the cloud, all in one 9.3mm thick package? Check out the full SlashGear review after the cut.
Hardware: From the outside the iPhone 4S looks identical to the iPhone 4. Inside, it's anything but. Apple has resisted the urge to change design for the sake of change, and stuck with the same 3.5-inch Retina Display, glass and aluminum casing, and minimalistic aesthetic as before. It's a decision that frustrated some in the aftermath of the launch event, but makes sense if you consider the evolution of the iPhone. A bigger display would've made for a bigger device overall, and potentially alienated women, teens and anyone with smaller hands.
iOS 5: Apple's newest version of iOS may be fresh to the iPhone 4S, but it's also being pushed out to the iPhone 3GS, iPhone 4, iPod touch 3rd/4th-gen, iPad and iPad 2 this week. We've covered all the changes – and there are many – in our full iOS 5 Review.The most notable features are Siri, iCloud and the new Notifications Center, certainly the three likely to have the biggest impact on everyday iPhone 4S use.

With these two powerful smart phones, we can enjoy our HD movies, music, or clear pictures anytime and anywhere. But many people probably get confused with how to convert DVD movies or videos into your favorite smart phones. The most effective and easy way is to use some powerful and professional programs like: Nidesoft DVD Ripper and Nidesoft Video Converter.
Nidesoft DVD Ripper is an excellent software with powerful functions that can convert DVD files to almost all popular video and audio formats including MP4, MP3, AVI,WMV, 3GP, AVC, AAC,etc. And Nidesoft Video Converter can convert between almost all popular video and audio formats so that you can get movies and music from any format files with high quality and the super fast speed. It is really easy to use and only a few clicks were needed. You can free download the Nidesoft DVD Ripper and Video Converter from nidesoft.com/video-converter.html. Now, the specific steps will be introduced about how to get and convert DVD movies and videos with these powerful programs.

How to get movies and music from DVD?
Step1: you may open the Nideosoft DVD Ripper and load DVD movies first.
a. Open the Nidesoft DVD Ripper you have just downloaded.
b. Insert the DVD disc into the DVD Drive
c. Click the Open DVD button, browse your computer, find the DVD folder of the movie and open it.

After add your movie, you can click any title or chapter to preview it in the preview window on the right. Then you can choose any titles or chapters you want to convert by click the check boxes before them. In this way, you can choose to convert DVD with the entire movie or just convert one or several chapters.
Step 2: Nidesoft DVD Ripper has powerful functions that enable you edit your video during conversion. You may use the functions below to make your perfect video.
Merge: A regular DVD movie has several chapters, you can convert several chapters into one by click the blank box before merge into one file. Click the check box before any chapter you want and merge them into one file.
Crop: you can cut off the black edges of the DVD movie to watch in full screen by click the crop button. A window will be opened and you can customize the size of screen by your will.
Effect: Click the Effect button you can set special effect including gray effect and negative effect.
You can also set the brightness, contrast, saturation and volume.
Trim: as you have selected the clips to convert, you can trim any segment of the clips by clicking the trim button. You can move the slide below the screen or set the start time and end time to trim any segment.
Step 3: you may customize the output video with its full functions.
Audio Track: Select an audio track from the available audio tracks of your DVD movie.
Subtitle: Common DVD movies have several subtitles such as English, Chinese, French, etc. You can choose one language you prefer or select "None" to delete subtitle.
Profile: Click the button and show the list of profiles, you can select the profiles you want. For example, if you want to convert your DVD movies to your iPod video player, click the "iPod video MPEG-4 (*.mp4)".
Step 4: now you can start your conversion.
After the settings finished, you can just click the Convert button to start the conversion. You can view the conversion speed at the bottom. The conversion will be completed in few minutes.

How to convert video or audio files to some formats which your player supports
For example, you have downloaded a file from YouTube is in "flv" format and you may follow the way below to convert the flv files or other video files in your computer into your portable player.
Step 1: open the Nidesoft Video Converter and load files.
a. Open the Nidesoft DVD Ripper you have just downloaded.
b. click "add Files" button and import the videos from your computer. Nidesoft video converter supports batch conversion so you can import multiple files at one time.

c. EDIT the video with the function button: Crop, Effect, Trim, Options
(1) Crop: Remove the undesired area or just convert part of the video area from your video file by dragging the frame around the video or setting the crop values: Top, Button, Left and Right.
(2) Effect: You can select gray effect or Negative effect from Special Effect or tune the Brightness, Contrast, Saturation and Volume to get special effect movie.
(3) Trim: To get your favorite segment by setting the "Start Time" and "End Time" or dragging the Start Time slider to set the start time and dragging the End Time slider to set the finish time.
(4)Options: Set video Resolution, video Bitrate, Audio Channels, and Audio Bitrate.
Note: You could click the white box besides "Merge into one file" to merge your selected titles into one video before starting the conversion.
Step2: Select the out file format
Click the "format" drop-down list to select the output format. If you don't know what formats your device supports, you can just select the format according to the device name.
Step3: Click the "Convert" button and start the conversion. Please wait a few minutes before the conversion succeeds!
Ok, now you have got music from videos and next what you need to do is enjoying it. If you have any questions, please visit Nidesoft Studio website nidesoft.com to get more information.

Tuesday 29 November 2011

hack bt openzone

hack bt openzone

just bought a mini laptop running linux "easypeasy". When I try to get online only opens a BTopenzone page that asks me to pay to get online. Is there a hack I can use to get online without having to pay BT.

Profiling time elapse of array access using rdtscll in a kernel module

Profiling time elapse of array access using rdtscll in a kernel module

Hi,
I am trying to profile the time elapse of accessing an integer array using rdtscll.
I wrote a user-mode program and a kernel module doing the same work. The
results from rdtsc however look pretty odd.
The machine is an Intel xeon 3.1Ghz box.

The user-mode program is

Code:

unsigned long long ini, end;
int dummy;

/* Initialize a 6144KB integer array */
.. ...
gettimeofday(&start_tv, &tz);
ini = rdtsc();
for (i = 0; i < array_element; i++) { dummy = int_array[j]; }
end = rdtsc();
gettimeofday(&end_tv, &tz1);

.. ...
printf("Time elapse %llu cycles\n", end-ini);
printf("Time elapse in %lf usec\n", ....);

So I got the output of
ini: 2032056902618536, end: 2032056914493232
Time elapse 11874696 cycles
Time elapse in 3769.000000 usec
These number looks reasonable.

However, when I use the same logic in my kernel module which has the following
code

Code:

data_array = (int *)vmalloc(6144KB);
for(i = 0; i < 6144KB/sizeof(int); i++) { data_array[i] = random32() % 1000;}

rdtscll(ini);
for(i = 0; i < nr_elements; i++) {
    val = data_array[i];
}
rdtscll(end);
printk("ini: %llu, end: %llu\n", ini, end);
printk("TIme elapse %llu\n", end - ini);

The outputs are
ini: 2031745377590838, end: 2031745377591152
data array access is 314.
So it only takes about 314 CPU cycles to traverse the 6144KB size array, which
should not be correct. Assuming that in an ideal case the CPU uses 1 cycle to load
the integer from on-chip cache, and the total number of integer of 6144KB array is
1572864, which is much greater than 314. As the user-mode time elapse (11874696
cycles) looks reasonable, I am wondering is there anything wrong in my kernel
module. Any suggestion is welcome. Thanks in advance.

OpenSUSE freezes during auto-configure on first boot

OpenSUSE freezes during auto-configure on first boot

Hey,
I recently installed the latest OpenSUSE 12.1 but ran into issues upon first boot.

The system installed just fine, but upon restarting the system, it would get to about 82% over all and 23% percent through one of the configuration settings before just freezing.

The whole system would freeze, i left it for over an hour, thinking it might be just a large file, But it didn't budge after an 1hr and 30mins, also the mouse didn't move.

I find these interesting because this has happened in the previous 11.4 at exactly the same place, percentages and all. and i just couldn't be bothered to work out the problem. But i am actually interested to run OpenSUSE.

Regards
SL6-A1000

double click to select, but it selects a bit more than needed

double click to select, but it selects a bit more than needed

I think there must be an easy answer for this. I double click something, it will automatically choose regular words, as well as semicolon, etc, say, it selects aaaa:. But I just want it to select aaaa. How can I possibly achieve that? Thanks,

Song tags on iPod don't correspond to tags on PC

Song tags on iPod don't correspond to tags on PC

Hi all!

I own an iPod fifth-gen, 160 GB and I use it on linux (I used to use Ubuntu now I switched to openSuse). The problem is that there is one (and only one) track that keeps going to the top of the list in its album, i.e. it plays first, although it is track 11. I've checked in my local music folder and it is number 11 and it plays accordingly; even when I connect the iPod to the PC it plays as number 11. I've tried with Rhythmbox, gtkpod and exaile to edit this track's tag on my iPod and it reads it as track 11 but when I unplug the iPod and play that album, it keeps going to the top. Any help or suggestions? Thanks in advance!

Recent Belly Flops!

Recent Belly Flops!

There is nothing like an article that has you laughing out loud in the first two paragraphs. For LF members who are into cars:
Recent Belly Flops by Eric Peters

Intel motherboard DQ67EP and ubuntu 64-bit.

Intel motherboard DQ67EP and ubuntu 64-bit.

Anybody else use this mobo? I have that with a core i3 with 8GB of DDR3 1333 ram for a micro ITX Linux box. Any issues drivers wise?

ACL - Access Control Lists on file systems

ACL - Access Control Lists on file systems

Greetings.

I have a newbie question about ACLs. The man page on acl gives me section 5, the file format. It refers to library functions (Section 3) but there seem to be no shell-level commands for manipulating ACLs, at least not on my work computer.

My browser search has pointed me to some interesting articles on ACL across the network but that's beyond the basic information I want. I've looked into man chmod and info chmod to no avail.

So where can I find information on manipulating the ACL on a file (or directory) at the shell level? Are there even such utilities available?

Pointers anyone?

Thanks.

-- Rasputin P.

Sun Java?

Sun Java?

My bank tells me that I need to have Sun Java in order to
log into my account from Linux. I do have Java, but not the
Sun version. How do I install it, and will it overwrite the
present Java?

single clicking desktop icons in xubuntu

single clicking desktop icons in xubuntu

I've been using xubuntu for a while now and trying to figure out how to setup single clicking desktop icons. I've searched pretty extensively and have found nothing. From what I've seen its not possible. Any suggestions on this?

Xbox xebian

Xbox xebian

Hi !
I just installed Xebian 1.1.4 (its old)on my xbox.im new to linux.
There is a very old version of firefox on this distro that only can display primitive sites like google ect.
Isnt there a way to get a more updated browser on this ditribution ?

how do I turn of the motd for a user with no home directory?

how do I turn of the motd for a user with no home directory?

I'm trying to set up my computer to have a password-less account that simply prints out the date and time, and then exits:cool:. However the motd keeps getting in the way.

editing boot options

editing boot options

Hi everyone, I need some help to do something I used to know how to do but have forgotten.
I recently installed open suse on my second hard drive that also has Win8dev on it. I made sure that Grub went onto the / partition because I want to use a bootloader on my main hard drive that has osx, win7 and Ubuntu on it. Now when I installed open suse I unplugged my first hard drive just in case (as has happened to me several times) suse messes up the boot info on that drive.
Now when I use my bootloader (Chimera) to boot open suse Grub asks me to input boot options because it can't see root on hd(0,2) because it is now on hd(1,2).
I have dealt with this before, I have to type a boot option in to boot into open suse and then edit Grub to reflect the new hd number but I can't remember how I have done it in the past.
If anyone can jog my memory ( I'm getting on a bit now) I would be most grateful.
Mike

ssh putty closes automatically

ssh putty closes automatically

Hello all,

I have dedicated server on fdcservers and i logged into ssh using putty now i try to use scp command from remote server to another remote server and it downloads files correctly but after 20 to 30 minutes putty closes while downloading files automatically.

It doesnt give any message like session logout it simply closes putty.

My files are around 40 to 50 gb so i am using scp command

scp -r root at 127.0.0.1:/home/admin/www/example exampled

Can you tell me how i must tell or change settings for putty not to close automatically while downloading files ?

Please suggest me as what to be done immediately.

Thanks.

linux pam and group policy

linux pam and group policy

Is there a way to force pam to look at the group policy for log in restriction (local and remote login) on a windows 2008 AD?

I am looking at some easy way to manage login restriction on unix (rhel5.2/5.5) without having to manage every box individually.

did anyone done that?

Write to a specific memory space.

Write to a specific memory space.

Hello all. I need a simple way to write to a specific memory space (/dev/mem). In a bash script if possible. (I am using dd to read the changes) Thanks in advace.

I Surrender!

I Surrender!

There have been times during my life when Surrendering turned out to be a real blessing. Giving up on Windows, trying to manage my alcohol consumption, and trying to save failed relationships come immediately to mind as blessings . At any rate I loved reading this article today:
I Surrender Altucher Confidential

iphone 4 internet connection usb-cable instead of wifi.

iphone 4 internet connection usb-cable instead of wifi.

Hi everbody
I have iphone 4 phone and ubuntu 11.04 64x internet connected computer system. Is it possible to share this internet connection via usb-cable with iphone?
My iphone wifi connection doesnt work :(

Thanks for any help.

Want to set up Linux Server to work with Windows Workstations

Want to set up Linux Server to work with Windows Workstations

I have a client who does not want to spend the money for windows server 2008 or any of the windows server software. I need to network his computers and all of his computers are running Windows XP. My question is could I use Fedora to network his computers together and make them secure. I do not know if you can have a Linux server and interact with Windows workstations. I studied Fedora in college and have a book on it so I feel most comfortable with Fedora, but if you can suggest a better Linux system to use please let me know. Thank you Codin

DCP-7030 Brother printer under 64X ubuntu computer

DCP-7030 Brother printer under 64X ubuntu computer

Hi everyone

I have Ubuntu 64X 11.10 linux computer system with network connected Brother DCP-7030 printer (192.168.0.30). I could print simply on windows computer. I have found some documents in brother website but its not so easy to understand and apply. Could u guys explain what should i do step by step.
Thanks for your helps.



Brother Solutions Center : Brother Driver for Linux Distributions
Brother Solutions Center : Brother Driver for Linux Distributions

Wgetting

Wgetting

hey so im a new to linux i know basics and i am curious how i can run multiple wgets at once... every time i start 1 and then try to start another it just cancels the first one..

thanks

X display not coming up on boot

X display not coming up on boot

Hi all,

i am using rhel 6 beta.
now when i reboot OS i am not getting X display. but i have installed all gnome and kde packages.

i have also initdefault to 5 in /etc/inittab.

when i use! startkde or gnome-session from console. it will show me X windows i mean graphical gnome or kde screen but not on boot.

what do you think i am missing here.

i am getting blace screen with mouse cursor moving and a cursor on black screen.


and then i can switch to al+ctrl+f2 for console login. i need graphical logon

any idea?

Parkar
UAEc

recompiling ffmpeg for the .configure option

recompiling ffmpeg for the .configure option

Hello,
I need to change ffmpeg to support a library which i installed. It is normally done at the compile time during installation. is there an alternative way to do it and dynamically load the library without recompiling and building ffmpeg again?


thanks

warning: implicit declaration of function "pread"

warning: implicit declaration of function "pread"

Hi,
While compiling my C program, I am getting warning as "warning: implicit declaration of function pread". I have included unistd.h header file(which contains pread function declaration). I also tried adding macro _XOPEN_SOURCE before including unistd.h header file, as it was suggested in one of the posts, but still I am getting the same warning. I tried to find answers on google, but I was unable to resolve it.
Though I am getting correct result even with warning, I want to rectify it.
Any help is appreciated. Thanks in advance.

-Pooja.

Help for Copying directory structure recursively

Help for Copying directory structure recursively

I have a directory that contain some .csv files and also some sub directories those contained csv files. I need to copy only my folder structure with csv's inside child directory without copying perant directory csv's
(only need to exclude parent directory csv files)
I tried lot with rsync and cp but couldn't make it please help.

---Sorry for bad explanation. ;)

Partition Editor in Debian

Partition Editor in Debian

By default it should come with partition editor but i can't seem to find it.

Is partition editor inclusive within synaptic package or where could i download it individually? Btw i'm running Debian live

My first Linux Server

My first Linux Server

Hy,

sorry if i am wrong but i could not find the right forum to post.

I heared about ZFS from a friend and after much reading i think it is the right time to build my first Linux Home Server.

I planed 1 SSD for System and as cache for ZFS, 3x 2TB Sata HDD on standard Software Raid Controller. The controller is because my mainboard can not handle this Discs.

But i am a Linux newbie (just have a Centos Web Server :D) i have some questions and hope you can help me.

- I want to use ZFS -> SSD as cache or is it the same effect if have have enough ram?
- i read that if i use SSD as cache zfs can cache e.g. Videofiles and spindown the Harddrives if there are no using of this HDDs, is that right? So i can save energy.
- I want to use it as testserver for Webdevelopment and i need php, mysql and other -> apache2 install
- i need samba network share
- i read about snapshot in ZFS, how muc space is used by a snaphot? Is it like a read only copy form the HDD?
- at this time i run windows on this machine and spindown is no problem

Wich Linux can i use for this best? Is this from above possible?

If you need more info please ask. :)

Tanks for your help

Linux Webserver with ISPCP and DDOS security

Linux Webserver with ISPCP and DDOS security

Hello, its there a professional who can perfectly setup a Linux Debian Lenny server? We must have a ISPCP (because its multilanguage) and Memcached.
We finished this:
isp-control.net/documentation/start/installation

But its no here security for server for Flood or DDOS attacks.

Category: Host for TORRENT tracker sites
Sorry my English when its wrong, greetings from Hungary :)

THX for all good people

Can that long string of letters & numbers get back into an account?

Can that long string of letters & numbers get back into an account?

So this is the second time I have locked myself out of Ubuntu by forgetting the password. I changed the password, got in, but cannot access the encrypted home folder. What does that long string of letters and numbers do? Can I get into the home folder with that? I tried a few different ways, looked all over the net for answers, but can't make progress.

Also, if there is any way to display the original password, I could use that info...

Thanks.

Monday 28 November 2011

mayor repository ?

mayor repository ?

I have searched around and I am wondering where the main open source repository's are located?

For example I am using eclipse and have the cvs , svn, git , mercurial plugins downloaded and would like to work on some open source projects or at least download them thru eclipse's.

I have located and successfully downloaded the apache projects thru eclipse. Their is about 105 different projects in there repository.

I am curious where the linux kernel downloads are located?
I have downloaded the tar zip source files thru kernel.org site in the past but don't see where the repo location is so I can download it thru eclipse? ( it is obviously cleaner not having to untar and import into my project as opposed to downloading thru git , that is if I can find the repo location).

Also curious where the gnome , kde , gcc, grub , x11 , and other gnu open source source code repo's would be at? (meaning I need a repo location for these)


Essentially what all this boils down to is is their a repository naming convention or some site that list all the open source repositories because not all sites / projects are clear about where their project is (i.e repo located for it)

mayor repository ?

mayor repository ?

I have searched around and I am wondering where the main open source repository's are located?

For example I am using eclipse and have the cvs , svn, git , mercurial plugins downloaded and would like to work on some open source projects or at least download them thru eclipse's.

I have located and successfully downloaded the apache projects thru eclipse. Their is about 105 different projects in there repository.

I am curious where the linux kernel downloads are located?
I have downloaded the tar zip source files thru kernel.org site in the past but don't see where the repo location is so I can download it thru eclipse? ( it is obviously cleaner not having to untar and import into my project as opposed to downloading thru git , that is if I can find the repo location).

Also curious where the gnome , kde , gcc, grub , x11 , and other gnu open source source code repo's would be at? (meaning I need a repo location for these)


Essentially what all this boils down to is is their a repository naming convention or some site that list all the open source repositories because not all sites / projects are clear about where their project is (i.e repo located for it)

Question on Stateful Packet Inspection

Question on Stateful Packet Inspection

Hi all,

Am working on "Stateful Packet Inspection", but i donno how to proceed. Can any one give me guidence how to do it....

Thanks & Regards
Sandeep NS

How to Set, Displace and Attenuate Windows Password?

How to Set, Displace and Attenuate Windows Password?

Do you plan to amend to Windows 7 or buy a new Windows 7 computer in 2011? Here are some quick tips on how to set countersign for your Windows 7 machine, displace Windows countersign if you forgot Windows password, and attenuate Windows countersign if you ambition to skip the Windows logon awning in Windows 7.
How to set Windows password?
To actualize a Windows 7 password, it just as simple as you actualizes a Windows XP or Vista password.
Step 1. Bang "Start", "Control Panel", "User Accounts and Family Safety", "User Accounts".
Step 2. Bang "Create a password" beneath Accomplish changes to your user annual in User Annual Window.
Step 3. Input and access your Windows password.
Step 4. Access your countersign adumbration or leave it coffer and bang "Create password".
Please bethink to actualize a Windows 7 countersign displace disk, which can advice you displace Windows countersign if your countersign get forgotten.
How to displace Windows password?
When you forgot Windows password, you can use countersign displace deejay to displace Windows countersign if you accept one. Otherwise, you can resort to Windows Login Recovery, abnormally if you are bound out of computer.
Step 1. Download and install Windows Login Recovery.
Step 2. Burn a bootable CD/DVD or USB beam drive.
Step 3. BIOS settings.
Step 4. Displace Windows countersign beneath DOS.
Windows Login Accretion is a safe and reliable Windows countersign accretion apparatus which allows you to displace Windows countersign by afire a bootable CD/DVD or USB beam drive.
How to attenuate Windows password?
There are abounding means for you to attenuate Windows countersign if you are in need. Here shows how to attenuate Windows countersign by ascendancy userpasswords2.
Step 1. Bang Windows Key + R and access "control userpasswords2" in the advancing Run box.
Step 2. Press Access to pop up the archetypal User Accounts window.
Step 3. Uncheck the box in foreground of users have to access a user name and countersign to use this computer, baldest the user name and bang Apply to attenuate its password.
Step 4. Access and affirm the countersign for the called user name. Afresh bang OK button to accomplishment your operation.
Windows Countersign Tips
1. Set a able Windows countersign composed of letters, numbers and symbols and it should be 8 characters continued at least.
2. Don't accommodate claimed advice or a complete chat in your Windows countersign to in case that others calmly assumption your password.
3. Avoid accepted countersign like "123456", "password", etc. as these passwords can be calmly hacked.
4. Change or displace Windows countersign on a approved basis Article Search, like every ages or every 3 months.
5. Don't use your Windows countersign everywhere. It should be altered from added accounts.
6. Never address your Windows countersign down on addendum bashed to the computer screen.
7. Actualize a countersign displace deejay to in case you forgot Windows password.

how to repack an installed programe

how to repack an installed programe

hello *,
In fedora is it possible to get back the installed files of an application and install them on another machine. like i downloaded and installed vlc via "yum install vlc" but i want to retrieve back the installed files (rpms) for re installation because i have a very slow connection.

switching users in the terminal

switching users in the terminal

hey folks,
i would like to know how to switch between users when on the terminal. for example i can switch to root using "su" then type "password". but here i want to switch to other accounts not root and switching from root without using exit.

routing question / problem

routing question / problem

Internet Gateway
192.168.0.201

Server 1
192.168.0.101
192.168.1.101
192.168.2.101
gateway: 192.168.0.201
VIP: 192.168.1.100
VIP: 192.168.2.100

Server 2
192.168.0.102
192.168.1.102
192.168.2.102
gateway: 192.168.0.201

Client 1
192.168.2.201
gateway: 192.168.2.100

>From Client 1, I can ping 192.168.2.102 (Server 2), this would make sense all three computers are on the same network. However, from client 1, I cannot ping or ssh to 192.168.1.102 (server 2). Why? I don't know. Using wireshark, I can see the ICMP echo request go through server 1 and pass to server 2. This path makes sense. I see the echo request being recieved on the 192.168.2.102 NIC on Server 2. But no response is sent out on either NIC on Server 2. Why?

I have made no routing table modification on either server. I have IP forwarding set in sysctl.conf on both servers. I have iptables turned off. The only way I can ping from client 1 to 192.168.1.102 (server 2) is enabling masquerading in iptables on both servers on all interfaces. The question is: why can't client 1 ping to 192.168.1.102 with no modifications to any routing table and with the iptables service stopped?

MPI code urgent

MPI code urgent

I have this code for parallel implement an Apriori algorithm. This code is written in VC++. I want to change it to C code. Could you please please someone help me with this. I tried many times, and I am frustrated.

#include "stdio.h"
#include <fstream>
#include <iostream>
#include "stdlib.h"
#include "string.h"
#include <iomanip>
#include <time.h>
#include "mpi.h"

struct tItem
{
int tag;
char itemset[15];
int count;
struct tItem *next;
};

#define LEN sizeof(struct tItem);

int GetColNum(char fileName1[]); //¶ÁÈ¡Ô´Êý¾ÝµÄÁÐÊý
int GetRecordNum(char fileName2[]); //¶ÁÈ¡Ô´Êý¾ÝµÄÐÐÊý
int Index(char *List, char c, int ListLength);
void GetSourceFile(char fileName[],int recordNum,int colNum); //»ñÈ¡Ô´Êý¾Ý
void FindFrequence1itemsets(char **fullSet1,double sup);
void Gen_association_rules(tItem *kf, tItem *p, double minCon); //Éú³É¹ØÁª¹æÔò
void SetminSup(); //ÉèÖÃ×îСֵ֧³Ö¶È
void SetminCon(); //ÉèÖÃ×îСÖÃÐŶÈ
struct tItem *Find_candidate_1itemsets(char **fullSet2, double sup2,int recordNum,int colNum); //Éú³ÉƵ·±1Ï
struct tItem *apriori_gen(tItem *freq); //Éú³ÉºòÑ¡Ï
struct tItem *Gen_candidate_itemset(tItem *cp,tItem *cp1,tItem *cp2); //Éú³ÉºóÑ¡Ïî
struct tItem *Gen_frequence(tItem *frequence, int recordNum, int colNum, int minNum, char **fullSet); //Éú³ÉƵ·±Ï
struct tItem *Gen_frequence1(tItem *frequence, int recordNum, int colNum, int minNum, char **fullSet);
struct tItem *Compute_candidateItem_Num(tItem *c,int recordNum, int colNum, char **fullSet); //¼ÆËãºòÑ¡ÏÖÐÿһÏîµÄ×îС֧³ÖÊý
struct tItem *Gen_kFrequence_subsets(tItem *f); //Éú³ÉƵ·±kÏÿÏîµÄ×Ó¼¯µÄ¼¯ºÏ
struct tItem *SubSet(char *List, int m, char *Buffer, int flag, tItem *fis, int ListLength); //Éú³ÉƵ·±¼¯ÖÐÿһÏîµÄ×Ó¼¯
struct tItem *AddToSubset(char *Buffer, int flag, tItem *fis); //½«Ò»¸ö×Ó¼¯¼ÓÈëÁ´±í
struct tItem *Combine_candidate_itemsets(tItem *lc, char rItemset, int rCount); //ºÏ²¢¾Ö²¿ºòÑ¡1Ï³ÉΪ×ܵĺòÑ¡1Ï
struct tItem *Combine_candidate_k_itemsets(tItem *lc,tItem *r);
bool Has_infrequence_subset(tItem *pp, tItem *f); //ÅжϺòÑ¡kÏµÄ×Ó¼¯ÊÇ·ñÔÚƵ·±k-1ÏÖÐ
bool Is_before_equal(tItem *pp1, tItem *pp2); //ÅжÏÁ½¸öÏîÄ¿¼¯µÄÇ°k-1ÏîÊÇ·ñÏàͬ
static void masterprocess(int rankNum);
static void slaveprocess(int rankNum);

char **fullSet;
int colNum=0;
int recordNum=0;
double minSup=0.37;
double minCon=0.50;

int main(int argc,char *argv[])
{
int rank,size;

MPI_Init(&argc,&argv);
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
MPI_Comm_size(MPI_COMM_WORLD,&size);

if(rank==0)
{
//printf("#%d#\n",size);
masterprocess(size);
}
else
{
slaveprocess(size);
}

MPI_Finalize();
return(0);
}

void SetminSup()
{
cout<<"Please input the minSup: ";
cin>>minSup;
}

void SetminCon()
{
cout<<"Please input the minCon: ";
cin>>minCon;
}

int GetColNum(char fileName1[]) //¶ÁÈ¡Ô´Êý¾ÝµÄÁÐÊý
{
ifstream file(fileName1);

char ch;
//int colNum=0;
while(ch!='\n')
{
if(ch==',')
{
colNum++;
ch=file.get();
}
ch=file.get();
}
//colNum++;
file.close();
return colNum;
}


int GetRecordNum(char fileName2[]) //¶ÁÈ¡Ô´Êý¾ÝµÄÐÐÊý
{
ifstream file(fileName2);

char ch=NULL;
//int recordNum=0;

while(!file.eof())
{
if(ch=='\n')
{
recordNum++;
ch=file.get();
}
ch=file.get();
}

file.close();
return recordNum;
}

void GetSourceFile(char fileName[],int rNum,int cNum) //»ñÈ¡Ô´Êý¾Ý¶ÁÈëÊý×éfullSet[][]ÖÐ
{
ifstream file(fileName);

char ch;
//char **fullSet;
int item=0;
int i=0,j=0;
int temp1='A';
int temp2='a';

/*b=(int**)malloc(row*sizeof(int*));
for(i=0;i<row;i++)
{
b[i]=(int*)malloc(col*sizeof(int));
}*/

fullSet=(char**)malloc(rNum*sizeof(char*));
for(int m=0;m<rNum;m++)
{
fullSet[m]=(char*)malloc(cNum*sizeof(char));
}

while(i<rNum)
{
while(j<colNum)
{
if(ch==',')
{
item++;
ch=file.get();
if(ch=='T')
{
fullSet[i][j]=(char)(item+temp1);
//printf("%c",fullSet[i][j]);
}
if(ch=='F')
{
fullSet[i][j]=(char)(item+temp2);
//printf("%c",fullSet[i][j]);
}
j++;
}
ch=file.get();
}
//printf("\n");
j=0;
ch=file.get();
item=0;
i++;
}
file.close();
}

static void masterprocess(int rankNum)
{

char inputFileName[]="c:\\shujuku.txt";
char *buffer;
int colNum,recordNum,blockNum,bound,i,j,m,k;
int rank,destRank,tag;
double starttime,endtime;

MPI_Status status;
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
starttime=MPI_Wtime();

//SetminSup();
//SetminCon();

//printf("#%d#\n",rankNum);

colNum=GetColNum(inputFileName);
recordNum=GetRecordNum(inputFileName);

//system("pause");
printf("recordNum= %d", recordNum);
printf("\n");
printf("colNum= %d",colNum);
printf("\n");

GetSourceFile(inputFileName,recordNum,colNum);

//system("pause");

/*for(i=0;i<recordNum;i++)
{
for(j=0;j<colNum;j++)
{
printf(" %c ",fullSet[i][j]);
}
printf("\n");
}*/

blockNum=recordNum/(rankNum-1);
bound=blockNum*(rankNum-1);
//printf("%d\n",blockNum);

m=0;
k=1;
destRank=1;
tag=1;
buffer=(char*)malloc(colNum*sizeof(char*));
while(m!=recordNum)
{
if(m==(k*blockNum-1)&&(m!=bound-1))
{
MPI_Send(&colNum,1,MPI_INT,destRank,100,MPI_COMM_W ORLD);
MPI_Send(&recordNum,1,MPI_INT,destRank,101,MPI_COM M_WORLD);
MPI_Send(&blockNum,1,MPI_INT,destRank,tag,MPI_COMM _WORLD);
//printf("%d\n",blockNum);
for(i=((k-1)*blockNum);i<k*blockNum;i++)
{
for(j=0;j<colNum;j++)
{
buffer[j]=fullSet[i][j];
printf("%c ",buffer[j]);
}
MPI_Send(buffer,colNum,MPI_CHAR,destRank,tag,MPI_C OMM_WORLD);
printf("\n");
}
printf("\n");
destRank++;
tag++;
k++;
}
else if(m==bound-1)
{
blockNum=recordNum-m-1+blockNum;
MPI_Send(&colNum,1,MPI_INT,destRank,100,MPI_COMM_W ORLD);
MPI_Send(&recordNum,1,MPI_INT,destRank,101,MPI_COM M_WORLD);
MPI_Send(&blockNum,1,MPI_INT,destRank,tag,MPI_COMM _WORLD);
//MPI_Send(&flag,1,MPI_INT,destRank,102,MPI_COMM_WOR LD);
//printf("%d\n",blockNum);
for(i=bound-blockNum;i<recordNum;i++)
{
for(j=0;j<colNum;j++)
{
buffer[j]=fullSet[i][j];
printf("%c ",buffer[j]);
}
MPI_Send(buffer,colNum,MPI_CHAR,destRank,tag,MPI_C OMM_WORLD);
printf("\n");
}
printf("\n");
}

m++;
}


/*int s,rItemNum;
tItem *r;
r=(struct tItem*)malloc(sizeof(struct tItem));

s=0;
MPI_Recv(&rItemNum,1,MPI_INT,1,1000,MPI_COMM_WORLD ,&status);
while(s<rItemNum)
{
for(j=0;j<=5;j++)
{
MPI_Recv(&r->itemset[j],1,MPI_CHAR,1,1001,MPI_COMM_WORLD,&status);
}
MPI_Recv(&r->count,1,MPI_INT,1,1002,MPI_COMM_WORLD,&status);
MPI_Recv(&r->tag,1,MPI_INT,0,1003,MPI_COMM_WORLD,&status);
s++;
}*/

endtime=MPI_Wtime();
printf("The master process tooks %f seconds.\n",endtime-starttime);
printf("\n");
}

static void slaveprocess(int rankNum)
{

int rowNum,recordNum,colNum,tag,stag,rank,destRank,m,i ,j;
char **fSet,*buffer;
double minSup=0.45;
double minCon=0.50;
double starttime,endtime;

MPI_Status status;
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
starttime=MPI_Wtime();

MPI_Recv(&colNum,1,MPI_INT,0,100,MPI_COMM_WORLD,&s tatus);
MPI_Recv(&recordNum,1,MPI_INT,0,101,MPI_COMM_WORLD ,&status);
//printf("%d\n",recordNum);
//printf("%d\n",colNum);

tag=rank;
MPI_Recv(&rowNum,1,MPI_INT,0,tag,MPI_COMM_WORLD,&s tatus);
printf("\n");
printf("\n");
printf("The block in rank %d has %d records.\n",rank,rowNum);
//MPI_Recv(&flag,1,MPI_INT,0,102,MPI_COMM_WORLD,&sta tus);

buffer=(char*)malloc(colNum*sizeof(char*));
fSet=(char**)malloc(rowNum*sizeof(char*));
for(m=0;m<rowNum;m++)
{
fSet[m]=(char*)malloc(colNum*sizeof(char));
}

//½ÓÊÕ½ø³Ì0·¢ËÍÀ´µÄ³õʼ¾ØÕóµÄÒ»¿é
for(i=0;i<rowNum;i++)
{
MPI_Recv(buffer,colNum,MPI_CHAR,0,tag,MPI_COMM_WOR LD,&status);
for(j=0;j<colNum;j++)
{
fSet[i][j]=buffer[j];
}
}

printf("\n");
printf("Rank %d receives part of the matrix is as follow:\n",rank);
printf("\n");
for(i=0;i<rowNum;i++)
{
for(j=0;j<colNum;j++)
{
printf("%c ",fSet[i][j]);
}
printf("\n");
}
printf("\n");

tItem *c; //¶¨Òå¾Ö²¿ºòÑ¡Ï
tItem *cr; //½ÓÊÕÆäËû½ø³Ì·¢ËÍÀ´µÄ¾Ö²¿ºòÑ¡¼¯
tItem *p;
int count=0,s,rCount,rTag;
char rItemset;


c=(struct tItem*)malloc(sizeof(struct tItem));
c=Find_candidate_1itemsets(fSet,minSup,rowNum,colN um);

destRank=1;
stag=1;

p=c;
while(p!=NULL)
{
count++;
p=p->next;
}

for(i=1;i<=rankNum-1;i++) //ÏòÆäËû½ø³Ì·¢Ë;ֲ¿ºòÑ¡1Ï
{
p=c;
if(i!=rank)
{
MPI_Send(&count,1,MPI_INT,destRank,14,MPI_COMM_WOR LD);
while(p!=NULL)
{
MPI_Send(&p->itemset[p->tag],1,MPI_CHAR,destRank,15,MPI_COMM_WORLD);
MPI_Send(&p->count,1,MPI_INT,destRank,16,MPI_COMM_WORLD);
MPI_Send(&p->tag,1,MPI_INT,destRank,17,MPI_COMM_WORLD);
p=p->next;
}
}
destRank++;
stag++;
}

int reRank=1,reTag=1,itemNum;
for(j=1;j<=rankNum-1;j++) //½ÓÊÕÆäËû½ø³Ì·¢ËÍÀ´µÄ¾Ö²¿ºòÑ¡1Ï
{
if(j!=rank)
{
s=0;
MPI_Recv(&itemNum,1,MPI_INT,reRank,14,MPI_COMM_WOR LD,&status);
while(s<itemNum)
{
MPI_Recv(&rItemset,1,MPI_CHAR,reRank,15,MPI_COMM_W ORLD,&status);
MPI_Recv(&rCount,1,MPI_INT,reRank,16,MPI_COMM_WORL D,&status);
MPI_Recv(&rTag,1,MPI_INT,reRank,17,MPI_COMM_WORLD, &status);

c=Combine_candidate_itemsets(c,rItemset,rCount);

//printf(" %c",rItemset);
//printf(" %d",rCount);
//printf(" %d",rTag);
//printf("\n");
s++;
}
printf("\n");
}
reRank++;
reTag++;
}

//Êä³öºÏ²¢ºóµÃµ½µÄÈ«²¿ºòÑ¡1Ï
p=c;
printf("Now every rank get the whole candidate itemsets as follow:\n\n");
while(p!=NULL)
{
printf(" %c",p->itemset[p->tag]);
printf(" %d",p->count);
printf(" %d",p->tag);
printf("\n");
p=p->next;
}

//ÓɺòÑ¡1ÏÉú³ÉƵ·±1Ï
tItem *pp,*fHead,*fp,*temp;
int minNum;

fp=fHead=(struct tItem*)malloc(sizeof(struct tItem));
minNum=(int)((recordNum*minSup)+1);
//printf("%d",minNum);
pp=c;

while(pp!=NULL)
{
if(pp->count>minNum)
{
fHead->count=pp->count;
fHead->tag=pp->tag;
fHead->itemset[fHead->tag]=pp->itemset[pp->tag];
fHead->next=NULL;
break;
}
pp=pp->next;
}

fp=fHead;
pp=pp->next;

while(pp!=NULL)
{
if(pp->count>minNum)
{
temp=(struct tItem*)malloc(sizeof(struct tItem));
temp->count=pp->count;
temp->next=NULL;
temp->tag=pp->tag;
temp->itemset[temp->tag]=pp->itemset[pp->tag];
fp->next=temp;
fp=temp;
//printf("%c",pp->itemset[pp->tag]);
}
pp=pp->next;
}

/*printf("\n");
printf("--------The local frequence 1_itemsets--------\n");
fp=fHead;
while(fp!=NULL)
{
printf(" %c",fp->itemset[fp->tag]);
printf(" %d",fp->count);
printf(" %d",fp->tag);
printf("\n");
fp=fp->next;
}*/

tItem *f1,*kFrequence,*kf,*fis,*kfTemp;

//kFrequence=(struct tItem*)malloc(sizeof(struct tItem));
f1=(struct tItem*)malloc(sizeof(struct tItem));
//f1=Find_frequence_1itemsets(fullSet,minSup);

f1=fHead;

//system("pause");
//printf(" %d",rowNum);
//printf(" %d*&*&*&\n",colNum);
kFrequence=Gen_frequence(f1,rowNum,colNum,minNum,f Set);//¾*¹ýÁ¬½ÓºÍ¼ôÖ¦Éú³É×îÖÕµÄƵ·±kÏ

i=2;
while(i<=5)
{
kfTemp=Gen_frequence(kFrequence,rowNum,colNum,minN um,fSet);
if(kfTemp==NULL)
{
break;
}
kFrequence=kfTemp;
i++;
}
//MPI_Barrier(MPI_COMM_WORLD);
/*printf("^^^^^^^^^^^^^^^\n");
kf=kFrequence;
while(kf!=NULL)
{
for(j=0;j<=kf->tag;j++)
{
printf(" %c",kf->itemset[j]);
}
printf(" %d",kf->count);
printf(" %d",kf->tag);
printf("\n");
kf=kf->next;
}
printf("^^^^^^^^^^^^^^^\n");*/


printf("\n");
kf=kFrequence;
printf("--------The frequence %d_itemsets--------\n",kf->tag+1);
while(kf!=NULL)
{
for(j=0;j<=kf->tag;j++)
{
printf(" %c",kf->itemset[j]);
}
printf(" %d",kf->count);
printf(" %d",kf->tag);
printf("\n");
kf=kf->next;
}
printf("\n");

/*kf=kFrequence;
int kItemNum=0;
while(kf!=NULL)
{
kItemNum++;
kf=kf->next;
}

kf=kFrequence;
if(rank==1)
{
MPI_Send(&kItemNum,1,MPI_INT,0,1000,MPI_COMM_WORLD );
while(kf!=NULL)
{
for(j=0;j<=kf->tag;j++)
{
MPI_Send(&kf->itemset[j],1,MPI_CHAR,0,1001,MPI_COMM_WORLD);
}
MPI_Send(&kf->count,1,MPI_INT,0,1002,MPI_COMM_WORLD);
MPI_Send(&kf->tag,1,MPI_INT,0,1003,MPI_COMM_WORLD);
kf=kf->next;
}
}*/

kf=kFrequence;
printf("\n\nThe subset of the frequence is:\n\n");
while(kf!=NULL)
{

fis=Gen_kFrequence_subsets(kf); //Éú³ÉƵ·±kÏÿÏîµÄ×Ó¼¯µÄ¼¯ºÏ
fis=Compute_candidateItem_Num(fis,rowNum,colNum,fS et); //¼ÆËãÿһ¸ö×Ó¼¯µÄÖ§³Ö¶È

/*p=fis;
p=p->next;
while(p!=NULL)
{
for(i=0;i<=p->tag;i++)
{
printf(" %c",p->itemset[i]);
}
printf(" %d",p->count);
printf(" %d",p->tag);
printf("\n");
p=p->next;
}*/

printf("\n\nNow we get the association rules:\n\n");
p=fis;
p=p->next;
while(p!=NULL)
{
//printf("\n");
Gen_association_rules(kf,p,minCon);
printf("\n");
p=p->next;
}

kf=kf->next;
}
endtime=MPI_Wtime();
printf("The slave process %d tooks %f seconds.\n",rank,endtime-starttime);
printf("\n");

}

struct tItem *Gen_frequence(tItem *frequence, int recordNum, int colNum, int minNum, char **fullSet) //Éú³ÉƵ·±Ï
{

tItem *candidate,*cp,*fp,*fpb,*p,*p1;
int i,j,k,m,count=0,rank,rankNum,destRank,stag;
//int i,m,n;
//char *buffer;
MPI_Status status;
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
MPI_Comm_size(MPI_COMM_WORLD,&rankNum);

/*printf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");
printf("##### %d\n",recordNum);
printf("##### %d\n",colNum);
printf("##### %d\n",minNum);
for(i=0;i<recordNum;i++)
{
for(j=0;j<colNum;j++)
{
printf(" %c",fullSet[i][j]);
}
printf("\n");
}
p=(struct tItem*)malloc(sizeof(struct tItem));
p=frequence;
while(p!=NULL)
{
printf(" %c",p->itemset[p->tag]);
printf(" %d",p->count);
printf(" %d",p->tag);
printf("\n");
p=p->next;
}
printf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");*/


//for(k=2;frequence!=NULL;k++)
//while(candidate!=NULL)
//{
//printf("++++++++++++++++++++++++++++++++++++++++++ ++\n");

candidate=apriori_gen(frequence);

if(candidate!=NULL)
{
candidate=Compute_candidateItem_Num(candidate,reco rdNum,colNum,fullSet);

destRank=1;
stag=1;

p=candidate;
p1=candidate;
while(p!=NULL)
{
count++;
p=p->next;
}
//printf(" #%d#\n",count);

//MPI_Barrier(MPI_COMM_WORLD);

for(i=1;i<=rankNum-1;i++) //ÏòÆäËû½ø³Ì·¢Ë;ֲ¿ºòÑ¡kÏ
{
p=candidate;
if(i!=rank)
{
MPI_Send(&count,1,MPI_INT,destRank,24,MPI_COMM_WOR LD);
while(p!=NULL)
{
for(j=0;j<=p->tag;j++)
{
MPI_Send(&p->itemset[j],1,MPI_CHAR,destRank,25,MPI_COMM_WORLD);
}

MPI_Send(&p->count,1,MPI_INT,destRank,26,MPI_COMM_WORLD);
MPI_Send(&p->tag,1,MPI_INT,destRank,27,MPI_COMM_WORLD);
p=p->next;
}
}
destRank++;
stag++;
}

//MPI_Barrier(MPI_COMM_WORLD);

int reRank=1,reTag=1,itemNum;
int rCount,rTag,s;
char rItemset;
tItem *r;
r=(struct tItem*)malloc(sizeof(struct tItem));
for(j=1;j<=rankNum-1;j++) //½ÓÊÕÆäËû½ø³Ì·¢ËÍÀ´µÄ¾Ö²¿ºòÑ¡kÏ
{
if(j!=rank)
{
s=0;
MPI_Recv(&itemNum,1,MPI_INT,reRank,24,MPI_COMM_WOR LD,&status);
while(s<itemNum)
{
for(m=0;m<=p1->tag;m++)
{
MPI_Recv(&r->itemset[m],1,MPI_CHAR,reRank,25,MPI_COMM_WORLD,&status);
//printf(" %c",r->itemset[m]);
}

MPI_Recv(&r->count,1,MPI_INT,reRank,26,MPI_COMM_WORLD,&status) ;
MPI_Recv(&r->tag,1,MPI_INT,reRank,27,MPI_COMM_WORLD,&status) ;


candidate=Combine_candidate_k_itemsets(candidate,r );

//printf(" %c",rItemset);
//printf(" %d",r->count);
//printf(" %d",r->tag);
//printf("\n");
s++;
}
//printf("\n");
//printf("&&&&&&&&&&&&&&&&&&&&&\n");
}
reRank++;
reTag++;
}

//MPI_Barrier(MPI_COMM_WORLD);

/*cp=candidate;
count=0;
printf("--------The candidate %d_itemsets--------\n",cp->tag+1);
while(cp!=NULL)
{
for(j=0;j<=cp->tag;j++)
{
printf(" %c",cp->itemset[j]);
}
printf(" %d",cp->count);
printf(" %d",cp->tag);
printf("\n");
count++;
cp=cp->next;
}
printf("\n");
printf("The total number is: %d\n",count);
printf("\n");*/

//MPI_Barrier(MPI_COMM_WORLD);

frequence=candidate;
fpb=(struct tItem*)malloc(sizeof(struct tItem));
fp=(struct tItem*)malloc(sizeof(struct tItem));
fpb=frequence;
fp=fpb->next;
//int minNum=(int)((recordNum*minSup)+1);
//printf("########## %d\n",minNum);

while(fp!=NULL) //ɾ³ýºóÑ¡ÏÖÐÖ§³Ö¶ÈСÓÚ×îС֧³Ö¶ÈµÄÏîÄ¿£¬Éú³ÉƵ·± Ï
{

if(fpb->count<minNum)
{
frequence=fp;
fpb=fp;
fp=fp->next;
}


if(fp->count<minNum)
{
fp=fp->next;
fpb->next=fp;
}
else
{
fp=fp->next;
fpb=fpb->next;

}
}

/*fp=frequence;
count=0;
printf("--------The frequence %d_itemsets--------\n",fp->tag+1);
while(fp!=NULL)
{
//MPI_Barrier(MPI_COMM_WORLD);
for(j=0;j<=fp->tag;j++)
{
printf(" %c",fp->itemset[j]);
}
printf(" %d",fp->count);
printf(" %d",fp->tag);
printf("\n");
count++;
fp=fp->next;
}

printf("\n");
printf("The total number is: %d\n",count);
printf("\n");*/

//MPI_Barrier(MPI_COMM_WORLD);
}
else
{
//return (NULL);
//break;
frequence=NULL;
}
//printf("++++++++++++++++++++++++++++++++++++++++++ ++\n");
//MPI_Barrier(MPI_COMM_WORLD);
//}

return (frequence);

}

struct tItem *Gen_frequence1(tItem *frequence, int recordNum, int colNum, int minNum, char **fullSet) //Éú³ÉƵ·±Ï
{

tItem *candidate,*cp,*fp,*fpb,*p,*p1;
int i,j,k,m,count=0,rank,rankNum,destRank,stag;
//int i,m,n;
//char *buffer;
MPI_Status status;
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
MPI_Comm_size(MPI_COMM_WORLD,&rankNum);

//printf("****************************************** *\n");

/*printf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");
printf("##### %d\n",recordNum);
printf("##### %d\n",colNum);
printf("##### %d\n",minNum);
printf("##### %d\n",rank);
for(i=0;i<recordNum;i++)
{
for(j=0;j<colNum;j++)
{
printf(" %c",fullSet[i][j]);
}
printf("\n");
}
p=(struct tItem*)malloc(sizeof(struct tItem));
p=frequence;
while(p!=NULL)
{
for(j=0;j<=p->tag;j++)
{
printf(" %c",p->itemset[j]);
}
printf(" %d",p->count);
printf(" %d",p->tag);
printf("\n");
p=p->next;
}
printf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");*/

//for(k=2;frequence!=NULL;k++)
//while(candidate!=NULL)
//{
printf("++++++++++++++++++++++++++++++++++++++++++ ++\n");

candidate=apriori_gen(frequence);

/*p=candidate;
int t=0;
printf("²âÊÔ½á¹û\n");
while(p!=NULL)
{
for(j=0;j<=p->tag;j++)
{
printf(" %c",p->itemset[j]);
}
printf(" %d",p->count);
printf(" %d",p->tag);
printf("\n");
t++;
p=p->next;
}
printf("Ò»¹²ÓÐ %d\n",t);
printf("½áÊø²âÊÔ\n");*/


/*if(rank==2)
{
printf("!!!!!!\n");
p=candidate;
while(p!=NULL)
{
for(j=0;j<=p->tag;j++)
{
printf(" %c",p->itemset[j]);
}
printf(" %d",p->count);
printf(" %d",p->tag);
printf("\n");
p=p->next;
}
}

printf("!!!!!!\n");*/


if(candidate!=NULL)
{
//printf("!!!!!!\n");
candidate=Compute_candidateItem_Num(candidate,reco rdNum,colNum,fullSet);

destRank=1;
stag=1;

p=candidate;
p1=candidate;
while(p!=NULL)
{
count++;
p=p->next;
}
//printf(" #%d#\n",count);
//printf("½øÐе½ÕâÀï\n");

//MPI_Barrier(MPI_COMM_WORLD);

for(i=1;i<=rankNum-1;i++) //ÏòÆäËû½ø³Ì·¢Ë;ֲ¿ºòÑ¡kÏ
{
p=candidate;
if(i!=rank)
{
MPI_Send(&count,1,MPI_INT,destRank,54,MPI_COMM_WOR LD);
//printf("### %d ###\n",count);
while(p!=NULL)
{
for(j=0;j<=p->tag;j++)
{
MPI_Send(&p->itemset[j],1,MPI_CHAR,destRank,55,MPI_COMM_WORLD);
//printf(" %c",p->itemset[j]);
}

MPI_Send(&p->count,1,MPI_INT,destRank,56,MPI_COMM_WORLD);
MPI_Send(&p->tag,1,MPI_INT,destRank,57,MPI_COMM_WORLD);
//printf(" %d",p->count);
//printf(" %d",p->tag);
//printf("\n");
p=p->next;
}
}
destRank++;
stag++;
}

//MPI_Barrier(MPI_COMM_WORLD);

int reRank=1,reTag=1,itemNum;
int rCount,rTag,s;
char rItemset;
tItem *r;
r=(struct tItem*)malloc(sizeof(struct tItem));
for(j=1;j<=rankNum-1;j++) //½ÓÊÕÆäËû½ø³Ì·¢ËÍÀ´µÄ¾Ö²¿ºòÑ¡kÏ
{
if(j!=rank)
{
s=0;
MPI_Recv(&itemNum,1,MPI_INT,reRank,54,MPI_COMM_WOR LD,&status);
while(s<itemNum)
{
for(m=0;m<=p1->tag;m++)
{
MPI_Recv(&r->itemset[m],1,MPI_CHAR,reRank,55,MPI_COMM_WORLD,&status);
//printf(" %c",r->itemset[m]);
}

MPI_Recv(&r->count,1,MPI_INT,reRank,56,MPI_COMM_WORLD,&status) ;
MPI_Recv(&r->tag,1,MPI_INT,reRank,57,MPI_COMM_WORLD,&status) ;


candidate=Combine_candidate_k_itemsets(candidate,r );

//printf(" %c",rItemset);
//printf(" %d",r->count);
//printf(" %d",r->tag);
//printf("\n");
s++;
}
//printf("\n");
printf("&&&&&&&&&&&&&&&&&&&&&\n");
}
reRank++;
reTag++;
}

//MPI_Barrier(MPI_COMM_WORLD);

cp=candidate;
count=0;
printf("--------The candidate %d_itemsets--------\n",cp->tag+1);
while(cp!=NULL)
{
for(j=0;j<=cp->tag;j++)
{
printf(" %c",cp->itemset[j]);
}
printf(" %d",cp->count);
printf(" %d",cp->tag);
printf("\n");
count++;
cp=cp->next;
}
printf("\n");
printf("The total number is: %d\n",count);
printf("\n");

//MPI_Barrier(MPI_COMM_WORLD);

frequence=candidate;
fpb=(struct tItem*)malloc(sizeof(struct tItem));
fp=(struct tItem*)malloc(sizeof(struct tItem));
fpb=frequence;
fp=fpb->next;
//int minNum=(int)((recordNum*minSup)+1);
//printf("########## %d\n",minNum);

while(fp!=NULL) //ɾ³ýºóÑ¡ÏÖÐÖ§³Ö¶ÈСÓÚ×îС֧³Ö¶ÈµÄÏîÄ¿£¬Éú³ÉƵ·± Ï
{

if(fpb->count<minNum)
{
frequence=fp;
fpb=fp;
fp=fp->next;
}


if(fp->count<minNum)
{
fp=fp->next;
fpb->next=fp;
}
else
{
fp=fp->next;
fpb=fpb->next;

}
}

fp=frequence;
count=0;
printf("--------The frequence %d_itemsets--------\n",fp->tag+1);
while(fp!=NULL)
{
//MPI_Barrier(MPI_COMM_WORLD);
for(j=0;j<=fp->tag;j++)
{
printf(" %c",fp->itemset[j]);
}
printf(" %d",fp->count);
printf(" %d",fp->tag);
printf("\n");
count++;
fp=fp->next;
}

printf("\n");
printf("The total number is: %d\n",count);
printf("\n");

//MPI_Barrier(MPI_COMM_WORLD);
}
else
{
//return (NULL);
//break;
//frequence=NULL;
}
//printf("++++++++++++++++++++++++++++++++++++++++++ ++\n");
//MPI_Barrier(MPI_COMM_WORLD);
//}

return (frequence);

}

bool Has_infrequence_subset(tItem *pp, tItem *f) //ÅжϺòÑ¡kÏµÄ×Ó¼¯ÊÇ·ñÔÚƵ·±k-1ÏÖÐ
{
tItem *p,*fp; //´¢´æ*ppÖеÄk-1Ïî×Ó¼¯
int i=0,j,m=0;
bool flag;

while(i<=pp->tag)
{

p=(struct tItem*)malloc(sizeof(struct tItem));

for(j=0;j<pp->tag;j++)
{
if(j==i)
{
j++;
}
else
{
p->itemset[j]=pp->itemset[j];
}
}

fp=f;
while(fp!=NULL)
{
while(m<=fp->tag)
{
if(p->itemset[m]==fp->itemset[m])
{
m++;
}
else
{
flag=false;
m++;
}
}

flag=true;
fp=fp->next;
}

i++;
}


return (flag);
}

struct tItem *Gen_candidate_itemset(tItem *cp,tItem *cp1,tItem *cp2) //Éú³ÉºóÑ¡Ïî
{
int i=0;

while(i<=cp1->tag)
{
cp->itemset[i]=cp1->itemset[i];
//cp->tag=cp1->tag+1;
i++;
}

cp->tag=cp1->tag+1;
cp->itemset[i]=cp2->itemset[i-1];
cp->count=0;
cp->next=NULL;

return (cp);
}

bool Is_before_equal(tItem *pp1, tItem *pp2) //ÅжÏÁ½¸öÏîÄ¿¼¯µÄÇ°k-1ÏîÊÇ·ñÏàͬ
{
int i=0;
bool flag;

while(i<pp1->tag)
{
if(pp1->itemset[i]==pp2->itemset[i])
{
flag=true;
}
else
{
flag=false;
break;
}
i++;
}

return (flag);
}

struct tItem *Compute_candidateItem_Num(tItem *c,int recordNum, int colNum, char **fullSet) //¼ÆËãºòÑ¡ÏÖÐÿһÏîµÄ×îС֧³ÖÊý
{
tItem *cp;
int i,j,m,n;
char *buffer;

cp=c;

while(cp!=NULL) //ͳ¼Æÿ¸öºòÑ¡ÏµÄ¼ÆÊý
{
for(i=0;i<recordNum;i++)
{

bool flag=true;
buffer=(char*)malloc(colNum*sizeof(char*));

for(j=0;j<colNum;j++)
{
buffer[j]=fullSet[i][j];
}

m=0;
while(m<=cp->tag)
{
bool flag1=false;
for(n=0;n<colNum;n++)
{
if(cp->itemset[m]==buffer[n])
{
flag1=true;
break;
}

flag1=false;
}

if(flag1==false)
{
flag=false;
}
m++;
}

if(flag==true)
{
cp->count++;
}
}

cp=cp->next;
}

return (c);
}

struct tItem *apriori_gen(tItem *freq) //Éú³ÉºòÑ¡Ï
{
tItem *p1,*p2,*head,*cHead,*p,*pTail;
int tag,i=0;
//bool flag;

if(freq->next!=NULL)
{

head=freq;
p1=head;
p2=head;
p2=p2->next;

p=(struct tItem*)malloc(sizeof(struct tItem));
tag=p1->tag+1;

if(tag==1)//Éú³ÉºòÑ¡2Ï
{
//printf("############\n");
while(i<=tag)
{
if(i<=tag-1)
{
//p->count=p1->count;
p->itemset[i]=p1->itemset[i];
p->tag=tag;
}
else
{
//p->count=p2->count;
p->itemset[i]=p2->itemset[i-1];
p->tag=tag;
}
i++;
}
p->count=0;
p->next=NULL;

/*printf(" %c",p->itemset[0]);
printf(" %c",p->itemset[1]);
printf(" %d",p->tag);*/

pTail=p;
cHead=p;
p2=p2->next;
//printf("#%c#",p1->itemset[p1->tag]);

while(p1!=NULL)
{
while(p2!=NULL)
{
p=(struct tItem*)malloc(sizeof(struct tItem));
tag=p1->tag+1;
i=0;

while(i<=tag)
{
if(i<=tag-1)
{
//p->count=p1->count;
p->itemset[i]=p1->itemset[i];
//printf("%c",p->itemset[i]);
p->tag=tag;
}
else
{
//p->count=p2->count;
p->itemset[i]=p2->itemset[i-1];
//printf("%c",p->itemset[i]);
p->tag=tag;
}
i++;
}
p->count=0;
p->next=NULL;

//flag=Has_infrequence_subset(cHead,freq);

//if(flag==true)
//{
pTail->next=p;
pTail=p;
//}
p2=p2->next;
}

p1=p1->next;
p2=p1->next;

if(p2==NULL)
{
break;
}
}
}
/*else if(p1->tag==3)
{
if(Is_before_equal(p1,p2))
{
//printf("½øÐе½ÕâÀï\n");
//p=(struct tItem*)malloc(sizeof(struct tItem));
//cHead=(struct tItem*)malloc(sizeof(struct tItem));
//pTail=(struct tItem*)malloc(sizeof(struct tItem));

p=Gen_candidate_itemset(p,p1,p2);
pTail=p;
cHead=p;
p2=p2->next;


while((p1!=NULL)&&(p2!=NULL))
{
//while(Is_before_equal(p1,p2))
while(p2!=NULL)
{
if(Is_before_equal(p1,p2))
{
p=(struct tItem*)malloc(sizeof(struct tItem));
tag=p1->tag+1;

p=Gen_candidate_itemset(p,p1,p2);

if(Has_infrequence_subset(p, freq))
{
pTail->next=p;
pTail=p;
}
}
//printf("½øÐе½ÕâÀï\n");
p2=p2->next;

}

p1=p1->next;
p2=p1->next;
}
}
//printf("½øÐе½ÕâÀï\n");
}*/
else//Éú³ÉºîÑ¡2ÏÒÔÉϵĺòÑ¡¼¯(±ê¼ÇcHeadʱºòÓÐÎÊÌâ)
{

/*while(p2!=NULL)
{
if(Is_before_equal(p1,p2))
{
break;
}
p2=p2->next;
}*/

if(Is_before_equal(p1,p2))
{
//p=(struct tItem*)malloc(sizeof(struct tItem));
//cHead=(struct tItem*)malloc(sizeof(struct tItem));
//pTail=(struct tItem*)malloc(sizeof(struct tItem));

p=Gen_candidate_itemset(p,p1,p2);
pTail=p;
cHead=p;
p2=p2->next;


while((p1!=NULL)&&(p2!=NULL))
{
//while(Is_before_equal(p1,p2))
while(p2!=NULL)
{
if(Is_before_equal(p1,p2))
{
p=(struct tItem*)malloc(sizeof(struct tItem));
tag=p1->tag+1;

p=Gen_candidate_itemset(p,p1,p2);

if(Has_infrequence_subset(p, freq))
{
pTail->next=p;
pTail=p;
}
}

p2=p2->next;

}

p1=p1->next;
p2=p1->next;
}
}
else
{
p1=p1->next;
p2=p2->next;
p=Gen_candidate_itemset(p,p1,p2);
pTail=p;
cHead=p;
p2=p2->next;


while((p1!=NULL)&&(p2!=NULL))
{
while(Is_before_equal(p1,p2))
{
p=(struct tItem*)malloc(sizeof(struct tItem));
tag=p1->tag+1;

p=Gen_candidate_itemset(p,p1,p2);

if(Has_infrequence_subset(p, freq))
{
pTail->next=p;
pTail=p;
}

p2=p2->next;

}

p1=p1->next;
p2=p1->next;
}
//cHead=NULL;
}
}
}
else
{
cHead=NULL;
}
/*tItem *pp;
int j,count=0;

pp=cHead;
printf("--------The candidate %d_itemsets--------\n",pp->tag+1);
while(pp!=NULL)
{
for(j=0;j<=tag;j++)
{
printf(" %c",pp->itemset[j]);
}
printf(" %d",pp->count);
printf(" %d",pp->tag);
printf("\n");
count++;
pp=pp->next;
}
printf("\n");
printf("The total number is: %d\n",count);
printf("\n");*/

return (cHead);
}

struct tItem *Combine_candidate_k_itemsets(tItem *lc,tItem *r)
{
tItem *p;
int i,j;
bool flag,flagj;

//printf("**************************\n");
p=lc;
while(p!=NULL)
{
//flag=true;
for(i=0;i<=r->tag;i++)
{
flagj=false;
for(j=0;j<=p->tag;j++)
{
if(p->itemset[j]==r->itemset[i])
{
flagj=true;
break;
}
}
if(flagj==false)
{
flag=false;
break;
}
else
{
flag=true;
}
}
if(flag==true)
{
p->count=p->count+r->count;
break;
}
p=p->next;
}

return (lc);
}

struct tItem *Combine_candidate_itemsets(tItem *lc, char rItemset, int rCount)
{
tItem *p;

p=lc;
while(p!=NULL)
{
if(p->itemset[p->tag]==rItemset)
{
p->count=p->count+rCount;
}
p=p->next;
}

return (lc);
}

struct tItem *Find_candidate_1itemsets(char **fullSet2, double sup2,int recordNum,int colNum) //Éú³ÉƵ·±1Ï
{
tItem *cHead,*fHead;
tItem *p1,*pHead,*pTail,*p;
tItem *fp,*temp,*pp;
fp=fHead=(struct tItem*)malloc(sizeof(struct tItem));

int i,j,count=0;
bool flag;

p=pHead=pTail=(struct tItem*)malloc(sizeof(struct tItem));
cHead=NULL;
pHead->tag=0;
pHead->itemset[pHead->tag]=fullSet2[0][0];
pHead->count=0;
pHead->next=NULL;


int minNum=(int)((recordNum*sup2)+1);
//printf("%d",minNum);

cHead=pHead;
for(i=0;i<recordNum;i++)
{
for(j=0;j<colNum;j++)
{
p=cHead;
while(p!=NULL)
{
if(p->itemset[p->tag]==fullSet2[i][j])
{
p->count++;
flag=false;
break;
}
else
{
pTail=p;
p=p->next;
flag=true;
}
}
if(flag==true)
{
p1=(struct tItem*)malloc(sizeof(struct tItem));
p1->tag=0;
p1->itemset[p1->tag]=fullSet2[i][j];
p1->count=1;
pTail->next=p1;
p1->next=NULL;
}
}
}

printf("\n");
printf("--------The local candidate 1_itemsets--------\n");
p=cHead;
while(p!=NULL)
{
count++;
printf(" %c",p->itemset[p->tag]);
printf(" %d",p->count);
printf(" %d",p->tag);
printf("\n");
p=p->next;
}
printf("\n");
printf("In all, there are %d candidate 1_itemsets.\n",count);

/*pp=cHead;

while(pp!=NULL)
{
if(pp->count>minNum)
{
fHead->count=cHead->count;
fHead->tag=cHead->tag;
fHead->itemset[fHead->tag]=cHead->itemset[cHead->tag];
fHead->next=NULL;
break;
}
pp=pp->next;
}

fp=fHead;
pp=pp->next;

while(pp!=NULL)
{
if(pp->count>minNum)
{
temp=(struct tItem*)malloc(sizeof(struct tItem));
temp->count=pp->count;
temp->next=NULL;
temp->tag=pp->tag;
temp->itemset[temp->tag]=pp->itemset[pp->tag];
fp->next=temp;
fp=temp;
//printf("%c",pp->itemset[pp->tag]);
}
pp=pp->next;
}

printf("\n");
printf("--------The frequence 1_itemsets--------\n");
fp=fHead;
while(fp!=NULL)
{
printf(" %c",fp->itemset[fp->tag]);
printf(" %d",fp->count);
printf(" %d",fp->tag);
printf("\n");
fp=fp->next;
}

return (fHead);*/
return (cHead);
}

struct tItem *Gen_kFrequence_subsets(tItem *f) //Éú³ÉƵ·±kÏÿÏîµÄ×Ó¼¯µÄ¼¯ºÏ
{
tItem *FreItemSubset;
//tItem *p;
int ListLength=f->tag+1;
int i;
//buffer=(int*)malloc(col*sizeof(int*))
char *List,*Buffer;

List=(char*)malloc(ListLength*sizeof(char*));
Buffer=(char*)malloc(ListLength*sizeof(char*));

for(i=0;i<f->tag+1;i++)
{
List[i]=f->itemset[i];
//printf(" %c",List[i]);
}

FreItemSubset=(struct tItem*)malloc(sizeof(struct tItem));
FreItemSubset->next=NULL;
FreItemSubset=SubSet(List,0,Buffer,0,FreItemSubset ,ListLength);

/*p=FreItemSubset;
p=p->next;
while(p!=NULL)
{
for(i=0;i<=p->tag;i++)
{
printf(" %c",p->itemset[i]);
}
printf(" %d",p->count);
printf(" %d",p->tag);
printf("\n");
p=p->next;
}*/

return (FreItemSubset);
}

int Index(char *List, char c, int ListLength)
{
for(int i=0; i<=ListLength-1; i++)
{
if(c==List[i])
{
return i;
break;
}
}
return -1;
}

struct tItem *SubSet(char *List, int m, char *Buffer, int flag, tItem *fis,int ListLength)
{
//fis->next=NULL;
//printf("###\n");
if(m <= ListLength-1)
{
/*if(m==0)
{
Buffer[0]=List[0];
}*/
//Buffer[flag]=List[m];
/*if(flag==0)
{
Buffer[flag]=List[m];
}*/

for(int i=(flag==0) ? 0 : Index(List,Buffer[flag-1],ListLength)+1; i<=ListLength-1; i++)
//µ±flag==0ʱ£¬BufferÖÐûÓÐÈκÎÔªËØ£¬´Ëʱi=[0...ListLength-1]
//µ±flag>0ʱ£¬ÕÒµ½BufferÖеÄ×îºóÒ»¸öÔªËØÔÚ¼¯ºÏListÖÐ µÄλÖÃi£¬°Ñ[i....ListLength-1]
//´¦µÄÔªËØ£¬¼Óµ½BufferÔªËصÄ×îºóÃæ
{

Buffer[flag]=List[i];
fis=AddToSubset(Buffer,flag,fis);
//Output(Buffer,flag);
SubSet(List, m+1, Buffer,flag+1,fis,ListLength);
}
}

/*tItem *p;
p=fis;
while(p!=NULL)
{
for(int j=0;j<=p->tag;j++)
{
printf(" %c",p->itemset[j]);
}
printf(" %d",p->count);
printf(" %d",p->tag);
printf("\n");
p=p->next;
}*/

return (fis);
}

struct tItem *AddToSubset(char *Buffer, int flag, tItem *fis) //½«×Ó¼¯Ìí¼Óµ½Á´±íÖÐ
{

tItem *p;
int i=0;

p=(struct tItem*)malloc(sizeof(struct tItem));

p->count=0;
p->tag=flag;

while(i<=flag)
{
p->itemset[i]=Buffer[i];
i++;
}

p->next=fis->next;
fis->next=p;

return (fis);
}

void Gen_association_rules(tItem *kf, tItem *p, double minCon) //Éú³É¹ØÁª¹æÔò
{
int i=0;
int j=0;
double m;
bool flag;

//printf("@@@@ %f\n",minCon);

m=(double)(kf->count)/(double)(p->count);

if(m>=minCon)
{
printf("\n");
while(i<=p->tag)
{
if(i!=p->tag)
{
printf("%c ",p->itemset[i]);
}
else
{
printf("%c ",p->itemset[i]);
}
i++;
}

printf("=====> ");

while(j<=kf->tag)
{
if(j!=kf->tag)
{
for(i=0;i<=p->tag;i++)
{
if(kf->itemset[j]==p->itemset[i])
{
flag=false;
break;
}
else
{
flag=true;
}
}
if(flag==true)
{
printf("%c ",kf->itemset[j]);
}

}
else
{
for(i=0;i<=p->tag;i++)
{
if(kf->itemset[j]==p->itemset[i])
{
flag=false;
break;
}
else
{
flag=true;
}
}
if(flag==true)
{
printf("%c ",kf->itemset[j]);
}

}
j++;
}

//cout << setprecision<< m <<endl;
m=(double)(p->count)/(double)(kf->count);
printf(" Confidence : %f",m);

printf("\n");
}
}