91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

ad hoc網(wǎng)絡(luò)olsr路由在linux下的實現(xiàn)源代碼

資源截圖

代碼片段和文件信息


/*
?*?NetsimPcap?-?a?userspace?network?bridge?with?simulated?packet?loss
?*?????????????Copyright?2008?H.?Rogge?(rogge@fgan.de)
?*
?*?This?program?is?free?software:?you?can?redistribute?it?and/or?modify
?*?it?under?the?terms?of?the?GNU?General?Public?License?as?published?by
?*?the?Free?Software?Foundation?either?version?3?of?the?License?or
?*?(at?your?option)?any?later?version.
?*
?*?This?program?is?distributed?in?the?hope?that?it?will?be?useful
?*?but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
?*?MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.??See?the
?*?GNU?General?Public?License?for?more?details.
?*
?*?You?should?have?received?a?copy?of?the?GNU?General?Public?License
?*?along?with?this?program.??If?not?see?.
?*/

#include?
#include?
#include?

#include?“config.h“
#include?“debug.h“

/*
?*?stripString
?*
?*?this?function?strips?leading?and?trailing?whitespaces?from?a?string
?*
?*?@param?string?to?strip
?*?@return?stripped?string
?*/
char?*
stripString(char?*str)
{

??/*?strip?left?whitespaces?*/
??while?(*str?==?‘?‘?||?*str?==?‘\t‘)?{
????str++;
??}

??/*?strip?right?whitespaces?*/
??int?i?=?strlen(str);
??while?(--i?>=?0)?{
????if?(str[i]?==?‘?‘?||?str[i]?==?‘\r‘?||?str[i]?==?‘\n‘?||?str[i]?==?‘\t‘)?{
??????str[i]?=?0;
??????break;
????}
??}

??return?str;
}

/*
?*?readConnectionMatrix
?*
?*?This?function?reads?the?network?settings?and?place?them?in?the
?*?connection?matrix?(float?array?with?size?“l(fā)en“?x?“l(fā)en“.
?*
?*?@param?pointer?to?begin?of?connection?matrix
?*?@param?pointer?to?filename
?*?@param?number?of?elements?in?each?connection?matrix?line
?*?@return?0?if?function?was?successfull?1?if?an?error?happened
?*/
int
readConnectionMatrix(float?*connectionMatrix?char?*filename?int?len)
{
??FILE?*file?=?fopen(filename?“r“);
??if?(!file)?{
????return?1;
??}

??char?buffer[1024];
??while?(fgets(buffer?1024?file))?{
????int?from?to;
????float?propability;

????char?*line?=?stripString(buffer);
????DPRINT(“%s\n“?line);

????if?(line[0]?==?‘#‘?||?line[0]?==?0)?{
??????continue;
????}

????if?(sscanf(line?“%d?%d?%f“?&from?&to?&propability)?!=?3)?{
??????continue;
????}

????if?(from?=?len?||?to?=?len?||?from?==?to)?{
??????continue;
????}

????connectionMatrix[GRID(from?to?len)]?=?propability;
????if?(connectionMatrix[GRID(to?from?len)]?==?0)?{
??????connectionMatrix[GRID(to?from?len)]?=?propability;
????}
??}
??fclose(file);
??return?0;
}

/*
?*?Local?Variables:
?*?c-basic-offset:?2
?*?indent-tabs-mode:?nil
?*?End:
?*/

評論

共有 條評論

相關(guān)資源