int between_days(struct node *date1head, struct node *date2head){ struct node *temp; int d1[3], d2[3],main,dif=0; if ((date1head == NULL) || (date2head == NULL)) { return -1; } temp = date1head; d1[0] = (temp->data * 10) + temp->next->data; temp = temp->next->next; d1[1] = (temp->data * 10) + temp->next->data; temp = temp->next->next; date1head = temp->next->next; d1[2] = (temp->data * 1000) + (temp->next->data * 100) + (date1head->data * 10) + date1head->next->data; temp = date2head; d2[0] = (temp->data * 10) + temp->next->data; temp = temp->next->next; d2[1] = (temp->data * 10) + temp->next->data; temp = temp->next->next; date2head = temp->next->next; d2[2] = (temp->data * 1000) + (temp->next->data * 100) + (date2head->data * 10) + date2head->next->data; if (d2[2] > d1[2]) { main = d2[2]; dif=callfunction(d1, d2); } else { main = d1[2]; dif=callfunction(d2, d1); } return dif; }
void LuaBinding_RestoreWindow( void ) { l_Lstack = lua_gettop(l_L); if (callfunction(l_L,0,LUXI_TRUE,"LXFRestoreWindow")) { printpoperror(); } }
// Window handling int LuaBinding_OpenWindow( int width, int height, int redbits, int greenbits, int bluebits, int alphabits, int depthbits, int stencilbits, int mode ) { int stacksize; l_Lstack = lua_gettop(l_L); lua_pushnumber(l_L,width); lua_pushnumber(l_L,height); lua_pushnumber(l_L,redbits); lua_pushnumber(l_L,greenbits); lua_pushnumber(l_L,bluebits); lua_pushnumber(l_L,alphabits); lua_pushnumber(l_L,depthbits); lua_pushnumber(l_L,stencilbits); lua_pushnumber(l_L,mode); if (callfunction(l_L,9,LUXI_FALSE,"LXFOpenWindow")) { printpoperror();; return LUXI_FALSE; } stacksize = lua_gettop(l_L); if (stacksize-l_Lstack == 1){ int state = lua_toboolean(l_L,stacksize); lua_settop(l_L,l_Lstack); return state; } else{ lua_settop(l_L,l_Lstack); return LUXI_FALSE; } }
void LuaBinding_SetCallbacks( void ) { l_Lstack = lua_gettop(l_L); if (callfunction(l_L,0,LUXI_TRUE,"LXFSetCallbacks")) { printpoperror(); } }
void LuaBinding_SwapBuffers( void ) { l_Lstack = lua_gettop(l_L); if (callfunction(l_L,0,LUXI_TRUE,"LXFSwapBuffers")) { printpoperror(); } }
void LuaBinding_PostInit() { l_Lstack = lua_gettop(l_L); if (callfunction(l_L,0,LUXI_TRUE,"LXFPostInit")) { printpoperror(); } }
void LuaBinding_SetWindowTitle( const char *title ) { l_Lstack = lua_gettop(l_L); lua_pushstring(l_L,title); if (callfunction(l_L,1,LUXI_TRUE,"LXFSetWindowTitle")) { printpoperror(); } }
void LuaBinding_SetWindowOnTop( int state ) { l_Lstack = lua_gettop(l_L); lua_pushboolean(l_L,state); if (callfunction(l_L,1,LUXI_TRUE,"LXFSetWindowOnTop")) { printpoperror(); } }
void LuaBinding_Disable( int token ) { l_Lstack = lua_gettop(l_L); lua_pushnumber(l_L,token); if (callfunction(l_L,1,LUXI_TRUE,"LXFDisable")) { printpoperror(); } }
void LuaBinding_SetMouseWheel( int pos ) { l_Lstack = lua_gettop(l_L); lua_pushnumber(l_L,pos); if (callfunction(l_L,1,LUXI_TRUE,"LXFSetMouseWheel")) { printpoperror(); } }
void LuaBinding_OpenWindowHint( int target, int hint ) { l_Lstack = lua_gettop(l_L); lua_pushnumber(l_L,target); lua_pushnumber(l_L,hint); if (callfunction(l_L,2,LUXI_TRUE,"LXFOpenWindowHint")) { printpoperror(); } }
void LuaBinding_SetWindowSize( int width, int height ) { l_Lstack = lua_gettop(l_L); lua_pushnumber(l_L,width); lua_pushnumber(l_L,height); if (callfunction(l_L,2,LUXI_TRUE,"LXFSetWindowSize")) { printpoperror(); } }
void LuaBinding_SetMousePos( int x, int y ) { l_Lstack = lua_gettop(l_L); lua_pushnumber(l_L,x); lua_pushnumber(l_L,y); if (callfunction(l_L,2,LUXI_TRUE,"LXFSetMousePos")) { printpoperror(); } }
int callfunction(int *old, int *young) { int dif = 0,k,temp; int month[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; if (old[2] - young[2] == 0) { if ((old[1] - young[1]) == 0) { if ((old[0] - young[0]) > 0) return old[0] - young[0]; else if ((old[0] - young[0])==0) { return 0; } else { return -1 * (old[0] - young[0]); } } else if ((old[1] - young[1]) > 0) { k = old[1] - young[1] - 1; temp = young[1]+1; while (k>0) { dif += month[temp - 1]; k--; temp++; } dif += (month[old[1]] - old[0]) + (month[young[0]] - young[0]); return dif; } else { dif = callfunction(young, old); return dif; } } k = old[2] - young[2] - 1; temp = young[2] + 1; while (k > 0) { if (temp % 4 == 0) dif += 366; else dif += 365; k--; temp++; } }
void LuaBinding_GetMousePos( int *x, int *y ) { int stacksize; l_Lstack = lua_gettop(l_L); if (callfunction(l_L,0,LUXI_FALSE,"LXFGetMousePos")) { printpoperror(); return; } stacksize = lua_gettop(l_L); if (stacksize-l_Lstack == 2){ *x = (int)lua_tointeger(l_L,stacksize-1); *y = (int)lua_tointeger(l_L,stacksize); } lua_settop(l_L,l_Lstack); }
void LuaBinding_GetWindowSize( int *width, int *height ) { int stacksize; l_Lstack = lua_gettop(l_L); if (callfunction(l_L,0,LUXI_FALSE,"LXFGetWindowSize")) { printpoperror(); return; } stacksize = lua_gettop(l_L); if (stacksize-l_Lstack == 2){ *width = (int)lua_tointeger(l_L,stacksize-1); *height = (int)lua_tointeger(l_L,stacksize); } lua_settop(l_L,l_Lstack); }
int LuaBinding_Print(char*str, va_list args) { static char buffer[512]; int cnt = vsprintf(buffer,str,args); if (!cnt){ return 0; } // pass to lua l_Lstack = lua_gettop(l_L); lua_pushstring(l_L,buffer); if (callfunction(l_L,1,LUXI_TRUE,"LXFPrint")) { printpoperror(); } return cnt; }
int LuaBinding_GetWindowPos( int *x, int *y ) { int stacksize; int success = LUXI_FALSE; l_Lstack = lua_gettop(l_L); if (callfunction(l_L,0,LUXI_FALSE,"LXFGetWindowPos")) { printpoperror(); return LUXI_FALSE; } stacksize = lua_gettop(l_L); if (stacksize - l_Lstack == 2){ *x = (int)lua_tointeger(l_L,stacksize-1); *y = (int)lua_tointeger(l_L,stacksize); success = LUXI_TRUE; } lua_settop(l_L,l_Lstack); return success; }
int LuaBinding_GetMouseWheel( void ) { int stacksize; l_Lstack = lua_gettop(l_L); if (callfunction(l_L,0,LUXI_FALSE,"LXFGetMousePos")) { printpoperror(); return 0; } stacksize = lua_gettop(l_L); if (stacksize-l_Lstack == 1){ int pos = (int)lua_tointeger(l_L,stacksize); lua_settop(l_L,l_Lstack); return pos; } else{ lua_settop(l_L,l_Lstack); return 0; } }
int LuaBinding_GetMouseButton( int button ) { int stacksize; l_Lstack = lua_gettop(l_L); lua_pushnumber(l_L,button); if (callfunction(l_L,1,LUXI_FALSE,"LXFGetMouseButton")) { printpoperror(); return LUXI_RELEASE; } stacksize = lua_gettop(l_L); if (stacksize-l_Lstack == 1){ int pos = (int)lua_toboolean(l_L,stacksize); lua_settop(l_L,l_Lstack); return pos; } else{ lua_settop(l_L,l_Lstack); return LUXI_RELEASE; } }
int LuaBinding_ScreenToClient( int *x, int *y ) { int stacksize; int success = LUXI_FALSE; l_Lstack = lua_gettop(l_L); lua_pushnumber(l_L,*x); lua_pushnumber(l_L,*y); if (callfunction(l_L,0,LUXI_FALSE,"LXFScreenToClient")) { printpoperror(); return LUXI_FALSE; } stacksize = lua_gettop(l_L); if (stacksize - l_Lstack == 2){ *x = (int)lua_tointeger(l_L,stacksize-1); *y = (int)lua_tointeger(l_L,stacksize); success = LUXI_TRUE; } lua_settop(l_L,l_Lstack); return success; }
int LuaBinding_GetWindowParam( int key ) { int stacksize; l_Lstack = lua_gettop(l_L); lua_pushnumber(l_L,key); if (callfunction(l_L,1,LUXI_FALSE,"LXFGetWindowParam")) { printpoperror(); return LUXI_TRUE; } stacksize = lua_gettop(l_L); if (stacksize - l_Lstack == 1){ int pos = lua_type(l_L,stacksize)== LUA_TBOOLEAN ? (int)lua_toboolean(l_L,stacksize) : (int)lua_tointeger(l_L,stacksize); lua_settop(l_L,l_Lstack); return pos; } else{ lua_settop(l_L,l_Lstack); return LUXI_TRUE; } }
static void factor(Pu *L, __pu_value *&temp) { PuType tp = TOKEN.type; OperatorType nv = TOKEN.optype; if (tp == OP)// ( [ { switch (nv) { case OPT_LB: { NEXT_TOKEN; const __pu_value *exp_result = exp(L); CHECK_EXP(exp_result); MAKE_TEMP_VALUE(temp); *temp = *exp_result; PuType tp = TOKEN.type; int nv = TOKEN.optype; if (tp != OP || nv != OPT_RB) { error(L,1); return; } NEXT_TOKEN; } break; case OPT_LSB: get_array(L, temp); break; case OPT_LBR: get_map(L, temp); break; case OPT_NOT: get_value(L, temp); default: break; } } else { get_value(L, temp); CHECK_EXP(temp); PuType tp = TOKEN.type; OperatorType nv = TOKEN.optype; while (tp == OP) { switch (nv) { case OPT_LB: if (temp->type() == FUN || temp->type() == CFUN) { VarMap *old = L->upvalue; L->upvalue = 0; if (temp->userdata()) { L->upvalue = ((_up_value*)temp->userdata())->vmap; } callfunction(L, L->funclist[(int)temp->numVal()]); L->upvalue = old; MAKE_TEMP_VALUE(temp); *temp = L->return_value; tp = TOKEN.type; nv = TOKEN.optype; CLEAR_RETURN; break; }return; case OPT_LSB: if (temp->type() == ARRAY || temp->type() == STR) { get_arrref(L,temp); CHECK_EXP(temp); NEXT_TOKEN; break; }return; default: return; } tp = TOKEN.type; nv = TOKEN.optype; } } }