Saturday, September 25, 2010

C mixed programming with scripting



Write programs in linux, do network of people, more or less of several scripts.鑴氭湰璇█鐏垫椿鐨勫彉閲忕被鍨嬨?寮哄ぇ鐨勬鍒欒〃杈惧紡澶勭悊鑳藉姏锛屽啀鍔犱笂linux绯荤粺鏈韩鐨勭閬撱?閲嶅畾鍚戜互鍙婁赴瀵岀殑鍛戒护琛屽伐鍏凤紝璁╀綘缂栫▼璧锋潵娓稿垉鏈変綑銆?br />
The C language does have many advantages, but it is undeniable that many occasions, more convenient to use scripting language, such as we will illustrate the handling of the configuration file.

Take a look at our sample program tasks:

Suppose we have a program written with c, it has a configuration file user.conf, save some user information, user.conf defined as follows:

1) to comment line # at the beginning of the act, not treated

2) to allow blank lines

3), if not 1 and 2, it is valid data in the following form

# User.conf: configure file for user
銆??# username age backup bin conf config data eshow_sitemap.html generate.sh log maint sitemap.html svn tmp country
tom 20 male us
銆??chen 22 female cn
Each column is divided into four fields, between fields with one or more blank characters (spaces or tabs) separate the field followed by the name, age, gender, national

Our c procedures to be completed on user.conf the add, delete, edit, query

Such a simple task, together with c processing is not complicated, but also to spend something about, and if the scripting language used to do, very simply, can call the script in the c done it?

銆??Awk鏄痩inux涓婁竴绉嶈剼鏈瑷?紝瀹冪殑闀垮鍦ㄤ簬澶勭悊鏈変竴瀹氭牸寮忚鍒欑殑鏂囦欢锛屼緥濡傚挶浠殑user.conf銆?Information on awk, many, oreilly company out of a special awk programming books, the Internet also can be downloaded. You can also look directly man awk.

Let's see how combine with the shell awk to accomplish these tasks:

1) Add a record

銆??渚嬪锛岃娣诲姞 jack 18 male us 杩欐牱涓?潯璁板綍锛屽彲浠ョ畝鍗曠殑鐢ㄩ噸瀹氬悜鍔熻兘

Echo Ce "jack 18 male us">> user.conf
銆??鐜板湪锛岃繖鏉¤褰曡娣诲姞鍒?user.conf鏈熬浜嗐?

2) Delete a record

For example, the information you want to delete the user chen

cat user.conf awk '! / ^ chen: blank: + / print'> tmp.conf; mvCftmp.conf user.conf
3), editing a record

銆??鐜板湪锛屾兂鎶?tom鐨勬?鍒敼涓?female

Through the system () this function, we can call the above script in c to complete the task.

However, system () still feel uncomfortable with them, the lack of it is only for scripting, but can not get the script output data, which is usually our source of data for further processing. (In the shell and perl, you can by anti-quotation marks (``) to get the command output). One solution is to redirect output to a temporary file, then read the file in the c, to obtain data, and finally of course, delete this file. However, this method always make people feel a little uncomfortable, if the output directly to the script execution in the data input to our buffer to the better.

I wrote a small function, called my_system (), through pipes and redirection, to achieve the above ideas.鍑芥暟鍘熷瀷濡備笅锛?br />
銆??int my_system(const char* pCmd, char* pResult, int size)锛?br />Output data is saved to the buffer pointed to by pResult, the buffer size for the size, can save up to size-1 data.

Functions to achieve the final article on

With this function after calling the script in the c more convenient, we can use it to achieve user.conf inquiries.

4), query a record

