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

  • 大小: 1.05MB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2023-10-02
  • 語言: C/C++
  • 標簽: C++實現??執行時間??

資源簡介

實現思路詳見:https://blog.csdn.net/qq_33901011/article/details/100155334 該工程用C語言實現了crontab表達式執行時間,與在線crontab執行時間計算在線工具結果一致,用在嵌入式行業里的設備定時喚醒,定時操作等功能。里面用到了Linux源碼中的Crond.c的ParseField函數來解析crontab表達式,基姆拉爾森計算公式計算星期等。

資源截圖

代碼片段和文件信息

/*
作者:李猿
聯系方式:QQ?--?2573507779
測試方法:
*/


#include?“stdlib.h“
#include?“string.h“
#include?“stdio.h“

typedef?unsigned?????????char????uint8_t;
typedef?unsigned????short?int????uint16_t;
typedef?unsigned??????????int????uint32_t;




#define?DEBUG_LINE() printf(“FUN:%s?LINE:%d?TIME:%s\r\n“?__FUNCTION__?__LINE__?__TIME__)//

//時間?的臨時變量,以計算下次喚醒的時間節點?
struct?data_time_str
{
//uint8_t?sec;
uint8_t?min;
uint8_t?hour;
uint8_t?day;
uint8_t?month;
uint16_t?year;
uint8_t?week;
};


static?const?char?*const?DowAry[]?=?{
“sun“
“mon“
“tue“
“wed“
“thu“
“fri“
“sat“

“Sun“
“Mon“
“Tue“
“Wed“
“Thu“
“Fri“
“Sat“
NULL
};

static?const?char?*const?MonAry[]?=?{
“jan“
“feb“
“mar“
“apr“
“may“
“jun“
“jul“
“aug“
“sep“
“oct“
“nov“
“dec“

“Jan“
“Feb“
“Mar“
“Apr“
“May“
“Jun“
“Jul“
“Aug“
“Sep“
“Oct“
“Nov“
“Dec“
NULL
};

typedef?struct?CronLine?
{
char?cl_Mins[60]; /*?0-59?????????????????????????????????*/
char?cl_Hrs[24]; /*?0-23?????????????????????????????????*/
char?cl_Days[32]; /*?0-31?????????????????????????????????*/
char?cl_Mons[12]; /*?0-11?????????????????????????????????*/
char?cl_Dow[7]; /*?0-6?beginning?sunday????????????????*/
}?CronLine;



static?char?*ParseField(char?*user?char?*ary?int?modvalue?int?off
const?char?*const?*names?char?*ptr)
{
char?*base?=?ptr;
int?n1?=?-1;
int?n2?=?-1;

if?(base?==?NULL)?{
return?(NULL);
}

while?(*ptr?!=?‘?‘?&&?*ptr?!=?‘\t‘?&&?*ptr?!=?‘\n‘)?{
int?skip?=?0;

/*?Handle?numeric?digit?or?symbol?or?‘*‘?*/

if?(*ptr?==?‘*‘)?{
n1?=?0; /*?everything?will?be?filled?*/
n2?=?modvalue?-?1;
skip?=?1;
++ptr;
}?else?if?(*ptr?>=?‘0‘?&&?*ptr?<=?‘9‘)?{
if?(n1? n1?=?strtol(ptr?&ptr?10)?+?off;
}?else?{
n2?=?strtol(ptr?&ptr?10)?+?off;
}
skip?=?1;
}?else?if?(names)?{
int?i;

for?(i?=?0;?names[i];?++i)?{
if?(strncmp(ptr?names[i]?strlen(names[i]))?==?0)?{
break;
}
}
if?(names[i])?{
ptr?+=?strlen(names[i]);
if?(n1? n1?=?i;
}?else?{
n2?=?i;
}
skip?=?1;
}
}

/*?handle?optional?range?‘-‘?*/

if?(skip?==?0)?{
printf(“??failed?user?%s?parsing?%s\n“?user?base);
DEBUG_LINE();
return?(NULL);
}
if?(*ptr?==?‘-‘?&&?n2? ++ptr;
continue;
}

/*
?*?collapse?single-value?ranges?handle?skipmark?and?fill
?*?in?the?character?array?appropriately.
?*/

if?(n2? n2?=?n1;
}
if?(*ptr?==?‘/‘)?{
skip?=?strtol(ptr?+?1?&ptr?10);
}
/*
?*?fill?array?using?a?failsafe?is?the?easiest?way?to?prevent
?*?an?endless?loop
?*/

{
int?s0?=?1;
int?failsafe?=?1024;

--n1;
do?{
n1?=?(n1?+?1)?%?modvalue;

if?(--s0?==?0)?{
ary[n1?%?modvalue]?=?1;
s0?=?skip;
}
}
while?(n1?!=?

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-08-30?11:31??尋找喚醒時間節點\
?????目錄???????????0??2019-08-30?10:07??尋找喚醒時間節點\Debug\
?????文件???????32256??2019-08-30?13:13??尋找喚醒時間節點\Debug\尋找喚醒時間節點.exe
?????文件??????454356??2019-08-30?13:13??尋找喚醒時間節點\Debug\尋找喚醒時間節點.ilk
?????文件??????437248??2019-08-30?13:13??尋找喚醒時間節點\Debug\尋找喚醒時間節點.pdb
?????目錄???????????0??2019-08-30?10:05??尋找喚醒時間節點\ipch\
?????目錄???????????0??2019-08-30?10:05??尋找喚醒時間節點\ipch\尋找喚醒時間節點-4b2a15d9\
?????文件?????2359296??2019-08-30?10:05??尋找喚醒時間節點\ipch\尋找喚醒時間節點-4b2a15d9\尋找喚醒時間節點-a3f58340.ipch
?????目錄???????????0??2019-08-30?10:07??尋找喚醒時間節點\尋找喚醒時間節點\
?????目錄???????????0??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\
?????文件????????1338??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\cl.command.1.tlog
?????文件????????3890??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\CL.read.1.tlog
?????文件?????????612??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\CL.write.1.tlog
?????文件???????????2??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\link-cvtres.read.1.tlog
?????文件???????????2??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\link-cvtres.write.1.tlog
?????文件???????????2??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\link.8020-cvtres.read.1.tlog
?????文件???????????2??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\link.8020-cvtres.write.1.tlog
?????文件???????????2??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\link.8020.read.1.tlog
?????文件???????????2??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\link.8020.write.1.tlog
?????文件????????1544??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\link.command.1.tlog
?????文件????????3048??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\link.read.1.tlog
?????文件?????????826??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\link.write.1.tlog
?????文件???????23768??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\main.obj
?????文件?????????406??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\mt.command.1.tlog
?????文件?????????346??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\mt.read.1.tlog
?????文件?????????346??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\mt.write.1.tlog
?????文件?????????566??2019-08-30?10:07??尋找喚醒時間節點\尋找喚醒時間節點\Debug\rc.command.1.tlog
?????文件?????????318??2019-08-30?10:07??尋找喚醒時間節點\尋找喚醒時間節點\Debug\rc.read.1.tlog
?????文件?????????326??2019-08-30?10:07??尋找喚醒時間節點\尋找喚醒時間節點\Debug\rc.write.1.tlog
?????文件???????52224??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\vc100.idb
?????文件???????69632??2019-08-30?13:13??尋找喚醒時間節點\尋找喚醒時間節點\Debug\vc100.pdb
............此處省略15個文件信息

評論

共有 條評論