static void GetApplication(MessageHandler *handler, NETFILE *fp, ProcessNode *node) { int i; ConvFuncs *conv; conv = handler->serialize; LBS_EmitStart(iobuff); RecvLargeString(fp, iobuff); ON_IO_ERROR(fp, badio); ConvSetRecName(handler->conv, node->mcprec->name); conv->UnPackValue(handler->conv, LBS_Body(iobuff), node->mcprec->value); if (node->linkrec != NULL) { ConvSetRecName(handler->conv, node->linkrec->name); conv->UnPackValue(handler->conv, LBS_Body(iobuff), node->linkrec->value); } if (node->sparec != NULL) { ConvSetRecName(handler->conv, node->sparec->name); conv->UnPackValue(handler->conv, LBS_Body(iobuff), node->sparec->value); } for (i = 0; i < node->cWindow; i++) { if (node->scrrec[i] != NULL) { ConvSetRecName(handler->conv, node->scrrec[i]->name); conv->UnPackValue(handler->conv, LBS_Body(iobuff), node->scrrec[i]->value); } } DumpNode(node); badio: return; }
static ValueStruct * _DBCOMMIT( DBG_Struct *dbg, DBCOMM_CTRL *ctrl) { int rc; char *p , *q; LargeByteString *lbs; ENTER_FUNC; CheckDB_Redirect(dbg); lbs = (LargeByteString *)dbg->process[PROCESS_UPDATE].conn; rc = 0; if (LBS_Size(lbs) > 0){ LBS_EmitEnd(lbs); RewindLBS(lbs); p = (char *)LBS_Body(lbs); while ( ( q = strchr(p,0xFF) ) != NULL ) { *q = 0; rc += DoShell(p); p = q + 1; } rc += DoShell(p); LBS_String(dbg->last_query,p); LBS_Clear(lbs); } CommitDB_Redirect(dbg); if ( ctrl != NULL ) { ctrl->rc = rc; } LEAVE_FUNC; return (NULL); }
extern void RecvLBS(NETFILE *fp, LargeByteString *lbs) { size_t size; size = RecvLength(fp); LBS_ReserveSize(lbs, size, FALSE); if (size > 0) { Recv(fp, LBS_Body(lbs), size); } }
static void SetFileEntry( GtkWidget *widget, WidgetData *wdata, _FileEntry *data) { static GHashTable *connectlist = NULL; GtkPandaFileEntry *fentry; GtkWidget *subWidget; WidgetData *subdata; char *longname; char *folder; ENTER_FUNC; SetCommon(widget,wdata); fentry = GTK_PANDA_FILE_ENTRY(widget); g_return_if_fail(data->binary != NULL); longname = (char *)glade_get_widget_long_name(widget); if (connectlist == NULL) { connectlist = NewNameHash(); } if (g_hash_table_lookup(connectlist, longname) == NULL) { g_hash_table_insert(connectlist, longname, longname); g_signal_connect_after(G_OBJECT(widget), "done_action", G_CALLBACK(SavePreviousFolder), NULL); } folder = GetWidgetCache(longname); if (folder == NULL) { folder = ""; } gtk_panda_file_entry_set_folder(fentry, folder); if (LBS_Size(data->binary) > 0) { //download gtk_panda_file_entry_set_mode(fentry, GTK_FILE_CHOOSER_ACTION_SAVE); gtk_panda_file_entry_set_data(fentry, LBS_Size(data->binary), LBS_Body(data->binary)); //set subwidget subdata = GetWidgetData(data->subname); subWidget = GetWidgetByLongName(data->subname); if (subdata != NULL || subWidget != NULL) { SetEntry(subWidget, subdata,(_Entry *)subdata->attrs); } g_signal_emit_by_name(G_OBJECT(widget), "browse_clicked", NULL); } else { //upload gtk_panda_file_entry_set_mode(GTK_PANDA_FILE_ENTRY(widget), GTK_FILE_CHOOSER_ACTION_OPEN); } LEAVE_FUNC; }
static void SetPandaPreview( GtkWidget *widget, WidgetData *wdata, _PREVIEW *data) { ENTER_FUNC; SetCommon(widget,wdata); gtk_panda_pdf_set(GTK_PANDA_PDF(widget), LBS_Size(data->binary), LBS_Body(data->binary)); LEAVE_FUNC; }
static PacketClass SYSDB_RequestCommon(NETFILE *fp, PacketClass pc, ValueStruct *val) { PacketClass rc; LargeByteString *buf; rc = SESSION_CONTROL_NG; buf = NewLBS(); LBS_ReserveSize(buf, NativeSizeValue(NULL, val), FALSE); NativePackValue(NULL, LBS_Body(buf), val); SendPacketClass(fp, SYSDATA_SYSDB); ON_IO_ERROR(fp, badio); SendPacketClass(fp, pc); ON_IO_ERROR(fp, badio); SendLBS(fp, buf); ON_IO_ERROR(fp, badio); rc = RecvPacketClass(fp); RecvLBS(fp, buf); NativeUnPackValue(NULL, LBS_Body(buf), val); badio: FreeLBS(buf); return rc; }
static void GL_SendLBS( NETFILE *fp, LargeByteString *lbs) { GL_SendLength(fp,LBS_Size(lbs)); if ( LBS_Size(lbs) > 0 ) { Send(fp,LBS_Body(lbs),LBS_Size(lbs)); if ( !CheckNetFile(fp) ) { GL_Error(); } } }
static void SetDBAudit(DBG_Struct *dbg) { ValueStruct *audit; LargeByteString *lbs; if (dbg->auditlog > 0) { if (ThisEnv->auditrec->value != NULL) { audit = ThisEnv->auditrec->value; SetValueInteger(GetItemLongName(audit, "ticket_id"), dbg->ticket_id); lbs = dbg->last_query; if ((lbs != NULL) && (LBS_Size(lbs) > 0)) { SetValueString(GetItemLongName(audit, "exec_query"), LBS_Body(lbs), dbg->coding); } } } }
static LargeByteString * NewLinkData(void) { LargeByteString *linkdata; size_t size; if (ThisEnv->linkrec != NULL) { linkdata = NewLBS(); size = NativeSizeValue(NULL,ThisEnv->linkrec->value); LBS_ReserveSize(linkdata,size,FALSE); NativePackValue(NULL,LBS_Body(linkdata),ThisEnv->linkrec->value); } else { linkdata = NULL; } return linkdata; }
PacketClass SYSDB_GetDataAll(NETFILE *fp, int *size, ValueStruct *vals) { PacketClass rc; LargeByteString *buf; rc = SESSION_CONTROL_NG; buf = NewLBS(); SendPacketClass(fp, SYSDATA_SYSDB); ON_IO_ERROR(fp, badio); SendPacketClass(fp, SYSDB_GET_DATA_ALL); ON_IO_ERROR(fp, badio); rc = RecvPacketClass(fp); *size = RecvInt(fp); RecvLBS(fp, buf); NativeUnPackValue(NULL, LBS_Body(buf), vals); badio: FreeLBS(buf); return rc; }
static void SetPixmap( GtkWidget *widget, WidgetData *wdata, _Pixmap *data) { ENTER_FUNC; SetCommon(widget,wdata); if ( LBS_Size(data->binary) <= 0) { gtk_widget_hide(widget); } else { gtk_widget_show(widget); gtk_panda_pixmap_set_image(GTK_PANDA_PIXMAP(widget), (gchar*)LBS_Body(data->binary),(gsize)LBS_Size(data->binary)); } LEAVE_FUNC; }
static void GL_RecvLBS( NETFILE *fp, LargeByteString *lbs) { size_t size; ENTER_FUNC; size = GL_RecvLength(fp); LBS_ReserveSize(lbs,size,FALSE); if ( size > 0 ) { Recv(fp,LBS_Body(lbs),size); if ( !CheckNetFile(fp) ) { GL_Error(); } } else { dbgmsg("Recv LBS 0 size."); } LEAVE_FUNC; }
static SessionData * InitAPISession( char *user, char *ldname, char *wname, char *host) { SessionData *data; LD_Node *ld; RecordStruct *rec; size_t size; uuid_t u; ENTER_FUNC; data = NewSessionData(); data->type = SESSION_TYPE_API; uuid_generate(u); uuid_unparse(u,data->hdr->uuid); strcpy(data->hdr->window,wname); strcpy(data->hdr->user,user); strcpy(data->host,host); data->fInProcess = TRUE; if ((ld = g_hash_table_lookup(APS_Hash, ldname)) != NULL) { data->ld = ld; data->linkdata = NULL; data->cWindow = ld->info->cWindow; data->scrdata = NULL; data->hdr->puttype = SCREEN_NULL; rec = GetWindow(wname); size = NativeSizeValue(NULL,rec->value); LBS_ReserveSize(data->apidata->rec, size,FALSE); NativePackValue(NULL,LBS_Body(data->apidata->rec),rec->value); } else { Warning("[%s] session fail LD [%s] not found.",data->hdr->uuid,ldname); data = NULL; } LEAVE_FUNC; return (data); }
extern PacketDataType RecvStringData( NETFILE *fp, char *str, size_t size) { PacketDataType type; ENTER_FUNC; type = GL_RecvDataType(fp); switch (type) { case GL_TYPE_INT: dbgmsg("int"); sprintf(str,"%d",GL_RecvInt(fp)); break; case GL_TYPE_CHAR: case GL_TYPE_VARCHAR: case GL_TYPE_DBCODE: case GL_TYPE_TEXT: GL_RecvString(fp, size, str); break; case GL_TYPE_BINARY: case GL_TYPE_BYTE: case GL_TYPE_OBJECT: dbgmsg("LBS"); GL_RecvLBS(fp,LargeBuff); if ( LBS_Size(LargeBuff) > 0 ) { memcpy(str,LBS_Body(LargeBuff),LBS_Size(LargeBuff)); str[LBS_Size(LargeBuff)] = 0; } else { *str = 0; } break; } LEAVE_FUNC; return type; }
extern void SendStringData( NETFILE *fp, PacketDataType type, char *str) { ENTER_FUNC; GL_SendDataType(fp,type); switch (type) { case GL_TYPE_CHAR: case GL_TYPE_VARCHAR: case GL_TYPE_DBCODE: case GL_TYPE_TEXT: GL_SendString(fp,(char *)str); break; case GL_TYPE_BINARY: case GL_TYPE_BYTE: case GL_TYPE_OBJECT: LBS_ReserveSize(LargeBuff,strlen(str)+1,FALSE); strcpy(LBS_Body(LargeBuff),str); GL_SendLBS(fp,LargeBuff); break; case GL_TYPE_INT: GL_SendInt(fp,atoi(str)); break; case GL_TYPE_FLOAT: GL_SendFloat(fp,atof(str)); break; case GL_TYPE_BOOL: GL_SendBool(fp,(( *str == 'T' ) ? TRUE: FALSE )); break; default: break; } LEAVE_FUNC; }
extern void SendLBS(NETFILE *fp, LargeByteString *lbs) { SendLength(fp, LBS_Size(lbs)); if (LBS_Size(lbs) > 0) { Send(fp, LBS_Body(lbs), LBS_Size(lbs)); } }
static void PutApplication(MessageHandler *handler, NETFILE *fp, ProcessNode *node) { int i; size_t size; ConvFuncs *conv; DumpNode(node); conv = handler->serialize; ConvSetRecName(handler->conv, node->mcprec->name); size = conv->SizeValue(handler->conv, node->mcprec->value); LBS_EmitStart(iobuff); LBS_ReserveSize(iobuff, size, FALSE); conv->PackValue(handler->conv, LBS_Body(iobuff), node->mcprec->value); LBS_EmitEnd(iobuff); SendLargeString(fp, iobuff); ON_IO_ERROR(fp, badio); Send(fp, conv->fsep, strlen(conv->fsep)); ON_IO_ERROR(fp, badio); if (node->linkrec != NULL) { ConvSetRecName(handler->conv, node->linkrec->name); size = conv->SizeValue(handler->conv, node->linkrec->value); LBS_EmitStart(iobuff); LBS_ReserveSize(iobuff, size, FALSE); conv->PackValue(handler->conv, LBS_Body(iobuff), node->linkrec->value); LBS_EmitEnd(iobuff); SendLargeString(fp, iobuff); ON_IO_ERROR(fp, badio); Send(fp, conv->fsep, strlen(conv->fsep)); ON_IO_ERROR(fp, badio); } if (node->sparec != NULL) { ConvSetRecName(handler->conv, node->sparec->name); size = conv->SizeValue(handler->conv, node->sparec->value); LBS_EmitStart(iobuff); LBS_ReserveSize(iobuff, size, FALSE); conv->PackValue(handler->conv, LBS_Body(iobuff), node->sparec->value); LBS_EmitEnd(iobuff); SendLargeString(fp, iobuff); ON_IO_ERROR(fp, badio); } for (i = 0; i < node->cWindow; i++) { LBS_EmitStart(iobuff); if (node->scrrec[i] != NULL) { ConvSetRecName(handler->conv, node->scrrec[i]->name); size = conv->SizeValue(handler->conv, node->scrrec[i]->value); if (size > 0) { Send(fp, conv->fsep, strlen(conv->fsep)); ON_IO_ERROR(fp, badio); } LBS_ReserveSize(iobuff, size, FALSE); conv->PackValue(handler->conv, LBS_Body(iobuff), node->scrrec[i]->value); } LBS_EmitEnd(iobuff); SendLargeString(fp, iobuff); ON_IO_ERROR(fp, badio); } Send(fp, conv->bsep, strlen(conv->bsep)); ON_IO_ERROR(fp, badio); badio: return; }
static void ExecuteDB_Server(MessageHandler *handler) { RecordStruct *rec; ValueStruct *value, *ret; PathStruct *path; DB_Operation *op; size_t size; int rno, pno, ono; DBCOMM_CTRL ctrl; char *rname, *pname, *func; ConvFuncs *conv; InitializeCTRL(&ctrl); conv = handler->serialize; while (TRUE) { dbgmsg("read"); LBS_EmitStart(dbbuff); RecvLargeString(fpDBR, dbbuff); ON_IO_ERROR(fpDBR, badio); ConvSetRecName(handler->conv, recDBCTRL->name); InitializeValue(recDBCTRL->value); conv->UnPackValue(handler->conv, LBS_Body(dbbuff), recDBCTRL->value); rname = ValueStringPointer(GetItemLongName(recDBCTRL->value, "rname")); strncpy(ctrl.rname, rname, SIZE_NAME); value = NULL; ret = NULL; if ((rname != NULL) && ((rno = (int)(long)g_hash_table_lookup(DB_Table, rname)) != 0)) { ctrl.rno = rno - 1; rec = ThisDB[ctrl.rno]; value = rec->value; pname = ValueStringPointer(GetItemLongName(recDBCTRL->value, "pname")); strncpy(ctrl.pname, pname, SIZE_NAME); if ((pno = (int)(long)g_hash_table_lookup(rec->opt.db->paths, pname)) != 0) { ctrl.pno = pno - 1; path = rec->opt.db->path[pno - 1]; value = (path->args != NULL) ? path->args : value; } else { ctrl.pno = 0; path = NULL; } } else { rec = NULL; path = NULL; } func = ValueStringPointer(GetItemLongName(recDBCTRL->value, "func")); if (*func != 0) { if (path == NULL) { Error("path is NULL"); } else if ((ono = (int)(long)g_hash_table_lookup(path->opHash, func)) != 0) { op = path->ops[ono - 1]; value = (op->args != NULL) ? op->args : value; } if (rec != NULL) { ConvSetRecName(handler->conv, rec->name); } else { Error("rec is NULL"); } InitializeValue(value); conv->UnPackValue(handler->conv, LBS_Body(dbbuff), value); strncpy(ctrl.func, func, SIZE_FUNC); ret = ExecDB_Process(&ctrl, rec, value); } else { ctrl.rc = 0; } dbgmsg("write"); SetValueInteger(GetItemLongName(recDBCTRL->value, "rc"), ctrl.rc); ConvSetRecName(handler->conv, recDBCTRL->name); LBS_EmitStart(dbbuff); size = conv->SizeValue(handler->conv, recDBCTRL->value); LBS_ReserveSize(dbbuff, size, FALSE); conv->PackValue(handler->conv, LBS_Body(dbbuff), recDBCTRL->value); LBS_EmitEnd(dbbuff); SendLargeString(fpDBW, dbbuff); ON_IO_ERROR(fpDBW, badio); if (ret != NULL) { Send(fpDBW, conv->fsep, strlen(conv->fsep)); ON_IO_ERROR(fpDBW, badio); LBS_EmitStart(dbbuff); if (rec != NULL) { ConvSetRecName(handler->conv, rec->name); } size = conv->SizeValue(handler->conv, ret); LBS_ReserveSize(dbbuff, size, FALSE); conv->PackValue(handler->conv, LBS_Body(dbbuff), ret); LBS_EmitEnd(dbbuff); SendLargeString(fpDBW, dbbuff); ON_IO_ERROR(fpDBW, badio); FreeValueStruct(ret); } Send(fpDBW, conv->bsep, strlen(conv->bsep)); ON_IO_ERROR(fpDBW, badio); } badio: return; }