您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ strptime函数代码示例

51自学网 2021-06-03 08:31:54
  C++
这篇教程C++ strptime函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中strptime函数的典型用法代码示例。如果您正苦于以下问题:C++ strptime函数的具体用法?C++ strptime怎么用?C++ strptime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了strptime函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: absolute_val_from_string

static gbooleanabsolute_val_from_string(fvalue_t *fv, const char *s, gchar **err_msg){	struct tm tm;	char    *curptr;	memset(&tm, 0, sizeof(tm));	curptr = strptime(s,"%b %d, %Y %H:%M:%S", &tm);	if (curptr == NULL)		curptr = strptime(s,"%Y-%m-%dT%H:%M:%S", &tm);	if (curptr == NULL)		curptr = strptime(s,"%Y-%m-%d %H:%M:%S", &tm);	if (curptr == NULL)		curptr = strptime(s,"%Y-%m-%d %H:%M", &tm);	if (curptr == NULL)		curptr = strptime(s,"%Y-%m-%d %H", &tm);	if (curptr == NULL)		curptr = strptime(s,"%Y-%m-%d", &tm);	if (curptr == NULL)		goto fail;	tm.tm_isdst = -1;	/* let the computer figure out if it's DST */	fv->value.time.secs = mktime(&tm);	if (*curptr != '/0') {		/*		 * Something came after the seconds field; it must be		 * a nanoseconds field.		 */		if (*curptr != '.')			goto fail;	/* it's not */		curptr++;	/* skip the "." */		if (!g_ascii_isdigit((unsigned char)*curptr))			goto fail;	/* not a digit, so not valid */		if (!get_nsecs(curptr, &fv->value.time.nsecs))			goto fail;	} else {		/*		 * No nanoseconds value - it's 0.		 */		fv->value.time.nsecs = 0;	}	if (fv->value.time.secs == -1) {		/*		 * XXX - should we supply an error message that mentions		 * that the time specified might be syntactically valid		 * but might not actually have occurred, e.g. a time in		 * the non-existent time range after the clocks are		 * set forward during daylight savings time (or possibly		 * that it's in the time range after the clocks are set		 * backward, so that there are two different times that		 * it could be)?		 */		goto fail;	}	return TRUE;fail:	if (err_msg != NULL)		*err_msg = g_strdup_printf("/"%s/" is not a valid absolute time. Example: /"Nov 12, 1999 08:55:44.123/" or /"2011-07-04 12:34:56/"",		    s);	return FALSE;}
开发者ID:DHODoS,项目名称:wireshark,代码行数:63,


示例2: parse_format

