| 1 | #ifdef RCSID |
| 2 | static char RCSid[] = |
| 3 | "$Header$"; |
| 4 | #endif |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) <year> Michael J. Roberts. All Rights Reserved. |
| 8 | * |
| 9 | * Please see the accompanying license file, LICENSE.TXT, for information |
| 10 | * on using and copying this software. |
| 11 | */ |
| 12 | /* |
| 13 | Name |
| 14 | vmhttpdum.cpp - dummy HTTPServer and HTTPRequest classes |
| 15 | Function |
| 16 | This is a dummy implementation HTTPServer and HTTPRequest, for linking |
| 17 | into the compiler (and any other executables where the classes are needed |
| 18 | for linking, but aren't instantiable at run-time). This version simply |
| 19 | throws an error if the byte-code program attempts to create one of these |
| 20 | classes. |
| 21 | Notes |
| 22 | |
| 23 | Modified |
| 24 | 08/07/10 MJRoberts - creation |
| 25 | */ |
| 26 | |
| 27 | #include <stdlib.h> |
| 28 | #include <string.h> |
| 29 | #include <assert.h> |
| 30 | |
| 31 | #include "t3std.h" |
| 32 | #include "vmhttpsrv.h" |
| 33 | #include "vmhttpreq.h" |
| 34 | #include "vmerr.h" |
| 35 | #include "vmerrnum.h" |
| 36 | #include "vmtype.h" |
| 37 | #include "vmglob.h" |
| 38 | #include "vmobj.h" |
| 39 | #include "vmundo.h" |
| 40 | #include "vmmcreg.h" |
| 41 | #include "vmfile.h" |
| 42 | #include "vmbif.h" |
| 43 | #include "vmmeta.h" |
| 44 | #include "vmstack.h" |
| 45 | #include "vmrun.h" |
| 46 | #include "vmstr.h" |
| 47 | #include "utf8.h" |
| 48 | #include "vmnetfil.h" |
| 49 | |
| 50 | |
| 51 | /* ------------------------------------------------------------------------ */ |
| 52 | /* |
| 53 | * CVmObjHTTPServer |
| 54 | */ |
| 55 | |
| 56 | /* metaclass registration object */ |
| 57 | static CVmMetaclassHTTPServer metaclass_reg_obj_srv; |
| 58 | CVmMetaclass *CVmObjHTTPServer::metaclass_reg_ = &metaclass_reg_obj_srv; |
| 59 | |
| 60 | vm_obj_id_t CVmObjHTTPServer::create_from_stack( |
| 61 | VMG_ const uchar **pc_ptr, uint argc) |
| 62 | { |
| 63 | err_throw(VMERR_UNKNOWN_METACLASS); |
| 64 | AFTER_ERR_THROW(return VM_INVALID_OBJ;) |
| 65 | } |
| 66 | |
| 67 | void CVmObjHTTPServer::notify_delete(VMG_ int /*in_root_set*/) |
| 68 | { |
| 69 | } |
| 70 | |
| 71 | void CVmObjHTTPServer::set_prop(VMG_ class CVmUndo *undo, |
| 72 | vm_obj_id_t self, vm_prop_id_t prop, |
| 73 | const vm_val_t *val) |
| 74 | { |
| 75 | } |
| 76 | |
| 77 | int CVmObjHTTPServer::get_prop(VMG_ vm_prop_id_t prop, vm_val_t *retval, |
| 78 | vm_obj_id_t self, vm_obj_id_t *source_obj, |
| 79 | uint *argc) |
| 80 | { |
| 81 | return FALSE; |
| 82 | } |
| 83 | |
| 84 | void CVmObjHTTPServer::load_from_image(VMG_ vm_obj_id_t self, |
| 85 | const char *ptr, size_t siz) |
| 86 | { |
| 87 | } |
| 88 | |
| 89 | void CVmObjHTTPServer::reload_from_image(VMG_ vm_obj_id_t self, |
| 90 | const char *ptr, size_t siz) |
| 91 | { |
| 92 | } |
| 93 | |
| 94 | void CVmObjHTTPServer::save_to_file(VMG_ class CVmFile *fp) |
| 95 | { |
| 96 | } |
| 97 | |
| 98 | void CVmObjHTTPServer::restore_from_file(VMG_ vm_obj_id_t self, |
| 99 | CVmFile *fp, CVmObjFixup *fixups) |
| 100 | { |
| 101 | } |
| 102 | |
| 103 | /* ------------------------------------------------------------------------ */ |
| 104 | /* |
| 105 | * CVmObjHTTPRequest |
| 106 | */ |
| 107 | |
| 108 | /* metaclass registration object */ |
| 109 | static CVmMetaclassHTTPRequest metaclass_reg_obj_req; |
| 110 | CVmMetaclass *CVmObjHTTPRequest::metaclass_reg_ = &metaclass_reg_obj_req; |
| 111 | |
| 112 | vm_obj_id_t CVmObjHTTPRequest::create_from_stack( |
| 113 | VMG_ const uchar **pc_ptr, uint argc) |
| 114 | { |
| 115 | err_throw(VMERR_UNKNOWN_METACLASS); |
| 116 | AFTER_ERR_THROW(return VM_INVALID_OBJ;) |
| 117 | } |
| 118 | |
| 119 | void CVmObjHTTPRequest::notify_delete(VMG_ int /*in_root_set*/) |
| 120 | { |
| 121 | } |
| 122 | |
| 123 | void CVmObjHTTPRequest::mark_refs(VMG_ uint state) |
| 124 | { |
| 125 | } |
| 126 | |
| 127 | void CVmObjHTTPRequest::set_prop(VMG_ class CVmUndo *undo, |
| 128 | vm_obj_id_t self, vm_prop_id_t prop, |
| 129 | const vm_val_t *val) |
| 130 | { |
| 131 | } |
| 132 | |
| 133 | int CVmObjHTTPRequest::get_prop(VMG_ vm_prop_id_t prop, vm_val_t *retval, |
| 134 | vm_obj_id_t self, vm_obj_id_t *source_obj, |
| 135 | uint *argc) |
| 136 | { |
| 137 | return FALSE; |
| 138 | } |
| 139 | |
| 140 | void CVmObjHTTPRequest::load_from_image(VMG_ vm_obj_id_t self, |
| 141 | const char *ptr, size_t siz) |
| 142 | { |
| 143 | } |
| 144 | |
| 145 | void CVmObjHTTPRequest::reload_from_image(VMG_ vm_obj_id_t self, |
| 146 | const char *ptr, size_t siz) |
| 147 | { |
| 148 | } |
| 149 | |
| 150 | void CVmObjHTTPRequest::save_to_file(VMG_ class CVmFile *fp) |
| 151 | { |
| 152 | } |
| 153 | |
| 154 | void CVmObjHTTPRequest::restore_from_file(VMG_ vm_obj_id_t self, |
| 155 | CVmFile *fp, CVmObjFixup *fixups) |
| 156 | { |
| 157 | } |
| 158 | |
| 159 | /* ------------------------------------------------------------------------ */ |
| 160 | /* |
| 161 | * HTTP client request object |
| 162 | */ |
| 163 | int OS_HttpClient::request(int, const char *, unsigned short, |
| 164 | const char *, const char *, |
| 165 | const char *, size_t, |
| 166 | class OS_HttpPayload *, class CVmDataSource *, |
| 167 | char **, char **, const char *) |
| 168 | { |
| 169 | return 0; |
| 170 | } |
| 171 | |
| 172 | |
| 173 | /* ------------------------------------------------------------------------ */ |
| 174 | /* |
| 175 | * HTTP request payload |
| 176 | */ |
| 177 | OS_HttpPayload::OS_HttpPayload() { } |
| 178 | OS_HttpPayload::~OS_HttpPayload() { } |
| 179 | void OS_HttpPayload::add(const char *, const char *) { } |
| 180 | void OS_HttpPayload::add(const char *, const char *, |
| 181 | const char *, CVmDataSource *) { } |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | /* ------------------------------------------------------------------------ */ |
| 188 | /* |
| 189 | * Network configuration object |
| 190 | */ |
| 191 | const char *TadsNetConfig::get(const char *) const |
| 192 | { |
| 193 | return 0; |
| 194 | } |
| 195 | |
| 196 | TadsNetConfig::~TadsNetConfig() |
| 197 | { |
| 198 | } |
| 199 | |
| 200 | void vmnet_check_storagesrv_reply(VMG_ int, class CVmStream *) |
| 201 | { |
| 202 | } |
| 203 | |
| 204 | /* ------------------------------------------------------------------------ */ |
| 205 | /* |
| 206 | * local Web UI askfile |
| 207 | */ |
| 208 | int osnet_askfile(const char *prompt, char *fname_buf, int fname_buf_len, |
| 209 | int prompt_type, int file_type) |
| 210 | { |
| 211 | return OS_AFE_FAILURE; |
| 212 | } |
| 213 | |
| 214 | /* ------------------------------------------------------------------------ */ |
| 215 | /* |
| 216 | * Network storage server file operations - force local mode |
| 217 | */ |
| 218 | CVmNetFile *CVmNetFile::open(VMG_ const char *fname, int sfid, int mode, |
| 219 | os_filetype_t typ, const char *mime_type) |
| 220 | { |
| 221 | return new CVmNetFile(fname, sfid, 0, mode, typ, 0); |
| 222 | } |
| 223 | |
| 224 | void CVmNetFile::close(VMG0_) |
| 225 | { |
| 226 | delete this; |
| 227 | } |
| 228 | |
| 229 | int CVmNetFile::is_net_mode(VMG0_) |
| 230 | { |
| 231 | return FALSE; |
| 232 | } |
| 233 | |
| 234 | int CVmNetFile::exists(VMG_ const char *fname, int sfid) |
| 235 | { |
| 236 | return !osfacc(fname); |
| 237 | } |
| 238 | |
| 239 | int CVmNetFile::can_write(VMG_ const char *fname, int sfid) |
| 240 | { |
| 241 | /* note whether the file already exists */ |
| 242 | int existed = !osfacc(fname); |
| 243 | |
| 244 | /* try opening it (keeping existing contents) or creating it */ |
| 245 | osfildef *fp = osfoprwb(fname, OSFTBIN); |
| 246 | if (fp != 0) |
| 247 | { |
| 248 | /* successfully opened it - close it */ |
| 249 | osfcls(fp); |
| 250 | |
| 251 | /* if it didn't already exist, delete it */ |
| 252 | if (!existed) |
| 253 | osfdel(fname); |
| 254 | |
| 255 | /* success */ |
| 256 | return TRUE; |
| 257 | } |
| 258 | else |
| 259 | { |
| 260 | /* couldn't open the file */ |
| 261 | return FALSE; |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | int CVmNetFile::get_file_mode( |
| 266 | VMG_ unsigned long *mode, unsigned long *attr, int follow_links) |
| 267 | { |
| 268 | return osfmode(lclfname, follow_links, mode, attr); |
| 269 | } |
| 270 | |
| 271 | int CVmNetFile::get_file_stat(VMG_ os_file_stat_t *stat, int follow_links) |
| 272 | { |
| 273 | return os_file_stat(lclfname, follow_links, stat); |
| 274 | } |
| 275 | |
| 276 | int CVmNetFile::resolve_symlink(VMG_ char *target, size_t target_size) |
| 277 | { |
| 278 | return os_resolve_symlink(lclfname, target, target_size); |
| 279 | } |
| 280 | |
| 281 | void CVmNetFile::rename_to(VMG_ CVmNetFile *newname) |
| 282 | { |
| 283 | rename_to_local(vmg_ newname); |
| 284 | } |
| 285 | |
| 286 | void CVmNetFile::mkdir(VMG_ int create_parents) |
| 287 | { |
| 288 | mkdir_local(vmg_ create_parents); |
| 289 | } |
| 290 | |
| 291 | void CVmNetFile::rmdir(VMG_ int remove_contents) |
| 292 | { |
| 293 | rmdir_local(vmg_ remove_contents); |
| 294 | } |
| 295 | |
| 296 | int CVmNetFile::readdir(VMG_ const char *nominal_path, vm_val_t *ret) |
| 297 | { |
| 298 | ret->set_nil(); |
| 299 | return FALSE; |
| 300 | } |
| 301 | |
| 302 | int CVmNetFile::readdir_cb(VMG_ const char *nominal_path, |
| 303 | const struct vm_rcdesc *, const vm_val_t *, int) |
| 304 | { |
| 305 | return FALSE; |
| 306 | } |
| 307 |