??xml version="1.0" encoding="utf-8" standalone="yes"?>
1 ?/span> linux 安装好后已经装好?/span> cvs Q可?/span> rpm -qa|grep cvs 查看?/span>
如果没有安装你可以在 Redhat W?/span> 2 张光盘上扑ֈQ另外你也可以在|上下蝲到最新的 rpm 包。很Ҏ找,其实不存在什?/span> linux 版本?/span>
2 、创?/span> cvs 使用的目录: mkdir /home/mycvstest
3 、创?/span> cvs 使用的用户和l?/span>
groupadd cvs
useradd -g cvs -G cvs –d /home/mycvstest cvs
passwd cvs
4 、修?/span> mycvstest 的用P chown -R cvs:cvs /home/mycvstest
chmod 755 /home/mycvstest
5 、切换用P su cvs
6 、创建源码仓库: mkdir /home/mycvstest/drcls drclgw
7 、初始化源码仓库Q?/span> cvs -d /home/mycvstest/drcls init
cvs -d /home/mycvstest/drclgw init
chmod 755 /home/mycvstest/drcls drclgw
初始化后可以在目录下见到新增加的
CVSROOT
目录Q?/span>
cvs
所有的控制信息都在q个目录里?/span>
8 、退回到 root 用户Q徏?/span> CVS 服务启动文gQ?/span> CVS 使用 xinetd 方式启动?/span>
vi /etc/xinetd.d/cvspserver
service cvspserver
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server= /usr/bin/cvs
server_args= -f --allow-root=/home/mycvstest/drcls
--allow-root=/home/mycvstest/drclgw pserver
log_on_failure += USERID
}
注:U色的参数很重要Q由?/span> xinetd ?/span> server_args 长度限制 , 当你惌行很多的单个仓库的时?/span> ( 是有很多个模块Ӟ比如 drcrgw), 但在 server_args 中无法输入这么多单个的仓库, 可以采取以下方式解决Q现在实验室 90 上就用的q种方式Q:
#> vi cvspserver
service cvspserver
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/cvs.run
server_args =""
}
~写 cvs.run 脚本
vi /cvsroot/cvs.run
#!/bin/bash
/usr/bin/cvs -f
--allow-root=/home/mycvstest/drcls
--allow-root= /home/mycvstest/drclgw
pserver
chmod a+x cvs.run
9 、加?/span> cvs 服务Q?/span>
#>vi /etc/services
cvspserver 2401/tcp #pserver cvs service
cvspserver 2401/udp #pserver cvs service
10 、启?/span> cvs 服务Q?/span>
#> service xinetd restart
11 、检?/span> cvspserver 服务是否已经启动Q?/span>
#> netstat -l |grep cvspserver
应该有如下结果:
tcp 0 0 *:cvspserver *:* LISTEN
二、用和理
1 、创?/span> cvs 用户Q?/span>
cd /home/mycvstest/drcls/CVSROOT
htpasswd –c passwd zhangcan (htpasswd
命o要安?/span>
apache
后才有,此命令创Z?/span>
passwd
文gQ里面内容ؓ新徏
cvs
用户的用户名和密?/span>
)
vi passwd ( 在新建的用户后手工加入用户属于的l?/span> cvs)
例如Q?/span>
zhangcan:dgeagasdgasdr:cvs
蓝色字符串表C加密后的密码?/span>
2
、赋予用戯写权?/span>
手工?/span> CVSROOT 目录中徏?/span> readers ?/span> writers 文g?/span> Readers 文g中的用户只有L限, writers 中的用户hd权限Q一行只写一个用户名?/span>
3 、登?/span> cvs
在客h Linux 下面用命令:
export CVSROOT=:pserver:zhangcan@192.168.100.197:/home/mycvstest/drcls
cvs login
4 、向源码仓库中导入源?/span>
首先q入你本Z安装源码的目录,然后使用以下命oQ?/span>
cvs import –m “this is my soure code?drcls NISEC test start
-m 表示?/span> cvs 历史文g昄的消息, drclst Z指定的源码目录名Q?/span> NISEC Z应商标签Q?/span> test 为发行标{(q两可以不要)Q?/span> start 必须要?/span>
5 ?/span> checkout 出需要修改的源代?/span>
cvs co drcls 在你的当前目录下会发现多了一?/span> drcls 目录Q要修改的源码都在里?/span>
co
?/span>
checkout
的简?/span>
6 、提交修?/span>
假设刚才?/span> readme 文gq行了修改,现在提交
cvs commit –m “modify a few of wrong words?span style="mso-spacerun: yes"> readme
命o执行后会提示版本已经改ؓ 1.2 ?/span>
7 ?/span> checkout Z前的版本
如果xZ前的版本可以用以下命令:
cvs co –r 1.1 drcls/readme 或?/span> cvs –D yesterday drcls/readme
8 、删除文?/span>
若想从源码仓库中删除 readme 文gQ首先应把客h工作目录中的 readme 文g删除Q然后?/span> cvs 的删除命令,最后提交删除,程如下Q?/span>
rm readme
cvs rm readme
cvs commit –m ?/span> 现在不需要这?/span> readme 文g ?span style="mso-spacerun: yes"> readme
如果pȝcM错误Q?/span> cannot remove file `INSTALL' which has a numeric sticky tag of `1.1'
可以用命?/span>
cvs update –A readme
后再删除文g?/span>
以上为火山哥提供?以下是我d的部?
1.在reader和writes文g中添加用用h要注?当在reader中添加了某一只读用户后就不要在writers中添加此用户,如果在两个文件中都添加同一用户的话,在用cvs?CVS服务器会把此用户当做只读用户看待,当用一些命令如import时会产生权限问题,以下是linux关于此问题的说明:
/* This command has the potential to modify the repository, so
* we check if the user have permission to do that.
*
* (Only relevant for remote users -- local users can do
* whatever normal Unix file permissions allow them to do.)
*
* The decision method:
*
* If $CVSROOT/CVSADMROOT_READERS exists and user is listed
* in it, then read-only access for user.
*
* Or if $CVSROOT/CVSADMROOT_WRITERS exists and user NOT
* listed in it, then also read-only access for user.
*
* Else read-write access for user.
*/
?q是由于我的LINUX下不支持中文?是注释不用管?br />Demo.cpp:代码如下:
#include <string.h>
#include <iostream>
#include "Demo.h"
int main( int argc , char* argv[])
{
MemoryInf mymem;
DiskInf mydisk;
DbInf mydb;
Inital( argv[1]);
mydisk = GetDiskStat();
mymem = GetMemInf();
mydb = GetDbStat();
printf("disk total space:%d\n",mydisk.TotalSpace);
printf("disk FreeSpace space:%d\n",mydisk.FreeSpace);
printf("Memory TotalMem:%d\n",mymem.TotalMem);
printf("ValidMem:%d\n",mymem.ValidMem);
printf("VirtualMem:%d\n",mymem.VirtualMem);
printf("DbConnNum:%d\n",mydb.DbConnNum);
printf("DbStat:%d\n",mydb.DbStat);
printf("cpu:%d\n",GetCpuInf());
DesIceCom();
return 1;
}
5.~译文g生成可执行程?
用以下命?
$c++ -lMyApp -o Demo Demo.cpp
说明:-lMyApp参数表示,用动态链接库libMyApp.so一赯行编?对了libMyApp.so最好放?usr/lib目录下哈
如不出意外刚会生成名为Demo的可执行文g
#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + (double)((x).LowPart))
//ICE预编译语?/p>
#ifdef _DEBUG
#pragma comment(lib, "iced.lib")
#pragma comment(lib, "iceutild.lib")
#else
#pragma comment(lib, "ice.lib")
#pragma comment(lib, "iceutil.lib")
#endif
typedef struct
{
DWORD dwUnknown1;
ULONG uKeMaximumIncrement;
ULONG uPageSize;
ULONG uMmNumberOfPhysicalPages;
ULONG uMmLowestPhysicalPage;
ULONG uMmHighestPhysicalPage;
ULONG uAllocationGranularity;
PVOID pLowestUserAddress;
PVOID pMmHighestUserAddress;
ULONG uKeActiveProcessors;
BYTE bKeNumberProcessors;
BYTE bUnknown2;
WORD wUnknown3;
} SYSTEM_BASIC_INFORMATION;
typedef struct
{
LARGE_INTEGER liIdleTime;
DWORD dwSpare[76];
} SYSTEM_PERFORMANCE_INFORMATION;
typedef struct
{
LARGE_INTEGER liKeBootTime;
LARGE_INTEGER liKeSystemTime;
LARGE_INTEGER liExpTimeZoneBias;
ULONG uCurrentTimeZoneId;
DWORD dwReserved;
} SYSTEM_TIME_INFORMATION;
// ntdll!NtQuerySystemInformation (NT specific!)
//
// The function copies the system information of the
// specified type into a buffer
//
// NTSYSAPI
// NTSTATUS
// NTAPI
// NtQuerySystemInformation(
// IN UINT SystemInformationClass, // information type
// OUT PVOID SystemInformation, // pointer to buffer
// IN ULONG SystemInformationLength, // buffer size in bytes
// OUT PULONG ReturnLength OPTIONAL // pointer to a 32-bit
// // variable that receives
// // the number of bytes
// // written to the buffer
// );
typedef LONG (WINAPI *PROCNTQSI)(UINT,PVOID,ULONG,PULONG);
PROCNTQSI NtQuerySystemInformation;
/*
功能:得到CPU使用状?br /> 参数:?br /> q回?内存占用?br /> 作?늉散步
*/
int GetCpuStat()
{
SYSTEM_PERFORMANCE_INFORMATION SysPerfInfo;
SYSTEM_TIME_INFORMATION SysTimeInfo;
SYSTEM_BASIC_INFORMATION SysBaseInfo;
double dbIdleTime;
double dbSystemTime;
LONG status;
LARGE_INTEGER liOldIdleTime = {0,0};
LARGE_INTEGER liOldSystemTime = {0,0};
int UsageCpu = 0;
NtQuerySystemInformation = (PROCNTQSI)GetProcAddress(
GetModuleHandle("ntdll"),
"NtQuerySystemInformation"
);
if (!NtQuerySystemInformation)
return 0;
status = NtQuerySystemInformation(SystemBasicInformation,&SysBaseInfo,sizeof(SysBaseInfo),NULL);
if (status != NO_ERROR)
return 0;
for( int t = 0 ; t < 2 ; t++ )
{
status = NtQuerySystemInformation(SystemTimeInformation,&SysTimeInfo,sizeof(SysTimeInfo),0);
if (status!=NO_ERROR)
return 0;
status = NtQuerySystemInformation(SystemPerformanceInformation,&SysPerfInfo,sizeof(SysPerfInfo),NULL);
if (status != NO_ERROR)
return 0;
if (liOldIdleTime.QuadPart != 0)
{
dbIdleTime = Li2Double(SysPerfInfo.liIdleTime) - Li2Double(liOldIdleTime);
dbSystemTime = Li2Double(SysTimeInfo.liKeSystemTime) - Li2Double(liOldSystemTime);
dbIdleTime = dbIdleTime / dbSystemTime;
dbIdleTime = 100.0 - dbIdleTime * 100.0 / (double)SysBaseInfo.bKeNumberProcessors + 0.5;
UsageCpu = (int)dbIdleTime;
}
// store new CPU's idle and system time
liOldIdleTime = SysPerfInfo.liIdleTime;
liOldSystemTime = SysTimeInfo.liKeSystemTime;
// wait one second
Sleep(500);
}
return UsageCpu;
}
/*
功能:得到内存使用状?br /> 参数:?br /> q回?内存信息l构体[包括ȝ物理内存,q可使用内存,虚拟内存,单位为K]
作?늉散步
*/
MemoryInf MemorySta()
{
MemoryInf tmp;//在ICE SLICE里定义的信息l构?br /> MEMORYSTATUS memStatus;
GlobalMemoryStatus(&memStatus);
DWORD tom=memStatus.dwTotalPhys/1024;
DWORD mem=memStatus.dwAvailPhys/1024;
DWORD res=memStatus.dwAvailVirtual/1024;
tmp.TotalMem = (int)tom;
tmp.ValidMem = (int)mem;
tmp.VirtualMem = (int)res;
return tmp;
}
/*
功能:得到盘使用情况
参数:?br /> q回?盘信息l构?br /> 作?늉散步
*/
DiskInf GetDiskSta()
{
ULARGE_INTEGER FreeAvailable,TotalNum,TotalFreeNum;
char p[3];
bool b_flag;
DiskInf tmp;//ICE SLICE里定义的盘信息l构?br /> tmp.TotalSpace = 0;
tmp.FreeSpace = 0;
//得到有效的驱动器?即盘W?
for( int drive = 1; drive <= 26; drive++ )
{
if( !_chdrive( drive ) )
{
memset( p , 0 , sizeof(p));
p[0] = drive + 'A' - 1;
p[1] = ':';
p[2] = '\0';
b_flag = GetDiskFreeSpaceEx( p ,&FreeAvailable,&TotalNum,&TotalFreeNum );
if( b_flag )
{
tmp.TotalSpace += (int)(TotalNum.QuadPart/(1024*1024));
tmp.FreeSpace += (int)(FreeAvailable.QuadPart/(1024*1024));
}
}
}
return tmp;
}
int main()
{
return 1;
}
|
在所有的预处理指令中Q?Pragma 指o可能是最复杂的了Q它的作用是讑֮~译器的状态或者是指示~译器完成一些特定的动作?pragma指oҎ个编译器l出了一个方?在保持与C和C ++语言完全兼容的情况下,l出L或操作系l专有的特征。依据定?~译指示是机器或操作pȝ专有?且对于每个编译器都是不同的? 其格式一般ؓ: #Pragma Para 其中Para 为参敎ͼ下面来看一些常用的参数? 传统的到?DLL 函数的方法是使用模块定义文g (.def)QVisual C++ 提供了更z方便的ҎQ那是“__declspec()”关键字后面跟“dllexport”,告诉q接去要导出q个函数Q例如: 把“__declspec(dllexport)”放在函数声明的最前面Q连接生成的 DLL ׃导出函数“_MyExportFunction@4”?/P>
上面的导出函数的名称也许不是我的希望的,我们希望导出的是原版的“MyExportFunction”。还好,VC 提供了一个预处理指示W?pragma”来指定q接选项 (不仅仅是q一个功能,q有很多指示功能) Q如下: q下天如h愿了Q)。如果你x定导出的序Q或者只函数导Zؓ序号Q没?EntrynameQ这个预处理指示W?(切地说是连接器) 都能够实玎ͼ看看 MSDN 的语法说明: @ordinal 指定序QNONAME 指定只将函数导出为序PDATA 关键字指定导出项为数据项?/P> |