銆??渚嬪锛屾垜浠鑾峰彇 tom 鐨勬?鍒?br />
銆??鍙互鐢ㄨ剼鏈繖鏍锋潵瀹炵幇锛?br />
銆??cat user.conf awk 鈥?^tom:blank:+/ print $3鈥?br />銆??鑴氭湰鐨勬墽琛岀粨鏋滄槸 tom鐨勬?鍒?male琚緭鍑哄埌灞忓箷涓?br />
銆??鍦ㄦ垜浠殑 c绋嬪簭涓紝濡傛璋冪敤 my_system()锛?br />
char buf101;
銆??my_system(鈥渃at user.conf awk 鈥?^tom:blank:+/ print $3鈥欌?,buf,101);
After the call finished, buf the data is the "male" a, how, pretty easy right?

銆??浠ヤ笂鍙槸鐢ㄧ粨鍚堣剼鏈畬鎴愪簡涓?釜姣旇緝绠?崟鐨勪换鍔★紝鎵?互鎴戞病鏈夋妸杩欎簺鑴氭湰鍗曠嫭褰㈡垚鑴氭湰鏂囦欢銆?If you are good at using perl, shell, awk, you can write a more powerful script file to handle more complex problems, then a similar my_system () method, in c / c + + and other languages to obtain the script output to achieve interesting "hybrid programming."

I hope you can have fun!

# Include
# Include
# Include
# Include
# Include
銆??static int my_system(const char* pCmd, char* pResult,intsize)
銆??int fd2;
int pid;
int count;
int center;
char * p = 0;
int maxlen = size C 1;
memset (pResult, 0, size);
printf (pipe error \ n);
return C1;
/ / Chile process
int fd22;
printf (pipe2 error \ n);
return C1;
close (1);
dup2 (fd21, 1);
close (fd0);
close (fd21);
銆??system(pCmd);
read (fd20, pResult, maxlen);
pResultstrlen (pResult) -1 = 0;
write (fd1, pResult, strlen (pResult));
close (fd20);
exit (0);
/ / Parent process
close (fd1);
p = pResult;
center = maxlen;
銆??while((count = read(fd0, p, center)))
p + = count;
center -= count;
break;
close (fd0);
return 0;
int main (void)
char result1025;
my_system (/ sbin / ifconfig, result, 1025);
printf (the result is \ n \ n% s \ n, result);
return 0;







相关链接:



DVR-MS to MPEG



MKV to Xbox 360



Review 0



AMD Intel on EU antitrust penalties comment



The secret of growth



Kodak V705 Dual Lens Camera Stabilization Cheap Listing Weekend



Family can offer car parking bus transfer brush 2 yuan per CARD



Internal control: harm than good, or at every step



WiMAX and TD-band battle began deemed to be an advantageous position in China



QuickTime To MPEG



Training Of New Employees Approach HR



Master Is Not Highly Educated Does Not Mean That High-income Elite



Servlet's Context and Config



Terminal And Telnet Clients evaluation



Convert for



Thursday, September 16, 2010

Job 10 kinds of unhealthy attitude towards students


Shyness. Lost in the written submissions and run job site, facing recruiters stammer, blush, such a person is naturally uncomfortable employer appreciated.

Career psychology. "Learning and the Official Career," an official is the only proper that, Qiaojiannaodai to "Yamen" drill, did not realize that these places are the relationship between strength and Competition, well very people who can enter, and the results are mostly ending up first broken blood flow.

Mental comparisons. Some students say "level", during which I feel results in the campus than you, honor more than you, "official" than you, of course, work should be better than you. But I do not know the employer does not judge talent as the sole criterion, the keen rivalry of the "outstanding student" can only in the "standing above the crowd" to appreciate the lonely days and lonely.

Psychotherapy. Some students lack of independence, go out to see the Federation Ella parents, classmates and companions, or a buddy to help co-applicants the same unit by fixing the future take care of each other, this non-assertive and enterprising graduates will be the employer abandoned.

Psychological dependence. They do not hurry to find work, which climbed all day thinking about the relationship between relatives and friends, get some money to buy a job, so I am afraid that difficult to do long posts bought.