static intparse_format (GLogItem * glog, const char *fmt, const char *date_format,              char *str){  const char *p;  double serve_secs;  int special = 0;  struct tm tm;  unsigned long long bandw, serve_time;  if (str == NULL || *str == '/0')    return 1;  memset (&tm, 0, sizeof (tm));  /* iterate over the log format */  for (p = fmt; *p; p++) {    if (*p == '%') {      special++;      continue;    }    if (special && *p != '/0') {      char *pch, *sEnd, *bEnd, *tkn = NULL, *end = NULL;      errno = 0;      bandw = 0;      serve_time = 0;      serve_secs = 0;      switch (*p) {         /* date */       case 'd':         if (glog->date)           return 1;         /* parse date format including dates containing spaces,          * i.e., syslog date format (Jul 15 20:10:56) */         tkn = parse_string (&str, p[1], count_matches (date_format, ' ') + 1);         if (tkn == NULL)           return 1;         end = strptime (tkn, date_format, &tm);         if (end == NULL || *end != '/0') {           free (tkn);           return 1;         }         glog->date = tkn;         break;         /* remote hostname (IP only) */       case 'h':         if (glog->host)           return 1;         tkn = parse_string (&str, p[1], 1);         if (tkn == NULL)           return 1;         if (invalid_ipaddr (tkn)) {           free (tkn);           return 1;         }         glog->host = tkn;         break;         /* request method */       case 'm':         if (glog->method)           return 1;         tkn = parse_string (&str, p[1], 1);         if (tkn == NULL)           return 1;         if (invalid_method (tkn)) {           free (tkn);           return 1;         }         glog->method = tkn;         break;         /* request not including method or protocol */       case 'U':         if (glog->req)           return 1;         tkn = parse_string (&str, p[1], 1);         if (tkn == NULL || *tkn == '/0')           return 1;         if ((glog->req = decode_url (tkn)) == NULL)           return 1;         free (tkn);         break;         /* request protocol */       case 'H':         if (glog->protocol)           return 1;         tkn = parse_string (&str, p[1], 1);         if (tkn == NULL)           return 1;         if (invalid_protocol (tkn)) {           free (tkn);           return 1;         }         glog->protocol = tkn;         break;         /* request, including method + protocol */       case 'r':         if (glog->req)           return 1;         tkn = parse_string (&str, p[1], 1);//.........这里部分代码省略.........
开发者ID:nwaldispuehl,项目名称:goaccess,代码行数:101,


示例3: command_touch

int command_touch (int argc, char **argv){   int i;   char *ptr, *c;   struct tm *m;      progname = argv[0];   time (&now);   t.actime = now;   t.modtime = now;      for (i = 1; i < argc; ++i)   {      ptr = argv[i];      if (*ptr == '-')      {         while (*++ptr)         switch (*ptr)         {            case '-':               if (!strcmp (ptr, "-help"))               {                  puts (help_text);                  return (EXIT_SUCCESS);               }               else if (!strcmp (ptr, "-version"))               {                  puts ("touch: version "VERSION);                  return (EXIT_SUCCESS);               }            case 'a':               flag_access = 1;               continue;            case 'c':               flag_create = 0;               continue;            case 'm':               flag_modification = 1;               continue;            case 'r':               if (++i >= argc)                  terror ("missing operand to `-r' option");               lstat (argv[i], &s);               t.actime = s.st_atime;               t.modtime = s.st_mtime;               break;            case 't':               if (++i >= argc)                  terror ("missing operand to `-t' option");               m = xmalloc (sizeof (struct tm));               memset (m, '/0', sizeof (*m));               c = strptime (argv[i], "%C%Y%m%d%H%M%S", m);               t.actime = mktime (m);               t.modtime = mktime (m);               break;         }      }      else         do_touch (argv[i]);   }   return (EXIT_SUCCESS);}
开发者ID:bproctor,项目名称:utils,代码行数:63,


示例4: run_loader

void run_loader(int thread, char *filename) {	bson_t *record;	mongoc_client_t *conn;	mongoc_collection_t *collection;	bson_error_t error;	bson_t reply;	int count;	FILE *infile;	char *rptr;	char ilinebuf[BUFSIZ];	char rlinebuf[BUFSIZ];	char *ritem;	char *rlast = NULL;	int rfcount = 0;	int batchcount = 0;	char *str;	int total = 0;	//Get the highest used value on that shard so far	conn = mongoc_client_new(DEFAULT_URI);	if (!conn) {		fprintf(stderr, "Failed to parse URI./n");		exit(1);	}	collection = mongoc_client_get_collection(conn, DATA_DB, DATA_COLLECTION);	long long chunkno = carve_chunk(conn, collection);	printf("Thread %d reading %s/n", thread, filename);	infile = fopen(filename, "r");	if (infile == NULL) {		perror("Opening results file");		exit(1);	}	mongoc_bulk_operation_t *bulk = mongoc_collection_create_bulk_operation(			collection, true, NULL);	if(!bulk)	{		printf("Failed to create bulk op/n");	}	rptr = fgets(rlinebuf, BUFSIZ, infile);	rlinebuf[strlen(rlinebuf) - 1] = '/0';	//Read the Results Line	while (rptr) {		total++;		if (total % (INSERT_THREADS_PER_SHARD * nshards) == thread) {			ritem = strtok_r(rptr, "|", &rlast);			rfcount = 0;			record = bson_new();			//Two part ID - a loader (32 bits for that) and a one_up			bson_append_int64(record, "_id", -1, (chunkno << 32) + total);			while (ritem) {				switch (resulttype[rfcount]) {				case 0:					//printf("%s/n",ritem);					bson_append_utf8(record, resultfields[rfcount], -1, ritem,							-1);					break;				case 1:					bson_append_int32(record, resultfields[rfcount], -1,							atoi(ritem));					break;				case 2:					if (strncmp(ritem, "NULL", 4)) {						struct tm tm;						if (strptime(ritem, "%Y-%m-%d", &tm)) {							time_t t = mktime(&tm); // t is now your desired time_t							bson_append_date_time(record, resultfields[rfcount],									-1, (long long) t * 1000);						}					}					break;				default:					printf("Unknown type col %d = %d/n", rfcount,							resulttype[rfcount]);				}				ritem = strtok_r(NULL, "|", &rlast);				rfcount++;			}			mongoc_bulk_operation_insert(bulk, record);			bson_destroy(record);			if (batchcount == (BATCHSIZE - 1)) {				int ret = mongoc_bulk_operation_execute(bulk, &reply, &error);				if (!ret) {					printf( "Error: %s/n", error.message);//.........这里部分代码省略.........
开发者ID:johnlpage,项目名称:BigAggBlog,代码行数:101,


示例5: parsetime

static time_tparsetime(char *str, time_t current){	struct tm *cur, t;	int zulu = 0;	char *format;	size_t len = strlen(str);	cur = localtime(&current);	t.tm_isdst = -1;	switch (len) {	/* -t flag argument */	case 8:		t.tm_sec = 0;		t.tm_year = cur->tm_year;		format = "%m%d%H%M";		break;	case 10:		t.tm_sec = 0;		format = "%y%m%d%H%M";		break;	case 11:		t.tm_year = cur->tm_year;		format = "%m%d%H%M.%S";		break;	case 12:		t.tm_sec = 0;		format = "%Y%m%d%H%M";		break;	case 13:		format = "%y%m%d%H%M.%S";		break;	case 15:		format = "%Y%m%d%H%M.%S";		break;	/* -d flag argument */	case 19:		format = "%Y-%m-%dT%H:%M:%S";		break;	case 20:		/* only Zulu-timezone supported */		if (str[19] != 'Z')			eprintf("Invalid time zone/n");		str[19] = 0;		zulu = 1;		format = "%Y-%m-%dT%H:%M:%S";		break;	default:		eprintf("Invalid date format length/n", str);	}	if (!strptime(str, format, &t))		weprintf("strptime %s: Invalid date format/n", str);	if (zulu) {		t.tm_hour += t.tm_gmtoff / 60;		t.tm_gmtoff = 0;		t.tm_zone = "Z";	}	return mktime(&t);}
开发者ID:rovaughn,项目名称:distro,代码行数:62,


示例6: GetJournalFileName

bool CScrobbler::LoadJournal(){  int                     journalVersion  = 0;  SubmissionJournalEntry  entry;  TiXmlDocument           xmlDoc;  CStdString              JournalFileName = GetJournalFileName();  CSingleLock             lock(m_queueLock);  m_vecSubmissionQueue.clear();    if (!xmlDoc.LoadFile(JournalFileName))  {    CLog::Log(LOGDEBUG, "%s: %s, Line %d (%s)", m_strLogPrefix.c_str(),         JournalFileName.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc());    return false;  }  TiXmlElement *pRoot = xmlDoc.RootElement();  if (strcmpi(pRoot->Value(), "asjournal") != 0)  {    CLog::Log(LOGDEBUG, "%s: %s missing <asjournal>", m_strLogPrefix.c_str(),        JournalFileName.c_str());    return false;  }  if (pRoot->Attribute("version"))    journalVersion = atoi(pRoot->Attribute("version"));  TiXmlNode *pNode = pRoot->FirstChild("entry");  for (; pNode; pNode = pNode->NextSibling("entry"))  {    entry.Clear();    XMLUtils::GetString(pNode, "artist", entry.strArtist);    XMLUtils::GetString(pNode, "album", entry.strAlbum);    XMLUtils::GetString(pNode, "title", entry.strTitle);    XMLUtils::GetString(pNode, "length", entry.strLength);    entry.length = atoi(entry.strLength.c_str());    XMLUtils::GetString(pNode, "starttime", entry.strStartTime);    XMLUtils::GetString(pNode, "musicbrainzid", entry.strMusicBrainzID);    if (journalVersion > 0)    {      XMLUtils::GetString(pNode, "tracknum", entry.strTrackNum);      XMLUtils::GetString(pNode, "source", entry.strSource);      XMLUtils::GetString(pNode, "rating", entry.strRating);    }    else    {      // Update from journal v0      // Convert start time stamp      struct tm starttm;      time_t startt;      if (!strptime(entry.strStartTime.c_str(), "%Y-%m-%d %H:%M:%S", &starttm))        continue;      if ((startt = mktime(&starttm)) == -1)        continue;      entry.strStartTime.Format("%d", startt);      // url encode entries      CURL::Encode(entry.strArtist);       CURL::Encode(entry.strTitle);      CURL::Encode(entry.strAlbum);      CURL::Encode(entry.strMusicBrainzID);    }    m_vecSubmissionQueue.push_back(entry);  }  CLog::Log(LOGDEBUG, "%s: Journal loaded with %"PRIuS" entries.", m_strLogPrefix.c_str(),      m_vecSubmissionQueue.size());  return !m_vecSubmissionQueue.empty();}
开发者ID:wonslung,项目名称:xbmc,代码行数:70,


示例7: request_handler

int request_handler(struct mg_connection *conn){  char tmpBuf[1024];  sprintf(tmpBuf, "%s %s from %s", conn->request_method, conn->uri, conn->remote_ip);  log_line(tmpBuf, LOG_INFO);  if(strcmp(STATS_JSON_URI, conn->uri) == 0){    return stats_json(conn);  }#ifndef DEBUG  // serve assets from resources.c  size_t asset_size;  int is_modified = 0;  const char *asset_content = NULL, *if_modifier_since_header = NULL;  char date_str[48], cache_control[58], expires[48], last_modified[48];  time_t current_time, expires_time, if_modified_time, modified_time;  struct tm *current_time_tm, *expires_tm, if_modifier_since, *last_modified_tm;  last_modified_tm = gmtime(&globalOptions.start_time);  strftime(last_modified, sizeof(last_modified), CONST_RFC1945_TIME_FORMAT, last_modified_tm);  if_modifier_since_header = mg_get_header(conn, "If-Modified-Since");  if(if_modifier_since_header){    strptime(if_modifier_since_header, CONST_RFC1945_TIME_FORMAT, &if_modifier_since);    if_modified_time = mktime(&if_modifier_since);    modified_time = mktime(last_modified_tm);    if(modified_time <= if_modified_time){      mg_send_status(conn, 304);      is_modified = 1;    }  }  if(strcmp("/", conn->uri) == 0){    asset_content = find_embedded_file("public/index.html", &asset_size);    mg_send_header(conn, "Content-Type", "text/html; charset=utf-8");  }else if(strcmp("/assets/app.js", conn->uri) == 0){    asset_content = find_embedded_file("public/assets/app.js", &asset_size);    mg_send_header(conn, "Content-Type", "application/x-javascript; charset=utf-8");  }else if(strcmp("/assets/app.css", conn->uri) == 0){    asset_content = find_embedded_file("public/assets/app.css", &asset_size);    mg_send_header(conn, "Content-Type", "text/css; charset=utf-8");  }  if(asset_content != NULL){    current_time = time(NULL);    current_time_tm = gmtime(&current_time);    strftime(date_str, sizeof(date_str), CONST_RFC1945_TIME_FORMAT, current_time_tm);    sprintf(cache_control, "max-age=%d, public", CACHE_LIMIT);    expires_time = time(NULL) + CACHE_LIMIT;    expires_tm = gmtime(&expires_time);    strftime(expires, sizeof(expires), CONST_RFC1945_TIME_FORMAT, expires_tm);    mg_send_header(conn, "Date", date_str);    mg_send_header(conn, "Cache-Control", cache_control);    mg_send_header(conn, "Vary", "Accept-Encoding");    mg_send_header(conn, "Expires", expires);    if(is_modified == 0){      mg_send_header(conn, "Last-Modified", last_modified);      mg_send_data(conn, asset_content, asset_size);    }else{      // close connection      mg_send_data(conn, "/r/n", 2);    }    return MG_REQUEST_PROCESSED;  }#endif  return MG_REQUEST_NOT_PROCESSED;}
开发者ID:gcbinsp,项目名称:system_monitor,代码行数:77,


示例8: stime_darg

static voidstime_darg(const char *arg, struct timespec *tvp){	struct tm t = { .tm_sec = 0 };	const char *fmt, *colon;	char *p;	int val, isutc = 0;	tvp[0].tv_nsec = 0;	t.tm_isdst = -1;	colon = strchr(arg, ':');	if (colon == NULL || strchr(colon + 1, ':') == NULL)		goto bad;	fmt = strchr(arg, 'T') != NULL ? "%Y-%m-%dT%H:%M:%S" :	    "%Y-%m-%d %H:%M:%S";	p = strptime(arg, fmt, &t);	if (p == NULL)		goto bad;	/* POSIX: must have at least one digit after dot */	if ((*p == '.' || *p == ',') && isdigit((unsigned char)p[1])) {		p++;		val = 100000000;		while (isdigit((unsigned char)*p)) {			tvp[0].tv_nsec += val * (*p - '0');			p++;			val /= 10;		}	}	if (*p == 'Z') {		isutc = 1;		p++;	}	if (*p != '/0')		goto bad;	tvp[0].tv_sec = isutc ? timegm(&t) : mktime(&t);	tvp[1] = tvp[0];	return;bad:	errx(1, "out of range or illegal time specification: YYYY-MM-DDThh:mm:SS[.frac][tz]");}/* Calculate a time offset in seconds, given an arg of the format [-]HHMMSS. */inttimeoffset(const char *arg){	int offset;	int isneg;	offset = 0;	isneg = *arg == '-';	if (isneg)		arg++;	switch (strlen(arg)) {	default:				/* invalid */		errx(1, "Invalid offset spec, must be [-][[HH]MM]SS");	case 6:					/* HHMMSS */		offset = ATOI2(arg);		/* FALLTHROUGH */	case 4:					/* MMSS */		offset = offset * 60 + ATOI2(arg);		/* FALLTHROUGH */	case 2:					/* SS */		offset = offset * 60 + ATOI2(arg);	}	if (isneg)		return (-offset);	else		return (offset);}
开发者ID:Absolight,项目名称:poudriere,代码行数:73,


示例9: log_file_exit

void log_file_exit(logd_file * plf){	pid_t pid;	int ret_len = 0;	int round_off = 0;	/* Get current time and assign to end time*/	time_t cur_time = time(NULL);	struct tm ltime;	aln_interval *pal = NULL;        char tmp_filename[1024] = { 0 };        char cmd[1024] = { 0 };        struct stat file_status;        FILE *pipefd = NULL;        char path[1024];	char *token = NULL;	int field = 0;	char trailer_record[SIZE_OF_TIMEBUFFER] = {0};	struct tm mtime;	struct tm etime;	time_t et;	unsigned long tmp_et;	uploadInfo *p_uploadInfo = NULL;	char gz_filename[MAX_FILE_SZ] = { 0 };	int err = 0;	char *bname = NULL, *b = NULL;	char *bname_upldinfo = NULL, *b_upldinfo = NULL;        char *dname_upldinfo = NULL, *d_upldinfo = NULL;	memset(&ltime, 0, sizeof(struct tm) );	memset(&etime, 0, sizeof(struct tm) );	if(!plf->fp) {	    snprintf(cmd,1024,"/bin/ls %s/%s.%d*",		    "/log/varlog/nkn", plf->filename, plf->cur_fileid);	    pipefd = popen(cmd, "r");	    if(pipefd == NULL) {		return;            }            fscanf(pipefd,"%s/n",path);            plf->fullfilename = strdup(path);            pclose(pipefd);        }        strlcpy(tmp_filename,plf->fullfilename,sizeof(tmp_filename));        //Parse the crawl.log file name when started for        // the first time parsse from :"crawl.log.0.20120517_09:45:00"        if(strcmp(plf->file_start_time,"") == 0){            token = strtok(tmp_filename,"._:");            while(token != NULL) {              /* The 3rd field till 5th field indicates the start timestamp*/		if((field >= 3)&&(field <= 5)) {		    strlcat(plf->file_start_time ,token,			    sizeof(plf->file_start_time));		}		token = strtok(NULL, "._:");		field++;	    }	}	//Fix for PR782738	if(strcmp(plf->file_end_time,"") == 0){	    if(strcmp(plf->file_start_time,"") != 0) {		if(plf->rt_interval){		    strptime(plf->file_start_time, "%Y%m%d%H%M", &ltime );		    et =  mktime(&ltime);		    et = et + (60 * plf->rt_interval);		    localtime_r(&et, &etime);		}		else {		    time_t now = time(NULL);		    localtime_r(&now ,&etime);		}		strftime(plf->file_end_time,			SIZE_OF_TIMEBUFFER, "%G%m%d%H%M", &etime);	    }	}        sscanf(plf->file_end_time,"%lu",&tmp_et);        if(plf->version_etime == 0){            plf->version_etime = tmp_et;            plf->version_number ++;        }else{            if(tmp_et > plf->version_etime){                plf->version_number = 0;            }else {                plf->version_number ++;            }            plf->version_etime = tmp_et;        }	if(stat(plf->fullfilename, &file_status) == 0) {	    //Got the file status            if(plf->fp == NULL){                plf->fp = fopen(plf->fullfilename, "a+");            }	    if(plf->fp != NULL)	    {		localtime_r(&file_status.st_mtime, &mtime);		strftime (trailer_record, SIZE_OF_TIMEBUFFER, "%G%m%d%H%M%S",			&mtime);		fprintf(plf->fp,"/n#Last Modified : %s",trailer_record);//.........这里部分代码省略.........
开发者ID:skizhak,项目名称:open-media-flow-controller,代码行数:101,


示例10: strptime

    if (std::isnan(MISSING))    {        return std::isnan(v);    }    else    {        return v == MISSING;    }}auto date_xlt = [](const char * str) -> real_type{    std::tm parsed = {0};    strptime(str, "%Y-%m-%d %T", &parsed);    const auto tp = std::chrono::system_clock::from_time_t(std::mktime(&parsed));    const auto days_since_1900 = std::chrono::duration_cast<std::chrono::hours>(tp.time_since_epoch()).count() / 24;    return days_since_1900;};/* * generic pattern converter for loadtxt */auto from_list_xlt = [](const std::vector<std::string> & patterns, const char * str) -> real_type{    auto matched_it = std::find_if(patterns.cbegin(), patterns.cend(),        [&str](const std::string & what)        {
开发者ID:WojciechMigda,项目名称:TCO-ElectronicPartsClassification,代码行数:31,


示例11: strptime

char * strptime(const char *buf, const char *fmt, struct tm *tm){    char c;    const char *bp;    size_t len = 0;    int alt_format, i, split_year = 0;    bp = buf;    while ((c = *fmt) != '/0')    {        /* Clear `alternate' modifier prior to new conversion. */        alt_format = 0;        /* Eat up white-space. */        if (isspace(c))        {            while (isspace(*bp))                bp++;            fmt++;            continue;        }        if ((c = *fmt++) != '%')            goto literal;    again:    switch (c = *fmt++)    {    case '%': /* "%%" is converted to "%". */        literal :            if (c != *bp++)                return (0);        break;        /*         * "Alternative" modifiers. Just set the appropriate flag         * and start over again.         */    case 'E': /* "%E?" alternative conversion modifier. */        LEGAL_ALT(0);        alt_format |= ALT_E;        goto again;    case 'O': /* "%O?" alternative conversion modifier. */        LEGAL_ALT(0);        alt_format |= ALT_O;        goto again;        /*         * "Complex" conversion rules, implemented through recursion.         */    case 'c': /* Date and time, using the locale's format. */        LEGAL_ALT(ALT_E);        if (!(bp = strptime(bp, "%x %X", tm)))            return (0);        break;    case 'D': /* The date as "%m/%d/%y". */        LEGAL_ALT(0);        if (!(bp = strptime(bp, "%m/%d/%y", tm)))            return (0);        break;    case 'R': /* The time as "%H:%M". */        LEGAL_ALT(0);        if (!(bp = strptime(bp, "%H:%M", tm)))            return (0);        break;    case 'r': /* The time in 12-hour clock representation. */        LEGAL_ALT(0);        if (!(bp = strptime(bp, "%I:%M:%S %p", tm)))            return (0);        break;    case 'T': /* The time as "%H:%M:%S". */        LEGAL_ALT(0);        if (!(bp = strptime(bp, "%H:%M:%S", tm)))            return (0);        break;    case 'X': /* The time, using the locale's format. */        LEGAL_ALT(ALT_E);        if (!(bp = strptime(bp, "%H:%M:%S", tm)))            return (0);        break;    case 'x': /* The date, using the locale's format. */        LEGAL_ALT(ALT_E);        if (!(bp = strptime(bp, "%m/%d/%y", tm)))            return (0);        break;        /*         * "Elementary" conversion rules.         */    case 'A': /* The day of week, using the locale's form. */    case 'a'://.........这里部分代码省略.........
开发者ID:MrCollaborator,项目名称:CiscoUCScripts,代码行数:101,


示例12: parse_preamble

static voidparse_preamble (void){	struct tm timecode;	char *subsecs;	char *p;	int  subseclen;	int  i;	/*	 * If no "-t" flag was specified, don't attempt to parse a packet	 * preamble to extract a time stamp.	 */	if (ts_fmt == NULL)	    return;	/*	 * Initialize to today localtime, just in case not all fields	 * of the date and time are specified.	 */	timecode = timecode_default;	ts_usec = 0;	/*	 * Null-terminate the preamble.	 */	packet_preamble[packet_preamble_len] = '/0';	/* Ensure preamble has more than two chars before atempting to parse.	 * This should cover line breaks etc that get counted.	 */	if ( strlen(packet_preamble) > 2 ) {		/* Get Time leaving subseconds */		subsecs = strptime( packet_preamble, ts_fmt, &timecode );		if (subsecs != NULL) {			/* Get the long time from the tm structure */                        /*  (will return -1 if failure)            */			ts_sec  = mktime( &timecode );		} else			ts_sec = -1;	/* we failed to parse it */		/* This will ensure incorrectly parsed dates get set to zero */		if ( -1 == ts_sec )		{			/* Sanitize - remove all '/r' */			char *c;			while ((c = strchr(packet_preamble, '/r')) != NULL) *c=' ';			fprintf (stderr, "Failure processing time /"%s/" using time format /"%s/"/n   (defaulting to Jan 1,1970 00:00:00 GMT)/n",				 packet_preamble, ts_fmt);			if (debug >= 2) {				fprintf(stderr, "timecode: %02d/%02d/%d %02d:%02d:%02d %d/n",					timecode.tm_mday, timecode.tm_mon, timecode.tm_year,					timecode.tm_hour, timecode.tm_min, timecode.tm_sec, timecode.tm_isdst);			}			ts_sec  = 0;  /* Jan 1,1970: 00:00 GMT; tshark/wireshark will display date/time as adjusted by timezone */			ts_usec = 0;		}		else		{			/* Parse subseconds */			ts_usec = strtol(subsecs, &p, 10);			if (subsecs == p) {				/* Error */				ts_usec = 0;			} else {				/*				 * Convert that number to a number				 * of microseconds; if it's N digits				 * long, it's in units of 10^(-N) seconds,				 * so, to convert it to units of				 * 10^-6 seconds, we multiply by				 * 10^(6-N).				 */				subseclen = (int) (p - subsecs);				if (subseclen > 6) {					/*					 * *More* than 6 digits; 6-N is					 * negative, so we divide by					 * 10^(N-6).					 */					for (i = subseclen - 6; i != 0; i--)						ts_usec /= 10;				} else if (subseclen < 6) {					for (i = 6 - subseclen; i != 0; i--)						ts_usec *= 10;				}			}		}	}	if (debug >= 2) {		char *c;		while ((c = strchr(packet_preamble, '/r')) != NULL) *c=' ';		fprintf(stderr, "[[parse_preamble: /"%s/"]]/n", packet_preamble);		fprintf(stderr, "Format(%s), time(%u), subsecs(%u)/n", ts_fmt, (guint32)ts_sec, ts_usec);	}	/* Clear Preamble */	packet_preamble_len = 0;//.........这里部分代码省略.........
开发者ID:dogphilly,项目名称:wireshark,代码行数:101,


示例13: parse_and_write_detail_data

//.........这里部分代码省略.........    /* Current weather forecast */    /* Evaluate xpath expression */    xpathObj = xmlXPathEvalExpression((const xmlChar*)"/html/body/div/div/table//tr[1]/th[@colspan='4']/text()", xpathCtx);      if(xpathObj == NULL) {        fprintf(stderr,"Error: unable to evaluate xpath expression /"%s/"/n", " /html/body/div/div/table//tr[1]/th[@colspan='4']/text()");        xmlXPathFreeContext(xpathCtx);         return(-1);    }    temp_char = strchr(xpathObj->nodesetval->nodeTab[0]->content, ' ');    if (temp_char == NULL || strlen(temp_char)<2)        return -1;    temp_char = temp_char + 1;    temp_char = strchr(temp_char, ' ');    if (temp_char != NULL){        for (j=0; j<strlen(temp_char)-1; j++){            if (temp_char[j] == ' ' || temp_char[j] == '/n')                continue;             else{                temp_char = temp_char + j;                break;            }        }    }    xpathObj = xmlXPathEvalExpression((const xmlChar*)"/html/body/div/div/table//tr[3]/td[@class='in']/text()", xpathCtx);    if (xpathObj && xpathObj->nodesetval->nodeTab[0]->content){        snprintf(buffer, sizeof(buffer)-1,"%s %s", temp_char, xpathObj->nodesetval->nodeTab[0]->content);        current_time = time(NULL);        tm = localtime(&current_time);        setlocale(LC_TIME, "POSIX");        strptime((const char*)buffer, "%d/%m %H:%M", &tmp_tm);        setlocale(LC_TIME, "");        /* set begin of day in localtime */        tmp_tm.tm_year = tm->tm_year;        t_start = mktime(&tmp_tm);        fprintf(file_out,"    <period start=/"%li/"", (t_start + 1 - 2*3600));        /* set end of current time in localtime */        t_end = t_start + 3600*4 - 1;        fprintf(file_out," end=/"%li/" current=/"true/" >/n", t_end);    }    if (xpathObj)        xmlXPathFreeObject(xpathObj);    xpathObj = xmlXPathEvalExpression((const xmlChar*)"/html/body/div/div/table//tr[3]/td[2]/span/text()", xpathCtx);    /* added temperature */    if (xpathObj && !xmlXPathNodeSetIsEmpty(xpathObj->nodesetval) &&        xpathObj->nodesetval->nodeTab[0] && xpathObj->nodesetval->nodeTab[0]->content){        /* fprintf (stderr, "temperature %s/n", xpathObj->nodesetval->nodeTab[0]->content); */        snprintf(buffer, sizeof(buffer)-1,"%s", xpathObj->nodesetval->nodeTab[0]->content);        memset(temp_buffer, 0, sizeof(temp_buffer));        for (j = 0 ; (j<(strlen(buffer)) && j < buff_size); j++ ){            if (buffer[j] == '&')               break;            if ((uint)buffer[j] == 226 ||  buffer[j] == '-' ||                 (buffer[j]>='0' && buffer[j]<='9')){                if ((uint)buffer[j] == 226)                   sprintf(temp_buffer,"%s-",temp_buffer);                else                   sprintf(temp_buffer,"%s%c",temp_buffer, buffer[j]);            }        }
开发者ID:AnadoluPanteri,项目名称:meecast,代码行数:67,


示例14: parse_and_write_xml_data

//.........这里部分代码省略.........    xpathObj2 = xmlXPathEvalExpression("/html/body/div/div/table//tr/td[@class='in']//span[1]/text()", xpathCtx);    xpathObj3 = xmlXPathEvalExpression("/html/body/div/div/table//tr/td[@class='in']//span[2]/text()", xpathCtx);    xpathObj4 = xmlXPathEvalExpression("/html/body/div/div/table//tr/td[2]/img/@alt", xpathCtx);    xpathObj5 = xmlXPathEvalExpression("/html/body/div/div/table//tr/td[2]/text()", xpathCtx);    xpathObj6 = xmlXPathEvalExpression("/html/body/div/div/table//tr/td[3]/img/@src", xpathCtx);    xpathObj7 = xmlXPathEvalExpression("/html/body/div/div/table//tr/td[@class='in2']/text()[1]", xpathCtx);    xpathObj8 = xmlXPathEvalExpression("/html/body/div/div/table//tr/td[@class='in2']/text()[2]", xpathCtx);      /* fprintf(stderr, "Result (%d nodes):/n", size); */    for(i = 0; i < size; ++i) {         day = NULL;         /* Take time: */         if (!nodes->nodeTab[i]->children->content)             continue;         temp_char = strstr(nodes->nodeTab[i]->children->content, " ");         int j = 0;         if (temp_char != NULL){             for (j=0; j<strlen(temp_char)-1; j++){                 if (temp_char[j] == ' ' || temp_char[j] == '/n')                     continue;                  else{                     temp_char = temp_char + j;                     break;                 }             }         }         if (temp_char == NULL)            continue;         current_time = time(NULL);         tm = localtime(&current_time);         setlocale(LC_TIME, "POSIX");         strptime((const char*)temp_char, "%b %d", &tmp_tm);         setlocale(LC_TIME, "");         /* set begin of day in localtime */         tmp_tm.tm_year = tm->tm_year;         tmp_tm.tm_hour = 0; tmp_tm.tm_min = 0; tmp_tm.tm_sec = 0;         t_start = mktime(&tmp_tm);         fprintf(file_out,"    <period start=/"%li/"", (t_start +1));         /* set end of day in localtime */         t_end = t_start + 3600*24 - 1;         fprintf(file_out," end=/"%li/">/n", t_end);                         /* added hi temperature */         if (xpathObj2 && !xmlXPathNodeSetIsEmpty(xpathObj2->nodesetval) &&             xpathObj2->nodesetval->nodeTab[i] && xpathObj2->nodesetval->nodeTab[i]->content){             /* fprintf (stderr, "temperature %s/n", xpathObj2->nodesetval->nodeTab[i]->content); */             snprintf(buffer, sizeof(buffer)-1,"%s", xpathObj2->nodesetval->nodeTab[i]->content);             memset(temp_buffer, 0, sizeof(temp_buffer));             for (j = 0 ; (j<(strlen(buffer)) && j < buff_size); j++ ){                 if (buffer[j] == '&')                    break;                 if ((uint)buffer[j] == 226 ||  buffer[j] == '-' ||                      (buffer[j]>='0' && buffer[j]<='9')){                     if ((uint)buffer[j] == 226)                        sprintf(temp_buffer,"%s-",temp_buffer);                     else                        sprintf(temp_buffer,"%s%c",temp_buffer, buffer[j]);                 }             }             /* fprintf(stderr, "     <temperature>%s</temperature>/n", temp_buffer); */             fprintf(file_out,"     <temperature_hi>%s</temperature_hi>/n", temp_buffer);          }
开发者ID:AnadoluPanteri,项目名称:meecast,代码行数:67,


示例15: parse_timestamp

//.........这里部分代码省略.........        if (streq(t, "today")) {                tm.tm_sec = tm.tm_min = tm.tm_hour = 0;                goto from_tm;        } else if (streq(t, "yesterday")) {                tm.tm_mday--;                tm.tm_sec = tm.tm_min = tm.tm_hour = 0;                goto from_tm;        } else if (streq(t, "tomorrow")) {                tm.tm_mday++;                tm.tm_sec = tm.tm_min = tm.tm_hour = 0;                goto from_tm;        }        for (i = 0; i < ELEMENTSOF(day_nr); i++) {                size_t skip;                if (!startswith_no_case(t, day_nr[i].name))                        continue;                skip = strlen(day_nr[i].name);                if (t[skip] != ' ')                        continue;                weekday = day_nr[i].nr;                t += skip + 1;                break;        }        copy = tm;        k = strptime(t, "%y-%m-%d %H:%M:%S", &tm);        if (k) {                if (*k == '.')                        goto parse_usec;                else if (*k == 0)                        goto from_tm;        }        tm = copy;        k = strptime(t, "%Y-%m-%d %H:%M:%S", &tm);        if (k) {                if (*k == '.')                        goto parse_usec;                else if (*k == 0)                        goto from_tm;        }        tm = copy;        k = strptime(t, "%y-%m-%d %H:%M", &tm);        if (k && *k == 0) {                tm.tm_sec = 0;                goto from_tm;        }        tm = copy;        k = strptime(t, "%Y-%m-%d %H:%M", &tm);        if (k && *k == 0) {                tm.tm_sec = 0;                goto from_tm;        }        tm = copy;        k = strptime(t, "%y-%m-%d", &tm);
开发者ID:ChALkeR,项目名称:systemd,代码行数:67,


示例16: http_response_handle_cachable

int http_response_handle_cachable(server *srv, connection *con, buffer *mtime, buffer *etag) {	data_string *http_if_none_match;	data_string *http_if_modified_since;	UNUSED(srv);	/*	 * 14.26 If-None-Match	 *    [...]	 *    If none of the entity tags match, then the server MAY perform the	 *    requested method as if the If-None-Match header field did not exist,	 *    but MUST also ignore any If-Modified-Since header field(s) in the	 *    request. That is, if no entity tags match, then the server MUST NOT	 *    return a 304 (Not Modified) response.	 */	http_if_none_match = (data_string *)array_get_element(con->request.headers, CONST_STR_LEN("if-none-match"));	http_if_modified_since = (data_string *)array_get_element(con->request.headers, CONST_STR_LEN("if-modified-since"));	/* last-modified handling */	if (http_if_none_match) {		if (etag_is_equal(etag, BUF_STR(http_if_none_match->value))) {			if (con->request.http_method == HTTP_METHOD_GET ||			    con->request.http_method == HTTP_METHOD_HEAD) {				/* check if etag + last-modified */				if (http_if_modified_since) {					size_t used_len;					char *semicolon;					if (NULL == (semicolon = strchr(BUF_STR(http_if_modified_since->value), ';'))) {						used_len = http_if_modified_since->value->used - 1;					} else {						used_len = semicolon - BUF_STR(http_if_modified_since->value);					}					if (0 == strncmp(BUF_STR(http_if_modified_since->value), mtime->ptr, used_len)) {						if ('/0' == mtime->ptr[used_len]) con->http_status = 304;						return HANDLER_FINISHED;					} else {#ifdef HAVE_STRPTIME						char buf[sizeof("Sat, 23 Jul 2005 21:20:01 GMT")];						time_t t_header, t_file;						struct tm tm;						/* check if we can safely copy the string */						if (used_len >= sizeof(buf)) {							TRACE("last-mod check failed as timestamp was too long: %s: %zu, %zu",									SAFE_BUF_STR(http_if_modified_since->value),									used_len, sizeof(buf) - 1);							con->http_status = 412;							return HANDLER_FINISHED;						}						strncpy(buf, BUF_STR(http_if_modified_since->value), used_len);						buf[used_len] = '/0';						if (NULL == strptime(buf, "%a, %d %b %Y %H:%M:%S GMT", &tm)) {							con->http_status = 412;							return HANDLER_FINISHED;						}						tm.tm_isdst = 0;						t_header = mktime(&tm);						strptime(mtime->ptr, "%a, %d %b %Y %H:%M:%S GMT", &tm);						tm.tm_isdst = 0;						t_file = mktime(&tm);						if (t_file > t_header) return HANDLER_GO_ON;						con->http_status = 304;						return HANDLER_FINISHED;#else						return HANDLER_GO_ON;#endif					}				} else {					con->http_status = 304;					return HANDLER_FINISHED;				}			} else {				con->http_status = 412;				return HANDLER_FINISHED;			}		}	} else if (http_if_modified_since) {		size_t used_len;		char *semicolon;		if (NULL == (semicolon = strchr(BUF_STR(http_if_modified_since->value), ';'))) {			used_len = http_if_modified_since->value->used - 1;		} else {			used_len = semicolon - BUF_STR(http_if_modified_since->value);		}		if (0 == strncmp(BUF_STR(http_if_modified_since->value), mtime->ptr, used_len)) {			if ('/0' == mtime->ptr[used_len]) con->http_status = 304;			return HANDLER_FINISHED;//.........这里部分代码省略.........
开发者ID:deba12,项目名称:lighttpd-1.5,代码行数:101,


示例17: _ftw_callback

/** * Analyzes a file and copies it if it contains image data. * @param fpath The filename of the current entry. * @param sb A pointer to the stat structure. * @param typeflag The current entry type. */static int_ftw_callback(char const* fpath, struct stat const* sb, int typeflag){  int rc;  ExifData* exif_data;  ExifEntry* exif_entry;  char exif_entry_val[20];  struct tm tm;  // The current entry is not a file. Skip it.  if (!S_ISREG(sb->st_mode)) {    return 0;  }  // The current entry has no EXIF data. Skip it.  exif_data = exif_data_new_from_file(fpath);  if (exif_data == NULL) {    return 0;  }  rc = 0;  exif_entry = exif_content_get_entry(*(exif_data->ifd), EXIF_TAG_DATE_TIME);  if (exif_entry != NULL      && exif_entry_get_value(exif_entry, exif_entry_val, 20) != NULL      && strptime(exif_entry_val, "%Y:%m:%d %H:%M:%S", &tm) != 0) {    size_t dst_size;    char* dst;    dst_size = strlen(_DST) + 12;    dst = (char*) malloc(dst_size);    // Create the destination path.    if (snprintf(dst, dst_size, "%s/%d/%02d/%02d", _DST, tm.tm_year + 1900,                 tm.tm_mon + 1, tm.tm_mday) >= 0        && _mkdir_recursive(dst) == 0) {      size_t offset;      char* dst_fpath;      offset = strlen(fpath);      while (offset > 0 && fpath[offset - 1] != '/') {        --offset;      }      // Copy the file.      dst_fpath = (char*) malloc(strlen(dst) + strlen(fpath + offset) + 2);      sprintf(dst_fpath, "%s/%s", dst, fpath + offset);      rc = _cp(dst_fpath, fpath);      free(dst_fpath);      if (rc == -1 && errno == EEXIST) {        rc = 0;      }    }    free(dst);  }  exif_data_unref(exif_data);  return rc;}
开发者ID:kjiwa,项目名称:coprissi,代码行数:67,


示例18: strptime

char *strptime(const char *buf, const char *fmt, struct tm *tm){	unsigned char c;	const unsigned char *bp, *ep;	int alt_format, i, split_year = 0, neg = 0, offs;	const char *new_fmt;	bp = (const u_char *)buf;	while (bp != NULL && (c = *fmt++) != '/0') {		/* Clear `alternate' modifier prior to new conversion. */		alt_format = 0;		i = 0;		/* Eat up white-space. */		if (isspace(c)) {			while (isspace(*bp))				bp++;			continue;		}		if (c != '%')			goto literal;again:		switch (c = *fmt++) {		case '%':	/* "%%" is converted to "%". */literal:			if (c != *bp++)				return NULL;			LEGAL_ALT(0);			continue;		/*		 * "Alternative" modifiers. Just set the appropriate flag		 * and start over again.		 */		case 'E':	/* "%E?" alternative conversion modifier. */			LEGAL_ALT(0);			alt_format |= ALT_E;			goto again;		case 'O':	/* "%O?" alternative conversion modifier. */			LEGAL_ALT(0);			alt_format |= ALT_O;			goto again;		/*		 * "Complex" conversion rules, implemented through recursion.		 */#ifdef _ctloc		case 'c':	/* Date and time, using the locale's format. */			new_fmt = _ctloc(d_t_fmt);			goto recurse;#endif		case 'D':	/* The date as "%m/%d/%y". */			new_fmt = "%m/%d/%y";			LEGAL_ALT(0);			goto recurse;		case 'F':	/* The date as "%Y-%m-%d". */			new_fmt = "%Y-%m-%d";			LEGAL_ALT(0);			goto recurse;		case 'R':	/* The time as "%H:%M". */			new_fmt = "%H:%M";			LEGAL_ALT(0);			goto recurse;#ifdef _ctloc		case 'r':	/* The time in 12-hour clock representation. */			new_fmt =_ctloc(t_fmt_ampm);			LEGAL_ALT(0);			goto recurse;#endif		case 'T':	/* The time as "%H:%M:%S". */			new_fmt = "%H:%M:%S";			LEGAL_ALT(0);			goto recurse;#ifdef _ctloc		case 'X':	/* The time, using the locale's format. */			new_fmt =_ctloc(t_fmt);			goto recurse;#endif#ifdef _ctloc		case 'x':	/* The date, using the locale's format. */			new_fmt =_ctloc(d_fmt);#endifrecurse:			bp = (const u_char *)strptime((const char *)bp,							    new_fmt, tm);			LEGAL_ALT(ALT_E);			continue;//.........这里部分代码省略.........
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:101,


示例19: strptime

/* extern "C" */char */* strptime (const char *buf, const char *format, struct tm *timeptr) */strptime (const char *buf, const char *format, struct tm *timeptr){    char c;    for (; (c = *format) != '/0'; ++format) {	char *s;	int ret;	if (isspace (c)) {	    while (isspace (*buf))		++buf;	} else if (c == '%' && format[1] != '/0') {	    c = *++format;	    if (c == 'E' || c == 'O')		c = *++format;	    switch (c) {	    case 'A' :		ret = match_string (&buf, full_weekdays);		if (ret < 0)		    return NULL;		timeptr->tm_wday = ret;		break;	    case 'a' :		ret = match_string (&buf, abb_weekdays);		if (ret < 0)		    return NULL;		timeptr->tm_wday = ret;		break;	    case 'B' :		ret = match_string (&buf, full_month);		if (ret < 0)		    return NULL;		timeptr->tm_mon = ret;		break;	    case 'b' :	    case 'h' :		ret = match_string (&buf, abb_month);		if (ret < 0)		    return NULL;		timeptr->tm_mon = ret;		break;	    case 'C' :		ret = strtol (buf, &s, 10);		if (s == buf)		    return NULL;		timeptr->tm_year = (ret * 100) - tm_year_base;		buf = s;		break;	    case 'c' :		abort ();	    case 'D' :		/* %m/%d/%y */		s = strptime (buf, "%m/%d/%y", timeptr);		if (s == NULL)		    return NULL;		buf = s;		break;	    case 'd' :	    case 'e' :		ret = strtol (buf, &s, 10);		if (s == buf)		    return NULL;		timeptr->tm_mday = ret;		buf = s;		break;	    case 'H' :	    case 'k' :		ret = strtol (buf, &s, 10);		if (s == buf)		    return NULL;		timeptr->tm_hour = ret;		buf = s;		break;	    case 'I' :	    case 'l' :		ret = strtol (buf, &s, 10);		if (s == buf)		    return NULL;		if (ret == 12)		    timeptr->tm_hour = 0;		else		    timeptr->tm_hour = ret;		buf = s;		break;	    case 'j' :		ret = strtol (buf, &s, 10);		if (s == buf)		    return NULL;		timeptr->tm_yday = ret - 1;		buf = s;		break;	    case 'm' :		ret = strtol (buf, &s, 10);		if (s == buf)		    return NULL;		timeptr->tm_mon = ret - 1;		buf = s;		break;//.........这里部分代码省略.........
开发者ID:havatv,项目名称:mapcache,代码行数:101,


示例20: talloc_new

/*  convert a filename from a share relative path, to a path in the  snapshot directory */static char *convert_shadow2_name(vfs_handle_struct *handle, const char *fname, const char *gmt_path){	TALLOC_CTX *tmp_ctx = talloc_new(handle->data);	const char *snapdir, *relpath, *baseoffset, *basedir;	size_t baselen;	char *ret;	struct tm timestamp;	time_t timestamp_t;	char snapshot[MAXPATHLEN];	const char *fmt;	fmt = lp_parm_const_string(SNUM(handle->conn), "shadow",				   "format", SHADOW_COPY2_DEFAULT_FORMAT);	snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle);	if (snapdir == NULL) {		DEBUG(2,("no snapdir found for share at %s/n", handle->conn->connectpath));		talloc_free(tmp_ctx);		return NULL;	}	basedir = shadow_copy2_find_basedir(tmp_ctx, handle);	if (basedir == NULL) {		DEBUG(2,("no basedir found for share at %s/n", handle->conn->connectpath));		talloc_free(tmp_ctx);		return NULL;	}	if (strncmp(fname, "@GMT-", 5) != 0) {		fname = shadow_copy2_normalise_path(tmp_ctx, fname, gmt_path);		if (fname == NULL) {			talloc_free(tmp_ctx);			return NULL;		}	}	ZERO_STRUCT(timestamp);	relpath = strptime(fname, SHADOW_COPY2_GMT_FORMAT, &timestamp);	if (relpath == NULL) {		talloc_free(tmp_ctx);		return NULL;	}	/* relpath is the remaining portion of the path after the @GMT-xxx */	if (lp_parm_bool(SNUM(handle->conn), "shadow", "localtime",			 SHADOW_COPY2_DEFAULT_LOCALTIME))	{		timestamp_t = timegm(&timestamp);		localtime_r(&timestamp_t, &timestamp);	}	strftime(snapshot, MAXPATHLEN, fmt, &timestamp);	baselen = strlen(basedir);	baseoffset = handle->conn->connectpath + baselen;	/* some sanity checks */	if (strncmp(basedir, handle->conn->connectpath, baselen) != 0 ||	    (handle->conn->connectpath[baselen] != 0 && handle->conn->connectpath[baselen] != '/')) {		DEBUG(0,("convert_shadow2_name: basedir %s is not a parent of %s/n",			 basedir, handle->conn->connectpath));		talloc_free(tmp_ctx);		return NULL;	}	if (*relpath == '/') relpath++;	if (*baseoffset == '/') baseoffset++;	ret = talloc_asprintf(handle->data, "%s/%s/%s/%s",			      snapdir, 			      snapshot,			      baseoffset, 			      relpath);	DEBUG(6,("convert_shadow2_name: '%s' -> '%s'/n", fname, ret));	talloc_free(tmp_ctx);	return ret;}
开发者ID:endisd,项目名称:samba,代码行数:83,


示例21: parse_request

void parse_request(router_request_t *req, tdata_t *tdata, HashGrid *hg, int opt, char *optarg) {    const char delim[2] = ",";    char *token;    switch (opt) {    case 'a':        req->arrive_by = true;        break;    case 'd':        req->arrive_by = false;        break;    case 'r':        srand(time(NULL));        router_request_randomize(req, tdata);        break;    case 'D':        {            struct tm ltm;            memset (&ltm, 0, sizeof(struct tm));            strptime (optarg, "%Y-%m-%dT%H:%M:%S", &ltm);            ltm.tm_isdst = -1;            router_request_from_epoch (req, tdata, mktime(&ltm)); // from struct_tm instead?        }        break;    case 'f':        req->from = strtol(optarg, NULL, 10);        break;    case 't':        req->to = strtol(optarg, NULL, 10);        break;    case 'V':        req->via = strtol(optarg, NULL, 10);        break;    case 's':        req->walk_slack = strtol(optarg, NULL, 10);        break;    case 'S':        req->walk_speed = strtod(optarg, NULL);        break;    case 'o':        req->optimise = 0;        token = strtok(optarg, delim);        while ( token != NULL ) {            if (strcmp(token, "shortest")  == 0) req->optimise |= o_shortest;            if (strcmp(token, "transfers") == 0) req->optimise |= o_transfers;            if (strcmp(token, "all")       == 0) req->optimise  = o_all;            token = strtok(NULL, delim);        }        break;    case 'l':    case 'L':        if (hg) {            token = strtok(optarg, delim);            if (token != NULL) {                double lat = strtod(token, NULL);                token = strtok(NULL, delim);                if (token != NULL) {                    double lon = strtod(token, NULL);                    HashGridResult result;                    coord_t qc;                    double radius_meters = 150;                    coord_from_lat_lon (&qc, lat, lon);                    HashGrid_query (hg, &result, qc, radius_meters);                    uint32_t item = HashGridResult_closest (&result);                    if (opt == 'l') {                        req->from = item;                    } else {                        req->to = item;                    }                }            }        }    break;    case 'm':        req->mode = 0;        token = strtok(optarg, delim);        while ( token  != NULL ) {            if (strcmp(token, "tram") == 0)      req->mode |= m_tram;            if (strcmp(token, "subway") == 0)    req->mode |= m_subway;            if (strcmp(token, "rail") == 0)      req->mode |= m_rail;            if (strcmp(token, "bus") == 0)       req->mode |= m_bus;            if (strcmp(token, "ferry") == 0)     req->mode |= m_ferry;            if (strcmp(token, "cablecar") == 0)  req->mode |= m_cablecar;            if (strcmp(token, "gondola") == 0)   req->mode |= m_gondola;            if (strcmp(token, "funicular") == 0) req->mode |= m_funicular;            if (strcmp(token, "all") == 0)       req->mode = m_all;            token = strtok(NULL, delim);        }        break;    case 'A':        token = strtok(optarg, delim);        while ( token != NULL ) {            if (strcmp(token, "accessible") == 0) req->trip_attributes |= ta_accessible;            if (strcmp(token, "toilet")     == 0) req->trip_attributes |= ta_toilet;            if (strcmp(token, "wifi")       == 0) req->trip_attributes |= ta_wifi;            if (strcmp(token, "none")       == 0) req->trip_attributes =  ta_none;//.........这里部分代码省略.........
开发者ID:BennyKJohnson,项目名称:rrrr,代码行数:101,


示例22: main

//.........这里部分代码省略.........            break;            /* version */        case 'V':            action.version = 1;            action.help = 0;            action.normal = 0;            action.format = 0;            action.rfc2822 = 0;            break;        default:            fprintf(stderr, "jdate: usage [OPTION]... [+FORMAT]/n");            exit(EXIT_FAILURE);        }    }    /*     * Format string handler. INPUT_FORMAT and DATE_STRING     * are separated using a semicolon. ';'     * e.g. "%Y/%m/%d %H:%M:%S;1390/03/06 18:35:41"     */    for (i=1; i<argc; i++) {        if (argv[i][0] == '+') {            action.format = 1;            action.format_ptr = &argv[i][1];        }    }    /*     *@action_handlers     */    if (action.jalali) {        if (!strptime(action.jalali_ptr, "%Y/%m/%d", &g)) {            fprintf(stderr, "Specify gregorian date in the following format/n");            fprintf(stderr, "%%Y/%%m/%%d e.g. 2011/06/15/n");            exit(EXIT_FAILURE);        }        g.tm_hour = 0;        g.tm_min = 0;        g.tm_sec = 0;        t = mktime(&g);    } else if (action.gregorian) {        if (!jstrptime(action.gregorian_ptr, "%Y/%m/%d", &j)) {            fprintf(stderr, "Specify jalali date in the following format/n");            fprintf(stderr, "%%Y/%%m/%%d e.g. 1390/03/25/n");            exit(EXIT_FAILURE);        }        jalali_update(&j);        j.tm_hour = 0;        j.tm_min = 0;        j.tm_sec = 0;        t = jmktime(&j);    }    if (action.date) {        char* ptr;        ptr = strchr(action.date_ptr, ';');        if (!ptr) {
开发者ID:AhmadHamzeei,项目名称:jcal,代码行数:67,


示例23: get_calendar_events

// -------------------------------------------------------------------------// This software is furnished "as is", without technical// support, and with no warranty, express or implied, as to its usefulness for// any purpose.//// gcal.c //    This file acts as the wrapper around the sp_func.py python library//// Author: Vedvyas Shanbhogue// ------------------------------------------------------------------------*/#ifdef IDENT_Cstatic const char* const <filename>_c_Id = "$Id$";#endif#include <Python.h>// -- global -----------------------------------------------------------------// get_calendar_events()//// Returns://     0 - success //     1 - error// On success return, the duration is set to the duration of the event// if no event was found then duration is returned as 0// -------------------------------------------------------------------------*/int get_calendar_events(    time_t *duration){    PyObject *pName, *pModule, *pDict, *pFunc, *pValue;    struct tm start_time, end_time;    char *start, *end, *name;    char *argv[] = {        "sp",        "sp_func",        "get_cal_events"    };    // Initialize the Python Interpreter    Py_Initialize();    // Build the name object    pName = PyString_FromString(argv[1]);    // Load the module object    PySys_SetArgv(1, argv);    PyErr_Print();    pModule = PyImport_Import(pName);    PyErr_Print();    // pDict is a borrowed reference     pDict = PyModule_GetDict(pModule);    // pFunc is also a borrowed reference     pFunc = PyDict_GetItemString(pDict, argv[2]);    if ( !PyCallable_Check(pFunc) ) {        PyErr_Print();        Py_DECREF(pModule);        Py_DECREF(pName);        Py_Finalize();        return 1;    }    // Get the calendar events from google calendar    pValue = PyObject_CallObject(pFunc, NULL);    // Extract the start time, end time and event name strings    if ( PyArg_ParseTuple(pValue, "sss", &start, &end, &name) == 0 )    {        PyErr_Print();        Py_DECREF(pModule);        Py_DECREF(pName);        Py_Finalize();        return 1;    }    *duration = 0;    // check if any event returned    if ( strlen(start) && strlen(end) && strlen(name) &&         (strcmp(name, "Sprinkler On") == 0) ) {        // Turn time strings into struct tm        strptime(start, "%Y-%m-%dT%T", &start_time);        strptime(end, "%Y-%m-%dT%T", &end_time);        // Check if it is time to start the sprinker        if ( time(NULL) >= mktime(&start_time) &&             time(NULL) < mktime(&end_time) ) {            // Time to start the sprinker for specified duration            *duration = mktime(&end_time) - time(NULL);        }    }    Py_DECREF(pModule);    Py_DECREF(pName);    Py_Finalize();    return 0;//.........这里部分代码省略.........
开发者ID:vedvyas13686,项目名称:sprinkler,代码行数:101,


示例24: http_request

//.........这里部分代码省略.........			break;		#ifdef DEBUGHEADERS				if(sscanf(line, "HTTP/1.%*u %u", &http_status)){					if(http_status != 200)						debugging = 1;				}				if(sscanf(line, "Content-Length: %u", &content_length) || sscanf(line, "Content-Encoding: %s", content_encoding)){					if(!debugging){						InfoPrompt(line);					}				}				if(!strncmp(line, "Transfer-Encoding: chunked", 25)){ InfoPrompt("Transfer-Encoding: chunked"); chunked = 1; }		#else				sscanf(line, "HTTP/1.%*u %u", &http_status);				sscanf(line, "Content-Length: %u", &content_length);				sscanf(line, "Content-Encoding: %s", content_encoding);				if(!strncmp(line, "Transfer-Encoding: chunked", 25)) chunked = 1;		#endif		u32 api_ratelimit=0;		if(sscanf(line, "X-RateLimit-Remaining: %u", &api_ratelimit) && api_ratelimit <= 10 && api_ratelimit % 5 == 0){			WindowPrompt("You are on fire!", "You are about to reach Twitter's requests limit. WiiTweet will not work correctly then.", "I'll take a break", 0);		}				if(get_timeoffset){			if(!strncasecmp(line, "Date:", 5)){ //Case insensitiveness just in case...				const char format[] = "%a, %d %b %Y %H:%M:%S %Z";				const char *pointline = line;				pointline += 6;				struct tm tm;				memset(&tm, 0, sizeof(tm));				strptime(pointline, format, &tm);				timeoffset = mktime(&tm) - time(NULL);				get_timeoffset = 0;			}		}		#ifdef DEBUGHEADERS			if(debugging){				InfoPrompt(line);			}		#endif	}	if (http_status != 200)	{		result = HTTPR_ERR_STATUS;		#ifdef DEBUGERRORS			if(ssl_context){				if(ssl_shutdown(ssl_context)){					InfoPrompt("ssl_shutdown() 1");				}			}			net_close(s);		#else			if(ssl_context){ssl_shutdown(ssl_context);} net_close(s);		#endif		#ifdef DEBUGERRORS			char status[64];			sprintf(status, "HTTP Status = %d", http_status);			InfoPrompt(status);		#endif		return 0;	}//Try to read anyways? ssl gets rude if it is not convinced there is no data
开发者ID:ifish12,项目名称:WiiTweet,代码行数:66,


示例25: parse_timestamp

//.........这里部分代码省略.........                        return r;                goto finish;        } else if (endswith(t, " left")) {                _cleanup_free_ char *z;                z = strndup(t, strlen(t) - 4);                if (!z)                        return -ENOMEM;                r = parse_sec(z, &plus);                if (r < 0)                        return r;                goto finish;        }        for (i = 0; i < ELEMENTSOF(day_nr); i++) {                size_t skip;                if (!startswith_no_case(t, day_nr[i].name))                        continue;                skip = strlen(day_nr[i].name);                if (t[skip] != ' ')                        continue;                weekday = day_nr[i].nr;                t += skip + 1;                break;        }        copy = tm;        k = strptime(t, "%y-%m-%d %H:%M:%S", &tm);        if (k && *k == 0)                goto finish;        tm = copy;        k = strptime(t, "%Y-%m-%d %H:%M:%S", &tm);        if (k && *k == 0)                goto finish;        tm = copy;        k = strptime(t, "%y-%m-%d %H:%M", &tm);        if (k && *k == 0) {                tm.tm_sec = 0;                goto finish;        }        tm = copy;        k = strptime(t, "%Y-%m-%d %H:%M", &tm);        if (k && *k == 0) {                tm.tm_sec = 0;                goto finish;        }        tm = copy;        k = strptime(t, "%y-%m-%d", &tm);        if (k && *k == 0) {                tm.tm_sec = tm.tm_min = tm.tm_hour = 0;                goto finish;        }        tm = copy;        k = strptime(t, "%Y-%m-%d", &tm);        if (k && *k == 0) {
开发者ID:ajeddeloh,项目名称:systemd,代码行数:67,


示例26: parseISO8601Date

/* converts a ISO 8601 time string to a time_t value */time_t parseISO8601Date(gchar *date) {	struct tm	tm;	time_t		t, t2, offset = 0;	gboolean	success = FALSE;	gchar *pos;	if (date == NULL)		return -1;		memset(&tm, 0, sizeof(struct tm));		/* we expect at least something like "2003-08-07T15:28:19" and	   don't require the second fractions and the timezone info	   the most specific format:   YYYY-MM-DDThh:mm:ss.sTZD	 */	 	/* full specified variant */	if(NULL != (pos = strptime((const char *)date, "%Y-%m-%dT%H:%M:%SZ", &tm))) {		/* Parse seconds */		if (*pos == ':')			pos++;		if (isdigit(pos[0]) && !isdigit(pos[1])) {			tm.tm_sec = pos[0] - '0';			pos++;		} else if (isdigit(pos[0]) && isdigit(pos[1])) {			tm.tm_sec = 10*(pos[0]-'0') + pos[1] - '0';			pos +=2;		}		/* Parse timezone */		if (*pos == 'Z')			offset = 0;		else if ((*pos == '+' || *pos == '-') && isdigit(pos[1]) && isdigit(pos[2]) && strlen(pos) >= 3) {			offset = (10*(pos[1] - '0') + (pos[2] - '0')) * 60 * 60;						if (pos[3] == ':' && isdigit(pos[4]) && isdigit(pos[5]))				offset +=  (10*(pos[4] - '0') + (pos[5] - '0')) * 60;			else if (isdigit(pos[3]) && isdigit(pos[4]))				offset +=  (10*(pos[3] - '0') + (pos[4] - '0')) * 60;						offset *= (pos[0] == '+') ? 1 : -1;		}		success = TRUE;	/* only date */	} else if(NULL != strptime((const char *)date, "%t%Y-%m-%d", &tm))		success = TRUE;	/* there were others combinations too... */	if(TRUE == success) {		if((time_t)(-1) != (t = mktime(&tm))) {			/* Correct for the local timezone*/			t = t - offset;			t2 = mktime(gmtime(&t));			t = t - (t2 - t);						return t;		} else {			g_warning("internal error! time conversion error! mktime failed!/n");		}	} else {		g_warning("Invalid ISO8601 date format! Ignoring <dc:date> information!/n");	}		return 0;}
开发者ID:mishamehra,项目名称:claws-mail,代码行数:67,


示例27: main

//.........这里部分代码省略.........	exit( 0 );    }    if ( mysql_options( &mysql, MYSQL_READ_DEFAULT_FILE, config ) != 0 ) {	fprintf( stderr, "mysql_options %s failed/n", config );	exit( 0 );    }    if ( mysql_real_connect( &mysql, NULL, NULL, NULL, NULL, 0, NULL, 0 )	    == NULL ) {	fprintf( stderr, "MySQL connection failed: %s/n",		mysql_error( &mysql ));	exit( 0 );    }    len = strlen( from );    if (( escaped_from = malloc( len * 2 + 1 )) == NULL ) {	perror( "malloc" );	exit( 0 );    }    mysql_real_escape_string( &mysql, escaped_from, from, len );    if (( len = snprintf( query, sizeof( query ),	    "INSERT INTO signatures () VALUES"	    " ('%s', '%s', '%s', DEFAULT, '%s')",	    cksum, ip, escaped_from, reason )) >= sizeof( query )) {	fprintf( stderr, "INSERT too long! %d/n", len );	exit( 0 );    }    if (( rc = mysql_real_query( &mysql, query, len )) == 0 ) {	/*	 * Should I commit this transaction?  Should I close the connection?	 */	printf( "PenaltyBox: Record: [%s] <%s> %s/n", ip, from, reason );	exit( 1 );    }    if ( ER_DUP_ENTRY != mysql_errno( &mysql )) {	fprintf( stderr, "INSERT %s/n", mysql_error( &mysql ));	exit( 0 );    }    if (( len = snprintf( query, sizeof( query ),	    "SELECT time, reason FROM signatures WHERE"	    " checksum = '%s' AND ip_address = '%s' AND from_address = '%s'"	    " LIMIT 1",	    cksum, ip, escaped_from )) >= sizeof( query )) {	fprintf( stderr, "SELECT too long! %d/n", len );	exit( 0 );    }    if ( mysql_real_query( &mysql, query, len ) != 0 ) {	fprintf( stderr, "SELECT failed: %s/n", mysql_error( &mysql ));	exit( 0 );    }    if (( result = mysql_store_result( &mysql )) == NULL ) {	fprintf( stderr, "mysql_store_result failed: %s/n",		mysql_error( &mysql ));	exit( 0 );    }    if (( row = mysql_fetch_row( result )) == NULL ) {	fprintf( stderr, "mysql_fetch_row failed: %s/n",		mysql_error( &mysql ));	exit( 0 );    }    /* time is in the format YYYY-MM-DD HH:MM:SS */    tm.tm_isdst = -1;    if ( strptime( row[ 0 ], "%Y-%m-%d %H:%M:%S", &tm ) == NULL ) {	fprintf( stderr, "Could not parse timestamp: %s/n", row[ 0 ] );	exit( 0 );    }    then = mktime( &tm );    now = time( NULL );    if (( dt = difftime( now, then )) < 5 * 60 ) {	printf( "PenaltyBox: Window: %ds [%s] <%s> %s/n",		(int)dt, ip, from, row[ 1 ] );	exit( 1 );    }    if (( len = snprintf( query, sizeof( query ),	    "DELETE FROM signatures WHERE"	    " checksum = '%s' AND ip_address = '%s' AND from_address = '%s'"	    " LIMIT 1",	    cksum, ip, escaped_from )) >= sizeof( query )) {	fprintf( stderr, "DELETE too long! %d/n", len );	exit( 0 );    }    if ( mysql_real_query( &mysql, query, len ) != 0 ) {	fprintf( stderr, "DELETE failed: %s/n", mysql_error( &mysql ));	exit( 0 );    }    printf( "PenaltyBox: Accept: %ds [%s] <%s> %s/n",	    (int)dt, ip, from, row[ 1 ] );    exit( 0 );}
开发者ID:bawood,项目名称:simta,代码行数:101,


示例28: cloudfs_list_directory

int cloudfs_list_directory(const char *path, dir_entry **dir_list){  char container[MAX_PATH_SIZE * 3] = "";  char object[MAX_PATH_SIZE] = "";  char last_subdir[MAX_PATH_SIZE] = "";  int prefix_length = 0;  int response = 0;  int retval = 0;  int entry_count = 0;  *dir_list = NULL;  xmlNode *onode = NULL, *anode = NULL, *text_node = NULL;  xmlParserCtxtPtr xmlctx = xmlCreatePushParserCtxt(NULL, NULL, "", 0, NULL);  if (!strcmp(path, "") || !strcmp(path, "/"))  {    path = "";    strncpy(container, "/?format=xml", sizeof(container));  }  else  {    sscanf(path, "/%[^/]/%[^/n]", container, object);    char *encoded_container = curl_escape(container, 0);    char *encoded_object = curl_escape(object, 0);    // The empty path doesn't get a trailing slash, everything else does    char *trailing_slash;    prefix_length = strlen(object);    if (object[0] == 0)      trailing_slash = "";    else    {      trailing_slash = "/";      prefix_length++;    }    snprintf(container, sizeof(container), "%s?format=xml&delimiter=/&prefix=%s%s",              encoded_container, encoded_object, trailing_slash);    curl_free(encoded_container);    curl_free(encoded_object);  }  response = send_request("GET", container, NULL, xmlctx, NULL);  xmlParseChunk(xmlctx, "", 0, 1);  if (xmlctx->wellFormed && response >= 200 && response < 300)  {    xmlNode *root_element = xmlDocGetRootElement(xmlctx->myDoc);    for (onode = root_element->children; onode; onode = onode->next)    {      if (onode->type != XML_ELEMENT_NODE) continue;      char is_object = !strcasecmp((const char *)onode->name, "object");      char is_container = !strcasecmp((const char *)onode->name, "container");      char is_subdir = !strcasecmp((const char *)onode->name, "subdir");      if (is_object || is_container || is_subdir)      {        entry_count++;        dir_entry *de = (dir_entry *)malloc(sizeof(dir_entry));        de->next = NULL;        de->size = 0;        de->last_modified = time(NULL);        if (is_container || is_subdir)          de->content_type = strdup("application/directory");        for (anode = onode->children; anode; anode = anode->next)        {          char *content = "<?!?>";          for (text_node = anode->children; text_node; text_node = text_node->next)            if (text_node->type == XML_TEXT_NODE)              content = (char *)text_node->content;          if (!strcasecmp((const char *)anode->name, "name"))          {            de->name = strdup(content + prefix_length);            // Remove trailing slash            char *slash = strrchr(de->name, '/');            if (slash && (0 == *(slash + 1)))              *slash = 0;            if (asprintf(&(de->full_name), "%s/%s", path, de->name) < 0)              de->full_name = NULL;          }          if (!strcasecmp((const char *)anode->name, "bytes"))            de->size = strtoll(content, NULL, 10);          if (!strcasecmp((const char *)anode->name, "content_type"))          {            de->content_type = strdup(content);            char *semicolon = strchr(de->content_type, ';');            if (semicolon)              *semicolon = '/0';          }          if (!strcasecmp((const char *)anode->name, "last_modified"))          {            struct tm last_modified;            strptime(content, "%FT%T", &last_modified);            de->last_modified = mktime(&last_modified);          }        }        de->isdir = de->content_type &&            ((strstr(de->content_type, "application/folder") != NULL) ||//.........这里部分代码省略.........
开发者ID:AbhishekGhosh,项目名称:cloudfuse,代码行数:101,


示例29: list_directory

int list_directory(const char *path, dir_entry **dir_list){  char container[MAX_PATH_SIZE * 3] = "";  char object[MAX_PATH_SIZE] = "";  int response = 0;  int retval = 0;  *dir_list = NULL;  xmlNode *onode = NULL, *anode = NULL, *text_node = NULL;  xmlParserCtxtPtr xmlctx = xmlCreatePushParserCtxt(NULL, NULL, "", 0, NULL);  if (!strcmp(path, "") || !strcmp(path, "/"))  {    path = "";    strncpy(container, "/?format=xml", sizeof(container));  }  else  {    sscanf(path, "/%[^/]/%[^/n]", container, object);    char *encoded_container = curl_escape(container, 0);    char *encoded_object = curl_escape(object, 0);    snprintf(container, sizeof(container), "%s?format=xml&path=%s",              encoded_container, encoded_object);    curl_free(encoded_container);    curl_free(encoded_object);  }  response = send_request("GET", container, NULL, xmlctx, NULL);  xmlParseChunk(xmlctx, "", 0, 1);  if (xmlctx->wellFormed && response >= 200 && response < 300)  {    xmlNode *root_element = xmlDocGetRootElement(xmlctx->myDoc);    for (onode = root_element->children; onode; onode = onode->next)      if ((onode->type == XML_ELEMENT_NODE) &&         (!strcasecmp((const char *)onode->name, "object") || !strcasecmp((const char *)onode->name, "container")))      {        dir_entry *de = (dir_entry *)malloc(sizeof(dir_entry));        de->size = 0;        de->last_modified = time(NULL);        if (!strcasecmp((const char *)onode->name, "container"))          de->content_type = strdup("application/directory");        for (anode = onode->children; anode; anode = anode->next)        {          char *content = "<?!?>";          for (text_node = anode->children; text_node; text_node = text_node->next)            if (text_node->type == XML_TEXT_NODE)              content = (char *)text_node->content;          if (!strcasecmp((const char *)anode->name, "name"))          {            if (strrchr(content, '/'))              de->name = strdup(strrchr(content, '/')+1);            else              de->name = strdup(content);            if (asprintf(&(de->full_name), "%s/%s", path, de->name) < 0)              de->full_name = NULL;          }          if (!strcasecmp((const char *)anode->name, "bytes"))            de->size = atoi(content);          if (!strcasecmp((const char *)anode->name, "content_type"))          {            de->content_type = strdup(content);            char *semicolon = strchr(de->content_type, ';');            if (semicolon)              *semicolon = '/0';          }          if (!strcasecmp((const char *)anode->name, "last_modified"))          {            struct tm last_modified;            strptime(content, "%FT%T", &last_modified);            de->last_modified = mktime(&last_modified);          }        }        de->isdir = de->content_type &&            ((strstr(de->content_type, "application/folder") != NULL) ||             (strstr(de->content_type, "application/directory") != NULL));        de->next = *dir_list;        *dir_list = de;      }    retval = 1;  }  xmlFreeDoc(xmlctx->myDoc);  xmlFreeParserCtxt(xmlctx);  return retval;}
开发者ID:cub-uanic,项目名称:cloudfuse,代码行数:81,



注:本文中的strptime函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ strrchr函数代码示例
C++ strprintf函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。