Chinaunix首页 | 论坛 | 博客
  • 博客访问: 751894
  • 博文数量: 119
  • 博客积分: 137
  • 博客等级: 少校
  • 技术积分: 1582
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-28 16:39
文章分类

全部博文(119)

文章存档

2017年(3)

2016年(7)

2014年(1)

2013年(8)

2012年(20)

2011年(27)

2010年(53)

分类: LINUX

2016-10-24 11:11:40

目的: 在joyme_lib文件目录中执行
joyme_lib下面有一个文件夹为joyme_cmcc,里面有文件名全部以joyme_cmcc开头的文件。
要求打印出所有函数名为 int joyme_cmcc_* 的传入参数。



此为第一版:还要修改:




shell 脚本

点击(此处)折叠或打开

  1. #!/usr/bin/sh

  2. for file in ./joyme_cmcc/*
  3. do
  4.    PARAM_LINE=`grep "int joyme_cmcc_" $file`
  5.    PARAMS_STRING=`echo $PARAM_LINE | grep -Po '(?<=\050)[^\051]+'`
  6.    echo $PARAMS_STRING
  7.    newline="joyme_printf(JOYME_INFO,\"<>: ";
  8.    newShow="";
  9.    newParams="";
  10.    
  11.    i=1
  12.    while((1==1))
  13.     do
  14.      split=`echo $PARAMS_STRING|cut -d "," -f$i`
  15.      splitEqResp=$(echo $split | grep "response")
  16.     
  17.      if [ "$split"x != ""x ]
  18.      then
  19.      if [ $i -eq 2 ] && [[ "$splitEqResp" != "" ]]
  20.      then
  21.          break
  22.      fi    
  23.     
  24.      # echo $i" "$split

  25.     
  26.      if [ $i -ge 2 ];then
  27.     
  28.                         #echo $split"***************"
  29.                         
  30.                         include_list=$(echo $split | grep "List")
  31.                         include_void=$(echo $split | grep "void")
  32.                         #char*hostMACList[]
  33.                         if [[ "$include_list" != "" ]] ;then
  34.                               newShow=$newShow"/*AAAAAA*/"
  35.                               newParams=$newParams"/*AAAAAA*/"
  36.                         elif [[ "$include_void" != "" ]] ;then
  37.                                    newShow=$newShow"/*BBBBBB*/"
  38.                               newParams=$newParams"/*BBBBBB*/"
  39.                         else
  40.                         
  41.                          isString="0"
  42.                          for element in $split
  43.                          do
  44.                                 if [ "$element"x = "int"x ];then
  45.                                   newShow=$newShow",\n[%d]"
  46.                                   isString="0";
  47.                              elif [ "$element"x = "char*"x ];then
  48.                                   newShow=$newShow",\n[%s]"
  49.                                   isString="1";
  50.                              elif [ "$element"x = "char"x ];then
  51.                                   newShow=$newShow",\n[%s]"
  52.                                   isString="1";
  53.                              else
  54.                                  include_star=$(echo $element | grep "*")
  55.                                  if [[ "$include_star" != "" ]] ;then
  56.                                      element=`echo ${element#*\*}`
  57.                                      if [ "$isString"x = "0"x ] ;then
  58.                                          newParams=$newParams","$element
  59.                                      else
  60.                                          newParams=$newParams",strlen("$element")?"$element":\"NULL\""
  61.                                      fi
  62.                                  else
  63.                                      if [ "$isString"x = "0"x ] ;then
  64.                                          newParams=$newParams","$element
  65.                                      else
  66.                                          newParams=$newParams",strlen("$element")?"$element":\"NULL\""
  67.                                      fi
  68.                                  fi    
  69.                                  
  70.                              fi
  71.                             done
  72.                         fi
  73.      fi
  74.     
  75.      ((i++))
  76.      else
  77.      break
  78.      fi
  79.     done
  80.    
  81.    
  82.    newline=$newline$newShow"\n\"";
  83.    newline=$newline$newParams");";
  84.    
  85.    #将$newline追加到$file字符串<>所在行的行后
  86.    echo " "$newline > /var/tmp/aaaaa
  87.    cat /var/tmp/aaaaa
  88.    sed -i '/<>/ r /var/tmp/aaaaa' $file
  89. done

阅读(1601) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~