Local mental.杩欎簺澶у鐢熶笉鎰垮嚭杩滈棬锛屽彧鎰垮湪鐪煎墠鐨勨?涓?憨涓夊垎鍦扳?閲屽氨涓氾紝鍙︿竴浜涗汉鍒欐棭鏃╃櫥涓婄埍鎯呮柟鑸燂紝姣曚笟鍚庝负涓庡彟涓?崐鐣欏畧鍚屼竴鎴樺鑰屾瀹堜竴鏂癸紝杩欐牱鐨勪汉榧犵洰瀵稿厜锛岄毦鏈変綔涓恒?

Conservative psychology. Lack of sense of competition, not the challenge, or holding modesty "virtue" without letting go, afraid to reveal their own strengths and characteristics of the tiger air, loyalty are not, such people are not naturally favored employers.

Low on the psychological.涓庝繚瀹堝績鐞嗙浉鍙嶏紝杩欎簺浜烘?瑙夊緱绔炰簤婵?儓锛岃嚜宸辨妧涓嶅浜猴紝閬傜敇鎷滀笅椋庯紝涓嶆暍瀵硅嚜宸扁?鏄庣爜鏍囦环鈥濓紝鎵句釜涔板鑽夎崏鍗栧嚭銆?For some units out of the unequal agreements entered into with eyes closed, serious risks to future work.
World-weary psychological. These students thought radical, trendy, always put "cool", did not go out looking for work, low wages and there too badly treated here, one that is their job to the boss, do not say you can not find the money owed was also down a bunch of money.

False psychology. Fake degree, fake certificates, fake honor, etc. are not knocking on the door of employment straw, can not fake after all long, but only harm their reputation, destroy their future.






相关链接:



Font Tools Report



Ts format



Using VMware, Vowed To Computer "cloned A Technique"



Flv to dat converter



Wizard Newsgroup Clients



Master IS not highly educated does not mean that high-income elite



Business IS business had to kind



youtube m4v



Organization Process definition



Ad Blockers evaluation



Landscape engineering company in Yantai in hand Weaver



Convert f4v to flv



Photo 6 Of A Tough, For The First Magic



IM: Decisive FORCE'S crowded



"Tomato Garden" case of first instance pronounced loss of Chengdu, a total of over 10 million SOFT



Paladin examination and Topics for 4 years (1)



My Favorite Site Administration



Thursday, July 29, 2010

Gates forecast: computer input will be "words rather than hands"



Microsoft Chairman Bill Gates recently forecast that "words rather than hands," will become the development trend of computer input.

23, according to U.S. media reports, Gates Carnegie - Mellon University, a speech, said that the role of the computer keyboard will gradually reduce in the future when people use computers will no longer enter text via keyboard, but with a voice to enter text.

Gates said: "This (with voice input text) is that we (Microsoft) is one of the goals and work hard." He believes that in the next 5 years, Internet search will be more accomplished by voice. Earlier, he had expressed similar views on many occasions.

Speech Technology in the spring will be temporary

After many years of accumulated technology, voice technology, the spring is approaching.

Speech recognition and synthesis technologies, including. Recognition refers to computer analysis of human voice and convert to text entered into the computer, replace the keyboard in order to achieve the technology to speak. Corresponds with the speech recognition computer text into speech synthesis technology.

After years of basic research, speech technology is now the key to a breakthrough in the moment.

The face of potentially huge market, the global high-tech companies have to voice technologies as contested. Chinese Chinese voice unit standard, Team Leader, vice president of USTC Telecommunications white fly strong interview, said that Google set up "1-800-goog-411" voice search services; Microsoft spent 800 million U.S. dollars acquisition the voice technology company TellMe; our domestic advanced speech technology company has been the large-scale application of speech technology.

Of course, the spring of voice technology to meet a lot of difficulties still to overcome, such as voice recognition can distinguish different tone so the same sentence. However, emerging technologies to go through a process of continuous improvement, improved steam engine was brought about by several large-scale industrialization, the fundamental advantages of voice technology doomed it will bring a new era.







Recommended links:



Flac To Wav



How to enhance the productivity of textile and GARMENT factories?



reviews PUZZLE And Word Games



