⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dmtxtime.c

📁 Datamatrix二维码库和测试程序,运行于linux,仔细研究可以很容易转化成VC程序,有这就没必要化钱买个控件了,本人libdmtx-0.3版本转化过,的确可行,现在把找到该版本的libdmtx
💻 C
字号:
/*libdmtx - Data Matrix Encoding/Decoding LibraryCopyright (c) 2008 Mike LaughtonThis library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USAContact: mike@dragonflylogic.com*//* $Id: dmtxtime.c 514 2008-11-19 17:10:44Z mblaughton $ *//** * @file dmtxtime.c * @brief Time handling */#define DMTX_USEC_PER_SEC 1000000#if defined(HAVE_SYS_TIME_H) && defined(HAVE_GETTIMEOFDAY)#include <sys/time.h>#include <time.h>#define DMTX_TIME_PREC_USEC 1/** * @brief  GETTIMEOFDAY version * @return Time now */extern DmtxTimedmtxTimeNow(void){   int err;   struct timeval tv;   DmtxTime tNow;   err = gettimeofday(&tv, NULL);   if(err != 0)      ; /* XXX handle error better here */   tNow.sec = tv.tv_sec;   tNow.usec = tv.tv_usec;   return tNow;}#elif defined (_MSC_VER)#include <Windows.h>#define DMTX_TIME_PREC_USEC 1/** * @brief  MICROSOFT VC++ version * @return Time now */extern DmtxTimedmtxTimeNow(void){   FILETIME ft;   unsigned __int64 tm;   DmtxTime tNow;   GetSystemTimeAsFileTime(&ft);   tm = ft.dwHighDateTime;   tm <<= 32;   tm |= ft.dwLowDateTime;   tm /= 10;   tNow.sec = tm / 1000000UL;   tNow.usec = tm % 1000000UL;   return tNow;}#else#include <time.h>#define DMTX_TIME_PREC_USEC 1000000/** * @brief  Generic 1 second resolution version * @return Time now */extern DmtxTimedmtxTimeNow(void){   time_t s;   DmtxTime tNow;   s = time(NULL);   if(errno != 0)      ; /* XXX handle error better here */   tNow.sec = s;   tNow.usec = 0;   return tNow;}#endif/** * @brief  Add milliseconds to time t * @param  t * @param  msec * @return Adjusted time */extern DmtxTimedmtxTimeAdd(DmtxTime t, long msec){   int usec;   usec = msec * 1000;   /* Ensure that time difference will register on local system */   if(usec > 0 && usec < DMTX_TIME_PREC_USEC)      usec = DMTX_TIME_PREC_USEC;   /* Add time */   t.sec += usec/DMTX_USEC_PER_SEC;   t.usec += usec%DMTX_USEC_PER_SEC;   /* Roll extra usecs into secs */   while(t.usec >= DMTX_USEC_PER_SEC) {      t.sec++;      t.usec -= DMTX_USEC_PER_SEC;   }   return t;}/** * @brief  Determine whether the received timeout has been exceeded * @param  timeout * @return 1 (true) | 0 (false) */extern intdmtxTimeExceeded(DmtxTime timeout){   DmtxTime now;   now = dmtxTimeNow();   return (now.sec > timeout.sec || (now.sec == timeout.sec && now.usec > timeout.usec));}#undef DMTX_TIME_PREC_USEC#undef DMTX_USEC_PER_SEC

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -