fxhnkf
aix下的catopen求助
小弟现在在aix下作开发,将原来HP-UX下的工程移植到AIX下,目前遇到一个问题
使用catopen函数去打开一个.cat文件时老是出错(在原HP-UX下没有这个问题),NLSPATH设置是正确的/home/guard/lib/nls/msg/C/%N,文件的名称也是正确的,文件的读写权限也是正确的,但是调用catopen就是会出错(返回值为-1),但此时我把errno是打印出来为0,errno表明没有出错,很是奇怪,请大家帮帮忙
有没有可能是因为HP-UX下与AIX下.msg文件的格式不同,在AIX使用原.msgt生成的.cat文件无法使用,我的.msg文件格式如下
$set 1
$ ======== alert ========
$ MC_ALM_MSG
9999 %s.
$ ======== critical ========
$ MC_CRT_FILEOPR
10001 Operation %s() on file %s fail: %m.
$ MC_CRT_SYSFUNC
19998 System call %s() fail: %m.
$ MC_CRT_MSG
19999 %s.
$ ======== error ========
$ MC_ERR_SYSFUNC
20001 System call %s() fail: %m.
$ MC_ERR_OPEN_FILE_READ
20011 Can't open file %s for read: %m.
$ MC_ERR_OPEN_FILE_WRITE
20012 Can't open file %s for write: %m.
$ MC_ERR_CREATE_LINK
20013 Can't create symbol link %s: %m.
$ MC_ERR_READ_FILE_SHORT
20014 File %s read length %d is shorter than expected %d.
$ MC_ERR_FILEOPR
20015 Operation %s() on file %s fail: %m.
$ MC_ERR_ENV
20201 Environment variable %s not exist.
$ MC_ERR_TXN_TYPE_NOT_EXIST
20253 No such txn type %s.
$ MC_ERR_ROUTE_TYPE_NOT_EXIST
20254 No such route type %s.
$ MC_ERR_PROC_TERMINATE
20261 Process %s terminated with return code %d.
$ MC_ERR_PROC_TERMINATE_SIGNAL
20262 Process %s terminated by signal %d.
$ MC_ERR_PROC_TERMINATE_STOP
20263 Process %s stoped by signal %d.
$ MC_ERR_SEM_NOT_DEF
20301 Semaphore %d not defined.
$ MC_ERR_COMM_CONNECT
20401 Connect to remote host %s port %d failed: %m.
$ MC_ERR_COMM_RECEIVE
20402 Receive error, reason: %m, socket will be closed.
$ MC_ERR_COMM_SEND
20403 Send error, reason: %m, socket will be closed.
$ MC_ERR_COMM_TIMEOUT
20404 Communication timeout, remote IP: %s, port: %d.
$ MC_ERR_REQ_INVALID
20501 Request invalid, not in (%s), which is %s.
$ MC_ERR_VALUE_ERR
20502 %s must be %d, but in this message which is %d.
$ MC_ERR_STRING_ERR
20503 %s must be %s, but in this message which is %s.
$ MC_ERR_BUF_SIZE_LOW
20504 Buffer size is too low.
$ MC_ERR_FHK_ZIP
20601 Failed to zip files in directory %s.
$ MC_ERR_FHK_DELETE
20602 Failed to delete files in directory %s.
$ MC_ERR_FHK_MOVE
20603 Failed to move file %s to directory %s.
$ MC_ERR_FHK_MAKEDIR
20604 Failed to makedir %s.
$ MC_ERR_DBC_SQLPLUS
20701 SQLPLUS failed, configured in line %s of config file %s.
$ MC_ERR_DBC_SQL_SCRIPT
20702 SQL script running failed, configured in line %s of config file %s. Error meaage: %s.
$ MC_ERR_CMD_USAGE
20801 Command line command usage error.
$ MC_ERR_TYPE_UNKNOWN
20802 Type %s is unknown.
$ MC_ERR_CFG_UNKNOWN
20803 Config value %s is unknown.
$ MC_ERR_MYSQL_MSG
20901 MySQL error: %s.
$ MC_ERR_MSG
29999 %s.
$ ======== warning ========
$ MC_WRN_FUNC_RETURN
30001 Function %s() fail.
$ MC_WRN_IP_FORMAT
30002 IP %s format error.
$ MC_WRN_COMM_DISCONNECTED
30003 Peer disconnected.
$ MC_WRN_NOT_SOCKET
30004 FD is not socket-type.
$ MC_WRN_MSG_TYPE_INVALID
30005 Message type %d invalid.
$ MC_WRN_PROC_NOT_FOUND
30006 Process name %s not found.
$ MC_WRN_FHK_CFG_DIR
30011 Directory %s in config file %s is invalid.
$ MC_WRN_FHK_CFG_DAY
30012 Wrong zip day %s or clean day %s defined in config file %s.
$ MC_WRN_DBC_CFG_USER
30021 Wrong database user %s defined in line %s of config file %s.
$ MC_WRN_DBC_CFG_SID
30022 Database SID is null in line %s of config file %s.
$ MC_WRN_DBC_CFG_TABLE
30023 Table name is null in line %s of config file %s.
$ MC_WRN_DBC_CFG_COLUMN
30024 Column name is null in line %s of config file %s.
$ MC_WRN_DBC_CFG_TYPE
30025 Column type is null in line %s of config file %s.
$ MC_WRN_DBC_CFG_UNIT
30026 Period unit is null in line %s of config file %s.
$ MC_WRN_DBC_CFG_NUM
30027 Period number is null in line %s of config file %s.
$ MC_WRN_DBC_CFG_UNIT_INVALID
30028 Period unit %s is invalid in line %s of config file %s.
$ MC_WRN_DB_USER
30101 Database user %s not exist.
$ MC_WRN_TOO_MANY_PARA
30201 Too many parameters to be processed while writing log in shell script, original MsgCode is %d.
$ MC_WRN_HEAD_SHORT
30301 Message header length %d is shorter than expected %d.
$ MC_WRN_COMM_CFG_HEAD
30401 Message header configured in %s is wrong.
$ MC_WRN_COMM_BODY_LEN_LEN_LIMIT
30402 Body-length field length %d in message header configured in %s exceed limit %d.
$ MC_WRN_COMM_FAIL
30403 Communication failed: %m.
$ MC_WRN_NODE_NOT_EXIST
30410 No such node %s.
$ MC_WRN_CFG_SECTION_NOT_EXIST
30501 Section %s in config file %s not exist.
$ MC_WRN_CFG_ENTRY_NOT_EXIST
30502 Entry %s in section %s in config file %s not exist.
$ MC_WRN_MSG
39999 %s.
$ ======== notice ========
$ MC_NTC_DLV_TERM_NUM_LIMIT
40001 Number of message deliver terminal reaches upper limit, new terminal IP %s port %d's registraion request ignored.
$ MC_NTC_DLV_TERM_NOT_EXIST
40003 Message deliver terminal IP %s port %d not exist when unregistered.
$ MC_NTC_PROC_TERMINATE
40010 Process %s terminated with return code %d.
$ MC_NTC_SHELL_TERMINATE
40011 Shell program %s terminated with return code %s.
$ MC_NTC_READ_CFG_FILE
40021 Read config file %s fail.
$ MC_NTC_FHK_MV_GZIP
40031 Move & gzip %s to %s.
$ MC_NTC_STATION_CLOSED
40101 Station %s closed, send directly to device.
$ MC_NTC_MSG
49999 %s.
$ ======== information ========
$ MC_INF_PROC_START
50001 Process %s start, config name %s.
$ MC_INF_PROC_TERMINATE
50002 Process %s terminated successfully.
$ MC_INF_SHELL_START
50003 Shell program %s start.
$ MC_INF_SHELL_TERMINATE
50004 Shell program %s terminated successfully.
$ MC_INF_DLV_TERM_REG
50010 Message deliver terminal IP %s, port %d registered.
$ MC_INF_DLV_TERM_UNREG
50011 Message deliver terminal IP %s, port %d unregistered.
$ MC_INF_DBC_CFG_ITEM_SUCC
50021 Config item in line %s of config file %s processed successfully.
$ MC_INF_CONNECTED
50031 Connected to remote host %s port %d.
$ MC_INF_ACCEPTED
50032 Connection request from remote host %s port %d accepted.
$ MC_INF_MSG
59999 %s.
$ ======== debug ========
$ MC_DBG_VALUE
62999 %s = %d.
$ MC_DBG_MSG
63000 %s.
[[i] 本帖最后由 fxhnkf 于 2007-7-17 19:05 编辑 [/i]]
ivhb
[quote]
但是调用catopen就是会出错(返回值为-1),但此时我把errno是打印出来为0,errno表明没有出错,很是奇怪,请大家帮帮忙
[/quote]
没有用过catopen,只能给你贴一段说明。
希望对你有用[code]Return Values
The catopen subroutine returns a catalog descriptor. If the LC_MESSAGES category is set to the default value C, and the LC__FASTMSG environment variable is set to true, the catopen subroutine returns a value of -1.
If the LC_MESSAGES category is not set to the default value C but the catopen subroutine returns a value of -1, an error has occurred during creation of the structure of the nl_catd data type or the catalog name referred to by the CatalogName parameter does not exist.[/code]
此说明是aix 4.3的
hp的说明和aix不同。hp B.11如下
[code]
RETURN VALUE
Upon success, catopen() returns a message catalog descriptor.
Otherwise, catopen() returns a value of (nl_catd)-1 and sets errno to
indicate the error.
Upon success, catclose() returns zero. Otherwise, catclose() returns
-1 and sets errno to indicate the error.[/code]
好像aix不会设置errno,而hp会? 是这样么?
[[i] 本帖最后由 ivhb 于 2007-7-18 10:41 编辑 [/i]]
fxhnkf
终于发现问题在哪里了,只要我在catopen里使用全路径名,就可以正确打开.cat文件,难道catopen不是使用NLSPATH环境变量么?我的NLSPATH环境变量肯定是设置正确的,如下
/home/guard/lib/nls/msg/C/%N
我使用的全路径名是/home/guard/lib/nls/msg/C/commonmsg.cat
而且我使用dspcat命令来显示commonmsg.cat的内容时,也必须使用全路径
难道catopen,dspcat不是使用NLSPATH来搜索.cat文件么?或者还有什么别的设置,使得catopen,dspcat没有使用NLSPATH?
期待高手解释一下
ps:感谢楼上的帮助
ivhb
还是aix的一段说明:
[code]
If the catalog file name referred to by the CatalogName parameter contains a leading / (slash), it is assumed to be an absolute path name. If the catalog file name is not an absolute path name, the user environment determines which directory paths to search. The NLSPATH environment variable defines the directory search path. When this variable is used, the setlocale subroutine must be called before the catopen subroutine.
[/code]
不知道对你是不是有用
ivhb
好像是要加
setlocale(LC_ALL, "C");
anonyaniu
dspcat使用了NLSPATH。
还要搜索系统目录/usr/lib/nls/msg/en_US的cat文件。确认一下是否有重名。