Convert Dvd To Wmv



avc Player



How to save 280 million?



Some knowledge of JSP syntax



Production Of Fine Wood Decorative Painting



Games And Entertainment Specialist



avi to 3gp



Chinese input method commonly used FAST switching



Principal To Ensure Each Experience A 20 006 Practice Site



Pursuit of "simple simple" the ORM mapping framework [2]



Monday, July 12, 2010

"Warriors serpent Z" list of people attribute Xiangjie



The following is "unparalleled serpent Z" character property Xiangjie list of all the characters are divided into three categories namely power, technology, speed:

Character attributes

Property category, people

Power backup bin conf config data eshow_sitemap.html generate.sh log maint sitemap.html svn tmp Guan Yu, Zhang Fei, Ma Chao, Guan Ping, Xu Chu, Xiahou Yuan, Air /, Pound, Sun Quan, Huang Gai, Sun Ce, Lu Bu, Dong Zhuo, Meng Huo, Zhu Rong, Yuan Lu Zhi, Fu Yi, Ping Chiang Saen, really? far Lu Chi, cow ghosts, Benkei, the former Tian Qing times, Ishikawa Goemon, Uesugi Kenshin, 銇?銇?銇?銇? Mori Ranmaru, Imagawa Yoshimoto, The multi-Zhong Sheng, Tokugawa Ieyasu, shallow long political, Yoshihiro Shimazu, Tachibana Wylie Chiyoda, the former home field advantage, Shibata Singer

Technical backup bin conf config data eshow_sitemap.html generate.sh log maint sitemap.html svn tmp Zhao Yun, Zhuge Liang, Liu Bei, Huang, Yueh-ying, Dian Wei, Xu Huang, Cao Ren, Cao Pi, Zhou Yu, Wu Kingdom, Big Joe, Diao Chan , Yuan Shao, Zhang Jiao, Da Ji, grandfather Wang, Minamoto no Yoshitsune, Sanada Village, Oda Nobunaga, A City, A country Saiga Sun City, Takeda Shingen, Hattori Hanzo, Hideyoshi, Naoe and continued, Miyamoto Musashi, Ch艒sokabe Motochika, Sasaki Kojiro

Speed backup bin conf config data eshow_sitemap.html generate.sh log maint sitemap.html svn tmp Jiang Wei, Wei Yan, Pang Tong, Xing-cai, Xiahou Dun, Cao Cao, Zhang He, Zhen Ji, Taishi Ci, Sun Shangxiang, Sun Jian, Lu Meng, Gan Ning, Xiao Qiao, Zhou Tai, Ling Tong, Zuo Ci, the Monkey King, Nu Wa, Himiko, 100 Dodomeki, Tripitaka Master, Akechi Mitsuhide, Date Masamune, concentrated Ji, rice JI, Ishida Mitsunari, Ningning, celebrated Kotaro, Canada Laxia







相关链接:



Youtube Movie to Xbox 360 Pack



Explosion DVD Burner



DJ Music Mixer



free convert mp4 TO 3gp



Youtube Video Backup + Player Plus



MP3 M3U to ID3



Reviews Themes And Wallpaper



what is .mkv File



TingleSoft Mobile Video Converter



Evaluate Search Or Lookup TOOLS



Youtube Movie to Treo Pro



Digital DVD-Audio M4P OGG To ID3 Player



Wondershare Video to DVD Burner



convert M4A to m4r



what is rmvb



Wednesday, July 7, 2010

Youtube Movie to H264 Deluxe

