return to_int (p ());
}
+int64_t eval_int64 (MNode* cell, MlEnv* mlenv) {
+ MNodePtr p;
+ p = eval (cell, mlenv);
+ return to_int64 (p ());
+}
+
ustring eval_str (MNode* cell, MlEnv* mlenv) {
MNodePtr p;
p = eval (cell, mlenv);
MNode* eval (MNode* ptr, MlEnv* mlenv);
double eval_double (MNode* ptr, MlEnv* mlenv);
int eval_int (MNode* ptr, MlEnv* mlenv);
+int64_t eval_int64 (MNode* ptr, MlEnv* mlenv);
ustring eval_str (MNode* ptr, MlEnv* mlenv);
ustring eval_text1 (MNode* cell, MlEnv* mlenv);
ustring eval_asciiword (MNode* cell, MlEnv* mlenv);
int to_int () {
return (int)to_double ();
};
+ int64_t to_int64 () {
+ return (int64_t)to_double ();
+ };
bool to_bool ();
ustring cons_to_sexp (bool fcdr = false);
ustring to_sexp ();
inline int to_int (MNode* c) {
if (c) {
- return (int)(c->to_double ());
+ return c->to_int ();
+ } else {
+ return 0;
+ }
+}
+
+inline int64_t to_int64 (MNode* c) {
+ if (c) {
+ return c->to_int64 ();
} else {
return 0;
}
#include "ustring.h"
#include <iostream>
#include <fstream>
+#include <time.h>
static void location_sub (ustring& url, MNode* query, MlEnv* mlenv) {
upair scheme, delim, user, pass, host, port, rest;
}
/*DOC:
+===http-date===
+ (http-date INTEGER) -> STRING
+
+*/
+//#AFUNC http-date ml_http_date
+MNode* ml_http_date (MNode* cell, MlEnv* mlenv) {
+ MNode* arg = cell->cdr ();
+ time_t tm;
+ struct tm tms;
+ char b[64];
+ size_t s;
+
+ if (!arg)
+ throw (uErrorWrongNumber);
+ tm = eval_int64 (arg->car (), mlenv);
+ nextNode (arg);
+ if (arg)
+ throw (uErrorWrongNumber);
+
+ gmtime_r (&tm, &tms);
+ s = strftime (b, 64, "%a, %d %b %Y %H:%M:%S GMT", &tms);
+
+ return newMNode_str (new ustring (b, s));
+}
+
+/*DOC:
+===hostnamep===
+ (hostnamep STRING) -> BOOL
+
+*/
+//#AFUNC hostnamep ml_hostnamep
+MNode* ml_hostnamep (MNode* cell, MlEnv* mlenv) {
+ MNode* arg = cell->cdr ();
+ ustring hostname;
+
+ if (!arg)
+ throw (uErrorWrongNumber);
+ hostname = eval_str (arg->car (), mlenv);
+ nextNode (arg);
+ if (arg)
+ throw (uErrorWrongNumber);
+
+ return newMNode_bool (checkHostname (hostname));
+}
+
+/*DOC:
===$http-get==
($http-get URL [#get] [#post] [#put] [#delete] [#file] [#head]
[:id STRING] [:password STRING | :pw STRING]
return ans.release ();
}
+
MNode* ml_build_url (MNode* cell, MlEnv* mlenv);
MNode* ml_build_url_path (MNode* cell, MlEnv* mlenv);
MNode* ml_build_query (MNode* cell, MlEnv* mlenv);
+MNode* ml_http_date (MNode* cell, MlEnv* mlenv);
+MNode* ml_hostnamep (MNode* cell, MlEnv* mlenv);
MNode* ml_http_get (MNode* cell, MlEnv* mlenv);
MNode* ml_http_get_http_status (MNode* cell, MlEnv* mlenv, MLFunc* mobj);
MNode* ml_http_get_http_response (MNode* cell, MlEnv* mlenv, MLFunc* mobj);