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

📄 tools.h

📁 Magic C++!的源代码
💻 H
字号:
/* tools.h -- Magic C++ header file
   (Mostly) portable public-domain implementation
   -- Copyright(C) 2003 Magicunix Infomation Technology Limited 
   This file is part of magicd.
   magicd 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 2 of the License, or (at your option) any later version.
	 
   For details, see the Magic C++ World-Wide-Web page, 
   `http://www.magicunix.com',
   or send a mail to the Magic C++ developers <support@magicunix.com>.
 */
#ifndef __TOOLS_H_
#define __TOOLS_H_
/*declarations*/
/*if no */

/******************************************************/
/*log infomation
using util_log("%s%s",......);
output [time] ...
parameter fmt: just like printf()
*/
 
int util_log(  const char *fmt, ...);


/*error log*/
/*paramter
filename   current file name,obtain by __FILE__
line       current line number,obtain by __LINE__
err        current  errno
*/
int util_err_log(char * info ,char *  filename , int line , long err);

/*init semaphore
*/

int util_ipc_init();
int util_ipc_remove();

/*add the value in shared memory*/
/*up to limitation return -1 */
int util_add_global(int maxval);

/*subtract the value in shared memory,when the value is less than 0,return-1 */
int util_subtract_global();


/*lock the shared memory
nMillionSec   duration for 1/1000second
*/
int util_sem_lock(int nMillionSec);


int util_sem_unlock();

/*read a string from configure file
section  - name of section
key - name of key
value - return value of the value of key
*/
int util_getinfo_str(char *section ,char *key , char *value , char *inifile);

/*read a integer from configure file
section  - name of section
key - name of key
value - return value of the value of key
*/
int util_getinfo_int(char *section ,char *key , int *nvalue , char *inifile);


/*get one line in file
get rid of last '\r' and '\n'
fd - file descriptor
nLineLen - the max length of line
line -  return the content of line
return value:   -1 for end of file  ,>0 for real length of received string
*/
int util_getline( FILE *fd , int nLineLen , char *line);

int util_getlineex( FILE *fd , int nLineLen , char *line , int nstyle);
/*delete the blank and control charactor
buf- in ,out for the string
*/
void util_trim(char *buf );

/*get last modified time of the file*/
/*filename - full name of the file*/
/*time - return time in YYYYMMDDHHMISS format*/

int util_get_filemtime(char *filename , char *time );

/*get file length*/
/* return size of the file*/
/*return -1 for failed*/
int util_get_filesize( char *filename );

/*get size and time of the file
filename - file full name 
time - last modified time
return length of file
return -1 for failed
*/
long util_getfileinfo( char *filename , char *time );






/*flowing function is private*/
int util_getsection(char *line , char *section);
int util_getkeyvalue(char *line ,char *thekey ,char *thevalue );

int util_getkeyvalue_notrim(char *line ,char *thekey ,char *thevalue ); 

int util_semp_init();
int util_global_init();
int util_getshm(int flag);
int util_getsem(int flag);
int util_sem_init();
int util_shm_init();
int util_sem_remove();
int util_shm_remove();
void util_checkline(char * line , int n );
/*setup alarm*/
int util_alarm(int msec);

int util_strupr(char *str);
int util_strlwr(char *str);


#define RETRY_TIMES 5
/*get format of a file*/
int util_getfilestyle(FILE *fd);
#define CRLF_STYLE_DOS   0 
#define CRLF_STYLE_UNIX  1
#define CRLF_STYLE_UNIX2 2
#define CRLF_STYLE_MAC   3
#endif

⌨️ 快捷键说明

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