查看: 1227|回复: 3
收起左侧

[软件] 这源码是什么语言???

 关闭 [复制链接]
清泠
发表于 2012-9-13 18:33:02 | 显示全部楼层 |阅读模式
复制了一部分。。
  1. class netReq
  2.   request
  3.   method
  4.   connective
  5.   TimeOutSet
  6.   function init()
  7.     this.TimeOutSet = 10000;
  8.   end
  9.   function connect(method,url,addr)
  10.     this.method = method;
  11.     if this.method <> 'POST' and this.method <> 'GET' then
  12.       if this.method = '' then
  13.         print('Error: Null Method');
  14.         return -1;
  15.       end;
  16.       print('Error: Unsupported Method');
  17.       return -2;
  18.     end;
  19.     if url = '' then
  20.       url = '/';
  21.     end;
  22.     this.request = this.method + ' ' + url + ' ' + 'HTTP/1.1\r\n';
  23.     if not isnum(addr[1]) then
  24.       print 'Error: Invalid port number, must be integer';
  25.       return -10;
  26.     end;
  27.     io.timeout(this.TimeOutSet);
  28.     try
  29.       net.start(false);
  30.       this.connective = net.conn(addr[0],addr[1]);
  31.       //io.ces(this.connective,1);
  32.       io.timeout(0);
  33.     catch e by
  34.       print 'Error: Cannot connect in',this.TimeOutSet/1000,'seconds';
  35.       return -100;
  36.     end;
  37.     return 0;
  38.   end
  39.   function setHeader(headerDict)
  40.     headers = keys(headerDict);
  41.     for item in headers do
  42.       if headerDict[item] = '' then
  43.         print 'Error: Null header value' + item;
  44.         return -3;
  45.       end;
  46.       this.request = this.request + item + ': ' + headerDict[item] + '\r\n';
  47.     end;
  48.     return 0;
  49.   end
  50.   function send(data)
  51.     if this.method = 'POST' then
  52.       this.request = this.request+ 'Content-Length: ' + len(data) + '\r\n\r\n';
  53.       this.request = this.request + data;
  54.     else
  55.       this.request = this.request + '\r\n';
  56.     end;
  57.     io.timeout(TimeOutSet);
  58.     try
  59.       io.write(this.connective, this.request);
  60.       io.wait([this.connective]);
  61.       length = io.avail(this.connective);
  62.       h_data = io.read(this.connective,length);
  63.     catch e by
  64.       print 'Error: Cannot get data in',this.TimeOutSet/1000,'seconds';
  65.       io.close(this.connective);
  66.       return -200;
  67.     end;
  68.     io.timeout(0);
  69.     templist = split(h_data,'\r\n\r\n');
  70.     h_data = templist[0];
  71.     m_data = templist[1];
  72.     inf_start = index(h_data,'content-length: ',0,true);
  73.     if inf_start <> -1 then
  74.       io.timeout(TimeOutSet);
  75.       try
  76.         inf_end = index(h_data,'\r\n',inf_start,true);
  77.         Content_Length = num(substr(h_data,inf_start+16,inf_end - inf_start - 16));
  78.         if Content_Length = 0 then
  79.           return h_data;
  80.           io.close(this.connective);
  81.         end;
  82.         while len(m_data) < Content_Length do
  83.           io.wait([this.connective]);
  84.           length = io.avail(this.connective);
  85.           temp = io.read(this.connective,length);
  86.           m_data = m_data + temp;
  87.         end;
  88.         io.close(this.connective);
  89.       catch e by
  90.         print 'Error: Cannot get data in',this.TimeOutSet/1000,'seconds';
  91.         io.close(this.connective);
  92.         return -200;
  93.       end;
  94.       io.timeout(0);
  95.       return h_data + '\r\n\r\n' + m_data;
  96.     else
  97.       inf_start = index(h_data,'Transfer-Encoding: chunked',0,true);
  98.       if inf_start <> -1 then
  99.         is_end = 0;
  100.         lines = split(m_data,'\r\n');
  101.         for line in lines do
  102.           if line = '0' then
  103.             is_end = 1;
  104.           end;
  105.         end;
  106.         io.timeout(TimeOutSet);
  107.         try
  108.           while is_end = 0 do
  109.             io.wait([this.connective]);
  110.             length = io.avail(this.connective);
  111.             temp = io.read(this.connective,length);
  112.             lines = split(temp,'\r\n');
  113.             m_data = m_data + temp;
  114.             for line in lines do
  115.               if line = '0' then
  116.                 is_end = 1;
  117.                 break;
  118.               end;
  119.             end;
  120.           end;
  121.         catch e by
  122.           print 'Error: Cannot get data in',this.TimeOutSet/1000,'seconds';
  123.           io.close(this.connective);
  124.           return -200;
  125.         end;
  126.         io.timeout(0);
  127.         io.close(this.connective);
  128.         return en.fromutf8(h_data + '\r\n\r\n' + m_data);
  129.       end;
  130.     end;
  131.   end;
  132. end

  133. function cut(data,_start,_end,ori)
  134.   index1 = index(data,_start,ori,true);
  135.   if index1 = -1 then
  136.     return -1;
  137.   end;
  138.   StartLength = len(_start);
  139.   index2 = index(data,_end,index1 + StartLength,true);
  140.   if index2 = -1 then
  141.     return -1;
  142.   end;
  143.   d_start = index1 + StartLength;
  144.   result = substr(data,d_start,index2 - d_start);
  145.   return result;
  146. end

  147. function url_split(url)
  148.   _host=replace(url,"http://","");
  149.   url=split(_host,"/");
  150.   host=url[0];
  151.   url=replace(_host,host,"");
  152.   return [host,url];
  153. end
复制代码
yloko
发表于 2012-9-14 14:21:18 | 显示全部楼层
本帖最后由 yloko 于 2012-9-14 14:22 编辑

不清楚,搜了一下
搜出这个

http://code.google.com/p/youmone ... netreq.py?name=v0.9

python 2.5 +
wxPython 2.8.9 +
python sqlite3 module


关键字:class netReq
sly16
发表于 2012-9-14 17:02:41 | 显示全部楼层
貌似是VB编程语言,不会是c类语言
清泠
 楼主| 发表于 2012-9-14 18:38:39 来自手机 | 显示全部楼层
我需要把这个编译成程序
在赛班5版上运行

作者说过可以用m编译器
我不知道这个m编译器哪找
也不清楚这是什么语言
只知道这是基于某种平台运行的
您需要登录后才可以回帖 登录 | 快速注册

本版积分规则

手机版|杀毒软件|软件论坛| 卡饭论坛

Copyright © KaFan  KaFan.cn All Rights Reserved.

Powered by Discuz! X3.4( 沪ICP备2020031077号-2 ) GMT+8, 2025-5-20 03:50 , Processed in 0.119432 second(s), 16 queries .

卡饭网所发布的一切软件、样本、工具、文章等仅限用于学习和研究,不得将上述内容用于商业或者其他非法用途,否则产生的一切后果自负,本站信息来自网络,版权争议问题与本站无关,您必须在下载后的24小时之内从您的电脑中彻底删除上述信息,如有问题请通过邮件与我们联系。

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