QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 881|回复: 4

求救各位高手!Linux下C语言的难题!帮帮忙吧!

[复制链接]
发表于 2004-11-2 19:06:23 | 显示全部楼层 |阅读模式
描述:现有一名为detail.txt的文本文件,文件格式见detail.txt附件
1、文件以空行分割为不同的部分,每一部分开始于时间如:Fri Dec  5 17:46:15 2003,结束于空行
2、没部分可能包含但不限于:
        NAS-IP-Address(IP地址)
        User-Name(用户名)
        Called-Station-Id(被叫号码)
        Calling-Station-Id(主叫号码)
        Acct-Status-Type(计费状态类型:取值范围:Start,Stop)
        Connection_ID(唯一标识)
        Connect_Time(连接时间)
        Acct-Input-Octets(流入字节数)
        Acct-Output-Octets(流出字节数)
        Acct-Session-Time(时长)
        Timestamp(时间戳)
要求:
0、用UNIX下的C语言编写程序
1、提取Acct-Status-Type取值为Stop的部分
2、按用户名User-Name统计每个用户的时长Acct-Session-Time
3、按用户名User-Name统计每个用户的流量Acct-Input-Octets和Acct-Output-Octets
4、将统计结果存入文件,文件格式要求清除的表示每个用户的总时长,流入量总计,流出量总计,总流量
5、文件要有所有用户的总时长,流入量总计,流出量总计,总流量


附件:detail
Fri Dec  5 17:46:15 2003
        NAS-IP-Address = 192.168.217.131
        NAS-Port-Type = Async
        User-Name = "777777777777"
        Called-Station-Id = "2620"
        Calling-Station-Id = "3640"
        Acct-Status-Type = Stop
        Service-Type = Login-User
        Gateway_Name = "h323-gw-id=3640."
        Connection_ID = "h323-conf-id=A69F7477 D20411DB 0 24B28A08"
        Incoming_Connect_ID = "h323-incoming-conf-id=A69F7477 D20411DB 0 24B28A08"
        Call_Direction = "h323-call-origin=originate"
        Call_Type = "h323-call-type=VoIP"
        Setup_Time = "h323-setup-time=*03:01:29.337 UTC Mon Mar 8 1993"
        Connect_Time = "h323-connect-time=*03:01:30.703 UTC Mon Mar 8 1993"
        Disconnect_Time = "h323-disconnect-time=*03:01:36.053 UTC Mon Mar 8 1993"
        Disconnect_Cause = "h323-disconnect-cause=10"
        Voice_Quality = "h323-voice-quality=0"
        Remote_Gateway_ID = "h323-remote-address=192.168.217.132"
        Acct-Session-Id = "0000062A"
        Acct-Input-Octets = 5592
        Acct-Output-Octets = 1663
        Acct-Input-Packets = 282
        Acct-Output-Packets = 87
        Acct-Session-Time = 5
        Incoming_Connect_ID = "subscriber=RegularLine"
        Incoming_Connect_ID = "pre-bytes-in=0"
        Incoming_Connect_ID = "pre-bytes-out=0"
        Incoming_Connect_ID = "pre-paks-in=0"
        Incoming_Connect_ID = "pre-paks-out=0"
        Incoming_Connect_ID = "nas-rx-speed=0"
        Incoming_Connect_ID = "nas-tx-speed=0"
        Acct-Delay-Time = 0
        Timestamp = 1070617575

Mon Dec  8 10:43:58 2003
        NAS-IP-Address = 192.168.217.131
        NAS-Port-Type = Async
        User-Name = "777777777777"
        Called-Station-Id = "2620"
        Calling-Station-Id = "3640"
        Acct-Status-Type = Stop
        Service-Type = Login-User
        Gateway_Name = "h323-gw-id=3640."
        Connection_ID = "h323-conf-id=A69F7477 D20411E7 0 32A2F528"
        Incoming_Connect_ID = "h323-incoming-conf-id=A69F7477 D20411E7 0 32A2F528"
        Call_Direction = "h323-call-origin=originate"
        Call_Type = "h323-call-type=VoIP"
        Setup_Time = "h323-setup-time=*19:59:19.253 UTC Wed Mar 10 1993"
        Connect_Time = "h323-connect-time=*19:59:23.125 UTC Wed Mar 10 1993"
        Disconnect_Time = "h323-disconnect-time=*19:59:31.249 UTC Wed Mar 10 1993"
        Disconnect_Cause = "h323-disconnect-cause=10"
        Voice_Quality = "h323-voice-quality=0"
        Remote_Gateway_ID = "h323-remote-address=192.168.217.132"
        Acct-Session-Id = "0000062E"
        Acct-Input-Octets = 6293
        Acct-Output-Octets = 622
        Acct-Input-Packets = 318
        Acct-Output-Packets = 34
        Acct-Session-Time = 8
        Incoming_Connect_ID = "subscriber=RegularLine"
        Incoming_Connect_ID = "pre-bytes-in=0"
        Incoming_Connect_ID = "pre-bytes-out=0"
        Incoming_Connect_ID = "pre-paks-in=0"
        Incoming_Connect_ID = "pre-paks-out=0"
        Incoming_Connect_ID = "nas-rx-speed=0"
        Incoming_Connect_ID = "nas-tx-speed=0"
        Acct-Delay-Time = 0
        Timestamp = 1070851438
-------------------------------------------------------------------------------------
--------------------谢谢个位高手了,明天给俺个提示吧!------------------------
 楼主| 发表于 2004-11-2 19:26:36 | 显示全部楼层
不会没有人会吧!
回复

使用道具 举报

发表于 2004-11-2 19:30:53 | 显示全部楼层
要不楼主先说说你自己的想法
回复

使用道具 举报

发表于 2004-11-2 23:35:51 | 显示全部楼层
每一段的最后其实是个回车的字符'\n'那个空行就是两个回车。其他自己努力吧。
回复

使用道具 举报

发表于 2004-11-3 17:16:39 | 显示全部楼层
这样的数据,最好用个数据库管理比较简单效率也比较高
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-7 05:39 , Processed in 0.046650 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表