It's most popular and very easy to use YouTube tools. helps you Fast download, convert, play, manage your favorite YouTube videos. If you're a YouTube fan, you'll love YouTube tool! is the most powerful YouTube assistant on the planet. YouTube tool easily: 1. Fast downloads YouTube videos, 2. Supports unlimited simultaneous downloads (a real time saver!), 3. Automatically names the downloaded video the same as the YouTube title, 4. Converts YouTube videos to various video formats, including Video, DVD, VCD, AVI, MPG, MPEG, Divx, Xvid, WMV, RM, RMVB, MOV, MP4, 3GP, SWF, DAT, H264, VOB, Flash, PDA, M4V, 3G2, AMV, CDA, DV,QuickTime, ASX, TV, VHS, FLV, H264, BDMV, MAC, Apple TV, Zune, iPod, PDA, PSP, PS2, PS3, Xbox, Xbox 360, Mobile Phone, Cell Phone, Blackberry, Wii, Laptops, Printers, Palm OS, Pocket PC, PPC, Treo, Psion, EPOC, iphone.
Supports YouTube video or any .flv and .swf file as input file. Supports not only YouTube video, but also various video formats as input file, including avi, DivX, XviD, rm, rmvb, MOV, MPEG, WMV. Supports a wide variety of output file format., including avi, DivX, XviD, rm, rmvb, MOV, MPEG, WMV. Provides various profiles, these profiles can meet the needs of most people. - is the most powerful YouTube assistant on the planet.



Recommand Link:



Bliss Audio WAV to RA BACKUP



Professional APE M3U to OGG Cloner



Video Format



Flv to mp3 converter



Youtube To PS3 Help



BLUESEA MPG M4V Convert



Premier Audio Rippers And Converters



mpeg to Mp4 converter



Youtube Video to Xvid Platinum



FREE download convert mp4 to 3gp



Easy to use Printer



evaluation PIMS And Calendars



Happiness iPhone 3GPP2 Deconde



ID3 Lab



LasVegas YouTube to IPOD



Lohan Mobile Converter



Friday, July 2, 2010

AVS-Media Audio Tools

This audio software suite includes 10 smooth-in-use and handy applications for audio processing! Record audio, burn and create audio and MP3 CDs, rip and exact-copy audio discs, mix your own music, create your own ringtones with various effects and upload it then, record iRadio, convert audio.

- Boost your MP3 audio collection with surround sound!
- Set a soundtrack as a ringtone before the movie is released!
- With AVS Music Mix being creative and original is outstandingly easy!

Software supports all major audio file formats: WAV, PCM, MP3, WMA, OGG, AAC, M4A, AMR and others.



Recommand Link:



Movavi Video Tools Suite Platinum



PROFESSIONAL Youtube Deconde



Vacations MPG TO DVD



Guide E-Mail TOOLS



Evaluate Chat And Instant Messaging



Free FLV Player



SoundTaxi Platinum Pro New



Ever MP3 M3U Audio to DVD-Audio Editing



Christmas-Idea Flash To PSP Google Video



WorldCup DVD to Xbox



Smile MPG Converter



Compare People - Screen Savers



DVD Copy Pro



avi to M4v



Clone2Go DVD RIPPER



Monday, June 7, 2010

AlltoDVD DVD to Youtube


AlltoDVD DVD to Youtube is a All-in-One powerful tool. Convert all popular video and audio formats to Youtube video, swf or flv to video, such as avi, mpeg, 3gp, mp4, mov, it offers the solutions to problems that many other flash to video converting tools cannot solve, such as video and audio asynchronization, loss of frames, audio distortion, the process of alpha channel, and the process of both internal and external Flash video(flv). With the leading audio and video codec, AlltoDVD DVD to Youtube lets you easily and fully enjoy the original effects of your Flash files on your PC, iPod, PSP, Zune, iPhone, DVD players and Youtube Video, Google video, Myspace Video. In conclusion, with easy-to-use interface, fast converting speed, powerful functions.



Recommand Link:



AAC to BlackBerry Studio



Vacations iPhone Converter



LasVegas YouTube to iPod



Lists Games CARD



All Video SOLUTION Value Pack



CD Mobile Phone to Music



Astrology Or Biorhythms Or Mystic Specialist



Youtube Movie To BDMV Mixer



M4P OGG TO Sound



Youtube Video to Psion Suite



Premier Log Analysers



application windows mac linux



Youtube to RM Freeware



HAPPINESS iPod iPhone Convert