当前位置: 首页>>代码示例>>C++>>正文


C++ WebServer::readPOSTparam方法代码示例

本文整理汇总了C++中WebServer::readPOSTparam方法的典型用法代码示例。如果您正苦于以下问题:C++ WebServer::readPOSTparam方法的具体用法?C++ WebServer::readPOSTparam怎么用?C++ WebServer::readPOSTparam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebServer的用法示例。


在下文中一共展示了WebServer::readPOSTparam方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: web_input

/* ================================================================== *
 * Function: web_input
 * Description: Static callback function to handle input to the server
 * Parameters: See Webduino documentation
 *             obj is a pointer to the instance of Server that added the callback
 * ================================================================== */
void web_input(WebServer &server, WebServer::ConnectionType type, char * c, bool b, void * obj) {
    if (type == WebServer::POST) {
        Server * s = (Server *) obj;
        bool repeat;
        char name[16], value[16];
        do {
            // Read all POST params, returns false when no more params
            repeat = server.readPOSTparam(name, 16, value, 16);

            if (strcmp(name, "visualizer") == 0) {
                int type = strtol(value, NULL, 10);
                // Ensure type is valid, default to VISUALIZER_BARS
                switch (type) {
                    case VISUALIZER_BARS:
                    case VISUALIZER_BARS_MIDDLE:
                    case VISUALIZER_PULSE:
                    case VISUALIZER_PLASMA:
                    case VISUALIZER_RAINBOW:
                    case VISUALIZER_WHEEL:
                        s->set_visualizer(type); break;
                    default:
                        s->set_visualizer(VISUALIZER_BARS); break;
                }
            } else if (strcmp(name, "other") == 0) {
                int type = strtol(value, NULL, 10);
                // Ensure type is valid, default to BOUNCING_LINES
                switch (type) {
                    case BOUNCING_LINES:
                    case BAR_TEST:
                    case PIXEL_TEST:
                    case AMBIENT_LIGHTING:
                        s->set_visualizer(type); break;
                    default:
                        s->set_visualizer(BOUNCING_LINES); break;
                }
            } else if (strcmp(name, "power") == 0) {
                s->set_power(strtol(value, NULL, 10));
            }
        } while (repeat);
            // after procesing the POST data, tell the web browser to reload
            // the page using a GET method.
            server.httpSeeOther("/web_input");
            return;
        }

        /* for a GET or HEAD, send the standard "it's all OK headers" */
        server.httpSuccess();

        /* we don't output the body for a HEAD request */
        if (type == WebServer::GET) {
            server.printP(control_panel);
        }
}
开发者ID:SuperUser320,项目名称:muse,代码行数:59,代码来源:server.cpp

示例2: IsValidLogin

bool IsValidLogin(WebServer &rServer)
{
  const int nMaxParameterBuffer = 20;
  char achName[nMaxParameterBuffer];
  char achValue[nMaxParameterBuffer];

  // Check if there is a recent password & we are still within grace period. 
  if (PasswordManager.HasValidPassword())
    return true;

  // Work through all the parameters supplied until we find the one with the
  // password in it. Then check to see if the password is valid. 
  while (rServer.readPOSTparam(achName, sizeof(achName), achValue, sizeof(achValue)))
    if (strcmp(achName, "message") == 0) // we have the password parameter. 
      return PasswordManager.IsPasswordValid(achValue, false);

  return false; // didn't find the password parameter. 
}
开发者ID:VaughanHunt,项目名称:GarageDoorOpener,代码行数:18,代码来源:Webserver.cpp


注:本文中的WebServer::readPOSTparam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。